@skill-map/cli 0.16.6 → 0.18.0
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/dist/cli/tutorial/sm-tutorial.md +8 -0
- package/dist/cli.js +8324 -5644
- package/dist/cli.js.map +1 -1
- package/dist/conformance/index.js +36 -14
- package/dist/conformance/index.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +540 -61
- package/dist/index.js.map +1 -1
- package/dist/kernel/index.d.ts +443 -87
- package/dist/kernel/index.js +540 -61
- package/dist/kernel/index.js.map +1 -1
- package/dist/migrations/002_sidecar_columns.sql +53 -0
- package/dist/migrations/003_drop_node_author.sql +20 -0
- package/dist/migrations/004_sidecar_root_json.sql +23 -0
- package/dist/migrations/005_node_favorites.sql +20 -0
- package/dist/ui/chunk-3R7E3HPC.js +7 -0
- package/dist/ui/chunk-JKJGGXCS.js +1025 -0
- package/dist/ui/chunk-SX2A3WBX.js +247 -0
- package/dist/ui/chunk-TWZHUCAT.js +237 -0
- package/dist/ui/chunk-UJOZYR5I.js +1 -0
- package/dist/ui/chunk-WTAL2RK4.js +1 -0
- package/dist/ui/chunk-Z3UJHHTC.js +3091 -0
- package/dist/ui/index.html +2 -2
- package/dist/ui/main-AAYGMON4.js +1 -0
- package/dist/ui/skill-map-mark-dark.svg +8 -0
- package/dist/ui/skill-map-mark-light.svg +8 -0
- package/dist/ui/{styles-TCK5JUQE.css → styles-CBPFNGXA.css} +1 -1
- package/migrations/002_sidecar_columns.sql +53 -0
- package/migrations/003_drop_node_author.sql +20 -0
- package/migrations/004_sidecar_root_json.sql +23 -0
- package/migrations/005_node_favorites.sql +20 -0
- package/package.json +6 -6
- package/dist/ui/chunk-7PFTODKS.js +0 -1031
- package/dist/ui/chunk-A4RBO3TD.js +0 -38
- package/dist/ui/chunk-KPEISNOV.js +0 -819
- package/dist/ui/chunk-NKC42FI7.js +0 -210
- package/dist/ui/chunk-S5C4U3I3.js +0 -2403
- package/dist/ui/chunk-TG6IWVEC.js +0 -54
- package/dist/ui/chunk-TGJQE3TH.js +0 -54
- package/dist/ui/chunk-UGEECDPV.js +0 -1
- package/dist/ui/main-XSGTD7FQ.js +0 -1
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
import{g as Li,h as zi,i as Bi,u as Gi,v as Hi,w as bf}from"./chunk-KPEISNOV.js";import{b as Ai}from"./chunk-UGEECDPV.js";import"./chunk-TG6IWVEC.js";import{$ as at,$a as Pt,$c as Jt,A as oe,Aa as We,B as Ie,C as Kt,Ca as gt,Cb as Cf,D as X,Da as $e,E as he,F as Ii,Fa as tt,Ga as T,Ha as N,I as h,Ia as dt,J as ff,K as hf,Ka as _f,L as gf,M as hl,N as Si,O as se,Oa as mf,P as pf,Pa as Ri,Q as _e,Qa as pt,Ra as be,S as ce,T as Di,Vc as xf,W as te,Wc as wf,Z as k,_ as O,_a as yf,_c as Qt,aa as me,ab as G,ba as ye,bb as lt,ca as A,cb as F,d as p,da as m,db as ve,dd as Oi,ea as v,eb as Ni,ed as Fi,fa as U,fb as pl,ga as Je,gb as Mt,ha as et,ia as Zt,ib as re,ja as Ti,jb as Ne,ka as Ei,l as f,m as lf,ma as Pi,n as ee,na as Mi,o as Yt,oa as Et,p as c,q as uf,qa as Se,r as ue,ra as S,rb as vf,s as fe,sa as En,sb as ki,t as Ge,ta as De,u as Ae,v as bi,w as Ze,x as Qe,y as Tn,ya as gl,za as ct}from"./chunk-7PFTODKS.js";import{a as J,b as fl}from"./chunk-Q7L6LLAK.js";var Rt=class{constructor(i,e,t,o,r){this.center=i,this.radiusX=e,this.radiusY=t,this.startAngle=o,this.endAngle=r}},M=class n{static castToPoint(i){return i||n.initialize()}static initialize(i=0,e=0){return{x:i,y:e}}static copy(i){return n.initialize(i.x,i.y)}static isEqual(i,e){return i.x===e.x&&i.y===e.y}static sum(i,e){return{x:i.x+e.x,y:i.y+e.y}}static sub(i,e){return{x:i.x-e.x,y:i.y-e.y}}static div(i,e){return{x:i.x/e,y:i.y/e}}static mult(i,e){return{x:i.x*e,y:i.y*e}}static interpolatePoints(i,e,t){let o=1-t;return n.initialize(i.x*o+e.x*t,i.y*o+e.y*t)}static roundTo(i,e){let t=Math.trunc(i.x/e),o=Math.trunc(i.y/e);return{x:t*e,y:o*e}}static hypotenuse(i,e){let t=e.x-i.x,o=e.y-i.y;return Math.abs(Math.sqrt(t*t+o*o))}static distance(i,e){let t=i.x-e.x,o=i.y-e.y;return Math.sqrt(t*t+o*o)}static getMinimum(i,e){return n.initialize(Math.min(i.x,e.x),Math.min(i.y,e.y))}static getMaximum(i,e){return n.initialize(Math.max(i.x,e.x),Math.max(i.y,e.y))}static matrixTransform(i,e){let t=n.initialize(i.x,i.y),o=e.getScreenCTM();if(o){let r=e.createSVGPoint();r.x=i.x,r.y=i.y,t=r.matrixTransform(o.inverse())}return t}static elementTransform(i,e){let t=n.initialize(i.x,i.y),o=e.getBoundingClientRect();return t=n.sub(t,n.initialize(o.left,o.top)),t}},j=class n{constructor(i=0,e=0){this.x=i,this.y=e}static fromPoint(i){return new n(i.x,i.y)}add(i){let e=M.sum(this,i);return n.fromPoint(e)}sub(i){let e=M.sub(this,i);return n.fromPoint(e)}subNumber(i){let e=M.sub(this,new n(i,i));return n.fromPoint(e)}div(i){let e=M.div(this,i);return n.fromPoint(e)}mult(i){let e=M.mult(this,i);return n.fromPoint(e)}matrixTransform(i){let e=M.matrixTransform(this,i);return n.fromPoint(e)}elementTransform(i){let e=M.elementTransform(this,i);return n.fromPoint(e)}},Pn=class{static initialize(i=M.initialize(),e=M.initialize()){return{point1:i,point2:e}}static copy(i){return{point1:i.point1,point2:i.point2}}static hypotenuse(i){return Math.sqrt(Math.pow(i.point1.x-i.point2.x,2)+Math.pow(i.point1.y-i.point2.y,2))}},Nt=class{constructor(i,e){this.point1=i,this.point2=e}},z=class n{static initialize(i=0,e=0,t=0,o=0){t<0&&(i=i+t,t=-t),o<0&&(e=e+o,o=-o);let r=M.initialize(i+t/2,e+o/2);return{x:i,y:e,width:t,height:o,gravityCenter:r}}static copy(i){return n.initialize(i.x,i.y,i.width,i.height)}static fromElement(i){let{x:e,y:t,width:o,height:r}=i.getBoundingClientRect();return n.initialize(e,t,o,r)}static isIncludePoint(i,e){return e.x>=n.left(i)&&e.x<=n.right(i)&&e.y>=n.top(i)&&e.y<=n.bottom(i)}static intersectionWithRect(i,e){return!(i.x+i.width<e.x||e.x+e.width<i.x||i.y+i.height<e.y||e.y+e.height<i.y)}static left(i){return i.x}static top(i){return i.y}static right(i){return i.x+i.width}static bottom(i){return i.y+i.height}static addPoint(i,e){let t=n.copy(i);return t.x+=e.x,t.y+=e.y,this.initialize(t.x,t.y,t.width,t.height)}static mult(i,e){let t=n.copy(i);return t.x*=e,t.y*=e,t.width*=e,t.height*=e,this.initialize(t.x,t.y,t.width,t.height)}static div(i,e){let t=n.copy(i);return t.x/=e,t.y/=e,t.width/=e,t.height/=e,this.initialize(t.x,t.y,t.width,t.height)}static addPointToSize(i,e){let t=n.copy(i);return t.width+=e.x,t.height+=e.y,this.initialize(t.x,t.y,t.width,t.height)}static union(i){return!i||i.length===0?null:i.reduce((e,t)=>{let o=Math.min(e.x,t.x),r=Math.min(e.y,t.y),s=Math.max(e.x+e.width,t.x+t.width),a=Math.max(e.y+e.height,t.y+t.height);return n.initialize(o,r,s-o,a-r)},i[0])}static elementTransform(i,e){let t=e.getBoundingClientRect(),o=M.sub(i,M.initialize(t.left,t.top));return n.initialize(o.x,o.y,i.width,i.height)}static updateIsNotFinite(i){return!Number.isFinite(i.width)||!Number.isFinite(i.height)||!Number.isFinite(i.x)||!Number.isFinite(i.y)?n.initialize(0,0,0,0):i}};function If(n,i){let e=Math.max(n.width,i),t=Math.max(n.height,i),o=(e-n.width)/2,r=(t-n.height)/2;return z.initialize(n.x-o,n.y-r,e,t)}function ml(n,i){n=z.updateIsNotFinite(n),i.setAttribute("x",n.x.toString()),i.setAttribute("y",n.y.toString()),i.setAttribute("width",n.width.toString()),i.setAttribute("height",n.height.toString())}function Sf(n,i){n=z.updateIsNotFinite(n),i.setAttribute("viewBox",`${n.x} ${n.y} ${n.width} ${n.height}`)}var ge=class n{constructor(i=0,e=0,t=0,o=0,r=0,s=0,a=0,d=0){this.x=i,this.y=e,this.width=t,this.height=o,this.radius1=r,this.radius2=s,this.radius3=a,this.radius4=d,this.gravityCenter=M.initialize(),this.gravityCenter=this.calculateGravityCenter(this)}calculateGravityCenter(i){return new j(i.x+i.width/2,i.y+i.height/2)}static fromRect(i){return new n(i.x,i.y,i.width,i.height)}static fromRoundedRect(i){return new n(i.x,i.y,i.width,i.height,i.radius1,i.radius2,i.radius3,i.radius4)}static fromCenter(i,e,t){return new n(i.gravityCenter.x-e/2,i.gravityCenter.y-t/2,e,t,i.radius1,i.radius2,i.radius3,i.radius4)}static fromPoint(i){return new n(i.x,i.y)}addPoint(i){let e=n.fromRoundedRect(this);return e.x+=i.x,e.y+=i.y,e.gravityCenter=this.calculateGravityCenter(e),e}},Xe=class n{static initialize(i=0,e=0){return{width:i,height:e}}static isEqual(i,e){return i.width===e.width&&i.height===e.height}static offsetFromElement(i){if(i instanceof SVGGraphicsElement){let e=i.getBBox();return n.initialize(e.width,e.height)}else if(i instanceof HTMLElement)return n.initialize(i.offsetWidth,i.offsetHeight)}};function jg(){return{position:M.initialize(),scaledPosition:M.initialize(),scale:1,rotate:0}}function Vg(n){let i;if(n){n=n.replace("matrix(",""),n=n.replace(")","");let e=n.split(" ");i={position:{x:Number(e[4]),y:Number(e[5])},scaledPosition:M.initialize(),scale:Number(e[0]),rotate:0}}return i}var _t=class{static toString(i){let e=M.sum(i.position,i.scaledPosition);return`matrix(${i.scale}, 0, 0, ${i.scale}, ${e.x}, ${e.y})`}static fromString(i){return Vg(i)}static default(){return jg()}},Le=class n{static initialize(i=0,e=0){return M.initialize(i,e)}static fromPoints(i,e){return n.initialize(e.x-i.x,e.y-i.y)}static vectorLength(i){return Math.sqrt(n.magnitudeSquared(i))}static magnitudeSquared(i){return i.x*i.x+i.y*i.y}static dotProduct(i,e){return i.x*e.x+i.y*e.y}static crossProduct(i,e){return i.x*e.y-i.y*e.x}static subtract(i,e){return n.initialize(i.x-e.x,i.y-e.y)}static add(i,e){return n.initialize(i.x+e.x,i.y+e.y)}static scale(i,e){return n.initialize(i.x*e,i.y*e)}static angle(i,e){let t=Math.acos(Math.max(-1,Math.min(n.dotProduct(i,e)/(n.vectorLength(i)*n.vectorLength(e)),1)));return n.crossProduct(i,e)<0?-t:t}},_l=class{static parseRoundedRect(i){let e=Math.PI*.5,t=i.x,o=i.y,r=i.x+i.width,s=i.y+i.height,a=i.x+i.radius1,d=i.y+i.radius1,l=i.x+i.width-i.radius2,u=i.y+i.radius2,g=i.x+i.width-i.radius3,y=i.y+i.height-i.radius3,C=i.x+i.radius4,E=i.y+i.height-i.radius4;return[new Rt({x:a,y:d},i.radius1,i.radius1,2*e,3*e),new Nt({x:a,y:o},{x:l,y:o}),new Rt({x:l,y:u},i.radius2,i.radius2,3*e,4*e),new Nt({x:r,y:u},{x:r,y}),new Rt({x:g,y},i.radius3,i.radius3,0,e),new Nt({x:g,y:s},{x:C,y:s}),new Rt({x:C,y:E},i.radius4,i.radius4,e,2*e),new Nt({x:t,y:E},{x:t,y:d})]}},en=class{static getRoundedRectIntersections(i,e,t){let o=_l.parseRoundedRect(t);for(let r of o)if(r instanceof Rt){let s=this.intersectArcWithLine(r,i,e);if(s.length>0)return s}else if(r instanceof Nt){let s=this.intersectLineSegments(i,e,r.point1,r.point2);if(s)return[s]}return[]}static getRoundedRectIntersectionsWithSVGPath(i,e){let t=i.getTotalLength(),o=[];for(let r=0;r<=t;r+=1){let s=i.getPointAtLength(r);o.push({x:s.x,y:s.y})}for(let r=1;r<o.length;r++){let s=this.getRoundedRectIntersections(o[r-1],o[r],e);if(s.length>0)return s}return[]}static intersectArcWithLine(i,e,t){return this.filterPointsWithinArc(this.findEllipseLineIntersections(i.center,i.radiusX,i.radiusY,e,t),i)}static intersectLineSegments(i,e,t,o){let r=e.x-i.x,s=e.y-i.y,a=o.x-t.x,d=o.y-t.y,l=(-s*(i.x-t.x)+r*(i.y-t.y))/(-a*s+r*d),u=(a*(i.y-t.y)-d*(i.x-t.x))/(-a*s+r*d);return l>=0&&l<=1&&u>=0&&u<=1?{x:i.x+u*r,y:i.y+u*s}:null}static filterPointsWithinArc(i,e){let{center:t,startAngle:o,endAngle:r}=e;if(i.length===0)return i;r<o&&([o,r]=[r,o]),(o<0||r<0)&&(o+=2*Math.PI,r+=2*Math.PI);let s=[];for(let a of i){let d=this.normalizeAngle(Le.angle(Le.initialize(1,0),Le.initialize(a.x-t.x,a.y-t.y)));d<o&&(d+=2*Math.PI),o<=d&&d<=r&&s.push(a)}return s}static normalizeAngle(i){let e=i%(2*Math.PI);return e<0?e+2*Math.PI:e}static findEllipseLineIntersections(i,e,t,o,r){let s=Le.initialize(o.x,o.y),a=Le.fromPoints(o,r),d=Le.initialize(i.x,i.y),l=Le.subtract(s,d),u=Le.initialize(a.x/(e*e),a.y/(t*t)),g=Le.initialize(l.x/(e*e),l.y/(t*t)),y=Le.dotProduct(a,u),C=Le.dotProduct(a,g),E=Le.dotProduct(l,g)-1,b=C*C-y*E;return b<0?[]:this.calculateIntersectionPoints(b,y,C,o,r)}static calculateIntersectionPoints(i,e,t,o,r){let s=[];if(i>0){let a=Math.sqrt(i),d=(-t-a)/e,l=(-t+a)/e;d>=0&&d<=1&&s.push(M.interpolatePoints(o,r,d)),l>=0&&l<=1&&s.push(M.interpolatePoints(o,r,l))}else{let a=-t/e;a>=0&&a<=1&&s.push(M.interpolatePoints(o,r,a))}return s}};var yl=class{handle(i,e){let t=!0;if(this.validator&&(t=e.get(this.validator).handle(i)),!!t)return e.get(this.execution).handle(i)}execute(i,e){return e.get(this.execution).handle(i)}setValidator(i){this.validator=i}setExecution(i){this.execution=i}},D=class n{constructor(){this._injector=c(Ae)}static registerPipeline(i,e,t){if(!i||!i.fToken)throw new Error("Type must have a fToken static property.");let o=this.pipelines.get(i.fToken)||new yl;t?o.setValidator(e):o.setExecution(e),this.pipelines.set(i.fToken,o)}send(i){let e=n.pipelines.get(i.constructor.fToken);if(e)return e.handle(i,this._injector);throw new Error("Handler not registered for request type.")}execute(i){return n.pipelines.get(i.constructor.fToken).execute(i,this._injector)}};D.pipelines=new Map;D.\u0275fac=function(i){return new(i||D)};D.\u0275prov=f({token:D,factory:D.\u0275fac});function _(n){return function(i){D.registerPipeline(n,i,!1)}}var Ug=(()=>{class n{setItem(e,t){localStorage.setItem(e,t)}getItem(e){return localStorage.getItem(e)}removeItem(e){localStorage.removeItem(e)}clear(){localStorage.clear()}static \u0275fac=function(t){return new(t||n)};static \u0275prov=f({token:n,factory:n.\u0275fac,providedIn:"root"})}return n})(),Wg=(()=>{class n{storage={};setItem(e,t){this.storage[e]=t}getItem(e){return this.storage[e]||null}removeItem(e){delete this.storage[e]}clear(){this.storage={}}static \u0275fac=function(t){return new(t||n)};static \u0275prov=f({token:n,factory:n.\u0275fac,providedIn:"root"})}return n})(),$g=new ee("F_LOCAL_STORAGE",{providedIn:"root",factory:()=>ki(c(Ii))?c(Ug):c(Wg)}),Xg=(()=>{class n{getComputedStyle(e){return window.getComputedStyle(e)}get innerWidth(){return window.innerWidth}get innerHeight(){return window.innerHeight}get pageXOffset(){return window.pageXOffset}get pageYOffset(){return window.pageYOffset}isMediaQuery(e){return window.matchMedia(e).matches}requestAnimationFrame(e){return window.requestAnimationFrame(e)}get location(){return window.location}open(e,t,o){window.open(e,t,o)}static \u0275fac=function(t){return new(t||n)};static \u0275prov=f({token:n,factory:n.\u0275fac,providedIn:"root"})}return n})(),qg=(()=>{class n{getComputedStyle(e){return new Proxy({getPropertyValue:t=>"0"},{get:(t,o)=>o==="getPropertyValue"?t.getPropertyValue:"0"})}get innerWidth(){return 0}get innerHeight(){return 0}get pageXOffset(){return 0}get pageYOffset(){return 0}isMediaQuery(e){return!1}requestAnimationFrame(e){return setTimeout(e,0)}get location(){return{href:"",pathname:"",search:"",hash:"",origin:""}}open(e,t,o){}static \u0275fac=function(t){return new(t||n)};static \u0275prov=f({token:n,factory:n.\u0275fac,providedIn:"root"})}return n})(),Yg=new ee("F_WINDOW",{providedIn:"root",factory:()=>ki(c(Ii))?c(Xg):c(qg)}),mt=(function(n){return n.MAC_OS="macos",n.IOS="ios",n.WINDOWS="windows",n.ANDROID="android",n.LINUX="linux",n})(mt||{}),vl;try{vl=typeof Intl<"u"&&Intl.v8BreakIterator}catch{vl=!1}var Cl=(()=>{class n{_platformId;isBrowser=!1;EDGE=this.isBrowser&&/(edge)/i.test(navigator.userAgent);TRIDENT=this.isBrowser&&/(msie|trident)/i.test(navigator.userAgent);BLINK=this.isBrowser&&!!(window.chrome||vl)&&typeof CSS<"u"&&!this.EDGE&&!this.TRIDENT;WEBKIT=this.isBrowser&&/AppleWebKit/i.test(navigator.userAgent)&&!this.BLINK&&!this.EDGE&&!this.TRIDENT;IOS=this.isBrowser&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!("MSStream"in window);FIREFOX=this.isBrowser&&/(firefox|minefield)/i.test(navigator.userAgent);ANDROID=this.isBrowser&&/android/i.test(navigator.userAgent)&&!this.TRIDENT;SAFARI=this.isBrowser&&/safari/i.test(navigator.userAgent)&&this.WEBKIT;constructor(e){this._platformId=e,this.isBrowser=this._platformId?ki(this._platformId):typeof document=="object"&&!!document}getOS(){let e=navigator.userAgent.toLowerCase(),t=/(macintosh|macintel|macppc|mac68k|macos)/i,o=/(win32|win64|windows|wince)/i,r;return t.test(e)?r=mt.MAC_OS:this.IOS?r=mt.IOS:o.test(e)?r=mt.WINDOWS:this.ANDROID?r=mt.ANDROID:!r&&/linux/.test(e)&&(r=mt.LINUX),r}static \u0275fac=function(t){return new(t||n)(Yt(Ii))};static \u0275prov=f({token:n,factory:n.\u0275fac,providedIn:"root"})}return n})(),pe=(()=>{class n{injectedDocument;windowService;localStorageService;platformService;constructor(e,t,o,r){this.injectedDocument=e,this.windowService=t,this.localStorageService=o,this.platformService=r}isBrowser(){return this.platformService.isBrowser}get window(){return this.windowService}get localStorage(){return this.localStorageService}get document(){return this.injectedDocument}toPixels(e,t,o,r){if(e.endsWith("px"))return parseFloat(e);if(e.endsWith("%")){let s=parseFloat(e)/100;return Math.max(t,o)*s}else{if(e.endsWith("em"))return parseFloat(e)*parseFloat(r);if(e.endsWith("rem"))return parseFloat(e)*parseFloat(getComputedStyle(this.document.documentElement).fontSize);if(e.endsWith("vh")){let s=this.window.innerHeight/100;return parseFloat(e)*s}else if(e.endsWith("vw")){let s=this.window.innerWidth/100;return parseFloat(e)*s}}return parseFloat(e)||0}static \u0275fac=function(t){return new(t||n)(Yt(bi),Yt(Yg),Yt($g),Yt(Cl))};static \u0275prov=f({token:n,factory:n.\u0275fac,providedIn:"root"})}return n})();function xl(n,i){return n.reduce((e,t)=>[...e,...i(t)],[])}function wl(n){let i=n.cloneNode(!0),e=i.querySelectorAll("[id]"),t=n.nodeName.toLowerCase();i.removeAttribute("id");for(let o=0;o<e.length;o++)e[o].removeAttribute("id");return t==="canvas"?Ef(n,i):(t==="input"||t==="select"||t==="textarea")&&Tf(n,i),Df("canvas",n,i,Ef),Df("input, textarea, select",n,i,Tf),i}function Df(n,i,e,t){let o=i.querySelectorAll(n);if(o.length){let r=e.querySelectorAll(n);for(let s=0;s<o.length;s++)t(o[s],r[s])}}var Kg=0;function Tf(n,i){i.type!=="file"&&(i.value=n.value),i.type==="radio"&&i.name&&(i.name=`mat-clone-${i.name}-${Kg++}`)}function Ef(n,i){let e=i.getContext("2d");if(e)try{e.drawImage(n,0,0)}catch{}}function bl(n,i,e){for(let t in i)if(i.hasOwnProperty(t)){let o=i[t];o?n.setProperty(t,o,e?.has(t)?"important":""):n.removeProperty(t)}return n}function Pf(n){bl(n.style,{"touch-action":"none","-webkit-user-drag":"none","-webkit-tap-highlight-color":"transparent","user-select":"none","-ms-user-select":"none","-webkit-user-select":"none","-moz-user-select":"none"})}function Mf(n,i,e){return Zg(n,e).dataset[i]}function Zg(n,i){return n.closest(i)}function Il(n,i){let e=n.rootNodes;if(e.length===1&&e[0].nodeType===i.ELEMENT_NODE)return e[0];let t=i.createElement("div");return e.forEach(o=>t.appendChild(o)),t}function Mn(n,i){let e=Qg(n,i);return!!e&&!e.classList.contains(i+"-disabled")}function Qg(n,i){return n.closest(i)}function ut(n){return n.match(/^[a-zA-Z_]/)||(n="_"+n),n.replace(/[^a-zA-Z0-9_\-:.]/g,"_")}function tn(n,i,e){let t=e[n.toUpperCase()]||Jg(e,n.toLowerCase());if(t===void 0)throw new Error(`Unknown ${i}: ${n}. Accepted values: ${Object.keys(e).join(", ")}`);return t}function Jg(n,i){return Object.keys(n).find(e=>n[e]===i)}var ep=["markerElement"],tp=["fConnectionGradientRenderer",""],np=["f-connection-path",""],ip=["fConnectionSelection",""],op=["f-connection-drag-handle-start",""],rp=["f-connection-drag-handle-end",""],sp=["defs"],ap=["*"],cp=["fGroupsContainer"],dp=["fNodesContainer"],lp=["fConnectionsContainer"],up=[[["","fGroup",""],["","fGroups",""]],[["f-snap-connection"]],[["f-connection"],["","fConnections",""]],[["f-connection-for-create"]],[["","fNode",""],["","fNodes",""]]],fp=["[fGroup], [fGroups]","f-snap-connection","f-connection, [fConnections]","f-connection-for-create","[fNode], [fNodes]"],hp=[[["svg","fMarker",""]],[["f-connection-marker-circle"],["f-connection-marker-arrow"]],[["f-connection-gradient"]],[["f-connection-waypoints"]],[["","fConnectionContent",""]]],gp=["svg[fMarker]","f-connection-marker-circle, f-connection-marker-arrow","f-connection-gradient","f-connection-waypoints","[fConnectionContent]"];function pp(n,i){n&1&&(Ge(),U(0,"linearGradient",3)),n&2&&A("fConnectionGradientRendererFor",i)}function _p(n,i){n&1&&(Ge(),U(0,"circle",6))}function mp(n,i){n&1&&De(0,4)}var yp="[_nghost-%COMP%]{display:block;position:absolute;left:0;top:0;width:100%;height:100%;overflow:hidden;pointer-events:none;-webkit-user-select:none;user-select:none}",vp=[[["","fDefinitions",""]],[["f-background"]],[["f-line-alignment"]],[["f-canvas"]],[["f-selection-area"]],"*"],Cp=["[fDefinitions]","f-background","f-line-alignment","f-canvas","f-selection-area","*"],Pl=new ee("F_BACKGROUND_PATTERN"),ga=class{fPattern;static fToken=Symbol("AddPatternToBackgroundRequest");constructor(i){this.fPattern=i}},sn=class{_items=[];_byId=new Map;get(i){return this._byId.get(i)}require(i){let e=this._byId.get(i);if(!e)throw new Error(`${this.kind} not found: ${i}`);return e}has(i){return this._byId.has(i)}getAll(){return this._items}size(){return this._items.length}add(i){let e=i.fId();if(this._byId.has(e))throw new Error(`${this.kind} already exists: ${e}`);this._items.push(i),this._byId.set(e,i)}addMany(i){for(let e of i)this.add(e)}remove(i){let e=i.fId(),t=this._byId.get(e);if(!t)return!1;this._byId.delete(e);let o=this._items.indexOf(t);return o>=0&&this._items.splice(o,1),!0}removeById(i){let e=this._byId.get(i);if(!e)return;this._byId.delete(i);let t=this._items.indexOf(e);return t>=0&&this._items.splice(t,1),e}clear(){this._items.length=0,this._byId.clear()}};function Ot(n){return{name:n}}var Ml=class{_instances=new Map;get(i){return this._instances.get(i.name)}require(i){let e=this.get(i);if(!e)throw new Error(`Instance not found: ${i.name}`);return e}has(i){return this._instances.has(i.name)}add(i,e){if(this._instances.has(i.name))throw new Error(`${i.name} already exists`);this._instances.set(i.name,e)}remove(i){if(!this._instances.has(i.name))throw new Error(`${i.name} does not exist`);return this._instances.delete(i.name),!0}clear(){this._instances.clear()}},kn=class extends sn{kind;constructor(i){super(),this.kind=i}},Rl=class extends sn{kind="Connection Marker"},Nl=class extends sn{kind="Connection";_instancesForCreate;_instancesForSnap;getForSnap(){return this._instancesForSnap}getForCreate(){return this._instancesForCreate}addForCreate(i){this._instancesForCreate=i}addForSnap(i){this._instancesForSnap=i}removeInstanceForCreate(){this._instancesForCreate=void 0}removeInstanceForSnap(){this._instancesForSnap=void 0}},kl=class extends sn{kind="Node"},nn=class{notifyOnSubscribe;static fToken=Symbol("ListenConnectionsChangesRequest");constructor(i=!0){this.notifyOnSubscribe=i}};function xp(){return n=>{let i=null,e=null,t=()=>{i!==null&&cancelAnimationFrame(i),e!==null&&cancelAnimationFrame(e),i=e=null};return{callback:()=>{t(),i=requestAnimationFrame(()=>{i=null,e=requestAnimationFrame(()=>{e=null,n()})})},cleanup:t}}}function wp(){return n=>{let i=null;return{callback:()=>{i!==null&&cancelAnimationFrame(i),i=requestAnimationFrame(()=>{i=null,n()})},cleanup:()=>{i!==null&&cancelAnimationFrame(i),i=null}}}}function pa(n){return i=>{let e=null;return{callback:()=>{e!==null&&clearTimeout(e),e=setTimeout(()=>{e=null,i()},n)},cleanup:()=>{e!==null&&clearTimeout(e),e=null}}}}var je=class{_listeners=new Set;notify(){this._listeners.forEach(i=>i())}listen(i){return this._listeners.add(i),()=>this.stop(i)}stop(i){this._listeners.delete(i)}},Ol=class extends je{_htmlElement;_observer=new ResizeObserver(()=>this.notify());_isObserving=!1;constructor(i){super(),this._htmlElement=i}listen(i){return this._isObserving||(this._observer.observe(this._htmlElement),this._isObserving=!0),super.listen(i)}stop(i){super.stop(i),this._listeners.size===0&&this._disconnect()}_disconnect(){this._observer.unobserve(this._htmlElement),this._observer.disconnect(),this._isObserving=!1}},it=class n{_channels=[];_operators=[];constructor(...i){this._channels=[...i]}pipe(...i){let e=new n(...this._channels);return e._operators=[...this._operators,...i],e}listen(i,e){let t=e,o=[],r=[],s=[];for(let g of[...this._operators].reverse()){let y=g(t);t=y.callback,y.cleanup&&o.push(y.cleanup),y.onSubscribe&&r.push(y.onSubscribe),y.setTeardown&&s.push(y.setTeardown)}let a=this._channels.map(g=>g.listen(()=>t())),d=null,l=!1,u=()=>{l||(l=!0,d?.(),d=null,a.forEach(g=>g()),o.forEach(g=>g()))};s.slice().reverse().forEach(g=>g(u)),r.slice().reverse().forEach(g=>g(t)),d=i.onDestroy(u)}};function Gd(){return n=>{let i=!0;return{callback:n,onSubscribe:e=>{queueMicrotask(()=>{i&&e()})},cleanup:()=>{i=!1}}}}function Rf(){return n=>{let i=!1,e=null;return{setTeardown:t=>e=t,callback:()=>{if(!i){i=!0;try{n()}finally{e?.()}}}}}}var bp=(()=>{let n=class Ui{_store=c(x);handle({notifyOnSubscribe:e}){return e?new it(this._store.connectionsChanges$).pipe(Gd(),pa(1)):new it(this._store.connectionsChanges$).pipe(pa(1))}static \u0275fac=function(t){return new(t||Ui)};static \u0275prov=f({token:Ui,factory:Ui.\u0275fac})};return n=p([_(nn)],n),n})(),Fl=class{static fToken=Symbol("ListenNodesChangesRequest")},Ip=(()=>{let n=class Wi{_store=c(x);handle(e){return new it(this._store.nodesChanges$)}static \u0275fac=function(t){return new(t||Wi)};static \u0275prov=f({token:Wi,factory:Wi.\u0275fac})};return n=p([_(Fl)],n),n})(),_a=class{static fToken=Symbol("ListenTransformChangesRequest")},Sp=(()=>{let n=class $i{_store=c(x);handle(e){return new it(this._store.transformChanges$,this._store.connectionsChanges$,this._store.nodesChanges$)}static \u0275fac=function(t){return new(t||$i)};static \u0275prov=f({token:$i,factory:$i.\u0275fac})};return n=p([_(_a)],n),n})(),Ft=class{static fToken=Symbol("EmitConnectionsChangesRequest")},Dp=(()=>{let n=class Xi{_store=c(x);handle(e){this._store.emitConnectionChanges()}static \u0275fac=function(t){return new(t||Xi)};static \u0275prov=f({token:Xi,factory:Xi.\u0275fac})};return n=p([_(Ft)],n),n})(),xt=class{static fToken=Symbol("NotifyTransformChangedRequest")},x=(()=>{class n{transformChanges$=new je;viewportAnimationChanges$=new je;connectionsChanges$=new je;_connectionsRevision=0;connectionsRenderedChanges$=new je;_connectionsRenderedRevision=0;_connectionsRenderedNodesRevision=0;_viewportAnimationCount=0;nodesChanges$=new je;_nodesRevision=0;progressiveRenderChanges$=new je;_pendingProgressiveRenderCount=0;get connectionsRevision(){return this._connectionsRevision}get connectionsRenderedRevision(){return this._connectionsRenderedRevision}get connectionsRenderedNodesRevision(){return this._connectionsRenderedNodesRevision}get nodesRevision(){return this._nodesRevision}get hasPendingProgressiveRender(){return this._pendingProgressiveRenderCount>0}get isViewportAnimating(){return this._viewportAnimationCount>0}get flowHost(){return this.fFlow?.hostElement}fFlow;fCanvas;get transform(){return this.fCanvas?.transform}nodes=new kl;connections=new Nl;connectionMarkers=new Rl;outputs=new kn("Output");inputs=new kn("Input");outlets=new kn("Outlet");instances=new Ml;fDraggable;emitNodeChanges(){this._nodesRevision++,this.nodesChanges$.notify()}emitConnectionChanges(){this._connectionsRevision++,this.connectionsChanges$.notify()}completeConnectionsRender(e,t){e<this._connectionsRenderedRevision||e===this._connectionsRenderedRevision&&t<=this._connectionsRenderedNodesRevision||(this._connectionsRenderedRevision=Math.min(e,this._connectionsRevision),this._connectionsRenderedNodesRevision=t,this.connectionsRenderedChanges$.notify())}beginProgressiveRender(){this._pendingProgressiveRenderCount++,this.progressiveRenderChanges$.notify()}endProgressiveRender(){this._pendingProgressiveRenderCount&&(this._pendingProgressiveRenderCount--,this.progressiveRenderChanges$.notify())}transformChanged(){this.transformChanges$.notify()}beginViewportAnimation(){this._viewportAnimationCount++,this.viewportAnimationChanges$.notify()}endViewportAnimation(){this._viewportAnimationCount&&(this._viewportAnimationCount--,this.viewportAnimationChanges$.notify())}static \u0275fac=function(t){return new(t||n)};static \u0275prov=f({token:n,factory:n.\u0275fac})}return n})(),ae={MAGNETIC_LINES:Ot("magnetic-lines"),MAGNETIC_RECTS:Ot("magnetic-rects"),ZOOM:Ot("zoom-controls"),BACKGROUND:Ot("background"),SELECTION_AREA:Ot("selection-area"),MINIMAP:Ot("minimap"),AUTO_PAN:Ot("auto-pan")},Tp=(()=>{let n=class qi{_store=c(x);handle(e){this._store.transformChanged()}static \u0275fac=function(t){return new(t||qi)};static \u0275prov=f({token:qi,factory:qi.\u0275fac})};return n=p([_(xt)],n),n})(),At=class{key;instance;static fToken=Symbol("RegisterPluginInstanceRequest");constructor(i,e){this.key=i,this.instance=e}},Ep=(()=>{let n=class Yi{_store=c(x);handle({key:e,instance:t}){this._store.instances.add(e,t)}static \u0275fac=function(t){return new(t||Yi)};static \u0275prov=f({token:Yi,factory:Yi.\u0275fac})};return n=p([_(At)],n),n})(),Lt=class{key;static fToken=Symbol("RemovePluginInstanceRequest");constructor(i){this.key=i}},Pp=(()=>{let n=class Ki{_store=c(x);handle({key:e}){this._store.instances.remove(e)}static \u0275fac=function(t){return new(t||Ki)};static \u0275prov=f({token:Ki,factory:Ki.\u0275fac})};return n=p([_(Lt)],n),n})(),Mp=[x,Ip,bp,Sp,Dp,Tp,Ep,Pp],Rp=0,Np=(()=>{let n=class Zi{_store=c(x);_browser=c(pe);get _backgroundElement(){return this._store.instances.get(ae.BACKGROUND)?.hostElement}handle(e){let t=this._getPatterns(e.fPattern?.hostElement);if(!t?.length)return;let o=rn("defs",this._browser);if(e.fPattern?.hostElement.remove(),t.forEach(r=>{o.append(r)}),t.length){this._backgroundElement?.firstChild?.appendChild(o),t[t.length-1].id="f-background-pattern-"+Rp++;let r=t[t.length-1].id,s=rn("rect",this._browser);s.setAttribute("fill","url(#"+r+")"),s.setAttribute("width","100%"),s.setAttribute("height","100%"),this._backgroundElement?.firstChild?.appendChild(s);let a=this._store.fCanvas?.transform||_t.default();e.fPattern?.setTransform(a)}}_getPatterns(e){return Array.from(e?.getElementsByTagName("pattern")||[])}static \u0275fac=function(t){return new(t||Zi)};static \u0275prov=f({token:Zi,factory:Zi.\u0275fac})};return n=p([_(ga)],n),n})(),On=class{fTransform;static fToken=Symbol("SetBackgroundTransformRequest");constructor(i){this.fTransform=i}},kp=(()=>{let n=class Qi{_store=c(x);handle(e){this._store.instances.get(ae.BACKGROUND)?.setTransform(e.fTransform)}static \u0275fac=function(t){return new(t||Qi)};static \u0275prov=f({token:Qi,factory:Qi.\u0275fac})};return n=p([_(On)],n),n})(),Op=[Np,kp],ma=class{instance;static fToken=Symbol("AddCanvasToStoreRequest");constructor(i){this.instance=i}},Fp=(()=>{let n=class Ji{_store=c(x);handle({instance:e}){this._store.fCanvas=e}static \u0275fac=function(t){return new(t||Ji)};static \u0275prov=f({token:Ji,factory:Ji.\u0275fac})};return n=p([_(ma)],n),n})(),ya=class{id;animated;static fToken=Symbol("CenterGroupOrNodeRequest");constructor(i,e){this.id=i,this.animated=e}},Ap=(()=>{let n=class eo{_store=c(x);_mediator=c(D);get _transform(){return this._store.transform}handle({id:e,animated:t}){let o=this._store.nodes.get(e);o&&(this._toCenter(this._getNodeRect(o),this._getFlowRect(),o._position),this._mediator.execute(new an(t,zt.VIEWPORT_ONLY)))}_toCenter(e,t,o){this._transform.scaledPosition=M.initialize(),this._transform.position=M.initialize((t.width-e.width)/2-o.x*this._transform.scale,(t.height-e.height)/2-o.y*this._transform.scale)}_getNodeRect(e){return z.fromElement(e.hostElement)}_getFlowRect(){return z.fromElement(this._store.flowHost)}static \u0275fac=function(t){return new(t||eo)};static \u0275prov=f({token:eo,factory:eo.\u0275fac})};return n=p([_(ya)],n),n})(),va=class{toCenter;animated;static fToken=Symbol("FitToFlowRequest");constructor(i,e){this.toCenter=i,this.animated=e}},Lp=(()=>{let n=class to{_store=c(x);get _transform(){return this._store.transform}_mediator=c(D);handle({toCenter:e,animated:t}){let o=this._mediator.execute(new gn)||z.initialize();o.width===0||o.height===0||(this.fitToParent(o,z.fromElement(this._store.flowHost),this._store.nodes.getAll().map(r=>r._position),e),this._mediator.execute(new an(t,zt.VIEWPORT_ONLY)))}fitToParent(e,t,o,r){this._transform.scaledPosition=M.initialize(),this._transform.position=this._getZeroPositionWithoutScale(o);let s=e.width/this._transform.scale+r.x,a=e.height/this._transform.scale+r.y;(s>t.width||a>t.height||s<t.width&&a<t.height)&&(this._transform.scale=Math.min(t.width/s,t.height/a));let d=(t.width-s*this._transform.scale)/2-this._transform.position.x*this._transform.scale,l=(t.height-a*this._transform.scale)/2-this._transform.position.y*this._transform.scale;this._transform.position=M.initialize(d+r.x/2*this._transform.scale,l+r.y/2*this._transform.scale)}_getZeroPositionWithoutScale(e){let t=e.length?Math.min(...e.map(r=>r.x)):0,o=e.length?Math.min(...e.map(r=>r.y)):0;return M.initialize(t,o)}static \u0275fac=function(t){return new(t||to)};static \u0275prov=f({token:to,factory:to.\u0275fac})};return n=p([_(va)],n),n})(),Ca=class{transform;position;static fToken=Symbol("InputCanvasPositionRequest");constructor(i,e){this.transform=i,this.position=e}},zp=(()=>{let n=class no{_store=c(x);handle({transform:e,position:t}){t&&(M.isEqual(this._calculateTransformPosition(e),t)||(e.position=t,e.scaledPosition=M.initialize(),this._store.fCanvas?.redraw()))}_calculateTransformPosition(e){return M.sum(e.position,e.scaledPosition)}static \u0275fac=function(t){return new(t||no)};static \u0275prov=f({token:no,factory:no.\u0275fac})};return n=p([_(Ca)],n),n})(),xa=class{transform;scale;static fToken=Symbol("InputCanvasScaleRequest");constructor(i,e){this.transform=i,this.scale=e}},Bp=(()=>{let n=class io{_store=c(x);handle(e){!e.scale&&e.scale!==0||(e.transform.scale=e.scale,this._store.fCanvas?.redraw())}static \u0275fac=function(t){return new(t||io)};static \u0275prov=f({token:io,factory:io.\u0275fac})};return n=p([_(xa)],n),n})(),zt=(function(n){return n.VIEWPORT_ONLY="VIEWPORT_ONLY",n.WITH_CONNECTION_CHANGES="WITH_CONNECTION_CHANGES",n})(zt||{}),an=class{animated;context;static fToken=Symbol("RedrawCanvasWithAnimationRequest");constructor(i,e=zt.WITH_CONNECTION_CHANGES){this.animated=i,this.context=e}};function oh(n,i){let e=t=>{t.propertyName==="transform"&&(n.removeEventListener("transitionend",e),i(t))};n.addEventListener("transitionend",e)}var Gp=(()=>{let n=class oo{_store=c(x);get _canvas(){return this._store.fCanvas}handle(e){e.animated?this._redrawWithAnimation(e.context):this._redraw(e.context),this._canvas?.emitCanvasChangeEvent()}_redrawWithAnimation(e){this._store.beginViewportAnimation(),this._canvas?.redrawWithAnimation(),oh(this._canvas.hostElement,()=>{this._store.endViewportAnimation(),e===zt.WITH_CONNECTION_CHANGES&&this._store.emitConnectionChanges()})}_redraw(e){this._canvas?.redraw(),e===zt.WITH_CONNECTION_CHANGES&&this._store.emitConnectionChanges()}static \u0275fac=function(t){return new(t||oo)};static \u0275prov=f({token:oo,factory:oo.\u0275fac})};return n=p([_(an)],n),n})(),wa=class{static fToken=Symbol("RemoveCanvasFromStoreRequest")},Hp=(()=>{let n=class ro{_store=c(x);handle(e){this._store.fCanvas=void 0}static \u0275fac=function(t){return new(t||ro)};static \u0275prov=f({token:ro,factory:ro.\u0275fac})};return n=p([_(wa)],n),n})(),ba=class{static fToken=Symbol("ResetScaleRequest")},jp=(()=>{let n=class so{_store=c(x);get _transform(){return this._store.transform}handle(e){this._transform.scale=1,this._transform.scaledPosition=M.initialize()}static \u0275fac=function(t){return new(t||so)};static \u0275prov=f({token:so,factory:so.\u0275fac})};return n=p([_(ba)],n),n})(),Ia=class{animated;static fToken=Symbol("ResetScaleAndCenterRequest");constructor(i){this.animated=i}},Vp=(()=>{let n=class ao{_mediator=c(D);_store=c(x);get _transform(){return this._store.transform}handle({animated:e}){let t=this._mediator.execute(new gn)||z.initialize();t.width===0||t.height===0||(this._oneToOneCentering(t,z.fromElement(this._store.flowHost),this._store.nodes.getAll().map(o=>o._position)),this._mediator.execute(new an(e,zt.VIEWPORT_ONLY)))}_oneToOneCentering(e,t,o){this._transform.scaledPosition=M.initialize(),this._transform.position=this._getZeroPositionWithoutScale(o);let r=(t.width-e.width/this._transform.scale)/2-this._transform.position.x,s=(t.height-e.height/this._transform.scale)/2-this._transform.position.y;this._transform.scale=1,this._transform.position=M.initialize(r,s)}_getZeroPositionWithoutScale(e){let t=e.length?Math.min(...e.map(r=>r.x)):0,o=e.length?Math.min(...e.map(r=>r.y)):0;return M.initialize(t,o)}static \u0275fac=function(t){return new(t||ao)};static \u0275prov=f({token:ao,factory:ao.\u0275fac})};return n=p([_(Ia)],n),n})(),Sa=class{scale;toPosition;static fToken=Symbol("UpdateScaleRequest");constructor(i,e){this.scale=i,this.toPosition=e}},Up=(()=>{let n=class co{_store=c(x);get _transform(){return this._store.transform}handle({scale:e,toPosition:t}){if(e===this._transform.scale)return;let o=M.sum(this._transform.scaledPosition,this._transform.position),r=t.x-(t.x-o.x)*e/this._transform.scale,s=t.y-(t.y-o.y)*e/this._transform.scale;this._transform.scale=e,this._transform.scaledPosition=M.sub(M.initialize(r,s),this._transform.position)}static \u0275fac=function(t){return new(t||co)};static \u0275prov=f({token:co,factory:co.\u0275fac})};return n=p([_(Sa)],n),n})(),Wp=[Fp,Ap,Lp,zp,Bp,Gp,Hp,jp,Vp,Up],Al=class{connection;static fToken=Symbol("AddConnectionForCreateToStoreRequest");constructor(i){this.connection=i}},$p=(()=>{let n=class lo{_store=c(x);handle({connection:e}){this._store.connections.addForCreate(e)}static \u0275fac=function(t){return new(t||lo)};static \u0275prov=f({token:lo,factory:lo.\u0275fac})};return n=p([_(Al)],n),n})(),Ll=class{instance;static fToken=Symbol("AddConnectionMarkerToStoreRequest");constructor(i){this.instance=i}},Xp=(()=>{let n=class uo{_store=c(x);handle({instance:e}){this._store.connectionMarkers.add(e),this._store.emitNodeChanges()}static \u0275fac=function(t){return new(t||uo)};static \u0275prov=f({token:uo,factory:uo.\u0275fac})};return n=p([_(Ll)],n),n})(),Da=class{connection;static fToken=Symbol("AddConnectionToStoreRequest");constructor(i){this.connection=i}},qp=(()=>{let n=class fo{_store=c(x);handle({connection:e}){this._store.connections.add(e),this._store.emitConnectionChanges()}static \u0275fac=function(t){return new(t||fo)};static \u0275prov=f({token:fo,factory:fo.\u0275fac})};return n=p([_(Da)],n),n})(),zl=class{connection;static fToken=Symbol("AddSnapConnectionToStoreRequest");constructor(i){this.connection=i}},Yp=(()=>{let n=class ho{_store=c(x);handle({connection:e}){this._store.connections.addForSnap(e)}static \u0275fac=function(t){return new(t||ho)};static \u0275prov=f({token:ho,factory:ho.\u0275fac})};return n=p([_(zl)],n),n})(),cn=class{connection;static fToken=Symbol("CreateConnectionMarkersRequest");constructor(i){this.connection=i}},Nf=new ee("F_CONNECTION_CONTENT");var Ta=class n{points;cumulativeLengths;segmentTangents;totalLength;constructor(i){let e=n._removeConsecutiveDuplicates(i);if(e.length<2){this.points=[{x:0,y:0},{x:1,y:0}],this.cumulativeLengths=[0,1],this.segmentTangents=[{x:1,y:0}],this.totalLength=1;return}this.points=e;let t=this.points.length,o=t-1,r=new Array(t).fill(0),s=new Array(o),a=0;for(let d=0;d<o;d++){let l=this.points[d+1].x-this.points[d].x,u=this.points[d+1].y-this.points[d].y,g=Math.hypot(l,u),y=g?l/g:1,C=g?u/g:0;s[d]={x:y,y:C},a+=g,r[d+1]=a}this.cumulativeLengths=r,this.segmentTangents=s,this.totalLength=a||1}static from(i){return new n(i.map(e=>({x:e.x,y:e.y})))}static _removeConsecutiveDuplicates(i){let e=[];for(let t of i){let o=e[e.length-1];(!o||o.x!==t.x||o.y!==t.y)&&e.push({x:t.x,y:t.y})}return e}},Bl=class n{_polyline;constructor(i=[]){this._polyline=new Ta(i)}updatePoints(i){return this._polyline=new Ta(i),this._polyline.totalLength}calculateTotalLength(i){return this.updatePoints(i)}get totalLength(){return this._polyline.totalLength}getPointAtProgress(i){let{points:e,cumulativeLengths:t,segmentTangents:o,totalLength:r}=this._polyline,a=n._clamp(i,0,1)*r,d=.5;if(a<=d)return{point:e[0],tangent:o[0]??{x:1,y:0},atEdge:!0};if(r-a<=d){let P=e.length-1;return{point:e[P],tangent:o[P-1]??{x:1,y:0},atEdge:!0}}let l=n._findRightIndex(t,a),u=Math.max(1,l),g=t[u-1],y=t[u],C=n._safeRatio(a-g,y-g),E=e[u-1],b=e[u],w={x:n._lerp(E.x,b.x,C),y:n._lerp(E.y,b.y,C)},I=o[u-1]??{x:1,y:0};return{point:w,tangent:I,atEdge:!1}}getPointAtLength(i){return this.getPointAtProgress(i)}getPointAtDistance(i){let e=this._polyline.totalLength?i/this._polyline.totalLength:0;return this.getPointAtProgress(e)}static _findRightIndex(i,e){let t=0,o=i.length-1;for(;t<o;){let r=t+o>>1;i[r]<e?t=r+1:o=r}return t}static _lerp(i,e,t){return i+(e-i)*t}static _clamp(i,e,t){return i<e?e:i>t?t:i}static _safeRatio(i,e){let t=Math.abs(e)<1e-6?1e-6:e;return i/t}},rh=(function(n){return n.NONE="none",n.ALONG="along",n})(rh||{}),Gl=class{compute(i,e){let t=this._clamp01(e.position()),{point:o,tangent:r}=i.getPointAtLength(t),s={x:-r.y,y:r.x},a=e.offset()??0,d=o.x+s.x*a,l=o.y+s.y*a,g=this._sizeAlongDirection(e.hostElement,r)*.5,y=t*i.totalLength,C=i.totalLength-y,E=this._applyEdgeGuard(d,l,r,y,C,g),b=this._calculateContentRotation(e.align(),r);return{position:E,rotationDeg:b}}_clamp01(i){return i<=0?0:i>=1?1:i}_applyEdgeGuard(i,e,t,o,r,s){if(o<=s){let a=s-o;return{x:i+t.x*a,y:e+t.y*a}}if(r<=s){let a=s-r;return{x:i-t.x*a,y:e-t.y*a}}return{x:i,y:e}}_sizeAlongDirection(i,e){let t=z.fromElement(i);return Math.abs(e.x)*t.width+Math.abs(e.y)*t.height}_normalize180(i){let e=(i+180)%360;return e<0&&(e+=360),e-180}_keepUpright(i){let e=this._normalize180(i);return e>90?e-=180:e<-90&&(e+=180),e}_calculateContentRotation(i,e){let t=0;return i===rh.ALONG&&(t=Math.atan2(e.y,e.x)*180/Math.PI,t=this._keepUpright(t)),t}},Hl=class{_placement;constructor(i=new Gl){this._placement=i}layout(i,e){let t=new Bl(i),o=t.totalLength;for(let r of e){let{position:s,rotationDeg:a}=this._placement.compute(t,r);r.hostElement.style.transform=this._createTransformString(s,a)}return o}_createTransformString(i,e){return`translate3d(${i.x}px, ${i.y}px, 0) translate(-50%, -50%) rotate(${e}deg)`}};var kf=new ee("F_CONNECTION_WAYPOINTS");function sh(n,i,e){return(n.x-i.x)**2+(n.y-i.y)**2<=e**2}function Kp(n,i){let e=n.fWaypoints(),t=e?.radius()||8;return e?.candidates().find(o=>sh(i,o,t))}function Zp(n,i){let e=n.fWaypoints(),t=e?.radius()||8;return e?.waypoints().find(o=>sh(i,o,t))}function Qp(n,i){for(let e of n){let t=Zp(e,i);if(t&&e.fWaypoints()?.visibility())return{connection:e,waypoint:t};let o=Kp(e,i);if(o&&e.fWaypoints()?.visibility())return{connection:e,candidate:o}}}var Hd=new ee("F_CONNECTION_COMPONENTS_PARENT");var ne=(function(n){return n.START="f-connection-marker-start",n.END="f-connection-marker-end",n.SELECTED_START="f-connection-selected-marker-start",n.SELECTED_END="f-connection-selected-marker-end",n.START_ALL_STATES="f-connection-marker-start-all-states",n.END_ALL_STATES="f-connection-marker-end-all-states",n})(ne||{}),jl=new ee("F_CONNECTION_MARKER"),Jp=0,Vl=class{fId=oe(`f-marker-${Jp++}`);hostElement=c(he).nativeElement};function e_(n,i=ne.START){if(typeof n!="string")return i;let e=n.trim().toLowerCase();return e?t_(e)??i:i}function t_(n){switch(n){case"start":case"f-connection-marker-start":return ne.START;case"end":case"f-connection-marker-end":return ne.END;case"selected-start":case"f-connection-selected-marker-start":return ne.SELECTED_START;case"selected-end":case"f-connection-selected-marker-end":return ne.SELECTED_END;case"start-all-states":case"f-connection-marker-start-all-states":case"start-all":case"all-start":return ne.START_ALL_STATES;case"end-all-states":case"f-connection-marker-end-all-states":case"end-all":case"all-end":return ne.END_ALL_STATES;default:return null}}var ah=(()=>{class n extends Vl{_markerElement=ve.required("markerElement");_type=F(ne.END_ALL_STATES,{alias:"type",transform:e=>e_(e,ne.END_ALL_STATES)});get markerElement(){return this._markerElement().nativeElement}width=6;height=7;refX=5.5;refY=3.5;get type(){return this._type()}orient="auto";markerUnits="strokeWidth";static \u0275fac=(()=>{let e;return function(o){return(e||(e=X(n)))(o||n)}})();static \u0275cmp=se({type:n,selectors:[["f-connection-marker-arrow"]],viewQuery:function(t,o){t&1&&ct(o._markerElement,ep,5),t&2&&We()},hostAttrs:[1,"f-component",2,"display","none"],inputs:{_type:[1,"type","_type"]},features:[be([{provide:jl,useExisting:n}]),ce],decls:3,vars:0,consts:[["markerElement",""],["viewBox","0 0 6 6",1,"f-marker"],["d","M0,0 L6,3 0,6Z"]],template:function(t,o){t&1&&(Ge(),Je(0,"svg",1,0),Zt(2,"path",2),et())},encapsulation:2})}return n})();var vt=(function(n){return n.FIXED="fixed",n.FIXED_CENTER="fixed_center",n.FLOATING="floating",n})(vt||{}),ke=(function(n){return n.DEFAULT="default",n.TOP="top",n.BOTTOM="bottom",n.LEFT="left",n.RIGHT="right",n.CALCULATE="calculate",n.CALCULATE_HORIZONTAL="calculate_horizontal",n.CALCULATE_VERTICAL="calculate_vertical",n})(ke||{});function n_({sourceRect:n,targetRect:i}){return{point1:n.gravityCenter,point2:i.gravityCenter}}var R=(function(n){return n.LEFT="left",n.TOP="top",n.RIGHT="right",n.BOTTOM="bottom",n.CALCULATE="calculate",n.CALCULATE_HORIZONTAL="calculate_horizontal",n.CALCULATE_VERTICAL="calculate_vertical",n.AUTO="auto",n})(R||{}),yt=(function(n){return n.SEGMENT="segment",n.STRAIGHT="straight",n.BEZIER="bezier",n.ADAPTIVE_CURVE="adaptive-curve",n})(yt||{});function i_({sourceRect:n,sourceConnectableSide:i,targetRect:e,targetConnectableSide:t}){return{point1:Of(n,i===R.AUTO?R.BOTTOM:i),point2:Of(e,t===R.AUTO?R.TOP:t)}}function Of(n,i){switch(i){case R.TOP:return{x:n.x+n.width/2,y:n.y};case R.BOTTOM:return{x:n.x+n.width/2,y:n.y+n.height};case R.LEFT:return{x:n.x,y:n.y+n.height/2};case R.RIGHT:return{x:n.x+n.width,y:n.y+n.height/2};default:throw new Error(`Unknown side: ${i}`)}}function ch(n,i,e,t){if(!t||!t.rotationDeg)return en.getRoundedRectIntersections(n,i,e)[0];let o=go(n,-t.rotationDeg,t.pivot),r=go(i,-t.rotationDeg,t.pivot),s=o_(e,-t.rotationDeg,t.pivot),a=en.getRoundedRectIntersections(o,r,s)[0];return a?go(a,t.rotationDeg,t.pivot):void 0}function o_(n,i,e){let t=go(r_(n),i,e);return new ge(t.x-n.width/2,t.y-n.height/2,n.width,n.height,n.radius1,n.radius2,n.radius3,n.radius4)}function r_(n){return{x:n.x+n.width/2,y:n.y+n.height/2}}function go(n,i,e){let t=n.x-e.x,o=n.y-e.y,r=i*Math.PI/180,s=Math.cos(r),a=Math.sin(r);return{x:t*s-o*a+e.x,y:t*a+o*s+e.y}}function s_({sourceRect:n,targetRect:i,sourceRotationContext:e,targetRotationContext:t}){return d_(a_(n,i,e),c_(n,i,t),n,i)}function a_(n,i,e){return ch(n.gravityCenter,i.gravityCenter,n,e)}function c_(n,i,e){return ch(i.gravityCenter,n.gravityCenter,i,e)}function d_(n,i,e,t){return{point1:n||e.gravityCenter,point2:i||t.gravityCenter}}var ji=.5,l_={[vt.FLOATING]:s_,[vt.FIXED_CENTER]:n_,[vt.FIXED]:i_},Cn=(()=>{class n{handle(e){let t=this._calculateDirectionalVectors(e.sourceRect.gravityCenter.x,e.sourceRect.gravityCenter.y,e.targetRect.gravityCenter.x,e.targetRect.gravityCenter.y),o=this._determineSourceSide(e,t),r=this._determineTargetSide(e,t);return e.connection._applyResolvedSidesToConnection(o,r),this._getBehaviorHandler(e.connection.fBehavior)({sourceRect:e.sourceRect,targetRect:e.targetRect,sourceConnectableSide:o,targetConnectableSide:r,sourceRotationContext:e.sourceRotationContext,targetRotationContext:e.targetRotationContext})}_calculateDirectionalVectors(e,t,o,r){let s=o-e,a=r-t;return{sourceToTargetX:s,sourceToTargetY:a,targetToSourceX:-s,targetToSourceY:-a}}_determineSourceSide(e,t){return this._resolveConnectableSide(e.connection.fOutputSide(),t.sourceToTargetX,t.sourceToTargetY,e.sourceConnectableSide)}_determineTargetSide(e,t){return this._resolveConnectableSide(e.connection.fInputSide(),t.targetToSourceX,t.targetToSourceY,e.targetConnectableSide)}_resolveConnectableSide(e,t,o,r){if(e===ke.DEFAULT)return r;let s=Math.abs(t),a=Math.abs(o);if(s<ji&&a<ji)return r;let l=s>=a;switch(e){case ke.CALCULATE:return l?t>=0?R.RIGHT:R.LEFT:o>=0?R.BOTTOM:R.TOP;case ke.CALCULATE_HORIZONTAL:return s<ji?r:t>=0?R.RIGHT:R.LEFT;case ke.CALCULATE_VERTICAL:return a<ji?r:o>=0?R.BOTTOM:R.TOP;case ke.TOP:return R.TOP;case ke.BOTTOM:return R.BOTTOM;case ke.LEFT:return R.LEFT;case ke.RIGHT:return R.RIGHT;default:return r}}_getBehaviorHandler(e){let t=l_[e];if(!t)throw new Error(`[Behavior] No handler for behavior: ${e}`);return t}static \u0275fac=function(t){return new(t||n)};static \u0275prov=f({token:n,factory:n.\u0275fac})}return n})(),Ye=class{sourceRect;targetRect;connection;sourceConnectableSide;targetConnectableSide;sourceRotationContext;targetRotationContext;constructor(i,e,t,o,r,s,a){this.sourceRect=i,this.targetRect=e,this.connection=t,this.sourceConnectableSide=o,this.targetConnectableSide=r,this.sourceRotationContext=s,this.targetRotationContext=a}};function jd(n,i,e){return[n,...e??[],i]}function u_(n,i){let e=Math.abs(i.x-n.x)/2,t=i.x<n.x?i.x+e:i.x-e,o=Math.abs(i.y-n.y)/2,r=i.y<n.y?i.y+o:i.y-o;return{x:t,y:r}}function f_(n,i=32){let e=new Array(i+1);e[0]=J({},n[0]);for(let t=1;t<=i;t++)e[t]=dh(n[0],n[1],n[2],n[3],t/i);return e}function dh(n,i,e,t,o){let r=1-o,s=o*o,a=r*r,d=a*r,l=s*o;return{x:d*n.x+3*a*o*i.x+3*r*s*e.x+l*t.x,y:d*n.y+3*a*o*i.y+3*r*s*e.y+l*t.y}}function lh(n){return n.map(i=>dh(i.p0,i.c1,i.c2,i.p3,.5))}function h_(n){if(n.length<2)throw new Error("Polylines must be at least two points");let i=g_(n);return i<=0?[J({},n[0])]:[p_(n,i/2)]}function g_(n){let i=0;for(let e=0;e<n.length-1;e++)i+=uh(n[e],n[e+1]);return i}function p_(n,i){let e=0;for(let o=0;o<n.length-1;o++){let r=n[o],s=n[o+1],a=uh(r,s);if(!(a<=0)){if(e+a>=i){let d=(i-e)/a;return{x:r.x+(s.x-r.x)*d,y:r.y+(s.y-r.y)*d}}e+=a}}let t=n[n.length-1];return{x:t.x,y:t.y}}function uh(n,i){return Math.hypot(i.x-n.x,i.y-n.y)}function __(n){let i=[];for(let e of n)for(let t of e){let o=i[i.length-1];(!o||o.x!==t.x||o.y!==t.y)&&i.push(t)}return i}function fh(n){if(!n.length)return"";let i=`M ${n[0].p0.x} ${n[0].p0.y}`;for(let e=0;e<n.length;e++){let t=n[e],o=e===n.length-1,r=o?t.p3.x+2e-4:t.p3.x,s=o?t.p3.y+2e-4:t.p3.y;i+=` C ${t.c1.x} ${t.c1.y}, ${t.c2.x} ${t.c2.y}, ${r} ${s}`}return i}function hh(n,i=16){if(!n.length)return[];let e=[];for(let t=0;t<n.length;t++){let o=n[t],r=f_([o.p0,o.c1,o.c2,o.p3],i);t>0&&r.shift(),e.push(...r)}return e}function m_(n,i=1e-6){let e=n.length;if(e<=2)return n;let t=[];t.push(n[0]);for(let r=1;r<e;r++){let s=n[r],a=t[t.length-1];(Math.abs(s.x-a.x)>i||Math.abs(s.y-a.y)>i)&&t.push(s)}if(t.length<=2)return t;let o=[];o.push(t[0]);for(let r=1;r<t.length-1;r++){let s=o[o.length-1],a=t[r],d=t[r+1],l=Math.abs(s.x-a.x)<=i&&Math.abs(a.x-d.x)<=i,u=Math.abs(s.y-a.y)<=i&&Math.abs(a.y-d.y)<=i;!l&&!u&&o.push(a)}return o.push(t[t.length-1]),o}var Ul=class n{static _dir(i){switch(i){case R.LEFT:return{x:-1,y:0};case R.RIGHT:return{x:1,y:0};case R.TOP:return{x:0,y:-1};case R.BOTTOM:return{x:0,y:1};case R.AUTO:return{x:0,y:0}}return{x:0,y:0}}static _isHorizontal(i){return i===R.LEFT||i===R.RIGHT}static _handleLength(i,e,t,o){let r=Math.abs(e.x-i.x),s=Math.abs(e.y-i.y),a=Math.hypot(r,s),d=t===R.AUTO?Math.max(r,s):this._isHorizontal(t)?r:s,l=Math.max(8,o),u=o+.5*a,g=o*1.05+d*.3;return Math.min(u,Math.max(l,g))}static _softControl(i,e,t,o){let r=this._dir(i),s=t.x-e.x,a=t.y-e.y,d=Math.hypot(s,a)||1,l=s/d,u=a/d;if(i===R.AUTO)return{x:e.x+l*o,y:e.y+u*o};let g=r.x*l+r.y*u,y=.12,C=Math.max(0,-g)*.08,E=Math.min(.2,y+C),b=r.x*(1-E)+l*E,w=r.y*(1-E)+u*E,I=Math.hypot(b,w)||1;return{x:e.x+b/I*o,y:e.y+w/I*o}}handle({source:i,sourceSide:e,target:t,targetSide:o,offset:r,waypoints:s}){let a=Math.max(0,r??0),d=jd(i,t,s),l=[];for(let g=0;g<d.length-1;g++){let y=d[g],C=d[g+1],E=n._handleLength(y,C,e,a),b=n._handleLength(C,y,o,a),w=n._softControl(e,y,C,E),I=n._softControl(o,C,y,b);l.push({p0:y,c1:w,c2:I,p3:C,chainIndex:g})}let u=hh(l,12);return{path:fh(l),secondPoint:l[0]?.c1??i,penultimatePoint:l[l.length-1]?.c2??t,points:u,candidates:lh(l)}}},Wl=class{handle({source:i,sourceSide:e,target:t,targetSide:o,offset:r,waypoints:s}){let a=jd(i,t,s),d=[];for(let u=0;u<a.length-1;u++){let g=a[u],y=a[u+1],C=Ff(e,g,y,r??0),E=Ff(o,y,g,r??0);d.push({p0:g,c1:C,c2:E,p3:y,chainIndex:u})}let l=hh(d,12);return{path:fh(d),secondPoint:d[0]?.c1??i,penultimatePoint:d[d.length-1]?.c2??t,points:l,candidates:lh(d)}}};function Ff(n,i,e,t){let o={x:i.x,y:i.y};switch(n){case R.LEFT:o.x-=Vi(i.x-e.x,t);break;case R.RIGHT:o.x+=Vi(e.x-i.x,t);break;case R.TOP:o.y-=Vi(i.y-e.y,t);break;case R.BOTTOM:o.y+=Vi(e.y-i.y,t);break;case R.AUTO:break}return o}function Vi(n,i){return n>=i?n:i*Math.sqrt(i-n)}function y_(n){let{axis:i,source:e,target:t,sourceSide:o,targetSide:r,sourceGap:s,targetGap:a,sourceDir:d,targetDir:l,currentDir:u,offset:g,sourceGapOffset:y,targetGapOffset:C}=n,E=v_(s,a),b=C_(i,d,u,E);return o===r?x_(i,e,t,g,d,u,s,a,y,C):b=w_(i,d,l,s,a,E,b),b}function v_(n,i){return{sourceTarget:[{x:n.x,y:i.y}],targetSource:[{x:i.x,y:n.y}]}}function C_(n,i,e,t){return n==="x"?i.x===e?t.targetSource:t.sourceTarget:i.y===e?t.sourceTarget:t.targetSource}function x_(n,i,e,t,o,r,s,a,d,l){let u=Math.abs(i[n]-e[n]);if(u>t)return;let g=Math.min(t-1,t-u);g<=0||(o[n]===r?d[n]=(s[n]>i[n]?-1:1)*g:l[n]=(a[n]>e[n]?-1:1)*g)}function w_(n,i,e,t,o,r,s){let a=n==="x"?"y":"x",d=i[n]===e[a],l=t[a]>o[a],u=t[a]<o[a];return i[n]===1&&(!d&&l||d&&u)||i[n]!==1&&(!d&&u||d&&l)?n==="x"?r.sourceTarget:r.targetSource:s}var Rn=1e-6,Af=2e-4,b_=.75;function I_(n,i){let e=n.length,t=[];t.push(`M ${n[0].x} ${n[0].y}`);for(let r=1;r<e-1;r++)t.push(S_(n[r-1],n[r],n[r+1],i));let o=n[e-1];return t.push(`L ${o.x+Af} ${o.y+Af}`),t.join(" ")}function S_(n,i,e,t){let o=i.x,r=i.y;if(t<=0)return`L ${o} ${r}`;let s=Math.abs(n.x-o)<=Rn&&Math.abs(o-e.x)<=Rn,a=Math.abs(n.y-r)<=Rn&&Math.abs(r-e.y)<=Rn;if(s||a)return`L ${o} ${r}`;let d=Math.hypot(o-n.x,r-n.y),l=Math.hypot(e.x-o,e.y-r),u=Math.min(d*.5,l*.5,t);if(u<b_)return`L ${o} ${r}`;if(Math.abs(n.y-r)<=Rn){let w=n.x<e.x?-1:1,I=n.y<e.y?1:-1,P=o+u*w,L=r+u*I;return`L ${P} ${r} Q ${o} ${r} ${o} ${L}`}let y=n.x<e.x?1:-1,C=n.y<e.y?-1:1,E=r+u*C,b=o+u*y;return`L ${o} ${E} Q ${o} ${r} ${b} ${r}`}var Lf={[R.LEFT]:M.initialize(-1,0),[R.RIGHT]:M.initialize(1,0),[R.TOP]:M.initialize(0,-1),[R.BOTTOM]:M.initialize(0,1),[R.AUTO]:M.initialize(0,0)},$l=class{handle({source:i,sourceSide:e,target:t,targetSide:o,waypoints:r,offset:s,radius:a}){let d=jd(i,t,r),l=[],u=[];for(let E=0;E<d.length-1;E++){let b=d[E],w=d[E+1],I=this._getPathPoints(b,e,w,o,s??0);l.push(I),u.push(...h_(I))}let g=m_(__(l)),y=g.length>1?g[g.length-2]:i,C=g.length>1?g[1]:t;return{path:I_(g,a??0),penultimatePoint:y,secondPoint:C,points:g,candidates:u}}_getPathPoints(i,e,t,o,r){let s=Lf[e],a=Lf[o],d={x:i.x+s.x*r,y:i.y+s.y*r},l={x:t.x+a.x*r,y:t.y+a.y*r},u=this._getDirection(d,e,l),g=u.x!==0?"x":"y",y=u[g],C=[],E=M.initialize(),b=M.initialize(),w=u_(i,t);if(s[g]*a[g]===-1){let I=[{x:w.x,y:d.y},{x:w.x,y:l.y}],P=[{x:d.x,y:w.y},{x:l.x,y:w.y}];s[g]===y?C=g==="x"?I:P:C=g==="x"?P:I}else C=y_({axis:g,source:i,target:t,sourceSide:e,targetSide:o,sourceGap:d,targetGap:l,sourceDir:s,targetDir:a,currentDir:y,offset:r,sourceGapOffset:E,targetGapOffset:b});return[i,{x:d.x+E.x,y:d.y+E.y},...C,{x:l.x+b.x,y:l.y+b.y},t]}_getDirection(i,e,t){return e===R.LEFT||e===R.RIGHT?i.x<t.x?M.initialize(1,0):M.initialize(-1,0):i.y<t.y?M.initialize(0,1):M.initialize(0,-1)}},zf=2e-4,Xl=class{handle(i){let e=jd(i.source,i.target,i.waypoints),t=e.length,o=e[0],r=`M ${o.x} ${o.y}`,s=new Array(t-1);for(let a=0;a<t-1;a++){let d=e[a],l=e[a+1],u=a===t-2,g=u?l.x+zf:l.x,y=u?l.y+zf:l.y;r+=` L ${g} ${y}`,s[a]={x:(d.x+l.x)*.5,y:(d.y+l.y)*.5}}return{path:r,candidates:s,points:e,secondPoint:e[1]??i.target,penultimatePoint:e[t-2]??i.source}}},D_=new ee("F_CONNECTION_BUILDERS"),gh=(()=>{class n{_builtinBuilders={[yt.STRAIGHT]:new Xl,[yt.BEZIER]:new Wl,[yt.ADAPTIVE_CURVE]:new Ul,[yt.SEGMENT]:new $l};_providedBuilders;_builders;constructor(){this._providedBuilders=c(D_,{optional:!0})||{},this._builders=J(J({},this._builtinBuilders),this._providedBuilders)}handle({type:e,payload:t}){let o=this._builders[e];if(!o)throw this._createBuilderNotFoundError(e);return o.handle(t)}_createBuilderNotFoundError(e){let t=Object.keys(this._builtinBuilders).sort(),o=Object.keys(this._providedBuilders).sort(),r=Object.keys(this._builders).sort(),s=t.filter(d=>d in this._providedBuilders).sort(),a=[`Connection Builder Error: builder type "${e}" not found.`,`Registered types: ${r.length?r.join(", "):"(none)"}`,`Built-in types: ${t.length?t.join(", "):"(none)"}`,`Provided (F_CONNECTION_BUILDERS) types: ${o.length?o.join(", "):"(none)"}`,s.length?`Overridden built-ins: ${s.join(", ")}`:null,"Tip: ensure you pass a valid Connection Type or provide a builder via F_CONNECTION_BUILDERS."].filter(Boolean);return new Error(a.join(`
|
|
2
|
-
`))}static \u0275fac=function(t){return new(t||n)};static \u0275prov=f({token:n,factory:n.\u0275fac})}return n})();function T_(n,i,e){return ut("connection_"+n+i+e)}function E_(n,i,e){return ut("connection_for_selection_"+n+i+e)}function ph(n){return ut("connection_gradient_"+n)}function P_(n){return`url(#${ph(n)})`}var M_=(()=>{class n{_connection=c(Hd);_hostElement=c(he).nativeElement;_injector=c(Ae);_hostAttributes=new Map;_startColor;_endColor;gradientId=G(()=>ph(this._connection.fId()));ngOnInit(){this._listenColorChanges()}_listenColorChanges(){Ie(()=>{this.gradient().fStartColor(),this.gradient().fEndColor(),Pt(()=>{this._updateGradient()})},{injector:this._injector})}get stop1Element(){return this._hostElement.children.item(0)}get stop2Element(){return this._hostElement.children.item(1)}redraw(e){let t=e.point2.x-e.point1.x,o=e.point2.y-e.point1.y,r=Math.sqrt(t*t+o*o)||.01,s=new j(.5-.5*t/r,.5-.5*o/r);this._setHostAttribute("x1",s.x.toString()),this._setHostAttribute("y1",s.y.toString());let a=new j(.5+.5*t/r,.5+.5*o/r);this._setHostAttribute("x2",a.x.toString()),this._setHostAttribute("y2",a.y.toString()),this._updateGradient()}_updateGradient(){let e=this.gradient();this._setFromColor(e.fStartColor()),this._setToColor(e.fEndColor())}_setFromColor(e){let t=e||"transparent";this._startColor!==t&&(this._startColor=t,this.stop1Element.setAttribute("stop-color",t),this.stop1Element.style.setProperty("stop-color",t))}_setToColor(e){let t=e||"transparent";this._endColor!==t&&(this._endColor=t,this.stop2Element.setAttribute("stop-color",t),this.stop2Element.style.setProperty("stop-color",t))}_setHostAttribute(e,t){this._hostAttributes.get(e)!==t&&(this._hostAttributes.set(e,t),this._hostElement.setAttribute(e,t))}static \u0275fac=function(t){return new(t||n)};static \u0275dir=_e({type:n,standalone:!1})}return n})(),ql=(()=>{class n extends M_{gradient=F.required({alias:"fConnectionGradientRendererFor"});static \u0275fac=(()=>{let e;return function(o){return(e||(e=X(n)))(o||n)}})();static \u0275cmp=se({type:n,selectors:[["linearGradient","fConnectionGradientRenderer",""]],hostVars:1,hostBindings:function(t,o){t&2&&te("id",o.gradientId())},inputs:{gradient:[1,"fConnectionGradientRendererFor","gradient"]},features:[ce],attrs:tp,decls:3,vars:0,consts:[[0,"xmlns","svg","http://www.w3.org/2000/svg"],["offset","0%"],["offset","100%"]],template:function(t,o){t&1&&(Pi(0,0),Ge(),Zt(1,"stop",1)(2,"stop",2),Mi())},encapsulation:2,changeDetection:0})}return n})(),Bf=new ee("F_CONNECTION_GRADIENT");var Yl=new ee("F_CONNECTION_PATH"),Kl=class{hostElement=c(he).nativeElement},R_=(()=>{class n extends Kl{_connection=c(Hd);useGradient=F(!1);linkToGradient=G(()=>this.useGradient()?P_(this._connection.fId()):null);get fPathId(){return this._connection.fId()}get attrConnectionId(){return T_(this._connection.fId(),this._connection.fOutputId(),this._connection.fInputId())}initialize(){this.deselect()}setPath(e){this.hostElement.setAttribute("d",`${e}`)}select(){this.hostElement.setAttribute("marker-start",`url(#${O_(this._connection.fId())})`),this.hostElement.setAttribute("marker-end",`url(#${F_(this._connection.fId())})`)}deselect(){this.hostElement.setAttribute("marker-start",`url(#${N_(this._connection.fId())})`),this.hostElement.setAttribute("marker-end",`url(#${k_(this._connection.fId())})`)}static \u0275fac=(()=>{let e;return function(o){return(e||(e=X(n)))(o||n)}})();static \u0275cmp=se({type:n,selectors:[["path","f-connection-path",""]],hostAttrs:[1,"f-component","f-connection-path"],hostVars:4,hostBindings:function(t,o){t&2&&(te("id",o.attrConnectionId)("data-f-path-id",o.fPathId),gt("stroke",o.linkToGradient()))},inputs:{useGradient:[1,"useGradient"]},standalone:!1,features:[be([{provide:Yl,useExisting:n}]),ce],attrs:np,decls:0,vars:0,template:function(t,o){},styles:["[_nghost-%COMP%]{fill:none;pointer-events:stroke}"],changeDetection:0})}return n})();function N_(n){return ut(`f-connection-marker-start-${n}`)}function k_(n){return ut(`f-connection-marker-end-${n}`)}function O_(n){return ut(`f-connection-selected-marker-start-${n}`)}function F_(n){return ut(`f-connection-selected-marker-end-${n}`)}var Zl=new ee("F_CONNECTION_SELECTION"),Ql=class{hostElement=c(he).nativeElement},A_=(()=>{class n extends Ql{_connection=c(Hd);get connectionForSelectionId(){return E_(this._connection.fId(),this._connection.fOutputId(),this._connection.fInputId())}setPath(e){this.hostElement.setAttribute("d",`${e}`)}static \u0275fac=(()=>{let e;return function(o){return(e||(e=X(n)))(o||n)}})();static \u0275cmp=se({type:n,selectors:[["path","fConnectionSelection",""]],hostAttrs:[1,"f-component","f-connection-selection"],hostVars:1,hostBindings:function(t,o){t&2&&te("id",o.connectionForSelectionId)},standalone:!1,features:[be([{provide:Zl,useExisting:n}]),ce],attrs:ip,decls:0,vars:0,template:function(t,o){},styles:["[_nghost-%COMP%]{fill:none;pointer-events:stroke}"],changeDetection:0})}return n})(),Jl=new ee("F_CONNECTION_DRAG_HANDLE_END"),eu=new ee("F_CONNECTION_DRAG_HANDLE_START"),Ea=class{hostElement=c(he).nativeElement;point=M.initialize();class="f-connection-drag-handle";calculateCircleCenter(i,e,t){let o={x:e.x-i.x,y:e.y-i.y},r=Math.sqrt(o.x*o.x+o.y*o.y)||1,s={x:o.x/r,y:o.y/r},a={x:s.x*t,y:s.y*t};return{x:e.x-a.x,y:e.y-a.y}}},L_=(()=>{class n extends Ea{redraw(e,t){this.point=this.calculateCircleCenter(e,t,8),this.hostElement.setAttribute("cx",this.point.x.toString()),this.hostElement.setAttribute("cy",this.point.y.toString())}static \u0275fac=(()=>{let e;return function(o){return(e||(e=X(n)))(o||n)}})();static \u0275cmp=se({type:n,selectors:[["circle","f-connection-drag-handle-start",""]],hostVars:2,hostBindings:function(t,o){t&2&&tt(o.class)},standalone:!1,features:[be([{provide:eu,useExisting:n}]),ce],attrs:op,decls:0,vars:0,template:function(t,o){},encapsulation:2,changeDetection:0})}return n})(),z_=(()=>{class n extends Ea{redraw(e,t){this.point=this.calculateCircleCenter(e,t,8),this.hostElement.setAttribute("cx",this.point.x.toString()),this.hostElement.setAttribute("cy",this.point.y.toString())}static \u0275fac=(()=>{let e;return function(o){return(e||(e=X(n)))(o||n)}})();static \u0275cmp=se({type:n,selectors:[["circle","f-connection-drag-handle-end",""]],hostVars:2,hostBindings:function(t,o){t&2&&tt(o.class)},standalone:!1,features:[be([{provide:Jl,useExisting:n}]),ce],attrs:rp,decls:0,vars:0,template:function(t,o){},encapsulation:2,changeDetection:0})}return n})(),Sl="f-selected";function _h(n){return class extends n{fId=oe("");fSelectionDisabled=oe(!1);unmarkAsSelected(){this.unmarkChildrenAsSelected?.(),this.hostElement.classList.remove(Sl)}markAsSelected(){this.markChildrenAsSelected?.(),this.isSelected()||this.hostElement.classList.add(Sl)}isSelected(){return this.hostElement.classList.contains(Sl)}markChildrenAsSelected(){}unmarkChildrenAsSelected(){}constructor(...i){super(...i)}}}function B_(n){return class extends n{show(){this.hostElement.style.display="unset"}hide(){this.hostElement.style.display="none"}constructor(...i){super(...i)}}}var G_=_h(B_(class{hostElement;constructor(n){this.hostElement=n}})),H_=(()=>{class n extends G_{_fConnectionBuilder=c(gh);path="";line=Pn.initialize();fReassignableStart=oe(!1);fDraggingDisabled=oe(!1);fSelectionDisabled=oe(!1);fDefs=ve.required("defs");fPath=ve.required(Yl);fDragHandleStart=ve(eu);fDragHandleEnd=ve.required(Jl);fSelection=ve.required(Zl);fContents=pl(Nf,{descendants:!0});fMarkers=pl(jl,{descendants:!0});fGradient=Ni(Bf);_fGradientRenderer=ve(ql);fWaypoints=Ni(kf);fInputSide=oe(ke.DEFAULT);_contentLayoutEngine=new Hl;_sourceSide=R.AUTO;fOutputSide=oe(ke.DEFAULT);_targetSide=R.AUTO;_penultimatePoint=M.initialize();_secondPoint=M.initialize();constructor(){super(c(he).nativeElement)}initialize(){this.redraw(),this.isSelected()?this.markChildrenAsSelected():this.unmarkChildrenAsSelected()}isContains(e){return(this.hostElement.firstChild?.lastChild).contains(e)||Array.from(this.fContents()?.values()??[]).some(t=>t.hostElement?.contains(e))||this.fWaypoints()?.hostElement?.contains(e)}setLine({point1:e,point2:t}){this.line=Pn.initialize(e,t);let{path:o,points:r,penultimatePoint:s,secondPoint:a,candidates:d}=this._getPathResult(e,t);this.path=o,this._penultimatePoint=s||e,this._secondPoint=a||t,this.fWaypoints()?.candidates.set(d||[]),this._contentLayoutEngine.layout(r||[],this._contents())}_contents(){return Array.from(this.fContents()?.values()??[])}_getPathResult(e,t){return this._fConnectionBuilder.handle({type:this.fType,payload:{source:e,sourceSide:this._sourceSide,target:t,targetSide:this._targetSide,radius:this.fRadius,offset:this.fOffset,waypoints:this.fWaypoints()?.waypoints()||[]}})}markChildrenAsSelected(){this.fPath().select()}unmarkChildrenAsSelected(){this.fPath().deselect()}redraw(){this.fPath().setPath(this.path),this.fSelection().setPath(this.path),this.fDragHandleEnd().redraw(this._penultimatePoint,this.line.point2),this.fDragHandleStart()?.redraw(this._secondPoint,this.line.point1),this._fGradientRenderer()?.redraw(this.line)}getResolvedSides(){return{sourceSide:this._sourceSide,targetSide:this._targetSide}}_applyResolvedSidesToConnection(e,t){this._sourceSide=e,this._targetSide=t}static \u0275fac=function(t){return new(t||n)};static \u0275dir=_e({type:n,contentQueries:function(t,o,r){t&1&&gl(r,o.fContents,Nf,5)(r,o.fMarkers,jl,5)(r,o.fGradient,Bf,5)(r,o.fWaypoints,kf,5),t&2&&We(4)},viewQuery:function(t,o){t&1&&ct(o.fDefs,sp,5)(o.fPath,Yl,5)(o.fDragHandleStart,eu,5)(o.fDragHandleEnd,Jl,5)(o.fSelection,Zl,5)(o._fGradientRenderer,ql,5),t&2&&We(6)},standalone:!1,features:[ce]})}return n})(),j_=(()=>{let n=class po{_browser=c(pe);_markerCache=new WeakMap;handle({connection:e}){let t=this._findConnectionMarkers(e),o=e.fDefs();if(!o)return!1;let r=V_(t),s=this._markerCache.get(e);if(s?.signature===r&&s.defsElement===o.nativeElement)return!1;let a=yh("defs",this._browser);return t.forEach(d=>{mh(d.type).forEach(l=>{let u=U_(l,d,e.fId(),this._browser),g=d.markerElement.cloneNode(!0);g.setAttribute("height",`${d.height}`),g.setAttribute("width",`${d.width}`),g.removeAttribute("markerUnits"),g.style.display="unset",u.append(g),a.append(u)})}),o.nativeElement.innerHTML=a.innerHTML,this._markerCache.set(e,{signature:r,defsElement:o.nativeElement}),this._makeSafariCompatible(e),!0}_findConnectionMarkers(e){return Array.from(e.fMarkers()??[])}_makeSafariCompatible(e){e.fPath().hostElement.replaceWith(e.fPath().hostElement)}static \u0275fac=function(t){return new(t||po)};static \u0275prov=f({token:po,factory:po.\u0275fac})};return n=p([_(cn)],n),n})();function V_(n){return n.map(i=>[...mh(i.type),i.width,i.height,i.refX,i.refY,i.orient,i.markerUnits,i.markerElement.outerHTML].join("|")).join("||")}function U_(n,i,e,t){let o=yh("marker",t);return o.setAttribute("id",ut(n+"-"+e)),o.setAttribute("markerHeight",`${i.height}`),o.setAttribute("markerWidth",`${i.width}`),o.setAttribute("orient",`${i.orient}`),o.setAttribute("refX",`${i.refX}`),o.setAttribute("refY",`${i.refY}`),o.setAttribute("markerUnits",`${i.markerUnits}`),o}function mh(n){switch(n){case ne.START:return[ne.START];case ne.END:return[ne.END];case ne.SELECTED_START:return[ne.SELECTED_START];case ne.SELECTED_END:return[ne.SELECTED_END];case ne.START_ALL_STATES:return[ne.START,ne.SELECTED_START];case ne.END_ALL_STATES:return[ne.END,ne.SELECTED_END];default:return[]}}function yh(n,i){return i.document.createElementNS("http://www.w3.org/2000/svg",n)}var Vd=(()=>{class n{renderTicket=0;_connectedInPreviousRender=new Set;beginRender(){return++this.renderTicket}resetConnectedConnectors(){for(let e of this._connectedInPreviousRender)e.resetConnected();this._connectedInPreviousRender.clear()}trackConnectedConnectors(e,t){this._connectedInPreviousRender.add(e),this._connectedInPreviousRender.add(t)}static \u0275fac=function(t){return new(t||n)};static \u0275prov=f({token:n,factory:n.\u0275fac})}return n})(),W_=String.raw`
|
|
3
|
-
const EPSILON = 0.5;
|
|
4
|
-
|
|
5
|
-
addEventListener('message', (event) => {
|
|
6
|
-
const data = event?.data;
|
|
7
|
-
const requestId = data?.requestId;
|
|
8
|
-
const items = Array.isArray(data?.items) ? data.items : [];
|
|
9
|
-
|
|
10
|
-
try {
|
|
11
|
-
const results = items.map((item) => calculateItem(item));
|
|
12
|
-
postMessage({ requestId, results });
|
|
13
|
-
} catch (error) {
|
|
14
|
-
const message = error instanceof Error ? error.message : 'Connection worker failed.';
|
|
15
|
-
postMessage({ requestId, error: message });
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
function calculateItem(item) {
|
|
20
|
-
const sourceCenterX = item.sourceRect.x + item.sourceRect.width / 2;
|
|
21
|
-
const sourceCenterY = item.sourceRect.y + item.sourceRect.height / 2;
|
|
22
|
-
const targetCenterX = item.targetRect.x + item.targetRect.width / 2;
|
|
23
|
-
const targetCenterY = item.targetRect.y + item.targetRect.height / 2;
|
|
24
|
-
|
|
25
|
-
const sourceSide = resolveConnectableSide(
|
|
26
|
-
item.outputSide,
|
|
27
|
-
targetCenterX - sourceCenterX,
|
|
28
|
-
targetCenterY - sourceCenterY,
|
|
29
|
-
item.sourceConnectableSide,
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
const targetSide = resolveConnectableSide(
|
|
33
|
-
item.inputSide,
|
|
34
|
-
sourceCenterX - targetCenterX,
|
|
35
|
-
sourceCenterY - targetCenterY,
|
|
36
|
-
item.targetConnectableSide,
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
if (item.behavior === 'fixed_center') {
|
|
40
|
-
return {
|
|
41
|
-
originalIndex: item.originalIndex,
|
|
42
|
-
supported: true,
|
|
43
|
-
sourceSide,
|
|
44
|
-
targetSide,
|
|
45
|
-
line: {
|
|
46
|
-
point1: { x: sourceCenterX, y: sourceCenterY },
|
|
47
|
-
point2: { x: targetCenterX, y: targetCenterY },
|
|
48
|
-
},
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
if (item.sourceRotation || item.targetRotation) {
|
|
53
|
-
return { originalIndex: item.originalIndex, supported: false };
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
if (item.behavior !== 'fixed') {
|
|
57
|
-
if (item.behavior !== 'floating') {
|
|
58
|
-
return { originalIndex: item.originalIndex, supported: false };
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
if (hasRoundedCorners(item.sourceRect) || hasRoundedCorners(item.targetRect)) {
|
|
62
|
-
return { originalIndex: item.originalIndex, supported: false };
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return {
|
|
66
|
-
originalIndex: item.originalIndex,
|
|
67
|
-
supported: true,
|
|
68
|
-
sourceSide,
|
|
69
|
-
targetSide,
|
|
70
|
-
line: buildFloatingLine(item.sourceRect, item.targetRect),
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const line = buildFixedLine(item.sourceRect, item.targetRect, sourceSide, targetSide);
|
|
75
|
-
if (!line) {
|
|
76
|
-
return { originalIndex: item.originalIndex, supported: false };
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
return {
|
|
80
|
-
originalIndex: item.originalIndex,
|
|
81
|
-
supported: true,
|
|
82
|
-
sourceSide,
|
|
83
|
-
targetSide,
|
|
84
|
-
line,
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function resolveConnectableSide(requestedSide, deltaX, deltaY, fallbackSide) {
|
|
89
|
-
if (requestedSide === 'default') {
|
|
90
|
-
return fallbackSide;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
const absX = Math.abs(deltaX);
|
|
94
|
-
const absY = Math.abs(deltaY);
|
|
95
|
-
const nearZero = absX < EPSILON && absY < EPSILON;
|
|
96
|
-
|
|
97
|
-
if (nearZero) {
|
|
98
|
-
return fallbackSide;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
const horizontalDominant = absX >= absY;
|
|
102
|
-
|
|
103
|
-
switch (requestedSide) {
|
|
104
|
-
case 'calculate':
|
|
105
|
-
return horizontalDominant ? (deltaX >= 0 ? 'right' : 'left') : deltaY >= 0 ? 'bottom' : 'top';
|
|
106
|
-
|
|
107
|
-
case 'calculate_horizontal':
|
|
108
|
-
if (absX < EPSILON) {
|
|
109
|
-
return fallbackSide;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
return deltaX >= 0 ? 'right' : 'left';
|
|
113
|
-
|
|
114
|
-
case 'calculate_vertical':
|
|
115
|
-
if (absY < EPSILON) {
|
|
116
|
-
return fallbackSide;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
return deltaY >= 0 ? 'bottom' : 'top';
|
|
120
|
-
|
|
121
|
-
case 'top':
|
|
122
|
-
case 'bottom':
|
|
123
|
-
case 'left':
|
|
124
|
-
case 'right':
|
|
125
|
-
return requestedSide;
|
|
126
|
-
|
|
127
|
-
default:
|
|
128
|
-
return fallbackSide;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
function buildFixedLine(sourceRect, targetRect, sourceSide, targetSide) {
|
|
133
|
-
const sourceAnchor = sourceSide === 'auto' ? 'bottom' : sourceSide;
|
|
134
|
-
const targetAnchor = targetSide === 'auto' ? 'top' : targetSide;
|
|
135
|
-
|
|
136
|
-
const point1 = getSidePoint(sourceRect, sourceAnchor);
|
|
137
|
-
const point2 = getSidePoint(targetRect, targetAnchor);
|
|
138
|
-
|
|
139
|
-
if (!point1 || !point2) {
|
|
140
|
-
return null;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
return { point1, point2 };
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
function buildFloatingLine(sourceRect, targetRect) {
|
|
147
|
-
const sourceCenter = getRectCenter(sourceRect);
|
|
148
|
-
const targetCenter = getRectCenter(targetRect);
|
|
149
|
-
|
|
150
|
-
return {
|
|
151
|
-
point1: getRectBorderIntersection(sourceRect, sourceCenter, targetCenter),
|
|
152
|
-
point2: getRectBorderIntersection(targetRect, targetCenter, sourceCenter),
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
function hasRoundedCorners(rect) {
|
|
157
|
-
return !!(rect.radius1 || rect.radius2 || rect.radius3 || rect.radius4);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
function getRectCenter(rect) {
|
|
161
|
-
return {
|
|
162
|
-
x: rect.x + rect.width / 2,
|
|
163
|
-
y: rect.y + rect.height / 2,
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
function getRectBorderIntersection(rect, from, to) {
|
|
168
|
-
const halfWidth = rect.width / 2;
|
|
169
|
-
const halfHeight = rect.height / 2;
|
|
170
|
-
const center = getRectCenter(rect);
|
|
171
|
-
|
|
172
|
-
const dx = to.x - from.x;
|
|
173
|
-
const dy = to.y - from.y;
|
|
174
|
-
|
|
175
|
-
if (Math.abs(dx) < EPSILON && Math.abs(dy) < EPSILON) {
|
|
176
|
-
return center;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
const scaleX = Math.abs(dx) < EPSILON ? Number.POSITIVE_INFINITY : halfWidth / Math.abs(dx);
|
|
180
|
-
const scaleY = Math.abs(dy) < EPSILON ? Number.POSITIVE_INFINITY : halfHeight / Math.abs(dy);
|
|
181
|
-
const scale = Math.min(scaleX, scaleY);
|
|
182
|
-
|
|
183
|
-
return {
|
|
184
|
-
x: center.x + dx * scale,
|
|
185
|
-
y: center.y + dy * scale,
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
function getSidePoint(rect, side) {
|
|
190
|
-
const centerX = rect.x + rect.width / 2;
|
|
191
|
-
const centerY = rect.y + rect.height / 2;
|
|
192
|
-
|
|
193
|
-
switch (side) {
|
|
194
|
-
case 'top':
|
|
195
|
-
return { x: centerX, y: rect.y };
|
|
196
|
-
|
|
197
|
-
case 'right':
|
|
198
|
-
return { x: rect.x + rect.width, y: centerY };
|
|
199
|
-
|
|
200
|
-
case 'bottom':
|
|
201
|
-
return { x: centerX, y: rect.y + rect.height };
|
|
202
|
-
|
|
203
|
-
case 'left':
|
|
204
|
-
return { x: rect.x, y: centerY };
|
|
205
|
-
|
|
206
|
-
default:
|
|
207
|
-
return null;
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
`.trim();function vh(n){return!!Ch(n)}function Ch(n){let i=n,e=i?.Blob,t=i?.Worker,o=i?.URL;return!e||!t||typeof o?.createObjectURL!="function"||typeof o.revokeObjectURL!="function"?null:{blobCtor:e,workerCtor:t,urlApi:o}}function $_(n){let i=new n.blobCtor([W_],{type:"text/javascript"});return n.urlApi.createObjectURL(i)}function xh(n,i){if(!n)return;let e=i??(typeof URL>"u"?null:URL);typeof e?.revokeObjectURL=="function"&&e.revokeObjectURL(n)}var $t=(()=>{class n{worker=null;workerUrl=null;nextRequestId=0;isDisabled=!1;pending=new Map;resetRuntime(e){this.pending.forEach(t=>t.reject(e)),this.pending.clear(),this.worker?.terminate(),this.worker=null,xh(this.workerUrl),this.workerUrl=null}dispose(){this.resetRuntime(new Error("Connection worker was destroyed."))}static \u0275fac=function(t){return new(t||n)};static \u0275prov=f({token:n,factory:n.\u0275fac})}return n})(),Pa=class{connection;line;static fToken=Symbol("ApplyConnectionRenderRequest");constructor(i,e){this.connection=i,this.line=e}},X_=(()=>{let n=class _o{_mediator=c(D);_renderCache=new WeakMap;handle({connection:e,line:t}){!this._mediator.execute(new cn(e))&&!this._shouldRender(e,t)||(e.setLine(t),e.initialize())}_shouldRender(e,t){let o=e.fPath().hostElement,r=this._createConnectionRenderSignature(e,t),s=this._renderCache.get(e);return s?.signature===r&&s.pathElement===o?!1:(this._renderCache.set(e,{signature:r,pathElement:o}),!0)}_createConnectionRenderSignature(e,t){let{sourceSide:o,targetSide:r}=e.getResolvedSides();return[e.fBehavior,e.fType,e.fRadius,e.fOffset,e.fReassignableStart(),this._serializeContents([...e.fContents()||[]]),o,r,this._serializePoint(t.point1),this._serializePoint(t.point2),this._serializeWaypoints(e.fWaypoints()?.waypoints()||[])].join("|")}_serializePoint(e){return`${e.x}:${e.y}`}_serializeWaypoints(e){return e.map(this._serializePoint).join(";")}_serializeContents(e){return e.map(t=>[t.position(),t.offset(),t.align()].join(":")).join(";")}static \u0275fac=function(t){return new(t||_o)};static \u0275prov=f({token:_o,factory:_o.\u0275fac})};return n=p([_(Pa)],n),n})(),Ma=class{source;target;static fToken=Symbol("MarkConnectionConnectorsAsConnectedRequest");constructor(i,e){this.source=i,this.target=e}},q_=(()=>{let n=class mo{_state=c(Vd);handle({source:e,target:t}){e.setConnected(t),t.setConnected(e),this._state.trackConnectedConnectors(e,t)}static \u0275fac=function(t){return new(t||mo)};static \u0275prov=f({token:mo,factory:mo.\u0275fac})};return n=p([_(Ma)],n),n})(),wt=class{element;cache;static fToken=Symbol("GetNormalizedConnectorRectRequest");constructor(i,e=!0){this.element=i,this.cache=e}},Y_={enabled:!1},ot=new ee("F_CACHE_OPTIONS",{providedIn:"root",factory:()=>J({},Y_)});var Ra=class{id;nodeId;kind;element;static fToken=Symbol("RegisterFCacheConnectorRequest");constructor(i,e,t,o){this.id=i,this.nodeId=e,this.kind=t,this.element=o}},rt=(()=>{class n{nodeEntries=new Map;nodeIdByElement=new WeakMap;connectorEntries=new Map;connectorKeysByNodeId=new Map;connectorKeyByElement=new WeakMap;static \u0275fac=function(t){return new(t||n)};static \u0275prov=f({token:n,factory:n.\u0275fac})}return n})(),tu=class{key;id;kind;nodeId;element;rect;constructor(i,e,t,o,r,s){this.key=i,this.id=e,this.kind=t,this.nodeId=o,this.element=r,this.rect=s}},Fn=class{static build(i,e){return`${i}:${e}`}},nu=class{id;element;reference;rect;constructor(i,e,t,o){this.id=i,this.element=e,this.reference=t,this.rect=o}},dn=class{nodeId;reason;static fToken=Symbol("InvalidateFCacheNodeRequest");constructor(i,e="manual"){this.nodeId=i,this.reason=e}},K_=(()=>{let n=class yo{_store=c(rt);_options=c(ot);handle({nodeId:e,reason:t}){if(!this._options.enabled)return;let o=this._store.nodeEntries.get(e);if(!o)return;o.rect=void 0;let r=this._store.connectorKeysByNodeId.get(e);if(r?.size)for(let s of r){let a=this._store.connectorEntries.get(s);a&&(a.rect=void 0)}}static \u0275fac=function(t){return new(t||yo)};static \u0275prov=f({token:yo,factory:yo.\u0275fac})};return n=p([_(dn)],n),n})(),Na=class{id;element;reference;static fToken=Symbol("RegisterFCacheNodeRequest");constructor(i,e,t){this.id=i,this.element=e,this.reference=t}},Z_=(()=>{let n=class vo{_store=c(rt);_options=c(ot);handle({id:e,element:t,reference:o}){if(!this._options.enabled)return;let r=new nu(e,t,o);this._store.nodeEntries.set(e,r),this._store.nodeIdByElement.set(t,e),this._store.connectorKeysByNodeId.set(e,this._store.connectorKeysByNodeId.get(e)??new Set)}static \u0275fac=function(t){return new(t||vo)};static \u0275prov=f({token:vo,factory:vo.\u0275fac})};return n=p([_(Na)],n),n})(),ka=class{id;static fToken=Symbol("UnregisterFCacheNodeRequest");constructor(i){this.id=i}},Q_=(()=>{let n=class Co{_store=c(rt);_mediator=c(D);_options=c(ot);handle({id:e}){if(!this._options.enabled)return;let t=this._store.nodeEntries.get(e);if(!t)return;this._store.nodeEntries.delete(e),this._store.nodeIdByElement.delete(t.element);let o=Array.from(this._store.connectorKeysByNodeId.get(e)??[]);for(let r of o){let s=this._store.connectorEntries.get(r);s&&this._mediator.execute(new An(s.id,s.kind))}this._store.connectorKeysByNodeId.delete(e)}static \u0275fac=function(t){return new(t||Co)};static \u0275prov=f({token:Co,factory:Co.\u0275fac})};return n=p([_(ka)],n),n})(),J_=(()=>{let n=class xo{_store=c(rt);_mediator=c(D);_options=c(ot);handle({id:e,nodeId:t,kind:o,element:r}){if(!this._options.enabled)return;let s=Fn.build(e,o),a=this._store.connectorEntries.get(s);a&&(this._detachConnectorFromNode(a.key,a.nodeId),this._store.connectorKeyByElement.delete(a.element));let d=new tu(s,e,o,t,r);this._store.connectorEntries.set(s,d),this._store.connectorKeyByElement.set(r,s);let l=this._store.connectorKeysByNodeId.get(t)??new Set;l.add(s),this._store.connectorKeysByNodeId.set(t,l),this._mediator.execute(new dn(t,"connector-registered"))}_detachConnectorFromNode(e,t){let o=this._store.connectorKeysByNodeId.get(t);o&&(o.delete(e),o.size||this._store.connectorKeysByNodeId.delete(t))}static \u0275fac=function(t){return new(t||xo)};static \u0275prov=f({token:xo,factory:xo.\u0275fac})};return n=p([_(Ra)],n),n})(),An=class{connectorId;kind;static fToken=Symbol("UnregisterFCacheConnectorRequest");constructor(i,e){this.connectorId=i,this.kind=e}},em=(()=>{let n=class wo{_store=c(rt);_mediator=c(D);_options=c(ot);handle({connectorId:e,kind:t}){if(!this._options.enabled)return;let o=Fn.build(e,t),r=this._store.connectorEntries.get(o);r&&(this._store.connectorEntries.delete(o),this._store.connectorKeyByElement.delete(r.element),this._detachConnectorFromNode(o,r.nodeId),this._store.nodeEntries.has(r.nodeId)&&this._mediator.execute(new dn(r.nodeId,"connector-unregistered")))}_detachConnectorFromNode(e,t){let o=this._store.connectorKeysByNodeId.get(t);o&&(o.delete(e),o.size||this._store.connectorKeysByNodeId.delete(t))}static \u0275fac=function(t){return new(t||wo)};static \u0275prov=f({token:wo,factory:wo.\u0275fac})};return n=p([_(An)],n),n})(),ln=class{element;static fToken=Symbol("GetCachedFCacheRectRequest");constructor(i){this.element=i}},tm=(()=>{let n=class bo{_store=c(rt);_options=c(ot);handle({element:e}){if(!this._options.enabled)return;let t=this._store.nodeIdByElement.get(e);if(t){let r=this._store.nodeEntries.get(t)?.rect;if(r)return r}let o=this._store.connectorKeyByElement.get(e);if(o)return this._store.connectorEntries.get(o)?.rect??void 0}static \u0275fac=function(t){return new(t||bo)};static \u0275prov=f({token:bo,factory:bo.\u0275fac})};return n=p([_(ln)],n),n})(),Bt=class{connectorId;kind;rect;static fToken=Symbol("SetFCacheConnectorRectRequest");constructor(i,e,t){this.connectorId=i,this.kind=e,this.rect=t}},nm=(()=>{let n=class Io{_store=c(rt);_options=c(ot);handle({connectorId:e,kind:t,rect:o}){if(!this._options.enabled)return;let r=Fn.build(e,t),s=this._store.connectorEntries.get(r);s&&(s.rect=ge.fromRoundedRect(o))}static \u0275fac=function(t){return new(t||Io)};static \u0275prov=f({token:Io,factory:Io.\u0275fac})};return n=p([_(Bt)],n),n})(),Gt=class{nodeId;rect;static fToken=Symbol("SetFCacheNodeRectRequest");constructor(i,e){this.nodeId=i,this.rect=e}},im=(()=>{let n=class So{_store=c(rt);_options=c(ot);handle({nodeId:e,rect:t}){if(!this._options.enabled)return;let o=this._store.nodeEntries.get(e);if(!o)return;let r=o.rect;o.rect=z.initialize(t.x,t.y,t.width,t.height),r&&this._updateConnectorRectsByNodeRect(e,r,o.rect)}_updateConnectorRectsByNodeRect(e,t,o){let r=this._store.connectorKeysByNodeId.get(e);if(!r?.size)return;let s=o.x-t.x,a=o.y-t.y,d=t.width!==0,l=t.height!==0,u=d?o.width/t.width:1,g=l?o.height/t.height:1;for(let y of r){let C=this._store.connectorEntries.get(y);if(!C?.rect)continue;let E=C.rect,b=E.gravityCenter,w=d?o.x+(b.x-t.x)*u:b.x+s,I=l?o.y+(b.y-t.y)*g:b.y+a;C.rect=new ge(w-E.width/2,I-E.height/2,E.width,E.height,E.radius1,E.radius2,E.radius3,E.radius4)}}static \u0275fac=function(t){return new(t||So)};static \u0275prov=f({token:So,factory:So.\u0275fac})};return n=p([_(Gt)],n),n})(),Ln=class{element;rect;static fToken=Symbol("UpdateFCacheRectByElementRequest");constructor(i,e){this.element=i,this.rect=e}},om=(()=>{let n=class Do{_store=c(rt);_options=c(ot);handle({element:e,rect:t}){if(!this._options.enabled)return;let o=this._store.nodeIdByElement.get(e);if(o){let a=this._store.nodeEntries.get(o);a&&(a.rect=t);return}let r=this._store.connectorKeyByElement.get(e);if(!r)return;let s=this._store.connectorEntries.get(r);s&&(s.rect=t)}static \u0275fac=function(t){return new(t||Do)};static \u0275prov=f({token:Do,factory:Do.\u0275fac})};return n=p([_(Ln)],n),n})(),rm=[rt,Z_,Q_,K_,J_,em,tm,im,nm,om];function xn(n,i,e){return i?j.fromPoint(n).elementTransform(i).sub(e.scaledPosition).sub(e.position).div(e.scale):j.fromPoint(n)}function wh(){return{min:{x:-1/0,y:-1/0},max:{x:1/0,y:1/0}}}function un(n){return n?`${n}`:void 0}var sm=(()=>{let n=class To{_store=c(x);_mediator=c(D);_browser=c(pe);get _transform(){return this._store.transform}handle({element:e,cache:t}){let o=this._mediator.execute(new ln(e));if(o&&t)return o;let r=this._getElementRoundedRect(e),s=this._normalizePosition(r),a=this._unscaleSize(r),d=this._getUnscaledRect(s,a,r),l=this._getOffsetSize(e,a),u=ge.fromCenter(d,l.width,l.height);return this._mediator.execute(new Ln(e,u)),u}_getElementRoundedRect(e){return this._getRoundedRect(z.fromElement(e),e,this._getComputedStyle(e))}_getRoundedRect(e,t,o){let[r,s,a,d]=this._normalizeCircularBorderRadii(e.width,e.height,[this._getSystemRadius(o.borderTopLeftRadius,t,o.fontSize),this._getSystemRadius(o.borderTopRightRadius,t,o.fontSize),this._getSystemRadius(o.borderBottomRightRadius,t,o.fontSize),this._getSystemRadius(o.borderBottomLeftRadius,t,o.fontSize)]);return new ge(e.x,e.y,e.width,e.height,r,s,a,d)}_getComputedStyle(e){return this._browser.window.getComputedStyle(e)}_toPixels(e,t,o){return this._browser.toPixels(e,t.clientWidth,t.clientHeight,o)||0}_getSystemRadius(e,t,o){return this._toPixels(e,t,o)*this._transform.scale}_normalizeCircularBorderRadii(e,t,o){let[r,s,a,d]=o.map(u=>Math.max(0,u)),l=Math.min(1,this._getRadiusScaleFactor(e,r+s),this._getRadiusScaleFactor(t,s+a),this._getRadiusScaleFactor(e,a+d),this._getRadiusScaleFactor(t,d+r));return[r*l,s*l,a*l,d*l]}_getRadiusScaleFactor(e,t){return t<=0?1:e<=0?0:e/t}_normalizePosition(e){return xn(e,this._store.flowHost,this._transform)}_unscaleSize(e){return Xe.initialize(e.width/this._transform.scale,e.height/this._transform.scale)}_getUnscaledRect(e,t,o){return new ge(e.x,e.y,t.width,t.height,this._unscaleRadius(o.radius1),this._unscaleRadius(o.radius2),this._unscaleRadius(o.radius3),this._unscaleRadius(o.radius4))}_unscaleRadius(e){return e/this._transform.scale}_getOffsetSize(e,t){return Xe.offsetFromElement(e)||t}static \u0275fac=function(t){return new(t||To)};static \u0275prov=f({token:To,factory:To.\u0275fac})};return n=p([_(wt)],n),n})(),Oa=class{connector;cache;static fToken=Symbol("ResolveConnectionEndpointRectRequest");constructor(i,e){this.connector=i,this.cache=e}},am=(()=>{let n=class Eo{_mediator=c(D);handle({connector:e,cache:t}){let o=this._buildCacheKey(e),r=t.get(o)??this._calculateRect(e);return t.set(o,r),r}_buildCacheKey(e){return`${e.kind}::${e.fId()}`}_calculateRect(e){return this._mediator.execute(new wt(e.hostElement))}static \u0275fac=function(t){return new(t||Eo)};static \u0275prov=f({token:Eo,factory:Eo.\u0275fac})};return n=p([_(Oa)],n),n})(),Fa=class{connection;static fToken=Symbol("ResolveConnectionEndpointsRequest");constructor(i){this.connection=i}},cm=(()=>{let n=class Po{_store=c(x);handle({connection:e}){let t=this._store.outputs.get(e.fOutputId()),o=this._store.inputs.get(e.fInputId());return!t||!o?null:{source:t,target:o}}static \u0275fac=function(t){return new(t||Po)};static \u0275prov=f({token:Po,factory:Po.\u0275fac})};return n=p([_(Fa)],n),n})(),zn=class{connection;cache;static fToken=Symbol("ResolveConnectionGeometryRequest");constructor(i,e){this.connection=i,this.cache=e}},dm=(()=>{let n=class Mo{_mediator=c(D);handle({connection:e,cache:t}){let o=this._resolveConnectionEndpoints(e);return o?fl(J({},o),{sourceRect:this._resolveEndpointRect(o.source,t),targetRect:this._resolveEndpointRect(o.target,t)}):null}_resolveConnectionEndpoints(e){return this._mediator.execute(new Fa(e))}_resolveEndpointRect(e,t){return this._mediator.execute(new Oa(e,t))}static \u0275fac=function(t){return new(t||Mo)};static \u0275prov=f({token:Mo,factory:Mo.\u0275fac})};return n=p([_(zn)],n),n})(),de=class{element;static fToken=Symbol("GetNormalizedElementRectRequest");constructor(i){this.element=i}},lm=(()=>{let n=class Ro{_store=c(x);_mediator=c(D);get _transform(){return this._store.transform}handle({element:e}){let t=this._mediator.execute(new ln(e));if(t)return t;let o=z.fromElement(e),r=this._normalizePosition(o),s=this._unscaleSize(o),a=this._getUnscaledRect(r,s),d=this._getOffsetSize(e,s),l=this._fromCenter(a,d.width,d.height);return this._mediator.execute(new Ln(e,l)),l}_fromCenter(e,t,o){return z.initialize(e.gravityCenter.x-t/2,e.gravityCenter.y-o/2,t,o)}_normalizePosition(e){return xn(e,this._store.flowHost,this._transform)}_unscaleSize(e){return Xe.initialize(e.width/this._transform.scale,e.height/this._transform.scale)}_getUnscaledRect(e,t){return new ge(e.x,e.y,t.width,t.height)}_getOffsetSize(e,t){return Xe.offsetFromElement(e)||t}static \u0275fac=function(t){return new(t||Ro)};static \u0275prov=f({token:Ro,factory:Ro.\u0275fac})};return n=p([_(de)],n),n})(),ht=class{connector;static fToken=Symbol("ResolveConnectionEndpointRotationContextRequest");constructor(i){this.connector=i}},um=(()=>{let n=class No{_store=c(x);_mediator=c(D);handle({connector:e}){if(!e)return;let t=this._store.nodes.get(e.fNodeId);if(!t||!t._rotate)return;let o=this._mediator.execute(new de(t.hostElement));return{rotationDeg:t._rotate,pivot:o.gravityCenter}}static \u0275fac=function(t){return new(t||No)};static \u0275prov=f({token:No,factory:No.\u0275fac})};return n=p([_(ht)],n),n})(),Aa=class{connection;geometry;static fToken=Symbol("BuildConnectionLineRequest");constructor(i,e){this.connection=i,this.geometry=e}},fm=(()=>{let n=class ko{_mediator=c(D);_connectionBehaviour=c(Cn);handle({connection:e,geometry:t}){return this._connectionBehaviour.handle(new Ye(t.sourceRect,t.targetRect,e,t.source.fConnectableSide,t.target.fConnectableSide,this._resolveRotationContext(t.source),this._resolveRotationContext(t.target)))}_resolveRotationContext(e){return this._mediator.execute(new ht(e))}static \u0275fac=function(t){return new(t||ko)};static \u0275prov=f({token:ko,factory:ko.\u0275fac})};return n=p([_(Aa)],n),n})(),Bn=class{connection;source;target;line;static fToken=Symbol("RenderConnectionWithLineRequest");constructor(i,e,t,o){this.connection=i,this.source=e,this.target=t,this.line=o}},hm=(()=>{let n=class Oo{_mediator=c(D);handle({connection:e,source:t,target:o,line:r}){this._mediator.execute(new Ma(t,o)),this._mediator.execute(new Pa(e,r))}static \u0275fac=function(t){return new(t||Oo)};static \u0275prov=f({token:Oo,factory:Oo.\u0275fac})};return n=p([_(Bn)],n),n})(),Gn=class{connection;geometry;static fToken=Symbol("RenderConnectionFromGeometryRequest");constructor(i,e){this.connection=i,this.geometry=e}},gm=(()=>{let n=class Fo{_mediator=c(D);handle({connection:e,geometry:t}){let o=this._mediator.execute(new Aa(e,t));this._mediator.execute(new Bn(e,t.source,t.target,o))}static \u0275fac=function(t){return new(t||Fo)};static \u0275prov=f({token:Fo,factory:Fo.\u0275fac})};return n=p([_(Gn)],n),n})(),La=class{connection;cache;static fToken=Symbol("RenderConnectionRequest");constructor(i,e){this.connection=i,this.cache=e}},pm=(()=>{let n=class Ao{_mediator=c(D);handle({connection:e,cache:t}){let o=this._mediator.execute(new zn(e,t));o&&this._mediator.execute(new Gn(e,o))}static \u0275fac=function(t){return new(t||Ao)};static \u0275prov=f({token:Ao,factory:Ao.\u0275fac})};return n=p([_(La)],n),n})(),Ht=class{session;static fToken=Symbol("IsConnectionRedrawCurrentRequest");constructor(i){this.session=i}},_m=(()=>{let n=class Lo{_store=c(x);_state=c(Vd);handle({session:e}){return e.renderTicket===this._state.renderTicket&&e.nodesRevision===this._store.nodesRevision}static \u0275fac=function(t){return new(t||Lo)};static \u0275prov=f({token:Lo,factory:Lo.\u0275fac})};return n=p([_(Ht)],n),n})(),Hn=class{session;static fToken=Symbol("CompleteConnectionRedrawRequest");constructor(i){this.session=i}},mm=(()=>{let n=class zo{_mediator=c(D);_store=c(x);handle({session:e}){this._mediator.execute(new Ht(e))&&this._store.completeConnectionsRender(e.connectionsRevision,e.nodesRevision)}static \u0275fac=function(t){return new(t||zo)};static \u0275prov=f({token:zo,factory:zo.\u0275fac})};return n=p([_(Hn)],n),n})(),za=class{batchItem;result;static fToken=Symbol("ApplyConnectionWorkerResultRequest");constructor(i,e){this.batchItem=i,this.result=e}},ym=(()=>{let n=class Bo{_mediator=c(D);handle({batchItem:e,result:t}){if(e){if(!this._isSupportedWorkerResult(t)){this._fallbackToMainThread(e);return}try{e.connection._applyResolvedSidesToConnection(t.sourceSide,t.targetSide),this._mediator.execute(new Bn(e.connection,e.geometry.source,e.geometry.target,t.line))}catch{this._fallbackToMainThread(e)}}}_fallbackToMainThread(e){this._mediator.execute(new Gn(e.connection,e.geometry))}_isSupportedWorkerResult(e){return!!(e?.supported&&e.sourceSide&&e.targetSide&&e.line)}static \u0275fac=function(t){return new(t||Bo)};static \u0275prov=f({token:Bo,factory:Bo.\u0275fac})};return n=p([_(za)],n),n})(),Ct=class{connections;cache;startIndex;session;batchItems;workerResults;static fToken=Symbol("RunConnectionRedrawSliceRequest");constructor(i,e,t,o,r,s){this.connections=i,this.cache=e,this.startIndex=t,this.session=o,this.batchItems=r,this.workerResults=s}},vm=500,Cm=6,xm=(()=>{let n=class Go{_mediator=c(D);_browser=c(pe);handle({connections:e,cache:t,startIndex:o,session:r,batchItems:s,workerResults:a}){if(!this._isCurrent(r))return;let d=this._now(),l=o,u=0;for(;l<e.length&&u<vm&&this._isWithinSliceBudget(d);){let g=e[l];if(s?this._mediator.execute(new za(s[l]??null,a?.[l])):this._mediator.execute(new La(g,t)),l++,u++,!this._isCurrent(r))return}if(l>=e.length){this._mediator.execute(new Hn(r));return}this._requestAnimationFrame(()=>this._mediator.execute(new Ct(e,t,l,r,s,a)))}_isCurrent(e){return this._mediator.execute(new Ht(e))}_requestAnimationFrame(e){let t=this._browser.document.defaultView;if(!t){e();return}t.requestAnimationFrame(e)}_now(){let e=this._browser.document.defaultView?.performance;return e?e.now():Date.now()}_isWithinSliceBudget(e){return this._browser.isBrowser()?this._now()-e<Cm:!0}static \u0275fac=function(t){return new(t||Go)};static \u0275prov=f({token:Go,factory:Go.\u0275fac})};return n=p([_(Ct)],n),n})(),Ba=class{static fToken=Symbol("StartConnectionRedrawRequest")},wm=(()=>{let n=class Ho{_store=c(x);_state=c(Vd);handle(e){return this._state.resetConnectedConnectors(),{renderTicket:this._state.beginRender(),connectionsRevision:this._store.connectionsRevision,nodesRevision:this._store.nodesRevision}}static \u0275fac=function(t){return new(t||Ho)};static \u0275prov=f({token:Ho,factory:Ho.\u0275fac})};return n=p([_(Ba)],n),n})(),jn=class{static fToken=Symbol("RedrawConnectionsRequest")},Ga=class{connectionCount;static fToken=Symbol("ShouldUseConnectionWorkerRequest");constructor(i){this.connectionCount=i}},Vn=class{static fToken=Symbol("IsConnectionWorkerEnabledRequest")},bm=(()=>{let n=class jo{_browser=c(pe);_state=c($t);handle(e){if(this._state.isDisabled||!this._isWorkerAvailable())return!1;let t=this._browser.document.defaultView;return vh(t)}_isWorkerAvailable(){return this._browser.isBrowser()}static \u0275fac=function(t){return new(t||jo)};static \u0275prov=f({token:jo,factory:jo.\u0275fac})};return n=p([_(Vn)],n),n})(),Im=(()=>{let n=class Vo{_mediator=c(D);handle({connectionCount:e}){return e>0&&this._mediator.execute(new Vn)}static \u0275fac=function(t){return new(t||Vo)};static \u0275prov=f({token:Vo,factory:Vo.\u0275fac})};return n=p([_(Ga)],n),n})(),Ha=class{connection;geometry;originalIndex;static fToken=Symbol("BuildConnectionWorkerPayloadItemRequest");constructor(i,e,t){this.connection=i,this.geometry=e,this.originalIndex=t}},Sm=(()=>{let n=class Uo{_store=c(x);handle({connection:e,geometry:t,originalIndex:o}){let{source:r,target:s,sourceRect:a,targetRect:d}=t;return{originalIndex:o,behavior:e.fBehavior,outputSide:e.fOutputSide(),inputSide:e.fInputSide(),sourceConnectableSide:r.fConnectableSide,targetConnectableSide:s.fConnectableSide,sourceRotation:this._store.nodes.get(r.fNodeId)?._rotate||0,targetRotation:this._store.nodes.get(s.fNodeId)?._rotate||0,sourceRect:{x:a.x,y:a.y,width:a.width,height:a.height,radius1:a.radius1,radius2:a.radius2,radius3:a.radius3,radius4:a.radius4},targetRect:{x:d.x,y:d.y,width:d.width,height:d.height,radius1:d.radius1,radius2:d.radius2,radius3:d.radius3,radius4:d.radius4}}}static \u0275fac=function(t){return new(t||Uo)};static \u0275prov=f({token:Uo,factory:Uo.\u0275fac})};return n=p([_(Ha)],n),n})(),ja=class{connections;cache;static fToken=Symbol("BuildConnectionWorkerBatchRequest");constructor(i,e){this.connections=i,this.cache=e}},Dm=(()=>{let n=class Wo{_mediator=c(D);handle({connections:e,cache:t}){let o=new Array(e.length),r=[];for(let s=0;s<e.length;s++){let a=this._buildBatchItem(e[s],t,s);o[s]=a,a&&r.push(a.payload)}return{items:o,payload:r}}_buildBatchItem(e,t,o){let r=this._mediator.execute(new zn(e,t));return r?{connection:e,geometry:r,payload:this._mediator.execute(new Ha(e,r,o))}:null}static \u0275fac=function(t){return new(t||Wo)};static \u0275prov=f({token:Wo,factory:Wo.\u0275fac})};return n=p([_(ja)],n),n})(),Va=class{error;static fToken=Symbol("DisableConnectionWorkerRequest");constructor(i){this.error=i}},Un=class{error;static fToken=Symbol("ResetConnectionWorkerRuntimeRequest");constructor(i){this.error=i}},Tm=(()=>{let n=class $o{_state=c($t);handle({error:e}){this._state.resetRuntime(e)}static \u0275fac=function(t){return new(t||$o)};static \u0275prov=f({token:$o,factory:$o.\u0275fac})};return n=p([_(Un)],n),n})(),Em=(()=>{let n=class Xo{_state=c($t);_mediator=c(D);handle({error:e}){this._state.isDisabled=!0,this._mediator.execute(new Un(e))}static \u0275fac=function(t){return new(t||Xo)};static \u0275prov=f({token:Xo,factory:Xo.\u0275fac})};return n=p([_(Va)],n),n})(),Ua=class{message;static fToken=Symbol("HandleConnectionWorkerMessageRequest");constructor(i){this.message=i}},Pm=(()=>{let n=class qo{_state=c($t);handle({message:e}){if(!e||typeof e.requestId!="number")return;let t=this._state.pending.get(e.requestId);if(t){if(this._state.pending.delete(e.requestId),e.error){t.reject(new Error(e.error));return}t.resolve(e.results??[])}}static \u0275fac=function(t){return new(t||qo)};static \u0275prov=f({token:qo,factory:qo.\u0275fac})};return n=p([_(Ua)],n),n})(),Wa=class{static fToken=Symbol("EnsureConnectionWorkerRequest")},Mm=(()=>{let n=class Yo{_browser=c(pe);_state=c($t);_mediator=c(D);handle(e){if(this._state.worker)return this._state.worker;let t=this._browser.document.defaultView;if(!vh(t))return null;let o=Ch(t);if(!o)return null;let r=$_(o);try{let s=new o.workerCtor(r,{name:"f-flow-connection-worker"});return s.onmessage=a=>{this._mediator.execute(new Ua(a.data))},s.onerror=()=>{this._resetWorkerAfterRuntimeError(new Error("Connection worker runtime error."))},s.onmessageerror=()=>{this._resetWorkerAfterRuntimeError(new Error("Connection worker message deserialization error."))},this._state.workerUrl=r,this._state.worker=s,s}catch(s){return xh(r,o.urlApi),this._disableWorker(s instanceof Error?s:new Error("Connection worker initialization failed.")),null}}_disableWorker(e){this._mediator.execute(new Va(e))}_resetWorkerAfterRuntimeError(e){this._mediator.execute(new Un(e))}static \u0275fac=function(t){return new(t||Yo)};static \u0275prov=f({token:Yo,factory:Yo.\u0275fac})};return n=p([_(Wa)],n),n})(),$a=class{payload;static fToken=Symbol("RunConnectionWorkerRequest");constructor(i){this.payload=i}},Rm=(()=>{let n=class Ko{_state=c($t);_mediator=c(D);handle({payload:e}){if(!e.length)return Promise.resolve([]);if(!this._mediator.execute(new Vn))return Promise.reject(new Error("Connection worker is disabled."));this._interruptPendingRequests();let t=this._mediator.execute(new Wa);if(!t)return Promise.reject(new Error("Unable to initialize connection worker."));let o=++this._state.nextRequestId;return new Promise((r,s)=>{this._state.pending.set(o,{resolve:r,reject:s});try{t.postMessage({requestId:o,items:e})}catch(a){this._state.pending.delete(o),s(a instanceof Error?a:new Error("Unknown error while posting message to connection worker."))}})}_interruptPendingRequests(){if(!this._state.pending.size)return;let e=new Error("Connection worker request was superseded by a newer redraw.");this._state.pending.forEach(t=>t.reject(e)),this._state.pending.clear()}static \u0275fac=function(t){return new(t||Ko)};static \u0275prov=f({token:Ko,factory:Ko.\u0275fac})};return n=p([_($a)],n),n})(),Xa=class{batch;static fToken=Symbol("RunConnectionWorkerBatchRequest");constructor(i){this.batch=i}},Nm=(()=>{let n=class Zo{_mediator=c(D);handle({batch:e}){return e.payload.length?this._mediator.execute(new $a(e.payload)):Promise.resolve([])}static \u0275fac=function(t){return new(t||Zo)};static \u0275prov=f({token:Zo,factory:Zo.\u0275fac})};return n=p([_(Xa)],n),n})(),qa=class{connections;cache;session;static fToken=Symbol("StartConnectionWorkerRedrawRequest");constructor(i,e,t){this.connections=i,this.cache=e,this.session=t}},km=(()=>{let n=class Qo{_mediator=c(D);handle({connections:e,cache:t,session:o}){let r=this._mediator.execute(new ja(e,t));if(!r.payload.length){this._mediator.execute(new Ct(e,t,0,o,r.items));return}this._mediator.execute(new Xa(r)).then(s=>{this._mediator.execute(new Ht(o))&&this._mediator.execute(new Ct(e,t,0,o,r.items,this._alignWorkerResults(s,e.length)))}).catch(()=>{this._mediator.execute(new Ht(o))&&this._mediator.execute(new Ct(e,t,0,o,r.items))})}_alignWorkerResults(e,t){let o=new Array(t);for(let r of e){let s=r.originalIndex;s<0||s>=t||(o[s]=r)}return o}static \u0275fac=function(t){return new(t||Qo)};static \u0275prov=f({token:Qo,factory:Qo.\u0275fac})};return n=p([_(qa)],n),n})(),Om=(()=>{let n=class Jo{_mediator=c(D);_store=c(x);handle(e){let t=this._mediator.execute(new Ba);this._createMarkersForCreate(),this._createMarkersForSnap();let o=[...this._store.connections.getAll()],r=new Map;if(!o.length){this._mediator.execute(new Hn(t));return}this._shouldUseConnectionWorker(o.length)?this._redrawUsingWorker(o,r,t):this._redrawWithoutWorker(o,r,t)}_createMarkersForCreate(){let e=this._store.connections.getForCreate();e&&this._mediator.execute(new cn(e))}_createMarkersForSnap(){let e=this._store.connections.getForSnap();e&&this._mediator.execute(new cn(e))}_shouldUseConnectionWorker(e){return this._mediator.execute(new Ga(e))}_redrawUsingWorker(e,t,o){this._mediator.execute(new qa(e,t,o))}_redrawWithoutWorker(e,t,o){this._mediator.execute(new Ct(e,t,0,o))}static \u0275fac=function(t){return new(t||Jo)};static \u0275prov=f({token:Jo,factory:Jo.\u0275fac})};return n=p([_(jn)],n),n})(),iu=class{static fToken=Symbol("RemoveConnectionForCreateFromStoreRequest")},Fm=(()=>{let n=class er{_store=c(x);handle(e){this._store.connections.removeInstanceForCreate()}static \u0275fac=function(t){return new(t||er)};static \u0275prov=f({token:er,factory:er.\u0275fac})};return n=p([_(iu)],n),n})(),Ya=class{connection;static fToken=Symbol("RemoveConnectionFromStoreRequest");constructor(i){this.connection=i}},Am=(()=>{let n=class tr{_store=c(x);handle({connection:e}){this._store.connections.remove(e),this._store.emitConnectionChanges()}static \u0275fac=function(t){return new(t||tr)};static \u0275prov=f({token:tr,factory:tr.\u0275fac})};return n=p([_(Ya)],n),n})(),ou=class{instance;static fToken=Symbol("RemoveConnectionMarkerFromStoreRequest");constructor(i){this.instance=i}},Lm=(()=>{let n=class nr{_store=c(x);handle({instance:e}){this._store.connectionMarkers.remove(e),this._store.emitNodeChanges()}static \u0275fac=function(t){return new(t||nr)};static \u0275prov=f({token:nr,factory:nr.\u0275fac})};return n=p([_(ou)],n),n})(),ru=class{waypointIndex;connectionId;static fToken=Symbol("RemoveConnectionWaypointRequest");constructor(i,e){this.waypointIndex=i,this.connectionId=e}},Ka=class{static fToken=Symbol("EmitEndDragSequenceEventRequest")},zm=(()=>{let n=class ir{_store=c(x);_dragSession=c(V);handle(e){this._store.flowHost.classList.remove(Ce.DRAG_AND_DROP.DRAGGING),this._dragSession.reset(),this._emitEvent()}_emitEvent(){this._store.fDraggable?.fDragEnded?.emit()}static \u0275fac=function(t){return new(t||ir)};static \u0275prov=f({token:ir,factory:ir.\u0275fac})};return n=p([_(Ka)],n),n})(),Za=class{static fToken=Symbol("EmitStartDragSequenceEventRequest")},Bm=(()=>{let n=class or{_mediator=c(D);_store=c(x);_dragContext=c(V);handle(e){this._dragContext.draggableItems.length>0&&(this._store.flowHost.classList.add(Ce.DRAG_AND_DROP.DRAGGING),this._mediator.execute(new Wn),this._emitDragStarted())}_emitDragStarted(){let e=this._dragContext.draggableItems[0].getEvent();this._store.fDraggable?.fDragStarted?.emit(new ic(e.kind,e.data?J({},e.data):void 0,e.fEventType))}static \u0275fac=function(t){return new(t||or)};static \u0275prov=f({token:or,factory:or.\u0275fac})};return n=p([_(Za)],n),n})(),Wn=class{static fToken=Symbol("EmitSelectionChangeEventRequest")},jt=class{_event;_target;get originalEvent(){return this._event}get targetElement(){return this._target||this.originalEvent.target}get touchEvent(){return this._event}get touches(){return this.touchEvent.touches}constructor(i,e){this._event=i,this._target=e}setTarget(i){this._target=i}preventDefault(){this.originalEvent.preventDefault()}get isEventInLockedContext(){return this.targetElement.closest("[fLockedContext]")!==null}},Qa=class extends jt{constructor(i,e){super(i,e)}isMouseLeftButton(){return this.originalEvent.button===0}isMouseRightButton(){return this.originalEvent.buttons===2}getPosition(){return{x:this.originalEvent.clientX,y:this.originalEvent.clientY}}},su=class extends jt{constructor(i,e){super(i,e)}isMouseLeftButton(){let i=this.originalEvent;return i.pointerType==="mouse"&&i.button===0||i.pointerType==="touch"}isMouseRightButton(){let i=this.originalEvent;return i.pointerType==="mouse"&&i.button===2||i.pointerType==="touch"}getPosition(){let i=this.originalEvent;return{x:i.clientX,y:i.clientY}}getPointerType(){return this.originalEvent.pointerType}getPointerId(){return this.originalEvent.pointerId}},au=class extends jt{constructor(i){super(i)}isMouseLeftButton(){return!0}isMouseRightButton(){return!1}getPosition(){let i=this.originalEvent.touches;return{x:i[0].clientX,y:i[0].clientY}}},cu=class extends jt{constructor(i,e){super(i,e)}isMouseLeftButton(){return!0}isMouseRightButton(){return!1}getPosition(){let i=this.originalEvent.targetTouches[0];return{x:i.clientX,y:i.clientY}}},Z=(()=>{class n{static _isSupported;static _isPassiveEventListenerSupported(){if(n._isSupported==null&&typeof window<"u")try{window.addEventListener("test",n.emptyListener,{passive:!0}),n._isSupported=!0}catch{n._isSupported=!1}return n._isSupported}static _passiveEventListener(e){return n._isPassiveEventListenerSupported()?e:!!e.capture}static activeListener(){return n._passiveEventListener({passive:!1})}static passiveListener(){return n._passiveEventListener({passive:!0})}static activeCaptureListener(){return n._passiveEventListener({passive:!1,capture:!0})}static emptyListener(){return()=>{}}}return n})(),Gm=800,du=class{_document=c(bi);_ngZone=c(Tn,{optional:!0});_mouseListeners=Z.emptyListener();_touchListeners=Z.emptyListener();_startListeners=Z.emptyListener();isSyntheticEvent(i){return!!this._lastTouchEventTime&&this._lastTouchEventTime+Gm>Date.now()}_lastTouchEventTime=0;isDragStarted=!1;_dragStartThreshold=3;_dragStartDelay=0;_dragStartTime=0;_dragStartPosition={x:0,y:0};_moveHandler=this._checkDragSequenceToStart;_pointerDownElement=null;_onMouseDown=i=>{let e=this.isSyntheticEvent(i),t=jm(i),o=new Qa(i);if(e||t||this.disabled||this.isDragStarted)return;this._pointerDownElement=o.targetElement,this.onPointerDown(o)&&(this._dragStartTime=Date.now(),this._dragStartPosition=o.getPosition(),this._ngZone?.runOutsideAngular(()=>{this._listen("selectstart",this._onSelectStart,Z.activeListener()),this._listen("mousemove",this._onMouseMove),this._listen("pointerup",this._onPointerUpEvent),this._listen("pointercancel",this._onPointerUpEvent,Z.activeCaptureListener()),this._listen("contextmenu",this._preventDuringDrag,Z.activeCaptureListener())}),this._mouseListeners=()=>{this._unlisten("selectstart",this._onSelectStart,Z.activeListener()),this._unlisten("mousemove",this._onMouseMove),this._unlisten("pointerup",this._onPointerUpEvent),this._unlisten("pointercancel",this._onPointerUpEvent,Z.activeCaptureListener()),this._unlisten("contextmenu",this._preventDuringDrag,Z.activeCaptureListener())})};_onTouchDown=i=>{let e=Vm(i),t=new au(i);if(e||this.disabled||this.isDragStarted)return;this._pointerDownElement=t.targetElement,this.onPointerDown(t)&&(this._dragStartTime=Date.now(),this._dragStartPosition=t.getPosition(),this._ngZone?.runOutsideAngular(()=>{this._listen("selectstart",this._onSelectStart,Z.activeListener()),this._listen("touchmove",this._onTouchMove),this._listen("pointerup",this._onPointerUpEvent),this._listen("pointercancel",this._onPointerUpEvent,Z.activeCaptureListener()),this._listen("contextmenu",this._preventDuringDrag,Z.activeCaptureListener())}),this._touchListeners=()=>{this._unlisten("selectstart",this._onSelectStart,Z.activeListener()),this._unlisten("touchmove",this._onTouchMove),this._unlisten("pointerup",this._onPointerUpEvent),this._unlisten("pointercancel",this._onPointerUpEvent,Z.activeCaptureListener()),this._unlisten("contextmenu",this._preventDuringDrag,Z.activeCaptureListener())})};_onSelectStart=i=>{this.onSelect(i)};_onMouseMove=i=>{this._moveHandler(new Qa(i))};_onTouchMove=i=>{this._moveHandler(new cu(i))};_checkDragSequenceToStart(i){let e=i.getPosition();if(!this.isDragStarted&&this._pointerDownElement){i.setTarget(this._pointerDownElement);let t=Math.abs(e.x-this._dragStartPosition.x),o=Math.abs(e.y-this._dragStartPosition.y);if(t+o>=this._dragStartThreshold){if(!(Date.now()>=this._dragStartTime+this._dragStartDelay)){this._endDragSequence();return}i.preventDefault(),this.prepareDragSequence(i),this.isDragStarted=!0,this._moveHandler=this.onPointerMove,Hm(i.originalEvent)&&(this._lastTouchEventTime=Date.now())}}}_onPointerUpEvent=i=>{this.isDragStarted&&this.onPointerUp(new su(i)),this._endDragSequence()};_endDragSequence(){this.isDragStarted=!1,this._pointerDownElement=null,this._moveHandler=this._checkDragSequenceToStart,this._mouseListeners(),this._mouseListeners=Z.emptyListener(),this._touchListeners(),this._touchListeners=Z.emptyListener(),this.finalizeDragSequence()}subscribe(){this.unsubscribe(),this._ngZone?.runOutsideAngular(()=>{this._listen("mousedown",this._onMouseDown,Z.activeListener()),this._listen("touchstart",this._onTouchDown,Z.passiveListener())}),this._startListeners=()=>{this._unlisten("mousedown",this._onMouseDown,Z.activeListener()),this._unlisten("touchstart",this._onTouchDown,Z.passiveListener())}}unsubscribe(){this._startListeners(),this._startListeners=Z.emptyListener(),this._touchListeners(),this._touchListeners=Z.emptyListener(),this._mouseListeners(),this._mouseListeners=Z.emptyListener()}_listen(i,e,t){this._document.addEventListener(i,e,t)}_unlisten(i,e,t){this._document.removeEventListener(i,e,t)}_preventDuringDrag=i=>{this.isDragStarted&&i.preventDefault()}};function Hm(n){return n.type[0]==="t"}function jm(n){return n.buttons===0||n.offsetX===0&&n.offsetY===0}function Vm(n){let i=n.touches&&n.touches[0]||n.changedTouches&&n.changedTouches[0];return!!i&&i.identifier===-1&&(i.radiusX==null||i.radiusX===1)&&(i.radiusY==null||i.radiusY===1)}var lu=class extends jt{_position;_isMouseLeftButton;_isMouseRightButton;constructor(i){super(i.originalEvent,i.targetElement),this._position=i.getPosition(),this._isMouseLeftButton=i.isMouseLeftButton(),this._isMouseRightButton=i.isMouseRightButton()}isMouseLeftButton(){return this._isMouseLeftButton}isMouseRightButton(){return this._isMouseRightButton}getPosition(){return J({},this._position)}};function Um(n){return new lu(n)}var V=(()=>{class n{selectedItems=[];isSelectedChanged=!1;onPointerDownScale=1;onPointerDownPosition=new j(0,0);draggableItems=[];autoPanFrameId=null;lastPointerEvent=null;lastPointerPosition=null;isAutoPanCanvasMoved=!1;reset(){for(let e of this.draggableItems)try{e.destroy?.()}catch{console.error(`Error while destroying drag handler of type ${e.type}`)}this.draggableItems=[],this.onPointerDownScale=1,this.onPointerDownPosition=new j(0,0),this.autoPanFrameId=null,this.lastPointerEvent=null,this.lastPointerPosition=null,this.isAutoPanCanvasMoved=!1}markSelectionAsChanged(){this.isSelectedChanged=!0}rememberPointerEvent(e){this.lastPointerEvent=Um(e),this.lastPointerPosition=this.lastPointerEvent.getPosition()}isEmpty(){return!this.draggableItems.length}static \u0275fac=function(t){return new(t||n)};static \u0275prov=f({token:n,factory:n.\u0275fac})}return n})(),uu=class{nodeIds;groupIds;connectionIds;get fNodeIds(){return this.nodeIds}get fGroupIds(){return this.groupIds}get fConnectionIds(){return this.connectionIds}constructor(i,e,t){this.nodeIds=i,this.groupIds=e,this.connectionIds=t}},Wm=(()=>{let n=class rr{_mediator=c(D);_store=c(x);_dragSession=c(V);handle(e){this._dragSession.isSelectedChanged&&(this._emitSelectionChange(this._getSelection()),this._dragSession.isSelectedChanged=!1,this._mediator.execute(new xt))}_getSelection(){return this._mediator.execute(new gi)}_emitSelectionChange(e){this._store.fDraggable?.fSelectionChange.emit(new uu(e.fNodeIds,e.fGroupIds,e.fConnectionIds))}static \u0275fac=function(t){return new(t||rr)};static \u0275prov=f({token:rr,factory:rr.\u0275fac})};return n=p([_(Wn)],n),n})(),fu=class{nodeOrGroup;static fToken=Symbol("GetNormalizedParentNodeRectRequest");constructor(i){this.nodeOrGroup=i}},$m=(()=>{let n=class sr{_store=c(x);_mediator=c(D);handle({nodeOrGroup:e}){let t=z.initialize(-1/0,-1/0,1/0,1/0),o=this._getNode(e.fParentId());return o&&(t=this._getParentRect(o)),t}_getNode(e){return this._store.nodes.get(e)}_getParentRect(e){let t=this._getNodeRect(e),o=this._getNodePadding(e,t);return z.initialize(t.x+o[0],t.y+o[1],t.width-o[0]-o[2],t.height-o[1]-o[3])}_getNodeRect(e){return this._mediator.execute(new de(e.hostElement))}_getNodePadding(e,t){return this._mediator.execute(new Ut(e,t))}static \u0275fac=function(t){return new(t||sr)};static \u0275prov=f({token:sr,factory:sr.\u0275fac})};return n=p([_(fu)],n),n})(),hu=class{fParentNodes;fDraggedNodes;static fToken=Symbol("IsArrayHasParentNodeRequest");constructor(i,e){this.fParentNodes=i,this.fDraggedNodes=e}},Xm=(()=>{let n=class ar{handle(e){return this._isParentNodeInArray(this._getParentNodeIds(e.fParentNodes),e.fDraggedNodes)}_getParentNodeIds(e){return e.map(t=>t.fId())}_isParentNodeInArray(e,t){return t.some(o=>e.includes(o.fId()))}static \u0275fac=function(t){return new(t||ar)};static \u0275prov=f({token:ar,factory:ar.\u0275fac})};return n=p([_(hu)],n),n})(),gu=class{fNodeId;fConnectionIds;constructor(i,e){this.fNodeId=i,this.fConnectionIds=e}},Ja=class extends gu{nodeId;connectionIds;constructor(i,e){super(i,e),this.nodeId=i,this.connectionIds=e}},ec=class{nodeOrGroup;static fToken=Symbol("DetectConnectionsUnderDragNodeRequest");constructor(i){this.nodeOrGroup=i}},qm=(()=>{let n=class cr{_mediator=c(D);_store=c(x);handle({nodeOrGroup:e}){let t=this._collectConnectableConnectorIds(e,"source"),o=this._collectConnectableConnectorIds(e,"target");if(!t.size||!o.size)return;let r=this._collectAttachedConnectionIds(t,o),s=this._collectConnectionsUnderNode(e),a=[];for(let d of s){let l=d.fId();r.has(l)||a.push(l)}a.length&&(this._store.fDraggable?.fNodeIntersectedWithConnections.emit(new Ja(e.fId(),a)),this._store.fDraggable?.fNodeConnectionsIntersection.emit(new Ja(e.fId(),a)))}_collectConnectableConnectorIds(e,t){let o=t==="source"?this._store.outputs.getAll():this._store.inputs.getAll(),r=new Set;for(let s of o)s.canBeConnected&&e.isContains(s.hostElement)&&r.add(s.fId());return r}_collectAttachedConnectionIds(e,t){let o=new Set;for(let r of this._store.connections.getAll())(e.has(r.fOutputId())||t.has(r.fInputId()))&&o.add(r.fId());return o}_collectConnectionsUnderNode(e){let t=this._mediator.execute(new wt(e.hostElement,!1)),o=[];for(let r of this._store.connections.getAll())this._hasIntersection(r,t)&&o.push(r);return o}_hasIntersection(e,t){return en.getRoundedRectIntersectionsWithSVGPath(e.fPath().hostElement,t).length>0}static \u0275fac=function(t){return new(t||cr)};static \u0275prov=f({token:cr,factory:cr.\u0275fac})};return n=p([_(ec)],n),n})(),Ym=[Bm,zm,Wm,$m,Xm,qm],Km=new Set(["create-connection","reassign-connection","drag-node"]),Zm=new Set(["selection-area"]),Qm=new Set(["assign-to-container"]);function bh(n){let i=null;for(let e of n){if(Qm.has(e))continue;let t=Km.has(e)?"rebase":Zm.has(e)?"direct":null;if(!t)return null;if(!i){i=t;continue}if(i!==t)return null}return i}function Ih(n,i,e,t,o){return M.initialize(Gf(n.x,i.left,i.right,e,t,o),Gf(n.y,i.top,i.bottom,e,t,o))}function Gf(n,i,e,t,o,r){let s=Math.max(0,t),a=Math.max(0,o);if(!s||!a)return 0;if(n<=i+s){let d=jf((i+s-n)/s,0,1);return Hf(d,a,r)}if(n>=e-s){let d=jf((n-(e-s))/s,0,1);return-Hf(d,a,r)}return 0}function Jm(n,i,e){let t=e||1;return j.fromPoint(n).add(j.fromPoint(i).div(t))}function Hf(n,i,e){return e?i*n:i}function jf(n,i,e){return Math.max(i,Math.min(e,n))}var tc=class{static fToken=Symbol("RunAutoPanFrameRequest")},bt=class{static fToken=Symbol("StopAutoPanRequest")},e0=(()=>{let n=class dr{_store=c(x);_dragContext=c(V);handle(e){this._dragContext.autoPanFrameId!==null&&(cancelAnimationFrame(this._dragContext.autoPanFrameId),this._dragContext.autoPanFrameId=null),this._dragContext.isAutoPanCanvasMoved&&(this._store.fCanvas?.emitCanvasChangeEvent(),this._dragContext.isAutoPanCanvasMoved=!1)}static \u0275fac=function(t){return new(t||dr)};static \u0275prov=f({token:dr,factory:dr.\u0275fac})};return n=p([_(bt)],n),n})(),$n=class{static fToken=Symbol("SyncAutoPanRequest")},t0=(()=>{let n=class lr{_mediator=c(D);_store=c(x);_dragContext=c(V);handle(e){if(!this._canAutoPan()||!this._hasAutoPanDelta()){this._mediator.execute(new bt);return}this._dragContext.autoPanFrameId===null&&(this._dragContext.autoPanFrameId=requestAnimationFrame(()=>{this._dragContext.autoPanFrameId=null,this._mediator.execute(new tc)}))}_canAutoPan(){return!!this._store.fFlow&&!!this._store.fCanvas&&!!this._store.fDraggable?.isDragStarted&&!!this._autoPan()&&!!this._getAutoPanMode()&&this._edgeThreshold()>0&&this._speed()>0}_hasAutoPanDelta(){let e=this._getAutoPanDelta();return!!e.x||!!e.y}_getAutoPanDelta(){let e=this._dragContext.lastPointerPosition,t=this._store.fFlow?.hostElement;return!e||!t?M.initialize():Ih(e,t.getBoundingClientRect(),this._edgeThreshold(),this._speed(),this._acceleration())}_getAutoPanMode(){return bh(this._dragContext.draggableItems.map(e=>e.getEvent().kind))}_edgeThreshold(){return Math.max(0,this._autoPan()?.fEdgeThreshold()??0)}_speed(){return Math.max(0,this._autoPan()?.fSpeed()??0)}_acceleration(){return!!this._autoPan()?.fAcceleration()}_autoPan(){return this._store.instances.get(ae.AUTO_PAN)}static \u0275fac=function(t){return new(t||lr)};static \u0275prov=f({token:lr,factory:lr.\u0275fac})};return n=p([_($n)],n),n})(),n0=(()=>{let n=class ur{_mediator=c(D);_store=c(x);_dragContext=c(V);handle(e){let t=this._getAutoPanMode();if(!this._canAutoPan(t)){this._mediator.execute(new bt);return}let o=this._getAutoPanDelta();if(!o.x&&!o.y){this._mediator.execute(new bt);return}this._applyCanvasDelta(o,t),this._replayLastPointerMove(),this._mediator.execute(new $n)}_applyCanvasDelta(e,t){let o=this._store.transform;t==="rebase"&&(this._dragContext.onPointerDownPosition=Jm(this._dragContext.onPointerDownPosition,e,this._dragContext.onPointerDownScale||o.scale||1)),o.position=j.fromPoint(o.position).add(e),this._store.fCanvas?.redraw(),this._dragContext.isAutoPanCanvasMoved=!0}_replayLastPointerMove(){let e=this._dragContext.lastPointerEvent;if(!e)return;let t=this._getPointerPositionInCanvas(e).div(this._dragContext.onPointerDownScale).sub(this._dragContext.onPointerDownPosition);this._dragContext.draggableItems.forEach(o=>{o.onPointerMove(J({},t),e)})}_getPointerPositionInCanvas(e){return j.fromPoint(e.getPosition()).elementTransform(this._store.flowHost)}_canAutoPan(e){return!!this._store.fFlow&&!!this._store.fCanvas&&!!this._store.fDraggable?.isDragStarted&&!!this._autoPan()&&!!e&&this._edgeThreshold()>0&&this._speed()>0}_getAutoPanMode(){return bh(this._dragContext.draggableItems.map(e=>e.getEvent().kind))}_getAutoPanDelta(){let e=this._dragContext.lastPointerPosition,t=this._store.fFlow?.hostElement;return!e||!t?M.initialize():Ih(e,t.getBoundingClientRect(),this._edgeThreshold(),this._speed(),this._acceleration())}_edgeThreshold(){return Math.max(0,this._autoPan()?.fEdgeThreshold()??0)}_speed(){return Math.max(0,this._autoPan()?.fSpeed()??0)}_acceleration(){return!!this._autoPan()?.fAcceleration()}_autoPan(){return this._store.instances.get(ae.AUTO_PAN)}static \u0275fac=function(t){return new(t||ur)};static \u0275prov=f({token:ur,factory:ur.\u0275fac})};return n=p([_(tc)],n),n})(),i0=[t0,n0,e0],nc=class{event;static fToken=Symbol("DragCanvasFinalizeRequest");constructor(i){this.event=i}},ic=class{kind;data;fEventType;get fData(){return this.data}constructor(i,e,t){this.kind=i,this.data=e,this.fEventType=t??i}},Oe=class{data(){}_features=[];getEvent(){return new ic(this.kind,this.data(),this.type)}attachFeature(i){this._features.push(i)}featuresPrepare(i){for(let e of this._features)e.onPrepare?.(i)}featuresMove(i,e){for(let t of this._features)t.onMove?.(i,e)}featuresFinalize(i,e){for(let t of this._features)t.onFinalize?.(i,e)}featuresEnd(i){for(let e of this._features)e.onEnd?.(i)}},oc=class{_isConnected=!1;get isConnected(){return this._isConnected}toConnector=[];isSelfConnectable=!0;fConnectableSide=R.AUTO;userFConnectableSide=R.AUTO;isContains(i){return this.hostElement.contains(i)}setConnected(i){this._isConnected=!0,this.toConnector.push(i)}resetConnected(){this._isConnected=!1,this.toConnector=[]}},o0=new ee("F_NODE_INPUT"),r0=(()=>{class n extends oc{kind="input";get canBeConnected(){return!this.disabled()&&(this.multiple()?!0:!this.isConnected)}static \u0275fac=(()=>{let e;return function(o){return(e||(e=X(n)))(o||n)}})();static \u0275dir=_e({type:n,standalone:!1,features:[ce]})}return n})(),nt=(function(n){return n.LEFT="left",n.LEFT_TOP="left-top",n.TOP="top",n.RIGHT_TOP="right-top",n.RIGHT="right",n.RIGHT_BOTTOM="right-bottom",n.BOTTOM="bottom",n.LEFT_BOTTOM="left-bottom",n})(nt||{});function s0(n){return Mn(n,".f-rotate-handle")}var Sh=(()=>{class n{static \u0275fac=function(t){return new(t||n)};static \u0275dir=_e({type:n,selectors:[["","fDragHandle",""]],hostAttrs:[1,"f-drag-handle","f-component"],standalone:!1})}return n})(),Ud=new ee("F_NODE"),a0=_h(class{hostElement;constructor(n){this.hostElement=n}}),rc=class extends a0{_injector=c(Ae);renderer=c(gf);browser=c(pe);stateChanges=new je;_position=M.initialize();_rotate=0;_size;connectors=[];positionChanges(){Ie(()=>{let i=this.position();Pt(()=>{M.isEqual(this._position,i)||(this._position=i,this.redraw(),this.refresh())})},{injector:this._injector})}sizeChanges(){Ie(()=>{let i=this.size();Pt(()=>{this._isSizeEqual(i)||(this._size=i,this.redraw(),this.refresh())})},{injector:this._injector})}rotateChanges(){Ie(()=>{let i=this.rotate();Pt(()=>{this._rotate!==i&&(this._rotate=i,this.redraw(),this.refresh())})},{injector:this._injector})}parentChanges(){Ie(()=>{this.fParentId(),this.fIncludePadding(),this.fAutoSizeToFitChildren(),Pt(()=>this.refresh())},{injector:this._injector})}_isSizeEqual(i){return this._size?.width===i?.width&&this._size?.height===i?.height}isContains(i){return this.hostElement.contains(i)}redraw(){this._size&&(this.setStyle("width",""+this._size.width+"px"),this.setStyle("height",""+this._size.height+"px")),this.setStyle("transform",`translate(${this._position.x}px,${this._position.y}px) rotate(${this._rotate}deg)`)}resetSize(){this.removeStyle("width"),this.removeStyle("height")}updatePosition(i){this._position=i}updateRotate(i){this._rotate=i}updateSize(i){this._size=i}setClass(i){this.hostElement.classList.add(i)}removeClass(i){this.hostElement.classList.remove(i)}addConnector(i){this.connectors.push(i),this.refresh()}removeConnector(i){let e=this.connectors.indexOf(i);e!==-1&&this.connectors.splice(e,1),this.refresh()}},c0=0,d0=3,pu=(()=>{class n extends rc{_debounceTimer=null;_destroyRef=c(Ze);_mediator=c(D);fId=F(`f-group-${c0++}`,{alias:"fGroupId"});fParentId=F(null,{alias:"fGroupParentId"});position=Mt(M.initialize(),{alias:"fGroupPosition"});size=F(void 0,{alias:"fGroupSize"});sizeChange=lt({alias:"fGroupSizeChange"});rotate=Mt(0,{alias:"fGroupRotate"});fConnectOnNode=F(!0,{transform:re});fMinimapClass=F([]);fDraggingDisabled=F(!1,{alias:"fGroupDraggingDisabled",transform:re});fSelectionDisabled=F(!1,{alias:"fGroupSelectionDisabled",transform:re});fIncludePadding=F(!0,{transform:re});fAutoExpandOnChildHit=F(!1,{transform:re});fAutoSizeToFitChildren=F(!1,{transform:re});constructor(e){super(e.nativeElement),super.positionChanges(),super.sizeChanges(),super.rotateChanges(),super.parentChanges()}ngOnInit(){super.redraw(),this._mediator.execute(new ai(this))}setStyle(e,t){this.renderer.setStyle(this.hostElement,e,t)}removeStyle(e){this.renderer.removeStyle(this.hostElement,e)}redraw(){super.redraw(),this._mediator.execute(new xt),this._updateConnectorsSides()}_updateConnectorsSides(){this.connectors.length&&(this._debounceTimer&&clearTimeout(this._debounceTimer),this._debounceTimer=setTimeout(()=>this._calculateNodeConnectorsConnectableSides(),d0))}_calculateNodeConnectorsConnectableSides(){this._mediator.execute(new hn(this))}ngAfterViewInit(){this.browser.isBrowser()&&this._listenStateSizeChanges()}_listenStateSizeChanges(){this._mediator.execute(new di(this,this._destroyRef))}refresh(){this.stateChanges.notify()}ngOnDestroy(){this._mediator.execute(new li(this))}static \u0275fac=function(t){return new(t||n)(hl(he))};static \u0275dir=_e({type:n,selectors:[["","fGroup",""]],hostAttrs:[1,"f-group","f-component"],hostVars:5,hostBindings:function(t,o){t&2&&(te("data-f-group-id",o.fId()),$e("f-group-dragging-disabled",o.fDraggingDisabled())("f-group-selection-disabled",o.fSelectionDisabled()))},inputs:{fId:[1,"fGroupId","fId"],fParentId:[1,"fGroupParentId","fParentId"],position:[1,"fGroupPosition","position"],size:[1,"fGroupSize","size"],rotate:[1,"fGroupRotate","rotate"],fConnectOnNode:[1,"fConnectOnNode"],fMinimapClass:[1,"fMinimapClass"],fDraggingDisabled:[1,"fGroupDraggingDisabled","fDraggingDisabled"],fSelectionDisabled:[1,"fGroupSelectionDisabled","fSelectionDisabled"],fIncludePadding:[1,"fIncludePadding"],fAutoExpandOnChildHit:[1,"fAutoExpandOnChildHit"],fAutoSizeToFitChildren:[1,"fAutoSizeToFitChildren"]},outputs:{position:"fGroupPositionChange",sizeChange:"fGroupSizeChange",rotate:"fGroupRotateChange"},exportAs:["fComponent"],standalone:!1,features:[be([{provide:Ud,useExisting:n}]),ce]})}return n})(),Vf=0,l0=3,Wd=(()=>{class n extends rc{_debounceTimer=null;_destroyRef=c(Ze);_mediator=c(D);fId=F(`f-node-${Vf++}`,{alias:"fNodeId",transform:e=>un(e)||`f-node-${Vf++}`});fParentId=F(null,{alias:"fNodeParentId"});position=Mt(M.initialize(),{alias:"fNodePosition"});size=F(void 0,{alias:"fNodeSize"});sizeChange=lt({alias:"fNodeSizeChange"});rotate=Mt(0,{alias:"fNodeRotate"});fConnectOnNode=F(!0,{transform:re});fMinimapClass=F([]);fDraggingDisabled=F(!1,{alias:"fNodeDraggingDisabled",transform:re});fSelectionDisabled=F(!1,{alias:"fNodeSelectionDisabled",transform:re});fIncludePadding=F(!0,{transform:re});fAutoExpandOnChildHit=F(!1,{transform:re});fAutoSizeToFitChildren=F(!1,{transform:re});constructor(e){super(e.nativeElement),super.positionChanges(),super.sizeChanges(),super.rotateChanges(),super.parentChanges()}ngOnInit(){super.redraw(),this._mediator.execute(new ai(this))}setStyle(e,t){this.renderer.setStyle(this.hostElement,e,t)}removeStyle(e){this.renderer.removeStyle(this.hostElement,e)}redraw(){super.redraw(),this._mediator.execute(new xt),this._updateConnectorsSides()}_updateConnectorsSides(){this.connectors.length&&(this._debounceTimer&&clearTimeout(this._debounceTimer),this._debounceTimer=setTimeout(()=>this._calculateNodeConnectorsConnectableSides(),l0))}_calculateNodeConnectorsConnectableSides(){this._mediator.execute(new hn(this))}ngAfterViewInit(){this.browser.isBrowser()&&this._listenStateSizeChanges()}_listenStateSizeChanges(){this._mediator.execute(new di(this,this._destroyRef))}refresh(){this.stateChanges.notify()}ngOnDestroy(){this._mediator.execute(new li(this))}static \u0275fac=function(t){return new(t||n)(hl(he))};static \u0275dir=_e({type:n,selectors:[["","fNode",""]],hostAttrs:[1,"f-node","f-component"],hostVars:5,hostBindings:function(t,o){t&2&&(te("data-f-node-id",o.fId()),$e("f-node-dragging-disabled",o.fDraggingDisabled())("f-node-selection-disabled",o.fSelectionDisabled()))},inputs:{fId:[1,"fNodeId","fId"],fParentId:[1,"fNodeParentId","fParentId"],position:[1,"fNodePosition","position"],size:[1,"fNodeSize","size"],rotate:[1,"fNodeRotate","rotate"],fConnectOnNode:[1,"fConnectOnNode"],fMinimapClass:[1,"fMinimapClass"],fDraggingDisabled:[1,"fNodeDraggingDisabled","fDraggingDisabled"],fSelectionDisabled:[1,"fNodeSelectionDisabled","fSelectionDisabled"],fIncludePadding:[1,"fIncludePadding"],fAutoExpandOnChildHit:[1,"fAutoExpandOnChildHit"],fAutoSizeToFitChildren:[1,"fAutoSizeToFitChildren"]},outputs:{position:"fNodePositionChange",sizeChange:"fNodeSizeChange",rotate:"fNodeRotateChange"},exportAs:["fComponent"],standalone:!1,features:[be([{provide:Ud,useExisting:n}]),ce]})}return n})();function u0(n){return!!n.closest("[fNode]")}var Uf=0,Dh=(()=>{class n extends r0{hostElement=c(he).nativeElement;_mediator=c(D);_node=c(Ud);fId=F(`f-node-input-${Uf++}`,{alias:"fInputId",transform:e=>un(e)||`f-node-input-${Uf++}`});category=F(void 0,{alias:"fInputCategory",transform:un});multiple=F(!0,{alias:"fInputMultiple",transform:re});disabled=F(!1,{alias:"fInputDisabled",transform:re});userFConnectableSide=R.AUTO;get fNodeId(){return this._node.fId()}get fNodeHost(){return this._node.hostElement}ngOnInit(){this._mediator.execute(new oi(this)),this._node.addConnector(this)}ngOnChanges(e){e.userFConnectableSide&&this._node.refresh()}setConnected(e){super.setConnected(e),this.hostElement.classList.toggle(Ce.CONNECTOR.INPUT_CONNECTED,!0),this.hostElement.classList.toggle(Ce.CONNECTOR.INPUT_NOT_CONNECTABLE,!this.canBeConnected)}resetConnected(){super.resetConnected(),this.hostElement.classList.toggle(Ce.CONNECTOR.INPUT_CONNECTED,!1),this.hostElement.classList.toggle(Ce.CONNECTOR.INPUT_NOT_CONNECTABLE,!this.canBeConnected)}ngOnDestroy(){this._node.removeConnector(this),this._mediator.execute(new ui(this))}static \u0275fac=(()=>{let e;return function(o){return(e||(e=X(n)))(o||n)}})();static \u0275dir=_e({type:n,selectors:[["","fNodeInput",""]],hostAttrs:[1,"f-component","f-node-input"],hostVars:5,hostBindings:function(t,o){t&2&&(te("data-f-input-id",o.fId()),$e("f-node-input-multiple",o.multiple)("f-node-input-disabled",o.disabled()))},inputs:{fId:[1,"fInputId","fId"],category:[1,"fInputCategory","category"],multiple:[1,"fInputMultiple","multiple"],disabled:[1,"fInputDisabled","disabled"],userFConnectableSide:[2,"fInputConnectableSide","userFConnectableSide",e=>tn(e,"fInputConnectableSide",R)]},exportAs:["fNodeInput"],standalone:!1,features:[be([{provide:o0,useExisting:n}]),ce,Kt]})}return n})(),f0=(()=>{class n extends oc{get hasConnectionLimits(){return!!this.canBeConnectedInputs&&this.canBeConnectedInputs.length>0}canConnectTo(e){return[e.fId(),e.category()].some(o=>o&&this.canBeConnectedInputs?.includes(o))}static \u0275fac=(()=>{let e;return function(o){return(e||(e=X(n)))(o||n)}})();static \u0275dir=_e({type:n,standalone:!1,features:[ce]})}return n})();function Th(n){return!!n.closest("[fNodeOutlet]")}var h0=new ee("F_NODE_OUTPUT"),g0=(()=>{class n extends f0{kind="output";get canBeConnected(){return!this.disabled()&&(this.multiple()?!0:!this.isConnected)}static \u0275fac=(()=>{let e;return function(o){return(e||(e=X(n)))(o||n)}})();static \u0275dir=_e({type:n,standalone:!1,features:[ce]})}return n})();function Eh(n){return!!n.closest("[fNodeOutput]")}var Wf=0,Ph=(()=>{class n extends g0{hostElement=c(he).nativeElement;_mediator=c(D);_node=c(Ud);fId=F(`f-node-output-${Wf++}`,{alias:"fOutputId",transform:e=>un(e)||`f-node-output-${Wf++}`});multiple=F(!1,{alias:"fOutputMultiple",transform:re});disabled=F(!1,{alias:"fOutputDisabled",transform:re});userFConnectableSide=R.AUTO;isSelfConnectable=!0;canBeConnectedInputs=[];get fNodeId(){return this._node.fId()}get fNodeHost(){return this._node.hostElement}ngOnInit(){this._mediator.execute(new oi(this)),this._node.addConnector(this)}ngOnChanges(e){e.userFConnectableSide&&this._node.refresh()}setConnected(e){super.setConnected(e),this.hostElement.classList.toggle(Ce.CONNECTOR.OUTPUT_CONNECTED,!0),this.hostElement.classList.toggle(Ce.CONNECTOR.OUTPUT_NOT_CONNECTABLE,!this.canBeConnected)}resetConnected(){super.resetConnected(),this.hostElement.classList.toggle(Ce.CONNECTOR.OUTPUT_CONNECTED,!1),this.hostElement.classList.toggle(Ce.CONNECTOR.OUTPUT_NOT_CONNECTABLE,!this.canBeConnected)}ngOnDestroy(){this._node.removeConnector(this),this._mediator.execute(new ui(this))}static \u0275fac=(()=>{let e;return function(o){return(e||(e=X(n)))(o||n)}})();static \u0275dir=_e({type:n,selectors:[["","fNodeOutput",""]],hostAttrs:[1,"f-component","f-node-output"],hostVars:7,hostBindings:function(t,o){t&2&&(te("data-f-output-id",o.fId()),$e("f-node-output-multiple",o.multiple)("f-node-output-disabled",o.disabled())("f-node-output-self-connectable",o.isSelfConnectable))},inputs:{fId:[1,"fOutputId","fId"],multiple:[1,"fOutputMultiple","multiple"],disabled:[1,"fOutputDisabled","disabled"],userFConnectableSide:[2,"fOutputConnectableSide","userFConnectableSide",e=>tn(e,"fOutputConnectableSide",R)],isSelfConnectable:"isSelfConnectable",canBeConnectedInputs:[0,"fCanBeConnectedInputs","canBeConnectedInputs"]},exportAs:["fNodeOutput"],standalone:!1,features:[be([{provide:h0,useExisting:n}]),ce,Kt]})}return n})();var sc=class{event;static fToken=Symbol("CreateConnectionFinalizeRequest");constructor(i){this.event=i}},Xn=class{outlet;static fToken=Symbol("ResolveConnectableOutputForOutletRequest");constructor(i){this.outlet=i}},p0=(()=>{let n=class fr{_store=c(x);handle({outlet:e}){let t=this._findOwnerNode(e);if(!t)throw new Error("The fOutlet must belong to an fNode");let o=this._findFirstConnectableOutputInNode(t);if(!o)throw new Error("Outlet requires at least one connectable output in the same node.");return o}_findOwnerNode(e){let t=e.hostElement;return this._store.nodes.getAll().find(o=>o.isContains(t))}_findFirstConnectableOutputInNode(e){return this._store.outputs.getAll().find(t=>e.isContains(t.hostElement)&&t.canBeConnected)}static \u0275fac=function(t){return new(t||fr)};static \u0275prov=f({token:fr,factory:fr.\u0275fac})};return n=p([_(Xn)],n),n})(),_u=class{sourceId;targetId;dropPosition;fOutputId;fInputId;fDropPosition;constructor(i,e,t){this.sourceId=i,this.targetId=e,this.dropPosition=t,this.fOutputId=i,this.fInputId=e,this.fDropPosition=t}},ac=(()=>{class n extends Oe{type="create-connection";kind="create-connection";data(){return{fOutputOrOutletId:this._sourceRef.connector.fId()}}_result=c(St);_mediator=c(D);_connectionBehaviour=c(Cn);_store=c(x);get _connection(){return this._store.connections.getForCreate()}get _snapConnection(){return this._store.connections.getForSnap()}_targets=[];_sourceRef;_pointerDown=new ge;initialize(e,t){this._sourceRef=this._mediator.execute(new He(e)),this._pointerDown=ge.fromRect(z.initialize(t.x,t.y))}prepareDragSequence(){this._collectAndMarkTargets(),this._initSnapConnection(),this._initCreateConnection(),this._connection.show(),this.onPointerMove(M.initialize()),this._result.setData({toConnectorRect:this._pointerDown,canBeConnectedInputs:this._targets,fOutputId:this._sourceRef.connector.fId()})}_collectAndMarkTargets(){this._targets=this._mediator.execute(new si(this._sourceRef.connector,this._sourceRef.rect.gravityCenter)),this._mediator.execute(new _n(this._targets.map(e=>e.connector)))}_initSnapConnection(){this._snapConnection&&(this._snapConnection.fOutputId.set(this._sourceRef.connector.fId()),this._snapConnection.initialize())}_initCreateConnection(){this._connection.fOutputId.set(this._sourceRef.connector.fId()),this._connection.initialize()}onPointerMove(e){let t=this._pointerDown.addPoint(e),o=this._findClosestTarget(t),r=o?.connector.fConnectableSide||R.TOP;this._drawCreateConnection(t,r);let s=this._snapConnection;if(!s)return;let a=o&&o.distance<s.fSnapThreshold?o:void 0;this._drawSnapConnection(a)}_findClosestTarget(e){return this._mediator.execute(new Vt(e,this._targets))}_drawCreateConnection(e,t){let o=this._connectionBehaviour.handle(new Ye(this._sourceRef.rect,e,this._connection,this._sourceRef.connector.fConnectableSide,t,this._resolveRotationContext(this._sourceRef.connector)));this._connection.setLine(o),this._connection.redraw()}_drawSnapConnection(e){let t=this._snapConnection;if(!t)return;if(!e){t.hide();return}let o=this._connectionBehaviour.handle(new Ye(this._sourceRef.rect,e.rect,t,this._sourceRef.connector.fConnectableSide,e.connector.fConnectableSide,this._resolveRotationContext(this._sourceRef.connector),this._resolveRotationContext(e.connector)));t.show(),t.setLine(o),t.redraw()}onPointerUp(){this._connection.redraw(),this._connection.hide(),this._snapConnection?.hide(),this._mediator.execute(new mn(this._targets.map(e=>e.connector)))}_resolveRotationContext(e){return this._mediator.execute(new ht(e))}static \u0275fac=(()=>{let e;return function(o){return(e||(e=X(n)))(o||n)}})();static \u0275prov=f({token:n,factory:n.\u0275fac})}return n})(),_0=(()=>{let n=class hr{_result=c(St);_mediator=c(D);_store=c(x);_dragContext=c(V);get _dragHandler(){return this._dragContext.draggableItems[0]}handle(e){this._isValid()&&(this._emitEvent(e.event),this._dragHandler.onPointerUp())}_isValid(){return this._dragContext.draggableItems.some(e=>e instanceof ac)}_getTargetOutput(e){if(!e)throw new Error(`Output with fOutputId ${this._result.getData().fOutputId} not found. Make sure there is no f-connection to a non-existent fOutput.`);return Th(e.hostElement)?this._mediator.execute(new Xn(e)):e}_getOutput(){return this._store.outputs.get(this._result.getData().fOutputId)}_getOutlet(){return this._store.outlets.get(this._result.getData().fOutputId)}_emitEvent(e){this._store.fDraggable?.fCreateConnection.emit(new _u(this._getTargetOutput(this._getOutput()||this._getOutlet()).fId(),this._getInputUnderPointer(e)?.fId(),e.getPosition()))}_getInputUnderPointer(e){return this._mediator.execute(new ri(e.getPosition(),this._result.getData().canBeConnectedInputs))}static \u0275fac=function(t){return new(t||hr)};static \u0275prov=f({token:hr,factory:hr.\u0275fac})};return n=p([_(sc)],n),n})(),qn=class{eventPosition;source;static fToken=Symbol("CreateConnectionCreateDragHandlerRequest");constructor(i,e){this.eventPosition=i,this.source=e}},m0=(()=>{let n=class gr{_store=c(x);_dragContext=c(V);_dragInjector=c(Pe);get _transform(){return this._store.transform}handle({source:e,eventPosition:t}){this._dragContext.onPointerDownScale=this._transform.scale;let o=this._toFlowSpace(t);this._dragContext.onPointerDownPosition=o;let r=this._toCanvasSpace(o),s=this._dragInjector.get(ac);s.initialize(e,r),this._dragContext.draggableItems=[s]}_toFlowSpace(e){return j.fromPoint(e).elementTransform(this._store.flowHost).div(this._transform.scale)}_toCanvasSpace(e){return j.fromPoint(e).mult(this._transform.scale).sub(this._transform.position).sub(this._transform.scaledPosition).div(this._transform.scale)}static \u0275fac=function(t){return new(t||gr)};static \u0275prov=f({token:gr,factory:gr.\u0275fac})};return n=p([_(qn)],n),n})(),cc=class{event;node;static fToken=Symbol("CreateConnectionFromOutletPreparationRequest");constructor(i,e){this.event=i,this.node=e}},y0=(()=>{let n=class pr{_mediator=c(D);_store=c(x);handle({event:e,node:t}){let o=this._findOutlet(t);if(!o||(o.setOutputs(this._getOutputs(t)),!o.canBeConnected))return;let r=o.isConnectionFromOutlet?o:this._resolveOutput(o);!r||!r.canBeConnected||this._startDrag(e.getPosition(),r)}_findOutlet(e){return this._store.outlets.getAll().find(t=>e.isContains(t.hostElement))}_getOutputs(e){return this._store.outputs.getAll().filter(t=>e.isContains(t.hostElement))}_resolveOutput(e){return this._mediator.execute(new Xn(e))}_startDrag(e,t){this._mediator.execute(new qn(e,t))}static \u0275fac=function(t){return new(t||pr)};static \u0275prov=f({token:pr,factory:pr.\u0275fac})};return n=p([_(cc)],n),n})(),dc=class{event;node;static fToken=Symbol("CreateConnectionFromOutputPreparationRequest");constructor(i,e){this.event=i,this.node=e}},v0=(()=>{let n=class _r{_mediator=c(D);_store=c(x);handle({event:e,node:t}){if(!Eh(e.targetElement)||this._hasOutlet(t))return;let o=this._findOutput(e.targetElement);!o||!o.canBeConnected||this._startDrag(e.getPosition(),o)}_hasOutlet(e){return this._store.outlets.getAll().some(t=>e.isContains(t.hostElement))}_findOutput(e){return this._store.outputs.getAll().find(t=>t.hostElement.contains(e))}_startDrag(e,t){this._mediator.execute(new qn(e,t))}static \u0275fac=function(t){return new(t||_r)};static \u0275prov=f({token:_r,factory:_r.\u0275fac})};return n=p([_(dc)],n),n})(),lc=class{event;fTrigger;static fToken=Symbol("CreateConnectionPreparationRequest");constructor(i,e){this.event=i,this.fTrigger=e}},C0=(()=>{let n=class mr{_mediator=c(D);_store=c(x);_dragContext=c(V);handle({event:e,fTrigger:t}){if(!this._isValidConditions()||!this._isValidTrigger(e,t))return;let o=Th(e.targetElement),r=!o&&Eh(e.targetElement);if(!o&&!r)return;let s=this._findOwnerNode(e.targetElement);s&&(o?this._mediator.execute(new cc(e,s)):this._mediator.execute(new dc(e,s)))}_findOwnerNode(e){return this._store.nodes.getAll().find(t=>t.isContains(e))}_isValidConditions(){return this._dragContext.isEmpty()&&!!this._store.connections.getForCreate()}_isValidTrigger(e,t){return Ve(e.originalEvent,t)}static \u0275fac=function(t){return new(t||mr)};static \u0275prov=f({token:mr,factory:mr.\u0275fac})};return n=p([_(lc)],n),n})(),uc=class{event;static fToken=Symbol("ReassignConnectionFinalizeRequest");constructor(i){this.event=i}},mu=class{connectionId;endpoint;previousSourceId;nextSourceId;previousTargetId;nextTargetId;dropPosition;isSourceReassign;isTargetReassign;oldSourceId;newSourceId;oldTargetId;newTargetId;dropPoint;constructor(i,e,t,o,r,s,a){this.connectionId=i,this.endpoint=e,this.previousSourceId=t,this.nextSourceId=o,this.previousTargetId=r,this.nextTargetId=s,this.dropPosition=a,this.isSourceReassign=e==="source",this.isTargetReassign=e==="target",this.oldSourceId=t,this.newSourceId=o,this.oldTargetId=r,this.newTargetId=s,this.dropPoint=a}},x0=(()=>{let n=class yr{_dragResult=c(St);_mediator=c(D);_store=c(x);_dragContext=c(V);get _dragDirective(){return this._store.fDraggable}handle({event:e}){let t=this._findReassignHandler();t&&(this._emitIfChanged(e),t.onPointerUp())}_findReassignHandler(){return this._dragContext.draggableItems.find(t=>t.getEvent().fEventType==="reassign-connection")}_emitIfChanged(e){let t=this._dragResult.getData(),o=this._findConnectableConnector(e,t.candidates);o&&!this._isReassignedToDifferentConnector(t,o)||this._dragDirective.fReassignConnection.emit(this._buildEvent(t,e,o))}_findConnectableConnector(e,t){return this._mediator.execute(new ri(e.getPosition(),t))}_isReassignedToDifferentConnector(e,t){let o=e.connection;return e.draggedEnd==="target"?o.fInputId()!==t.fId():o.fOutputId()!==t.fId()}_buildEvent(e,t,o){let r=e.connection;return new mu(r.fId(),e.draggedEnd,r.fOutputId(),e.draggedEnd==="source"?o?.fId():void 0,r.fInputId(),e.draggedEnd==="target"?o?.fId():void 0,t.getPosition())}static \u0275fac=function(t){return new(t||yr)};static \u0275prov=f({token:yr,factory:yr.\u0275fac})};return n=p([_(uc)],n),n})(),fc=class{event;fTrigger;static fToken=Symbol("ReassignConnectionPreparationRequest");constructor(i,e){this.event=i,this.fTrigger=e}};function w0(n,i){return Mh(n,i)||b0(n,i)}function Mh(n,i){return n.fDragHandleEnd()?.point&&Rh(i,n.fDragHandleEnd().point)&&!n.fDraggingDisabled()}function b0(n,i){return!!n.fDragHandleStart()?.point&&Rh(i,n.fDragHandleStart().point)&&!n.fDraggingDisabled()&&n.fReassignableStart()}function Rh(n,i){return(n.x-i.x)**2+(n.y-i.y)**2<=8**2}function Nh(n,i){return n&&n.distance<i.fSnapThreshold?n:void 0}function hc(n){return ge.fromRect(z.initialize(n.x,n.y))}var yu=class{_mediator;_behaviour;_connection;_sourceRef;_targetRef;_candidates=[];_snap;_anchorRect;get _source(){return this._sourceRef.connector}get _target(){return this._targetRef.connector}constructor(i,e,t,o,r){this._mediator=i,this._behaviour=e,this._connection=t,this._sourceRef=o,this._targetRef=r,this._anchorRect=hc(this._connection.line.point1)}candidates(){return this._candidates}collectAndMarkCandidates(){this._candidates=this._mediator.execute(new _d(this._target,this._targetRef.rect.gravityCenter)),this._candidates.some(i=>i.connector.fId()===this._source.fId())||this._candidates.push(this._sourceRef),this._mediator.execute(new _n(this._candidates.map(i=>i.connector)))}setSnapConnection(i){this._snap=i,i&&(i.fInputId.set(this._connection.fInputId()),i.initialize())}onPointerMove(i){let e=this._anchorRect.addPoint(i),t=this._findClosest(e.gravityCenter),o=t?.connector.fConnectableSide??this._source.fConnectableSide;this._draw(e,o);let r=this._snap;r&&this._drawSnap(Nh(t,r))}_findClosest(i){return this._mediator.execute(new Vt(i,this._candidates))}_draw(i,e){let t=this._behaviour.handle(new Ye(i,this._targetRef.rect,this._connection,e,this._targetRef.connector.fConnectableSide,void 0,this._resolveRotationContext(this._targetRef.connector)));this._connection.setLine(t),this._connection.redraw()}_drawSnap(i){let e=this._snap;if(!e)return;if(!i){e.hide();return}let t=this._behaviour.handle(new Ye(i.rect,this._targetRef.rect,e,i.connector.fConnectableSide,this._target.fConnectableSide,this._resolveRotationContext(i.connector),this._resolveRotationContext(this._targetRef.connector)));e.show(),e.setLine(t),e.redraw()}onPointerUp(){this._draw(this._anchorRect,this._sourceRef.connector.fConnectableSide),this._snap?.hide(),this._mediator.execute(new mn(this._candidates.map(i=>i.connector)))}_resolveRotationContext(i){return this._mediator.execute(new ht(i))}},vu=class{_mediator;_behaviour;_connection;_sourceRef;_targetRef;_candidates=[];_snap;_anchorRect;get _source(){return this._sourceRef.connector}get _target(){return this._targetRef.connector}constructor(i,e,t,o,r){this._mediator=i,this._behaviour=e,this._connection=t,this._sourceRef=o,this._targetRef=r,this._anchorRect=hc(this._connection.line.point2)}candidates(){return this._candidates}collectAndMarkCandidates(){this._candidates=this._mediator.execute(new si(this._source,this._sourceRef.rect.gravityCenter));let i=this._connection.fInputId();i&&!this._candidates.some(e=>e.connector.fId()===i)&&this._candidates.push(this._targetRef),this._mediator.execute(new _n(this._candidates.map(e=>e.connector)))}setSnapConnection(i){this._snap=i,i&&(i.fOutputId.set(this._connection.fOutputId()),i.initialize())}onPointerMove(i){let e=this._anchorRect.addPoint(i),t=this._findClosest(e.gravityCenter),o=t?.connector.fConnectableSide??this._target.fConnectableSide;this._draw(e,o);let r=this._snap;r&&this._drawSnap(Nh(t,r))}onPointerUp(){this._draw(this._anchorRect,this._targetRef.connector.fConnectableSide),this._snap?.hide(),this._mediator.execute(new mn(this._candidates.map(i=>i.connector)))}_findClosest(i){return this._mediator.execute(new Vt(i,this._candidates))}_draw(i,e){let t=this._behaviour.handle(new Ye(this._sourceRef.rect,i,this._connection,this._source.fConnectableSide,e,this._resolveRotationContext(this._sourceRef.connector),void 0));this._connection.setLine(t),this._connection.redraw()}_drawSnap(i){let e=this._snap;if(!e)return;if(!i){e.hide();return}let t=this._behaviour.handle(new Ye(this._sourceRef.rect,i.rect,e,this._source.fConnectableSide,i.connector.fConnectableSide,this._resolveRotationContext(this._sourceRef.connector),this._resolveRotationContext(i.connector)));e.show(),e.setLine(t),e.redraw()}_resolveRotationContext(i){return this._mediator.execute(new ht(i))}},Cu=(()=>{class n extends Oe{type="reassign-connection";kind="reassign-connection";data(){return{fConnectionId:this._connection.fId()}}_result=c(St);_mediator=c(D);_connectionBehaviour=c(Cn);_store=c(x);get _snapConnection(){return this._store.connections.getForSnap()}_connection;_draggedEnd;_sourceRef;_targetRef;_reassignHandler;initialize(e,t){this._connection=e,this._draggedEnd=t?"target":"source",this._sourceRef=this._mediator.execute(new He(this._store.outputs.require(this._connection.fOutputId()))),this._targetRef=this._mediator.execute(new He(this._store.inputs.require(this._connection.fInputId()))),this._reassignHandler=this._draggedEnd==="target"?this._createTargetHandler():this._createSourceHandler()}_createSourceHandler(){return new yu(this._mediator,this._connectionBehaviour,this._connection,this._sourceRef,this._targetRef)}_createTargetHandler(){return new vu(this._mediator,this._connectionBehaviour,this._connection,this._sourceRef,this._targetRef)}prepareDragSequence(){this._reassignHandler.collectAndMarkCandidates(),this._reassignHandler.setSnapConnection(this._snapConnection),this._result.setData({draggedEnd:this._draggedEnd,sourceAnchorRect:hc(this._connection.line.point1),targetAnchorRect:hc(this._connection.line.point2),candidates:this._reassignHandler.candidates(),connection:this._connection})}onPointerMove(e){this._reassignHandler.onPointerMove(e)}onPointerUp(){this._reassignHandler.onPointerUp()}static \u0275fac=(()=>{let e;return function(o){return(e||(e=X(n)))(o||n)}})();static \u0275prov=f({token:n,factory:n.\u0275fac})}return n})(),I0=(()=>{let n=class vr{_mediator=c(D);_store=c(x);_dragContext=c(V);_dragInjector=c(Pe);get _canvas(){return this._store.fCanvas}get _transform(){return this._store.transform}get _connections(){return this._store.connections.getAll()}handle(e){if(!this._dragContext.isEmpty()||!this._isValidTrigger(e))return;let t=xn(e.event.getPosition(),this._store.flowHost,this._transform),o=this._findConnectionAt(t);o&&(this._capturePointerDown(e),this._startDrag(o,t),queueMicrotask(()=>this._bringToFront(o)))}_findConnectionAt(e){return this._connections.find(t=>w0(t,e))}_capturePointerDown(e){this._dragContext.onPointerDownScale=this._transform.scale,this._dragContext.onPointerDownPosition=j.fromPoint(e.event.getPosition()).elementTransform(this._store.flowHost).div(this._transform.scale)}_startDrag(e,t){let o=this._dragInjector.get(Cu);o.initialize(e,Mh(e,t)),this._dragContext.draggableItems=[o]}_isValidTrigger(e){return Ve(e.event.originalEvent,e.fTrigger)}_bringToFront(e){this._mediator.execute(new Wt(e,this._canvas.fConnectionsContainer().nativeElement))}static \u0275fac=function(t){return new(t||vr)};static \u0275prov=f({token:vr,factory:vr.\u0275fac})};return n=p([_(fc)],n),n})(),gc=class{event;static fToken=Symbol("DragConnectionWaypointFinalizeRequest");constructor(i){this.event=i}},pc=class{connectionId;waypoints;constructor(i,e){this.connectionId=i,this.waypoints=e}},_c=(()=>{class n extends Oe{type="move-connection-waypoint";kind="drag-connection-waypoint";_store=c(x);_point;_pick;get _waypointsComponent(){return this._pick?.connection.fWaypoints()}get _connection(){return this._pick?.connection}setPick(e){this._pick=e}prepareDragSequence(){this._pick?.candidate?(this._point=J({},this._pick.candidate),this._waypointsComponent.insert(this._pick.candidate)):this._pick?.waypoint&&(this._point=J({},this._pick.waypoint),this._waypointsComponent.select(this._pick.waypoint)),this._redrawConnection()}onPointerMove(e){this._waypointsComponent.move(M.sum(this._point,e)),this._redrawConnection()}onPointerUp(){this._waypointsComponent.update(),this._store.fDraggable?.fConnectionWaypointsChanged.emit(this._eventFromPick())}_redrawConnection(){this._connection.setLine(this._connection.line),this._connection.redraw()}_eventFromPick(){return new pc(this._connection.fId(),this._connection.fWaypoints()?.waypoints()||[])}static \u0275fac=(()=>{let e;return function(o){return(e||(e=X(n)))(o||n)}})();static \u0275prov=f({token:n,factory:n.\u0275fac})}return n})(),S0=(()=>{let n=class Cr{_dragContext=c(V);get _fDragHandler(){return this._dragContext.draggableItems[0]}handle(e){this._isDroppedConnectionReassignEvent()&&this._fDragHandler.onPointerUp()}_isDroppedConnectionReassignEvent(){return this._dragContext.draggableItems.some(e=>e instanceof _c)}static \u0275fac=function(t){return new(t||Cr)};static \u0275prov=f({token:Cr,factory:Cr.\u0275fac})};return n=p([_(gc)],n),n})(),mc=class{event;fTrigger;static fToken=Symbol("DragConnectionWaypointPreparationRequest");constructor(i,e){this.event=i,this.fTrigger=e}},D0=(()=>{let n=class xr{_mediator=c(D);_store=c(x);_dragContext=c(V);_dragInjector=c(Pe);get _canvas(){return this._store.fCanvas}get _transform(){return this._canvas.transform}get _flowHost(){return this._store.flowHost}get _connections(){return this._store.connections.getAll()}handle(e){let t=xn(e.event.getPosition(),this._flowHost,this._transform),o=this._pickControlPoint(t);if(!o||!this._isValidTrigger(e))return;let r=this._dragInjector.get(_c);r.setPick(o),this._dragContext.onPointerDownScale=this._transform.scale,this._dragContext.onPointerDownPosition=j.fromPoint(e.event.getPosition()).elementTransform(this._flowHost).div(this._transform.scale),this._dragContext.draggableItems=[r],queueMicrotask(()=>this._updateConnectionLayer(o.connection))}_pickControlPoint(e){if(this._dragContext.isEmpty())return Qp(this._connections,e)}_isValidTrigger(e){return Ve(e.event.originalEvent,e.fTrigger)}_updateConnectionLayer(e){this._mediator.execute(new Wt(e,this._canvas.fConnectionsContainer().nativeElement))}static \u0275fac=function(t){return new(t||xr)};static \u0275prov=f({token:xr,factory:xr.\u0275fac})};return n=p([_(mc)],n),n})(),T0=[_0,m0,y0,p0,v0,C0,x0,I0,D0,S0],yc=class{event;static fToken=Symbol("DropToGroupFinalizeRequest");constructor(i){this.event=i}},E0=1,Yn=(()=>{class n extends Oe{type="move-node-to-parent";kind="assign-to-container";_store=c(x);_dragSession=c(V);get _transform(){return this._store.transform}_candidateGroups=[];_debounceTimer=null;_activeTarget=null;get activeTarget(){return this._activeTarget}initialize(e){this._candidateGroups=e}prepareDragSequence(){for(let{node:e}of this._candidateGroups)e.hostElement.classList.add(Ce.GROUPING.DROP_ACTIVE)}onPointerMove(e){this._debounceTimer&&clearTimeout(this._debounceTimer),this._debounceTimer=setTimeout(()=>this._updateActiveTarget(e),E0)}onPointerUp(){this._clearActiveTarget();for(let{node:e}of this._candidateGroups)e.hostElement.classList.remove(Ce.GROUPING.DROP_ACTIVE);this._debounceTimer&&(clearTimeout(this._debounceTimer),this._debounceTimer=null)}_updateActiveTarget(e){let t=this._getPointerInFlow(e),o=this._findTargetUnderPointer(t);o?this._setActiveTarget(o):this._clearActiveTarget()}_getPointerInFlow(e){let t=j.fromPoint(this._dragSession.onPointerDownPosition).add(e),o=j.fromPoint(this._transform.position).add(this._transform.scaledPosition).div(this._transform.scale);return t.sub(o)}_findTargetUnderPointer(e){return this._candidateGroups.find(t=>z.isIncludePoint(t.rect,e))}_setActiveTarget(e){this._activeTarget?.node!==e.node&&(this._clearActiveTarget(),this._activeTarget=e,e.node.setClass(Ce.GROUPING.OVER_BOUNDARY))}_clearActiveTarget(){this._activeTarget?.node.removeClass(Ce.GROUPING.OVER_BOUNDARY),this._activeTarget=null}static \u0275fac=(()=>{let e;return function(o){return(e||(e=X(n)))(o||n)}})();static \u0275prov=f({token:n,factory:n.\u0275fac})}return n})(),vc=class{nodesAndGroups;static fToken=Symbol("CreateDragNodeHierarchyRequest");constructor(i){this.nodesAndGroups=i}},xu=class{rootHandlers;participants;constructor(i,e){this.rootHandlers=i,this.participants=e}},wu=class{fNodeIds;constructor(i){this.fNodeIds=i}},qu="move-node",Yu="drag-node";function P0(n){return n.getEvent().kind===Yu||n.getEvent().fEventType===qu}var It=(()=>{class n extends Oe{type=qu;kind=Yu;data(){return new wu(this.items.map(e=>e.nodeOrGroup.fId()))}_magneticLines=null;_magneticRects=null;items;roots;initialize(e,t){this.items=e,this.roots=t}setMagneticLines(e){this._magneticLines=e}setMagneticRects(e){this._magneticRects=e}calculateMagneticLinesGuides(e){return this.calculateMagneticSnaps(e).lines}calculateMagneticSnaps(e){this._previewRoots(e);let t=this._rootsUnionRect();return{lines:this._magneticLines?._computeGuides(t),rects:this._magneticRects?._computeRects(t)}}prepareDragSequence(){for(let e of this.roots)e.prepareDragSequence()}onPointerMove(e){this._previewRoots(e);let t=this._rootsUnionRect();this._magneticLines?.scheduleRender(t),this._magneticRects?.scheduleRender(t)}onPointerUp(){for(let e of this.roots)e.onPointerUp();this._magneticLines?.clearGuides(),this._magneticRects?.clearGuides(),requestAnimationFrame(()=>this._refreshDraggedNodes())}_previewRoots(e){for(let t of this.roots)t.onPointerMove(e)}_rootsUnionRect(){let e=null;for(let t of this.roots){let o=t.getLastRect();e=e?z.union([e,o]):o}return e??z.initialize()}_refreshDraggedNodes(){for(let{nodeOrGroup:e}of this.roots)e.refresh()}destroy(){for(let e of this.roots??[])e.destroy?.()}static \u0275fac=(()=>{let e;return function(o){return(e||(e=X(n)))(o||n)}})();static \u0275prov=f({token:n,factory:n.\u0275fac})}return n})(),Cc=class{_limits;_quantizeStep;constructor(i,e=.5){this._limits=i,this._quantizeStep=e}applyInto(i,e){let{min:t,max:o}=this._limits,r=this._clamp(i.x,t.x,o.x),s=this._clamp(i.y,t.y,o.y),a=i.x-r,d=i.y-s,l=this._quantizeSigned(a,this._quantizeStep),u=this._quantizeSigned(d,this._quantizeStep);e.value.x=r,e.value.y=s,e.edges.left=l<0,e.edges.right=l>0,e.edges.top=u<0,e.edges.bottom=u>0,e.overflow.x=Math.abs(l),e.overflow.y=Math.abs(u)}_quantizeSigned(i,e){if(e<=0||i===0)return 0;let t=i/e;return(i>0?Math.ceil(t):Math.floor(t))*e}_clamp(i,e,t){return Math.min(Math.max(i,e),t)}},bu=class{_pointerDown;_vCellSize;_hCellSize;_snapWhileDragging;constructor(i,e){this._pointerDown=e,this._vCellSize=i.vCellSize(),this._hCellSize=i.hCellSize(),this._snapWhileDragging=i.fCellSizeWhileDragging()}snap(i,e){let t=e||this._snapWhileDragging;return this._strategies[+t](i)}_strategies={0:this._noSnap.bind(this),1:this._snapWithCellSize.bind(this)};_snapWithCellSize(i){return{x:this._snapToGrid(this._pointerDown.x+i.x,this._hCellSize)-this._pointerDown.x,y:this._snapToGrid(this._pointerDown.y+i.y,this._vCellSize)-this._pointerDown.y}}_noSnap(i){return i}_snapToGrid(i,e){return Math.round(i/e)*e}};function $f(){return{value:{x:0,y:0},overflow:{x:0,y:0},edges:{left:!1,right:!1,top:!1,bottom:!1}}}var Iu=class{_snapper;_hardClamp;_hardResult=$f();_softClamps=[];_softResults=[];constructor(i,e,t){let o=i.get(x).fDraggable;this._snapper=new bu(o,e),this._hardClamp=new Cc(t.hard,.5);for(let r of t.soft)this._softClamps.push(new Cc(r.limits,.5)),this._softResults.push($f())}apply(i,e=!1){let t=this._snapper.snap(i,e);this._hardClamp.applyInto(t,this._hardResult);let o={x:this._hardResult.value.x,y:this._hardResult.value.y};for(let r=0;r<this._softClamps.length;r++)this._softClamps[r].applyInto(o,this._softResults[r]);return{hardDelta:o,soft:this._softResults}}finalize(i){return this.apply(i,!0)}};function Xf(n,i,e){let{x:t,y:o,width:r,height:s}=n;return e.right&&i.x>0&&(r+=i.x),e.left&&i.x>0&&(t-=i.x,r+=i.x),e.bottom&&i.y>0&&(s+=i.y),e.top&&i.y>0&&(o-=i.y,s+=i.y),z.initialize(t,o,r,s)}var Su=class extends Oe{_injector;nodeOrGroup;children;sourceConnectionHandlers;targetConnectionHandlers;type=qu;kind=Yu;_startPosition=M.initialize();_startRect=z.initialize();_applyConstraints=i=>i;_lastSoftResults=[];_deltaConstraints;_constraints;_lastPosition=M.initialize();_softParentConnectionHandlers=[];_mediator;constructor(i,e,t=[],o=[],r=[]){super(),this._injector=i,this.nodeOrGroup=e,this.children=t,this.sourceConnectionHandlers=o,this.targetConnectionHandlers=r,this._mediator=i.get(D),this._startRect=this._mediator.execute(new de(e.hostElement)),this._startPosition=J({},e._position)}setConstraints(i){this._constraints=i,this._deltaConstraints=new Iu(this._injector,this._startPosition,i),this._applyConstraints=e=>{let t=this._deltaConstraints.apply(e);return this._applySoftExpansions(t.soft),t.hardDelta}}setSoftParentConnectionHandlers(i){this._softParentConnectionHandlers=i}finalizeConstraints(){this._applyConstraints=i=>{let e=this._deltaConstraints.finalize(i);return this._applySoftExpansions(e.soft),e.hardDelta}}getLastRect(){return z.initialize(this._lastPosition.x,this._lastPosition.y,this._startRect.width,this._startRect.height)}prepareDragSequence(){for(let i of this.children)i.prepareDragSequence();this.nodeOrGroup.hostElement.classList.add(Ce.DRAG_AND_DROP.DRAGGING)}onPointerMove(i){let e=this._applyConstraints(i);for(let t of this.children)t.onPointerMove(e);this._redraw(this._startPlus(e));for(let t of this.sourceConnectionHandlers)t.setSourceDelta(e);for(let t of this.targetConnectionHandlers)t.setTargetDelta(e)}onPointerUp(){for(let i of this.children)i.onPointerUp();this.nodeOrGroup.position.set(this.nodeOrGroup._position),this.nodeOrGroup.hostElement.classList.remove(Ce.DRAG_AND_DROP.DRAGGING),this._emitExpandedEvent()}_startPlus(i){return M.sum(this._startPosition,i)}_redraw(i){this._lastPosition=i,this.nodeOrGroup.updatePosition(i),this._mediator.execute(new Gt(this.nodeOrGroup.fId(),z.initialize(i.x,i.y,this._startRect.width,this._startRect.height))),this.nodeOrGroup.redraw()}_applySoftExpansions(i){this._lastSoftResults=i;for(let e=0;e<i.length;e++){let t=i[e],o=this._constraints.soft[e],r=Xf(o.boundingRect,t.overflow,t.edges);this._commitParentRect(o.nodeOrGroup,r)&&this._updateParentConnectionHandlers(e)}}_commitParentRect(i,e){let t=i._position.x!==e.x||i._position.y!==e.y||i._size?.width!==e.width||i._size?.height!==e.height;return i.updateSize({width:e.width,height:e.height}),i.updatePosition({x:e.x,y:e.y}),this._mediator.execute(new Gt(i.fId(),e)),i.redraw(),t}_updateParentConnectionHandlers(i){let e=this._softParentConnectionHandlers[i];if(!e)return;let t=new Map;for(let o of e.source){let r=this._readConnectorRect(o.connector,t);o.handler.setSourceDelta(this._buildDelta(o.baselineRect,r))}for(let o of e.target){let r=this._readConnectorRect(o.connector,t);o.handler.setTargetDelta(this._buildDelta(o.baselineRect,r))}}_readConnectorRect(i,e){let t=`${i.kind}::${i.fId()}`,o=e.get(t);if(o)return o;let r=this._mediator.execute(new He(i)).rect;return e.set(t,r),r}_buildDelta(i,e){return M.initialize(e.x-i.x,e.y-i.y)}_emitExpandedEvent(){for(let i=0;i<this._lastSoftResults.length;i++){let e=this._lastSoftResults[i];if(!e.overflow.x&&!e.overflow.y)continue;let t=this._constraints.soft[i],o=Xf(t.boundingRect,e.overflow,e.edges);t.nodeOrGroup.sizeChange.emit(o)}}destroy(){for(let i of this.children)i.destroy?.();this.children=[],this.sourceConnectionHandlers=[],this.targetConnectionHandlers=[],this._lastSoftResults=[],this._applyConstraints=i=>i,this._softParentConnectionHandlers=[]}},M0=(()=>{let n=class wr{_injector=c(Ae);handle({nodesAndGroups:e}){let t=this._createHandlerByNodeId(e),o=this._linkParentsAndCollectRoots(e,t);return new xu(o,Array.from(t.values()))}_createHandlerByNodeId(e){let t=new Map;for(let o of e)t.set(o.fId(),new Su(this._injector,o));return t}_linkParentsAndCollectRoots(e,t){let o=[];for(let r of e){let s=t.get(r.fId());if(!s)continue;let a=r.fParentId(),d=a?t.get(a):void 0;d?d.children.push(s):o.push(s)}return o}static \u0275fac=function(t){return new(t||wr)};static \u0275prov=f({token:wr,factory:wr.\u0275fac})};return n=p([_(vc)],n),n})(),xc=class{nodeOrGroup;static fToken=Symbol("BuildDragNodeConstraintsRequest");constructor(i){this.nodeOrGroup=i}},Kn=class{nodeOrGroup;childrenPaddings;static fToken=Symbol("ReadNodeBoundsWithPaddingsRequest");constructor(i,e){this.nodeOrGroup=i,this.childrenPaddings=e}},Du=class{nodeOrGroup;boundingRect;innerRect;paddings;constructor(i,e,t,o){this.nodeOrGroup=i,this.boundingRect=e,this.innerRect=t,this.paddings=o}},R0=(()=>{let n=class br{_mediator=c(D);handle({nodeOrGroup:e,childrenPaddings:t}){let o=this._readBoundingRect(e),r=this._readOwnPaddings(e,o),s=[r[0]+t[0],r[1]+t[1],r[2]+t[2],r[3]+t[3]],a=z.initialize(o.x+s[0],o.y+s[1],o.width-s[0]-s[2],o.height-s[1]-s[3]);return new Du(e,o,a,s)}_readBoundingRect(e){return this._mediator.execute(new de(e.hostElement))}_readOwnPaddings(e,t){return this._mediator.execute(new Ut(e,t))}static \u0275fac=function(t){return new(t||br)};static \u0275prov=f({token:br,factory:br.\u0275fac})};return n=p([_(Kn)],n),n})(),N0=(()=>{let n=class Ir{_mediator=c(D);handle({nodeOrGroup:e}){let t=this._readCurrentRect(e),o=this._readParentsChain(e);return this._buildConstraints(o,t)}_readCurrentRect(e){return this._mediator.execute(new de(e.hostElement))}_readParentsChain(e){return this._mediator.execute(new pn(e))??[]}_buildConstraints(e,t){let o=[],r=wh(),s=[0,0,0,0];for(let a of e){let d=this._readParentBounds(a,s);s=d.paddings;let l=this._calculateDifference(d.innerRect,t);if(this._isAutoExpand(a))o.push(this._makeSoftLimit(a,d.boundingRect,l));else{r=l;break}}return{soft:o,hard:r}}_readParentBounds(e,t){return this._mediator.execute(new Kn(e,t))}_calculateDifference(e,t){return{min:this._calculateMinimumDifference(e,t),max:this._calculateMaximumDifference(e,t)}}_calculateMinimumDifference(e,t){return M.initialize(e.x-t.x,e.y-t.y)}_calculateMaximumDifference(e,t){return M.initialize(e.x+e.width-(t.x+t.width),e.y+e.height-(t.y+t.height))}_isAutoExpand(e){return e.fAutoExpandOnChildHit()}_makeSoftLimit(e,t,o){return{nodeOrGroup:e,boundingRect:t,initialSize:e._size,limits:o}}static \u0275fac=function(t){return new(t||Ir)};static \u0275prov=f({token:Ir,factory:Ir.\u0275fac})};return n=p([_(xc)],n),n})(),wc=class{rootHandlers;participants;static fToken=Symbol("CreateDragNodeHandlerRequest");constructor(i,e){this.rootHandlers=i,this.participants=e}},bc=class{dragHandler;constraints;handlerPool;static fToken=Symbol("AttachSoftParentConnectionDragHandlersToNodeRequest");constructor(i,e,t){this.dragHandler=i,this.constraints=e,this.handlerPool=t}},Zn=class{_mediator=c(D);_store=c(x);_behaviour=c(Cn);_source;_target;_sourceRef;_targetRef;_sourceDelta=M.initialize();_targetDelta=M.initialize();connection;initialize(i){this.connection=i,this._source=this._store.outputs.require(this.connection.fOutputId()),this._target=this._store.inputs.require(this.connection.fInputId()),this._sourceRef=this._readRectRef(this._source),this._targetRef=this._readRectRef(this._target)}setSourceDelta(i){this._sourceDelta=i,this._mediator.execute(new Bt(this._source.fId(),this._source.kind,this._withDelta(this._sourceRef.rect,i)))}setTargetDelta(i){this._targetDelta=i,this._mediator.execute(new Bt(this._target.fId(),this._target.kind,this._withDelta(this._targetRef.rect,i)))}redraw(){let i=this._buildLine();this.connection.setLine(i),this.connection.redraw()}_buildLine(){let i=ge.fromRoundedRect(this._sourceRef.rect).addPoint(this._sourceDelta),e=ge.fromRoundedRect(this._targetRef.rect).addPoint(this._targetDelta);return this._behaviour.handle(new Ye(i,e,this.connection,this._sourceRef.connector.fConnectableSide,this._targetRef.connector.fConnectableSide,this._resolveRotationContext(this._sourceRef.connector),this._resolveRotationContext(this._targetRef.connector)))}_readRectRef(i){return this._mediator.execute(new He(i))}_withDelta(i,e){return ge.fromRoundedRect(i).addPoint(e)}_resolveRotationContext(i){return this._mediator.execute(new ht(i))}},Qn=(()=>{class n extends Zn{setSourceDelta(e){super.setSourceDelta(e),super.redraw()}static \u0275fac=(()=>{let e;return function(o){return(e||(e=X(n)))(o||n)}})();static \u0275prov=f({token:n,factory:n.\u0275fac})}return n})(),Jn=(()=>{class n extends Zn{_sourceUpdated=!1;_targetUpdated=!1;setSourceDelta(e){super.setSourceDelta(e),this._sourceUpdated=!0,this._redrawIfReady()}setTargetDelta(e){super.setTargetDelta(e),this._targetUpdated=!0,this._redrawIfReady()}_redrawIfReady(){!this._sourceUpdated||!this._targetUpdated||(this._sourceUpdated=!1,this._targetUpdated=!1,this.redraw())}static \u0275fac=(()=>{let e;return function(o){return(e||(e=X(n)))(o||n)}})();static \u0275prov=f({token:n,factory:n.\u0275fac})}return n})(),ei=(()=>{class n extends Zn{setTargetDelta(e){super.setTargetDelta(e),this.redraw()}static \u0275fac=(()=>{let e;return function(o){return(e||(e=X(n)))(o||n)}})();static \u0275prov=f({token:n,factory:n.\u0275fac})}return n})(),k0=(()=>{let n=class Sr{_store=c(x);_mediator=c(D);_dragInjector=c(Pe);handle({dragHandler:e,constraints:t,handlerPool:o}){let r=t.soft.map(s=>this._buildParentConnectionHandlers(s.nodeOrGroup,o));e.setSoftParentConnectionHandlers(r)}_buildParentConnectionHandlers(e,t){let o=this._store.outputs.getAll().filter(u=>u.fNodeId===e.fId()),r=this._store.inputs.getAll().filter(u=>u.fNodeId===e.fId());if(!o.length&&!r.length)return{source:[],target:[]};let s=new Set(o.map(u=>u.fId())),a=new Set(r.map(u=>u.fId())),d=new Map,l={source:[],target:[]};for(let u of this._store.connections.getAll()){let g=s.has(u.fOutputId()),y=a.has(u.fInputId());if(!g&&!y)continue;let C=this._getExistingConnectionHandler(t,u);if(C||(C=this._createConnectionHandler(u,g,y),t.push(C)),g){let E=this._store.outputs.require(u.fOutputId());l.source.push({handler:C,connector:E,baselineRect:this._readConnectorRect(E,d)})}if(y){let E=this._store.inputs.require(u.fInputId());l.target.push({handler:C,connector:E,baselineRect:this._readConnectorRect(E,d)})}}return l}_getExistingConnectionHandler(e,t){return e.find(o=>o.connection.fId()===t.fId())}_createConnectionHandler(e,t,o){let r;return t&&o?r=this._dragInjector.createInstance(Jn):t?r=this._dragInjector.createInstance(Qn):r=this._dragInjector.createInstance(ei),r.initialize(e),r}_readConnectorRect(e,t){let o=`${e.kind}::${e.fId()}`,r=t.get(o);if(r)return r;let s=this._mediator.execute(new He(e)).rect;return t.set(o,s),s}static \u0275fac=function(t){return new(t||Sr)};static \u0275prov=f({token:Sr,factory:Sr.\u0275fac})};return n=p([_(bc)],n),n})(),O0=(()=>{let n=class Dr{_dragInjector=c(Pe);_mediator=c(D);handle({rootHandlers:e,participants:t}){let o=this._collectConnectionHandlers(t);this._applyConstraintsToRoots(e,o);let r=this._dragInjector.createInstance(It);return r.initialize(t,e),r}_applyConstraintsToRoots(e,t){for(let o of e){let r=this._calculateConstraints(o.nodeOrGroup);o.setConstraints(r),this._attachSoftParentConnectionHandlers(o,r,t)}}_collectConnectionHandlers(e){let t=new Map;for(let o of e){for(let r of o.sourceConnectionHandlers)t.set(r.connection.fId(),r);for(let r of o.targetConnectionHandlers)t.set(r.connection.fId(),r)}return Array.from(t.values())}_attachSoftParentConnectionHandlers(e,t,o){this._mediator.execute(new bc(e,t,o))}_calculateConstraints(e){return this._mediator.execute(new xc(e))}static \u0275fac=function(t){return new(t||Dr)};static \u0275prov=f({token:Dr,factory:Dr.\u0275fac})};return n=p([_(wc)],n),n})(),Ic=class{dragHandler;sourceIds;handlerPool;static fToken=Symbol("AttachTargetConnectionDragHandlersToNodeRequest");constructor(i,e,t){this.dragHandler=i,this.sourceIds=e,this.handlerPool=t}},F0=(()=>{let n=class Tr{_store=c(x);_dragInjector=c(Pe);get _connections(){return this._store.connections.getAll()}handle(e){this._getInputConnections(e.dragHandler.nodeOrGroup).forEach(t=>{this._createAndSetConnectionToNodeHandler(t,e)})}_getInputConnections(e){let t=new Set(this._getNodeInputIds(e));return this._connections.filter(o=>t.has(o.fInputId()))}_getNodeInputIds(e){return this._store.inputs.getAll().filter(t=>e.isContains(t.hostElement)).map(t=>t.fId())}_createAndSetConnectionToNodeHandler(e,t){let o=this._getExistingConnectionHandler(t.handlerPool,e);o||(o=this._createConnectionHandler(t.sourceIds,e),t.handlerPool.push(o)),t.dragHandler.targetConnectionHandlers.push(o)}_getExistingConnectionHandler(e,t){return e.find(o=>o.connection.fId()===t.fId())}_createConnectionHandler(e,t){let o;return e.includes(t.fOutputId())?o=this._dragInjector.createInstance(Jn):o=this._dragInjector.createInstance(ei),o.initialize(t),o}static \u0275fac=function(t){return new(t||Tr)};static \u0275prov=f({token:Tr,factory:Tr.\u0275fac})};return n=p([_(Ic)],n),n})(),Sc=class{dragHandler;targetIds;handlerPool;static fToken=Symbol("AttachSourceConnectionDragHandlersToNodeRequest");constructor(i,e,t){this.dragHandler=i,this.targetIds=e,this.handlerPool=t}},A0=(()=>{let n=class Er{_store=c(x);_dragInjector=c(Pe);get _connections(){return this._store.connections.getAll()}handle(e){this._getOutputConnections(e.dragHandler.nodeOrGroup).forEach(t=>{this._createAndSetConnectionToNodeHandler(t,e)})}_getOutputConnections(e){let t=new Set(this._getNodeOutputIds(e));return this._connections.filter(o=>t.has(o.fOutputId()))}_getNodeOutputIds(e){return this._store.outputs.getAll().filter(t=>e.isContains(t.hostElement)).map(t=>t.fId())}_createAndSetConnectionToNodeHandler(e,t){let o=this._getExistingConnectionHandler(t.handlerPool,e);o||(o=this._createConnectionHandler(t.targetIds,e),t.handlerPool.push(o)),t.dragHandler.sourceConnectionHandlers.push(o)}_getExistingConnectionHandler(e,t){return e.find(o=>o.connection.fId()===t.fId())}_createConnectionHandler(e,t){let o;return e.includes(t.fInputId())?o=this._dragInjector.createInstance(Jn):o=this._dragInjector.createInstance(Qn),o.initialize(t),o}static \u0275fac=function(t){return new(t||Er)};static \u0275prov=f({token:Er,factory:Er.\u0275fac})};return n=p([_(Sc)],n),n})(),Dc=class{nodeOrGroup;static fToken=Symbol("AttachDragNodeHandlerFromSelectionRequest");constructor(i){this.nodeOrGroup=i}},L0=(()=>{let n=class Pr{_mediator=c(D);_store=c(x);_dragSession=c(V);handle({nodeOrGroup:e}){let t=this._collectSelected(e),o=this._withDeepChildren(t),r=this._mediator.execute(new vc(o)),s=this._collectSourceConnectorIds(o),a=this._collectTargetConnectorIds(o);return this._attachConnectionHandlers(r.participants,s,a),this._mediator.execute(new wc(r.rootHandlers,r.participants))}_collectSelected(e){let t=[];for(let o of this._dragSession.selectedItems){let r=this._findNodeByHost(o.hostElement);r&&t.push(r)}return e&&!t.includes(e)&&t.push(e),t}_findNodeByHost(e){return this._store.nodes.getAll().find(t=>t.isContains(e))}_withDeepChildren(e){let t=[];for(let o of e){t.push(o);let r=this._mediator.execute(new vn(o.fId()));t.push(...r)}return t}_collectSourceConnectorIds(e){return xl(e,t=>this._store.outputs.getAll().filter(o=>o.fNodeId===t.fId()).map(o=>o.fId()))}_collectTargetConnectorIds(e){return xl(e,t=>this._store.inputs.getAll().filter(o=>o.fNodeId===t.fId()).map(o=>o.fId()))}_attachConnectionHandlers(e,t,o){let r=[];for(let s of e)this._mediator.execute(new Sc(s,o,r)),this._mediator.execute(new Ic(s,t,r))}static \u0275fac=function(t){return new(t||Pr)};static \u0275prov=f({token:Pr,factory:Pr.\u0275fac})};return n=p([_(Dc)],n),n})(),z0=[M0,N0,O0,F0,A0,k0,R0,L0];function B0(n,i,e=10){let t=i.x,o=i.y,r=t+i.width,s=o+i.height,a=i.gravityCenter.x,d=i.gravityCenter.y,l,u,g=1/0,y,C,E=1/0,b=(I,P)=>{let L=P<0?-P:P;L<=e&&L<g&&(g=L,l=I,u=P)},w=(I,P)=>{let L=P<0?-P:P;L<=e&&L<E&&(E=L,y=I,C=P)};for(let I=0;I<n.length;I++){let P=n[I],L=P.x,B=P.y,H=L+P.width,W=B+P.height,le=P.gravityCenter.x,K=P.gravityCenter.y;b(L,t-L),b(H,t-H),b(le,a-le),b(L,r-L),b(H,r-H),w(B,o-B),w(W,o-W),w(K,d-K),w(B,s-B),w(W,s-W)}return{x:{guide:l,delta:u},y:{guide:y,delta:C}}}var qf=["left","top","width","height"],Tc=class{_element;constructor(i,e,t="f-line"){this._element=i.document.createElement("div"),this._element.classList.add(t),this._element.style.position="absolute",this._element.style.display="none",e.appendChild(this._element)}show(){this._element.style.display="block"}hide(){this._element.style.display="none"}render(i){for(let e of qf){let t=i[e];t!=null&&(this._element.style[e]=`${t}px`)}}clearRect(){for(let i of qf)this._element.style.removeProperty(i)}destroy(){this._element.remove()}},Tu=class{_horizontal;_vertical;constructor(i,e){this._horizontal=new Tc(i,e),this._vertical=new Tc(i,e),this._horizontal.hide(),this._vertical.hide()}drawVerticalLine(i,e,t){this._vertical.show(),this._vertical.render({left:i*t.scale+t.position.x+t.scaledPosition.x,top:0,width:1,height:e.height})}drawHorizontalLine(i,e,t){this._horizontal.show(),this._horizontal.render({left:0,top:i*t.scale+t.position.y+t.scaledPosition.y,width:e.width,height:1})}hideVertical(){this._vertical.hide()}hideHorizontal(){this._horizontal.hide()}hideAll(){this._vertical.hide(),this._horizontal.hide()}destroy(){this._vertical.destroy(),this._horizontal.destroy()}},Ec=class{static fToken=Symbol("MagneticLinesPreparationRequest")},G0=(()=>{let n=class Mr{_mediator=c(D);_store=c(x);_browser=c(pe);_injector=c(Ae);_dragSession=c(V);_renderer;handle(e){let t=this._store.instances.get(ae.MAGNETIC_LINES);if(!t)return;let o=this._dragSession.draggableItems.find(r=>r instanceof It);o&&o.setMagneticLines(new Eu(this._injector,this._renderer??this._createRenderer(t),this._flowHostSize(),this._notDraggedRects(this._draggedNodes(o.items))))}_draggedNodes(e){return e.map(t=>t.nodeOrGroup)}_flowHostSize(){return this._store.flowHost.getBoundingClientRect()}_createRenderer({hostElement:e}){return this._renderer=new Tu(this._browser,e),this._renderer}_notDraggedRects(e){let t=new Set(e);return this._store.nodes.getAll().filter(r=>!t.has(r)).map(r=>this._mediator.execute(new de(r.hostElement)))}static \u0275fac=function(t){return new(t||Mr)};static \u0275prov=f({token:Mr,factory:Mr.\u0275fac})};return n=p([_(Ec)],n),n})(),Eu=class{_renderer;_size;_rects;_timerId=null;_canvasTransform;_alignThreshold=10;constructor(i,e,t,o){this._renderer=e,this._size=t,this._rects=o;let r=i.get(x);this._alignThreshold=r.instances.require(ae.MAGNETIC_LINES).threshold(),this._canvasTransform=r.transform}scheduleRender(i){this._timerId&&clearTimeout(this._timerId),this._timerId=setTimeout(()=>this._renderGuides(this._computeGuides(i)),15)}_renderGuides(i){this._renderVertical(i),this._renderHorizontal(i)}_renderVertical(i){i.x.guide!==void 0?this._renderer.drawVerticalLine(i.x.guide,this._size,this._canvasTransform):this._renderer.hideVertical()}_renderHorizontal(i){i.y.guide!==void 0?this._renderer.drawHorizontalLine(i.y.guide,this._size,this._canvasTransform):this._renderer.hideHorizontal()}_computeGuides(i){return B0(this._rects,i,this._alignThreshold)}clearGuides(){this._renderer.hideAll(),this._timerId&&(clearTimeout(this._timerId),this._timerId=null)}},Yf=["top","center","bottom"],Kf=["left","center","right"];function H0(n,i,e=10,t=10){let o=i.x,r=i.y,s=o+i.width,a=r+i.height,d=i.gravityCenter.x,l=i.gravityCenter.y,u=j0(n,i,o,r,s,a,d,l,e,t),g=V0(n,i,o,r,s,a,d,l,e,t);return u&&(!g||u.absDelta<=g.absDelta)?{axis:"x",delta:u.delta,gap:u.gap,rects:u.rects,alignMode:u.alignMode,crossDelta:u.crossDelta}:g?{axis:"y",delta:g.delta,gap:g.gap,rects:g.rects,alignMode:g.alignMode,crossDelta:g.crossDelta}:{rects:[]}}function j0(n,i,e,t,o,r,s,a,d,l){let u=1/0,g,y=0,C,E=[],b=0,w=[],I=[],P=[];for(let L=0;L<Yf.length;L++){let B=L===0?t:L===1?a:r;w.length=0,I.length=0,P.length=0;let H=1/0,W=-1/0,le=0,K=1/0,Ee=1/0;for(let Q=0;Q<n.length;Q++){let q=n[Q],In=L===0?q.y:L===1?q.gravityCenter.y:q.y+q.height,ul=B-In,st=on(ul);if(st>d)continue;w.push(Q),I.push(q.x),P.push(q.x+q.width);let Sn=q.y,Dn=q.y+q.height;Sn<H&&(H=Sn),Dn>W&&(W=Dn),(st<K||st===K&&Q<Ee)&&(K=st,le=In,Ee=Q)}let $=w.length;if($<2)continue;kh(w,I,P);let Y=0;for(;Y<$&&I[Y]<=s;)Y++;let Me=Y>0&&Y<$,ie,ze;Me?(ie=Y-1,ze=Y):Y<=0?(ie=0,ze=1):(ie=$-2,ze=$-1);let Be=I[ze]-P[ie];if(Be<0)continue;let we;if(Me){we=P[ie]+Be;let Q=we+i.width,q=I[ze]-Q;if(on(q-Be)>l)continue}else Y<=0?we=I[0]-Be-i.width:we=P[$-1]+Be;let bn=e-we,Tt=on(bn);if(Tt>l||Tt>=u)continue;let Ue=U0(w,I,P,H,W);if(Me){let Q=we,q=we+i.width;Ue.push({left:P[ie],top:H,width:Q-P[ie],height:W-H}),Ue.push({left:q,top:H,width:I[ze]-q,height:W-H})}else if(Y<=0){let Q=we+i.width;Ue.push({left:Q,top:H,width:I[0]-Q,height:W-H})}else Ue.push({left:P[$-1],top:H,width:we-P[$-1],height:W-H});let ll=B-le;u=Tt,g=bn,y=Be,C=Yf[L],E=Ue,b=ll}if(!(g===void 0||C===void 0))return{delta:g,absDelta:u,gap:y,rects:E,alignMode:C,crossDelta:b}}function V0(n,i,e,t,o,r,s,a,d,l){let u=1/0,g,y=0,C,E=[],b=0,w=[],I=[],P=[];for(let L=0;L<Kf.length;L++){let B=L===0?e:L===1?s:o;w.length=0,I.length=0,P.length=0;let H=1/0,W=-1/0,le=0,K=1/0,Ee=1/0;for(let Q=0;Q<n.length;Q++){let q=n[Q],In=L===0?q.x:L===1?q.gravityCenter.x:q.x+q.width,ul=B-In,st=on(ul);if(st>d)continue;w.push(Q),I.push(q.y),P.push(q.y+q.height);let Sn=q.x,Dn=q.x+q.width;Sn<H&&(H=Sn),Dn>W&&(W=Dn),(st<K||st===K&&Q<Ee)&&(K=st,le=In,Ee=Q)}let $=w.length;if($<2)continue;kh(w,I,P);let Y=0;for(;Y<$&&I[Y]<=a;)Y++;let Me=Y>0&&Y<$,ie,ze;Me?(ie=Y-1,ze=Y):Y<=0?(ie=0,ze=1):(ie=$-2,ze=$-1);let Be=I[ze]-P[ie];if(Be<0)continue;let we;if(Me){we=P[ie]+Be;let Q=we+i.height,q=I[ze]-Q;if(on(q-Be)>l)continue}else Y<=0?we=I[0]-Be-i.height:we=P[$-1]+Be;let bn=t-we,Tt=on(bn);if(Tt>l||Tt>=u)continue;let Ue=W0(w,I,P,H,W);if(Me){let Q=we,q=we+i.height;Ue.push({left:H,top:P[ie],width:W-H,height:Q-P[ie]}),Ue.push({left:H,top:q,width:W-H,height:I[ze]-q})}else if(Y<=0){let Q=we+i.height;Ue.push({left:H,top:Q,width:W-H,height:I[0]-Q})}else Ue.push({left:H,top:P[$-1],width:W-H,height:we-P[$-1]});let ll=B-le;u=Tt,g=bn,y=Be,C=Kf[L],E=Ue,b=ll}if(!(g===void 0||C===void 0))return{delta:g,absDelta:u,gap:y,rects:E,alignMode:C,crossDelta:b}}function U0(n,i,e,t,o){let r=[],s=o-t;for(let a=0;a<n.length-1;a++){let d=i[a+1]-e[a];d<0||r.push({left:e[a],top:t,width:d,height:s})}return r}function W0(n,i,e,t,o){let r=[],s=o-t;for(let a=0;a<n.length-1;a++){let d=i[a+1]-e[a];d<0||r.push({left:t,top:e[a],width:s,height:d})}return r}function kh(n,i,e){for(let t=1;t<i.length;t++){let o=i[t],r=e[t],s=n[t],a=t-1;for(;a>=0;){let d=i[a],l=n[a];if(d<o||d===o&&l<s)break;i[a+1]=d,e[a+1]=e[a],n[a+1]=l,a--}i[a+1]=o,e[a+1]=r,n[a+1]=s}}function on(n){return n<0?-n:n}var Pu=class{_element;_isVisible=!1;_left=Number.NaN;_top=Number.NaN;_width=Number.NaN;_height=Number.NaN;constructor(i,e,t="f-rect"){this._element=i.document.createElement("div"),this._element.classList.add(t);let o=this._element.style;o.position="absolute",o.display="none",o.boxSizing="border-box",o.pointerEvents="none",e.appendChild(this._element)}show(){this._isVisible||(this._isVisible=!0,this._element.style.display="block")}hide(){this._isVisible&&(this._isVisible=!1,this._element.style.display="none")}render(i,e,t,o){let r=this._element.style;i!==this._left&&(this._left=i,r.left=i+"px"),e!==this._top&&(this._top=e,r.top=e+"px"),t!==this._width&&(this._width=t,r.width=t+"px"),o!==this._height&&(this._height=o,r.height=o+"px")}clearRect(){this._left=Number.NaN,this._top=Number.NaN,this._width=Number.NaN,this._height=Number.NaN;let i=this._element.style;i.removeProperty("left"),i.removeProperty("top"),i.removeProperty("width"),i.removeProperty("height")}destroy(){this._element.remove()}},Mu=class{_browser;_hostElement;_className;_pool=[];_activeCount=0;constructor(i,e,t="f-rect"){this._browser=i,this._hostElement=e,this._className=t}draw(i,e){let t=e.scale,o=e.position.x+e.scaledPosition.x,r=e.position.y+e.scaledPosition.y;for(let s=0;s<i.length;s++){let a=this._getOrCreate(s),d=i[s];a.show(),a.render(d.left*t+o,d.top*t+r,d.width*t,d.height*t)}for(let s=i.length;s<this._activeCount;s++)this._pool[s].hide();this._activeCount=i.length}hideAll(){for(let i=0;i<this._activeCount;i++)this._pool[i].hide();this._activeCount=0}destroy(){for(let i of this._pool)i.destroy();this._pool.length=0,this._activeCount=0}_getOrCreate(i){if(i<this._pool.length)return this._pool[i];let e=new Pu(this._browser,this._hostElement,this._className);return this._pool.push(e),e}},Pc=class{static fToken=Symbol("MagneticRectsPreparationRequest")},$0=(()=>{let n=class Rr{_mediator=c(D);_store=c(x);_browser=c(pe);_injector=c(Ae);_dragSession=c(V);_renderer;handle(e){let t=this._store.instances.get(ae.MAGNETIC_RECTS);if(!t)return;let o=this._dragSession.draggableItems.find(r=>r instanceof It);o&&o.setMagneticRects(new Ru(this._injector,this._getRenderer(t),this._notDraggedRects(this._draggedNodes(o.items))))}_draggedNodes(e){return e.map(t=>t.nodeOrGroup)}_getRenderer(e){return this._renderer||(this._renderer=new Mu(this._browser,e.hostElement)),this._renderer?.destroy(),this._renderer}_notDraggedRects(e){let t=new Set(e);return this._store.nodes.getAll().filter(r=>!t.has(r)).map(r=>this._mediator.execute(new de(r.hostElement)))}static \u0275fac=function(t){return new(t||Rr)};static \u0275prov=f({token:Rr,factory:Rr.\u0275fac})};return n=p([_(Pc)],n),n})(),Ru=class{_renderer;_rects;_timerId=null;_canvasTransform;_alignThreshold=10;_spacingThreshold=10;constructor(i,e,t){this._renderer=e,this._rects=t;let o=i.get(x),r=o.instances.require(ae.MAGNETIC_RECTS);this._alignThreshold=r.alignThreshold(),this._spacingThreshold=r.spacingThreshold(),this._canvasTransform=o.transform}scheduleRender(i){this._timerId&&clearTimeout(this._timerId),this._timerId=setTimeout(()=>this._renderRects(this._computeRects(i)),15)}_renderRects(i){if(i.axis!==void 0&&i.delta!==void 0&&i.rects.length>0){this._renderer.draw(i.rects,this._canvasTransform);return}this._renderer.hideAll()}_computeRects(i){return H0(this._rects,i,this._alignThreshold,this._spacingThreshold)}clearGuides(){this._renderer.hideAll(),this._timerId&&(clearTimeout(this._timerId),this._timerId=null)}},Mc=class{event;static fToken=Symbol("DragNodeFinalizeRequest");constructor(i){this.event=i}},Nu=class{nodes;fNodes;constructor(i){this.nodes=i,this.fNodes=i}},X0=(()=>{let n=class Nr{_mediator=c(D);_store=c(x);_dragSession=c(V);_dragHandler;handle({event:e}){if(this._dragHandler=this._getDragHandler(),!this._dragHandler)return;let t=this._buildDragDelta(e.getPosition()),o=this._dragHandler.calculateMagneticSnaps(t),r=this._applySnapToDelta(t,o.lines,o.rects);this._finalizeMove(this._dragHandler,r),this._emitNodeIntersectIfNeeded(this._dragHandler)}_getDragHandler(){return this._dragSession.draggableItems.find(P0)}_buildDragDelta(e){return j.fromPoint(e).elementTransform(this._store.flowHost).div(this._dragSession.onPointerDownScale).sub(this._dragSession.onPointerDownPosition)}_applySnapToDelta(e,t,o){let r=e.x,s=e.y;return t&&(r=this._hasLineSnapValue(t.x)?e.x-(t.x.delta||0):r,s=this._hasLineSnapValue(t.y)?e.y-(t.y.delta||0):s),this._hasRectSnapValue(o)&&(o.axis==="x"?(r=e.x-o.delta,s=e.y-(o.crossDelta??0)):(s=e.y-o.delta,r=e.x-(o.crossDelta??0))),{x:r,y:s}}_hasLineSnapValue(e){return e.guide!==void 0&&e.guide!==null}_hasRectSnapValue(e){return!!e&&e.axis!==void 0&&e.delta!==void 0}_finalizeMove(e,t){for(let o of e.roots)o.finalizeConstraints();e.onPointerMove(t),e.onPointerUp?.(),this._store.fDraggable?.fMoveNodes.emit(this._buildMoveNodesEvent(e))}_buildMoveNodesEvent(e){let t=e.getEvent(),s=((t.data??t.fData)?.fNodeIds??[]).map(a=>({id:a,position:this._store.nodes.get(a)?._position}));return new Nu(s)}_emitNodeIntersectIfNeeded(e){if(!this._isDraggedJustOneNode(e)||!this._store.fDraggable?.fEmitOnNodeIntersect)return;let t=e.roots[0].nodeOrGroup;queueMicrotask(()=>this._mediator.execute(new ec(t)))}_isDraggedJustOneNode(e){return e.roots.length===1}static \u0275fac=function(t){return new(t||Nr)};static \u0275prov=f({token:Nr,factory:Nr.\u0275fac})};return n=p([_(Mc)],n),n})(),Rc=class{event;trigger;static fToken=Symbol("DragNodePreparationRequest");constructor(i,e){this.event=i,this.trigger=e}},q0=(()=>{let n=class kr{_mediator=c(D);_store=c(x);_dragSession=c(V);handle({event:e,trigger:t}){if(!this._canStartDrag(e,t))return;let o=this._findDraggableNode(e.targetElement);o&&(this._storePointerDownContext(e),this._dragSession.draggableItems=[this._buildDragNodeHandler(o)],this._mediator.execute(new Ec),this._mediator.execute(new Pc))}_canStartDrag(e,t){return this._dragSession.isEmpty()&&this._isDragHandle(e.targetElement)&&Ve(e.originalEvent,t)}_isDragHandle(e){return Mn(e,".f-drag-handle")}_findDraggableNode(e){let t=this._store.nodes.getAll();for(let o of t)if(!o.fDraggingDisabled()&&o.isContains(e))return o}_storePointerDownContext(e){this._dragSession.onPointerDownScale=this._store.transform.scale,this._dragSession.onPointerDownPosition=j.fromPoint(e.getPosition()).elementTransform(this._store.flowHost).div(this._store.transform.scale)}_buildDragNodeHandler(e){return(e.fSelectionDisabled()||!e.isSelected())&&queueMicrotask(()=>{this._mediator.execute(new yn(e))}),this._mediator.execute(new Dc(e))}static \u0275fac=function(t){return new(t||kr)};static \u0275prov=f({token:kr,factory:kr.\u0275fac})};return n=p([_(Rc)],n),n})(),Y0=[...z0,G0,$0,X0,q0],ku=class{targetGroupId;nodeIds;dropPosition;fTargetNode;fNodes;fDropPosition;constructor(i,e,t){this.targetGroupId=i,this.nodeIds=e,this.dropPosition=t,this.fTargetNode=i,this.fNodes=e,this.fDropPosition=t}},K0=(()=>{let n=class Or{_dragSession=c(V);_store=c(x);handle({event:e}){let t=this._findDropHandler();if(!t)return;let o=t.activeTarget?.node;o&&this._emitDropToGroupEvent(o.fId(),e),t.onPointerUp?.()}_findDropHandler(){return this._dragSession.draggableItems.find(e=>e instanceof Yn)}_emitDropToGroupEvent(e,t){this._store.fDraggable?.fDropToGroup.emit(new ku(e,this._getTopLevelDraggedIds(),t.getPosition()))}_getTopLevelDraggedIds(){let t=this._getMoveSummaryHandler().items.map(s=>s.nodeOrGroup),o=new Set(t.map(s=>s.fId())),r=[];for(let s of t){let a=s.fParentId();(!a||!o.has(a))&&r.push(s.fId())}return r}_getMoveSummaryHandler(){let e=this._dragSession.draggableItems.find(t=>t instanceof It);if(!e)throw new Error("DropToGroup requires DragNodeHandler.");return e}static \u0275fac=function(t){return new(t||Or)};static \u0275prov=f({token:Or,factory:Or.\u0275fac})};return n=p([_(yc)],n),n})(),Nc=class{event;static fToken=Symbol("DropToGroupPreparationRequest");constructor(i){this.event=i}},kc=class{candidates;static fToken=Symbol("SortDropCandidatesByLayerRequest");constructor(i){this.candidates=i}},Z0=(()=>{let n=class Fr{handle({candidates:e}){let t=e.map((o,r)=>({candidate:o,index:r}));return t.sort((o,r)=>{let s=this._compareDomOrder(o.candidate.node.hostElement,r.candidate.node.hostElement);return s!==0?-s:o.index-r.index}),t.map(o=>o.candidate)}_compareDomOrder(e,t){if(e===t)return 0;let o=e.compareDocumentPosition(t);if((o&Node.DOCUMENT_POSITION_FOLLOWING)!==0)return-1;if((o&Node.DOCUMENT_POSITION_PRECEDING)!==0)return 1;if(o&Node.DOCUMENT_POSITION_DISCONNECTED){let r=e.getBoundingClientRect?.()??{top:0,left:0},s=t.getBoundingClientRect?.()??{top:0,left:0};return r.top!==s.top?r.top<s.top?-1:1:r.left!==s.left?r.left<s.left?-1:1:0}return 0}static \u0275fac=function(t){return new(t||Fr)};static \u0275prov=f({token:Fr,factory:Fr.\u0275fac})};return n=p([_(kc)],n),n})(),Ou=class{_onPointerDown;_limit;_vCellSize;_hCellSize;_adjustCellSize;constructor(i,e,t){this._onPointerDown=e,this._limit=t;let o=i.get(x);this._vCellSize=o.fDraggable.vCellSize(),this._hCellSize=o.fDraggable.hCellSize(),this._adjustCellSize=o.fDraggable.fCellSizeWhileDragging()}limit(i){let{min:e,max:t}=this._limit,{x:o,y:r}=this._cellSizeStrategies[+this._adjustCellSize](i);return{x:this._clamp(o,e.x,t.x),y:this._clamp(r,e.y,t.y)}}_cellSizeStrategies={0:this._skipCellSize.bind(this),1:this._applyCellSize.bind(this)};_applyCellSize(i){return{x:this._snapToGrid(this._onPointerDown.x+i.x,this._hCellSize)-this._onPointerDown.x,y:this._snapToGrid(this._onPointerDown.y+i.y,this._vCellSize)-this._onPointerDown.y}}_skipCellSize(i){return i}_clamp(i,e,t){return Math.min(Math.max(i,e),t)}_snapToGrid(i,e){return Math.round(i/e)*e}},Oc=class{externalItem;static fToken=Symbol("DragExternalItemCreatePlaceholderRequest");constructor(i){this.externalItem=i}},Q0=(()=>{let n=class Ar{_browser=c(pe);_containerRef=c(Si);handle({externalItem:e}){let{hostElement:t,placeholder:o}=e,r=o(),s=r?this._fromTemplate(r):this._fromHost(t);return s.classList.add("f-external-item-placeholder"),s.style.pointerEvents="none",s}_fromTemplate(e){return Il(this._createViewRef(e),this._browser.document)}_fromHost(e){return wl(e)}_createViewRef(e){let t=this._containerRef.createEmbeddedView(e);return t.detectChanges(),t}static \u0275fac=function(t){return new(t||Ar)};static \u0275prov=f({token:Ar,factory:Ar.\u0275fac})};return n=p([_(Oc)],n),n})(),Fc=class{externalItem;static fToken=Symbol("DragExternalItemCreatePreviewRequest");constructor(i){this.externalItem=i}},J0=(()=>{let n=class Lr{_browser=c(pe);_containerRef=c(Si);handle({externalItem:e}){let{hostElement:t,preview:o}=e,r=o(),s=r?this._fromTemplate(r):this._fromHost(t);return this._setPreviewStyles(s),Pf(s),s.classList.add("f-external-item-preview"),s}_fromTemplate(e){return Il(this._createViewRef(e),this._browser.document)}_fromHost(e){return wl(e)}_createViewRef(e){let t=this._containerRef.createEmbeddedView(e);return t.detectChanges(),t}_setPreviewStyles(e){bl(e.style,{"pointer-events":"none",margin:"showPopover"in e?"0 auto 0 0":"0",position:"fixed",top:"0",left:"0","z-index":"1000"},new Set(["position"]))}static \u0275fac=function(t){return new(t||Lr)};static \u0275prov=f({token:Lr,factory:Lr.\u0275fac})};return n=p([_(Fc)],n),n})(),Ac=class{event;static fToken=Symbol("DragExternalItemFinalizeRequest");constructor(i){this.event=i}},Fu=class{externalItemRect;data;targetContainerId;dropPosition;rect;fTargetNode;fDropPosition;constructor(i,e,t,o){this.externalItemRect=i,this.data=e,this.targetContainerId=t,this.dropPosition=o,this.rect=i,this.fTargetNode=t,this.fDropPosition=o}},ey="external-item",ty="drag-external-item";function ny(n){return n.getEvent().kind===ty||n.getEvent().fEventType===ey}var iy=(()=>{let n=class zr{_result=c(St);_mediator=c(D);_store=c(x);_dragSession=c(V);_browser=c(pe);get _createNodeEmitter(){return this._store.fDraggable?.fCreateNode}handle(e){let t=this._findExternalItemHandler();if(!t)return;let o=this._getDestinationNodeOrGroupId();this._emitEvent(this._getElementsFromPoint(e.event.getPosition()),o,e.event.getPosition()),t.onPointerUp(),this._dragSession.draggableItems=[]}_findExternalItemHandler(){return this._dragSession.draggableItems.find(e=>ny(e))}_getDestinationNodeOrGroupId(){let e=this._getDropToGroupHandler(),t=e.activeTarget?.node.fId();return e.onPointerUp?.(),t}_getDropToGroupHandler(){let e=this._dragSession.draggableItems.find(t=>t instanceof Yn);if(!e)throw new Error("NodeDragToParentDragHandler not found");return e}_getElementsFromPoint(e){return this._browser.document.elementsFromPoint(e.x,e.y).filter(t=>!t.closest(".f-external-item")&&!t.closest(".f-external-item-preview"))}_emitEvent(e,t,o){this._isPointerInCanvasRect(e)&&this._createNodeEmitter?.emit(new Fu(this._getPreviewRect(),this._result.getData().externalItem.data(),t,t?o:void 0))}_isPointerInCanvasRect(e){return e.length?this._store.flowHost.contains(e[0]):!1}_getPreviewRect(){return this._mediator.execute(new de(this._result.getData().preview))}static \u0275fac=function(t){return new(t||zr)};static \u0275prov=f({token:zr,factory:zr.\u0275fac})};return n=p([_(Ac)],n),n})(),Au=class{data;constructor(i){this.data=i}},Lc=class extends Oe{_externalItem;_pointerDownClientPosition;type="external-item";kind="drag-external-item";data(){return new Au(this._externalItem.data())}_result;_mediator;_browser;_store;_previewEl;_placeholderEl;_startRect=z.initialize();_pointerDownRect=z.initialize();_absoluteOffsetFromFlow=M.initialize();_grabOffsetFromPointer=M.initialize();_originalParent;_originalNextSibling;_originalDisplay;_applyConstraints=i=>i;constructor(i,e,t){super(),this._externalItem=e,this._pointerDownClientPosition=t,this._store=i.get(x),this._result=i.get(St),this._mediator=i.get(D),this._browser=i.get(pe),this._originalDisplay=this._host.style.display,this._initConstraints(i)}get _host(){return this._externalItem.hostElement}get _overlayRoot(){return this._browser.document.fullscreenElement??this._browser.document.body}get _transform(){return this._store.transform}_initConstraints(i){this._startRect=this._getStartRect();let e=new Ou(i,this._startRect,wh());this._applyConstraints=t=>e.limit(t)}_getStartRect(){return this._mediator.execute(new de(this._externalItem.hostElement))}prepareDragSequence(){this._pointerDownRect=this._readAbsoluteRect(this._host),this._absoluteOffsetFromFlow=j.fromPoint(this._pointerDownRect).sub(this._toAbsolutePoint(this._startRect)),this._grabOffsetFromPointer=this._clientToAbsolute(this._pointerDownClientPosition).sub(this._pointerDownRect),this._rememberOriginalPlacement(),this._previewEl=this._createPreview(),this._placeholderEl=this._createPlaceholder(),this._placePreviewIntoOverlay(),this._swapOriginalWithPlaceholderAndMoveOriginalIntoOverlay(),this._result.setData({preview:this._previewEl,externalItem:this._externalItem})}_rememberOriginalPlacement(){let i=this._host.parentNode;if(!i){this._originalParent=void 0,this._originalNextSibling=null;return}this._originalParent=i,this._originalNextSibling=this._host.nextSibling}_createPreview(){let i=this._mediator.execute(new Fc(this._externalItem));return this._externalItem.previewMatchSize()&&this._matchSize(i,this._pointerDownRect),i.style.transform=Zf(this._pointerDownRect),i}_createPlaceholder(){return this._mediator.execute(new Oc(this._externalItem))}_placePreviewIntoOverlay(){this._overlayRoot.appendChild(this._previewEl)}_swapOriginalWithPlaceholderAndMoveOriginalIntoOverlay(){let i=this._originalParent,e=this._placeholderEl;if(!i||!e)return;let t=i.replaceChild(e,this._host);this._overlayRoot.appendChild(t),this._host.style.display="none"}onPointerMove(i,e){if(!this._previewEl)return;let t=this._resolveDeltaFromPointer(i,e),o=this._applyConstraints(t),r=j.fromPoint(this._startRect).add(o),s=this._toAbsolutePoint(r).add(this._absoluteOffsetFromFlow);this._previewEl.style.transform=Zf(s)}onPointerUp(){this._previewEl&&this._previewEl.parentNode&&this._previewEl.parentNode.removeChild(this._previewEl),this._restoreOriginalInParent(),this._host.style.display=this._originalDisplay||"block",this._previewEl=void 0,this._placeholderEl=void 0,this._originalParent=void 0,this._originalNextSibling=null}_restoreOriginalInParent(){let i=this._originalParent,e=this._placeholderEl;if(!(!i||!e)){if(e.parentNode===i){i.replaceChild(this._host,e);return}this._originalNextSibling&&this._originalNextSibling.parentNode===i?i.insertBefore(this._host,this._originalNextSibling):i.appendChild(this._host)}}_matchSize(i,e){i.style.width=`${e.width}px`,i.style.height=`${e.height}px`}_readAbsoluteRect(i){let e=i.getBoundingClientRect(),t=this._browser.window.pageYOffset||this._browser.document.documentElement.scrollTop,o=this._browser.window.pageXOffset||this._browser.document.documentElement.scrollLeft;return z.initialize(e.left+o,e.top+t,e.width,e.height)}_toAbsolutePoint(i){let e=j.fromPoint(this._transform.position).add(this._transform.scaledPosition);return j.fromPoint(i).mult(this._transform.scale).add(e).add(this._getFlowHostAbsolutePosition())}_resolveDeltaFromPointer(i,e){let t=e?.getPosition();if(!t)return i;let o=this._clientToAbsolute(t).sub(this._grabOffsetFromPointer),r=this._toFlowPoint(o);return j.fromPoint(r).sub(this._startRect)}_toFlowPoint(i){let e=this._getFlowHostAbsolutePosition(),t=j.fromPoint(this._transform.position).add(this._transform.scaledPosition);return j.fromPoint(i).sub(e).sub(t).div(this._transform.scale)}_getFlowHostAbsolutePosition(){let i=this._store.flowHost.getBoundingClientRect(),e=this._browser.window.pageYOffset||this._browser.document.documentElement.scrollTop,t=this._browser.window.pageXOffset||this._browser.document.documentElement.scrollLeft;return M.initialize(i.left+t,i.top+e)}_clientToAbsolute(i){let e=this._browser.window.pageYOffset||this._browser.document.documentElement.scrollTop,t=this._browser.window.pageXOffset||this._browser.document.documentElement.scrollLeft;return j.fromPoint(i).add(M.initialize(t,e))}};function Zf({x:n,y:i}){return`translate3d(${Math.round(n)}px, ${Math.round(i)}px, 0)`}var zc=class{event;fTrigger;static fToken=Symbol("DragExternalItemPreparationRequest");constructor(i,e){this.event=i,this.fTrigger=e}};function oy(n){return!!n.closest?.("[fExternalItem]")}function ry(n){return n.closest("[fExternalItem]")}var sy=(()=>{class n{_byHost=new Map;_items=oe([]);items=G(()=>this._items());getByElement(e){let t=ry(e);return t?this._byHost.get(t):void 0}getByHost(e){return this._byHost.get(e)}register(e){let t=e.hostElement,o=this._byHost.get(t);o!==e&&(o&&o!==e&&this._byHost.delete(t),this._byHost.set(t,e),this._sync())}remove(e){let t=e.hostElement;this._byHost.get(t)===e&&(this._byHost.delete(t),this._sync())}_sync(){this._items.set([...this._byHost.values()])}static \u0275fac=function(t){return new(t||n)};static \u0275prov=f({token:n,factory:n.\u0275fac,providedIn:"root"})}return n})();var ay=(()=>{let n=class Br{_apiService=c(sy);_dragSession=c(V);_store=c(x);_injector=c(Ae);get _flowHost(){return this._store.flowHost}get _transform(){return this._store.transform}handle({event:e,fTrigger:t}){if(!this._dragSession.isEmpty()||!Ve(e.originalEvent,t))return;let o=this._resolveExternalItem(e.targetElement);if(!o||o.disabled())return;let r=this._transform.scale??1;this._dragSession.onPointerDownScale=r,this._dragSession.onPointerDownPosition=j.fromPoint(e.getPosition()).elementTransform(this._flowHost).div(r),this._dragSession.draggableItems=[new Lc(this._injector,o,e.getPosition())]}_resolveExternalItem(e){return this._apiService.getByElement(e)}static \u0275fac=function(t){return new(t||Br)};static \u0275prov=f({token:Br,factory:Br.\u0275fac})};return n=p([_(zc)],n),n})(),Bc=class{event;static fToken=Symbol("PreventDefaultIsExternalItemRequest");constructor(i){this.event=i}},cy=(()=>{let n=class Gr{handle(e){this._isTargetItemExternal(e.event)&&e.event.preventDefault()}_isTargetItemExternal(e){let t=this._isExternalItem(e.target),o=this._isExternalItem(e.target.parentNode);return t||o}_isExternalItem(e){let t=!1;try{t=oy(e)}catch{}return t}static \u0275fac=function(t){return new(t||Gr)};static \u0275prov=f({token:Gr,factory:Gr.\u0275fac})};return n=p([_(Bc)],n),n})(),dy=[Q0,J0,iy,ay,cy],ly=(()=>{let n=class Hr{_mediator=c(D);_dragContext=c(V);_store=c(x);_dragInjector=c(Pe);get _allNodes(){return this._store.nodes.getAll()}handle({event:e}){if(!this._canPrepare())return;let t=this._allNodes.find(s=>s.isContains(e.targetElement));if(!t&&!this._hasExternalDrag())throw new Error("Drag target node not found");let o=this._sortedTargetsForDrop();if(t){let s=t.fParentId(),a=this._mediator.execute(new pd(s));a.length&&(o=o.filter(d=>a.includes(d.node.fId())))}let r=this._dragInjector.get(Yn);r.initialize(o),this._dragContext.draggableItems.push(r)}_canPrepare(){return this._hasMoveDrag()||this._hasExternalDrag()}_hasMoveDrag(){return this._dragContext.draggableItems.some(e=>e instanceof It)}_hasExternalDrag(){return this._dragContext.draggableItems.some(e=>e instanceof Lc)}_sortedTargetsForDrop(){let e=this._getDraggedNodes(),t=e.some(a=>a instanceof pu),o=this._withParents(e),s=this._eligibleTargets(o,t).map(a=>{let d=this._mediator.execute(new de(a.hostElement));return{node:a,rect:d}});return this._mediator.execute(new kc(s))}_getDraggedNodes(){let e=this._dragContext.draggableItems.find(t=>t instanceof It);return e?e.items.map(t=>t.nodeOrGroup):[]}_withParents(e){return e.reduce((t,o)=>{t.push(o);let r=this._mediator.execute(new pn(o));return t.push(...r),t},[])}_eligibleTargets(e,t){let o=this._allNodes.filter(r=>!e.includes(r));return t?o.filter(r=>r instanceof pu):o}static \u0275fac=function(t){return new(t||Hr)};static \u0275prov=f({token:Hr,factory:Hr.\u0275fac})};return n=p([_(Nc)],n),n})(),uy=[Z0,ly,K0],Gc=class{event;static fToken=Symbol("PinchToZoomFinalizeRequest");constructor(i){this.event=i}},fy=.5,Hc=(()=>{class n extends Oe{type="pinch-to-zoom";kind="pinch-to-zoom";_store=c(x);get _flowHost(){return this._store.flowHost}get _canvas(){return this._store.fCanvas}get _zoomComponent(){return this._store.instances.require(ae.ZOOM)}_startDistance=null;_startScale=null;_touches;initialize(e){this._touches=e}prepareDragSequence(){let e=Qf(this._touches);e!=null&&(this._startDistance=e,this._startScale=this._canvas.transform.scale)}onPointerMove(e,t){if(t.touches.length!==2||this._startDistance==null||this._startScale==null)return;let o=Qf(t.touches),r=hy(t.touches);if(o==null||r==null){this._reset();return}if(Math.abs(o-this._startDistance)<fy)return;t.preventDefault();let s=o/this._startDistance,a=this._clamp(this._startScale*s);this._canvas.setScale(a,this._castPositionToFlow(r)),this._canvas.redraw()}_clamp(e){return Math.max(this._zoomComponent.minimum,Math.min(e,this._zoomComponent.maximum))}_castPositionToFlow(e){return j.fromPoint(e).elementTransform(this._flowHost)}_reset(){this._startScale=null,this._startDistance=null}onPointerUp(){this._reset(),this._canvas.emitCanvasChangeEvent()}static \u0275fac=(()=>{let e;return function(o){return(e||(e=X(n)))(o||n)}})();static \u0275prov=f({token:n,factory:n.\u0275fac})}return n})();function hy(n){if(n.length!==2)return null;let i=n[0],e=n[1];return M.initialize((i.clientX+e.clientX)/2,(i.clientY+e.clientY)/2)}function Qf(n){if(n.length!==2)return null;let i=n[0],e=n[1];return Math.hypot(e.clientX-i.clientX,e.clientY-i.clientY)}var gy=(()=>{let n=class jr{_dragSession=c(V);handle(e){if(this._hasPinchZoomHandler())for(let t of this._dragSession.draggableItems)t.onPointerUp?.()}_hasPinchZoomHandler(){return this._dragSession.draggableItems.some(e=>e instanceof Hc)}static \u0275fac=function(t){return new(t||jr)};static \u0275prov=f({token:jr,factory:jr.\u0275fac})};return n=p([_(Gc)],n),n})(),jc=class{event;static fToken=Symbol("PinchToZoomPreparationRequest");constructor(i){this.event=i}},py=(()=>{let n=class Vr{_dragInjector=c(Pe);_store=c(x);_dragSession=c(V);handle({event:e}){this._canStart(e)&&(this._dragSession.onPointerDownScale=1,this._dragSession.onPointerDownPosition=new j,this._dragSession.draggableItems=[this._getHandler(e)])}_canStart(e){return this._dragSession.isEmpty()&&e.touches?.length===2&&!e.isEventInLockedContext&&this._hasZoomComponent()}_hasZoomComponent(){return this._store.instances.has(ae.ZOOM)}_getHandler(e){let t=this._dragInjector.get(Hc);return t.initialize(e.touches),t}static \u0275fac=function(t){return new(t||Vr)};static \u0275prov=f({token:Vr,factory:Vr.\u0275fac})};return n=p([_(jc)],n),n})(),_y=[py,gy],Vc=class{event;static fToken=Symbol("SelectionAreaFinalizeRequest");constructor(i){this.event=i}},my=(()=>{let n=class Ur{_dragSession=c(V);handle(e){this._isValid()&&this._dragSession.draggableItems.forEach(t=>{t.onPointerUp?.()})}_isValid(){return this._dragSession.draggableItems.some(e=>e.getEvent().kind==="selection-area")}static \u0275fac=function(t){return new(t||Ur)};static \u0275prov=f({token:Ur,factory:Ur.\u0275fac})};return n=p([_(Vc)],n),n})(),Lu=(()=>{class n extends Oe{type="selection-area";kind="selection-area";_store=c(x);_dragSession=c(V);_mediator=c(D);_canBeSelected=[];_selectedByMove=[];get _transform(){return this._store.transform}get _canvasPosition(){return j.fromPoint(this._transform.position).add(this._transform.scaledPosition)}get _instance(){return this._store.instances.require(ae.SELECTION_AREA)}prepareDragSequence(){this._canBeSelected=this._mediator.execute(new Td),this._show(),this._draw(z.initialize(this._dragSession.onPointerDownPosition.x,this._dragSession.onPointerDownPosition.y))}onPointerMove(e){let t=j.fromPoint(e).add(this._dragSession.onPointerDownPosition),o=this._getMinimumPoint(this._dragSession.onPointerDownPosition,t),r=Math.abs(e.x),s=Math.abs(e.y),a=z.initialize(o.x,o.y,r,s);this._draw(a),this._selectedByMove=[],this._canBeSelected.forEach(d=>{d.element.unmarkAsSelected();let l=z.addPoint(z.mult(d.fRect,this._transform.scale),this._canvasPosition);z.intersectionWithRect(l,a)&&(d.element.markAsSelected(),this._selectedByMove.push(d.element))}),this._mediator.execute(new xt)}_getMinimumPoint(e,t){return M.initialize(Math.min(e.x,t.x),Math.min(e.y,t.y))}onPointerUp(){this._hide(),this._dragSession.selectedItems.push(...this._selectedByMove),this._selectedByMove.length>0&&(this._dragSession.isSelectedChanged=!0)}_draw(e){let t=this._instance.hostElement.style;t.left=e.x+"px",t.top=e.y+"px",t.width=e.width+"px",t.height=e.height+"px"}_show(){this._instance.hostElement.style.display="block"}_hide(){this._instance.hostElement.style.display="none"}static \u0275fac=(()=>{let e;return function(o){return(e||(e=X(n)))(o||n)}})();static \u0275prov=f({token:n,factory:n.\u0275fac})}return n})(),Uc=class{event;static fToken=Symbol("SelectionAreaPreparationRequest");constructor(i){this.event=i}},yy=(()=>{let n=class Wr{_store=c(x);_dragSession=c(V);_dragInjector=c(Pe);get _instance(){return this._store.instances.get(ae.SELECTION_AREA)}handle(e){this._isValid(e)&&(this._dragSession.onPointerDownScale=1,this._dragSession.onPointerDownPosition=j.fromPoint(e.event.getPosition()).elementTransform(this._store.flowHost),this._dragSession.draggableItems=[this._dragInjector.createInstance(Lu)])}_isValid(e){return!!this._instance&&this._dragSession.isEmpty()&&Ve(e.event.originalEvent,this._instance.fTrigger)}static \u0275fac=function(t){return new(t||Wr)};static \u0275prov=f({token:Wr,factory:Wr.\u0275fac})};return n=p([_(Uc)],n),n})(),vy=[yy,my],Wc=class{rect;childrenBounds;static fToken=Symbol("ApplyChildResizeConstraintsRequest");constructor(i,e){this.rect=i,this.childrenBounds=e}},Cy=(()=>{let n=class $r{handle({rect:e,childrenBounds:t}){t&&this._apply(e,t)}_apply(e,t){this._restrictLeft(e,t),this._restrictTop(e,t),this._restrictRight(e,t),this._restrictBottom(e,t),e.width=Math.max(0,e.width),e.height=Math.max(0,e.height)}_restrictLeft(e,t){let o=e.x-t.x;o>0&&(e.x-=o,e.width+=o)}_restrictTop(e,t){let o=e.y-t.y;o>0&&(e.y-=o,e.height+=o)}_restrictRight(e,t){let o=t.x+t.width;e.x+e.width<=o&&(e.width=o-e.x)}_restrictBottom(e,t){let o=t.y+t.height;e.y+e.height<=o&&(e.height=o-e.y)}static \u0275fac=function(t){return new(t||$r)};static \u0275prov=f({token:$r,factory:$r.\u0275fac})};return n=p([_(Wc)],n),n})(),$c=class{rect;limits;static fToken=Symbol("ApplyParentResizeConstraintsRequest");constructor(i,e){this.rect=i,this.limits=e}},xy=(()=>{let n=class Xr{_mediator=c(D);handle({rect:e,limits:t}){this._applyResizeConstraints(e,t)}_applyResizeConstraints(e,t){if(!t)return;let o=this._clampedCopyForCalculation(e,t);this._applySoftParentExpansions(o,t.softLimits),t.hardLimit&&this._clampRectToInner(e,t.hardLimit.innerRect)}_clampedCopyForCalculation(e,t){let o=J({},e);return t.hardLimit&&this._clampRectToInner(o,t.hardLimit.innerRect),o}_clampRectToInner(e,t){if(e.x<t.x){let s=t.x-e.x;e.x+=s,e.width-=s}if(e.y<t.y){let s=t.y-e.y;e.y+=s,e.height-=s}let o=t.x+t.width;e.x+e.width>o&&(e.width=o-e.x);let r=t.y+t.height;e.y+e.height>r&&(e.height=r-e.y),e.width=Math.max(0,e.width),e.height=Math.max(0,e.height)}_applySoftParentExpansions(e,t){if(t?.length)for(let o of t)this._expandParentFromOriginalIfOverflow(e,o)}_expandParentFromOriginalIfOverflow(e,t){let o=t.innerRect,r=t.boundingRect,s=this._computeOverflow(o,e);if(!this._hasOverflow(s)){this._applyParentRect(t,r);return}let a=this._buildExpandedParentRect(r,s);this._applyParentRect(t,a)}_hasOverflow(e){return!!(e.left||e.top||e.right||e.bottom)}_computeOverflow(e,t){let o=Math.max(0,e.x-t.x),r=Math.max(0,e.y-t.y),s=Math.max(0,t.x+t.width-(e.x+e.width)),a=Math.max(0,t.y+t.height-(e.y+e.height));return{left:o,top:r,right:s,bottom:a}}_buildExpandedParentRect(e,t){let o=J({},e);return t.left&&(o.x=e.x-t.left,o.width=e.width+t.left),t.top&&(o.y=e.y-t.top,o.height=e.height+t.top),t.right&&(o.width=(o.width??e.width)+t.right),t.bottom&&(o.height=(o.height??e.height)+t.bottom),o}_applyParentRect(e,t){e.nodeOrGroup.updatePosition(t),e.nodeOrGroup.updateSize(t),this._mediator.execute(new Gt(e.nodeOrGroup.fId(),t)),e.nodeOrGroup.redraw()}static \u0275fac=function(t){return new(t||Xr)};static \u0275prov=f({token:Xr,factory:Xr.\u0275fac})};return n=p([_($c)],n),n})(),Xc=class{originalRect;difference;handleType;minimumSize;static fToken=Symbol("CalculateChangedRectFromDifferenceRequest");constructor(i,e,t,o){this.originalRect=i,this.difference=e,this.handleType=t,this.minimumSize=o}},Jf={[nt.LEFT]:{x:-1,y:0},[nt.LEFT_TOP]:{x:-1,y:-1},[nt.TOP]:{x:0,y:-1},[nt.RIGHT_TOP]:{x:1,y:-1},[nt.RIGHT]:{x:1,y:0},[nt.RIGHT_BOTTOM]:{x:1,y:1},[nt.BOTTOM]:{x:0,y:1},[nt.LEFT_BOTTOM]:{x:-1,y:1}},wy=(()=>{let n=class qr{handle({originalRect:e,difference:t,handleType:o,minimumSize:r}){let s=this._changeSizeInRect(e,t,Jf[o],r);return this._changePosition(e,t,Jf[o],s)}_changeSizeInRect(e,t,o,r){let s=e.width+o.x*t.x,a=e.height+o.y*t.y,d=0,l=0;return s<0&&(d=s,s=Math.abs(s)),s<r.width&&(o.x===-1&&(d+=s-r.width),s=r.width),a<0&&(l=a,a=Math.abs(a)),a<r.height&&(o.y===-1&&(l+=a-r.height),a=r.height),z.initialize(d,l,s,a)}_changePosition(e,t,o,r){let s=e.x+(o.x===-1?t.x:0)+r.x,a=e.y+(o.y===-1?t.y:0)+r.y;return z.initialize(s,a,r.width,r.height)}static \u0275fac=function(t){return new(t||qr)};static \u0275prov=f({token:qr,factory:qr.\u0275fac})};return n=p([_(Xc)],n),n})(),qc=class{nodeOrGroup;paddings;static fToken=Symbol("CalculateDirectChildrenUnionRectRequest");constructor(i,e){this.nodeOrGroup=i,this.paddings=e}},by=(()=>{let n=class Yr{_mediator=c(D);_store=c(x);get _allNodesAndGroups(){return this._store.nodes.getAll()}handle({nodeOrGroup:e,paddings:t}){let o=z.union(this._calculateDirectChildren(e.fId()).map(r=>this._normalizeRect(r)));return o?this._concatRectWithParentPadding(o,t):null}_calculateDirectChildren(e){return this._allNodesAndGroups.filter(t=>t.fParentId()===e)}_normalizeRect(e){return this._mediator.execute(new de(e.hostElement))}_concatRectWithParentPadding(e,t){return z.initialize(e.x-t[0],e.y-t[1],e.width+t[0]+t[2],e.height+t[1]+t[3])}static \u0275fac=function(t){return new(t||Yr)};static \u0275prov=f({token:Yr,factory:Yr.\u0275fac})};return n=p([_(qc)],n),n})(),ti=class{nodeOrGroup;rect;static fToken=Symbol("CalculateResizeLimitsRequest");constructor(i,e){this.nodeOrGroup=i,this.rect=e}},Iy=(()=>{let n=class Kr{_mediator=c(D);handle({nodeOrGroup:e,rect:t}){let o=this._getParentsChain(e),r=this._calculateNodePaddings(e,t);return{limits:this._buildSoftHardLimits(o),childrenBounds:this._getNormalizedChildrenBounds(e,r),minimumSize:Xe.initialize(r[0]+r[2],r[1]+r[3])}}_calculateNodePaddings(e,t){return this._mediator.execute(new Ut(e,t))}_getNormalizedChildrenBounds(e,t){return this._mediator.execute(new qc(e,t))}_getParentsChain(e){return this._mediator.execute(new pn(e))??[]}_buildSoftHardLimits(e){let t=[],o,r=[0,0,0,0];for(let s of e){let a=this._getParentInfo(s,r);if(r=a.paddings,this._isAutoExpand(s))t.push(this._makeLimit(s,a));else{o=this._makeLimit(s,a);break}}return{softLimits:t,hardLimit:o}}_getParentInfo(e,t){return this._mediator.execute(new Kn(e,t))}_isAutoExpand(e){return e.fAutoExpandOnChildHit()}_makeLimit(e,{boundingRect:t,innerRect:o}){return{nodeOrGroup:e,boundingRect:t,innerRect:o}}static \u0275fac=function(t){return new(t||Kr)};static \u0275prov=f({token:Kr,factory:Kr.\u0275fac})};return n=p([_(ti)],n),n})(),Yc=class{event;static fToken=Symbol("ResizeNodeFinalizeRequest");constructor(i){this.event=i}},Oh="node-resize",Fh="resize-node";function Sy(n){return n.getEvent().kind===Fh||n.getEvent().fEventType===Oh}var Dy=(()=>{let n=class Zr{_dragSession=c(V);handle(e){this._isNodeResizeHandler()&&this._dragSession.draggableItems.forEach(t=>t.onPointerUp?.())}_isNodeResizeHandler(){return this._dragSession.draggableItems.some(e=>Sy(e))}static \u0275fac=function(t){return new(t||Zr)};static \u0275prov=f({token:Zr,factory:Zr.\u0275fac})};return n=p([_(Yc)],n),n})(),zu=class{fNodeId;constructor(i){this.fNodeId=i}},Bu=(()=>{class n extends Oe{type=Oh;kind=Fh;data(){return new zu(this._nodeOrGroup.fId())}_mediator=c(D);_baselineRect;_constraints;_lastRect=null;_nodeOrGroup;_handleType;_nodeConnections={source:[],target:[]};_softParentConnections=[];initialize(e,t){this._nodeOrGroup=e,this._handleType=t}setNodeConnectionHandlers(e){this._nodeConnections=e}setSoftParentConnectionHandlers(e){this._softParentConnections=e}prepareDragSequence(){this._baselineRect=this._readBaselineRect(),this._constraints=this._buildConstraints(this._baselineRect),this._lastRect=this._baselineRect}onPointerMove(e){let t=this._calcNextRect(e);this._applyConstraints(t),this._commitRect(t),this._applyConnectionHandlers(this._nodeConnections);for(let o of this._softParentConnections)this._applyConnectionHandlers(o);this._lastRect=t}onPointerUp(){let e=this._lastRect??this._fallbackRectFromModel();this._nodeOrGroup.sizeChange.emit(e),requestAnimationFrame(()=>this._nodeOrGroup.refresh())}_readBaselineRect(){return this._mediator.execute(new de(this._nodeOrGroup.hostElement))}_buildConstraints(e){return this._mediator.execute(new ti(this._nodeOrGroup,e))}_calcNextRect(e){return this._mediator.execute(new Xc(this._baselineRect,e,this._handleType,this._constraints.minimumSize))}_applyConstraints(e){this._mediator.execute(new Wc(e,this._constraints.childrenBounds)),this._mediator.execute(new $c(e,this._constraints.limits))}_commitRect(e){this._nodeOrGroup.updatePosition({x:e.x,y:e.y}),this._nodeOrGroup.updateSize({width:e.width,height:e.height}),this._mediator.execute(new Gt(this._nodeOrGroup.fId(),e)),this._nodeOrGroup.redraw()}_fallbackRectFromModel(){return z.initialize(this._nodeOrGroup._position.x,this._nodeOrGroup._position.y,this._nodeOrGroup._size?.width,this._nodeOrGroup._size?.height)}_applyConnectionHandlers(e){if(!e.source.length&&!e.target.length)return;let t=new Map;for(let o of e.source){let r=this._readConnectorRect(o.connector,t);o.handler.setSourceRect(r)}for(let o of e.target){let r=this._readConnectorRect(o.connector,t);o.handler.setTargetRect(r)}}_readConnectorRect(e,t){let o=`${e.kind}::${e.fId()}`,r=t.get(o);if(r)return r;let s=this._mediator.execute(new wt(e.hostElement,!1));return t.set(o,s),s}static \u0275fac=(()=>{let e;return function(o){return(e||(e=X(n)))(o||n)}})();static \u0275prov=f({token:n,factory:n.\u0275fac})}return n})(),ni=class{_mediator=c(D);_store=c(x);_behaviour=c(Cn);_source;_target;_sourceRef;_targetRef;_sourceRect;_targetRect;connection;initialize(i){this.connection=i,this._source=this._store.outputs.require(this.connection.fOutputId()),this._target=this._store.inputs.require(this.connection.fInputId()),this._sourceRef=this._readRectRef(this._source),this._targetRef=this._readRectRef(this._target),this._sourceRect=ge.fromRoundedRect(this._sourceRef.rect),this._targetRect=ge.fromRoundedRect(this._targetRef.rect)}setSourceRect(i){this._sourceRect=ge.fromRoundedRect(i),this._mediator.execute(new Bt(this._source.fId(),this._source.kind,this._sourceRect))}setTargetRect(i){this._targetRect=ge.fromRoundedRect(i),this._mediator.execute(new Bt(this._target.fId(),this._target.kind,this._targetRect))}redraw(){let i=this._buildLine();this.connection.setLine(i),this.connection.redraw()}_buildLine(){let i=ge.fromRoundedRect(this._sourceRect),e=ge.fromRoundedRect(this._targetRect);return this._behaviour.handle(new Ye(i,e,this.connection,this._sourceRef.connector.fConnectableSide,this._targetRef.connector.fConnectableSide,this._resolveRotationContext(this._sourceRef.connector),this._resolveRotationContext(this._targetRef.connector)))}_readRectRef(i){return{connector:i,rect:this._mediator.execute(new wt(i.hostElement,!1))}}_resolveRotationContext(i){return this._mediator.execute(new ht(i))}},Ty=(()=>{class n extends ni{_sourceUpdated=!1;_targetUpdated=!1;setSourceRect(e){super.setSourceRect(e),this._sourceUpdated=!0,this._redrawIfReady()}setTargetRect(e){super.setTargetRect(e),this._targetUpdated=!0,this._redrawIfReady()}_redrawIfReady(){!this._sourceUpdated||!this._targetUpdated||(this._sourceUpdated=!1,this._targetUpdated=!1,super.redraw())}static \u0275fac=(()=>{let e;return function(o){return(e||(e=X(n)))(o||n)}})();static \u0275prov=f({token:n,factory:n.\u0275fac})}return n})(),Ey=(()=>{class n extends ni{setSourceRect(e){super.setSourceRect(e),super.redraw()}static \u0275fac=(()=>{let e;return function(o){return(e||(e=X(n)))(o||n)}})();static \u0275prov=f({token:n,factory:n.\u0275fac})}return n})(),Py=(()=>{class n extends ni{setTargetRect(e){super.setTargetRect(e),super.redraw()}static \u0275fac=(()=>{let e;return function(o){return(e||(e=X(n)))(o||n)}})();static \u0275prov=f({token:n,factory:n.\u0275fac})}return n})(),Kc=class{event;fTrigger;static fToken=Symbol("ResizeNodePreparationRequest");constructor(i,e){this.event=i,this.fTrigger=e}},Zc=class{handler;nodeOrGroup;static fToken=Symbol("AttachResizeConnectionDragHandlersToNodeRequest");constructor(i,e){this.handler=i,this.nodeOrGroup=e}},My=(()=>{let n=class Qr{_store=c(x);_mediator=c(D);_dragInjector=c(Pe);handle({handler:e,nodeOrGroup:t}){let o=this._readSoftParents(t),r=[t,...o],s=this._collectSourceConnectorIds(r),a=this._collectTargetConnectorIds(r),d=new Map;e.setNodeConnectionHandlers(this._buildConnectionHandlersForNode(t,s,a,d)),e.setSoftParentConnectionHandlers(o.map(l=>this._buildConnectionHandlersForNode(l,s,a,d)))}_readSoftParents(e){let t=this._mediator.execute(new de(e.hostElement));return this._mediator.execute(new ti(e,t)).limits.softLimits.map(r=>r.nodeOrGroup)}_collectSourceConnectorIds(e){let t=new Set(e.map(o=>o.fId()));return new Set(this._store.outputs.getAll().filter(o=>t.has(o.fNodeId)).map(o=>o.fId()))}_collectTargetConnectorIds(e){let t=new Set(e.map(o=>o.fId()));return new Set(this._store.inputs.getAll().filter(o=>t.has(o.fNodeId)).map(o=>o.fId()))}_buildConnectionHandlersForNode(e,t,o,r){let s=this._store.outputs.getAll().filter(g=>g.fNodeId===e.fId()),a=this._store.inputs.getAll().filter(g=>g.fNodeId===e.fId());if(!s.length&&!a.length)return{source:[],target:[]};let d=new Set(s.map(g=>g.fId())),l=new Set(a.map(g=>g.fId())),u={source:[],target:[]};for(let g of this._store.connections.getAll()){let y=d.has(g.fOutputId()),C=l.has(g.fInputId());if(!y&&!C)continue;let E=r.get(g.fId())??this._createConnectionHandler(g,t,o);if(r.set(g.fId(),E),y){let b=this._store.outputs.require(g.fOutputId());u.source.push({handler:E,connector:b})}if(C){let b=this._store.inputs.require(g.fInputId());u.target.push({handler:E,connector:b})}}return u}_createConnectionHandler(e,t,o){let r=t.has(e.fOutputId()),s=o.has(e.fInputId()),a=r&&s?this._dragInjector.createInstance(Ty):r?this._dragInjector.createInstance(Ey):this._dragInjector.createInstance(Py);return a.initialize(e),a}static \u0275fac=function(t){return new(t||Qr)};static \u0275prov=f({token:Qr,factory:Qr.\u0275fac})};return n=p([_(Zc)],n),n})(),Ry=(()=>{let n=class Jr{_mediator=c(D);_store=c(x);_dragSession=c(V);_dragInjector=c(Pe);get _transform(){return this._store.transform}handle({event:e,fTrigger:t}){if(!this._dragSession.isEmpty()||!this._isResizeHandle(e.targetElement)||!Ve(e.originalEvent,t))return;let o=this._findResizableNode(e.targetElement);if(!o)return;this._selectBeforeResize(o);let r=this._transform.scale??1;this._dragSession.onPointerDownScale=r,this._dragSession.onPointerDownPosition=j.fromPoint(e.getPosition()).elementTransform(this._store.flowHost).div(r);let s=this._dragInjector.createInstance(Bu);s.initialize(o,this._readResizeHandleType(e.targetElement)),this._mediator.execute(new Zc(s,o)),this._dragSession.draggableItems=[s]}_isResizeHandle(e){return Mn(e,".f-resize-handle")}_findResizableNode(e){let t=this._store.nodes.getAll().find(o=>o.isContains(e));if(t)return t.fDraggingDisabled()?void 0:t}_selectBeforeResize(e){queueMicrotask(()=>{this._mediator.execute(new yn(e))})}_readResizeHandleType(e){let t=Mf(e,"fResizeHandleType",".f-resize-handle");return nt[t]}static \u0275fac=function(t){return new(t||Jr)};static \u0275prov=f({token:Jr,factory:Jr.\u0275fac})};return n=p([_(Kc)],n),n})(),Ny=[Cy,xy,wy,by,Iy,My,Dy,Ry],Qc=class{event;static fToken=Symbol("RotateNodeFinalizeRequest");constructor(i){this.event=i}},Ah="node-rotate",Lh="rotate-node";function ky(n){return n.getEvent().kind===Lh||n.getEvent().fEventType===Ah}var Oy=(()=>{let n=class es{_dragSession=c(V);handle(e){this._isValid()&&this._dragSession.draggableItems.forEach(t=>{t.onPointerUp?.()})}_isValid(){return this._dragSession.draggableItems.some(e=>ky(e))}static \u0275fac=function(t){return new(t||es)};static \u0275prov=f({token:es,factory:es.\u0275fac})};return n=p([_(Qc)],n),n})(),Jc=class{event;fTrigger;static fToken=Symbol("RotateNodePreparationRequest");constructor(i,e){this.event=i,this.fTrigger=e}},Gu=class{fNodeId;constructor(i){this.fNodeId=i}};function Fy(n,i,e){let{x:t,y:o}=Ay(n,i,e),r=t-n.x,s=o-n.y;return{x:r,y:s}}function Ay(n,i,e){let t=n.x-e.x,o=n.y-e.y,r=i*Math.PI/180,s=Math.cos(r),a=Math.sin(r),d=t*s-o*a,l=t*a+o*s,u=d+e.x,g=l+e.y;return{x:u,y:g}}var Hu=(()=>{class n extends Oe{type=Ah;kind=Lh;data(){return new Gu(this._nodeOrGroup.fId())}_store=c(x);_mediator=c(D);_dragSession=c(V);_nodeOrGroup;_sourceConnections;_targetConnections;_startRotation=0;_nodeRect;_nodeCenter;_pointerDownInFlow;_rotationOffsetDeg=0;get _transform(){return this._store.transform}initialize(e,t,o){this._nodeOrGroup=e,this._sourceConnections=t,this._targetConnections=o,this._startRotation=this._nodeOrGroup._rotate}prepareDragSequence(){this._nodeRect=this._readNodeRect(),this._nodeCenter=this._nodeRect.gravityCenter,this._pointerDownInFlow=this._calculatePointerDownInFlow();let e=this._angleDeg(this._pointerDownInFlow);this._rotationOffsetDeg=e-this._startRotation}onPointerMove(e){let t=M.sum(this._pointerDownInFlow,e),r=this._angleDeg(t)-this._rotationOffsetDeg;this._applyRotation(r);let s=r-this._startRotation;for(let a of this._sourceConnections)a.connection.setSourceDelta(this._deltaAfterRotation(a.connector,s));for(let a of this._targetConnections)a.connection.setTargetDelta(this._deltaAfterRotation(a.connector,s))}onPointerUp(){this._nodeOrGroup.rotate.set(this._nodeOrGroup._rotate),this._nodeOrGroup.refresh()}_readNodeRect(){return this._mediator.execute(new de(this._nodeOrGroup.hostElement))}_calculatePointerDownInFlow(){return M.sub(this._dragSession.onPointerDownPosition,M.sum(this._transform.position,this._transform.scaledPosition))}_angleDeg(e){return Math.atan2(e.y-this._nodeCenter.y,e.x-this._nodeCenter.x)*(180/Math.PI)}_applyRotation(e){this._nodeOrGroup.updateRotate(e),this._nodeOrGroup.redraw()}_deltaAfterRotation(e,t){return Fy(e,t,this._nodeCenter)}static \u0275fac=(()=>{let e;return function(o){return(e||(e=X(n)))(o||n)}})();static \u0275prov=f({token:n,factory:n.\u0275fac})}return n})(),Ly=(()=>{let n=class ts{_mediator=c(D);_store=c(x);_dragContext=c(V);_dragInjector=c(Pe);get _transform(){return this._store.transform}handle(e){if(!this._isPreparationAllowed(e))return;let t=this._findRotatableNode(e.event.targetElement);if(!t)return;this._selectBeforeRotate(t);let o=this._transform.scale;this._dragContext.onPointerDownScale=o,this._dragContext.onPointerDownPosition=j.fromPoint(e.event.getPosition()).elementTransform(this._store.flowHost).div(o);let r=this._dragInjector.createInstance(Hu);r.initialize(t,this._buildOutputConnectionHandlers(t),this._buildInputConnectionHandlers(t)),this._dragContext.draggableItems=[r]}_isPreparationAllowed({event:e,fTrigger:t}){return this._dragContext.isEmpty()&&s0(e.targetElement)&&Ve(e.originalEvent,t)}_findRotatableNode(e){for(let t of this._store.nodes.getAll())if(!t.fDraggingDisabled()&&t.isContains(e))return t}_selectBeforeRotate(e){queueMicrotask(()=>{this._mediator.execute(new yn(e))})}_buildInputConnectionHandlers(e){return this._mediator.execute(new rd(e)).map(t=>{let o=this._store.inputs.require(t.fInputId()),r=this._mediator.execute(new He(o)),s=this._dragInjector.get(ei);return s.initialize(t),{connection:s,connector:r.rect.gravityCenter}})}_buildOutputConnectionHandlers(e){return this._mediator.execute(new gd(e)).map(t=>{let o=this._store.outputs.require(t.fOutputId()),r=this._mediator.execute(new He(o)),s=this._dragInjector.get(Qn);return s.initialize(t),{connection:s,connector:r.rect.gravityCenter}})}static \u0275fac=function(t){return new(t||ts)};static \u0275prov=f({token:ts,factory:ts.\u0275fac})};return n=p([_(Jc)],n),n})(),zy=[Oy,Ly],ii=class{flowRect;canvasPosition;eventPoint;minimap;static fToken=Symbol("CalculateFlowPointFromMinimapPointRequest");constructor(i,e,t,o){this.flowRect=i,this.canvasPosition=e,this.eventPoint=t,this.minimap=o}},By=(()=>{let n=class ns{_store=c(x);get _canvasScale(){return this._store.transform.scale||1}handle(e){return M.sub(e.canvasPosition,M.sub(this._getPositionInViewBox(e.eventPoint,e.minimap),this._getNormalizedFlowCenter(e.flowRect)))}_getNormalizedFlowCenter(e){return j.fromPoint(e.gravityCenter).sub(e)}_getPositionInViewBox(e,t){let o=this.normalizeEventPoint(e,t);return M.sum(o,z.mult(t.viewBox,this._canvasScale))}normalizeEventPoint(e,t){return this._getEventPointInMinimap(e,t).mult(t.scale).mult(this._canvasScale)}_getEventPointInMinimap(e,t){return j.fromPoint(e).elementTransform(t.element)}static \u0275fac=function(t){return new(t||ns)};static \u0275prov=f({token:ns,factory:ns.\u0275fac})};return n=p([_(ii)],n),n})(),ed=class{event;static fToken=Symbol("DragMinimapFinalizeRequest");constructor(i){this.event=i}},Gy=(()=>{let n=class is{_dragSession=c(V);handle(e){this._isValid()&&this._dragSession.draggableItems.forEach(t=>{t.onPointerUp?.()})}_isValid(){return this._dragSession.draggableItems.some(Hy)}static \u0275fac=function(t){return new(t||is)};static \u0275prov=f({token:is,factory:is.\u0275fac})};return n=p([_(ed)],n),n})(),zh="minimap",Bh="minimap";function Hy(n){return n.getEvent().kind===Bh||n.getEvent().fEventType===zh}var ju=(()=>{class n extends Oe{type=zh;kind=Bh;_store=c(x);_mediator=c(D);_lastDelta=null;_flowRect;_startCanvasPosition;_eventPoint;_minimap;initialize(e,t,o,r){this._flowRect=e,this._startCanvasPosition=t,this._eventPoint=o,this._minimap=r}prepareDragSequence(){this._store.fCanvas?.hostElement.classList.add("f-scaled-animate")}onPointerMove(e){this._lastDelta&&this._isSamePoint(e,this._lastDelta)||(this._lastDelta=e,this._store.fCanvas?.setPosition(this._getNewPosition(j.fromPoint(this._eventPoint).add(e))),this._store.fCanvas?.redraw())}_isSamePoint(e,t){return e.x===t.x&&e.y===t.y}_getNewPosition(e){return this._mediator.execute(new ii(this._flowRect,this._startCanvasPosition,e,this._minimap))}onPointerUp(){this._store.fCanvas?.hostElement.classList.remove("f-scaled-animate"),this._store.fCanvas?.emitCanvasChangeEvent()}static \u0275fac=(()=>{let e;return function(o){return(e||(e=X(n)))(o||n)}})();static \u0275prov=f({token:n,factory:n.\u0275fac})}return n})(),td=class{event;static fToken=Symbol("DragMinimapPreparationRequest");constructor(i){this.event=i}},jy=(()=>{let n=class os{_store=c(x);_mediator=c(D);_dragSession=c(V);_dragInjector=c(Pe);get _canvas(){return this._store.fCanvas}get _flowHost(){return this._store.flowHost}handle({event:e}){if(!this._isValid(e))return;let t=this._store.instances.require(ae.MINIMAP).state,o=e.getPosition(),r=j.fromPoint(this._store.transform.position),s=z.fromElement(this._flowHost);this._canvas.setPosition(this._calculateCanvasPosition(s,o,t)),this._canvas.redraw(),this._canvas.emitCanvasChangeEvent(),this._dragSession.onPointerDownScale=1,this._dragSession.onPointerDownPosition=j.fromPoint(o).elementTransform(this._flowHost);let a=this._dragInjector.createInstance(ju);a.initialize(s,r,o,t),this._dragSession.draggableItems=[a]}_isValid(e){return!(!this._dragSession.isEmpty()||!this._flowHost.contains(e.targetElement)||!e.targetElement.closest(".f-minimap")||!this._store.instances.get(ae.MINIMAP))}_calculateCanvasPosition(e,t,o){return this._mediator.execute(new ii(e,j.fromPoint(this._canvas.transform.position),t,o))}static \u0275fac=function(t){return new(t||os)};static \u0275prov=f({token:os,factory:os.\u0275fac})};return n=p([_(td)],n),n})(),Vy=[By,Gy,jy];function Uy(n){return!!n&&typeof n.destroy=="function"}var Pe=(()=>{class n{_injector=c(Ae);_dragInjector=null;_created=[];create(){this._dragInjector=Ae.create({providers:[{provide:nd,useClass:nd},{provide:_c,useClass:_c},{provide:ac,useClass:ac},{provide:Cu,useClass:Cu},{provide:Yn,useClass:Yn},{provide:Qn,useClass:Qn},{provide:ei,useClass:ei},{provide:Jn,useClass:Jn},{provide:It,useClass:It},{provide:Hc,useClass:Hc},{provide:Lu,useClass:Lu},{provide:Bu,useClass:Bu},{provide:Hu,useClass:Hu},{provide:ju,useClass:ju}],parent:this._injector}),this._created=[]}get(e){if(!this._dragInjector)throw new Error("DragHandlerInjector has not been created. Call create() before using get().");return this._dragInjector.get(e)}createInstance(e){if(!this._dragInjector)throw new Error("DragHandlerInjector is not created");let t=uf(this._dragInjector,()=>new e);return this._created.push(t),t}destroy(){for(let e of this._created)Uy(e)&&e.destroy();this._created=[],this._dragInjector?.destroy?.(),this._dragInjector=null}static \u0275fac=function(t){return new(t||n)};static \u0275prov=f({token:n,factory:n.\u0275fac})}return n})(),St=(()=>{class n{_data;setData(e){this._data=J(J({},this._data),e)}getData(){return this._data}clear(){this._data=void 0}static \u0275fac=function(t){return new(t||n)};static \u0275prov=f({token:n,factory:n.\u0275fac})}return n})(),eh="f-canvas-dragging",th="canvas-dragging",nd=(()=>{class n extends Oe{type="canvas-move";kind="drag-canvas";_store=c(x);_onPointerDownPosition=M.initialize();constructor(){super(),this._store.fCanvas?.hostElement.classList.add(eh,th)}prepareDragSequence(){this._onPointerDownPosition=this._store.transform.position}onPointerMove(e){this._store.fCanvas?.setPosition(j.fromPoint(this._onPointerDownPosition).add(e)),this._store.fCanvas?.redraw()}onPointerUp(){this._store.fCanvas?.emitCanvasChangeEvent(),this._store.fCanvas?.hostElement.classList.remove(eh,th)}static \u0275fac=function(t){return new(t||n)};static \u0275prov=f({token:n,factory:n.\u0275fac})}return n})(),Wy=(()=>{let n=class rs{_dragContext=c(V);handle(e){this._isValid()&&this._dragContext.draggableItems.forEach(t=>t.onPointerUp?.())}_isValid(){return this._dragContext.draggableItems.some(e=>e instanceof nd)}static \u0275fac=function(t){return new(t||rs)};static \u0275prov=f({token:rs,factory:rs.\u0275fac})};return n=p([_(nc)],n),n})(),id=class{event;fTrigger;static fToken=Symbol("DragCanvasPreparationRequest");constructor(i,e){this.event=i,this.fTrigger=e}},$y=(()=>{let n=class ss{_store=c(x);_dragContext=c(V);_dragInjector=c(Pe);handle({event:e,fTrigger:t}){!this._isValid(e)||!this._isValidTrigger(e,t)||(this._dragContext.onPointerDownScale=1,this._dragContext.onPointerDownPosition=j.fromPoint(e.getPosition()).elementTransform(this._store.flowHost),this._dragContext.draggableItems=[this._dragInjector.get(nd)])}_isValid(e){return this._dragContext.isEmpty()&&(this._isBackgroundElement(e.targetElement)||this._isDragOnHost(e.targetElement))}_isBackgroundElement(e){return this._store.instances.get(ae.BACKGROUND)?.hostElement.contains(e)}_isDragOnHost(e){return this._store.flowHost.contains(e)&&!this._getNode(e)}_getNode(e){let t=this._store.nodes.getAll().find(o=>o.isContains(e));return t&&t.fDraggingDisabled()&&(t=void 0),t}_isValidTrigger(e,t){return Ve(e.originalEvent,t)}static \u0275fac=function(t){return new(t||ss)};static \u0275prov=f({token:ss,factory:ss.\u0275fac})};return n=p([_(id)],n),n})(),Xy=[Wy,$y],od=class{event;trigger;static fToken=Symbol("SelectByPointerRequest");constructor(i,e){this.event=i,this.trigger=e}},qy=(()=>{let n=class as{_mediator=c(D);_store=c(x);_dragSession=c(V);handle({event:e,trigger:t}){if(!this._isSelectionAllowed(e))return;let o=this._resolveSelectable(e.targetElement);this._deferRaiseLayerFor(o),Ve(e.originalEvent,t)?this._applyToggleSelect(o):this._applySingleSelect(o)}_isSelectionAllowed(e){return this._store.flowHost.contains(e.targetElement)&&this._dragSession.isEmpty()}_resolveSelectable(e){return this._findNodeOrGroupAt(e)??this._findConnectionAt(e)}_findNodeOrGroupAt(e){return this._store.nodes.getAll().find(t=>t.isContains(e))}_findConnectionAt(e){return this._store.connections.getAll().find(t=>t.isContains(e))}_deferRaiseLayerFor(e){e&&queueMicrotask(()=>{this._mediator.execute(new Wt(e,e.hostElement.parentElement))})}_applySingleSelect(e){if(!e||e.fSelectionDisabled()){this._clearSelection();return}e.isSelected()||(this._clearSelection(),this._select(e))}_applyToggleSelect(e){!e||e.fSelectionDisabled()||(e.isSelected()?this._deselect(e):this._select(e))}_clearSelection(){if(this._dragSession.selectedItems.length){for(let e of this._dragSession.selectedItems)e.unmarkAsSelected();this._dragSession.markSelectionAsChanged(),this._dragSession.selectedItems=[]}}_select(e){this._dragSession.selectedItems.push(e),e.markAsSelected(),this._dragSession.markSelectionAsChanged()}_deselect(e){let t=this._dragSession.selectedItems.indexOf(e);t>=0&&this._dragSession.selectedItems.splice(t,1),e.unmarkAsSelected(),this._dragSession.markSelectionAsChanged()}static \u0275fac=function(t){return new(t||as)};static \u0275prov=f({token:as,factory:as.\u0275fac})};return n=p([_(od)],n),n})(),Yy=[qy];var Vu=class extends du{hostElement=c(he).nativeElement};function Ky(n){return Mn(n,".f-drag-blocker")}var Gh=(()=>{class n extends Vu{_result=c(St);_mediator=c(D);_platform=c(Cl);disabled=!1;fMultiSelectTrigger=e=>this._platform.getOS()===mt.MAC_OS?e.metaKey:e.ctrlKey;fReassignConnectionTrigger=qe;fCreateConnectionTrigger=qe;fConnectionWaypointsTrigger=F(qe);fMoveControlPointTrigger=qe;fNodeResizeTrigger=qe;fNodeRotateTrigger=qe;fNodeMoveTrigger=qe;fCanvasMoveTrigger=qe;fExternalItemTrigger=qe;fSelectionChange=new Qe;fNodeIntersectedWithConnections=new Qe;fNodeConnectionsIntersection=lt();fEmitOnNodeIntersect=!1;fCreateNode=new Qe;fMoveNodes=new Qe;fReassignConnection=new Qe;fCreateConnection=new Qe;fConnectionWaypointsChanged=lt();fDropToGroup=new Qe;vCellSize=F(1,{transform:e=>Ne(e,1)});hCellSize=F(1,{transform:e=>Ne(e,1)});fCellSizeWhileDragging=F(!1,{transform:e=>re(e)});fDragStarted=new Qe;fDragEnded=new Qe;_dragHandlerInjector=c(Pe);ngOnInit(){this._mediator.execute(new cd(this))}ngAfterViewInit(){super.subscribe()}onPointerDown(e){if(Ky(e.targetElement))return!1;this._dragHandlerInjector.create(),this._result.clear(),this._mediator.execute(new ld),this._mediator.execute(new Uc(e)),this._mediator.execute(new td(e)),this._mediator.execute(new jc(e)),this._mediator.execute(new od(e,this.fMultiSelectTrigger)),this._mediator.execute(new fc(e,this.fReassignConnectionTrigger)),this._mediator.execute(new lc(e,this.fCreateConnectionTrigger)),this._mediator.execute(new mc(e,this.fConnectionWaypointsTrigger()));let t=e.isMouseLeftButton();return t||this.finalizeDragSequence(),t}prepareDragSequence(e){this._mediator.execute(new Kc(e,this.fNodeResizeTrigger)),this._mediator.execute(new Jc(e,this.fNodeRotateTrigger)),this._mediator.execute(new Rc(e,this.fNodeMoveTrigger)),this._mediator.execute(new zc(e,this.fExternalItemTrigger)),this._mediator.execute(new Nc(e)),this._mediator.execute(new id(e,this.fCanvasMoveTrigger)),this._mediator.execute(new ud)}onSelect(e){this._mediator.execute(new Bc(e))}onPointerMove(e){this._mediator.execute(new dd(e))}onPointerUp(e){this._mediator.execute(new ed(e)),this._mediator.execute(new Vc(e)),this._mediator.execute(new uc(e)),this._mediator.execute(new sc(e)),this._mediator.execute(new Yc(e)),this._mediator.execute(new Qc(e)),this._mediator.execute(new Mc(e)),this._mediator.execute(new Ac(e)),this._mediator.execute(new yc(e)),this._mediator.execute(new nc(e)),this._mediator.execute(new Gc(e)),this._mediator.execute(new gc(e)),this._mediator.execute(new Ka)}finalizeDragSequence(){this._mediator.execute(new bt),this._mediator.execute(new Wn),this._result.clear(),this._dragHandlerInjector.destroy()}ngOnDestroy(){this._mediator.execute(new bt),this._mediator.execute(new fd),super.unsubscribe()}static \u0275fac=(()=>{let e;return function(o){return(e||(e=X(n)))(o||n)}})();static \u0275dir=_e({type:n,selectors:[["f-flow","fDraggable",""]],inputs:{disabled:[2,"fDraggableDisabled","disabled",re],fMultiSelectTrigger:"fMultiSelectTrigger",fReassignConnectionTrigger:"fReassignConnectionTrigger",fCreateConnectionTrigger:"fCreateConnectionTrigger",fConnectionWaypointsTrigger:[1,"fConnectionWaypointsTrigger"],fMoveControlPointTrigger:"fMoveControlPointTrigger",fNodeResizeTrigger:"fNodeResizeTrigger",fNodeRotateTrigger:"fNodeRotateTrigger",fNodeMoveTrigger:"fNodeMoveTrigger",fCanvasMoveTrigger:"fCanvasMoveTrigger",fExternalItemTrigger:"fExternalItemTrigger",fEmitOnNodeIntersect:[2,"fEmitOnNodeIntersect","fEmitOnNodeIntersect",re],vCellSize:[1,"vCellSize"],hCellSize:[1,"hCellSize"],fCellSizeWhileDragging:[1,"fCellSizeWhileDragging"]},outputs:{fSelectionChange:"fSelectionChange",fNodeIntersectedWithConnections:"fNodeIntersectedWithConnections",fNodeConnectionsIntersection:"fNodeConnectionsIntersection",fCreateNode:"fCreateNode",fMoveNodes:"fMoveNodes",fReassignConnection:"fReassignConnection",fCreateConnection:"fCreateConnection",fConnectionWaypointsChanged:"fConnectionWaypointsChanged",fDropToGroup:"fDropToGroup",fDragStarted:"fDragStarted",fDragEnded:"fDragEnded"},exportAs:["fDraggable"],standalone:!1,features:[be([St,Pe]),ce]})}return n})(),Zy=[...Xy,...T0,...Ym,...Yy,...dy,...i0,...Vy,...Y0,...uy,...Ny,...zy,...vy,..._y],Qy=(()=>{let n=class cs{_store=c(x);handle({waypointIndex:e,connectionId:t}){let o=this._store.connections.require(t),r=o.fWaypoints()?.waypoints().slice();if(!r)throw new Error("Connection waypoints not found");r.splice(e,1),o.fWaypoints()?.waypoints.set(r),this._store.fDraggable?.fConnectionWaypointsChanged.emit(this._changeEvent(o))}_changeEvent(e){return new pc(e.fId(),e.fWaypoints()?.waypoints()||[])}static \u0275fac=function(t){return new(t||cs)};static \u0275prov=f({token:cs,factory:cs.\u0275fac})};return n=p([_(ru)],n),n})(),Uu=class{static fToken=Symbol("RemoveSnapConnectionFromStoreRequest")},Jy=(()=>{let n=class ds{_store=c(x);handle(e){this._store.connections.removeInstanceForSnap()}static \u0275fac=function(t){return new(t||ds)};static \u0275prov=f({token:ds,factory:ds.\u0275fac})};return n=p([_(Uu)],n),n})(),ev=[Vd,$t,$p,Xp,qp,Yp,j_,ym,X_,fm,Dm,Sm,mm,Em,Mm,Pm,_m,bm,q_,Om,pm,gm,hm,am,um,cm,dm,Tm,xm,Rm,Nm,Im,wm,km,Fm,Am,Lm,Jy,Qy],oi=class{instance;static fToken=Symbol("AddConnectorToStoreRequest");constructor(i){this.instance=i}},tv=(()=>{let n=class ls{_store=c(x);_mediator=c(D);handle({instance:e}){switch(e.kind){case"input":this._addInput(e);break;case"output":this._addOutput(e);break;case"outlet":this._addOutlet(e);break;default:throw new Error(`Unknown connector kind: ${e.kind}`)}}_addInput(e){this._store.inputs.add(e),this._store.emitNodeChanges(),this._geometryRegister(e)}_addOutput(e){this._store.outputs.add(e),this._store.emitNodeChanges(),this._geometryRegister(e)}_addOutlet(e){this._store.outlets.add(e),this._store.emitNodeChanges(),this._geometryRegister(e)}_geometryRegister(e){this._mediator.execute(new Ra(e.fId(),e.fNodeId,e.kind,e.hostElement))}static \u0275fac=function(t){return new(t||ls)};static \u0275prov=f({token:ls,factory:ls.\u0275fac})};return n=p([_(oi)],n),n})(),Vt=class{position;connectorRefs;static fToken=Symbol("CalculateClosestConnectorRequest");constructor(i,e){this.position=i,this.connectorRefs=e}},nv=(()=>{let n=class us{handle({position:e,connectorRefs:t}){let o,r=1/0;for(let s of t){let a=this._distanceToRect(e,s.rect);a<r&&(r=a,o=s)}return o?fl(J({},o),{distance:r}):void 0}_distanceToRect(e,{x:t,y:o,width:r,height:s}){let a=this._clamp(e.x,t,t+r),d=this._clamp(e.y,o,o+s),l=e.x-a,u=e.y-d;return Math.sqrt(l*l+u*u)}_clamp(e,t,o){return Math.max(t,Math.min(o,e))}static \u0275fac=function(t){return new(t||us)};static \u0275prov=f({token:us,factory:us.\u0275fac})};return n=p([_(Vt)],n),n})(),ri=class{pointerPosition;connectableConnectors;static fToken=Symbol("FindConnectableConnectorUsingPriorityAndPositionRequest");constructor(i,e){this.pointerPosition=i,this.connectableConnectors=e}},iv=(()=>{let n=class fs{_mediator=c(D);_store=c(x);_browser=c(pe);get _transform(){return this._store.transform}get _flowHost(){return this._store.flowHost}get _fNodes(){return this._store.nodes.getAll()}get _snapConnection(){return this._store.connections.getForSnap()}handle(e){let t=this._findConnectorAtPosition(e);return t.length>0?t[0]:void 0}_findConnectorAtPosition(e){let t=[];t.push(...this._filterConnectorsThatLocatedAtPosition(e));let o=this._isSnapConnectionEnabledAndHasClosestConnector(e);o&&t.unshift(o.connector);let r=this._getFirstConnectableConnectorOfNodeAtPosition(e);return r&&t.push(r),t}_filterConnectorsThatLocatedAtPosition(e){return e.connectableConnectors.filter(t=>z.isIncludePoint(t.rect,this._calculatePointerInFlow(e.pointerPosition))).map(t=>t.connector)}_calculatePointerInFlow(e){return xn(e,this._flowHost,this._transform)}_isSnapConnectionEnabledAndHasClosestConnector(e){if(!this._snapConnection)return;let t=this._mediator.execute(new Vt(this._calculatePointerInFlow(e.pointerPosition),e.connectableConnectors));return this._isValidClosestInput(t)?t:void 0}_isValidClosestInput(e){return!!e&&e.distance<this._snapConnection.fSnapThreshold}_getFirstConnectableConnectorOfNodeAtPosition(e){return this._getElementsFromPoint(e.pointerPosition).map(t=>this._findConnectableNode(t)).filter(t=>!!t).map(t=>this._findFirstConnectableConnectorOfNode(e.connectableConnectors,t)).find(t=>!!t)}_getElementsFromPoint(e){return this._browser.document.elementsFromPoint(e.x,e.y)}_findConnectableNode(e){return this._fNodes.find(t=>t.isContains(e)&&t.fConnectOnNode())}_findFirstConnectableConnectorOfNode(e,t){return e.find(o=>o.connector.fNodeId===t.fId())?.connector}static \u0275fac=function(t){return new(t||fs)};static \u0275prov=f({token:fs,factory:fs.\u0275fac})};return n=p([_(ri)],n),n})(),si=class{source;pointer;static fToken=Symbol("CalculateTargetConnectorsToConnectRequest");constructor(i,e){this.source=i,this.pointer=e}},He=class{connector;static fToken=Symbol("GetConnectorRectReferenceRequest");constructor(i){this.connector=i}},ov=(()=>{let n=class hs{_mediator=c(D);handle({connector:e}){return{connector:e,rect:this._getRect(e)}}_getRect(e){return this._mediator.execute(new wt(e.hostElement))}static \u0275fac=function(t){return new(t||hs)};static \u0275prov=f({token:hs,factory:hs.\u0275fac})};return n=p([_(He)],n),n})(),ai=class{nodeOrGroup;static fToken=Symbol("AddNodeToStoreRequest");constructor(i){this.nodeOrGroup=i}},rv=(()=>{let n=class gs{_store=c(x);_mediator=c(D);handle({nodeOrGroup:e}){this._store.nodes.add(e),this._mediator.execute(new Na(e.fId(),e.hostElement,e)),this._store.emitNodeChanges()}static \u0275fac=function(t){return new(t||gs)};static \u0275prov=f({token:gs,factory:gs.\u0275fac})};return n=p([_(ai)],n),n})(),rd=class{nodeOrGroup;static fToken=Symbol("CalculateInputConnectionsRequest");constructor(i){this.nodeOrGroup=i}},sv=(()=>{let n=class ps{_store=c(x);handle({nodeOrGroup:e}){let t=this._collectInputIds(e);return this._collectConnections(t)}_collectInputIds(e){let t=new Set,o=this._store.inputs.getAll();for(let r of o)e.isContains(r.hostElement)&&t.add(r.fId());return t}_collectConnections(e){let t=[],o=this._store.connections.getAll();for(let r of o)e.has(r.fInputId())&&t.push(r);return t}static \u0275fac=function(t){return new(t||ps)};static \u0275prov=f({token:ps,factory:ps.\u0275fac})};return n=p([_(rd)],n),n})(),fn=class{connector;pointerPosition;static fToken=Symbol("CalculateConnectableSideByConnectedPositionsRequest");constructor(i,e){this.connector=i,this.pointerPosition=e}},nh=2,Re=(function(n){return n[n.NONE=0]="NONE",n[n.LEFT=1]="LEFT",n[n.RIGHT=2]="RIGHT",n[n.TOP=4]="TOP",n[n.BOTTOM=8]="BOTTOM",n[n.ALL=15]="ALL",n})(Re||{});function av(n,i,e,t,o){let r=cv(o),s=e-n,a=t-i,d=dv(s,a);return lv(d,r)?d:uv(s,a,r,d)}function cv(n){if(!n||n.length===0)return Re.ALL;let i=Re.NONE;for(let e=0;e<n.length;e++)switch(n[e]){case R.LEFT:i|=Re.LEFT;break;case R.RIGHT:i|=Re.RIGHT;break;case R.TOP:i|=Re.TOP;break;case R.BOTTOM:i|=Re.BOTTOM;break}return i||Re.ALL}function dv(n,i){let e=n<0?-n:n,t=i<0?-i:i;return e-t>nh?n<0?R.LEFT:R.RIGHT:(t-e>nh,i<0?R.TOP:R.BOTTOM)}function lv(n,i){switch(n){case R.LEFT:return(i&Re.LEFT)!==0;case R.RIGHT:return(i&Re.RIGHT)!==0;case R.TOP:return(i&Re.TOP)!==0;case R.BOTTOM:return(i&Re.BOTTOM)!==0;default:return!0}}function uv(n,i,e,t){let o=t,r=-1/0;if(e&Re.RIGHT){let s=n;s>r&&(r=s,o=R.RIGHT)}if(e&Re.LEFT){let s=-n;s>r&&(r=s,o=R.LEFT)}if(e&Re.BOTTOM){let s=i;s>r&&(r=s,o=R.BOTTOM)}if(e&Re.TOP){let s=-i;s>r&&(r=s,o=R.TOP)}return o}function sd(n){return n===R.CALCULATE||n===R.CALCULATE_HORIZONTAL||n===R.CALCULATE_VERTICAL}var fv={[R.CALCULATE]:[R.TOP,R.BOTTOM,R.LEFT,R.RIGHT],[R.CALCULATE_HORIZONTAL]:[R.LEFT,R.RIGHT],[R.CALCULATE_VERTICAL]:[R.TOP,R.BOTTOM]},hv=(()=>{let n=class _s{_mediator=c(D);handle({connector:e,pointerPosition:t}){let o=e.userFConnectableSide,r=this._getConnectorRect(e.hostElement).gravityCenter,s=this._accumulateConnectedCenters(e.hostElement,e.toConnector,t),a=s.sumX/s.count,d=s.sumY/s.count;return av(r.x,r.y,a,d,fv[o])}_accumulateConnectedCenters(e,t,o){let r=o?.x||0,s=o?.y||0,a=o?1:0;if(t&&t.length)for(let d=0;d<t.length;d++){let l=t[d].hostElement;if(l===e)continue;let u=this._getConnectorRect(l).gravityCenter;r+=u.x,s+=u.y,a++}return{sumX:r,sumY:s,count:a}}_getConnectorRect(e){return this._mediator.execute(new de(e))}static \u0275fac=function(t){return new(t||_s)};static \u0275prov=f({token:_s,factory:_s.\u0275fac})};return n=p([_(fn)],n),n})(),ad=class{connector;static fToken=Symbol("CalculateConnectableSideByInternalPositionRequest");constructor(i){this.connector=i}},cd=class{fComponent;static fToken=Symbol("AddDndToStoreRequest");constructor(i){this.fComponent=i}},gv=(()=>{let n=class ms{_store=c(x);handle(e){this._store.fDraggable=e.fComponent}static \u0275fac=function(t){return new(t||ms)};static \u0275prov=f({token:ms,factory:ms.\u0275fac})};return n=p([_(cd)],n),n})(),dd=class{event;static fToken=Symbol("OnPointerMoveRequest");constructor(i){this.event=i}},pv=(()=>{let n=class ys{_mediator=c(D);_store=c(x);get _hostElement(){return this._store.fDraggable?.hostElement}_dragContext=c(V);handle({event:e}){this._dragContext.rememberPointerEvent(e),this._setDifferenceToDraggableItems(this._getDifferenceBetweenPointerAndPointerDown(e),e),this._mediator.execute(new $n)}_setDifferenceToDraggableItems(e,t){this._dragContext.draggableItems.forEach(o=>{o.onPointerMove(J({},e),t)})}_getDifferenceBetweenPointerAndPointerDown(e){return this._getPointerPositionInCanvas(e).div(this._dragContext.onPointerDownScale).sub(this._dragContext.onPointerDownPosition)}_getPointerPositionInCanvas(e){return j.fromPoint(e.getPosition()).elementTransform(this._hostElement)}static \u0275fac=function(t){return new(t||ys)};static \u0275prov=f({token:ys,factory:ys.\u0275fac})};return n=p([_(dd)],n),n})(),ld=class{static fToken=Symbol("InitializeDragSequenceRequest")},_v=(()=>{let n=class vs{_dragContext=c(V);handle(e){this._dragContext.reset()}static \u0275fac=function(t){return new(t||vs)};static \u0275prov=f({token:vs,factory:vs.\u0275fac})};return n=p([_(ld)],n),n})(),Dt=class{static fToken=Symbol("IsDragStartedRequest")},mv=(()=>{let n=class Cs{_store=c(x);handle(e){return!!this._store.fDraggable?.isDragStarted}static \u0275fac=function(t){return new(t||Cs)};static \u0275prov=f({token:Cs,factory:Cs.\u0275fac})};return n=p([_(Dt)],n),n})(),ud=class{static fToken=Symbol("PrepareDragSequenceRequest")},yv=(()=>{let n=class xs{_mediator=c(D);_dragContext=c(V);handle(e){this._callPrepareDragSequence(),this._mediator.execute(new Za)}_callPrepareDragSequence(){this._dragContext.draggableItems.forEach(e=>e.prepareDragSequence?.())}static \u0275fac=function(t){return new(t||xs)};static \u0275prov=f({token:xs,factory:xs.\u0275fac})};return n=p([_(ud)],n),n})(),fd=class{static fToken=Symbol("RemoveDndFromStoreRequest")},vv=(()=>{let n=class ws{_store=c(x);handle(e){this._store.fDraggable=void 0}static \u0275fac=function(t){return new(t||ws)};static \u0275prov=f({token:ws,factory:ws.\u0275fac})};return n=p([_(fd)],n),n})(),Cv=[gv,pv,_v,yv,mv,vv],xv=new ee("CONNECTABLE_SIDE_EPSILON"),wv=(()=>{let n=class bs{_mediator=c(D);_lastSide=new WeakMap;_epsilon=Math.max(0,c(xv,{optional:!0})??2);handle({connector:e}){if(this._isDragging()){let o=this._lastSide.get(e);if(o!==void 0)return o;let r=this._getSideByDelta(e.hostElement,e.fNodeHost,e);return this._lastSide.set(e,r),r}let t=this._getSideByDelta(e.hostElement,e.fNodeHost,e);return this._lastSide.set(e,t),t}_getSideByDelta(e,t,o){let r=z.fromElement(e),s=t.getBoundingClientRect(),a=r.gravityCenter.x,d=r.gravityCenter.y,l=a-s.left,u=s.right-a,g=d-s.top,y=s.bottom-d,C=0,E=l,b=[l,u,g,y];for(let P=1;P<4;P++){let L=b[P];L<E&&(E=L,C=P)}let w=C===0?R.LEFT:C===1?R.RIGHT:C===2?R.TOP:R.BOTTOM,I=this._lastSide.get(o);if(I!==void 0&&I!==w){let P=I===R.LEFT?0:I===R.RIGHT?1:I===R.TOP?2:3;(P===0?l:P===1?u:P===2?g:y)-E<=this._epsilon&&(w=I)}return w}_isDragging(){return this._mediator.execute(new Dt)}static \u0275fac=function(t){return new(t||bs)};static \u0275prov=f({token:bs,factory:bs.\u0275fac})};return n=p([_(ad)],n),n})(),hn=class{nodeOrGroup;static fToken=Symbol("CalculateConnectorsConnectableSidesRequest");constructor(i){this.nodeOrGroup=i}},bv=(()=>{let n=class Is{_mediator=c(D);handle({nodeOrGroup:e}){let t=e.connectors,o=t.length;for(let s=0;s<o;s++){let a=t[s];a.fConnectableSide=this._resolveSideForConnectorFast(a)}let r=new Set;for(let s=0;s<o;s++){let d=t[s].toConnector;if(d&&d.length)for(let l=0,u=d.length;l<u;l++){let g=d[l],y=g.userFConnectableSide;sd(y)&&r.add(g)}}r.size>0&&r.forEach(s=>{s.fConnectableSide=this._calculateByConnectedPositions(s)})}_resolveSideForConnectorFast(e){let t=e.userFConnectableSide;return t===R.AUTO?this._mediator.execute(new ad(e)):sd(t)?this._calculateByConnectedPositions(e):t}_calculateByConnectedPositions(e){return this._mediator.execute(new fn(e))}static \u0275fac=function(t){return new(t||Is)};static \u0275prov=f({token:Is,factory:Is.\u0275fac})};return n=p([_(hn)],n),n})(),gn=class{static fToken=Symbol("CalculateNodesBoundingBoxRequest")},Iv=(()=>{let n=class Ss{_store=c(x);handle(e){return z.union(this._nodesRects())}_nodesRects(){return this._store.nodes.getAll().map(e=>z.fromElement(e.hostElement))}static \u0275fac=function(t){return new(t||Ss)};static \u0275prov=f({token:Ss,factory:Ss.\u0275fac})};return n=p([_(gn)],n),n})(),hd=class{fNodes;static fToken=Symbol("CalculateNodesBoundingBoxNormalizedPositionRequest");constructor(i){this.fNodes=i}},Sv=(()=>{let n=class Ds{_store=c(x);_mediator=c(D);handle(e){return z.union(this._getNodesRects(e.fNodes||this._store.nodes.getAll()))}_getNodesRects(e){return e.map(t=>this._getNodeRect(t))}_getNodeRect(e){let t=this._mediator.execute(new ln(e.hostElement));if(t)return this._getElementRect(e,t);let o=this._mediator.execute(new de(e.hostElement));return this._getElementRect(e,o)}_getElementRect(e,t){return z.initialize(e._position.x,e._position.y,t.width,t.height)}static \u0275fac=function(t){return new(t||Ds)};static \u0275prov=f({token:Ds,factory:Ds.\u0275fac})};return n=p([_(hd)],n),n})(),gd=class{nodeOrGroup;static fToken=Symbol("CalculateOutputConnectionsRequest");constructor(i){this.nodeOrGroup=i}},Dv=(()=>{let n=class Ts{_store=c(x);handle({nodeOrGroup:e}){let t=this._collectOutputIds(e);return this._collectConnections(t)}_collectOutputIds(e){let t=new Set,o=this._store.outputs.getAll();for(let r of o)e.isContains(r.hostElement)&&t.add(r.fId());return t}_collectConnections(e){let t=[],o=this._store.connections.getAll();for(let r of o)e.has(r.fOutputId())&&t.push(r);return t}static \u0275fac=function(t){return new(t||Ts)};static \u0275prov=f({token:Ts,factory:Ts.\u0275fac})};return n=p([_(gd)],n),n})(),ci=class{nodeOrGroup;static fToken=Symbol("FitToChildNodesAndGroupsRequest");constructor(i){this.nodeOrGroup=i}},Ut=class{fNode;rect;static fToken=Symbol("GetNodePaddingRequest");constructor(i,e){this.fNode=i,this.rect=e}},Tv=(()=>{let n=class Es{_browser=c(pe);handle(e){return e.fNode.fIncludePadding()?this._getPaddingData(e.fNode,e.rect):[0,0,0,0]}_getPaddingData(e,t){let o=this._browser.window.getComputedStyle(e.hostElement);return[this._browser.toPixels(o.paddingLeft,t.width,t.height,o.fontSize),this._browser.toPixels(o.paddingTop,t.width,t.height,o.fontSize),this._browser.toPixels(o.paddingRight,t.width,t.height,o.fontSize),this._browser.toPixels(o.paddingBottom,t.width,t.height,o.fontSize)]}static \u0275fac=function(t){return new(t||Es)};static \u0275prov=f({token:Es,factory:Es.\u0275fac})};return n=p([_(Ut)],n),n})(),Ev=(()=>{let n=class Ps{_mediator=c(D);_store=c(x);get _nodes(){return this._store.nodes.getAll()}handle({nodeOrGroup:e}){if(e.fAutoSizeToFitChildren()){let r=this._calculateDirectChildren(e);if(r.length){let s=this._boundingRect(e),a=this._calculateChildrenBounding(r,this._paddings(e,s));e.updatePosition(a),e.updateSize(a),e.redraw()}}let t=e.fParentId();if(!t)return;let o=this._nodes.find(r=>r.fId()===t);o&&this._mediator.execute(new ci(o))}_calculateDirectChildren(e){return this._nodes.filter(t=>t.fParentId()===e.fId())}_unionRect(e){return z.union(e.map(t=>this._boundingRect(t)))||z.initialize()}_boundingRect(e){return this._mediator.execute(new de(e.hostElement))}_paddings(e,t){return this._mediator.execute(new Ut(e,t))}_calculateChildrenBounding(e,[t,o,r,s]){let a=this._unionRect(e);return a=z.initialize(a.x-t,a.y-o,a.width+t+r,a.height+o+s),a}static \u0275fac=function(t){return new(t||Ps)};static \u0275prov=f({token:Ps,factory:Ps.\u0275fac})};return n=p([_(ci)],n),n})(),pd=class{id;static fToken=Symbol("GetChildNodeIdsRequest");constructor(i){this.id=i}},Pv=(()=>{let n=class Ms{_store=c(x);get _allNodesAndGroups(){return this._store.nodes.getAll()}handle(e){if(!e.id)return[];let t=new Set,o=[];return this._collectDescendants(e.id,o,t),o}_collectDescendants(e,t,o){if(o.has(e))throw new Error(`Circular reference detected in the node hierarchy. Node id: ${e}`);o.add(e);let r=this._allNodesAndGroups.filter(s=>s.fParentId()===e).map(s=>s.fId());t.push(...r);for(let s of r)this._collectDescendants(s,t,o)}static \u0275fac=function(t){return new(t||Ms)};static \u0275prov=f({token:Ms,factory:Ms.\u0275fac})};return n=p([_(pd)],n),n})(),pn=class{nodeOrGroup;static fToken=Symbol("GetParentNodesRequest");constructor(i){this.nodeOrGroup=i}},Mv=(()=>{let n=class Rs{_store=c(x);handle({nodeOrGroup:e}){return this._getParentNodes(e,new Set,[])}_getParentNodes(e,t,o){if(t.has(e.fId()))throw new Error("Circular reference detected in the node hierarchy. Node id: "+e.fId());t.add(e.fId());let r=this._store.nodes.get(e.fParentId());return r?(o.push(r),this._getParentNodes(r,t,o)):o}static \u0275fac=function(t){return new(t||Rs)};static \u0275prov=f({token:Rs,factory:Rs.\u0275fac})};return n=p([_(pn)],n),n})(),di=class{nodeOrGroup;destroyRef;static fToken=Symbol("UpdateNodeWhenStateOrSizeChangedRequest");constructor(i,e){this.nodeOrGroup=i,this.destroyRef=e}},Rv=(()=>{let n=class Ns{_mediator=c(D);handle({nodeOrGroup:e,destroyRef:t}){let{hostElement:o,stateChanges:r}=e;new it(new Ol(o),r).listen(t,()=>{this._mediator.execute(new Ft),this._isDragging()||(this._mediator.execute(new dn(e.fId(),"UpdateNodeWhenStateOrSizeChanged")),this._mediator.execute(new hn(e)),this._mediator.execute(new ci(e)))})}_isDragging(){return this._mediator.execute(new Dt)}static \u0275fac=function(t){return new(t||Ns)};static \u0275prov=f({token:Ns,factory:Ns.\u0275fac})};return n=p([_(di)],n),n})(),li=class{instance;static fToken=Symbol("RemoveNodeFromStoreRequest");constructor(i){this.instance=i}},Nv=(()=>{let n=class ks{_store=c(x);_mediator=c(D);handle({instance:e}){this._store.nodes.remove(e),this._mediator.execute(new ka(e.fId())),this._store.emitNodeChanges()}static \u0275fac=function(t){return new(t||ks)};static \u0275prov=f({token:ks,factory:ks.\u0275fac})};return n=p([_(li)],n),n})(),kv=[rv,hv,wv,sv,bv,Iv,Sv,Dv,Ev,Pv,Tv,Mv,Rv,Nv],Ov=(()=>{let n=class Os{_mediator=c(D);_store=c(x);get _targets(){return this._store.inputs.getAll()}handle({source:e,pointer:t}){let o=this._getConnectableTargets(e),r=[];for(let s of o)r.push(this._mediator.execute(new He(s)));return this._scheduleApplyCalculatedSides(r,t),r}_getConnectableTargets(e){if(e.hasConnectionLimits)return this._targets.filter(o=>e.canConnectTo(o));let t=this._targets.filter(o=>o.canBeConnected);return e.isSelfConnectable||(t=t.filter(o=>o.fNodeId!==e.fNodeId)),t}_scheduleApplyCalculatedSides(e,t){queueMicrotask(()=>this._applyCalculatedConnectableSides(e,t))}_applyCalculatedConnectableSides(e,t){for(let{connector:o}of e)sd(o.userFConnectableSide)&&(o.fConnectableSide=this._calculateByConnectedPositions(o,t))}_calculateByConnectedPositions(e,t){return this._mediator.execute(new fn(e,t))}static \u0275fac=function(t){return new(t||Os)};static \u0275prov=f({token:Os,factory:Os.\u0275fac})};return n=p([_(si)],n),n})(),_d=class{target;pointer;static fToken=Symbol("CalculateSourceConnectorsToConnectRequest");constructor(i,e){this.target=i,this.pointer=e}},Fv=(()=>{let n=class Fs{_mediator=c(D);_store=c(x);get _sources(){return this._store.outputs.getAll()}handle({target:e,pointer:t}){let o=this._getConnectableSources(e),r=[];for(let s of o)r.push(this._mediator.execute(new He(s)));return this._scheduleApplyCalculatedSides(r,t),r}_getConnectableSources(e){return this._sources.filter(t=>{let o=t.canBeConnected;return o&&t.hasConnectionLimits&&(o=t.canConnectTo(e)),o})}_scheduleApplyCalculatedSides(e,t){queueMicrotask(()=>this._applyCalculatedConnectableSides(e,t))}_applyCalculatedConnectableSides(e,t){for(let{connector:o}of e)sd(o.userFConnectableSide)&&(o.fConnectableSide=this._calculateByConnectedPositions(o,t))}_calculateByConnectedPositions(e,t){return this._mediator.execute(new fn(e,t))}static \u0275fac=function(t){return new(t||Fs)};static \u0275prov=f({token:Fs,factory:Fs.\u0275fac})};return n=p([_(_d)],n),n})(),_n=class{connectors;static fToken=Symbol("MarkConnectableConnectorsRequest");constructor(i){this.connectors=i}},Ce={DRAG_AND_DROP:{DRAGGING:"f-dragging",CONNECTIONS_DRAGGING:"f-connections-dragging"},GROUPING:{OVER_BOUNDARY:"f-grouping-over-boundary",DROP_ACTIVE:"f-grouping-drop-active"},CONNECTOR:{OUTPUT_CONNECTED:"f-node-output-connected",OUTPUT_NOT_CONNECTABLE:"f-node-output-not-connectable",INPUT_CONNECTED:"f-node-input-connected",INPUT_NOT_CONNECTABLE:"f-node-input-not-connectable",CONNECTABLE:"f-connector-connectable"}},Av=(()=>{let n=class As{_store=c(x);handle({connectors:e}){this._store.flowHost.classList.add(Ce.DRAG_AND_DROP.CONNECTIONS_DRAGGING),e.forEach(t=>this._markConnector(t))}_markConnector({hostElement:e}){e.classList.add(Ce.CONNECTOR.CONNECTABLE)}static \u0275fac=function(t){return new(t||As)};static \u0275prov=f({token:As,factory:As.\u0275fac})};return n=p([_(_n)],n),n})(),ui=class{instance;static fToken=Symbol("RemoveConnectorFromStoreRequest");constructor(i){this.instance=i}},Lv=(()=>{let n=class Ls{_store=c(x);_mediator=c(D);handle({instance:e}){switch(e.kind){case"input":this._removeInput(e);break;case"output":this._removeOutput(e);break;case"outlet":this._removeOutlet(e);break;default:throw new Error(`Unknown connector kind: ${e.kind}`)}}_removeInput(e){this._store.inputs.removeById(e.fId()),this._store.emitNodeChanges(),this._geometryUnregister(e)}_removeOutput(e){this._store.outputs.removeById(e.fId()),this._store.emitNodeChanges(),this._geometryUnregister(e)}_removeOutlet(e){this._store.outlets.removeById(e.fId()),this._store.emitNodeChanges(),this._geometryUnregister(e)}_geometryUnregister(e){this._mediator.execute(new An(e.fId(),e.kind))}static \u0275fac=function(t){return new(t||Ls)};static \u0275prov=f({token:Ls,factory:Ls.\u0275fac})};return n=p([_(ui)],n),n})(),mn=class{connectors;static fToken=Symbol("UnmarkConnectableConnectorsRequest");constructor(i){this.connectors=i}},zv=(()=>{let n=class zs{_store=c(x);handle({connectors:e}){this._store.flowHost.classList.remove(Ce.DRAG_AND_DROP.CONNECTIONS_DRAGGING),e.forEach(t=>this._unmarkConnector(t))}_unmarkConnector({hostElement:e}){e.classList.remove(Ce.CONNECTOR.CONNECTABLE)}static \u0275fac=function(t){return new(t||zs)};static \u0275prov=f({token:zs,factory:zs.\u0275fac})};return n=p([_(mn)],n),n})(),Bv=[tv,Lv,nv,iv,Fv,Ov,ov,Av,zv],md=class{instance;static fToken=Symbol("AddFlowToStoreRequest");constructor(i){this.instance=i}};var Nn=(function(n){return n.MANUAL="manual",n.AUTO="auto",n})(Nn||{});function Gv(n){let i=[...n.nodes.map(ih),...n.groups.map(ih)],e=new Set(n.nodes.map(a=>a.id)),t=new Set(n.groups.map(a=>a.id)),o=new Map,r=new Map;for(let a of[...n.nodes,...n.groups]){for(let d of a.fOutputs)o.set(d.id,a.id);for(let d of a.fInputs)r.set(d.id,a.id)}let s=n.connections.reduce((a,d)=>{let l=o.get(d.fOutputId),u=r.get(d.fInputId);return!l||!u||a.push({source:l,target:u}),a},[]);return{nodes:i,connections:s,nodeIds:e,groupIds:t}}function ih(n){return{id:n.id,size:n.measuredSize?J({},n.measuredSize):n.size?J({},n.size):void 0}}var Hv=1,Hh=(()=>{class n{_destroyRef=c(Ze);_flows=new Map;_engine;constructor(){this._destroyRef.onDestroy(()=>{Array.from(this._flows.keys()).forEach(e=>this.unregisterFlow(e)),this._engine=void 0})}attachEngine(e){this._engine=e}registerFlow(e,t){let o=e.fId();this.unregisterFlow(o);let r={flow:e,store:t,nodeSignature:this._buildNodeSignature(t),connectionSignature:this._buildConnectionSignature(t),timeoutId:null,raf1:null,raf2:null,unsubs:[],runId:0,isApplying:!1};r.unsubs.push(t.nodesChanges$.listen(()=>this._handleNodesChanges(o)),t.connectionsChanges$.listen(()=>this._handleConnectionsChanges(o))),this._flows.set(o,r),this._engine?.getMode()===Nn.AUTO&&this._scheduleRelayout(o)}unregisterFlow(e){let t=this._flows.get(e);t&&(t.unsubs.forEach(o=>o()),this._clearScheduledWork(t),this._flows.delete(e))}handleModeChanged(e){if(e===Nn.AUTO)for(let t of this._flows.keys())this._scheduleRelayout(t)}async relayout(e){if(this._engine){if(e){let t=this._flows.get(e);t&&await this._relayoutRegisteredFlow(e,t);return}for(let[t,o]of this._flows.entries())await this._relayoutRegisteredFlow(t,o)}}_handleNodesChanges(e){let t=this._flows.get(e);if(!t||t.isApplying)return;let o=this._buildNodeSignature(t.store);o!==t.nodeSignature&&(t.nodeSignature=o,this._scheduleRelayout(e))}_handleConnectionsChanges(e){let t=this._flows.get(e);if(!t||t.isApplying)return;let o=this._buildConnectionSignature(t.store);o!==t.connectionSignature&&(t.connectionSignature=o,this._scheduleRelayout(e))}_scheduleRelayout(e){let t=this._flows.get(e);!t||!this._engine||this._engine.getMode()!==Nn.AUTO||(t.timeoutId!==null&&clearTimeout(t.timeoutId),this._cancelAnimationFrames(t),t.timeoutId=setTimeout(()=>{t.timeoutId=null,this._runAfterNextPaint(t,()=>{this._relayoutFlowIfReady(e)})},Hv))}async _relayoutFlowIfReady(e){let t=this._flows.get(e);if(!(!t||!this._engine||this._engine.getMode()!==Nn.AUTO)){if(t.store.hasPendingProgressiveRender){this._scheduleRelayout(e);return}await this._relayoutRegisteredFlow(e,t)}}async _relayoutRegisteredFlow(e,t){if(!this._engine)return;let o=Gv(t.flow.getState({measuredSize:!0})),r=++t.runId,s=await this._engine.calculate(o.nodes,o.connections,{flowId:e,mode:this._engine.getMode()}),a=this._flows.get(e);if(!(!a||a.runId!==r||!this._applyPositions(a.store,s.nodes).length)){a.isApplying=!0;try{a.flow.redraw(),this._emitWriteback(e,s.nodes,o.nodeIds,o.groupIds)}finally{queueMicrotask(()=>{let l=this._flows.get(e);l&&(l.isApplying=!1)})}}}_emitWriteback(e,t,o,r){let s=this._engine?.getWriteback();s&&s({flowId:e,nodes:t.filter(a=>o.has(a.id)),groups:t.filter(a=>r.has(a.id))})}_applyPositions(e,t){return t.filter(o=>{let r=e.nodes.get(o.id);return!r||M.isEqual(r._position,o.position)?!1:(r.position.set(J({},o.position)),!0)})}_buildNodeSignature(e){return e.nodes.getAll().map(t=>t.fId()).sort().join("|")}_buildConnectionSignature(e){return e.connections.getAll().map(t=>`${t.fId()}:${t.fOutputId()}:${t.fInputId()}`).sort().join("|")}_runAfterNextPaint(e,t){if(this._cancelAnimationFrames(e),typeof requestAnimationFrame!="function"){t();return}e.raf1=requestAnimationFrame(()=>{e.raf1=null,e.raf2=requestAnimationFrame(()=>{e.raf2=null,t()})})}_clearScheduledWork(e){e.timeoutId!==null&&(clearTimeout(e.timeoutId),e.timeoutId=null),this._cancelAnimationFrames(e)}_cancelAnimationFrames(e){e.raf1!==null&&typeof cancelAnimationFrame=="function"&&(cancelAnimationFrame(e.raf1),e.raf1=null),e.raf2!==null&&typeof cancelAnimationFrame=="function"&&(cancelAnimationFrame(e.raf2),e.raf2=null)}static \u0275fac=function(t){return new(t||n)};static \u0275prov=f({token:n,factory:n.\u0275fac})}return n})();var jv=(()=>{let n=class Bs{_store=c(x);_layoutController=c(Hh,{optional:!0});handle({instance:e}){this._store.fFlow=e,this._layoutController?.registerFlow(e,this._store)}static \u0275fac=function(t){return new(t||Bs)};static \u0275prov=f({token:Bs,factory:Bs.\u0275fac})};return n=p([_(md)],n),n})(),yd=class{static fToken=Symbol("GetFlowRequest")},Vv=(()=>{let n=class Gs{_store=c(x);handle(e){let t=this._store.fFlow;if(!t)throw new Error("Flow not found in store");return t}static \u0275fac=function(t){return new(t||Gs)};static \u0275prov=f({token:Gs,factory:Gs.\u0275fac})};return n=p([_(yd)],n),n})(),vd=class{static fToken=Symbol("CalculateConnectionsStateRequest")},Uv=(()=>{let n=class Hs{_store=c(x);handle(e){return this._store.connections.getAll().map(this._mapToConnectionState)}_mapToConnectionState(e){return{id:e.fId(),fOutputId:e.fOutputId(),fInputId:e.fInputId(),fType:e.fType,fBehavior:e.fBehavior,isSelected:e.isSelected(),waypoints:e.fWaypoints()?.waypoints()||[],fInputSide:e.fInputSide(),fOutputSide:e.fOutputSide()}}static \u0275fac=function(t){return new(t||Hs)};static \u0275prov=f({token:Hs,factory:Hs.\u0275fac})};return n=p([_(vd)],n),n})(),fi=class{component;measuredSize;static fToken=Symbol("CalculateNodesStateRequest");constructor(i,e=!1){this.component=i,this.measuredSize=e}},Wv=(()=>{let n=class js{_store=c(x);_mediator=c(D);handle({component:e,measuredSize:t}){return this._store.nodes.getAll().filter(o=>o instanceof e).map(o=>{let r=t?this._mediator.execute(new de(o.hostElement)):null;return{id:o.fId(),parentId:o.fParentId()??void 0,position:J({},o._position),size:o._size?J({},o._size):void 0,measuredSize:r?{width:r.width,height:r.height}:void 0,rotate:o._rotate,fOutputs:this._getOutputs(o.hostElement),fInputs:this._getInputs(o.hostElement),isSelected:o.isSelected()}})}_getOutputs(e){return this._store.outputs.getAll().filter(t=>e.contains(t.hostElement)).map(t=>({id:t.fId(),fConnectableSide:t.fConnectableSide}))}_getInputs(e){return this._store.inputs.getAll().filter(t=>e.contains(t.hostElement)).map(t=>({id:t.fId(),fConnectableSide:t.fConnectableSide}))}static \u0275fac=function(t){return new(t||js)};static \u0275prov=f({token:js,factory:js.\u0275fac})};return n=p([_(fi)],n),n})(),Cd=class{measuredSize;static fToken=Symbol("CalculateFlowStateRequest");constructor(i=!1){this.measuredSize=i}},$v=(()=>{let n=class Vs{_mediator=c(D);_store=c(x);get _canvas(){return this._store.fCanvas}get _transform(){return this._canvas.transform}get _canvasPosition(){return M.sum(this._transform.position,this._transform.scaledPosition)}handle({measuredSize:e}){return{position:this._canvasPosition,scale:this._canvas.transform.scale,nodes:this._mediator.execute(new fi(Wd,e)),groups:this._mediator.execute(new fi(pu,e)),connections:this._mediator.execute(new vd)}}static \u0275fac=function(t){return new(t||Vs)};static \u0275prov=f({token:Vs,factory:Vs.\u0275fac})};return n=p([_(Cd)],n),n})(),Xv=[$v,Wv,Uv],xd=class{instance;static fToken=Symbol("RemoveFlowFromStoreRequest");constructor(i){this.instance=i}},qv=(()=>{let n=class Us{_store=c(x);_layoutController=c(Hh,{optional:!0});handle({instance:e}){this._layoutController?.unregisterFlow(e.fId()),this._store.fFlow=void 0}static \u0275fac=function(t){return new(t||Us)};static \u0275prov=f({token:Us,factory:Us.\u0275fac})};return n=p([_(xd)],n),n})(),$d=(()=>{class n{isNodesRendered=!1;isFullRendered=!1;static \u0275fac=function(t){return new(t||n)};static \u0275prov=f({token:n,factory:n.\u0275fac})}return n})(),wd=class{static fToken=Symbol("NotifyNodesRenderedRequest")},Ku=new ee("F_FLOW"),Wu=class{},Yv=(()=>{let n=class Ws{_state=c($d);_fFlow=c(Ku);handle(e){this._state.isNodesRendered||(this._state.isNodesRendered=!0,this._fFlow.fNodesRendered.emit(this._fFlow.fId()))}static \u0275fac=function(t){return new(t||Ws)};static \u0275prov=f({token:Ws,factory:Ws.\u0275fac})};return n=p([_(wd)],n),n})(),bd=class{static fToken=Symbol("NotifyFullRenderedRequest")},Kv=(()=>{let n=class $s{_state=c($d);_fFlow=c(Ku);handle(e){this._state.isFullRendered||(this._state.isFullRendered=!0,this._fFlow.fFullRendered.emit(this._fFlow.fId()),this._fFlow.fLoaded.emit(this._fFlow.fId()))}static \u0275fac=function(t){return new(t||$s)};static \u0275prov=f({token:$s,factory:$s.\u0275fac})};return n=p([_(bd)],n),n})(),hi=class{targetConnectionsRevision;targetNodesRevision;callback;destroyRef;static fToken=Symbol("WaitForConnectionsRenderedRequest");constructor(i,e,t,o){this.targetConnectionsRevision=i,this.targetNodesRevision=e,this.callback=t,this.destroyRef=o}},Zv=(()=>{let n=class Xs{_store=c(x);handle({targetConnectionsRevision:e,targetNodesRevision:t,callback:o,destroyRef:r}){if(this._store.connectionsRenderedRevision>=e&&this._store.connectionsRenderedNodesRevision>=t){o();return}let s=this._store.connectionsRenderedChanges$.listen(()=>{this._store.connectionsRenderedRevision<e||this._store.connectionsRenderedNodesRevision<t||(s(),o())});r.onDestroy(s)}static \u0275fac=function(t){return new(t||Xs)};static \u0275prov=f({token:Xs,factory:Xs.\u0275fac})};return n=p([_(hi)],n),n})(),Id=class{static fToken=Symbol("ResetRenderLifecycleRequest")},Qv=(()=>{let n=class qs{_state=c($d);handle(e){this._state.isNodesRendered=!1,this._state.isFullRendered=!1}static \u0275fac=function(t){return new(t||qs)};static \u0275prov=f({token:qs,factory:qs.\u0275fac})};return n=p([_(Id)],n),n})(),Sd=class{destroyRef;static fToken=Symbol("QueueConnectionRedrawRequest");constructor(i){this.destroyRef=i}},jh=(()=>{class n{isWaitingForViewportAnimation=!1;pendingRedraw=!1;static \u0275fac=function(t){return new(t||n)};static \u0275prov=f({token:n,factory:n.\u0275fac})}return n})(),Jv=(()=>{let n=class Ys{_state=c(jh);_store=c(x);_mediator=c(D);handle(e){if(this._state.pendingRedraw=!0,this._state.isWaitingForViewportAnimation)return;this._state.isWaitingForViewportAnimation=!0;let t=this._store.viewportAnimationChanges$.listen(()=>{if(this._store.isViewportAnimating)return;let o=this._state.pendingRedraw;t(),this._state.isWaitingForViewportAnimation=!1,this._state.pendingRedraw=!1,o&&this._mediator.execute(new jn)});e.destroyRef.onDestroy(t)}static \u0275fac=function(t){return new(t||Ys)};static \u0275prov=f({token:Ys,factory:Ys.\u0275fac})};return n=p([_(Sd)],n),n})(),eC=[jv,Vv,...Xv,qv,$d,Yv,Kv,Zv,Qv,jh,Jv],Dd=class{static fToken=Symbol("ClearSelectionRequest")},tC=(()=>{let n=class Ks{_dragContext=c(V);handle(e){this._dragContext.selectedItems.forEach(t=>t.unmarkAsSelected()),this._dragContext.selectedItems=[],this._dragContext.isSelectedChanged=!0}static \u0275fac=function(t){return new(t||Ks)};static \u0275prov=f({token:Ks,factory:Ks.\u0275fac})};return n=p([_(Dd)],n),n})(),Td=class{static fToken=Symbol("CalculateSelectableItemsRequest")},nC=(()=>{let n=class Zs{_mediator=c(D);_store=c(x);_dragContext=c(V);get _nodes(){return this._store.nodes.getAll()}get _connections(){return this._store.connections.getAll()}handle(){return[...this._nodeRects(),...this._connectionRects()].filter(e=>!this._dragContext.selectedItems.includes(e.element))}_nodeRects(){return this._nodes.filter(e=>!e.fSelectionDisabled()).map(e=>({element:e,fRect:this._mediator.execute(new de(e.hostElement))}))}_connectionRects(){return this._connections.filter(e=>!e.fSelectionDisabled()).map(e=>({element:e,fRect:this._mediator.execute(new de(e.boundingElement))}))}static \u0275fac=function(t){return new(t||Zs)};static \u0275prov=f({token:Zs,factory:Zs.\u0275fac})};return n=p([_(Td)],n),n})(),gi=class{static fToken=Symbol("GetCurrentSelectionRequest")},iC=(()=>{let n=class Qs{_dragContext=c(V);handle(){return{fNodeIds:this._getSelectedNodes(),fGroupIds:this._getSelectedGroups(),fConnectionIds:this._getSelectedConnections()}}_getSelectedNodes(){return this._dragContext.selectedItems.filter(e=>e.hostElement.classList.contains("f-node")).map(e=>e.hostElement.dataset.fNodeId)}_getSelectedGroups(){return this._dragContext.selectedItems.filter(e=>e.hostElement.classList.contains("f-group")).map(e=>e.hostElement.dataset.fGroupId)}_getSelectedConnections(){return this._dragContext.selectedItems.filter(e=>!e.hostElement.classList.contains("f-node")&&!e.hostElement.classList.contains("f-group")).map(e=>e.hostElement.id)}static \u0275fac=function(t){return new(t||Qs)};static \u0275prov=f({token:Qs,factory:Qs.\u0275fac})};return n=p([_(gi)],n),n})(),Ed=class{nodes;connections;isSelectedChanged;static fToken=Symbol("SelectRequest");constructor(i,e,t=!0){this.nodes=i,this.connections=e,this.isSelectedChanged=t}},oC=(()=>{let n=class Js{_dragContext=c(V);_store=c(x);handle(e){this._dragContext.selectedItems.forEach(t=>{t.unmarkAsSelected()}),this._dragContext.selectedItems=[],e.nodes.forEach(t=>{let o=this._store.nodes.get(t);o&&(o.markAsSelected(),this._dragContext.selectedItems.push(o))}),e.connections.forEach(t=>{let o=this._store.connections.get(t);o&&(o.markAsSelected(),this._dragContext.selectedItems.push(o))}),this._dragContext.isSelectedChanged=e.isSelectedChanged}static \u0275fac=function(t){return new(t||Js)};static \u0275prov=f({token:Js,factory:Js.\u0275fac})};return n=p([_(Ed)],n),n})(),Pd=class{static fToken=Symbol("SelectAllRequest")},rC=(()=>{let n=class ea{_dragSession=c(V);_store=c(x);handle(e){this._dragSession.selectedItems.forEach(t=>{t.unmarkAsSelected()}),this._dragSession.selectedItems=[],this._store.nodes.getAll().forEach(t=>{t.markAsSelected(),this._dragSession.selectedItems.push(t)}),this._store.connections.getAll().forEach(t=>{t.markAsSelected(),this._dragSession.selectedItems.push(t)}),this._dragSession.isSelectedChanged=!0}static \u0275fac=function(t){return new(t||ea)};static \u0275prov=f({token:ea,factory:ea.\u0275fac})};return n=p([_(Pd)],n),n})(),yn=class{nodeOrGroup;static fToken=Symbol("SelectAndUpdateNodeLayerRequest");constructor(i){this.nodeOrGroup=i}},Md=class{fItemsContainer;allElements;elementsThatShouldBeInFront;targetIndex;static fToken=Symbol("MoveFrontElementsBeforeTargetElementRequest");constructor(i,e,t,o){this.fItemsContainer=i,this.allElements=e,this.elementsThatShouldBeInFront=t,this.targetIndex=o}},sC=(()=>{let n=class ta{handle(e){let t=[];for(let o=e.targetIndex+1;o<e.allElements.length;o++){let r=e.allElements[o];e.elementsThatShouldBeInFront.includes(r)||t.push(r)}t.forEach(o=>{e.fItemsContainer.removeChild(o),e.fItemsContainer.insertBefore(o,e.allElements[e.targetIndex])})}static \u0275fac=function(t){return new(t||ta)};static \u0275prov=f({token:ta,factory:ta.\u0275fac})};return n=p([_(Md)],n),n})(),Wt=class{item;itemContainer;static fToken=Symbol("UpdateItemAndChildrenLayersRequest");constructor(i,e){this.item=i,this.itemContainer=e}},vn=class{nodeOrGroupId;static fToken=Symbol("GetDeepChildrenNodesAndGroupsRequest");constructor(i){this.nodeOrGroupId=i}},aC=(()=>{let n=class na{_store=c(x);handle({nodeOrGroupId:e}){return this._getChildrenNodes(e)}_getChildrenNodes(e,t=new Set){if(t.has(e))throw new Error("Circular reference detected in the node hierarchy. Node id: "+e);t.add(e);let o=this._store.nodes.getAll().filter(r=>r.fParentId()===e);return o.reduce((r,s)=>r.concat(this._getChildrenNodes(s.fId(),t)),o)}static \u0275fac=function(t){return new(t||na)};static \u0275prov=f({token:na,factory:na.\u0275fac})};return n=p([_(vn)],n),n})(),cC=(()=>{let n=class ia{_store=c(x);_mediator=c(D);get _canvas(){return this._store.fCanvas}get _groupsContainer(){return this._canvas.fGroupsContainer().nativeElement}get _nodesContainer(){return this._canvas.fNodesContainer().nativeElement}get _connectionsContainer(){return this._canvas.fConnectionsContainer().nativeElement}handle(e){switch(e.itemContainer){case this._groupsContainer:this._handleGroup(e);break;case this._nodesContainer:this._handleNode(e);break;case this._connectionsContainer:this._handleConnection(e);break;default:throw new Error("Unknown container")}}_handleGroup(e){let t=this._getChildrenNodesAndGroups(e.item.fId()),o=this._getChildrenGroups(t);this._updateLayers(this._groupsContainer,e.item.hostElement,o);let r=this._getChildrenNodes(t);r.length&&this._updateLayers(this._nodesContainer,r[0],r)}_handleNode(e){let t=this._getChildrenNodesAndGroups(e.item.fId()),o=this._getChildrenNodes(t);this._updateLayers(e.itemContainer,e.item.hostElement,o)}_handleConnection(e){this._updateLayers(e.itemContainer,e.item.hostElement,[])}_updateLayers(e,t,o){let r=Array.from(e.children),s=r.findIndex(a=>a===t);this._isAnythingNeedToBeMoved(r,s,o)&&this._mediator.execute(new Md(e,r,o,s))}_isAnythingNeedToBeMoved(e,t,o){for(let r=t+1;r<e.length;r++)if(!o.includes(e[r]))return!0;return!1}_getChildrenGroups(e){let t=Array.from(this._groupsContainer.children);return e.filter(o=>this._groupsContainer.contains(o)).sort((o,r)=>t.indexOf(o)-t.indexOf(r))}_getChildrenNodes(e){let t=Array.from(this._nodesContainer.children);return e.filter(o=>this._nodesContainer.contains(o)).sort((o,r)=>t.indexOf(o)-t.indexOf(r))}_getChildrenNodesAndGroups(e){return this._mediator.execute(new vn(e)).map(t=>t.hostElement)}static \u0275fac=function(t){return new(t||ia)};static \u0275prov=f({token:ia,factory:ia.\u0275fac})};return n=p([_(Wt)],n),n})(),dC=(()=>{let n=class oa{_dragSession=c(V);_mediator=c(D);handle({nodeOrGroup:e}){this._selectNodeIfNotSelected(e),this._mediator.execute(new Wt(e,e.hostElement.parentElement))}_selectNodeIfNotSelected(e){e.fSelectionDisabled()||this._dragSession.selectedItems.includes(e)||(this._dragSession.selectedItems.push(e),e.markAsSelected(),this._dragSession.isSelectedChanged=!0)}static \u0275fac=function(t){return new(t||oa)};static \u0275prov=f({token:oa,factory:oa.\u0275fac})};return n=p([_(yn)],n),n})(),lC=[tC,nC,iC,oC,rC,dC],Rd=class{static fToken=Symbol("ResetZoomRequest")},uC=(()=>{let n=class ra{_store=c(x);get _canvas(){return this._store.fCanvas}handle(e){this._canvas.resetScale(),this._canvas.redraw(),this._canvas.emitCanvasChangeEvent()}static \u0275fac=function(t){return new(t||ra)};static \u0275prov=f({token:ra,factory:ra.\u0275fac})};return n=p([_(Rd)],n),n})(),Nd=class{position;step;direction;animate;static fToken=Symbol("SetZoomRequest");constructor(i,e,t,o=!1){this.position=i,this.step=e,this.direction=t,this.animate=o}},fC=new Set(["drag-node","drag-external-item","resize-node","rotate-node","create-connection","reassign-connection","drag-connection-waypoint","assign-to-container"]),hC=new Set(["drag-canvas","selection-area"]),gC=(()=>{let n=class sa{_mediator=c(D);_store=c(x);_dragContext=c(V,{optional:!0});get _flowHost(){return this._store.flowHost}get _canvas(){return this._store.fCanvas}get _zoomComponent(){return this._store.instances.get(ae.ZOOM)}get _isDragStarted(){return this._mediator.execute(new Dt)}handle(e){if(!this._zoomComponent)return;let t=this._canvas.transform.scale,o=this._clamp(t+e.step*e.direction);if(o===t)return;let r=this._castPositionToFlow(e.position);if(this._isDragStarted){let s=this._getDragZoomMode();if(s==="blocked")return;s==="rebase"&&this._rebaseDragContext(r,o)}this._canvas.setScale(o,r),e.animate?this._canvas.redrawWithAnimation():this._canvas.redraw(),this._canvas.emitCanvasChangeEvent()}_clamp(e){return Math.max(this._zoomComponent?.minimum||1,Math.min(e,this._zoomComponent?.maximum||1))}_castPositionToFlow(e){return j.fromPoint(e).elementTransform(this._flowHost)}_getDragZoomMode(){if(this._dragContext?.isEmpty())return"blocked";let e=!1;for(let t of this._dragContext?.draggableItems??[]){let o=t.getEvent().kind;if(fC.has(o)){e=!0;continue}if(!hC.has(o))return"blocked"}return e?"rebase":"direct"}_rebaseDragContext(e,t){if(!this._dragContext)return;let o=this._dragContext.onPointerDownScale;if(!o||o===t){this._dragContext.onPointerDownScale=t;return}let r=1/t-1/o;this._dragContext.onPointerDownPosition=j.fromPoint(this._dragContext.onPointerDownPosition).add(j.fromPoint(e).mult(r)),this._dragContext.onPointerDownScale=t}static \u0275fac=function(t){return new(t||sa)};static \u0275prov=f({token:sa,factory:sa.\u0275fac})};return n=p([_(Nd)],n),n})(),pC=[uC,gC],kd=class{static fToken=Symbol("MinimapDrawNodesRequest")},_C=(()=>{let n=class aa{_browser=c(pe);_store=c(x);handle(e){let t=this._store.fFlow,o=this._store.fCanvas;return!t||!o?[]:this._store.nodes.getAll().map(s=>this._renderNode(s,t,o))}_renderNode(e,t,o){let r=rn("rect",this._browser);ml(this._nodeRect(e,t,o),r);let s=e instanceof Wd;return r.classList.add("f-component",s?"f-minimap-node":"f-minimap-group"),r.classList.add(...this._minimapClasses(e)),e.isSelected()&&r.classList.add("f-selected"),r}_nodeRect(e,t,o){let r=z.elementTransform(z.fromElement(e.hostElement),t.hostElement);return z.div(r,o.transform.scale)}_minimapClasses(e){let t=e.fMinimapClass();return Array.isArray(t)?t:[t]}static \u0275fac=function(t){return new(t||aa)};static \u0275prov=f({token:aa,factory:aa.\u0275fac})};return n=p([_(kd)],n),n})(),Od=class{svg;minSize;static fToken=Symbol("MinimapCalculateViewportRequest");constructor(i,e){this.svg=i,this.minSize=e}},mC=(()=>{let n=class ca{_mediator=c(D);_store=c(x);handle({svg:e,minSize:t}){let o=this._store.fFlow,r=this._store.fCanvas;if(!o||!r)return{scale:1,viewBox:z.initialize(0,0,0,0)};let s=this._contentRectInMinimapSpace(o,r,t),a=this._minimapRectInFlowSpace(e,o),d=this._viewportScale(s,a),l=this._viewportViewBox(s,a,d);return{scale:d,viewBox:l}}_contentRectInMinimapSpace(e,t,o){let r=this._nodesBoundingBox(),s=z.elementTransform(r,e.hostElement),a=z.div(s,t.transform.scale);return If(a,o)}_nodesBoundingBox(){return this._mediator.execute(new gn)??z.initialize(0,0,0,0)}_minimapRectInFlowSpace(e,t){return z.elementTransform(z.fromElement(e),t.hostElement)}_viewportScale(e,t){let o=t.width||1,r=t.height||1;return Math.max(e.width/o,e.height/r)}_viewportViewBox(e,t,o){let r=this._viewportSize(t,o),s=e.x-(r.width-e.width)/2,a=e.y-(r.height-e.height)/2;return z.initialize(s,a,r.width,r.height)}_viewportSize(e,t){return Xe.initialize(e.width*t||0,e.height*t||0)}static \u0275fac=function(t){return new(t||ca)};static \u0275prov=f({token:ca,factory:ca.\u0275fac})};return n=p([_(Od)],n),n})(),Fd=class{static fToken=Symbol("MinimapCalculateViewRectRequest")},yC=(()=>{let n=class da{_store=c(x);handle(e){let t=this._store.fFlow,o=this._store.fCanvas;if(!t||!o)return z.initialize();let r=z.div(z.fromElement(t.hostElement),o.transform.scale);return r.x=0,r.y=0,r}static \u0275fac=function(t){return new(t||da)};static \u0275prov=f({token:da,factory:da.\u0275fac})};return n=p([_(Fd)],n),n})(),Ad=class{element;scale;viewBox;constructor(i,e=1,t=z.initialize(0,0,0,0)){this.element=i,this.scale=e,this.viewBox=t}},vC=[_C,mC,yC],Ld=class{position;static fToken=Symbol("GetNormalizedPointRequest");constructor(i){this.position=i}},CC=(()=>{let n=class la{_store=c(x);handle({position:e}){return xn(e,this._store.flowHost,this._store.transform)}static \u0275fac=function(t){return new(t||la)};static \u0275prov=f({token:la,factory:la.\u0275fac})};return n=p([_(Ld)],n),n})(),zd=class{static fToken=Symbol("SortNodeLayersRequest")},xC=(()=>{let n=class ua{_store=c(x);_mediator=c(D);_browser=c(pe);get _canvas(){return this._store.fCanvas}get _groupsContainer(){return this._canvas.fGroupsContainer().nativeElement}get _nodesContainer(){return this._canvas.fNodesContainer().nativeElement}get _fNodeElements(){return Array.from(this._nodesContainer.children)}handle(e){this._getGroups().forEach(t=>{this._moveChildrenNodes(this._getSortedChildrenNodes(t))})}_getGroups(){return this._store.nodes.getAll().filter(e=>this._groupsContainer.contains(e.hostElement))}_getSortedChildrenNodes(e){let t=this._fNodeElements;return this._getChildrenNodes(e.fId()).sort((o,r)=>t.indexOf(o)-t.indexOf(r))}_getChildrenNodes(e){return this._mediator.execute(new vn(e)).filter(t=>this._nodesContainer.contains(t.hostElement)).map(t=>t.hostElement)}_moveChildrenNodes(e){let t=this._browser.document.createDocumentFragment();e.forEach(o=>{t.appendChild(o)}),this._nodesContainer.appendChild(t)}static \u0275fac=function(t){return new(t||ua)};static \u0275prov=f({token:ua,factory:ua.\u0275fac})};return n=p([_(zd)],n),n})(),pi=class{itemsContainer;static fToken=Symbol("SortItemsByParentRequest");constructor(i){this.itemsContainer=i}},wC=(()=>{let n=class fa{_store=c(x);_browser=c(pe);handle({itemsContainer:e}){let t=Array.from(e.children);if(t.length<2)return;let o=this._buildPositions(t),r=this._store.nodes.getAll().filter(d=>e.contains(d.hostElement));if(r.length<2||!r.some(d=>!!d.fParentId()))return;let s=this._buildChildrenByParentId(r),a=new Map;for(let d of r){let l=this._getSortedChildrenBeforeParent(e,o,d,s,a);l.length&&this._moveBeforeNextSibling(e,l,d.hostElement.nextElementSibling)}}_buildPositions(e){let t=new Map;for(let o=0;o<e.length;o++)t.set(e[o],o);return t}_getSortedChildrenBeforeParent(e,t,o,r,s){let a=t.get(o.hostElement);if(a===void 0)return[];let d=this._getDeepChildren(o.fId(),r,s);if(!d.length)return[];let l=[];for(let u of d){let g=u.hostElement;if(!e.contains(g))continue;let y=t.get(g);y===void 0||y>=a||l.push(g)}return l.sort((u,g)=>(t.get(u)??0)-(t.get(g)??0)),l}_buildChildrenByParentId(e){let t=new Map;for(let o of e){let r=o.fParentId();if(!r)continue;let s=t.get(r)??[];s.push(o),t.set(r,s)}return t}_getDeepChildren(e,t,o){let r=o.get(e);if(r)return r;let s=[],a=[...t.get(e)??[]],d=new Set([e]);for(;a.length;){let l=a.pop();if(!l)continue;let u=l.fId();if(d.has(u))continue;d.add(u),s.push(l);let g=t.get(u);g?.length&&a.push(...g)}return o.set(e,s),s}_moveBeforeNextSibling(e,t,o){let r=this._browser.document.createDocumentFragment();for(let s of t)r.appendChild(s);e.insertBefore(r,o)}static \u0275fac=function(t){return new(t||fa)};static \u0275prov=f({token:fa,factory:fa.\u0275fac})};return n=p([_(pi)],n),n})(),Bd=class{static fToken=Symbol("SortItemLayersRequest")},bC=(()=>{let n=class ha{_store=c(x);_mediator=c(D);get _canvas(){return this._store.fCanvas}handle(e){if(!this._canvas)return;let t=this._store.nodes.getAll();t.length<2||!t.some(o=>!!o.fParentId())||(this._mediator.execute(new pi(this._canvas.fGroupsContainer().nativeElement)),this._mediator.execute(new zd),this._mediator.execute(new pi(this._canvas.fNodesContainer().nativeElement)))}static \u0275fac=function(t){return new(t||ha)};static \u0275prov=f({token:ha,factory:ha.\u0275fac})};return n=p([_(Bd)],n),n})();function rn(n,i){return i.document.createElementNS("http://www.w3.org/2000/svg",n)}function Ve(n,i){return i(n)}function qe(n){return!0}function IC(){return/android|iPad|iPhone|iPod/i.test(navigator.userAgent||navigator.vendor||window.opera)}var SC=[...Wp,...ev,...Op,...Bv,...Cv,...eC,...kv,...lC,...pC,...vC,...rm,aC,sm,lm,CC,bC,wC,xC,cC,sC],DC=0,Vh=(()=>{class n{_destroyRef=c(Ze);_elementReference=c(he);_fBrowser=c(pe);_stateChanges=new je;get hostElement(){return this._elementReference.nativeElement}id=F(`f-pattern-${DC++}`);vColor=F("rgba(0,0,0,0.1)");hColor=F("rgba(0,0,0,0.1)");vSize=F(20,{transform:Ne});hSize=F(20,{transform:Ne});_transform=_t.default();_position=M.initialize();_size=Xe.initialize(this.hSize(),this.vSize());_pattern;_vLine;_hLine;constructor(){this._createPattern()}_createPattern(){this._pattern=rn("pattern",this._fBrowser),this._pattern.setAttribute("patternUnits","userSpaceOnUse"),this.hostElement.appendChild(this._pattern),this._vLine=rn("line",this._fBrowser),this._pattern.appendChild(this._vLine),this._hLine=rn("line",this._fBrowser),this._pattern.appendChild(this._hLine)}ngOnInit(){this._listenStateChanges()}_listenStateChanges(){new it(this._stateChanges).pipe(Gd()).listen(this._destroyRef,()=>this._redraw())}ngOnChanges(e){(e.vSize||e.hSize||e.vColor||e.hColor)&&this._refresh()}_redraw(){this._calculatePattern(),this._redrawPattern(),this._redrawLine(this._vLine,this.vColor(),this._size.width,0,this._size.width,this._size.height),this._redrawLine(this._hLine,this.hColor(),0,this._size.height,this._size.width,this._size.height)}_calculatePattern(){this._position.x=this._transform.position.x+this._transform.scaledPosition.x,this._position.y=this._transform.position.y+this._transform.scaledPosition.y,this._size=Xe.initialize(this.hSize()*this._transform.scale,this.vSize()*this._transform.scale)}_redrawPattern(){this._pattern.setAttribute("x",`${this._position.x}`),this._pattern.setAttribute("y",`${this._position.y}`),this._pattern.setAttribute("width",`${this._size.width}`),this._pattern.setAttribute("height",`${this._size.height}`)}_redrawLine(e,t,o,r,s,a){e.setAttribute("stroke",`${t}`),e.setAttribute("x1",`${o}`),e.setAttribute("x2",`${s}`),e.setAttribute("y1",`${r}`),e.setAttribute("y2",`${a}`)}setTransform(e){this._transform=e,this._refresh()}_refresh(){this._stateChanges.notify()}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=se({type:n,selectors:[["f-rect-pattern"]],hostVars:1,hostBindings:function(t,o){t&2&&te("id",o.id)},inputs:{id:[1,"id"],vColor:[1,"vColor"],hColor:[1,"hColor"],vSize:[1,"vSize"],hSize:[1,"hSize"]},features:[be([{provide:Pl,useExisting:n}]),Kt],decls:0,vars:0,template:function(t,o){},encapsulation:2,changeDetection:0})}return n})();var TC=new ee("F_BACKGROUND"),EC=(()=>{class n{hostElement=c(he).nativeElement;static \u0275fac=function(t){return new(t||n)};static \u0275dir=_e({type:n,standalone:!1})}return n})(),Uh=(()=>{class n extends EC{_mediator=c(D);fBackgroundPattern=Ni(Pl);ngOnInit(){this._mediator.execute(new At(ae.BACKGROUND,this))}ngAfterContentInit(){this._mediator.execute(new ga(this.fBackgroundPattern()))}setTransform(e){this.fBackgroundPattern()?.setTransform(e)}ngOnDestroy(){this._mediator.execute(new Lt(ae.BACKGROUND))}static \u0275fac=(()=>{let e;return function(o){return(e||(e=X(n)))(o||n)}})();static \u0275cmp=se({type:n,selectors:[["f-background"]],contentQueries:function(t,o,r){t&1&&gl(r,o.fBackgroundPattern,Pl,5),t&2&&We()},hostAttrs:[1,"f-component","f-background"],features:[be([{provide:TC,useExisting:n}]),ce],ngContentSelectors:ap,decls:2,vars:0,template:function(t,o){t&1&&(En(),Ge(),Je(0,"svg"),De(1),et())},styles:["[_nghost-%COMP%]{position:absolute;width:100%;height:100%;left:0;top:0;transform-origin:0 0;pointer-events:none}[_nghost-%COMP%] svg[_ngcontent-%COMP%]{width:100%;height:100%}"],changeDetection:0})}return n})();var $u=class{position;scale;constructor(i,e){this.position=i,this.scale=e}},PC=new ee("F_CANVAS"),MC=(()=>{class n{transform=_t.default();_fCanvasChange=new je;destroyRef=c(Ze);getPosition(){return this.transform.position}setPosition(e){this.transform.position=e}emitCanvasChangeEvent(){this._fCanvasChange.notify()}subscribeOnCanvasChange(){new it(this._fCanvasChange).pipe(pa(this.debounce())).listen(this.destroyRef,()=>{this.fCanvasChange.emit(new $u(M.sum(this.transform.position,this.transform.scaledPosition),this.transform.scale))})}static \u0275fac=function(t){return new(t||n)};static \u0275dir=_e({type:n,standalone:!1})}return n})(),_i=(()=>{class n extends MC{_mediator=c(D);_componentsStore=c(x);_elementReference=c(he);_injector=c(Ae);_flowId;fCanvasChange=lt();position=F(M.initialize(),{transform:M.castToPoint});scale=F(1,{transform:Ne});debounceTime=F(0,{transform:Ne});debounce=G(()=>this.debounceTime()<0?0:this.debounceTime());get hostElement(){return this._elementReference.nativeElement}fGroupsContainer=ve.required("fGroupsContainer");fNodesContainer=ve.required("fNodesContainer");fConnectionsContainer=ve.required("fConnectionsContainer");get flowId(){return this._flowId||""}ngOnInit(){this._flowId=this._mediator.execute(new yd).fId(),this._mediator.execute(new ma(this)),this._positionChange(),this._scaleChange(),super.subscribeOnCanvasChange()}_positionChange(){Ie(()=>{this._mediator.execute(new Ca(this.transform,this.position()))},{injector:this._injector})}_scaleChange(){Ie(()=>{this._mediator.execute(new xa(this.transform,this.scale()))},{injector:this._injector})}redraw(){this._mediator.execute(new On(this.transform)),this.hostElement.style.removeProperty("transition"),this.hostElement.style.transform=_t.toString(this.transform),this._mediator.execute(new xt)}redrawWithAnimation(){this._mediator.execute(new On(this.transform)),this.hostElement.style.transition=`transform ${IC()?80:150}ms ease-in-out`,this.hostElement.style.transform=_t.toString(this.transform),oh(this.hostElement,()=>this.redraw())}centerGroupOrNode(e,t=!0){this._afterRedraw(()=>{this._mediator.execute(new ya(e,t))})}fitToScreen(e=M.initialize(),t=!0){this._afterRedraw(()=>{this._mediator.execute(new va(e,t))})}resetScaleAndCenter(e=!0){this._afterRedraw(()=>{this._mediator.execute(new Ia(e))})}getScale(){return this.transform.scale||1}setScale(e,t=M.initialize()){this._mediator.execute(new Sa(e,t))}resetScale(){this._mediator.execute(new ba)}ngOnDestroy(){this._mediator.execute(new wa)}_afterRedraw(e){this._mediator.execute(new hi(this._componentsStore.connectionsRevision,this._componentsStore.nodesRevision,()=>ff(e,{injector:this._injector}),this.destroyRef))}static \u0275fac=(()=>{let e;return function(o){return(e||(e=X(n)))(o||n)}})();static \u0275cmp=se({type:n,selectors:[["f-canvas"]],viewQuery:function(t,o){t&1&&ct(o.fGroupsContainer,cp,5)(o.fNodesContainer,dp,5)(o.fConnectionsContainer,lp,5),t&2&&We(3)},hostAttrs:[1,"f-component","f-canvas"],inputs:{position:[1,"position"],scale:[1,"scale"],debounceTime:[1,"debounceTime"]},outputs:{fCanvasChange:"fCanvasChange"},features:[be([{provide:PC,useExisting:n}]),ce],ngContentSelectors:fp,decls:12,vars:0,consts:[["fGroupsContainer",""],["fConnectionsContainer",""],["fNodesContainer",""],[1,"f-connections-container"]],template:function(t,o){t&1&&(En(up),Pi(0),Je(1,"div",null,0),De(3),et(),Je(4,"div",3,1),De(6,1),De(7,2),De(8,3),et(),Je(9,"div",null,2),De(11,4),et(),Mi())},styles:["[_nghost-%COMP%]{position:absolute;overflow:visible;width:100%;height:100%;left:0;top:0;transform-origin:0 0;pointer-events:none}.f-canvas-dragging[_nghost-%COMP%], .canvas-dragging[_nghost-%COMP%]{transform:translateZ(0)}.f-connections-container[_ngcontent-%COMP%]{position:absolute;z-index:2}"],changeDetection:0})}return n})();var RC=0,Wh=(()=>{class n extends H_{fId=F(`f-connection-${RC++}`,{alias:"fConnectionId"});fOutputId=F("",{transform:e=>un(e)||""});fInputId=F("",{transform:e=>un(e)||""});fRadius=8;fOffset=12;fBehavior=vt.FIXED;fType=yt.STRAIGHT;fSelectionDisabled=F(!1,{transform:re});fReassignableStart=F(!1,{transform:re});fDraggingDisabled=F(!1,{alias:"fReassignDisabled",transform:re});fInputSide=F(ke.DEFAULT,{transform:e=>tn(e,"fInputSide",ke)});fOutputSide=F(ke.DEFAULT,{transform:e=>tn(e,"fOutputSide",ke)});get boundingElement(){return this.fPath().hostElement}_mediator=c(D);ngOnInit(){this._mediator.execute(new Da(this))}ngOnChanges(){this._mediator.execute(new Ft)}ngOnDestroy(){this._mediator.execute(new Ya(this))}static \u0275fac=(()=>{let e;return function(o){return(e||(e=X(n)))(o||n)}})();static \u0275cmp=se({type:n,selectors:[["f-connection"]],hostAttrs:[1,"f-component","f-connection"],hostVars:5,hostBindings:function(t,o){t&2&&(te("id",o.fId()),$e("f-connection-selection-disabled",o.fSelectionDisabled())("f-connection-reassign-disabled",o.fDraggingDisabled()))},inputs:{fId:[1,"fConnectionId","fId"],fOutputId:[1,"fOutputId"],fInputId:[1,"fInputId"],fRadius:[2,"fRadius","fRadius",Ne],fOffset:[2,"fOffset","fOffset",Ne],fBehavior:[2,"fBehavior","fBehavior",e=>tn(e,"fBehavior",vt)],fType:"fType",fSelectionDisabled:[1,"fSelectionDisabled"],fReassignableStart:[1,"fReassignableStart"],fDraggingDisabled:[1,"fReassignDisabled","fDraggingDisabled"],fInputSide:[1,"fInputSide"],fOutputSide:[1,"fOutputSide"]},exportAs:["fComponent"],standalone:!1,features:[be([{provide:Hd,useExisting:n}]),ce,Kt],ngContentSelectors:gp,decls:15,vars:6,consts:[["defs",""],["xmlns","http://www.w3.org/2000/svg"],[1,"f-connection-group"],["fConnectionGradientRenderer","",3,"fConnectionGradientRendererFor"],["fConnectionSelection",""],["f-connection-path","",3,"useGradient"],["f-connection-drag-handle-start","","r","8"],["f-connection-drag-handle-end","","r","8"]],template:function(t,o){if(t&1&&(En(hp),Ge(),m(0,"svg",1),U(1,"defs",null,0),De(3),m(4,"g",2),k(5,pp,1,1,":svg:linearGradient",3),U(6,"path",4),m(7,"g"),U(8,"path",5),k(9,_p,1,0,":svg:circle",6),U(10,"circle",7),v()()(),De(11,1),De(12,2),De(13,3),k(14,mp,1,0)),t&2){let r;h(5),O((r=o.fGradient())?5:-1,r),h(),te("d",o.path),h(2),A("useGradient",!!o.fGradient()),te("d",o.path),h(),O(o.fReassignableStart()?9:-1),h(5),O(o.fContents().length?14:-1)}},dependencies:[ql,L_,z_,R_,A_],styles:["[_nghost-%COMP%]{pointer-events:none}[_nghost-%COMP%] svg[_ngcontent-%COMP%]{display:block;vertical-align:middle;overflow:visible!important;position:absolute}[_nghost-%COMP%] svg[_ngcontent-%COMP%] .f-connection-group[_ngcontent-%COMP%]{pointer-events:all}[_nghost-%COMP%] .f-connection-content[_ngcontent-%COMP%]{pointer-events:all}"],changeDetection:0})}return n})();var NC=new ee("F_MAGNETIC_LINES"),kC=(()=>{class n{hostElement=c(he).nativeElement;static \u0275fac=function(t){return new(t||n)};static \u0275dir=_e({type:n,standalone:!1})}return n})();var $h=(()=>{class n extends kC{threshold=F(10,{transform:Ne,alias:"fAlignThreshold"});_mediator=c(D);ngOnInit(){this._mediator.execute(new At(ae.MAGNETIC_LINES,this))}ngOnDestroy(){this._mediator.execute(new Lt(ae.MAGNETIC_LINES))}static \u0275fac=(()=>{let e;return function(o){return(e||(e=X(n)))(o||n)}})();static \u0275cmp=se({type:n,selectors:[["f-line-alignment"]],hostAttrs:[1,"f-line-alignment","f-component"],inputs:{threshold:[1,"fAlignThreshold","threshold"]},exportAs:["fComponent"],standalone:!1,features:[be([{provide:NC,useExisting:n}]),ce],decls:0,vars:0,template:function(t,o){},styles:[yp]})}return n})();var Dl=(()=>{class n{fMinSize=F(1e3);_mediator=c(D);hostElement=c(he).nativeElement;model=new Ad(this.hostElement);redraw(){let{scale:e,viewBox:t}=this._mediator.execute(new Od(this.hostElement,this.fMinSize()));this.model=new Ad(this.hostElement,e,t),Sf(t,this.hostElement)}static \u0275fac=function(t){return new(t||n)};static \u0275dir=_e({type:n,selectors:[["svg","fMinimapFlow",""]],inputs:{fMinSize:[1,"fMinSize"]}})}return n})(),Tl=(()=>{class n{_mediator=c(D);_elementRef=c(he);hostElement=this._elementRef.nativeElement;redraw(){this.clear();let e=this._elementRef.nativeElement.ownerDocument.createDocumentFragment();this._mediator.execute(new kd).forEach(t=>{e.appendChild(t)}),this.hostElement.appendChild(e)}clear(){this.hostElement.replaceChildren()}static \u0275fac=function(t){return new(t||n)};static \u0275dir=_e({type:n,selectors:[["g","fMinimapCanvas",""]]})}return n})(),El=(()=>{class n{_mediator=c(D);hostElement=c(he).nativeElement;redraw(){ml(this._mediator.execute(new Fd),this.hostElement)}static \u0275fac=function(t){return new(t||n)};static \u0275dir=_e({type:n,selectors:[["rect","fMinimapView",""]],hostAttrs:[1,"f-component","f-minimap-view"]})}return n})(),OC=new ee("F_MINIMAP_BASE"),FC=(()=>{class n{hostElement=c(he).nativeElement;static \u0275fac=function(t){return new(t||n)};static \u0275dir=_e({type:n,standalone:!1})}return n})(),Xh=(()=>{class n extends FC{_destroyRef=c(Ze);_mediator=c(D);_browser=c(pe);_store=c(x);_canvas=ve.required(Tl);_flow=ve.required(Dl);_minimapView=ve.required(El);fMinSize=F(1e3);fNodeRenderLimit=F(1500,{transform:Ne});get state(){return this._flow().model}ngOnInit(){this._mediator.execute(new At(ae.MINIMAP,this))}ngAfterViewInit(){this._listenTransformChanges()}_listenTransformChanges(){this._mediator.execute(new _a).pipe(Gd(),wp()).listen(this._destroyRef,()=>{this._redraw()})}_redraw(){if(this._browser.isBrowser()){if(this._isOverNodeRenderLimit()){this._canvas().clear();return}this._flow().redraw(),this._minimapView().redraw(),this._canvas().redraw()}}_isOverNodeRenderLimit(){let e=this.fNodeRenderLimit();return e>0&&this._store.nodes.size()>e}ngOnDestroy(){this._mediator.execute(new Lt(ae.MINIMAP))}static \u0275fac=(()=>{let e;return function(o){return(e||(e=X(n)))(o||n)}})();static \u0275cmp=se({type:n,selectors:[["f-minimap"]],viewQuery:function(t,o){t&1&&ct(o._canvas,Tl,5)(o._flow,Dl,5)(o._minimapView,El,5),t&2&&We(3)},hostAttrs:[1,"f-component","f-minimap"],inputs:{fMinSize:[1,"fMinSize"],fNodeRenderLimit:[1,"fNodeRenderLimit"]},exportAs:["fComponent"],features:[be([{provide:OC,useExisting:n}]),ce],decls:3,vars:1,consts:[["fMinimapFlow","","width","100%","height","100%","fLockedContext","",3,"fMinSize"],["fMinimapCanvas",""],["fMinimapView","","x","0","y","0","width","100%","height","100%","stroke","none"]],template:function(t,o){t&1&&(Ge(),m(0,"svg",0),U(1,"g",1)(2,"rect",2),v()),t&2&&A("fMinSize",o.fMinSize())},dependencies:[Dl,Tl,El],styles:["[_nghost-%COMP%]{display:block;position:absolute}[_nghost-%COMP%] svg[_ngcontent-%COMP%]{overflow:hidden}"],changeDetection:0})}return n})();var AC=0,LC=120,qh=(()=>{class n extends Wu{_destroyRef=c(Ze);_mediator=c(D);_browser=c(pe);_componentsStore=c(x);_cache=c(ot);_injector=c(Ae);fId=F(`f-flow-${AC++}`,{alias:"fFlowId"});fCache=F(!1,{transform:re});hostElement=c(he).nativeElement;fNodesRendered=lt();fFullRendered=lt();fLoaded=lt();ngOnInit(){this._mediator.execute(new md(this)),this._listenCacheChanges()}ngAfterContentInit(){this._browser.isBrowser()&&(this._listenNodesChanges(),this._listenConnectionsChanges())}_listenCacheChanges(){Ie(()=>{this._cache.enabled=this.fCache()},{injector:this._injector})}_listenNodesChanges(){new it(this._componentsStore.nodesChanges$,this._componentsStore.progressiveRenderChanges$).pipe(Gd(),pa(LC),xp()).listen(this._destroyRef,()=>{this._mediator.execute(new Dt)||this._componentsStore.hasPendingProgressiveRender||(this._mediator.execute(new Bd),this._mediator.execute(new wd),this._mediator.execute(new hi(this._componentsStore.connectionsRevision+1,this._componentsStore.nodesRevision,()=>this._mediator.execute(new bd),this._destroyRef)),this._mediator.execute(new Ft))})}_listenConnectionsChanges(){this._mediator.execute(new nn).listen(this._destroyRef,()=>{if(!this._mediator.execute(new Dt)){if(this._componentsStore.isViewportAnimating){this._mediator.execute(new Sd(this._destroyRef));return}this._mediator.execute(new jn)}})}redraw(){this._mediator.execute(new Ft)}reset(){this._mediator.execute(new Id)}getNodesBoundingBox(){return this._mediator.execute(new hd)}getSelection(){return this._mediator.execute(new gi)}getPositionInFlow(e){return this._mediator.execute(new Ld(e))}getState(e){return this._mediator.execute(new Cd(e?.measuredSize??!1))}selectAll(){this._mediator.execute(new nn).pipe(Rf()).listen(this._destroyRef,()=>{this._mediator.execute(new Pd)})}select(e,t,o=!0){this._mediator.execute(new nn).pipe(Rf()).listen(this._destroyRef,()=>{this._mediator.execute(new Ed(e,t,o))})}clearSelection(){this._mediator.execute(new Dd)}ngOnDestroy(){this._mediator.execute(new xd(this))}static \u0275fac=(()=>{let e;return function(o){return(e||(e=X(n)))(o||n)}})();static \u0275cmp=se({type:n,selectors:[["f-flow"]],hostAttrs:[1,"f-component","f-flow"],hostVars:1,hostBindings:function(t,o){t&2&&te("id",o.fId())},inputs:{fId:[1,"fFlowId","fId"],fCache:[1,"fCache"]},outputs:{fNodesRendered:"fNodesRendered",fFullRendered:"fFullRendered",fLoaded:"fLoaded"},features:[be([D,...Mp,gh,Cn,...SC,V,...Zy,{provide:Ku,useExisting:n}]),ce],ngContentSelectors:Cp,decls:7,vars:0,template:function(t,o){t&1&&(En(vp),Pi(0),De(1),De(2,1),De(3,2),De(4,3),De(5,4),De(6,5),Mi())},styles:["[_nghost-%COMP%]{display:block;position:relative;width:100%;height:100%;overflow:hidden;pointer-events:all;-webkit-user-select:none;user-select:none;touch-action:none} .f-connection-content{position:absolute;left:0;top:0;inline-size:max-content;pointer-events:all;transform-origin:50% 50%} .f-node, .f-group{position:absolute!important;transform-origin:center;-webkit-user-select:none;user-select:none;pointer-events:all;left:0!important;top:0!important;box-sizing:border-box} .f-group{z-index:1} .f-connection-content{z-index:3} .f-node{z-index:4}.hidden[_ngcontent-%COMP%]{opacity:0}"],changeDetection:0})}return n})();var Yh=(()=>{class n{fVirtualForOf=[];fVirtualForTrackBy;_vc=c(Si);_tpl=c(hf);_zone=c(Tn);_componentsStore=c(x,{optional:!0});_views=[];_rafId=null;_isProgressiveRenderActive=!1;ngOnChanges(e){e.fVirtualForOf&&(this._reset(),this._renderProgressively())}ngOnDestroy(){this._reset()}_reset(){this._rafId!==null&&(cancelAnimationFrame(this._rafId),this._rafId=null),this._finishProgressiveRender(),this._vc.clear(),this._views.length=0}_renderProgressively(){let t=0;this._startProgressiveRender(),this._zone.runOutsideAngular(()=>{let o=()=>{let r=performance.now();for(;t<this.fVirtualForOf.length&&performance.now()-r<10;){let s=this.fVirtualForOf[t],a=this._vc.createEmbeddedView(this._tpl,{$implicit:s,index:t});this._views.push(a),t++}if(t<this.fVirtualForOf.length){this._rafId=requestAnimationFrame(o);return}this._rafId=null,this._finishProgressiveRender()};this._rafId=requestAnimationFrame(o)})}_startProgressiveRender(){this._isProgressiveRenderActive||(this._isProgressiveRenderActive=!0,this._componentsStore?.beginProgressiveRender())}_finishProgressiveRender(){this._isProgressiveRenderActive&&(this._isProgressiveRenderActive=!1,this._componentsStore?.endProgressiveRender())}static \u0275fac=function(t){return new(t||n)};static \u0275dir=_e({type:n,selectors:[["","fVirtualFor","","fVirtualForOf",""]],inputs:{fVirtualForOf:"fVirtualForOf",fVirtualForTrackBy:"fVirtualForTrackBy"},features:[Kt]})}return n})();var ft=(function(n){return n[n.ZOOM_IN=1]="ZOOM_IN",n[n.ZOOM_OUT=-1]="ZOOM_OUT",n})(ft||{}),zC=new ee("F_ZOOM"),Xu=class{},BC=.1,GC=1,HC=.5,jC=60,VC=.5;function UC(n){return Math.abs(n.deltaY)>=Math.abs(n.deltaX)?n.deltaY:n.deltaX}function WC(n,i,e){return $C(n)?qC(i,e):XC(i,e)}function $C(n){return(n.ctrlKey||n.metaKey)&&n.deltaMode===WheelEvent.DOM_DELTA_PIXEL}function XC(n,i){let e=Math.abs(n)/100,t=Kh(e,BC,GC);return i*t}function qC(n,i){if(Math.abs(n)<HC)return 0;let e=Math.abs(n)/jC,t=Kh(e,0,VC);return i*t}function Kh(n,i,e){return Math.max(i,Math.min(e,n))}var mi=(()=>{class n extends Xu{_mediator=c(D);_injector=c(Ae);_store=c(x);_triggersListener=Z.emptyListener();isEnabled=F(!1,{alias:"fZoom",transform:re});fWheelTrigger=qe;fDblClickTrigger=qe;minimum=.1;maximum=4;step=.1;dblClickStep=.5;get _flowHost(){return this._store.flowHost}get _canvas(){return this._store.fCanvas}ngOnInit(){this._mediator.execute(new At(ae.ZOOM,this))}ngAfterViewInit(){this._listenZoomEnabledChanges()}_listenZoomEnabledChanges(){Ie(()=>{this.isEnabled(),Pt(()=>this._listenTriggers())},{injector:this._injector})}_listenTriggers(){this._flowHost&&(this._disposeListeners(),this.isEnabled()&&(this._listen("wheel",this._onWheel,Z.activeListener()),this._listen("dblclick",this._onDoubleClick),this._triggersListener=()=>{this._unlisten("wheel",this._onWheel,Z.activeListener()),this._unlisten("dblclick",this._onDoubleClick)}))}_onWheel=e=>{if(!Ve(e,this.fWheelTrigger)||(e.preventDefault(),e.target?.closest("[fLockedContext]")))return;let o=UC(e);if(o===0)return;let r=this._normalizeWheelStep(e,o);r!==0&&this.setZoom(M.initialize(e.clientX,e.clientY),r,this._calculateDirection(o),!1)};_normalizeWheelStep(e,t){return WC(e,t,this.step)}_calculateDirection(e){return e>0?ft.ZOOM_OUT:ft.ZOOM_IN}_onDoubleClick=e=>{if(!Ve(e,this.fDblClickTrigger))return;e.preventDefault();let t=e.target;u0(t)||t?.closest("[fLockedContext]")||this.setZoom(M.initialize(e.clientX,e.clientY),this.dblClickStep,ft.ZOOM_IN,!0)};_getToCenterPosition(e,t){return M.initialize(e?.x||t.gravityCenter.x,e?.y||t.gravityCenter.y)}zoomIn(e){this._onZoomToCenter(ft.ZOOM_IN,e)}zoomOut(e){this._onZoomToCenter(ft.ZOOM_OUT,e)}_onZoomToCenter(e,t){this.setZoom(this._getToCenterPosition(t,z.fromElement(this._flowHost)),this.step,e,!1)}setZoom(e,t,o,r){this._mediator.execute(new Nd(e,t,o,r))}getZoomValue(){return this._canvas.transform.scale||1}reset(){this._mediator.execute(new Rd)}_disposeListeners(){this._triggersListener(),this._triggersListener=Z.emptyListener()}ngOnDestroy(){this._disposeListeners(),this._mediator.execute(new Lt(ae.ZOOM))}_listen(e,t,o){this._flowHost.addEventListener(e,t,o)}_unlisten(e,t,o){this._flowHost.removeEventListener(e,t,o)}static \u0275fac=(()=>{let e;return function(o){return(e||(e=X(n)))(o||n)}})();static \u0275dir=_e({type:n,selectors:[["f-canvas","fZoom",""]],hostAttrs:[1,"f-zoom","f-component"],inputs:{isEnabled:[1,"fZoom","isEnabled"],fWheelTrigger:"fWheelTrigger",fDblClickTrigger:"fDblClickTrigger",minimum:[2,"fZoomMinimum","minimum",Ne],maximum:[2,"fZoomMaximum","maximum",Ne],step:[2,"fZoomStep","step",Ne],dblClickStep:[2,"fZoomDblClickStep","dblClickStep",Ne]},features:[be([{provide:zC,useExisting:n}]),ce]})}return n})();var Zh=(()=>{class n{static \u0275fac=function(t){return new(t||n)};static \u0275mod=pf({type:n});static \u0275inj=lf({imports:[vf]})}return n})();var Zu={title:"Graph",subtitlePrefix:"Auto-laid-out (Dagre, top-bottom) \xB7 connections show how each node refers to another: ",subtitleSuffix:". Click to highlight neighbors, double-click to inspect.",loading:"Loading collection",errorTitle:"Failed to load",emptyTitle:"No nodes match",emptyDesc:"Adjust or reset the filters above.",legend:{invokes:"invokes",references:"references",mentions:"mentions",supersedes:"supersedes"},legendTooltip:{invokes:"Execution-level call (e.g. /command in body)",references:"Explicit reference (e.g. @handle or [[wikilink]])",mentions:"Plain-text mention of another node by name",supersedes:"Lifecycle replacement (declared in metadata.supersedes)"},a11y:{toolbar:"Graph controls",edgeLegend:"Edge legend"},toolbar:{zoomIn:"Zoom in",zoomOut:"Zoom out",fitToScreen:"Fit to screen",resetLayoutLabel:"Reset layout",resetLayoutTooltip:"Reset layout (re-run auto layout, clear saved positions)"},resetLayoutConfirm:"Reset all node positions to the automatic layout? This cannot be undone."};var Qu={graph:{perf:{cache:!0,virtualization:!1},perfHud:!0}};var Qh={a11y:{toolbarLabel:"Toggle node kinds"}};var QC=(n,i)=>i.kind;function JC(n,i){if(n&1){let e=Et();m(0,"p-togglebutton",2),Se("ngModelChange",function(){let o=ue(e).$implicit,r=S();return fe(r.toggle(o.kind))}),v()}if(n&2){let e=i.$implicit,t=S();A("ngModel",t.isActive(e.kind))("onIcon",e.icon)("offIcon",e.icon)("onLabel",e.count.toString())("offLabel",e.count.toString())("pTooltip",e.label)("styleClass","kind-palette__btn kind-palette__btn--"+e.kind),te("data-testid","kind-palette-"+e.kind)}}var Xd=class n{loader=c(Oi);filters=c(Ai);kindRegistry=c(Fi);texts=Qh;entries=G(()=>{let i=new Map;for(let e of this.loader.nodes())i.set(e.kind,(i.get(e.kind)??0)+1);return this.kindRegistry.kinds().map(e=>({kind:e.name,icon:e.icon?.kind==="pi"?`pi ${e.icon.id}`:"pi pi-tag",label:e.label,count:i.get(e.name)??0}))});isActive(i){return this.filters.isKindActive(i)}toggle(i){this.filters.toggleKind(i)}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=se({type:n,selectors:[["app-kind-palette"]],decls:3,vars:1,consts:[["role","toolbar","data-testid","kind-palette",1,"kind-palette"],[3,"ngModel","onIcon","offIcon","onLabel","offLabel","pTooltip","styleClass"],[3,"ngModelChange","ngModel","onIcon","offIcon","onLabel","offLabel","pTooltip","styleClass"]],template:function(e,t){e&1&&(m(0,"div",0),me(1,JC,1,8,"p-togglebutton",1,QC),v()),e&2&&(te("aria-label",t.texts.a11y.toolbarLabel),h(),ye(t.entries()))},dependencies:[Bi,Li,zi,Hi,Gi,Jt,Qt],styles:["[_nghost-%COMP%]{position:absolute;top:16px;left:16px;z-index:2;pointer-events:none}.kind-palette[_ngcontent-%COMP%]{pointer-events:auto;display:flex;flex-direction:column;gap:2px;padding:4px;background:var(--sm-bg-content);border:1px solid var(--sm-border);border-radius:.65rem;box-shadow:var(--sm-shadow-floating)}.kind-palette__btn[_ngcontent-%COMP%]{--p-togglebutton-padding: 0;--p-togglebutton-content-padding: 0 .55rem;--p-togglebutton-border-radius: 999px;--p-togglebutton-content-border-radius: 999px;--p-togglebutton-gap: .4rem;--p-togglebutton-background: transparent;--p-togglebutton-checked-background: transparent;--p-togglebutton-hover-background: transparent;--p-togglebutton-border-color: transparent;--p-togglebutton-checked-border-color: transparent;--p-togglebutton-content-checked-background: var(--sm-bg-hover);--p-togglebutton-color: var(--p-text-muted-color);--p-togglebutton-hover-color: var(--p-text-color);--p-togglebutton-checked-color: var(--p-text-color);--p-togglebutton-icon-color: var(--p-text-muted-color);--p-togglebutton-icon-hover-color: var(--p-text-color);--p-togglebutton-icon-checked-color: var(--p-text-color);width:56px;height:30px;font-size:.72rem;font-weight:600;font-variant-numeric:tabular-nums}[_nghost-%COMP%] .kind-palette__btn .p-togglebutton-content{width:100%;height:100%;justify-content:flex-start}[_nghost-%COMP%] .kind-palette__btn .p-togglebutton-label{flex:1;text-align:right}[_nghost-%COMP%] .kind-palette__btn .p-togglebutton-icon{font-size:.95rem}.kind-palette__btn--skill[_ngcontent-%COMP%]{--p-togglebutton-icon-checked-color: var(--sm-kind-skill)}.kind-palette__btn--agent[_ngcontent-%COMP%]{--p-togglebutton-icon-checked-color: var(--sm-kind-agent)}.kind-palette__btn--command[_ngcontent-%COMP%]{--p-togglebutton-icon-checked-color: var(--sm-kind-command)}.kind-palette__btn--hook[_ngcontent-%COMP%]{--p-togglebutton-icon-checked-color: var(--sm-kind-hook)}.kind-palette__btn--note[_ngcontent-%COMP%]{--p-togglebutton-icon-checked-color: var(--sm-kind-note)}"],changeDetection:0})};var eg={llm:{what:{label:"what",tooltip:"What it does (LLM-inferred summary)"},when:{label:"when",tooltip:"When to use (LLM-inferred)"},style:{label:"style",tooltip:"Interaction style (LLM-inferred)"},does:{label:"does",tooltip:"Capabilities (LLM-inferred)"},steps:{label:"steps",tooltip:"Recipe / ordered steps (LLM-inferred)"},pre:{label:"pre",tooltip:"Preconditions (LLM-inferred)"},out:{label:"out",tooltip:"Outputs / produced artifacts (LLM-inferred)"},fx:{label:"fx",tooltip:"Side effects (LLM-inferred)"},eg:{label:"eg",tooltip:"Invocation example (LLM-inferred)"},trigger:{label:"trigger",tooltip:"Inferred trigger (LLM-inferred from body)"},topics:{label:"topics",tooltip:"Topics covered (LLM-inferred)"},facts:{label:"facts",tooltip:"Key facts (LLM-inferred discrete claims)"}},meta:{model:"model",inputs:"inputs",outputs:"outputs",args:"args",shortcut:"shortcut",event:"event",cond:"cond",flags:"flags",blocking:{label:"blocking",tooltip:"blocking: host waits for hook to finish before proceeding"},idempotent:{label:"idempotent",tooltip:"idempotent: safe to run multiple times with the same input"},allowed:"allowed",tools:"tools",tags:"tags"},stats:{errors:n=>`${n} error${n===1?"":"s"}`,warns:n=>`${n} warning${n===1?"":"s"}`,tools:n=>`${n} tool${n===1?"":"s"}`,toolsBreakdown:(n,i)=>`${n} allowlist + ${i} pre-approved`,linksIn:n=>`${n} incoming link${n===1?"":"s"}`,linksOut:n=>`${n} outgoing link${n===1?"":"s"}`,extRefs:n=>`${n} external URL${n===1?"":"s"} in body`,bytes:n=>`${n.toLocaleString("en-US")} bytes`,tokens:n=>`${n.toLocaleString("en-US")} tokens`,daysAgo:(n,i)=>`updated ${n} (${i} day${i===1?"":"s"} ago)`},stability:{experimental:"experimental",deprecated:"deprecated"},safety:{injection:n=>`injection${n?`: ${n}`:""}`},confidence:n=>`LLM summary \xB7 confidence ${n.toFixed(2)}`,ariaExpand:"Expand"};function ex(n,i){if(n&1&&Zt(0,"i",4),n&2){let e=S();tt(e.piClass()),gt("font-size",e.size(),"px")}}function tx(n,i){if(n&1&&(Ge(),Je(0,"svg",1),Zt(1,"path"),et()),n&2){let e=S();te("width",e.size())("height",e.size()),h(),te("d",e.svgPath())}}function nx(n,i){if(n&1&&(Je(0,"span",4),T(1),et()),n&2){let e=S();gt("font-size",e.size(),"px")("line-height",e.size(),"px"),h(),N(e.emoji())}}function ix(n,i){if(n&1&&(Je(0,"span",5),T(1),et()),n&2){let e=S();gt("font-size",e.size(),"px")("line-height",e.size(),"px"),h(),N(e.letter())}}var Yd=class n{kindRegistry=c(Fi);kind=F.required();size=F(18);variant=G(()=>{let i=this.kindRegistry.lookup(this.kind());return i?.icon?.kind==="pi"?"pi":i?.icon?.kind==="svg"?"svg":i?.emoji?"emoji":"letter"});piClass=G(()=>{let i=this.kindRegistry.lookup(this.kind())?.icon;return i?.kind==="pi"?`pi ${i.id}`:""});svgPath=G(()=>{let i=this.kindRegistry.lookup(this.kind())?.icon;return i?.kind==="svg"?i.path:""});emoji=G(()=>this.kindRegistry.lookup(this.kind())?.emoji??"");letter=G(()=>this.kindRegistry.labelOf(this.kind()).charAt(0).toUpperCase());static \u0275fac=function(e){return new(e||n)};static \u0275cmp=se({type:n,selectors:[["sm-kind-icon"]],inputs:{kind:[1,"kind"],size:[1,"size"]},decls:4,vars:1,consts:[["aria-hidden","true",3,"class","font-size"],["viewBox","0 0 24 24","fill","none","stroke","currentColor","stroke-width","2.2","stroke-linecap","round","stroke-linejoin","round","aria-hidden","true"],["aria-hidden","true",3,"font-size","line-height"],["aria-hidden","true",1,"kind-icon__letter",3,"font-size","line-height"],["aria-hidden","true"],["aria-hidden","true",1,"kind-icon__letter"]],template:function(e,t){if(e&1&&k(0,ex,1,4,"i",0)(1,tx,2,3,":svg:svg",1)(2,nx,2,5,"span",2)(3,ix,2,5,"span",3),e&2){let o;O((o=t.variant())==="pi"?0:o==="svg"?1:o==="emoji"?2:o==="letter"?3:-1)}},styles:["[_nghost-%COMP%]{display:inline-flex;align-items:center;justify-content:center;line-height:1}"],changeDetection:0})};var ox=(n,i)=>i.step,Ju=(n,i)=>i.name,rx=(n,i)=>i.ruleId+i.message;function sx(n,i){if(n&1&&(m(0,"span",25),T(1),v()),n&2){let e=S(),t=pt(0),o=pt(2);tt("sm-gnode__llm-marker--"+o),A("pTooltip",e.texts.confidence(t.confidence)),h(),dt("",e.confidencePct(),"%")}}function ax(n,i){if(n&1&&(m(0,"span",11)(1,"span",26),T(2,"T"),v(),T(3),v()),n&2){let e=S(),t=pt(1);A("pTooltip",e.texts.stats.tokens(t.tokensTotal)),h(3),N(e.tokensShort())}}function cx(n,i){if(n&1&&(m(0,"span",12)(1,"span",26),T(2,"B"),v(),T(3),v()),n&2){let e=S(),t=pt(1);A("pTooltip",e.texts.stats.bytes(t.bytesTotal)),h(3),N(e.bytesShort())}}function dx(n,i){if(n&1&&(m(0,"span",13),U(1,"i",27),T(2),v()),n&2){let e=i,t=S();A("pTooltip",t.texts.stats.daysAgo(e.iso,e.days)),h(2),N(e.short)}}function lx(n,i){n&1&&(m(0,"span",14),T(1),v()),n&2&&(h(),N(i))}function ux(n,i){if(n&1&&(m(0,"div",28)(1,"span",29),T(2),v(),m(3,"span"),T(4),v()()),n&2){let e=S(),t=S(2);h(),A("pTooltip",t.texts.llm.what.tooltip),h(),N(t.texts.llm.what.label),h(2),N(e.whatItCovers)}}function fx(n,i){if(n&1&&(m(0,"span",31),T(1),v()),n&2){let e=i.$implicit;h(),N(e)}}function hx(n,i){if(n&1&&(m(0,"div",28)(1,"span",29),T(2),v(),m(3,"div",30),me(4,fx,2,1,"span",31,at),v()()),n&2){let e=S(),t=S(2);h(),A("pTooltip",t.texts.llm.topics.tooltip),h(),N(t.texts.llm.topics.label),h(2),ye(e.topics)}}function gx(n,i){if(n&1&&(m(0,"span",31),T(1),v()),n&2){let e=i.$implicit;h(),N(e)}}function px(n,i){if(n&1&&(m(0,"div",28)(1,"span",29),T(2),v(),m(3,"div",30),me(4,gx,2,1,"span",31,at),v()()),n&2){let e=S(),t=S(2);h(),A("pTooltip",t.texts.llm.facts.tooltip),h(),N(t.texts.llm.facts.label),h(2),ye(e.keyFacts)}}function _x(n,i){if(n&1&&(k(0,ux,5,3,"div",28),k(1,hx,6,2,"div",28),k(2,px,6,2,"div",28)),n&2){let e=i,t=S(2);O(t.showLlmWhat?0:-1),h(),O(e.topics!=null&&e.topics.length?1:-1),h(),O(e.keyFacts!=null&&e.keyFacts.length?2:-1)}}function mx(n,i){if(n&1&&(m(0,"div",28)(1,"span",29),T(2),v(),m(3,"span"),T(4),v()()),n&2){let e=S(),t=S(2);h(),A("pTooltip",t.texts.llm.what.tooltip),h(),N(t.texts.llm.what.label),h(2),N(e.whatItDoes)}}function yx(n,i){if(n&1&&(m(0,"div",28)(1,"span",29),T(2),v(),m(3,"span"),T(4),v()()),n&2){let e=S(),t=S(2);h(),A("pTooltip",t.texts.llm.when.tooltip),h(),N(t.texts.llm.when.label),h(2),N(e.whenToUse)}}function vx(n,i){if(n&1&&(m(0,"div",28)(1,"span",29),T(2),v(),m(3,"span"),T(4),v()()),n&2){let e=S(),t=S(2);h(),A("pTooltip",t.texts.llm.style.tooltip),h(),N(t.texts.llm.style.label),h(2),N(e.interactionStyle)}}function Cx(n,i){if(n&1&&(m(0,"span",31),T(1),v()),n&2){let e=i.$implicit;h(),N(e)}}function xx(n,i){if(n&1&&(m(0,"div",28)(1,"span",29),T(2),v(),m(3,"div",30),me(4,Cx,2,1,"span",31,at),v()()),n&2){let e=S(),t=S(2);h(),A("pTooltip",t.texts.llm.does.tooltip),h(),N(t.texts.llm.does.label),h(2),ye(e.capabilities)}}function wx(n,i){if(n&1&&(k(0,mx,5,3,"div",28),k(1,yx,5,3,"div",28),k(2,vx,5,3,"div",28),k(3,xx,6,2,"div",28)),n&2){let e=i,t=S(2);O(t.showLlmWhat?0:-1),h(),O(e.whenToUse?1:-1),h(),O(e.interactionStyle?2:-1),h(),O(e.capabilities!=null&&e.capabilities.length?3:-1)}}function bx(n,i){if(n&1&&(m(0,"div",28)(1,"span",29),T(2),v(),m(3,"span"),T(4),v()()),n&2){let e=S(),t=S(2);h(),A("pTooltip",t.texts.llm.what.tooltip),h(),N(t.texts.llm.what.label),h(2),N(e.whatItDoes)}}function Ix(n,i){if(n&1&&T(0),n&2){let e=i.$implicit,t=i.$index,o=i.$count;_f("",e.step,". ",e.description,"",t===o-1?"":" \xB7 ")}}function Sx(n,i){if(n&1&&(m(0,"div",28)(1,"span",29),T(2),v(),m(3,"span"),me(4,Ix,1,3,null,null,ox),v()()),n&2){let e=S(),t=S(2);h(),A("pTooltip",t.texts.llm.steps.tooltip),h(),N(t.texts.llm.steps.label),h(2),ye(e.recipe)}}function Dx(n,i){if(n&1&&(m(0,"span",31),T(1),v()),n&2){let e=i.$implicit;h(),N(e)}}function Tx(n,i){if(n&1&&(m(0,"div",28)(1,"span",29),T(2),v(),m(3,"div",30),me(4,Dx,2,1,"span",31,at),v()()),n&2){let e=S(),t=S(2);h(),A("pTooltip",t.texts.llm.pre.tooltip),h(),N(t.texts.llm.pre.label),h(2),ye(e.preconditions)}}function Ex(n,i){if(n&1&&(m(0,"span",31),T(1),v()),n&2){let e=i.$implicit;h(),N(e)}}function Px(n,i){if(n&1&&(m(0,"div",28)(1,"span",29),T(2),v(),m(3,"div",30),me(4,Ex,2,1,"span",31,at),v()()),n&2){let e=S(),t=S(2);h(),A("pTooltip",t.texts.llm.out.tooltip),h(),N(t.texts.llm.out.label),h(2),ye(e.outputs)}}function Mx(n,i){if(n&1&&(m(0,"span",31),T(1),v()),n&2){let e=i.$implicit;h(),N(e)}}function Rx(n,i){if(n&1&&(m(0,"div",28)(1,"span",29),T(2),v(),m(3,"div",30),me(4,Mx,2,1,"span",31,at),v()()),n&2){let e=S(),t=S(2);h(),A("pTooltip",t.texts.llm.fx.tooltip),h(),N(t.texts.llm.fx.label),h(2),ye(e.sideEffects)}}function Nx(n,i){if(n&1&&(k(0,bx,5,3,"div",28),k(1,Sx,6,2,"div",28),k(2,Tx,6,2,"div",28),k(3,Px,6,2,"div",28),k(4,Rx,6,2,"div",28)),n&2){let e=i,t=S(2);O(t.showLlmWhat?0:-1),h(),O(e.recipe!=null&&e.recipe.length?1:-1),h(),O(e.preconditions!=null&&e.preconditions.length?2:-1),h(),O(e.outputs!=null&&e.outputs.length?3:-1),h(),O(e.sideEffects!=null&&e.sideEffects.length?4:-1)}}function kx(n,i){if(n&1&&(m(0,"div",28)(1,"span",29),T(2),v(),m(3,"span"),T(4),v()()),n&2){let e=S(),t=S(2);h(),A("pTooltip",t.texts.llm.what.tooltip),h(),N(t.texts.llm.what.label),h(2),N(e.whatItDoes)}}function Ox(n,i){if(n&1&&(m(0,"div",28)(1,"span",29),T(2),v(),m(3,"code",32),T(4),v()()),n&2){let e=S(),t=S(2);h(),A("pTooltip",t.texts.llm.eg.tooltip),h(),N(t.texts.llm.eg.label),h(2),N(e.invocationExample)}}function Fx(n,i){if(n&1&&(m(0,"span",31),T(1),v()),n&2){let e=i.$implicit;h(),N(e)}}function Ax(n,i){if(n&1&&(m(0,"div",28)(1,"span",29),T(2),v(),m(3,"div",30),me(4,Fx,2,1,"span",31,at),v()()),n&2){let e=S(),t=S(2);h(),A("pTooltip",t.texts.llm.fx.tooltip),h(),N(t.texts.llm.fx.label),h(2),ye(e.sideEffects)}}function Lx(n,i){if(n&1&&(k(0,kx,5,3,"div",28),k(1,Ox,5,3,"div",28),k(2,Ax,6,2,"div",28)),n&2){let e=i,t=S(2);O(t.showLlmWhat?0:-1),h(),O(e.invocationExample?1:-1),h(),O(e.sideEffects!=null&&e.sideEffects.length?2:-1)}}function zx(n,i){if(n&1&&(m(0,"div",28)(1,"span",29),T(2),v(),m(3,"span"),T(4),v()()),n&2){let e=S(),t=S(2);h(),A("pTooltip",t.texts.llm.what.tooltip),h(),N(t.texts.llm.what.label),h(2),N(e.whatItDoes)}}function Bx(n,i){if(n&1&&(m(0,"div",28)(1,"span",29),T(2),v(),m(3,"span"),T(4),v()()),n&2){let e=S(),t=S(2);h(),A("pTooltip",t.texts.llm.trigger.tooltip),h(),N(t.texts.llm.trigger.label),h(2),N(e.triggerInferred)}}function Gx(n,i){if(n&1&&(m(0,"span",31),T(1),v()),n&2){let e=i.$implicit;h(),N(e)}}function Hx(n,i){if(n&1&&(m(0,"div",28)(1,"span",29),T(2),v(),m(3,"div",30),me(4,Gx,2,1,"span",31,at),v()()),n&2){let e=S(),t=S(2);h(),A("pTooltip",t.texts.llm.fx.tooltip),h(),N(t.texts.llm.fx.label),h(2),ye(e.sideEffects)}}function jx(n,i){if(n&1&&(k(0,zx,5,3,"div",28),k(1,Bx,5,3,"div",28),k(2,Hx,6,2,"div",28)),n&2){let e=i,t=S(2);O(t.showLlmWhat?0:-1),h(),O(e.triggerInferred?1:-1),h(),O(e.sideEffects!=null&&e.sideEffects.length?2:-1)}}function Vx(n,i){if(n&1&&(m(0,"div",16),k(1,_x,3,3),k(2,wx,4,4),k(3,Nx,5,5),k(4,Lx,3,3),k(5,jx,3,3),v()),n&2){let e,t,o,r,s,a=S();h(),O((e=a.summaryNote())?1:-1,e),h(),O((t=a.summaryAgent())?2:-1,t),h(),O((o=a.summarySkill())?3:-1,o),h(),O((r=a.summaryCommand())?4:-1,r),h(),O((s=a.summaryHook())?5:-1,s)}}function Ux(n,i){if(n&1&&(m(0,"div",17),T(1),v()),n&2){let e=S();h(),N(e.description())}}function Wx(n,i){if(n&1&&(m(0,"div",18)(1,"div",33)(2,"span",34),T(3),v(),m(4,"span",35),T(5),v()()()),n&2){let e=S(),t=S();h(3),N(t.texts.meta.model),h(2),N(e.model)}}function $x(n,i){n&1&&k(0,Wx,6,2,"div",18),n&2&&O(i.model?0:-1)}function Xx(n,i){n&1&&(m(0,"span",37),T(1,"*"),v())}function qx(n,i){if(n&1&&(m(0,"span",36),T(1),k(2,Xx,2,0,"span",37),v()),n&2){let e=i.$implicit;A("pTooltip",e.description??e.name),h(),N(e.name),h(),O(e.required?2:-1)}}function Yx(n,i){if(n&1&&(m(0,"div",33)(1,"span",34),T(2),v(),m(3,"div",30),me(4,qx,3,3,"span",36,Ju),v()()),n&2){let e=S(2),t=S();h(2),N(t.texts.meta.inputs),h(2),ye(e.inputs)}}function Kx(n,i){if(n&1&&(m(0,"span",36),T(1),v()),n&2){let e=i.$implicit;A("pTooltip",e.description??e.name),h(),N(e.name)}}function Zx(n,i){if(n&1&&(m(0,"div",33)(1,"span",34),T(2),v(),m(3,"div",30),me(4,Kx,2,2,"span",36,Ju),v()()),n&2){let e=S(2),t=S();h(2),N(t.texts.meta.outputs),h(2),ye(e.outputs)}}function Qx(n,i){if(n&1&&(m(0,"div",18),k(1,Yx,6,1,"div",33),k(2,Zx,6,1,"div",33),v()),n&2){let e=S();h(),O(e.inputs!=null&&e.inputs.length?1:-1),h(),O(e.outputs!=null&&e.outputs.length?2:-1)}}function Jx(n,i){if(n&1&&k(0,Qx,3,2,"div",18),n&2){let e=i;O(e.inputs!=null&&e.inputs.length||e.outputs!=null&&e.outputs.length?0:-1)}}function ew(n,i){n&1&&(m(0,"span",37),T(1,"*"),v())}function tw(n,i){if(n&1&&(m(0,"span",36),T(1),k(2,ew,2,0,"span",37),v()),n&2){let e=i.$implicit;A("pTooltip",e.description??e.name),h(),N(e.name),h(),O(e.required?2:-1)}}function nw(n,i){if(n&1&&(m(0,"div",33)(1,"span",34),T(2),v(),m(3,"div",30),me(4,tw,3,3,"span",36,Ju),v()()),n&2){let e=S(2),t=S();h(2),N(t.texts.meta.args),h(2),ye(e.args)}}function iw(n,i){if(n&1&&(m(0,"div",33)(1,"span",34),T(2),v(),m(3,"span",35),T(4),v()()),n&2){let e=S(2),t=S();h(2),N(t.texts.meta.shortcut),h(2),N(e.shortcut)}}function ow(n,i){if(n&1&&(m(0,"div",18),k(1,nw,6,1,"div",33),k(2,iw,5,2,"div",33),v()),n&2){let e=S();h(),O(e.args!=null&&e.args.length?1:-1),h(),O(e.shortcut?2:-1)}}function rw(n,i){if(n&1&&k(0,ow,3,2,"div",18),n&2){let e=i;O(e.args!=null&&e.args.length||e.shortcut?0:-1)}}function sw(n,i){if(n&1&&(m(0,"div",33)(1,"span",34),T(2),v(),m(3,"span",35),T(4),v()()),n&2){let e=S(),t=S();h(2),N(t.texts.meta.event),h(2),N(e.event)}}function aw(n,i){if(n&1&&(m(0,"div",33)(1,"span",34),T(2),v(),m(3,"span",35),T(4),v()()),n&2){let e=S(),t=S();h(2),N(t.texts.meta.cond),h(2),N(e.condition)}}function cw(n,i){if(n&1&&(m(0,"span",38),T(1),v()),n&2){let e=S(3);A("pTooltip",e.texts.meta.blocking.tooltip),h(),N(e.texts.meta.blocking.label)}}function dw(n,i){if(n&1&&(m(0,"span",38),T(1),v()),n&2){let e=S(3);A("pTooltip",e.texts.meta.idempotent.tooltip),h(),N(e.texts.meta.idempotent.label)}}function lw(n,i){if(n&1&&(m(0,"div",33)(1,"span",34),T(2),v(),m(3,"div",30),k(4,cw,2,2,"span",38),k(5,dw,2,2,"span",38),v()()),n&2){let e=S(),t=S();h(2),N(t.texts.meta.flags),h(2),O(e.blocking?4:-1),h(),O(e.idempotent?5:-1)}}function uw(n,i){if(n&1&&(m(0,"div",18),k(1,sw,5,2,"div",33),k(2,aw,5,2,"div",33),k(3,lw,6,3,"div",33),v()),n&2){let e=i;h(),O(e.event?1:-1),h(),O(e.condition?2:-1),h(),O(e.blocking||e.idempotent?3:-1)}}function fw(n,i){if(n&1&&(m(0,"div",40),U(1,"i",41),m(2,"code",42),T(3),v(),m(4,"span",43),T(5),v()()),n&2){let e=i.$implicit;tt("sm-gnode__issue--"+e.severity),A("pTooltip",e.detail??e.ruleId+" \xB7 "+e.message),h(),$e("pi",!0)("pi-times-circle",e.severity==="error")("pi-exclamation-triangle",e.severity==="warn"),h(2),N(e.ruleId),h(2),N(e.message)}}function hw(n,i){if(n&1&&(m(0,"div",19),me(1,fw,6,11,"div",39,rx),v()),n&2){let e=S();h(),ye(e.visibleIssues())}}function gw(n,i){if(n&1&&(m(0,"span",21),U(1,"i",44),m(2,"span",45),T(3),v()()),n&2){let e=S();A("pTooltip",e.texts.stats.errors(e.errorCount())),h(3),N(e.errorCount())}}function pw(n,i){if(n&1&&(m(0,"span",22),U(1,"i",46),m(2,"span",45),T(3),v()()),n&2){let e=S();A("pTooltip",e.texts.stats.warns(e.warnCount())),h(3),N(e.warnCount())}}function _w(n,i){if(n&1&&(m(0,"span",23),U(1,"i",47),m(2,"span",45),T(3),v()()),n&2){let e=S();A("pTooltip",e.toolsTooltip()),h(3),N(e.toolsCount())}}function mw(n,i){if(n&1&&(m(0,"span",23)(1,"span",48),T(2,"\u2193"),v(),m(3,"span",45),T(4),v()()),n&2){let e=S(),t=pt(1);A("pTooltip",e.texts.stats.linksIn(t.linksIn)),h(4),N(t.linksIn)}}function yw(n,i){if(n&1&&(m(0,"span",23)(1,"span",48),T(2,"\u2191"),v(),m(3,"span",45),T(4),v()()),n&2){let e=S(),t=pt(1);A("pTooltip",e.texts.stats.linksOut(t.linksOut)),h(4),N(t.linksOut)}}function vw(n,i){if(n&1&&(m(0,"span",23),U(1,"i",49),m(2,"span",45),T(3),v()()),n&2){let e=S(),t=pt(1);A("pTooltip",e.texts.stats.extRefs(t.externalRefsCount)),h(3),N(t.externalRefsCount)}}function Cw(n,i){if(n&1&&(m(0,"span",23),Ge(),m(1,"svg",51),U(2,"path",52)(3,"path",53)(4,"path",54),v()()),n&2){let e=S(2);A("pTooltip",e.texts.stability.experimental)}}function xw(n,i){if(n&1&&(m(0,"span",23),U(1,"i",55),v()),n&2){let e=S(2);A("pTooltip",e.texts.stability.deprecated)}}function ww(n,i){if(n&1&&(m(0,"span",50),Ge(),m(1,"svg",51),U(2,"path",56)(3,"line",57)(4,"line",58),v()()),n&2){let e=S(2);A("pTooltip",e.texts.safety.injection(e.injectionType()))}}function bw(n,i){if(n&1&&(m(0,"div",24),k(1,Cw,5,1,"span",23),k(2,xw,2,1,"span",23),k(3,ww,5,1,"span",50),v()),n&2){let e=S();h(),O(e.stability()==="experimental"?1:-1),h(),O(e.stability()==="deprecated"?2:-1),h(),O(e.hasInjection()?3:-1)}}var Kd=class n{node=F.required();stats=F({linksIn:0,linksOut:0});summary=F(null);issues=F([]);selected=F(!1);highlighted=F(!1);dimmed=F(!1);texts=eg;showLlmWhat=!1;showLlmConfidence=!1;expanded=Mt(!1);fmAgent=G(()=>{let i=this.node();return i.kind==="agent"?i.frontmatter:null});fmSkill=G(()=>{let i=this.node();return i.kind==="skill"?i.frontmatter:null});fmCommand=G(()=>{let i=this.node();return i.kind==="command"?i.frontmatter:null});fmHook=G(()=>{let i=this.node();return i.kind==="hook"?i.frontmatter:null});summaryAgent=G(()=>{let i=this.summary();return i?.kind==="agent"?i:null});summarySkill=G(()=>{let i=this.summary();return i?.kind==="skill"?i:null});summaryCommand=G(()=>{let i=this.summary();return i?.kind==="command"?i:null});summaryHook=G(()=>{let i=this.summary();return i?.kind==="hook"?i:null});summaryNote=G(()=>{let i=this.summary();return i?.kind==="note"?i:null});hasLlmCluster=G(()=>{let i=this.summary();return i===null?!1:this.showLlmWhat?!0:this.hasNonWhatLlmContent(i)});hasNonWhatLlmContent(i){switch(i.kind){case"note":return(i.topics?.length??0)>0||(i.keyFacts?.length??0)>0;case"agent":return!!i.whenToUse||!!i.interactionStyle||(i.capabilities?.length??0)>0;case"skill":return(i.recipe?.length??0)>0||(i.preconditions?.length??0)>0||(i.outputs?.length??0)>0||(i.sideEffects?.length??0)>0;case"command":return!!i.invocationExample||(i.sideEffects?.length??0)>0;case"hook":return!!i.triggerInferred||(i.sideEffects?.length??0)>0;default:return!1}}hasInjection=G(()=>this.summary()?.safety.injectionDetected===!0);confidenceTier=G(()=>{let i=this.summary();return i?i.confidence>.8?"high":i.confidence>=.5?"med":"low":null});confidencePct=G(()=>{let i=this.summary();return i?Math.round(i.confidence*100):null});injectionType=G(()=>{let i=this.summary();return i?.safety.injectionDetected?i.safety.injectionType??null:null});visibleIssues=G(()=>this.issues().filter(i=>i.severity==="error"||i.severity==="warn"));errorCount=G(()=>this.visibleIssues().filter(i=>i.severity==="error").length);warnCount=G(()=>this.visibleIssues().filter(i=>i.severity==="warn").length);nodeColor=G(()=>{let i=this.node().frontmatter.metadata.color;return typeof i=="string"&&i.length>0?i:null});bytesShort=G(()=>{let i=this.stats().bytesTotal;return i===void 0?null:tg(i)});tokensShort=G(()=>{let i=this.stats().tokensTotal;return i===void 0?null:tg(i)});daysAgo=G(()=>{let i=this.node().frontmatter.metadata.updated;if(!i)return null;let e=new Date(i);if(isNaN(e.getTime()))return null;let t=Math.max(0,Math.floor((Date.now()-e.getTime())/864e5));return{short:`${t}d`,iso:typeof i=="string"?i:e.toISOString(),days:t}});version=G(()=>{let i=this.node().frontmatter.metadata.version;return i?`v${i}`:null});stability=G(()=>this.node().frontmatter.metadata.stability??null);displayName=G(()=>this.node().frontmatter.name||this.node().path);description=G(()=>this.node().frontmatter.description??"");toolsCount=G(()=>{let i=this.node().frontmatter,e=Array.isArray(i.tools)?i.tools.length:0,t=Array.isArray(i.allowedTools)?i.allowedTools.length:0;return e+t});toolsTooltip=G(()=>{let i=this.node().frontmatter,e=Array.isArray(i.tools)?i.tools.length:0,t=Array.isArray(i.allowedTools)?i.allowedTools.length:0;return this.texts.stats.toolsBreakdown(e,t)});toggleExpanded(i){i.stopPropagation(),this.expanded.update(e=>!e)}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=se({type:n,selectors:[["sm-node-card"]],hostAttrs:[1,"sm-gnode"],hostVars:26,hostBindings:function(e,t){e&2&&(gt("--node-color",t.nodeColor()),$e("sm-gnode--skill",t.node().kind==="skill")("sm-gnode--agent",t.node().kind==="agent")("sm-gnode--command",t.node().kind==="command")("sm-gnode--hook",t.node().kind==="hook")("sm-gnode--note",t.node().kind==="note")("sm-gnode--danger",t.hasInjection())("sm-gnode--with-color",!!t.nodeColor())("sm-gnode--deprecated",t.stability()==="deprecated")("sm-gnode--expanded",t.expanded())("sm-gnode--selected",t.selected())("sm-gnode--highlighted",t.highlighted())("sm-gnode--dimmed",t.dimmed()))},inputs:{node:[1,"node"],stats:[1,"stats"],summary:[1,"summary"],issues:[1,"issues"],selected:[1,"selected"],highlighted:[1,"highlighted"],dimmed:[1,"dimmed"],expanded:[1,"expanded"]},outputs:{expanded:"expandedChange"},decls:35,vars:27,consts:[[1,"sm-gnode__main"],["aria-hidden","true",1,"sm-gnode__icon-box"],[3,"kind","size"],[1,"sm-gnode__content"],[1,"sm-gnode__name-row"],[1,"sm-gnode__name",3,"pTooltip"],[1,"sm-gnode__actions"],[1,"sm-gnode__confidence",3,"class","pTooltip"],["type","button",1,"sm-gnode__chevron",3,"click"],["aria-hidden","true",1,"pi","pi-chevron-down"],[1,"sm-gnode__sub"],[1,"sm-gnode__sub-stat","sm-gnode__sub-stat--tokens",3,"pTooltip"],[1,"sm-gnode__sub-stat","sm-gnode__sub-stat--bytes",3,"pTooltip"],[1,"sm-gnode__sub-stat","sm-gnode__sub-stat--date",3,"pTooltip"],[1,"sm-gnode__sub-version"],[1,"sm-gnode__panel"],[1,"sm-gnode__llm"],[1,"sm-gnode__desc"],[1,"sm-gnode__meta"],[1,"sm-gnode__issues-block"],[1,"sm-gnode__footer"],[1,"sm-gnode__stat","sm-gnode__stat--error",3,"pTooltip"],[1,"sm-gnode__stat","sm-gnode__stat--warn",3,"pTooltip"],[1,"sm-gnode__stat",3,"pTooltip"],[1,"sm-gnode__footer-end"],[1,"sm-gnode__confidence",3,"pTooltip"],[1,"sm-gnode__sub-key"],["aria-hidden","true",1,"pi","pi-calendar"],[1,"sm-gnode__llm-line"],[1,"sm-gnode__llm-label",3,"pTooltip"],[1,"sm-gnode__chips"],[1,"sm-gnode__chip","sm-gnode__chip--llm"],[1,"sm-gnode__llm-code"],[1,"sm-gnode__meta-row"],[1,"sm-gnode__meta-label"],[1,"sm-gnode__meta-value","sm-gnode__meta-value--mono"],[1,"sm-gnode__chip","sm-gnode__chip--mono",3,"pTooltip"],[1,"sm-gnode__chip-required"],[1,"sm-gnode__chip",3,"pTooltip"],[1,"sm-gnode__issue",3,"class","pTooltip"],[1,"sm-gnode__issue",3,"pTooltip"],["aria-hidden","true",1,"sm-gnode__issue-icon"],[1,"sm-gnode__issue-rule"],[1,"sm-gnode__issue-msg"],["aria-hidden","true",1,"pi","pi-times-circle"],[1,"sm-gnode__stat-num"],["aria-hidden","true",1,"pi","pi-exclamation-triangle"],["aria-hidden","true",1,"pi","pi-wrench"],["aria-hidden","true"],["aria-hidden","true",1,"pi","pi-link"],[1,"sm-gnode__stat","sm-gnode__stat--danger",3,"pTooltip"],["width","14","height","14","viewBox","0 0 24 24","fill","none","stroke","currentColor","stroke-width","2","stroke-linecap","round","stroke-linejoin","round","aria-hidden","true"],["d","M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2"],["d","M6.453 15h11.094"],["d","M8.5 2h7"],["aria-hidden","true",1,"pi","pi-ban"],["d","M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"],["x1","12","y1","8","x2","12","y2","12"],["x1","12","y1","16","x2","12.01","y2","16"]],template:function(e,t){if(e&1&&(mf(0)(1)(2),m(3,"div",0)(4,"div",1),U(5,"sm-kind-icon",2),v(),m(6,"div",3)(7,"div",4)(8,"span",5),T(9),v()()(),m(10,"div",6),k(11,sx,2,4,"span",7),m(12,"button",8),Se("click",function(r){return t.toggleExpanded(r)}),U(13,"i",9),v()(),m(14,"div",10),k(15,ax,4,2,"span",11),k(16,cx,4,2,"span",12),k(17,dx,3,2,"span",13),k(18,lx,2,1,"span",14),v()(),m(19,"div",15),k(20,Vx,6,5,"div",16),k(21,Ux,2,1,"div",17),k(22,$x,1,1),k(23,Jx,1,1),k(24,rw,1,1),k(25,uw,4,3,"div",18),k(26,hw,3,0,"div",19),v(),m(27,"div",20),k(28,gw,4,2,"span",21),k(29,pw,4,2,"span",22),k(30,_w,4,2,"span",23),k(31,mw,5,2,"span",23),k(32,yw,5,2,"span",23),k(33,vw,4,2,"span",23),k(34,bw,4,3,"div",24),v()),e&2){let o,r,s,a,d,l,u=t.node(),g=Ri(t.summary());h();let y=Ri(t.stats());h();let C=Ri(t.confidenceTier());h(3),A("kind",u.kind)("size",18),h(3),A("pTooltip",t.displayName()),h(),N(t.displayName()),h(2),O(t.showLlmConfidence&&g!==null&&C!==null?11:-1),h(),te("aria-label",t.texts.ariaExpand),h(3),O(t.tokensShort()!==null?15:-1),h(),O(t.bytesShort()!==null?16:-1),h(),O((o=t.daysAgo())?17:-1,o),h(),O((r=t.version())?18:-1,r),h(2),O(t.hasLlmCluster()?20:-1),h(),O(t.description()?21:-1),h(),O((s=t.fmAgent())?22:-1,s),h(),O((a=t.fmSkill())?23:-1,a),h(),O((d=t.fmCommand())?24:-1,d),h(),O((l=t.fmHook())?25:-1,l),h(),O(t.visibleIssues().length?26:-1),h(2),O(t.errorCount()>0?28:-1),h(),O(t.warnCount()>0?29:-1),h(),O(t.toolsCount()>0?30:-1),h(),O(y.linksIn>0?31:-1),h(),O(y.linksOut>0?32:-1),h(),O(y.externalRefsCount&&y.externalRefsCount>0?33:-1),h(),O(t.stability()==="experimental"||t.stability()==="deprecated"||t.hasInjection()?34:-1)}},dependencies:[Yd,Jt,Qt],styles:['[_nghost-%COMP%]{position:relative;display:inline-block;width:260px;background:var(--sm-bg-content);border:1px solid var(--sm-border);border-radius:8px;box-shadow:var(--sm-shadow-card);overflow:hidden;transition:box-shadow .12s ease,transform .12s ease;-webkit-user-select:none;user-select:none;text-align:start}[_nghost-%COMP%]:hover{box-shadow:var(--sm-shadow-card-hover)}[_nghost-%COMP%]:before{content:"";position:absolute;top:0;left:0;right:0;height:3px;background:var(--accent, var(--sm-kind-note))}.sm-gnode--skill[_nghost-%COMP%]{--accent: var(--sm-kind-skill)}.sm-gnode--agent[_nghost-%COMP%]{--accent: var(--sm-kind-agent)}.sm-gnode--command[_nghost-%COMP%]{--accent: var(--sm-kind-command)}.sm-gnode--hook[_nghost-%COMP%]{--accent: var(--sm-kind-hook)}.sm-gnode--note[_nghost-%COMP%]{--accent: var(--sm-kind-note)}.sm-gnode--danger[_nghost-%COMP%]{--accent: var(--sm-severity-error)}.sm-gnode--deprecated[_nghost-%COMP%]{opacity:.55}.sm-gnode--selected[_nghost-%COMP%]{border-color:var(--p-primary-color);box-shadow:0 0 0 2px var(--p-primary-color),0 4px 16px color-mix(in srgb,var(--p-primary-color) 25%,transparent)}.sm-gnode--highlighted[_nghost-%COMP%]{border-color:var(--p-primary-color);box-shadow:var(--sm-shadow-card-hover)}.sm-gnode--dimmed[_nghost-%COMP%]{opacity:.25}.sm-gnode__main[_ngcontent-%COMP%]{display:grid;grid-template-columns:auto minmax(0,1fr) auto;column-gap:.6rem;row-gap:.3rem;align-items:start;padding:.6rem .65rem}.sm-gnode__icon-box[_ngcontent-%COMP%]{width:38px;height:38px;border-radius:8px;display:flex;align-items:center;justify-content:center;background:var(--kind-bg, var(--sm-kind-note-bg));color:var(--kind-fg, var(--sm-kind-note-fg));flex:none;font-size:1.05rem;grid-row:1 / span 2;align-self:center}.sm-gnode--skill[_nghost-%COMP%] .sm-gnode__icon-box[_ngcontent-%COMP%]{--kind-bg: var(--sm-kind-skill-bg);--kind-fg: var(--sm-kind-skill-fg)}.sm-gnode--agent[_nghost-%COMP%] .sm-gnode__icon-box[_ngcontent-%COMP%]{--kind-bg: var(--sm-kind-agent-bg);--kind-fg: var(--sm-kind-agent-fg)}.sm-gnode--command[_nghost-%COMP%] .sm-gnode__icon-box[_ngcontent-%COMP%]{--kind-bg: var(--sm-kind-command-bg);--kind-fg: var(--sm-kind-command-fg)}.sm-gnode--hook[_nghost-%COMP%] .sm-gnode__icon-box[_ngcontent-%COMP%]{--kind-bg: var(--sm-kind-hook-bg);--kind-fg: var(--sm-kind-hook-fg)}.sm-gnode--note[_nghost-%COMP%] .sm-gnode__icon-box[_ngcontent-%COMP%]{--kind-bg: var(--sm-kind-note-bg);--kind-fg: var(--sm-kind-note-fg)}.sm-gnode__content[_ngcontent-%COMP%]{min-width:0;width:100%;justify-self:stretch;display:flex;flex-direction:column;gap:.15rem}.sm-gnode__name-row[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.4rem;min-width:0}.sm-gnode__name[_ngcontent-%COMP%]{font-size:.9rem;font-weight:600;line-height:1.2;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--p-text-color);flex:0 1 auto;min-width:0}.sm-gnode--with-color[_nghost-%COMP%] .sm-gnode__name[_ngcontent-%COMP%]{background:color-mix(in srgb,var(--node-color) 7%,transparent);padding:.05rem .4rem;border-radius:3px}.sm-gnode__actions[_ngcontent-%COMP%]{display:flex;align-items:flex-start;gap:.2rem}.sm-gnode__confidence[_ngcontent-%COMP%]{display:flex;align-items:flex-start;font-size:.65rem;font-weight:600;font-variant-numeric:tabular-nums;line-height:1;flex:none;cursor:help;padding-top:.35rem}.sm-gnode__llm-marker--high[_ngcontent-%COMP%]{color:var(--sm-severity-success)}.sm-gnode__llm-marker--med[_ngcontent-%COMP%]{color:var(--sm-severity-warn)}.sm-gnode__llm-marker--low[_ngcontent-%COMP%]{color:var(--sm-severity-error)}.sm-gnode__chevron[_ngcontent-%COMP%]{width:22px;height:22px;display:inline-flex;align-items:center;justify-content:center;border:none;background:transparent;cursor:pointer;color:var(--sm-text-muted);border-radius:4px;transition:transform .16s ease,background .12s ease,color .12s ease}.sm-gnode__chevron[_ngcontent-%COMP%] .pi[_ngcontent-%COMP%]{font-size:.7rem;line-height:1}.sm-gnode__chevron[_ngcontent-%COMP%]:hover{background:var(--sm-bg-hover);color:var(--p-text-color)}.sm-gnode--expanded[_nghost-%COMP%] .sm-gnode__chevron[_ngcontent-%COMP%]{transform:rotate(180deg)}.sm-gnode__sub[_ngcontent-%COMP%]{grid-column:2 / -1;grid-row:2;display:flex;flex-wrap:nowrap;align-items:center;gap:6px;font-family:var(--sm-font-mono);font-size:.6rem;color:var(--sm-text-muted);line-height:1.2;margin-top:.1rem;min-width:0;width:100%}.sm-gnode__sub-version[_ngcontent-%COMP%]{margin-left:auto}.sm-gnode__sub-stat[_ngcontent-%COMP%], .sm-gnode__sub-version[_ngcontent-%COMP%]{padding:.08rem .35rem;border-radius:3px;background:var(--sm-bg-hover);font-family:var(--sm-font-mono);font-size:.6rem;color:var(--sm-text-muted);font-weight:400;flex:none}.sm-gnode__sub-stat[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:.15rem;cursor:help}.sm-gnode__sub-stat[_ngcontent-%COMP%] i[_ngcontent-%COMP%]{font-size:.65rem}.sm-gnode__sub-key[_ngcontent-%COMP%]{font-weight:700}.sm-gnode__sub-stat--tokens[_ngcontent-%COMP%]{background:color-mix(in srgb,var(--sm-kind-agent) 7%,transparent)}.sm-gnode__sub-stat--bytes[_ngcontent-%COMP%]{background:color-mix(in srgb,var(--sm-kind-command) 7%,transparent)}.sm-gnode__sub-stat--date[_ngcontent-%COMP%]{background:color-mix(in srgb,var(--sm-kind-skill) 7%,transparent)}.app-dark[_nghost-%COMP%] .sm-gnode__sub-stat--tokens[_ngcontent-%COMP%], .app-dark [_nghost-%COMP%] .sm-gnode__sub-stat--tokens[_ngcontent-%COMP%]{background:color-mix(in srgb,var(--sm-kind-agent) 22%,transparent);color:var(--sm-kind-agent-fg)}.app-dark[_nghost-%COMP%] .sm-gnode__sub-stat--bytes[_ngcontent-%COMP%], .app-dark [_nghost-%COMP%] .sm-gnode__sub-stat--bytes[_ngcontent-%COMP%]{background:color-mix(in srgb,var(--sm-kind-command) 22%,transparent);color:var(--sm-kind-command-fg)}.app-dark[_nghost-%COMP%] .sm-gnode__sub-stat--date[_ngcontent-%COMP%], .app-dark [_nghost-%COMP%] .sm-gnode__sub-stat--date[_ngcontent-%COMP%]{background:color-mix(in srgb,var(--sm-kind-skill) 22%,transparent);color:var(--sm-kind-skill-fg)}.sm-gnode__panel[_ngcontent-%COMP%]{display:none;border-top:1px solid var(--sm-border)}.sm-gnode--expanded[_nghost-%COMP%] .sm-gnode__panel[_ngcontent-%COMP%]{display:block}.sm-gnode__llm[_ngcontent-%COMP%]{padding:.5rem .7rem;display:flex;flex-direction:column;gap:.25rem;font-size:.75rem;line-height:1.4}.sm-gnode__llm-line[_ngcontent-%COMP%]{display:flex;gap:.4rem;align-items:baseline;color:var(--p-text-color);font-style:italic;min-width:0}.sm-gnode__llm-label[_ngcontent-%COMP%]{flex:none;font-style:normal;color:var(--sm-text-muted);font-size:.6rem;letter-spacing:.04em;text-transform:uppercase;font-weight:600;min-width:2.2rem;padding-top:.2rem;cursor:help}.sm-gnode__chips[_ngcontent-%COMP%]{display:flex;flex-wrap:wrap;gap:.25rem;flex:1;min-width:0}.sm-gnode__chip[_ngcontent-%COMP%]{font-size:.65rem;padding:.1rem .4rem;border-radius:3px;border:1px solid var(--sm-border);background:var(--sm-bg-hover);color:var(--p-text-color);line-height:1.3}.sm-gnode__chip--mono[_ngcontent-%COMP%]{font-family:var(--sm-font-mono)}.sm-gnode__chip--allowed[_ngcontent-%COMP%]{border-style:dashed;background:transparent;color:var(--sm-text-muted)}.sm-gnode__chip--llm[_ngcontent-%COMP%]{font-style:italic}.sm-gnode__chip-required[_ngcontent-%COMP%]{color:var(--sm-severity-error);margin-left:2px}.sm-gnode__llm-code[_ngcontent-%COMP%]{font-family:var(--sm-font-mono);background:var(--sm-bg-hover);padding:.1rem .4rem;border-radius:3px;font-size:.7rem;font-style:normal;color:var(--p-text-color)}.sm-gnode__desc[_ngcontent-%COMP%]{padding:.55rem .7rem;font-size:.78rem;line-height:1.45;color:var(--p-text-color);max-height:140px;overflow-y:auto;overscroll-behavior:contain;border-top:1px solid var(--sm-border);scrollbar-width:thin;scrollbar-color:var(--sm-border) transparent}.sm-gnode__desc[_ngcontent-%COMP%]::-webkit-scrollbar{width:6px}.sm-gnode__desc[_ngcontent-%COMP%]::-webkit-scrollbar-track{background:transparent}.sm-gnode__desc[_ngcontent-%COMP%]::-webkit-scrollbar-thumb{background:var(--sm-border);border-radius:3px}.sm-gnode__meta[_ngcontent-%COMP%]{padding:.5rem .7rem;border-top:1px solid var(--sm-border);display:flex;flex-direction:column;gap:.35rem}.sm-gnode__meta-row[_ngcontent-%COMP%]{display:flex;align-items:flex-start;gap:.5rem;font-size:.7rem;min-width:0}.sm-gnode__meta-label[_ngcontent-%COMP%]{color:var(--sm-text-muted);text-transform:uppercase;letter-spacing:.04em;font-weight:600;font-size:.6rem;flex:none;min-width:60px;padding-top:.15rem}.sm-gnode__meta-value[_ngcontent-%COMP%]{color:var(--p-text-color);font-weight:500;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.sm-gnode__meta-value--mono[_ngcontent-%COMP%]{font-family:var(--sm-font-mono);background:var(--sm-bg-hover);padding:.08rem .4rem;border-radius:3px;font-size:.68rem}.sm-gnode__issues-block[_ngcontent-%COMP%]{padding:.5rem .7rem;border-top:1px solid var(--sm-border);display:flex;flex-direction:column;gap:.25rem}.sm-gnode__issue[_ngcontent-%COMP%]{display:flex;align-items:baseline;gap:.35rem;font-size:.7rem;line-height:1.35;min-width:0}.sm-gnode__issue-icon[_ngcontent-%COMP%]{font-size:.7rem;flex:none}.sm-gnode__issue--error[_ngcontent-%COMP%] .sm-gnode__issue-icon[_ngcontent-%COMP%]{color:var(--sm-severity-error)}.sm-gnode__issue--warn[_ngcontent-%COMP%] .sm-gnode__issue-icon[_ngcontent-%COMP%]{color:var(--sm-severity-warn)}.sm-gnode__issue-rule[_ngcontent-%COMP%]{font-family:var(--sm-font-mono);color:var(--sm-text-muted);flex:none;font-size:.65rem}.sm-gnode__issue-msg[_ngcontent-%COMP%]{color:var(--p-text-color);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex:1;min-width:0}.sm-gnode__footer[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.7rem;padding:.4rem .7rem;border-top:1px solid var(--sm-border);background:var(--sm-bg-hover);font-size:.7rem;color:var(--sm-text-muted)}.sm-gnode__footer[_ngcontent-%COMP%]:empty{display:none}.sm-gnode__footer-end[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:.7rem;margin-left:auto}.sm-gnode__stat[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:.3rem;line-height:1}.sm-gnode__stat[_ngcontent-%COMP%] i[_ngcontent-%COMP%], .sm-gnode__stat[_ngcontent-%COMP%] svg[_ngcontent-%COMP%]{font-size:.85rem}.sm-gnode__stat-num[_ngcontent-%COMP%]{font-weight:600;color:var(--p-text-color)}.sm-gnode__stat--error[_ngcontent-%COMP%]{background:var(--sm-severity-error-bg);color:var(--sm-severity-error);padding:.1rem .4rem;border-radius:3px}.sm-gnode__stat--error[_ngcontent-%COMP%] .sm-gnode__stat-num[_ngcontent-%COMP%]{color:var(--sm-severity-error)}.sm-gnode__stat--warn[_ngcontent-%COMP%]{background:var(--sm-severity-warn-bg);color:var(--sm-severity-warn);padding:.1rem .4rem;border-radius:3px}.sm-gnode__stat--warn[_ngcontent-%COMP%] .sm-gnode__stat-num[_ngcontent-%COMP%]{color:var(--sm-severity-warn)}.sm-gnode__stat--danger[_ngcontent-%COMP%]{color:var(--sm-severity-error)}'],changeDetection:0})};function tg(n){return n<1e3?`${n}`:n<1e4?`${(n/1e3).toFixed(1).replace(/\.0$/,"")}k`:`${Math.round(n/1e3)}k`}var ng={a11y:{expand:"Expand performance HUD",collapse:"Collapse performance HUD"},units:{fps:n=>`${n} fps`,ms:n=>`${n}ms`,mb:n=>`${n} MB`,longTasks:n=>`${n} long`,domNodes:n=>`${n} dom`,nodes:(n,i)=>`${n}/${i} nodes`,edges:n=>`${n} edges`,cacheAge:n=>`cache ${n}s`}};var Iw=["sparkline"];function Sw(n,i){if(n&1&&(m(0,"span",5),T(1,"\xB7"),v(),m(2,"span",3),T(3),v()),n&2){let e=S(3);h(3),N(e.texts.units.mb(e.heapMb()))}}function Dw(n,i){if(n&1&&(m(0,"span",5),T(1,"\xB7"),v(),m(2,"span",3),T(3),v()),n&2){let e=S(3);h(3),N(e.texts.units.cacheAge(e.cacheAgeSec()))}}function Tw(n,i){if(n&1&&(U(0,"canvas",4,1),m(2,"span",5),T(3,"\xB7"),v(),m(4,"span",3),T(5),v(),k(6,Sw,4,1),m(7,"span",5),T(8,"\xB7"),v(),m(9,"span",3),T(10),v(),m(11,"span",5),T(12,"\xB7"),v(),m(13,"span",3),T(14),v(),m(15,"span",5),T(16,"\xB7"),v(),m(17,"span",3),T(18),v(),m(19,"span",5),T(20,"\xB7"),v(),m(21,"span",3),T(22),v(),k(23,Dw,4,1)),n&2){let e=S(2);h(5),N(e.texts.units.ms(e.frameTimeMs())),h(),O(e.hasHeap()?6:-1),h(4),N(e.texts.units.longTasks(e.longTasks())),h(4),N(e.texts.units.domNodes(e.domNodes())),h(4),N(e.texts.units.nodes(e.visible(),e.total())),h(4),N(e.texts.units.edges(e.edges())),h(),O(e.cacheAgeSec()!==null?23:-1)}}function Ew(n,i){if(n&1&&(m(0,"span",3),T(1),v(),k(2,Tw,24,7)),n&2){let e=S();h(),N(e.texts.units.fps(e.fps())),h(),O(e.expanded()?2:-1)}}var Pw=30,ef=60,Zd=14,Qd=class n{visible=F(0);total=F(0);edges=F(0);cacheAt=F(null);texts=ng;destroyRef=c(Ze);zone=c(Tn);fps=oe(0);frameTimeMs=oe(0);fpsSamples=oe([]);sparklineCanvas=ve("sparkline");heapMb=oe(null);longTasks=oe(0);domNodes=oe(0);nowTick=oe(performance.now());expanded=oe(Mw());cacheAgeSec=G(()=>{let i=this.cacheAt();return i===null?null:Math.max(0,Math.floor((this.nowTick()-i)/1e3))});hasHeap=G(()=>this.heapMb()!==null);constructor(){let i=0,e=0,t=performance.now(),o=t,r=0,s=d=>{let l=d-t;if(t=d,i+=1,e+=l,d-o>=1e3){let u=(d-o)/1e3,g=Math.round(i/u);this.fps.set(g),this.frameTimeMs.set(Math.round(e/Math.max(i,1))),this.heapMb.set(Nw()),this.domNodes.set(document.querySelectorAll("*").length),this.nowTick.set(d),this.fpsSamples.update(y=>{let C=y.length>=Pw?y.slice(1):y.slice();return C.push(g),C}),i=0,e=0,o=d}r=requestAnimationFrame(s)};this.zone.runOutsideAngular(()=>{r=requestAnimationFrame(s)});let a=null;if(typeof PerformanceObserver<"u")try{a=new PerformanceObserver(d=>{this.longTasks.update(l=>l+d.getEntries().length)}),a.observe({type:"longtask",buffered:!0})}catch{}this.destroyRef.onDestroy(()=>{cancelAnimationFrame(r),a?.disconnect()}),Ie(()=>{let d=this.sparklineCanvas(),l=this.fpsSamples();d&&kw(d.nativeElement,l)})}setExpanded(i){this.expanded.set(i),Rw(i)}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=se({type:n,selectors:[["app-perf-hud"]],viewQuery:function(e,t){e&1&&ct(t.sparklineCanvas,Iw,5),e&2&&We()},inputs:{visible:[1,"visible"],total:[1,"total"],edges:[1,"edges"],cacheAt:[1,"cacheAt"]},decls:3,vars:2,consts:[["content",""],["sparkline",""],["styleClass","perf-hud","data-testid","perf-hud",3,"ngModelChange","ngModel","ariaLabel"],[1,"perf-hud__cell"],["aria-hidden","true",1,"perf-hud__sparkline"],["aria-hidden","true",1,"perf-hud__sep"]],template:function(e,t){e&1&&(m(0,"p-togglebutton",2),Se("ngModelChange",function(r){return t.setExpanded(r)}),Di(1,Ew,3,2,"ng-template",null,0,yf),v()),e&2&&A("ngModel",t.expanded())("ariaLabel",t.expanded()?t.texts.a11y.collapse:t.texts.a11y.expand)},dependencies:[Bi,Li,zi,Hi,Gi],styles:["[_nghost-%COMP%]{position:absolute;bottom:16px;left:16px;z-index:2;pointer-events:none}.perf-hud[_ngcontent-%COMP%]{pointer-events:auto;--p-togglebutton-padding: 0;--p-togglebutton-content-padding: .25rem .7rem;--p-togglebutton-border-radius: 999px;--p-togglebutton-content-border-radius: 999px;--p-togglebutton-gap: .4rem;--p-togglebutton-background: var(--sm-bg-content);--p-togglebutton-checked-background: var(--sm-bg-content);--p-togglebutton-hover-background: var(--sm-bg-content);--p-togglebutton-border-color: var(--sm-border);--p-togglebutton-checked-border-color: var(--sm-border);--p-togglebutton-content-checked-background: transparent;--p-togglebutton-color: var(--p-text-muted-color);--p-togglebutton-hover-color: var(--p-text-color);--p-togglebutton-checked-color: var(--p-text-muted-color);box-shadow:var(--sm-shadow-floating);font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;font-size:.7rem;font-weight:500;line-height:14px;opacity:.75;transition:opacity .15s ease,color .15s ease}.perf-hud[_ngcontent-%COMP%]:hover{opacity:1}[_nghost-%COMP%] .perf-hud .p-togglebutton-content{display:inline-flex;align-items:center;gap:.4rem}.perf-hud__cell[_ngcontent-%COMP%]{white-space:nowrap;font-variant-numeric:tabular-nums}.perf-hud__sep[_ngcontent-%COMP%]{opacity:.45}.perf-hud__sparkline[_ngcontent-%COMP%]{width:60px;height:14px;opacity:.6}"],changeDetection:0})},ig="sm.perf-hud.expanded";function Mw(){try{return localStorage.getItem(ig)==="1"}catch{return!1}}function Rw(n){try{localStorage.setItem(ig,n?"1":"0")}catch{}}function Nw(){let n=performance.memory;return n?Math.round(n.usedJSHeapSize/1024/1024):null}function kw(n,i){let e=window.devicePixelRatio||1,t=ef*e,o=Zd*e;(n.width!==t||n.height!==o)&&(n.width=t,n.height=o);let r=n.getContext("2d");if(!r||(r.setTransform(e,0,0,e,0,0),r.clearRect(0,0,ef,Zd),i.length<2))return;let s=Math.max(60,...i),a=ef/(i.length-1);r.beginPath();for(let d=0;d<i.length;d+=1){let l=d*a,u=Zd-i[d]/s*Zd;d===0?r.moveTo(l,u):r.lineTo(l,u)}r.strokeStyle=getComputedStyle(n).color,r.lineWidth=1,r.stroke()}function tf(n,i){var e,t=1;n==null&&(n=0),i==null&&(i=0);function o(){var r,s=e.length,a,d=0,l=0;for(r=0;r<s;++r)a=e[r],d+=a.x,l+=a.y;for(d=(d/s-n)*t,l=(l/s-i)*t,r=0;r<s;++r)a=e[r],a.x-=d,a.y-=l}return o.initialize=function(r){e=r},o.x=function(r){return arguments.length?(n=+r,o):n},o.y=function(r){return arguments.length?(i=+r,o):i},o.strength=function(r){return arguments.length?(t=+r,o):t},o}function og(n){let i=+this._x.call(null,n),e=+this._y.call(null,n);return rg(this.cover(i,e),i,e,n)}function rg(n,i,e,t){if(isNaN(i)||isNaN(e))return n;var o,r=n._root,s={data:t},a=n._x0,d=n._y0,l=n._x1,u=n._y1,g,y,C,E,b,w,I,P;if(!r)return n._root=s,n;for(;r.length;)if((b=i>=(g=(a+l)/2))?a=g:l=g,(w=e>=(y=(d+u)/2))?d=y:u=y,o=r,!(r=r[I=w<<1|b]))return o[I]=s,n;if(C=+n._x.call(null,r.data),E=+n._y.call(null,r.data),i===C&&e===E)return s.next=r,o?o[I]=s:n._root=s,n;do o=o?o[I]=new Array(4):n._root=new Array(4),(b=i>=(g=(a+l)/2))?a=g:l=g,(w=e>=(y=(d+u)/2))?d=y:u=y;while((I=w<<1|b)===(P=(E>=y)<<1|C>=g));return o[P]=r,o[I]=s,n}function sg(n){var i,e,t=n.length,o,r,s=new Array(t),a=new Array(t),d=1/0,l=1/0,u=-1/0,g=-1/0;for(e=0;e<t;++e)isNaN(o=+this._x.call(null,i=n[e]))||isNaN(r=+this._y.call(null,i))||(s[e]=o,a[e]=r,o<d&&(d=o),o>u&&(u=o),r<l&&(l=r),r>g&&(g=r));if(d>u||l>g)return this;for(this.cover(d,l).cover(u,g),e=0;e<t;++e)rg(this,s[e],a[e],n[e]);return this}function ag(n,i){if(isNaN(n=+n)||isNaN(i=+i))return this;var e=this._x0,t=this._y0,o=this._x1,r=this._y1;if(isNaN(e))o=(e=Math.floor(n))+1,r=(t=Math.floor(i))+1;else{for(var s=o-e||1,a=this._root,d,l;e>n||n>=o||t>i||i>=r;)switch(l=(i<t)<<1|n<e,d=new Array(4),d[l]=a,a=d,s*=2,l){case 0:o=e+s,r=t+s;break;case 1:e=o-s,r=t+s;break;case 2:o=e+s,t=r-s;break;case 3:e=o-s,t=r-s;break}this._root&&this._root.length&&(this._root=a)}return this._x0=e,this._y0=t,this._x1=o,this._y1=r,this}function cg(){var n=[];return this.visit(function(i){if(!i.length)do n.push(i.data);while(i=i.next)}),n}function dg(n){return arguments.length?this.cover(+n[0][0],+n[0][1]).cover(+n[1][0],+n[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function Te(n,i,e,t,o){this.node=n,this.x0=i,this.y0=e,this.x1=t,this.y1=o}function lg(n,i,e){var t,o=this._x0,r=this._y0,s,a,d,l,u=this._x1,g=this._y1,y=[],C=this._root,E,b;for(C&&y.push(new Te(C,o,r,u,g)),e==null?e=1/0:(o=n-e,r=i-e,u=n+e,g=i+e,e*=e);E=y.pop();)if(!(!(C=E.node)||(s=E.x0)>u||(a=E.y0)>g||(d=E.x1)<o||(l=E.y1)<r))if(C.length){var w=(s+d)/2,I=(a+l)/2;y.push(new Te(C[3],w,I,d,l),new Te(C[2],s,I,w,l),new Te(C[1],w,a,d,I),new Te(C[0],s,a,w,I)),(b=(i>=I)<<1|n>=w)&&(E=y[y.length-1],y[y.length-1]=y[y.length-1-b],y[y.length-1-b]=E)}else{var P=n-+this._x.call(null,C.data),L=i-+this._y.call(null,C.data),B=P*P+L*L;if(B<e){var H=Math.sqrt(e=B);o=n-H,r=i-H,u=n+H,g=i+H,t=C.data}}return t}function ug(n){if(isNaN(u=+this._x.call(null,n))||isNaN(g=+this._y.call(null,n)))return this;var i,e=this._root,t,o,r,s=this._x0,a=this._y0,d=this._x1,l=this._y1,u,g,y,C,E,b,w,I;if(!e)return this;if(e.length)for(;;){if((E=u>=(y=(s+d)/2))?s=y:d=y,(b=g>=(C=(a+l)/2))?a=C:l=C,i=e,!(e=e[w=b<<1|E]))return this;if(!e.length)break;(i[w+1&3]||i[w+2&3]||i[w+3&3])&&(t=i,I=w)}for(;e.data!==n;)if(o=e,!(e=e.next))return this;return(r=e.next)&&delete e.next,o?(r?o.next=r:delete o.next,this):i?(r?i[w]=r:delete i[w],(e=i[0]||i[1]||i[2]||i[3])&&e===(i[3]||i[2]||i[1]||i[0])&&!e.length&&(t?t[I]=e:this._root=e),this):(this._root=r,this)}function fg(n){for(var i=0,e=n.length;i<e;++i)this.remove(n[i]);return this}function hg(){return this._root}function gg(){var n=0;return this.visit(function(i){if(!i.length)do++n;while(i=i.next)}),n}function pg(n){var i=[],e,t=this._root,o,r,s,a,d;for(t&&i.push(new Te(t,this._x0,this._y0,this._x1,this._y1));e=i.pop();)if(!n(t=e.node,r=e.x0,s=e.y0,a=e.x1,d=e.y1)&&t.length){var l=(r+a)/2,u=(s+d)/2;(o=t[3])&&i.push(new Te(o,l,u,a,d)),(o=t[2])&&i.push(new Te(o,r,u,l,d)),(o=t[1])&&i.push(new Te(o,l,s,a,u)),(o=t[0])&&i.push(new Te(o,r,s,l,u))}return this}function _g(n){var i=[],e=[],t;for(this._root&&i.push(new Te(this._root,this._x0,this._y0,this._x1,this._y1));t=i.pop();){var o=t.node;if(o.length){var r,s=t.x0,a=t.y0,d=t.x1,l=t.y1,u=(s+d)/2,g=(a+l)/2;(r=o[0])&&i.push(new Te(r,s,a,u,g)),(r=o[1])&&i.push(new Te(r,u,a,d,g)),(r=o[2])&&i.push(new Te(r,s,g,u,l)),(r=o[3])&&i.push(new Te(r,u,g,d,l))}e.push(t)}for(;t=e.pop();)n(t.node,t.x0,t.y0,t.x1,t.y1);return this}function mg(n){return n[0]}function yg(n){return arguments.length?(this._x=n,this):this._x}function vg(n){return n[1]}function Cg(n){return arguments.length?(this._y=n,this):this._y}function Xt(n,i,e){var t=new nf(i??mg,e??vg,NaN,NaN,NaN,NaN);return n==null?t:t.addAll(n)}function nf(n,i,e,t,o,r){this._x=n,this._y=i,this._x0=e,this._y0=t,this._x1=o,this._y1=r,this._root=void 0}function xg(n){for(var i={data:n.data},e=i;n=n.next;)e=e.next={data:n.data};return i}var Fe=Xt.prototype=nf.prototype;Fe.copy=function(){var n=new nf(this._x,this._y,this._x0,this._y0,this._x1,this._y1),i=this._root,e,t;if(!i)return n;if(!i.length)return n._root=xg(i),n;for(e=[{source:i,target:n._root=new Array(4)}];i=e.pop();)for(var o=0;o<4;++o)(t=i.source[o])&&(t.length?e.push({source:t,target:i.target[o]=new Array(4)}):i.target[o]=xg(t));return n};Fe.add=og;Fe.addAll=sg;Fe.cover=ag;Fe.data=cg;Fe.extent=dg;Fe.find=lg;Fe.remove=ug;Fe.removeAll=fg;Fe.root=hg;Fe.size=gg;Fe.visit=pg;Fe.visitAfter=_g;Fe.x=yg;Fe.y=Cg;function xe(n){return function(){return n}}function Ke(n){return(n()-.5)*1e-6}function Ow(n){return n.x+n.vx}function Fw(n){return n.y+n.vy}function Jd(n){var i,e,t,o=1,r=1;typeof n!="function"&&(n=xe(n==null?1:+n));function s(){for(var l,u=i.length,g,y,C,E,b,w,I=0;I<r;++I)for(g=Xt(i,Ow,Fw).visitAfter(a),l=0;l<u;++l)y=i[l],b=e[y.index],w=b*b,C=y.x+y.vx,E=y.y+y.vy,g.visit(P);function P(L,B,H,W,le){var K=L.data,Ee=L.r,$=b+Ee;if(K){if(K.index>y.index){var Y=C-K.x-K.vx,Me=E-K.y-K.vy,ie=Y*Y+Me*Me;ie<$*$&&(Y===0&&(Y=Ke(t),ie+=Y*Y),Me===0&&(Me=Ke(t),ie+=Me*Me),ie=($-(ie=Math.sqrt(ie)))/ie*o,y.vx+=(Y*=ie)*($=(Ee*=Ee)/(w+Ee)),y.vy+=(Me*=ie)*$,K.vx-=Y*($=1-$),K.vy-=Me*$)}return}return B>C+$||W<C-$||H>E+$||le<E-$}}function a(l){if(l.data)return l.r=e[l.data.index];for(var u=l.r=0;u<4;++u)l[u]&&l[u].r>l.r&&(l.r=l[u].r)}function d(){if(i){var l,u=i.length,g;for(e=new Array(u),l=0;l<u;++l)g=i[l],e[g.index]=+n(g,l,i)}}return s.initialize=function(l,u){i=l,t=u,d()},s.iterations=function(l){return arguments.length?(r=+l,s):r},s.strength=function(l){return arguments.length?(o=+l,s):o},s.radius=function(l){return arguments.length?(n=typeof l=="function"?l:xe(+l),d(),s):n},s}function Aw(n){return n.index}function wg(n,i){var e=n.get(i);if(!e)throw new Error("node not found: "+i);return e}function el(n){var i=Aw,e=g,t,o=xe(30),r,s,a,d,l,u=1;n==null&&(n=[]);function g(w){return 1/Math.min(a[w.source.index],a[w.target.index])}function y(w){for(var I=0,P=n.length;I<u;++I)for(var L=0,B,H,W,le,K,Ee,$;L<P;++L)B=n[L],H=B.source,W=B.target,le=W.x+W.vx-H.x-H.vx||Ke(l),K=W.y+W.vy-H.y-H.vy||Ke(l),Ee=Math.sqrt(le*le+K*K),Ee=(Ee-r[L])/Ee*w*t[L],le*=Ee,K*=Ee,W.vx-=le*($=d[L]),W.vy-=K*$,H.vx+=le*($=1-$),H.vy+=K*$}function C(){if(s){var w,I=s.length,P=n.length,L=new Map(s.map((H,W)=>[i(H,W,s),H])),B;for(w=0,a=new Array(I);w<P;++w)B=n[w],B.index=w,typeof B.source!="object"&&(B.source=wg(L,B.source)),typeof B.target!="object"&&(B.target=wg(L,B.target)),a[B.source.index]=(a[B.source.index]||0)+1,a[B.target.index]=(a[B.target.index]||0)+1;for(w=0,d=new Array(P);w<P;++w)B=n[w],d[w]=a[B.source.index]/(a[B.source.index]+a[B.target.index]);t=new Array(P),E(),r=new Array(P),b()}}function E(){if(s)for(var w=0,I=n.length;w<I;++w)t[w]=+e(n[w],w,n)}function b(){if(s)for(var w=0,I=n.length;w<I;++w)r[w]=+o(n[w],w,n)}return y.initialize=function(w,I){s=w,l=I,C()},y.links=function(w){return arguments.length?(n=w,C(),y):n},y.id=function(w){return arguments.length?(i=w,y):i},y.iterations=function(w){return arguments.length?(u=+w,y):u},y.strength=function(w){return arguments.length?(e=typeof w=="function"?w:xe(+w),E(),y):e},y.distance=function(w){return arguments.length?(o=typeof w=="function"?w:xe(+w),b(),y):o},y}var Lw={value:()=>{}};function Ig(){for(var n=0,i=arguments.length,e={},t;n<i;++n){if(!(t=arguments[n]+"")||t in e||/[\s.]/.test(t))throw new Error("illegal type: "+t);e[t]=[]}return new tl(e)}function tl(n){this._=n}function zw(n,i){return n.trim().split(/^|\s+/).map(function(e){var t="",o=e.indexOf(".");if(o>=0&&(t=e.slice(o+1),e=e.slice(0,o)),e&&!i.hasOwnProperty(e))throw new Error("unknown type: "+e);return{type:e,name:t}})}tl.prototype=Ig.prototype={constructor:tl,on:function(n,i){var e=this._,t=zw(n+"",e),o,r=-1,s=t.length;if(arguments.length<2){for(;++r<s;)if((o=(n=t[r]).type)&&(o=Bw(e[o],n.name)))return o;return}if(i!=null&&typeof i!="function")throw new Error("invalid callback: "+i);for(;++r<s;)if(o=(n=t[r]).type)e[o]=bg(e[o],n.name,i);else if(i==null)for(o in e)e[o]=bg(e[o],n.name,null);return this},copy:function(){var n={},i=this._;for(var e in i)n[e]=i[e].slice();return new tl(n)},call:function(n,i){if((o=arguments.length-2)>0)for(var e=new Array(o),t=0,o,r;t<o;++t)e[t]=arguments[t+2];if(!this._.hasOwnProperty(n))throw new Error("unknown type: "+n);for(r=this._[n],t=0,o=r.length;t<o;++t)r[t].value.apply(i,e)},apply:function(n,i,e){if(!this._.hasOwnProperty(n))throw new Error("unknown type: "+n);for(var t=this._[n],o=0,r=t.length;o<r;++o)t[o].value.apply(i,e)}};function Bw(n,i){for(var e=0,t=n.length,o;e<t;++e)if((o=n[e]).name===i)return o.value}function bg(n,i,e){for(var t=0,o=n.length;t<o;++t)if(n[t].name===i){n[t]=Lw,n=n.slice(0,t).concat(n.slice(t+1));break}return e!=null&&n.push({name:i,value:e}),n}var of=Ig;var wn=0,vi=0,yi=0,Dg=1e3,nl,Ci,il=0,qt=0,ol=0,xi=typeof performance=="object"&&performance.now?performance:Date,Tg=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(n){setTimeout(n,17)};function af(){return qt||(Tg(Gw),qt=xi.now()+ol)}function Gw(){qt=0}function rf(){this._call=this._time=this._next=null}rf.prototype=rl.prototype={constructor:rf,restart:function(n,i,e){if(typeof n!="function")throw new TypeError("callback is not a function");e=(e==null?af():+e)+(i==null?0:+i),!this._next&&Ci!==this&&(Ci?Ci._next=this:nl=this,Ci=this),this._call=n,this._time=e,sf()},stop:function(){this._call&&(this._call=null,this._time=1/0,sf())}};function rl(n,i,e){var t=new rf;return t.restart(n,i,e),t}function Eg(){af(),++wn;for(var n=nl,i;n;)(i=qt-n._time)>=0&&n._call.call(void 0,i),n=n._next;--wn}function Sg(){qt=(il=xi.now())+ol,wn=vi=0;try{Eg()}finally{wn=0,jw(),qt=0}}function Hw(){var n=xi.now(),i=n-il;i>Dg&&(ol-=i,il=n)}function jw(){for(var n,i=nl,e,t=1/0;i;)i._call?(t>i._time&&(t=i._time),n=i,i=i._next):(e=i._next,i._next=null,i=n?n._next=e:nl=e);Ci=n,sf(t)}function sf(n){if(!wn){vi&&(vi=clearTimeout(vi));var i=n-qt;i>24?(n<1/0&&(vi=setTimeout(Sg,n-xi.now()-ol)),yi&&(yi=clearInterval(yi))):(yi||(il=xi.now(),yi=setInterval(Hw,Dg)),wn=1,Tg(Sg))}}function Pg(){let n=1;return()=>(n=(1664525*n+1013904223)%4294967296)/4294967296}function Mg(n){return n.x}function Rg(n){return n.y}var Vw=10,Uw=Math.PI*(3-Math.sqrt(5));function sl(n){var i,e=1,t=.001,o=1-Math.pow(t,1/300),r=0,s=.6,a=new Map,d=rl(g),l=of("tick","end"),u=Pg();n==null&&(n=[]);function g(){y(),l.call("tick",i),e<t&&(d.stop(),l.call("end",i))}function y(b){var w,I=n.length,P;b===void 0&&(b=1);for(var L=0;L<b;++L)for(e+=(r-e)*o,a.forEach(function(B){B(e)}),w=0;w<I;++w)P=n[w],P.fx==null?P.x+=P.vx*=s:(P.x=P.fx,P.vx=0),P.fy==null?P.y+=P.vy*=s:(P.y=P.fy,P.vy=0);return i}function C(){for(var b=0,w=n.length,I;b<w;++b){if(I=n[b],I.index=b,I.fx!=null&&(I.x=I.fx),I.fy!=null&&(I.y=I.fy),isNaN(I.x)||isNaN(I.y)){var P=Vw*Math.sqrt(.5+b),L=b*Uw;I.x=P*Math.cos(L),I.y=P*Math.sin(L)}(isNaN(I.vx)||isNaN(I.vy))&&(I.vx=I.vy=0)}}function E(b){return b.initialize&&b.initialize(n,u),b}return C(),i={tick:y,restart:function(){return d.restart(g),i},stop:function(){return d.stop(),i},nodes:function(b){return arguments.length?(n=b,C(),a.forEach(E),i):n},alpha:function(b){return arguments.length?(e=+b,i):e},alphaMin:function(b){return arguments.length?(t=+b,i):t},alphaDecay:function(b){return arguments.length?(o=+b,i):+o},alphaTarget:function(b){return arguments.length?(r=+b,i):r},velocityDecay:function(b){return arguments.length?(s=1-b,i):1-s},randomSource:function(b){return arguments.length?(u=b,a.forEach(E),i):u},force:function(b,w){return arguments.length>1?(w==null?a.delete(b):a.set(b,E(w)),i):a.get(b)},find:function(b,w,I){var P=0,L=n.length,B,H,W,le,K;for(I==null?I=1/0:I*=I,P=0;P<L;++P)le=n[P],B=b-le.x,H=w-le.y,W=B*B+H*H,W<I&&(K=le,I=W);return K},on:function(b,w){return arguments.length>1?(l.on(b,w),i):l.on(b)}}}function al(){var n,i,e,t,o=xe(-30),r,s=1,a=1/0,d=.81;function l(C){var E,b=n.length,w=Xt(n,Mg,Rg).visitAfter(g);for(t=C,E=0;E<b;++E)i=n[E],w.visit(y)}function u(){if(n){var C,E=n.length,b;for(r=new Array(E),C=0;C<E;++C)b=n[C],r[b.index]=+o(b,C,n)}}function g(C){var E=0,b,w,I=0,P,L,B;if(C.length){for(P=L=B=0;B<4;++B)(b=C[B])&&(w=Math.abs(b.value))&&(E+=b.value,I+=w,P+=w*b.x,L+=w*b.y);C.x=P/I,C.y=L/I}else{b=C,b.x=b.data.x,b.y=b.data.y;do E+=r[b.data.index];while(b=b.next)}C.value=E}function y(C,E,b,w){if(!C.value)return!0;var I=C.x-i.x,P=C.y-i.y,L=w-E,B=I*I+P*P;if(L*L/d<B)return B<a&&(I===0&&(I=Ke(e),B+=I*I),P===0&&(P=Ke(e),B+=P*P),B<s&&(B=Math.sqrt(s*B)),i.vx+=I*C.value*t/B,i.vy+=P*C.value*t/B),!0;if(C.length||B>=a)return;(C.data!==i||C.next)&&(I===0&&(I=Ke(e),B+=I*I),P===0&&(P=Ke(e),B+=P*P),B<s&&(B=Math.sqrt(s*B)));do C.data!==i&&(L=r[C.data.index]*t/B,i.vx+=I*L,i.vy+=P*L);while(C=C.next)}return l.initialize=function(C,E){n=C,e=E,u()},l.strength=function(C){return arguments.length?(o=typeof C=="function"?C:xe(+C),u(),l):o},l.distanceMin=function(C){return arguments.length?(s=C*C,l):Math.sqrt(s)},l.distanceMax=function(C){return arguments.length?(a=C*C,l):Math.sqrt(a)},l.theta=function(C){return arguments.length?(d=C*C,l):Math.sqrt(d)},l}function cl(n){var i=xe(.1),e,t,o;typeof n!="function"&&(n=xe(n==null?0:+n));function r(a){for(var d=0,l=e.length,u;d<l;++d)u=e[d],u.vx+=(o[d]-u.x)*t[d]*a}function s(){if(e){var a,d=e.length;for(t=new Array(d),o=new Array(d),a=0;a<d;++a)t[a]=isNaN(o[a]=+n(e[a],a,e))?0:+i(e[a],a,e)}}return r.initialize=function(a){e=a,s()},r.strength=function(a){return arguments.length?(i=typeof a=="function"?a:xe(+a),s(),r):i},r.x=function(a){return arguments.length?(n=typeof a=="function"?a:xe(+a),s(),r):n},r}function dl(n){var i=xe(.1),e,t,o;typeof n!="function"&&(n=xe(n==null?0:+n));function r(a){for(var d=0,l=e.length,u;d<l;++d)u=e[d],u.vy+=(o[d]-u.y)*t[d]*a}function s(){if(e){var a,d=e.length;for(t=new Array(d),o=new Array(d),a=0;a<d;++a)t[a]=isNaN(o[a]=+n(e[a],a,e))?0:+i(e[a],a,e)}}return r.initialize=function(a){e=a,s()},r.strength=function(a){return arguments.length?(i=typeof a=="function"?a:xe(+a),s(),r):i},r.y=function(a){return arguments.length?(n=typeof a=="function"?a:xe(+a),s(),r):n},r}var wi=260,cf=120;function Ww(n,i){let e=n.map(o=>o.path).sort(),t=i.map(o=>o.id).sort();return`${e.length}|${e.join(",")}|${t.length}|${t.join(",")}`}function Ng(){let n=null;return(i,e)=>{let t=new Set(i.map(y=>y.path)),o=new Map,r=e?.links??[];for(let y of r){if(!t.has(y.source)||!t.has(y.target)||y.source===y.target)continue;let C=qw(y.kind,y.source,y.target);o.has(C)||o.set(C,{id:C,from:y.source,to:y.target,kind:y.kind})}let s=[...o.values()],a=new Map;for(let y of i)a.set(y.path,y);let d=new Map;for(let y of e?.nodes??[])d.set(y.path,y);let l=Ww(i,s);if(n&&n.fingerprint===l)return{nodesByPath:a,apiNodesByPath:d,edges:n.edges,positions:n.positions,computedAt:n.computedAt};let u=$w(i,s),g=performance.now();return n={fingerprint:l,positions:u,edges:s,computedAt:g},{nodesByPath:a,apiNodesByPath:d,edges:s,positions:u,computedAt:g}}}function $w(n,i){let e=n.map(a=>({id:a.path})),t=i.map(a=>({source:a.from,target:a.to})),o=sl(e).force("link",el(t).id(a=>a.id).distance(90).strength(1)).force("charge",al().strength(-200)).force("center",tf(0,0)).force("x",cl(0).strength(.06)).force("y",dl(0).strength(.06)).force("collide",Jd(wi/2+12)).stop(),r=400;for(let a=0;a<r;a++)o.tick();let s=new Map;for(let a of e)s.set(a.id,{x:(a.x??0)-wi/2,y:(a.y??0)-cf/2});return s}function kg(n,i,e,t){let o=new Set(t),r=n.map(u=>{let g={id:u.path};if(o.has(u.path))return g;let y=e[u.path];if(!y)return g;let C=y.x+wi/2,E=y.y+cf/2;return g.x=C,g.y=E,g.fx=C,g.fy=E,g}),s=i.map(u=>({source:u.from,target:u.to})),a=sl(r).force("link",el(s).id(u=>u.id).distance(90).strength(1)).force("charge",al().strength(-200)).force("x",cl(0).strength(.06)).force("y",dl(0).strength(.06)).force("collide",Jd(wi/2+12)).stop(),d=200;for(let u=0;u<d;u++)a.tick();let l=new Map;for(let u of r)o.has(u.id)&&l.set(u.id,{x:(u.x??0)-wi/2,y:(u.y??0)-cf/2});return l}function Og(n,i,e){let t=n.edges.filter(a=>i.has(a.from)&&i.has(a.to)),o=new Map,r=new Map;for(let a of t)o.set(a.from,(o.get(a.from)??0)+1),r.set(a.to,(r.get(a.to)??0)+1);let s=[];for(let a of i){let d=n.nodesByPath.get(a);if(!d)continue;let l=n.apiNodesByPath.get(a),u=e[a],g=n.positions.get(a)??{x:0,y:0},y=u?{x:u.x,y:u.y}:g;s.push({id:a,path:a,view:d,kind:d.kind,position:y,stats:{linksIn:r.get(a)??0,linksOut:o.get(a)??0,bytesTotal:l?.bytes.total,tokensTotal:l?.tokens?.total,externalRefsCount:l?.externalRefsCount},summary:Xw(d)})}return{nodes:s,edges:t}}function Xw(n){let i={injectionDetected:!1,contentQuality:"clean"},e=(n.frontmatter.description??n.frontmatter.name??"").trim();return{kind:"note",confidence:.6,safety:i,whatItCovers:e||`${n.kind} entry`,topics:[],keyFacts:[]}}function qw(n,i,e){let[t,o]=[i,e].sort();return`${n}:${t}::${o}`}var Yw=["canvasWrap"],zg=(n,i)=>i.id;function Kw(n,i){if(n&1&&(m(0,"div",5),U(1,"span",8),m(2,"p",9),T(3),v()()),n&2){let e=S();h(3),N(e.texts.loading)}}function Zw(n,i){if(n&1&&(m(0,"div",6),U(1,"span",10),m(2,"p",9),T(3),v(),m(4,"p",11),T(5),v()()),n&2){let e=S();h(3),N(e.texts.errorTitle),h(2),N(e.error())}}function Qw(n,i){if(n&1&&(m(0,"div",7),U(1,"span",12),m(2,"p",9),T(3),v(),m(4,"p",11),T(5),v()()),n&2){let e=S();h(3),N(e.texts.emptyTitle),h(2),N(e.texts.emptyDesc)}}function Jw(n,i){if(n&1&&(m(0,"f-connection",33),U(1,"f-connection-marker-arrow",34),v()),n&2){let e=i.$implicit,t=S(2);tt("f-conn--"+e.kind),$e("f-conn--highlighted",t.isEdgeHighlighted(e))("f-conn--dimmed",t.isEdgeDimmed(e)),A("fOutputId",e.from+"-out")("fInputId",e.to+"-in")("fType",t.connectionType)("fBehavior",t.connectionBehavior)("fOffset",4)("fReassignDisabled",!0)("fSelectionDisabled",!0),h(),A("type",t.markerEnd)}}function eb(n,i){if(n&1){let e=Et();Ti(0,19),m(1,"div",36),Se("fNodePositionChange",function(o){let r=ue(e).$implicit,s=S(3);return fe(s.onNodePositionChange(r.id,o))})("pointerdown",function(o){ue(e);let r=S(3);return fe(r.onNodePointerDown(o))})("click",function(o){let r=ue(e).$implicit,s=S(3);return fe(s.selectNode(r,o))})("dblclick",function(){let o=ue(e).$implicit,r=S(3);return fe(r.openNode(o))}),U(2,"div",37),m(3,"sm-node-card",38),Se("expandedChange",function(o){let r=ue(e).$implicit,s=S(3);return fe(s.setExpanded(r.id,o))}),v(),U(4,"div",39),v(),Ei()}if(n&2){let e=i.$implicit,t=S(3);h(),A("fNodeId",e.id)("fNodePosition",e.position),te("data-testid","graph-node-"+e.id),h(),A("fInputId",e.id+"-in")("fInputConnectableSide",t.inputSide),h(),A("node",e.view)("stats",e.stats)("summary",e.summary)("selected",t.isSelected(e.id))("highlighted",t.isHighlighted(e.id))("dimmed",t.isDimmed(e.id))("expanded",t.isExpanded(e.id)),h(),A("fOutputId",e.id+"-out")("fOutputConnectableSide",t.outputSide)}}function tb(n,i){if(n&1&&Di(0,eb,5,14,"ng-container",35),n&2){let e=S(2);A("fVirtualForOf",e.graph().nodes)}}function nb(n,i){if(n&1){let e=Et();m(0,"div",36),Se("fNodePositionChange",function(o){let r=ue(e).$implicit,s=S(3);return fe(s.onNodePositionChange(r.id,o))})("pointerdown",function(o){ue(e);let r=S(3);return fe(r.onNodePointerDown(o))})("click",function(o){let r=ue(e).$implicit,s=S(3);return fe(s.selectNode(r,o))})("dblclick",function(){let o=ue(e).$implicit,r=S(3);return fe(r.openNode(o))}),U(1,"div",37),m(2,"sm-node-card",38),Se("expandedChange",function(o){let r=ue(e).$implicit,s=S(3);return fe(s.setExpanded(r.id,o))}),v(),U(3,"div",39),v()}if(n&2){let e=i.$implicit,t=S(3);A("fNodeId",e.id)("fNodePosition",e.position),te("data-testid","graph-node-"+e.id),h(),A("fInputId",e.id+"-in")("fInputConnectableSide",t.inputSide),h(),A("node",e.view)("stats",e.stats)("summary",e.summary)("selected",t.isSelected(e.id))("highlighted",t.isHighlighted(e.id))("dimmed",t.isDimmed(e.id))("expanded",t.isExpanded(e.id)),h(),A("fOutputId",e.id+"-out")("fOutputConnectableSide",t.outputSide)}}function ib(n,i){if(n&1&&(Ti(0,19),me(1,nb,4,14,"div",40,zg),Ei()),n&2){let e=S(2);h(),ye(e.graph().nodes)}}function ob(n,i){if(n&1&&U(0,"app-perf-hud",20),n&2){let e=S(2);A("visible",e.visibleCount())("total",e.totalCount())("edges",e.edgeCount())("cacheAt",e.layoutComputedAt())}}function rb(n,i){if(n&1){let e=Et();m(0,"div",13,0),Se("mousedown",function(o){ue(e);let r=S();return fe(r.onCanvasMouseDown(o))})("click",function(o){ue(e);let r=S();return fe(r.onCanvasClick(o))}),m(2,"f-flow",14),Se("fLoaded",function(){ue(e);let o=S();return fe(o.onLoaded())}),m(3,"f-background"),U(4,"f-rect-pattern"),v(),U(5,"f-line-alignment",15),m(6,"f-canvas",16),Se("fCanvasChange",function(o){ue(e);let r=S();return fe(r.onCanvasChange(o))}),Ti(7,17),me(8,Jw,2,14,"f-connection",18,zg),Ei(),k(10,tb,1,1,"ng-container",19)(11,ib,3,0,"ng-container",19),v(),U(12,"f-minimap"),v(),U(13,"app-kind-palette"),k(14,ob,1,4,"app-perf-hud",20),m(15,"div",21)(16,"p-button",22),Se("onClick",function(){ue(e);let o=S();return fe(o.zoomIn())}),v(),m(17,"p-button",23),Se("onClick",function(){ue(e);let o=S();return fe(o.zoomOut())}),v(),m(18,"p-button",24),Se("onClick",function(){ue(e);let o=S();return fe(o.fitToScreen())}),v(),U(19,"span",25),m(20,"p-button",26),Se("onClick",function(){ue(e);let o=S();return fe(o.resetLayout())}),v()()(),m(21,"aside",27)(22,"span",28),U(23,"span",29),T(24),v(),m(25,"span",28),U(26,"span",30),T(27),v(),m(28,"span",28),U(29,"span",31),T(30),v(),m(31,"span",28),U(32,"span",32),T(33),v()()}if(n&2){let e=S();h(2),A("fCache",e.perf.cache),h(3),A("fAlignThreshold",20),h(),A("position",e.viewportPosition())("scale",e.viewportScale())("fZoomStep",.06)("fZoomDblClickStep",.35)("debounceTime",150),h(2),ye(e.graph().edges),h(2),O(e.perf.virtualization?10:11),h(4),O(e.perfHud?14:-1),h(),te("aria-label",e.texts.a11y.toolbar),h(),A("ariaLabel",e.texts.toolbar.zoomIn)("pTooltip",e.texts.toolbar.zoomIn)("text",!0)("rounded",!0)("disabled",!e.canZoomIn()),h(),A("ariaLabel",e.texts.toolbar.zoomOut)("pTooltip",e.texts.toolbar.zoomOut)("text",!0)("rounded",!0)("disabled",!e.canZoomOut()),h(),A("ariaLabel",e.texts.toolbar.fitToScreen)("pTooltip",e.texts.toolbar.fitToScreen)("text",!0)("rounded",!0),h(2),A("ariaLabel",e.texts.toolbar.resetLayoutLabel)("pTooltip",e.texts.toolbar.resetLayoutTooltip)("text",!0)("rounded",!0),h(),te("aria-label",e.texts.a11y.edgeLegend),h(),A("pTooltip",e.texts.legendTooltip.invokes),h(2),dt(" ",e.texts.legend.invokes),h(),A("pTooltip",e.texts.legendTooltip.references),h(2),dt(" ",e.texts.legend.references),h(),A("pTooltip",e.texts.legendTooltip.mentions),h(2),dt(" ",e.texts.legend.mentions),h(),A("pTooltip",e.texts.legendTooltip.supersedes),h(2),dt(" ",e.texts.legend.supersedes)}}var sb=.1,ab=4,Fg=.2,Bg="sm.graph.viewport",Gg="sm.graph.node-positions",Hg="sm.graph.node-expanded",Ag=class n{loader=c(Oi);filters=c(Ai);router=c(Cf);canvas=ve(_i);zoom=ve(mi);canvasWrap=ve("canvasWrap");outputSide=R.BOTTOM;inputSide=R.TOP;connectionType=yt.SEGMENT;connectionBehavior=vt.FIXED;markerEnd=ne.END_ALL_STATES;perf=Qu.graph.perf;perfHud=Qu.graph.perfHud;pointerDownAt=null;savedViewport=cb();hasCompletedInitialLayout=!1;viewportPosition=oe(this.savedViewport?{x:this.savedViewport.x,y:this.savedViewport.y}:{x:0,y:0});viewportScale=oe(this.savedViewport?.scale??1);canZoomIn=G(()=>this.viewportScale()<ab-1e-6);canZoomOut=G(()=>this.viewportScale()>sb+1e-6);texts=Zu;middlePanOrigin=null;nodePositions=oe(db());expandedNodeIds=oe(lb());loading=this.loader.loading;error=this.loader.error;visibleNodes=G(()=>this.filters.apply(this.loader.nodes()));computeLayout=Ng();fullLayout=G(()=>this.computeLayout(this.loader.nodes(),this.loader.scan()));graph=G(()=>{let i=new Set(this.visibleNodes().map(e=>e.path));return Og(this.fullLayout(),i,this.nodePositions())});hasData=G(()=>this.graph().nodes.length>0);visibleCount=G(()=>this.graph().nodes.length);totalCount=G(()=>this.loader.nodes().length);edgeCount=G(()=>this.graph().edges.length);layoutComputedAt=G(()=>this.fullLayout().computedAt);selectedNodeId=oe(null);adjacency=G(()=>{let i=new Map;for(let e of this.graph().edges)i.has(e.from)||i.set(e.from,new Set),i.has(e.to)||i.set(e.to,new Set),i.get(e.from).add(e.to),i.get(e.to).add(e.from);return i});selectionGuard=Ie(()=>{let i=this.selectedNodeId();if(i===null)return;this.graph().nodes.some(t=>t.id===i)||this.selectedNodeId.set(null)});pathsFingerprint=G(()=>this.loader.nodes().map(i=>i.path).sort().join("|"));lastPathsFingerprint=null;constructor(){Ie(()=>{let i=this.visibleNodes();this.hasCompletedInitialLayout||i.length!==0&&queueMicrotask(()=>{this.hasCompletedInitialLayout=!0,this.savedViewport||this.canvas()?.fitToScreen({x:40,y:40},!1)})}),Ie(()=>{let i=this.pathsFingerprint();if(!this.hasCompletedInitialLayout){this.lastPathsFingerprint=i;return}this.lastPathsFingerprint!==i&&(this.lastPathsFingerprint=i,queueMicrotask(()=>this.canvas()?.fitToScreen({x:40,y:40},!0)))}),Ie(()=>{let i=new Set(this.loader.nodes().map(r=>r.path));if(i.size===0)return;let e=this.expandedNodeIds();if(e.size===0)return;let t=!1,o=new Set;for(let r of e)i.has(r)?o.add(r):t=!0;t&&(this.expandedNodeIds.set(o),df(o))}),Ie(()=>{let i=this.loader.nodes();if(i.length===0)return;let e=this.nodePositions(),t=new Set(i.map(a=>a.path)),o=!1,r=J({},e);for(let a of Object.keys(r))t.has(a)||(delete r[a],o=!0);let s=[];for(let a of t)a in r||s.push(a);if(s.length>0){let a=this.fullLayout();if(Object.keys(r).length===0)for(let d of s){let l=a.positions.get(d);l&&(r[d]={x:l.x,y:l.y})}else{let d=kg(i,a.edges,r,s);for(let l of s){let u=d.get(l);u&&(r[l]=u)}}o=!0}o&&(this.nodePositions.set(r),Lg(r))})}ngOnInit(){this.loader.nodes().length===0&&!this.loader.loading()&&this.loader.load()}onLoaded(){}onCanvasChange(i){if(this.viewportPosition.set({x:i.position.x,y:i.position.y}),this.viewportScale.set(i.scale),!this.hasCompletedInitialLayout)return;let e={x:i.position.x,y:i.position.y,scale:i.scale};try{localStorage.setItem(Bg,JSON.stringify(e))}catch{}}onNodePositionChange(i,e){this.dragBuffer||(this.dragBuffer=J({},this.nodePositions())),this.dragBuffer[i]={x:e.x,y:e.y},this.nodeDragInProgress=!0}zoomIn(){this.zoom()?.setZoom(this.getViewportCenter(),Fg,ft.ZOOM_IN,!0)}zoomOut(){this.zoom()?.setZoom(this.getViewportCenter(),Fg,ft.ZOOM_OUT,!0)}fitToScreen(){this.canvas()?.fitToScreen({x:40,y:40},!0)}resetLayout(){window.confirm(Zu.resetLayoutConfirm)&&(this.nodePositions.set({}),this.expandedNodeIds.set(new Set),df(new Set),queueMicrotask(()=>this.canvas()?.fitToScreen({x:40,y:40},!0)))}getViewportCenter(){let i=this.canvasWrap()?.nativeElement;if(!i)return{x:0,y:0};let e=i.getBoundingClientRect();return{x:e.width/2,y:e.height/2}}onCanvasMouseDown(i){if(i.button!==1)return;i.preventDefault();let e=this.canvas()?.getPosition()??{x:0,y:0};this.middlePanOrigin={mouseX:i.clientX,mouseY:i.clientY,canvasX:e.x,canvasY:e.y},document.addEventListener("mousemove",this.onMiddlePanMove),document.addEventListener("mouseup",this.onMiddlePanEnd)}middlePanRafId=null;pendingPanPosition=null;onMiddlePanMove=i=>{this.middlePanOrigin&&(this.pendingPanPosition={x:this.middlePanOrigin.canvasX+(i.clientX-this.middlePanOrigin.mouseX),y:this.middlePanOrigin.canvasY+(i.clientY-this.middlePanOrigin.mouseY)},this.middlePanRafId===null&&(this.middlePanRafId=requestAnimationFrame(()=>{this.middlePanRafId=null;let e=this.canvas();!e||!this.pendingPanPosition||(e.setPosition(this.pendingPanPosition),e.redraw())})))};onMiddlePanEnd=()=>{this.middlePanRafId!==null&&(cancelAnimationFrame(this.middlePanRafId),this.middlePanRafId=null),this.pendingPanPosition=null,this.middlePanOrigin=null,document.removeEventListener("mousemove",this.onMiddlePanMove),document.removeEventListener("mouseup",this.onMiddlePanEnd),this.canvas()?.emitCanvasChangeEvent()};ngOnDestroy(){this.onMiddlePanEnd()}onNodePointerDown(i){this.pointerDownAt={x:i.clientX,y:i.clientY},document.addEventListener("mouseup",this.onNodeMouseUp,{once:!0})}nodeDragInProgress=!1;dragBuffer=null;onNodeMouseUp=()=>{queueMicrotask(()=>{if(!this.nodeDragInProgress){this.dragBuffer=null;return}this.nodeDragInProgress=!1,this.dragBuffer&&(this.nodePositions.set(this.dragBuffer),this.dragBuffer=null),Lg(this.nodePositions())})};selectNode(i,e){this.isClickWithoutDrag(e)&&this.selectedNodeId.set(i.id)}openNode(i){this.router.navigate(["/inspector"],{queryParams:{path:i.path}})}onCanvasClick(i){let e=i.target;e?.closest(".sm-gnode")||e?.closest(".graph__toolbar")||e?.closest(".perf-hud")||e?.closest(".kind-palette")||this.selectedNodeId.set(null)}isSelected(i){return this.selectedNodeId()===i}isHighlighted(i){let e=this.selectedNodeId();return e===null||e===i?!1:this.adjacency().get(e)?.has(i)??!1}isDimmed(i){let e=this.selectedNodeId();return e===null||e===i?!1:!(this.adjacency().get(e)?.has(i)??!1)}isExpanded(i){return this.expandedNodeIds().has(i)}setExpanded(i,e){let t=this.expandedNodeIds();if(t.has(i)===e)return;let o=new Set(t);e?o.add(i):o.delete(i),this.expandedNodeIds.set(o),df(o)}isEdgeHighlighted(i){let e=this.selectedNodeId();return e!==null&&(i.from===e||i.to===e)}isEdgeDimmed(i){let e=this.selectedNodeId();return e===null?!1:i.from!==e&&i.to!==e}isClickWithoutDrag(i){let e=this.pointerDownAt;if(this.pointerDownAt=null,!e)return!0;let t=i.clientX-e.x,o=i.clientY-e.y;return Math.hypot(t,o)<=4}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=se({type:n,selectors:[["app-graph-view"]],viewQuery:function(e,t){e&1&&ct(t.canvas,_i,5)(t.zoom,mi,5)(t.canvasWrap,Yw,5),e&2&&We(3)},decls:24,vars:9,consts:[["canvasWrap",""],["data-testid","graph-view",1,"graph"],[1,"graph__header"],[1,"graph__sub"],[3,"showKinds"],["data-testid","graph-loading",1,"empty-state"],["data-testid","graph-error",1,"empty-state"],["data-testid","graph-empty",1,"empty-state"],[1,"empty-state__icon","pi","pi-spin","pi-spinner"],[1,"empty-state__title"],[1,"empty-state__icon","pi","pi-exclamation-circle",2,"color","var(--sm-severity-error)","opacity","1"],[1,"empty-state__desc"],[1,"empty-state__icon","pi","pi-filter-slash"],["data-testid","graph-canvas-wrap",1,"graph__canvas-wrap",3,"mousedown","click"],["fDraggable","",3,"fLoaded","fCache"],[3,"fAlignThreshold"],["fZoom","",3,"fCanvasChange","position","scale","fZoomStep","fZoomDblClickStep","debounceTime"],["ngProjectAs","[fConnections]",5,["","fConnections",""]],[3,"fOutputId","fInputId","fType","fBehavior","fOffset","fReassignDisabled","fSelectionDisabled","class","f-conn--highlighted","f-conn--dimmed"],["ngProjectAs","[fNodes]",5,["","fNodes",""]],[3,"visible","total","edges","cacheAt"],["role","toolbar","data-testid","graph-toolbar",1,"graph__toolbar"],["icon","pi pi-search-plus","severity","secondary","size","small","data-testid","graph-zoom-in",3,"onClick","ariaLabel","pTooltip","text","rounded","disabled"],["icon","pi pi-search-minus","severity","secondary","size","small","data-testid","graph-zoom-out",3,"onClick","ariaLabel","pTooltip","text","rounded","disabled"],["icon","pi pi-stop","severity","secondary","size","small","data-testid","graph-fit-to-screen",3,"onClick","ariaLabel","pTooltip","text","rounded"],["aria-hidden","true",1,"graph__toolbar-sep"],["icon","pi pi-refresh","severity","secondary","size","small","data-testid","graph-reset-layout",3,"onClick","ariaLabel","pTooltip","text","rounded"],["data-testid","graph-legend",1,"graph__legend"],[3,"pTooltip"],[1,"swatch","swatch--invokes"],[1,"swatch","swatch--references"],[1,"swatch","swatch--mentions"],[1,"swatch","swatch--supersedes"],[3,"fOutputId","fInputId","fType","fBehavior","fOffset","fReassignDisabled","fSelectionDisabled"],[3,"type"],["ngProjectAs","[fNodes]",5,["","fNodes",""],4,"fVirtualFor","fVirtualForOf"],["fNode","","fDragHandle","",1,"sm-gnode-host",3,"fNodePositionChange","pointerdown","click","dblclick","fNodeId","fNodePosition"],["fNodeInput","",1,"sm-gnode__connector","sm-gnode__connector--in",3,"fInputId","fInputConnectableSide"],[3,"expandedChange","node","stats","summary","selected","highlighted","dimmed","expanded"],["fNodeOutput","",1,"sm-gnode__connector","sm-gnode__connector--out",3,"fOutputId","fOutputConnectableSide"],["fNode","","fDragHandle","",1,"sm-gnode-host",3,"fNodeId","fNodePosition"]],template:function(e,t){e&1&&(m(0,"section",1)(1,"header",2)(2,"div")(3,"h2"),T(4),v(),m(5,"p",3),T(6),m(7,"code"),T(8),v(),T(9,", "),m(10,"code"),T(11),v(),T(12,", "),m(13,"code"),T(14),v(),T(15,", "),m(16,"code"),T(17),v(),T(18),v()()(),U(19,"app-filter-bar",4),k(20,Kw,4,1,"div",5)(21,Zw,6,2,"div",6)(22,Qw,6,2,"div",7)(23,rb,34,37),v()),e&2&&(h(4),N(t.texts.title),h(2),dt(" ",t.texts.subtitlePrefix),h(2),N(t.texts.legend.invokes),h(3),N(t.texts.legend.references),h(3),N(t.texts.legend.mentions),h(3),N(t.texts.legend.supersedes),h(),dt("",t.texts.subtitleSuffix," "),h(),A("showKinds",!1),h(),O(t.loading()&&!t.hasData()?20:t.error()&&!t.hasData()?21:t.hasData()?23:22))},dependencies:[bf,Zh,qh,_i,Uh,Vh,mi,ah,Wh,Dh,Ph,$h,Xh,Wd,Sh,Yh,Gh,Xd,Kd,Qd,wf,xf,Jt,Qt],styles:["[_nghost-%COMP%]{display:block;height:100%}.graph[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1rem;height:100%}.graph__header[_ngcontent-%COMP%]{display:flex;justify-content:space-between;align-items:flex-start;gap:1rem}.graph__header[_ngcontent-%COMP%] h2[_ngcontent-%COMP%]{margin:0;font-size:1.25rem;font-weight:600}.graph__sub[_ngcontent-%COMP%]{margin:.25rem 0 0;color:var(--p-text-muted-color);font-size:.9rem}.graph__sub[_ngcontent-%COMP%] code[_ngcontent-%COMP%]{background:var(--sm-bg-hover);padding:.05rem .3rem;border-radius:.25rem;font-size:.8rem}.graph__hint[_ngcontent-%COMP%]{padding:2rem;text-align:center;color:var(--p-text-muted-color)}.graph__hint--error[_ngcontent-%COMP%]{color:var(--sm-severity-error)}.graph__canvas-wrap[_ngcontent-%COMP%]{position:relative;flex:1;min-height:0;border:1px solid var(--sm-border);border-radius:.75rem;background:var(--sm-bg-content);overflow:hidden;--ff-connection-drag-handle-stroke: transparent;--ff-connector-background-color: transparent;--ff-connector-border-color: transparent;--ff-connector-connected-color: transparent;--ff-connector-node-ring-color: transparent;--ff-canvas-background-color: transparent}.graph__canvas-wrap[_ngcontent-%COMP%] f-flow[_ngcontent-%COMP%]{width:100%;height:100%}.graph__toolbar[_ngcontent-%COMP%]{position:absolute;bottom:16px;left:50%;transform:translate(-50%);display:flex;align-items:center;gap:2px;padding:4px;background:var(--sm-bg-content);border:1px solid var(--sm-border);border-radius:999px;box-shadow:var(--sm-shadow-floating);z-index:2;pointer-events:auto}.graph__toolbar-sep[_ngcontent-%COMP%]{width:1px;height:18px;margin:0 2px;background:var(--sm-border);flex-shrink:0}.graph__legend[_ngcontent-%COMP%]{display:flex;gap:1.5rem;font-size:.85rem;color:var(--p-text-muted-color)}.graph__legend[_ngcontent-%COMP%] .swatch[_ngcontent-%COMP%]{display:inline-block;width:18px;height:3px;vertical-align:middle;margin-right:.4rem;border-radius:2px}.swatch--invokes[_ngcontent-%COMP%]{background:var(--sm-edge-invokes)}.swatch--references[_ngcontent-%COMP%]{background:var(--sm-edge-references)}.swatch--mentions[_ngcontent-%COMP%]{background:var(--sm-edge-mentions)}.swatch--supersedes[_ngcontent-%COMP%]{background:var(--sm-edge-supersedes)}.sm-gnode-host[_ngcontent-%COMP%]{position:relative;display:inline-block;cursor:pointer;--ff-node-width: auto;--ff-node-min-height: 0;--ff-node-padding: 0;--ff-node-background-color: transparent;--ff-node-border-color: transparent;--ff-node-border-color-selected: transparent;--ff-node-border-radius: 0;--ff-node-shadow: none;--ff-node-shadow-selected: none}.sm-gnode__connector[_ngcontent-%COMP%]{position:absolute;pointer-events:none}.sm-gnode__connector--out[_ngcontent-%COMP%]{bottom:calc(var(--ff-connector-size) / -2);left:50%;transform:translate(-50%)}.sm-gnode__connector--in[_ngcontent-%COMP%]{top:calc(var(--ff-connector-size) / -2);left:50%;transform:translate(-50%)}.f-conn--invokes[_ngcontent-%COMP%]{--ff-connection-color: var(--sm-edge-invokes);--ff-connection-width: 2.5px;--ff-marker-color: var(--sm-edge-invokes)}.f-conn--references[_ngcontent-%COMP%]{--ff-connection-color: var(--sm-edge-references);--ff-connection-width: 2px;--ff-marker-color: var(--sm-edge-references)}.f-conn--mentions[_ngcontent-%COMP%]{--ff-connection-color: var(--sm-edge-mentions);--ff-connection-width: 1.5px;--ff-marker-color: var(--sm-edge-mentions)}.f-conn--supersedes[_ngcontent-%COMP%]{--ff-connection-color: var(--sm-edge-supersedes);--ff-connection-width: 2px;--ff-marker-color: var(--sm-edge-supersedes)}.graph__canvas-wrap[_ngcontent-%COMP%] .f-conn--supersedes .f-connection-path{stroke-dasharray:8 4}.f-conn--highlighted[_ngcontent-%COMP%]{--ff-connection-width: 3px}.f-conn--dimmed[_ngcontent-%COMP%]{opacity:.15}"],changeDetection:0})};function cb(){let n=null;try{n=localStorage.getItem(Bg)}catch{return null}if(!n)return null;let i;try{i=JSON.parse(n)}catch{return null}return fb(i)?i:null}function db(){let n=null;try{n=localStorage.getItem(Gg)}catch{return{}}if(!n)return{};let i;try{i=JSON.parse(n)}catch{return{}}if(typeof i!="object"||i===null)return{};let e={};for(let[t,o]of Object.entries(i))ub(o)&&(e[t]={x:o.x,y:o.y});return e}function Lg(n){try{localStorage.setItem(Gg,JSON.stringify(n))}catch{}}function lb(){let n=null;try{n=localStorage.getItem(Hg)}catch{return new Set}if(!n)return new Set;let i;try{i=JSON.parse(n)}catch{return new Set}if(!Array.isArray(i))return new Set;let e=new Set;for(let t of i)typeof t=="string"&&t.length>0&&e.add(t);return e}function df(n){try{localStorage.setItem(Hg,JSON.stringify([...n]))}catch{}}function ub(n){if(typeof n!="object"||n===null)return!1;let i=n;return typeof i.x=="number"&&typeof i.y=="number"&&Number.isFinite(i.x)&&Number.isFinite(i.y)}function fb(n){if(typeof n!="object"||n===null)return!1;let i=n;return typeof i.x=="number"&&typeof i.y=="number"&&typeof i.scale=="number"&&Number.isFinite(i.x)&&Number.isFinite(i.y)&&Number.isFinite(i.scale)&&i.scale>0}export{Ag as GraphView};
|