@signalwire/cfb 0.0.15-dev.202602041255.60cbbfe.0 → 0.0.15
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/main.js +4 -4
- package/dist/style.css +1 -1
- package/package.json +3 -3
package/dist/main.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
(function(go,ys){typeof exports=="object"&&typeof module<"u"?ys(exports):typeof define=="function"&&define.amd?define(["exports"],ys):(go=typeof globalThis<"u"?globalThis:go||self,ys(go.CFB={}))})(this,function(go){"use strict";/**
|
|
2
|
-
* Visual Builder v0.0.14 [
|
|
2
|
+
* Visual Builder v0.0.14 [14ac6c2] (https://signalwire.com)
|
|
3
3
|
* Copyright 2018-2026 SignalWire.
|
|
4
4
|
*/
|
|
5
5
|
function ys(e,t){for(var r=0;r<t.length;r++){const s=t[r];if(typeof s!="string"&&!Array.isArray(s)){for(const i in s)if(i!=="default"&&!(i in e)){const a=Object.getOwnPropertyDescriptor(s,i);a&&Object.defineProperty(e,i,a.get?a:{enumerable:!0,get:()=>s[i]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}function Hi(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var lc={exports:{}},vs={},ac={exports:{}},Te={};/**
|
|
@@ -57,14 +57,14 @@ Error generating stack: `+y.message+`
|
|
|
57
57
|
*
|
|
58
58
|
* This source code is licensed under the MIT license found in the
|
|
59
59
|
* LICENSE file in the root directory of this source tree.
|
|
60
|
-
*/var up;function Qv(){if(up)return _c;up=1;var e=xs(),t=Xv();function r(p,m){return p===m&&(p!==0||1/p===1/m)||p!==p&&m!==m}var s=typeof Object.is=="function"?Object.is:r,i=t.useSyncExternalStore,a=e.useRef,c=e.useEffect,u=e.useMemo,f=e.useDebugValue;return _c.useSyncExternalStoreWithSelector=function(p,m,E,v,x){var _=a(null);if(_.current===null){var w={hasValue:!1,value:null};_.current=w}else w=_.current;_=u(function(){function N(L){if(!O){if(O=!0,D=L,L=v(L),x!==void 0&&w.hasValue){var F=w.value;if(x(F,L))return T=F}return T=L}if(F=T,s(D,L))return F;var K=v(L);return x!==void 0&&x(F,K)?F:(D=L,T=K)}var O=!1,D,T,A=E===void 0?null:E;return[function(){return N(m())},A===null?void 0:function(){return N(A())}]},[m,E,v,x]);var S=i(p,_[0],_[1]);return c(function(){w.hasValue=!0,w.value=S},[S]),f(S),S},_c}var dp;function qv(){return dp||(dp=1,Sc.exports=Qv()),Sc.exports}var Zv=qv();const fp=Hi(Zv),Jv={},pp=e=>{let t;const r=new Set,s=(f,p)=>{const m=typeof f=="function"?f(t):f;if(!Object.is(m,t)){const E=t;t=p??(typeof m!="object"||m===null)?m:Object.assign({},t,m),r.forEach(v=>v(t,E))}},i=()=>t,u={setState:s,getState:i,subscribe:f=>(r.add(f),()=>r.delete(f)),destroy:()=>{(Jv?"staging":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),r.clear()}};return t=e(s,i,u),u},hp=e=>e?pp(e):pp,{useDebugValue:ex}=te,{useSyncExternalStoreWithSelector:tx}=fp;function mp(e,t=e.getState,r){const s=tx(e.subscribe,e.getState,e.getServerState||e.getState,t,r);return ex(s),s}const gp=(e,t)=>{const r=hp(e),s=(i,a=t)=>mp(r,i,a);return Object.assign(s,r),s},nx=(e,t)=>e?gp(e,t):gp;function gt(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[s,i]of e)if(!Object.is(i,t.get(s)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const s of e)if(!t.has(s))return!1;return!0}const r=Object.keys(e);if(r.length!==Object.keys(t).length)return!1;for(let s=0;s<r.length;s++)if(!Object.prototype.hasOwnProperty.call(t,r[s])||!Object.is(e[r[s]],t[r[s]]))return!1;return!0}var rx={value:()=>{}};function Wi(){for(var e=0,t=arguments.length,r={},s;e<t;++e){if(!(s=arguments[e]+"")||s in r||/[\s.]/.test(s))throw new Error("illegal type: "+s);r[s]=[]}return new Gi(r)}function Gi(e){this._=e}function ox(e,t){return e.trim().split(/^|\s+/).map(function(r){var s="",i=r.indexOf(".");if(i>=0&&(s=r.slice(i+1),r=r.slice(0,i)),r&&!t.hasOwnProperty(r))throw new Error("unknown type: "+r);return{type:r,name:s}})}Gi.prototype=Wi.prototype={constructor:Gi,on:function(e,t){var r=this._,s=ox(e+"",r),i,a=-1,c=s.length;if(arguments.length<2){for(;++a<c;)if((i=(e=s[a]).type)&&(i=sx(r[i],e.name)))return i;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++a<c;)if(i=(e=s[a]).type)r[i]=Ep(r[i],e.name,t);else if(t==null)for(i in r)r[i]=Ep(r[i],e.name,null);return this},copy:function(){var e={},t=this._;for(var r in t)e[r]=t[r].slice();return new Gi(e)},call:function(e,t){if((i=arguments.length-2)>0)for(var r=new Array(i),s=0,i,a;s<i;++s)r[s]=arguments[s+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(a=this._[e],s=0,i=a.length;s<i;++s)a[s].value.apply(t,r)},apply:function(e,t,r){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var s=this._[e],i=0,a=s.length;i<a;++i)s[i].value.apply(t,r)}};function sx(e,t){for(var r=0,s=e.length,i;r<s;++r)if((i=e[r]).name===t)return i.value}function Ep(e,t,r){for(var s=0,i=e.length;s<i;++s)if(e[s].name===t){e[s]=rx,e=e.slice(0,s).concat(e.slice(s+1));break}return r!=null&&e.push({name:t,value:r}),e}var Rc="http://www.w3.org/1999/xhtml";const yp={svg:"http://www.w3.org/2000/svg",xhtml:Rc,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Yi(e){var t=e+="",r=t.indexOf(":");return r>=0&&(t=e.slice(0,r))!=="xmlns"&&(e=e.slice(r+1)),yp.hasOwnProperty(t)?{space:yp[t],local:e}:e}function ix(e){return function(){var t=this.ownerDocument,r=this.namespaceURI;return r===Rc&&t.documentElement.namespaceURI===Rc?t.createElement(e):t.createElementNS(r,e)}}function lx(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function vp(e){var t=Yi(e);return(t.local?lx:ix)(t)}function ax(){}function Tc(e){return e==null?ax:function(){return this.querySelector(e)}}function cx(e){typeof e!="function"&&(e=Tc(e));for(var t=this._groups,r=t.length,s=new Array(r),i=0;i<r;++i)for(var a=t[i],c=a.length,u=s[i]=new Array(c),f,p,m=0;m<c;++m)(f=a[m])&&(p=e.call(f,f.__data__,m,a))&&("__data__"in f&&(p.__data__=f.__data__),u[m]=p);return new Ft(s,this._parents)}function ux(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function dx(){return[]}function xp(e){return e==null?dx:function(){return this.querySelectorAll(e)}}function fx(e){return function(){return ux(e.apply(this,arguments))}}function px(e){typeof e=="function"?e=fx(e):e=xp(e);for(var t=this._groups,r=t.length,s=[],i=[],a=0;a<r;++a)for(var c=t[a],u=c.length,f,p=0;p<u;++p)(f=c[p])&&(s.push(e.call(f,f.__data__,p,c)),i.push(f));return new Ft(s,i)}function Sp(e){return function(){return this.matches(e)}}function _p(e){return function(t){return t.matches(e)}}var hx=Array.prototype.find;function mx(e){return function(){return hx.call(this.children,e)}}function gx(){return this.firstElementChild}function Ex(e){return this.select(e==null?gx:mx(typeof e=="function"?e:_p(e)))}var yx=Array.prototype.filter;function vx(){return Array.from(this.children)}function xx(e){return function(){return yx.call(this.children,e)}}function Sx(e){return this.selectAll(e==null?vx:xx(typeof e=="function"?e:_p(e)))}function _x(e){typeof e!="function"&&(e=Sp(e));for(var t=this._groups,r=t.length,s=new Array(r),i=0;i<r;++i)for(var a=t[i],c=a.length,u=s[i]=[],f,p=0;p<c;++p)(f=a[p])&&e.call(f,f.__data__,p,a)&&u.push(f);return new Ft(s,this._parents)}function wp(e){return new Array(e.length)}function wx(){return new Ft(this._enter||this._groups.map(wp),this._parents)}function Ki(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Ki.prototype={constructor:Ki,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function Nx(e){return function(){return e}}function Rx(e,t,r,s,i,a){for(var c=0,u,f=t.length,p=a.length;c<p;++c)(u=t[c])?(u.__data__=a[c],s[c]=u):r[c]=new Ki(e,a[c]);for(;c<f;++c)(u=t[c])&&(i[c]=u)}function Tx(e,t,r,s,i,a,c){var u,f,p=new Map,m=t.length,E=a.length,v=new Array(m),x;for(u=0;u<m;++u)(f=t[u])&&(v[u]=x=c.call(f,f.__data__,u,t)+"",p.has(x)?i[u]=f:p.set(x,f));for(u=0;u<E;++u)x=c.call(e,a[u],u,a)+"",(f=p.get(x))?(s[u]=f,f.__data__=a[u],p.delete(x)):r[u]=new Ki(e,a[u]);for(u=0;u<m;++u)(f=t[u])&&p.get(v[u])===f&&(i[u]=f)}function Ox(e){return e.__data__}function Cx(e,t){if(!arguments.length)return Array.from(this,Ox);var r=t?Tx:Rx,s=this._parents,i=this._groups;typeof e!="function"&&(e=Nx(e));for(var a=i.length,c=new Array(a),u=new Array(a),f=new Array(a),p=0;p<a;++p){var m=s[p],E=i[p],v=E.length,x=Ax(e.call(m,m&&m.__data__,p,s)),_=x.length,w=u[p]=new Array(_),S=c[p]=new Array(_),N=f[p]=new Array(v);r(m,E,w,S,N,x,t);for(var O=0,D=0,T,A;O<_;++O)if(T=w[O]){for(O>=D&&(D=O+1);!(A=S[D])&&++D<_;);T._next=A||null}}return c=new Ft(c,s),c._enter=u,c._exit=f,c}function Ax(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Ix(){return new Ft(this._exit||this._groups.map(wp),this._parents)}function bx(e,t,r){var s=this.enter(),i=this,a=this.exit();return typeof e=="function"?(s=e(s),s&&(s=s.selection())):s=s.append(e+""),t!=null&&(i=t(i),i&&(i=i.selection())),r==null?a.remove():r(a),s&&i?s.merge(i).order():i}function Lx(e){for(var t=e.selection?e.selection():e,r=this._groups,s=t._groups,i=r.length,a=s.length,c=Math.min(i,a),u=new Array(i),f=0;f<c;++f)for(var p=r[f],m=s[f],E=p.length,v=u[f]=new Array(E),x,_=0;_<E;++_)(x=p[_]||m[_])&&(v[_]=x);for(;f<i;++f)u[f]=r[f];return new Ft(u,this._parents)}function Dx(){for(var e=this._groups,t=-1,r=e.length;++t<r;)for(var s=e[t],i=s.length-1,a=s[i],c;--i>=0;)(c=s[i])&&(a&&c.compareDocumentPosition(a)^4&&a.parentNode.insertBefore(c,a),a=c);return this}function kx(e){e||(e=Mx);function t(E,v){return E&&v?e(E.__data__,v.__data__):!E-!v}for(var r=this._groups,s=r.length,i=new Array(s),a=0;a<s;++a){for(var c=r[a],u=c.length,f=i[a]=new Array(u),p,m=0;m<u;++m)(p=c[m])&&(f[m]=p);f.sort(t)}return new Ft(i,this._parents).order()}function Mx(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Px(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Ux(){return Array.from(this)}function Fx(){for(var e=this._groups,t=0,r=e.length;t<r;++t)for(var s=e[t],i=0,a=s.length;i<a;++i){var c=s[i];if(c)return c}return null}function jx(){let e=0;for(const t of this)++e;return e}function Vx(){return!this.node()}function $x(e){for(var t=this._groups,r=0,s=t.length;r<s;++r)for(var i=t[r],a=0,c=i.length,u;a<c;++a)(u=i[a])&&e.call(u,u.__data__,a,i);return this}function Hx(e){return function(){this.removeAttribute(e)}}function Bx(e){return function(){this.removeAttributeNS(e.space,e.local)}}function zx(e,t){return function(){this.setAttribute(e,t)}}function Wx(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Gx(e,t){return function(){var r=t.apply(this,arguments);r==null?this.removeAttribute(e):this.setAttribute(e,r)}}function Yx(e,t){return function(){var r=t.apply(this,arguments);r==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,r)}}function Kx(e,t){var r=Yi(e);if(arguments.length<2){var s=this.node();return r.local?s.getAttributeNS(r.space,r.local):s.getAttribute(r)}return this.each((t==null?r.local?Bx:Hx:typeof t=="function"?r.local?Yx:Gx:r.local?Wx:zx)(r,t))}function Np(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Xx(e){return function(){this.style.removeProperty(e)}}function Qx(e,t,r){return function(){this.style.setProperty(e,t,r)}}function qx(e,t,r){return function(){var s=t.apply(this,arguments);s==null?this.style.removeProperty(e):this.style.setProperty(e,s,r)}}function Zx(e,t,r){return arguments.length>1?this.each((t==null?Xx:typeof t=="function"?qx:Qx)(e,t,r??"")):yo(this.node(),e)}function yo(e,t){return e.style.getPropertyValue(t)||Np(e).getComputedStyle(e,null).getPropertyValue(t)}function Jx(e){return function(){delete this[e]}}function eS(e,t){return function(){this[e]=t}}function tS(e,t){return function(){var r=t.apply(this,arguments);r==null?delete this[e]:this[e]=r}}function nS(e,t){return arguments.length>1?this.each((t==null?Jx:typeof t=="function"?tS:eS)(e,t)):this.node()[e]}function Rp(e){return e.trim().split(/^|\s+/)}function Oc(e){return e.classList||new Tp(e)}function Tp(e){this._node=e,this._names=Rp(e.getAttribute("class")||"")}Tp.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function Op(e,t){for(var r=Oc(e),s=-1,i=t.length;++s<i;)r.add(t[s])}function Cp(e,t){for(var r=Oc(e),s=-1,i=t.length;++s<i;)r.remove(t[s])}function rS(e){return function(){Op(this,e)}}function oS(e){return function(){Cp(this,e)}}function sS(e,t){return function(){(t.apply(this,arguments)?Op:Cp)(this,e)}}function iS(e,t){var r=Rp(e+"");if(arguments.length<2){for(var s=Oc(this.node()),i=-1,a=r.length;++i<a;)if(!s.contains(r[i]))return!1;return!0}return this.each((typeof t=="function"?sS:t?rS:oS)(r,t))}function lS(){this.textContent=""}function aS(e){return function(){this.textContent=e}}function cS(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function uS(e){return arguments.length?this.each(e==null?lS:(typeof e=="function"?cS:aS)(e)):this.node().textContent}function dS(){this.innerHTML=""}function fS(e){return function(){this.innerHTML=e}}function pS(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function hS(e){return arguments.length?this.each(e==null?dS:(typeof e=="function"?pS:fS)(e)):this.node().innerHTML}function mS(){this.nextSibling&&this.parentNode.appendChild(this)}function gS(){return this.each(mS)}function ES(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function yS(){return this.each(ES)}function vS(e){var t=typeof e=="function"?e:vp(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function xS(){return null}function SS(e,t){var r=typeof e=="function"?e:vp(e),s=t==null?xS:typeof t=="function"?t:Tc(t);return this.select(function(){return this.insertBefore(r.apply(this,arguments),s.apply(this,arguments)||null)})}function _S(){var e=this.parentNode;e&&e.removeChild(this)}function wS(){return this.each(_S)}function NS(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function RS(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function TS(e){return this.select(e?RS:NS)}function OS(e){return arguments.length?this.property("__data__",e):this.node().__data__}function CS(e){return function(t){e.call(this,t,this.__data__)}}function AS(e){return e.trim().split(/^|\s+/).map(function(t){var r="",s=t.indexOf(".");return s>=0&&(r=t.slice(s+1),t=t.slice(0,s)),{type:t,name:r}})}function IS(e){return function(){var t=this.__on;if(t){for(var r=0,s=-1,i=t.length,a;r<i;++r)a=t[r],(!e.type||a.type===e.type)&&a.name===e.name?this.removeEventListener(a.type,a.listener,a.options):t[++s]=a;++s?t.length=s:delete this.__on}}}function bS(e,t,r){return function(){var s=this.__on,i,a=CS(t);if(s){for(var c=0,u=s.length;c<u;++c)if((i=s[c]).type===e.type&&i.name===e.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=a,i.options=r),i.value=t;return}}this.addEventListener(e.type,a,r),i={type:e.type,name:e.name,value:t,listener:a,options:r},s?s.push(i):this.__on=[i]}}function LS(e,t,r){var s=AS(e+""),i,a=s.length,c;if(arguments.length<2){var u=this.node().__on;if(u){for(var f=0,p=u.length,m;f<p;++f)for(i=0,m=u[f];i<a;++i)if((c=s[i]).type===m.type&&c.name===m.name)return m.value}return}for(u=t?bS:IS,i=0;i<a;++i)this.each(u(s[i],t,r));return this}function Ap(e,t,r){var s=Np(e),i=s.CustomEvent;typeof i=="function"?i=new i(t,r):(i=s.document.createEvent("Event"),r?(i.initEvent(t,r.bubbles,r.cancelable),i.detail=r.detail):i.initEvent(t,!1,!1)),e.dispatchEvent(i)}function DS(e,t){return function(){return Ap(this,e,t)}}function kS(e,t){return function(){return Ap(this,e,t.apply(this,arguments))}}function MS(e,t){return this.each((typeof t=="function"?kS:DS)(e,t))}function*PS(){for(var e=this._groups,t=0,r=e.length;t<r;++t)for(var s=e[t],i=0,a=s.length,c;i<a;++i)(c=s[i])&&(yield c)}var Ip=[null];function Ft(e,t){this._groups=e,this._parents=t}function _s(){return new Ft([[document.documentElement]],Ip)}function US(){return this}Ft.prototype=_s.prototype={constructor:Ft,select:cx,selectAll:px,selectChild:Ex,selectChildren:Sx,filter:_x,data:Cx,enter:wx,exit:Ix,join:bx,merge:Lx,selection:US,order:Dx,sort:kx,call:Px,nodes:Ux,node:Fx,size:jx,empty:Vx,each:$x,attr:Kx,style:Zx,property:nS,classed:iS,text:uS,html:hS,raise:gS,lower:yS,append:vS,insert:SS,remove:wS,clone:TS,datum:OS,on:LS,dispatch:MS,[Symbol.iterator]:PS};function on(e){return typeof e=="string"?new Ft([[document.querySelector(e)]],[document.documentElement]):new Ft([[e]],Ip)}function FS(e){let t;for(;t=e.sourceEvent;)e=t;return e}function _n(e,t){if(e=FS(e),t===void 0&&(t=e.currentTarget),t){var r=t.ownerSVGElement||t;if(r.createSVGPoint){var s=r.createSVGPoint();return s.x=e.clientX,s.y=e.clientY,s=s.matrixTransform(t.getScreenCTM().inverse()),[s.x,s.y]}if(t.getBoundingClientRect){var i=t.getBoundingClientRect();return[e.clientX-i.left-t.clientLeft,e.clientY-i.top-t.clientTop]}}return[e.pageX,e.pageY]}const jS={passive:!1},ws={capture:!0,passive:!1};function Cc(e){e.stopImmediatePropagation()}function vo(e){e.preventDefault(),e.stopImmediatePropagation()}function bp(e){var t=e.document.documentElement,r=on(e).on("dragstart.drag",vo,ws);"onselectstart"in t?r.on("selectstart.drag",vo,ws):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Lp(e,t){var r=e.document.documentElement,s=on(e).on("dragstart.drag",null);t&&(s.on("click.drag",vo,ws),setTimeout(function(){s.on("click.drag",null)},0)),"onselectstart"in r?s.on("selectstart.drag",null):(r.style.MozUserSelect=r.__noselect,delete r.__noselect)}const Xi=e=>()=>e;function Ac(e,{sourceEvent:t,subject:r,target:s,identifier:i,active:a,x:c,y:u,dx:f,dy:p,dispatch:m}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:r,enumerable:!0,configurable:!0},target:{value:s,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:a,enumerable:!0,configurable:!0},x:{value:c,enumerable:!0,configurable:!0},y:{value:u,enumerable:!0,configurable:!0},dx:{value:f,enumerable:!0,configurable:!0},dy:{value:p,enumerable:!0,configurable:!0},_:{value:m}})}Ac.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function VS(e){return!e.ctrlKey&&!e.button}function $S(){return this.parentNode}function HS(e,t){return t??{x:e.x,y:e.y}}function BS(){return navigator.maxTouchPoints||"ontouchstart"in this}function zS(){var e=VS,t=$S,r=HS,s=BS,i={},a=Wi("start","drag","end"),c=0,u,f,p,m,E=0;function v(T){T.on("mousedown.drag",x).filter(s).on("touchstart.drag",S).on("touchmove.drag",N,jS).on("touchend.drag touchcancel.drag",O).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function x(T,A){if(!(m||!e.call(this,T,A))){var L=D(this,t.call(this,T,A),T,A,"mouse");L&&(on(T.view).on("mousemove.drag",_,ws).on("mouseup.drag",w,ws),bp(T.view),Cc(T),p=!1,u=T.clientX,f=T.clientY,L("start",T))}}function _(T){if(vo(T),!p){var A=T.clientX-u,L=T.clientY-f;p=A*A+L*L>E}i.mouse("drag",T)}function w(T){on(T.view).on("mousemove.drag mouseup.drag",null),Lp(T.view,p),vo(T),i.mouse("end",T)}function S(T,A){if(e.call(this,T,A)){var L=T.changedTouches,F=t.call(this,T,A),K=L.length,Q,X;for(Q=0;Q<K;++Q)(X=D(this,F,T,A,L[Q].identifier,L[Q]))&&(Cc(T),X("start",T,L[Q]))}}function N(T){var A=T.changedTouches,L=A.length,F,K;for(F=0;F<L;++F)(K=i[A[F].identifier])&&(vo(T),K("drag",T,A[F]))}function O(T){var A=T.changedTouches,L=A.length,F,K;for(m&&clearTimeout(m),m=setTimeout(function(){m=null},500),F=0;F<L;++F)(K=i[A[F].identifier])&&(Cc(T),K("end",T,A[F]))}function D(T,A,L,F,K,Q){var X=a.copy(),ee=_n(Q||L,A),ne,W,I;if((I=r.call(T,new Ac("beforestart",{sourceEvent:L,target:v,identifier:K,active:c,x:ee[0],y:ee[1],dx:0,dy:0,dispatch:X}),F))!=null)return ne=I.x-ee[0]||0,W=I.y-ee[1]||0,function V(j,B,U){var $=ee,z;switch(j){case"start":i[K]=V,z=c++;break;case"end":delete i[K],--c;case"drag":ee=_n(U||B,A),z=c;break}X.call(j,T,new Ac(j,{sourceEvent:B,subject:I,target:v,identifier:K,active:z,x:ee[0]+ne,y:ee[1]+W,dx:ee[0]-$[0],dy:ee[1]-$[1],dispatch:X}),F)}}return v.filter=function(T){return arguments.length?(e=typeof T=="function"?T:Xi(!!T),v):e},v.container=function(T){return arguments.length?(t=typeof T=="function"?T:Xi(T),v):t},v.subject=function(T){return arguments.length?(r=typeof T=="function"?T:Xi(T),v):r},v.touchable=function(T){return arguments.length?(s=typeof T=="function"?T:Xi(!!T),v):s},v.on=function(){var T=a.on.apply(a,arguments);return T===a?v:T},v.clickDistance=function(T){return arguments.length?(E=(T=+T)*T,v):Math.sqrt(E)},v}function Ic(e,t,r){e.prototype=t.prototype=r,r.constructor=e}function Dp(e,t){var r=Object.create(e.prototype);for(var s in t)r[s]=t[s];return r}function Ns(){}var Rs=.7,Qi=1/Rs,xo="\\s*([+-]?\\d+)\\s*",Ts="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",wn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",WS=/^#([0-9a-f]{3,8})$/,GS=new RegExp(`^rgb\\(${xo},${xo},${xo}\\)$`),YS=new RegExp(`^rgb\\(${wn},${wn},${wn}\\)$`),KS=new RegExp(`^rgba\\(${xo},${xo},${xo},${Ts}\\)$`),XS=new RegExp(`^rgba\\(${wn},${wn},${wn},${Ts}\\)$`),QS=new RegExp(`^hsl\\(${Ts},${wn},${wn}\\)$`),qS=new RegExp(`^hsla\\(${Ts},${wn},${wn},${Ts}\\)$`),kp={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Ic(Ns,Os,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Mp,formatHex:Mp,formatHex8:ZS,formatHsl:JS,formatRgb:Pp,toString:Pp});function Mp(){return this.rgb().formatHex()}function ZS(){return this.rgb().formatHex8()}function JS(){return $p(this).formatHsl()}function Pp(){return this.rgb().formatRgb()}function Os(e){var t,r;return e=(e+"").trim().toLowerCase(),(t=WS.exec(e))?(r=t[1].length,t=parseInt(t[1],16),r===6?Up(t):r===3?new Ot(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):r===8?qi(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):r===4?qi(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=GS.exec(e))?new Ot(t[1],t[2],t[3],1):(t=YS.exec(e))?new Ot(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=KS.exec(e))?qi(t[1],t[2],t[3],t[4]):(t=XS.exec(e))?qi(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=QS.exec(e))?Vp(t[1],t[2]/100,t[3]/100,1):(t=qS.exec(e))?Vp(t[1],t[2]/100,t[3]/100,t[4]):kp.hasOwnProperty(e)?Up(kp[e]):e==="transparent"?new Ot(NaN,NaN,NaN,0):null}function Up(e){return new Ot(e>>16&255,e>>8&255,e&255,1)}function qi(e,t,r,s){return s<=0&&(e=t=r=NaN),new Ot(e,t,r,s)}function e_(e){return e instanceof Ns||(e=Os(e)),e?(e=e.rgb(),new Ot(e.r,e.g,e.b,e.opacity)):new Ot}function bc(e,t,r,s){return arguments.length===1?e_(e):new Ot(e,t,r,s??1)}function Ot(e,t,r,s){this.r=+e,this.g=+t,this.b=+r,this.opacity=+s}Ic(Ot,bc,Dp(Ns,{brighter(e){return e=e==null?Qi:Math.pow(Qi,e),new Ot(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Rs:Math.pow(Rs,e),new Ot(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Ot(Fr(this.r),Fr(this.g),Fr(this.b),Zi(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Fp,formatHex:Fp,formatHex8:t_,formatRgb:jp,toString:jp}));function Fp(){return`#${jr(this.r)}${jr(this.g)}${jr(this.b)}`}function t_(){return`#${jr(this.r)}${jr(this.g)}${jr(this.b)}${jr((isNaN(this.opacity)?1:this.opacity)*255)}`}function jp(){const e=Zi(this.opacity);return`${e===1?"rgb(":"rgba("}${Fr(this.r)}, ${Fr(this.g)}, ${Fr(this.b)}${e===1?")":`, ${e})`}`}function Zi(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Fr(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function jr(e){return e=Fr(e),(e<16?"0":"")+e.toString(16)}function Vp(e,t,r,s){return s<=0?e=t=r=NaN:r<=0||r>=1?e=t=NaN:t<=0&&(e=NaN),new sn(e,t,r,s)}function $p(e){if(e instanceof sn)return new sn(e.h,e.s,e.l,e.opacity);if(e instanceof Ns||(e=Os(e)),!e)return new sn;if(e instanceof sn)return e;e=e.rgb();var t=e.r/255,r=e.g/255,s=e.b/255,i=Math.min(t,r,s),a=Math.max(t,r,s),c=NaN,u=a-i,f=(a+i)/2;return u?(t===a?c=(r-s)/u+(r<s)*6:r===a?c=(s-t)/u+2:c=(t-r)/u+4,u/=f<.5?a+i:2-a-i,c*=60):u=f>0&&f<1?0:c,new sn(c,u,f,e.opacity)}function n_(e,t,r,s){return arguments.length===1?$p(e):new sn(e,t,r,s??1)}function sn(e,t,r,s){this.h=+e,this.s=+t,this.l=+r,this.opacity=+s}Ic(sn,n_,Dp(Ns,{brighter(e){return e=e==null?Qi:Math.pow(Qi,e),new sn(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Rs:Math.pow(Rs,e),new sn(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,r=this.l,s=r+(r<.5?r:1-r)*t,i=2*r-s;return new Ot(Lc(e>=240?e-240:e+120,i,s),Lc(e,i,s),Lc(e<120?e+240:e-120,i,s),this.opacity)},clamp(){return new sn(Hp(this.h),Ji(this.s),Ji(this.l),Zi(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=Zi(this.opacity);return`${e===1?"hsl(":"hsla("}${Hp(this.h)}, ${Ji(this.s)*100}%, ${Ji(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Hp(e){return e=(e||0)%360,e<0?e+360:e}function Ji(e){return Math.max(0,Math.min(1,e||0))}function Lc(e,t,r){return(e<60?t+(r-t)*e/60:e<180?r:e<240?t+(r-t)*(240-e)/60:t)*255}const Bp=e=>()=>e;function r_(e,t){return function(r){return e+r*t}}function o_(e,t,r){return e=Math.pow(e,r),t=Math.pow(t,r)-e,r=1/r,function(s){return Math.pow(e+s*t,r)}}function s_(e){return(e=+e)==1?zp:function(t,r){return r-t?o_(t,r,e):Bp(isNaN(t)?r:t)}}function zp(e,t){var r=t-e;return r?r_(e,r):Bp(isNaN(e)?t:e)}const Wp=function e(t){var r=s_(t);function s(i,a){var c=r((i=bc(i)).r,(a=bc(a)).r),u=r(i.g,a.g),f=r(i.b,a.b),p=zp(i.opacity,a.opacity);return function(m){return i.r=c(m),i.g=u(m),i.b=f(m),i.opacity=p(m),i+""}}return s.gamma=e,s}(1);function sr(e,t){return e=+e,t=+t,function(r){return e*(1-r)+t*r}}var Dc=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,kc=new RegExp(Dc.source,"g");function i_(e){return function(){return e}}function l_(e){return function(t){return e(t)+""}}function a_(e,t){var r=Dc.lastIndex=kc.lastIndex=0,s,i,a,c=-1,u=[],f=[];for(e=e+"",t=t+"";(s=Dc.exec(e))&&(i=kc.exec(t));)(a=i.index)>r&&(a=t.slice(r,a),u[c]?u[c]+=a:u[++c]=a),(s=s[0])===(i=i[0])?u[c]?u[c]+=i:u[++c]=i:(u[++c]=null,f.push({i:c,x:sr(s,i)})),r=kc.lastIndex;return r<t.length&&(a=t.slice(r),u[c]?u[c]+=a:u[++c]=a),u.length<2?f[0]?l_(f[0].x):i_(t):(t=f.length,function(p){for(var m=0,E;m<t;++m)u[(E=f[m]).i]=E.x(p);return u.join("")})}var Gp=180/Math.PI,Mc={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Yp(e,t,r,s,i,a){var c,u,f;return(c=Math.sqrt(e*e+t*t))&&(e/=c,t/=c),(f=e*r+t*s)&&(r-=e*f,s-=t*f),(u=Math.sqrt(r*r+s*s))&&(r/=u,s/=u,f/=u),e*s<t*r&&(e=-e,t=-t,f=-f,c=-c),{translateX:i,translateY:a,rotate:Math.atan2(t,e)*Gp,skewX:Math.atan(f)*Gp,scaleX:c,scaleY:u}}var el;function c_(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Mc:Yp(t.a,t.b,t.c,t.d,t.e,t.f)}function u_(e){return e==null||(el||(el=document.createElementNS("http://www.w3.org/2000/svg","g")),el.setAttribute("transform",e),!(e=el.transform.baseVal.consolidate()))?Mc:(e=e.matrix,Yp(e.a,e.b,e.c,e.d,e.e,e.f))}function Kp(e,t,r,s){function i(p){return p.length?p.pop()+" ":""}function a(p,m,E,v,x,_){if(p!==E||m!==v){var w=x.push("translate(",null,t,null,r);_.push({i:w-4,x:sr(p,E)},{i:w-2,x:sr(m,v)})}else(E||v)&&x.push("translate("+E+t+v+r)}function c(p,m,E,v){p!==m?(p-m>180?m+=360:m-p>180&&(p+=360),v.push({i:E.push(i(E)+"rotate(",null,s)-2,x:sr(p,m)})):m&&E.push(i(E)+"rotate("+m+s)}function u(p,m,E,v){p!==m?v.push({i:E.push(i(E)+"skewX(",null,s)-2,x:sr(p,m)}):m&&E.push(i(E)+"skewX("+m+s)}function f(p,m,E,v,x,_){if(p!==E||m!==v){var w=x.push(i(x)+"scale(",null,",",null,")");_.push({i:w-4,x:sr(p,E)},{i:w-2,x:sr(m,v)})}else(E!==1||v!==1)&&x.push(i(x)+"scale("+E+","+v+")")}return function(p,m){var E=[],v=[];return p=e(p),m=e(m),a(p.translateX,p.translateY,m.translateX,m.translateY,E,v),c(p.rotate,m.rotate,E,v),u(p.skewX,m.skewX,E,v),f(p.scaleX,p.scaleY,m.scaleX,m.scaleY,E,v),p=m=null,function(x){for(var _=-1,w=v.length,S;++_<w;)E[(S=v[_]).i]=S.x(x);return E.join("")}}}var d_=Kp(c_,"px, ","px)","deg)"),f_=Kp(u_,", ",")",")"),p_=1e-12;function Xp(e){return((e=Math.exp(e))+1/e)/2}function h_(e){return((e=Math.exp(e))-1/e)/2}function m_(e){return((e=Math.exp(2*e))-1)/(e+1)}const g_=function e(t,r,s){function i(a,c){var u=a[0],f=a[1],p=a[2],m=c[0],E=c[1],v=c[2],x=m-u,_=E-f,w=x*x+_*_,S,N;if(w<p_)N=Math.log(v/p)/t,S=function(F){return[u+F*x,f+F*_,p*Math.exp(t*F*N)]};else{var O=Math.sqrt(w),D=(v*v-p*p+s*w)/(2*p*r*O),T=(v*v-p*p-s*w)/(2*v*r*O),A=Math.log(Math.sqrt(D*D+1)-D),L=Math.log(Math.sqrt(T*T+1)-T);N=(L-A)/t,S=function(F){var K=F*N,Q=Xp(A),X=p/(r*O)*(Q*m_(t*K+A)-h_(A));return[u+X*x,f+X*_,p*Q/Xp(t*K+A)]}}return S.duration=N*1e3*t/Math.SQRT2,S}return i.rho=function(a){var c=Math.max(.001,+a),u=c*c,f=u*u;return e(c,u,f)},i}(Math.SQRT2,2,4);var So=0,Cs=0,As=0,Qp=1e3,tl,Is,nl=0,Vr=0,rl=0,bs=typeof performance=="object"&&performance.now?performance:Date,qp=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Pc(){return Vr||(qp(E_),Vr=bs.now()+rl)}function E_(){Vr=0}function ol(){this._call=this._time=this._next=null}ol.prototype=Zp.prototype={constructor:ol,restart:function(e,t,r){if(typeof e!="function")throw new TypeError("callback is not a function");r=(r==null?Pc():+r)+(t==null?0:+t),!this._next&&Is!==this&&(Is?Is._next=this:tl=this,Is=this),this._call=e,this._time=r,Uc()},stop:function(){this._call&&(this._call=null,this._time=1/0,Uc())}};function Zp(e,t,r){var s=new ol;return s.restart(e,t,r),s}function y_(){Pc(),++So;for(var e=tl,t;e;)(t=Vr-e._time)>=0&&e._call.call(void 0,t),e=e._next;--So}function Jp(){Vr=(nl=bs.now())+rl,So=Cs=0;try{y_()}finally{So=0,x_(),Vr=0}}function v_(){var e=bs.now(),t=e-nl;t>Qp&&(rl-=t,nl=e)}function x_(){for(var e,t=tl,r,s=1/0;t;)t._call?(s>t._time&&(s=t._time),e=t,t=t._next):(r=t._next,t._next=null,t=e?e._next=r:tl=r);Is=e,Uc(s)}function Uc(e){if(!So){Cs&&(Cs=clearTimeout(Cs));var t=e-Vr;t>24?(e<1/0&&(Cs=setTimeout(Jp,e-bs.now()-rl)),As&&(As=clearInterval(As))):(As||(nl=bs.now(),As=setInterval(v_,Qp)),So=1,qp(Jp))}}function eh(e,t,r){var s=new ol;return t=t==null?0:+t,s.restart(i=>{s.stop(),e(i+t)},t,r),s}var S_=Wi("start","end","cancel","interrupt"),__=[],th=0,nh=1,Fc=2,sl=3,rh=4,jc=5,il=6;function ll(e,t,r,s,i,a){var c=e.__transition;if(!c)e.__transition={};else if(r in c)return;w_(e,r,{name:t,index:s,group:i,on:S_,tween:__,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:th})}function Vc(e,t){var r=ln(e,t);if(r.state>th)throw new Error("too late; already scheduled");return r}function Nn(e,t){var r=ln(e,t);if(r.state>sl)throw new Error("too late; already running");return r}function ln(e,t){var r=e.__transition;if(!r||!(r=r[t]))throw new Error("transition not found");return r}function w_(e,t,r){var s=e.__transition,i;s[t]=r,r.timer=Zp(a,0,r.time);function a(p){r.state=nh,r.timer.restart(c,r.delay,r.time),r.delay<=p&&c(p-r.delay)}function c(p){var m,E,v,x;if(r.state!==nh)return f();for(m in s)if(x=s[m],x.name===r.name){if(x.state===sl)return eh(c);x.state===rh?(x.state=il,x.timer.stop(),x.on.call("interrupt",e,e.__data__,x.index,x.group),delete s[m]):+m<t&&(x.state=il,x.timer.stop(),x.on.call("cancel",e,e.__data__,x.index,x.group),delete s[m])}if(eh(function(){r.state===sl&&(r.state=rh,r.timer.restart(u,r.delay,r.time),u(p))}),r.state=Fc,r.on.call("start",e,e.__data__,r.index,r.group),r.state===Fc){for(r.state=sl,i=new Array(v=r.tween.length),m=0,E=-1;m<v;++m)(x=r.tween[m].value.call(e,e.__data__,r.index,r.group))&&(i[++E]=x);i.length=E+1}}function u(p){for(var m=p<r.duration?r.ease.call(null,p/r.duration):(r.timer.restart(f),r.state=jc,1),E=-1,v=i.length;++E<v;)i[E].call(e,m);r.state===jc&&(r.on.call("end",e,e.__data__,r.index,r.group),f())}function f(){r.state=il,r.timer.stop(),delete s[t];for(var p in s)return;delete e.__transition}}function al(e,t){var r=e.__transition,s,i,a=!0,c;if(r){t=t==null?null:t+"";for(c in r){if((s=r[c]).name!==t){a=!1;continue}i=s.state>Fc&&s.state<jc,s.state=il,s.timer.stop(),s.on.call(i?"interrupt":"cancel",e,e.__data__,s.index,s.group),delete r[c]}a&&delete e.__transition}}function N_(e){return this.each(function(){al(this,e)})}function R_(e,t){var r,s;return function(){var i=Nn(this,e),a=i.tween;if(a!==r){s=r=a;for(var c=0,u=s.length;c<u;++c)if(s[c].name===t){s=s.slice(),s.splice(c,1);break}}i.tween=s}}function T_(e,t,r){var s,i;if(typeof r!="function")throw new Error;return function(){var a=Nn(this,e),c=a.tween;if(c!==s){i=(s=c).slice();for(var u={name:t,value:r},f=0,p=i.length;f<p;++f)if(i[f].name===t){i[f]=u;break}f===p&&i.push(u)}a.tween=i}}function O_(e,t){var r=this._id;if(e+="",arguments.length<2){for(var s=ln(this.node(),r).tween,i=0,a=s.length,c;i<a;++i)if((c=s[i]).name===e)return c.value;return null}return this.each((t==null?R_:T_)(r,e,t))}function $c(e,t,r){var s=e._id;return e.each(function(){var i=Nn(this,s);(i.value||(i.value={}))[t]=r.apply(this,arguments)}),function(i){return ln(i,s).value[t]}}function oh(e,t){var r;return(typeof t=="number"?sr:t instanceof Os?Wp:(r=Os(t))?(t=r,Wp):a_)(e,t)}function C_(e){return function(){this.removeAttribute(e)}}function A_(e){return function(){this.removeAttributeNS(e.space,e.local)}}function I_(e,t,r){var s,i=r+"",a;return function(){var c=this.getAttribute(e);return c===i?null:c===s?a:a=t(s=c,r)}}function b_(e,t,r){var s,i=r+"",a;return function(){var c=this.getAttributeNS(e.space,e.local);return c===i?null:c===s?a:a=t(s=c,r)}}function L_(e,t,r){var s,i,a;return function(){var c,u=r(this),f;return u==null?void this.removeAttribute(e):(c=this.getAttribute(e),f=u+"",c===f?null:c===s&&f===i?a:(i=f,a=t(s=c,u)))}}function D_(e,t,r){var s,i,a;return function(){var c,u=r(this),f;return u==null?void this.removeAttributeNS(e.space,e.local):(c=this.getAttributeNS(e.space,e.local),f=u+"",c===f?null:c===s&&f===i?a:(i=f,a=t(s=c,u)))}}function k_(e,t){var r=Yi(e),s=r==="transform"?f_:oh;return this.attrTween(e,typeof t=="function"?(r.local?D_:L_)(r,s,$c(this,"attr."+e,t)):t==null?(r.local?A_:C_)(r):(r.local?b_:I_)(r,s,t))}function M_(e,t){return function(r){this.setAttribute(e,t.call(this,r))}}function P_(e,t){return function(r){this.setAttributeNS(e.space,e.local,t.call(this,r))}}function U_(e,t){var r,s;function i(){var a=t.apply(this,arguments);return a!==s&&(r=(s=a)&&P_(e,a)),r}return i._value=t,i}function F_(e,t){var r,s;function i(){var a=t.apply(this,arguments);return a!==s&&(r=(s=a)&&M_(e,a)),r}return i._value=t,i}function j_(e,t){var r="attr."+e;if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!="function")throw new Error;var s=Yi(e);return this.tween(r,(s.local?U_:F_)(s,t))}function V_(e,t){return function(){Vc(this,e).delay=+t.apply(this,arguments)}}function $_(e,t){return t=+t,function(){Vc(this,e).delay=t}}function H_(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?V_:$_)(t,e)):ln(this.node(),t).delay}function B_(e,t){return function(){Nn(this,e).duration=+t.apply(this,arguments)}}function z_(e,t){return t=+t,function(){Nn(this,e).duration=t}}function W_(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?B_:z_)(t,e)):ln(this.node(),t).duration}function G_(e,t){if(typeof t!="function")throw new Error;return function(){Nn(this,e).ease=t}}function Y_(e){var t=this._id;return arguments.length?this.each(G_(t,e)):ln(this.node(),t).ease}function K_(e,t){return function(){var r=t.apply(this,arguments);if(typeof r!="function")throw new Error;Nn(this,e).ease=r}}function X_(e){if(typeof e!="function")throw new Error;return this.each(K_(this._id,e))}function Q_(e){typeof e!="function"&&(e=Sp(e));for(var t=this._groups,r=t.length,s=new Array(r),i=0;i<r;++i)for(var a=t[i],c=a.length,u=s[i]=[],f,p=0;p<c;++p)(f=a[p])&&e.call(f,f.__data__,p,a)&&u.push(f);return new Un(s,this._parents,this._name,this._id)}function q_(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,r=e._groups,s=t.length,i=r.length,a=Math.min(s,i),c=new Array(s),u=0;u<a;++u)for(var f=t[u],p=r[u],m=f.length,E=c[u]=new Array(m),v,x=0;x<m;++x)(v=f[x]||p[x])&&(E[x]=v);for(;u<s;++u)c[u]=t[u];return new Un(c,this._parents,this._name,this._id)}function Z_(e){return(e+"").trim().split(/^|\s+/).every(function(t){var r=t.indexOf(".");return r>=0&&(t=t.slice(0,r)),!t||t==="start"})}function J_(e,t,r){var s,i,a=Z_(t)?Vc:Nn;return function(){var c=a(this,e),u=c.on;u!==s&&(i=(s=u).copy()).on(t,r),c.on=i}}function ew(e,t){var r=this._id;return arguments.length<2?ln(this.node(),r).on.on(e):this.each(J_(r,e,t))}function tw(e){return function(){var t=this.parentNode;for(var r in this.__transition)if(+r!==e)return;t&&t.removeChild(this)}}function nw(){return this.on("end.remove",tw(this._id))}function rw(e){var t=this._name,r=this._id;typeof e!="function"&&(e=Tc(e));for(var s=this._groups,i=s.length,a=new Array(i),c=0;c<i;++c)for(var u=s[c],f=u.length,p=a[c]=new Array(f),m,E,v=0;v<f;++v)(m=u[v])&&(E=e.call(m,m.__data__,v,u))&&("__data__"in m&&(E.__data__=m.__data__),p[v]=E,ll(p[v],t,r,v,p,ln(m,r)));return new Un(a,this._parents,t,r)}function ow(e){var t=this._name,r=this._id;typeof e!="function"&&(e=xp(e));for(var s=this._groups,i=s.length,a=[],c=[],u=0;u<i;++u)for(var f=s[u],p=f.length,m,E=0;E<p;++E)if(m=f[E]){for(var v=e.call(m,m.__data__,E,f),x,_=ln(m,r),w=0,S=v.length;w<S;++w)(x=v[w])&&ll(x,t,r,w,v,_);a.push(v),c.push(m)}return new Un(a,c,t,r)}var sw=_s.prototype.constructor;function iw(){return new sw(this._groups,this._parents)}function lw(e,t){var r,s,i;return function(){var a=yo(this,e),c=(this.style.removeProperty(e),yo(this,e));return a===c?null:a===r&&c===s?i:i=t(r=a,s=c)}}function sh(e){return function(){this.style.removeProperty(e)}}function aw(e,t,r){var s,i=r+"",a;return function(){var c=yo(this,e);return c===i?null:c===s?a:a=t(s=c,r)}}function cw(e,t,r){var s,i,a;return function(){var c=yo(this,e),u=r(this),f=u+"";return u==null&&(f=u=(this.style.removeProperty(e),yo(this,e))),c===f?null:c===s&&f===i?a:(i=f,a=t(s=c,u))}}function uw(e,t){var r,s,i,a="style."+t,c="end."+a,u;return function(){var f=Nn(this,e),p=f.on,m=f.value[a]==null?u||(u=sh(t)):void 0;(p!==r||i!==m)&&(s=(r=p).copy()).on(c,i=m),f.on=s}}function dw(e,t,r){var s=(e+="")=="transform"?d_:oh;return t==null?this.styleTween(e,lw(e,s)).on("end.style."+e,sh(e)):typeof t=="function"?this.styleTween(e,cw(e,s,$c(this,"style."+e,t))).each(uw(this._id,e)):this.styleTween(e,aw(e,s,t),r).on("end.style."+e,null)}function fw(e,t,r){return function(s){this.style.setProperty(e,t.call(this,s),r)}}function pw(e,t,r){var s,i;function a(){var c=t.apply(this,arguments);return c!==i&&(s=(i=c)&&fw(e,c,r)),s}return a._value=t,a}function hw(e,t,r){var s="style."+(e+="");if(arguments.length<2)return(s=this.tween(s))&&s._value;if(t==null)return this.tween(s,null);if(typeof t!="function")throw new Error;return this.tween(s,pw(e,t,r??""))}function mw(e){return function(){this.textContent=e}}function gw(e){return function(){var t=e(this);this.textContent=t??""}}function Ew(e){return this.tween("text",typeof e=="function"?gw($c(this,"text",e)):mw(e==null?"":e+""))}function yw(e){return function(t){this.textContent=e.call(this,t)}}function vw(e){var t,r;function s(){var i=e.apply(this,arguments);return i!==r&&(t=(r=i)&&yw(i)),t}return s._value=e,s}function xw(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,vw(e))}function Sw(){for(var e=this._name,t=this._id,r=ih(),s=this._groups,i=s.length,a=0;a<i;++a)for(var c=s[a],u=c.length,f,p=0;p<u;++p)if(f=c[p]){var m=ln(f,t);ll(f,e,r,p,c,{time:m.time+m.delay+m.duration,delay:0,duration:m.duration,ease:m.ease})}return new Un(s,this._parents,e,r)}function _w(){var e,t,r=this,s=r._id,i=r.size();return new Promise(function(a,c){var u={value:c},f={value:function(){--i===0&&a()}};r.each(function(){var p=Nn(this,s),m=p.on;m!==e&&(t=(e=m).copy(),t._.cancel.push(u),t._.interrupt.push(u),t._.end.push(f)),p.on=t}),i===0&&a()})}var ww=0;function Un(e,t,r,s){this._groups=e,this._parents=t,this._name=r,this._id=s}function ih(){return++ww}var Fn=_s.prototype;Un.prototype={constructor:Un,select:rw,selectAll:ow,selectChild:Fn.selectChild,selectChildren:Fn.selectChildren,filter:Q_,merge:q_,selection:iw,transition:Sw,call:Fn.call,nodes:Fn.nodes,node:Fn.node,size:Fn.size,empty:Fn.empty,each:Fn.each,on:ew,attr:k_,attrTween:j_,style:dw,styleTween:hw,text:Ew,textTween:xw,remove:nw,tween:O_,delay:H_,duration:W_,ease:Y_,easeVarying:X_,end:_w,[Symbol.iterator]:Fn[Symbol.iterator]};function Nw(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Rw={time:null,delay:0,duration:250,ease:Nw};function Tw(e,t){for(var r;!(r=e.__transition)||!(r=r[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return r}function Ow(e){var t,r;e instanceof Un?(t=e._id,e=e._name):(t=ih(),(r=Rw).time=Pc(),e=e==null?null:e+"");for(var s=this._groups,i=s.length,a=0;a<i;++a)for(var c=s[a],u=c.length,f,p=0;p<u;++p)(f=c[p])&&ll(f,e,t,p,c,r||Tw(f,t));return new Un(s,this._parents,e,t)}_s.prototype.interrupt=N_,_s.prototype.transition=Ow;const cl=e=>()=>e;function Cw(e,{sourceEvent:t,target:r,transform:s,dispatch:i}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},transform:{value:s,enumerable:!0,configurable:!0},_:{value:i}})}function jn(e,t,r){this.k=e,this.x=t,this.y=r}jn.prototype={constructor:jn,scale:function(e){return e===1?this:new jn(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new jn(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var ir=new jn(1,0,0);jn.prototype;function Hc(e){e.stopImmediatePropagation()}function Ls(e){e.preventDefault(),e.stopImmediatePropagation()}function Aw(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Iw(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function lh(){return this.__zoom||ir}function bw(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Lw(){return navigator.maxTouchPoints||"ontouchstart"in this}function Dw(e,t,r){var s=e.invertX(t[0][0])-r[0][0],i=e.invertX(t[1][0])-r[1][0],a=e.invertY(t[0][1])-r[0][1],c=e.invertY(t[1][1])-r[1][1];return e.translate(i>s?(s+i)/2:Math.min(0,s)||Math.max(0,i),c>a?(a+c)/2:Math.min(0,a)||Math.max(0,c))}function kw(){var e=Aw,t=Iw,r=Dw,s=bw,i=Lw,a=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],u=250,f=g_,p=Wi("start","zoom","end"),m,E,v,x=500,_=150,w=0,S=10;function N(I){I.property("__zoom",lh).on("wheel.zoom",K,{passive:!1}).on("mousedown.zoom",Q).on("dblclick.zoom",X).filter(i).on("touchstart.zoom",ee).on("touchmove.zoom",ne).on("touchend.zoom touchcancel.zoom",W).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}N.transform=function(I,V,j,B){var U=I.selection?I.selection():I;U.property("__zoom",lh),I!==U?A(I,V,j,B):U.interrupt().each(function(){L(this,arguments).event(B).start().zoom(null,typeof V=="function"?V.apply(this,arguments):V).end()})},N.scaleBy=function(I,V,j,B){N.scaleTo(I,function(){var U=this.__zoom.k,$=typeof V=="function"?V.apply(this,arguments):V;return U*$},j,B)},N.scaleTo=function(I,V,j,B){N.transform(I,function(){var U=t.apply(this,arguments),$=this.__zoom,z=j==null?T(U):typeof j=="function"?j.apply(this,arguments):j,k=$.invert(z),Y=typeof V=="function"?V.apply(this,arguments):V;return r(D(O($,Y),z,k),U,c)},j,B)},N.translateBy=function(I,V,j,B){N.transform(I,function(){return r(this.__zoom.translate(typeof V=="function"?V.apply(this,arguments):V,typeof j=="function"?j.apply(this,arguments):j),t.apply(this,arguments),c)},null,B)},N.translateTo=function(I,V,j,B,U){N.transform(I,function(){var $=t.apply(this,arguments),z=this.__zoom,k=B==null?T($):typeof B=="function"?B.apply(this,arguments):B;return r(ir.translate(k[0],k[1]).scale(z.k).translate(typeof V=="function"?-V.apply(this,arguments):-V,typeof j=="function"?-j.apply(this,arguments):-j),$,c)},B,U)};function O(I,V){return V=Math.max(a[0],Math.min(a[1],V)),V===I.k?I:new jn(V,I.x,I.y)}function D(I,V,j){var B=V[0]-j[0]*I.k,U=V[1]-j[1]*I.k;return B===I.x&&U===I.y?I:new jn(I.k,B,U)}function T(I){return[(+I[0][0]+ +I[1][0])/2,(+I[0][1]+ +I[1][1])/2]}function A(I,V,j,B){I.on("start.zoom",function(){L(this,arguments).event(B).start()}).on("interrupt.zoom end.zoom",function(){L(this,arguments).event(B).end()}).tween("zoom",function(){var U=this,$=arguments,z=L(U,$).event(B),k=t.apply(U,$),Y=j==null?T(k):typeof j=="function"?j.apply(U,$):j,re=Math.max(k[1][0]-k[0][0],k[1][1]-k[0][1]),oe=U.__zoom,le=typeof V=="function"?V.apply(U,$):V,de=f(oe.invert(Y).concat(re/oe.k),le.invert(Y).concat(re/le.k));return function(he){if(he===1)he=le;else{var ue=de(he),me=re/ue[2];he=new jn(me,Y[0]-ue[0]*me,Y[1]-ue[1]*me)}z.zoom(null,he)}})}function L(I,V,j){return!j&&I.__zooming||new F(I,V)}function F(I,V){this.that=I,this.args=V,this.active=0,this.sourceEvent=null,this.extent=t.apply(I,V),this.taps=0}F.prototype={event:function(I){return I&&(this.sourceEvent=I),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(I,V){return this.mouse&&I!=="mouse"&&(this.mouse[1]=V.invert(this.mouse[0])),this.touch0&&I!=="touch"&&(this.touch0[1]=V.invert(this.touch0[0])),this.touch1&&I!=="touch"&&(this.touch1[1]=V.invert(this.touch1[0])),this.that.__zoom=V,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(I){var V=on(this.that).datum();p.call(I,this.that,new Cw(I,{sourceEvent:this.sourceEvent,target:N,transform:this.that.__zoom,dispatch:p}),V)}};function K(I,...V){if(!e.apply(this,arguments))return;var j=L(this,V).event(I),B=this.__zoom,U=Math.max(a[0],Math.min(a[1],B.k*Math.pow(2,s.apply(this,arguments)))),$=_n(I);if(j.wheel)(j.mouse[0][0]!==$[0]||j.mouse[0][1]!==$[1])&&(j.mouse[1]=B.invert(j.mouse[0]=$)),clearTimeout(j.wheel);else{if(B.k===U)return;j.mouse=[$,B.invert($)],al(this),j.start()}Ls(I),j.wheel=setTimeout(z,_),j.zoom("mouse",r(D(O(B,U),j.mouse[0],j.mouse[1]),j.extent,c));function z(){j.wheel=null,j.end()}}function Q(I,...V){if(v||!e.apply(this,arguments))return;var j=I.currentTarget,B=L(this,V,!0).event(I),U=on(I.view).on("mousemove.zoom",Y,!0).on("mouseup.zoom",re,!0),$=_n(I,j),z=I.clientX,k=I.clientY;bp(I.view),Hc(I),B.mouse=[$,this.__zoom.invert($)],al(this),B.start();function Y(oe){if(Ls(oe),!B.moved){var le=oe.clientX-z,de=oe.clientY-k;B.moved=le*le+de*de>w}B.event(oe).zoom("mouse",r(D(B.that.__zoom,B.mouse[0]=_n(oe,j),B.mouse[1]),B.extent,c))}function re(oe){U.on("mousemove.zoom mouseup.zoom",null),Lp(oe.view,B.moved),Ls(oe),B.event(oe).end()}}function X(I,...V){if(e.apply(this,arguments)){var j=this.__zoom,B=_n(I.changedTouches?I.changedTouches[0]:I,this),U=j.invert(B),$=j.k*(I.shiftKey?.5:2),z=r(D(O(j,$),B,U),t.apply(this,V),c);Ls(I),u>0?on(this).transition().duration(u).call(A,z,B,I):on(this).call(N.transform,z,B,I)}}function ee(I,...V){if(e.apply(this,arguments)){var j=I.touches,B=j.length,U=L(this,V,I.changedTouches.length===B).event(I),$,z,k,Y;for(Hc(I),z=0;z<B;++z)k=j[z],Y=_n(k,this),Y=[Y,this.__zoom.invert(Y),k.identifier],U.touch0?!U.touch1&&U.touch0[2]!==Y[2]&&(U.touch1=Y,U.taps=0):(U.touch0=Y,$=!0,U.taps=1+!!m);m&&(m=clearTimeout(m)),$&&(U.taps<2&&(E=Y[0],m=setTimeout(function(){m=null},x)),al(this),U.start())}}function ne(I,...V){if(this.__zooming){var j=L(this,V).event(I),B=I.changedTouches,U=B.length,$,z,k,Y;for(Ls(I),$=0;$<U;++$)z=B[$],k=_n(z,this),j.touch0&&j.touch0[2]===z.identifier?j.touch0[0]=k:j.touch1&&j.touch1[2]===z.identifier&&(j.touch1[0]=k);if(z=j.that.__zoom,j.touch1){var re=j.touch0[0],oe=j.touch0[1],le=j.touch1[0],de=j.touch1[1],he=(he=le[0]-re[0])*he+(he=le[1]-re[1])*he,ue=(ue=de[0]-oe[0])*ue+(ue=de[1]-oe[1])*ue;z=O(z,Math.sqrt(he/ue)),k=[(re[0]+le[0])/2,(re[1]+le[1])/2],Y=[(oe[0]+de[0])/2,(oe[1]+de[1])/2]}else if(j.touch0)k=j.touch0[0],Y=j.touch0[1];else return;j.zoom("touch",r(D(z,k,Y),j.extent,c))}}function W(I,...V){if(this.__zooming){var j=L(this,V).event(I),B=I.changedTouches,U=B.length,$,z;for(Hc(I),v&&clearTimeout(v),v=setTimeout(function(){v=null},x),$=0;$<U;++$)z=B[$],j.touch0&&j.touch0[2]===z.identifier?delete j.touch0:j.touch1&&j.touch1[2]===z.identifier&&delete j.touch1;if(j.touch1&&!j.touch0&&(j.touch0=j.touch1,delete j.touch1),j.touch0)j.touch0[1]=this.__zoom.invert(j.touch0[0]);else if(j.end(),j.taps===2&&(z=_n(z,this),Math.hypot(E[0]-z[0],E[1]-z[1])<S)){var k=on(this).on("dblclick.zoom");k&&k.apply(this,arguments)}}}return N.wheelDelta=function(I){return arguments.length?(s=typeof I=="function"?I:cl(+I),N):s},N.filter=function(I){return arguments.length?(e=typeof I=="function"?I:cl(!!I),N):e},N.touchable=function(I){return arguments.length?(i=typeof I=="function"?I:cl(!!I),N):i},N.extent=function(I){return arguments.length?(t=typeof I=="function"?I:cl([[+I[0][0],+I[0][1]],[+I[1][0],+I[1][1]]]),N):t},N.scaleExtent=function(I){return arguments.length?(a[0]=+I[0],a[1]=+I[1],N):[a[0],a[1]]},N.translateExtent=function(I){return arguments.length?(c[0][0]=+I[0][0],c[1][0]=+I[1][0],c[0][1]=+I[0][1],c[1][1]=+I[1][1],N):[[c[0][0],c[0][1]],[c[1][0],c[1][1]]]},N.constrain=function(I){return arguments.length?(r=I,N):r},N.duration=function(I){return arguments.length?(u=+I,N):u},N.interpolate=function(I){return arguments.length?(f=I,N):f},N.on=function(){var I=p.on.apply(p,arguments);return I===p?N:I},N.clickDistance=function(I){return arguments.length?(w=(I=+I)*I,N):Math.sqrt(w)},N.tapDistance=function(I){return arguments.length?(S=+I,N):S},N}var Bc=ip();const ul=b.createContext(null),Mw=ul.Provider,Vn={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,t)=>`Couldn't create edge for ${e?"target":"source"} handle id: "${e?t.targetHandle:t.sourceHandle}", edge id: ${t.id}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`},ah=Vn.error001();function Me(e,t){const r=b.useContext(ul);if(r===null)throw new Error(ah);return mp(r,e,t)}const tt=()=>{const e=b.useContext(ul);if(e===null)throw new Error(ah);return b.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe,destroy:e.destroy}),[e])},Pw=e=>e.userSelectionActive?"none":"all";function Ds({position:e,children:t,className:r,style:s,...i}){const a=Me(Pw),c=`${e}`.split("-");return te.createElement("div",{className:St(["react-flow__panel",r,...c]),style:{...s,pointerEvents:a},...i},t)}function Uw({proOptions:e,position:t="bottom-right"}){return e?.hideAttribution?null:te.createElement(Ds,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://reactflow.dev/pro"},te.createElement("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution"},"React Flow"))}const Fw=({x:e,y:t,label:r,labelStyle:s={},labelShowBg:i=!0,labelBgStyle:a={},labelBgPadding:c=[2,4],labelBgBorderRadius:u=2,children:f,className:p,...m})=>{const E=b.useRef(null),[v,x]=b.useState({x:0,y:0,width:0,height:0}),_=St(["react-flow__edge-textwrapper",p]);return b.useEffect(()=>{if(E.current){const w=E.current.getBBox();x({x:w.x,y:w.y,width:w.width,height:w.height})}},[r]),typeof r>"u"||!r?null:te.createElement("g",{transform:`translate(${e-v.width/2} ${t-v.height/2})`,className:_,visibility:v.width?"visible":"hidden",...m},i&&te.createElement("rect",{width:v.width+2*c[0],x:-c[0],y:-c[1],height:v.height+2*c[1],className:"react-flow__edge-textbg",style:a,rx:u,ry:u}),te.createElement("text",{className:"react-flow__edge-text",y:v.height/2,dy:"0.3em",ref:E,style:s},r),f)};var jw=b.memo(Fw);const zc=e=>({width:e.offsetWidth,height:e.offsetHeight}),_o=(e,t=0,r=1)=>Math.min(Math.max(e,t),r),Wc=(e={x:0,y:0},t)=>({x:_o(e.x,t[0][0],t[1][0]),y:_o(e.y,t[0][1],t[1][1])}),ch=(e,t,r)=>e<t?_o(Math.abs(e-t),1,50)/50:e>r?-_o(Math.abs(e-r),1,50)/50:0,uh=(e,t)=>{const r=ch(e.x,35,t.width-35)*20,s=ch(e.y,35,t.height-35)*20;return[r,s]},dh=e=>e.getRootNode?.()||window?.document,Vw=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),Gc=({x:e,y:t,width:r,height:s})=>({x:e,y:t,x2:e+r,y2:t+s}),$w=({x:e,y:t,x2:r,y2:s})=>({x:e,y:t,width:r-e,height:s-t}),fh=e=>({...e.positionAbsolute||{x:0,y:0},width:e.width||0,height:e.height||0}),Yc=(e,t)=>{const r=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),s=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(r*s)},Hw=e=>Yt(e.width)&&Yt(e.height)&&Yt(e.x)&&Yt(e.y),Yt=e=>!isNaN(e)&&isFinite(e),nt=Symbol.for("internals"),ph=["Enter"," ","Escape"],Bw=(e,t)=>{},zw=e=>"nativeEvent"in e;function Kc(e){const r=(zw(e)?e.nativeEvent:e).composedPath?.()?.[0]||e.target;return["INPUT","SELECT","TEXTAREA"].includes(r?.nodeName)||r?.hasAttribute("contenteditable")||!!r?.closest(".nokey")}const hh=e=>"clientX"in e,lr=(e,t)=>{const r=hh(e),s=r?e.clientX:e.touches?.[0].clientX,i=r?e.clientY:e.touches?.[0].clientY;return{x:s-(t?.left??0),y:i-(t?.top??0)}},dl=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0,wo=({id:e,path:t,labelX:r,labelY:s,label:i,labelStyle:a,labelShowBg:c,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:E,markerStart:v,interactionWidth:x=20})=>te.createElement(te.Fragment,null,te.createElement("path",{id:e,style:m,d:t,fill:"none",className:"react-flow__edge-path",markerEnd:E,markerStart:v}),x&&te.createElement("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:x,className:"react-flow__edge-interaction"}),i&&Yt(r)&&Yt(s)?te.createElement(jw,{x:r,y:s,label:i,labelStyle:a,labelShowBg:c,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:p}):null);wo.displayName="BaseEdge";function ks(e,t,r){return r===void 0?r:s=>{const i=t().edges.find(a=>a.id===e);i&&r(s,{...i})}}function mh({sourceX:e,sourceY:t,targetX:r,targetY:s}){const i=Math.abs(r-e)/2,a=r<e?r+i:r-i,c=Math.abs(s-t)/2,u=s<t?s+c:s-c;return[a,u,i,c]}function gh({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:i,sourceControlY:a,targetControlX:c,targetControlY:u}){const f=e*.125+i*.375+c*.375+r*.125,p=t*.125+a*.375+u*.375+s*.125,m=Math.abs(f-e),E=Math.abs(p-t);return[f,p,m,E]}var ar;(function(e){e.Strict="strict",e.Loose="loose"})(ar||(ar={}));var $r;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})($r||($r={}));var Ms;(function(e){e.Partial="partial",e.Full="full"})(Ms||(Ms={}));var cr;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(cr||(cr={}));var Ps;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Ps||(Ps={}));var xe;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(xe||(xe={}));function Eh({pos:e,x1:t,y1:r,x2:s,y2:i}){return e===xe.Left||e===xe.Right?[.5*(t+s),r]:[t,.5*(r+i)]}function yh({sourceX:e,sourceY:t,sourcePosition:r=xe.Bottom,targetX:s,targetY:i,targetPosition:a=xe.Top}){const[c,u]=Eh({pos:r,x1:e,y1:t,x2:s,y2:i}),[f,p]=Eh({pos:a,x1:s,y1:i,x2:e,y2:t}),[m,E,v,x]=gh({sourceX:e,sourceY:t,targetX:s,targetY:i,sourceControlX:c,sourceControlY:u,targetControlX:f,targetControlY:p});return[`M${e},${t} C${c},${u} ${f},${p} ${s},${i}`,m,E,v,x]}const Xc=b.memo(({sourceX:e,sourceY:t,targetX:r,targetY:s,sourcePosition:i=xe.Bottom,targetPosition:a=xe.Top,label:c,labelStyle:u,labelShowBg:f,labelBgStyle:p,labelBgPadding:m,labelBgBorderRadius:E,style:v,markerEnd:x,markerStart:_,interactionWidth:w})=>{const[S,N,O]=yh({sourceX:e,sourceY:t,sourcePosition:i,targetX:r,targetY:s,targetPosition:a});return te.createElement(wo,{path:S,labelX:N,labelY:O,label:c,labelStyle:u,labelShowBg:f,labelBgStyle:p,labelBgPadding:m,labelBgBorderRadius:E,style:v,markerEnd:x,markerStart:_,interactionWidth:w})});Xc.displayName="SimpleBezierEdge";const vh={[xe.Left]:{x:-1,y:0},[xe.Right]:{x:1,y:0},[xe.Top]:{x:0,y:-1},[xe.Bottom]:{x:0,y:1}},Ww=({source:e,sourcePosition:t=xe.Bottom,target:r})=>t===xe.Left||t===xe.Right?e.x<r.x?{x:1,y:0}:{x:-1,y:0}:e.y<r.y?{x:0,y:1}:{x:0,y:-1},xh=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function Gw({source:e,sourcePosition:t=xe.Bottom,target:r,targetPosition:s=xe.Top,center:i,offset:a}){const c=vh[t],u=vh[s],f={x:e.x+c.x*a,y:e.y+c.y*a},p={x:r.x+u.x*a,y:r.y+u.y*a},m=Ww({source:f,sourcePosition:t,target:p}),E=m.x!==0?"x":"y",v=m[E];let x=[],_,w;const S={x:0,y:0},N={x:0,y:0},[O,D,T,A]=mh({sourceX:e.x,sourceY:e.y,targetX:r.x,targetY:r.y});if(c[E]*u[E]===-1){_=i.x||O,w=i.y||D;const F=[{x:_,y:f.y},{x:_,y:p.y}],K=[{x:f.x,y:w},{x:p.x,y:w}];c[E]===v?x=E==="x"?F:K:x=E==="x"?K:F}else{const F=[{x:f.x,y:p.y}],K=[{x:p.x,y:f.y}];if(E==="x"?x=c.x===v?K:F:x=c.y===v?F:K,t===s){const W=Math.abs(e[E]-r[E]);if(W<=a){const I=Math.min(a-1,a-W);c[E]===v?S[E]=(f[E]>e[E]?-1:1)*I:N[E]=(p[E]>r[E]?-1:1)*I}}if(t!==s){const W=E==="x"?"y":"x",I=c[E]===u[W],V=f[W]>p[W],j=f[W]<p[W];(c[E]===1&&(!I&&V||I&&j)||c[E]!==1&&(!I&&j||I&&V))&&(x=E==="x"?F:K)}const Q={x:f.x+S.x,y:f.y+S.y},X={x:p.x+N.x,y:p.y+N.y},ee=Math.max(Math.abs(Q.x-x[0].x),Math.abs(X.x-x[0].x)),ne=Math.max(Math.abs(Q.y-x[0].y),Math.abs(X.y-x[0].y));ee>=ne?(_=(Q.x+X.x)/2,w=x[0].y):(_=x[0].x,w=(Q.y+X.y)/2)}return[[e,{x:f.x+S.x,y:f.y+S.y},...x,{x:p.x+N.x,y:p.y+N.y},r],_,w,T,A]}function Yw(e,t,r,s){const i=Math.min(xh(e,t)/2,xh(t,r)/2,s),{x:a,y:c}=t;if(e.x===a&&a===r.x||e.y===c&&c===r.y)return`L${a} ${c}`;if(e.y===c){const p=e.x<r.x?-1:1,m=e.y<r.y?1:-1;return`L ${a+i*p},${c}Q ${a},${c} ${a},${c+i*m}`}const u=e.x<r.x?1:-1,f=e.y<r.y?-1:1;return`L ${a},${c+i*f}Q ${a},${c} ${a+i*u},${c}`}function Us({sourceX:e,sourceY:t,sourcePosition:r=xe.Bottom,targetX:s,targetY:i,targetPosition:a=xe.Top,borderRadius:c=5,centerX:u,centerY:f,offset:p=20}){const[m,E,v,x,_]=Gw({source:{x:e,y:t},sourcePosition:r,target:{x:s,y:i},targetPosition:a,center:{x:u,y:f},offset:p});return[m.reduce((S,N,O)=>{let D="";return O>0&&O<m.length-1?D=Yw(m[O-1],N,m[O+1],c):D=`${O===0?"M":"L"}${N.x} ${N.y}`,S+=D,S},""),E,v,x,_]}const fl=b.memo(({sourceX:e,sourceY:t,targetX:r,targetY:s,label:i,labelStyle:a,labelShowBg:c,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:p,style:m,sourcePosition:E=xe.Bottom,targetPosition:v=xe.Top,markerEnd:x,markerStart:_,pathOptions:w,interactionWidth:S})=>{const[N,O,D]=Us({sourceX:e,sourceY:t,sourcePosition:E,targetX:r,targetY:s,targetPosition:v,borderRadius:w?.borderRadius,offset:w?.offset});return te.createElement(wo,{path:N,labelX:O,labelY:D,label:i,labelStyle:a,labelShowBg:c,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:x,markerStart:_,interactionWidth:S})});fl.displayName="SmoothStepEdge";const Qc=b.memo(e=>te.createElement(fl,{...e,pathOptions:b.useMemo(()=>({borderRadius:0,offset:e.pathOptions?.offset}),[e.pathOptions?.offset])}));Qc.displayName="StepEdge";function Kw({sourceX:e,sourceY:t,targetX:r,targetY:s}){const[i,a,c,u]=mh({sourceX:e,sourceY:t,targetX:r,targetY:s});return[`M ${e},${t}L ${r},${s}`,i,a,c,u]}const qc=b.memo(({sourceX:e,sourceY:t,targetX:r,targetY:s,label:i,labelStyle:a,labelShowBg:c,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:E,markerStart:v,interactionWidth:x})=>{const[_,w,S]=Kw({sourceX:e,sourceY:t,targetX:r,targetY:s});return te.createElement(wo,{path:_,labelX:w,labelY:S,label:i,labelStyle:a,labelShowBg:c,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:E,markerStart:v,interactionWidth:x})});qc.displayName="StraightEdge";function pl(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Sh({pos:e,x1:t,y1:r,x2:s,y2:i,c:a}){switch(e){case xe.Left:return[t-pl(t-s,a),r];case xe.Right:return[t+pl(s-t,a),r];case xe.Top:return[t,r-pl(r-i,a)];case xe.Bottom:return[t,r+pl(i-r,a)]}}function _h({sourceX:e,sourceY:t,sourcePosition:r=xe.Bottom,targetX:s,targetY:i,targetPosition:a=xe.Top,curvature:c=.25}){const[u,f]=Sh({pos:r,x1:e,y1:t,x2:s,y2:i,c}),[p,m]=Sh({pos:a,x1:s,y1:i,x2:e,y2:t,c}),[E,v,x,_]=gh({sourceX:e,sourceY:t,targetX:s,targetY:i,sourceControlX:u,sourceControlY:f,targetControlX:p,targetControlY:m});return[`M${e},${t} C${u},${f} ${p},${m} ${s},${i}`,E,v,x,_]}const hl=b.memo(({sourceX:e,sourceY:t,targetX:r,targetY:s,sourcePosition:i=xe.Bottom,targetPosition:a=xe.Top,label:c,labelStyle:u,labelShowBg:f,labelBgStyle:p,labelBgPadding:m,labelBgBorderRadius:E,style:v,markerEnd:x,markerStart:_,pathOptions:w,interactionWidth:S})=>{const[N,O,D]=_h({sourceX:e,sourceY:t,sourcePosition:i,targetX:r,targetY:s,targetPosition:a,curvature:w?.curvature});return te.createElement(wo,{path:N,labelX:O,labelY:D,label:c,labelStyle:u,labelShowBg:f,labelBgStyle:p,labelBgPadding:m,labelBgBorderRadius:E,style:v,markerEnd:x,markerStart:_,interactionWidth:S})});hl.displayName="BezierEdge";const Zc=b.createContext(null),Xw=Zc.Provider;Zc.Consumer;const Qw=()=>b.useContext(Zc),qw=e=>"id"in e&&"source"in e&&"target"in e,wh=({source:e,sourceHandle:t,target:r,targetHandle:s})=>`reactflow__edge-${e}${t||""}-${r}${s||""}`,Jc=(e,t)=>typeof e>"u"?"":typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(s=>`${s}=${e[s]}`).join("&")}`,Zw=(e,t)=>t.some(r=>r.source===e.source&&r.target===e.target&&(r.sourceHandle===e.sourceHandle||!r.sourceHandle&&!e.sourceHandle)&&(r.targetHandle===e.targetHandle||!r.targetHandle&&!e.targetHandle)),Nh=(e,t)=>{if(!e.source||!e.target)return t;let r;return qw(e)?r={...e}:r={...e,id:wh(e)},Zw(r,t)?t:t.concat(r)},Jw=(e,t,r,s={shouldReplaceId:!0})=>{const{id:i,...a}=e;if(!t.source||!t.target||!r.find(f=>f.id===i))return r;const u={...a,id:s.shouldReplaceId?wh(t):i,source:t.source,target:t.target,sourceHandle:t.sourceHandle,targetHandle:t.targetHandle};return r.filter(f=>f.id!==i).concat(u)},eu=({x:e,y:t},[r,s,i],a,[c,u])=>{const f={x:(e-r)/i,y:(t-s)/i};return a?{x:c*Math.round(f.x/c),y:u*Math.round(f.y/u)}:f},Rh=({x:e,y:t},[r,s,i])=>({x:e*i+r,y:t*i+s}),No=(e,t=[0,0])=>{if(!e)return{x:0,y:0,positionAbsolute:{x:0,y:0}};const r=(e.width??0)*t[0],s=(e.height??0)*t[1],i={x:e.position.x-r,y:e.position.y-s};return{...i,positionAbsolute:e.positionAbsolute?{x:e.positionAbsolute.x-r,y:e.positionAbsolute.y-s}:i}},tu=(e,t=[0,0])=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const r=e.reduce((s,i)=>{const{x:a,y:c}=No(i,t).positionAbsolute;return Vw(s,Gc({x:a,y:c,width:i.width||0,height:i.height||0}))},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return $w(r)},Th=(e,t,[r,s,i]=[0,0,1],a=!1,c=!1,u=[0,0])=>{const f={x:(t.x-r)/i,y:(t.y-s)/i,width:t.width/i,height:t.height/i},p=[];return e.forEach(m=>{const{width:E,height:v,selectable:x=!0,hidden:_=!1}=m;if(c&&!x||_)return!1;const{positionAbsolute:w}=No(m,u),S={x:w.x,y:w.y,width:E||0,height:v||0},N=Yc(f,S),O=typeof E>"u"||typeof v>"u"||E===null||v===null,D=a&&N>0,T=(E||0)*(v||0);(O||D||N>=T||m.dragging)&&p.push(m)}),p},Oh=(e,t)=>{const r=e.map(s=>s.id);return t.filter(s=>r.includes(s.source)||r.includes(s.target))},Ch=(e,t,r,s,i,a=.1)=>{const c=t/(e.width*(1+a)),u=r/(e.height*(1+a)),f=Math.min(c,u),p=_o(f,s,i),m=e.x+e.width/2,E=e.y+e.height/2,v=t/2-m*p,x=r/2-E*p;return{x:v,y:x,zoom:p}},Hr=(e,t=0)=>e.transition().duration(t);function Ah(e,t,r,s){return(t[r]||[]).reduce((i,a)=>(`${e.id}-${a.id}-${r}`!==s&&i.push({id:a.id||null,type:r,nodeId:e.id,x:(e.positionAbsolute?.x??0)+a.x+a.width/2,y:(e.positionAbsolute?.y??0)+a.y+a.height/2}),i),[])}function eN(e,t,r,s,i,a){const{x:c,y:u}=lr(e),p=t.elementsFromPoint(c,u).find(_=>_.classList.contains("react-flow__handle"));if(p){const _=p.getAttribute("data-nodeid");if(_){const w=nu(void 0,p),S=p.getAttribute("data-handleid"),N=a({nodeId:_,id:S,type:w});if(N){const O=i.find(D=>D.nodeId===_&&D.type===w&&D.id===S);return{handle:{id:S,type:w,nodeId:_,x:O?.x||r.x,y:O?.y||r.y},validHandleResult:N}}}}let m=[],E=1/0;if(i.forEach(_=>{const w=Math.sqrt((_.x-r.x)**2+(_.y-r.y)**2);if(w<=s){const S=a(_);w<=E&&(w<E?m=[{handle:_,validHandleResult:S}]:w===E&&m.push({handle:_,validHandleResult:S}),E=w)}}),!m.length)return{handle:null,validHandleResult:Ih()};if(m.length===1)return m[0];const v=m.some(({validHandleResult:_})=>_.isValid),x=m.some(({handle:_})=>_.type==="target");return m.find(({handle:_,validHandleResult:w})=>x?_.type==="target":v?w.isValid:!0)||m[0]}const tN={source:null,target:null,sourceHandle:null,targetHandle:null},Ih=()=>({handleDomNode:null,isValid:!1,connection:tN,endHandle:null});function bh(e,t,r,s,i,a,c){const u=i==="target",f=c.querySelector(`.react-flow__handle[data-id="${e?.nodeId}-${e?.id}-${e?.type}"]`),p={...Ih(),handleDomNode:f};if(f){const m=nu(void 0,f),E=f.getAttribute("data-nodeid"),v=f.getAttribute("data-handleid"),x=f.classList.contains("connectable"),_=f.classList.contains("connectableend"),w={source:u?E:r,sourceHandle:u?v:s,target:u?r:E,targetHandle:u?s:v};p.connection=w,x&&_&&(t===ar.Strict?u&&m==="source"||!u&&m==="target":E!==r||v!==s)&&(p.endHandle={nodeId:E,handleId:v,type:m},p.isValid=a(w))}return p}function nN({nodes:e,nodeId:t,handleId:r,handleType:s}){return e.reduce((i,a)=>{if(a[nt]){const{handleBounds:c}=a[nt];let u=[],f=[];c&&(u=Ah(a,c,"source",`${t}-${r}-${s}`),f=Ah(a,c,"target",`${t}-${r}-${s}`)),i.push(...u,...f)}return i},[])}function nu(e,t){return e||(t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null)}function ru(e){e?.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function rN(e,t){let r=null;return t?r="valid":e&&!t&&(r="invalid"),r}function Lh({event:e,handleId:t,nodeId:r,onConnect:s,isTarget:i,getState:a,setState:c,isValidConnection:u,edgeUpdaterType:f,onEdgeUpdateEnd:p}){const m=dh(e.target),{connectionMode:E,domNode:v,autoPanOnConnect:x,connectionRadius:_,onConnectStart:w,panBy:S,getNodes:N,cancelConnection:O}=a();let D=0,T;const{x:A,y:L}=lr(e),F=m?.elementFromPoint(A,L),K=nu(f,F),Q=v?.getBoundingClientRect();if(!Q||!K)return;let X,ee=lr(e,Q),ne=!1,W=null,I=!1,V=null;const j=nN({nodes:N(),nodeId:r,handleId:t,handleType:K}),B=()=>{if(!x)return;const[z,k]=uh(ee,Q);S({x:z,y:k}),D=requestAnimationFrame(B)};c({connectionPosition:ee,connectionStatus:null,connectionNodeId:r,connectionHandleId:t,connectionHandleType:K,connectionStartHandle:{nodeId:r,handleId:t,type:K},connectionEndHandle:null}),w?.(e,{nodeId:r,handleId:t,handleType:K});function U(z){const{transform:k}=a();ee=lr(z,Q);const{handle:Y,validHandleResult:re}=eN(z,m,eu(ee,k,!1,[1,1]),_,j,oe=>bh(oe,E,r,t,i?"target":"source",u,m));if(T=Y,ne||(B(),ne=!0),V=re.handleDomNode,W=re.connection,I=re.isValid,c({connectionPosition:T&&I?Rh({x:T.x,y:T.y},k):ee,connectionStatus:rN(!!T,I),connectionEndHandle:re.endHandle}),!T&&!I&&!V)return ru(X);W.source!==W.target&&V&&(ru(X),X=V,V.classList.add("connecting","react-flow__handle-connecting"),V.classList.toggle("valid",I),V.classList.toggle("react-flow__handle-valid",I))}function $(z){(T||V)&&W&&I&&s?.(W),a().onConnectEnd?.(z),f&&p?.(z),ru(X),O(),cancelAnimationFrame(D),ne=!1,I=!1,W=null,V=null,m.removeEventListener("mousemove",U),m.removeEventListener("mouseup",$),m.removeEventListener("touchmove",U),m.removeEventListener("touchend",$)}m.addEventListener("mousemove",U),m.addEventListener("mouseup",$),m.addEventListener("touchmove",U),m.addEventListener("touchend",$)}const Dh=()=>!0,oN=e=>({connectionStartHandle:e.connectionStartHandle,connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName}),sN=(e,t,r)=>s=>{const{connectionStartHandle:i,connectionEndHandle:a,connectionClickStartHandle:c}=s;return{connecting:i?.nodeId===e&&i?.handleId===t&&i?.type===r||a?.nodeId===e&&a?.handleId===t&&a?.type===r,clickConnecting:c?.nodeId===e&&c?.handleId===t&&c?.type===r}},kh=b.forwardRef(({type:e="source",position:t=xe.Top,isValidConnection:r,isConnectable:s=!0,isConnectableStart:i=!0,isConnectableEnd:a=!0,id:c,onConnect:u,children:f,className:p,onMouseDown:m,onTouchStart:E,...v},x)=>{const _=c||null,w=e==="target",S=tt(),N=Qw(),{connectOnClick:O,noPanClassName:D}=Me(oN,gt),{connecting:T,clickConnecting:A}=Me(sN(N,_,e),gt);N||S.getState().onError?.("010",Vn.error010());const L=Q=>{const{defaultEdgeOptions:X,onConnect:ee,hasDefaultEdges:ne}=S.getState(),W={...X,...Q};if(ne){const{edges:I,setEdges:V}=S.getState();V(Nh(W,I))}ee?.(W),u?.(W)},F=Q=>{if(!N)return;const X=hh(Q);i&&(X&&Q.button===0||!X)&&Lh({event:Q,handleId:_,nodeId:N,onConnect:L,isTarget:w,getState:S.getState,setState:S.setState,isValidConnection:r||S.getState().isValidConnection||Dh}),X?m?.(Q):E?.(Q)},K=Q=>{const{onClickConnectStart:X,onClickConnectEnd:ee,connectionClickStartHandle:ne,connectionMode:W,isValidConnection:I}=S.getState();if(!N||!ne&&!i)return;if(!ne){X?.(Q,{nodeId:N,handleId:_,handleType:e}),S.setState({connectionClickStartHandle:{nodeId:N,type:e,handleId:_}});return}const V=dh(Q.target),j=r||I||Dh,{connection:B,isValid:U}=bh({nodeId:N,id:_,type:e},W,ne.nodeId,ne.handleId||null,ne.type,j,V);U&&L(B),ee?.(Q),S.setState({connectionClickStartHandle:null})};return te.createElement("div",{"data-handleid":_,"data-nodeid":N,"data-handlepos":t,"data-id":`${N}-${_}-${e}`,className:St(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",D,p,{source:!w,target:w,connectable:s,connectablestart:i,connectableend:a,connecting:A,connectionindicator:s&&(i&&!T||a&&T)}]),onMouseDown:F,onTouchStart:F,onClick:O?K:void 0,ref:x,...v},f)});kh.displayName="Handle";var Ro=b.memo(kh);const Mh=({data:e,isConnectable:t,targetPosition:r=xe.Top,sourcePosition:s=xe.Bottom})=>te.createElement(te.Fragment,null,te.createElement(Ro,{type:"target",position:r,isConnectable:t}),e?.label,te.createElement(Ro,{type:"source",position:s,isConnectable:t}));Mh.displayName="DefaultNode";var ou=b.memo(Mh);const Ph=({data:e,isConnectable:t,sourcePosition:r=xe.Bottom})=>te.createElement(te.Fragment,null,e?.label,te.createElement(Ro,{type:"source",position:r,isConnectable:t}));Ph.displayName="InputNode";var Uh=b.memo(Ph);const Fh=({data:e,isConnectable:t,targetPosition:r=xe.Top})=>te.createElement(te.Fragment,null,te.createElement(Ro,{type:"target",position:r,isConnectable:t}),e?.label);Fh.displayName="OutputNode";var jh=b.memo(Fh);const su=()=>null;su.displayName="GroupNode";const iN=e=>({selectedNodes:e.getNodes().filter(t=>t.selected),selectedEdges:e.edges.filter(t=>t.selected)}),ml=e=>e.id;function lN(e,t){return gt(e.selectedNodes.map(ml),t.selectedNodes.map(ml))&>(e.selectedEdges.map(ml),t.selectedEdges.map(ml))}const Vh=b.memo(({onSelectionChange:e})=>{const t=tt(),{selectedNodes:r,selectedEdges:s}=Me(iN,lN);return b.useEffect(()=>{const i={nodes:r,edges:s};e?.(i),t.getState().onSelectionChange.forEach(a=>a(i))},[r,s,e]),null});Vh.displayName="SelectionListener";const aN=e=>!!e.onSelectionChange;function cN({onSelectionChange:e}){const t=Me(aN);return e||t?te.createElement(Vh,{onSelectionChange:e}):null}const uN=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset});function To(e,t){b.useEffect(()=>{typeof e<"u"&&t(e)},[e])}function Oe(e,t,r){b.useEffect(()=>{typeof t<"u"&&r({[e]:t})},[t])}const dN=({nodes:e,edges:t,defaultNodes:r,defaultEdges:s,onConnect:i,onConnectStart:a,onConnectEnd:c,onClickConnectStart:u,onClickConnectEnd:f,nodesDraggable:p,nodesConnectable:m,nodesFocusable:E,edgesFocusable:v,edgesUpdatable:x,elevateNodesOnSelect:_,minZoom:w,maxZoom:S,nodeExtent:N,onNodesChange:O,onEdgesChange:D,elementsSelectable:T,connectionMode:A,snapGrid:L,snapToGrid:F,translateExtent:K,connectOnClick:Q,defaultEdgeOptions:X,fitView:ee,fitViewOptions:ne,onNodesDelete:W,onEdgesDelete:I,onNodeDrag:V,onNodeDragStart:j,onNodeDragStop:B,onSelectionDrag:U,onSelectionDragStart:$,onSelectionDragStop:z,noPanClassName:k,nodeOrigin:Y,rfId:re,autoPanOnConnect:oe,autoPanOnNodeDrag:le,onError:de,connectionRadius:he,isValidConnection:ue,nodeDragThreshold:me})=>{const{setNodes:Re,setEdges:Pe,setDefaultNodesAndEdges:Je,setMinZoom:wt,setMaxZoom:Be,setTranslateExtent:Ue,setNodeExtent:ft,reset:pt}=Me(uN,gt),we=tt();return b.useEffect(()=>{const un=s?.map(Ht=>({...Ht,...X}));return Je(r,un),()=>{pt()}},[]),Oe("defaultEdgeOptions",X,we.setState),Oe("connectionMode",A,we.setState),Oe("onConnect",i,we.setState),Oe("onConnectStart",a,we.setState),Oe("onConnectEnd",c,we.setState),Oe("onClickConnectStart",u,we.setState),Oe("onClickConnectEnd",f,we.setState),Oe("nodesDraggable",p,we.setState),Oe("nodesConnectable",m,we.setState),Oe("nodesFocusable",E,we.setState),Oe("edgesFocusable",v,we.setState),Oe("edgesUpdatable",x,we.setState),Oe("elementsSelectable",T,we.setState),Oe("elevateNodesOnSelect",_,we.setState),Oe("snapToGrid",F,we.setState),Oe("snapGrid",L,we.setState),Oe("onNodesChange",O,we.setState),Oe("onEdgesChange",D,we.setState),Oe("connectOnClick",Q,we.setState),Oe("fitViewOnInit",ee,we.setState),Oe("fitViewOnInitOptions",ne,we.setState),Oe("onNodesDelete",W,we.setState),Oe("onEdgesDelete",I,we.setState),Oe("onNodeDrag",V,we.setState),Oe("onNodeDragStart",j,we.setState),Oe("onNodeDragStop",B,we.setState),Oe("onSelectionDrag",U,we.setState),Oe("onSelectionDragStart",$,we.setState),Oe("onSelectionDragStop",z,we.setState),Oe("noPanClassName",k,we.setState),Oe("nodeOrigin",Y,we.setState),Oe("rfId",re,we.setState),Oe("autoPanOnConnect",oe,we.setState),Oe("autoPanOnNodeDrag",le,we.setState),Oe("onError",de,we.setState),Oe("connectionRadius",he,we.setState),Oe("isValidConnection",ue,we.setState),Oe("nodeDragThreshold",me,we.setState),To(e,Re),To(t,Pe),To(w,wt),To(S,Be),To(K,Ue),To(N,ft),null},$h={display:"none"},fN={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Hh="react-flow__node-desc",Bh="react-flow__edge-desc",pN="react-flow__aria-live",hN=e=>e.ariaLiveMessage;function mN({rfId:e}){const t=Me(hN);return te.createElement("div",{id:`${pN}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:fN},t)}function gN({rfId:e,disableKeyboardA11y:t}){return te.createElement(te.Fragment,null,te.createElement("div",{id:`${Hh}-${e}`,style:$h},"Press enter or space to select a node.",!t&&"You can then use the arrow keys to move the node around."," Press delete to remove it and escape to cancel."," "),te.createElement("div",{id:`${Bh}-${e}`,style:$h},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!t&&te.createElement(mN,{rfId:e}))}var Oo=(e=null,t={actInsideInputWithModifier:!0})=>{const[r,s]=b.useState(!1),i=b.useRef(!1),a=b.useRef(new Set([])),[c,u]=b.useMemo(()=>{if(e!==null){const p=(Array.isArray(e)?e:[e]).filter(E=>typeof E=="string").map(E=>E.split("+")),m=p.reduce((E,v)=>E.concat(...v),[]);return[p,m]}return[[],[]]},[e]);return b.useEffect(()=>{const f=typeof document<"u"?document:null,p=t?.target||f;if(e!==null){const m=x=>{if(i.current=x.ctrlKey||x.metaKey||x.shiftKey,(!i.current||i.current&&!t.actInsideInputWithModifier)&&Kc(x))return!1;const w=Wh(x.code,u);a.current.add(x[w]),zh(c,a.current,!1)&&(x.preventDefault(),s(!0))},E=x=>{if((!i.current||i.current&&!t.actInsideInputWithModifier)&&Kc(x))return!1;const w=Wh(x.code,u);zh(c,a.current,!0)?(s(!1),a.current.clear()):a.current.delete(x[w]),x.key==="Meta"&&a.current.clear(),i.current=!1},v=()=>{a.current.clear(),s(!1)};return p?.addEventListener("keydown",m),p?.addEventListener("keyup",E),window.addEventListener("blur",v),()=>{p?.removeEventListener("keydown",m),p?.removeEventListener("keyup",E),window.removeEventListener("blur",v)}}},[e,s]),r};function zh(e,t,r){return e.filter(s=>r||s.length===t.size).some(s=>s.every(i=>t.has(i)))}function Wh(e,t){return t.includes(e)?"code":"key"}function Gh(e,t,r,s){if(!e.parentNode)return r;const i=t.get(e.parentNode),a=No(i,s);return Gh(i,t,{x:(r.x??0)+a.x,y:(r.y??0)+a.y,z:(i[nt]?.z??0)>(r.z??0)?i[nt]?.z??0:r.z??0},s)}function Yh(e,t,r){e.forEach(s=>{if(s.parentNode&&!e.has(s.parentNode))throw new Error(`Parent node ${s.parentNode} not found`);if(s.parentNode||r?.[s.id]){const{x:i,y:a,z:c}=Gh(s,e,{...s.position,z:s[nt]?.z??0},t);s.positionAbsolute={x:i,y:a},s[nt].z=c,r?.[s.id]&&(s[nt].isParent=!0)}})}function iu(e,t,r,s){const i=new Map,a={},c=s?1e3:0;return e.forEach(u=>{const f=(Yt(u.zIndex)?u.zIndex:0)+(u.selected?c:0),p=t.get(u.id),m={width:p?.width,height:p?.height,...u,positionAbsolute:{x:u.position.x,y:u.position.y}};u.parentNode&&(m.parentNode=u.parentNode,a[u.parentNode]=!0),Object.defineProperty(m,nt,{enumerable:!1,value:{handleBounds:p?.[nt]?.handleBounds,z:f}}),i.set(u.id,m)}),Yh(i,r,a),i}function Kh(e,t={}){const{getNodes:r,width:s,height:i,minZoom:a,maxZoom:c,d3Zoom:u,d3Selection:f,fitViewOnInitDone:p,fitViewOnInit:m,nodeOrigin:E}=e(),v=t.initial&&!p&&m;if(u&&f&&(v||!t.initial)){const _=r().filter(S=>{const N=t.includeHiddenNodes?S.width&&S.height:!S.hidden;return t.nodes?.length?N&&t.nodes.some(O=>O.id===S.id):N}),w=_.every(S=>S.width&&S.height);if(_.length>0&&w){const S=tu(_,E),{x:N,y:O,zoom:D}=Ch(S,s,i,t.minZoom??a,t.maxZoom??c,t.padding??.1),T=ir.translate(N,O).scale(D);return typeof t.duration=="number"&&t.duration>0?u.transform(Hr(f,t.duration),T):u.transform(f,T),!0}}return!1}function EN(e,t){return e.forEach(r=>{const s=t.get(r.id);s&&t.set(s.id,{...s,[nt]:s[nt],selected:r.selected})}),new Map(t)}function yN(e,t){return t.map(r=>{const s=e.find(i=>i.id===r.id);return s&&(r.selected=s.selected),r})}function gl({changedNodes:e,changedEdges:t,get:r,set:s}){const{nodeInternals:i,edges:a,onNodesChange:c,onEdgesChange:u,hasDefaultNodes:f,hasDefaultEdges:p}=r();e?.length&&(f&&s({nodeInternals:EN(e,i)}),c?.(e)),t?.length&&(p&&s({edges:yN(t,a)}),u?.(t))}const Co=()=>{},vN={zoomIn:Co,zoomOut:Co,zoomTo:Co,getZoom:()=>1,setViewport:Co,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:Co,fitBounds:Co,project:e=>e,screenToFlowPosition:e=>e,flowToScreenPosition:e=>e,viewportInitialized:!1},xN=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection}),SN=()=>{const e=tt(),{d3Zoom:t,d3Selection:r}=Me(xN,gt);return b.useMemo(()=>r&&t?{zoomIn:i=>t.scaleBy(Hr(r,i?.duration),1.2),zoomOut:i=>t.scaleBy(Hr(r,i?.duration),1/1.2),zoomTo:(i,a)=>t.scaleTo(Hr(r,a?.duration),i),getZoom:()=>e.getState().transform[2],setViewport:(i,a)=>{const[c,u,f]=e.getState().transform,p=ir.translate(i.x??c,i.y??u).scale(i.zoom??f);t.transform(Hr(r,a?.duration),p)},getViewport:()=>{const[i,a,c]=e.getState().transform;return{x:i,y:a,zoom:c}},fitView:i=>Kh(e.getState,i),setCenter:(i,a,c)=>{const{width:u,height:f,maxZoom:p}=e.getState(),m=typeof c?.zoom<"u"?c.zoom:p,E=u/2-i*m,v=f/2-a*m,x=ir.translate(E,v).scale(m);t.transform(Hr(r,c?.duration),x)},fitBounds:(i,a)=>{const{width:c,height:u,minZoom:f,maxZoom:p}=e.getState(),{x:m,y:E,zoom:v}=Ch(i,c,u,f,p,a?.padding??.1),x=ir.translate(m,E).scale(v);t.transform(Hr(r,a?.duration),x)},project:i=>{const{transform:a,snapToGrid:c,snapGrid:u}=e.getState();return console.warn("[DEPRECATED] `project` is deprecated. Instead use `screenToFlowPosition`. There is no need to subtract the react flow bounds anymore! https://reactflow.dev/api-reference/types/react-flow-instance#screen-to-flow-position"),eu(i,a,c,u)},screenToFlowPosition:i=>{const{transform:a,snapToGrid:c,snapGrid:u,domNode:f}=e.getState();if(!f)return i;const{x:p,y:m}=f.getBoundingClientRect(),E={x:i.x-p,y:i.y-m};return eu(E,a,c,u)},flowToScreenPosition:i=>{const{transform:a,domNode:c}=e.getState();if(!c)return i;const{x:u,y:f}=c.getBoundingClientRect(),p=Rh(i,a);return{x:p.x+u,y:p.y+f}},viewportInitialized:!0}:vN,[t,r])};function lu(){const e=SN(),t=tt(),r=b.useCallback(()=>t.getState().getNodes().map(w=>({...w})),[]),s=b.useCallback(w=>t.getState().nodeInternals.get(w),[]),i=b.useCallback(()=>{const{edges:w=[]}=t.getState();return w.map(S=>({...S}))},[]),a=b.useCallback(w=>{const{edges:S=[]}=t.getState();return S.find(N=>N.id===w)},[]),c=b.useCallback(w=>{const{getNodes:S,setNodes:N,hasDefaultNodes:O,onNodesChange:D}=t.getState(),T=S(),A=typeof w=="function"?w(T):w;if(O)N(A);else if(D){const L=A.length===0?T.map(F=>({type:"remove",id:F.id})):A.map(F=>({item:F,type:"reset"}));D(L)}},[]),u=b.useCallback(w=>{const{edges:S=[],setEdges:N,hasDefaultEdges:O,onEdgesChange:D}=t.getState(),T=typeof w=="function"?w(S):w;if(O)N(T);else if(D){const A=T.length===0?S.map(L=>({type:"remove",id:L.id})):T.map(L=>({item:L,type:"reset"}));D(A)}},[]),f=b.useCallback(w=>{const S=Array.isArray(w)?w:[w],{getNodes:N,setNodes:O,hasDefaultNodes:D,onNodesChange:T}=t.getState();if(D){const L=[...N(),...S];O(L)}else if(T){const A=S.map(L=>({item:L,type:"add"}));T(A)}},[]),p=b.useCallback(w=>{const S=Array.isArray(w)?w:[w],{edges:N=[],setEdges:O,hasDefaultEdges:D,onEdgesChange:T}=t.getState();if(D)O([...N,...S]);else if(T){const A=S.map(L=>({item:L,type:"add"}));T(A)}},[]),m=b.useCallback(()=>{const{getNodes:w,edges:S=[],transform:N}=t.getState(),[O,D,T]=N;return{nodes:w().map(A=>({...A})),edges:S.map(A=>({...A})),viewport:{x:O,y:D,zoom:T}}},[]),E=b.useCallback(({nodes:w,edges:S})=>{const{nodeInternals:N,getNodes:O,edges:D,hasDefaultNodes:T,hasDefaultEdges:A,onNodesDelete:L,onEdgesDelete:F,onNodesChange:K,onEdgesChange:Q}=t.getState(),X=(w||[]).map(V=>V.id),ee=(S||[]).map(V=>V.id),ne=O().reduce((V,j)=>{const B=!X.includes(j.id)&&j.parentNode&&V.find($=>$.id===j.parentNode);return(typeof j.deletable=="boolean"?j.deletable:!0)&&(X.includes(j.id)||B)&&V.push(j),V},[]),W=D.filter(V=>typeof V.deletable=="boolean"?V.deletable:!0),I=W.filter(V=>ee.includes(V.id));if(ne||I){const V=Oh(ne,W),j=[...I,...V],B=j.reduce((U,$)=>(U.includes($.id)||U.push($.id),U),[]);if((A||T)&&(A&&t.setState({edges:D.filter(U=>!B.includes(U.id))}),T&&(ne.forEach(U=>{N.delete(U.id)}),t.setState({nodeInternals:new Map(N)}))),B.length>0&&(F?.(j),Q&&Q(B.map(U=>({id:U,type:"remove"})))),ne.length>0&&(L?.(ne),K)){const U=ne.map($=>({id:$.id,type:"remove"}));K(U)}}},[]),v=b.useCallback(w=>{const S=Hw(w),N=S?null:t.getState().nodeInternals.get(w.id);return[S?w:fh(N),N,S]},[]),x=b.useCallback((w,S=!0,N)=>{const[O,D,T]=v(w);return O?(N||t.getState().getNodes()).filter(A=>{if(!T&&(A.id===D.id||!A.positionAbsolute))return!1;const L=fh(A),F=Yc(L,O);return S&&F>0||F>=O.width*O.height}):[]},[]),_=b.useCallback((w,S,N=!0)=>{const[O]=v(w);if(!O)return!1;const D=Yc(O,S);return N&&D>0||D>=O.width*O.height},[]);return b.useMemo(()=>({...e,getNodes:r,getNode:s,getEdges:i,getEdge:a,setNodes:c,setEdges:u,addNodes:f,addEdges:p,toObject:m,deleteElements:E,getIntersectingNodes:x,isNodeIntersecting:_}),[e,r,s,i,a,c,u,f,p,m,E,x,_])}const _N={actInsideInputWithModifier:!1};var wN=({deleteKeyCode:e,multiSelectionKeyCode:t})=>{const r=tt(),{deleteElements:s}=lu(),i=Oo(e,_N),a=Oo(t);b.useEffect(()=>{if(i){const{edges:c,getNodes:u}=r.getState(),f=u().filter(m=>m.selected),p=c.filter(m=>m.selected);s({nodes:f,edges:p}),r.setState({nodesSelectionActive:!1})}},[i]),b.useEffect(()=>{r.setState({multiSelectionActive:a})},[a])};function NN(e){const t=tt();b.useEffect(()=>{let r;const s=()=>{if(!e.current)return;const i=zc(e.current);(i.height===0||i.width===0)&&t.getState().onError?.("004",Vn.error004()),t.setState({width:i.width||500,height:i.height||500})};return s(),window.addEventListener("resize",s),e.current&&(r=new ResizeObserver(()=>s()),r.observe(e.current)),()=>{window.removeEventListener("resize",s),r&&e.current&&r.unobserve(e.current)}},[])}const au={position:"absolute",width:"100%",height:"100%",top:0,left:0},RN=(e,t)=>e.x!==t.x||e.y!==t.y||e.zoom!==t.k,El=e=>({x:e.x,y:e.y,zoom:e.k}),Ao=(e,t)=>e.target.closest(`.${t}`),Xh=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),Qh=e=>{const t=e.ctrlKey&&dl()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t},TN=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection,d3ZoomHandler:e.d3ZoomHandler,userSelectionActive:e.userSelectionActive}),ON=({onMove:e,onMoveStart:t,onMoveEnd:r,onPaneContextMenu:s,zoomOnScroll:i=!0,zoomOnPinch:a=!0,panOnScroll:c=!1,panOnScrollSpeed:u=.5,panOnScrollMode:f=$r.Free,zoomOnDoubleClick:p=!0,elementsSelectable:m,panOnDrag:E=!0,defaultViewport:v,translateExtent:x,minZoom:_,maxZoom:w,zoomActivationKeyCode:S,preventScrolling:N=!0,children:O,noWheelClassName:D,noPanClassName:T})=>{const A=b.useRef(),L=tt(),F=b.useRef(!1),K=b.useRef(!1),Q=b.useRef(null),X=b.useRef({x:0,y:0,zoom:0}),{d3Zoom:ee,d3Selection:ne,d3ZoomHandler:W,userSelectionActive:I}=Me(TN,gt),V=Oo(S),j=b.useRef(0),B=b.useRef(!1),U=b.useRef();return NN(Q),b.useEffect(()=>{if(Q.current){const $=Q.current.getBoundingClientRect(),z=kw().scaleExtent([_,w]).translateExtent(x),k=on(Q.current).call(z),Y=ir.translate(v.x,v.y).scale(_o(v.zoom,_,w)),re=[[0,0],[$.width,$.height]],oe=z.constrain()(Y,re,x);z.transform(k,oe),z.wheelDelta(Qh),L.setState({d3Zoom:z,d3Selection:k,d3ZoomHandler:k.on("wheel.zoom"),transform:[oe.x,oe.y,oe.k],domNode:Q.current.closest(".react-flow")})}},[]),b.useEffect(()=>{ne&&ee&&(c&&!V&&!I?ne.on("wheel.zoom",$=>{if(Ao($,D))return!1;$.preventDefault(),$.stopImmediatePropagation();const z=ne.property("__zoom").k||1,k=dl();if($.ctrlKey&&a&&k){const me=_n($),Re=Qh($),Pe=z*Math.pow(2,Re);ee.scaleTo(ne,Pe,me,$);return}const Y=$.deltaMode===1?20:1;let re=f===$r.Vertical?0:$.deltaX*Y,oe=f===$r.Horizontal?0:$.deltaY*Y;!k&&$.shiftKey&&f!==$r.Vertical&&(re=$.deltaY*Y,oe=0),ee.translateBy(ne,-(re/z)*u,-(oe/z)*u,{internal:!0});const le=El(ne.property("__zoom")),{onViewportChangeStart:de,onViewportChange:he,onViewportChangeEnd:ue}=L.getState();clearTimeout(U.current),B.current||(B.current=!0,t?.($,le),de?.(le)),B.current&&(e?.($,le),he?.(le),U.current=setTimeout(()=>{r?.($,le),ue?.(le),B.current=!1},150))},{passive:!1}):typeof W<"u"&&ne.on("wheel.zoom",function($,z){if(!N||Ao($,D))return null;$.preventDefault(),W.call(this,$,z)},{passive:!1}))},[I,c,f,ne,ee,W,V,a,N,D,t,e,r]),b.useEffect(()=>{ee&&ee.on("start",$=>{if(!$.sourceEvent||$.sourceEvent.internal)return null;j.current=$.sourceEvent?.button;const{onViewportChangeStart:z}=L.getState(),k=El($.transform);F.current=!0,X.current=k,$.sourceEvent?.type==="mousedown"&&L.setState({paneDragging:!0}),z?.(k),t?.($.sourceEvent,k)})},[ee,t]),b.useEffect(()=>{ee&&(I&&!F.current?ee.on("zoom",null):I||ee.on("zoom",$=>{const{onViewportChange:z}=L.getState();if(L.setState({transform:[$.transform.x,$.transform.y,$.transform.k]}),K.current=!!(s&&Xh(E,j.current??0)),(e||z)&&!$.sourceEvent?.internal){const k=El($.transform);z?.(k),e?.($.sourceEvent,k)}}))},[I,ee,e,E,s]),b.useEffect(()=>{ee&&ee.on("end",$=>{if(!$.sourceEvent||$.sourceEvent.internal)return null;const{onViewportChangeEnd:z}=L.getState();if(F.current=!1,L.setState({paneDragging:!1}),s&&Xh(E,j.current??0)&&!K.current&&s($.sourceEvent),K.current=!1,(r||z)&&RN(X.current,$.transform)){const k=El($.transform);X.current=k,clearTimeout(A.current),A.current=setTimeout(()=>{z?.(k),r?.($.sourceEvent,k)},c?150:0)}})},[ee,c,E,r,s]),b.useEffect(()=>{ee&&ee.filter($=>{const z=V||i,k=a&&$.ctrlKey;if((E===!0||Array.isArray(E)&&E.includes(1))&&$.button===1&&$.type==="mousedown"&&(Ao($,"react-flow__node")||Ao($,"react-flow__edge")))return!0;if(!E&&!z&&!c&&!p&&!a||I||!p&&$.type==="dblclick"||Ao($,D)&&$.type==="wheel"||Ao($,T)&&($.type!=="wheel"||c&&$.type==="wheel"&&!V)||!a&&$.ctrlKey&&$.type==="wheel"||!z&&!c&&!k&&$.type==="wheel"||!E&&($.type==="mousedown"||$.type==="touchstart")||Array.isArray(E)&&!E.includes($.button)&&($.type==="mousedown"||$.type==="touchstart"))return!1;const Y=Array.isArray(E)&&E.includes($.button)||!$.button||$.button<=1;return(!$.ctrlKey||$.type==="wheel")&&Y})},[I,ee,i,a,c,p,E,m,V]),te.createElement("div",{className:"react-flow__renderer",ref:Q,style:au},O)},CN=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function AN(){const{userSelectionActive:e,userSelectionRect:t}=Me(CN,gt);return e&&t?te.createElement("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}function qh(e,t){const r=e.find(s=>s.id===t.parentNode);if(r){const s=t.position.x+t.width-r.width,i=t.position.y+t.height-r.height;if(s>0||i>0||t.position.x<0||t.position.y<0){if(r.style={...r.style},r.style.width=r.style.width??r.width,r.style.height=r.style.height??r.height,s>0&&(r.style.width+=s),i>0&&(r.style.height+=i),t.position.x<0){const a=Math.abs(t.position.x);r.position.x=r.position.x-a,r.style.width+=a,t.position.x=0}if(t.position.y<0){const a=Math.abs(t.position.y);r.position.y=r.position.y-a,r.style.height+=a,t.position.y=0}r.width=r.style.width,r.height=r.style.height}}}function Zh(e,t){if(e.some(s=>s.type==="reset"))return e.filter(s=>s.type==="reset").map(s=>s.item);const r=e.filter(s=>s.type==="add").map(s=>s.item);return t.reduce((s,i)=>{const a=e.filter(u=>u.id===i.id);if(a.length===0)return s.push(i),s;const c={...i};for(const u of a)if(u)switch(u.type){case"select":{c.selected=u.selected;break}case"position":{typeof u.position<"u"&&(c.position=u.position),typeof u.positionAbsolute<"u"&&(c.positionAbsolute=u.positionAbsolute),typeof u.dragging<"u"&&(c.dragging=u.dragging),c.expandParent&&qh(s,c);break}case"dimensions":{typeof u.dimensions<"u"&&(c.width=u.dimensions.width,c.height=u.dimensions.height),typeof u.updateStyle<"u"&&(c.style={...c.style||{},...u.dimensions}),typeof u.resizing=="boolean"&&(c.resizing=u.resizing),c.expandParent&&qh(s,c);break}case"remove":return s}return s.push(c),s},r)}function Jh(e,t){return Zh(e,t)}function IN(e,t){return Zh(e,t)}const ur=(e,t)=>({id:e,type:"select",selected:t});function Io(e,t){return e.reduce((r,s)=>{const i=t.includes(s.id);return!s.selected&&i?(s.selected=!0,r.push(ur(s.id,!0))):s.selected&&!i&&(s.selected=!1,r.push(ur(s.id,!1))),r},[])}const cu=(e,t)=>r=>{r.target===t.current&&e?.(r)},bN=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging}),em=b.memo(({isSelecting:e,selectionMode:t=Ms.Full,panOnDrag:r,onSelectionStart:s,onSelectionEnd:i,onPaneClick:a,onPaneContextMenu:c,onPaneScroll:u,onPaneMouseEnter:f,onPaneMouseMove:p,onPaneMouseLeave:m,children:E})=>{const v=b.useRef(null),x=tt(),_=b.useRef(0),w=b.useRef(0),S=b.useRef(),{userSelectionActive:N,elementsSelectable:O,dragging:D}=Me(bN,gt),T=()=>{x.setState({userSelectionActive:!1,userSelectionRect:null}),_.current=0,w.current=0},A=W=>{a?.(W),x.getState().resetSelectedElements(),x.setState({nodesSelectionActive:!1})},L=W=>{if(Array.isArray(r)&&r?.includes(2)){W.preventDefault();return}c?.(W)},F=u?W=>u(W):void 0,K=W=>{const{resetSelectedElements:I,domNode:V}=x.getState();if(S.current=V?.getBoundingClientRect(),!O||!e||W.button!==0||W.target!==v.current||!S.current)return;const{x:j,y:B}=lr(W,S.current);I(),x.setState({userSelectionRect:{width:0,height:0,startX:j,startY:B,x:j,y:B}}),s?.(W)},Q=W=>{const{userSelectionRect:I,nodeInternals:V,edges:j,transform:B,onNodesChange:U,onEdgesChange:$,nodeOrigin:z,getNodes:k}=x.getState();if(!e||!S.current||!I)return;x.setState({userSelectionActive:!0,nodesSelectionActive:!1});const Y=lr(W,S.current),re=I.startX??0,oe=I.startY??0,le={...I,x:Y.x<re?Y.x:re,y:Y.y<oe?Y.y:oe,width:Math.abs(Y.x-re),height:Math.abs(Y.y-oe)},de=k(),he=Th(V,le,B,t===Ms.Partial,!0,z),ue=Oh(he,j).map(Re=>Re.id),me=he.map(Re=>Re.id);if(_.current!==me.length){_.current=me.length;const Re=Io(de,me);Re.length&&U?.(Re)}if(w.current!==ue.length){w.current=ue.length;const Re=Io(j,ue);Re.length&&$?.(Re)}x.setState({userSelectionRect:le})},X=W=>{if(W.button!==0)return;const{userSelectionRect:I}=x.getState();!N&&I&&W.target===v.current&&A?.(W),x.setState({nodesSelectionActive:_.current>0}),T(),i?.(W)},ee=W=>{N&&(x.setState({nodesSelectionActive:_.current>0}),i?.(W)),T()},ne=O&&(e||N);return te.createElement("div",{className:St(["react-flow__pane",{dragging:D,selection:e}]),onClick:ne?void 0:cu(A,v),onContextMenu:cu(L,v),onWheel:cu(F,v),onMouseEnter:ne?void 0:f,onMouseDown:ne?K:void 0,onMouseMove:ne?Q:p,onMouseUp:ne?X:void 0,onMouseLeave:ne?ee:m,ref:v,style:au},E,te.createElement(AN,null))});em.displayName="Pane";function tm(e,t){if(!e.parentNode)return!1;const r=t.get(e.parentNode);return r?r.selected?!0:tm(r,t):!1}function nm(e,t,r){let s=e;do{if(s?.matches(t))return!0;if(s===r.current)return!1;s=s.parentElement}while(s);return!1}function LN(e,t,r,s){return Array.from(e.values()).filter(i=>(i.selected||i.id===s)&&(!i.parentNode||!tm(i,e))&&(i.draggable||t&&typeof i.draggable>"u")).map(i=>({id:i.id,position:i.position||{x:0,y:0},positionAbsolute:i.positionAbsolute||{x:0,y:0},distance:{x:r.x-(i.positionAbsolute?.x??0),y:r.y-(i.positionAbsolute?.y??0)},delta:{x:0,y:0},extent:i.extent,parentNode:i.parentNode,width:i.width,height:i.height,expandParent:i.expandParent}))}function DN(e,t){return!t||t==="parent"?t:[t[0],[t[1][0]-(e.width||0),t[1][1]-(e.height||0)]]}function rm(e,t,r,s,i=[0,0],a){const c=DN(e,e.extent||s);let u=c;if(e.extent==="parent"&&!e.expandParent)if(e.parentNode&&e.width&&e.height){const m=r.get(e.parentNode),{x:E,y:v}=No(m,i).positionAbsolute;u=m&&Yt(E)&&Yt(v)&&Yt(m.width)&&Yt(m.height)?[[E+e.width*i[0],v+e.height*i[1]],[E+m.width-e.width+e.width*i[0],v+m.height-e.height+e.height*i[1]]]:u}else a?.("005",Vn.error005()),u=c;else if(e.extent&&e.parentNode&&e.extent!=="parent"){const m=r.get(e.parentNode),{x:E,y:v}=No(m,i).positionAbsolute;u=[[e.extent[0][0]+E,e.extent[0][1]+v],[e.extent[1][0]+E,e.extent[1][1]+v]]}let f={x:0,y:0};if(e.parentNode){const m=r.get(e.parentNode);f=No(m,i).positionAbsolute}const p=u&&u!=="parent"?Wc(t,u):t;return{position:{x:p.x-f.x,y:p.y-f.y},positionAbsolute:p}}function uu({nodeId:e,dragItems:t,nodeInternals:r}){const s=t.map(i=>({...r.get(i.id),position:i.position,positionAbsolute:i.positionAbsolute}));return[e?s.find(i=>i.id===e):s[0],s]}const om=(e,t,r,s)=>{const i=t.querySelectorAll(e);if(!i||!i.length)return null;const a=Array.from(i),c=t.getBoundingClientRect(),u={x:c.width*s[0],y:c.height*s[1]};return a.map(f=>{const p=f.getBoundingClientRect();return{id:f.getAttribute("data-handleid"),position:f.getAttribute("data-handlepos"),x:(p.left-c.left-u.x)/r,y:(p.top-c.top-u.y)/r,...zc(f)}})};function Fs(e,t,r){return r===void 0?r:s=>{const i=t().nodeInternals.get(e);i&&r(s,{...i})}}function du({id:e,store:t,unselect:r=!1,nodeRef:s}){const{addSelectedNodes:i,unselectNodesAndEdges:a,multiSelectionActive:c,nodeInternals:u,onError:f}=t.getState(),p=u.get(e);if(!p){f?.("012",Vn.error012(e));return}t.setState({nodesSelectionActive:!1}),p.selected?(r||p.selected&&c)&&(a({nodes:[p],edges:[]}),requestAnimationFrame(()=>s?.current?.blur())):i([e])}function kN(){const e=tt();return b.useCallback(({sourceEvent:r})=>{const{transform:s,snapGrid:i,snapToGrid:a}=e.getState(),c=r.touches?r.touches[0].clientX:r.clientX,u=r.touches?r.touches[0].clientY:r.clientY,f={x:(c-s[0])/s[2],y:(u-s[1])/s[2]};return{xSnapped:a?i[0]*Math.round(f.x/i[0]):f.x,ySnapped:a?i[1]*Math.round(f.y/i[1]):f.y,...f}},[])}function fu(e){return(t,r,s)=>e?.(t,s)}function sm({nodeRef:e,disabled:t=!1,noDragClassName:r,handleSelector:s,nodeId:i,isSelectable:a,selectNodesOnDrag:c}){const u=tt(),[f,p]=b.useState(!1),m=b.useRef([]),E=b.useRef({x:null,y:null}),v=b.useRef(0),x=b.useRef(null),_=b.useRef({x:0,y:0}),w=b.useRef(null),S=b.useRef(!1),N=b.useRef(!1),O=kN();return b.useEffect(()=>{if(e?.current){const D=on(e.current),T=({x:F,y:K})=>{const{nodeInternals:Q,onNodeDrag:X,onSelectionDrag:ee,updateNodePositions:ne,nodeExtent:W,snapGrid:I,snapToGrid:V,nodeOrigin:j,onError:B}=u.getState();E.current={x:F,y:K};let U=!1,$={x:0,y:0,x2:0,y2:0};if(m.current.length>1&&W){const k=tu(m.current,j);$=Gc(k)}if(m.current=m.current.map(k=>{const Y={x:F-k.distance.x,y:K-k.distance.y};V&&(Y.x=I[0]*Math.round(Y.x/I[0]),Y.y=I[1]*Math.round(Y.y/I[1]));const re=[[W[0][0],W[0][1]],[W[1][0],W[1][1]]];m.current.length>1&&W&&!k.extent&&(re[0][0]=k.positionAbsolute.x-$.x+W[0][0],re[1][0]=k.positionAbsolute.x+(k.width??0)-$.x2+W[1][0],re[0][1]=k.positionAbsolute.y-$.y+W[0][1],re[1][1]=k.positionAbsolute.y+(k.height??0)-$.y2+W[1][1]);const oe=rm(k,Y,Q,re,j,B);return U=U||k.position.x!==oe.position.x||k.position.y!==oe.position.y,k.position=oe.position,k.positionAbsolute=oe.positionAbsolute,k}),!U)return;ne(m.current,!0,!0),p(!0);const z=i?X:fu(ee);if(z&&w.current){const[k,Y]=uu({nodeId:i,dragItems:m.current,nodeInternals:Q});z(w.current,k,Y)}},A=()=>{if(!x.current)return;const[F,K]=uh(_.current,x.current);if(F!==0||K!==0){const{transform:Q,panBy:X}=u.getState();E.current.x=(E.current.x??0)-F/Q[2],E.current.y=(E.current.y??0)-K/Q[2],X({x:F,y:K})&&T(E.current)}v.current=requestAnimationFrame(A)},L=F=>{const{nodeInternals:K,multiSelectionActive:Q,nodesDraggable:X,unselectNodesAndEdges:ee,onNodeDragStart:ne,onSelectionDragStart:W}=u.getState();N.current=!0;const I=i?ne:fu(W);(!c||!a)&&!Q&&i&&(K.get(i)?.selected||ee()),i&&a&&c&&du({id:i,store:u,nodeRef:e});const V=O(F);if(E.current=V,m.current=LN(K,X,V,i),I&&m.current){const[j,B]=uu({nodeId:i,dragItems:m.current,nodeInternals:K});I(F.sourceEvent,j,B)}};if(t)D.on(".drag",null);else{const F=zS().on("start",K=>{const{domNode:Q,nodeDragThreshold:X}=u.getState();X===0&&L(K);const ee=O(K);E.current=ee,x.current=Q?.getBoundingClientRect()||null,_.current=lr(K.sourceEvent,x.current)}).on("drag",K=>{const Q=O(K),{autoPanOnNodeDrag:X,nodeDragThreshold:ee}=u.getState();if(!S.current&&N.current&&X&&(S.current=!0,A()),!N.current){const ne=Q.xSnapped-(E?.current?.x??0),W=Q.ySnapped-(E?.current?.y??0);Math.sqrt(ne*ne+W*W)>ee&&L(K)}(E.current.x!==Q.xSnapped||E.current.y!==Q.ySnapped)&&m.current&&N.current&&(w.current=K.sourceEvent,_.current=lr(K.sourceEvent,x.current),T(Q))}).on("end",K=>{if(N.current&&(p(!1),S.current=!1,N.current=!1,cancelAnimationFrame(v.current),m.current)){const{updateNodePositions:Q,nodeInternals:X,onNodeDragStop:ee,onSelectionDragStop:ne}=u.getState(),W=i?ee:fu(ne);if(Q(m.current,!1,!1),W){const[I,V]=uu({nodeId:i,dragItems:m.current,nodeInternals:X});W(K.sourceEvent,I,V)}}}).filter(K=>{const Q=K.target;return!K.button&&(!r||!nm(Q,`.${r}`,e))&&(!s||nm(Q,s,e))});return D.call(F),()=>{D.on(".drag",null)}}}},[e,t,r,s,a,u,i,c,O]),f}function im(){const e=tt();return b.useCallback(r=>{const{nodeInternals:s,nodeExtent:i,updateNodePositions:a,getNodes:c,snapToGrid:u,snapGrid:f,onError:p,nodesDraggable:m}=e.getState(),E=c().filter(O=>O.selected&&(O.draggable||m&&typeof O.draggable>"u")),v=u?f[0]:5,x=u?f[1]:5,_=r.isShiftPressed?4:1,w=r.x*v*_,S=r.y*x*_,N=E.map(O=>{if(O.positionAbsolute){const D={x:O.positionAbsolute.x+w,y:O.positionAbsolute.y+S};u&&(D.x=f[0]*Math.round(D.x/f[0]),D.y=f[1]*Math.round(D.y/f[1]));const{positionAbsolute:T,position:A}=rm(O,D,s,i,void 0,p);O.position=A,O.positionAbsolute=T}return O});a(N,!0,!1)},[])}const bo={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var js=e=>{const t=({id:r,type:s,data:i,xPos:a,yPos:c,xPosOrigin:u,yPosOrigin:f,selected:p,onClick:m,onMouseEnter:E,onMouseMove:v,onMouseLeave:x,onContextMenu:_,onDoubleClick:w,style:S,className:N,isDraggable:O,isSelectable:D,isConnectable:T,isFocusable:A,selectNodesOnDrag:L,sourcePosition:F,targetPosition:K,hidden:Q,resizeObserver:X,dragHandle:ee,zIndex:ne,isParent:W,noDragClassName:I,noPanClassName:V,initialized:j,disableKeyboardA11y:B,ariaLabel:U,rfId:$})=>{const z=tt(),k=b.useRef(null),Y=b.useRef(F),re=b.useRef(K),oe=b.useRef(s),le=D||O||m||E||v||x,de=im(),he=Fs(r,z.getState,E),ue=Fs(r,z.getState,v),me=Fs(r,z.getState,x),Re=Fs(r,z.getState,_),Pe=Fs(r,z.getState,w),Je=Ue=>{const{nodeDragThreshold:ft}=z.getState();if(D&&(!L||!O||ft>0)&&du({id:r,store:z,nodeRef:k}),m){const pt=z.getState().nodeInternals.get(r);pt&&m(Ue,{...pt})}},wt=Ue=>{if(!Kc(Ue))if(ph.includes(Ue.key)&&D){const ft=Ue.key==="Escape";du({id:r,store:z,unselect:ft,nodeRef:k})}else!B&&O&&p&&Object.prototype.hasOwnProperty.call(bo,Ue.key)&&(z.setState({ariaLiveMessage:`Moved selected node ${Ue.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~a}, y: ${~~c}`}),de({x:bo[Ue.key].x,y:bo[Ue.key].y,isShiftPressed:Ue.shiftKey}))};b.useEffect(()=>{if(k.current&&!Q){const Ue=k.current;return X?.observe(Ue),()=>X?.unobserve(Ue)}},[Q]),b.useEffect(()=>{const Ue=oe.current!==s,ft=Y.current!==F,pt=re.current!==K;k.current&&(Ue||ft||pt)&&(Ue&&(oe.current=s),ft&&(Y.current=F),pt&&(re.current=K),z.getState().updateNodeDimensions([{id:r,nodeElement:k.current,forceUpdate:!0}]))},[r,s,F,K]);const Be=sm({nodeRef:k,disabled:Q||!O,noDragClassName:I,handleSelector:ee,nodeId:r,isSelectable:D,selectNodesOnDrag:L});return Q?null:te.createElement("div",{className:St(["react-flow__node",`react-flow__node-${s}`,{[V]:O},N,{selected:p,selectable:D,parent:W,dragging:Be}]),ref:k,style:{zIndex:ne,transform:`translate(${u}px,${f}px)`,pointerEvents:le?"all":"none",visibility:j?"visible":"hidden",...S},"data-id":r,"data-testid":`rf__node-${r}`,onMouseEnter:he,onMouseMove:ue,onMouseLeave:me,onContextMenu:Re,onClick:Je,onDoubleClick:Pe,onKeyDown:A?wt:void 0,tabIndex:A?0:void 0,role:A?"button":void 0,"aria-describedby":B?void 0:`${Hh}-${$}`,"aria-label":U},te.createElement(Xw,{value:r},te.createElement(e,{id:r,data:i,type:s,xPos:a,yPos:c,selected:p,isConnectable:T,sourcePosition:F,targetPosition:K,dragging:Be,dragHandle:ee,zIndex:ne})))};return t.displayName="NodeWrapper",b.memo(t)};const MN=e=>{const t=e.getNodes().filter(r=>r.selected);return{...tu(t,e.nodeOrigin),transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`,userSelectionActive:e.userSelectionActive}};function PN({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:r}){const s=tt(),{width:i,height:a,x:c,y:u,transformString:f,userSelectionActive:p}=Me(MN,gt),m=im(),E=b.useRef(null);if(b.useEffect(()=>{r||E.current?.focus({preventScroll:!0})},[r]),sm({nodeRef:E}),p||!i||!a)return null;const v=e?_=>{const w=s.getState().getNodes().filter(S=>S.selected);e(_,w)}:void 0,x=_=>{Object.prototype.hasOwnProperty.call(bo,_.key)&&m({x:bo[_.key].x,y:bo[_.key].y,isShiftPressed:_.shiftKey})};return te.createElement("div",{className:St(["react-flow__nodesselection","react-flow__container",t]),style:{transform:f}},te.createElement("div",{ref:E,className:"react-flow__nodesselection-rect",onContextMenu:v,tabIndex:r?void 0:-1,onKeyDown:r?void 0:x,style:{width:i,height:a,top:u,left:c}}))}var UN=b.memo(PN);const FN=e=>e.nodesSelectionActive,lm=({children:e,onPaneClick:t,onPaneMouseEnter:r,onPaneMouseMove:s,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:c,deleteKeyCode:u,onMove:f,onMoveStart:p,onMoveEnd:m,selectionKeyCode:E,selectionOnDrag:v,selectionMode:x,onSelectionStart:_,onSelectionEnd:w,multiSelectionKeyCode:S,panActivationKeyCode:N,zoomActivationKeyCode:O,elementsSelectable:D,zoomOnScroll:T,zoomOnPinch:A,panOnScroll:L,panOnScrollSpeed:F,panOnScrollMode:K,zoomOnDoubleClick:Q,panOnDrag:X,defaultViewport:ee,translateExtent:ne,minZoom:W,maxZoom:I,preventScrolling:V,onSelectionContextMenu:j,noWheelClassName:B,noPanClassName:U,disableKeyboardA11y:$})=>{const z=Me(FN),k=Oo(E),Y=Oo(N),re=Y||X,oe=Y||L,le=k||v&&re!==!0;return wN({deleteKeyCode:u,multiSelectionKeyCode:S}),te.createElement(ON,{onMove:f,onMoveStart:p,onMoveEnd:m,onPaneContextMenu:a,elementsSelectable:D,zoomOnScroll:T,zoomOnPinch:A,panOnScroll:oe,panOnScrollSpeed:F,panOnScrollMode:K,zoomOnDoubleClick:Q,panOnDrag:!k&&re,defaultViewport:ee,translateExtent:ne,minZoom:W,maxZoom:I,zoomActivationKeyCode:O,preventScrolling:V,noWheelClassName:B,noPanClassName:U},te.createElement(em,{onSelectionStart:_,onSelectionEnd:w,onPaneClick:t,onPaneMouseEnter:r,onPaneMouseMove:s,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:c,panOnDrag:re,isSelecting:!!le,selectionMode:x},e,z&&te.createElement(UN,{onSelectionContextMenu:j,noPanClassName:U,disableKeyboardA11y:$})))};lm.displayName="FlowRenderer";var jN=b.memo(lm);function VN(e){return Me(b.useCallback(r=>e?Th(r.nodeInternals,{x:0,y:0,width:r.width,height:r.height},r.transform,!0):r.getNodes(),[e]))}function $N(e){const t={input:js(e.input||Uh),default:js(e.default||ou),output:js(e.output||jh),group:js(e.group||su)},r={},s=Object.keys(e).filter(i=>!["input","default","output","group"].includes(i)).reduce((i,a)=>(i[a]=js(e[a]||ou),i),r);return{...t,...s}}const HN=({x:e,y:t,width:r,height:s,origin:i})=>!r||!s?{x:e,y:t}:i[0]<0||i[1]<0||i[0]>1||i[1]>1?{x:e,y:t}:{x:e-r*i[0],y:t-s*i[1]},BN=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,updateNodeDimensions:e.updateNodeDimensions,onError:e.onError}),am=e=>{const{nodesDraggable:t,nodesConnectable:r,nodesFocusable:s,elementsSelectable:i,updateNodeDimensions:a,onError:c}=Me(BN,gt),u=VN(e.onlyRenderVisibleElements),f=b.useRef(),p=b.useMemo(()=>{if(typeof ResizeObserver>"u")return null;const m=new ResizeObserver(E=>{const v=E.map(x=>({id:x.target.getAttribute("data-id"),nodeElement:x.target,forceUpdate:!0}));a(v)});return f.current=m,m},[]);return b.useEffect(()=>()=>{f?.current?.disconnect()},[]),te.createElement("div",{className:"react-flow__nodes",style:au},u.map(m=>{let E=m.type||"default";e.nodeTypes[E]||(c?.("003",Vn.error003(E)),E="default");const v=e.nodeTypes[E]||e.nodeTypes.default,x=!!(m.draggable||t&&typeof m.draggable>"u"),_=!!(m.selectable||i&&typeof m.selectable>"u"),w=!!(m.connectable||r&&typeof m.connectable>"u"),S=!!(m.focusable||s&&typeof m.focusable>"u"),N=e.nodeExtent?Wc(m.positionAbsolute,e.nodeExtent):m.positionAbsolute,O=N?.x??0,D=N?.y??0,T=HN({x:O,y:D,width:m.width??0,height:m.height??0,origin:e.nodeOrigin});return te.createElement(v,{key:m.id,id:m.id,className:m.className,style:m.style,type:E,data:m.data,sourcePosition:m.sourcePosition||xe.Bottom,targetPosition:m.targetPosition||xe.Top,hidden:m.hidden,xPos:O,yPos:D,xPosOrigin:T.x,yPosOrigin:T.y,selectNodesOnDrag:e.selectNodesOnDrag,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,selected:!!m.selected,isDraggable:x,isSelectable:_,isConnectable:w,isFocusable:S,resizeObserver:p,dragHandle:m.dragHandle,zIndex:m[nt]?.z??0,isParent:!!m[nt]?.isParent,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,initialized:!!m.width&&!!m.height,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,ariaLabel:m.ariaLabel})}))};am.displayName="NodeRenderer";var zN=b.memo(am);const WN=(e,t,r)=>r===xe.Left?e-t:r===xe.Right?e+t:e,GN=(e,t,r)=>r===xe.Top?e-t:r===xe.Bottom?e+t:e,cm="react-flow__edgeupdater",um=({position:e,centerX:t,centerY:r,radius:s=10,onMouseDown:i,onMouseEnter:a,onMouseOut:c,type:u})=>te.createElement("circle",{onMouseDown:i,onMouseEnter:a,onMouseOut:c,className:St([cm,`${cm}-${u}`]),cx:WN(t,s,e),cy:GN(r,s,e),r:s,stroke:"transparent",fill:"transparent"}),YN=()=>!0;var Lo=e=>{const t=({id:r,className:s,type:i,data:a,onClick:c,onEdgeDoubleClick:u,selected:f,animated:p,label:m,labelStyle:E,labelShowBg:v,labelBgStyle:x,labelBgPadding:_,labelBgBorderRadius:w,style:S,source:N,target:O,sourceX:D,sourceY:T,targetX:A,targetY:L,sourcePosition:F,targetPosition:K,elementsSelectable:Q,hidden:X,sourceHandleId:ee,targetHandleId:ne,onContextMenu:W,onMouseEnter:I,onMouseMove:V,onMouseLeave:j,edgeUpdaterRadius:B,onEdgeUpdate:U,onEdgeUpdateStart:$,onEdgeUpdateEnd:z,markerEnd:k,markerStart:Y,rfId:re,ariaLabel:oe,isFocusable:le,isUpdatable:de,pathOptions:he,interactionWidth:ue})=>{const me=b.useRef(null),[Re,Pe]=b.useState(!1),[Je,wt]=b.useState(!1),Be=tt(),Ue=b.useMemo(()=>`url(#${Jc(Y,re)})`,[Y,re]),ft=b.useMemo(()=>`url(#${Jc(k,re)})`,[k,re]);if(X)return null;const pt=Ke=>{const{edges:it,addSelectedEdges:Gn,unselectNodesAndEdges:bn,multiSelectionActive:Yn}=Be.getState(),qt=it.find(hn=>hn.id===r);qt&&(Q&&(Be.setState({nodesSelectionActive:!1}),qt.selected&&Yn?(bn({nodes:[],edges:[qt]}),me.current?.blur()):Gn([r])),c&&c(Ke,qt))},we=ks(r,Be.getState,u),un=ks(r,Be.getState,W),Ht=ks(r,Be.getState,I),Qt=ks(r,Be.getState,V),Cn=ks(r,Be.getState,j),An=(Ke,it)=>{if(Ke.button!==0)return;const{edges:Gn,isValidConnection:bn}=Be.getState(),Yn=it?O:N,qt=(it?ne:ee)||null,hn=it?"target":"source",Qr=bn||YN,qr=it,Kn=Gn.find(Lt=>Lt.id===r);wt(!0),$?.(Ke,Kn,hn);const Zr=Lt=>{wt(!1),z?.(Lt,Kn,hn)};Lh({event:Ke,handleId:qt,nodeId:Yn,onConnect:Lt=>U?.(Kn,Lt),isTarget:qr,getState:Be.getState,setState:Be.setState,isValidConnection:Qr,edgeUpdaterType:hn,onEdgeUpdateEnd:Zr})},dn=Ke=>An(Ke,!0),zn=Ke=>An(Ke,!1),fn=()=>Pe(!0),pn=()=>Pe(!1),In=!Q&&!c,Wn=Ke=>{if(ph.includes(Ke.key)&&Q){const{unselectNodesAndEdges:it,addSelectedEdges:Gn,edges:bn}=Be.getState();Ke.key==="Escape"?(me.current?.blur(),it({edges:[bn.find(qt=>qt.id===r)]})):Gn([r])}};return te.createElement("g",{className:St(["react-flow__edge",`react-flow__edge-${i}`,s,{selected:f,animated:p,inactive:In,updating:Re}]),onClick:pt,onDoubleClick:we,onContextMenu:un,onMouseEnter:Ht,onMouseMove:Qt,onMouseLeave:Cn,onKeyDown:le?Wn:void 0,tabIndex:le?0:void 0,role:le?"button":"img","data-testid":`rf__edge-${r}`,"aria-label":oe===null?void 0:oe||`Edge from ${N} to ${O}`,"aria-describedby":le?`${Bh}-${re}`:void 0,ref:me},!Je&&te.createElement(e,{id:r,source:N,target:O,selected:f,animated:p,label:m,labelStyle:E,labelShowBg:v,labelBgStyle:x,labelBgPadding:_,labelBgBorderRadius:w,data:a,style:S,sourceX:D,sourceY:T,targetX:A,targetY:L,sourcePosition:F,targetPosition:K,sourceHandleId:ee,targetHandleId:ne,markerStart:Ue,markerEnd:ft,pathOptions:he,interactionWidth:ue}),de&&te.createElement(te.Fragment,null,(de==="source"||de===!0)&&te.createElement(um,{position:F,centerX:D,centerY:T,radius:B,onMouseDown:dn,onMouseEnter:fn,onMouseOut:pn,type:"source"}),(de==="target"||de===!0)&&te.createElement(um,{position:K,centerX:A,centerY:L,radius:B,onMouseDown:zn,onMouseEnter:fn,onMouseOut:pn,type:"target"})))};return t.displayName="EdgeWrapper",b.memo(t)};function KN(e){const t={default:Lo(e.default||hl),straight:Lo(e.bezier||qc),step:Lo(e.step||Qc),smoothstep:Lo(e.step||fl),simplebezier:Lo(e.simplebezier||Xc)},r={},s=Object.keys(e).filter(i=>!["default","bezier"].includes(i)).reduce((i,a)=>(i[a]=Lo(e[a]||hl),i),r);return{...t,...s}}function dm(e,t,r=null){const s=(r?.x||0)+t.x,i=(r?.y||0)+t.y,a=r?.width||t.width,c=r?.height||t.height;switch(e){case xe.Top:return{x:s+a/2,y:i};case xe.Right:return{x:s+a,y:i+c/2};case xe.Bottom:return{x:s+a/2,y:i+c};case xe.Left:return{x:s,y:i+c/2}}}function fm(e,t){return e?e.length===1||!t?e[0]:t&&e.find(r=>r.id===t)||null:null}const XN=(e,t,r,s,i,a)=>{const c=dm(r,e,t),u=dm(a,s,i);return{sourceX:c.x,sourceY:c.y,targetX:u.x,targetY:u.y}};function QN({sourcePos:e,targetPos:t,sourceWidth:r,sourceHeight:s,targetWidth:i,targetHeight:a,width:c,height:u,transform:f}){const p={x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x+r,t.x+i),y2:Math.max(e.y+s,t.y+a)};p.x===p.x2&&(p.x2+=1),p.y===p.y2&&(p.y2+=1);const m=Gc({x:(0-f[0])/f[2],y:(0-f[1])/f[2],width:c/f[2],height:u/f[2]}),E=Math.max(0,Math.min(m.x2,p.x2)-Math.max(m.x,p.x)),v=Math.max(0,Math.min(m.y2,p.y2)-Math.max(m.y,p.y));return Math.ceil(E*v)>0}function pm(e){const t=e?.[nt]?.handleBounds||null,r=t&&e?.width&&e?.height&&typeof e?.positionAbsolute?.x<"u"&&typeof e?.positionAbsolute?.y<"u";return[{x:e?.positionAbsolute?.x||0,y:e?.positionAbsolute?.y||0,width:e?.width||0,height:e?.height||0},t,!!r]}const qN=[{level:0,isMaxLevel:!0,edges:[]}];function ZN(e,t,r=!1){let s=-1;const i=e.reduce((c,u)=>{const f=Yt(u.zIndex);let p=f?u.zIndex:0;if(r){const m=t.get(u.target),E=t.get(u.source),v=u.selected||m?.selected||E?.selected,x=Math.max(E?.[nt]?.z||0,m?.[nt]?.z||0,1e3);p=(f?u.zIndex:0)+(v?x:0)}return c[p]?c[p].push(u):c[p]=[u],s=p>s?p:s,c},{}),a=Object.entries(i).map(([c,u])=>{const f=+c;return{edges:u,level:f,isMaxLevel:f===s}});return a.length===0?qN:a}function JN(e,t,r){const s=Me(b.useCallback(i=>e?i.edges.filter(a=>{const c=t.get(a.source),u=t.get(a.target);return c?.width&&c?.height&&u?.width&&u?.height&&QN({sourcePos:c.positionAbsolute||{x:0,y:0},targetPos:u.positionAbsolute||{x:0,y:0},sourceWidth:c.width,sourceHeight:c.height,targetWidth:u.width,targetHeight:u.height,width:i.width,height:i.height,transform:i.transform})}):i.edges,[e,t]));return ZN(s,t,r)}const eR=({color:e="none",strokeWidth:t=1})=>te.createElement("polyline",{style:{stroke:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),tR=({color:e="none",strokeWidth:t=1})=>te.createElement("polyline",{style:{stroke:e,fill:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"}),hm={[Ps.Arrow]:eR,[Ps.ArrowClosed]:tR};function nR(e){const t=tt();return b.useMemo(()=>Object.prototype.hasOwnProperty.call(hm,e)?hm[e]:(t.getState().onError?.("009",Vn.error009(e)),null),[e])}const rR=({id:e,type:t,color:r,width:s=12.5,height:i=12.5,markerUnits:a="strokeWidth",strokeWidth:c,orient:u="auto-start-reverse"})=>{const f=nR(t);return f?te.createElement("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${s}`,markerHeight:`${i}`,viewBox:"-10 -10 20 20",markerUnits:a,orient:u,refX:"0",refY:"0"},te.createElement(f,{color:r,strokeWidth:c})):null},oR=({defaultColor:e,rfId:t})=>r=>{const s=[];return r.edges.reduce((i,a)=>([a.markerStart,a.markerEnd].forEach(c=>{if(c&&typeof c=="object"){const u=Jc(c,t);s.includes(u)||(i.push({id:u,color:c.color||e,...c}),s.push(u))}}),i),[]).sort((i,a)=>i.id.localeCompare(a.id))},mm=({defaultColor:e,rfId:t})=>{const r=Me(b.useCallback(oR({defaultColor:e,rfId:t}),[e,t]),(s,i)=>!(s.length!==i.length||s.some((a,c)=>a.id!==i[c].id)));return te.createElement("defs",null,r.map(s=>te.createElement(rR,{id:s.id,key:s.id,type:s.type,color:s.color,width:s.width,height:s.height,markerUnits:s.markerUnits,strokeWidth:s.strokeWidth,orient:s.orient})))};mm.displayName="MarkerDefinitions";var sR=b.memo(mm);const iR=e=>({nodesConnectable:e.nodesConnectable,edgesFocusable:e.edgesFocusable,edgesUpdatable:e.edgesUpdatable,elementsSelectable:e.elementsSelectable,width:e.width,height:e.height,connectionMode:e.connectionMode,nodeInternals:e.nodeInternals,onError:e.onError}),gm=({defaultMarkerColor:e,onlyRenderVisibleElements:t,elevateEdgesOnSelect:r,rfId:s,edgeTypes:i,noPanClassName:a,onEdgeUpdate:c,onEdgeContextMenu:u,onEdgeMouseEnter:f,onEdgeMouseMove:p,onEdgeMouseLeave:m,onEdgeClick:E,edgeUpdaterRadius:v,onEdgeDoubleClick:x,onEdgeUpdateStart:_,onEdgeUpdateEnd:w,children:S})=>{const{edgesFocusable:N,edgesUpdatable:O,elementsSelectable:D,width:T,height:A,connectionMode:L,nodeInternals:F,onError:K}=Me(iR,gt),Q=JN(t,F,r);return T?te.createElement(te.Fragment,null,Q.map(({level:X,edges:ee,isMaxLevel:ne})=>te.createElement("svg",{key:X,style:{zIndex:X},width:T,height:A,className:"react-flow__edges react-flow__container"},ne&&te.createElement(sR,{defaultColor:e,rfId:s}),te.createElement("g",null,ee.map(W=>{const[I,V,j]=pm(F.get(W.source)),[B,U,$]=pm(F.get(W.target));if(!j||!$)return null;let z=W.type||"default";i[z]||(K?.("011",Vn.error011(z)),z="default");const k=i[z]||i.default,Y=L===ar.Strict?U.target:(U.target??[]).concat(U.source??[]),re=fm(V.source,W.sourceHandle),oe=fm(Y,W.targetHandle),le=re?.position||xe.Bottom,de=oe?.position||xe.Top,he=!!(W.focusable||N&&typeof W.focusable>"u"),ue=typeof c<"u"&&(W.updatable||O&&typeof W.updatable>"u");if(!re||!oe)return K?.("008",Vn.error008(re,W)),null;const{sourceX:me,sourceY:Re,targetX:Pe,targetY:Je}=XN(I,re,le,B,oe,de);return te.createElement(k,{key:W.id,id:W.id,className:St([W.className,a]),type:z,data:W.data,selected:!!W.selected,animated:!!W.animated,hidden:!!W.hidden,label:W.label,labelStyle:W.labelStyle,labelShowBg:W.labelShowBg,labelBgStyle:W.labelBgStyle,labelBgPadding:W.labelBgPadding,labelBgBorderRadius:W.labelBgBorderRadius,style:W.style,source:W.source,target:W.target,sourceHandleId:W.sourceHandle,targetHandleId:W.targetHandle,markerEnd:W.markerEnd,markerStart:W.markerStart,sourceX:me,sourceY:Re,targetX:Pe,targetY:Je,sourcePosition:le,targetPosition:de,elementsSelectable:D,onEdgeUpdate:c,onContextMenu:u,onMouseEnter:f,onMouseMove:p,onMouseLeave:m,onClick:E,edgeUpdaterRadius:v,onEdgeDoubleClick:x,onEdgeUpdateStart:_,onEdgeUpdateEnd:w,rfId:s,ariaLabel:W.ariaLabel,isFocusable:he,isUpdatable:ue,pathOptions:"pathOptions"in W?W.pathOptions:void 0,interactionWidth:W.interactionWidth})})))),S):null};gm.displayName="EdgeRenderer";var lR=b.memo(gm);const aR=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function cR({children:e}){const t=Me(aR);return te.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:t}},e)}function uR(e){const t=lu(),r=b.useRef(!1);b.useEffect(()=>{!r.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),r.current=!0)},[e,t.viewportInitialized])}const dR={[xe.Left]:xe.Right,[xe.Right]:xe.Left,[xe.Top]:xe.Bottom,[xe.Bottom]:xe.Top},Em=({nodeId:e,handleType:t,style:r,type:s=cr.Bezier,CustomComponent:i,connectionStatus:a})=>{const{fromNode:c,handleId:u,toX:f,toY:p,connectionMode:m}=Me(b.useCallback(L=>({fromNode:L.nodeInternals.get(e),handleId:L.connectionHandleId,toX:(L.connectionPosition.x-L.transform[0])/L.transform[2],toY:(L.connectionPosition.y-L.transform[1])/L.transform[2],connectionMode:L.connectionMode}),[e]),gt),E=c?.[nt]?.handleBounds;let v=E?.[t];if(m===ar.Loose&&(v=v||E?.[t==="source"?"target":"source"]),!c||!v)return null;const x=u?v.find(L=>L.id===u):v[0],_=x?x.x+x.width/2:(c.width??0)/2,w=x?x.y+x.height/2:c.height??0,S=(c.positionAbsolute?.x??0)+_,N=(c.positionAbsolute?.y??0)+w,O=x?.position,D=O?dR[O]:null;if(!O||!D)return null;if(i)return te.createElement(i,{connectionLineType:s,connectionLineStyle:r,fromNode:c,fromHandle:x,fromX:S,fromY:N,toX:f,toY:p,fromPosition:O,toPosition:D,connectionStatus:a});let T="";const A={sourceX:S,sourceY:N,sourcePosition:O,targetX:f,targetY:p,targetPosition:D};return s===cr.Bezier?[T]=_h(A):s===cr.Step?[T]=Us({...A,borderRadius:0}):s===cr.SmoothStep?[T]=Us(A):s===cr.SimpleBezier?[T]=yh(A):T=`M${S},${N} ${f},${p}`,te.createElement("path",{d:T,fill:"none",className:"react-flow__connection-path",style:r})};Em.displayName="ConnectionLine";const fR=e=>({nodeId:e.connectionNodeId,handleType:e.connectionHandleType,nodesConnectable:e.nodesConnectable,connectionStatus:e.connectionStatus,width:e.width,height:e.height});function pR({containerStyle:e,style:t,type:r,component:s}){const{nodeId:i,handleType:a,nodesConnectable:c,width:u,height:f,connectionStatus:p}=Me(fR,gt);return!(i&&a&&u&&c)?null:te.createElement("svg",{style:e,width:u,height:f,className:"react-flow__edges react-flow__connectionline react-flow__container"},te.createElement("g",{className:St(["react-flow__connection",p])},te.createElement(Em,{nodeId:i,handleType:a,style:t,type:r,CustomComponent:s,connectionStatus:p})))}function ym(e,t){return b.useRef(null),tt(),b.useMemo(()=>t(e),[e])}const vm=({nodeTypes:e,edgeTypes:t,onMove:r,onMoveStart:s,onMoveEnd:i,onInit:a,onNodeClick:c,onEdgeClick:u,onNodeDoubleClick:f,onEdgeDoubleClick:p,onNodeMouseEnter:m,onNodeMouseMove:E,onNodeMouseLeave:v,onNodeContextMenu:x,onSelectionContextMenu:_,onSelectionStart:w,onSelectionEnd:S,connectionLineType:N,connectionLineStyle:O,connectionLineComponent:D,connectionLineContainerStyle:T,selectionKeyCode:A,selectionOnDrag:L,selectionMode:F,multiSelectionKeyCode:K,panActivationKeyCode:Q,zoomActivationKeyCode:X,deleteKeyCode:ee,onlyRenderVisibleElements:ne,elementsSelectable:W,selectNodesOnDrag:I,defaultViewport:V,translateExtent:j,minZoom:B,maxZoom:U,preventScrolling:$,defaultMarkerColor:z,zoomOnScroll:k,zoomOnPinch:Y,panOnScroll:re,panOnScrollSpeed:oe,panOnScrollMode:le,zoomOnDoubleClick:de,panOnDrag:he,onPaneClick:ue,onPaneMouseEnter:me,onPaneMouseMove:Re,onPaneMouseLeave:Pe,onPaneScroll:Je,onPaneContextMenu:wt,onEdgeUpdate:Be,onEdgeContextMenu:Ue,onEdgeMouseEnter:ft,onEdgeMouseMove:pt,onEdgeMouseLeave:we,edgeUpdaterRadius:un,onEdgeUpdateStart:Ht,onEdgeUpdateEnd:Qt,noDragClassName:Cn,noWheelClassName:An,noPanClassName:dn,elevateEdgesOnSelect:zn,disableKeyboardA11y:fn,nodeOrigin:pn,nodeExtent:In,rfId:Wn})=>{const Ke=ym(e,$N),it=ym(t,KN);return uR(a),te.createElement(jN,{onPaneClick:ue,onPaneMouseEnter:me,onPaneMouseMove:Re,onPaneMouseLeave:Pe,onPaneContextMenu:wt,onPaneScroll:Je,deleteKeyCode:ee,selectionKeyCode:A,selectionOnDrag:L,selectionMode:F,onSelectionStart:w,onSelectionEnd:S,multiSelectionKeyCode:K,panActivationKeyCode:Q,zoomActivationKeyCode:X,elementsSelectable:W,onMove:r,onMoveStart:s,onMoveEnd:i,zoomOnScroll:k,zoomOnPinch:Y,zoomOnDoubleClick:de,panOnScroll:re,panOnScrollSpeed:oe,panOnScrollMode:le,panOnDrag:he,defaultViewport:V,translateExtent:j,minZoom:B,maxZoom:U,onSelectionContextMenu:_,preventScrolling:$,noDragClassName:Cn,noWheelClassName:An,noPanClassName:dn,disableKeyboardA11y:fn},te.createElement(cR,null,te.createElement(lR,{edgeTypes:it,onEdgeClick:u,onEdgeDoubleClick:p,onEdgeUpdate:Be,onlyRenderVisibleElements:ne,onEdgeContextMenu:Ue,onEdgeMouseEnter:ft,onEdgeMouseMove:pt,onEdgeMouseLeave:we,onEdgeUpdateStart:Ht,onEdgeUpdateEnd:Qt,edgeUpdaterRadius:un,defaultMarkerColor:z,noPanClassName:dn,elevateEdgesOnSelect:!!zn,disableKeyboardA11y:fn,rfId:Wn},te.createElement(pR,{style:O,type:N,component:D,containerStyle:T})),te.createElement("div",{className:"react-flow__edgelabel-renderer"}),te.createElement(zN,{nodeTypes:Ke,onNodeClick:c,onNodeDoubleClick:f,onNodeMouseEnter:m,onNodeMouseMove:E,onNodeMouseLeave:v,onNodeContextMenu:x,selectNodesOnDrag:I,onlyRenderVisibleElements:ne,noPanClassName:dn,noDragClassName:Cn,disableKeyboardA11y:fn,nodeOrigin:pn,nodeExtent:In,rfId:Wn})))};vm.displayName="GraphView";var hR=b.memo(vm);const pu=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],dr={rfId:"1",width:0,height:0,transform:[0,0,1],nodeInternals:new Map,edges:[],onNodesChange:null,onEdgesChange:null,hasDefaultNodes:!1,hasDefaultEdges:!1,d3Zoom:null,d3Selection:null,d3ZoomHandler:void 0,minZoom:.5,maxZoom:2,translateExtent:pu,nodeExtent:pu,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:ar.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:[0,0],nodeDragThreshold:0,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesUpdatable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,fitViewOnInit:!1,fitViewOnInitDone:!1,fitViewOnInitOptions:void 0,onSelectionChange:[],multiSelectionActive:!1,connectionStartHandle:null,connectionEndHandle:null,connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,connectionRadius:20,onError:Bw,isValidConnection:void 0},mR=()=>nx((e,t)=>({...dr,setNodes:r=>{const{nodeInternals:s,nodeOrigin:i,elevateNodesOnSelect:a}=t();e({nodeInternals:iu(r,s,i,a)})},getNodes:()=>Array.from(t().nodeInternals.values()),setEdges:r=>{const{defaultEdgeOptions:s={}}=t();e({edges:r.map(i=>({...s,...i}))})},setDefaultNodesAndEdges:(r,s)=>{const i=typeof r<"u",a=typeof s<"u",c=i?iu(r,new Map,t().nodeOrigin,t().elevateNodesOnSelect):new Map;e({nodeInternals:c,edges:a?s:[],hasDefaultNodes:i,hasDefaultEdges:a})},updateNodeDimensions:r=>{const{onNodesChange:s,nodeInternals:i,fitViewOnInit:a,fitViewOnInitDone:c,fitViewOnInitOptions:u,domNode:f,nodeOrigin:p}=t(),m=f?.querySelector(".react-flow__viewport");if(!m)return;const E=window.getComputedStyle(m),{m22:v}=new window.DOMMatrixReadOnly(E.transform),x=r.reduce((w,S)=>{const N=i.get(S.id);if(N){const O=zc(S.nodeElement);!!(O.width&&O.height&&(N.width!==O.width||N.height!==O.height||S.forceUpdate))&&(i.set(N.id,{...N,[nt]:{...N[nt],handleBounds:{source:om(".source",S.nodeElement,v,p),target:om(".target",S.nodeElement,v,p)}},...O}),w.push({id:N.id,type:"dimensions",dimensions:O}))}return w},[]);Yh(i,p);const _=c||a&&!c&&Kh(t,{initial:!0,...u});e({nodeInternals:new Map(i),fitViewOnInitDone:_}),x?.length>0&&s?.(x)},updateNodePositions:(r,s=!0,i=!1)=>{const{triggerNodeChanges:a}=t(),c=r.map(u=>{const f={id:u.id,type:"position",dragging:i};return s&&(f.positionAbsolute=u.positionAbsolute,f.position=u.position),f});a(c)},triggerNodeChanges:r=>{const{onNodesChange:s,nodeInternals:i,hasDefaultNodes:a,nodeOrigin:c,getNodes:u,elevateNodesOnSelect:f}=t();if(r?.length){if(a){const p=Jh(r,u()),m=iu(p,i,c,f);e({nodeInternals:m})}s?.(r)}},addSelectedNodes:r=>{const{multiSelectionActive:s,edges:i,getNodes:a}=t();let c,u=null;s?c=r.map(f=>ur(f,!0)):(c=Io(a(),r),u=Io(i,[])),gl({changedNodes:c,changedEdges:u,get:t,set:e})},addSelectedEdges:r=>{const{multiSelectionActive:s,edges:i,getNodes:a}=t();let c,u=null;s?c=r.map(f=>ur(f,!0)):(c=Io(i,r),u=Io(a(),[])),gl({changedNodes:u,changedEdges:c,get:t,set:e})},unselectNodesAndEdges:({nodes:r,edges:s}={})=>{const{edges:i,getNodes:a}=t(),c=r||a(),u=s||i,f=c.map(m=>(m.selected=!1,ur(m.id,!1))),p=u.map(m=>ur(m.id,!1));gl({changedNodes:f,changedEdges:p,get:t,set:e})},setMinZoom:r=>{const{d3Zoom:s,maxZoom:i}=t();s?.scaleExtent([r,i]),e({minZoom:r})},setMaxZoom:r=>{const{d3Zoom:s,minZoom:i}=t();s?.scaleExtent([i,r]),e({maxZoom:r})},setTranslateExtent:r=>{t().d3Zoom?.translateExtent(r),e({translateExtent:r})},resetSelectedElements:()=>{const{edges:r,getNodes:s}=t(),a=s().filter(u=>u.selected).map(u=>ur(u.id,!1)),c=r.filter(u=>u.selected).map(u=>ur(u.id,!1));gl({changedNodes:a,changedEdges:c,get:t,set:e})},setNodeExtent:r=>{const{nodeInternals:s}=t();s.forEach(i=>{i.positionAbsolute=Wc(i.position,r)}),e({nodeExtent:r,nodeInternals:new Map(s)})},panBy:r=>{const{transform:s,width:i,height:a,d3Zoom:c,d3Selection:u,translateExtent:f}=t();if(!c||!u||!r.x&&!r.y)return!1;const p=ir.translate(s[0]+r.x,s[1]+r.y).scale(s[2]),m=[[0,0],[i,a]],E=c?.constrain()(p,m,f);return c.transform(u,E),s[0]!==E.x||s[1]!==E.y||s[2]!==E.k},cancelConnection:()=>e({connectionNodeId:dr.connectionNodeId,connectionHandleId:dr.connectionHandleId,connectionHandleType:dr.connectionHandleType,connectionStatus:dr.connectionStatus,connectionStartHandle:dr.connectionStartHandle,connectionEndHandle:dr.connectionEndHandle}),reset:()=>e({...dr})}),Object.is),hu=({children:e})=>{const t=b.useRef(null);return t.current||(t.current=mR()),te.createElement(Mw,{value:t.current},e)};hu.displayName="ReactFlowProvider";const xm=({children:e})=>b.useContext(ul)?te.createElement(te.Fragment,null,e):te.createElement(hu,null,e);xm.displayName="ReactFlowWrapper";const gR={input:Uh,default:ou,output:jh,group:su},ER={default:hl,straight:qc,step:Qc,smoothstep:fl,simplebezier:Xc},yR=[0,0],vR=[15,15],xR={x:0,y:0,zoom:1},SR={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},Sm=b.forwardRef(({nodes:e,edges:t,defaultNodes:r,defaultEdges:s,className:i,nodeTypes:a=gR,edgeTypes:c=ER,onNodeClick:u,onEdgeClick:f,onInit:p,onMove:m,onMoveStart:E,onMoveEnd:v,onConnect:x,onConnectStart:_,onConnectEnd:w,onClickConnectStart:S,onClickConnectEnd:N,onNodeMouseEnter:O,onNodeMouseMove:D,onNodeMouseLeave:T,onNodeContextMenu:A,onNodeDoubleClick:L,onNodeDragStart:F,onNodeDrag:K,onNodeDragStop:Q,onNodesDelete:X,onEdgesDelete:ee,onSelectionChange:ne,onSelectionDragStart:W,onSelectionDrag:I,onSelectionDragStop:V,onSelectionContextMenu:j,onSelectionStart:B,onSelectionEnd:U,connectionMode:$=ar.Strict,connectionLineType:z=cr.Bezier,connectionLineStyle:k,connectionLineComponent:Y,connectionLineContainerStyle:re,deleteKeyCode:oe="Backspace",selectionKeyCode:le="Shift",selectionOnDrag:de=!1,selectionMode:he=Ms.Full,panActivationKeyCode:ue="Space",multiSelectionKeyCode:me=dl()?"Meta":"Control",zoomActivationKeyCode:Re=dl()?"Meta":"Control",snapToGrid:Pe=!1,snapGrid:Je=vR,onlyRenderVisibleElements:wt=!1,selectNodesOnDrag:Be=!0,nodesDraggable:Ue,nodesConnectable:ft,nodesFocusable:pt,nodeOrigin:we=yR,edgesFocusable:un,edgesUpdatable:Ht,elementsSelectable:Qt,defaultViewport:Cn=xR,minZoom:An=.5,maxZoom:dn=2,translateExtent:zn=pu,preventScrolling:fn=!0,nodeExtent:pn,defaultMarkerColor:In="#b1b1b7",zoomOnScroll:Wn=!0,zoomOnPinch:Ke=!0,panOnScroll:it=!1,panOnScrollSpeed:Gn=.5,panOnScrollMode:bn=$r.Free,zoomOnDoubleClick:Yn=!0,panOnDrag:qt=!0,onPaneClick:hn,onPaneMouseEnter:Qr,onPaneMouseMove:qr,onPaneMouseLeave:Kn,onPaneScroll:Zr,onPaneContextMenu:Xn,children:Lt,onEdgeUpdate:zl,onEdgeContextMenu:Wl,onEdgeDoubleClick:Gl,onEdgeMouseEnter:Yl,onEdgeMouseMove:Kl,onEdgeMouseLeave:ri,onEdgeUpdateStart:Xl,onEdgeUpdateEnd:Jr,edgeUpdaterRadius:oi=10,onNodesChange:eo,onEdgesChange:sd,noDragClassName:to="nodrag",noWheelClassName:Ko="nowheel",noPanClassName:no="nopan",fitView:si=!1,fitViewOptions:id,connectOnClick:ld=!0,attributionPosition:ad,proOptions:Qn,defaultEdgeOptions:Ql,elevateNodesOnSelect:ql=!0,elevateEdgesOnSelect:cd=!1,disableKeyboardA11y:ii=!1,autoPanOnConnect:Zl=!0,autoPanOnNodeDrag:Jl=!0,connectionRadius:ea=20,isValidConnection:ud,onError:dd,style:We,id:ta,nodeDragThreshold:li,...na},Xo)=>{const ai=ta||"1";return te.createElement("div",{...na,style:{...We,...SR},ref:Xo,className:St(["react-flow",i]),"data-testid":"rf__wrapper",id:ta},te.createElement(xm,null,te.createElement(hR,{onInit:p,onMove:m,onMoveStart:E,onMoveEnd:v,onNodeClick:u,onEdgeClick:f,onNodeMouseEnter:O,onNodeMouseMove:D,onNodeMouseLeave:T,onNodeContextMenu:A,onNodeDoubleClick:L,nodeTypes:a,edgeTypes:c,connectionLineType:z,connectionLineStyle:k,connectionLineComponent:Y,connectionLineContainerStyle:re,selectionKeyCode:le,selectionOnDrag:de,selectionMode:he,deleteKeyCode:oe,multiSelectionKeyCode:me,panActivationKeyCode:ue,zoomActivationKeyCode:Re,onlyRenderVisibleElements:wt,selectNodesOnDrag:Be,defaultViewport:Cn,translateExtent:zn,minZoom:An,maxZoom:dn,preventScrolling:fn,zoomOnScroll:Wn,zoomOnPinch:Ke,zoomOnDoubleClick:Yn,panOnScroll:it,panOnScrollSpeed:Gn,panOnScrollMode:bn,panOnDrag:qt,onPaneClick:hn,onPaneMouseEnter:Qr,onPaneMouseMove:qr,onPaneMouseLeave:Kn,onPaneScroll:Zr,onPaneContextMenu:Xn,onSelectionContextMenu:j,onSelectionStart:B,onSelectionEnd:U,onEdgeUpdate:zl,onEdgeContextMenu:Wl,onEdgeDoubleClick:Gl,onEdgeMouseEnter:Yl,onEdgeMouseMove:Kl,onEdgeMouseLeave:ri,onEdgeUpdateStart:Xl,onEdgeUpdateEnd:Jr,edgeUpdaterRadius:oi,defaultMarkerColor:In,noDragClassName:to,noWheelClassName:Ko,noPanClassName:no,elevateEdgesOnSelect:cd,rfId:ai,disableKeyboardA11y:ii,nodeOrigin:we,nodeExtent:pn}),te.createElement(dN,{nodes:e,edges:t,defaultNodes:r,defaultEdges:s,onConnect:x,onConnectStart:_,onConnectEnd:w,onClickConnectStart:S,onClickConnectEnd:N,nodesDraggable:Ue,nodesConnectable:ft,nodesFocusable:pt,edgesFocusable:un,edgesUpdatable:Ht,elementsSelectable:Qt,elevateNodesOnSelect:ql,minZoom:An,maxZoom:dn,nodeExtent:pn,onNodesChange:eo,onEdgesChange:sd,snapToGrid:Pe,snapGrid:Je,connectionMode:$,translateExtent:zn,connectOnClick:ld,defaultEdgeOptions:Ql,fitView:si,fitViewOptions:id,onNodesDelete:X,onEdgesDelete:ee,onNodeDragStart:F,onNodeDrag:K,onNodeDragStop:Q,onSelectionDrag:I,onSelectionDragStart:W,onSelectionDragStop:V,noPanClassName:no,nodeOrigin:we,rfId:ai,autoPanOnConnect:Zl,autoPanOnNodeDrag:Jl,onError:dd,connectionRadius:ea,isValidConnection:ud,nodeDragThreshold:li}),te.createElement(cN,{onSelectionChange:ne}),Lt,te.createElement(Uw,{proOptions:Qn,position:ad}),te.createElement(gN,{rfId:ai,disableKeyboardA11y:ii})))});Sm.displayName="ReactFlow";const _R=e=>e.domNode?.querySelector(".react-flow__edgelabel-renderer");function wR({children:e}){const t=Me(_R);return t?Bc.createPortal(e,t):null}function NR(){const e=tt();return b.useCallback(t=>{const{domNode:r,updateNodeDimensions:s}=e.getState(),a=(Array.isArray(t)?t:[t]).reduce((c,u)=>{const f=r?.querySelector(`.react-flow__node[data-id="${u}"]`);return f&&c.push({id:u,nodeElement:f,forceUpdate:!0}),c},[]);requestAnimationFrame(()=>s(a))},[])}function RR({onStart:e,onChange:t,onEnd:r}){const s=tt();b.useEffect(()=>{s.setState({onViewportChangeStart:e})},[e]),b.useEffect(()=>{s.setState({onViewportChange:t})},[t]),b.useEffect(()=>{s.setState({onViewportChangeEnd:r})},[r])}const TR=e=>t=>t.nodeInternals.size===0?!1:t.getNodes().filter(r=>e.includeHiddenNodes?!0:!r.hidden).every(r=>r[nt]?.handleBounds!==void 0),OR={includeHiddenNodes:!1};function CR(e=OR){return Me(TR(e))}function AR(){return te.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},te.createElement("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"}))}function IR(){return te.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},te.createElement("path",{d:"M0 0h32v4.2H0z"}))}function bR(){return te.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30"},te.createElement("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"}))}function LR(){return te.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},te.createElement("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"}))}function DR(){return te.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},te.createElement("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"}))}const Vs=({children:e,className:t,...r})=>te.createElement("button",{type:"button",className:St(["react-flow__controls-button",t]),...r},e);Vs.displayName="ControlButton";const kR=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom}),_m=({style:e,showZoom:t=!0,showFitView:r=!0,showInteractive:s=!0,fitViewOptions:i,onZoomIn:a,onZoomOut:c,onFitView:u,onInteractiveChange:f,className:p,children:m,position:E="bottom-left"})=>{const v=tt(),[x,_]=b.useState(!1),{isInteractive:w,minZoomReached:S,maxZoomReached:N}=Me(kR,gt),{zoomIn:O,zoomOut:D,fitView:T}=lu();if(b.useEffect(()=>{_(!0)},[]),!x)return null;const A=()=>{O(),a?.()},L=()=>{D(),c?.()},F=()=>{T(i),u?.()},K=()=>{v.setState({nodesDraggable:!w,nodesConnectable:!w,elementsSelectable:!w}),f?.(!w)};return te.createElement(Ds,{className:St(["react-flow__controls",p]),position:E,style:e,"data-testid":"rf__controls"},t&&te.createElement(te.Fragment,null,te.createElement(Vs,{onClick:A,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:N},te.createElement(AR,null)),te.createElement(Vs,{onClick:L,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:S},te.createElement(IR,null))),r&&te.createElement(Vs,{className:"react-flow__controls-fitview",onClick:F,title:"fit view","aria-label":"fit view"},te.createElement(bR,null)),s&&te.createElement(Vs,{className:"react-flow__controls-interactive",onClick:K,title:"toggle interactivity","aria-label":"toggle interactivity"},w?te.createElement(DR,null):te.createElement(LR,null)),m)};_m.displayName="Controls";var MR=b.memo(_m),Kt;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Kt||(Kt={}));function PR({color:e,dimensions:t,lineWidth:r}){return te.createElement("path",{stroke:e,strokeWidth:r,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`})}function UR({color:e,radius:t}){return te.createElement("circle",{cx:t,cy:t,r:t,fill:e})}const FR={[Kt.Dots]:"#91919a",[Kt.Lines]:"#eee",[Kt.Cross]:"#e2e2e2"},jR={[Kt.Dots]:1,[Kt.Lines]:1,[Kt.Cross]:6},VR=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function wm({id:e,variant:t=Kt.Dots,gap:r=20,size:s,lineWidth:i=1,offset:a=2,color:c,style:u,className:f}){const p=b.useRef(null),{transform:m,patternId:E}=Me(VR,gt),v=c||FR[t],x=s||jR[t],_=t===Kt.Dots,w=t===Kt.Cross,S=Array.isArray(r)?r:[r,r],N=[S[0]*m[2]||1,S[1]*m[2]||1],O=x*m[2],D=w?[O,O]:N,T=_?[O/a,O/a]:[D[0]/a,D[1]/a];return te.createElement("svg",{className:St(["react-flow__background",f]),style:{...u,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:p,"data-testid":"rf__background"},te.createElement("pattern",{id:E+e,x:m[0]%N[0],y:m[1]%N[1],width:N[0],height:N[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${T[0]},-${T[1]})`},_?te.createElement(UR,{color:v,radius:O/a}):te.createElement(PR,{dimensions:D,color:v,lineWidth:i})),te.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${E+e})`}))}wm.displayName="Background";var $R=b.memo(wm);const Nm={},{useDebugValue:HR}=te,{useSyncExternalStoreWithSelector:BR}=fp;let Rm=!1;function zR(e,t=e.getState,r){(Nm?"staging":void 0)!=="production"&&r&&!Rm&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),Rm=!0);const s=BR(e.subscribe,e.getState,e.getServerState||e.getState,t,r);return HR(s),s}const Tm=e=>{(Nm?"staging":void 0)!=="production"&&typeof e!="function"&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");const t=typeof e=="function"?hp(e):e,r=(s,i)=>zR(t,s,i);return Object.assign(r,t),r},Do=e=>e?Tm(e):Tm,WR=!1,GR="staging",YR="0.0.14",$s="0.0.10",Om=230,KR=640,Cm=20,ko={markerEnd:{height:20,type:Ps.ArrowClosed,width:20},style:{stroke:"inherit",strokeWidth:1.5},type:"floating"},XR="422",QR="404",Am="document-sync",mu=1e3,qR=1e3,ZR=300,JR=5e3,Im=300,e1="Shift+Backspace",t1="Meta",n1="Shift",yl=25,gu={duration:mu,includeHiddenNodes:!1,padding:.3},Eu=()=>{const e={},t=document.querySelector('meta[name="csrf-token"]');return t&&(e["X-CSRF-Token"]=t?.content),e},r1=(e,t)=>{const r=new Blob([JSON.stringify({edges:t,nodes:e},null,2)],{type:"application/json"}),s=window.URL.createObjectURL(r),i=window.open();i?.location?.href&&(i.location.href=s)},bm=e=>({...e,...ko}),Lm=e=>e.type==="handleCall"?{...e,deletable:!1}:e,Dm=e=>e==="success"?"positive":"negative",o1=e=>e.toLowerCase().replace(/ /g,"-"),jt=e=>typeof e=="string"?e.trim():e,km=(e,t,r)=>e.sort((s,i)=>{const a=s[r],c=i[r];if(typeof a=="string"&&typeof c=="string")return a.toLowerCase().localeCompare(c.toLowerCase());if(typeof a=="number"&&typeof c=="number")return a-c;throw new Error(`sort fn can only sort strings & numbers, but got ${typeof a} and ${typeof c}`)}),s1=e=>{try{return new URL(e).pathname.split("/").at(-1)}catch{return""}};function Mm(e,t){const r=[{divisor:1,threshold:60,unit:"second"},{divisor:60,threshold:3600,unit:"minute"},{divisor:3600,threshold:86400,unit:"hour"},{divisor:86400,threshold:86400,unit:"day"}],s=new Intl.RelativeTimeFormat(e,{numeric:"always",...t});return function(a,c={}){const{excludeUnits:u={}}=c,f=new Date().getTime(),p=new Date(a).getTime(),m=Math.floor((f-p)/1e3),E=r.filter(({unit:w})=>!u[w]),{divisor:v,unit:x}=E.find(({threshold:w})=>Math.abs(m)<w)??E[E.length-1],_=Math.floor(m/v);return s.format(-_,x)}}function Pm(e){return new Promise(t=>setTimeout(t,e))}const i1=(e,t,r)=>{const s=e==="ArrowDown";if(!t)return s?r[0]:r[r.length-1];const i=r.findIndex(u=>u.id===t),a=s?i+1:i-1;if(a<0||a>=r.length)return;const c=r[a];if(!c)throw new Error(`Could not find option at index ${a}`);return c},Um=(e,t,r)=>{const s=e.find(i=>{if(t in i)return i[t]===r});if(!s)throw new Error(`Could not find option with id ${t}`);return s},l1=e=>Object.keys(e),yu=()=>({callOrder:"single",callStateEvents:"",callStateUrl:"",connections:[{connectConfirmDisplayName:"",connectConfirmEnabled:!1,connectConfirmId:"",connectConfirmUrl:"",connectFrom:"",connectTimeout:"",connectTo:"",id:Le()}],defaultFrom:"",defaultTimeout:"",destinationType:"phone",options:[{id:Le(),result:"success"},{id:Le(),result:"noAnswer"},{id:Le(),result:"busy"},{id:Le(),result:"decline"},{id:Le(),result:"error"}]}),Fm={aiAgent:()=>({agent:""}),answer:()=>({valid:!0}),cond:()=>({fallback:Le(),options:[{id:Le(),value:""}]}),condRequest:()=>({body:"",error:Le(),fallback:Le(),headers:"",method:"POST",options:[{id:Le(),value:""}],url:""}),executeSWML:()=>({dest:"",fallback:Le(),meta:"",options:[{id:Le(),value:""}],params:""}),forwardAddress:()=>({...yu(),destinationType:"address"}),forwardPhone:()=>({...yu(),destinationType:"phone"}),forwardResource:()=>({...yu(),destinationType:"resource"}),handleCall:()=>({valid:!0}),hangup:()=>({valid:!0}),play:()=>({selected:"",text:"",url:""}),promptPlay:()=>({digitTimeout:"",initialTimeout:"",options:[{command:"",digit:"",id:Le()}],results:[{id:Le(),result:"no_match"},{id:Le(),result:"no_input"}],selected:"",text:"",url:""}),record:()=>({beep:!1,endSilenceTimeout:"",format:"wav",initialTimeout:"",maxLength:"",stereo:!1,terminators:"",valid:!0}),recordCallStart:()=>({beep:!1,controlId:Le(),format:"wav",label:"",stereo:!1,terminators:""}),recordCallStop:()=>({controlId:""}),request:()=>({body:"",headers:"",method:"POST",options:[{id:Le(),result:"success"},{id:Le(),result:"failed"}],url:""}),sendSms:()=>({body:"",fromNumber:"",media:[],region:"",tags:[],toNumber:""}),set:()=>({variables:[{duplicate:!1,id:Le(),key:"",value:""}]}),unset:()=>({variables:[]})},a1={type:"logger",log(e){this.output("log",e)},warn(e){this.output("warn",e)},error(e){this.output("error",e)},output(e,t){console&&console[e]&&console[e].apply(console,t)}};class vl{constructor(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.init(t,r)}init(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.prefix=r.prefix||"i18next:",this.logger=t||a1,this.options=r,this.debug=r.debug}log(){for(var t=arguments.length,r=new Array(t),s=0;s<t;s++)r[s]=arguments[s];return this.forward(r,"log","",!0)}warn(){for(var t=arguments.length,r=new Array(t),s=0;s<t;s++)r[s]=arguments[s];return this.forward(r,"warn","",!0)}error(){for(var t=arguments.length,r=new Array(t),s=0;s<t;s++)r[s]=arguments[s];return this.forward(r,"error","")}deprecate(){for(var t=arguments.length,r=new Array(t),s=0;s<t;s++)r[s]=arguments[s];return this.forward(r,"warn","WARNING DEPRECATED: ",!0)}forward(t,r,s,i){return i&&!this.debug?null:(typeof t[0]=="string"&&(t[0]=`${s}${this.prefix} ${t[0]}`),this.logger[r](t))}create(t){return new vl(this.logger,{prefix:`${this.prefix}:${t}:`,...this.options})}clone(t){return t=t||this.options,t.prefix=t.prefix||this.prefix,new vl(this.logger,t)}}var Rn=new vl;class xl{constructor(){this.observers={}}on(t,r){return t.split(" ").forEach(s=>{this.observers[s]=this.observers[s]||[],this.observers[s].push(r)}),this}off(t,r){if(this.observers[t]){if(!r){delete this.observers[t];return}this.observers[t]=this.observers[t].filter(s=>s!==r)}}emit(t){for(var r=arguments.length,s=new Array(r>1?r-1:0),i=1;i<r;i++)s[i-1]=arguments[i];this.observers[t]&&[].concat(this.observers[t]).forEach(c=>{c(...s)}),this.observers["*"]&&[].concat(this.observers["*"]).forEach(c=>{c.apply(c,[t,...s])})}}function Hs(){let e,t;const r=new Promise((s,i)=>{e=s,t=i});return r.resolve=e,r.reject=t,r}function jm(e){return e==null?"":""+e}function c1(e,t,r){e.forEach(s=>{t[s]&&(r[s]=t[s])})}function vu(e,t,r){function s(c){return c&&c.indexOf("###")>-1?c.replace(/###/g,"."):c}function i(){return!e||typeof e=="string"}const a=typeof t!="string"?[].concat(t):t.split(".");for(;a.length>1;){if(i())return{};const c=s(a.shift());!e[c]&&r&&(e[c]=new r),Object.prototype.hasOwnProperty.call(e,c)?e=e[c]:e={}}return i()?{}:{obj:e,k:s(a.shift())}}function Vm(e,t,r){const{obj:s,k:i}=vu(e,t,Object);s[i]=r}function u1(e,t,r,s){const{obj:i,k:a}=vu(e,t,Object);i[a]=i[a]||[],i[a].push(r)}function Sl(e,t){const{obj:r,k:s}=vu(e,t);if(r)return r[s]}function d1(e,t,r){const s=Sl(e,r);return s!==void 0?s:Sl(t,r)}function $m(e,t,r){for(const s in t)s!=="__proto__"&&s!=="constructor"&&(s in e?typeof e[s]=="string"||e[s]instanceof String||typeof t[s]=="string"||t[s]instanceof String?r&&(e[s]=t[s]):$m(e[s],t[s],r):e[s]=t[s]);return e}function Mo(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}var f1={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};function p1(e){return typeof e=="string"?e.replace(/[&<>"'\/]/g,t=>f1[t]):e}const h1=[" ",",","?","!",";"];function m1(e,t,r){t=t||"",r=r||"";const s=h1.filter(c=>t.indexOf(c)<0&&r.indexOf(c)<0);if(s.length===0)return!0;const i=new RegExp(`(${s.map(c=>c==="?"?"\\?":c).join("|")})`);let a=!i.test(e);if(!a){const c=e.indexOf(r);c>0&&!i.test(e.substring(0,c))&&(a=!0)}return a}function _l(e,t){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:".";if(!e)return;if(e[t])return e[t];const s=t.split(r);let i=e;for(let a=0;a<s.length;++a){if(!i||typeof i[s[a]]=="string"&&a+1<s.length)return;if(i[s[a]]===void 0){let c=2,u=s.slice(a,a+c).join(r),f=i[u];for(;f===void 0&&s.length>a+c;)c++,u=s.slice(a,a+c).join(r),f=i[u];if(f===void 0)return;if(f===null)return null;if(t.endsWith(u)){if(typeof f=="string")return f;if(u&&typeof f[u]=="string")return f[u]}const p=s.slice(a+c).join(r);return p?_l(f,p,r):void 0}i=i[s[a]]}return i}function wl(e){return e&&e.indexOf("_")>0?e.replace("_","-"):e}class Hm extends xl{constructor(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{ns:["translation"],defaultNS:"translation"};super(),this.data=t||{},this.options=r,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(t){this.options.ns.indexOf(t)<0&&this.options.ns.push(t)}removeNamespaces(t){const r=this.options.ns.indexOf(t);r>-1&&this.options.ns.splice(r,1)}getResource(t,r,s){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};const a=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,c=i.ignoreJSONStructure!==void 0?i.ignoreJSONStructure:this.options.ignoreJSONStructure;let u=[t,r];s&&typeof s!="string"&&(u=u.concat(s)),s&&typeof s=="string"&&(u=u.concat(a?s.split(a):s)),t.indexOf(".")>-1&&(u=t.split("."));const f=Sl(this.data,u);return f||!c||typeof s!="string"?f:_l(this.data&&this.data[t]&&this.data[t][r],s,a)}addResource(t,r,s,i){let a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{silent:!1};const c=a.keySeparator!==void 0?a.keySeparator:this.options.keySeparator;let u=[t,r];s&&(u=u.concat(c?s.split(c):s)),t.indexOf(".")>-1&&(u=t.split("."),i=r,r=u[1]),this.addNamespaces(r),Vm(this.data,u,i),a.silent||this.emit("added",t,r,s,i)}addResources(t,r,s){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{silent:!1};for(const a in s)(typeof s[a]=="string"||Object.prototype.toString.apply(s[a])==="[object Array]")&&this.addResource(t,r,a,s[a],{silent:!0});i.silent||this.emit("added",t,r,s)}addResourceBundle(t,r,s,i,a){let c=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{silent:!1},u=[t,r];t.indexOf(".")>-1&&(u=t.split("."),i=s,s=r,r=u[1]),this.addNamespaces(r);let f=Sl(this.data,u)||{};i?$m(f,s,a):f={...f,...s},Vm(this.data,u,f),c.silent||this.emit("added",t,r,s)}removeResourceBundle(t,r){this.hasResourceBundle(t,r)&&delete this.data[t][r],this.removeNamespaces(r),this.emit("removed",t,r)}hasResourceBundle(t,r){return this.getResource(t,r)!==void 0}getResourceBundle(t,r){return r||(r=this.options.defaultNS),this.options.compatibilityAPI==="v1"?{...this.getResource(t,r)}:this.getResource(t,r)}getDataByLanguage(t){return this.data[t]}hasLanguageSomeTranslations(t){const r=this.getDataByLanguage(t);return!!(r&&Object.keys(r)||[]).find(i=>r[i]&&Object.keys(r[i]).length>0)}toJSON(){return this.data}}var Bm={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,r,s,i){return e.forEach(a=>{this.processors[a]&&(t=this.processors[a].process(t,r,s,i))}),t}};const zm={};class Nl extends xl{constructor(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),c1(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],t,this),this.options=r,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=Rn.create("translator")}changeLanguage(t){t&&(this.language=t)}exists(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}};if(t==null)return!1;const s=this.resolve(t,r);return s&&s.res!==void 0}extractFromKey(t,r){let s=r.nsSeparator!==void 0?r.nsSeparator:this.options.nsSeparator;s===void 0&&(s=":");const i=r.keySeparator!==void 0?r.keySeparator:this.options.keySeparator;let a=r.ns||this.options.defaultNS||[];const c=s&&t.indexOf(s)>-1,u=!this.options.userDefinedKeySeparator&&!r.keySeparator&&!this.options.userDefinedNsSeparator&&!r.nsSeparator&&!m1(t,s,i);if(c&&!u){const f=t.match(this.interpolator.nestingRegexp);if(f&&f.length>0)return{key:t,namespaces:a};const p=t.split(s);(s!==i||s===i&&this.options.ns.indexOf(p[0])>-1)&&(a=p.shift()),t=p.join(i)}return typeof a=="string"&&(a=[a]),{key:t,namespaces:a}}translate(t,r,s){if(typeof r!="object"&&this.options.overloadTranslationOptionHandler&&(r=this.options.overloadTranslationOptionHandler(arguments)),typeof r=="object"&&(r={...r}),r||(r={}),t==null)return"";Array.isArray(t)||(t=[String(t)]);const i=r.returnDetails!==void 0?r.returnDetails:this.options.returnDetails,a=r.keySeparator!==void 0?r.keySeparator:this.options.keySeparator,{key:c,namespaces:u}=this.extractFromKey(t[t.length-1],r),f=u[u.length-1],p=r.lng||this.language,m=r.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(p&&p.toLowerCase()==="cimode"){if(m){const T=r.nsSeparator||this.options.nsSeparator;return i?{res:`${f}${T}${c}`,usedKey:c,exactUsedKey:c,usedLng:p,usedNS:f,usedParams:this.getUsedParamsDetails(r)}:`${f}${T}${c}`}return i?{res:c,usedKey:c,exactUsedKey:c,usedLng:p,usedNS:f,usedParams:this.getUsedParamsDetails(r)}:c}const E=this.resolve(t,r);let v=E&&E.res;const x=E&&E.usedKey||c,_=E&&E.exactUsedKey||c,w=Object.prototype.toString.apply(v),S=["[object Number]","[object Function]","[object RegExp]"],N=r.joinArrays!==void 0?r.joinArrays:this.options.joinArrays,O=!this.i18nFormat||this.i18nFormat.handleAsObject;if(O&&v&&(typeof v!="string"&&typeof v!="boolean"&&typeof v!="number")&&S.indexOf(w)<0&&!(typeof N=="string"&&w==="[object Array]")){if(!r.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const T=this.options.returnedObjectHandler?this.options.returnedObjectHandler(x,v,{...r,ns:u}):`key '${c} (${this.language})' returned an object instead of string.`;return i?(E.res=T,E.usedParams=this.getUsedParamsDetails(r),E):T}if(a){const T=w==="[object Array]",A=T?[]:{},L=T?_:x;for(const F in v)if(Object.prototype.hasOwnProperty.call(v,F)){const K=`${L}${a}${F}`;A[F]=this.translate(K,{...r,joinArrays:!1,ns:u}),A[F]===K&&(A[F]=v[F])}v=A}}else if(O&&typeof N=="string"&&w==="[object Array]")v=v.join(N),v&&(v=this.extendTranslation(v,t,r,s));else{let T=!1,A=!1;const L=r.count!==void 0&&typeof r.count!="string",F=Nl.hasDefaultValue(r),K=L?this.pluralResolver.getSuffix(p,r.count,r):"",Q=r.ordinal&&L?this.pluralResolver.getSuffix(p,r.count,{ordinal:!1}):"",X=r[`defaultValue${K}`]||r[`defaultValue${Q}`]||r.defaultValue;!this.isValidLookup(v)&&F&&(T=!0,v=X),this.isValidLookup(v)||(A=!0,v=c);const ne=(r.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&A?void 0:v,W=F&&X!==v&&this.options.updateMissing;if(A||T||W){if(this.logger.log(W?"updateKey":"missingKey",p,f,c,W?X:v),a){const B=this.resolve(c,{...r,keySeparator:!1});B&&B.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let I=[];const V=this.languageUtils.getFallbackCodes(this.options.fallbackLng,r.lng||this.language);if(this.options.saveMissingTo==="fallback"&&V&&V[0])for(let B=0;B<V.length;B++)I.push(V[B]);else this.options.saveMissingTo==="all"?I=this.languageUtils.toResolveHierarchy(r.lng||this.language):I.push(r.lng||this.language);const j=(B,U,$)=>{const z=F&&$!==v?$:ne;this.options.missingKeyHandler?this.options.missingKeyHandler(B,f,U,z,W,r):this.backendConnector&&this.backendConnector.saveMissing&&this.backendConnector.saveMissing(B,f,U,z,W,r),this.emit("missingKey",B,f,U,v)};this.options.saveMissing&&(this.options.saveMissingPlurals&&L?I.forEach(B=>{this.pluralResolver.getSuffixes(B,r).forEach(U=>{j([B],c+U,r[`defaultValue${U}`]||X)})}):j(I,c,X))}v=this.extendTranslation(v,t,r,E,s),A&&v===c&&this.options.appendNamespaceToMissingKey&&(v=`${f}:${c}`),(A||T)&&this.options.parseMissingKeyHandler&&(this.options.compatibilityAPI!=="v1"?v=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${f}:${c}`:c,T?v:void 0):v=this.options.parseMissingKeyHandler(v))}return i?(E.res=v,E.usedParams=this.getUsedParamsDetails(r),E):v}extendTranslation(t,r,s,i,a){var c=this;if(this.i18nFormat&&this.i18nFormat.parse)t=this.i18nFormat.parse(t,{...this.options.interpolation.defaultVariables,...s},s.lng||this.language||i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!s.skipInterpolation){s.interpolation&&this.interpolator.init({...s,interpolation:{...this.options.interpolation,...s.interpolation}});const p=typeof t=="string"&&(s&&s.interpolation&&s.interpolation.skipOnVariables!==void 0?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let m;if(p){const v=t.match(this.interpolator.nestingRegexp);m=v&&v.length}let E=s.replace&&typeof s.replace!="string"?s.replace:s;if(this.options.interpolation.defaultVariables&&(E={...this.options.interpolation.defaultVariables,...E}),t=this.interpolator.interpolate(t,E,s.lng||this.language,s),p){const v=t.match(this.interpolator.nestingRegexp),x=v&&v.length;m<x&&(s.nest=!1)}!s.lng&&this.options.compatibilityAPI!=="v1"&&i&&i.res&&(s.lng=i.usedLng),s.nest!==!1&&(t=this.interpolator.nest(t,function(){for(var v=arguments.length,x=new Array(v),_=0;_<v;_++)x[_]=arguments[_];return a&&a[0]===x[0]&&!s.context?(c.logger.warn(`It seems you are nesting recursively key: ${x[0]} in key: ${r[0]}`),null):c.translate(...x,r)},s)),s.interpolation&&this.interpolator.reset()}const u=s.postProcess||this.options.postProcess,f=typeof u=="string"?[u]:u;return t!=null&&f&&f.length&&s.applyPostProcessor!==!1&&(t=Bm.handle(f,t,r,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...i,usedParams:this.getUsedParamsDetails(s)},...s}:s,this)),t}resolve(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s,i,a,c,u;return typeof t=="string"&&(t=[t]),t.forEach(f=>{if(this.isValidLookup(s))return;const p=this.extractFromKey(f,r),m=p.key;i=m;let E=p.namespaces;this.options.fallbackNS&&(E=E.concat(this.options.fallbackNS));const v=r.count!==void 0&&typeof r.count!="string",x=v&&!r.ordinal&&r.count===0&&this.pluralResolver.shouldUseIntlApi(),_=r.context!==void 0&&(typeof r.context=="string"||typeof r.context=="number")&&r.context!=="",w=r.lngs?r.lngs:this.languageUtils.toResolveHierarchy(r.lng||this.language,r.fallbackLng);E.forEach(S=>{this.isValidLookup(s)||(u=S,!zm[`${w[0]}-${S}`]&&this.utils&&this.utils.hasLoadedNamespace&&!this.utils.hasLoadedNamespace(u)&&(zm[`${w[0]}-${S}`]=!0,this.logger.warn(`key "${i}" for languages "${w.join(", ")}" won't get resolved as namespace "${u}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),w.forEach(N=>{if(this.isValidLookup(s))return;c=N;const O=[m];if(this.i18nFormat&&this.i18nFormat.addLookupKeys)this.i18nFormat.addLookupKeys(O,m,N,S,r);else{let T;v&&(T=this.pluralResolver.getSuffix(N,r.count,r));const A=`${this.options.pluralSeparator}zero`,L=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(v&&(O.push(m+T),r.ordinal&&T.indexOf(L)===0&&O.push(m+T.replace(L,this.options.pluralSeparator)),x&&O.push(m+A)),_){const F=`${m}${this.options.contextSeparator}${r.context}`;O.push(F),v&&(O.push(F+T),r.ordinal&&T.indexOf(L)===0&&O.push(F+T.replace(L,this.options.pluralSeparator)),x&&O.push(F+A))}}let D;for(;D=O.pop();)this.isValidLookup(s)||(a=D,s=this.getResource(N,S,D,r))}))})}),{res:s,usedKey:i,exactUsedKey:a,usedLng:c,usedNS:u}}isValidLookup(t){return t!==void 0&&!(!this.options.returnNull&&t===null)&&!(!this.options.returnEmptyString&&t==="")}getResource(t,r,s){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return this.i18nFormat&&this.i18nFormat.getResource?this.i18nFormat.getResource(t,r,s,i):this.resourceStore.getResource(t,r,s,i)}getUsedParamsDetails(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const r=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],s=t.replace&&typeof t.replace!="string";let i=s?t.replace:t;if(s&&typeof t.count<"u"&&(i.count=t.count),this.options.interpolation.defaultVariables&&(i={...this.options.interpolation.defaultVariables,...i}),!s){i={...i};for(const a of r)delete i[a]}return i}static hasDefaultValue(t){const r="defaultValue";for(const s in t)if(Object.prototype.hasOwnProperty.call(t,s)&&r===s.substring(0,r.length)&&t[s]!==void 0)return!0;return!1}}function xu(e){return e.charAt(0).toUpperCase()+e.slice(1)}class Wm{constructor(t){this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Rn.create("languageUtils")}getScriptPartFromCode(t){if(t=wl(t),!t||t.indexOf("-")<0)return null;const r=t.split("-");return r.length===2||(r.pop(),r[r.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(r.join("-"))}getLanguagePartFromCode(t){if(t=wl(t),!t||t.indexOf("-")<0)return t;const r=t.split("-");return this.formatLanguageCode(r[0])}formatLanguageCode(t){if(typeof t=="string"&&t.indexOf("-")>-1){const r=["hans","hant","latn","cyrl","cans","mong","arab"];let s=t.split("-");return this.options.lowerCaseLng?s=s.map(i=>i.toLowerCase()):s.length===2?(s[0]=s[0].toLowerCase(),s[1]=s[1].toUpperCase(),r.indexOf(s[1].toLowerCase())>-1&&(s[1]=xu(s[1].toLowerCase()))):s.length===3&&(s[0]=s[0].toLowerCase(),s[1].length===2&&(s[1]=s[1].toUpperCase()),s[0]!=="sgn"&&s[2].length===2&&(s[2]=s[2].toUpperCase()),r.indexOf(s[1].toLowerCase())>-1&&(s[1]=xu(s[1].toLowerCase())),r.indexOf(s[2].toLowerCase())>-1&&(s[2]=xu(s[2].toLowerCase()))),s.join("-")}return this.options.cleanCode||this.options.lowerCaseLng?t.toLowerCase():t}isSupportedCode(t){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(t=this.getLanguagePartFromCode(t)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(t)>-1}getBestMatchFromCodes(t){if(!t)return null;let r;return t.forEach(s=>{if(r)return;const i=this.formatLanguageCode(s);(!this.options.supportedLngs||this.isSupportedCode(i))&&(r=i)}),!r&&this.options.supportedLngs&&t.forEach(s=>{if(r)return;const i=this.getLanguagePartFromCode(s);if(this.isSupportedCode(i))return r=i;r=this.options.supportedLngs.find(a=>{if(a===i)return a;if(!(a.indexOf("-")<0&&i.indexOf("-")<0)&&a.indexOf(i)===0)return a})}),r||(r=this.getFallbackCodes(this.options.fallbackLng)[0]),r}getFallbackCodes(t,r){if(!t)return[];if(typeof t=="function"&&(t=t(r)),typeof t=="string"&&(t=[t]),Object.prototype.toString.apply(t)==="[object Array]")return t;if(!r)return t.default||[];let s=t[r];return s||(s=t[this.getScriptPartFromCode(r)]),s||(s=t[this.formatLanguageCode(r)]),s||(s=t[this.getLanguagePartFromCode(r)]),s||(s=t.default),s||[]}toResolveHierarchy(t,r){const s=this.getFallbackCodes(r||this.options.fallbackLng||[],t),i=[],a=c=>{c&&(this.isSupportedCode(c)?i.push(c):this.logger.warn(`rejecting language code not found in supportedLngs: ${c}`))};return typeof t=="string"&&(t.indexOf("-")>-1||t.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&a(this.formatLanguageCode(t)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&a(this.getScriptPartFromCode(t)),this.options.load!=="currentOnly"&&a(this.getLanguagePartFromCode(t))):typeof t=="string"&&a(this.formatLanguageCode(t)),s.forEach(c=>{i.indexOf(c)<0&&a(this.formatLanguageCode(c))}),i}}let g1=[{lngs:["ach","ak","am","arn","br","fil","gun","ln","mfe","mg","mi","oc","pt","pt-BR","tg","tl","ti","tr","uz","wa"],nr:[1,2],fc:1},{lngs:["af","an","ast","az","bg","bn","ca","da","de","dev","el","en","eo","es","et","eu","fi","fo","fur","fy","gl","gu","ha","hi","hu","hy","ia","it","kk","kn","ku","lb","mai","ml","mn","mr","nah","nap","nb","ne","nl","nn","no","nso","pa","pap","pms","ps","pt-PT","rm","sco","se","si","so","son","sq","sv","sw","ta","te","tk","ur","yo"],nr:[1,2],fc:2},{lngs:["ay","bo","cgg","fa","ht","id","ja","jbo","ka","km","ko","ky","lo","ms","sah","su","th","tt","ug","vi","wo","zh"],nr:[1],fc:3},{lngs:["be","bs","cnr","dz","hr","ru","sr","uk"],nr:[1,2,5],fc:4},{lngs:["ar"],nr:[0,1,2,3,11,100],fc:5},{lngs:["cs","sk"],nr:[1,2,5],fc:6},{lngs:["csb","pl"],nr:[1,2,5],fc:7},{lngs:["cy"],nr:[1,2,3,8],fc:8},{lngs:["fr"],nr:[1,2],fc:9},{lngs:["ga"],nr:[1,2,3,7,11],fc:10},{lngs:["gd"],nr:[1,2,3,20],fc:11},{lngs:["is"],nr:[1,2],fc:12},{lngs:["jv"],nr:[0,1],fc:13},{lngs:["kw"],nr:[1,2,3,4],fc:14},{lngs:["lt"],nr:[1,2,10],fc:15},{lngs:["lv"],nr:[1,2,0],fc:16},{lngs:["mk"],nr:[1,2],fc:17},{lngs:["mnk"],nr:[0,1,2],fc:18},{lngs:["mt"],nr:[1,2,11,20],fc:19},{lngs:["or"],nr:[2,1],fc:2},{lngs:["ro"],nr:[1,2,20],fc:20},{lngs:["sl"],nr:[5,1,2,3],fc:21},{lngs:["he","iw"],nr:[1,2,20,21],fc:22}],E1={1:function(e){return+(e>1)},2:function(e){return+(e!=1)},3:function(e){return 0},4:function(e){return e%10==1&&e%100!=11?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2},5:function(e){return e==0?0:e==1?1:e==2?2:e%100>=3&&e%100<=10?3:e%100>=11?4:5},6:function(e){return e==1?0:e>=2&&e<=4?1:2},7:function(e){return e==1?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2},8:function(e){return e==1?0:e==2?1:e!=8&&e!=11?2:3},9:function(e){return+(e>=2)},10:function(e){return e==1?0:e==2?1:e<7?2:e<11?3:4},11:function(e){return e==1||e==11?0:e==2||e==12?1:e>2&&e<20?2:3},12:function(e){return+(e%10!=1||e%100==11)},13:function(e){return+(e!==0)},14:function(e){return e==1?0:e==2?1:e==3?2:3},15:function(e){return e%10==1&&e%100!=11?0:e%10>=2&&(e%100<10||e%100>=20)?1:2},16:function(e){return e%10==1&&e%100!=11?0:e!==0?1:2},17:function(e){return e==1||e%10==1&&e%100!=11?0:1},18:function(e){return e==0?0:e==1?1:2},19:function(e){return e==1?0:e==0||e%100>1&&e%100<11?1:e%100>10&&e%100<20?2:3},20:function(e){return e==1?0:e==0||e%100>0&&e%100<20?1:2},21:function(e){return e%100==1?1:e%100==2?2:e%100==3||e%100==4?3:0},22:function(e){return e==1?0:e==2?1:(e<0||e>10)&&e%10==0?2:3}};const y1=["v1","v2","v3"],v1=["v4"],Gm={zero:0,one:1,two:2,few:3,many:4,other:5};function x1(){const e={};return g1.forEach(t=>{t.lngs.forEach(r=>{e[r]={numbers:t.nr,plurals:E1[t.fc]}})}),e}class S1{constructor(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.languageUtils=t,this.options=r,this.logger=Rn.create("pluralResolver"),(!this.options.compatibilityJSON||v1.includes(this.options.compatibilityJSON))&&(typeof Intl>"u"||!Intl.PluralRules)&&(this.options.compatibilityJSON="v3",this.logger.error("Your environment seems not to be Intl API compatible, use an Intl.PluralRules polyfill. Will fallback to the compatibilityJSON v3 format handling.")),this.rules=x1()}addRule(t,r){this.rules[t]=r}getRule(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(this.shouldUseIntlApi())try{return new Intl.PluralRules(wl(t),{type:r.ordinal?"ordinal":"cardinal"})}catch{return}return this.rules[t]||this.rules[this.languageUtils.getLanguagePartFromCode(t)]}needsPlural(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const s=this.getRule(t,r);return this.shouldUseIntlApi()?s&&s.resolvedOptions().pluralCategories.length>1:s&&s.numbers.length>1}getPluralFormsOfKey(t,r){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return this.getSuffixes(t,s).map(i=>`${r}${i}`)}getSuffixes(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const s=this.getRule(t,r);return s?this.shouldUseIntlApi()?s.resolvedOptions().pluralCategories.sort((i,a)=>Gm[i]-Gm[a]).map(i=>`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${i}`):s.numbers.map(i=>this.getSuffix(t,i,r)):[]}getSuffix(t,r){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const i=this.getRule(t,s);return i?this.shouldUseIntlApi()?`${this.options.prepend}${s.ordinal?`ordinal${this.options.prepend}`:""}${i.select(r)}`:this.getSuffixRetroCompatible(i,r):(this.logger.warn(`no plural rule found for: ${t}`),"")}getSuffixRetroCompatible(t,r){const s=t.noAbs?t.plurals(r):t.plurals(Math.abs(r));let i=t.numbers[s];this.options.simplifyPluralSuffix&&t.numbers.length===2&&t.numbers[0]===1&&(i===2?i="plural":i===1&&(i=""));const a=()=>this.options.prepend&&i.toString()?this.options.prepend+i.toString():i.toString();return this.options.compatibilityJSON==="v1"?i===1?"":typeof i=="number"?`_plural_${i.toString()}`:a():this.options.compatibilityJSON==="v2"||this.options.simplifyPluralSuffix&&t.numbers.length===2&&t.numbers[0]===1?a():this.options.prepend&&s.toString()?this.options.prepend+s.toString():s.toString()}shouldUseIntlApi(){return!y1.includes(this.options.compatibilityJSON)}}function Ym(e,t,r){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:".",i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,a=d1(e,t,r);return!a&&i&&typeof r=="string"&&(a=_l(e,r,s),a===void 0&&(a=_l(t,r,s))),a}class _1{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=Rn.create("interpolator"),this.options=t,this.format=t.interpolation&&t.interpolation.format||(r=>r),this.init(t)}init(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};t.interpolation||(t.interpolation={escapeValue:!0});const r=t.interpolation;this.escape=r.escape!==void 0?r.escape:p1,this.escapeValue=r.escapeValue!==void 0?r.escapeValue:!0,this.useRawValueToEscape=r.useRawValueToEscape!==void 0?r.useRawValueToEscape:!1,this.prefix=r.prefix?Mo(r.prefix):r.prefixEscaped||"{{",this.suffix=r.suffix?Mo(r.suffix):r.suffixEscaped||"}}",this.formatSeparator=r.formatSeparator?r.formatSeparator:r.formatSeparator||",",this.unescapePrefix=r.unescapeSuffix?"":r.unescapePrefix||"-",this.unescapeSuffix=this.unescapePrefix?"":r.unescapeSuffix||"",this.nestingPrefix=r.nestingPrefix?Mo(r.nestingPrefix):r.nestingPrefixEscaped||Mo("$t("),this.nestingSuffix=r.nestingSuffix?Mo(r.nestingSuffix):r.nestingSuffixEscaped||Mo(")"),this.nestingOptionsSeparator=r.nestingOptionsSeparator?r.nestingOptionsSeparator:r.nestingOptionsSeparator||",",this.maxReplaces=r.maxReplaces?r.maxReplaces:1e3,this.alwaysFormat=r.alwaysFormat!==void 0?r.alwaysFormat:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const t=`${this.prefix}(.+?)${this.suffix}`;this.regexp=new RegExp(t,"g");const r=`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`;this.regexpUnescape=new RegExp(r,"g");const s=`${this.nestingPrefix}(.+?)${this.nestingSuffix}`;this.nestingRegexp=new RegExp(s,"g")}interpolate(t,r,s,i){let a,c,u;const f=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{};function p(_){return _.replace(/\$/g,"$$$$")}const m=_=>{if(_.indexOf(this.formatSeparator)<0){const O=Ym(r,f,_,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(O,void 0,s,{...i,...r,interpolationkey:_}):O}const w=_.split(this.formatSeparator),S=w.shift().trim(),N=w.join(this.formatSeparator).trim();return this.format(Ym(r,f,S,this.options.keySeparator,this.options.ignoreJSONStructure),N,s,{...i,...r,interpolationkey:S})};this.resetRegExp();const E=i&&i.missingInterpolationHandler||this.options.missingInterpolationHandler,v=i&&i.interpolation&&i.interpolation.skipOnVariables!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:_=>p(_)},{regex:this.regexp,safeValue:_=>this.escapeValue?p(this.escape(_)):p(_)}].forEach(_=>{for(u=0;a=_.regex.exec(t);){const w=a[1].trim();if(c=m(w),c===void 0)if(typeof E=="function"){const N=E(t,a,i);c=typeof N=="string"?N:""}else if(i&&Object.prototype.hasOwnProperty.call(i,w))c="";else if(v){c=a[0];continue}else this.logger.warn(`missed to pass in variable ${w} for interpolating ${t}`),c="";else typeof c!="string"&&!this.useRawValueToEscape&&(c=jm(c));const S=_.safeValue(c);if(t=t.replace(a[0],S),v?(_.regex.lastIndex+=c.length,_.regex.lastIndex-=a[0].length):_.regex.lastIndex=0,u++,u>=this.maxReplaces)break}}),t}nest(t,r){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},i,a,c;function u(f,p){const m=this.nestingOptionsSeparator;if(f.indexOf(m)<0)return f;const E=f.split(new RegExp(`${m}[ ]*{`));let v=`{${E[1]}`;f=E[0],v=this.interpolate(v,c);const x=v.match(/'/g),_=v.match(/"/g);(x&&x.length%2===0&&!_||_.length%2!==0)&&(v=v.replace(/'/g,'"'));try{c=JSON.parse(v),p&&(c={...p,...c})}catch(w){return this.logger.warn(`failed parsing options string in nesting for key ${f}`,w),`${f}${m}${v}`}return delete c.defaultValue,f}for(;i=this.nestingRegexp.exec(t);){let f=[];c={...s},c=c.replace&&typeof c.replace!="string"?c.replace:c,c.applyPostProcessor=!1,delete c.defaultValue;let p=!1;if(i[0].indexOf(this.formatSeparator)!==-1&&!/{.*}/.test(i[1])){const m=i[1].split(this.formatSeparator).map(E=>E.trim());i[1]=m.shift(),f=m,p=!0}if(a=r(u.call(this,i[1].trim(),c),c),a&&i[0]===t&&typeof a!="string")return a;typeof a!="string"&&(a=jm(a)),a||(this.logger.warn(`missed to resolve ${i[1]} for nesting ${t}`),a=""),p&&(a=f.reduce((m,E)=>this.format(m,E,s.lng,{...s,interpolationkey:i[1].trim()}),a.trim())),t=t.replace(i[0],a),this.regexp.lastIndex=0}return t}}function w1(e){let t=e.toLowerCase().trim();const r={};if(e.indexOf("(")>-1){const s=e.split("(");t=s[0].toLowerCase().trim();const i=s[1].substring(0,s[1].length-1);t==="currency"&&i.indexOf(":")<0?r.currency||(r.currency=i.trim()):t==="relativetime"&&i.indexOf(":")<0?r.range||(r.range=i.trim()):i.split(";").forEach(c=>{if(!c)return;const[u,...f]=c.split(":"),p=f.join(":").trim().replace(/^'+|'+$/g,"");r[u.trim()]||(r[u.trim()]=p),p==="false"&&(r[u.trim()]=!1),p==="true"&&(r[u.trim()]=!0),isNaN(p)||(r[u.trim()]=parseInt(p,10))})}return{formatName:t,formatOptions:r}}function Po(e){const t={};return function(s,i,a){const c=i+JSON.stringify(a);let u=t[c];return u||(u=e(wl(i),a),t[c]=u),u(s)}}class N1{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=Rn.create("formatter"),this.options=t,this.formats={number:Po((r,s)=>{const i=new Intl.NumberFormat(r,{...s});return a=>i.format(a)}),currency:Po((r,s)=>{const i=new Intl.NumberFormat(r,{...s,style:"currency"});return a=>i.format(a)}),datetime:Po((r,s)=>{const i=new Intl.DateTimeFormat(r,{...s});return a=>i.format(a)}),relativetime:Po((r,s)=>{const i=new Intl.RelativeTimeFormat(r,{...s});return a=>i.format(a,s.range||"day")}),list:Po((r,s)=>{const i=new Intl.ListFormat(r,{...s});return a=>i.format(a)})},this.init(t)}init(t){const s=(arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}}).interpolation;this.formatSeparator=s.formatSeparator?s.formatSeparator:s.formatSeparator||","}add(t,r){this.formats[t.toLowerCase().trim()]=r}addCached(t,r){this.formats[t.toLowerCase().trim()]=Po(r)}format(t,r,s){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return r.split(this.formatSeparator).reduce((u,f)=>{const{formatName:p,formatOptions:m}=w1(f);if(this.formats[p]){let E=u;try{const v=i&&i.formatParams&&i.formatParams[i.interpolationkey]||{},x=v.locale||v.lng||i.locale||i.lng||s;E=this.formats[p](u,x,{...m,...i,...v})}catch(v){this.logger.warn(v)}return E}else this.logger.warn(`there was no format function for ${p}`);return u},t)}}function R1(e,t){e.pending[t]!==void 0&&(delete e.pending[t],e.pendingCount--)}class T1 extends xl{constructor(t,r,s){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};super(),this.backend=t,this.store=r,this.services=s,this.languageUtils=s.languageUtils,this.options=i,this.logger=Rn.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=i.maxParallelReads||10,this.readingCalls=0,this.maxRetries=i.maxRetries>=0?i.maxRetries:5,this.retryTimeout=i.retryTimeout>=1?i.retryTimeout:350,this.state={},this.queue=[],this.backend&&this.backend.init&&this.backend.init(s,i.backend,i)}queueLoad(t,r,s,i){const a={},c={},u={},f={};return t.forEach(p=>{let m=!0;r.forEach(E=>{const v=`${p}|${E}`;!s.reload&&this.store.hasResourceBundle(p,E)?this.state[v]=2:this.state[v]<0||(this.state[v]===1?c[v]===void 0&&(c[v]=!0):(this.state[v]=1,m=!1,c[v]===void 0&&(c[v]=!0),a[v]===void 0&&(a[v]=!0),f[E]===void 0&&(f[E]=!0)))}),m||(u[p]=!0)}),(Object.keys(a).length||Object.keys(c).length)&&this.queue.push({pending:c,pendingCount:Object.keys(c).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(a),pending:Object.keys(c),toLoadLanguages:Object.keys(u),toLoadNamespaces:Object.keys(f)}}loaded(t,r,s){const i=t.split("|"),a=i[0],c=i[1];r&&this.emit("failedLoading",a,c,r),s&&this.store.addResourceBundle(a,c,s),this.state[t]=r?-1:2;const u={};this.queue.forEach(f=>{u1(f.loaded,[a],c),R1(f,t),r&&f.errors.push(r),f.pendingCount===0&&!f.done&&(Object.keys(f.loaded).forEach(p=>{u[p]||(u[p]={});const m=f.loaded[p];m.length&&m.forEach(E=>{u[p][E]===void 0&&(u[p][E]=!0)})}),f.done=!0,f.errors.length?f.callback(f.errors):f.callback())}),this.emit("loaded",u),this.queue=this.queue.filter(f=>!f.done)}read(t,r,s){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:this.retryTimeout,c=arguments.length>5?arguments[5]:void 0;if(!t.length)return c(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:t,ns:r,fcName:s,tried:i,wait:a,callback:c});return}this.readingCalls++;const u=(p,m)=>{if(this.readingCalls--,this.waitingReads.length>0){const E=this.waitingReads.shift();this.read(E.lng,E.ns,E.fcName,E.tried,E.wait,E.callback)}if(p&&m&&i<this.maxRetries){setTimeout(()=>{this.read.call(this,t,r,s,i+1,a*2,c)},a);return}c(p,m)},f=this.backend[s].bind(this.backend);if(f.length===2){try{const p=f(t,r);p&&typeof p.then=="function"?p.then(m=>u(null,m)).catch(u):u(null,p)}catch(p){u(p)}return}return f(t,r,u)}prepareLoading(t,r){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},i=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),i&&i();typeof t=="string"&&(t=this.languageUtils.toResolveHierarchy(t)),typeof r=="string"&&(r=[r]);const a=this.queueLoad(t,r,s,i);if(!a.toLoad.length)return a.pending.length||i(),null;a.toLoad.forEach(c=>{this.loadOne(c)})}load(t,r,s){this.prepareLoading(t,r,{},s)}reload(t,r,s){this.prepareLoading(t,r,{reload:!0},s)}loadOne(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";const s=t.split("|"),i=s[0],a=s[1];this.read(i,a,"read",void 0,void 0,(c,u)=>{c&&this.logger.warn(`${r}loading namespace ${a} for language ${i} failed`,c),!c&&u&&this.logger.log(`${r}loaded namespace ${a} for language ${i}`,u),this.loaded(t,c,u)})}saveMissing(t,r,s,i,a){let c=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{},u=arguments.length>6&&arguments[6]!==void 0?arguments[6]:()=>{};if(this.services.utils&&this.services.utils.hasLoadedNamespace&&!this.services.utils.hasLoadedNamespace(r)){this.logger.warn(`did not save key "${s}" as the namespace "${r}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(s==null||s==="")){if(this.backend&&this.backend.create){const f={...c,isUpdate:a},p=this.backend.create.bind(this.backend);if(p.length<6)try{let m;p.length===5?m=p(t,r,s,i,f):m=p(t,r,s,i),m&&typeof m.then=="function"?m.then(E=>u(null,E)).catch(u):u(null,m)}catch(m){u(m)}else p(t,r,s,i,u,f)}!t||!t[0]||this.store.addResource(t[0],r,s,i)}}}function Km(){return{debug:!1,initImmediate:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:function(t){let r={};if(typeof t[1]=="object"&&(r=t[1]),typeof t[1]=="string"&&(r.defaultValue=t[1]),typeof t[2]=="string"&&(r.tDescription=t[2]),typeof t[2]=="object"||typeof t[3]=="object"){const s=t[3]||t[2];Object.keys(s).forEach(i=>{r[i]=s[i]})}return r},interpolation:{escapeValue:!0,format:(e,t,r,s)=>e,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0}}}function Xm(e){return typeof e.ns=="string"&&(e.ns=[e.ns]),typeof e.fallbackLng=="string"&&(e.fallbackLng=[e.fallbackLng]),typeof e.fallbackNS=="string"&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs&&e.supportedLngs.indexOf("cimode")<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),e}function Rl(){}function O1(e){Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(r=>{typeof e[r]=="function"&&(e[r]=e[r].bind(e))})}class Bs extends xl{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;if(super(),this.options=Xm(t),this.services={},this.logger=Rn,this.modules={external:[]},O1(this),r&&!this.isInitialized&&!t.isClone){if(!this.options.initImmediate)return this.init(t,r),this;setTimeout(()=>{this.init(t,r)},0)}}init(){var t=this;let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},s=arguments.length>1?arguments[1]:void 0;typeof r=="function"&&(s=r,r={}),!r.defaultNS&&r.defaultNS!==!1&&r.ns&&(typeof r.ns=="string"?r.defaultNS=r.ns:r.ns.indexOf("translation")<0&&(r.defaultNS=r.ns[0]));const i=Km();this.options={...i,...this.options,...Xm(r)},this.options.compatibilityAPI!=="v1"&&(this.options.interpolation={...i.interpolation,...this.options.interpolation}),r.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=r.keySeparator),r.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=r.nsSeparator);function a(m){return m?typeof m=="function"?new m:m:null}if(!this.options.isClone){this.modules.logger?Rn.init(a(this.modules.logger),this.options):Rn.init(null,this.options);let m;this.modules.formatter?m=this.modules.formatter:typeof Intl<"u"&&(m=N1);const E=new Wm(this.options);this.store=new Hm(this.options.resources,this.options);const v=this.services;v.logger=Rn,v.resourceStore=this.store,v.languageUtils=E,v.pluralResolver=new S1(E,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),m&&(!this.options.interpolation.format||this.options.interpolation.format===i.interpolation.format)&&(v.formatter=a(m),v.formatter.init(v,this.options),this.options.interpolation.format=v.formatter.format.bind(v.formatter)),v.interpolator=new _1(this.options),v.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},v.backendConnector=new T1(a(this.modules.backend),v.resourceStore,v,this.options),v.backendConnector.on("*",function(x){for(var _=arguments.length,w=new Array(_>1?_-1:0),S=1;S<_;S++)w[S-1]=arguments[S];t.emit(x,...w)}),this.modules.languageDetector&&(v.languageDetector=a(this.modules.languageDetector),v.languageDetector.init&&v.languageDetector.init(v,this.options.detection,this.options)),this.modules.i18nFormat&&(v.i18nFormat=a(this.modules.i18nFormat),v.i18nFormat.init&&v.i18nFormat.init(this)),this.translator=new Nl(this.services,this.options),this.translator.on("*",function(x){for(var _=arguments.length,w=new Array(_>1?_-1:0),S=1;S<_;S++)w[S-1]=arguments[S];t.emit(x,...w)}),this.modules.external.forEach(x=>{x.init&&x.init(this)})}if(this.format=this.options.interpolation.format,s||(s=Rl),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const m=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);m.length>0&&m[0]!=="dev"&&(this.options.lng=m[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(m=>{this[m]=function(){return t.store[m](...arguments)}}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(m=>{this[m]=function(){return t.store[m](...arguments),t}});const f=Hs(),p=()=>{const m=(E,v)=>{this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),f.resolve(v),s(E,v)};if(this.languages&&this.options.compatibilityAPI!=="v1"&&!this.isInitialized)return m(null,this.t.bind(this));this.changeLanguage(this.options.lng,m)};return this.options.resources||!this.options.initImmediate?p():setTimeout(p,0),f}loadResources(t){let s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Rl;const i=typeof t=="string"?t:this.language;if(typeof t=="function"&&(s=t),!this.options.resources||this.options.partialBundledLanguages){if(i&&i.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return s();const a=[],c=u=>{if(!u||u==="cimode")return;this.services.languageUtils.toResolveHierarchy(u).forEach(p=>{p!=="cimode"&&a.indexOf(p)<0&&a.push(p)})};i?c(i):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(f=>c(f)),this.options.preload&&this.options.preload.forEach(u=>c(u)),this.services.backendConnector.load(a,this.options.ns,u=>{!u&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),s(u)})}else s(null)}reloadResources(t,r,s){const i=Hs();return t||(t=this.languages),r||(r=this.options.ns),s||(s=Rl),this.services.backendConnector.reload(t,r,a=>{i.resolve(),s(a)}),i}use(t){if(!t)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!t.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return t.type==="backend"&&(this.modules.backend=t),(t.type==="logger"||t.log&&t.warn&&t.error)&&(this.modules.logger=t),t.type==="languageDetector"&&(this.modules.languageDetector=t),t.type==="i18nFormat"&&(this.modules.i18nFormat=t),t.type==="postProcessor"&&Bm.addPostProcessor(t),t.type==="formatter"&&(this.modules.formatter=t),t.type==="3rdParty"&&this.modules.external.push(t),this}setResolvedLanguage(t){if(!(!t||!this.languages)&&!(["cimode","dev"].indexOf(t)>-1))for(let r=0;r<this.languages.length;r++){const s=this.languages[r];if(!(["cimode","dev"].indexOf(s)>-1)&&this.store.hasLanguageSomeTranslations(s)){this.resolvedLanguage=s;break}}}changeLanguage(t,r){var s=this;this.isLanguageChangingTo=t;const i=Hs();this.emit("languageChanging",t);const a=f=>{this.language=f,this.languages=this.services.languageUtils.toResolveHierarchy(f),this.resolvedLanguage=void 0,this.setResolvedLanguage(f)},c=(f,p)=>{p?(a(p),this.translator.changeLanguage(p),this.isLanguageChangingTo=void 0,this.emit("languageChanged",p),this.logger.log("languageChanged",p)):this.isLanguageChangingTo=void 0,i.resolve(function(){return s.t(...arguments)}),r&&r(f,function(){return s.t(...arguments)})},u=f=>{!t&&!f&&this.services.languageDetector&&(f=[]);const p=typeof f=="string"?f:this.services.languageUtils.getBestMatchFromCodes(f);p&&(this.language||a(p),this.translator.language||this.translator.changeLanguage(p),this.services.languageDetector&&this.services.languageDetector.cacheUserLanguage&&this.services.languageDetector.cacheUserLanguage(p)),this.loadResources(p,m=>{c(m,p)})};return!t&&this.services.languageDetector&&!this.services.languageDetector.async?u(this.services.languageDetector.detect()):!t&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(u):this.services.languageDetector.detect(u):u(t),i}getFixedT(t,r,s){var i=this;const a=function(c,u){let f;if(typeof u!="object"){for(var p=arguments.length,m=new Array(p>2?p-2:0),E=2;E<p;E++)m[E-2]=arguments[E];f=i.options.overloadTranslationOptionHandler([c,u].concat(m))}else f={...u};f.lng=f.lng||a.lng,f.lngs=f.lngs||a.lngs,f.ns=f.ns||a.ns,f.keyPrefix=f.keyPrefix||s||a.keyPrefix;const v=i.options.keySeparator||".";let x;return f.keyPrefix&&Array.isArray(c)?x=c.map(_=>`${f.keyPrefix}${v}${_}`):x=f.keyPrefix?`${f.keyPrefix}${v}${c}`:c,i.t(x,f)};return typeof t=="string"?a.lng=t:a.lngs=t,a.ns=r,a.keyPrefix=s,a}t(){return this.translator&&this.translator.translate(...arguments)}exists(){return this.translator&&this.translator.exists(...arguments)}setDefaultNamespace(t){this.options.defaultNS=t}hasLoadedNamespace(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const s=r.lng||this.resolvedLanguage||this.languages[0],i=this.options?this.options.fallbackLng:!1,a=this.languages[this.languages.length-1];if(s.toLowerCase()==="cimode")return!0;const c=(u,f)=>{const p=this.services.backendConnector.state[`${u}|${f}`];return p===-1||p===2};if(r.precheck){const u=r.precheck(this,c);if(u!==void 0)return u}return!!(this.hasResourceBundle(s,t)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||c(s,t)&&(!i||c(a,t)))}loadNamespaces(t,r){const s=Hs();return this.options.ns?(typeof t=="string"&&(t=[t]),t.forEach(i=>{this.options.ns.indexOf(i)<0&&this.options.ns.push(i)}),this.loadResources(i=>{s.resolve(),r&&r(i)}),s):(r&&r(),Promise.resolve())}loadLanguages(t,r){const s=Hs();typeof t=="string"&&(t=[t]);const i=this.options.preload||[],a=t.filter(c=>i.indexOf(c)<0);return a.length?(this.options.preload=i.concat(a),this.loadResources(c=>{s.resolve(),r&&r(c)}),s):(r&&r(),Promise.resolve())}dir(t){if(t||(t=this.resolvedLanguage||(this.languages&&this.languages.length>0?this.languages[0]:this.language)),!t)return"rtl";const r=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],s=this.services&&this.services.languageUtils||new Wm(Km());return r.indexOf(s.getLanguagePartFromCode(t))>-1||t.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;return new Bs(t,r)}cloneInstance(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Rl;const s=t.forkResourceStore;s&&delete t.forkResourceStore;const i={...this.options,...t,isClone:!0},a=new Bs(i);return(t.debug!==void 0||t.prefix!==void 0)&&(a.logger=a.logger.clone(t)),["store","services","language"].forEach(u=>{a[u]=this[u]}),a.services={...this.services},a.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},s&&(a.store=new Hm(this.store.data,i),a.services.resourceStore=a.store),a.translator=new Nl(a.services,i),a.translator.on("*",function(u){for(var f=arguments.length,p=new Array(f>1?f-1:0),m=1;m<f;m++)p[m-1]=arguments[m];a.emit(u,...p)}),a.init(i,r),a.translator.options=i,a.translator.backendConnector.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},a}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const ut=Bs.createInstance();ut.createInstance=Bs.createInstance,ut.createInstance,ut.dir,ut.init,ut.loadResources,ut.reloadResources,ut.use,ut.changeLanguage,ut.getFixedT;const M=ut.t;ut.exists,ut.setDefaultNamespace,ut.hasLoadedNamespace,ut.loadNamespaces,ut.loadLanguages;function C1(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function zs(e){"@babel/helpers - typeof";return zs=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},zs(e)}function A1(e,t){if(zs(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var s=r.call(e,t);if(zs(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}function I1(e){var t=A1(e,"string");return zs(t)=="symbol"?t:t+""}function b1(e,t){for(var r=0;r<t.length;r++){var s=t[r];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,I1(s.key),s)}}function L1(e,t,r){return t&&b1(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var Qm=[],D1=Qm.forEach,k1=Qm.slice;function M1(e){return D1.call(k1.call(arguments,1),function(t){if(t)for(var r in t)e[r]===void 0&&(e[r]=t[r])}),e}var qm=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,P1=function(t,r,s){var i=s||{};i.path=i.path||"/";var a=encodeURIComponent(r),c="".concat(t,"=").concat(a);if(i.maxAge>0){var u=i.maxAge-0;if(Number.isNaN(u))throw new Error("maxAge should be a Number");c+="; Max-Age=".concat(Math.floor(u))}if(i.domain){if(!qm.test(i.domain))throw new TypeError("option domain is invalid");c+="; Domain=".concat(i.domain)}if(i.path){if(!qm.test(i.path))throw new TypeError("option path is invalid");c+="; Path=".concat(i.path)}if(i.expires){if(typeof i.expires.toUTCString!="function")throw new TypeError("option expires is invalid");c+="; Expires=".concat(i.expires.toUTCString())}if(i.httpOnly&&(c+="; HttpOnly"),i.secure&&(c+="; Secure"),i.sameSite){var f=typeof i.sameSite=="string"?i.sameSite.toLowerCase():i.sameSite;switch(f){case!0:c+="; SameSite=Strict";break;case"lax":c+="; SameSite=Lax";break;case"strict":c+="; SameSite=Strict";break;case"none":c+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}}return c},Zm={create:function(t,r,s,i){var a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{path:"/",sameSite:"strict"};s&&(a.expires=new Date,a.expires.setTime(a.expires.getTime()+s*60*1e3)),i&&(a.domain=i),document.cookie=P1(t,encodeURIComponent(r),a)},read:function(t){for(var r="".concat(t,"="),s=document.cookie.split(";"),i=0;i<s.length;i++){for(var a=s[i];a.charAt(0)===" ";)a=a.substring(1,a.length);if(a.indexOf(r)===0)return a.substring(r.length,a.length)}return null},remove:function(t){this.create(t,"",-1)}},U1={name:"cookie",lookup:function(t){var r;if(t.lookupCookie&&typeof document<"u"){var s=Zm.read(t.lookupCookie);s&&(r=s)}return r},cacheUserLanguage:function(t,r){r.lookupCookie&&typeof document<"u"&&Zm.create(r.lookupCookie,t,r.cookieMinutes,r.cookieDomain,r.cookieOptions)}},F1={name:"querystring",lookup:function(t){var r;if(typeof window<"u"){var s=window.location.search;!window.location.search&&window.location.hash&&window.location.hash.indexOf("?")>-1&&(s=window.location.hash.substring(window.location.hash.indexOf("?")));for(var i=s.substring(1),a=i.split("&"),c=0;c<a.length;c++){var u=a[c].indexOf("=");if(u>0){var f=a[c].substring(0,u);f===t.lookupQuerystring&&(r=a[c].substring(u+1))}}}return r}},Ws=null,Jm=function(){if(Ws!==null)return Ws;try{Ws=window!=="undefined"&&window.localStorage!==null;var t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{Ws=!1}return Ws},j1={name:"localStorage",lookup:function(t){var r;if(t.lookupLocalStorage&&Jm()){var s=window.localStorage.getItem(t.lookupLocalStorage);s&&(r=s)}return r},cacheUserLanguage:function(t,r){r.lookupLocalStorage&&Jm()&&window.localStorage.setItem(r.lookupLocalStorage,t)}},Gs=null,eg=function(){if(Gs!==null)return Gs;try{Gs=window!=="undefined"&&window.sessionStorage!==null;var t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{Gs=!1}return Gs},V1={name:"sessionStorage",lookup:function(t){var r;if(t.lookupSessionStorage&&eg()){var s=window.sessionStorage.getItem(t.lookupSessionStorage);s&&(r=s)}return r},cacheUserLanguage:function(t,r){r.lookupSessionStorage&&eg()&&window.sessionStorage.setItem(r.lookupSessionStorage,t)}},$1={name:"navigator",lookup:function(t){var r=[];if(typeof navigator<"u"){if(navigator.languages)for(var s=0;s<navigator.languages.length;s++)r.push(navigator.languages[s]);navigator.userLanguage&&r.push(navigator.userLanguage),navigator.language&&r.push(navigator.language)}return r.length>0?r:void 0}},H1={name:"htmlTag",lookup:function(t){var r,s=t.htmlTag||(typeof document<"u"?document.documentElement:null);return s&&typeof s.getAttribute=="function"&&(r=s.getAttribute("lang")),r}},B1={name:"path",lookup:function(t){var r;if(typeof window<"u"){var s=window.location.pathname.match(/\/([a-zA-Z-]*)/g);if(s instanceof Array)if(typeof t.lookupFromPathIndex=="number"){if(typeof s[t.lookupFromPathIndex]!="string")return;r=s[t.lookupFromPathIndex].replace("/","")}else r=s[0].replace("/","")}return r}},z1={name:"subdomain",lookup:function(t){var r=typeof t.lookupFromSubdomainIndex=="number"?t.lookupFromSubdomainIndex+1:1,s=typeof window<"u"&&window.location&&window.location.hostname&&window.location.hostname.match(/^(\w{2,5})\.(([a-z0-9-]{1,63}\.[a-z]{2,6})|localhost)/i);if(s)return s[r]}};function W1(){return{order:["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"],lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:function(t){return t}}}var tg=function(){function e(t){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};C1(this,e),this.type="languageDetector",this.detectors={},this.init(t,r)}return L1(e,[{key:"init",value:function(r){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.services=r||{languageUtils:{}},this.options=M1(s,this.options||{},W1()),typeof this.options.convertDetectedLanguage=="string"&&this.options.convertDetectedLanguage.indexOf("15897")>-1&&(this.options.convertDetectedLanguage=function(a){return a.replace("-","_")}),this.options.lookupFromUrlIndex&&(this.options.lookupFromPathIndex=this.options.lookupFromUrlIndex),this.i18nOptions=i,this.addDetector(U1),this.addDetector(F1),this.addDetector(j1),this.addDetector(V1),this.addDetector($1),this.addDetector(H1),this.addDetector(B1),this.addDetector(z1)}},{key:"addDetector",value:function(r){this.detectors[r.name]=r}},{key:"detect",value:function(r){var s=this;r||(r=this.options.order);var i=[];return r.forEach(function(a){if(s.detectors[a]){var c=s.detectors[a].lookup(s.options);c&&typeof c=="string"&&(c=[c]),c&&(i=i.concat(c))}}),i=i.map(function(a){return s.options.convertDetectedLanguage(a)}),this.services.languageUtils.getBestMatchFromCodes?i:i.length>0?i[0]:null}},{key:"cacheUserLanguage",value:function(r,s){var i=this;s||(s=this.options.caches),s&&(this.options.excludeCacheFor&&this.options.excludeCacheFor.indexOf(r)>-1||s.forEach(function(a){i.detectors[a]&&i.detectors[a].cacheUserLanguage(r,i.options)}))}}]),e}();tg.type="languageDetector";function Su(){return Su=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var s in r)({}).hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},Su.apply(null,arguments)}var _u,ng;function G1(){return ng||(ng=1,_u={area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0}),_u}var Y1=G1();const K1=Hi(Y1);var X1=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;function rg(e){var t={type:"tag",name:"",voidElement:!1,attrs:{},children:[]},r=e.match(/<\/?([^\s]+?)[/\s>]/);if(r&&(t.name=r[1],(K1[r[1]]||e.charAt(e.length-2)==="/")&&(t.voidElement=!0),t.name.startsWith("!--"))){var s=e.indexOf("-->");return{type:"comment",comment:s!==-1?e.slice(4,s):""}}for(var i=new RegExp(X1),a=null;(a=i.exec(e))!==null;)if(a[0].trim())if(a[1]){var c=a[1].trim(),u=[c,""];c.indexOf("=")>-1&&(u=c.split("=")),t.attrs[u[0]]=u[1],i.lastIndex--}else a[2]&&(t.attrs[a[2]]=a[3].trim().substring(1,a[3].length-1));return t}var Q1=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,q1=/^\s*$/,Z1=Object.create(null);function og(e,t){switch(t.type){case"text":return e+t.content;case"tag":return e+="<"+t.name+(t.attrs?function(r){var s=[];for(var i in r)s.push(i+'="'+r[i]+'"');return s.length?" "+s.join(" "):""}(t.attrs):"")+(t.voidElement?"/>":">"),t.voidElement?e:e+t.children.reduce(og,"")+"</"+t.name+">";case"comment":return e+"<!--"+t.comment+"-->"}}var J1={parse:function(e,t){t||(t={}),t.components||(t.components=Z1);var r,s=[],i=[],a=-1,c=!1;if(e.indexOf("<")!==0){var u=e.indexOf("<");s.push({type:"text",content:u===-1?e:e.substring(0,u)})}return e.replace(Q1,function(f,p){if(c){if(f!=="</"+r.name+">")return;c=!1}var m,E=f.charAt(1)!=="/",v=f.startsWith("<!--"),x=p+f.length,_=e.charAt(x);if(v){var w=rg(f);return a<0?(s.push(w),s):((m=i[a]).children.push(w),s)}if(E&&(a++,(r=rg(f)).type==="tag"&&t.components[r.name]&&(r.type="component",c=!0),r.voidElement||c||!_||_==="<"||r.children.push({type:"text",content:e.slice(x,e.indexOf("<",x))}),a===0&&s.push(r),(m=i[a-1])&&m.children.push(r),i[a]=r),(!E||r.voidElement)&&(a>-1&&(r.voidElement||r.name===f.slice(2,-1))&&(a--,r=a===-1?s:i[a]),!c&&_!=="<"&&_)){m=a===-1?s:i[a].children;var S=e.indexOf("<",x),N=e.slice(x,S===-1?void 0:S);q1.test(N)&&(N=" "),(S>-1&&a+m.length>=0||N!==" ")&&m.push({type:"text",content:N})}}),s},stringify:function(e){return e.reduce(function(t,r){return t+og("",r)},"")}};function Tl(){if(console&&console.warn){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];typeof t[0]=="string"&&(t[0]=`react-i18next:: ${t[0]}`),console.warn(...t)}}const sg={};function eT(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];typeof t[0]=="string"&&sg[t[0]]||(typeof t[0]=="string"&&(sg[t[0]]=new Date),Tl(...t))}const tT=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,nT={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"©","©":"©","®":"®","®":"®","…":"…","…":"…","/":"/","/":"/"},rT=e=>nT[e];let wu={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:e=>e.replace(tT,rT)};function oT(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};wu={...wu,...e}}function sT(){return wu}let ig;function iT(e){ig=e}function lg(){return ig}function Nu(e,t){if(!e)return!1;const r=e.props?e.props.children:e.children;return t?r.length>0:!!r}function Ru(e){if(!e)return[];const t=e.props?e.props.children:e.children;return e.props&&e.props.i18nIsDynamicList?Uo(t):t}function lT(e){return Object.prototype.toString.call(e)!=="[object Array]"?!1:e.every(t=>b.isValidElement(t))}function Uo(e){return Array.isArray(e)?e:[e]}function aT(e,t){const r={...t};return r.props=Object.assign(e.props,t.props),r}function ag(e,t){if(!e)return"";let r="";const s=Uo(e),i=t.transSupportBasicHtmlNodes&&t.transKeepBasicHtmlNodesFor?t.transKeepBasicHtmlNodesFor:[];return s.forEach((a,c)=>{if(typeof a=="string")r+=`${a}`;else if(b.isValidElement(a)){const u=Object.keys(a.props).length,f=i.indexOf(a.type)>-1,p=a.props.children;if(!p&&f&&u===0)r+=`<${a.type}/>`;else if(!p&&(!f||u!==0))r+=`<${c}></${c}>`;else if(a.props.i18nIsDynamicList)r+=`<${c}></${c}>`;else if(f&&u===1&&typeof p=="string")r+=`<${a.type}>${p}</${a.type}>`;else{const m=ag(p,t);r+=`<${c}>${m}</${c}>`}}else if(a===null)Tl("Trans: the passed in value is invalid - seems you passed in a null child.");else if(typeof a=="object"){const{format:u,...f}=a,p=Object.keys(f);if(p.length===1){const m=u?`${p[0]}, ${u}`:p[0];r+=`{{${m}}}`}else Tl("react-i18next: the passed in object contained more than one variable - the object should look like {{ value, format }} where format is optional.",a)}else Tl("Trans: the passed in value is invalid - seems you passed in a variable like {number} - please pass in variables for interpolation as full objects like {{number}}.",a)}),r}function cT(e,t,r,s,i,a){if(t==="")return[];const c=s.transKeepBasicHtmlNodesFor||[],u=t&&new RegExp(c.map(S=>`<${S}`).join("|")).test(t);if(!e&&!u&&!a)return[t];const f={};function p(S){Uo(S).forEach(O=>{typeof O!="string"&&(Nu(O)?p(Ru(O)):typeof O=="object"&&!b.isValidElement(O)&&Object.assign(f,O))})}p(e);const m=J1.parse(`<0>${t}</0>`),E={...f,...i};function v(S,N,O){const D=Ru(S),T=_(D,N.children,O);return lT(D)&&T.length===0||S.props&&S.props.i18nIsDynamicList?D:T}function x(S,N,O,D,T){S.dummy?(S.children=N,O.push(b.cloneElement(S,{key:D},T?void 0:N))):O.push(...b.Children.map([S],A=>{const L={...A.props};return delete L.i18nIsDynamicList,te.createElement(A.type,Su({},L,{key:D,ref:A.ref},T?{}:{children:N}))}))}function _(S,N,O){const D=Uo(S);return Uo(N).reduce((A,L,F)=>{const K=L.children&&L.children[0]&&L.children[0].content&&r.services.interpolator.interpolate(L.children[0].content,E,r.language);if(L.type==="tag"){let Q=D[parseInt(L.name,10)];O.length===1&&!Q&&(Q=O[0][L.name]),Q||(Q={});const X=Object.keys(L.attrs).length!==0?aT({props:L.attrs},Q):Q,ee=b.isValidElement(X),ne=ee&&Nu(L,!0)&&!L.voidElement,W=u&&typeof X=="object"&&X.dummy&&!ee,I=typeof e=="object"&&e!==null&&Object.hasOwnProperty.call(e,L.name);if(typeof X=="string"){const V=r.services.interpolator.interpolate(X,E,r.language);A.push(V)}else if(Nu(X)||ne){const V=v(X,L,O);x(X,V,A,F)}else if(W){const V=_(D,L.children,O);x(X,V,A,F)}else if(Number.isNaN(parseFloat(L.name)))if(I){const V=v(X,L,O);x(X,V,A,F,L.voidElement)}else if(s.transSupportBasicHtmlNodes&&c.indexOf(L.name)>-1)if(L.voidElement)A.push(b.createElement(L.name,{key:`${L.name}-${F}`}));else{const V=_(D,L.children,O);A.push(b.createElement(L.name,{key:`${L.name}-${F}`},V))}else if(L.voidElement)A.push(`<${L.name} />`);else{const V=_(D,L.children,O);A.push(`<${L.name}>${V}</${L.name}>`)}else if(typeof X=="object"&&!ee){const V=L.children[0]?K:null;V&&A.push(V)}else x(X,K,A,F,L.children.length!==1||!K)}else if(L.type==="text"){const Q=s.transWrapTextNodes,X=a?s.unescape(r.services.interpolator.interpolate(L.content,E,r.language)):r.services.interpolator.interpolate(L.content,E,r.language);Q?A.push(b.createElement(Q,{key:`${L.name}-${F}`},X)):A.push(X)}return A},[])}const w=_([{dummy:!0,children:e||[]}],m,Uo(e||[]));return Ru(w[0])}function uT(e){let{children:t,count:r,parent:s,i18nKey:i,context:a,tOptions:c={},values:u,defaults:f,components:p,ns:m,i18n:E,t:v,shouldUnescape:x,..._}=e;const w=E||lg();if(!w)return eT("You will need to pass in an i18next instance by using i18nextReactModule"),t;const S=v||w.t.bind(w)||(ne=>ne);a&&(c.context=a);const N={...sT(),...w.options&&w.options.react};let O=m||S.ns||w.options&&w.options.defaultNS;O=typeof O=="string"?[O]:O||["translation"];const D=ag(t,N),T=f||D||N.transEmptyNodeValue||i,{hashTransKey:A}=N,L=i||(A?A(D||T):D||T);w.options&&w.options.interpolation&&w.options.interpolation.defaultVariables&&(u=u&&Object.keys(u).length>0?{...u,...w.options.interpolation.defaultVariables}:{...w.options.interpolation.defaultVariables});const F=u?c.interpolation:{interpolation:{...c.interpolation,prefix:"#$?",suffix:"?$#"}},K={...c,count:r,...u,...F,defaultValue:T,ns:O},Q=L?S(L,K):T;p&&Object.keys(p).forEach(ne=>{const W=p[ne];if(typeof W.type=="function"||!W.props||!W.props.children||Q.indexOf(`${ne}/>`)<0&&Q.indexOf(`${ne} />`)<0)return;function I(){return te.createElement(te.Fragment,null,W)}p[ne]=te.createElement(I,null)});const X=cT(p||t,Q,w,N,K,x),ee=s!==void 0?s:N.defaultTransParent;return ee?b.createElement(ee,_,X):X}const dT={type:"3rdParty",init(e){oT(e.options.react),iT(e)}},fT=b.createContext();function pT(e){let{children:t,count:r,parent:s,i18nKey:i,context:a,tOptions:c={},values:u,defaults:f,components:p,ns:m,i18n:E,t:v,shouldUnescape:x,..._}=e;const{i18n:w,defaultNS:S}=b.useContext(fT)||{},N=E||w||lg(),O=v||N&&N.t.bind(N);return uT({children:t,count:r,parent:s,i18nKey:i,context:a,tOptions:c,values:u,defaults:f,components:p,ns:m||O&&O.ns||S||N&&N.options&&N.options.defaultNS,i18n:N,t:v,shouldUnescape:x,..._})}var hT={prefix:"fas",iconName:"trash-can",icon:[448,512,[61460,"trash-alt"],"f2ed","M135.2 17.7C140.6 6.8 151.7 0 163.8 0H284.2c12.1 0 23.2 6.8 28.6 17.7L320 32h96c17.7 0 32 14.3 32 32s-14.3 32-32 32H32C14.3 96 0 81.7 0 64S14.3 32 32 32h96l7.2-14.3zM32 128H416V448c0 35.3-28.7 64-64 64H96c-35.3 0-64-28.7-64-64V128zm96 64c-8.8 0-16 7.2-16 16V432c0 8.8 7.2 16 16 16s16-7.2 16-16V208c0-8.8-7.2-16-16-16zm96 0c-8.8 0-16 7.2-16 16V432c0 8.8 7.2 16 16 16s16-7.2 16-16V208c0-8.8-7.2-16-16-16zm96 0c-8.8 0-16 7.2-16 16V432c0 8.8 7.2 16 16 16s16-7.2 16-16V208c0-8.8-7.2-16-16-16z"]},mT={prefix:"fas",iconName:"bars",icon:[448,512,["navicon"],"f0c9","M0 96C0 78.3 14.3 64 32 64H416c17.7 0 32 14.3 32 32s-14.3 32-32 32H32C14.3 128 0 113.7 0 96zM0 256c0-17.7 14.3-32 32-32H416c17.7 0 32 14.3 32 32s-14.3 32-32 32H32c-17.7 0-32-14.3-32-32zM448 416c0 17.7-14.3 32-32 32H32c-17.7 0-32-14.3-32-32s14.3-32 32-32H416c17.7 0 32 14.3 32 32z"]},gT={prefix:"fas",iconName:"circle-exclamation",icon:[512,512,["exclamation-circle"],"f06a","M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zm0-384c13.3 0 24 10.7 24 24V264c0 13.3-10.7 24-24 24s-24-10.7-24-24V152c0-13.3 10.7-24 24-24zM224 352a32 32 0 1 1 64 0 32 32 0 1 1 -64 0z"]},ET={prefix:"fas",iconName:"circle-dot",icon:[512,512,[128280,"dot-circle"],"f192","M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zm0-352a96 96 0 1 1 0 192 96 96 0 1 1 0-192z"]},yT=ET,vT={prefix:"fas",iconName:"circle-check",icon:[512,512,[61533,"check-circle"],"f058","M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM369 209L241 337c-9.4 9.4-24.6 9.4-33.9 0l-64-64c-9.4-9.4-9.4-24.6 0-33.9s24.6-9.4 33.9 0l47 47L335 175c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9z"]},xT={prefix:"fas",iconName:"arrows-rotate",icon:[512,512,[128472,"refresh","sync"],"f021","M105.1 202.6c7.7-21.8 20.2-42.3 37.8-59.8c62.5-62.5 163.8-62.5 226.3 0L386.3 160H352c-17.7 0-32 14.3-32 32s14.3 32 32 32H463.5c0 0 0 0 0 0h.4c17.7 0 32-14.3 32-32V80c0-17.7-14.3-32-32-32s-32 14.3-32 32v35.2L414.4 97.6c-87.5-87.5-229.3-87.5-316.8 0C73.2 122 55.6 150.7 44.8 181.4c-5.9 16.7 2.9 34.9 19.5 40.8s34.9-2.9 40.8-19.5zM39 289.3c-5 1.5-9.8 4.2-13.7 8.2c-4 4-6.7 8.8-8.1 14c-.3 1.2-.6 2.5-.8 3.8c-.3 1.7-.4 3.4-.4 5.1V432c0 17.7 14.3 32 32 32s32-14.3 32-32V396.9l17.6 17.5 0 0c87.5 87.4 229.3 87.4 316.7 0c24.4-24.4 42.1-53.1 52.9-83.7c5.9-16.7-2.9-34.9-19.5-40.8s-34.9 2.9-40.8 19.5c-7.7 21.8-20.2 42.3-37.8 59.8c-62.5 62.5-163.8 62.5-226.3 0l-.1-.1L125.6 352H160c17.7 0 32-14.3 32-32s-14.3-32-32-32H48.4c-1.6 0-3.2 .1-4.8 .3s-3.1 .5-4.6 1z"]},ST={prefix:"fas",iconName:"arrow-turn-down-right",icon:[512,512,[],"e3d6","M64 64c0-17.7-14.3-32-32-32S0 46.3 0 64V224c0 53 43 96 96 96H402.7l-73.4 73.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l128-128c12.5-12.5 12.5-32.8 0-45.3l-128-128c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L402.7 256H96c-17.7 0-32-14.3-32-32V64z"]},_T={prefix:"fas",iconName:"arrow-right",icon:[448,512,[8594],"f061","M438.6 278.6c12.5-12.5 12.5-32.8 0-45.3l-160-160c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L338.8 224 32 224c-17.7 0-32 14.3-32 32s14.3 32 32 32l306.7 0L233.4 393.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l160-160z"]},wT={prefix:"fas",iconName:"circle-question",icon:[512,512,[62108,"question-circle"],"f059","M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM169.8 165.3c7.9-22.3 29.1-37.3 52.8-37.3h58.3c34.9 0 63.1 28.3 63.1 63.1c0 22.6-12.1 43.5-31.7 54.8L280 264.4c-.2 13-10.9 23.6-24 23.6c-13.3 0-24-10.7-24-24V250.5c0-8.6 4.6-16.5 12.1-20.8l44.3-25.4c4.7-2.7 7.6-7.7 7.6-13.1c0-8.4-6.8-15.1-15.1-15.1H222.6c-3.4 0-6.4 2.1-7.5 5.3l-.4 1.2c-4.4 12.5-18.2 19-30.6 14.6s-19-18.2-14.6-30.6l.4-1.2zM224 352a32 32 0 1 1 64 0 32 32 0 1 1 -64 0z"]},NT={prefix:"fas",iconName:"arrow-left",icon:[448,512,[8592],"f060","M9.4 233.4c-12.5 12.5-12.5 32.8 0 45.3l160 160c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L109.2 288 416 288c17.7 0 32-14.3 32-32s-14.3-32-32-32l-306.7 0L214.6 118.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-160 160z"]},RT={prefix:"fas",iconName:"circle-small",icon:[320,512,[],"e122","M0 256a160 160 0 1 1 320 0A160 160 0 1 1 0 256z"]},TT={prefix:"fas",iconName:"circle-info",icon:[512,512,["info-circle"],"f05a","M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM216 336h24V272H216c-13.3 0-24-10.7-24-24s10.7-24 24-24h48c13.3 0 24 10.7 24 24v88h8c13.3 0 24 10.7 24 24s-10.7 24-24 24H216c-13.3 0-24-10.7-24-24s10.7-24 24-24zm40-208a32 32 0 1 1 0 64 32 32 0 1 1 0-64z"]},OT={prefix:"fas",iconName:"bolt",icon:[448,512,[9889,"zap"],"f0e7","M349.4 44.6c5.9-13.7 1.5-29.7-10.6-38.5s-28.6-8-39.9 1.8l-256 224c-10 8.8-13.6 22.9-8.9 35.3S50.7 288 64 288H175.5L98.6 467.4c-5.9 13.7-1.5 29.7 10.6 38.5s28.6 8 39.9-1.8l256-224c10-8.8 13.6-22.9 8.9-35.3s-16.6-20.7-30-20.7H272.5L349.4 44.6z"]},CT={prefix:"fas",iconName:"xmark",icon:[384,512,[128473,10005,10006,10060,215,"close","multiply","remove","times"],"f00d","M342.6 150.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L192 210.7 86.6 105.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L146.7 256 41.4 361.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L192 301.3 297.4 406.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L237.3 256 342.6 150.6z"]},AT={prefix:"fas",iconName:"clock-rotate-left",icon:[512,512,["history"],"f1da","M75 75L41 41C25.9 25.9 0 36.6 0 57.9V168c0 13.3 10.7 24 24 24H134.1c21.4 0 32.1-25.9 17-41l-30.8-30.8C155 85.5 203 64 256 64c106 0 192 86 192 192s-86 192-192 192c-40.8 0-78.6-12.7-109.7-34.4c-14.5-10.1-34.4-6.6-44.6 7.9s-6.6 34.4 7.9 44.6C151.2 495 201.7 512 256 512c141.4 0 256-114.6 256-256S397.4 0 256 0C185.3 0 121.3 28.7 75 75zm181 53c-13.3 0-24 10.7-24 24V256c0 6.4 2.5 12.5 7 17l72 72c9.4 9.4 24.6 9.4 33.9 0s9.4-24.6 0-33.9l-65-65V152c0-13.3-10.7-24-24-24z"]},IT={prefix:"fas",iconName:"triangle-exclamation",icon:[512,512,[9888,"exclamation-triangle","warning"],"f071","M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24V296c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224a32 32 0 1 0 -64 0 32 32 0 1 0 64 0z"]},bT={prefix:"fas",iconName:"circle-xmark",icon:[512,512,[61532,"times-circle","xmark-circle"],"f057","M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM175 175c9.4-9.4 24.6-9.4 33.9 0l47 47 47-47c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9l-47 47 47 47c9.4 9.4 9.4 24.6 0 33.9s-24.6 9.4-33.9 0l-47-47-47 47c-9.4 9.4-24.6 9.4-33.9 0s-9.4-24.6 0-33.9l47-47-47-47c-9.4-9.4-9.4-24.6 0-33.9z"]};const LT={"arrow-left":NT,"arrow-right":_T,"arrow-turn-down-right":ST,"arrows-rotate":xT,bars:mT,bolt:OT,"circle-check":vT,"circle-exclamation":gT,"circle-info":TT,"circle-question":wT,"circle-small":RT,"circle-xmark":bT,"clock-rotate-left":AT,"dot-circle":yT,"trash-can":hT,"triangle-exclamation":IT,xmark:CT},Ce=b.forwardRef(function({className:t="",size:r="",tag:s},i){const a=LT[s];return a?h.jsx("svg",{"aria-hidden":"true","data-prefix":a.prefix,"data-icon":s,className:`svg-inline--fa fa-${s} ${r?`fa-${r}`:""} ${t}`,focusable:"false",ref:i,role:"img",viewBox:`0 0 ${a.icon[0]} ${a.icon[1]}`,xmlns:"http://www.w3.org/2000/svg",children:h.jsx("path",{d:a.icon[4],fill:"currentColor"})}):(Qe().debug(`Unknown icon: ${s}`),null)}),Fo=({className:e="",confirm:t=!0,handleDelete:r,label:s,scale:i=1,show:a=!0,showLabel:c=!1,size:u})=>{const[f,p]=b.useState(!1),[m,E]=b.useState(i);i!==m&&(p(!1),E(i));const v=_=>{_.preventDefault(),p(w=>!w)},x=_=>{_.preventDefault(),r(_)};return h.jsx(gr,{enable:t,open:f,onOpenChange:p,placement:"top",scale:i,trigger:h.jsxs("button",{className:`${a?"visible opacity-100":"invisible opacity-0"} text-xs text-foreground/20 hover:text-negative group-hover/node-wrapper:visible group-hover/node-wrapper:animate-delay-opacity ${e}`,onClick:_=>v(_),type:"button",children:[h.jsx(Ce,{tag:"trash-can",size:u})," ",h.jsx("span",{className:`${c?"whitespace-nowrap text-foreground/40 underline hover:text-negative":"sr-only"}`,children:s})]}),children:h.jsxs("div",{className:"text-xs font-semibold",children:[h.jsx("p",{className:"w-full pb-2 text-center",children:M(C.ARE_YOU_SURE)}),h.jsxs("div",{className:"align-center flex justify-between gap-2",children:[h.jsx("button",{className:"rounded bg-secondary py-1 px-2",onClick:_=>v(_),children:M(C.CANCEL)}),h.jsx("button",{className:"rounded bg-negative py-1 px-2",onClick:_=>x(_),children:M(C.DELETE)})]})]})})},DT=e=>{const t=ye(r=>r.viewport.zoom);return h.jsx(Fo,{scale:t,...e})},kT=Qe(),MT=100,PT=100,cg=({children:e,className:t="",onClickListItem:r})=>{const s=ye(p=>p.nodes),i=ye(p=>p.reactFlowInstance),a=ye(p=>p.validationWarnings),{setSelectedNodes:c}=Ze();if(a.size===0)return null;const u=Array.from(a.values());u.sort((p,m)=>M(p.nodeTitle).toLowerCase().localeCompare(M(m.nodeTitle).toLowerCase()));const f=p=>{const m=s.find(x=>x.id===p);if(!m){kT.error(`Node with id ${p} not found`);return}const E=i?.getNode(p)?.height??PT,v=i?.getNode(p)?.width??Om;i?.fitBounds({height:E+MT,width:v,x:m.position.x,y:m.position.y},{duration:mu}),setTimeout(()=>c([m.id]),mu),r?.()};return h.jsxs("div",{className:`hidden max-h-60 flex-col sm:flex ${t}`,children:[e,h.jsxs("p",{className:"mb-2 text-xs",children:[M(C.NUMBER_OF_VALIDATION_WARNINGS,{count:u.length}),":"]}),h.jsx("div",{className:"flex-auto overflow-y-auto",children:h.jsx("ol",{className:"list-inside",children:u.map(p=>h.jsxs("li",{className:"mb-2 text-xs",children:[h.jsx("button",{className:"text-warning underline",onClick:()=>f(p.nodeId),children:M(p.nodeTitle)}),h.jsxs("ol",{className:"my-1 ml-4 flex list-inside flex-col gap-y-1",children:[!p.connected&&h.jsx("li",{children:M(C.NOT_CONNECTED_TO_FLOW)}),!p.valid&&h.jsx("li",{children:M(C.INVALID_SETTINGS)})]})]},p.id))})})]})},Ys=e=>{const{className:t="",direction:r="from",valid:s=!0,...i}=e,a=r==="from";return h.jsxs("div",{className:`relative ${t} ${s?"":"invalid"}`,children:[h.jsx("input",{className:`w-full !pl-5 ${s?"":"invalid"}`,placeholder:M(a?C.FROM:C.TO),...i}),h.jsx(Ce,{className:"absolute left-[.25rem] top-[.5rem] text-foreground/40",tag:a?"arrow-left":"arrow-right"})]})},UT=({children:e})=>h.jsx("span",{className:"whitespace-wrap inline-block",children:h.jsx("code",{className:"mr-[0.5ch] whitespace-pre-wrap rounded-md bg-background p-0 px-[0.5ch] text-sm leading-4 tracking-tighter text-foreground",children:e})}),Xt=({children:e})=>h.jsxs("section",{className:"flex gap-2 overflow-hidden px-4 pb-3 text-xs leading-5",children:[h.jsx("div",{className:"shrink-0 pl-1 text-secondary",children:h.jsx(Ce,{size:"lg",tag:"arrow-turn-down-right"})}),h.jsx("div",{className:"w-full overflow-hidden",children:e})]}),FT=({connected:e=!1,deletable:t=!0,isRoot:r=!1,nodeId:s,nodeTitle:i,selected:a=!1})=>{const{removeNode:c}=Ze(),u=ye(p=>p.isEdgeConnecting),f=(p=>p?"bg-positive/10 text-positive":e?"bg-focus/30 text-primary":"bg-foreground/10 text-foreground/50")(r);return h.jsxs("div",{className:"flex w-full items-center justify-start gap-x-2 p-4",children:[h.jsx("div",{className:`${f} flex h-5 w-5 shrink-0 items-center justify-center rounded-full`,children:h.jsx(Ce,{tag:"circle-small"})}),h.jsxs("div",{className:"flex-1",children:[h.jsx("h2",{className:"text-xs font-semibold",children:i}),!e&&h.jsxs("div",{className:"flex items-center justify-start text-tiny font-semibold leading-[14px] text-secondary",children:[h.jsx(Ce,{className:"px-1 text-warning",size:"lg",tag:"bolt"}),M(C.NOT_CONNECTED_TO_FLOW)]})]}),t&&!u&&h.jsx(DT,{handleDelete:()=>c(s),label:M(C.REMOVE_NODE,{title:i}),show:a})]})},jT=({valid:e})=>e?null:h.jsx("div",{className:"m-4 mt-0 inline-block",children:h.jsxs("div",{className:"flex items-start justify-start gap-2 rounded bg-negative/10 px-2 py-1 text-xs text-negative",children:[h.jsx(gr,{placement:"bottom",trigger:h.jsx("div",{role:"tooltip",tabIndex:0,children:h.jsx(Ce,{size:"lg",tag:"triangle-exclamation"})}),children:M(C.INFO_INVALID_SETTINGS)}),M(C.INVALID_SETTINGS)]})}),VT=({nodeId:e,valid:t})=>{const{deleteValidationWarning:r,getTargetEdges:s,partialUpdateValidationWarning:i}=Ze(),[a,c]=b.useState(!1);return b.useEffect(()=>{let u;const f=()=>{r(e),typeof u=="function"&&u()},p=()=>{const m=ye.getState().nodes.find(E=>E.id===e);if(!m)f();else{const E=s(e).length>0;c(E),i(e,{connected:E,nodeId:e,nodeType:m.type,valid:t})}};return p(),u=ye.subscribe((m,E)=>{const v=m.nodes.length!==E.nodes.length,x=m.edges.length!==E.edges.length,_=m.isEdgeUpdateSuccessful!==E.isEdgeUpdateSuccessful;(x||v||_)&&p()}),()=>{f()}},[r,s,e,i,t]),{isConnectedToFlow:a}},$T=({id:e,isConnectable:t})=>{if(!e)throw new Error("TargetHandle: id is required");return h.jsx("div",{className:"absolute left-0 top-5 h-3 w-3 -translate-x-1/2",children:h.jsx(Ro,{className:"-left-[2px] h-full w-full border-2 border-foreground/40 bg-background transition-colors hover:border-foreground/80",id:`target-${e}`,isConnectable:t,position:xe.Left,type:"target"})})},dt=({children:e,id:t,isConnectable:r=!0,isRoot:s=!1,nodeTitle:i,selected:a,deletable:c=!0,showValidation:u=!0,target:f=!0,valid:p=!0})=>{const{isConnectedToFlow:m}=VT({nodeId:t,valid:p});return h.jsx("section",{className:`${a?"!border-focus":""} group/node-wrapper rounded-xl border-2 border-background shadow-[0_4px_12px_0_rgba(0,0,0,0.08)] transition-[visibility]`,children:h.jsxs("div",{className:"group/node-wrapper relative rounded-xl bg-background",style:{width:Om},children:[f&&t&&h.jsx($T,{id:t,isConnectable:r}),h.jsx(FT,{connected:!f||m,deletable:c,isRoot:s,nodeId:t,nodeTitle:i,selected:a}),u&&h.jsx(jT,{valid:p}),e]})})},HT=({children:e,handleClick:t,...r})=>{const s=i=>{(i.key==="Backspace"||i.key==="Delete")&&(i.stopPropagation(),t?.())};return h.jsx("li",{"aria-selected":"true",tabIndex:0,role:"option",children:h.jsxs("div",{className:"flex items-center gap-2 rounded-lg bg-primary/20 p-1 pl-2 text-xs font-medium text-foreground",children:[e,h.jsxs("button",{className:"px-1",onClick:t,onKeyDown:s,type:"button",...r,children:[h.jsx("span",{className:"sr-only",children:"Remove"}),h.jsx(Ce,{tag:"xmark",size:"xs"})]})]})})},ug=({data:e})=>{let t=e.selected&&e[e.selected].trim();return t&&e.selected==="url"&&(t=s1(t)||M(C.PLAY_AUDIO)),t?h.jsx(Xt,{children:h.jsx("div",{className:"max-w-max",children:e.selected==="url"?h.jsx("a",{className:"break-words text-primary underline line-clamp-2",href:e.url,target:"_blank",rel:"noopener noreferrer",children:t}):h.jsx("p",{className:"break-words line-clamp-2",children:t})})}):null},dg=e=>{const{children:t,className:r="",disabled:s=!1,...i}=e;return h.jsxs("div",{className:`chevron-down relative mb-2 after:rotate-0 after:transition-transform focus-within:after:rotate-180
|
|
60
|
+
*/var up;function Qv(){if(up)return _c;up=1;var e=xs(),t=Xv();function r(p,m){return p===m&&(p!==0||1/p===1/m)||p!==p&&m!==m}var s=typeof Object.is=="function"?Object.is:r,i=t.useSyncExternalStore,a=e.useRef,c=e.useEffect,u=e.useMemo,f=e.useDebugValue;return _c.useSyncExternalStoreWithSelector=function(p,m,E,v,x){var _=a(null);if(_.current===null){var w={hasValue:!1,value:null};_.current=w}else w=_.current;_=u(function(){function N(L){if(!O){if(O=!0,D=L,L=v(L),x!==void 0&&w.hasValue){var F=w.value;if(x(F,L))return T=F}return T=L}if(F=T,s(D,L))return F;var K=v(L);return x!==void 0&&x(F,K)?F:(D=L,T=K)}var O=!1,D,T,A=E===void 0?null:E;return[function(){return N(m())},A===null?void 0:function(){return N(A())}]},[m,E,v,x]);var S=i(p,_[0],_[1]);return c(function(){w.hasValue=!0,w.value=S},[S]),f(S),S},_c}var dp;function qv(){return dp||(dp=1,Sc.exports=Qv()),Sc.exports}var Zv=qv();const fp=Hi(Zv),Jv={},pp=e=>{let t;const r=new Set,s=(f,p)=>{const m=typeof f=="function"?f(t):f;if(!Object.is(m,t)){const E=t;t=p??(typeof m!="object"||m===null)?m:Object.assign({},t,m),r.forEach(v=>v(t,E))}},i=()=>t,u={setState:s,getState:i,subscribe:f=>(r.add(f),()=>r.delete(f)),destroy:()=>{(Jv?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),r.clear()}};return t=e(s,i,u),u},hp=e=>e?pp(e):pp,{useDebugValue:ex}=te,{useSyncExternalStoreWithSelector:tx}=fp;function mp(e,t=e.getState,r){const s=tx(e.subscribe,e.getState,e.getServerState||e.getState,t,r);return ex(s),s}const gp=(e,t)=>{const r=hp(e),s=(i,a=t)=>mp(r,i,a);return Object.assign(s,r),s},nx=(e,t)=>e?gp(e,t):gp;function gt(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[s,i]of e)if(!Object.is(i,t.get(s)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const s of e)if(!t.has(s))return!1;return!0}const r=Object.keys(e);if(r.length!==Object.keys(t).length)return!1;for(let s=0;s<r.length;s++)if(!Object.prototype.hasOwnProperty.call(t,r[s])||!Object.is(e[r[s]],t[r[s]]))return!1;return!0}var rx={value:()=>{}};function Wi(){for(var e=0,t=arguments.length,r={},s;e<t;++e){if(!(s=arguments[e]+"")||s in r||/[\s.]/.test(s))throw new Error("illegal type: "+s);r[s]=[]}return new Gi(r)}function Gi(e){this._=e}function ox(e,t){return e.trim().split(/^|\s+/).map(function(r){var s="",i=r.indexOf(".");if(i>=0&&(s=r.slice(i+1),r=r.slice(0,i)),r&&!t.hasOwnProperty(r))throw new Error("unknown type: "+r);return{type:r,name:s}})}Gi.prototype=Wi.prototype={constructor:Gi,on:function(e,t){var r=this._,s=ox(e+"",r),i,a=-1,c=s.length;if(arguments.length<2){for(;++a<c;)if((i=(e=s[a]).type)&&(i=sx(r[i],e.name)))return i;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++a<c;)if(i=(e=s[a]).type)r[i]=Ep(r[i],e.name,t);else if(t==null)for(i in r)r[i]=Ep(r[i],e.name,null);return this},copy:function(){var e={},t=this._;for(var r in t)e[r]=t[r].slice();return new Gi(e)},call:function(e,t){if((i=arguments.length-2)>0)for(var r=new Array(i),s=0,i,a;s<i;++s)r[s]=arguments[s+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(a=this._[e],s=0,i=a.length;s<i;++s)a[s].value.apply(t,r)},apply:function(e,t,r){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var s=this._[e],i=0,a=s.length;i<a;++i)s[i].value.apply(t,r)}};function sx(e,t){for(var r=0,s=e.length,i;r<s;++r)if((i=e[r]).name===t)return i.value}function Ep(e,t,r){for(var s=0,i=e.length;s<i;++s)if(e[s].name===t){e[s]=rx,e=e.slice(0,s).concat(e.slice(s+1));break}return r!=null&&e.push({name:t,value:r}),e}var Rc="http://www.w3.org/1999/xhtml";const yp={svg:"http://www.w3.org/2000/svg",xhtml:Rc,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Yi(e){var t=e+="",r=t.indexOf(":");return r>=0&&(t=e.slice(0,r))!=="xmlns"&&(e=e.slice(r+1)),yp.hasOwnProperty(t)?{space:yp[t],local:e}:e}function ix(e){return function(){var t=this.ownerDocument,r=this.namespaceURI;return r===Rc&&t.documentElement.namespaceURI===Rc?t.createElement(e):t.createElementNS(r,e)}}function lx(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function vp(e){var t=Yi(e);return(t.local?lx:ix)(t)}function ax(){}function Tc(e){return e==null?ax:function(){return this.querySelector(e)}}function cx(e){typeof e!="function"&&(e=Tc(e));for(var t=this._groups,r=t.length,s=new Array(r),i=0;i<r;++i)for(var a=t[i],c=a.length,u=s[i]=new Array(c),f,p,m=0;m<c;++m)(f=a[m])&&(p=e.call(f,f.__data__,m,a))&&("__data__"in f&&(p.__data__=f.__data__),u[m]=p);return new Ft(s,this._parents)}function ux(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function dx(){return[]}function xp(e){return e==null?dx:function(){return this.querySelectorAll(e)}}function fx(e){return function(){return ux(e.apply(this,arguments))}}function px(e){typeof e=="function"?e=fx(e):e=xp(e);for(var t=this._groups,r=t.length,s=[],i=[],a=0;a<r;++a)for(var c=t[a],u=c.length,f,p=0;p<u;++p)(f=c[p])&&(s.push(e.call(f,f.__data__,p,c)),i.push(f));return new Ft(s,i)}function Sp(e){return function(){return this.matches(e)}}function _p(e){return function(t){return t.matches(e)}}var hx=Array.prototype.find;function mx(e){return function(){return hx.call(this.children,e)}}function gx(){return this.firstElementChild}function Ex(e){return this.select(e==null?gx:mx(typeof e=="function"?e:_p(e)))}var yx=Array.prototype.filter;function vx(){return Array.from(this.children)}function xx(e){return function(){return yx.call(this.children,e)}}function Sx(e){return this.selectAll(e==null?vx:xx(typeof e=="function"?e:_p(e)))}function _x(e){typeof e!="function"&&(e=Sp(e));for(var t=this._groups,r=t.length,s=new Array(r),i=0;i<r;++i)for(var a=t[i],c=a.length,u=s[i]=[],f,p=0;p<c;++p)(f=a[p])&&e.call(f,f.__data__,p,a)&&u.push(f);return new Ft(s,this._parents)}function wp(e){return new Array(e.length)}function wx(){return new Ft(this._enter||this._groups.map(wp),this._parents)}function Ki(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Ki.prototype={constructor:Ki,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function Nx(e){return function(){return e}}function Rx(e,t,r,s,i,a){for(var c=0,u,f=t.length,p=a.length;c<p;++c)(u=t[c])?(u.__data__=a[c],s[c]=u):r[c]=new Ki(e,a[c]);for(;c<f;++c)(u=t[c])&&(i[c]=u)}function Tx(e,t,r,s,i,a,c){var u,f,p=new Map,m=t.length,E=a.length,v=new Array(m),x;for(u=0;u<m;++u)(f=t[u])&&(v[u]=x=c.call(f,f.__data__,u,t)+"",p.has(x)?i[u]=f:p.set(x,f));for(u=0;u<E;++u)x=c.call(e,a[u],u,a)+"",(f=p.get(x))?(s[u]=f,f.__data__=a[u],p.delete(x)):r[u]=new Ki(e,a[u]);for(u=0;u<m;++u)(f=t[u])&&p.get(v[u])===f&&(i[u]=f)}function Ox(e){return e.__data__}function Cx(e,t){if(!arguments.length)return Array.from(this,Ox);var r=t?Tx:Rx,s=this._parents,i=this._groups;typeof e!="function"&&(e=Nx(e));for(var a=i.length,c=new Array(a),u=new Array(a),f=new Array(a),p=0;p<a;++p){var m=s[p],E=i[p],v=E.length,x=Ax(e.call(m,m&&m.__data__,p,s)),_=x.length,w=u[p]=new Array(_),S=c[p]=new Array(_),N=f[p]=new Array(v);r(m,E,w,S,N,x,t);for(var O=0,D=0,T,A;O<_;++O)if(T=w[O]){for(O>=D&&(D=O+1);!(A=S[D])&&++D<_;);T._next=A||null}}return c=new Ft(c,s),c._enter=u,c._exit=f,c}function Ax(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Ix(){return new Ft(this._exit||this._groups.map(wp),this._parents)}function bx(e,t,r){var s=this.enter(),i=this,a=this.exit();return typeof e=="function"?(s=e(s),s&&(s=s.selection())):s=s.append(e+""),t!=null&&(i=t(i),i&&(i=i.selection())),r==null?a.remove():r(a),s&&i?s.merge(i).order():i}function Lx(e){for(var t=e.selection?e.selection():e,r=this._groups,s=t._groups,i=r.length,a=s.length,c=Math.min(i,a),u=new Array(i),f=0;f<c;++f)for(var p=r[f],m=s[f],E=p.length,v=u[f]=new Array(E),x,_=0;_<E;++_)(x=p[_]||m[_])&&(v[_]=x);for(;f<i;++f)u[f]=r[f];return new Ft(u,this._parents)}function Dx(){for(var e=this._groups,t=-1,r=e.length;++t<r;)for(var s=e[t],i=s.length-1,a=s[i],c;--i>=0;)(c=s[i])&&(a&&c.compareDocumentPosition(a)^4&&a.parentNode.insertBefore(c,a),a=c);return this}function kx(e){e||(e=Mx);function t(E,v){return E&&v?e(E.__data__,v.__data__):!E-!v}for(var r=this._groups,s=r.length,i=new Array(s),a=0;a<s;++a){for(var c=r[a],u=c.length,f=i[a]=new Array(u),p,m=0;m<u;++m)(p=c[m])&&(f[m]=p);f.sort(t)}return new Ft(i,this._parents).order()}function Mx(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Px(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Ux(){return Array.from(this)}function Fx(){for(var e=this._groups,t=0,r=e.length;t<r;++t)for(var s=e[t],i=0,a=s.length;i<a;++i){var c=s[i];if(c)return c}return null}function jx(){let e=0;for(const t of this)++e;return e}function Vx(){return!this.node()}function $x(e){for(var t=this._groups,r=0,s=t.length;r<s;++r)for(var i=t[r],a=0,c=i.length,u;a<c;++a)(u=i[a])&&e.call(u,u.__data__,a,i);return this}function Hx(e){return function(){this.removeAttribute(e)}}function Bx(e){return function(){this.removeAttributeNS(e.space,e.local)}}function zx(e,t){return function(){this.setAttribute(e,t)}}function Wx(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Gx(e,t){return function(){var r=t.apply(this,arguments);r==null?this.removeAttribute(e):this.setAttribute(e,r)}}function Yx(e,t){return function(){var r=t.apply(this,arguments);r==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,r)}}function Kx(e,t){var r=Yi(e);if(arguments.length<2){var s=this.node();return r.local?s.getAttributeNS(r.space,r.local):s.getAttribute(r)}return this.each((t==null?r.local?Bx:Hx:typeof t=="function"?r.local?Yx:Gx:r.local?Wx:zx)(r,t))}function Np(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Xx(e){return function(){this.style.removeProperty(e)}}function Qx(e,t,r){return function(){this.style.setProperty(e,t,r)}}function qx(e,t,r){return function(){var s=t.apply(this,arguments);s==null?this.style.removeProperty(e):this.style.setProperty(e,s,r)}}function Zx(e,t,r){return arguments.length>1?this.each((t==null?Xx:typeof t=="function"?qx:Qx)(e,t,r??"")):yo(this.node(),e)}function yo(e,t){return e.style.getPropertyValue(t)||Np(e).getComputedStyle(e,null).getPropertyValue(t)}function Jx(e){return function(){delete this[e]}}function eS(e,t){return function(){this[e]=t}}function tS(e,t){return function(){var r=t.apply(this,arguments);r==null?delete this[e]:this[e]=r}}function nS(e,t){return arguments.length>1?this.each((t==null?Jx:typeof t=="function"?tS:eS)(e,t)):this.node()[e]}function Rp(e){return e.trim().split(/^|\s+/)}function Oc(e){return e.classList||new Tp(e)}function Tp(e){this._node=e,this._names=Rp(e.getAttribute("class")||"")}Tp.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function Op(e,t){for(var r=Oc(e),s=-1,i=t.length;++s<i;)r.add(t[s])}function Cp(e,t){for(var r=Oc(e),s=-1,i=t.length;++s<i;)r.remove(t[s])}function rS(e){return function(){Op(this,e)}}function oS(e){return function(){Cp(this,e)}}function sS(e,t){return function(){(t.apply(this,arguments)?Op:Cp)(this,e)}}function iS(e,t){var r=Rp(e+"");if(arguments.length<2){for(var s=Oc(this.node()),i=-1,a=r.length;++i<a;)if(!s.contains(r[i]))return!1;return!0}return this.each((typeof t=="function"?sS:t?rS:oS)(r,t))}function lS(){this.textContent=""}function aS(e){return function(){this.textContent=e}}function cS(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function uS(e){return arguments.length?this.each(e==null?lS:(typeof e=="function"?cS:aS)(e)):this.node().textContent}function dS(){this.innerHTML=""}function fS(e){return function(){this.innerHTML=e}}function pS(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function hS(e){return arguments.length?this.each(e==null?dS:(typeof e=="function"?pS:fS)(e)):this.node().innerHTML}function mS(){this.nextSibling&&this.parentNode.appendChild(this)}function gS(){return this.each(mS)}function ES(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function yS(){return this.each(ES)}function vS(e){var t=typeof e=="function"?e:vp(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function xS(){return null}function SS(e,t){var r=typeof e=="function"?e:vp(e),s=t==null?xS:typeof t=="function"?t:Tc(t);return this.select(function(){return this.insertBefore(r.apply(this,arguments),s.apply(this,arguments)||null)})}function _S(){var e=this.parentNode;e&&e.removeChild(this)}function wS(){return this.each(_S)}function NS(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function RS(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function TS(e){return this.select(e?RS:NS)}function OS(e){return arguments.length?this.property("__data__",e):this.node().__data__}function CS(e){return function(t){e.call(this,t,this.__data__)}}function AS(e){return e.trim().split(/^|\s+/).map(function(t){var r="",s=t.indexOf(".");return s>=0&&(r=t.slice(s+1),t=t.slice(0,s)),{type:t,name:r}})}function IS(e){return function(){var t=this.__on;if(t){for(var r=0,s=-1,i=t.length,a;r<i;++r)a=t[r],(!e.type||a.type===e.type)&&a.name===e.name?this.removeEventListener(a.type,a.listener,a.options):t[++s]=a;++s?t.length=s:delete this.__on}}}function bS(e,t,r){return function(){var s=this.__on,i,a=CS(t);if(s){for(var c=0,u=s.length;c<u;++c)if((i=s[c]).type===e.type&&i.name===e.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=a,i.options=r),i.value=t;return}}this.addEventListener(e.type,a,r),i={type:e.type,name:e.name,value:t,listener:a,options:r},s?s.push(i):this.__on=[i]}}function LS(e,t,r){var s=AS(e+""),i,a=s.length,c;if(arguments.length<2){var u=this.node().__on;if(u){for(var f=0,p=u.length,m;f<p;++f)for(i=0,m=u[f];i<a;++i)if((c=s[i]).type===m.type&&c.name===m.name)return m.value}return}for(u=t?bS:IS,i=0;i<a;++i)this.each(u(s[i],t,r));return this}function Ap(e,t,r){var s=Np(e),i=s.CustomEvent;typeof i=="function"?i=new i(t,r):(i=s.document.createEvent("Event"),r?(i.initEvent(t,r.bubbles,r.cancelable),i.detail=r.detail):i.initEvent(t,!1,!1)),e.dispatchEvent(i)}function DS(e,t){return function(){return Ap(this,e,t)}}function kS(e,t){return function(){return Ap(this,e,t.apply(this,arguments))}}function MS(e,t){return this.each((typeof t=="function"?kS:DS)(e,t))}function*PS(){for(var e=this._groups,t=0,r=e.length;t<r;++t)for(var s=e[t],i=0,a=s.length,c;i<a;++i)(c=s[i])&&(yield c)}var Ip=[null];function Ft(e,t){this._groups=e,this._parents=t}function _s(){return new Ft([[document.documentElement]],Ip)}function US(){return this}Ft.prototype=_s.prototype={constructor:Ft,select:cx,selectAll:px,selectChild:Ex,selectChildren:Sx,filter:_x,data:Cx,enter:wx,exit:Ix,join:bx,merge:Lx,selection:US,order:Dx,sort:kx,call:Px,nodes:Ux,node:Fx,size:jx,empty:Vx,each:$x,attr:Kx,style:Zx,property:nS,classed:iS,text:uS,html:hS,raise:gS,lower:yS,append:vS,insert:SS,remove:wS,clone:TS,datum:OS,on:LS,dispatch:MS,[Symbol.iterator]:PS};function on(e){return typeof e=="string"?new Ft([[document.querySelector(e)]],[document.documentElement]):new Ft([[e]],Ip)}function FS(e){let t;for(;t=e.sourceEvent;)e=t;return e}function _n(e,t){if(e=FS(e),t===void 0&&(t=e.currentTarget),t){var r=t.ownerSVGElement||t;if(r.createSVGPoint){var s=r.createSVGPoint();return s.x=e.clientX,s.y=e.clientY,s=s.matrixTransform(t.getScreenCTM().inverse()),[s.x,s.y]}if(t.getBoundingClientRect){var i=t.getBoundingClientRect();return[e.clientX-i.left-t.clientLeft,e.clientY-i.top-t.clientTop]}}return[e.pageX,e.pageY]}const jS={passive:!1},ws={capture:!0,passive:!1};function Cc(e){e.stopImmediatePropagation()}function vo(e){e.preventDefault(),e.stopImmediatePropagation()}function bp(e){var t=e.document.documentElement,r=on(e).on("dragstart.drag",vo,ws);"onselectstart"in t?r.on("selectstart.drag",vo,ws):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Lp(e,t){var r=e.document.documentElement,s=on(e).on("dragstart.drag",null);t&&(s.on("click.drag",vo,ws),setTimeout(function(){s.on("click.drag",null)},0)),"onselectstart"in r?s.on("selectstart.drag",null):(r.style.MozUserSelect=r.__noselect,delete r.__noselect)}const Xi=e=>()=>e;function Ac(e,{sourceEvent:t,subject:r,target:s,identifier:i,active:a,x:c,y:u,dx:f,dy:p,dispatch:m}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:r,enumerable:!0,configurable:!0},target:{value:s,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:a,enumerable:!0,configurable:!0},x:{value:c,enumerable:!0,configurable:!0},y:{value:u,enumerable:!0,configurable:!0},dx:{value:f,enumerable:!0,configurable:!0},dy:{value:p,enumerable:!0,configurable:!0},_:{value:m}})}Ac.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function VS(e){return!e.ctrlKey&&!e.button}function $S(){return this.parentNode}function HS(e,t){return t??{x:e.x,y:e.y}}function BS(){return navigator.maxTouchPoints||"ontouchstart"in this}function zS(){var e=VS,t=$S,r=HS,s=BS,i={},a=Wi("start","drag","end"),c=0,u,f,p,m,E=0;function v(T){T.on("mousedown.drag",x).filter(s).on("touchstart.drag",S).on("touchmove.drag",N,jS).on("touchend.drag touchcancel.drag",O).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function x(T,A){if(!(m||!e.call(this,T,A))){var L=D(this,t.call(this,T,A),T,A,"mouse");L&&(on(T.view).on("mousemove.drag",_,ws).on("mouseup.drag",w,ws),bp(T.view),Cc(T),p=!1,u=T.clientX,f=T.clientY,L("start",T))}}function _(T){if(vo(T),!p){var A=T.clientX-u,L=T.clientY-f;p=A*A+L*L>E}i.mouse("drag",T)}function w(T){on(T.view).on("mousemove.drag mouseup.drag",null),Lp(T.view,p),vo(T),i.mouse("end",T)}function S(T,A){if(e.call(this,T,A)){var L=T.changedTouches,F=t.call(this,T,A),K=L.length,Q,X;for(Q=0;Q<K;++Q)(X=D(this,F,T,A,L[Q].identifier,L[Q]))&&(Cc(T),X("start",T,L[Q]))}}function N(T){var A=T.changedTouches,L=A.length,F,K;for(F=0;F<L;++F)(K=i[A[F].identifier])&&(vo(T),K("drag",T,A[F]))}function O(T){var A=T.changedTouches,L=A.length,F,K;for(m&&clearTimeout(m),m=setTimeout(function(){m=null},500),F=0;F<L;++F)(K=i[A[F].identifier])&&(Cc(T),K("end",T,A[F]))}function D(T,A,L,F,K,Q){var X=a.copy(),ee=_n(Q||L,A),ne,W,I;if((I=r.call(T,new Ac("beforestart",{sourceEvent:L,target:v,identifier:K,active:c,x:ee[0],y:ee[1],dx:0,dy:0,dispatch:X}),F))!=null)return ne=I.x-ee[0]||0,W=I.y-ee[1]||0,function V(j,B,U){var $=ee,z;switch(j){case"start":i[K]=V,z=c++;break;case"end":delete i[K],--c;case"drag":ee=_n(U||B,A),z=c;break}X.call(j,T,new Ac(j,{sourceEvent:B,subject:I,target:v,identifier:K,active:z,x:ee[0]+ne,y:ee[1]+W,dx:ee[0]-$[0],dy:ee[1]-$[1],dispatch:X}),F)}}return v.filter=function(T){return arguments.length?(e=typeof T=="function"?T:Xi(!!T),v):e},v.container=function(T){return arguments.length?(t=typeof T=="function"?T:Xi(T),v):t},v.subject=function(T){return arguments.length?(r=typeof T=="function"?T:Xi(T),v):r},v.touchable=function(T){return arguments.length?(s=typeof T=="function"?T:Xi(!!T),v):s},v.on=function(){var T=a.on.apply(a,arguments);return T===a?v:T},v.clickDistance=function(T){return arguments.length?(E=(T=+T)*T,v):Math.sqrt(E)},v}function Ic(e,t,r){e.prototype=t.prototype=r,r.constructor=e}function Dp(e,t){var r=Object.create(e.prototype);for(var s in t)r[s]=t[s];return r}function Ns(){}var Rs=.7,Qi=1/Rs,xo="\\s*([+-]?\\d+)\\s*",Ts="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",wn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",WS=/^#([0-9a-f]{3,8})$/,GS=new RegExp(`^rgb\\(${xo},${xo},${xo}\\)$`),YS=new RegExp(`^rgb\\(${wn},${wn},${wn}\\)$`),KS=new RegExp(`^rgba\\(${xo},${xo},${xo},${Ts}\\)$`),XS=new RegExp(`^rgba\\(${wn},${wn},${wn},${Ts}\\)$`),QS=new RegExp(`^hsl\\(${Ts},${wn},${wn}\\)$`),qS=new RegExp(`^hsla\\(${Ts},${wn},${wn},${Ts}\\)$`),kp={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Ic(Ns,Os,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Mp,formatHex:Mp,formatHex8:ZS,formatHsl:JS,formatRgb:Pp,toString:Pp});function Mp(){return this.rgb().formatHex()}function ZS(){return this.rgb().formatHex8()}function JS(){return $p(this).formatHsl()}function Pp(){return this.rgb().formatRgb()}function Os(e){var t,r;return e=(e+"").trim().toLowerCase(),(t=WS.exec(e))?(r=t[1].length,t=parseInt(t[1],16),r===6?Up(t):r===3?new Ot(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):r===8?qi(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):r===4?qi(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=GS.exec(e))?new Ot(t[1],t[2],t[3],1):(t=YS.exec(e))?new Ot(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=KS.exec(e))?qi(t[1],t[2],t[3],t[4]):(t=XS.exec(e))?qi(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=QS.exec(e))?Vp(t[1],t[2]/100,t[3]/100,1):(t=qS.exec(e))?Vp(t[1],t[2]/100,t[3]/100,t[4]):kp.hasOwnProperty(e)?Up(kp[e]):e==="transparent"?new Ot(NaN,NaN,NaN,0):null}function Up(e){return new Ot(e>>16&255,e>>8&255,e&255,1)}function qi(e,t,r,s){return s<=0&&(e=t=r=NaN),new Ot(e,t,r,s)}function e_(e){return e instanceof Ns||(e=Os(e)),e?(e=e.rgb(),new Ot(e.r,e.g,e.b,e.opacity)):new Ot}function bc(e,t,r,s){return arguments.length===1?e_(e):new Ot(e,t,r,s??1)}function Ot(e,t,r,s){this.r=+e,this.g=+t,this.b=+r,this.opacity=+s}Ic(Ot,bc,Dp(Ns,{brighter(e){return e=e==null?Qi:Math.pow(Qi,e),new Ot(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Rs:Math.pow(Rs,e),new Ot(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Ot(Fr(this.r),Fr(this.g),Fr(this.b),Zi(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Fp,formatHex:Fp,formatHex8:t_,formatRgb:jp,toString:jp}));function Fp(){return`#${jr(this.r)}${jr(this.g)}${jr(this.b)}`}function t_(){return`#${jr(this.r)}${jr(this.g)}${jr(this.b)}${jr((isNaN(this.opacity)?1:this.opacity)*255)}`}function jp(){const e=Zi(this.opacity);return`${e===1?"rgb(":"rgba("}${Fr(this.r)}, ${Fr(this.g)}, ${Fr(this.b)}${e===1?")":`, ${e})`}`}function Zi(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Fr(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function jr(e){return e=Fr(e),(e<16?"0":"")+e.toString(16)}function Vp(e,t,r,s){return s<=0?e=t=r=NaN:r<=0||r>=1?e=t=NaN:t<=0&&(e=NaN),new sn(e,t,r,s)}function $p(e){if(e instanceof sn)return new sn(e.h,e.s,e.l,e.opacity);if(e instanceof Ns||(e=Os(e)),!e)return new sn;if(e instanceof sn)return e;e=e.rgb();var t=e.r/255,r=e.g/255,s=e.b/255,i=Math.min(t,r,s),a=Math.max(t,r,s),c=NaN,u=a-i,f=(a+i)/2;return u?(t===a?c=(r-s)/u+(r<s)*6:r===a?c=(s-t)/u+2:c=(t-r)/u+4,u/=f<.5?a+i:2-a-i,c*=60):u=f>0&&f<1?0:c,new sn(c,u,f,e.opacity)}function n_(e,t,r,s){return arguments.length===1?$p(e):new sn(e,t,r,s??1)}function sn(e,t,r,s){this.h=+e,this.s=+t,this.l=+r,this.opacity=+s}Ic(sn,n_,Dp(Ns,{brighter(e){return e=e==null?Qi:Math.pow(Qi,e),new sn(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Rs:Math.pow(Rs,e),new sn(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,r=this.l,s=r+(r<.5?r:1-r)*t,i=2*r-s;return new Ot(Lc(e>=240?e-240:e+120,i,s),Lc(e,i,s),Lc(e<120?e+240:e-120,i,s),this.opacity)},clamp(){return new sn(Hp(this.h),Ji(this.s),Ji(this.l),Zi(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=Zi(this.opacity);return`${e===1?"hsl(":"hsla("}${Hp(this.h)}, ${Ji(this.s)*100}%, ${Ji(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Hp(e){return e=(e||0)%360,e<0?e+360:e}function Ji(e){return Math.max(0,Math.min(1,e||0))}function Lc(e,t,r){return(e<60?t+(r-t)*e/60:e<180?r:e<240?t+(r-t)*(240-e)/60:t)*255}const Bp=e=>()=>e;function r_(e,t){return function(r){return e+r*t}}function o_(e,t,r){return e=Math.pow(e,r),t=Math.pow(t,r)-e,r=1/r,function(s){return Math.pow(e+s*t,r)}}function s_(e){return(e=+e)==1?zp:function(t,r){return r-t?o_(t,r,e):Bp(isNaN(t)?r:t)}}function zp(e,t){var r=t-e;return r?r_(e,r):Bp(isNaN(e)?t:e)}const Wp=function e(t){var r=s_(t);function s(i,a){var c=r((i=bc(i)).r,(a=bc(a)).r),u=r(i.g,a.g),f=r(i.b,a.b),p=zp(i.opacity,a.opacity);return function(m){return i.r=c(m),i.g=u(m),i.b=f(m),i.opacity=p(m),i+""}}return s.gamma=e,s}(1);function sr(e,t){return e=+e,t=+t,function(r){return e*(1-r)+t*r}}var Dc=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,kc=new RegExp(Dc.source,"g");function i_(e){return function(){return e}}function l_(e){return function(t){return e(t)+""}}function a_(e,t){var r=Dc.lastIndex=kc.lastIndex=0,s,i,a,c=-1,u=[],f=[];for(e=e+"",t=t+"";(s=Dc.exec(e))&&(i=kc.exec(t));)(a=i.index)>r&&(a=t.slice(r,a),u[c]?u[c]+=a:u[++c]=a),(s=s[0])===(i=i[0])?u[c]?u[c]+=i:u[++c]=i:(u[++c]=null,f.push({i:c,x:sr(s,i)})),r=kc.lastIndex;return r<t.length&&(a=t.slice(r),u[c]?u[c]+=a:u[++c]=a),u.length<2?f[0]?l_(f[0].x):i_(t):(t=f.length,function(p){for(var m=0,E;m<t;++m)u[(E=f[m]).i]=E.x(p);return u.join("")})}var Gp=180/Math.PI,Mc={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Yp(e,t,r,s,i,a){var c,u,f;return(c=Math.sqrt(e*e+t*t))&&(e/=c,t/=c),(f=e*r+t*s)&&(r-=e*f,s-=t*f),(u=Math.sqrt(r*r+s*s))&&(r/=u,s/=u,f/=u),e*s<t*r&&(e=-e,t=-t,f=-f,c=-c),{translateX:i,translateY:a,rotate:Math.atan2(t,e)*Gp,skewX:Math.atan(f)*Gp,scaleX:c,scaleY:u}}var el;function c_(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Mc:Yp(t.a,t.b,t.c,t.d,t.e,t.f)}function u_(e){return e==null||(el||(el=document.createElementNS("http://www.w3.org/2000/svg","g")),el.setAttribute("transform",e),!(e=el.transform.baseVal.consolidate()))?Mc:(e=e.matrix,Yp(e.a,e.b,e.c,e.d,e.e,e.f))}function Kp(e,t,r,s){function i(p){return p.length?p.pop()+" ":""}function a(p,m,E,v,x,_){if(p!==E||m!==v){var w=x.push("translate(",null,t,null,r);_.push({i:w-4,x:sr(p,E)},{i:w-2,x:sr(m,v)})}else(E||v)&&x.push("translate("+E+t+v+r)}function c(p,m,E,v){p!==m?(p-m>180?m+=360:m-p>180&&(p+=360),v.push({i:E.push(i(E)+"rotate(",null,s)-2,x:sr(p,m)})):m&&E.push(i(E)+"rotate("+m+s)}function u(p,m,E,v){p!==m?v.push({i:E.push(i(E)+"skewX(",null,s)-2,x:sr(p,m)}):m&&E.push(i(E)+"skewX("+m+s)}function f(p,m,E,v,x,_){if(p!==E||m!==v){var w=x.push(i(x)+"scale(",null,",",null,")");_.push({i:w-4,x:sr(p,E)},{i:w-2,x:sr(m,v)})}else(E!==1||v!==1)&&x.push(i(x)+"scale("+E+","+v+")")}return function(p,m){var E=[],v=[];return p=e(p),m=e(m),a(p.translateX,p.translateY,m.translateX,m.translateY,E,v),c(p.rotate,m.rotate,E,v),u(p.skewX,m.skewX,E,v),f(p.scaleX,p.scaleY,m.scaleX,m.scaleY,E,v),p=m=null,function(x){for(var _=-1,w=v.length,S;++_<w;)E[(S=v[_]).i]=S.x(x);return E.join("")}}}var d_=Kp(c_,"px, ","px)","deg)"),f_=Kp(u_,", ",")",")"),p_=1e-12;function Xp(e){return((e=Math.exp(e))+1/e)/2}function h_(e){return((e=Math.exp(e))-1/e)/2}function m_(e){return((e=Math.exp(2*e))-1)/(e+1)}const g_=function e(t,r,s){function i(a,c){var u=a[0],f=a[1],p=a[2],m=c[0],E=c[1],v=c[2],x=m-u,_=E-f,w=x*x+_*_,S,N;if(w<p_)N=Math.log(v/p)/t,S=function(F){return[u+F*x,f+F*_,p*Math.exp(t*F*N)]};else{var O=Math.sqrt(w),D=(v*v-p*p+s*w)/(2*p*r*O),T=(v*v-p*p-s*w)/(2*v*r*O),A=Math.log(Math.sqrt(D*D+1)-D),L=Math.log(Math.sqrt(T*T+1)-T);N=(L-A)/t,S=function(F){var K=F*N,Q=Xp(A),X=p/(r*O)*(Q*m_(t*K+A)-h_(A));return[u+X*x,f+X*_,p*Q/Xp(t*K+A)]}}return S.duration=N*1e3*t/Math.SQRT2,S}return i.rho=function(a){var c=Math.max(.001,+a),u=c*c,f=u*u;return e(c,u,f)},i}(Math.SQRT2,2,4);var So=0,Cs=0,As=0,Qp=1e3,tl,Is,nl=0,Vr=0,rl=0,bs=typeof performance=="object"&&performance.now?performance:Date,qp=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Pc(){return Vr||(qp(E_),Vr=bs.now()+rl)}function E_(){Vr=0}function ol(){this._call=this._time=this._next=null}ol.prototype=Zp.prototype={constructor:ol,restart:function(e,t,r){if(typeof e!="function")throw new TypeError("callback is not a function");r=(r==null?Pc():+r)+(t==null?0:+t),!this._next&&Is!==this&&(Is?Is._next=this:tl=this,Is=this),this._call=e,this._time=r,Uc()},stop:function(){this._call&&(this._call=null,this._time=1/0,Uc())}};function Zp(e,t,r){var s=new ol;return s.restart(e,t,r),s}function y_(){Pc(),++So;for(var e=tl,t;e;)(t=Vr-e._time)>=0&&e._call.call(void 0,t),e=e._next;--So}function Jp(){Vr=(nl=bs.now())+rl,So=Cs=0;try{y_()}finally{So=0,x_(),Vr=0}}function v_(){var e=bs.now(),t=e-nl;t>Qp&&(rl-=t,nl=e)}function x_(){for(var e,t=tl,r,s=1/0;t;)t._call?(s>t._time&&(s=t._time),e=t,t=t._next):(r=t._next,t._next=null,t=e?e._next=r:tl=r);Is=e,Uc(s)}function Uc(e){if(!So){Cs&&(Cs=clearTimeout(Cs));var t=e-Vr;t>24?(e<1/0&&(Cs=setTimeout(Jp,e-bs.now()-rl)),As&&(As=clearInterval(As))):(As||(nl=bs.now(),As=setInterval(v_,Qp)),So=1,qp(Jp))}}function eh(e,t,r){var s=new ol;return t=t==null?0:+t,s.restart(i=>{s.stop(),e(i+t)},t,r),s}var S_=Wi("start","end","cancel","interrupt"),__=[],th=0,nh=1,Fc=2,sl=3,rh=4,jc=5,il=6;function ll(e,t,r,s,i,a){var c=e.__transition;if(!c)e.__transition={};else if(r in c)return;w_(e,r,{name:t,index:s,group:i,on:S_,tween:__,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:th})}function Vc(e,t){var r=ln(e,t);if(r.state>th)throw new Error("too late; already scheduled");return r}function Nn(e,t){var r=ln(e,t);if(r.state>sl)throw new Error("too late; already running");return r}function ln(e,t){var r=e.__transition;if(!r||!(r=r[t]))throw new Error("transition not found");return r}function w_(e,t,r){var s=e.__transition,i;s[t]=r,r.timer=Zp(a,0,r.time);function a(p){r.state=nh,r.timer.restart(c,r.delay,r.time),r.delay<=p&&c(p-r.delay)}function c(p){var m,E,v,x;if(r.state!==nh)return f();for(m in s)if(x=s[m],x.name===r.name){if(x.state===sl)return eh(c);x.state===rh?(x.state=il,x.timer.stop(),x.on.call("interrupt",e,e.__data__,x.index,x.group),delete s[m]):+m<t&&(x.state=il,x.timer.stop(),x.on.call("cancel",e,e.__data__,x.index,x.group),delete s[m])}if(eh(function(){r.state===sl&&(r.state=rh,r.timer.restart(u,r.delay,r.time),u(p))}),r.state=Fc,r.on.call("start",e,e.__data__,r.index,r.group),r.state===Fc){for(r.state=sl,i=new Array(v=r.tween.length),m=0,E=-1;m<v;++m)(x=r.tween[m].value.call(e,e.__data__,r.index,r.group))&&(i[++E]=x);i.length=E+1}}function u(p){for(var m=p<r.duration?r.ease.call(null,p/r.duration):(r.timer.restart(f),r.state=jc,1),E=-1,v=i.length;++E<v;)i[E].call(e,m);r.state===jc&&(r.on.call("end",e,e.__data__,r.index,r.group),f())}function f(){r.state=il,r.timer.stop(),delete s[t];for(var p in s)return;delete e.__transition}}function al(e,t){var r=e.__transition,s,i,a=!0,c;if(r){t=t==null?null:t+"";for(c in r){if((s=r[c]).name!==t){a=!1;continue}i=s.state>Fc&&s.state<jc,s.state=il,s.timer.stop(),s.on.call(i?"interrupt":"cancel",e,e.__data__,s.index,s.group),delete r[c]}a&&delete e.__transition}}function N_(e){return this.each(function(){al(this,e)})}function R_(e,t){var r,s;return function(){var i=Nn(this,e),a=i.tween;if(a!==r){s=r=a;for(var c=0,u=s.length;c<u;++c)if(s[c].name===t){s=s.slice(),s.splice(c,1);break}}i.tween=s}}function T_(e,t,r){var s,i;if(typeof r!="function")throw new Error;return function(){var a=Nn(this,e),c=a.tween;if(c!==s){i=(s=c).slice();for(var u={name:t,value:r},f=0,p=i.length;f<p;++f)if(i[f].name===t){i[f]=u;break}f===p&&i.push(u)}a.tween=i}}function O_(e,t){var r=this._id;if(e+="",arguments.length<2){for(var s=ln(this.node(),r).tween,i=0,a=s.length,c;i<a;++i)if((c=s[i]).name===e)return c.value;return null}return this.each((t==null?R_:T_)(r,e,t))}function $c(e,t,r){var s=e._id;return e.each(function(){var i=Nn(this,s);(i.value||(i.value={}))[t]=r.apply(this,arguments)}),function(i){return ln(i,s).value[t]}}function oh(e,t){var r;return(typeof t=="number"?sr:t instanceof Os?Wp:(r=Os(t))?(t=r,Wp):a_)(e,t)}function C_(e){return function(){this.removeAttribute(e)}}function A_(e){return function(){this.removeAttributeNS(e.space,e.local)}}function I_(e,t,r){var s,i=r+"",a;return function(){var c=this.getAttribute(e);return c===i?null:c===s?a:a=t(s=c,r)}}function b_(e,t,r){var s,i=r+"",a;return function(){var c=this.getAttributeNS(e.space,e.local);return c===i?null:c===s?a:a=t(s=c,r)}}function L_(e,t,r){var s,i,a;return function(){var c,u=r(this),f;return u==null?void this.removeAttribute(e):(c=this.getAttribute(e),f=u+"",c===f?null:c===s&&f===i?a:(i=f,a=t(s=c,u)))}}function D_(e,t,r){var s,i,a;return function(){var c,u=r(this),f;return u==null?void this.removeAttributeNS(e.space,e.local):(c=this.getAttributeNS(e.space,e.local),f=u+"",c===f?null:c===s&&f===i?a:(i=f,a=t(s=c,u)))}}function k_(e,t){var r=Yi(e),s=r==="transform"?f_:oh;return this.attrTween(e,typeof t=="function"?(r.local?D_:L_)(r,s,$c(this,"attr."+e,t)):t==null?(r.local?A_:C_)(r):(r.local?b_:I_)(r,s,t))}function M_(e,t){return function(r){this.setAttribute(e,t.call(this,r))}}function P_(e,t){return function(r){this.setAttributeNS(e.space,e.local,t.call(this,r))}}function U_(e,t){var r,s;function i(){var a=t.apply(this,arguments);return a!==s&&(r=(s=a)&&P_(e,a)),r}return i._value=t,i}function F_(e,t){var r,s;function i(){var a=t.apply(this,arguments);return a!==s&&(r=(s=a)&&M_(e,a)),r}return i._value=t,i}function j_(e,t){var r="attr."+e;if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!="function")throw new Error;var s=Yi(e);return this.tween(r,(s.local?U_:F_)(s,t))}function V_(e,t){return function(){Vc(this,e).delay=+t.apply(this,arguments)}}function $_(e,t){return t=+t,function(){Vc(this,e).delay=t}}function H_(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?V_:$_)(t,e)):ln(this.node(),t).delay}function B_(e,t){return function(){Nn(this,e).duration=+t.apply(this,arguments)}}function z_(e,t){return t=+t,function(){Nn(this,e).duration=t}}function W_(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?B_:z_)(t,e)):ln(this.node(),t).duration}function G_(e,t){if(typeof t!="function")throw new Error;return function(){Nn(this,e).ease=t}}function Y_(e){var t=this._id;return arguments.length?this.each(G_(t,e)):ln(this.node(),t).ease}function K_(e,t){return function(){var r=t.apply(this,arguments);if(typeof r!="function")throw new Error;Nn(this,e).ease=r}}function X_(e){if(typeof e!="function")throw new Error;return this.each(K_(this._id,e))}function Q_(e){typeof e!="function"&&(e=Sp(e));for(var t=this._groups,r=t.length,s=new Array(r),i=0;i<r;++i)for(var a=t[i],c=a.length,u=s[i]=[],f,p=0;p<c;++p)(f=a[p])&&e.call(f,f.__data__,p,a)&&u.push(f);return new Un(s,this._parents,this._name,this._id)}function q_(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,r=e._groups,s=t.length,i=r.length,a=Math.min(s,i),c=new Array(s),u=0;u<a;++u)for(var f=t[u],p=r[u],m=f.length,E=c[u]=new Array(m),v,x=0;x<m;++x)(v=f[x]||p[x])&&(E[x]=v);for(;u<s;++u)c[u]=t[u];return new Un(c,this._parents,this._name,this._id)}function Z_(e){return(e+"").trim().split(/^|\s+/).every(function(t){var r=t.indexOf(".");return r>=0&&(t=t.slice(0,r)),!t||t==="start"})}function J_(e,t,r){var s,i,a=Z_(t)?Vc:Nn;return function(){var c=a(this,e),u=c.on;u!==s&&(i=(s=u).copy()).on(t,r),c.on=i}}function ew(e,t){var r=this._id;return arguments.length<2?ln(this.node(),r).on.on(e):this.each(J_(r,e,t))}function tw(e){return function(){var t=this.parentNode;for(var r in this.__transition)if(+r!==e)return;t&&t.removeChild(this)}}function nw(){return this.on("end.remove",tw(this._id))}function rw(e){var t=this._name,r=this._id;typeof e!="function"&&(e=Tc(e));for(var s=this._groups,i=s.length,a=new Array(i),c=0;c<i;++c)for(var u=s[c],f=u.length,p=a[c]=new Array(f),m,E,v=0;v<f;++v)(m=u[v])&&(E=e.call(m,m.__data__,v,u))&&("__data__"in m&&(E.__data__=m.__data__),p[v]=E,ll(p[v],t,r,v,p,ln(m,r)));return new Un(a,this._parents,t,r)}function ow(e){var t=this._name,r=this._id;typeof e!="function"&&(e=xp(e));for(var s=this._groups,i=s.length,a=[],c=[],u=0;u<i;++u)for(var f=s[u],p=f.length,m,E=0;E<p;++E)if(m=f[E]){for(var v=e.call(m,m.__data__,E,f),x,_=ln(m,r),w=0,S=v.length;w<S;++w)(x=v[w])&&ll(x,t,r,w,v,_);a.push(v),c.push(m)}return new Un(a,c,t,r)}var sw=_s.prototype.constructor;function iw(){return new sw(this._groups,this._parents)}function lw(e,t){var r,s,i;return function(){var a=yo(this,e),c=(this.style.removeProperty(e),yo(this,e));return a===c?null:a===r&&c===s?i:i=t(r=a,s=c)}}function sh(e){return function(){this.style.removeProperty(e)}}function aw(e,t,r){var s,i=r+"",a;return function(){var c=yo(this,e);return c===i?null:c===s?a:a=t(s=c,r)}}function cw(e,t,r){var s,i,a;return function(){var c=yo(this,e),u=r(this),f=u+"";return u==null&&(f=u=(this.style.removeProperty(e),yo(this,e))),c===f?null:c===s&&f===i?a:(i=f,a=t(s=c,u))}}function uw(e,t){var r,s,i,a="style."+t,c="end."+a,u;return function(){var f=Nn(this,e),p=f.on,m=f.value[a]==null?u||(u=sh(t)):void 0;(p!==r||i!==m)&&(s=(r=p).copy()).on(c,i=m),f.on=s}}function dw(e,t,r){var s=(e+="")=="transform"?d_:oh;return t==null?this.styleTween(e,lw(e,s)).on("end.style."+e,sh(e)):typeof t=="function"?this.styleTween(e,cw(e,s,$c(this,"style."+e,t))).each(uw(this._id,e)):this.styleTween(e,aw(e,s,t),r).on("end.style."+e,null)}function fw(e,t,r){return function(s){this.style.setProperty(e,t.call(this,s),r)}}function pw(e,t,r){var s,i;function a(){var c=t.apply(this,arguments);return c!==i&&(s=(i=c)&&fw(e,c,r)),s}return a._value=t,a}function hw(e,t,r){var s="style."+(e+="");if(arguments.length<2)return(s=this.tween(s))&&s._value;if(t==null)return this.tween(s,null);if(typeof t!="function")throw new Error;return this.tween(s,pw(e,t,r??""))}function mw(e){return function(){this.textContent=e}}function gw(e){return function(){var t=e(this);this.textContent=t??""}}function Ew(e){return this.tween("text",typeof e=="function"?gw($c(this,"text",e)):mw(e==null?"":e+""))}function yw(e){return function(t){this.textContent=e.call(this,t)}}function vw(e){var t,r;function s(){var i=e.apply(this,arguments);return i!==r&&(t=(r=i)&&yw(i)),t}return s._value=e,s}function xw(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,vw(e))}function Sw(){for(var e=this._name,t=this._id,r=ih(),s=this._groups,i=s.length,a=0;a<i;++a)for(var c=s[a],u=c.length,f,p=0;p<u;++p)if(f=c[p]){var m=ln(f,t);ll(f,e,r,p,c,{time:m.time+m.delay+m.duration,delay:0,duration:m.duration,ease:m.ease})}return new Un(s,this._parents,e,r)}function _w(){var e,t,r=this,s=r._id,i=r.size();return new Promise(function(a,c){var u={value:c},f={value:function(){--i===0&&a()}};r.each(function(){var p=Nn(this,s),m=p.on;m!==e&&(t=(e=m).copy(),t._.cancel.push(u),t._.interrupt.push(u),t._.end.push(f)),p.on=t}),i===0&&a()})}var ww=0;function Un(e,t,r,s){this._groups=e,this._parents=t,this._name=r,this._id=s}function ih(){return++ww}var Fn=_s.prototype;Un.prototype={constructor:Un,select:rw,selectAll:ow,selectChild:Fn.selectChild,selectChildren:Fn.selectChildren,filter:Q_,merge:q_,selection:iw,transition:Sw,call:Fn.call,nodes:Fn.nodes,node:Fn.node,size:Fn.size,empty:Fn.empty,each:Fn.each,on:ew,attr:k_,attrTween:j_,style:dw,styleTween:hw,text:Ew,textTween:xw,remove:nw,tween:O_,delay:H_,duration:W_,ease:Y_,easeVarying:X_,end:_w,[Symbol.iterator]:Fn[Symbol.iterator]};function Nw(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Rw={time:null,delay:0,duration:250,ease:Nw};function Tw(e,t){for(var r;!(r=e.__transition)||!(r=r[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return r}function Ow(e){var t,r;e instanceof Un?(t=e._id,e=e._name):(t=ih(),(r=Rw).time=Pc(),e=e==null?null:e+"");for(var s=this._groups,i=s.length,a=0;a<i;++a)for(var c=s[a],u=c.length,f,p=0;p<u;++p)(f=c[p])&&ll(f,e,t,p,c,r||Tw(f,t));return new Un(s,this._parents,e,t)}_s.prototype.interrupt=N_,_s.prototype.transition=Ow;const cl=e=>()=>e;function Cw(e,{sourceEvent:t,target:r,transform:s,dispatch:i}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},transform:{value:s,enumerable:!0,configurable:!0},_:{value:i}})}function jn(e,t,r){this.k=e,this.x=t,this.y=r}jn.prototype={constructor:jn,scale:function(e){return e===1?this:new jn(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new jn(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var ir=new jn(1,0,0);jn.prototype;function Hc(e){e.stopImmediatePropagation()}function Ls(e){e.preventDefault(),e.stopImmediatePropagation()}function Aw(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Iw(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function lh(){return this.__zoom||ir}function bw(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Lw(){return navigator.maxTouchPoints||"ontouchstart"in this}function Dw(e,t,r){var s=e.invertX(t[0][0])-r[0][0],i=e.invertX(t[1][0])-r[1][0],a=e.invertY(t[0][1])-r[0][1],c=e.invertY(t[1][1])-r[1][1];return e.translate(i>s?(s+i)/2:Math.min(0,s)||Math.max(0,i),c>a?(a+c)/2:Math.min(0,a)||Math.max(0,c))}function kw(){var e=Aw,t=Iw,r=Dw,s=bw,i=Lw,a=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],u=250,f=g_,p=Wi("start","zoom","end"),m,E,v,x=500,_=150,w=0,S=10;function N(I){I.property("__zoom",lh).on("wheel.zoom",K,{passive:!1}).on("mousedown.zoom",Q).on("dblclick.zoom",X).filter(i).on("touchstart.zoom",ee).on("touchmove.zoom",ne).on("touchend.zoom touchcancel.zoom",W).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}N.transform=function(I,V,j,B){var U=I.selection?I.selection():I;U.property("__zoom",lh),I!==U?A(I,V,j,B):U.interrupt().each(function(){L(this,arguments).event(B).start().zoom(null,typeof V=="function"?V.apply(this,arguments):V).end()})},N.scaleBy=function(I,V,j,B){N.scaleTo(I,function(){var U=this.__zoom.k,$=typeof V=="function"?V.apply(this,arguments):V;return U*$},j,B)},N.scaleTo=function(I,V,j,B){N.transform(I,function(){var U=t.apply(this,arguments),$=this.__zoom,z=j==null?T(U):typeof j=="function"?j.apply(this,arguments):j,k=$.invert(z),Y=typeof V=="function"?V.apply(this,arguments):V;return r(D(O($,Y),z,k),U,c)},j,B)},N.translateBy=function(I,V,j,B){N.transform(I,function(){return r(this.__zoom.translate(typeof V=="function"?V.apply(this,arguments):V,typeof j=="function"?j.apply(this,arguments):j),t.apply(this,arguments),c)},null,B)},N.translateTo=function(I,V,j,B,U){N.transform(I,function(){var $=t.apply(this,arguments),z=this.__zoom,k=B==null?T($):typeof B=="function"?B.apply(this,arguments):B;return r(ir.translate(k[0],k[1]).scale(z.k).translate(typeof V=="function"?-V.apply(this,arguments):-V,typeof j=="function"?-j.apply(this,arguments):-j),$,c)},B,U)};function O(I,V){return V=Math.max(a[0],Math.min(a[1],V)),V===I.k?I:new jn(V,I.x,I.y)}function D(I,V,j){var B=V[0]-j[0]*I.k,U=V[1]-j[1]*I.k;return B===I.x&&U===I.y?I:new jn(I.k,B,U)}function T(I){return[(+I[0][0]+ +I[1][0])/2,(+I[0][1]+ +I[1][1])/2]}function A(I,V,j,B){I.on("start.zoom",function(){L(this,arguments).event(B).start()}).on("interrupt.zoom end.zoom",function(){L(this,arguments).event(B).end()}).tween("zoom",function(){var U=this,$=arguments,z=L(U,$).event(B),k=t.apply(U,$),Y=j==null?T(k):typeof j=="function"?j.apply(U,$):j,re=Math.max(k[1][0]-k[0][0],k[1][1]-k[0][1]),oe=U.__zoom,le=typeof V=="function"?V.apply(U,$):V,de=f(oe.invert(Y).concat(re/oe.k),le.invert(Y).concat(re/le.k));return function(he){if(he===1)he=le;else{var ue=de(he),me=re/ue[2];he=new jn(me,Y[0]-ue[0]*me,Y[1]-ue[1]*me)}z.zoom(null,he)}})}function L(I,V,j){return!j&&I.__zooming||new F(I,V)}function F(I,V){this.that=I,this.args=V,this.active=0,this.sourceEvent=null,this.extent=t.apply(I,V),this.taps=0}F.prototype={event:function(I){return I&&(this.sourceEvent=I),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(I,V){return this.mouse&&I!=="mouse"&&(this.mouse[1]=V.invert(this.mouse[0])),this.touch0&&I!=="touch"&&(this.touch0[1]=V.invert(this.touch0[0])),this.touch1&&I!=="touch"&&(this.touch1[1]=V.invert(this.touch1[0])),this.that.__zoom=V,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(I){var V=on(this.that).datum();p.call(I,this.that,new Cw(I,{sourceEvent:this.sourceEvent,target:N,transform:this.that.__zoom,dispatch:p}),V)}};function K(I,...V){if(!e.apply(this,arguments))return;var j=L(this,V).event(I),B=this.__zoom,U=Math.max(a[0],Math.min(a[1],B.k*Math.pow(2,s.apply(this,arguments)))),$=_n(I);if(j.wheel)(j.mouse[0][0]!==$[0]||j.mouse[0][1]!==$[1])&&(j.mouse[1]=B.invert(j.mouse[0]=$)),clearTimeout(j.wheel);else{if(B.k===U)return;j.mouse=[$,B.invert($)],al(this),j.start()}Ls(I),j.wheel=setTimeout(z,_),j.zoom("mouse",r(D(O(B,U),j.mouse[0],j.mouse[1]),j.extent,c));function z(){j.wheel=null,j.end()}}function Q(I,...V){if(v||!e.apply(this,arguments))return;var j=I.currentTarget,B=L(this,V,!0).event(I),U=on(I.view).on("mousemove.zoom",Y,!0).on("mouseup.zoom",re,!0),$=_n(I,j),z=I.clientX,k=I.clientY;bp(I.view),Hc(I),B.mouse=[$,this.__zoom.invert($)],al(this),B.start();function Y(oe){if(Ls(oe),!B.moved){var le=oe.clientX-z,de=oe.clientY-k;B.moved=le*le+de*de>w}B.event(oe).zoom("mouse",r(D(B.that.__zoom,B.mouse[0]=_n(oe,j),B.mouse[1]),B.extent,c))}function re(oe){U.on("mousemove.zoom mouseup.zoom",null),Lp(oe.view,B.moved),Ls(oe),B.event(oe).end()}}function X(I,...V){if(e.apply(this,arguments)){var j=this.__zoom,B=_n(I.changedTouches?I.changedTouches[0]:I,this),U=j.invert(B),$=j.k*(I.shiftKey?.5:2),z=r(D(O(j,$),B,U),t.apply(this,V),c);Ls(I),u>0?on(this).transition().duration(u).call(A,z,B,I):on(this).call(N.transform,z,B,I)}}function ee(I,...V){if(e.apply(this,arguments)){var j=I.touches,B=j.length,U=L(this,V,I.changedTouches.length===B).event(I),$,z,k,Y;for(Hc(I),z=0;z<B;++z)k=j[z],Y=_n(k,this),Y=[Y,this.__zoom.invert(Y),k.identifier],U.touch0?!U.touch1&&U.touch0[2]!==Y[2]&&(U.touch1=Y,U.taps=0):(U.touch0=Y,$=!0,U.taps=1+!!m);m&&(m=clearTimeout(m)),$&&(U.taps<2&&(E=Y[0],m=setTimeout(function(){m=null},x)),al(this),U.start())}}function ne(I,...V){if(this.__zooming){var j=L(this,V).event(I),B=I.changedTouches,U=B.length,$,z,k,Y;for(Ls(I),$=0;$<U;++$)z=B[$],k=_n(z,this),j.touch0&&j.touch0[2]===z.identifier?j.touch0[0]=k:j.touch1&&j.touch1[2]===z.identifier&&(j.touch1[0]=k);if(z=j.that.__zoom,j.touch1){var re=j.touch0[0],oe=j.touch0[1],le=j.touch1[0],de=j.touch1[1],he=(he=le[0]-re[0])*he+(he=le[1]-re[1])*he,ue=(ue=de[0]-oe[0])*ue+(ue=de[1]-oe[1])*ue;z=O(z,Math.sqrt(he/ue)),k=[(re[0]+le[0])/2,(re[1]+le[1])/2],Y=[(oe[0]+de[0])/2,(oe[1]+de[1])/2]}else if(j.touch0)k=j.touch0[0],Y=j.touch0[1];else return;j.zoom("touch",r(D(z,k,Y),j.extent,c))}}function W(I,...V){if(this.__zooming){var j=L(this,V).event(I),B=I.changedTouches,U=B.length,$,z;for(Hc(I),v&&clearTimeout(v),v=setTimeout(function(){v=null},x),$=0;$<U;++$)z=B[$],j.touch0&&j.touch0[2]===z.identifier?delete j.touch0:j.touch1&&j.touch1[2]===z.identifier&&delete j.touch1;if(j.touch1&&!j.touch0&&(j.touch0=j.touch1,delete j.touch1),j.touch0)j.touch0[1]=this.__zoom.invert(j.touch0[0]);else if(j.end(),j.taps===2&&(z=_n(z,this),Math.hypot(E[0]-z[0],E[1]-z[1])<S)){var k=on(this).on("dblclick.zoom");k&&k.apply(this,arguments)}}}return N.wheelDelta=function(I){return arguments.length?(s=typeof I=="function"?I:cl(+I),N):s},N.filter=function(I){return arguments.length?(e=typeof I=="function"?I:cl(!!I),N):e},N.touchable=function(I){return arguments.length?(i=typeof I=="function"?I:cl(!!I),N):i},N.extent=function(I){return arguments.length?(t=typeof I=="function"?I:cl([[+I[0][0],+I[0][1]],[+I[1][0],+I[1][1]]]),N):t},N.scaleExtent=function(I){return arguments.length?(a[0]=+I[0],a[1]=+I[1],N):[a[0],a[1]]},N.translateExtent=function(I){return arguments.length?(c[0][0]=+I[0][0],c[1][0]=+I[1][0],c[0][1]=+I[0][1],c[1][1]=+I[1][1],N):[[c[0][0],c[0][1]],[c[1][0],c[1][1]]]},N.constrain=function(I){return arguments.length?(r=I,N):r},N.duration=function(I){return arguments.length?(u=+I,N):u},N.interpolate=function(I){return arguments.length?(f=I,N):f},N.on=function(){var I=p.on.apply(p,arguments);return I===p?N:I},N.clickDistance=function(I){return arguments.length?(w=(I=+I)*I,N):Math.sqrt(w)},N.tapDistance=function(I){return arguments.length?(S=+I,N):S},N}var Bc=ip();const ul=b.createContext(null),Mw=ul.Provider,Vn={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,t)=>`Couldn't create edge for ${e?"target":"source"} handle id: "${e?t.targetHandle:t.sourceHandle}", edge id: ${t.id}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`},ah=Vn.error001();function Me(e,t){const r=b.useContext(ul);if(r===null)throw new Error(ah);return mp(r,e,t)}const tt=()=>{const e=b.useContext(ul);if(e===null)throw new Error(ah);return b.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe,destroy:e.destroy}),[e])},Pw=e=>e.userSelectionActive?"none":"all";function Ds({position:e,children:t,className:r,style:s,...i}){const a=Me(Pw),c=`${e}`.split("-");return te.createElement("div",{className:St(["react-flow__panel",r,...c]),style:{...s,pointerEvents:a},...i},t)}function Uw({proOptions:e,position:t="bottom-right"}){return e?.hideAttribution?null:te.createElement(Ds,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://reactflow.dev/pro"},te.createElement("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution"},"React Flow"))}const Fw=({x:e,y:t,label:r,labelStyle:s={},labelShowBg:i=!0,labelBgStyle:a={},labelBgPadding:c=[2,4],labelBgBorderRadius:u=2,children:f,className:p,...m})=>{const E=b.useRef(null),[v,x]=b.useState({x:0,y:0,width:0,height:0}),_=St(["react-flow__edge-textwrapper",p]);return b.useEffect(()=>{if(E.current){const w=E.current.getBBox();x({x:w.x,y:w.y,width:w.width,height:w.height})}},[r]),typeof r>"u"||!r?null:te.createElement("g",{transform:`translate(${e-v.width/2} ${t-v.height/2})`,className:_,visibility:v.width?"visible":"hidden",...m},i&&te.createElement("rect",{width:v.width+2*c[0],x:-c[0],y:-c[1],height:v.height+2*c[1],className:"react-flow__edge-textbg",style:a,rx:u,ry:u}),te.createElement("text",{className:"react-flow__edge-text",y:v.height/2,dy:"0.3em",ref:E,style:s},r),f)};var jw=b.memo(Fw);const zc=e=>({width:e.offsetWidth,height:e.offsetHeight}),_o=(e,t=0,r=1)=>Math.min(Math.max(e,t),r),Wc=(e={x:0,y:0},t)=>({x:_o(e.x,t[0][0],t[1][0]),y:_o(e.y,t[0][1],t[1][1])}),ch=(e,t,r)=>e<t?_o(Math.abs(e-t),1,50)/50:e>r?-_o(Math.abs(e-r),1,50)/50:0,uh=(e,t)=>{const r=ch(e.x,35,t.width-35)*20,s=ch(e.y,35,t.height-35)*20;return[r,s]},dh=e=>e.getRootNode?.()||window?.document,Vw=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),Gc=({x:e,y:t,width:r,height:s})=>({x:e,y:t,x2:e+r,y2:t+s}),$w=({x:e,y:t,x2:r,y2:s})=>({x:e,y:t,width:r-e,height:s-t}),fh=e=>({...e.positionAbsolute||{x:0,y:0},width:e.width||0,height:e.height||0}),Yc=(e,t)=>{const r=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),s=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(r*s)},Hw=e=>Yt(e.width)&&Yt(e.height)&&Yt(e.x)&&Yt(e.y),Yt=e=>!isNaN(e)&&isFinite(e),nt=Symbol.for("internals"),ph=["Enter"," ","Escape"],Bw=(e,t)=>{},zw=e=>"nativeEvent"in e;function Kc(e){const r=(zw(e)?e.nativeEvent:e).composedPath?.()?.[0]||e.target;return["INPUT","SELECT","TEXTAREA"].includes(r?.nodeName)||r?.hasAttribute("contenteditable")||!!r?.closest(".nokey")}const hh=e=>"clientX"in e,lr=(e,t)=>{const r=hh(e),s=r?e.clientX:e.touches?.[0].clientX,i=r?e.clientY:e.touches?.[0].clientY;return{x:s-(t?.left??0),y:i-(t?.top??0)}},dl=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0,wo=({id:e,path:t,labelX:r,labelY:s,label:i,labelStyle:a,labelShowBg:c,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:E,markerStart:v,interactionWidth:x=20})=>te.createElement(te.Fragment,null,te.createElement("path",{id:e,style:m,d:t,fill:"none",className:"react-flow__edge-path",markerEnd:E,markerStart:v}),x&&te.createElement("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:x,className:"react-flow__edge-interaction"}),i&&Yt(r)&&Yt(s)?te.createElement(jw,{x:r,y:s,label:i,labelStyle:a,labelShowBg:c,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:p}):null);wo.displayName="BaseEdge";function ks(e,t,r){return r===void 0?r:s=>{const i=t().edges.find(a=>a.id===e);i&&r(s,{...i})}}function mh({sourceX:e,sourceY:t,targetX:r,targetY:s}){const i=Math.abs(r-e)/2,a=r<e?r+i:r-i,c=Math.abs(s-t)/2,u=s<t?s+c:s-c;return[a,u,i,c]}function gh({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:i,sourceControlY:a,targetControlX:c,targetControlY:u}){const f=e*.125+i*.375+c*.375+r*.125,p=t*.125+a*.375+u*.375+s*.125,m=Math.abs(f-e),E=Math.abs(p-t);return[f,p,m,E]}var ar;(function(e){e.Strict="strict",e.Loose="loose"})(ar||(ar={}));var $r;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})($r||($r={}));var Ms;(function(e){e.Partial="partial",e.Full="full"})(Ms||(Ms={}));var cr;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(cr||(cr={}));var Ps;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Ps||(Ps={}));var xe;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(xe||(xe={}));function Eh({pos:e,x1:t,y1:r,x2:s,y2:i}){return e===xe.Left||e===xe.Right?[.5*(t+s),r]:[t,.5*(r+i)]}function yh({sourceX:e,sourceY:t,sourcePosition:r=xe.Bottom,targetX:s,targetY:i,targetPosition:a=xe.Top}){const[c,u]=Eh({pos:r,x1:e,y1:t,x2:s,y2:i}),[f,p]=Eh({pos:a,x1:s,y1:i,x2:e,y2:t}),[m,E,v,x]=gh({sourceX:e,sourceY:t,targetX:s,targetY:i,sourceControlX:c,sourceControlY:u,targetControlX:f,targetControlY:p});return[`M${e},${t} C${c},${u} ${f},${p} ${s},${i}`,m,E,v,x]}const Xc=b.memo(({sourceX:e,sourceY:t,targetX:r,targetY:s,sourcePosition:i=xe.Bottom,targetPosition:a=xe.Top,label:c,labelStyle:u,labelShowBg:f,labelBgStyle:p,labelBgPadding:m,labelBgBorderRadius:E,style:v,markerEnd:x,markerStart:_,interactionWidth:w})=>{const[S,N,O]=yh({sourceX:e,sourceY:t,sourcePosition:i,targetX:r,targetY:s,targetPosition:a});return te.createElement(wo,{path:S,labelX:N,labelY:O,label:c,labelStyle:u,labelShowBg:f,labelBgStyle:p,labelBgPadding:m,labelBgBorderRadius:E,style:v,markerEnd:x,markerStart:_,interactionWidth:w})});Xc.displayName="SimpleBezierEdge";const vh={[xe.Left]:{x:-1,y:0},[xe.Right]:{x:1,y:0},[xe.Top]:{x:0,y:-1},[xe.Bottom]:{x:0,y:1}},Ww=({source:e,sourcePosition:t=xe.Bottom,target:r})=>t===xe.Left||t===xe.Right?e.x<r.x?{x:1,y:0}:{x:-1,y:0}:e.y<r.y?{x:0,y:1}:{x:0,y:-1},xh=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function Gw({source:e,sourcePosition:t=xe.Bottom,target:r,targetPosition:s=xe.Top,center:i,offset:a}){const c=vh[t],u=vh[s],f={x:e.x+c.x*a,y:e.y+c.y*a},p={x:r.x+u.x*a,y:r.y+u.y*a},m=Ww({source:f,sourcePosition:t,target:p}),E=m.x!==0?"x":"y",v=m[E];let x=[],_,w;const S={x:0,y:0},N={x:0,y:0},[O,D,T,A]=mh({sourceX:e.x,sourceY:e.y,targetX:r.x,targetY:r.y});if(c[E]*u[E]===-1){_=i.x||O,w=i.y||D;const F=[{x:_,y:f.y},{x:_,y:p.y}],K=[{x:f.x,y:w},{x:p.x,y:w}];c[E]===v?x=E==="x"?F:K:x=E==="x"?K:F}else{const F=[{x:f.x,y:p.y}],K=[{x:p.x,y:f.y}];if(E==="x"?x=c.x===v?K:F:x=c.y===v?F:K,t===s){const W=Math.abs(e[E]-r[E]);if(W<=a){const I=Math.min(a-1,a-W);c[E]===v?S[E]=(f[E]>e[E]?-1:1)*I:N[E]=(p[E]>r[E]?-1:1)*I}}if(t!==s){const W=E==="x"?"y":"x",I=c[E]===u[W],V=f[W]>p[W],j=f[W]<p[W];(c[E]===1&&(!I&&V||I&&j)||c[E]!==1&&(!I&&j||I&&V))&&(x=E==="x"?F:K)}const Q={x:f.x+S.x,y:f.y+S.y},X={x:p.x+N.x,y:p.y+N.y},ee=Math.max(Math.abs(Q.x-x[0].x),Math.abs(X.x-x[0].x)),ne=Math.max(Math.abs(Q.y-x[0].y),Math.abs(X.y-x[0].y));ee>=ne?(_=(Q.x+X.x)/2,w=x[0].y):(_=x[0].x,w=(Q.y+X.y)/2)}return[[e,{x:f.x+S.x,y:f.y+S.y},...x,{x:p.x+N.x,y:p.y+N.y},r],_,w,T,A]}function Yw(e,t,r,s){const i=Math.min(xh(e,t)/2,xh(t,r)/2,s),{x:a,y:c}=t;if(e.x===a&&a===r.x||e.y===c&&c===r.y)return`L${a} ${c}`;if(e.y===c){const p=e.x<r.x?-1:1,m=e.y<r.y?1:-1;return`L ${a+i*p},${c}Q ${a},${c} ${a},${c+i*m}`}const u=e.x<r.x?1:-1,f=e.y<r.y?-1:1;return`L ${a},${c+i*f}Q ${a},${c} ${a+i*u},${c}`}function Us({sourceX:e,sourceY:t,sourcePosition:r=xe.Bottom,targetX:s,targetY:i,targetPosition:a=xe.Top,borderRadius:c=5,centerX:u,centerY:f,offset:p=20}){const[m,E,v,x,_]=Gw({source:{x:e,y:t},sourcePosition:r,target:{x:s,y:i},targetPosition:a,center:{x:u,y:f},offset:p});return[m.reduce((S,N,O)=>{let D="";return O>0&&O<m.length-1?D=Yw(m[O-1],N,m[O+1],c):D=`${O===0?"M":"L"}${N.x} ${N.y}`,S+=D,S},""),E,v,x,_]}const fl=b.memo(({sourceX:e,sourceY:t,targetX:r,targetY:s,label:i,labelStyle:a,labelShowBg:c,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:p,style:m,sourcePosition:E=xe.Bottom,targetPosition:v=xe.Top,markerEnd:x,markerStart:_,pathOptions:w,interactionWidth:S})=>{const[N,O,D]=Us({sourceX:e,sourceY:t,sourcePosition:E,targetX:r,targetY:s,targetPosition:v,borderRadius:w?.borderRadius,offset:w?.offset});return te.createElement(wo,{path:N,labelX:O,labelY:D,label:i,labelStyle:a,labelShowBg:c,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:x,markerStart:_,interactionWidth:S})});fl.displayName="SmoothStepEdge";const Qc=b.memo(e=>te.createElement(fl,{...e,pathOptions:b.useMemo(()=>({borderRadius:0,offset:e.pathOptions?.offset}),[e.pathOptions?.offset])}));Qc.displayName="StepEdge";function Kw({sourceX:e,sourceY:t,targetX:r,targetY:s}){const[i,a,c,u]=mh({sourceX:e,sourceY:t,targetX:r,targetY:s});return[`M ${e},${t}L ${r},${s}`,i,a,c,u]}const qc=b.memo(({sourceX:e,sourceY:t,targetX:r,targetY:s,label:i,labelStyle:a,labelShowBg:c,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:E,markerStart:v,interactionWidth:x})=>{const[_,w,S]=Kw({sourceX:e,sourceY:t,targetX:r,targetY:s});return te.createElement(wo,{path:_,labelX:w,labelY:S,label:i,labelStyle:a,labelShowBg:c,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:E,markerStart:v,interactionWidth:x})});qc.displayName="StraightEdge";function pl(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Sh({pos:e,x1:t,y1:r,x2:s,y2:i,c:a}){switch(e){case xe.Left:return[t-pl(t-s,a),r];case xe.Right:return[t+pl(s-t,a),r];case xe.Top:return[t,r-pl(r-i,a)];case xe.Bottom:return[t,r+pl(i-r,a)]}}function _h({sourceX:e,sourceY:t,sourcePosition:r=xe.Bottom,targetX:s,targetY:i,targetPosition:a=xe.Top,curvature:c=.25}){const[u,f]=Sh({pos:r,x1:e,y1:t,x2:s,y2:i,c}),[p,m]=Sh({pos:a,x1:s,y1:i,x2:e,y2:t,c}),[E,v,x,_]=gh({sourceX:e,sourceY:t,targetX:s,targetY:i,sourceControlX:u,sourceControlY:f,targetControlX:p,targetControlY:m});return[`M${e},${t} C${u},${f} ${p},${m} ${s},${i}`,E,v,x,_]}const hl=b.memo(({sourceX:e,sourceY:t,targetX:r,targetY:s,sourcePosition:i=xe.Bottom,targetPosition:a=xe.Top,label:c,labelStyle:u,labelShowBg:f,labelBgStyle:p,labelBgPadding:m,labelBgBorderRadius:E,style:v,markerEnd:x,markerStart:_,pathOptions:w,interactionWidth:S})=>{const[N,O,D]=_h({sourceX:e,sourceY:t,sourcePosition:i,targetX:r,targetY:s,targetPosition:a,curvature:w?.curvature});return te.createElement(wo,{path:N,labelX:O,labelY:D,label:c,labelStyle:u,labelShowBg:f,labelBgStyle:p,labelBgPadding:m,labelBgBorderRadius:E,style:v,markerEnd:x,markerStart:_,interactionWidth:S})});hl.displayName="BezierEdge";const Zc=b.createContext(null),Xw=Zc.Provider;Zc.Consumer;const Qw=()=>b.useContext(Zc),qw=e=>"id"in e&&"source"in e&&"target"in e,wh=({source:e,sourceHandle:t,target:r,targetHandle:s})=>`reactflow__edge-${e}${t||""}-${r}${s||""}`,Jc=(e,t)=>typeof e>"u"?"":typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(s=>`${s}=${e[s]}`).join("&")}`,Zw=(e,t)=>t.some(r=>r.source===e.source&&r.target===e.target&&(r.sourceHandle===e.sourceHandle||!r.sourceHandle&&!e.sourceHandle)&&(r.targetHandle===e.targetHandle||!r.targetHandle&&!e.targetHandle)),Nh=(e,t)=>{if(!e.source||!e.target)return t;let r;return qw(e)?r={...e}:r={...e,id:wh(e)},Zw(r,t)?t:t.concat(r)},Jw=(e,t,r,s={shouldReplaceId:!0})=>{const{id:i,...a}=e;if(!t.source||!t.target||!r.find(f=>f.id===i))return r;const u={...a,id:s.shouldReplaceId?wh(t):i,source:t.source,target:t.target,sourceHandle:t.sourceHandle,targetHandle:t.targetHandle};return r.filter(f=>f.id!==i).concat(u)},eu=({x:e,y:t},[r,s,i],a,[c,u])=>{const f={x:(e-r)/i,y:(t-s)/i};return a?{x:c*Math.round(f.x/c),y:u*Math.round(f.y/u)}:f},Rh=({x:e,y:t},[r,s,i])=>({x:e*i+r,y:t*i+s}),No=(e,t=[0,0])=>{if(!e)return{x:0,y:0,positionAbsolute:{x:0,y:0}};const r=(e.width??0)*t[0],s=(e.height??0)*t[1],i={x:e.position.x-r,y:e.position.y-s};return{...i,positionAbsolute:e.positionAbsolute?{x:e.positionAbsolute.x-r,y:e.positionAbsolute.y-s}:i}},tu=(e,t=[0,0])=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const r=e.reduce((s,i)=>{const{x:a,y:c}=No(i,t).positionAbsolute;return Vw(s,Gc({x:a,y:c,width:i.width||0,height:i.height||0}))},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return $w(r)},Th=(e,t,[r,s,i]=[0,0,1],a=!1,c=!1,u=[0,0])=>{const f={x:(t.x-r)/i,y:(t.y-s)/i,width:t.width/i,height:t.height/i},p=[];return e.forEach(m=>{const{width:E,height:v,selectable:x=!0,hidden:_=!1}=m;if(c&&!x||_)return!1;const{positionAbsolute:w}=No(m,u),S={x:w.x,y:w.y,width:E||0,height:v||0},N=Yc(f,S),O=typeof E>"u"||typeof v>"u"||E===null||v===null,D=a&&N>0,T=(E||0)*(v||0);(O||D||N>=T||m.dragging)&&p.push(m)}),p},Oh=(e,t)=>{const r=e.map(s=>s.id);return t.filter(s=>r.includes(s.source)||r.includes(s.target))},Ch=(e,t,r,s,i,a=.1)=>{const c=t/(e.width*(1+a)),u=r/(e.height*(1+a)),f=Math.min(c,u),p=_o(f,s,i),m=e.x+e.width/2,E=e.y+e.height/2,v=t/2-m*p,x=r/2-E*p;return{x:v,y:x,zoom:p}},Hr=(e,t=0)=>e.transition().duration(t);function Ah(e,t,r,s){return(t[r]||[]).reduce((i,a)=>(`${e.id}-${a.id}-${r}`!==s&&i.push({id:a.id||null,type:r,nodeId:e.id,x:(e.positionAbsolute?.x??0)+a.x+a.width/2,y:(e.positionAbsolute?.y??0)+a.y+a.height/2}),i),[])}function eN(e,t,r,s,i,a){const{x:c,y:u}=lr(e),p=t.elementsFromPoint(c,u).find(_=>_.classList.contains("react-flow__handle"));if(p){const _=p.getAttribute("data-nodeid");if(_){const w=nu(void 0,p),S=p.getAttribute("data-handleid"),N=a({nodeId:_,id:S,type:w});if(N){const O=i.find(D=>D.nodeId===_&&D.type===w&&D.id===S);return{handle:{id:S,type:w,nodeId:_,x:O?.x||r.x,y:O?.y||r.y},validHandleResult:N}}}}let m=[],E=1/0;if(i.forEach(_=>{const w=Math.sqrt((_.x-r.x)**2+(_.y-r.y)**2);if(w<=s){const S=a(_);w<=E&&(w<E?m=[{handle:_,validHandleResult:S}]:w===E&&m.push({handle:_,validHandleResult:S}),E=w)}}),!m.length)return{handle:null,validHandleResult:Ih()};if(m.length===1)return m[0];const v=m.some(({validHandleResult:_})=>_.isValid),x=m.some(({handle:_})=>_.type==="target");return m.find(({handle:_,validHandleResult:w})=>x?_.type==="target":v?w.isValid:!0)||m[0]}const tN={source:null,target:null,sourceHandle:null,targetHandle:null},Ih=()=>({handleDomNode:null,isValid:!1,connection:tN,endHandle:null});function bh(e,t,r,s,i,a,c){const u=i==="target",f=c.querySelector(`.react-flow__handle[data-id="${e?.nodeId}-${e?.id}-${e?.type}"]`),p={...Ih(),handleDomNode:f};if(f){const m=nu(void 0,f),E=f.getAttribute("data-nodeid"),v=f.getAttribute("data-handleid"),x=f.classList.contains("connectable"),_=f.classList.contains("connectableend"),w={source:u?E:r,sourceHandle:u?v:s,target:u?r:E,targetHandle:u?s:v};p.connection=w,x&&_&&(t===ar.Strict?u&&m==="source"||!u&&m==="target":E!==r||v!==s)&&(p.endHandle={nodeId:E,handleId:v,type:m},p.isValid=a(w))}return p}function nN({nodes:e,nodeId:t,handleId:r,handleType:s}){return e.reduce((i,a)=>{if(a[nt]){const{handleBounds:c}=a[nt];let u=[],f=[];c&&(u=Ah(a,c,"source",`${t}-${r}-${s}`),f=Ah(a,c,"target",`${t}-${r}-${s}`)),i.push(...u,...f)}return i},[])}function nu(e,t){return e||(t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null)}function ru(e){e?.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function rN(e,t){let r=null;return t?r="valid":e&&!t&&(r="invalid"),r}function Lh({event:e,handleId:t,nodeId:r,onConnect:s,isTarget:i,getState:a,setState:c,isValidConnection:u,edgeUpdaterType:f,onEdgeUpdateEnd:p}){const m=dh(e.target),{connectionMode:E,domNode:v,autoPanOnConnect:x,connectionRadius:_,onConnectStart:w,panBy:S,getNodes:N,cancelConnection:O}=a();let D=0,T;const{x:A,y:L}=lr(e),F=m?.elementFromPoint(A,L),K=nu(f,F),Q=v?.getBoundingClientRect();if(!Q||!K)return;let X,ee=lr(e,Q),ne=!1,W=null,I=!1,V=null;const j=nN({nodes:N(),nodeId:r,handleId:t,handleType:K}),B=()=>{if(!x)return;const[z,k]=uh(ee,Q);S({x:z,y:k}),D=requestAnimationFrame(B)};c({connectionPosition:ee,connectionStatus:null,connectionNodeId:r,connectionHandleId:t,connectionHandleType:K,connectionStartHandle:{nodeId:r,handleId:t,type:K},connectionEndHandle:null}),w?.(e,{nodeId:r,handleId:t,handleType:K});function U(z){const{transform:k}=a();ee=lr(z,Q);const{handle:Y,validHandleResult:re}=eN(z,m,eu(ee,k,!1,[1,1]),_,j,oe=>bh(oe,E,r,t,i?"target":"source",u,m));if(T=Y,ne||(B(),ne=!0),V=re.handleDomNode,W=re.connection,I=re.isValid,c({connectionPosition:T&&I?Rh({x:T.x,y:T.y},k):ee,connectionStatus:rN(!!T,I),connectionEndHandle:re.endHandle}),!T&&!I&&!V)return ru(X);W.source!==W.target&&V&&(ru(X),X=V,V.classList.add("connecting","react-flow__handle-connecting"),V.classList.toggle("valid",I),V.classList.toggle("react-flow__handle-valid",I))}function $(z){(T||V)&&W&&I&&s?.(W),a().onConnectEnd?.(z),f&&p?.(z),ru(X),O(),cancelAnimationFrame(D),ne=!1,I=!1,W=null,V=null,m.removeEventListener("mousemove",U),m.removeEventListener("mouseup",$),m.removeEventListener("touchmove",U),m.removeEventListener("touchend",$)}m.addEventListener("mousemove",U),m.addEventListener("mouseup",$),m.addEventListener("touchmove",U),m.addEventListener("touchend",$)}const Dh=()=>!0,oN=e=>({connectionStartHandle:e.connectionStartHandle,connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName}),sN=(e,t,r)=>s=>{const{connectionStartHandle:i,connectionEndHandle:a,connectionClickStartHandle:c}=s;return{connecting:i?.nodeId===e&&i?.handleId===t&&i?.type===r||a?.nodeId===e&&a?.handleId===t&&a?.type===r,clickConnecting:c?.nodeId===e&&c?.handleId===t&&c?.type===r}},kh=b.forwardRef(({type:e="source",position:t=xe.Top,isValidConnection:r,isConnectable:s=!0,isConnectableStart:i=!0,isConnectableEnd:a=!0,id:c,onConnect:u,children:f,className:p,onMouseDown:m,onTouchStart:E,...v},x)=>{const _=c||null,w=e==="target",S=tt(),N=Qw(),{connectOnClick:O,noPanClassName:D}=Me(oN,gt),{connecting:T,clickConnecting:A}=Me(sN(N,_,e),gt);N||S.getState().onError?.("010",Vn.error010());const L=Q=>{const{defaultEdgeOptions:X,onConnect:ee,hasDefaultEdges:ne}=S.getState(),W={...X,...Q};if(ne){const{edges:I,setEdges:V}=S.getState();V(Nh(W,I))}ee?.(W),u?.(W)},F=Q=>{if(!N)return;const X=hh(Q);i&&(X&&Q.button===0||!X)&&Lh({event:Q,handleId:_,nodeId:N,onConnect:L,isTarget:w,getState:S.getState,setState:S.setState,isValidConnection:r||S.getState().isValidConnection||Dh}),X?m?.(Q):E?.(Q)},K=Q=>{const{onClickConnectStart:X,onClickConnectEnd:ee,connectionClickStartHandle:ne,connectionMode:W,isValidConnection:I}=S.getState();if(!N||!ne&&!i)return;if(!ne){X?.(Q,{nodeId:N,handleId:_,handleType:e}),S.setState({connectionClickStartHandle:{nodeId:N,type:e,handleId:_}});return}const V=dh(Q.target),j=r||I||Dh,{connection:B,isValid:U}=bh({nodeId:N,id:_,type:e},W,ne.nodeId,ne.handleId||null,ne.type,j,V);U&&L(B),ee?.(Q),S.setState({connectionClickStartHandle:null})};return te.createElement("div",{"data-handleid":_,"data-nodeid":N,"data-handlepos":t,"data-id":`${N}-${_}-${e}`,className:St(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",D,p,{source:!w,target:w,connectable:s,connectablestart:i,connectableend:a,connecting:A,connectionindicator:s&&(i&&!T||a&&T)}]),onMouseDown:F,onTouchStart:F,onClick:O?K:void 0,ref:x,...v},f)});kh.displayName="Handle";var Ro=b.memo(kh);const Mh=({data:e,isConnectable:t,targetPosition:r=xe.Top,sourcePosition:s=xe.Bottom})=>te.createElement(te.Fragment,null,te.createElement(Ro,{type:"target",position:r,isConnectable:t}),e?.label,te.createElement(Ro,{type:"source",position:s,isConnectable:t}));Mh.displayName="DefaultNode";var ou=b.memo(Mh);const Ph=({data:e,isConnectable:t,sourcePosition:r=xe.Bottom})=>te.createElement(te.Fragment,null,e?.label,te.createElement(Ro,{type:"source",position:r,isConnectable:t}));Ph.displayName="InputNode";var Uh=b.memo(Ph);const Fh=({data:e,isConnectable:t,targetPosition:r=xe.Top})=>te.createElement(te.Fragment,null,te.createElement(Ro,{type:"target",position:r,isConnectable:t}),e?.label);Fh.displayName="OutputNode";var jh=b.memo(Fh);const su=()=>null;su.displayName="GroupNode";const iN=e=>({selectedNodes:e.getNodes().filter(t=>t.selected),selectedEdges:e.edges.filter(t=>t.selected)}),ml=e=>e.id;function lN(e,t){return gt(e.selectedNodes.map(ml),t.selectedNodes.map(ml))&>(e.selectedEdges.map(ml),t.selectedEdges.map(ml))}const Vh=b.memo(({onSelectionChange:e})=>{const t=tt(),{selectedNodes:r,selectedEdges:s}=Me(iN,lN);return b.useEffect(()=>{const i={nodes:r,edges:s};e?.(i),t.getState().onSelectionChange.forEach(a=>a(i))},[r,s,e]),null});Vh.displayName="SelectionListener";const aN=e=>!!e.onSelectionChange;function cN({onSelectionChange:e}){const t=Me(aN);return e||t?te.createElement(Vh,{onSelectionChange:e}):null}const uN=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset});function To(e,t){b.useEffect(()=>{typeof e<"u"&&t(e)},[e])}function Oe(e,t,r){b.useEffect(()=>{typeof t<"u"&&r({[e]:t})},[t])}const dN=({nodes:e,edges:t,defaultNodes:r,defaultEdges:s,onConnect:i,onConnectStart:a,onConnectEnd:c,onClickConnectStart:u,onClickConnectEnd:f,nodesDraggable:p,nodesConnectable:m,nodesFocusable:E,edgesFocusable:v,edgesUpdatable:x,elevateNodesOnSelect:_,minZoom:w,maxZoom:S,nodeExtent:N,onNodesChange:O,onEdgesChange:D,elementsSelectable:T,connectionMode:A,snapGrid:L,snapToGrid:F,translateExtent:K,connectOnClick:Q,defaultEdgeOptions:X,fitView:ee,fitViewOptions:ne,onNodesDelete:W,onEdgesDelete:I,onNodeDrag:V,onNodeDragStart:j,onNodeDragStop:B,onSelectionDrag:U,onSelectionDragStart:$,onSelectionDragStop:z,noPanClassName:k,nodeOrigin:Y,rfId:re,autoPanOnConnect:oe,autoPanOnNodeDrag:le,onError:de,connectionRadius:he,isValidConnection:ue,nodeDragThreshold:me})=>{const{setNodes:Re,setEdges:Pe,setDefaultNodesAndEdges:Je,setMinZoom:wt,setMaxZoom:Be,setTranslateExtent:Ue,setNodeExtent:ft,reset:pt}=Me(uN,gt),we=tt();return b.useEffect(()=>{const un=s?.map(Ht=>({...Ht,...X}));return Je(r,un),()=>{pt()}},[]),Oe("defaultEdgeOptions",X,we.setState),Oe("connectionMode",A,we.setState),Oe("onConnect",i,we.setState),Oe("onConnectStart",a,we.setState),Oe("onConnectEnd",c,we.setState),Oe("onClickConnectStart",u,we.setState),Oe("onClickConnectEnd",f,we.setState),Oe("nodesDraggable",p,we.setState),Oe("nodesConnectable",m,we.setState),Oe("nodesFocusable",E,we.setState),Oe("edgesFocusable",v,we.setState),Oe("edgesUpdatable",x,we.setState),Oe("elementsSelectable",T,we.setState),Oe("elevateNodesOnSelect",_,we.setState),Oe("snapToGrid",F,we.setState),Oe("snapGrid",L,we.setState),Oe("onNodesChange",O,we.setState),Oe("onEdgesChange",D,we.setState),Oe("connectOnClick",Q,we.setState),Oe("fitViewOnInit",ee,we.setState),Oe("fitViewOnInitOptions",ne,we.setState),Oe("onNodesDelete",W,we.setState),Oe("onEdgesDelete",I,we.setState),Oe("onNodeDrag",V,we.setState),Oe("onNodeDragStart",j,we.setState),Oe("onNodeDragStop",B,we.setState),Oe("onSelectionDrag",U,we.setState),Oe("onSelectionDragStart",$,we.setState),Oe("onSelectionDragStop",z,we.setState),Oe("noPanClassName",k,we.setState),Oe("nodeOrigin",Y,we.setState),Oe("rfId",re,we.setState),Oe("autoPanOnConnect",oe,we.setState),Oe("autoPanOnNodeDrag",le,we.setState),Oe("onError",de,we.setState),Oe("connectionRadius",he,we.setState),Oe("isValidConnection",ue,we.setState),Oe("nodeDragThreshold",me,we.setState),To(e,Re),To(t,Pe),To(w,wt),To(S,Be),To(K,Ue),To(N,ft),null},$h={display:"none"},fN={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Hh="react-flow__node-desc",Bh="react-flow__edge-desc",pN="react-flow__aria-live",hN=e=>e.ariaLiveMessage;function mN({rfId:e}){const t=Me(hN);return te.createElement("div",{id:`${pN}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:fN},t)}function gN({rfId:e,disableKeyboardA11y:t}){return te.createElement(te.Fragment,null,te.createElement("div",{id:`${Hh}-${e}`,style:$h},"Press enter or space to select a node.",!t&&"You can then use the arrow keys to move the node around."," Press delete to remove it and escape to cancel."," "),te.createElement("div",{id:`${Bh}-${e}`,style:$h},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!t&&te.createElement(mN,{rfId:e}))}var Oo=(e=null,t={actInsideInputWithModifier:!0})=>{const[r,s]=b.useState(!1),i=b.useRef(!1),a=b.useRef(new Set([])),[c,u]=b.useMemo(()=>{if(e!==null){const p=(Array.isArray(e)?e:[e]).filter(E=>typeof E=="string").map(E=>E.split("+")),m=p.reduce((E,v)=>E.concat(...v),[]);return[p,m]}return[[],[]]},[e]);return b.useEffect(()=>{const f=typeof document<"u"?document:null,p=t?.target||f;if(e!==null){const m=x=>{if(i.current=x.ctrlKey||x.metaKey||x.shiftKey,(!i.current||i.current&&!t.actInsideInputWithModifier)&&Kc(x))return!1;const w=Wh(x.code,u);a.current.add(x[w]),zh(c,a.current,!1)&&(x.preventDefault(),s(!0))},E=x=>{if((!i.current||i.current&&!t.actInsideInputWithModifier)&&Kc(x))return!1;const w=Wh(x.code,u);zh(c,a.current,!0)?(s(!1),a.current.clear()):a.current.delete(x[w]),x.key==="Meta"&&a.current.clear(),i.current=!1},v=()=>{a.current.clear(),s(!1)};return p?.addEventListener("keydown",m),p?.addEventListener("keyup",E),window.addEventListener("blur",v),()=>{p?.removeEventListener("keydown",m),p?.removeEventListener("keyup",E),window.removeEventListener("blur",v)}}},[e,s]),r};function zh(e,t,r){return e.filter(s=>r||s.length===t.size).some(s=>s.every(i=>t.has(i)))}function Wh(e,t){return t.includes(e)?"code":"key"}function Gh(e,t,r,s){if(!e.parentNode)return r;const i=t.get(e.parentNode),a=No(i,s);return Gh(i,t,{x:(r.x??0)+a.x,y:(r.y??0)+a.y,z:(i[nt]?.z??0)>(r.z??0)?i[nt]?.z??0:r.z??0},s)}function Yh(e,t,r){e.forEach(s=>{if(s.parentNode&&!e.has(s.parentNode))throw new Error(`Parent node ${s.parentNode} not found`);if(s.parentNode||r?.[s.id]){const{x:i,y:a,z:c}=Gh(s,e,{...s.position,z:s[nt]?.z??0},t);s.positionAbsolute={x:i,y:a},s[nt].z=c,r?.[s.id]&&(s[nt].isParent=!0)}})}function iu(e,t,r,s){const i=new Map,a={},c=s?1e3:0;return e.forEach(u=>{const f=(Yt(u.zIndex)?u.zIndex:0)+(u.selected?c:0),p=t.get(u.id),m={width:p?.width,height:p?.height,...u,positionAbsolute:{x:u.position.x,y:u.position.y}};u.parentNode&&(m.parentNode=u.parentNode,a[u.parentNode]=!0),Object.defineProperty(m,nt,{enumerable:!1,value:{handleBounds:p?.[nt]?.handleBounds,z:f}}),i.set(u.id,m)}),Yh(i,r,a),i}function Kh(e,t={}){const{getNodes:r,width:s,height:i,minZoom:a,maxZoom:c,d3Zoom:u,d3Selection:f,fitViewOnInitDone:p,fitViewOnInit:m,nodeOrigin:E}=e(),v=t.initial&&!p&&m;if(u&&f&&(v||!t.initial)){const _=r().filter(S=>{const N=t.includeHiddenNodes?S.width&&S.height:!S.hidden;return t.nodes?.length?N&&t.nodes.some(O=>O.id===S.id):N}),w=_.every(S=>S.width&&S.height);if(_.length>0&&w){const S=tu(_,E),{x:N,y:O,zoom:D}=Ch(S,s,i,t.minZoom??a,t.maxZoom??c,t.padding??.1),T=ir.translate(N,O).scale(D);return typeof t.duration=="number"&&t.duration>0?u.transform(Hr(f,t.duration),T):u.transform(f,T),!0}}return!1}function EN(e,t){return e.forEach(r=>{const s=t.get(r.id);s&&t.set(s.id,{...s,[nt]:s[nt],selected:r.selected})}),new Map(t)}function yN(e,t){return t.map(r=>{const s=e.find(i=>i.id===r.id);return s&&(r.selected=s.selected),r})}function gl({changedNodes:e,changedEdges:t,get:r,set:s}){const{nodeInternals:i,edges:a,onNodesChange:c,onEdgesChange:u,hasDefaultNodes:f,hasDefaultEdges:p}=r();e?.length&&(f&&s({nodeInternals:EN(e,i)}),c?.(e)),t?.length&&(p&&s({edges:yN(t,a)}),u?.(t))}const Co=()=>{},vN={zoomIn:Co,zoomOut:Co,zoomTo:Co,getZoom:()=>1,setViewport:Co,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:Co,fitBounds:Co,project:e=>e,screenToFlowPosition:e=>e,flowToScreenPosition:e=>e,viewportInitialized:!1},xN=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection}),SN=()=>{const e=tt(),{d3Zoom:t,d3Selection:r}=Me(xN,gt);return b.useMemo(()=>r&&t?{zoomIn:i=>t.scaleBy(Hr(r,i?.duration),1.2),zoomOut:i=>t.scaleBy(Hr(r,i?.duration),1/1.2),zoomTo:(i,a)=>t.scaleTo(Hr(r,a?.duration),i),getZoom:()=>e.getState().transform[2],setViewport:(i,a)=>{const[c,u,f]=e.getState().transform,p=ir.translate(i.x??c,i.y??u).scale(i.zoom??f);t.transform(Hr(r,a?.duration),p)},getViewport:()=>{const[i,a,c]=e.getState().transform;return{x:i,y:a,zoom:c}},fitView:i=>Kh(e.getState,i),setCenter:(i,a,c)=>{const{width:u,height:f,maxZoom:p}=e.getState(),m=typeof c?.zoom<"u"?c.zoom:p,E=u/2-i*m,v=f/2-a*m,x=ir.translate(E,v).scale(m);t.transform(Hr(r,c?.duration),x)},fitBounds:(i,a)=>{const{width:c,height:u,minZoom:f,maxZoom:p}=e.getState(),{x:m,y:E,zoom:v}=Ch(i,c,u,f,p,a?.padding??.1),x=ir.translate(m,E).scale(v);t.transform(Hr(r,a?.duration),x)},project:i=>{const{transform:a,snapToGrid:c,snapGrid:u}=e.getState();return console.warn("[DEPRECATED] `project` is deprecated. Instead use `screenToFlowPosition`. There is no need to subtract the react flow bounds anymore! https://reactflow.dev/api-reference/types/react-flow-instance#screen-to-flow-position"),eu(i,a,c,u)},screenToFlowPosition:i=>{const{transform:a,snapToGrid:c,snapGrid:u,domNode:f}=e.getState();if(!f)return i;const{x:p,y:m}=f.getBoundingClientRect(),E={x:i.x-p,y:i.y-m};return eu(E,a,c,u)},flowToScreenPosition:i=>{const{transform:a,domNode:c}=e.getState();if(!c)return i;const{x:u,y:f}=c.getBoundingClientRect(),p=Rh(i,a);return{x:p.x+u,y:p.y+f}},viewportInitialized:!0}:vN,[t,r])};function lu(){const e=SN(),t=tt(),r=b.useCallback(()=>t.getState().getNodes().map(w=>({...w})),[]),s=b.useCallback(w=>t.getState().nodeInternals.get(w),[]),i=b.useCallback(()=>{const{edges:w=[]}=t.getState();return w.map(S=>({...S}))},[]),a=b.useCallback(w=>{const{edges:S=[]}=t.getState();return S.find(N=>N.id===w)},[]),c=b.useCallback(w=>{const{getNodes:S,setNodes:N,hasDefaultNodes:O,onNodesChange:D}=t.getState(),T=S(),A=typeof w=="function"?w(T):w;if(O)N(A);else if(D){const L=A.length===0?T.map(F=>({type:"remove",id:F.id})):A.map(F=>({item:F,type:"reset"}));D(L)}},[]),u=b.useCallback(w=>{const{edges:S=[],setEdges:N,hasDefaultEdges:O,onEdgesChange:D}=t.getState(),T=typeof w=="function"?w(S):w;if(O)N(T);else if(D){const A=T.length===0?S.map(L=>({type:"remove",id:L.id})):T.map(L=>({item:L,type:"reset"}));D(A)}},[]),f=b.useCallback(w=>{const S=Array.isArray(w)?w:[w],{getNodes:N,setNodes:O,hasDefaultNodes:D,onNodesChange:T}=t.getState();if(D){const L=[...N(),...S];O(L)}else if(T){const A=S.map(L=>({item:L,type:"add"}));T(A)}},[]),p=b.useCallback(w=>{const S=Array.isArray(w)?w:[w],{edges:N=[],setEdges:O,hasDefaultEdges:D,onEdgesChange:T}=t.getState();if(D)O([...N,...S]);else if(T){const A=S.map(L=>({item:L,type:"add"}));T(A)}},[]),m=b.useCallback(()=>{const{getNodes:w,edges:S=[],transform:N}=t.getState(),[O,D,T]=N;return{nodes:w().map(A=>({...A})),edges:S.map(A=>({...A})),viewport:{x:O,y:D,zoom:T}}},[]),E=b.useCallback(({nodes:w,edges:S})=>{const{nodeInternals:N,getNodes:O,edges:D,hasDefaultNodes:T,hasDefaultEdges:A,onNodesDelete:L,onEdgesDelete:F,onNodesChange:K,onEdgesChange:Q}=t.getState(),X=(w||[]).map(V=>V.id),ee=(S||[]).map(V=>V.id),ne=O().reduce((V,j)=>{const B=!X.includes(j.id)&&j.parentNode&&V.find($=>$.id===j.parentNode);return(typeof j.deletable=="boolean"?j.deletable:!0)&&(X.includes(j.id)||B)&&V.push(j),V},[]),W=D.filter(V=>typeof V.deletable=="boolean"?V.deletable:!0),I=W.filter(V=>ee.includes(V.id));if(ne||I){const V=Oh(ne,W),j=[...I,...V],B=j.reduce((U,$)=>(U.includes($.id)||U.push($.id),U),[]);if((A||T)&&(A&&t.setState({edges:D.filter(U=>!B.includes(U.id))}),T&&(ne.forEach(U=>{N.delete(U.id)}),t.setState({nodeInternals:new Map(N)}))),B.length>0&&(F?.(j),Q&&Q(B.map(U=>({id:U,type:"remove"})))),ne.length>0&&(L?.(ne),K)){const U=ne.map($=>({id:$.id,type:"remove"}));K(U)}}},[]),v=b.useCallback(w=>{const S=Hw(w),N=S?null:t.getState().nodeInternals.get(w.id);return[S?w:fh(N),N,S]},[]),x=b.useCallback((w,S=!0,N)=>{const[O,D,T]=v(w);return O?(N||t.getState().getNodes()).filter(A=>{if(!T&&(A.id===D.id||!A.positionAbsolute))return!1;const L=fh(A),F=Yc(L,O);return S&&F>0||F>=O.width*O.height}):[]},[]),_=b.useCallback((w,S,N=!0)=>{const[O]=v(w);if(!O)return!1;const D=Yc(O,S);return N&&D>0||D>=O.width*O.height},[]);return b.useMemo(()=>({...e,getNodes:r,getNode:s,getEdges:i,getEdge:a,setNodes:c,setEdges:u,addNodes:f,addEdges:p,toObject:m,deleteElements:E,getIntersectingNodes:x,isNodeIntersecting:_}),[e,r,s,i,a,c,u,f,p,m,E,x,_])}const _N={actInsideInputWithModifier:!1};var wN=({deleteKeyCode:e,multiSelectionKeyCode:t})=>{const r=tt(),{deleteElements:s}=lu(),i=Oo(e,_N),a=Oo(t);b.useEffect(()=>{if(i){const{edges:c,getNodes:u}=r.getState(),f=u().filter(m=>m.selected),p=c.filter(m=>m.selected);s({nodes:f,edges:p}),r.setState({nodesSelectionActive:!1})}},[i]),b.useEffect(()=>{r.setState({multiSelectionActive:a})},[a])};function NN(e){const t=tt();b.useEffect(()=>{let r;const s=()=>{if(!e.current)return;const i=zc(e.current);(i.height===0||i.width===0)&&t.getState().onError?.("004",Vn.error004()),t.setState({width:i.width||500,height:i.height||500})};return s(),window.addEventListener("resize",s),e.current&&(r=new ResizeObserver(()=>s()),r.observe(e.current)),()=>{window.removeEventListener("resize",s),r&&e.current&&r.unobserve(e.current)}},[])}const au={position:"absolute",width:"100%",height:"100%",top:0,left:0},RN=(e,t)=>e.x!==t.x||e.y!==t.y||e.zoom!==t.k,El=e=>({x:e.x,y:e.y,zoom:e.k}),Ao=(e,t)=>e.target.closest(`.${t}`),Xh=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),Qh=e=>{const t=e.ctrlKey&&dl()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t},TN=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection,d3ZoomHandler:e.d3ZoomHandler,userSelectionActive:e.userSelectionActive}),ON=({onMove:e,onMoveStart:t,onMoveEnd:r,onPaneContextMenu:s,zoomOnScroll:i=!0,zoomOnPinch:a=!0,panOnScroll:c=!1,panOnScrollSpeed:u=.5,panOnScrollMode:f=$r.Free,zoomOnDoubleClick:p=!0,elementsSelectable:m,panOnDrag:E=!0,defaultViewport:v,translateExtent:x,minZoom:_,maxZoom:w,zoomActivationKeyCode:S,preventScrolling:N=!0,children:O,noWheelClassName:D,noPanClassName:T})=>{const A=b.useRef(),L=tt(),F=b.useRef(!1),K=b.useRef(!1),Q=b.useRef(null),X=b.useRef({x:0,y:0,zoom:0}),{d3Zoom:ee,d3Selection:ne,d3ZoomHandler:W,userSelectionActive:I}=Me(TN,gt),V=Oo(S),j=b.useRef(0),B=b.useRef(!1),U=b.useRef();return NN(Q),b.useEffect(()=>{if(Q.current){const $=Q.current.getBoundingClientRect(),z=kw().scaleExtent([_,w]).translateExtent(x),k=on(Q.current).call(z),Y=ir.translate(v.x,v.y).scale(_o(v.zoom,_,w)),re=[[0,0],[$.width,$.height]],oe=z.constrain()(Y,re,x);z.transform(k,oe),z.wheelDelta(Qh),L.setState({d3Zoom:z,d3Selection:k,d3ZoomHandler:k.on("wheel.zoom"),transform:[oe.x,oe.y,oe.k],domNode:Q.current.closest(".react-flow")})}},[]),b.useEffect(()=>{ne&&ee&&(c&&!V&&!I?ne.on("wheel.zoom",$=>{if(Ao($,D))return!1;$.preventDefault(),$.stopImmediatePropagation();const z=ne.property("__zoom").k||1,k=dl();if($.ctrlKey&&a&&k){const me=_n($),Re=Qh($),Pe=z*Math.pow(2,Re);ee.scaleTo(ne,Pe,me,$);return}const Y=$.deltaMode===1?20:1;let re=f===$r.Vertical?0:$.deltaX*Y,oe=f===$r.Horizontal?0:$.deltaY*Y;!k&&$.shiftKey&&f!==$r.Vertical&&(re=$.deltaY*Y,oe=0),ee.translateBy(ne,-(re/z)*u,-(oe/z)*u,{internal:!0});const le=El(ne.property("__zoom")),{onViewportChangeStart:de,onViewportChange:he,onViewportChangeEnd:ue}=L.getState();clearTimeout(U.current),B.current||(B.current=!0,t?.($,le),de?.(le)),B.current&&(e?.($,le),he?.(le),U.current=setTimeout(()=>{r?.($,le),ue?.(le),B.current=!1},150))},{passive:!1}):typeof W<"u"&&ne.on("wheel.zoom",function($,z){if(!N||Ao($,D))return null;$.preventDefault(),W.call(this,$,z)},{passive:!1}))},[I,c,f,ne,ee,W,V,a,N,D,t,e,r]),b.useEffect(()=>{ee&&ee.on("start",$=>{if(!$.sourceEvent||$.sourceEvent.internal)return null;j.current=$.sourceEvent?.button;const{onViewportChangeStart:z}=L.getState(),k=El($.transform);F.current=!0,X.current=k,$.sourceEvent?.type==="mousedown"&&L.setState({paneDragging:!0}),z?.(k),t?.($.sourceEvent,k)})},[ee,t]),b.useEffect(()=>{ee&&(I&&!F.current?ee.on("zoom",null):I||ee.on("zoom",$=>{const{onViewportChange:z}=L.getState();if(L.setState({transform:[$.transform.x,$.transform.y,$.transform.k]}),K.current=!!(s&&Xh(E,j.current??0)),(e||z)&&!$.sourceEvent?.internal){const k=El($.transform);z?.(k),e?.($.sourceEvent,k)}}))},[I,ee,e,E,s]),b.useEffect(()=>{ee&&ee.on("end",$=>{if(!$.sourceEvent||$.sourceEvent.internal)return null;const{onViewportChangeEnd:z}=L.getState();if(F.current=!1,L.setState({paneDragging:!1}),s&&Xh(E,j.current??0)&&!K.current&&s($.sourceEvent),K.current=!1,(r||z)&&RN(X.current,$.transform)){const k=El($.transform);X.current=k,clearTimeout(A.current),A.current=setTimeout(()=>{z?.(k),r?.($.sourceEvent,k)},c?150:0)}})},[ee,c,E,r,s]),b.useEffect(()=>{ee&&ee.filter($=>{const z=V||i,k=a&&$.ctrlKey;if((E===!0||Array.isArray(E)&&E.includes(1))&&$.button===1&&$.type==="mousedown"&&(Ao($,"react-flow__node")||Ao($,"react-flow__edge")))return!0;if(!E&&!z&&!c&&!p&&!a||I||!p&&$.type==="dblclick"||Ao($,D)&&$.type==="wheel"||Ao($,T)&&($.type!=="wheel"||c&&$.type==="wheel"&&!V)||!a&&$.ctrlKey&&$.type==="wheel"||!z&&!c&&!k&&$.type==="wheel"||!E&&($.type==="mousedown"||$.type==="touchstart")||Array.isArray(E)&&!E.includes($.button)&&($.type==="mousedown"||$.type==="touchstart"))return!1;const Y=Array.isArray(E)&&E.includes($.button)||!$.button||$.button<=1;return(!$.ctrlKey||$.type==="wheel")&&Y})},[I,ee,i,a,c,p,E,m,V]),te.createElement("div",{className:"react-flow__renderer",ref:Q,style:au},O)},CN=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function AN(){const{userSelectionActive:e,userSelectionRect:t}=Me(CN,gt);return e&&t?te.createElement("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}function qh(e,t){const r=e.find(s=>s.id===t.parentNode);if(r){const s=t.position.x+t.width-r.width,i=t.position.y+t.height-r.height;if(s>0||i>0||t.position.x<0||t.position.y<0){if(r.style={...r.style},r.style.width=r.style.width??r.width,r.style.height=r.style.height??r.height,s>0&&(r.style.width+=s),i>0&&(r.style.height+=i),t.position.x<0){const a=Math.abs(t.position.x);r.position.x=r.position.x-a,r.style.width+=a,t.position.x=0}if(t.position.y<0){const a=Math.abs(t.position.y);r.position.y=r.position.y-a,r.style.height+=a,t.position.y=0}r.width=r.style.width,r.height=r.style.height}}}function Zh(e,t){if(e.some(s=>s.type==="reset"))return e.filter(s=>s.type==="reset").map(s=>s.item);const r=e.filter(s=>s.type==="add").map(s=>s.item);return t.reduce((s,i)=>{const a=e.filter(u=>u.id===i.id);if(a.length===0)return s.push(i),s;const c={...i};for(const u of a)if(u)switch(u.type){case"select":{c.selected=u.selected;break}case"position":{typeof u.position<"u"&&(c.position=u.position),typeof u.positionAbsolute<"u"&&(c.positionAbsolute=u.positionAbsolute),typeof u.dragging<"u"&&(c.dragging=u.dragging),c.expandParent&&qh(s,c);break}case"dimensions":{typeof u.dimensions<"u"&&(c.width=u.dimensions.width,c.height=u.dimensions.height),typeof u.updateStyle<"u"&&(c.style={...c.style||{},...u.dimensions}),typeof u.resizing=="boolean"&&(c.resizing=u.resizing),c.expandParent&&qh(s,c);break}case"remove":return s}return s.push(c),s},r)}function Jh(e,t){return Zh(e,t)}function IN(e,t){return Zh(e,t)}const ur=(e,t)=>({id:e,type:"select",selected:t});function Io(e,t){return e.reduce((r,s)=>{const i=t.includes(s.id);return!s.selected&&i?(s.selected=!0,r.push(ur(s.id,!0))):s.selected&&!i&&(s.selected=!1,r.push(ur(s.id,!1))),r},[])}const cu=(e,t)=>r=>{r.target===t.current&&e?.(r)},bN=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging}),em=b.memo(({isSelecting:e,selectionMode:t=Ms.Full,panOnDrag:r,onSelectionStart:s,onSelectionEnd:i,onPaneClick:a,onPaneContextMenu:c,onPaneScroll:u,onPaneMouseEnter:f,onPaneMouseMove:p,onPaneMouseLeave:m,children:E})=>{const v=b.useRef(null),x=tt(),_=b.useRef(0),w=b.useRef(0),S=b.useRef(),{userSelectionActive:N,elementsSelectable:O,dragging:D}=Me(bN,gt),T=()=>{x.setState({userSelectionActive:!1,userSelectionRect:null}),_.current=0,w.current=0},A=W=>{a?.(W),x.getState().resetSelectedElements(),x.setState({nodesSelectionActive:!1})},L=W=>{if(Array.isArray(r)&&r?.includes(2)){W.preventDefault();return}c?.(W)},F=u?W=>u(W):void 0,K=W=>{const{resetSelectedElements:I,domNode:V}=x.getState();if(S.current=V?.getBoundingClientRect(),!O||!e||W.button!==0||W.target!==v.current||!S.current)return;const{x:j,y:B}=lr(W,S.current);I(),x.setState({userSelectionRect:{width:0,height:0,startX:j,startY:B,x:j,y:B}}),s?.(W)},Q=W=>{const{userSelectionRect:I,nodeInternals:V,edges:j,transform:B,onNodesChange:U,onEdgesChange:$,nodeOrigin:z,getNodes:k}=x.getState();if(!e||!S.current||!I)return;x.setState({userSelectionActive:!0,nodesSelectionActive:!1});const Y=lr(W,S.current),re=I.startX??0,oe=I.startY??0,le={...I,x:Y.x<re?Y.x:re,y:Y.y<oe?Y.y:oe,width:Math.abs(Y.x-re),height:Math.abs(Y.y-oe)},de=k(),he=Th(V,le,B,t===Ms.Partial,!0,z),ue=Oh(he,j).map(Re=>Re.id),me=he.map(Re=>Re.id);if(_.current!==me.length){_.current=me.length;const Re=Io(de,me);Re.length&&U?.(Re)}if(w.current!==ue.length){w.current=ue.length;const Re=Io(j,ue);Re.length&&$?.(Re)}x.setState({userSelectionRect:le})},X=W=>{if(W.button!==0)return;const{userSelectionRect:I}=x.getState();!N&&I&&W.target===v.current&&A?.(W),x.setState({nodesSelectionActive:_.current>0}),T(),i?.(W)},ee=W=>{N&&(x.setState({nodesSelectionActive:_.current>0}),i?.(W)),T()},ne=O&&(e||N);return te.createElement("div",{className:St(["react-flow__pane",{dragging:D,selection:e}]),onClick:ne?void 0:cu(A,v),onContextMenu:cu(L,v),onWheel:cu(F,v),onMouseEnter:ne?void 0:f,onMouseDown:ne?K:void 0,onMouseMove:ne?Q:p,onMouseUp:ne?X:void 0,onMouseLeave:ne?ee:m,ref:v,style:au},E,te.createElement(AN,null))});em.displayName="Pane";function tm(e,t){if(!e.parentNode)return!1;const r=t.get(e.parentNode);return r?r.selected?!0:tm(r,t):!1}function nm(e,t,r){let s=e;do{if(s?.matches(t))return!0;if(s===r.current)return!1;s=s.parentElement}while(s);return!1}function LN(e,t,r,s){return Array.from(e.values()).filter(i=>(i.selected||i.id===s)&&(!i.parentNode||!tm(i,e))&&(i.draggable||t&&typeof i.draggable>"u")).map(i=>({id:i.id,position:i.position||{x:0,y:0},positionAbsolute:i.positionAbsolute||{x:0,y:0},distance:{x:r.x-(i.positionAbsolute?.x??0),y:r.y-(i.positionAbsolute?.y??0)},delta:{x:0,y:0},extent:i.extent,parentNode:i.parentNode,width:i.width,height:i.height,expandParent:i.expandParent}))}function DN(e,t){return!t||t==="parent"?t:[t[0],[t[1][0]-(e.width||0),t[1][1]-(e.height||0)]]}function rm(e,t,r,s,i=[0,0],a){const c=DN(e,e.extent||s);let u=c;if(e.extent==="parent"&&!e.expandParent)if(e.parentNode&&e.width&&e.height){const m=r.get(e.parentNode),{x:E,y:v}=No(m,i).positionAbsolute;u=m&&Yt(E)&&Yt(v)&&Yt(m.width)&&Yt(m.height)?[[E+e.width*i[0],v+e.height*i[1]],[E+m.width-e.width+e.width*i[0],v+m.height-e.height+e.height*i[1]]]:u}else a?.("005",Vn.error005()),u=c;else if(e.extent&&e.parentNode&&e.extent!=="parent"){const m=r.get(e.parentNode),{x:E,y:v}=No(m,i).positionAbsolute;u=[[e.extent[0][0]+E,e.extent[0][1]+v],[e.extent[1][0]+E,e.extent[1][1]+v]]}let f={x:0,y:0};if(e.parentNode){const m=r.get(e.parentNode);f=No(m,i).positionAbsolute}const p=u&&u!=="parent"?Wc(t,u):t;return{position:{x:p.x-f.x,y:p.y-f.y},positionAbsolute:p}}function uu({nodeId:e,dragItems:t,nodeInternals:r}){const s=t.map(i=>({...r.get(i.id),position:i.position,positionAbsolute:i.positionAbsolute}));return[e?s.find(i=>i.id===e):s[0],s]}const om=(e,t,r,s)=>{const i=t.querySelectorAll(e);if(!i||!i.length)return null;const a=Array.from(i),c=t.getBoundingClientRect(),u={x:c.width*s[0],y:c.height*s[1]};return a.map(f=>{const p=f.getBoundingClientRect();return{id:f.getAttribute("data-handleid"),position:f.getAttribute("data-handlepos"),x:(p.left-c.left-u.x)/r,y:(p.top-c.top-u.y)/r,...zc(f)}})};function Fs(e,t,r){return r===void 0?r:s=>{const i=t().nodeInternals.get(e);i&&r(s,{...i})}}function du({id:e,store:t,unselect:r=!1,nodeRef:s}){const{addSelectedNodes:i,unselectNodesAndEdges:a,multiSelectionActive:c,nodeInternals:u,onError:f}=t.getState(),p=u.get(e);if(!p){f?.("012",Vn.error012(e));return}t.setState({nodesSelectionActive:!1}),p.selected?(r||p.selected&&c)&&(a({nodes:[p],edges:[]}),requestAnimationFrame(()=>s?.current?.blur())):i([e])}function kN(){const e=tt();return b.useCallback(({sourceEvent:r})=>{const{transform:s,snapGrid:i,snapToGrid:a}=e.getState(),c=r.touches?r.touches[0].clientX:r.clientX,u=r.touches?r.touches[0].clientY:r.clientY,f={x:(c-s[0])/s[2],y:(u-s[1])/s[2]};return{xSnapped:a?i[0]*Math.round(f.x/i[0]):f.x,ySnapped:a?i[1]*Math.round(f.y/i[1]):f.y,...f}},[])}function fu(e){return(t,r,s)=>e?.(t,s)}function sm({nodeRef:e,disabled:t=!1,noDragClassName:r,handleSelector:s,nodeId:i,isSelectable:a,selectNodesOnDrag:c}){const u=tt(),[f,p]=b.useState(!1),m=b.useRef([]),E=b.useRef({x:null,y:null}),v=b.useRef(0),x=b.useRef(null),_=b.useRef({x:0,y:0}),w=b.useRef(null),S=b.useRef(!1),N=b.useRef(!1),O=kN();return b.useEffect(()=>{if(e?.current){const D=on(e.current),T=({x:F,y:K})=>{const{nodeInternals:Q,onNodeDrag:X,onSelectionDrag:ee,updateNodePositions:ne,nodeExtent:W,snapGrid:I,snapToGrid:V,nodeOrigin:j,onError:B}=u.getState();E.current={x:F,y:K};let U=!1,$={x:0,y:0,x2:0,y2:0};if(m.current.length>1&&W){const k=tu(m.current,j);$=Gc(k)}if(m.current=m.current.map(k=>{const Y={x:F-k.distance.x,y:K-k.distance.y};V&&(Y.x=I[0]*Math.round(Y.x/I[0]),Y.y=I[1]*Math.round(Y.y/I[1]));const re=[[W[0][0],W[0][1]],[W[1][0],W[1][1]]];m.current.length>1&&W&&!k.extent&&(re[0][0]=k.positionAbsolute.x-$.x+W[0][0],re[1][0]=k.positionAbsolute.x+(k.width??0)-$.x2+W[1][0],re[0][1]=k.positionAbsolute.y-$.y+W[0][1],re[1][1]=k.positionAbsolute.y+(k.height??0)-$.y2+W[1][1]);const oe=rm(k,Y,Q,re,j,B);return U=U||k.position.x!==oe.position.x||k.position.y!==oe.position.y,k.position=oe.position,k.positionAbsolute=oe.positionAbsolute,k}),!U)return;ne(m.current,!0,!0),p(!0);const z=i?X:fu(ee);if(z&&w.current){const[k,Y]=uu({nodeId:i,dragItems:m.current,nodeInternals:Q});z(w.current,k,Y)}},A=()=>{if(!x.current)return;const[F,K]=uh(_.current,x.current);if(F!==0||K!==0){const{transform:Q,panBy:X}=u.getState();E.current.x=(E.current.x??0)-F/Q[2],E.current.y=(E.current.y??0)-K/Q[2],X({x:F,y:K})&&T(E.current)}v.current=requestAnimationFrame(A)},L=F=>{const{nodeInternals:K,multiSelectionActive:Q,nodesDraggable:X,unselectNodesAndEdges:ee,onNodeDragStart:ne,onSelectionDragStart:W}=u.getState();N.current=!0;const I=i?ne:fu(W);(!c||!a)&&!Q&&i&&(K.get(i)?.selected||ee()),i&&a&&c&&du({id:i,store:u,nodeRef:e});const V=O(F);if(E.current=V,m.current=LN(K,X,V,i),I&&m.current){const[j,B]=uu({nodeId:i,dragItems:m.current,nodeInternals:K});I(F.sourceEvent,j,B)}};if(t)D.on(".drag",null);else{const F=zS().on("start",K=>{const{domNode:Q,nodeDragThreshold:X}=u.getState();X===0&&L(K);const ee=O(K);E.current=ee,x.current=Q?.getBoundingClientRect()||null,_.current=lr(K.sourceEvent,x.current)}).on("drag",K=>{const Q=O(K),{autoPanOnNodeDrag:X,nodeDragThreshold:ee}=u.getState();if(!S.current&&N.current&&X&&(S.current=!0,A()),!N.current){const ne=Q.xSnapped-(E?.current?.x??0),W=Q.ySnapped-(E?.current?.y??0);Math.sqrt(ne*ne+W*W)>ee&&L(K)}(E.current.x!==Q.xSnapped||E.current.y!==Q.ySnapped)&&m.current&&N.current&&(w.current=K.sourceEvent,_.current=lr(K.sourceEvent,x.current),T(Q))}).on("end",K=>{if(N.current&&(p(!1),S.current=!1,N.current=!1,cancelAnimationFrame(v.current),m.current)){const{updateNodePositions:Q,nodeInternals:X,onNodeDragStop:ee,onSelectionDragStop:ne}=u.getState(),W=i?ee:fu(ne);if(Q(m.current,!1,!1),W){const[I,V]=uu({nodeId:i,dragItems:m.current,nodeInternals:X});W(K.sourceEvent,I,V)}}}).filter(K=>{const Q=K.target;return!K.button&&(!r||!nm(Q,`.${r}`,e))&&(!s||nm(Q,s,e))});return D.call(F),()=>{D.on(".drag",null)}}}},[e,t,r,s,a,u,i,c,O]),f}function im(){const e=tt();return b.useCallback(r=>{const{nodeInternals:s,nodeExtent:i,updateNodePositions:a,getNodes:c,snapToGrid:u,snapGrid:f,onError:p,nodesDraggable:m}=e.getState(),E=c().filter(O=>O.selected&&(O.draggable||m&&typeof O.draggable>"u")),v=u?f[0]:5,x=u?f[1]:5,_=r.isShiftPressed?4:1,w=r.x*v*_,S=r.y*x*_,N=E.map(O=>{if(O.positionAbsolute){const D={x:O.positionAbsolute.x+w,y:O.positionAbsolute.y+S};u&&(D.x=f[0]*Math.round(D.x/f[0]),D.y=f[1]*Math.round(D.y/f[1]));const{positionAbsolute:T,position:A}=rm(O,D,s,i,void 0,p);O.position=A,O.positionAbsolute=T}return O});a(N,!0,!1)},[])}const bo={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var js=e=>{const t=({id:r,type:s,data:i,xPos:a,yPos:c,xPosOrigin:u,yPosOrigin:f,selected:p,onClick:m,onMouseEnter:E,onMouseMove:v,onMouseLeave:x,onContextMenu:_,onDoubleClick:w,style:S,className:N,isDraggable:O,isSelectable:D,isConnectable:T,isFocusable:A,selectNodesOnDrag:L,sourcePosition:F,targetPosition:K,hidden:Q,resizeObserver:X,dragHandle:ee,zIndex:ne,isParent:W,noDragClassName:I,noPanClassName:V,initialized:j,disableKeyboardA11y:B,ariaLabel:U,rfId:$})=>{const z=tt(),k=b.useRef(null),Y=b.useRef(F),re=b.useRef(K),oe=b.useRef(s),le=D||O||m||E||v||x,de=im(),he=Fs(r,z.getState,E),ue=Fs(r,z.getState,v),me=Fs(r,z.getState,x),Re=Fs(r,z.getState,_),Pe=Fs(r,z.getState,w),Je=Ue=>{const{nodeDragThreshold:ft}=z.getState();if(D&&(!L||!O||ft>0)&&du({id:r,store:z,nodeRef:k}),m){const pt=z.getState().nodeInternals.get(r);pt&&m(Ue,{...pt})}},wt=Ue=>{if(!Kc(Ue))if(ph.includes(Ue.key)&&D){const ft=Ue.key==="Escape";du({id:r,store:z,unselect:ft,nodeRef:k})}else!B&&O&&p&&Object.prototype.hasOwnProperty.call(bo,Ue.key)&&(z.setState({ariaLiveMessage:`Moved selected node ${Ue.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~a}, y: ${~~c}`}),de({x:bo[Ue.key].x,y:bo[Ue.key].y,isShiftPressed:Ue.shiftKey}))};b.useEffect(()=>{if(k.current&&!Q){const Ue=k.current;return X?.observe(Ue),()=>X?.unobserve(Ue)}},[Q]),b.useEffect(()=>{const Ue=oe.current!==s,ft=Y.current!==F,pt=re.current!==K;k.current&&(Ue||ft||pt)&&(Ue&&(oe.current=s),ft&&(Y.current=F),pt&&(re.current=K),z.getState().updateNodeDimensions([{id:r,nodeElement:k.current,forceUpdate:!0}]))},[r,s,F,K]);const Be=sm({nodeRef:k,disabled:Q||!O,noDragClassName:I,handleSelector:ee,nodeId:r,isSelectable:D,selectNodesOnDrag:L});return Q?null:te.createElement("div",{className:St(["react-flow__node",`react-flow__node-${s}`,{[V]:O},N,{selected:p,selectable:D,parent:W,dragging:Be}]),ref:k,style:{zIndex:ne,transform:`translate(${u}px,${f}px)`,pointerEvents:le?"all":"none",visibility:j?"visible":"hidden",...S},"data-id":r,"data-testid":`rf__node-${r}`,onMouseEnter:he,onMouseMove:ue,onMouseLeave:me,onContextMenu:Re,onClick:Je,onDoubleClick:Pe,onKeyDown:A?wt:void 0,tabIndex:A?0:void 0,role:A?"button":void 0,"aria-describedby":B?void 0:`${Hh}-${$}`,"aria-label":U},te.createElement(Xw,{value:r},te.createElement(e,{id:r,data:i,type:s,xPos:a,yPos:c,selected:p,isConnectable:T,sourcePosition:F,targetPosition:K,dragging:Be,dragHandle:ee,zIndex:ne})))};return t.displayName="NodeWrapper",b.memo(t)};const MN=e=>{const t=e.getNodes().filter(r=>r.selected);return{...tu(t,e.nodeOrigin),transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`,userSelectionActive:e.userSelectionActive}};function PN({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:r}){const s=tt(),{width:i,height:a,x:c,y:u,transformString:f,userSelectionActive:p}=Me(MN,gt),m=im(),E=b.useRef(null);if(b.useEffect(()=>{r||E.current?.focus({preventScroll:!0})},[r]),sm({nodeRef:E}),p||!i||!a)return null;const v=e?_=>{const w=s.getState().getNodes().filter(S=>S.selected);e(_,w)}:void 0,x=_=>{Object.prototype.hasOwnProperty.call(bo,_.key)&&m({x:bo[_.key].x,y:bo[_.key].y,isShiftPressed:_.shiftKey})};return te.createElement("div",{className:St(["react-flow__nodesselection","react-flow__container",t]),style:{transform:f}},te.createElement("div",{ref:E,className:"react-flow__nodesselection-rect",onContextMenu:v,tabIndex:r?void 0:-1,onKeyDown:r?void 0:x,style:{width:i,height:a,top:u,left:c}}))}var UN=b.memo(PN);const FN=e=>e.nodesSelectionActive,lm=({children:e,onPaneClick:t,onPaneMouseEnter:r,onPaneMouseMove:s,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:c,deleteKeyCode:u,onMove:f,onMoveStart:p,onMoveEnd:m,selectionKeyCode:E,selectionOnDrag:v,selectionMode:x,onSelectionStart:_,onSelectionEnd:w,multiSelectionKeyCode:S,panActivationKeyCode:N,zoomActivationKeyCode:O,elementsSelectable:D,zoomOnScroll:T,zoomOnPinch:A,panOnScroll:L,panOnScrollSpeed:F,panOnScrollMode:K,zoomOnDoubleClick:Q,panOnDrag:X,defaultViewport:ee,translateExtent:ne,minZoom:W,maxZoom:I,preventScrolling:V,onSelectionContextMenu:j,noWheelClassName:B,noPanClassName:U,disableKeyboardA11y:$})=>{const z=Me(FN),k=Oo(E),Y=Oo(N),re=Y||X,oe=Y||L,le=k||v&&re!==!0;return wN({deleteKeyCode:u,multiSelectionKeyCode:S}),te.createElement(ON,{onMove:f,onMoveStart:p,onMoveEnd:m,onPaneContextMenu:a,elementsSelectable:D,zoomOnScroll:T,zoomOnPinch:A,panOnScroll:oe,panOnScrollSpeed:F,panOnScrollMode:K,zoomOnDoubleClick:Q,panOnDrag:!k&&re,defaultViewport:ee,translateExtent:ne,minZoom:W,maxZoom:I,zoomActivationKeyCode:O,preventScrolling:V,noWheelClassName:B,noPanClassName:U},te.createElement(em,{onSelectionStart:_,onSelectionEnd:w,onPaneClick:t,onPaneMouseEnter:r,onPaneMouseMove:s,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:c,panOnDrag:re,isSelecting:!!le,selectionMode:x},e,z&&te.createElement(UN,{onSelectionContextMenu:j,noPanClassName:U,disableKeyboardA11y:$})))};lm.displayName="FlowRenderer";var jN=b.memo(lm);function VN(e){return Me(b.useCallback(r=>e?Th(r.nodeInternals,{x:0,y:0,width:r.width,height:r.height},r.transform,!0):r.getNodes(),[e]))}function $N(e){const t={input:js(e.input||Uh),default:js(e.default||ou),output:js(e.output||jh),group:js(e.group||su)},r={},s=Object.keys(e).filter(i=>!["input","default","output","group"].includes(i)).reduce((i,a)=>(i[a]=js(e[a]||ou),i),r);return{...t,...s}}const HN=({x:e,y:t,width:r,height:s,origin:i})=>!r||!s?{x:e,y:t}:i[0]<0||i[1]<0||i[0]>1||i[1]>1?{x:e,y:t}:{x:e-r*i[0],y:t-s*i[1]},BN=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,updateNodeDimensions:e.updateNodeDimensions,onError:e.onError}),am=e=>{const{nodesDraggable:t,nodesConnectable:r,nodesFocusable:s,elementsSelectable:i,updateNodeDimensions:a,onError:c}=Me(BN,gt),u=VN(e.onlyRenderVisibleElements),f=b.useRef(),p=b.useMemo(()=>{if(typeof ResizeObserver>"u")return null;const m=new ResizeObserver(E=>{const v=E.map(x=>({id:x.target.getAttribute("data-id"),nodeElement:x.target,forceUpdate:!0}));a(v)});return f.current=m,m},[]);return b.useEffect(()=>()=>{f?.current?.disconnect()},[]),te.createElement("div",{className:"react-flow__nodes",style:au},u.map(m=>{let E=m.type||"default";e.nodeTypes[E]||(c?.("003",Vn.error003(E)),E="default");const v=e.nodeTypes[E]||e.nodeTypes.default,x=!!(m.draggable||t&&typeof m.draggable>"u"),_=!!(m.selectable||i&&typeof m.selectable>"u"),w=!!(m.connectable||r&&typeof m.connectable>"u"),S=!!(m.focusable||s&&typeof m.focusable>"u"),N=e.nodeExtent?Wc(m.positionAbsolute,e.nodeExtent):m.positionAbsolute,O=N?.x??0,D=N?.y??0,T=HN({x:O,y:D,width:m.width??0,height:m.height??0,origin:e.nodeOrigin});return te.createElement(v,{key:m.id,id:m.id,className:m.className,style:m.style,type:E,data:m.data,sourcePosition:m.sourcePosition||xe.Bottom,targetPosition:m.targetPosition||xe.Top,hidden:m.hidden,xPos:O,yPos:D,xPosOrigin:T.x,yPosOrigin:T.y,selectNodesOnDrag:e.selectNodesOnDrag,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,selected:!!m.selected,isDraggable:x,isSelectable:_,isConnectable:w,isFocusable:S,resizeObserver:p,dragHandle:m.dragHandle,zIndex:m[nt]?.z??0,isParent:!!m[nt]?.isParent,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,initialized:!!m.width&&!!m.height,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,ariaLabel:m.ariaLabel})}))};am.displayName="NodeRenderer";var zN=b.memo(am);const WN=(e,t,r)=>r===xe.Left?e-t:r===xe.Right?e+t:e,GN=(e,t,r)=>r===xe.Top?e-t:r===xe.Bottom?e+t:e,cm="react-flow__edgeupdater",um=({position:e,centerX:t,centerY:r,radius:s=10,onMouseDown:i,onMouseEnter:a,onMouseOut:c,type:u})=>te.createElement("circle",{onMouseDown:i,onMouseEnter:a,onMouseOut:c,className:St([cm,`${cm}-${u}`]),cx:WN(t,s,e),cy:GN(r,s,e),r:s,stroke:"transparent",fill:"transparent"}),YN=()=>!0;var Lo=e=>{const t=({id:r,className:s,type:i,data:a,onClick:c,onEdgeDoubleClick:u,selected:f,animated:p,label:m,labelStyle:E,labelShowBg:v,labelBgStyle:x,labelBgPadding:_,labelBgBorderRadius:w,style:S,source:N,target:O,sourceX:D,sourceY:T,targetX:A,targetY:L,sourcePosition:F,targetPosition:K,elementsSelectable:Q,hidden:X,sourceHandleId:ee,targetHandleId:ne,onContextMenu:W,onMouseEnter:I,onMouseMove:V,onMouseLeave:j,edgeUpdaterRadius:B,onEdgeUpdate:U,onEdgeUpdateStart:$,onEdgeUpdateEnd:z,markerEnd:k,markerStart:Y,rfId:re,ariaLabel:oe,isFocusable:le,isUpdatable:de,pathOptions:he,interactionWidth:ue})=>{const me=b.useRef(null),[Re,Pe]=b.useState(!1),[Je,wt]=b.useState(!1),Be=tt(),Ue=b.useMemo(()=>`url(#${Jc(Y,re)})`,[Y,re]),ft=b.useMemo(()=>`url(#${Jc(k,re)})`,[k,re]);if(X)return null;const pt=Ke=>{const{edges:it,addSelectedEdges:Gn,unselectNodesAndEdges:bn,multiSelectionActive:Yn}=Be.getState(),qt=it.find(hn=>hn.id===r);qt&&(Q&&(Be.setState({nodesSelectionActive:!1}),qt.selected&&Yn?(bn({nodes:[],edges:[qt]}),me.current?.blur()):Gn([r])),c&&c(Ke,qt))},we=ks(r,Be.getState,u),un=ks(r,Be.getState,W),Ht=ks(r,Be.getState,I),Qt=ks(r,Be.getState,V),Cn=ks(r,Be.getState,j),An=(Ke,it)=>{if(Ke.button!==0)return;const{edges:Gn,isValidConnection:bn}=Be.getState(),Yn=it?O:N,qt=(it?ne:ee)||null,hn=it?"target":"source",Qr=bn||YN,qr=it,Kn=Gn.find(Lt=>Lt.id===r);wt(!0),$?.(Ke,Kn,hn);const Zr=Lt=>{wt(!1),z?.(Lt,Kn,hn)};Lh({event:Ke,handleId:qt,nodeId:Yn,onConnect:Lt=>U?.(Kn,Lt),isTarget:qr,getState:Be.getState,setState:Be.setState,isValidConnection:Qr,edgeUpdaterType:hn,onEdgeUpdateEnd:Zr})},dn=Ke=>An(Ke,!0),zn=Ke=>An(Ke,!1),fn=()=>Pe(!0),pn=()=>Pe(!1),In=!Q&&!c,Wn=Ke=>{if(ph.includes(Ke.key)&&Q){const{unselectNodesAndEdges:it,addSelectedEdges:Gn,edges:bn}=Be.getState();Ke.key==="Escape"?(me.current?.blur(),it({edges:[bn.find(qt=>qt.id===r)]})):Gn([r])}};return te.createElement("g",{className:St(["react-flow__edge",`react-flow__edge-${i}`,s,{selected:f,animated:p,inactive:In,updating:Re}]),onClick:pt,onDoubleClick:we,onContextMenu:un,onMouseEnter:Ht,onMouseMove:Qt,onMouseLeave:Cn,onKeyDown:le?Wn:void 0,tabIndex:le?0:void 0,role:le?"button":"img","data-testid":`rf__edge-${r}`,"aria-label":oe===null?void 0:oe||`Edge from ${N} to ${O}`,"aria-describedby":le?`${Bh}-${re}`:void 0,ref:me},!Je&&te.createElement(e,{id:r,source:N,target:O,selected:f,animated:p,label:m,labelStyle:E,labelShowBg:v,labelBgStyle:x,labelBgPadding:_,labelBgBorderRadius:w,data:a,style:S,sourceX:D,sourceY:T,targetX:A,targetY:L,sourcePosition:F,targetPosition:K,sourceHandleId:ee,targetHandleId:ne,markerStart:Ue,markerEnd:ft,pathOptions:he,interactionWidth:ue}),de&&te.createElement(te.Fragment,null,(de==="source"||de===!0)&&te.createElement(um,{position:F,centerX:D,centerY:T,radius:B,onMouseDown:dn,onMouseEnter:fn,onMouseOut:pn,type:"source"}),(de==="target"||de===!0)&&te.createElement(um,{position:K,centerX:A,centerY:L,radius:B,onMouseDown:zn,onMouseEnter:fn,onMouseOut:pn,type:"target"})))};return t.displayName="EdgeWrapper",b.memo(t)};function KN(e){const t={default:Lo(e.default||hl),straight:Lo(e.bezier||qc),step:Lo(e.step||Qc),smoothstep:Lo(e.step||fl),simplebezier:Lo(e.simplebezier||Xc)},r={},s=Object.keys(e).filter(i=>!["default","bezier"].includes(i)).reduce((i,a)=>(i[a]=Lo(e[a]||hl),i),r);return{...t,...s}}function dm(e,t,r=null){const s=(r?.x||0)+t.x,i=(r?.y||0)+t.y,a=r?.width||t.width,c=r?.height||t.height;switch(e){case xe.Top:return{x:s+a/2,y:i};case xe.Right:return{x:s+a,y:i+c/2};case xe.Bottom:return{x:s+a/2,y:i+c};case xe.Left:return{x:s,y:i+c/2}}}function fm(e,t){return e?e.length===1||!t?e[0]:t&&e.find(r=>r.id===t)||null:null}const XN=(e,t,r,s,i,a)=>{const c=dm(r,e,t),u=dm(a,s,i);return{sourceX:c.x,sourceY:c.y,targetX:u.x,targetY:u.y}};function QN({sourcePos:e,targetPos:t,sourceWidth:r,sourceHeight:s,targetWidth:i,targetHeight:a,width:c,height:u,transform:f}){const p={x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x+r,t.x+i),y2:Math.max(e.y+s,t.y+a)};p.x===p.x2&&(p.x2+=1),p.y===p.y2&&(p.y2+=1);const m=Gc({x:(0-f[0])/f[2],y:(0-f[1])/f[2],width:c/f[2],height:u/f[2]}),E=Math.max(0,Math.min(m.x2,p.x2)-Math.max(m.x,p.x)),v=Math.max(0,Math.min(m.y2,p.y2)-Math.max(m.y,p.y));return Math.ceil(E*v)>0}function pm(e){const t=e?.[nt]?.handleBounds||null,r=t&&e?.width&&e?.height&&typeof e?.positionAbsolute?.x<"u"&&typeof e?.positionAbsolute?.y<"u";return[{x:e?.positionAbsolute?.x||0,y:e?.positionAbsolute?.y||0,width:e?.width||0,height:e?.height||0},t,!!r]}const qN=[{level:0,isMaxLevel:!0,edges:[]}];function ZN(e,t,r=!1){let s=-1;const i=e.reduce((c,u)=>{const f=Yt(u.zIndex);let p=f?u.zIndex:0;if(r){const m=t.get(u.target),E=t.get(u.source),v=u.selected||m?.selected||E?.selected,x=Math.max(E?.[nt]?.z||0,m?.[nt]?.z||0,1e3);p=(f?u.zIndex:0)+(v?x:0)}return c[p]?c[p].push(u):c[p]=[u],s=p>s?p:s,c},{}),a=Object.entries(i).map(([c,u])=>{const f=+c;return{edges:u,level:f,isMaxLevel:f===s}});return a.length===0?qN:a}function JN(e,t,r){const s=Me(b.useCallback(i=>e?i.edges.filter(a=>{const c=t.get(a.source),u=t.get(a.target);return c?.width&&c?.height&&u?.width&&u?.height&&QN({sourcePos:c.positionAbsolute||{x:0,y:0},targetPos:u.positionAbsolute||{x:0,y:0},sourceWidth:c.width,sourceHeight:c.height,targetWidth:u.width,targetHeight:u.height,width:i.width,height:i.height,transform:i.transform})}):i.edges,[e,t]));return ZN(s,t,r)}const eR=({color:e="none",strokeWidth:t=1})=>te.createElement("polyline",{style:{stroke:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),tR=({color:e="none",strokeWidth:t=1})=>te.createElement("polyline",{style:{stroke:e,fill:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"}),hm={[Ps.Arrow]:eR,[Ps.ArrowClosed]:tR};function nR(e){const t=tt();return b.useMemo(()=>Object.prototype.hasOwnProperty.call(hm,e)?hm[e]:(t.getState().onError?.("009",Vn.error009(e)),null),[e])}const rR=({id:e,type:t,color:r,width:s=12.5,height:i=12.5,markerUnits:a="strokeWidth",strokeWidth:c,orient:u="auto-start-reverse"})=>{const f=nR(t);return f?te.createElement("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${s}`,markerHeight:`${i}`,viewBox:"-10 -10 20 20",markerUnits:a,orient:u,refX:"0",refY:"0"},te.createElement(f,{color:r,strokeWidth:c})):null},oR=({defaultColor:e,rfId:t})=>r=>{const s=[];return r.edges.reduce((i,a)=>([a.markerStart,a.markerEnd].forEach(c=>{if(c&&typeof c=="object"){const u=Jc(c,t);s.includes(u)||(i.push({id:u,color:c.color||e,...c}),s.push(u))}}),i),[]).sort((i,a)=>i.id.localeCompare(a.id))},mm=({defaultColor:e,rfId:t})=>{const r=Me(b.useCallback(oR({defaultColor:e,rfId:t}),[e,t]),(s,i)=>!(s.length!==i.length||s.some((a,c)=>a.id!==i[c].id)));return te.createElement("defs",null,r.map(s=>te.createElement(rR,{id:s.id,key:s.id,type:s.type,color:s.color,width:s.width,height:s.height,markerUnits:s.markerUnits,strokeWidth:s.strokeWidth,orient:s.orient})))};mm.displayName="MarkerDefinitions";var sR=b.memo(mm);const iR=e=>({nodesConnectable:e.nodesConnectable,edgesFocusable:e.edgesFocusable,edgesUpdatable:e.edgesUpdatable,elementsSelectable:e.elementsSelectable,width:e.width,height:e.height,connectionMode:e.connectionMode,nodeInternals:e.nodeInternals,onError:e.onError}),gm=({defaultMarkerColor:e,onlyRenderVisibleElements:t,elevateEdgesOnSelect:r,rfId:s,edgeTypes:i,noPanClassName:a,onEdgeUpdate:c,onEdgeContextMenu:u,onEdgeMouseEnter:f,onEdgeMouseMove:p,onEdgeMouseLeave:m,onEdgeClick:E,edgeUpdaterRadius:v,onEdgeDoubleClick:x,onEdgeUpdateStart:_,onEdgeUpdateEnd:w,children:S})=>{const{edgesFocusable:N,edgesUpdatable:O,elementsSelectable:D,width:T,height:A,connectionMode:L,nodeInternals:F,onError:K}=Me(iR,gt),Q=JN(t,F,r);return T?te.createElement(te.Fragment,null,Q.map(({level:X,edges:ee,isMaxLevel:ne})=>te.createElement("svg",{key:X,style:{zIndex:X},width:T,height:A,className:"react-flow__edges react-flow__container"},ne&&te.createElement(sR,{defaultColor:e,rfId:s}),te.createElement("g",null,ee.map(W=>{const[I,V,j]=pm(F.get(W.source)),[B,U,$]=pm(F.get(W.target));if(!j||!$)return null;let z=W.type||"default";i[z]||(K?.("011",Vn.error011(z)),z="default");const k=i[z]||i.default,Y=L===ar.Strict?U.target:(U.target??[]).concat(U.source??[]),re=fm(V.source,W.sourceHandle),oe=fm(Y,W.targetHandle),le=re?.position||xe.Bottom,de=oe?.position||xe.Top,he=!!(W.focusable||N&&typeof W.focusable>"u"),ue=typeof c<"u"&&(W.updatable||O&&typeof W.updatable>"u");if(!re||!oe)return K?.("008",Vn.error008(re,W)),null;const{sourceX:me,sourceY:Re,targetX:Pe,targetY:Je}=XN(I,re,le,B,oe,de);return te.createElement(k,{key:W.id,id:W.id,className:St([W.className,a]),type:z,data:W.data,selected:!!W.selected,animated:!!W.animated,hidden:!!W.hidden,label:W.label,labelStyle:W.labelStyle,labelShowBg:W.labelShowBg,labelBgStyle:W.labelBgStyle,labelBgPadding:W.labelBgPadding,labelBgBorderRadius:W.labelBgBorderRadius,style:W.style,source:W.source,target:W.target,sourceHandleId:W.sourceHandle,targetHandleId:W.targetHandle,markerEnd:W.markerEnd,markerStart:W.markerStart,sourceX:me,sourceY:Re,targetX:Pe,targetY:Je,sourcePosition:le,targetPosition:de,elementsSelectable:D,onEdgeUpdate:c,onContextMenu:u,onMouseEnter:f,onMouseMove:p,onMouseLeave:m,onClick:E,edgeUpdaterRadius:v,onEdgeDoubleClick:x,onEdgeUpdateStart:_,onEdgeUpdateEnd:w,rfId:s,ariaLabel:W.ariaLabel,isFocusable:he,isUpdatable:ue,pathOptions:"pathOptions"in W?W.pathOptions:void 0,interactionWidth:W.interactionWidth})})))),S):null};gm.displayName="EdgeRenderer";var lR=b.memo(gm);const aR=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function cR({children:e}){const t=Me(aR);return te.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:t}},e)}function uR(e){const t=lu(),r=b.useRef(!1);b.useEffect(()=>{!r.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),r.current=!0)},[e,t.viewportInitialized])}const dR={[xe.Left]:xe.Right,[xe.Right]:xe.Left,[xe.Top]:xe.Bottom,[xe.Bottom]:xe.Top},Em=({nodeId:e,handleType:t,style:r,type:s=cr.Bezier,CustomComponent:i,connectionStatus:a})=>{const{fromNode:c,handleId:u,toX:f,toY:p,connectionMode:m}=Me(b.useCallback(L=>({fromNode:L.nodeInternals.get(e),handleId:L.connectionHandleId,toX:(L.connectionPosition.x-L.transform[0])/L.transform[2],toY:(L.connectionPosition.y-L.transform[1])/L.transform[2],connectionMode:L.connectionMode}),[e]),gt),E=c?.[nt]?.handleBounds;let v=E?.[t];if(m===ar.Loose&&(v=v||E?.[t==="source"?"target":"source"]),!c||!v)return null;const x=u?v.find(L=>L.id===u):v[0],_=x?x.x+x.width/2:(c.width??0)/2,w=x?x.y+x.height/2:c.height??0,S=(c.positionAbsolute?.x??0)+_,N=(c.positionAbsolute?.y??0)+w,O=x?.position,D=O?dR[O]:null;if(!O||!D)return null;if(i)return te.createElement(i,{connectionLineType:s,connectionLineStyle:r,fromNode:c,fromHandle:x,fromX:S,fromY:N,toX:f,toY:p,fromPosition:O,toPosition:D,connectionStatus:a});let T="";const A={sourceX:S,sourceY:N,sourcePosition:O,targetX:f,targetY:p,targetPosition:D};return s===cr.Bezier?[T]=_h(A):s===cr.Step?[T]=Us({...A,borderRadius:0}):s===cr.SmoothStep?[T]=Us(A):s===cr.SimpleBezier?[T]=yh(A):T=`M${S},${N} ${f},${p}`,te.createElement("path",{d:T,fill:"none",className:"react-flow__connection-path",style:r})};Em.displayName="ConnectionLine";const fR=e=>({nodeId:e.connectionNodeId,handleType:e.connectionHandleType,nodesConnectable:e.nodesConnectable,connectionStatus:e.connectionStatus,width:e.width,height:e.height});function pR({containerStyle:e,style:t,type:r,component:s}){const{nodeId:i,handleType:a,nodesConnectable:c,width:u,height:f,connectionStatus:p}=Me(fR,gt);return!(i&&a&&u&&c)?null:te.createElement("svg",{style:e,width:u,height:f,className:"react-flow__edges react-flow__connectionline react-flow__container"},te.createElement("g",{className:St(["react-flow__connection",p])},te.createElement(Em,{nodeId:i,handleType:a,style:t,type:r,CustomComponent:s,connectionStatus:p})))}function ym(e,t){return b.useRef(null),tt(),b.useMemo(()=>t(e),[e])}const vm=({nodeTypes:e,edgeTypes:t,onMove:r,onMoveStart:s,onMoveEnd:i,onInit:a,onNodeClick:c,onEdgeClick:u,onNodeDoubleClick:f,onEdgeDoubleClick:p,onNodeMouseEnter:m,onNodeMouseMove:E,onNodeMouseLeave:v,onNodeContextMenu:x,onSelectionContextMenu:_,onSelectionStart:w,onSelectionEnd:S,connectionLineType:N,connectionLineStyle:O,connectionLineComponent:D,connectionLineContainerStyle:T,selectionKeyCode:A,selectionOnDrag:L,selectionMode:F,multiSelectionKeyCode:K,panActivationKeyCode:Q,zoomActivationKeyCode:X,deleteKeyCode:ee,onlyRenderVisibleElements:ne,elementsSelectable:W,selectNodesOnDrag:I,defaultViewport:V,translateExtent:j,minZoom:B,maxZoom:U,preventScrolling:$,defaultMarkerColor:z,zoomOnScroll:k,zoomOnPinch:Y,panOnScroll:re,panOnScrollSpeed:oe,panOnScrollMode:le,zoomOnDoubleClick:de,panOnDrag:he,onPaneClick:ue,onPaneMouseEnter:me,onPaneMouseMove:Re,onPaneMouseLeave:Pe,onPaneScroll:Je,onPaneContextMenu:wt,onEdgeUpdate:Be,onEdgeContextMenu:Ue,onEdgeMouseEnter:ft,onEdgeMouseMove:pt,onEdgeMouseLeave:we,edgeUpdaterRadius:un,onEdgeUpdateStart:Ht,onEdgeUpdateEnd:Qt,noDragClassName:Cn,noWheelClassName:An,noPanClassName:dn,elevateEdgesOnSelect:zn,disableKeyboardA11y:fn,nodeOrigin:pn,nodeExtent:In,rfId:Wn})=>{const Ke=ym(e,$N),it=ym(t,KN);return uR(a),te.createElement(jN,{onPaneClick:ue,onPaneMouseEnter:me,onPaneMouseMove:Re,onPaneMouseLeave:Pe,onPaneContextMenu:wt,onPaneScroll:Je,deleteKeyCode:ee,selectionKeyCode:A,selectionOnDrag:L,selectionMode:F,onSelectionStart:w,onSelectionEnd:S,multiSelectionKeyCode:K,panActivationKeyCode:Q,zoomActivationKeyCode:X,elementsSelectable:W,onMove:r,onMoveStart:s,onMoveEnd:i,zoomOnScroll:k,zoomOnPinch:Y,zoomOnDoubleClick:de,panOnScroll:re,panOnScrollSpeed:oe,panOnScrollMode:le,panOnDrag:he,defaultViewport:V,translateExtent:j,minZoom:B,maxZoom:U,onSelectionContextMenu:_,preventScrolling:$,noDragClassName:Cn,noWheelClassName:An,noPanClassName:dn,disableKeyboardA11y:fn},te.createElement(cR,null,te.createElement(lR,{edgeTypes:it,onEdgeClick:u,onEdgeDoubleClick:p,onEdgeUpdate:Be,onlyRenderVisibleElements:ne,onEdgeContextMenu:Ue,onEdgeMouseEnter:ft,onEdgeMouseMove:pt,onEdgeMouseLeave:we,onEdgeUpdateStart:Ht,onEdgeUpdateEnd:Qt,edgeUpdaterRadius:un,defaultMarkerColor:z,noPanClassName:dn,elevateEdgesOnSelect:!!zn,disableKeyboardA11y:fn,rfId:Wn},te.createElement(pR,{style:O,type:N,component:D,containerStyle:T})),te.createElement("div",{className:"react-flow__edgelabel-renderer"}),te.createElement(zN,{nodeTypes:Ke,onNodeClick:c,onNodeDoubleClick:f,onNodeMouseEnter:m,onNodeMouseMove:E,onNodeMouseLeave:v,onNodeContextMenu:x,selectNodesOnDrag:I,onlyRenderVisibleElements:ne,noPanClassName:dn,noDragClassName:Cn,disableKeyboardA11y:fn,nodeOrigin:pn,nodeExtent:In,rfId:Wn})))};vm.displayName="GraphView";var hR=b.memo(vm);const pu=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],dr={rfId:"1",width:0,height:0,transform:[0,0,1],nodeInternals:new Map,edges:[],onNodesChange:null,onEdgesChange:null,hasDefaultNodes:!1,hasDefaultEdges:!1,d3Zoom:null,d3Selection:null,d3ZoomHandler:void 0,minZoom:.5,maxZoom:2,translateExtent:pu,nodeExtent:pu,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:ar.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:[0,0],nodeDragThreshold:0,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesUpdatable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,fitViewOnInit:!1,fitViewOnInitDone:!1,fitViewOnInitOptions:void 0,onSelectionChange:[],multiSelectionActive:!1,connectionStartHandle:null,connectionEndHandle:null,connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,connectionRadius:20,onError:Bw,isValidConnection:void 0},mR=()=>nx((e,t)=>({...dr,setNodes:r=>{const{nodeInternals:s,nodeOrigin:i,elevateNodesOnSelect:a}=t();e({nodeInternals:iu(r,s,i,a)})},getNodes:()=>Array.from(t().nodeInternals.values()),setEdges:r=>{const{defaultEdgeOptions:s={}}=t();e({edges:r.map(i=>({...s,...i}))})},setDefaultNodesAndEdges:(r,s)=>{const i=typeof r<"u",a=typeof s<"u",c=i?iu(r,new Map,t().nodeOrigin,t().elevateNodesOnSelect):new Map;e({nodeInternals:c,edges:a?s:[],hasDefaultNodes:i,hasDefaultEdges:a})},updateNodeDimensions:r=>{const{onNodesChange:s,nodeInternals:i,fitViewOnInit:a,fitViewOnInitDone:c,fitViewOnInitOptions:u,domNode:f,nodeOrigin:p}=t(),m=f?.querySelector(".react-flow__viewport");if(!m)return;const E=window.getComputedStyle(m),{m22:v}=new window.DOMMatrixReadOnly(E.transform),x=r.reduce((w,S)=>{const N=i.get(S.id);if(N){const O=zc(S.nodeElement);!!(O.width&&O.height&&(N.width!==O.width||N.height!==O.height||S.forceUpdate))&&(i.set(N.id,{...N,[nt]:{...N[nt],handleBounds:{source:om(".source",S.nodeElement,v,p),target:om(".target",S.nodeElement,v,p)}},...O}),w.push({id:N.id,type:"dimensions",dimensions:O}))}return w},[]);Yh(i,p);const _=c||a&&!c&&Kh(t,{initial:!0,...u});e({nodeInternals:new Map(i),fitViewOnInitDone:_}),x?.length>0&&s?.(x)},updateNodePositions:(r,s=!0,i=!1)=>{const{triggerNodeChanges:a}=t(),c=r.map(u=>{const f={id:u.id,type:"position",dragging:i};return s&&(f.positionAbsolute=u.positionAbsolute,f.position=u.position),f});a(c)},triggerNodeChanges:r=>{const{onNodesChange:s,nodeInternals:i,hasDefaultNodes:a,nodeOrigin:c,getNodes:u,elevateNodesOnSelect:f}=t();if(r?.length){if(a){const p=Jh(r,u()),m=iu(p,i,c,f);e({nodeInternals:m})}s?.(r)}},addSelectedNodes:r=>{const{multiSelectionActive:s,edges:i,getNodes:a}=t();let c,u=null;s?c=r.map(f=>ur(f,!0)):(c=Io(a(),r),u=Io(i,[])),gl({changedNodes:c,changedEdges:u,get:t,set:e})},addSelectedEdges:r=>{const{multiSelectionActive:s,edges:i,getNodes:a}=t();let c,u=null;s?c=r.map(f=>ur(f,!0)):(c=Io(i,r),u=Io(a(),[])),gl({changedNodes:u,changedEdges:c,get:t,set:e})},unselectNodesAndEdges:({nodes:r,edges:s}={})=>{const{edges:i,getNodes:a}=t(),c=r||a(),u=s||i,f=c.map(m=>(m.selected=!1,ur(m.id,!1))),p=u.map(m=>ur(m.id,!1));gl({changedNodes:f,changedEdges:p,get:t,set:e})},setMinZoom:r=>{const{d3Zoom:s,maxZoom:i}=t();s?.scaleExtent([r,i]),e({minZoom:r})},setMaxZoom:r=>{const{d3Zoom:s,minZoom:i}=t();s?.scaleExtent([i,r]),e({maxZoom:r})},setTranslateExtent:r=>{t().d3Zoom?.translateExtent(r),e({translateExtent:r})},resetSelectedElements:()=>{const{edges:r,getNodes:s}=t(),a=s().filter(u=>u.selected).map(u=>ur(u.id,!1)),c=r.filter(u=>u.selected).map(u=>ur(u.id,!1));gl({changedNodes:a,changedEdges:c,get:t,set:e})},setNodeExtent:r=>{const{nodeInternals:s}=t();s.forEach(i=>{i.positionAbsolute=Wc(i.position,r)}),e({nodeExtent:r,nodeInternals:new Map(s)})},panBy:r=>{const{transform:s,width:i,height:a,d3Zoom:c,d3Selection:u,translateExtent:f}=t();if(!c||!u||!r.x&&!r.y)return!1;const p=ir.translate(s[0]+r.x,s[1]+r.y).scale(s[2]),m=[[0,0],[i,a]],E=c?.constrain()(p,m,f);return c.transform(u,E),s[0]!==E.x||s[1]!==E.y||s[2]!==E.k},cancelConnection:()=>e({connectionNodeId:dr.connectionNodeId,connectionHandleId:dr.connectionHandleId,connectionHandleType:dr.connectionHandleType,connectionStatus:dr.connectionStatus,connectionStartHandle:dr.connectionStartHandle,connectionEndHandle:dr.connectionEndHandle}),reset:()=>e({...dr})}),Object.is),hu=({children:e})=>{const t=b.useRef(null);return t.current||(t.current=mR()),te.createElement(Mw,{value:t.current},e)};hu.displayName="ReactFlowProvider";const xm=({children:e})=>b.useContext(ul)?te.createElement(te.Fragment,null,e):te.createElement(hu,null,e);xm.displayName="ReactFlowWrapper";const gR={input:Uh,default:ou,output:jh,group:su},ER={default:hl,straight:qc,step:Qc,smoothstep:fl,simplebezier:Xc},yR=[0,0],vR=[15,15],xR={x:0,y:0,zoom:1},SR={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},Sm=b.forwardRef(({nodes:e,edges:t,defaultNodes:r,defaultEdges:s,className:i,nodeTypes:a=gR,edgeTypes:c=ER,onNodeClick:u,onEdgeClick:f,onInit:p,onMove:m,onMoveStart:E,onMoveEnd:v,onConnect:x,onConnectStart:_,onConnectEnd:w,onClickConnectStart:S,onClickConnectEnd:N,onNodeMouseEnter:O,onNodeMouseMove:D,onNodeMouseLeave:T,onNodeContextMenu:A,onNodeDoubleClick:L,onNodeDragStart:F,onNodeDrag:K,onNodeDragStop:Q,onNodesDelete:X,onEdgesDelete:ee,onSelectionChange:ne,onSelectionDragStart:W,onSelectionDrag:I,onSelectionDragStop:V,onSelectionContextMenu:j,onSelectionStart:B,onSelectionEnd:U,connectionMode:$=ar.Strict,connectionLineType:z=cr.Bezier,connectionLineStyle:k,connectionLineComponent:Y,connectionLineContainerStyle:re,deleteKeyCode:oe="Backspace",selectionKeyCode:le="Shift",selectionOnDrag:de=!1,selectionMode:he=Ms.Full,panActivationKeyCode:ue="Space",multiSelectionKeyCode:me=dl()?"Meta":"Control",zoomActivationKeyCode:Re=dl()?"Meta":"Control",snapToGrid:Pe=!1,snapGrid:Je=vR,onlyRenderVisibleElements:wt=!1,selectNodesOnDrag:Be=!0,nodesDraggable:Ue,nodesConnectable:ft,nodesFocusable:pt,nodeOrigin:we=yR,edgesFocusable:un,edgesUpdatable:Ht,elementsSelectable:Qt,defaultViewport:Cn=xR,minZoom:An=.5,maxZoom:dn=2,translateExtent:zn=pu,preventScrolling:fn=!0,nodeExtent:pn,defaultMarkerColor:In="#b1b1b7",zoomOnScroll:Wn=!0,zoomOnPinch:Ke=!0,panOnScroll:it=!1,panOnScrollSpeed:Gn=.5,panOnScrollMode:bn=$r.Free,zoomOnDoubleClick:Yn=!0,panOnDrag:qt=!0,onPaneClick:hn,onPaneMouseEnter:Qr,onPaneMouseMove:qr,onPaneMouseLeave:Kn,onPaneScroll:Zr,onPaneContextMenu:Xn,children:Lt,onEdgeUpdate:zl,onEdgeContextMenu:Wl,onEdgeDoubleClick:Gl,onEdgeMouseEnter:Yl,onEdgeMouseMove:Kl,onEdgeMouseLeave:ri,onEdgeUpdateStart:Xl,onEdgeUpdateEnd:Jr,edgeUpdaterRadius:oi=10,onNodesChange:eo,onEdgesChange:sd,noDragClassName:to="nodrag",noWheelClassName:Ko="nowheel",noPanClassName:no="nopan",fitView:si=!1,fitViewOptions:id,connectOnClick:ld=!0,attributionPosition:ad,proOptions:Qn,defaultEdgeOptions:Ql,elevateNodesOnSelect:ql=!0,elevateEdgesOnSelect:cd=!1,disableKeyboardA11y:ii=!1,autoPanOnConnect:Zl=!0,autoPanOnNodeDrag:Jl=!0,connectionRadius:ea=20,isValidConnection:ud,onError:dd,style:We,id:ta,nodeDragThreshold:li,...na},Xo)=>{const ai=ta||"1";return te.createElement("div",{...na,style:{...We,...SR},ref:Xo,className:St(["react-flow",i]),"data-testid":"rf__wrapper",id:ta},te.createElement(xm,null,te.createElement(hR,{onInit:p,onMove:m,onMoveStart:E,onMoveEnd:v,onNodeClick:u,onEdgeClick:f,onNodeMouseEnter:O,onNodeMouseMove:D,onNodeMouseLeave:T,onNodeContextMenu:A,onNodeDoubleClick:L,nodeTypes:a,edgeTypes:c,connectionLineType:z,connectionLineStyle:k,connectionLineComponent:Y,connectionLineContainerStyle:re,selectionKeyCode:le,selectionOnDrag:de,selectionMode:he,deleteKeyCode:oe,multiSelectionKeyCode:me,panActivationKeyCode:ue,zoomActivationKeyCode:Re,onlyRenderVisibleElements:wt,selectNodesOnDrag:Be,defaultViewport:Cn,translateExtent:zn,minZoom:An,maxZoom:dn,preventScrolling:fn,zoomOnScroll:Wn,zoomOnPinch:Ke,zoomOnDoubleClick:Yn,panOnScroll:it,panOnScrollSpeed:Gn,panOnScrollMode:bn,panOnDrag:qt,onPaneClick:hn,onPaneMouseEnter:Qr,onPaneMouseMove:qr,onPaneMouseLeave:Kn,onPaneScroll:Zr,onPaneContextMenu:Xn,onSelectionContextMenu:j,onSelectionStart:B,onSelectionEnd:U,onEdgeUpdate:zl,onEdgeContextMenu:Wl,onEdgeDoubleClick:Gl,onEdgeMouseEnter:Yl,onEdgeMouseMove:Kl,onEdgeMouseLeave:ri,onEdgeUpdateStart:Xl,onEdgeUpdateEnd:Jr,edgeUpdaterRadius:oi,defaultMarkerColor:In,noDragClassName:to,noWheelClassName:Ko,noPanClassName:no,elevateEdgesOnSelect:cd,rfId:ai,disableKeyboardA11y:ii,nodeOrigin:we,nodeExtent:pn}),te.createElement(dN,{nodes:e,edges:t,defaultNodes:r,defaultEdges:s,onConnect:x,onConnectStart:_,onConnectEnd:w,onClickConnectStart:S,onClickConnectEnd:N,nodesDraggable:Ue,nodesConnectable:ft,nodesFocusable:pt,edgesFocusable:un,edgesUpdatable:Ht,elementsSelectable:Qt,elevateNodesOnSelect:ql,minZoom:An,maxZoom:dn,nodeExtent:pn,onNodesChange:eo,onEdgesChange:sd,snapToGrid:Pe,snapGrid:Je,connectionMode:$,translateExtent:zn,connectOnClick:ld,defaultEdgeOptions:Ql,fitView:si,fitViewOptions:id,onNodesDelete:X,onEdgesDelete:ee,onNodeDragStart:F,onNodeDrag:K,onNodeDragStop:Q,onSelectionDrag:I,onSelectionDragStart:W,onSelectionDragStop:V,noPanClassName:no,nodeOrigin:we,rfId:ai,autoPanOnConnect:Zl,autoPanOnNodeDrag:Jl,onError:dd,connectionRadius:ea,isValidConnection:ud,nodeDragThreshold:li}),te.createElement(cN,{onSelectionChange:ne}),Lt,te.createElement(Uw,{proOptions:Qn,position:ad}),te.createElement(gN,{rfId:ai,disableKeyboardA11y:ii})))});Sm.displayName="ReactFlow";const _R=e=>e.domNode?.querySelector(".react-flow__edgelabel-renderer");function wR({children:e}){const t=Me(_R);return t?Bc.createPortal(e,t):null}function NR(){const e=tt();return b.useCallback(t=>{const{domNode:r,updateNodeDimensions:s}=e.getState(),a=(Array.isArray(t)?t:[t]).reduce((c,u)=>{const f=r?.querySelector(`.react-flow__node[data-id="${u}"]`);return f&&c.push({id:u,nodeElement:f,forceUpdate:!0}),c},[]);requestAnimationFrame(()=>s(a))},[])}function RR({onStart:e,onChange:t,onEnd:r}){const s=tt();b.useEffect(()=>{s.setState({onViewportChangeStart:e})},[e]),b.useEffect(()=>{s.setState({onViewportChange:t})},[t]),b.useEffect(()=>{s.setState({onViewportChangeEnd:r})},[r])}const TR=e=>t=>t.nodeInternals.size===0?!1:t.getNodes().filter(r=>e.includeHiddenNodes?!0:!r.hidden).every(r=>r[nt]?.handleBounds!==void 0),OR={includeHiddenNodes:!1};function CR(e=OR){return Me(TR(e))}function AR(){return te.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},te.createElement("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"}))}function IR(){return te.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},te.createElement("path",{d:"M0 0h32v4.2H0z"}))}function bR(){return te.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30"},te.createElement("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"}))}function LR(){return te.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},te.createElement("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"}))}function DR(){return te.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},te.createElement("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"}))}const Vs=({children:e,className:t,...r})=>te.createElement("button",{type:"button",className:St(["react-flow__controls-button",t]),...r},e);Vs.displayName="ControlButton";const kR=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom}),_m=({style:e,showZoom:t=!0,showFitView:r=!0,showInteractive:s=!0,fitViewOptions:i,onZoomIn:a,onZoomOut:c,onFitView:u,onInteractiveChange:f,className:p,children:m,position:E="bottom-left"})=>{const v=tt(),[x,_]=b.useState(!1),{isInteractive:w,minZoomReached:S,maxZoomReached:N}=Me(kR,gt),{zoomIn:O,zoomOut:D,fitView:T}=lu();if(b.useEffect(()=>{_(!0)},[]),!x)return null;const A=()=>{O(),a?.()},L=()=>{D(),c?.()},F=()=>{T(i),u?.()},K=()=>{v.setState({nodesDraggable:!w,nodesConnectable:!w,elementsSelectable:!w}),f?.(!w)};return te.createElement(Ds,{className:St(["react-flow__controls",p]),position:E,style:e,"data-testid":"rf__controls"},t&&te.createElement(te.Fragment,null,te.createElement(Vs,{onClick:A,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:N},te.createElement(AR,null)),te.createElement(Vs,{onClick:L,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:S},te.createElement(IR,null))),r&&te.createElement(Vs,{className:"react-flow__controls-fitview",onClick:F,title:"fit view","aria-label":"fit view"},te.createElement(bR,null)),s&&te.createElement(Vs,{className:"react-flow__controls-interactive",onClick:K,title:"toggle interactivity","aria-label":"toggle interactivity"},w?te.createElement(DR,null):te.createElement(LR,null)),m)};_m.displayName="Controls";var MR=b.memo(_m),Kt;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Kt||(Kt={}));function PR({color:e,dimensions:t,lineWidth:r}){return te.createElement("path",{stroke:e,strokeWidth:r,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`})}function UR({color:e,radius:t}){return te.createElement("circle",{cx:t,cy:t,r:t,fill:e})}const FR={[Kt.Dots]:"#91919a",[Kt.Lines]:"#eee",[Kt.Cross]:"#e2e2e2"},jR={[Kt.Dots]:1,[Kt.Lines]:1,[Kt.Cross]:6},VR=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function wm({id:e,variant:t=Kt.Dots,gap:r=20,size:s,lineWidth:i=1,offset:a=2,color:c,style:u,className:f}){const p=b.useRef(null),{transform:m,patternId:E}=Me(VR,gt),v=c||FR[t],x=s||jR[t],_=t===Kt.Dots,w=t===Kt.Cross,S=Array.isArray(r)?r:[r,r],N=[S[0]*m[2]||1,S[1]*m[2]||1],O=x*m[2],D=w?[O,O]:N,T=_?[O/a,O/a]:[D[0]/a,D[1]/a];return te.createElement("svg",{className:St(["react-flow__background",f]),style:{...u,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:p,"data-testid":"rf__background"},te.createElement("pattern",{id:E+e,x:m[0]%N[0],y:m[1]%N[1],width:N[0],height:N[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${T[0]},-${T[1]})`},_?te.createElement(UR,{color:v,radius:O/a}):te.createElement(PR,{dimensions:D,color:v,lineWidth:i})),te.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${E+e})`}))}wm.displayName="Background";var $R=b.memo(wm);const Nm={},{useDebugValue:HR}=te,{useSyncExternalStoreWithSelector:BR}=fp;let Rm=!1;function zR(e,t=e.getState,r){(Nm?"production":void 0)!=="production"&&r&&!Rm&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),Rm=!0);const s=BR(e.subscribe,e.getState,e.getServerState||e.getState,t,r);return HR(s),s}const Tm=e=>{(Nm?"production":void 0)!=="production"&&typeof e!="function"&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");const t=typeof e=="function"?hp(e):e,r=(s,i)=>zR(t,s,i);return Object.assign(r,t),r},Do=e=>e?Tm(e):Tm,WR=!1,GR="prod",YR="0.0.14",$s="0.0.10",Om=230,KR=640,Cm=20,ko={markerEnd:{height:20,type:Ps.ArrowClosed,width:20},style:{stroke:"inherit",strokeWidth:1.5},type:"floating"},XR="422",QR="404",Am="document-sync",mu=1e3,qR=1e3,ZR=300,JR=5e3,Im=300,e1="Shift+Backspace",t1="Meta",n1="Shift",yl=25,gu={duration:mu,includeHiddenNodes:!1,padding:.3},Eu=()=>{const e={},t=document.querySelector('meta[name="csrf-token"]');return t&&(e["X-CSRF-Token"]=t?.content),e},r1=(e,t)=>{const r=new Blob([JSON.stringify({edges:t,nodes:e},null,2)],{type:"application/json"}),s=window.URL.createObjectURL(r),i=window.open();i?.location?.href&&(i.location.href=s)},bm=e=>({...e,...ko}),Lm=e=>e.type==="handleCall"?{...e,deletable:!1}:e,Dm=e=>e==="success"?"positive":"negative",o1=e=>e.toLowerCase().replace(/ /g,"-"),jt=e=>typeof e=="string"?e.trim():e,km=(e,t,r)=>e.sort((s,i)=>{const a=s[r],c=i[r];if(typeof a=="string"&&typeof c=="string")return a.toLowerCase().localeCompare(c.toLowerCase());if(typeof a=="number"&&typeof c=="number")return a-c;throw new Error(`sort fn can only sort strings & numbers, but got ${typeof a} and ${typeof c}`)}),s1=e=>{try{return new URL(e).pathname.split("/").at(-1)}catch{return""}};function Mm(e,t){const r=[{divisor:1,threshold:60,unit:"second"},{divisor:60,threshold:3600,unit:"minute"},{divisor:3600,threshold:86400,unit:"hour"},{divisor:86400,threshold:86400,unit:"day"}],s=new Intl.RelativeTimeFormat(e,{numeric:"always",...t});return function(a,c={}){const{excludeUnits:u={}}=c,f=new Date().getTime(),p=new Date(a).getTime(),m=Math.floor((f-p)/1e3),E=r.filter(({unit:w})=>!u[w]),{divisor:v,unit:x}=E.find(({threshold:w})=>Math.abs(m)<w)??E[E.length-1],_=Math.floor(m/v);return s.format(-_,x)}}function Pm(e){return new Promise(t=>setTimeout(t,e))}const i1=(e,t,r)=>{const s=e==="ArrowDown";if(!t)return s?r[0]:r[r.length-1];const i=r.findIndex(u=>u.id===t),a=s?i+1:i-1;if(a<0||a>=r.length)return;const c=r[a];if(!c)throw new Error(`Could not find option at index ${a}`);return c},Um=(e,t,r)=>{const s=e.find(i=>{if(t in i)return i[t]===r});if(!s)throw new Error(`Could not find option with id ${t}`);return s},l1=e=>Object.keys(e),yu=()=>({callOrder:"single",callStateEvents:"",callStateUrl:"",connections:[{connectConfirmDisplayName:"",connectConfirmEnabled:!1,connectConfirmId:"",connectConfirmUrl:"",connectFrom:"",connectTimeout:"",connectTo:"",id:Le()}],defaultFrom:"",defaultTimeout:"",destinationType:"phone",options:[{id:Le(),result:"success"},{id:Le(),result:"noAnswer"},{id:Le(),result:"busy"},{id:Le(),result:"decline"},{id:Le(),result:"error"}]}),Fm={aiAgent:()=>({agent:""}),answer:()=>({valid:!0}),cond:()=>({fallback:Le(),options:[{id:Le(),value:""}]}),condRequest:()=>({body:"",error:Le(),fallback:Le(),headers:"",method:"POST",options:[{id:Le(),value:""}],url:""}),executeSWML:()=>({dest:"",fallback:Le(),meta:"",options:[{id:Le(),value:""}],params:""}),forwardAddress:()=>({...yu(),destinationType:"address"}),forwardPhone:()=>({...yu(),destinationType:"phone"}),forwardResource:()=>({...yu(),destinationType:"resource"}),handleCall:()=>({valid:!0}),hangup:()=>({valid:!0}),play:()=>({selected:"",text:"",url:""}),promptPlay:()=>({digitTimeout:"",initialTimeout:"",options:[{command:"",digit:"",id:Le()}],results:[{id:Le(),result:"no_match"},{id:Le(),result:"no_input"}],selected:"",text:"",url:""}),record:()=>({beep:!1,endSilenceTimeout:"",format:"wav",initialTimeout:"",maxLength:"",stereo:!1,terminators:"",valid:!0}),recordCallStart:()=>({beep:!1,controlId:Le(),format:"wav",label:"",stereo:!1,terminators:""}),recordCallStop:()=>({controlId:""}),request:()=>({body:"",headers:"",method:"POST",options:[{id:Le(),result:"success"},{id:Le(),result:"failed"}],url:""}),sendSms:()=>({body:"",fromNumber:"",media:[],region:"",tags:[],toNumber:""}),set:()=>({variables:[{duplicate:!1,id:Le(),key:"",value:""}]}),unset:()=>({variables:[]})},a1={type:"logger",log(e){this.output("log",e)},warn(e){this.output("warn",e)},error(e){this.output("error",e)},output(e,t){console&&console[e]&&console[e].apply(console,t)}};class vl{constructor(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.init(t,r)}init(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.prefix=r.prefix||"i18next:",this.logger=t||a1,this.options=r,this.debug=r.debug}log(){for(var t=arguments.length,r=new Array(t),s=0;s<t;s++)r[s]=arguments[s];return this.forward(r,"log","",!0)}warn(){for(var t=arguments.length,r=new Array(t),s=0;s<t;s++)r[s]=arguments[s];return this.forward(r,"warn","",!0)}error(){for(var t=arguments.length,r=new Array(t),s=0;s<t;s++)r[s]=arguments[s];return this.forward(r,"error","")}deprecate(){for(var t=arguments.length,r=new Array(t),s=0;s<t;s++)r[s]=arguments[s];return this.forward(r,"warn","WARNING DEPRECATED: ",!0)}forward(t,r,s,i){return i&&!this.debug?null:(typeof t[0]=="string"&&(t[0]=`${s}${this.prefix} ${t[0]}`),this.logger[r](t))}create(t){return new vl(this.logger,{prefix:`${this.prefix}:${t}:`,...this.options})}clone(t){return t=t||this.options,t.prefix=t.prefix||this.prefix,new vl(this.logger,t)}}var Rn=new vl;class xl{constructor(){this.observers={}}on(t,r){return t.split(" ").forEach(s=>{this.observers[s]=this.observers[s]||[],this.observers[s].push(r)}),this}off(t,r){if(this.observers[t]){if(!r){delete this.observers[t];return}this.observers[t]=this.observers[t].filter(s=>s!==r)}}emit(t){for(var r=arguments.length,s=new Array(r>1?r-1:0),i=1;i<r;i++)s[i-1]=arguments[i];this.observers[t]&&[].concat(this.observers[t]).forEach(c=>{c(...s)}),this.observers["*"]&&[].concat(this.observers["*"]).forEach(c=>{c.apply(c,[t,...s])})}}function Hs(){let e,t;const r=new Promise((s,i)=>{e=s,t=i});return r.resolve=e,r.reject=t,r}function jm(e){return e==null?"":""+e}function c1(e,t,r){e.forEach(s=>{t[s]&&(r[s]=t[s])})}function vu(e,t,r){function s(c){return c&&c.indexOf("###")>-1?c.replace(/###/g,"."):c}function i(){return!e||typeof e=="string"}const a=typeof t!="string"?[].concat(t):t.split(".");for(;a.length>1;){if(i())return{};const c=s(a.shift());!e[c]&&r&&(e[c]=new r),Object.prototype.hasOwnProperty.call(e,c)?e=e[c]:e={}}return i()?{}:{obj:e,k:s(a.shift())}}function Vm(e,t,r){const{obj:s,k:i}=vu(e,t,Object);s[i]=r}function u1(e,t,r,s){const{obj:i,k:a}=vu(e,t,Object);i[a]=i[a]||[],i[a].push(r)}function Sl(e,t){const{obj:r,k:s}=vu(e,t);if(r)return r[s]}function d1(e,t,r){const s=Sl(e,r);return s!==void 0?s:Sl(t,r)}function $m(e,t,r){for(const s in t)s!=="__proto__"&&s!=="constructor"&&(s in e?typeof e[s]=="string"||e[s]instanceof String||typeof t[s]=="string"||t[s]instanceof String?r&&(e[s]=t[s]):$m(e[s],t[s],r):e[s]=t[s]);return e}function Mo(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}var f1={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};function p1(e){return typeof e=="string"?e.replace(/[&<>"'\/]/g,t=>f1[t]):e}const h1=[" ",",","?","!",";"];function m1(e,t,r){t=t||"",r=r||"";const s=h1.filter(c=>t.indexOf(c)<0&&r.indexOf(c)<0);if(s.length===0)return!0;const i=new RegExp(`(${s.map(c=>c==="?"?"\\?":c).join("|")})`);let a=!i.test(e);if(!a){const c=e.indexOf(r);c>0&&!i.test(e.substring(0,c))&&(a=!0)}return a}function _l(e,t){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:".";if(!e)return;if(e[t])return e[t];const s=t.split(r);let i=e;for(let a=0;a<s.length;++a){if(!i||typeof i[s[a]]=="string"&&a+1<s.length)return;if(i[s[a]]===void 0){let c=2,u=s.slice(a,a+c).join(r),f=i[u];for(;f===void 0&&s.length>a+c;)c++,u=s.slice(a,a+c).join(r),f=i[u];if(f===void 0)return;if(f===null)return null;if(t.endsWith(u)){if(typeof f=="string")return f;if(u&&typeof f[u]=="string")return f[u]}const p=s.slice(a+c).join(r);return p?_l(f,p,r):void 0}i=i[s[a]]}return i}function wl(e){return e&&e.indexOf("_")>0?e.replace("_","-"):e}class Hm extends xl{constructor(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{ns:["translation"],defaultNS:"translation"};super(),this.data=t||{},this.options=r,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(t){this.options.ns.indexOf(t)<0&&this.options.ns.push(t)}removeNamespaces(t){const r=this.options.ns.indexOf(t);r>-1&&this.options.ns.splice(r,1)}getResource(t,r,s){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};const a=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,c=i.ignoreJSONStructure!==void 0?i.ignoreJSONStructure:this.options.ignoreJSONStructure;let u=[t,r];s&&typeof s!="string"&&(u=u.concat(s)),s&&typeof s=="string"&&(u=u.concat(a?s.split(a):s)),t.indexOf(".")>-1&&(u=t.split("."));const f=Sl(this.data,u);return f||!c||typeof s!="string"?f:_l(this.data&&this.data[t]&&this.data[t][r],s,a)}addResource(t,r,s,i){let a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{silent:!1};const c=a.keySeparator!==void 0?a.keySeparator:this.options.keySeparator;let u=[t,r];s&&(u=u.concat(c?s.split(c):s)),t.indexOf(".")>-1&&(u=t.split("."),i=r,r=u[1]),this.addNamespaces(r),Vm(this.data,u,i),a.silent||this.emit("added",t,r,s,i)}addResources(t,r,s){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{silent:!1};for(const a in s)(typeof s[a]=="string"||Object.prototype.toString.apply(s[a])==="[object Array]")&&this.addResource(t,r,a,s[a],{silent:!0});i.silent||this.emit("added",t,r,s)}addResourceBundle(t,r,s,i,a){let c=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{silent:!1},u=[t,r];t.indexOf(".")>-1&&(u=t.split("."),i=s,s=r,r=u[1]),this.addNamespaces(r);let f=Sl(this.data,u)||{};i?$m(f,s,a):f={...f,...s},Vm(this.data,u,f),c.silent||this.emit("added",t,r,s)}removeResourceBundle(t,r){this.hasResourceBundle(t,r)&&delete this.data[t][r],this.removeNamespaces(r),this.emit("removed",t,r)}hasResourceBundle(t,r){return this.getResource(t,r)!==void 0}getResourceBundle(t,r){return r||(r=this.options.defaultNS),this.options.compatibilityAPI==="v1"?{...this.getResource(t,r)}:this.getResource(t,r)}getDataByLanguage(t){return this.data[t]}hasLanguageSomeTranslations(t){const r=this.getDataByLanguage(t);return!!(r&&Object.keys(r)||[]).find(i=>r[i]&&Object.keys(r[i]).length>0)}toJSON(){return this.data}}var Bm={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,r,s,i){return e.forEach(a=>{this.processors[a]&&(t=this.processors[a].process(t,r,s,i))}),t}};const zm={};class Nl extends xl{constructor(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),c1(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],t,this),this.options=r,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=Rn.create("translator")}changeLanguage(t){t&&(this.language=t)}exists(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}};if(t==null)return!1;const s=this.resolve(t,r);return s&&s.res!==void 0}extractFromKey(t,r){let s=r.nsSeparator!==void 0?r.nsSeparator:this.options.nsSeparator;s===void 0&&(s=":");const i=r.keySeparator!==void 0?r.keySeparator:this.options.keySeparator;let a=r.ns||this.options.defaultNS||[];const c=s&&t.indexOf(s)>-1,u=!this.options.userDefinedKeySeparator&&!r.keySeparator&&!this.options.userDefinedNsSeparator&&!r.nsSeparator&&!m1(t,s,i);if(c&&!u){const f=t.match(this.interpolator.nestingRegexp);if(f&&f.length>0)return{key:t,namespaces:a};const p=t.split(s);(s!==i||s===i&&this.options.ns.indexOf(p[0])>-1)&&(a=p.shift()),t=p.join(i)}return typeof a=="string"&&(a=[a]),{key:t,namespaces:a}}translate(t,r,s){if(typeof r!="object"&&this.options.overloadTranslationOptionHandler&&(r=this.options.overloadTranslationOptionHandler(arguments)),typeof r=="object"&&(r={...r}),r||(r={}),t==null)return"";Array.isArray(t)||(t=[String(t)]);const i=r.returnDetails!==void 0?r.returnDetails:this.options.returnDetails,a=r.keySeparator!==void 0?r.keySeparator:this.options.keySeparator,{key:c,namespaces:u}=this.extractFromKey(t[t.length-1],r),f=u[u.length-1],p=r.lng||this.language,m=r.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(p&&p.toLowerCase()==="cimode"){if(m){const T=r.nsSeparator||this.options.nsSeparator;return i?{res:`${f}${T}${c}`,usedKey:c,exactUsedKey:c,usedLng:p,usedNS:f,usedParams:this.getUsedParamsDetails(r)}:`${f}${T}${c}`}return i?{res:c,usedKey:c,exactUsedKey:c,usedLng:p,usedNS:f,usedParams:this.getUsedParamsDetails(r)}:c}const E=this.resolve(t,r);let v=E&&E.res;const x=E&&E.usedKey||c,_=E&&E.exactUsedKey||c,w=Object.prototype.toString.apply(v),S=["[object Number]","[object Function]","[object RegExp]"],N=r.joinArrays!==void 0?r.joinArrays:this.options.joinArrays,O=!this.i18nFormat||this.i18nFormat.handleAsObject;if(O&&v&&(typeof v!="string"&&typeof v!="boolean"&&typeof v!="number")&&S.indexOf(w)<0&&!(typeof N=="string"&&w==="[object Array]")){if(!r.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const T=this.options.returnedObjectHandler?this.options.returnedObjectHandler(x,v,{...r,ns:u}):`key '${c} (${this.language})' returned an object instead of string.`;return i?(E.res=T,E.usedParams=this.getUsedParamsDetails(r),E):T}if(a){const T=w==="[object Array]",A=T?[]:{},L=T?_:x;for(const F in v)if(Object.prototype.hasOwnProperty.call(v,F)){const K=`${L}${a}${F}`;A[F]=this.translate(K,{...r,joinArrays:!1,ns:u}),A[F]===K&&(A[F]=v[F])}v=A}}else if(O&&typeof N=="string"&&w==="[object Array]")v=v.join(N),v&&(v=this.extendTranslation(v,t,r,s));else{let T=!1,A=!1;const L=r.count!==void 0&&typeof r.count!="string",F=Nl.hasDefaultValue(r),K=L?this.pluralResolver.getSuffix(p,r.count,r):"",Q=r.ordinal&&L?this.pluralResolver.getSuffix(p,r.count,{ordinal:!1}):"",X=r[`defaultValue${K}`]||r[`defaultValue${Q}`]||r.defaultValue;!this.isValidLookup(v)&&F&&(T=!0,v=X),this.isValidLookup(v)||(A=!0,v=c);const ne=(r.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&A?void 0:v,W=F&&X!==v&&this.options.updateMissing;if(A||T||W){if(this.logger.log(W?"updateKey":"missingKey",p,f,c,W?X:v),a){const B=this.resolve(c,{...r,keySeparator:!1});B&&B.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let I=[];const V=this.languageUtils.getFallbackCodes(this.options.fallbackLng,r.lng||this.language);if(this.options.saveMissingTo==="fallback"&&V&&V[0])for(let B=0;B<V.length;B++)I.push(V[B]);else this.options.saveMissingTo==="all"?I=this.languageUtils.toResolveHierarchy(r.lng||this.language):I.push(r.lng||this.language);const j=(B,U,$)=>{const z=F&&$!==v?$:ne;this.options.missingKeyHandler?this.options.missingKeyHandler(B,f,U,z,W,r):this.backendConnector&&this.backendConnector.saveMissing&&this.backendConnector.saveMissing(B,f,U,z,W,r),this.emit("missingKey",B,f,U,v)};this.options.saveMissing&&(this.options.saveMissingPlurals&&L?I.forEach(B=>{this.pluralResolver.getSuffixes(B,r).forEach(U=>{j([B],c+U,r[`defaultValue${U}`]||X)})}):j(I,c,X))}v=this.extendTranslation(v,t,r,E,s),A&&v===c&&this.options.appendNamespaceToMissingKey&&(v=`${f}:${c}`),(A||T)&&this.options.parseMissingKeyHandler&&(this.options.compatibilityAPI!=="v1"?v=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${f}:${c}`:c,T?v:void 0):v=this.options.parseMissingKeyHandler(v))}return i?(E.res=v,E.usedParams=this.getUsedParamsDetails(r),E):v}extendTranslation(t,r,s,i,a){var c=this;if(this.i18nFormat&&this.i18nFormat.parse)t=this.i18nFormat.parse(t,{...this.options.interpolation.defaultVariables,...s},s.lng||this.language||i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!s.skipInterpolation){s.interpolation&&this.interpolator.init({...s,interpolation:{...this.options.interpolation,...s.interpolation}});const p=typeof t=="string"&&(s&&s.interpolation&&s.interpolation.skipOnVariables!==void 0?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let m;if(p){const v=t.match(this.interpolator.nestingRegexp);m=v&&v.length}let E=s.replace&&typeof s.replace!="string"?s.replace:s;if(this.options.interpolation.defaultVariables&&(E={...this.options.interpolation.defaultVariables,...E}),t=this.interpolator.interpolate(t,E,s.lng||this.language,s),p){const v=t.match(this.interpolator.nestingRegexp),x=v&&v.length;m<x&&(s.nest=!1)}!s.lng&&this.options.compatibilityAPI!=="v1"&&i&&i.res&&(s.lng=i.usedLng),s.nest!==!1&&(t=this.interpolator.nest(t,function(){for(var v=arguments.length,x=new Array(v),_=0;_<v;_++)x[_]=arguments[_];return a&&a[0]===x[0]&&!s.context?(c.logger.warn(`It seems you are nesting recursively key: ${x[0]} in key: ${r[0]}`),null):c.translate(...x,r)},s)),s.interpolation&&this.interpolator.reset()}const u=s.postProcess||this.options.postProcess,f=typeof u=="string"?[u]:u;return t!=null&&f&&f.length&&s.applyPostProcessor!==!1&&(t=Bm.handle(f,t,r,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...i,usedParams:this.getUsedParamsDetails(s)},...s}:s,this)),t}resolve(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s,i,a,c,u;return typeof t=="string"&&(t=[t]),t.forEach(f=>{if(this.isValidLookup(s))return;const p=this.extractFromKey(f,r),m=p.key;i=m;let E=p.namespaces;this.options.fallbackNS&&(E=E.concat(this.options.fallbackNS));const v=r.count!==void 0&&typeof r.count!="string",x=v&&!r.ordinal&&r.count===0&&this.pluralResolver.shouldUseIntlApi(),_=r.context!==void 0&&(typeof r.context=="string"||typeof r.context=="number")&&r.context!=="",w=r.lngs?r.lngs:this.languageUtils.toResolveHierarchy(r.lng||this.language,r.fallbackLng);E.forEach(S=>{this.isValidLookup(s)||(u=S,!zm[`${w[0]}-${S}`]&&this.utils&&this.utils.hasLoadedNamespace&&!this.utils.hasLoadedNamespace(u)&&(zm[`${w[0]}-${S}`]=!0,this.logger.warn(`key "${i}" for languages "${w.join(", ")}" won't get resolved as namespace "${u}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),w.forEach(N=>{if(this.isValidLookup(s))return;c=N;const O=[m];if(this.i18nFormat&&this.i18nFormat.addLookupKeys)this.i18nFormat.addLookupKeys(O,m,N,S,r);else{let T;v&&(T=this.pluralResolver.getSuffix(N,r.count,r));const A=`${this.options.pluralSeparator}zero`,L=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(v&&(O.push(m+T),r.ordinal&&T.indexOf(L)===0&&O.push(m+T.replace(L,this.options.pluralSeparator)),x&&O.push(m+A)),_){const F=`${m}${this.options.contextSeparator}${r.context}`;O.push(F),v&&(O.push(F+T),r.ordinal&&T.indexOf(L)===0&&O.push(F+T.replace(L,this.options.pluralSeparator)),x&&O.push(F+A))}}let D;for(;D=O.pop();)this.isValidLookup(s)||(a=D,s=this.getResource(N,S,D,r))}))})}),{res:s,usedKey:i,exactUsedKey:a,usedLng:c,usedNS:u}}isValidLookup(t){return t!==void 0&&!(!this.options.returnNull&&t===null)&&!(!this.options.returnEmptyString&&t==="")}getResource(t,r,s){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return this.i18nFormat&&this.i18nFormat.getResource?this.i18nFormat.getResource(t,r,s,i):this.resourceStore.getResource(t,r,s,i)}getUsedParamsDetails(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const r=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],s=t.replace&&typeof t.replace!="string";let i=s?t.replace:t;if(s&&typeof t.count<"u"&&(i.count=t.count),this.options.interpolation.defaultVariables&&(i={...this.options.interpolation.defaultVariables,...i}),!s){i={...i};for(const a of r)delete i[a]}return i}static hasDefaultValue(t){const r="defaultValue";for(const s in t)if(Object.prototype.hasOwnProperty.call(t,s)&&r===s.substring(0,r.length)&&t[s]!==void 0)return!0;return!1}}function xu(e){return e.charAt(0).toUpperCase()+e.slice(1)}class Wm{constructor(t){this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Rn.create("languageUtils")}getScriptPartFromCode(t){if(t=wl(t),!t||t.indexOf("-")<0)return null;const r=t.split("-");return r.length===2||(r.pop(),r[r.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(r.join("-"))}getLanguagePartFromCode(t){if(t=wl(t),!t||t.indexOf("-")<0)return t;const r=t.split("-");return this.formatLanguageCode(r[0])}formatLanguageCode(t){if(typeof t=="string"&&t.indexOf("-")>-1){const r=["hans","hant","latn","cyrl","cans","mong","arab"];let s=t.split("-");return this.options.lowerCaseLng?s=s.map(i=>i.toLowerCase()):s.length===2?(s[0]=s[0].toLowerCase(),s[1]=s[1].toUpperCase(),r.indexOf(s[1].toLowerCase())>-1&&(s[1]=xu(s[1].toLowerCase()))):s.length===3&&(s[0]=s[0].toLowerCase(),s[1].length===2&&(s[1]=s[1].toUpperCase()),s[0]!=="sgn"&&s[2].length===2&&(s[2]=s[2].toUpperCase()),r.indexOf(s[1].toLowerCase())>-1&&(s[1]=xu(s[1].toLowerCase())),r.indexOf(s[2].toLowerCase())>-1&&(s[2]=xu(s[2].toLowerCase()))),s.join("-")}return this.options.cleanCode||this.options.lowerCaseLng?t.toLowerCase():t}isSupportedCode(t){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(t=this.getLanguagePartFromCode(t)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(t)>-1}getBestMatchFromCodes(t){if(!t)return null;let r;return t.forEach(s=>{if(r)return;const i=this.formatLanguageCode(s);(!this.options.supportedLngs||this.isSupportedCode(i))&&(r=i)}),!r&&this.options.supportedLngs&&t.forEach(s=>{if(r)return;const i=this.getLanguagePartFromCode(s);if(this.isSupportedCode(i))return r=i;r=this.options.supportedLngs.find(a=>{if(a===i)return a;if(!(a.indexOf("-")<0&&i.indexOf("-")<0)&&a.indexOf(i)===0)return a})}),r||(r=this.getFallbackCodes(this.options.fallbackLng)[0]),r}getFallbackCodes(t,r){if(!t)return[];if(typeof t=="function"&&(t=t(r)),typeof t=="string"&&(t=[t]),Object.prototype.toString.apply(t)==="[object Array]")return t;if(!r)return t.default||[];let s=t[r];return s||(s=t[this.getScriptPartFromCode(r)]),s||(s=t[this.formatLanguageCode(r)]),s||(s=t[this.getLanguagePartFromCode(r)]),s||(s=t.default),s||[]}toResolveHierarchy(t,r){const s=this.getFallbackCodes(r||this.options.fallbackLng||[],t),i=[],a=c=>{c&&(this.isSupportedCode(c)?i.push(c):this.logger.warn(`rejecting language code not found in supportedLngs: ${c}`))};return typeof t=="string"&&(t.indexOf("-")>-1||t.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&a(this.formatLanguageCode(t)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&a(this.getScriptPartFromCode(t)),this.options.load!=="currentOnly"&&a(this.getLanguagePartFromCode(t))):typeof t=="string"&&a(this.formatLanguageCode(t)),s.forEach(c=>{i.indexOf(c)<0&&a(this.formatLanguageCode(c))}),i}}let g1=[{lngs:["ach","ak","am","arn","br","fil","gun","ln","mfe","mg","mi","oc","pt","pt-BR","tg","tl","ti","tr","uz","wa"],nr:[1,2],fc:1},{lngs:["af","an","ast","az","bg","bn","ca","da","de","dev","el","en","eo","es","et","eu","fi","fo","fur","fy","gl","gu","ha","hi","hu","hy","ia","it","kk","kn","ku","lb","mai","ml","mn","mr","nah","nap","nb","ne","nl","nn","no","nso","pa","pap","pms","ps","pt-PT","rm","sco","se","si","so","son","sq","sv","sw","ta","te","tk","ur","yo"],nr:[1,2],fc:2},{lngs:["ay","bo","cgg","fa","ht","id","ja","jbo","ka","km","ko","ky","lo","ms","sah","su","th","tt","ug","vi","wo","zh"],nr:[1],fc:3},{lngs:["be","bs","cnr","dz","hr","ru","sr","uk"],nr:[1,2,5],fc:4},{lngs:["ar"],nr:[0,1,2,3,11,100],fc:5},{lngs:["cs","sk"],nr:[1,2,5],fc:6},{lngs:["csb","pl"],nr:[1,2,5],fc:7},{lngs:["cy"],nr:[1,2,3,8],fc:8},{lngs:["fr"],nr:[1,2],fc:9},{lngs:["ga"],nr:[1,2,3,7,11],fc:10},{lngs:["gd"],nr:[1,2,3,20],fc:11},{lngs:["is"],nr:[1,2],fc:12},{lngs:["jv"],nr:[0,1],fc:13},{lngs:["kw"],nr:[1,2,3,4],fc:14},{lngs:["lt"],nr:[1,2,10],fc:15},{lngs:["lv"],nr:[1,2,0],fc:16},{lngs:["mk"],nr:[1,2],fc:17},{lngs:["mnk"],nr:[0,1,2],fc:18},{lngs:["mt"],nr:[1,2,11,20],fc:19},{lngs:["or"],nr:[2,1],fc:2},{lngs:["ro"],nr:[1,2,20],fc:20},{lngs:["sl"],nr:[5,1,2,3],fc:21},{lngs:["he","iw"],nr:[1,2,20,21],fc:22}],E1={1:function(e){return+(e>1)},2:function(e){return+(e!=1)},3:function(e){return 0},4:function(e){return e%10==1&&e%100!=11?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2},5:function(e){return e==0?0:e==1?1:e==2?2:e%100>=3&&e%100<=10?3:e%100>=11?4:5},6:function(e){return e==1?0:e>=2&&e<=4?1:2},7:function(e){return e==1?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2},8:function(e){return e==1?0:e==2?1:e!=8&&e!=11?2:3},9:function(e){return+(e>=2)},10:function(e){return e==1?0:e==2?1:e<7?2:e<11?3:4},11:function(e){return e==1||e==11?0:e==2||e==12?1:e>2&&e<20?2:3},12:function(e){return+(e%10!=1||e%100==11)},13:function(e){return+(e!==0)},14:function(e){return e==1?0:e==2?1:e==3?2:3},15:function(e){return e%10==1&&e%100!=11?0:e%10>=2&&(e%100<10||e%100>=20)?1:2},16:function(e){return e%10==1&&e%100!=11?0:e!==0?1:2},17:function(e){return e==1||e%10==1&&e%100!=11?0:1},18:function(e){return e==0?0:e==1?1:2},19:function(e){return e==1?0:e==0||e%100>1&&e%100<11?1:e%100>10&&e%100<20?2:3},20:function(e){return e==1?0:e==0||e%100>0&&e%100<20?1:2},21:function(e){return e%100==1?1:e%100==2?2:e%100==3||e%100==4?3:0},22:function(e){return e==1?0:e==2?1:(e<0||e>10)&&e%10==0?2:3}};const y1=["v1","v2","v3"],v1=["v4"],Gm={zero:0,one:1,two:2,few:3,many:4,other:5};function x1(){const e={};return g1.forEach(t=>{t.lngs.forEach(r=>{e[r]={numbers:t.nr,plurals:E1[t.fc]}})}),e}class S1{constructor(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.languageUtils=t,this.options=r,this.logger=Rn.create("pluralResolver"),(!this.options.compatibilityJSON||v1.includes(this.options.compatibilityJSON))&&(typeof Intl>"u"||!Intl.PluralRules)&&(this.options.compatibilityJSON="v3",this.logger.error("Your environment seems not to be Intl API compatible, use an Intl.PluralRules polyfill. Will fallback to the compatibilityJSON v3 format handling.")),this.rules=x1()}addRule(t,r){this.rules[t]=r}getRule(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(this.shouldUseIntlApi())try{return new Intl.PluralRules(wl(t),{type:r.ordinal?"ordinal":"cardinal"})}catch{return}return this.rules[t]||this.rules[this.languageUtils.getLanguagePartFromCode(t)]}needsPlural(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const s=this.getRule(t,r);return this.shouldUseIntlApi()?s&&s.resolvedOptions().pluralCategories.length>1:s&&s.numbers.length>1}getPluralFormsOfKey(t,r){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return this.getSuffixes(t,s).map(i=>`${r}${i}`)}getSuffixes(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const s=this.getRule(t,r);return s?this.shouldUseIntlApi()?s.resolvedOptions().pluralCategories.sort((i,a)=>Gm[i]-Gm[a]).map(i=>`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${i}`):s.numbers.map(i=>this.getSuffix(t,i,r)):[]}getSuffix(t,r){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const i=this.getRule(t,s);return i?this.shouldUseIntlApi()?`${this.options.prepend}${s.ordinal?`ordinal${this.options.prepend}`:""}${i.select(r)}`:this.getSuffixRetroCompatible(i,r):(this.logger.warn(`no plural rule found for: ${t}`),"")}getSuffixRetroCompatible(t,r){const s=t.noAbs?t.plurals(r):t.plurals(Math.abs(r));let i=t.numbers[s];this.options.simplifyPluralSuffix&&t.numbers.length===2&&t.numbers[0]===1&&(i===2?i="plural":i===1&&(i=""));const a=()=>this.options.prepend&&i.toString()?this.options.prepend+i.toString():i.toString();return this.options.compatibilityJSON==="v1"?i===1?"":typeof i=="number"?`_plural_${i.toString()}`:a():this.options.compatibilityJSON==="v2"||this.options.simplifyPluralSuffix&&t.numbers.length===2&&t.numbers[0]===1?a():this.options.prepend&&s.toString()?this.options.prepend+s.toString():s.toString()}shouldUseIntlApi(){return!y1.includes(this.options.compatibilityJSON)}}function Ym(e,t,r){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:".",i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,a=d1(e,t,r);return!a&&i&&typeof r=="string"&&(a=_l(e,r,s),a===void 0&&(a=_l(t,r,s))),a}class _1{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=Rn.create("interpolator"),this.options=t,this.format=t.interpolation&&t.interpolation.format||(r=>r),this.init(t)}init(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};t.interpolation||(t.interpolation={escapeValue:!0});const r=t.interpolation;this.escape=r.escape!==void 0?r.escape:p1,this.escapeValue=r.escapeValue!==void 0?r.escapeValue:!0,this.useRawValueToEscape=r.useRawValueToEscape!==void 0?r.useRawValueToEscape:!1,this.prefix=r.prefix?Mo(r.prefix):r.prefixEscaped||"{{",this.suffix=r.suffix?Mo(r.suffix):r.suffixEscaped||"}}",this.formatSeparator=r.formatSeparator?r.formatSeparator:r.formatSeparator||",",this.unescapePrefix=r.unescapeSuffix?"":r.unescapePrefix||"-",this.unescapeSuffix=this.unescapePrefix?"":r.unescapeSuffix||"",this.nestingPrefix=r.nestingPrefix?Mo(r.nestingPrefix):r.nestingPrefixEscaped||Mo("$t("),this.nestingSuffix=r.nestingSuffix?Mo(r.nestingSuffix):r.nestingSuffixEscaped||Mo(")"),this.nestingOptionsSeparator=r.nestingOptionsSeparator?r.nestingOptionsSeparator:r.nestingOptionsSeparator||",",this.maxReplaces=r.maxReplaces?r.maxReplaces:1e3,this.alwaysFormat=r.alwaysFormat!==void 0?r.alwaysFormat:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const t=`${this.prefix}(.+?)${this.suffix}`;this.regexp=new RegExp(t,"g");const r=`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`;this.regexpUnescape=new RegExp(r,"g");const s=`${this.nestingPrefix}(.+?)${this.nestingSuffix}`;this.nestingRegexp=new RegExp(s,"g")}interpolate(t,r,s,i){let a,c,u;const f=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{};function p(_){return _.replace(/\$/g,"$$$$")}const m=_=>{if(_.indexOf(this.formatSeparator)<0){const O=Ym(r,f,_,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(O,void 0,s,{...i,...r,interpolationkey:_}):O}const w=_.split(this.formatSeparator),S=w.shift().trim(),N=w.join(this.formatSeparator).trim();return this.format(Ym(r,f,S,this.options.keySeparator,this.options.ignoreJSONStructure),N,s,{...i,...r,interpolationkey:S})};this.resetRegExp();const E=i&&i.missingInterpolationHandler||this.options.missingInterpolationHandler,v=i&&i.interpolation&&i.interpolation.skipOnVariables!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:_=>p(_)},{regex:this.regexp,safeValue:_=>this.escapeValue?p(this.escape(_)):p(_)}].forEach(_=>{for(u=0;a=_.regex.exec(t);){const w=a[1].trim();if(c=m(w),c===void 0)if(typeof E=="function"){const N=E(t,a,i);c=typeof N=="string"?N:""}else if(i&&Object.prototype.hasOwnProperty.call(i,w))c="";else if(v){c=a[0];continue}else this.logger.warn(`missed to pass in variable ${w} for interpolating ${t}`),c="";else typeof c!="string"&&!this.useRawValueToEscape&&(c=jm(c));const S=_.safeValue(c);if(t=t.replace(a[0],S),v?(_.regex.lastIndex+=c.length,_.regex.lastIndex-=a[0].length):_.regex.lastIndex=0,u++,u>=this.maxReplaces)break}}),t}nest(t,r){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},i,a,c;function u(f,p){const m=this.nestingOptionsSeparator;if(f.indexOf(m)<0)return f;const E=f.split(new RegExp(`${m}[ ]*{`));let v=`{${E[1]}`;f=E[0],v=this.interpolate(v,c);const x=v.match(/'/g),_=v.match(/"/g);(x&&x.length%2===0&&!_||_.length%2!==0)&&(v=v.replace(/'/g,'"'));try{c=JSON.parse(v),p&&(c={...p,...c})}catch(w){return this.logger.warn(`failed parsing options string in nesting for key ${f}`,w),`${f}${m}${v}`}return delete c.defaultValue,f}for(;i=this.nestingRegexp.exec(t);){let f=[];c={...s},c=c.replace&&typeof c.replace!="string"?c.replace:c,c.applyPostProcessor=!1,delete c.defaultValue;let p=!1;if(i[0].indexOf(this.formatSeparator)!==-1&&!/{.*}/.test(i[1])){const m=i[1].split(this.formatSeparator).map(E=>E.trim());i[1]=m.shift(),f=m,p=!0}if(a=r(u.call(this,i[1].trim(),c),c),a&&i[0]===t&&typeof a!="string")return a;typeof a!="string"&&(a=jm(a)),a||(this.logger.warn(`missed to resolve ${i[1]} for nesting ${t}`),a=""),p&&(a=f.reduce((m,E)=>this.format(m,E,s.lng,{...s,interpolationkey:i[1].trim()}),a.trim())),t=t.replace(i[0],a),this.regexp.lastIndex=0}return t}}function w1(e){let t=e.toLowerCase().trim();const r={};if(e.indexOf("(")>-1){const s=e.split("(");t=s[0].toLowerCase().trim();const i=s[1].substring(0,s[1].length-1);t==="currency"&&i.indexOf(":")<0?r.currency||(r.currency=i.trim()):t==="relativetime"&&i.indexOf(":")<0?r.range||(r.range=i.trim()):i.split(";").forEach(c=>{if(!c)return;const[u,...f]=c.split(":"),p=f.join(":").trim().replace(/^'+|'+$/g,"");r[u.trim()]||(r[u.trim()]=p),p==="false"&&(r[u.trim()]=!1),p==="true"&&(r[u.trim()]=!0),isNaN(p)||(r[u.trim()]=parseInt(p,10))})}return{formatName:t,formatOptions:r}}function Po(e){const t={};return function(s,i,a){const c=i+JSON.stringify(a);let u=t[c];return u||(u=e(wl(i),a),t[c]=u),u(s)}}class N1{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=Rn.create("formatter"),this.options=t,this.formats={number:Po((r,s)=>{const i=new Intl.NumberFormat(r,{...s});return a=>i.format(a)}),currency:Po((r,s)=>{const i=new Intl.NumberFormat(r,{...s,style:"currency"});return a=>i.format(a)}),datetime:Po((r,s)=>{const i=new Intl.DateTimeFormat(r,{...s});return a=>i.format(a)}),relativetime:Po((r,s)=>{const i=new Intl.RelativeTimeFormat(r,{...s});return a=>i.format(a,s.range||"day")}),list:Po((r,s)=>{const i=new Intl.ListFormat(r,{...s});return a=>i.format(a)})},this.init(t)}init(t){const s=(arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}}).interpolation;this.formatSeparator=s.formatSeparator?s.formatSeparator:s.formatSeparator||","}add(t,r){this.formats[t.toLowerCase().trim()]=r}addCached(t,r){this.formats[t.toLowerCase().trim()]=Po(r)}format(t,r,s){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return r.split(this.formatSeparator).reduce((u,f)=>{const{formatName:p,formatOptions:m}=w1(f);if(this.formats[p]){let E=u;try{const v=i&&i.formatParams&&i.formatParams[i.interpolationkey]||{},x=v.locale||v.lng||i.locale||i.lng||s;E=this.formats[p](u,x,{...m,...i,...v})}catch(v){this.logger.warn(v)}return E}else this.logger.warn(`there was no format function for ${p}`);return u},t)}}function R1(e,t){e.pending[t]!==void 0&&(delete e.pending[t],e.pendingCount--)}class T1 extends xl{constructor(t,r,s){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};super(),this.backend=t,this.store=r,this.services=s,this.languageUtils=s.languageUtils,this.options=i,this.logger=Rn.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=i.maxParallelReads||10,this.readingCalls=0,this.maxRetries=i.maxRetries>=0?i.maxRetries:5,this.retryTimeout=i.retryTimeout>=1?i.retryTimeout:350,this.state={},this.queue=[],this.backend&&this.backend.init&&this.backend.init(s,i.backend,i)}queueLoad(t,r,s,i){const a={},c={},u={},f={};return t.forEach(p=>{let m=!0;r.forEach(E=>{const v=`${p}|${E}`;!s.reload&&this.store.hasResourceBundle(p,E)?this.state[v]=2:this.state[v]<0||(this.state[v]===1?c[v]===void 0&&(c[v]=!0):(this.state[v]=1,m=!1,c[v]===void 0&&(c[v]=!0),a[v]===void 0&&(a[v]=!0),f[E]===void 0&&(f[E]=!0)))}),m||(u[p]=!0)}),(Object.keys(a).length||Object.keys(c).length)&&this.queue.push({pending:c,pendingCount:Object.keys(c).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(a),pending:Object.keys(c),toLoadLanguages:Object.keys(u),toLoadNamespaces:Object.keys(f)}}loaded(t,r,s){const i=t.split("|"),a=i[0],c=i[1];r&&this.emit("failedLoading",a,c,r),s&&this.store.addResourceBundle(a,c,s),this.state[t]=r?-1:2;const u={};this.queue.forEach(f=>{u1(f.loaded,[a],c),R1(f,t),r&&f.errors.push(r),f.pendingCount===0&&!f.done&&(Object.keys(f.loaded).forEach(p=>{u[p]||(u[p]={});const m=f.loaded[p];m.length&&m.forEach(E=>{u[p][E]===void 0&&(u[p][E]=!0)})}),f.done=!0,f.errors.length?f.callback(f.errors):f.callback())}),this.emit("loaded",u),this.queue=this.queue.filter(f=>!f.done)}read(t,r,s){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:this.retryTimeout,c=arguments.length>5?arguments[5]:void 0;if(!t.length)return c(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:t,ns:r,fcName:s,tried:i,wait:a,callback:c});return}this.readingCalls++;const u=(p,m)=>{if(this.readingCalls--,this.waitingReads.length>0){const E=this.waitingReads.shift();this.read(E.lng,E.ns,E.fcName,E.tried,E.wait,E.callback)}if(p&&m&&i<this.maxRetries){setTimeout(()=>{this.read.call(this,t,r,s,i+1,a*2,c)},a);return}c(p,m)},f=this.backend[s].bind(this.backend);if(f.length===2){try{const p=f(t,r);p&&typeof p.then=="function"?p.then(m=>u(null,m)).catch(u):u(null,p)}catch(p){u(p)}return}return f(t,r,u)}prepareLoading(t,r){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},i=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),i&&i();typeof t=="string"&&(t=this.languageUtils.toResolveHierarchy(t)),typeof r=="string"&&(r=[r]);const a=this.queueLoad(t,r,s,i);if(!a.toLoad.length)return a.pending.length||i(),null;a.toLoad.forEach(c=>{this.loadOne(c)})}load(t,r,s){this.prepareLoading(t,r,{},s)}reload(t,r,s){this.prepareLoading(t,r,{reload:!0},s)}loadOne(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";const s=t.split("|"),i=s[0],a=s[1];this.read(i,a,"read",void 0,void 0,(c,u)=>{c&&this.logger.warn(`${r}loading namespace ${a} for language ${i} failed`,c),!c&&u&&this.logger.log(`${r}loaded namespace ${a} for language ${i}`,u),this.loaded(t,c,u)})}saveMissing(t,r,s,i,a){let c=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{},u=arguments.length>6&&arguments[6]!==void 0?arguments[6]:()=>{};if(this.services.utils&&this.services.utils.hasLoadedNamespace&&!this.services.utils.hasLoadedNamespace(r)){this.logger.warn(`did not save key "${s}" as the namespace "${r}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(s==null||s==="")){if(this.backend&&this.backend.create){const f={...c,isUpdate:a},p=this.backend.create.bind(this.backend);if(p.length<6)try{let m;p.length===5?m=p(t,r,s,i,f):m=p(t,r,s,i),m&&typeof m.then=="function"?m.then(E=>u(null,E)).catch(u):u(null,m)}catch(m){u(m)}else p(t,r,s,i,u,f)}!t||!t[0]||this.store.addResource(t[0],r,s,i)}}}function Km(){return{debug:!1,initImmediate:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:function(t){let r={};if(typeof t[1]=="object"&&(r=t[1]),typeof t[1]=="string"&&(r.defaultValue=t[1]),typeof t[2]=="string"&&(r.tDescription=t[2]),typeof t[2]=="object"||typeof t[3]=="object"){const s=t[3]||t[2];Object.keys(s).forEach(i=>{r[i]=s[i]})}return r},interpolation:{escapeValue:!0,format:(e,t,r,s)=>e,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0}}}function Xm(e){return typeof e.ns=="string"&&(e.ns=[e.ns]),typeof e.fallbackLng=="string"&&(e.fallbackLng=[e.fallbackLng]),typeof e.fallbackNS=="string"&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs&&e.supportedLngs.indexOf("cimode")<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),e}function Rl(){}function O1(e){Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(r=>{typeof e[r]=="function"&&(e[r]=e[r].bind(e))})}class Bs extends xl{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;if(super(),this.options=Xm(t),this.services={},this.logger=Rn,this.modules={external:[]},O1(this),r&&!this.isInitialized&&!t.isClone){if(!this.options.initImmediate)return this.init(t,r),this;setTimeout(()=>{this.init(t,r)},0)}}init(){var t=this;let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},s=arguments.length>1?arguments[1]:void 0;typeof r=="function"&&(s=r,r={}),!r.defaultNS&&r.defaultNS!==!1&&r.ns&&(typeof r.ns=="string"?r.defaultNS=r.ns:r.ns.indexOf("translation")<0&&(r.defaultNS=r.ns[0]));const i=Km();this.options={...i,...this.options,...Xm(r)},this.options.compatibilityAPI!=="v1"&&(this.options.interpolation={...i.interpolation,...this.options.interpolation}),r.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=r.keySeparator),r.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=r.nsSeparator);function a(m){return m?typeof m=="function"?new m:m:null}if(!this.options.isClone){this.modules.logger?Rn.init(a(this.modules.logger),this.options):Rn.init(null,this.options);let m;this.modules.formatter?m=this.modules.formatter:typeof Intl<"u"&&(m=N1);const E=new Wm(this.options);this.store=new Hm(this.options.resources,this.options);const v=this.services;v.logger=Rn,v.resourceStore=this.store,v.languageUtils=E,v.pluralResolver=new S1(E,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),m&&(!this.options.interpolation.format||this.options.interpolation.format===i.interpolation.format)&&(v.formatter=a(m),v.formatter.init(v,this.options),this.options.interpolation.format=v.formatter.format.bind(v.formatter)),v.interpolator=new _1(this.options),v.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},v.backendConnector=new T1(a(this.modules.backend),v.resourceStore,v,this.options),v.backendConnector.on("*",function(x){for(var _=arguments.length,w=new Array(_>1?_-1:0),S=1;S<_;S++)w[S-1]=arguments[S];t.emit(x,...w)}),this.modules.languageDetector&&(v.languageDetector=a(this.modules.languageDetector),v.languageDetector.init&&v.languageDetector.init(v,this.options.detection,this.options)),this.modules.i18nFormat&&(v.i18nFormat=a(this.modules.i18nFormat),v.i18nFormat.init&&v.i18nFormat.init(this)),this.translator=new Nl(this.services,this.options),this.translator.on("*",function(x){for(var _=arguments.length,w=new Array(_>1?_-1:0),S=1;S<_;S++)w[S-1]=arguments[S];t.emit(x,...w)}),this.modules.external.forEach(x=>{x.init&&x.init(this)})}if(this.format=this.options.interpolation.format,s||(s=Rl),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const m=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);m.length>0&&m[0]!=="dev"&&(this.options.lng=m[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(m=>{this[m]=function(){return t.store[m](...arguments)}}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(m=>{this[m]=function(){return t.store[m](...arguments),t}});const f=Hs(),p=()=>{const m=(E,v)=>{this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),f.resolve(v),s(E,v)};if(this.languages&&this.options.compatibilityAPI!=="v1"&&!this.isInitialized)return m(null,this.t.bind(this));this.changeLanguage(this.options.lng,m)};return this.options.resources||!this.options.initImmediate?p():setTimeout(p,0),f}loadResources(t){let s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Rl;const i=typeof t=="string"?t:this.language;if(typeof t=="function"&&(s=t),!this.options.resources||this.options.partialBundledLanguages){if(i&&i.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return s();const a=[],c=u=>{if(!u||u==="cimode")return;this.services.languageUtils.toResolveHierarchy(u).forEach(p=>{p!=="cimode"&&a.indexOf(p)<0&&a.push(p)})};i?c(i):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(f=>c(f)),this.options.preload&&this.options.preload.forEach(u=>c(u)),this.services.backendConnector.load(a,this.options.ns,u=>{!u&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),s(u)})}else s(null)}reloadResources(t,r,s){const i=Hs();return t||(t=this.languages),r||(r=this.options.ns),s||(s=Rl),this.services.backendConnector.reload(t,r,a=>{i.resolve(),s(a)}),i}use(t){if(!t)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!t.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return t.type==="backend"&&(this.modules.backend=t),(t.type==="logger"||t.log&&t.warn&&t.error)&&(this.modules.logger=t),t.type==="languageDetector"&&(this.modules.languageDetector=t),t.type==="i18nFormat"&&(this.modules.i18nFormat=t),t.type==="postProcessor"&&Bm.addPostProcessor(t),t.type==="formatter"&&(this.modules.formatter=t),t.type==="3rdParty"&&this.modules.external.push(t),this}setResolvedLanguage(t){if(!(!t||!this.languages)&&!(["cimode","dev"].indexOf(t)>-1))for(let r=0;r<this.languages.length;r++){const s=this.languages[r];if(!(["cimode","dev"].indexOf(s)>-1)&&this.store.hasLanguageSomeTranslations(s)){this.resolvedLanguage=s;break}}}changeLanguage(t,r){var s=this;this.isLanguageChangingTo=t;const i=Hs();this.emit("languageChanging",t);const a=f=>{this.language=f,this.languages=this.services.languageUtils.toResolveHierarchy(f),this.resolvedLanguage=void 0,this.setResolvedLanguage(f)},c=(f,p)=>{p?(a(p),this.translator.changeLanguage(p),this.isLanguageChangingTo=void 0,this.emit("languageChanged",p),this.logger.log("languageChanged",p)):this.isLanguageChangingTo=void 0,i.resolve(function(){return s.t(...arguments)}),r&&r(f,function(){return s.t(...arguments)})},u=f=>{!t&&!f&&this.services.languageDetector&&(f=[]);const p=typeof f=="string"?f:this.services.languageUtils.getBestMatchFromCodes(f);p&&(this.language||a(p),this.translator.language||this.translator.changeLanguage(p),this.services.languageDetector&&this.services.languageDetector.cacheUserLanguage&&this.services.languageDetector.cacheUserLanguage(p)),this.loadResources(p,m=>{c(m,p)})};return!t&&this.services.languageDetector&&!this.services.languageDetector.async?u(this.services.languageDetector.detect()):!t&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(u):this.services.languageDetector.detect(u):u(t),i}getFixedT(t,r,s){var i=this;const a=function(c,u){let f;if(typeof u!="object"){for(var p=arguments.length,m=new Array(p>2?p-2:0),E=2;E<p;E++)m[E-2]=arguments[E];f=i.options.overloadTranslationOptionHandler([c,u].concat(m))}else f={...u};f.lng=f.lng||a.lng,f.lngs=f.lngs||a.lngs,f.ns=f.ns||a.ns,f.keyPrefix=f.keyPrefix||s||a.keyPrefix;const v=i.options.keySeparator||".";let x;return f.keyPrefix&&Array.isArray(c)?x=c.map(_=>`${f.keyPrefix}${v}${_}`):x=f.keyPrefix?`${f.keyPrefix}${v}${c}`:c,i.t(x,f)};return typeof t=="string"?a.lng=t:a.lngs=t,a.ns=r,a.keyPrefix=s,a}t(){return this.translator&&this.translator.translate(...arguments)}exists(){return this.translator&&this.translator.exists(...arguments)}setDefaultNamespace(t){this.options.defaultNS=t}hasLoadedNamespace(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const s=r.lng||this.resolvedLanguage||this.languages[0],i=this.options?this.options.fallbackLng:!1,a=this.languages[this.languages.length-1];if(s.toLowerCase()==="cimode")return!0;const c=(u,f)=>{const p=this.services.backendConnector.state[`${u}|${f}`];return p===-1||p===2};if(r.precheck){const u=r.precheck(this,c);if(u!==void 0)return u}return!!(this.hasResourceBundle(s,t)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||c(s,t)&&(!i||c(a,t)))}loadNamespaces(t,r){const s=Hs();return this.options.ns?(typeof t=="string"&&(t=[t]),t.forEach(i=>{this.options.ns.indexOf(i)<0&&this.options.ns.push(i)}),this.loadResources(i=>{s.resolve(),r&&r(i)}),s):(r&&r(),Promise.resolve())}loadLanguages(t,r){const s=Hs();typeof t=="string"&&(t=[t]);const i=this.options.preload||[],a=t.filter(c=>i.indexOf(c)<0);return a.length?(this.options.preload=i.concat(a),this.loadResources(c=>{s.resolve(),r&&r(c)}),s):(r&&r(),Promise.resolve())}dir(t){if(t||(t=this.resolvedLanguage||(this.languages&&this.languages.length>0?this.languages[0]:this.language)),!t)return"rtl";const r=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],s=this.services&&this.services.languageUtils||new Wm(Km());return r.indexOf(s.getLanguagePartFromCode(t))>-1||t.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;return new Bs(t,r)}cloneInstance(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Rl;const s=t.forkResourceStore;s&&delete t.forkResourceStore;const i={...this.options,...t,isClone:!0},a=new Bs(i);return(t.debug!==void 0||t.prefix!==void 0)&&(a.logger=a.logger.clone(t)),["store","services","language"].forEach(u=>{a[u]=this[u]}),a.services={...this.services},a.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},s&&(a.store=new Hm(this.store.data,i),a.services.resourceStore=a.store),a.translator=new Nl(a.services,i),a.translator.on("*",function(u){for(var f=arguments.length,p=new Array(f>1?f-1:0),m=1;m<f;m++)p[m-1]=arguments[m];a.emit(u,...p)}),a.init(i,r),a.translator.options=i,a.translator.backendConnector.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},a}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const ut=Bs.createInstance();ut.createInstance=Bs.createInstance,ut.createInstance,ut.dir,ut.init,ut.loadResources,ut.reloadResources,ut.use,ut.changeLanguage,ut.getFixedT;const M=ut.t;ut.exists,ut.setDefaultNamespace,ut.hasLoadedNamespace,ut.loadNamespaces,ut.loadLanguages;function C1(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function zs(e){"@babel/helpers - typeof";return zs=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},zs(e)}function A1(e,t){if(zs(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var s=r.call(e,t);if(zs(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}function I1(e){var t=A1(e,"string");return zs(t)=="symbol"?t:t+""}function b1(e,t){for(var r=0;r<t.length;r++){var s=t[r];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,I1(s.key),s)}}function L1(e,t,r){return t&&b1(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var Qm=[],D1=Qm.forEach,k1=Qm.slice;function M1(e){return D1.call(k1.call(arguments,1),function(t){if(t)for(var r in t)e[r]===void 0&&(e[r]=t[r])}),e}var qm=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,P1=function(t,r,s){var i=s||{};i.path=i.path||"/";var a=encodeURIComponent(r),c="".concat(t,"=").concat(a);if(i.maxAge>0){var u=i.maxAge-0;if(Number.isNaN(u))throw new Error("maxAge should be a Number");c+="; Max-Age=".concat(Math.floor(u))}if(i.domain){if(!qm.test(i.domain))throw new TypeError("option domain is invalid");c+="; Domain=".concat(i.domain)}if(i.path){if(!qm.test(i.path))throw new TypeError("option path is invalid");c+="; Path=".concat(i.path)}if(i.expires){if(typeof i.expires.toUTCString!="function")throw new TypeError("option expires is invalid");c+="; Expires=".concat(i.expires.toUTCString())}if(i.httpOnly&&(c+="; HttpOnly"),i.secure&&(c+="; Secure"),i.sameSite){var f=typeof i.sameSite=="string"?i.sameSite.toLowerCase():i.sameSite;switch(f){case!0:c+="; SameSite=Strict";break;case"lax":c+="; SameSite=Lax";break;case"strict":c+="; SameSite=Strict";break;case"none":c+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}}return c},Zm={create:function(t,r,s,i){var a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{path:"/",sameSite:"strict"};s&&(a.expires=new Date,a.expires.setTime(a.expires.getTime()+s*60*1e3)),i&&(a.domain=i),document.cookie=P1(t,encodeURIComponent(r),a)},read:function(t){for(var r="".concat(t,"="),s=document.cookie.split(";"),i=0;i<s.length;i++){for(var a=s[i];a.charAt(0)===" ";)a=a.substring(1,a.length);if(a.indexOf(r)===0)return a.substring(r.length,a.length)}return null},remove:function(t){this.create(t,"",-1)}},U1={name:"cookie",lookup:function(t){var r;if(t.lookupCookie&&typeof document<"u"){var s=Zm.read(t.lookupCookie);s&&(r=s)}return r},cacheUserLanguage:function(t,r){r.lookupCookie&&typeof document<"u"&&Zm.create(r.lookupCookie,t,r.cookieMinutes,r.cookieDomain,r.cookieOptions)}},F1={name:"querystring",lookup:function(t){var r;if(typeof window<"u"){var s=window.location.search;!window.location.search&&window.location.hash&&window.location.hash.indexOf("?")>-1&&(s=window.location.hash.substring(window.location.hash.indexOf("?")));for(var i=s.substring(1),a=i.split("&"),c=0;c<a.length;c++){var u=a[c].indexOf("=");if(u>0){var f=a[c].substring(0,u);f===t.lookupQuerystring&&(r=a[c].substring(u+1))}}}return r}},Ws=null,Jm=function(){if(Ws!==null)return Ws;try{Ws=window!=="undefined"&&window.localStorage!==null;var t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{Ws=!1}return Ws},j1={name:"localStorage",lookup:function(t){var r;if(t.lookupLocalStorage&&Jm()){var s=window.localStorage.getItem(t.lookupLocalStorage);s&&(r=s)}return r},cacheUserLanguage:function(t,r){r.lookupLocalStorage&&Jm()&&window.localStorage.setItem(r.lookupLocalStorage,t)}},Gs=null,eg=function(){if(Gs!==null)return Gs;try{Gs=window!=="undefined"&&window.sessionStorage!==null;var t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{Gs=!1}return Gs},V1={name:"sessionStorage",lookup:function(t){var r;if(t.lookupSessionStorage&&eg()){var s=window.sessionStorage.getItem(t.lookupSessionStorage);s&&(r=s)}return r},cacheUserLanguage:function(t,r){r.lookupSessionStorage&&eg()&&window.sessionStorage.setItem(r.lookupSessionStorage,t)}},$1={name:"navigator",lookup:function(t){var r=[];if(typeof navigator<"u"){if(navigator.languages)for(var s=0;s<navigator.languages.length;s++)r.push(navigator.languages[s]);navigator.userLanguage&&r.push(navigator.userLanguage),navigator.language&&r.push(navigator.language)}return r.length>0?r:void 0}},H1={name:"htmlTag",lookup:function(t){var r,s=t.htmlTag||(typeof document<"u"?document.documentElement:null);return s&&typeof s.getAttribute=="function"&&(r=s.getAttribute("lang")),r}},B1={name:"path",lookup:function(t){var r;if(typeof window<"u"){var s=window.location.pathname.match(/\/([a-zA-Z-]*)/g);if(s instanceof Array)if(typeof t.lookupFromPathIndex=="number"){if(typeof s[t.lookupFromPathIndex]!="string")return;r=s[t.lookupFromPathIndex].replace("/","")}else r=s[0].replace("/","")}return r}},z1={name:"subdomain",lookup:function(t){var r=typeof t.lookupFromSubdomainIndex=="number"?t.lookupFromSubdomainIndex+1:1,s=typeof window<"u"&&window.location&&window.location.hostname&&window.location.hostname.match(/^(\w{2,5})\.(([a-z0-9-]{1,63}\.[a-z]{2,6})|localhost)/i);if(s)return s[r]}};function W1(){return{order:["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"],lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:function(t){return t}}}var tg=function(){function e(t){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};C1(this,e),this.type="languageDetector",this.detectors={},this.init(t,r)}return L1(e,[{key:"init",value:function(r){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.services=r||{languageUtils:{}},this.options=M1(s,this.options||{},W1()),typeof this.options.convertDetectedLanguage=="string"&&this.options.convertDetectedLanguage.indexOf("15897")>-1&&(this.options.convertDetectedLanguage=function(a){return a.replace("-","_")}),this.options.lookupFromUrlIndex&&(this.options.lookupFromPathIndex=this.options.lookupFromUrlIndex),this.i18nOptions=i,this.addDetector(U1),this.addDetector(F1),this.addDetector(j1),this.addDetector(V1),this.addDetector($1),this.addDetector(H1),this.addDetector(B1),this.addDetector(z1)}},{key:"addDetector",value:function(r){this.detectors[r.name]=r}},{key:"detect",value:function(r){var s=this;r||(r=this.options.order);var i=[];return r.forEach(function(a){if(s.detectors[a]){var c=s.detectors[a].lookup(s.options);c&&typeof c=="string"&&(c=[c]),c&&(i=i.concat(c))}}),i=i.map(function(a){return s.options.convertDetectedLanguage(a)}),this.services.languageUtils.getBestMatchFromCodes?i:i.length>0?i[0]:null}},{key:"cacheUserLanguage",value:function(r,s){var i=this;s||(s=this.options.caches),s&&(this.options.excludeCacheFor&&this.options.excludeCacheFor.indexOf(r)>-1||s.forEach(function(a){i.detectors[a]&&i.detectors[a].cacheUserLanguage(r,i.options)}))}}]),e}();tg.type="languageDetector";function Su(){return Su=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var s in r)({}).hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},Su.apply(null,arguments)}var _u,ng;function G1(){return ng||(ng=1,_u={area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0}),_u}var Y1=G1();const K1=Hi(Y1);var X1=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;function rg(e){var t={type:"tag",name:"",voidElement:!1,attrs:{},children:[]},r=e.match(/<\/?([^\s]+?)[/\s>]/);if(r&&(t.name=r[1],(K1[r[1]]||e.charAt(e.length-2)==="/")&&(t.voidElement=!0),t.name.startsWith("!--"))){var s=e.indexOf("-->");return{type:"comment",comment:s!==-1?e.slice(4,s):""}}for(var i=new RegExp(X1),a=null;(a=i.exec(e))!==null;)if(a[0].trim())if(a[1]){var c=a[1].trim(),u=[c,""];c.indexOf("=")>-1&&(u=c.split("=")),t.attrs[u[0]]=u[1],i.lastIndex--}else a[2]&&(t.attrs[a[2]]=a[3].trim().substring(1,a[3].length-1));return t}var Q1=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,q1=/^\s*$/,Z1=Object.create(null);function og(e,t){switch(t.type){case"text":return e+t.content;case"tag":return e+="<"+t.name+(t.attrs?function(r){var s=[];for(var i in r)s.push(i+'="'+r[i]+'"');return s.length?" "+s.join(" "):""}(t.attrs):"")+(t.voidElement?"/>":">"),t.voidElement?e:e+t.children.reduce(og,"")+"</"+t.name+">";case"comment":return e+"<!--"+t.comment+"-->"}}var J1={parse:function(e,t){t||(t={}),t.components||(t.components=Z1);var r,s=[],i=[],a=-1,c=!1;if(e.indexOf("<")!==0){var u=e.indexOf("<");s.push({type:"text",content:u===-1?e:e.substring(0,u)})}return e.replace(Q1,function(f,p){if(c){if(f!=="</"+r.name+">")return;c=!1}var m,E=f.charAt(1)!=="/",v=f.startsWith("<!--"),x=p+f.length,_=e.charAt(x);if(v){var w=rg(f);return a<0?(s.push(w),s):((m=i[a]).children.push(w),s)}if(E&&(a++,(r=rg(f)).type==="tag"&&t.components[r.name]&&(r.type="component",c=!0),r.voidElement||c||!_||_==="<"||r.children.push({type:"text",content:e.slice(x,e.indexOf("<",x))}),a===0&&s.push(r),(m=i[a-1])&&m.children.push(r),i[a]=r),(!E||r.voidElement)&&(a>-1&&(r.voidElement||r.name===f.slice(2,-1))&&(a--,r=a===-1?s:i[a]),!c&&_!=="<"&&_)){m=a===-1?s:i[a].children;var S=e.indexOf("<",x),N=e.slice(x,S===-1?void 0:S);q1.test(N)&&(N=" "),(S>-1&&a+m.length>=0||N!==" ")&&m.push({type:"text",content:N})}}),s},stringify:function(e){return e.reduce(function(t,r){return t+og("",r)},"")}};function Tl(){if(console&&console.warn){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];typeof t[0]=="string"&&(t[0]=`react-i18next:: ${t[0]}`),console.warn(...t)}}const sg={};function eT(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];typeof t[0]=="string"&&sg[t[0]]||(typeof t[0]=="string"&&(sg[t[0]]=new Date),Tl(...t))}const tT=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,nT={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"©","©":"©","®":"®","®":"®","…":"…","…":"…","/":"/","/":"/"},rT=e=>nT[e];let wu={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:e=>e.replace(tT,rT)};function oT(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};wu={...wu,...e}}function sT(){return wu}let ig;function iT(e){ig=e}function lg(){return ig}function Nu(e,t){if(!e)return!1;const r=e.props?e.props.children:e.children;return t?r.length>0:!!r}function Ru(e){if(!e)return[];const t=e.props?e.props.children:e.children;return e.props&&e.props.i18nIsDynamicList?Uo(t):t}function lT(e){return Object.prototype.toString.call(e)!=="[object Array]"?!1:e.every(t=>b.isValidElement(t))}function Uo(e){return Array.isArray(e)?e:[e]}function aT(e,t){const r={...t};return r.props=Object.assign(e.props,t.props),r}function ag(e,t){if(!e)return"";let r="";const s=Uo(e),i=t.transSupportBasicHtmlNodes&&t.transKeepBasicHtmlNodesFor?t.transKeepBasicHtmlNodesFor:[];return s.forEach((a,c)=>{if(typeof a=="string")r+=`${a}`;else if(b.isValidElement(a)){const u=Object.keys(a.props).length,f=i.indexOf(a.type)>-1,p=a.props.children;if(!p&&f&&u===0)r+=`<${a.type}/>`;else if(!p&&(!f||u!==0))r+=`<${c}></${c}>`;else if(a.props.i18nIsDynamicList)r+=`<${c}></${c}>`;else if(f&&u===1&&typeof p=="string")r+=`<${a.type}>${p}</${a.type}>`;else{const m=ag(p,t);r+=`<${c}>${m}</${c}>`}}else if(a===null)Tl("Trans: the passed in value is invalid - seems you passed in a null child.");else if(typeof a=="object"){const{format:u,...f}=a,p=Object.keys(f);if(p.length===1){const m=u?`${p[0]}, ${u}`:p[0];r+=`{{${m}}}`}else Tl("react-i18next: the passed in object contained more than one variable - the object should look like {{ value, format }} where format is optional.",a)}else Tl("Trans: the passed in value is invalid - seems you passed in a variable like {number} - please pass in variables for interpolation as full objects like {{number}}.",a)}),r}function cT(e,t,r,s,i,a){if(t==="")return[];const c=s.transKeepBasicHtmlNodesFor||[],u=t&&new RegExp(c.map(S=>`<${S}`).join("|")).test(t);if(!e&&!u&&!a)return[t];const f={};function p(S){Uo(S).forEach(O=>{typeof O!="string"&&(Nu(O)?p(Ru(O)):typeof O=="object"&&!b.isValidElement(O)&&Object.assign(f,O))})}p(e);const m=J1.parse(`<0>${t}</0>`),E={...f,...i};function v(S,N,O){const D=Ru(S),T=_(D,N.children,O);return lT(D)&&T.length===0||S.props&&S.props.i18nIsDynamicList?D:T}function x(S,N,O,D,T){S.dummy?(S.children=N,O.push(b.cloneElement(S,{key:D},T?void 0:N))):O.push(...b.Children.map([S],A=>{const L={...A.props};return delete L.i18nIsDynamicList,te.createElement(A.type,Su({},L,{key:D,ref:A.ref},T?{}:{children:N}))}))}function _(S,N,O){const D=Uo(S);return Uo(N).reduce((A,L,F)=>{const K=L.children&&L.children[0]&&L.children[0].content&&r.services.interpolator.interpolate(L.children[0].content,E,r.language);if(L.type==="tag"){let Q=D[parseInt(L.name,10)];O.length===1&&!Q&&(Q=O[0][L.name]),Q||(Q={});const X=Object.keys(L.attrs).length!==0?aT({props:L.attrs},Q):Q,ee=b.isValidElement(X),ne=ee&&Nu(L,!0)&&!L.voidElement,W=u&&typeof X=="object"&&X.dummy&&!ee,I=typeof e=="object"&&e!==null&&Object.hasOwnProperty.call(e,L.name);if(typeof X=="string"){const V=r.services.interpolator.interpolate(X,E,r.language);A.push(V)}else if(Nu(X)||ne){const V=v(X,L,O);x(X,V,A,F)}else if(W){const V=_(D,L.children,O);x(X,V,A,F)}else if(Number.isNaN(parseFloat(L.name)))if(I){const V=v(X,L,O);x(X,V,A,F,L.voidElement)}else if(s.transSupportBasicHtmlNodes&&c.indexOf(L.name)>-1)if(L.voidElement)A.push(b.createElement(L.name,{key:`${L.name}-${F}`}));else{const V=_(D,L.children,O);A.push(b.createElement(L.name,{key:`${L.name}-${F}`},V))}else if(L.voidElement)A.push(`<${L.name} />`);else{const V=_(D,L.children,O);A.push(`<${L.name}>${V}</${L.name}>`)}else if(typeof X=="object"&&!ee){const V=L.children[0]?K:null;V&&A.push(V)}else x(X,K,A,F,L.children.length!==1||!K)}else if(L.type==="text"){const Q=s.transWrapTextNodes,X=a?s.unescape(r.services.interpolator.interpolate(L.content,E,r.language)):r.services.interpolator.interpolate(L.content,E,r.language);Q?A.push(b.createElement(Q,{key:`${L.name}-${F}`},X)):A.push(X)}return A},[])}const w=_([{dummy:!0,children:e||[]}],m,Uo(e||[]));return Ru(w[0])}function uT(e){let{children:t,count:r,parent:s,i18nKey:i,context:a,tOptions:c={},values:u,defaults:f,components:p,ns:m,i18n:E,t:v,shouldUnescape:x,..._}=e;const w=E||lg();if(!w)return eT("You will need to pass in an i18next instance by using i18nextReactModule"),t;const S=v||w.t.bind(w)||(ne=>ne);a&&(c.context=a);const N={...sT(),...w.options&&w.options.react};let O=m||S.ns||w.options&&w.options.defaultNS;O=typeof O=="string"?[O]:O||["translation"];const D=ag(t,N),T=f||D||N.transEmptyNodeValue||i,{hashTransKey:A}=N,L=i||(A?A(D||T):D||T);w.options&&w.options.interpolation&&w.options.interpolation.defaultVariables&&(u=u&&Object.keys(u).length>0?{...u,...w.options.interpolation.defaultVariables}:{...w.options.interpolation.defaultVariables});const F=u?c.interpolation:{interpolation:{...c.interpolation,prefix:"#$?",suffix:"?$#"}},K={...c,count:r,...u,...F,defaultValue:T,ns:O},Q=L?S(L,K):T;p&&Object.keys(p).forEach(ne=>{const W=p[ne];if(typeof W.type=="function"||!W.props||!W.props.children||Q.indexOf(`${ne}/>`)<0&&Q.indexOf(`${ne} />`)<0)return;function I(){return te.createElement(te.Fragment,null,W)}p[ne]=te.createElement(I,null)});const X=cT(p||t,Q,w,N,K,x),ee=s!==void 0?s:N.defaultTransParent;return ee?b.createElement(ee,_,X):X}const dT={type:"3rdParty",init(e){oT(e.options.react),iT(e)}},fT=b.createContext();function pT(e){let{children:t,count:r,parent:s,i18nKey:i,context:a,tOptions:c={},values:u,defaults:f,components:p,ns:m,i18n:E,t:v,shouldUnescape:x,..._}=e;const{i18n:w,defaultNS:S}=b.useContext(fT)||{},N=E||w||lg(),O=v||N&&N.t.bind(N);return uT({children:t,count:r,parent:s,i18nKey:i,context:a,tOptions:c,values:u,defaults:f,components:p,ns:m||O&&O.ns||S||N&&N.options&&N.options.defaultNS,i18n:N,t:v,shouldUnescape:x,..._})}var hT={prefix:"fas",iconName:"trash-can",icon:[448,512,[61460,"trash-alt"],"f2ed","M135.2 17.7C140.6 6.8 151.7 0 163.8 0H284.2c12.1 0 23.2 6.8 28.6 17.7L320 32h96c17.7 0 32 14.3 32 32s-14.3 32-32 32H32C14.3 96 0 81.7 0 64S14.3 32 32 32h96l7.2-14.3zM32 128H416V448c0 35.3-28.7 64-64 64H96c-35.3 0-64-28.7-64-64V128zm96 64c-8.8 0-16 7.2-16 16V432c0 8.8 7.2 16 16 16s16-7.2 16-16V208c0-8.8-7.2-16-16-16zm96 0c-8.8 0-16 7.2-16 16V432c0 8.8 7.2 16 16 16s16-7.2 16-16V208c0-8.8-7.2-16-16-16zm96 0c-8.8 0-16 7.2-16 16V432c0 8.8 7.2 16 16 16s16-7.2 16-16V208c0-8.8-7.2-16-16-16z"]},mT={prefix:"fas",iconName:"bars",icon:[448,512,["navicon"],"f0c9","M0 96C0 78.3 14.3 64 32 64H416c17.7 0 32 14.3 32 32s-14.3 32-32 32H32C14.3 128 0 113.7 0 96zM0 256c0-17.7 14.3-32 32-32H416c17.7 0 32 14.3 32 32s-14.3 32-32 32H32c-17.7 0-32-14.3-32-32zM448 416c0 17.7-14.3 32-32 32H32c-17.7 0-32-14.3-32-32s14.3-32 32-32H416c17.7 0 32 14.3 32 32z"]},gT={prefix:"fas",iconName:"circle-exclamation",icon:[512,512,["exclamation-circle"],"f06a","M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zm0-384c13.3 0 24 10.7 24 24V264c0 13.3-10.7 24-24 24s-24-10.7-24-24V152c0-13.3 10.7-24 24-24zM224 352a32 32 0 1 1 64 0 32 32 0 1 1 -64 0z"]},ET={prefix:"fas",iconName:"circle-dot",icon:[512,512,[128280,"dot-circle"],"f192","M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zm0-352a96 96 0 1 1 0 192 96 96 0 1 1 0-192z"]},yT=ET,vT={prefix:"fas",iconName:"circle-check",icon:[512,512,[61533,"check-circle"],"f058","M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM369 209L241 337c-9.4 9.4-24.6 9.4-33.9 0l-64-64c-9.4-9.4-9.4-24.6 0-33.9s24.6-9.4 33.9 0l47 47L335 175c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9z"]},xT={prefix:"fas",iconName:"arrows-rotate",icon:[512,512,[128472,"refresh","sync"],"f021","M105.1 202.6c7.7-21.8 20.2-42.3 37.8-59.8c62.5-62.5 163.8-62.5 226.3 0L386.3 160H352c-17.7 0-32 14.3-32 32s14.3 32 32 32H463.5c0 0 0 0 0 0h.4c17.7 0 32-14.3 32-32V80c0-17.7-14.3-32-32-32s-32 14.3-32 32v35.2L414.4 97.6c-87.5-87.5-229.3-87.5-316.8 0C73.2 122 55.6 150.7 44.8 181.4c-5.9 16.7 2.9 34.9 19.5 40.8s34.9-2.9 40.8-19.5zM39 289.3c-5 1.5-9.8 4.2-13.7 8.2c-4 4-6.7 8.8-8.1 14c-.3 1.2-.6 2.5-.8 3.8c-.3 1.7-.4 3.4-.4 5.1V432c0 17.7 14.3 32 32 32s32-14.3 32-32V396.9l17.6 17.5 0 0c87.5 87.4 229.3 87.4 316.7 0c24.4-24.4 42.1-53.1 52.9-83.7c5.9-16.7-2.9-34.9-19.5-40.8s-34.9 2.9-40.8 19.5c-7.7 21.8-20.2 42.3-37.8 59.8c-62.5 62.5-163.8 62.5-226.3 0l-.1-.1L125.6 352H160c17.7 0 32-14.3 32-32s-14.3-32-32-32H48.4c-1.6 0-3.2 .1-4.8 .3s-3.1 .5-4.6 1z"]},ST={prefix:"fas",iconName:"arrow-turn-down-right",icon:[512,512,[],"e3d6","M64 64c0-17.7-14.3-32-32-32S0 46.3 0 64V224c0 53 43 96 96 96H402.7l-73.4 73.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l128-128c12.5-12.5 12.5-32.8 0-45.3l-128-128c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L402.7 256H96c-17.7 0-32-14.3-32-32V64z"]},_T={prefix:"fas",iconName:"arrow-right",icon:[448,512,[8594],"f061","M438.6 278.6c12.5-12.5 12.5-32.8 0-45.3l-160-160c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L338.8 224 32 224c-17.7 0-32 14.3-32 32s14.3 32 32 32l306.7 0L233.4 393.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l160-160z"]},wT={prefix:"fas",iconName:"circle-question",icon:[512,512,[62108,"question-circle"],"f059","M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM169.8 165.3c7.9-22.3 29.1-37.3 52.8-37.3h58.3c34.9 0 63.1 28.3 63.1 63.1c0 22.6-12.1 43.5-31.7 54.8L280 264.4c-.2 13-10.9 23.6-24 23.6c-13.3 0-24-10.7-24-24V250.5c0-8.6 4.6-16.5 12.1-20.8l44.3-25.4c4.7-2.7 7.6-7.7 7.6-13.1c0-8.4-6.8-15.1-15.1-15.1H222.6c-3.4 0-6.4 2.1-7.5 5.3l-.4 1.2c-4.4 12.5-18.2 19-30.6 14.6s-19-18.2-14.6-30.6l.4-1.2zM224 352a32 32 0 1 1 64 0 32 32 0 1 1 -64 0z"]},NT={prefix:"fas",iconName:"arrow-left",icon:[448,512,[8592],"f060","M9.4 233.4c-12.5 12.5-12.5 32.8 0 45.3l160 160c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L109.2 288 416 288c17.7 0 32-14.3 32-32s-14.3-32-32-32l-306.7 0L214.6 118.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-160 160z"]},RT={prefix:"fas",iconName:"circle-small",icon:[320,512,[],"e122","M0 256a160 160 0 1 1 320 0A160 160 0 1 1 0 256z"]},TT={prefix:"fas",iconName:"circle-info",icon:[512,512,["info-circle"],"f05a","M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM216 336h24V272H216c-13.3 0-24-10.7-24-24s10.7-24 24-24h48c13.3 0 24 10.7 24 24v88h8c13.3 0 24 10.7 24 24s-10.7 24-24 24H216c-13.3 0-24-10.7-24-24s10.7-24 24-24zm40-208a32 32 0 1 1 0 64 32 32 0 1 1 0-64z"]},OT={prefix:"fas",iconName:"bolt",icon:[448,512,[9889,"zap"],"f0e7","M349.4 44.6c5.9-13.7 1.5-29.7-10.6-38.5s-28.6-8-39.9 1.8l-256 224c-10 8.8-13.6 22.9-8.9 35.3S50.7 288 64 288H175.5L98.6 467.4c-5.9 13.7-1.5 29.7 10.6 38.5s28.6 8 39.9-1.8l256-224c10-8.8 13.6-22.9 8.9-35.3s-16.6-20.7-30-20.7H272.5L349.4 44.6z"]},CT={prefix:"fas",iconName:"xmark",icon:[384,512,[128473,10005,10006,10060,215,"close","multiply","remove","times"],"f00d","M342.6 150.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L192 210.7 86.6 105.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L146.7 256 41.4 361.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L192 301.3 297.4 406.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L237.3 256 342.6 150.6z"]},AT={prefix:"fas",iconName:"clock-rotate-left",icon:[512,512,["history"],"f1da","M75 75L41 41C25.9 25.9 0 36.6 0 57.9V168c0 13.3 10.7 24 24 24H134.1c21.4 0 32.1-25.9 17-41l-30.8-30.8C155 85.5 203 64 256 64c106 0 192 86 192 192s-86 192-192 192c-40.8 0-78.6-12.7-109.7-34.4c-14.5-10.1-34.4-6.6-44.6 7.9s-6.6 34.4 7.9 44.6C151.2 495 201.7 512 256 512c141.4 0 256-114.6 256-256S397.4 0 256 0C185.3 0 121.3 28.7 75 75zm181 53c-13.3 0-24 10.7-24 24V256c0 6.4 2.5 12.5 7 17l72 72c9.4 9.4 24.6 9.4 33.9 0s9.4-24.6 0-33.9l-65-65V152c0-13.3-10.7-24-24-24z"]},IT={prefix:"fas",iconName:"triangle-exclamation",icon:[512,512,[9888,"exclamation-triangle","warning"],"f071","M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24V296c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224a32 32 0 1 0 -64 0 32 32 0 1 0 64 0z"]},bT={prefix:"fas",iconName:"circle-xmark",icon:[512,512,[61532,"times-circle","xmark-circle"],"f057","M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM175 175c9.4-9.4 24.6-9.4 33.9 0l47 47 47-47c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9l-47 47 47 47c9.4 9.4 9.4 24.6 0 33.9s-24.6 9.4-33.9 0l-47-47-47 47c-9.4 9.4-24.6 9.4-33.9 0s-9.4-24.6 0-33.9l47-47-47-47c-9.4-9.4-9.4-24.6 0-33.9z"]};const LT={"arrow-left":NT,"arrow-right":_T,"arrow-turn-down-right":ST,"arrows-rotate":xT,bars:mT,bolt:OT,"circle-check":vT,"circle-exclamation":gT,"circle-info":TT,"circle-question":wT,"circle-small":RT,"circle-xmark":bT,"clock-rotate-left":AT,"dot-circle":yT,"trash-can":hT,"triangle-exclamation":IT,xmark:CT},Ce=b.forwardRef(function({className:t="",size:r="",tag:s},i){const a=LT[s];return a?h.jsx("svg",{"aria-hidden":"true","data-prefix":a.prefix,"data-icon":s,className:`svg-inline--fa fa-${s} ${r?`fa-${r}`:""} ${t}`,focusable:"false",ref:i,role:"img",viewBox:`0 0 ${a.icon[0]} ${a.icon[1]}`,xmlns:"http://www.w3.org/2000/svg",children:h.jsx("path",{d:a.icon[4],fill:"currentColor"})}):(Qe().debug(`Unknown icon: ${s}`),null)}),Fo=({className:e="",confirm:t=!0,handleDelete:r,label:s,scale:i=1,show:a=!0,showLabel:c=!1,size:u})=>{const[f,p]=b.useState(!1),[m,E]=b.useState(i);i!==m&&(p(!1),E(i));const v=_=>{_.preventDefault(),p(w=>!w)},x=_=>{_.preventDefault(),r(_)};return h.jsx(gr,{enable:t,open:f,onOpenChange:p,placement:"top",scale:i,trigger:h.jsxs("button",{className:`${a?"visible opacity-100":"invisible opacity-0"} text-xs text-foreground/20 hover:text-negative group-hover/node-wrapper:visible group-hover/node-wrapper:animate-delay-opacity ${e}`,onClick:_=>v(_),type:"button",children:[h.jsx(Ce,{tag:"trash-can",size:u})," ",h.jsx("span",{className:`${c?"whitespace-nowrap text-foreground/40 underline hover:text-negative":"sr-only"}`,children:s})]}),children:h.jsxs("div",{className:"text-xs font-semibold",children:[h.jsx("p",{className:"w-full pb-2 text-center",children:M(C.ARE_YOU_SURE)}),h.jsxs("div",{className:"align-center flex justify-between gap-2",children:[h.jsx("button",{className:"rounded bg-secondary py-1 px-2",onClick:_=>v(_),children:M(C.CANCEL)}),h.jsx("button",{className:"rounded bg-negative py-1 px-2",onClick:_=>x(_),children:M(C.DELETE)})]})]})})},DT=e=>{const t=ye(r=>r.viewport.zoom);return h.jsx(Fo,{scale:t,...e})},kT=Qe(),MT=100,PT=100,cg=({children:e,className:t="",onClickListItem:r})=>{const s=ye(p=>p.nodes),i=ye(p=>p.reactFlowInstance),a=ye(p=>p.validationWarnings),{setSelectedNodes:c}=Ze();if(a.size===0)return null;const u=Array.from(a.values());u.sort((p,m)=>M(p.nodeTitle).toLowerCase().localeCompare(M(m.nodeTitle).toLowerCase()));const f=p=>{const m=s.find(x=>x.id===p);if(!m){kT.error(`Node with id ${p} not found`);return}const E=i?.getNode(p)?.height??PT,v=i?.getNode(p)?.width??Om;i?.fitBounds({height:E+MT,width:v,x:m.position.x,y:m.position.y},{duration:mu}),setTimeout(()=>c([m.id]),mu),r?.()};return h.jsxs("div",{className:`hidden max-h-60 flex-col sm:flex ${t}`,children:[e,h.jsxs("p",{className:"mb-2 text-xs",children:[M(C.NUMBER_OF_VALIDATION_WARNINGS,{count:u.length}),":"]}),h.jsx("div",{className:"flex-auto overflow-y-auto",children:h.jsx("ol",{className:"list-inside",children:u.map(p=>h.jsxs("li",{className:"mb-2 text-xs",children:[h.jsx("button",{className:"text-warning underline",onClick:()=>f(p.nodeId),children:M(p.nodeTitle)}),h.jsxs("ol",{className:"my-1 ml-4 flex list-inside flex-col gap-y-1",children:[!p.connected&&h.jsx("li",{children:M(C.NOT_CONNECTED_TO_FLOW)}),!p.valid&&h.jsx("li",{children:M(C.INVALID_SETTINGS)})]})]},p.id))})})]})},Ys=e=>{const{className:t="",direction:r="from",valid:s=!0,...i}=e,a=r==="from";return h.jsxs("div",{className:`relative ${t} ${s?"":"invalid"}`,children:[h.jsx("input",{className:`w-full !pl-5 ${s?"":"invalid"}`,placeholder:M(a?C.FROM:C.TO),...i}),h.jsx(Ce,{className:"absolute left-[.25rem] top-[.5rem] text-foreground/40",tag:a?"arrow-left":"arrow-right"})]})},UT=({children:e})=>h.jsx("span",{className:"whitespace-wrap inline-block",children:h.jsx("code",{className:"mr-[0.5ch] whitespace-pre-wrap rounded-md bg-background p-0 px-[0.5ch] text-sm leading-4 tracking-tighter text-foreground",children:e})}),Xt=({children:e})=>h.jsxs("section",{className:"flex gap-2 overflow-hidden px-4 pb-3 text-xs leading-5",children:[h.jsx("div",{className:"shrink-0 pl-1 text-secondary",children:h.jsx(Ce,{size:"lg",tag:"arrow-turn-down-right"})}),h.jsx("div",{className:"w-full overflow-hidden",children:e})]}),FT=({connected:e=!1,deletable:t=!0,isRoot:r=!1,nodeId:s,nodeTitle:i,selected:a=!1})=>{const{removeNode:c}=Ze(),u=ye(p=>p.isEdgeConnecting),f=(p=>p?"bg-positive/10 text-positive":e?"bg-focus/30 text-primary":"bg-foreground/10 text-foreground/50")(r);return h.jsxs("div",{className:"flex w-full items-center justify-start gap-x-2 p-4",children:[h.jsx("div",{className:`${f} flex h-5 w-5 shrink-0 items-center justify-center rounded-full`,children:h.jsx(Ce,{tag:"circle-small"})}),h.jsxs("div",{className:"flex-1",children:[h.jsx("h2",{className:"text-xs font-semibold",children:i}),!e&&h.jsxs("div",{className:"flex items-center justify-start text-tiny font-semibold leading-[14px] text-secondary",children:[h.jsx(Ce,{className:"px-1 text-warning",size:"lg",tag:"bolt"}),M(C.NOT_CONNECTED_TO_FLOW)]})]}),t&&!u&&h.jsx(DT,{handleDelete:()=>c(s),label:M(C.REMOVE_NODE,{title:i}),show:a})]})},jT=({valid:e})=>e?null:h.jsx("div",{className:"m-4 mt-0 inline-block",children:h.jsxs("div",{className:"flex items-start justify-start gap-2 rounded bg-negative/10 px-2 py-1 text-xs text-negative",children:[h.jsx(gr,{placement:"bottom",trigger:h.jsx("div",{role:"tooltip",tabIndex:0,children:h.jsx(Ce,{size:"lg",tag:"triangle-exclamation"})}),children:M(C.INFO_INVALID_SETTINGS)}),M(C.INVALID_SETTINGS)]})}),VT=({nodeId:e,valid:t})=>{const{deleteValidationWarning:r,getTargetEdges:s,partialUpdateValidationWarning:i}=Ze(),[a,c]=b.useState(!1);return b.useEffect(()=>{let u;const f=()=>{r(e),typeof u=="function"&&u()},p=()=>{const m=ye.getState().nodes.find(E=>E.id===e);if(!m)f();else{const E=s(e).length>0;c(E),i(e,{connected:E,nodeId:e,nodeType:m.type,valid:t})}};return p(),u=ye.subscribe((m,E)=>{const v=m.nodes.length!==E.nodes.length,x=m.edges.length!==E.edges.length,_=m.isEdgeUpdateSuccessful!==E.isEdgeUpdateSuccessful;(x||v||_)&&p()}),()=>{f()}},[r,s,e,i,t]),{isConnectedToFlow:a}},$T=({id:e,isConnectable:t})=>{if(!e)throw new Error("TargetHandle: id is required");return h.jsx("div",{className:"absolute left-0 top-5 h-3 w-3 -translate-x-1/2",children:h.jsx(Ro,{className:"-left-[2px] h-full w-full border-2 border-foreground/40 bg-background transition-colors hover:border-foreground/80",id:`target-${e}`,isConnectable:t,position:xe.Left,type:"target"})})},dt=({children:e,id:t,isConnectable:r=!0,isRoot:s=!1,nodeTitle:i,selected:a,deletable:c=!0,showValidation:u=!0,target:f=!0,valid:p=!0})=>{const{isConnectedToFlow:m}=VT({nodeId:t,valid:p});return h.jsx("section",{className:`${a?"!border-focus":""} group/node-wrapper rounded-xl border-2 border-background shadow-[0_4px_12px_0_rgba(0,0,0,0.08)] transition-[visibility]`,children:h.jsxs("div",{className:"group/node-wrapper relative rounded-xl bg-background",style:{width:Om},children:[f&&t&&h.jsx($T,{id:t,isConnectable:r}),h.jsx(FT,{connected:!f||m,deletable:c,isRoot:s,nodeId:t,nodeTitle:i,selected:a}),u&&h.jsx(jT,{valid:p}),e]})})},HT=({children:e,handleClick:t,...r})=>{const s=i=>{(i.key==="Backspace"||i.key==="Delete")&&(i.stopPropagation(),t?.())};return h.jsx("li",{"aria-selected":"true",tabIndex:0,role:"option",children:h.jsxs("div",{className:"flex items-center gap-2 rounded-lg bg-primary/20 p-1 pl-2 text-xs font-medium text-foreground",children:[e,h.jsxs("button",{className:"px-1",onClick:t,onKeyDown:s,type:"button",...r,children:[h.jsx("span",{className:"sr-only",children:"Remove"}),h.jsx(Ce,{tag:"xmark",size:"xs"})]})]})})},ug=({data:e})=>{let t=e.selected&&e[e.selected].trim();return t&&e.selected==="url"&&(t=s1(t)||M(C.PLAY_AUDIO)),t?h.jsx(Xt,{children:h.jsx("div",{className:"max-w-max",children:e.selected==="url"?h.jsx("a",{className:"break-words text-primary underline line-clamp-2",href:e.url,target:"_blank",rel:"noopener noreferrer",children:t}):h.jsx("p",{className:"break-words line-clamp-2",children:t})})}):null},dg=e=>{const{children:t,className:r="",disabled:s=!1,...i}=e;return h.jsxs("div",{className:`chevron-down relative mb-2 after:rotate-0 after:transition-transform focus-within:after:rotate-180
|
|
61
61
|
${s?"after:border-t-foreground/40":"after:border-t-foreground"}`,children:[h.jsx("select",{className:`pr-8 ${r}`,disabled:s,...i,children:t}),h.jsx("p",{className:"requirements w-full",role:"alert",children:M(C.ERROR_SELECTION_REQUIRED)})]})},Tn=e=>{const{label:t="",id:r="",...s}=e,i=b.useId(),a=r||i;return h.jsxs(h.Fragment,{children:[t&&h.jsx("label",{className:"block pb-1 font-medium",htmlFor:a,children:t}),h.jsx(dg,{id:a,...s})]})},BT=({label:e,vars:t={}})=>h.jsx(pT,{components:{a:h.jsx("a",{className:"underline hover:text-background/80",href:t.linkTo||"#",target:"_blank",rel:"noopener noreferrer"}),code:h.jsx(UT,{}),p:h.jsx("p",{className:"mb-2"})},i18nKey:e}),zT={disabled:"border-disabled cursor-not-allowed",negative:"border-negative hover:bg-negative",positive:"border-positive hover:bg-positive"},an=({color:e="positive",enabled:t=!0,id:r,isConnectable:s})=>{if(!r)throw new Error("SourceHandle: id is required");const i=t?e:"disabled",a=ye(m=>m.updatingSourceHandleId),f=!ye(m=>m.edges.some(E=>E.sourceHandle===r))||a===r,p=f&&s&&t;return h.jsx("div",{className:`absolute right-0 top-1/2 h-3 w-3 -translate-y-1/2 translate-x-1/2 ${p?"":"nodrag cursor-not-allowed"}`,children:h.jsx(Ro,{className:`-right-[2px] h-full w-full border-2 bg-background transition-colors ${zT[i]??""}`,id:r,isConnectable:f&&s&&t,position:xe.Right,type:"source"})})},jo=({children:e})=>h.jsx("div",{className:"flex w-full flex-col items-start text-xs",children:e}),cn=({color:e="positive",enabled:t=!0,id:r,isConnectable:s,optionSubtitle:i="",optionTitle:a})=>h.jsxs("div",{className:"relative w-full min-w-[104px] whitespace-nowrap border-t border-foreground/10 py-3",children:[h.jsx("div",{className:"flex flex-col items-start justify-center px-4",children:h.jsxs("div",{className:`${t?"":"text-disabled"} min-h-[1rem] w-full overflow-hidden`,children:[a,i?h.jsx("span",{className:"block text-xxs text-secondary",children:i}):null]})}),h.jsx(an,{color:e,enabled:t,id:r,isConnectable:s})]}),WT=({checked:e=!1,name:t,onClick:r,...s})=>h.jsxs("button",{"aria-checked":e?"true":"false",className:`${e?"bg-primary":"bg-secondary"} relative inline-flex h-4 w-6 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out`,name:t,onClick:r,role:"switch",type:"button",...s,children:[h.jsx("span",{className:"sr-only",children:M(e?C.ON:C.OFF)}),h.jsx("span",{className:`pointer-events-none inline-block h-3 w-3 ${e?"translate-x-2":"translate-x-0"} transform rounded-full bg-white shadow transition duration-200 ease-in-out`})]}),Ol=({checked:e,clickHandler:t,name:r,subtitle:s,title:i,...a})=>h.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[h.jsxs("div",{className:"flex flex-grow flex-col",children:[h.jsx("span",{className:"text-xs font-medium",children:i}),s&&h.jsx("span",{className:"text-xxs text-foreground/50",children:s})]}),h.jsx(WT,{checked:e,name:r,onClick:t,...a})]}),$n=({errorText:e,label:t,name:r,onChange:s,required:i,valid:a,value:c,...u})=>h.jsxs(h.Fragment,{children:[t?.trim()?h.jsx("div",{className:"pb-1",children:t}):null,h.jsx("textarea",{"aria-invalid":a?void 0:"true",className:`peer min-h-[77px] w-full resize-y ${a?"":"invalid"}`,inputMode:"text",minLength:1,name:r,onChange:s,required:i,value:c,...u}),h.jsx("p",{className:"requirements",role:"alert",children:e})]});function fr(e){return fg(e)?(e.nodeName||"").toLowerCase():"#document"}function Ct(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Hn(e){var t;return(t=(fg(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function fg(e){return e instanceof Node||e instanceof Ct(e).Node}function $e(e){return e instanceof Element||e instanceof Ct(e).Element}function Vt(e){return e instanceof HTMLElement||e instanceof Ct(e).HTMLElement}function Tu(e){return typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Ct(e).ShadowRoot}function Ks(e){const{overflow:t,overflowX:r,overflowY:s,display:i}=$t(e);return/auto|scroll|overlay|hidden|clip/.test(t+s+r)&&!["inline","contents"].includes(i)}function GT(e){return["table","td","th"].includes(fr(e))}function Ou(e){const t=Cu(),r=$t(e);return r.transform!=="none"||r.perspective!=="none"||(r.containerType?r.containerType!=="normal":!1)||!t&&(r.backdropFilter?r.backdropFilter!=="none":!1)||!t&&(r.filter?r.filter!=="none":!1)||["transform","perspective","filter"].some(s=>(r.willChange||"").includes(s))||["paint","layout","strict","content"].some(s=>(r.contain||"").includes(s))}function YT(e){let t=Br(e);for(;Vt(t)&&!Vo(t);){if(Ou(t))return t;t=Br(t)}return null}function Cu(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function Vo(e){return["html","body","#document"].includes(fr(e))}function $t(e){return Ct(e).getComputedStyle(e)}function Cl(e){return $e(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.pageXOffset,scrollTop:e.pageYOffset}}function Br(e){if(fr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Tu(e)&&e.host||Hn(e);return Tu(t)?t.host:t}function pg(e){const t=Br(e);return Vo(t)?e.ownerDocument?e.ownerDocument.body:e.body:Vt(t)&&Ks(t)?t:pg(t)}function pr(e,t,r){var s;t===void 0&&(t=[]),r===void 0&&(r=!0);const i=pg(e),a=i===((s=e.ownerDocument)==null?void 0:s.body),c=Ct(i);return a?t.concat(c,c.visualViewport||[],Ks(i)?i:[],c.frameElement&&r?pr(c.frameElement):[]):t.concat(i,pr(i,[],r))}function hg(e){let t=e.activeElement;for(;((r=t)==null||(r=r.shadowRoot)==null?void 0:r.activeElement)!=null;){var r;t=t.shadowRoot.activeElement}return t}function hr(e,t){if(!e||!t)return!1;const r=t.getRootNode&&t.getRootNode();if(e.contains(t))return!0;if(r&&Tu(r)){let s=t;for(;s;){if(e===s)return!0;s=s.parentNode||s.host}}return!1}function mg(){const e=navigator.userAgentData;return e!=null&&e.platform?e.platform:navigator.platform}function KT(){const e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(t=>{let{brand:r,version:s}=t;return r+"/"+s}).join(" "):navigator.userAgent}function XT(e){return!qT()&&e.width===0&&e.height===0||e.width===1&&e.height===1&&e.pressure===0&&e.detail===0&&e.pointerType==="mouse"||e.width<1&&e.height<1&&e.pressure===0&&e.detail===0}function QT(){return/apple/i.test(navigator.vendor)}function qT(){const e=/android/i;return e.test(mg())||e.test(KT())}function ZT(){return mg().toLowerCase().startsWith("mac")&&!navigator.maxTouchPoints}function gg(e,t){const r=["mouse","pen"];return r.push("",void 0),r.includes(e)}function JT(e){return"nativeEvent"in e}function eO(e){return e.matches("html,body")}function zr(e){return e?.ownerDocument||document}function Au(e,t){if(t==null)return!1;if("composedPath"in e)return e.composedPath().includes(t);const r=e;return r.target!=null&&t.contains(r.target)}function Wr(e){return"composedPath"in e?e.composedPath()[0]:e.target}const tO="input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";function nO(e){return Vt(e)&&e.matches(tO)}const $o=Math.min,Gr=Math.max,Al=Math.round,Il=Math.floor,mr=e=>({x:e,y:e}),rO={left:"right",right:"left",bottom:"top",top:"bottom"},oO={start:"end",end:"start"};function Iu(e,t,r){return Gr(e,$o(t,r))}function Xs(e,t){return typeof e=="function"?e(t):e}function Yr(e){return e.split("-")[0]}function Qs(e){return e.split("-")[1]}function Eg(e){return e==="x"?"y":"x"}function bu(e){return e==="y"?"height":"width"}function bl(e){return["top","bottom"].includes(Yr(e))?"y":"x"}function Lu(e){return Eg(bl(e))}function sO(e,t,r){r===void 0&&(r=!1);const s=Qs(e),i=Lu(e),a=bu(i);let c=i==="x"?s===(r?"end":"start")?"right":"left":s==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(c=Ll(c)),[c,Ll(c)]}function iO(e){const t=Ll(e);return[Du(e),t,Du(t)]}function Du(e){return e.replace(/start|end/g,t=>oO[t])}function lO(e,t,r){const s=["left","right"],i=["right","left"],a=["top","bottom"],c=["bottom","top"];switch(e){case"top":case"bottom":return r?t?i:s:t?s:i;case"left":case"right":return t?a:c;default:return[]}}function aO(e,t,r,s){const i=Qs(e);let a=lO(Yr(e),r==="start",s);return i&&(a=a.map(c=>c+"-"+i),t&&(a=a.concat(a.map(Du)))),a}function Ll(e){return e.replace(/left|right|bottom|top/g,t=>rO[t])}function cO(e){return{top:0,right:0,bottom:0,left:0,...e}}function yg(e){return typeof e!="number"?cO(e):{top:e,right:e,bottom:e,left:e}}function Dl(e){return{...e,top:e.y,left:e.x,right:e.x+e.width,bottom:e.y+e.height}}function vg(e,t,r){let{reference:s,floating:i}=e;const a=bl(t),c=Lu(t),u=bu(c),f=Yr(t),p=a==="y",m=s.x+s.width/2-i.width/2,E=s.y+s.height/2-i.height/2,v=s[u]/2-i[u]/2;let x;switch(f){case"top":x={x:m,y:s.y-i.height};break;case"bottom":x={x:m,y:s.y+s.height};break;case"right":x={x:s.x+s.width,y:E};break;case"left":x={x:s.x-i.width,y:E};break;default:x={x:s.x,y:s.y}}switch(Qs(t)){case"start":x[c]-=v*(r&&p?-1:1);break;case"end":x[c]+=v*(r&&p?-1:1);break}return x}const uO=async(e,t,r)=>{const{placement:s="bottom",strategy:i="absolute",middleware:a=[],platform:c}=r,u=a.filter(Boolean),f=await(c.isRTL==null?void 0:c.isRTL(t));let p=await c.getElementRects({reference:e,floating:t,strategy:i}),{x:m,y:E}=vg(p,s,f),v=s,x={},_=0;for(let w=0;w<u.length;w++){const{name:S,fn:N}=u[w],{x:O,y:D,data:T,reset:A}=await N({x:m,y:E,initialPlacement:s,placement:v,strategy:i,middlewareData:x,rects:p,platform:c,elements:{reference:e,floating:t}});if(m=O??m,E=D??E,x={...x,[S]:{...x[S],...T}},A&&_<=50){_++,typeof A=="object"&&(A.placement&&(v=A.placement),A.rects&&(p=A.rects===!0?await c.getElementRects({reference:e,floating:t,strategy:i}):A.rects),{x:m,y:E}=vg(p,v,f)),w=-1;continue}}return{x:m,y:E,placement:v,strategy:i,middlewareData:x}};async function xg(e,t){var r;t===void 0&&(t={});const{x:s,y:i,platform:a,rects:c,elements:u,strategy:f}=e,{boundary:p="clippingAncestors",rootBoundary:m="viewport",elementContext:E="floating",altBoundary:v=!1,padding:x=0}=Xs(t,e),_=yg(x),S=u[v?E==="floating"?"reference":"floating":E],N=Dl(await a.getClippingRect({element:(r=await(a.isElement==null?void 0:a.isElement(S)))==null||r?S:S.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(u.floating)),boundary:p,rootBoundary:m,strategy:f})),O=E==="floating"?{...c.floating,x:s,y:i}:c.reference,D=await(a.getOffsetParent==null?void 0:a.getOffsetParent(u.floating)),T=await(a.isElement==null?void 0:a.isElement(D))?await(a.getScale==null?void 0:a.getScale(D))||{x:1,y:1}:{x:1,y:1},A=Dl(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({rect:O,offsetParent:D,strategy:f}):O);return{top:(N.top-A.top+_.top)/T.y,bottom:(A.bottom-N.bottom+_.bottom)/T.y,left:(N.left-A.left+_.left)/T.x,right:(A.right-N.right+_.right)/T.x}}const Sg=e=>({name:"arrow",options:e,async fn(t){const{x:r,y:s,placement:i,rects:a,platform:c,elements:u,middlewareData:f}=t,{element:p,padding:m=0}=Xs(e,t)||{};if(p==null)return{};const E=yg(m),v={x:r,y:s},x=Lu(i),_=bu(x),w=await c.getDimensions(p),S=x==="y",N=S?"top":"left",O=S?"bottom":"right",D=S?"clientHeight":"clientWidth",T=a.reference[_]+a.reference[x]-v[x]-a.floating[_],A=v[x]-a.reference[x],L=await(c.getOffsetParent==null?void 0:c.getOffsetParent(p));let F=L?L[D]:0;(!F||!await(c.isElement==null?void 0:c.isElement(L)))&&(F=u.floating[D]||a.floating[_]);const K=T/2-A/2,Q=F/2-w[_]/2-1,X=$o(E[N],Q),ee=$o(E[O],Q),ne=X,W=F-w[_]-ee,I=F/2-w[_]/2+K,V=Iu(ne,I,W),j=!f.arrow&&Qs(i)!=null&&I!=V&&a.reference[_]/2-(I<ne?X:ee)-w[_]/2<0,B=j?I<ne?I-ne:I-W:0;return{[x]:v[x]+B,data:{[x]:V,centerOffset:I-V-B,...j&&{alignmentOffset:B}},reset:j}}}),dO=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var r,s;const{placement:i,middlewareData:a,rects:c,initialPlacement:u,platform:f,elements:p}=t,{mainAxis:m=!0,crossAxis:E=!0,fallbackPlacements:v,fallbackStrategy:x="bestFit",fallbackAxisSideDirection:_="none",flipAlignment:w=!0,...S}=Xs(e,t);if((r=a.arrow)!=null&&r.alignmentOffset)return{};const N=Yr(i),O=Yr(u)===u,D=await(f.isRTL==null?void 0:f.isRTL(p.floating)),T=v||(O||!w?[Ll(u)]:iO(u));!v&&_!=="none"&&T.push(...aO(u,w,_,D));const A=[u,...T],L=await xg(t,S),F=[];let K=((s=a.flip)==null?void 0:s.overflows)||[];if(m&&F.push(L[N]),E){const ne=sO(i,c,D);F.push(L[ne[0]],L[ne[1]])}if(K=[...K,{placement:i,overflows:F}],!F.every(ne=>ne<=0)){var Q,X;const ne=(((Q=a.flip)==null?void 0:Q.index)||0)+1,W=A[ne];if(W)return{data:{index:ne,overflows:K},reset:{placement:W}};let I=(X=K.filter(V=>V.overflows[0]<=0).sort((V,j)=>V.overflows[1]-j.overflows[1])[0])==null?void 0:X.placement;if(!I)switch(x){case"bestFit":{var ee;const V=(ee=K.map(j=>[j.placement,j.overflows.filter(B=>B>0).reduce((B,U)=>B+U,0)]).sort((j,B)=>j[1]-B[1])[0])==null?void 0:ee[0];V&&(I=V);break}case"initialPlacement":I=u;break}if(i!==I)return{reset:{placement:I}}}return{}}}};async function fO(e,t){const{placement:r,platform:s,elements:i}=e,a=await(s.isRTL==null?void 0:s.isRTL(i.floating)),c=Yr(r),u=Qs(r),f=bl(r)==="y",p=["left","top"].includes(c)?-1:1,m=a&&f?-1:1,E=Xs(t,e);let{mainAxis:v,crossAxis:x,alignmentAxis:_}=typeof E=="number"?{mainAxis:E,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...E};return u&&typeof _=="number"&&(x=u==="end"?_*-1:_),f?{x:x*m,y:v*p}:{x:v*p,y:x*m}}const pO=function(e){return{name:"offset",options:e,async fn(t){var r,s;const{x:i,y:a,placement:c,middlewareData:u}=t,f=await fO(t,e);return c===((r=u.offset)==null?void 0:r.placement)&&(s=u.arrow)!=null&&s.alignmentOffset?{}:{x:i+f.x,y:a+f.y,data:{...f,placement:c}}}}},hO=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:r,y:s,placement:i}=t,{mainAxis:a=!0,crossAxis:c=!1,limiter:u={fn:S=>{let{x:N,y:O}=S;return{x:N,y:O}}},...f}=Xs(e,t),p={x:r,y:s},m=await xg(t,f),E=bl(Yr(i)),v=Eg(E);let x=p[v],_=p[E];if(a){const S=v==="y"?"top":"left",N=v==="y"?"bottom":"right",O=x+m[S],D=x-m[N];x=Iu(O,x,D)}if(c){const S=E==="y"?"top":"left",N=E==="y"?"bottom":"right",O=_+m[S],D=_-m[N];_=Iu(O,_,D)}const w=u.fn({...t,[v]:x,[E]:_});return{...w,data:{x:w.x-r,y:w.y-s}}}}};function _g(e){const t=$t(e);let r=parseFloat(t.width)||0,s=parseFloat(t.height)||0;const i=Vt(e),a=i?e.offsetWidth:r,c=i?e.offsetHeight:s,u=Al(r)!==a||Al(s)!==c;return u&&(r=a,s=c),{width:r,height:s,$:u}}function ku(e){return $e(e)?e:e.contextElement}function Ho(e){const t=ku(e);if(!Vt(t))return mr(1);const r=t.getBoundingClientRect(),{width:s,height:i,$:a}=_g(t);let c=(a?Al(r.width):r.width)/s,u=(a?Al(r.height):r.height)/i;return(!c||!Number.isFinite(c))&&(c=1),(!u||!Number.isFinite(u))&&(u=1),{x:c,y:u}}const mO=mr(0);function wg(e){const t=Ct(e);return!Cu()||!t.visualViewport?mO:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function gO(e,t,r){return t===void 0&&(t=!1),!r||t&&r!==Ct(e)?!1:t}function Kr(e,t,r,s){t===void 0&&(t=!1),r===void 0&&(r=!1);const i=e.getBoundingClientRect(),a=ku(e);let c=mr(1);t&&(s?$e(s)&&(c=Ho(s)):c=Ho(e));const u=gO(a,r,s)?wg(a):mr(0);let f=(i.left+u.x)/c.x,p=(i.top+u.y)/c.y,m=i.width/c.x,E=i.height/c.y;if(a){const v=Ct(a),x=s&&$e(s)?Ct(s):s;let _=v.frameElement;for(;_&&s&&x!==v;){const w=Ho(_),S=_.getBoundingClientRect(),N=$t(_),O=S.left+(_.clientLeft+parseFloat(N.paddingLeft))*w.x,D=S.top+(_.clientTop+parseFloat(N.paddingTop))*w.y;f*=w.x,p*=w.y,m*=w.x,E*=w.y,f+=O,p+=D,_=Ct(_).frameElement}}return Dl({width:m,height:E,x:f,y:p})}function EO(e){let{rect:t,offsetParent:r,strategy:s}=e;const i=Vt(r),a=Hn(r);if(r===a)return t;let c={scrollLeft:0,scrollTop:0},u=mr(1);const f=mr(0);if((i||!i&&s!=="fixed")&&((fr(r)!=="body"||Ks(a))&&(c=Cl(r)),Vt(r))){const p=Kr(r);u=Ho(r),f.x=p.x+r.clientLeft,f.y=p.y+r.clientTop}return{width:t.width*u.x,height:t.height*u.y,x:t.x*u.x-c.scrollLeft*u.x+f.x,y:t.y*u.y-c.scrollTop*u.y+f.y}}function yO(e){return Array.from(e.getClientRects())}function Ng(e){return Kr(Hn(e)).left+Cl(e).scrollLeft}function vO(e){const t=Hn(e),r=Cl(e),s=e.ownerDocument.body,i=Gr(t.scrollWidth,t.clientWidth,s.scrollWidth,s.clientWidth),a=Gr(t.scrollHeight,t.clientHeight,s.scrollHeight,s.clientHeight);let c=-r.scrollLeft+Ng(e);const u=-r.scrollTop;return $t(s).direction==="rtl"&&(c+=Gr(t.clientWidth,s.clientWidth)-i),{width:i,height:a,x:c,y:u}}function xO(e,t){const r=Ct(e),s=Hn(e),i=r.visualViewport;let a=s.clientWidth,c=s.clientHeight,u=0,f=0;if(i){a=i.width,c=i.height;const p=Cu();(!p||p&&t==="fixed")&&(u=i.offsetLeft,f=i.offsetTop)}return{width:a,height:c,x:u,y:f}}function SO(e,t){const r=Kr(e,!0,t==="fixed"),s=r.top+e.clientTop,i=r.left+e.clientLeft,a=Vt(e)?Ho(e):mr(1),c=e.clientWidth*a.x,u=e.clientHeight*a.y,f=i*a.x,p=s*a.y;return{width:c,height:u,x:f,y:p}}function Rg(e,t,r){let s;if(t==="viewport")s=xO(e,r);else if(t==="document")s=vO(Hn(e));else if($e(t))s=SO(t,r);else{const i=wg(e);s={...t,x:t.x-i.x,y:t.y-i.y}}return Dl(s)}function Tg(e,t){const r=Br(e);return r===t||!$e(r)||Vo(r)?!1:$t(r).position==="fixed"||Tg(r,t)}function _O(e,t){const r=t.get(e);if(r)return r;let s=pr(e,[],!1).filter(u=>$e(u)&&fr(u)!=="body"),i=null;const a=$t(e).position==="fixed";let c=a?Br(e):e;for(;$e(c)&&!Vo(c);){const u=$t(c),f=Ou(c);!f&&u.position==="fixed"&&(i=null),(a?!f&&!i:!f&&u.position==="static"&&!!i&&["absolute","fixed"].includes(i.position)||Ks(c)&&!f&&Tg(e,c))?s=s.filter(m=>m!==c):i=u,c=Br(c)}return t.set(e,s),s}function wO(e){let{element:t,boundary:r,rootBoundary:s,strategy:i}=e;const c=[...r==="clippingAncestors"?_O(t,this._c):[].concat(r),s],u=c[0],f=c.reduce((p,m)=>{const E=Rg(t,m,i);return p.top=Gr(E.top,p.top),p.right=$o(E.right,p.right),p.bottom=$o(E.bottom,p.bottom),p.left=Gr(E.left,p.left),p},Rg(t,u,i));return{width:f.right-f.left,height:f.bottom-f.top,x:f.left,y:f.top}}function NO(e){return _g(e)}function RO(e,t,r){const s=Vt(t),i=Hn(t),a=r==="fixed",c=Kr(e,!0,a,t);let u={scrollLeft:0,scrollTop:0};const f=mr(0);if(s||!s&&!a)if((fr(t)!=="body"||Ks(i))&&(u=Cl(t)),s){const p=Kr(t,!0,a,t);f.x=p.x+t.clientLeft,f.y=p.y+t.clientTop}else i&&(f.x=Ng(i));return{x:c.left+u.scrollLeft-f.x,y:c.top+u.scrollTop-f.y,width:c.width,height:c.height}}function Og(e,t){return!Vt(e)||$t(e).position==="fixed"?null:t?t(e):e.offsetParent}function Cg(e,t){const r=Ct(e);if(!Vt(e))return r;let s=Og(e,t);for(;s&>(s)&&$t(s).position==="static";)s=Og(s,t);return s&&(fr(s)==="html"||fr(s)==="body"&&$t(s).position==="static"&&!Ou(s))?r:s||YT(e)||r}const TO=async function(e){let{reference:t,floating:r,strategy:s}=e;const i=this.getOffsetParent||Cg,a=this.getDimensions;return{reference:RO(t,await i(r),s),floating:{x:0,y:0,...await a(r)}}};function OO(e){return $t(e).direction==="rtl"}const CO={convertOffsetParentRelativeRectToViewportRelativeRect:EO,getDocumentElement:Hn,getClippingRect:wO,getOffsetParent:Cg,getElementRects:TO,getClientRects:yO,getDimensions:NO,getScale:Ho,isElement:$e,isRTL:OO};function AO(e,t){let r=null,s;const i=Hn(e);function a(){clearTimeout(s),r&&r.disconnect(),r=null}function c(u,f){u===void 0&&(u=!1),f===void 0&&(f=1),a();const{left:p,top:m,width:E,height:v}=e.getBoundingClientRect();if(u||t(),!E||!v)return;const x=Il(m),_=Il(i.clientWidth-(p+E)),w=Il(i.clientHeight-(m+v)),S=Il(p),O={rootMargin:-x+"px "+-_+"px "+-w+"px "+-S+"px",threshold:Gr(0,$o(1,f))||1};let D=!0;function T(A){const L=A[0].intersectionRatio;if(L!==f){if(!D)return c();L?c(!1,L):s=setTimeout(()=>{c(!1,1e-7)},100)}D=!1}try{r=new IntersectionObserver(T,{...O,root:i.ownerDocument})}catch{r=new IntersectionObserver(T,O)}r.observe(e)}return c(!0),a}function IO(e,t,r,s){s===void 0&&(s={});const{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:c=typeof ResizeObserver=="function",layoutShift:u=typeof IntersectionObserver=="function",animationFrame:f=!1}=s,p=ku(e),m=i||a?[...p?pr(p):[],...pr(t)]:[];m.forEach(N=>{i&&N.addEventListener("scroll",r,{passive:!0}),a&&N.addEventListener("resize",r)});const E=p&&u?AO(p,r):null;let v=-1,x=null;c&&(x=new ResizeObserver(N=>{let[O]=N;O&&O.target===p&&x&&(x.unobserve(t),cancelAnimationFrame(v),v=requestAnimationFrame(()=>{x&&x.observe(t)})),r()}),p&&!f&&x.observe(p),x.observe(t));let _,w=f?Kr(e):null;f&&S();function S(){const N=Kr(e);w&&(N.x!==w.x||N.y!==w.y||N.width!==w.width||N.height!==w.height)&&r(),w=N,_=requestAnimationFrame(S)}return r(),()=>{m.forEach(N=>{i&&N.removeEventListener("scroll",r),a&&N.removeEventListener("resize",r)}),E&&E(),x&&x.disconnect(),x=null,f&&cancelAnimationFrame(_)}}const bO=(e,t,r)=>{const s=new Map,i={platform:CO,...r},a={...i.platform,_c:s};return uO(e,t,{...i,platform:a})},LO=e=>{function t(r){return{}.hasOwnProperty.call(r,"current")}return{name:"arrow",options:e,fn(r){const{element:s,padding:i}=typeof e=="function"?e(r):e;return s&&t(s)?s.current!=null?Sg({element:s.current,padding:i}).fn(r):{}:s?Sg({element:s,padding:i}).fn(r):{}}}};var kl=typeof document<"u"?b.useLayoutEffect:b.useEffect;function Ml(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let r,s,i;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(r=e.length,r!=t.length)return!1;for(s=r;s--!==0;)if(!Ml(e[s],t[s]))return!1;return!0}if(i=Object.keys(e),r=i.length,r!==Object.keys(t).length)return!1;for(s=r;s--!==0;)if(!{}.hasOwnProperty.call(t,i[s]))return!1;for(s=r;s--!==0;){const a=i[s];if(!(a==="_owner"&&e.$$typeof)&&!Ml(e[a],t[a]))return!1}return!0}return e!==e&&t!==t}function Ag(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Ig(e,t){const r=Ag(e);return Math.round(t*r)/r}function bg(e){const t=b.useRef(e);return kl(()=>{t.current=e}),t}function DO(e){e===void 0&&(e={});const{placement:t="bottom",strategy:r="absolute",middleware:s=[],platform:i,elements:{reference:a,floating:c}={},transform:u=!0,whileElementsMounted:f,open:p}=e,[m,E]=b.useState({x:0,y:0,strategy:r,placement:t,middlewareData:{},isPositioned:!1}),[v,x]=b.useState(s);Ml(v,s)||x(s);const[_,w]=b.useState(null),[S,N]=b.useState(null),O=b.useCallback(j=>{j!=L.current&&(L.current=j,w(j))},[w]),D=b.useCallback(j=>{j!==F.current&&(F.current=j,N(j))},[N]),T=a||_,A=c||S,L=b.useRef(null),F=b.useRef(null),K=b.useRef(m),Q=bg(f),X=bg(i),ee=b.useCallback(()=>{if(!L.current||!F.current)return;const j={placement:t,strategy:r,middleware:v};X.current&&(j.platform=X.current),bO(L.current,F.current,j).then(B=>{const U={...B,isPositioned:!0};ne.current&&!Ml(K.current,U)&&(K.current=U,Bc.flushSync(()=>{E(U)}))})},[v,t,r,X]);kl(()=>{p===!1&&K.current.isPositioned&&(K.current.isPositioned=!1,E(j=>({...j,isPositioned:!1})))},[p]);const ne=b.useRef(!1);kl(()=>(ne.current=!0,()=>{ne.current=!1}),[]),kl(()=>{if(T&&(L.current=T),A&&(F.current=A),T&&A){if(Q.current)return Q.current(T,A,ee);ee()}},[T,A,ee,Q]);const W=b.useMemo(()=>({reference:L,floating:F,setReference:O,setFloating:D}),[O,D]),I=b.useMemo(()=>({reference:T,floating:A}),[T,A]),V=b.useMemo(()=>{const j={position:r,left:0,top:0};if(!I.floating)return j;const B=Ig(I.floating,m.x),U=Ig(I.floating,m.y);return u?{...j,transform:"translate("+B+"px, "+U+"px)",...Ag(I.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:B,top:U}},[r,u,I.floating,m.x,m.y]);return b.useMemo(()=>({...m,update:ee,refs:W,elements:I,floatingStyles:V}),[m,ee,W,I,V])}function Lg(e){return b.useMemo(()=>e.every(t=>t==null)?null:t=>{e.forEach(r=>{typeof r=="function"?r(t):r!=null&&(r.current=t)})},e)}const kO=tp.useInsertionEffect||(e=>e());function Bo(e){const t=b.useRef(()=>{});return kO(()=>{t.current=e}),b.useCallback(function(){for(var r=arguments.length,s=new Array(r),i=0;i<r;i++)s[i]=arguments[i];return t.current==null?void 0:t.current(...s)},[])}var qs=typeof document<"u"?b.useLayoutEffect:b.useEffect;let Mu=!1,MO=0;const Dg=()=>"floating-ui-"+MO++;function PO(){const[e,t]=b.useState(()=>Mu?Dg():void 0);return qs(()=>{e==null&&t(Dg())},[]),b.useEffect(()=>{Mu||(Mu=!0)},[]),e}const kg=tp.useId||PO;function UO(){const e=new Map;return{emit(t,r){var s;(s=e.get(t))==null||s.forEach(i=>i(r))},on(t,r){e.set(t,[...e.get(t)||[],r])},off(t,r){var s;e.set(t,((s=e.get(t))==null?void 0:s.filter(i=>i!==r))||[])}}}const FO=b.createContext(null),jO=b.createContext(null),Pu=()=>{var e;return((e=b.useContext(FO))==null?void 0:e.id)||null},Uu=()=>b.useContext(jO);function Fu(e){return"data-floating-ui-"+e}function Mg(e){const t=b.useRef(e);return qs(()=>{t.current=e}),t}const Pg=Fu("safe-polygon");function ju(e,t,r){return r&&!gg(r)?0:typeof e=="number"?e:e?.[t]}function VO(e,t){t===void 0&&(t={});const{open:r,onOpenChange:s,dataRef:i,events:a,elements:{domReference:c,floating:u},refs:f}=e,{enabled:p=!0,delay:m=0,handleClose:E=null,mouseOnly:v=!1,restMs:x=0,move:_=!0}=t,w=Uu(),S=Pu(),N=Mg(E),O=Mg(m),D=b.useRef(),T=b.useRef(),A=b.useRef(),L=b.useRef(),F=b.useRef(!0),K=b.useRef(!1),Q=b.useRef(()=>{}),X=b.useCallback(()=>{var I;const V=(I=i.current.openEvent)==null?void 0:I.type;return V?.includes("mouse")&&V!=="mousedown"},[i]);b.useEffect(()=>{if(!p)return;function I(V){let{open:j}=V;j||(clearTimeout(T.current),clearTimeout(L.current),F.current=!0)}return a.on("openchange",I),()=>{a.off("openchange",I)}},[p,a]),b.useEffect(()=>{if(!p||!N.current||!r)return;function I(j){X()&&s(!1,j,"hover")}const V=zr(u).documentElement;return V.addEventListener("mouseleave",I),()=>{V.removeEventListener("mouseleave",I)}},[u,r,s,p,N,i,X]);const ee=b.useCallback(function(I,V,j){V===void 0&&(V=!0),j===void 0&&(j="hover");const B=ju(O.current,"close",D.current);B&&!A.current?(clearTimeout(T.current),T.current=setTimeout(()=>s(!1,I,j),B)):V&&(clearTimeout(T.current),s(!1,I,j))},[O,s]),ne=b.useCallback(()=>{Q.current(),A.current=void 0},[]),W=b.useCallback(()=>{if(K.current){const I=zr(f.floating.current).body;I.style.pointerEvents="",I.removeAttribute(Pg),K.current=!1}},[f]);return b.useEffect(()=>{if(!p)return;function I(){return i.current.openEvent?["click","mousedown"].includes(i.current.openEvent.type):!1}function V(U){if(clearTimeout(T.current),F.current=!1,v&&!gg(D.current)||x>0&&ju(O.current,"open")===0)return;const $=ju(O.current,"open",D.current);$?T.current=setTimeout(()=>{s(!0,U,"hover")},$):s(!0,U,"hover")}function j(U){if(I())return;Q.current();const $=zr(u);if(clearTimeout(L.current),N.current){r||clearTimeout(T.current),A.current=N.current({...e,tree:w,x:U.clientX,y:U.clientY,onClose(){W(),ne(),ee(U,!0,"safe-polygon")}});const k=A.current;$.addEventListener("mousemove",k),Q.current=()=>{$.removeEventListener("mousemove",k)};return}(D.current==="touch"?!hr(u,U.relatedTarget):!0)&&ee(U)}function B(U){I()||N.current==null||N.current({...e,tree:w,x:U.clientX,y:U.clientY,onClose(){W(),ne(),ee(U)}})(U)}if($e(c)){const U=c;return r&&U.addEventListener("mouseleave",B),u?.addEventListener("mouseleave",B),_&&U.addEventListener("mousemove",V,{once:!0}),U.addEventListener("mouseenter",V),U.addEventListener("mouseleave",j),()=>{r&&U.removeEventListener("mouseleave",B),u?.removeEventListener("mouseleave",B),_&&U.removeEventListener("mousemove",V),U.removeEventListener("mouseenter",V),U.removeEventListener("mouseleave",j)}}},[c,u,p,e,v,x,_,ee,ne,W,s,r,w,O,N,i]),qs(()=>{var I;if(p&&r&&(I=N.current)!=null&&I.__options.blockPointerEvents&&X()){const j=zr(u).body;if(j.setAttribute(Pg,""),j.style.pointerEvents="none",K.current=!0,$e(c)&&u){var V;const B=c,U=w==null||(V=w.nodesRef.current.find($=>$.id===S))==null||(V=V.context)==null?void 0:V.elements.floating;return U&&(U.style.pointerEvents=""),B.style.pointerEvents="auto",u.style.pointerEvents="auto",()=>{B.style.pointerEvents="",u.style.pointerEvents=""}}}},[p,r,S,u,c,w,N,i,X]),qs(()=>{r||(D.current=void 0,ne(),W())},[r,ne,W]),b.useEffect(()=>()=>{ne(),clearTimeout(T.current),clearTimeout(L.current),W()},[p,c,ne,W]),b.useMemo(()=>{if(!p)return{};function I(V){D.current=V.pointerType}return{reference:{onPointerDown:I,onPointerEnter:I,onMouseMove(V){r||x===0||(clearTimeout(L.current),L.current=setTimeout(()=>{F.current||s(!0,V.nativeEvent,"hover")},x))}},floating:{onMouseEnter(){clearTimeout(T.current)},onMouseLeave(V){ee(V.nativeEvent,!1)}}}},[p,x,r,s,ee])}function Pl(e,t){let r=e.filter(i=>{var a;return i.parentId===t&&((a=i.context)==null?void 0:a.open)}),s=r;for(;s.length;)s=e.filter(i=>{var a;return(a=s)==null?void 0:a.some(c=>{var u;return i.parentId===c.id&&((u=i.context)==null?void 0:u.open)})}),r=r.concat(s);return r}const $O={pointerdown:"onPointerDown",mousedown:"onMouseDown",click:"onClick"},HO={pointerdown:"onPointerDownCapture",mousedown:"onMouseDownCapture",click:"onClickCapture"},Ug=e=>{var t,r;return{escapeKey:typeof e=="boolean"?e:(t=e?.escapeKey)!=null?t:!1,outsidePress:typeof e=="boolean"?e:(r=e?.outsidePress)!=null?r:!0}};function BO(e,t){t===void 0&&(t={});const{open:r,onOpenChange:s,nodeId:i,elements:{reference:a,domReference:c,floating:u},dataRef:f}=e,{enabled:p=!0,escapeKey:m=!0,outsidePress:E=!0,outsidePressEvent:v="pointerdown",referencePress:x=!1,referencePressEvent:_="pointerdown",ancestorScroll:w=!1,bubbles:S,capture:N}=t,O=Uu(),D=Bo(typeof E=="function"?E:()=>!1),T=typeof E=="function"?D:E,A=b.useRef(!1),L=b.useRef(!1),{escapeKey:F,outsidePress:K}=Ug(S),{escapeKey:Q,outsidePress:X}=Ug(N),ee=Bo(V=>{if(!r||!p||!m||V.key!=="Escape")return;const j=O?Pl(O.nodesRef.current,i):[];if(!F&&(V.stopPropagation(),j.length>0)){let B=!0;if(j.forEach(U=>{var $;if(($=U.context)!=null&&$.open&&!U.context.dataRef.current.__escapeKeyBubbles){B=!1;return}}),!B)return}s(!1,JT(V)?V.nativeEvent:V,"escape-key")}),ne=Bo(V=>{var j;const B=()=>{var U;ee(V),(U=Wr(V))==null||U.removeEventListener("keydown",B)};(j=Wr(V))==null||j.addEventListener("keydown",B)}),W=Bo(V=>{const j=A.current;A.current=!1;const B=L.current;if(L.current=!1,v==="click"&&B||j||typeof T=="function"&&!T(V))return;const U=Wr(V),$="["+Fu("inert")+"]",z=zr(u).querySelectorAll($);let k=$e(U)?U:null;for(;k&&!Vo(k);){const oe=Br(k);if(Vo(oe)||!$e(oe))break;k=oe}if(z.length&&$e(U)&&!eO(U)&&!hr(U,u)&&Array.from(z).every(oe=>!hr(k,oe)))return;if(Vt(U)&&u){const oe=U.clientWidth>0&&U.scrollWidth>U.clientWidth,le=U.clientHeight>0&&U.scrollHeight>U.clientHeight;let de=le&&V.offsetX>U.clientWidth;if(le&&$t(U).direction==="rtl"&&(de=V.offsetX<=U.offsetWidth-U.clientWidth),de||oe&&V.offsetY>U.clientHeight)return}const Y=O&&Pl(O.nodesRef.current,i).some(oe=>{var le;return Au(V,(le=oe.context)==null?void 0:le.elements.floating)});if(Au(V,u)||Au(V,c)||Y)return;const re=O?Pl(O.nodesRef.current,i):[];if(re.length>0){let oe=!0;if(re.forEach(le=>{var de;if((de=le.context)!=null&&de.open&&!le.context.dataRef.current.__outsidePressBubbles){oe=!1;return}}),!oe)return}s(!1,V,"outside-press")}),I=Bo(V=>{var j;const B=()=>{var U;W(V),(U=Wr(V))==null||U.removeEventListener(v,B)};(j=Wr(V))==null||j.addEventListener(v,B)});return b.useEffect(()=>{if(!r||!p)return;f.current.__escapeKeyBubbles=F,f.current.__outsidePressBubbles=K;function V(U){s(!1,U,"ancestor-scroll")}const j=zr(u);m&&j.addEventListener("keydown",Q?ne:ee,Q),T&&j.addEventListener(v,X?I:W,X);let B=[];return w&&($e(c)&&(B=pr(c)),$e(u)&&(B=B.concat(pr(u))),!$e(a)&&a&&a.contextElement&&(B=B.concat(pr(a.contextElement)))),B=B.filter(U=>{var $;return U!==(($=j.defaultView)==null?void 0:$.visualViewport)}),B.forEach(U=>{U.addEventListener("scroll",V,{passive:!0})}),()=>{m&&j.removeEventListener("keydown",Q?ne:ee,Q),T&&j.removeEventListener(v,X?I:W,X),B.forEach(U=>{U.removeEventListener("scroll",V)})}},[f,u,c,a,m,T,v,r,s,w,p,F,K,ee,Q,ne,W,X,I]),b.useEffect(()=>{A.current=!1},[T,v]),b.useMemo(()=>p?{reference:{onKeyDown:ee,[$O[_]]:V=>{x&&s(!1,V.nativeEvent,"reference-press")}},floating:{onKeyDown:ee,onMouseDown(){L.current=!0},onMouseUp(){L.current=!0},[HO[v]]:()=>{A.current=!0}}}:{},[p,x,v,_,s,ee])}function zO(e){var t;e===void 0&&(e={});const{open:r=!1,onOpenChange:s,nodeId:i}=e,[a,c]=b.useState(null),u=((t=e.elements)==null?void 0:t.reference)||a,f=DO(e),p=Uu(),m=Pu()!=null,E=Bo((A,L,F)=>{A&&(x.current.openEvent=L),_.emit("openchange",{open:A,event:L,reason:F,nested:m}),s?.(A,L,F)}),v=b.useRef(null),x=b.useRef({}),_=b.useState(()=>UO())[0],w=kg(),S=b.useCallback(A=>{const L=$e(A)?{getBoundingClientRect:()=>A.getBoundingClientRect(),contextElement:A}:A;f.refs.setReference(L)},[f.refs]),N=b.useCallback(A=>{($e(A)||A===null)&&(v.current=A,c(A)),($e(f.refs.reference.current)||f.refs.reference.current===null||A!==null&&!$e(A))&&f.refs.setReference(A)},[f.refs]),O=b.useMemo(()=>({...f.refs,setReference:N,setPositionReference:S,domReference:v}),[f.refs,N,S]),D=b.useMemo(()=>({...f.elements,domReference:u}),[f.elements,u]),T=b.useMemo(()=>({...f,refs:O,elements:D,dataRef:x,nodeId:i,floatingId:w,events:_,open:r,onOpenChange:E}),[f,i,w,_,r,E,O,D]);return qs(()=>{const A=p?.nodesRef.current.find(L=>L.id===i);A&&(A.context=T)}),b.useMemo(()=>({...f,context:T,refs:O,elements:D}),[f,O,D,T])}function WO(e,t){t===void 0&&(t={});const{open:r,onOpenChange:s,events:i,refs:a,elements:{floating:c,domReference:u}}=e,{enabled:f=!0,visibleOnly:p=!0}=t,m=b.useRef(!1),E=b.useRef(),v=b.useRef(!0);return b.useEffect(()=>{if(!f)return;const x=Ct(u);function _(){!r&&Vt(u)&&u===hg(zr(u))&&(m.current=!0)}function w(){v.current=!0}return x.addEventListener("blur",_),x.addEventListener("keydown",w,!0),()=>{x.removeEventListener("blur",_),x.removeEventListener("keydown",w,!0)}},[c,u,r,f]),b.useEffect(()=>{if(!f)return;function x(_){let{reason:w}=_;(w==="reference-press"||w==="escape-key")&&(m.current=!0)}return i.on("openchange",x),()=>{i.off("openchange",x)}},[i,f]),b.useEffect(()=>()=>{clearTimeout(E.current)},[]),b.useMemo(()=>f?{reference:{onPointerDown(x){XT(x.nativeEvent)||(v.current=!1)},onMouseLeave(){m.current=!1},onFocus(x){if(m.current)return;const _=Wr(x.nativeEvent);if(p&&$e(_))try{if(QT()&&ZT())throw Error();if(!_.matches(":focus-visible"))return}catch{if(!v.current&&!nO(_))return}s(!0,x.nativeEvent,"focus")},onBlur(x){m.current=!1;const _=x.relatedTarget,w=$e(_)&&_.hasAttribute(Fu("focus-guard"))&&_.getAttribute("data-type")==="outside";E.current=window.setTimeout(()=>{const S=hg(u?u.ownerDocument:document);!_&&S===u||hr(a.floating.current,_)||hr(u,_)||w||s(!1,x.nativeEvent,"focus")})}}}:{},[f,p,u,a,s])}const Fg="active",jg="selected";function Vu(e,t,r){const s=new Map,i=r==="item";let a=e;if(i&&e){const{[Fg]:c,[jg]:u,...f}=e;a=f}return{...r==="floating"&&{tabIndex:-1},...a,...t.map(c=>{const u=c?c[r]:null;return typeof u=="function"?e?u(e):null:u}).concat(e).reduce((c,u)=>(u&&Object.entries(u).forEach(f=>{let[p,m]=f;if(!(i&&[Fg,jg].includes(p)))if(p.indexOf("on")===0){if(s.has(p)||s.set(p,[]),typeof m=="function"){var E;(E=s.get(p))==null||E.push(m),c[p]=function(){for(var v,x=arguments.length,_=new Array(x),w=0;w<x;w++)_[w]=arguments[w];return(v=s.get(p))==null?void 0:v.map(S=>S(..._)).find(S=>S!==void 0)}}}else c[p]=m}),c),{})}}function GO(e){e===void 0&&(e=[]);const t=e,r=b.useCallback(a=>Vu(a,e,"reference"),t),s=b.useCallback(a=>Vu(a,e,"floating"),t),i=b.useCallback(a=>Vu(a,e,"item"),e.map(a=>a?.item));return b.useMemo(()=>({getReferenceProps:r,getFloatingProps:s,getItemProps:i}),[r,s,i])}const YO=new Map([["select","listbox"],["combobox","listbox"],["label",!1]]);function KO(e,t){var r;t===void 0&&(t={});const{open:s,floatingId:i}=e,{enabled:a=!0,role:c="dialog"}=t,u=(r=YO.get(c))!=null?r:c,f=kg(),m=Pu()!=null;return b.useMemo(()=>{if(!a)return{};const E={id:i,...u&&{role:u}};return u==="tooltip"||c==="label"?{reference:{["aria-"+(c==="label"?"labelledby":"describedby")]:s?i:void 0},floating:E}:{reference:{"aria-expanded":s?"true":"false","aria-haspopup":u==="alertdialog"?"dialog":u,"aria-controls":s?i:void 0,...u==="listbox"&&{role:"combobox"},...u==="menu"&&{id:f},...u==="menu"&&m&&{role:"menuitem"},...c==="select"&&{"aria-autocomplete":"none"},...c==="combobox"&&{"aria-autocomplete":"list"}},floating:{...E,...u==="menu"&&{"aria-labelledby":f}},item(v){let{active:x,selected:_}=v;const w={role:"option",...x&&{id:i+"-option"}};switch(c){case"select":return{...w,"aria-selected":x&&_};case"combobox":return{...w,...x&&{"aria-selected":!0}}}return{}}}},[a,c,u,s,i,f,m])}function Vg(e,t){const[r,s]=e;let i=!1;const a=t.length;for(let c=0,u=a-1;c<a;u=c++){const[f,p]=t[c]||[0,0],[m,E]=t[u]||[0,0];p>=s!=E>=s&&r<=(m-f)*(s-p)/(E-p)+f&&(i=!i)}return i}function XO(e,t){return e[0]>=t.x&&e[0]<=t.x+t.width&&e[1]>=t.y&&e[1]<=t.y+t.height}function QO(e){e===void 0&&(e={});const{buffer:t=.5,blockPointerEvents:r=!1,requireIntent:s=!0}=e;let i,a=!1,c=null,u=null,f=performance.now();function p(E,v){const x=performance.now(),_=x-f;if(c===null||u===null||_===0)return c=E,u=v,f=x,null;const w=E-c,S=v-u,O=Math.sqrt(w*w+S*S)/_;return c=E,u=v,f=x,O}const m=E=>{let{x:v,y:x,placement:_,elements:w,onClose:S,nodeId:N,tree:O}=E;return function(T){function A(){clearTimeout(i),S()}if(clearTimeout(i),!w.domReference||!w.floating||_==null||v==null||x==null)return;const{clientX:L,clientY:F}=T,K=[L,F],Q=Wr(T),X=T.type==="mouseleave",ee=hr(w.floating,Q),ne=hr(w.domReference,Q),W=w.domReference.getBoundingClientRect(),I=w.floating.getBoundingClientRect(),V=_.split("-")[0],j=v>I.right-I.width/2,B=x>I.bottom-I.height/2,U=XO(K,W),$=I.width>W.width,z=I.height>W.height,k=($?W:I).left,Y=($?W:I).right,re=(z?W:I).top,oe=(z?W:I).bottom;if(ee&&(a=!0,!X))return;if(ne&&(a=!1),ne&&!X){a=!0;return}if(X&&$e(T.relatedTarget)&&hr(w.floating,T.relatedTarget)||O&&Pl(O.nodesRef.current,N).some(he=>{let{context:ue}=he;return ue?.open}))return;if(V==="top"&&x>=W.bottom-1||V==="bottom"&&x<=W.top+1||V==="left"&&v>=W.right-1||V==="right"&&v<=W.left+1)return A();let le=[];switch(V){case"top":le=[[k,W.top+1],[k,I.bottom-1],[Y,I.bottom-1],[Y,W.top+1]];break;case"bottom":le=[[k,I.top+1],[k,W.bottom-1],[Y,W.bottom-1],[Y,I.top+1]];break;case"left":le=[[I.right-1,oe],[I.right-1,re],[W.left+1,re],[W.left+1,oe]];break;case"right":le=[[W.right-1,oe],[W.right-1,re],[I.left+1,re],[I.left+1,oe]];break}function de(he){let[ue,me]=he;switch(V){case"top":{const Re=[$?ue+t/2:j?ue+t*4:ue-t*4,me+t+1],Pe=[$?ue-t/2:j?ue+t*4:ue-t*4,me+t+1],Je=[[I.left,j||$?I.bottom-t:I.top],[I.right,j?$?I.bottom-t:I.top:I.bottom-t]];return[Re,Pe,...Je]}case"bottom":{const Re=[$?ue+t/2:j?ue+t*4:ue-t*4,me-t],Pe=[$?ue-t/2:j?ue+t*4:ue-t*4,me-t],Je=[[I.left,j||$?I.top+t:I.bottom],[I.right,j?$?I.top+t:I.bottom:I.top+t]];return[Re,Pe,...Je]}case"left":{const Re=[ue+t+1,z?me+t/2:B?me+t*4:me-t*4],Pe=[ue+t+1,z?me-t/2:B?me+t*4:me-t*4];return[...[[B||z?I.right-t:I.left,I.top],[B?z?I.right-t:I.left:I.right-t,I.bottom]],Re,Pe]}case"right":{const Re=[ue-t,z?me+t/2:B?me+t*4:me-t*4],Pe=[ue-t,z?me-t/2:B?me+t*4:me-t*4],Je=[[B||z?I.left+t:I.right,I.top],[B?z?I.left+t:I.right:I.left+t,I.bottom]];return[Re,Pe,...Je]}}}if(!Vg([L,F],le)){if(a&&!U)return A();if(!X&&s){const he=p(T.clientX,T.clientY);if(he!==null&&he<.1)return A()}Vg([L,F],de([v,x]))?!a&&s&&(i=window.setTimeout(A,40)):A()}}};return m.__options={blockPointerEvents:r},m}function qO({arrowPadding:e,escapeKey:t=!0,initialOpen:r=!1,keepOpenOverContent:s=!1,onOpenChange:i,open:a,outsidePress:c=!0,placement:u,role:f="tooltip"}){const p=ye(L=>L.rootElementId),m=b.useRef(null),[E,v]=b.useState(r),x=a??E,_=i??v,w=zO({middleware:[pO(8),dO({boundary:document.querySelector(`#${p}`)||void 0}),hO({padding:4}),LO({element:m,padding:e??{bottom:0,left:8,right:8,top:8}})],onOpenChange:_,open:x,placement:u,strategy:"fixed",whileElementsMounted:IO}),S=w.context,N=VO(S,{enabled:a==null,handleClose:s?QO():null,move:!1}),O=WO(S,{enabled:a==null}),D=BO(S,{escapeKey:t,outsidePress:c}),T=KO(S,{role:f}),A=GO([N,O,D,T]);return b.useMemo(()=>({arrowRef:m,open:x,setOpen:_,...A,...w}),[x,_,A,w])}const $g=te.createContext(null),$u=()=>{const e=te.useContext($g);if(e==null)throw new Error("Tooltip components must be wrapped in <Tooltip />");return e},ZO=({children:e,...t})=>{const r=qO(t);return h.jsx($g.Provider,{value:r,children:e})},JO={bottom:"-top-1 before:border-b-0 before:border-r-0",left:"-right-1 before:border-r-0 before:border-t-0",right:"-left-1 before:border-l-0 before:border-b-0",top:"-bottom-1 before:border-t-0 before:border-l-0"},eC=()=>{const e=$u(),[t,r]=b.useState(e.middlewareData.arrow);b.useEffect(()=>{e.middlewareData.arrow&&r(e.middlewareData.arrow)},[e.middlewareData.arrow]);const s={left:t?.x!=null?`${t?.x}px`:"",top:t?.y!=null?`${t?.y}px`:""},i=e.placement?.split("-")?.[0]||"top",a=`${JO[i]}`;return h.jsx("div",{ref:e.arrowRef,style:s,className:`tooltip-arrow absolute h-2 w-2 rotate-45 bg-inherit
|
|
62
62
|
before:absolute before:h-2 before:w-2 before:border before:border-foreground/30 before:content-['']
|
|
63
63
|
${a}`})},tC=te.forwardRef(function(t,r){const{children:s,style:i,...a}=t,c=$u(),u=Lg([c.refs.setFloating,r]);return c.open?h.jsxs("div",{className:"relative max-w-md rounded-md bg-foreground p-2 text-sm text-background shadow-sm",ref:u,style:{left:c.x??0,position:c.strategy,top:c.y??0,visibility:c.x==null?"hidden":"visible",zIndex:10,...i},...c.getFloatingProps(a),children:[h.jsx("div",{className:"overflow-hidden",children:s}),h.jsx(eC,{})]}):null}),nC=b.forwardRef(function({children:t,asChild:r=!1,...s},i){const a=$u(),c=Lg([a.refs.setReference,i,t?.ref]);return r&&b.isValidElement(t)?b.cloneElement(t,a.getReferenceProps({ref:c,...s,...t.props,"data-state":a.open?"open":"closed"})):h.jsx("button",{ref:c,"data-state":a.open?"open":"closed",...a.getReferenceProps(s),children:t})}),Hg={bottom:"top",left:"right",right:"left",top:"bottom"},gr=({asChild:e=!0,children:t,enable:r=!0,placement:s="right",scale:i=1,trigger:a=h.jsx(Ce,{tag:"circle-info"}),...c})=>{let u=s.split("-")[0];return u=Object.keys(Hg).includes(u)?u:"right",r?h.jsxs(ZO,{...c,placement:s,children:[h.jsx(nC,{asChild:e,children:a}),h.jsx(tC,{style:i!==1?{transform:`scale(${i})`,transformOrigin:Hg[u]}:void 0,children:t})]}):h.jsx(h.Fragment,{children:a})},rC={ABOUT:"About",ACTION:"Action",ADD_ADDRESS:"Add address",ADD_AI_AGENT:"Add AI agent",ADD_CONDITION:"Add condition",ADD_OPTION:"Add option",ADD_PHONE_NUMBER:"Add phone number",ADD_RESOURCE:"Add resource",ADD_SWML_SCRIPTS:"Add SWML Scripts",ADD_VARIABLE:"Add variable",ADDRESS_NUMBER:"Address {{index}}",AI_AGENT:"AI Agent",AI_AGENT_NAME:"AI Agent Name",ANSWER_CALL:"Answer Call",ARE_YOU_SURE:"Are you sure?",AUDIO_FILE:"Audio File",BEEP:"Beep",BEEP_SUBTITLE:"Play a beep before recording",BUSY:"Busy",CALL_ADDRESSES:"Call Addresses",CALL_NUMBERS:"Call Numbers",CALL_RESOURCES:"Call Resources",CALL_STATE_EVENTS:"Call State Events",CALL_STATE_URL:"Call State URL",CALLER_PRESSES:"Caller presses",CALLER_SAYS:"Caller says",CANCEL:"Cancel",CAUTION:"Caution",CHOOSE_OPTION_TTS_AUDIO:"Choose how to play the message",CLOSE:"Close",CONDITION_NUMBER:"Condition {{index}}",CONDITIONS:"Conditions",DECISION:"Decision",DECLINE:"Decline",DEFAULT_FROM:"Default From",DEFAULT_TIMEOUT:"Default Timeout",DELETE:"Delete",DELETE_NODE:"Delete node",DEPLOY:"Deploy",DEPLOY_WARNING:"Caution - Confirm Deploy",DEPRECATED:"Deprecated",DOCUMENT_OUT_OF_SYNC:"Document Out of Sync",EDIT_SELECTED_AI_AGENT:"Edit Selected AI Agent",ELSE:"Else",END_SILENCE_TIMEOUT:"End Silence Timeout",ENABLE_WHISPER:"Enable Whisper",ENTER_URL:"Enter URL",ERROR:"Error",ERROR_ADD_AI_AGENT_FIRST:"Please add an AI Agent first.",ERROR_ADD_RECORDING_FIRST:"Please add a Start Call Recording node first.",ERROR_DUPLICATE_COMMAND:"This command is already used. Please use a unique phrase.",ERROR_DUPLICATE_RECORDING_LABEL:"This entry already exists. Please use a unique label.",ERROR_DUPLICATE_TELEPHONE_KEY:"This key is already used. Please use a unique key.",ERROR_DUPLICATE_VARIABLE_KEY:"This variable already exists. Please use a unique key.",ERROR_FETCHING_AI_AGENTS:"Error fetching AI Agents.",ERROR_FETCHING_DEPLOYED_VERSIONS:"Error fetching deployed versions.",ERROR_FETCHING_SWML_SCRIPTS:"Error fetching SWML Scripts.",ERROR_INVALID_JSON:"Invalid JSON",ERROR_NUMBER_IS_REQUIRED:"A number is required.",ERROR_NUMBER_MIN_MAX_IS_REQUIRED:"A number between {{min}} and {{max}} is required.",ERROR_RECORDING_LABEL_REQUIRED:"A value is required. Maximum 20 characters.",ERROR_SELECTION_REQUIRED:"A selection is required.",ERROR_TELEPHONE_KEY_REQUIRED:"A value of 0-9, *, or # is required.",ERROR_TERMINATORS:"This value should contain only 0-9, *, or #.",ERROR_TEXT_IS_REQUIRED:"A text value is required.",ERROR_URL_IS_REQUIRED:"A valid URL is required.",ERROR_VALUE_IS_REQUIRED:"A value is required.",ERROR_VARIABLE_KEY_REQUIRED:"Valid characters are lowercase letters, digits, or underscore. Maximum 20 characters.",EXTERNAL_OPTION_LABEL:"Enter the URL of the external resource.",EXTERNAL_OR_INTERNAL_RESOURCE:"External or Internal Resource",EXTERNAL_URL:"External URL",EXECUTE_SWML:"Execute SWML",FAILED:"Failed",FAILURE:"Failure",FLOW_DATA_VERSION:"Flow Data Version",FORMAT:"Format",FORWARD:"Forward",FORWARD_TO_ADDRESS:"Forward to Address",FORWARD_TO_PHONE:"Forward to Phone",FORWARD_TO_RESOURCE:"Forward to Resource",FROM:"From",FROM_PHONE_NUMBER:"From Phone Number",GATHER_INPUT:"Gather Input",GENDER:"Gender",GO_BACK:"Go Back",HANDLE_VIA:"Handle Via",HANDLE_CALL:"Handle Call",HANG_UP:"Hang Up",HANG_UP_CALL:"Hang Up Call",HELP:"Help",HIDDEN:"Hidden",IGNORE:"Ignore",INFO_DEPLOY:"Deploy the latest changes for the current call flow.",INFO_INVALID_SETTINGS:"Please check the settings and ensure that all required fields are filled in correctly.",INFO_NODE_AI_AGENT:"<p>Used to connect to a conversational AI Agent for processing.</p><p>Choose the appropriate AI Agent or create a new one: <a>AI Agents</a></p>",INFO_NODE_COND:`<p>A condition works like a JavaScript <code>if</code> statement.</p><p>A condition field can reference variables that have been set in the flow with <code>%{Key}</code>, Request node responses accessed with <code>%{request_response['object_field']}</code>, or call parameters such as <code>%{call.from}</code>.</p><p>Add additional conditions to create <code>else if</code> conditions.</p><p>The "Cond #" path will be executed for a truthy condition. The "Else" path will be executed for a falsy condition.</p>`,INFO_NODE_CONDREQUEST:"<p>Send a GET, POST, PUT, or DELETE request to any webhook.</p><p>This can be used to submit variables and information about an inbound call to an external server, or you can retrieve information from external servers and use them as variables throughout the call flow. You can also build conditions directly into this module.</p><p>Response variables can be accessed with <code>%{request_response['object_field']}</code>.</p><p>Headers should be input in JSON format. Valid header values are <code>Accept</code>, <code>Authorization</code>, <code>Content-Type</code>, <code>Range</code>, and <code>custom X- headers</code>.</p>",INFO_NODE_EXECUTE_SWML:"Execute a remote SWML document and return to the current document. Use <code>%{return_value.['object_field']}</code> to reference the return values from the external SWML.",INFO_NODE_FORWARD_TO_ADDRESS:"Forwards the current call to the specified Address as defined within your SignalWire space.",INFO_NODE_FORWARD_TO_PHONE:"Forwards the current call to the specified phone number (must be E.164 format).",INFO_NODE_FORWARD_TO_RESOURCE:"Forwards the current call to the specified Resource as defined within your SignalWire space.",INFO_NODE_GATHER_INPUT:"Plays an audio file or Text to Speech phrase and waits for a keypress or spoken input from the caller, allowing them to proceed through the call flow based on their input.",INFO_NODE_HANG_UP:"Ends the call with the ability to provide a reason (hangup, busy, or decline).",INFO_NODE_PLAY:"Plays an audio file or Text to Speech phrase. A valid URL must be provided for the audio file to be played. Text to Speech will read aloud the provided text using the voice option that is selected.",INFO_NODE_RECORD:"Triggers foreground recording of both sides of the call and waits for the recording to end. Options can be set to enable stereo audio, play a notification beep before recording, set a digit to stop recording (terminator), and specify the recording name and format (WAV or MP3).",INFO_NODE_RECORD_CALL_START:"Triggers background recording of both sides of the call. Options can be set to enable stereo audio, play a notification beep before recording, set a digit to stop recording (terminator), and specify the recording name and format (WAV or MP3).",INFO_NODE_RECORD_CALL_STOP:"Triggers a background call recording to stop at a specific point in the call flow, if it has not already been terminated.",INFO_NODE_REQUEST:"<p>Send a GET, POST, PUT, or DELETE request to any webhook.</p><p>This can be used to submit variables and information about an inbound call to an external server, or you can retrieve information from external servers and use them as variables throughout the call flow. You can also build conditions directly into this module.</p><p>Response variables can be accessed with <code>%{request_response['object_field']}</code>.</p><p>Headers should be input in JSON format. Valid header values are <code>Accept</code>, <code>Authorization</code>, <code>Content-Type</code>, <code>Range</code>, and <code>custom X- headers</code>.</p>",INFO_NODE_SEND_SMS:"Sends an SMS message to the specified phone number. The 'From' phone number must be enabled for messaging (a 10DLC number assigned to an active TCR campaign or a verified toll free number).",INFO_NODE_SET_VARIABLES:`<p>Set variables that can be accessed from other node blocks in the call flow.</p><p>The value can be a static value <code>("value")</code>, a variable from another node such as a request response <code>%{request_response.['object_field']}</code>, or a call parameter <code>%{call.from}</code>.</p><p>Access these variables in other blocks with <code>%{Key}</code> and unset variables with the Unset Variables block.</p>`,INFO_NODE_UNSET_VARIABLES:"Unsets script variables.",INFO_STATUS_ERROR:"An error occurred while loading or saving the flow.",INFO_STATUS_ERROR_OUT_OF_SYNC:"This document is locked because another user has made updates to the Call Flow. Refresh the page to discard your changes and unlock the flow with the latest updates.",INITIAL_TIMEOUT:"Initial Timeout",INPUT:"Input",INVALID_SETTINGS:"Invalid settings",JSON_OBJECT:"JSON object to serialize",KEY:"Key",KEYPAD_VALUE:"Keypad value",LANGUAGE:"Language",MAXIMUM_RECORDING_LENGTH:"Maximum Recording Length",META:"Meta",METHOD:"Method",MORE_INFO_DEPLOY:"Deploying a Call Flow makes it live.",MORE_INFO_DEPLOY_ERROR:"There was an error deploying the Call Flow. Please try again. {{message}}",MORE_INFO_STATUS_ERROR:"More info on Flow document error",MORE_INFO_TESTING_YOUR_FLOW:"Info on testing your call flow",MORE_WITH_COUNT:"{{count}} more",NAVIGATE_BACK:"Navigate Back",NO_ANSWER:"No Answer",NO_DEPLOYED_VERSIONS:"<p>No deployed versions found.</p> <p>Deploy a flow to view the history.</p>",NO_INPUT:"No Input",NO_RESULTS:"No results",NO_SCRIPTS_FOUND:"No scripts found.",NO_VARIABLES_SET:"Please set variables first",NOT_CONNECTED_TO_FLOW:"Not connected to flow",NUMBER_OF_VALIDATION_WARNINGS_one:"There is {{count}} validation warning in your flow",NUMBER_OF_VALIDATION_WARNINGS_other:"There are {{count}} validation warnings in your flow",NUMBER_OF_VARIABLES_SELECTED_one:"{{count}} variable selected",NUMBER_OF_VARIABLES_SELECTED_other:"{{count}} variables selected",OFF:"Off",ON:"On",OPTION_NUMBER:"Option {{index}}",OPTIONAL:"optional",OR_CALLER_SAYS:"or says",OR_SAYS:"Or says",PARAMS:"Params",PHONE_NUMBER:"Phone Number",PHONE_NUMBER_NUMBER:"Phone Number {{index}}",PKG_VERSION:"Package Version",PLAY_AUDIO:"Play Audio",PLAY_AUDIO_FILE:"Play Audio File",PLAY_AUDIO_TTS:"Play Audio or TTS",PREVIEW_DEPLOYED_VERSION:"You are previewing this version.",REASON:"Reason",RECORD:"Record",RECORD_CALL_START:"Start Call Recording",RECORD_CALL_STOP:"Stop Call Recording",RECORDING:"Recording",RECORDING_NAME:"Recording Name",RECORDING_NAME_DEFAULT:"Recording {{index}}",REMOVE_ADDRESS:"Remove Address {{index}}",REMOVE_CONDITION:"Remove Condition {{index}}",REMOVE_EDGE:"Remove Edge",REMOVE_NODE:"Remove Node {{title}}",REMOVE_OPTION:"Remove Option {{index}}",REMOVE_PHONE_NUMBER:"Remove Phone Number {{index}}",REMOVE_RESOURCE:"Remove Resource {{index}}",REMOVE_VARIABLE:"Remove Variable {{index}}",REQUEST:"Request",REQUEST_BODY:"Body",REQUEST_HEADERS:"Headers (JSON)",RESOURCE_NUMBER:"Resource {{index}}",RESTORE:"Restore",RESTORE_THIS_VERSION:"Restore this version",RESYNC:"Resync",RESYNC_AI_AGENTS:"Resync AI Agents",SAVED:"Saved",SAVE_VARIABLES:"Save Variables",SAVE_VARIABLES_SUBTITLE:"Store the response as variables",SCRIPT_NOT_FOUND:"Selected script not found. A selection is required.",SEARCH_FOR_INTERNAL_SCRIPT:"Search for internal script",SECONDS:"Seconds",SELECT:"Select",SELECT_VARIABLES:"Select Variables",SELECT_VARIABLES_TO_UNSET:"Select Variables to Unset",SEND_SMS:"Send SMS",SEPARATE_WITH_COMMAS:"Separate with commas",SEQUENTIALLY:"Sequentially",SET_VARIABLES:"Set Variables",SIMULTANEOUSLY:"Simultaneously",SMS_TEXT:"SMS Text",SPOKEN_PROMPT:"Spoken prompt",STATUS_DEPLOY:"Deploy",STATUS_DEPLOY_ERROR:"Deploy Error",STATUS_DEPLOYED:"Deployed",STATUS_DEPLOYING:"Deploying...",STATUS_ERROR:"Error",STATUS_LOADING:"Loading...",STATUS_LOCKED:"Locked",STATUS_SAVED:"Saved",STATUS_SAVING:"Saving...",STEREO:"Stereo",STEREO_SUBTITLE:"Enable stereo audio",STRING_OR_JSON:"String or JSON to serialize",SUCCESS:"Success",SWML_TO_EXECUTE:"SWML to execute on answer",TERMINATORS:"Terminators",TEXT:"Text",TEXT_TO_SPEECH:"Text to Speech",TIMEOUT:"Timeout",TO:"To",TO_PHONE_NUMBER:"To Phone Number",TOAST_DEPLOY_WARNING:'<p>There are inconsistencies in your Call Flow which may cause unexpected behavior. Please review the Call Flow before deploying.</p><p>Choose "Deploy" to deploy the Call Flow or "Cancel" to return to editing.</p>',TOAST_DOCUMENT_OUT_OF_SYNC:'<p>Updates have been made to this Call Flow by another user and your recent changes have not been saved.</p><p>Choose "Ignore" to view your changes in a locked state or "Resync" to abandon your changes and adopt the latest updates.</p>',TOGGLE_CLOSE:"Toggle close",TOGGLE_OPEN:"Toggle open",UNKNOWN:"Unknown",UNSET_VARIABLES:"Unset Variables",URL:"URL",VALUE:"Value",VARIABLE_KEY:"Variable {{key}}",VARIABLE_NUMBER:"Variable {{index}}",VERSION_HISTORY:"Version History",VERSION_LIST_ITEM:"Version {{number}}",VERSION_RESTORED:"Version restored",VOICE:"Voice",VOICEMAIL_RECORDING:"Voicemail Recording",WAIT_FOR_DIGIT:"Wait for Digit",WAIT_FOR_INPUT:"Wait for Input",WARNING:"Warning",WRITE_SOMETHING:"Write something"},C={ABOUT:"ABOUT",ACTION:"ACTION",ADDRESS_NUMBER:"ADDRESS_NUMBER",ADD_ADDRESS:"ADD_ADDRESS",ADD_AI_AGENT:"ADD_AI_AGENT",ADD_CONDITION:"ADD_CONDITION",ADD_OPTION:"ADD_OPTION",ADD_PHONE_NUMBER:"ADD_PHONE_NUMBER",ADD_RESOURCE:"ADD_RESOURCE",ADD_SWML_SCRIPTS:"ADD_SWML_SCRIPTS",ADD_VARIABLE:"ADD_VARIABLE",AI_AGENT:"AI_AGENT",AI_AGENT_NAME:"AI_AGENT_NAME",ANSWER_CALL:"ANSWER_CALL",ARE_YOU_SURE:"ARE_YOU_SURE",AUDIO_FILE:"AUDIO_FILE",BEEP:"BEEP",BEEP_SUBTITLE:"BEEP_SUBTITLE",BUSY:"BUSY",CALLER_PRESSES:"CALLER_PRESSES",CALLER_SAYS:"CALLER_SAYS",CALL_ADDRESSES:"CALL_ADDRESSES",CALL_NUMBERS:"CALL_NUMBERS",CALL_RESOURCES:"CALL_RESOURCES",CALL_STATE_EVENTS:"CALL_STATE_EVENTS",CALL_STATE_URL:"CALL_STATE_URL",CANCEL:"CANCEL",CAUTION:"CAUTION",CHOOSE_OPTION_TTS_AUDIO:"CHOOSE_OPTION_TTS_AUDIO",CLOSE:"CLOSE",CONDITIONS:"CONDITIONS",CONDITION_NUMBER:"CONDITION_NUMBER",DECISION:"DECISION",DECLINE:"DECLINE",DEFAULT_FROM:"DEFAULT_FROM",DEFAULT_TIMEOUT:"DEFAULT_TIMEOUT",DELETE:"DELETE",DELETE_NODE:"DELETE_NODE",DEPLOY:"DEPLOY",DEPLOY_WARNING:"DEPLOY_WARNING",DEPRECATED:"DEPRECATED",DOCUMENT_OUT_OF_SYNC:"DOCUMENT_OUT_OF_SYNC",EDIT_SELECTED_AI_AGENT:"EDIT_SELECTED_AI_AGENT",ELSE:"ELSE",ENABLE_WHISPER:"ENABLE_WHISPER",END_SILENCE_TIMEOUT:"END_SILENCE_TIMEOUT",ENTER_URL:"ENTER_URL",ERROR:"ERROR",ERROR_ADD_AI_AGENT_FIRST:"ERROR_ADD_AI_AGENT_FIRST",ERROR_ADD_RECORDING_FIRST:"ERROR_ADD_RECORDING_FIRST",ERROR_DUPLICATE_COMMAND:"ERROR_DUPLICATE_COMMAND",ERROR_DUPLICATE_RECORDING_LABEL:"ERROR_DUPLICATE_RECORDING_LABEL",ERROR_DUPLICATE_TELEPHONE_KEY:"ERROR_DUPLICATE_TELEPHONE_KEY",ERROR_DUPLICATE_VARIABLE_KEY:"ERROR_DUPLICATE_VARIABLE_KEY",ERROR_FETCHING_AI_AGENTS:"ERROR_FETCHING_AI_AGENTS",ERROR_FETCHING_DEPLOYED_VERSIONS:"ERROR_FETCHING_DEPLOYED_VERSIONS",ERROR_FETCHING_SWML_SCRIPTS:"ERROR_FETCHING_SWML_SCRIPTS",ERROR_INVALID_JSON:"ERROR_INVALID_JSON",ERROR_NUMBER_IS_REQUIRED:"ERROR_NUMBER_IS_REQUIRED",ERROR_NUMBER_MIN_MAX_IS_REQUIRED:"ERROR_NUMBER_MIN_MAX_IS_REQUIRED",ERROR_RECORDING_LABEL_REQUIRED:"ERROR_RECORDING_LABEL_REQUIRED",ERROR_SELECTION_REQUIRED:"ERROR_SELECTION_REQUIRED",ERROR_TELEPHONE_KEY_REQUIRED:"ERROR_TELEPHONE_KEY_REQUIRED",ERROR_TERMINATORS:"ERROR_TERMINATORS",ERROR_TEXT_IS_REQUIRED:"ERROR_TEXT_IS_REQUIRED",ERROR_URL_IS_REQUIRED:"ERROR_URL_IS_REQUIRED",ERROR_VALUE_IS_REQUIRED:"ERROR_VALUE_IS_REQUIRED",ERROR_VARIABLE_KEY_REQUIRED:"ERROR_VARIABLE_KEY_REQUIRED",EXECUTE_SWML:"EXECUTE_SWML",EXTERNAL_OPTION_LABEL:"EXTERNAL_OPTION_LABEL",EXTERNAL_OR_INTERNAL_RESOURCE:"EXTERNAL_OR_INTERNAL_RESOURCE",EXTERNAL_URL:"EXTERNAL_URL",FAILED:"FAILED",FAILURE:"FAILURE",FLOW_DATA_VERSION:"FLOW_DATA_VERSION",FORMAT:"FORMAT",FORWARD:"FORWARD",FORWARD_TO_ADDRESS:"FORWARD_TO_ADDRESS",FORWARD_TO_PHONE:"FORWARD_TO_PHONE",FORWARD_TO_RESOURCE:"FORWARD_TO_RESOURCE",FROM:"FROM",FROM_PHONE_NUMBER:"FROM_PHONE_NUMBER",GATHER_INPUT:"GATHER_INPUT",GENDER:"GENDER",GO_BACK:"GO_BACK",HANDLE_CALL:"HANDLE_CALL",HANDLE_VIA:"HANDLE_VIA",HANG_UP:"HANG_UP",HANG_UP_CALL:"HANG_UP_CALL",HELP:"HELP",HIDDEN:"HIDDEN",IGNORE:"IGNORE",INFO_INVALID_SETTINGS:"INFO_INVALID_SETTINGS",INFO_NODE_AI_AGENT:"INFO_NODE_AI_AGENT",INFO_NODE_COND:"INFO_NODE_COND",INFO_NODE_CONDREQUEST:"INFO_NODE_CONDREQUEST",INFO_NODE_EXECUTE_SWML:"INFO_NODE_EXECUTE_SWML",INFO_NODE_FORWARD_TO_ADDRESS:"INFO_NODE_FORWARD_TO_ADDRESS",INFO_NODE_FORWARD_TO_PHONE:"INFO_NODE_FORWARD_TO_PHONE",INFO_NODE_FORWARD_TO_RESOURCE:"INFO_NODE_FORWARD_TO_RESOURCE",INFO_NODE_GATHER_INPUT:"INFO_NODE_GATHER_INPUT",INFO_NODE_HANG_UP:"INFO_NODE_HANG_UP",INFO_NODE_PLAY:"INFO_NODE_PLAY",INFO_NODE_RECORD:"INFO_NODE_RECORD",INFO_NODE_RECORD_CALL_START:"INFO_NODE_RECORD_CALL_START",INFO_NODE_RECORD_CALL_STOP:"INFO_NODE_RECORD_CALL_STOP",INFO_NODE_REQUEST:"INFO_NODE_REQUEST",INFO_NODE_SEND_SMS:"INFO_NODE_SEND_SMS",INFO_NODE_SET_VARIABLES:"INFO_NODE_SET_VARIABLES",INFO_NODE_UNSET_VARIABLES:"INFO_NODE_UNSET_VARIABLES",INFO_STATUS_ERROR:"INFO_STATUS_ERROR",INFO_STATUS_ERROR_OUT_OF_SYNC:"INFO_STATUS_ERROR_OUT_OF_SYNC",INITIAL_TIMEOUT:"INITIAL_TIMEOUT",INPUT:"INPUT",INVALID_SETTINGS:"INVALID_SETTINGS",JSON_OBJECT:"JSON_OBJECT",KEY:"KEY",KEYPAD_VALUE:"KEYPAD_VALUE",LANGUAGE:"LANGUAGE",MAXIMUM_RECORDING_LENGTH:"MAXIMUM_RECORDING_LENGTH",META:"META",METHOD:"METHOD",MORE_INFO_DEPLOY:"MORE_INFO_DEPLOY",MORE_INFO_DEPLOY_ERROR:"MORE_INFO_DEPLOY_ERROR",MORE_INFO_STATUS_ERROR:"MORE_INFO_STATUS_ERROR",MORE_INFO_TESTING_YOUR_FLOW:"MORE_INFO_TESTING_YOUR_FLOW",MORE_WITH_COUNT:"MORE_WITH_COUNT",NAVIGATE_BACK:"NAVIGATE_BACK",NOT_CONNECTED_TO_FLOW:"NOT_CONNECTED_TO_FLOW",NO_ANSWER:"NO_ANSWER",NO_DEPLOYED_VERSIONS:"NO_DEPLOYED_VERSIONS",NO_INPUT:"NO_INPUT",NO_RESULTS:"NO_RESULTS",NO_SCRIPTS_FOUND:"NO_SCRIPTS_FOUND",NO_VARIABLES_SET:"NO_VARIABLES_SET",NUMBER_OF_VALIDATION_WARNINGS:"NUMBER_OF_VALIDATION_WARNINGS",NUMBER_OF_VARIABLES_SELECTED:"NUMBER_OF_VARIABLES_SELECTED",OFF:"OFF",ON:"ON",OPTIONAL:"OPTIONAL",OPTION_NUMBER:"OPTION_NUMBER",OR_CALLER_SAYS:"OR_CALLER_SAYS",OR_SAYS:"OR_SAYS",PARAMS:"PARAMS",PHONE_NUMBER_NUMBER:"PHONE_NUMBER_NUMBER",PKG_VERSION:"PKG_VERSION",PLAY_AUDIO:"PLAY_AUDIO",PLAY_AUDIO_FILE:"PLAY_AUDIO_FILE",PLAY_AUDIO_TTS:"PLAY_AUDIO_TTS",PREVIEW_DEPLOYED_VERSION:"PREVIEW_DEPLOYED_VERSION",REASON:"REASON",RECORD:"RECORD",RECORDING_NAME:"RECORDING_NAME",RECORDING_NAME_DEFAULT:"RECORDING_NAME_DEFAULT",RECORD_CALL_START:"RECORD_CALL_START",RECORD_CALL_STOP:"RECORD_CALL_STOP",REMOVE_ADDRESS:"REMOVE_ADDRESS",REMOVE_CONDITION:"REMOVE_CONDITION",REMOVE_EDGE:"REMOVE_EDGE",REMOVE_NODE:"REMOVE_NODE",REMOVE_OPTION:"REMOVE_OPTION",REMOVE_PHONE_NUMBER:"REMOVE_PHONE_NUMBER",REMOVE_RESOURCE:"REMOVE_RESOURCE",REMOVE_VARIABLE:"REMOVE_VARIABLE",REQUEST:"REQUEST",REQUEST_BODY:"REQUEST_BODY",REQUEST_HEADERS:"REQUEST_HEADERS",RESOURCE_NUMBER:"RESOURCE_NUMBER",RESTORE:"RESTORE",RESTORE_THIS_VERSION:"RESTORE_THIS_VERSION",RESYNC:"RESYNC",RESYNC_AI_AGENTS:"RESYNC_AI_AGENTS",SAVED:"SAVED",SAVE_VARIABLES:"SAVE_VARIABLES",SAVE_VARIABLES_SUBTITLE:"SAVE_VARIABLES_SUBTITLE",SCRIPT_NOT_FOUND:"SCRIPT_NOT_FOUND",SEARCH_FOR_INTERNAL_SCRIPT:"SEARCH_FOR_INTERNAL_SCRIPT",SECONDS:"SECONDS",SELECT:"SELECT",SELECT_VARIABLES:"SELECT_VARIABLES",SELECT_VARIABLES_TO_UNSET:"SELECT_VARIABLES_TO_UNSET",SEND_SMS:"SEND_SMS",SEPARATE_WITH_COMMAS:"SEPARATE_WITH_COMMAS",SEQUENTIALLY:"SEQUENTIALLY",SET_VARIABLES:"SET_VARIABLES",SIMULTANEOUSLY:"SIMULTANEOUSLY",SMS_TEXT:"SMS_TEXT",SPOKEN_PROMPT:"SPOKEN_PROMPT",STATUS_DEPLOY:"STATUS_DEPLOY",STATUS_DEPLOYED:"STATUS_DEPLOYED",STATUS_DEPLOYING:"STATUS_DEPLOYING",STATUS_DEPLOY_ERROR:"STATUS_DEPLOY_ERROR",STATUS_ERROR:"STATUS_ERROR",STATUS_LOADING:"STATUS_LOADING",STATUS_LOCKED:"STATUS_LOCKED",STATUS_SAVED:"STATUS_SAVED",STATUS_SAVING:"STATUS_SAVING",STEREO:"STEREO",STEREO_SUBTITLE:"STEREO_SUBTITLE",STRING_OR_JSON:"STRING_OR_JSON",SUCCESS:"SUCCESS",SWML_TO_EXECUTE:"SWML_TO_EXECUTE",TERMINATORS:"TERMINATORS",TEXT:"TEXT",TEXT_TO_SPEECH:"TEXT_TO_SPEECH",TIMEOUT:"TIMEOUT",TO:"TO",TOAST_DEPLOY_WARNING:"TOAST_DEPLOY_WARNING",TOAST_DOCUMENT_OUT_OF_SYNC:"TOAST_DOCUMENT_OUT_OF_SYNC",TOGGLE_CLOSE:"TOGGLE_CLOSE",TOGGLE_OPEN:"TOGGLE_OPEN",TO_PHONE_NUMBER:"TO_PHONE_NUMBER",UNKNOWN:"UNKNOWN",UNSET_VARIABLES:"UNSET_VARIABLES",URL:"URL",VALUE:"VALUE",VARIABLE_NUMBER:"VARIABLE_NUMBER",VERSION_HISTORY:"VERSION_HISTORY",VERSION_LIST_ITEM:"VERSION_LIST_ITEM",VERSION_RESTORED:"VERSION_RESTORED",VOICE:"VOICE",VOICEMAIL_RECORDING:"VOICEMAIL_RECORDING",WAIT_FOR_DIGIT:"WAIT_FOR_DIGIT",WAIT_FOR_INPUT:"WAIT_FOR_INPUT",WARNING:"WARNING",WRITE_SOMETHING:"WRITE_SOMETHING"},oC={order:["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag","path","subdomain"],lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupQuerystring:"lng",lookupSessionStorage:"i18nextLng",caches:["localStorage","cookie"],excludeCacheFor:["cimode"]},sC={"en-US":{translation:rC}},iC=async()=>{await ut.use(tg).use(dT).init({debug:WR,detection:oC,fallbackLng:"en-US",interpolation:{escapeValue:!1},keySeparator:!1,resources:sC})};function Ul(e,t){return h.jsx(BT,{label:e,vars:t})}const Bg=()=>ut.resolvedLanguage,lC={entries:[],nextLabelIndex:0},zo=Do((e,t)=>({...lC,actions:{getEntries(){return t().entries},getEntryValue(r){return t().entries.find(s=>s.controlId===r)?.label},getGeneratedLabel(){let r="",s=t().nextLabelIndex;do s++,r=M(C.RECORDING_NAME_DEFAULT,{index:s});while(this.isValueDuplicate(r));return e({nextLabelIndex:s}),r},isKeyDuplicate(r){return t().entries.some(s=>s.controlId===r)},isValueDuplicate(r,s){const i=r.trim();return!!t().entries.reduce((c,u)=>{const{label:f,controlId:p}=u;return f!==""&&f===i&&(!s||p!==s)?[...c,u]:c},[]).length},removeEntry(r){e(s=>({entries:s.entries.filter(i=>i.controlId!==r)}))},upsertEntry:r=>{const{actions:s}=t(),{isKeyDuplicate:i}=s;e(a=>{let c=[...a.entries];const u=r.label.trim(),f=!!u;return(i(r.controlId)||!f)&&(c=c.filter(p=>p.controlId!==r.controlId)),f&&c.push({...r,label:u}),{entries:c}})}}})),Hu=()=>zo.getState().actions,zg=e=>{const t=[];e.forEach(r=>{r.type==="recordCallStart"&&r.data.controlId&&r.data.label&&t.push({controlId:r.data.controlId,label:r.data.label})}),zo.setState({entries:t,nextLabelIndex:t.length})},aC=(e,t)=>{const r=[];return t.forEach(s=>{s.type==="recordCallStart"&&s.data.controlId&&(r.push(s.data.controlId),zo.getState().actions.removeEntry(s.data.controlId))}),r.length?e.reduce((s,i)=>i.type==="recordCallStop"&&r.includes(i.data.controlId)?[...s,{...i,data:{...i.data,controlId:""}}]:s,[]):[]},Wg={recordCallStart:e=>{const t=zo.getState().actions.getGeneratedLabel();return zo.getState().actions.upsertEntry({controlId:e.data.controlId,label:t}),{...e,data:{...e.data,label:t}}}},cC=e=>typeof e=="object"&&e!==null&&Object.keys(e).length>0,uC=e=>Wg[e.type]!==void 0,Gg=(e,t={})=>{const{deletable:r=!0,position:s={x:300,y:250},selected:i=!0}=t,a=()=>({data:{initial:!0,valid:!1},deletable:r,id:Le(),position:s,selected:i,type:e}),c=(p,m)=>({...p,data:{...p.data,...m}});let u=a();const f=Fm[e]();return cC(f)&&(u=c(u,f)),uC(u)&&(u=Wg[u.type](u)),u},Fl={action:{label:C.ACTION,nodes:{answer:{active:!0,label:C.ANSWER_CALL},hangup:{active:!0,infoLabel:C.INFO_NODE_HANG_UP,label:C.HANG_UP_CALL},play:{active:!0,infoLabel:C.INFO_NODE_PLAY,label:C.PLAY_AUDIO_TTS},sendSms:{active:!0,infoLabel:C.INFO_NODE_SEND_SMS,label:C.SEND_SMS}}},decision:{label:C.DECISION,nodes:{cond:{active:!0,infoLabel:C.INFO_NODE_COND,label:C.CONDITIONS},executeSWML:{active:!0,infoLabel:C.INFO_NODE_EXECUTE_SWML,label:C.EXECUTE_SWML},set:{active:!0,infoLabel:C.INFO_NODE_SET_VARIABLES,label:C.SET_VARIABLES},unset:{active:!0,infoLabel:C.INFO_NODE_UNSET_VARIABLES,label:C.UNSET_VARIABLES}}},forwardTo:{label:C.FORWARD,nodes:{forwardAddress:{active:!1,infoLabel:C.INFO_NODE_FORWARD_TO_ADDRESS,label:C.FORWARD_TO_ADDRESS},forwardPhone:{active:!0,infoLabel:C.INFO_NODE_FORWARD_TO_PHONE,label:C.FORWARD_TO_PHONE},forwardResource:{active:!1,infoLabel:C.INFO_NODE_FORWARD_TO_RESOURCE,label:C.FORWARD_TO_RESOURCE}}},hidden:{label:C.HIDDEN,nodes:{handleCall:{active:!0,label:C.HANDLE_CALL}}},input:{label:C.INPUT,nodes:{aiAgent:{active:!0,infoLabel:C.INFO_NODE_AI_AGENT,label:C.AI_AGENT},condRequest:{active:!0,infoLabel:C.INFO_NODE_CONDREQUEST,label:C.REQUEST},promptPlay:{active:!0,infoLabel:C.INFO_NODE_GATHER_INPUT,label:C.GATHER_INPUT},request:{active:!1,deprecated:!0,infoLabel:C.INFO_NODE_REQUEST,label:C.REQUEST}}},recording:{label:C.RECORD,nodes:{record:{active:!0,infoLabel:C.INFO_NODE_RECORD,label:C.VOICEMAIL_RECORDING},recordCallStart:{active:!0,infoLabel:C.INFO_NODE_RECORD_CALL_START,label:C.RECORD_CALL_START},recordCallStop:{active:!0,infoLabel:C.INFO_NODE_RECORD_CALL_STOP,label:C.RECORD_CALL_STOP}}}},dC=Object.entries(Fl).reduce((e,[,{nodes:t}])=>(Object.entries(t).forEach(([r,{label:s}])=>{e.set(r,s)}),e),new Map),fC=Object.entries(Fl).reduce((e,[,{nodes:t}])=>(Object.entries(t).forEach(([r,{infoLabel:s}])=>{e.set(r,s)}),e),new Map),jl=Qe(),pC={aiAgentMap:new Map,error:"",status:"initial"},hC=(e,t)=>({...pC,actions:{fetchAiAgents:async()=>{try{const{actions:r}=t(),{getAiAgents:s}=r;if(!s){jl.error("getAiAgents is not defined");return}e({status:"loading"});const i=await s(),a=km(i.data,"asc","display_name"),c=new Map(a.map(u=>[u.id,u]));e({aiAgentMap:c,error:"",status:"loaded"})}catch(r){let s="Unknown error";jl.error("Error fetching aiAgents ",r),r instanceof Error&&(s=r.message),e({aiAgentMap:new Map,error:s,status:"error"})}},init:({getAiAgentsURL:r})=>{if(!r){jl.error("getAiAgentsURL is not defined");return}const s=gc({getAiAgentsURL:r,headers:Eu()}),i=async()=>await s.getAiAgents();e(a=>({...a,actions:{...a.actions,getAiAgents:i}}))}}}),Yg=(e,t)=>{if(e.find(s=>s.type==="aiAgent")){const{fetchAiAgents:s}=On.getState().actions;s().then(()=>{const{aiAgentMap:i,status:a}=On.getState();a==="loaded"&&e.forEach(c=>{if(c.data&&"agent"in c.data){const u=i.has(c.data.agent);u||t(c.id,{agent:u?c.data.agent:"",valid:u})}})}).catch(i=>jl.error("Error rehydrating AiAgentStore",i))}},On=Do()(hC),mC=()=>On.getState().actions;window.__useAiAgentStore=On;const gC=e=>!!(e&&e>=KR),EC=e=>(t,r,s)=>(s.setState=(i,a,...c)=>{const{edges:u,detachedMode:f,httpError:p,initializing:m,isCanvasInteractive:E,isInteractiveControlOn:v,nodes:x,rootAppWidth:_,viewportChanging:w}=r(),S=typeof i=="function"?i(r()):i,N=["detachedMode","httpError","initializing","isInteractiveControlOn","rootAppWidth","viewportChanging"],O="initializing"in S?S.initializing:m;if(N.some(D=>D in S)){const D=gC("rootAppWidth"in S?S.rootAppWidth:_),T="isInteractiveControlOn"in S?S.isInteractiveControlOn:v,A="detachedMode"in S?S.detachedMode:f,L=("httpError"in S?S.httpError:p)===Am,F="viewportChanging"in S?S.viewportChanging:w;if(S.isCanvasInteractive=!!(D&&T&&!A&&!O&&!L&&!F),S.showInteractiveControl=D&&!L&&!A,E&&!S.isCanvasInteractive){const K="nodes"in S?S.nodes:x;S.nodes=K.map(X=>({...X,selected:!1}));const Q="edges"in S?S.edges:u;S.edges=Q.map(X=>({...X,selected:!1})),S.selectedNode=void 0}}t(S,a,...c)},e(s.setState,r,s)),Kg=1e3,Zs=Qe(),yC=e=>(t,r,s)=>{let i,a;const c=async()=>{const{httpService:u,nodes:f,edges:p,documentVersion:m}=r();t({dataHandlingStatus:"saving",saveFlowStatus:"saving"}),clearTimeout(a);try{if(!u)throw new Error("Missing httpService");const E=await u.putFlow({documentVersion:m,edges:p,flowDataVersion:$s,nodes:f}),v={documentLastUpdated:E.updated_at,documentVersion:E.document_version},x=r().dataHandlingStatus;switch(x){case"saving":t({...v,dataHandlingStatus:"queueing",deployFlowStatus:"deploy",saveFlowStatus:"saved"});break;case"holding":t({...v,saveFlowStatus:"awaiting-save"}),Zs.debug("Setting up a new save for held changes"),a=setTimeout(()=>{c().catch(_=>{Zs.error("Error Save Flow",_)})},Kg);break;default:Zs.debug("Invalid dataHandlingStatus",x)}}catch(E){Zs.error("Put Flow",E),E instanceof Error&&E.message.includes(XR)?t({dataHandlingStatus:"holding",httpError:"document-sync",saveFlowStatus:"error"}):t({dataHandlingStatus:"queueing",saveFlowStatus:"error"})}};return s.setState=(u,f,...p)=>{const{dataHandlingStatus:m,detachedMode:E,initializing:v,saveFlowStatus:x}=r(),_=typeof u=="function"?u(r()):u,w="initializing"in _?_.initializing:v,S="detachedMode"in _?_.detachedMode:E;!w&&!S&&(_.nodes||_.edges)?m==="queueing"?(_.saveFlowStatus="awaiting-save",t(_,f,...p),clearTimeout(i),i=setTimeout(()=>{c().catch(O=>{Zs.error("Error Save Flow",O)})},Kg)):(_.dataHandlingStatus="holding",t(_,f,...p)):"initializing"in _&&!_.initializing?(_.dataHandlingStatus="queueing",x!=="error"&&(_.saveFlowStatus="saved"),t(_,f,...p)):t(_,f,...p)},e(s.setState,r,s)},Vl=Qe(),vC={cachedResults:new Map,error:"",results:[],status:"initial",swmlScriptMap:new Map},xC={ids:"ids",name:"name"},SC=(e,t)=>({...vC,actions:{buildParamsFromQuery:r=>{const{searchParams:s}=new URL(r,window.location.href);return l1(xC).reduce((a,c)=>{const u=s.get(c);return u&&(c==="ids"?a[c]=u.split(","):a[c]=u),a},{})},buildQueryFromParams:r=>{const s=hc(window.location.origin,{...r}),{search:i}=new URL(s);return`/${i}`},fetchSwmlScript:async r=>{try{const{actions:s}=t(),{getSwmlScripts:i,updateMapAndCache:a}=s;if(!i){Vl.error("getSwmlScripts is not defined");return}e({status:"loading"});const c=await i(r),u=km(c.data,"asc","display_name"),f=new Map(u.map(p=>[p.id,{displayName:p.display_name,id:p.id,requestUrl:p.request_url}]));a(f,r),e({error:"",results:Array.from(f.values()),status:"loaded"})}catch(s){let i="Unknown error";Vl.error("Error fetching swmlScripts ",s),s instanceof Error&&(i=s.message),e({error:i,status:"error"})}},getCachedResults:r=>{const{cachedResults:s,swmlScriptMap:i}=t(),a=s.get(r);if(a)return a.reduce((c,u)=>{const f=i.get(u);return f&&c.push(f),c},[])},init:({getSwmlScriptsURL:r})=>{if(!r){Vl.error("getSwmlScriptsURL is not defined");return}const s=gc({getSwmlScriptsURL:r,headers:Eu()}),i=async a=>await s.getSwmlScripts(a);e(a=>({...a,actions:{...a.actions,getSwmlScripts:i}}))},setResults:r=>{e({results:r})},updateConnection:(r,s)=>{if(r.connectConfirmId!=="external"){const i=s.get(r.connectConfirmId),a={...r};if(i&&i.displayName!==r.connectConfirmDisplayName)return a.connectConfirmDisplayName=i.displayName,a;if(!i)return a.connectConfirmId="",a.connectConfirmUrl="",a}},updateMapAndCache:(r,s)=>{const{actions:i,cachedResults:a,swmlScriptMap:c}=t(),{buildQueryFromParams:u}=i,f=s?.ids,p=u(s),E=a.get(p)?.filter(w=>r.has(w))??[],v=f?.filter(w=>!r.has(w))??[],x=[...new Set([...v,...E])];x.length>0&&(Array.from(a.entries()).forEach(([S,N])=>{if(S===s){const O=N.filter(D=>!x.includes(D));a.set(S,O)}}),x.forEach(S=>{c.delete(S)})),r.forEach((w,S)=>{c.set(S,w)});const _=Array.from(r.keys());a.set(p,_),e({cachedResults:new Map(a),swmlScriptMap:new Map(c)})},validateCache:(()=>{let r;return()=>{r&&clearTimeout(r),r=setTimeout(async()=>{const{actions:i,swmlScriptMap:a}=t(),{fetchSwmlScript:c}=i,u=Array.from(a.keys());u.length>0&&c&&await c({ids:u})},Im)}})(),validateScriptsFromNodes:(r,s)=>{const{actions:i}=t(),{fetchSwmlScript:a}=i,c=new Set,u=r.filter(p=>Xg(p)&&"connections"in p.data&&p.data.connections.some(m=>m.connectConfirmEnabled));if(u.length===0)return;const f=(p,m)=>u.forEach(E=>{const v=E.data.connections.map(x=>p(x)??x);typeof m=="function"&&m(v,E)});f(p=>{p.connectConfirmId!==""&&p.connectConfirmId!=="external"&&p.connectConfirmEnabled&&c.add(p.connectConfirmId)}),c.size!==0&&a({ids:Array.from(c.values())}).then(()=>{const{actions:p,swmlScriptMap:m,status:E}=Bn.getState(),{updateConnection:v}=p;E==="loaded"&&f(x=>{const _=v(x,m);return _||x},(x,_)=>{s(_.id,{connections:x})})}).catch(p=>Vl.error("Error rehydrating SwmlScriptStore",p))}}}),Xg=e=>e.type==="forwardAddress"||e.type==="forwardPhone"||e.type==="forwardResource",_C=(e,t)=>{if(e.some(Xg)){const{validateScriptsFromNodes:s}=Bn.getState().actions;s(e,t)}},Bn=Do()(SC),Qg=()=>Bn.getState().actions;window.__useSwmlScriptStore=Bn;const qg=500,wC=100,qe=Qe(),NC=Gg("handleCall",{deletable:!1,position:{x:300,y:100}}),Bu={backButtonHref:void 0,colorMode:"light",dataHandlingStatus:"queueing",deployFlowStatus:"deploy",deployFlowURL:"",deployedVersionsList:[],detachedMode:!1,documentLastUpdated:void 0,documentVersion:0,dragNodeType:void 0,edges:[],flowId:"",flowTitle:"",flowWrapperElement:void 0,getFlowURL:"",httpError:void 0,httpService:void 0,initializing:!0,isCanvasInteractive:!1,isDraggingNode:!1,isEdgeConnecting:!1,isEdgeUpdateSuccessful:!1,isInteractiveControlOn:!0,nodes:[],reactFlowInstance:void 0,rootAppHeight:void 0,rootAppWidth:void 0,rootElement:void 0,rootElementId:"",saveFlowStatus:"initial",selectedNode:void 0,showDeployWarning:!1,showDeployedHistory:!1,showDeployedHistoryToast:!1,showInteractiveControl:!0,showValidationWarnings:!1,toastsMap:new Map,updateFlowURL:"",updatingSourceHandleId:void 0,validationWarnings:new Map,viewport:{x:0,y:0,zoom:1},viewportChanging:!1,workingFlowCopy:void 0},RC=(e,t)=>({...Bu,actions:{addNode:({nodeType:r,x:s=150,y:i=150})=>{qe.debug("Add Node",r);const{nodes:a,reactFlowInstance:c}=t();if(!c)throw new Error("ReactFlowInstance not found");const u=Gg(r,{position:c.project({x:s,y:i})}),f=a.map(p=>({...p,selected:!1}));f.push(u),e({nodes:f,selectedNode:u})},addToast:r=>{const{toastsMap:s}=t(),i=Le();s.set(i,{...r,id:i}),e({toastsMap:new Map(s)})},cancelDetachedMode:async()=>{const{actions:r,workingFlowCopy:s}=t(),{cleanUpDetachedMode:i}=r;if(s){const{edges:a,nodes:c,saveFlowStatus:u}=s;e({edges:[],initializing:!0,nodes:[]}),await Pm(qg),e({edges:a,nodes:c,saveFlowStatus:u})}else qe.error("There was no working flow to restore");i()},cleanUpDetachedMode:()=>{e({detachedMode:!1,showDeployedHistory:!1,showDeployedHistoryToast:!1,workingFlowCopy:void 0})},deleteToast:r=>{const{toastsMap:s}=t();s.delete(r)&&e({toastsMap:new Map(s)})},deleteValidationWarning:r=>{const{validationWarnings:s}=t();s.delete(r)&&e({validationWarnings:new Map(s)})},deployFlow:async()=>{qe.info("Deploying..."),e({deployFlowStatus:"deploying"});try{const{httpService:r,documentVersion:s}=t();if(!r)throw new Error("Missing httpService");const i=await r.deployFlow({documentVersion:s});qe.info("Deploy response",i),e({deployFlowStatus:"deployed"})}catch(r){throw qe.info("Deploy error",r),e({deployFlowStatus:"error"}),r}},exportStoreData:()=>{const{nodes:r,edges:s}=t();r1(r,s)},getDeployedVersionsList:async r=>{try{const{httpService:s}=t();if(!s)throw new Error("Missing httpService");const i=await s.getFlowVersions(r),a=Mm(Bg());return e({deployedVersionsList:i.map((c,u)=>({id:c.id,relativeTimeSince:a(c.created_at),version:(i.length-u).toFixed(1)}))}),i}catch(s){throw qe.error("Could not get deployed versions",s),e({deployedVersionsList:[]}),s}},getNodeType:r=>t().nodes.find(i=>i.id===r)?.type,getRootElement:()=>{const{rootElement:r,rootElementId:s}=t();if(!r)throw new Error(`Root element not found for ID ${s}`);return r.shadowRoot?r.shadowRoot.getRootNode():r},getTargetEdges:r=>t().edges.filter(s=>{const i=s.target===r,a=s.source!==s.target;return i&&a}),getValidationWarnings:()=>t().validationWarnings,migrateAndLoadDeployedFlow:async r=>{const{actions:s,workingFlowCopy:i}=t(),{partialUpdateNodeData:a,saveWorkingFlowCopy:c}=s,f=new ep({dbRecord:r}).migrateTo($s),{flow_data:p}=f;if(!p)qe.error("Cannot load flow: missing flowData",p);else{i||c();const m=p.nodes.map(Lm),E=p.edges.map(bm);e({detachedMode:!0,edges:[],initializing:!0,nodes:[]}),await Pm(qg),e({edges:E,nodes:m,showDeployedHistoryToast:!0}),zg(m),Yg(m,a)}},onConnect:r=>{qe.debug("onConnect"),e({edges:Nh(r,t().edges)})},onConnectEnd:()=>{qe.debug("onConnectEnd"),e({isEdgeConnecting:!1})},onConnectStart:()=>{qe.debug("onConnectStart"),e({isEdgeConnecting:!0})},onEdgeUpdate:(r,s)=>{qe.debug("onEdgeUpdate"),e({edges:Jw(r,s,t().edges),isEdgeUpdateSuccessful:!0})},onEdgeUpdateEnd:(r,s)=>{qe.debug("onEdgeUpdateEnd"),t().isEdgeUpdateSuccessful?e({isEdgeUpdateSuccessful:!0}):t().reactFlowInstance?.deleteElements({edges:[{id:s.id}]}),e({updatingSourceHandleId:void 0})},onEdgeUpdateStart:(r,s)=>{qe.debug("onEdgeUpdateStart"),e({isEdgeUpdateSuccessful:!1,updatingSourceHandleId:s.sourceHandle??void 0})},onEdgesChange:r=>{e({edges:IN(r,t().edges)})},onEdgesDelete:r=>{qe.debug("onEdgesDelete [noop]",r)},onInit:async r=>{const{actions:s,deployFlowURL:i,getFlowURL:a,updateFlowURL:c}=t(),{partialUpdateNodeData:u}=s;qe.log("onInit",{getFlowURL:a,updateFlowURL:c});try{const f=gc({deployFlowURL:i,getFlowURL:a,headers:Eu(),updateFlowURL:c}),[p,m]=await Promise.all([f.getFlow(),f.getFlowVersions({pageSize:1})]),v=new ep({dbRecord:p}).migrateTo($s),{document_version:x,flow_data:_,id:w,title:S,updated_at:N}=v;if(m.length&&m[0]){const{document_version:D}=m[0];D===x&&e({deployFlowStatus:"deployed"})}let O=_;O||(O={edges:Bu.edges,flowDataVersion:$s,nodes:Bu.nodes.concat([NC])}),e({documentLastUpdated:N,documentVersion:x,edges:O.edges.map(bm),flowId:w,flowTitle:S,httpService:f,nodes:O.nodes.map(Lm),reactFlowInstance:r}),zg(O.nodes),Yg(O.nodes,u),_C(O.nodes,u)}catch(f){qe.error("Could not load flow. URL:",a);let p="unknown";f instanceof Error&&f.message.includes(QR)&&(p="not-found"),e({httpError:p})}},onNodeDragStart:()=>{e({isDraggingNode:!0})},onNodeDragStop:()=>{e({isDraggingNode:!1})},onNodesChange:r=>{const s=r.filter(i=>i.type!=="dimensions");s.length>0&&e({nodes:Jh(s,t().nodes)})},onNodesDelete:r=>{qe.debug("onNodesDelete");const{actions:s}=t(),{partialUpdateNodeData:i}=s;aC(t().nodes,r).forEach(c=>{i(c.id,c.data)})},onSelectionChange:({nodes:r})=>{e({selectedNode:r.find(s=>s.selected)})},onViewportChange:(()=>{let r;function s(i){r&&clearTimeout(r),r=setTimeout(()=>{e({viewportChanging:!1})},wC),e({viewport:{...i},viewportChanging:!0})}return s})(),onViewportChangeEnd:()=>{},onViewportChangeStart:()=>{},partialUpdateNodeData:(r,s)=>{qe.debug("partialUpdateNodeData",r,s);const i=[],a=t().nodes.map(c=>{if(c.id===r){if("options"in s&&"options"in c.data){const u=c.data.options.map(p=>p.id),f=s.options.map(p=>p.id);i.push(...u.filter(p=>!f.includes(p)))}return{...c,data:{...c.data,...s}}}return c});if(i.length){const c=t().edges.filter(u=>u.sourceHandle&&i.includes(u.sourceHandle));qe.debug("Remove orphaned edges",{edgesToDelete:c,sourceHandleDeleted:i}),t().reactFlowInstance?.deleteElements({edges:c})}e({nodes:a})},partialUpdateValidationWarning:(r,s)=>{const{validationWarnings:i}=t(),a=u=>u.connected===!1||u.valid===!1,c=i.get(r);if(s.nodeType!=="handleCall"&&!c&&a(s)){const u=dC.get(s.nodeType),f={connected:s.connected,id:Le(),nodeId:s.nodeId,nodeTitle:u,nodeType:s.nodeType,valid:s.valid};i.set(r,f)}else if(c){const u={...c,...s};a(u)?i.set(r,u):i.delete(r)}e({validationWarnings:new Map(i)})},removeEdge:r=>{qe.debug("removeEdge",r);const s=t().reactFlowInstance;s&&s.deleteElements({edges:[{id:r}]})},removeNode:r=>{qe.debug("removeNode",r);const s=t().reactFlowInstance;s&&s.deleteElements({nodes:[{id:r}]})},restoreDeployedFlow:()=>{const{actions:r,edges:s,nodes:i}=t(),{cleanUpDetachedMode:a}=r;e({detachedMode:!1,edges:s,nodes:i}),a()},saveWorkingFlowCopy:()=>{const{edges:r,nodes:s,saveFlowStatus:i}=t();e({workingFlowCopy:{edges:r,nodes:s,saveFlowStatus:i}})},setColorMode:r=>{e({colorMode:r})},setDragNodeType:r=>{e({dragNodeType:r})},setFlowWrapperElement:r=>{e({flowWrapperElement:r||void 0})},setInitializing:r=>{e({initializing:r})},setSelectedNodes:r=>{const{nodes:s}=t(),i=s.map(a=>({...a,selected:r.includes(a.id)}));e({nodes:i})},setShowDeployWarning:r=>{e({showDeployWarning:r})},setShowDeployedHistory:r=>{e({showDeployedHistory:r})},setShowValidationWarnings:r=>{e({showValidationWarnings:r})},setViewportChanging:r=>{e({viewportChanging:r})}}}),ye=Do()(EC(yC(RC))),Ze=()=>ye.getState().actions;window.__useRFStore=ye;const TC={"not-found":{message:"Please ensure that the Call Flow exists and the URL is correct.",status:"404",title:"Call Flow not found"},unknown:{message:"An unknown error occurred. Please try again or go back.",status:"",title:"Unknown error"}},OC=({errorType:e})=>{const t=ye(a=>a.backButtonHref),{title:r,message:s,status:i}=TC[e];return h.jsx("section",{className:"flex min-h-full w-full items-center justify-center bg-background px-6",children:h.jsxs("div",{className:"text-center",children:[i&&h.jsx("p",{className:"text-2xl font-semibold text-foreground/50",children:i}),h.jsx("h1",{className:"mt-4 text-3xl font-bold tracking-tight text-foreground",children:r}),h.jsx("p",{className:"mt-6 leading-7 text-foreground",children:s}),t&&h.jsx("div",{className:"mt-8 flex items-center justify-center gap-x-6",children:h.jsx("a",{href:t,className:"rounded-md bg-foreground px-3.5 py-2.5 text-sm font-semibold text-background shadow-sm transition-colors hover:bg-foreground/80 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-foreground",children:M(C.GO_BACK)})})]})})},Zg=({height:e,strokeWidth:t,toX:r,toY:s,width:i})=>h.jsx("svg",{x:r-i*t/2,y:s-e*t/2,height:e*t,width:i*t,viewBox:`-${i/2} -${e/2} ${i} ${e}`,children:h.jsx("g",{children:h.jsx("polyline",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:t,points:"-5,-4 0,0 -5,4 -5,-4"})})}),CC=({fromHandle:e,fromNode:t,fromPosition:r,fromX:s,fromY:i,toPosition:a,toX:c,toY:u})=>{if(!t)return null;const[f]=Us({borderRadius:Cm,sourcePosition:r,sourceX:s,sourceY:i,targetPosition:a,targetX:c,targetY:u}),{height:p,strokeWidth:m,width:E}={...ko.markerEnd,...ko.style},v=e?.position===xe.Left,x=v?s:c,_=v?i:u;return h.jsxs("g",{className:"cfb-connection-line",children:[h.jsx("path",{fill:"none",strokeWidth:m,className:"animated",d:f}),h.jsx(Zg,{height:p,strokeWidth:m,toX:x,toY:_,width:E}),v&&h.jsx("circle",{cx:c-2,cy:u,fill:"none",r:4,strokeWidth:m})]})};function AC({isCircular:e=!1,targetNode:t,targetX:r,targetY:s}){const{width:i,height:a,position:c}=t,u=i??0,f=a??0,p=u/2;return e?{tx:c.x+p,ty:c.y+f}:{tx:r,ty:s}}const IC=e=>{const t={...e,interactionWidth:40},{id:r,source:s,target:i,sourcePosition:a,sourceX:c,sourceY:u,targetX:f,targetY:p}=t,{removeEdge:m}=Ze(),E=b.useRef(null),v=Me(b.useCallback(X=>X.nodeInternals.get(s),[s])),x=Me(b.useCallback(X=>X.nodeInternals.get(i),[i]));if(!v||!x)return null;const _=s===i,{tx:w,ty:S}=AC({isCircular:_,targetNode:x,targetX:f,targetY:p}),[N,O,D]=Us({borderRadius:Cm,sourcePosition:a,sourceX:c,sourceY:u,targetPosition:_?xe.Bottom:xe.Left,targetX:w,targetY:S}),T=(X,ee)=>{X.stopPropagation(),m(ee)},A=X=>{X.currentTarget?.classList.add("highlight"),E.current?.classList.add("animate-delay-opacity","flex"),E.current?.classList.remove("hidden")},L=X=>{X.currentTarget?.classList.remove("highlight"),E.current?.classList.remove("animate-delay-opacity","flex"),E.current?.classList.add("hidden")},{height:F,strokeWidth:K,width:Q}={...ko.markerEnd,...ko.style};return h.jsxs("g",{onMouseEnter:A,onMouseLeave:L,children:[h.jsx(wo,{path:N,...t}),h.jsx(Zg,{height:F,strokeWidth:K,toX:w,toY:S,width:Q}),h.jsx(wR,{children:h.jsxs("button",{className:"nodrag nopan pointer-events-auto absolute hidden h-[18px] w-[26px] cursor-pointer items-center justify-center rounded-full bg-foreground/90 opacity-0 hover:h-[22px] hover:w-[30px] hover:border-2 hover:border-focus",onClick:X=>T(X,r),ref:E,style:{transform:`translate(-50%, -50%) translate(${O}px,${D}px)`},children:[h.jsx(Ce,{tag:"trash-can",className:"py-0.5 px-1.5 text-background"}),h.jsx("span",{className:"sr-only",children:M(C.REMOVE_EDGE)})]})})]})},bC=/^[\w\d -']+$/,LC=/^\d+$/,DC=/^\d|\*|#$/,kC=/^[\d*#$]{0,12}$/,MC=/^.{1,20}$/,Wo={MAX:3600,MIN:0},PC=/^[a-z0-9_]{1,20}$/,He={MAX:99,MIN:1},Go=e=>t=>!!e.exec(t),zu=e=>{if(!jt(e))return!0;try{return!!new URL(e)}catch{return!1}},At=e=>jt(e)?Go(LC)(e):!0,UC=e=>jt(e)?Go(DC)(e):!0,FC=e=>jt(e)?Go(bC)(e):!0,jC=e=>jt(e)?Go(PC)(e):!0,Jg=e=>jt(e)?Go(kC)(e):!0,VC=e=>jt(e)?Go(MC)(e):!0,$l=e=>{if(!jt(e))return!0;try{return JSON.parse(e),!0}catch{return!1}},De=e=>!!jt(e),Js=(e,t)=>{if(typeof e=="string"&&!jt(e))return!0;const r=typeof e!="number"?parseInt(e,10):e;return!Number.isNaN(r)&&r>=t},ei=(e,t)=>{if(typeof e=="string"&&!jt(e))return!0;const r=typeof e!="number"?parseInt(e,10):e;return!Number.isNaN(r)&&r<=t},Er=(e,t)=>{const r=new Set,s=e.reduce((i,a)=>{const c=a[t];if(typeof c=="string"){const u=c.trim();u&&(r.has(u)&&i.add(u),r.add(u))}return i},new Set);return i=>s.has(i.trim())},Hl={aiAgent:{fieldValidators:{agent:[De]},validate:e=>Yo({nodeData:e,nodeType:"aiAgent"}),validateField:(e,t)=>Ie({name:e,nodeType:"aiAgent",value:t})},cond:{fieldValidators:{value:[De]},validate:e=>Gu("cond",e),validateField:(e,t)=>Ie({name:e,nodeType:"cond",value:t})},condRequest:{fieldValidators:{body:[],headers:[$l],method:[De],saveVariables:[],url:[De],value:[De]},validate:e=>{const t=e,r=[];return["body","headers","method","saveVariables","url"].forEach(i=>{Ie({name:i,nodeType:"condRequest",value:t[i]})||r.push(i)}),[...r,...Gu("condRequest",e)]},validateField:(e,t)=>Ie({name:e,nodeType:"condRequest",value:t})},executeSWML:{fieldValidators:{dest:[De],meta:[$l],params:[$l]},validate:e=>{const t=e,r=[];return["dest","params","meta"].forEach(i=>{Ie({name:i,nodeType:"executeSWML",value:t[i]})||r.push(i)}),[...r,...Gu("executeSWML",e)]},validateField:(e,t)=>Ie({name:e,nodeType:"executeSWML",value:t})},forwardAddress:{fieldValidators:{callOrder:[],callStateEvents:[],callStateUrl:[],connectConfirmDisplayName:[],connectConfirmEnabled:[],connectConfirmId:[De],connectConfirmUrl:[De,zu],connectFrom:[],connectTimeout:[At],connectTo:[De],defaultFrom:[],defaultTimeout:[At],sessionTimeout:[At]},validate:e=>Yu("forwardAddress",e),validateField:(e,t)=>Ie({name:e,nodeType:"forwardAddress",value:t})},forwardPhone:{fieldValidators:{callOrder:[],callStateEvents:[],callStateUrl:[],connectConfirmDisplayName:[],connectConfirmEnabled:[],connectConfirmId:[De],connectConfirmUrl:[De,zu],connectFrom:[],connectTimeout:[At],connectTo:[De],defaultFrom:[],defaultTimeout:[At],sessionTimeout:[At]},validate:e=>Yu("forwardPhone",e),validateField:(e,t)=>Ie({name:e,nodeType:"forwardPhone",value:t})},forwardResource:{fieldValidators:{callOrder:[],callStateEvents:[],callStateUrl:[],connectConfirmDisplayName:[],connectConfirmEnabled:[],connectConfirmId:[De],connectConfirmUrl:[De,zu],connectFrom:[],connectTimeout:[At],connectTo:[De],defaultFrom:[],defaultTimeout:[At],sessionTimeout:[At]},validate:e=>Yu("forwardResource",e),validateField:(e,t)=>Ie({name:e,nodeType:"forwardResource",value:t})},hangup:{fieldValidators:{reason:[]},validate:e=>Ku("hangup",e),validateField:(e,t)=>Ie({name:e,nodeType:"hangup",value:t})},play:{fieldValidators:{selected:[De],text:[De],url:[De]},validate:e=>Ku("play",e),validateField:(e,t)=>Ie({name:e,nodeType:"play",value:t})},promptPlay:{fieldValidators:{command:[FC],digit:[UC],digitTimeout:[At,{test:Js,testValue:He.MIN},{test:ei,testValue:He.MAX}],initialTimeout:[At,{test:Js,testValue:He.MIN},{test:ei,testValue:He.MAX}],selected:[De],text:[De],url:[De]},validate:e=>{const t="promptPlay",r=e,s=Er(r.options,"command"),i=Er(r.options,"digit"),a=Ku("promptPlay",r),c=pc(r.initialTimeout);c?.trim()&&!Ie({name:"initialTimeout",nodeType:t,value:c})&&a.push("initialTimeout");const u=pc(r.digitTimeout);return u?.trim()&&!Ie({name:"digitTimeout",nodeType:t,value:u})&&a.push("digitTimeout"),r.options.forEach(f=>{const p=Ie({name:"command",nodeType:t,value:f.command})&&!s(f.command),m=Ie({name:"digit",nodeType:t,value:f.digit})&&!i(f.digit);p&&m&&(f.command||f.digit)||a.push(`option_${f.id}`)}),a},validateField:(e,t)=>Ie({name:e,nodeType:"promptPlay",value:t})},record:{fieldValidators:{beep:[],endSilenceTimeout:[At,{test:Js,testValue:He.MIN},{test:ei,testValue:He.MAX}],format:[De],initialTimeout:[At,{test:Js,testValue:He.MIN},{test:ei,testValue:He.MAX}],maxLength:[At,{test:Js,testValue:Wo.MIN},{test:ei,testValue:Wo.MAX}],stereo:[],terminators:[Jg]},validate:e=>Yo({nodeData:e,nodeType:"record"}),validateField:(e,t)=>Ie({name:e,nodeType:"record",value:t})},recordCallStart:{fieldValidators:{beep:[],controlId:[],format:[De],label:[De,VC],stereo:[],terminators:[Jg]},validate:e=>Yo({nodeData:e,nodeType:"recordCallStart"}),validateField:(e,t)=>Ie({name:e,nodeType:"recordCallStart",value:t})},recordCallStop:{fieldValidators:{controlId:[De]},validate:e=>Yo({nodeData:e,nodeType:"recordCallStop"}),validateField:(e,t)=>Ie({name:e,nodeType:"recordCallStop",value:t})},request:{fieldValidators:{body:[],headers:[$l],method:[De],saveVariables:[],url:[De]},validate:e=>Yo({nodeData:e,nodeType:"request"}),validateField:(e,t)=>Ie({name:e,nodeType:"request",value:t})},sendSms:{fieldValidators:{body:[De],fromNumber:[De],toNumber:[De]},validate:e=>Yo({nodeData:e,nodeType:"sendSms"}),validateField:(e,t)=>Ie({name:e,nodeType:"sendSms",value:t})},set:{fieldValidators:{key:[De,jC],value:[]},validate:e=>{const t=e,r="set",s=[],i=Er(t.variables,"key");return t.variables.forEach(a=>{const c=Ie({name:"key",nodeType:r,value:a.key})&&!i(a.key),u=Ie({name:"value",nodeType:r,value:a.value});c&&u||s.push(`variable_${a.id}`)}),s},validateField:(e,t)=>Ie({name:e,nodeType:"set",value:t})},unset:{fieldValidators:{},validate:e=>e.variables.length>0?[]:["variables"],validateField:(e,t)=>Ie({name:e,nodeType:"unset",value:t})}},It=e=>{const t=Hl?.[e];return{validate:t?.validate,validateField:t?.validateField}},eE=(e,t)=>{const r=Hl[e]?.validate;return r===void 0?[]:r(t)},Wu=(e,t)=>!e||!t?!1:eE(e,t)?.length===0,$C=e=>Hl[e]?.fieldValidators,Ie=({name:e,nodeType:t,value:r})=>{let s=!0;return $C(t)?.[e]?.forEach(a=>{typeof a=="function"?s=s&&a(r):s=s&&a.test(r,a.testValue)}),s},Yo=({nodeData:e,nodeType:t})=>{const r=Hl[t]?.fieldValidators??{},s=[];return Object.keys(r).forEach(i=>{Ie({name:i,nodeType:t,value:e?.[i]??""})||s.push(i)}),s},Gu=(e,t)=>{const r=t,s=[];return r.options.forEach(i=>{Ie({name:"value",nodeType:e,value:i.value})||s.push(`condition_${i.id}`)}),s},Yu=(e,t)=>{const r=[];["callOrder","callStateEvents","callStateUrl","defaultFrom","defaultTimeout"].forEach(a=>{Ie({name:a,nodeType:e,value:t[a]})||r.push(a)});const i=["connectFrom","connectTo","connectTimeout","connectConfirmUrl","connectConfirmId"];return t.connections?.forEach(a=>{i.forEach(c=>{!a.connectConfirmEnabled&&(c==="connectConfirmUrl"||c==="connectConfirmId")||Ie({name:c,nodeType:e,value:a[c]})||r.push(`${c}_${a.id}`)})}),r},Ku=(e,t)=>{const r=[];return Ie({name:"selected",nodeType:e,value:t?.selected})||r.push("selected"),t.selected==="url"?Ie({name:"url",nodeType:e,value:t.url})||r.push("url"):t.selected==="text"&&(Ie({name:"text",nodeType:e,value:t.text})||r.push("text")),r},bt=({data:e,id:t})=>{const r=ye(u=>u.isCanvasInteractive),{getNodeType:s,partialUpdateNodeData:i}=Ze(),{isValueDuplicate:a}=Hu(),c=s(t);return b.useEffect(()=>{if(c&&r){let u=Wu(c,e);c==="recordCallStart"&&"label"in e&&(u=u&&!a(e.label,e.controlId)),u!==e.valid&&i(t,{valid:u})}},[e,t,r,a,i,c]),b.useEffect(()=>{if(c==="aiAgent"&&r){const u=On.subscribe(f=>{if(f.status==="loaded"&&"agent"in e){const p=f.aiAgentMap.has(e.agent),m=p&&Wu(c,e);m!==e.valid&&i(t,{agent:p?e.agent:"",valid:m})}});return()=>{u()}}},[e,t,r,i,c]),b.useEffect(()=>{if((f=>(c==="forwardAddress"||c==="forwardPhone"||c==="forwardResource")&&"connections"in f)(e)&&r){const f=Bn.subscribe(p=>{if(p.status==="loaded"){let m=!0;const E=e.connections.map(x=>{const _=p.actions.updateConnection(x,p.swmlScriptMap);return _?(m=!1,_):x}),v=m&&Wu(c,e);v!==e.valid&&i(t,{connections:E,valid:v})}});return()=>{f()}}},[e,t,r,i,c]),{getInvalidFields:()=>!c||e.valid?[]:eE(c,e),valid:()=>e.valid}},HC=({data:e,id:t,isConnectable:r,selected:s})=>{bt({data:e,id:t});const a=On(c=>c.aiAgentMap.get(e.agent))?.display_name;return h.jsxs(dt,{id:t,isConnectable:r,nodeTitle:M(C.AI_AGENT),selected:s,valid:e.valid,children:[a&&h.jsx(Xt,{children:h.jsx("p",{className:"truncate text-xs",children:a})}),h.jsx(an,{id:t,color:"positive",isConnectable:r})]})},BC=({data:e,id:t,isConnectable:r,selected:s})=>h.jsx(dt,{id:t,isConnectable:r,nodeTitle:M(C.ANSWER_CALL),selected:s,valid:e.valid,children:h.jsx(an,{id:t,isConnectable:r,color:"positive"})}),zC=({id:e,data:t,isConnectable:r,selected:s})=>(bt({data:t,id:e}),h.jsx(dt,{id:e,isConnectable:r,nodeTitle:M(C.CONDITIONS),selected:s,valid:t.valid,children:h.jsxs(jo,{children:[t.options.map((i,a)=>{const c=i.value.trim();return h.jsx(cn,{color:"positive",enabled:!!c,id:i.id,isConnectable:r,optionTitle:c?h.jsx("div",{className:"truncate",children:c}):M(C.CONDITION_NUMBER,{index:a+1})},i.id)}),h.jsx(cn,{color:"negative",id:t.fallback,isConnectable:r,optionTitle:M(C.ELSE)})]})})),WC=({data:e,id:t,isConnectable:r,selected:s})=>{bt({data:e,id:t});const i=e.url.trim();return h.jsxs(dt,{id:t,isConnectable:r,nodeTitle:M(C.REQUEST),selected:s,valid:e.valid,children:[i&&h.jsx(Xt,{children:h.jsx("div",{className:"break-all line-clamp-3",children:i})}),h.jsxs(jo,{children:[e?.options?.map((a,c)=>{const u=a.value.trim();return h.jsx(cn,{color:"positive",enabled:!!u,id:a.id,isConnectable:r,optionTitle:u?h.jsx("div",{className:"truncate",children:u}):M(C.CONDITION_NUMBER,{index:c+1})},a.id)}),h.jsx(cn,{color:"negative",id:e.fallback,isConnectable:r,optionTitle:M(C.ELSE)}),h.jsx(cn,{color:"negative",id:e.error,isConnectable:r,optionTitle:M(C.FAILURE)})]})]})},GC=({data:e,id:t,isConnectable:r,selected:s})=>{bt({data:e,id:t});const i=e.dest.trim();return h.jsxs(dt,{id:t,isConnectable:r,nodeTitle:M(C.EXECUTE_SWML),selected:s,valid:e.valid,children:[i&&h.jsx(Xt,{children:h.jsx("div",{className:"break-all line-clamp-3",children:i})}),h.jsxs(jo,{children:[e?.options?.map((a,c)=>{const u=a.value.trim();return h.jsx(cn,{color:"positive",enabled:!!u,id:a.id,isConnectable:r,optionTitle:u?h.jsx("div",{className:"truncate",children:u}):M(C.CONDITION_NUMBER,{index:c+1})},a.id)}),h.jsx(cn,{color:"negative",id:e.fallback,isConnectable:r,optionTitle:M(C.ELSE)})]})]})},Xu=3,YC={busy:C.BUSY,decline:C.DECLINE,error:C.ERROR,noAnswer:C.NO_ANSWER,success:C.SUCCESS},KC={address:C.FORWARD_TO_ADDRESS,phone:C.FORWARD_TO_PHONE,resource:C.FORWARD_TO_RESOURCE},Qu=({id:e,data:t,isConnectable:r,selected:s})=>{bt({data:t,id:e});const i=t.connections.filter(c=>c.connectTo),a=i.slice(0,Xu);return h.jsxs(dt,{id:e,isConnectable:r,nodeTitle:M(KC[t.destinationType]),selected:s,valid:t.valid,children:[i.length?h.jsxs(Xt,{children:[h.jsx("ul",{children:a.map(c=>h.jsx("li",{className:"pb-2",children:h.jsx("div",{className:"max-w-max truncate rounded bg-secondary/20 px-1 ",children:c.connectTo})},`node-${c.id}`))}),i.length>Xu&&h.jsx("div",{children:`+ ${M(C.MORE_WITH_COUNT,{count:i.length-Xu})}`})]}):null,h.jsx(jo,{children:t.options.map(c=>h.jsx(cn,{color:Dm(c.result),id:c.id,isConnectable:r,optionTitle:M(YC[c.result])},c.id))})]})},XC=({id:e,data:t,isConnectable:r,selected:s})=>{bt({data:t,id:e});const i=Er(t.options,"command"),a=Er(t.options,"digit");return h.jsxs(dt,{id:e,isConnectable:r,nodeTitle:M(C.GATHER_INPUT),selected:s,valid:t.valid,children:[h.jsx(ug,{data:t}),h.jsxs(jo,{children:[t.options.map((c,u)=>{const f=c.command.trim(),p=c.digit.trim(),m=!!(f||p)&&!i(c.command)&&!a(c.digit),E=h.jsxs("div",{className:"flex gap-1",children:[M(C.CALLER_PRESSES)," ",h.jsx("span",{className:"truncate rounded bg-secondary/20 px-1",children:p})]}),v=w=>h.jsxs("div",{className:"flex",children:[M(w?C.CALLER_SAYS:C.OR_CALLER_SAYS)," '",h.jsx("span",{className:"truncate",children:f}),"'"]});let x=M(C.OPTION_NUMBER,{index:u+1}),_="";switch(!0){case!!(f&&!p):x=v(!0);break;case!!(!f&&p):x=E;break;case!!(f&&p):x=E,_=v(!1);break}return h.jsx(cn,{color:"positive",enabled:m,id:c.id,isConnectable:r,optionTitle:x,optionSubtitle:_},c.id)}),t.results.map(c=>h.jsx(cn,{color:"negative",id:c.id,isConnectable:r,optionTitle:c.result==="no_input"?M(C.NO_INPUT):M(C.UNKNOWN)},c.id))]})]})},QC=({id:e,isConnectable:t,selected:r})=>h.jsx(dt,{id:e,isConnectable:t,isRoot:!0,nodeTitle:M(C.HANDLE_CALL),selected:r,deletable:!1,showValidation:!1,target:!1,children:h.jsx(an,{id:e,color:"positive",isConnectable:t})}),qu={busy:C.BUSY,decline:C.DECLINE,hangup:C.HANG_UP},qC=({data:e,id:t,isConnectable:r,selected:s})=>h.jsx(dt,{id:t,isConnectable:r,nodeTitle:M(C.HANG_UP_CALL),selected:s,valid:e.valid,children:e.reason&&h.jsx(Xt,{children:h.jsx("p",{children:M(qu[e.reason])})})}),ZC=({data:e,id:t,isConnectable:r,selected:s})=>(bt({data:e,id:t}),h.jsxs(dt,{id:t,isConnectable:r,nodeTitle:M(C.PLAY_AUDIO_TTS),selected:s,valid:e.valid,children:[h.jsx(ug,{data:e}),h.jsx(an,{id:t,isConnectable:r})]})),JC=({data:e,id:t,isConnectable:r,selected:s})=>{const{label:i,valid:a}=e;return bt({data:e,id:t}),h.jsxs(dt,{id:t,isConnectable:r,nodeTitle:M(C.RECORD_CALL_START),selected:s,valid:a,children:[i&&a&&h.jsx(Xt,{children:h.jsx("p",{className:"truncate text-xs leading-5",children:i})}),h.jsx(an,{id:t,isConnectable:r,color:"positive"})]})},eA=({data:e,id:t,isConnectable:r,selected:s})=>{bt({data:e,id:t});const a=zo(c=>c.entries)?.find(c=>c.controlId===e.controlId)?.label;return h.jsxs(dt,{id:t,isConnectable:r,nodeTitle:M(C.RECORD_CALL_STOP),selected:s,valid:e.valid,children:[a&&h.jsx(Xt,{children:h.jsx("p",{className:"truncate text-xs leading-5",children:a})}),h.jsx(an,{id:t,color:"positive",isConnectable:r})]})},tA=({data:e,id:t,isConnectable:r,selected:s})=>{bt({data:e,id:t});const i=new Set(e.terminators);return h.jsxs(dt,{id:t,isConnectable:r,nodeTitle:M(C.VOICEMAIL_RECORDING),selected:s,valid:e.valid,children:[e.terminators?h.jsxs(Xt,{children:[M(C.TERMINATORS),":"," ",h.jsx("ul",{className:"inline-flex flex-wrap justify-start gap-1",children:[...i].sort().map((a,c)=>h.jsx("li",{className:"rounded bg-secondary/20 px-1",children:a},`${c}-${a}`))})]}):null,h.jsx(an,{id:t,isConnectable:r,color:"positive"})]})},nA={failed:C.FAILED,success:C.SUCCESS},tE={aiAgent:HC,answer:BC,cond:zC,condRequest:WC,executeSWML:GC,forwardAddress:Qu,forwardPhone:Qu,forwardResource:Qu,handleCall:QC,hangup:qC,play:ZC,promptPlay:XC,record:tA,recordCallStart:JC,recordCallStop:eA,request:({data:e,id:t,isConnectable:r,selected:s})=>(bt({data:e,id:t}),h.jsxs(dt,{id:t,isConnectable:r,nodeTitle:M(C.REQUEST),selected:s,valid:e.valid,children:[h.jsx("p",{className:"p-4 pt-0 text-xs text-negative",children:M(C.DEPRECATED)}),h.jsx(jo,{children:e?.options?.map(i=>h.jsx(cn,{color:Dm(i.result),id:i.id,isConnectable:r,optionTitle:M(nA[i.result])},i.id))})]})),sendSms:({data:e,id:t,isConnectable:r,selected:s})=>(bt({data:e,id:t}),h.jsxs(dt,{id:t,isConnectable:r,nodeTitle:M(C.SEND_SMS),selected:s,valid:e.valid,children:[e.body&&h.jsx(Xt,{children:h.jsx("p",{className:"break-words line-clamp-3",children:e.body})}),h.jsx(an,{id:t,isConnectable:r})]})),set:({id:e,data:t,isConnectable:r,selected:s})=>{const{getInvalidFields:i}=bt({data:t,id:e}),a=i().reduce((u,f)=>(f.startsWith("variable_")&&u.push(f.replace("variable_","")),u),[]),c=t.variables.filter(u=>!!u.key);return h.jsxs(dt,{id:e,isConnectable:r,nodeTitle:M(C.SET_VARIABLES),selected:s,valid:t.valid,children:[c.length>0&&h.jsx(Xt,{children:h.jsx("ul",{className:"flex flex-col",children:c.map(u=>h.jsxs("li",{className:"flex w-full gap-1 pb-2",children:[h.jsx("div",{className:`max-w-[50%] shrink-0 truncate rounded px-1 ${a.includes(u.id)?"bg-negative/10 text-negative":"bg-secondary/20"}`,children:u.key}),"=",u.value&&h.jsx("div",{className:"truncate",children:u.value})]},u.id))})}),h.jsx(an,{id:e,isConnectable:r,color:"positive"})]})},unset:({id:e,data:t,isConnectable:r,selected:s})=>{bt({data:t,id:e});const i=t.variables.filter(a=>!!a.key);return h.jsxs(dt,{id:e,isConnectable:r,nodeTitle:M(C.UNSET_VARIABLES),selected:s,valid:t.valid,children:[i.length>0&&h.jsx(Xt,{children:h.jsx("ul",{children:i.map(a=>h.jsx("li",{className:"pb-2",children:h.jsx("div",{className:"max-w-max truncate rounded bg-secondary/20 px-1",children:a.key})},a.id))})}),h.jsx(an,{id:e,isConnectable:r,color:"positive"})]})}},rA={floating:IC},oA=({children:e})=>{const t=ye(D=>D.nodes),r=ye(D=>D.edges),s=ye(D=>D.isCanvasInteractive),{onConnect:i,onConnectEnd:a,onConnectStart:c,onEdgesChange:u,onEdgesDelete:f,onEdgeUpdate:p,onEdgeUpdateEnd:m,onEdgeUpdateStart:E,onInit:v,onNodeDragStart:x,onNodeDragStop:_,onNodesChange:w,onNodesDelete:S,onSelectionChange:N,setFlowWrapperElement:O}=Ze();return h.jsx("div",{className:"bg-sw-white !h-auto w-full",ref:D=>O(D),children:h.jsxs(Sm,{attributionPosition:"bottom-left",connectionLineComponent:CC,connectionMode:ar.Strict,deleteKeyCode:s?e1:null,defaultEdgeOptions:ko,edges:r,edgeTypes:rA,elementsSelectable:s,fitViewOptions:gu,multiSelectionKeyCode:s?t1:null,nodes:t,nodesConnectable:s,nodesDraggable:s,nodeTypes:tE,onConnect:i,onConnectEnd:a,onConnectStart:c,onEdgesChange:u,onEdgesDelete:f,onEdgeUpdate:s?p:void 0,onEdgeUpdateEnd:m,onEdgeUpdateStart:E,onInit:v,onNodeDragStart:x,onNodeDragStop:_,onNodesChange:w,onNodesDelete:S,onSelectionChange:N,selectionKeyCode:s?n1:null,snapGrid:[yl,yl],snapToGrid:!0,children:[h.jsx($R,{className:"bg-background-alt text-grid",color:"currentColor",gap:[yl,yl],variant:Kt.Dots}),e]})})},sA=()=>{const e=ye(u=>u.initializing),t=ye(u=>u.reactFlowInstance),{setInitializing:r,setViewportChanging:s}=Ze(),i=b.useRef(!1),a=CR({includeHiddenNodes:!0}),c=b.useMemo(()=>()=>{t?.fitView(gu)},[t]);b.useEffect(()=>{let u;e?!i.current&&!a?i.current=!0:i.current&&a&&(clearTimeout(u),s(!0),c(),u=setTimeout(()=>{s(!1)},gu.duration),r(!1),i.current=!1):i.current=!1},[e,c,a,r,s])},iA=()=>{const{onViewportChange:e,onViewportChangeEnd:t,onViewportChangeStart:r}=Ze();return sA(),RR({onChange:e,onEnd:t,onStart:r}),null},lA=()=>{const e=ye(r=>r.selectedNode),t=e?fC.get(e.type):void 0;return t?h.jsx(Ds,{className:"z-40 max-w-[40%] rounded-md bg-background",position:"bottom-center",children:h.jsxs("div",{className:"justify-left flex items-center gap-2 rounded-md bg-primary/10 p-3 py-4","data-testid":"cfb__info",children:[h.jsx(Ce,{className:"shrink-0 text-primary",tag:"circle-info",size:"xl"}),h.jsx("div",{className:"text-xs font-medium",children:Ul(t)})]})}):null},aA=e=>{const t=b.useRef(),r=NR(),s=e&&"options"in e.data?e.data.options?.length:0;return t.current=s,{updateDynamicHandles:a=>{"options"in a&&a.options.length!==t.current&&(e&&r(e.id),t.current=a.options.length)}}},cA="/hello/.test('%{foo}')",uA=()=>({id:Le(),value:""}),Zu=({nodeData:e,handleOnUpdate:t,placeholder:r=cA})=>{const{validateField:s}=It("cond"),[i,a]=b.useState({options:e.options.map(E=>({id:!0,initial:e.initial,value:s("value",E.value)}))}),c=E=>{E.preventDefault(),a({...i,options:[...i.options,{initial:!0,value:!0}]}),t({options:[...e.options,uA()]})},u=E=>v=>{v.preventDefault();const x=[...i.options];x.splice(E,1),a({...i,options:x});const _=[...e.options];_.splice(E,1),t({options:_})},f=(E,v)=>{const x=[...e.options];if(!x[E])throw new Error(`Option not found at index ${E}`);const{name:_,value:w}=v,S=[...i.options];S[E]={...S[E],initial:!1,[_]:s(_,w)},a({...i,options:S}),x[E]={...x[E],[_]:w},t({options:x})},p=(E,v)=>{const x=E.target,{name:_,value:w}=x;switch(t({initial:!1}),_){case"value":v!==void 0&&f(v,{name:_,value:w});break;default:Qe().error(`Unhandled input name: ${_}`)}},m=({index:E,name:v})=>{const x=i.options[E];return x?.[v]||x?.initial};return h.jsxs(h.Fragment,{children:[h.jsx("ol",{className:"divide-y-4 divide-foreground/10 border-b-4 border-foreground/10",children:e.options.map((E,v,x)=>h.jsxs("li",{className:"flex pt-3",children:[h.jsx("div",{className:"w-8 shrink-0 text-center",children:h.jsx(Ce,{className:"text-foreground/60",size:"xs",tag:"bars"})}),h.jsxs("div",{className:"relative mr-3",children:[x.length>1&&h.jsx(Fo,{className:"absolute right-0 top-0",handleDelete:u(v),label:M(C.REMOVE_CONDITION,{index:v+1}),size:"sm",show:!0}),h.jsxs("label",{className:"mb-2 block",children:[M(C.CONDITION_NUMBER,{index:v+1}),h.jsx("input",{className:`w-full ${m({index:v,name:"value"})?"":"invalid"}`,name:"value",onChange:_=>p(_,v),placeholder:r,type:"text",value:E.value}),h.jsx("p",{className:"requirements",role:"alert",children:M(C.ERROR_VALUE_IS_REQUIRED)})]})]})]},E.id))}),h.jsx("div",{className:"p-3 text-right",children:h.jsx("button",{className:"rounded bg-foreground/10 py-1 px-2 font-medium",onClick:c,type:"button",children:M(C.ADD_CONDITION)})})]})},dA=Qe(),ti=(e,t)=>[e,t].filter(Boolean).join("-").toLowerCase(),fA={idsByKey:{},languageById:{},voiceById:{}},pA=(e,t)=>({...fA,actions:{getGenderByKeys:({languageId:r})=>{const{idsByKey:s}=t(),i=r?.split(",").map(c=>ti(c))??[];if(!i.length)return["female","male"];const a=new Set;return i.forEach(c=>s[c]?.forEach(u=>{u.gender&&a.add(u.gender)})),Array.from(a).sort((c,u)=>c.toLowerCase().localeCompare(u.toLowerCase()))},getLanguages:()=>Object.values(t().languageById).sort((r,s)=>r.name.toLowerCase().localeCompare(s.name.toLowerCase())),getVoicesByKeys:({languageId:r,gender:s})=>{const{voiceById:i,idsByKey:a}=t(),c=r?.split(",").map(f=>ti(f,s))??[];let u=[];return!c.length||c[0]===""?u=Object.values(i):c.forEach(f=>{u=u.concat(a[f]??[])}),u.sort((f,p)=>{const m=/^\w{2,3}-\w{2,}-.+/;return f.name.match(m)&&!p.name.match(m)?1:!f.name.match(m)&&p.name.match(m)?-1:f.name.toLowerCase().localeCompare(p.name.toLowerCase())})},init:async({voicesURL:r="/cfb/voices.json"})=>{try{dA.debug("Load voicesURL",r);const i=await(await fetch(r)).json(),a={},c={},u={};i.forEach(f=>{const p=!!f.premium,m=f.signalwire_id,E=f.gender.toLowerCase(),v={gender:E,id:m,key:`${f.language_code}-${E}-${f.signalwire_id}`,name:`${f.friendly_name.trim()} ${p?"(premium)":""}`,premium:p};a[m]=v,c[f.language_code]={id:f.language_code,name:f.language};const x=ti(f.language_code);x in u||(u[x]=[]),u[x]?.push(v);const _=ti(E);_ in u||(u[_]=[]),u[_]?.push(v);const w=ti(f.language_code,E);w in u||(u[w]=[]),u[w]?.push(v)}),e({idsByKey:u,languageById:c,voiceById:a})}catch(s){console.error("Error",s)}}}}),Ju=Do()(pA),hA=()=>Ju.getState().actions;window.__useVoiceStore=Ju;const nE=e=>h.jsx("option",{value:e.id,children:e.name},e.key??e.id),mA=({onChange:e,languageId:t,gender:r,voiceId:s})=>{const{getLanguages:i,getVoicesByKeys:a,getGenderByKeys:c}=hA();return h.jsxs(h.Fragment,{children:[h.jsxs(Tn,{className:"w-full",label:M(C.LANGUAGE),name:"language",onChange:e,value:t??"",children:[h.jsx("option",{value:"",children:M(C.SELECT)}),i().map(nE)]}),h.jsxs(Tn,{className:"w-full capitalize",label:M(C.GENDER),name:"gender",onChange:e,value:r??"",children:[h.jsx("option",{value:"",children:M(C.SELECT)}),c({languageId:t}).map(u=>h.jsx("option",{value:u,children:u},u))]}),h.jsxs(Tn,{className:"w-full",label:M(C.VOICE),name:"voice",onChange:e,value:s??"",children:[h.jsx("option",{value:"",children:M(C.SELECT)}),a({gender:r,languageId:t}).map(nE)]})]})},rE={text:C.TEXT_TO_SPEECH,url:C.PLAY_AUDIO_FILE},oE=({handleOnUpdate:e,label:t,nodeData:r,showDefaultOption:s})=>{const{validateField:i}=It("play"),[a,c]=b.useState({gender:!0,language:!0,selected:r.initial||i("selected",r.selected),text:r.initial||i("text",r.text),url:r.initial||i("url",r.url),voice:!0}),u=r.selected;b.useEffect(()=>{!u&&!s&&e({selected:"url"})},[e,u,s]);const f=m=>{const E=m.target,{name:v,value:x}=E;switch(v){case"selected":case"text":case"url":c({...a,[v]:i(v,x)}),e({initial:!1,[v]:x});break;default:throw new Error(`Unhandled input name: ${v}`)}},p=m=>{const E=m.target,{name:v,value:x}=E;switch(v){case"language":e({gender:void 0,language:x,voice:void 0});break;case"gender":e({gender:x,voice:void 0});break;default:e({[v]:x})}};return h.jsxs(h.Fragment,{children:[h.jsxs("label",{className:"mb-2",children:[h.jsx("span",{className:"sr-only",children:t}),h.jsxs(dg,{className:`w-full ${a.selected?"":"invalid"}`,name:"selected",onChange:f,value:u,children:[s&&h.jsx("option",{value:"",children:M(C.SELECT)}),Object.keys(rE).map(m=>h.jsx("option",{value:m,children:M(rE[m])},m))]})]}),u&&h.jsx(gA,{nodeData:r,onChange:f,voiceSettingsChangeHandler:p,selected:u,valid:a[u]})]})},gA=({nodeData:e,onChange:t,voiceSettingsChangeHandler:r,selected:s,valid:i})=>{const a=e[s],u={text:h.jsxs(h.Fragment,{children:[h.jsx(mA,{onChange:r,languageId:e.language,gender:e.gender,voiceId:e.voice}),h.jsx($n,{errorText:M(C.ERROR_VALUE_IS_REQUIRED),inputMode:"text",label:M(C.TEXT),name:s,onChange:t,placeholder:M(C.WRITE_SOMETHING),valid:i,value:a})]}),url:h.jsx($n,{errorText:M(C.ERROR_URL_IS_REQUIRED),inputMode:"url",label:M(C.AUDIO_FILE),name:s,onChange:t,placeholder:M(C.ENTER_URL),valid:i,value:a})}[s];return h.jsx(h.Fragment,{children:u})},EA=[{field:"stereo",subtitle:C.STEREO_SUBTITLE,title:C.STEREO},{field:"beep",subtitle:C.BEEP_SUBTITLE,title:C.BEEP}],sE=({handleOnUpdate:e,nodeData:t,type:r})=>{const{validateField:s}=It("record"),[i,a]=b.useState({beep:!0,endSilenceTimeout:t.initial||s("endSilenceTimeout",t.endSilenceTimeout),format:!0,initialTimeout:t.initial||s("initialTimeout",t.initialTimeout),maxLength:t.initial||s("maxLength",t.maxLength),stereo:!0,terminators:t.initial||s("terminators",t.terminators)});t.format||e({format:"mp3"});const c=f=>{const p=f.target.name;e({[p]:!t[p]})},u=f=>{const p=f.target,{name:m,value:E}=p;switch(m){case"endSilenceTimeout":case"format":case"initialTimeout":case"maxLength":case"terminators":a({...i,[m]:s(m,E)}),e({initial:!1,[m]:E});break;default:throw new Error(`Unhandled input name: ${m}`)}};return h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"mb-2",children:EA.map(f=>{const p=t[f.field];return h.jsx("div",{children:h.jsx(Ol,{checked:p,clickHandler:c,name:f.field,subtitle:M(f.subtitle),title:M(f.title)})},f.field)})}),h.jsxs("label",{className:"mb-2 block",children:[M(C.TERMINATORS),h.jsx("span",{className:"block text-xxs text-foreground/50",children:M(C.SEPARATE_WITH_COMMAS)}),h.jsx("input",{className:`w-full ${i.terminators?"":"invalid"}`,name:"terminators",onChange:u,placeholder:"#*0",type:"text",value:t.terminators}),h.jsx("p",{className:"requirements",role:"alert",children:M(C.ERROR_TERMINATORS)})]}),r==="voicemail"&&h.jsxs(h.Fragment,{children:[h.jsxs("label",{className:"mb-2 block",children:[h.jsx("div",{className:"w-full",children:M(C.MAXIMUM_RECORDING_LENGTH)}),h.jsxs("div",{className:"flex flex-wrap items-center gap-x-2",children:[h.jsx("input",{className:`w-14 ${i.maxLength?"":"invalid"}`,inputMode:"numeric",min:Wo.MIN,max:Wo.MAX,name:"maxLength",onChange:u,placeholder:M(C.SECONDS),type:"number",value:t.maxLength}),h.jsx("p",{className:"requirements w-full",role:"alert",children:M(C.ERROR_NUMBER_MIN_MAX_IS_REQUIRED,{max:Wo.MAX,min:Wo.MIN})})]})]}),h.jsxs("label",{className:"mb-2 block",children:[h.jsx("div",{className:"w-full",children:M(C.INITIAL_TIMEOUT)}),h.jsxs("div",{className:"flex flex-wrap items-center gap-x-2",children:[h.jsx("input",{className:`w-14 ${i.initialTimeout?"":"invalid"}`,inputMode:"numeric",min:He.MIN,max:He.MAX,name:"initialTimeout",onChange:u,placeholder:M(C.SECONDS),type:"number",value:t.initialTimeout}),h.jsx("p",{className:"requirements w-full",role:"alert",children:M(C.ERROR_NUMBER_MIN_MAX_IS_REQUIRED,{max:He.MAX,min:He.MIN})})]})]}),h.jsxs("label",{className:"mb-2 block",children:[h.jsx("div",{className:"w-full",children:M(C.END_SILENCE_TIMEOUT)}),h.jsxs("div",{className:"flex flex-wrap items-center gap-x-2",children:[h.jsx("input",{className:`w-14 ${i.endSilenceTimeout?"":"invalid"}`,inputMode:"numeric",min:He.MIN,max:He.MAX,name:"endSilenceTimeout",onChange:u,placeholder:M(C.SECONDS),type:"number",value:t.endSilenceTimeout}),h.jsx("p",{className:"requirements w-full",role:"alert",children:M(C.ERROR_NUMBER_MIN_MAX_IS_REQUIRED,{max:He.MAX,min:He.MIN})})]})]})]}),h.jsxs(Tn,{className:"w-full",label:M(C.FORMAT),name:"format",onChange:u,value:t.format,children:[h.jsx("option",{value:"mp3",children:"MP3"}),h.jsx("option",{value:"wav",children:"WAV"})]})]})},_t=({children:e,formRef:t,handleOnChange:r=()=>null,title:s})=>h.jsxs("div",{className:"flex flex-col overflow-hidden","data-testid":"cfb__settings",children:[h.jsxs("div",{className:"flex w-full items-center justify-start gap-x-2 px-4 pb-3",children:[h.jsx("div",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-focus/30 text-primary",children:h.jsx(Ce,{tag:"circle-small"})}),h.jsx("div",{className:"flex-1",children:h.jsx("h2",{className:"text-xs font-semibold",children:s})})]}),h.jsx("form",{className:"flex h-full flex-col overflow-hidden text-xs",noValidate:!0,onChange:r,ref:t,children:h.jsx("div",{className:"flex-1 overflow-y-auto pt-1 pb-4",children:e})})]}),yA=({nodeData:e,handleOnUpdate:t})=>{const{validateField:r}=It("aiAgent"),[s,i]=b.useState({agent:e.initial||r("agent",e.agent)}),a=On(w=>w.aiAgentMap.values()),c=On(w=>w.error),u=On(w=>w.status),{fetchAiAgents:f}=mC();b.useEffect(()=>{f()},[f]);const p=Array.from(a),m=u==="loading",E=!!c||u==="error",v=E||u==="initial",x=w=>{const S=w.target,{name:N,value:O}=S;i({...s,[N]:r(N,O)}),t({initial:!1,[N]:O})},_=b.useId();return h.jsx(_t,{title:M(C.AI_AGENT),children:h.jsx("div",{className:"mx-3",children:!E&&p.length?h.jsxs("div",{className:"relative",children:[h.jsxs(Tn,{id:_,className:`${s.agent?"":"invalid"}`,disabled:v,label:M(C.AI_AGENT_NAME),name:"agent",onChange:x,value:e.agent,children:[h.jsx("option",{value:"",children:M(C.SELECT)}),p.map(w=>h.jsx("option",{value:w.id,children:w.display_name},w.id))]}),h.jsx(iE,{className:"absolute top-0 right-0 mx-1",handleClickResync:f,isLoading:m}),e.agent&&h.jsx("p",{children:h.jsx(lE,{agent:e.agent,mode:"edit",className:"mb-2",children:M(C.EDIT_SELECTED_AI_AGENT)})})]}):h.jsxs("div",{className:"flex items-end justify-between",children:[h.jsx("p",{role:"alert",className:"text-negative",children:E?h.jsx(h.Fragment,{children:M(C.ERROR_FETCHING_AI_AGENTS)}):h.jsxs(h.Fragment,{children:[M(C.ERROR_ADD_AI_AGENT_FIRST),h.jsx(lE,{mode:"add",className:"mt-2 block",children:M(C.ADD_AI_AGENT)})]})}),h.jsx(iE,{className:"mx-1",handleClickResync:f,isLoading:m})]})})})},iE=({className:e="",isLoading:t,handleClickResync:r})=>h.jsx(gr,{placement:"bottom-end",trigger:h.jsxs("button",{className:`overflow-hidden ${t?"text-disabled":""} ${e}`,disabled:t,onClick:r,type:"button",children:[h.jsx(Ce,{className:`${t?"animate-spin":""}`,tag:"arrows-rotate"}),h.jsx("span",{className:"sr-only",children:M(C.RESYNC_AI_AGENTS)})]}),children:h.jsx("p",{className:"text-sm",children:M(C.RESYNC_AI_AGENTS)})}),lE=({agent:e="",children:t,className:r="",mode:s})=>{const i={add:"",edit:`${e}/edit`};return h.jsx("a",{className:`w-fit text-foreground underline hover:text-foreground/80 ${r}`,href:`/ai_agents/${i[s]}`,target:"_blank",rel:"noopener noreferrer",children:t})},vA=["GET","POST","PUT","DELETE"],xA=({nodeData:e,handleOnUpdate:t})=>{const{validateField:r}=It("condRequest"),[s,i]=b.useState({body:e.initial||r("body",e.body),headers:e.initial||r("headers",e.headers),method:e.initial||r("method",e.method),saveVariables:e.initial||r("saveVariables",e.saveVariables),url:e.initial||r("url",e.url)}),a=f=>{const p=f.target,{name:m,value:E}=p;switch(t({initial:!1}),m){case"url":case"method":i({...s,[m]:r(m,E)}),t({[m]:E});break;case"headers":i({...s,[m]:r(m,E)}),t({[m]:E});break;case"body":i({...s,[m]:r(m,E)}),t({[m]:E});break;default:throw new Error(`Unhandled input name: ${m}`)}},c=f=>{const{name:p,value:m}=f.target;t({[p]:m})},u=f=>{const{name:p}=f.target,m=!e[p];t({[p]:m})};return h.jsxs(_t,{title:M(C.REQUEST),children:[h.jsxs("div",{className:"border-b-4 border-foreground/10 px-3",children:[h.jsxs("label",{className:"mb-2 block",children:[M(C.URL),h.jsx("input",{className:`w-full ${s.url?"":"invalid"}`,name:"url",onChange:a,placeholder:"https://u:p@example.com/api/status",type:"text",value:e.url}),h.jsx("p",{className:"requirements w-full",role:"alert",children:M(C.ERROR_VALUE_IS_REQUIRED)})]}),h.jsx("div",{className:"mb-1",children:h.jsx(Tn,{className:"w-full",label:M(C.METHOD),name:"method",onChange:c,value:e.method,children:vA.map(f=>h.jsx("option",{value:f,children:f},f))})}),h.jsx("div",{className:"mb-4",children:h.jsx(Ol,{checked:e.saveVariables,clickHandler:u,name:"saveVariables",subtitle:M(C.SAVE_VARIABLES_SUBTITLE),title:M(C.SAVE_VARIABLES)})}),h.jsx("label",{className:"mb-2 block",children:h.jsx($n,{errorText:M(C.ERROR_INVALID_JSON),inputMode:"text",label:M(C.REQUEST_HEADERS),name:"headers",onChange:a,placeholder:'{"Content-Type": "application/json", "X-Custom-Header": "foo"}',valid:s.headers,value:e.headers})}),h.jsx("label",{className:"mb-2 block",children:h.jsx($n,{errorText:M(C.ERROR_INVALID_JSON),inputMode:"text",label:M(C.REQUEST_BODY),name:"body",onChange:a,placeholder:M(C.STRING_OR_JSON),valid:s.body,value:e.body??""})})]}),h.jsx(Zu,{nodeData:e,handleOnUpdate:t})]})},SA=({nodeData:e,handleOnUpdate:t})=>{const r=b.useRef();return h.jsx(_t,{formRef:r,title:M(C.CONDITIONS),children:h.jsx("div",{children:h.jsx(Zu,{nodeData:e,handleOnUpdate:t})})})},_A=({nodeData:e,handleOnUpdate:t})=>{const{validateField:r}=It("executeSWML"),[s,i]=b.useState({dest:e.initial||r("dest",e.dest),meta:e.initial||r("meta",e.meta),params:e.initial||r("params",e.params)}),a=c=>{const u=c.target,{name:f,value:p}=u;switch(t({initial:!1}),f){case"dest":case"params":case"meta":i({...s,[f]:r(f,p)}),t({[f]:p});break;default:throw new Error(`Unhandled input name: ${f}`)}};return h.jsxs(_t,{title:M(C.EXECUTE_SWML),children:[h.jsxs("div",{className:"border-b-4 border-foreground/10 px-3",children:[h.jsxs("label",{className:"mb-2 block",children:[M(C.URL),h.jsx("input",{className:`w-full ${s.dest?"":"invalid"}`,name:"dest",onChange:a,placeholder:"https://u:p@test.com/go.swml",type:"text",value:e.dest}),h.jsx("p",{className:"requirements w-full",role:"alert",children:M(C.ERROR_VALUE_IS_REQUIRED)})]}),h.jsx("label",{className:"mb-2 block",children:h.jsx($n,{errorText:M(C.ERROR_INVALID_JSON),inputMode:"text",label:M(C.PARAMS),name:"params",onChange:a,placeholder:'{"Content-Type": "application/json", "X-Custom-Header": "foo"}',valid:s.params,value:e.params??""})}),h.jsx("label",{className:"mb-2 block",children:h.jsx($n,{errorText:M(C.ERROR_INVALID_JSON),inputMode:"text",label:M(C.META),name:"meta",onChange:a,placeholder:M(C.JSON_OBJECT),valid:s.meta,value:e.meta??""})})]}),h.jsx(Zu,{nodeData:e,handleOnUpdate:t,placeholder:"return_value === '1'"})]})},aE=(e,t)=>{b.useEffect(()=>{const r=e.current?.getRootNode(),s=i=>{const a=i.target;a instanceof Node&&!e.current?.contains(a)&&t(i)};return r&&r.addEventListener("pointerdown",s),()=>{r&&r.removeEventListener("pointerdown",s)}},[e,t])},ed=e=>{const[t,r]=b.useReducer((s,i)=>({...s,...i}),e);return[t,r]},wA=Qe(),NA=({enable:e,searchParams:t})=>{const r=Bn(E=>E.results),s=Bn(E=>E.status),i=Bn(E=>E.error),{buildParamsFromQuery:a,buildQueryFromParams:c,getCachedResults:u,fetchSwmlScript:f,setResults:p}=Qg(),m=c(t);return b.useEffect(()=>{if(!e)return;const E=u(m);E&&p(E);const v=a(m),x=setTimeout(()=>{f(v).catch(_=>{wA.error("Error fetching swml scripts",_)})},Im);return()=>clearTimeout(x)},[a,c,e,f,u,m,p]),[r,s,i]},td=e=>e==="external",RA={externalValue:"",focusedId:"",focusedName:"",open:!1,query:""},TA=({confirmId:e,confirmName:t,confirmUrl:r,onChange:s,valid:i})=>{const a={displayName:M(C.EXTERNAL_URL),id:"external"},c=b.useRef(null),u=b.useRef(null),f=b.useRef(null),p=b.useRef({}),m=b.useId(),E=b.useId(),v=b.useId(),[x,_]=ed({...RA,externalValue:td(e)?r:"",query:t??""}),w=td(e),S=x.query===""||x.query.toLocaleLowerCase()===t.toLocaleLowerCase(),[N,O]=NA({enable:x.open&&!x.focusedName,searchParams:{name:S?"":x.query}}),D=[{displayName:M(C.EXTERNAL_URL),id:a.id},...N],T=S?D:N,A=()=>_({focusedId:"",focusedName:""}),L=Y=>{_({open:!0,query:Y.target.value}),A()},F=Y=>{_({externalValue:Y.target.value}),s({connectConfirmDisplayName:a.displayName,connectConfirmId:a.id,connectConfirmUrl:Y.target.value})},K=()=>{_({focusedId:e,open:!0}),ee()},Q=()=>{_({open:!1}),A()},X=()=>x.open?Q():K(),ee=()=>{u.current?.focus()},ne=Y=>{const re=Um(D,"id",Y);_({query:re.displayName});const oe=le=>"requestUrl"in le?le.requestUrl:x.externalValue;s({connectConfirmDisplayName:re.displayName,connectConfirmId:re.id,connectConfirmUrl:oe(re)}),Q()},W=Y=>{ee(),ne(Y)},I=Y=>{const re=x.focusedId||e||"",oe=i1(Y,re,T),le=oe&&p.current[oe?.id];if(le){le?.focus({preventScroll:!0}),le?.scrollIntoView({block:"nearest"});const de=Um(D,"id",le.id);_({focusedId:de.id,focusedName:de.displayName}),u.current&&(u.current.value=de.displayName)}else ee();x.open||K()},V=()=>{p.current[x.focusedId]&&ne(x.focusedId)},j=()=>{x.query!==t&&_({query:t}),Q()},B=Y=>{const{key:re}=Y;switch(re){case"ArrowDown":case"ArrowUp":Y.preventDefault(),I(re),ee();break;case"Enter":Y.preventDefault(),V();break;case"Escape":Y.preventDefault(),j();break}};b.useEffect(()=>{w&&f.current&&f.current.focus()},[w]),aE(c,Q);const U=x.open&&!T.length,$=O==="loading"&&U,z=O==="error",k=t&&e===""&&r==="";return h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:`relative mb-2 block ${z?"after:border-t-foreground/40":"after:border-t-foreground"}`,ref:c,children:[h.jsx("label",{className:"block pb-1 font-medium",id:E,htmlFor:m,children:M(C.HANDLE_VIA)}),h.jsxs("div",{className:"relative pb-1",children:[h.jsx("input",{"aria-activedescendant":x.open?x.focusedId:void 0,"aria-invalid":U,"aria-autocomplete":"list","aria-controls":x.open?m:void 0,"aria-expanded":x.open,"aria-labelledby":E,autoComplete:"off",className:`${z||k?"invalid":""} rounded-md border border-foreground !p-2 !pr-8`,disabled:z,onChange:L,onClick:K,onKeyDown:B,placeholder:x.open?M(C.SEARCH_FOR_INTERNAL_SCRIPT):M(C.EXTERNAL_OR_INTERNAL_RESOURCE),ref:u,role:"combobox",type:"text",value:x.focusedName||x.query}),h.jsxs("button",{"aria-controls":x.open?m:void 0,"aria-expanded":x.open,"aria-haspopup":"listbox","aria-labelledby":`${E} ${v}`,className:`${x.open?"after:rotate-180":"after:rotate-0"} chevron-down absolute inset-y-0 right-0 px-4 after:transition-transform focus-within:!ring-0 focus-within:!ring-offset-0`,disabled:z,id:v,onClick:X,tabIndex:-1,type:"button",children:[$&&h.jsx(Ce,{className:"absolute top-3 right-7 animate-spin",tag:"arrows-rotate",size:"xs"}),h.jsx("span",{className:"sr-only",children:M(x.open?C.TOGGLE_CLOSE:C.TOGGLE_OPEN)})]}),h.jsxs("p",{className:"requirements w-full",role:"alert",children:[k&&M(C.SCRIPT_NOT_FOUND),z&&M(C.ERROR_FETCHING_SWML_SCRIPTS)]})]}),!z&&x.open&&h.jsx("ul",{className:"max-h-60 w-full overflow-auto rounded shadow-[0px_2px_6px_2px_rgba(0,0,0,0.15),_0px_1px_2px_0px_rgba(0,0,0,0.30)]","aria-labelledby":E,id:m,role:"listbox",onKeyDown:B,children:T.length?h.jsxs(h.Fragment,{children:[T.length===1&&td(T?.[0]?.id)&&(O==="loaded"||O==="loading")&&h.jsx(nd,{displayName:M(O==="loading"?C.STATUS_LOADING:C.NO_SCRIPTS_FOUND)}),T.map(({displayName:Y,id:re},oe)=>{const le=e===re,de=x.focusedId?x.focusedId===re:oe===0;return h.jsx(nd,{active:le,focus:de,displayName:Y,handleOnClick:()=>W(re),id:re,ref:he=>p.current[re]=he},re)})]}):h.jsx(nd,{displayName:M($?C.STATUS_LOADING:C.NO_RESULTS)})})]}),w&&h.jsxs("label",{className:"mb-2 block",children:[h.jsx("span",{className:"sr-only",children:M(C.EXTERNAL_OPTION_LABEL)}),h.jsxs("div",{className:"flex flex-wrap items-center gap-x-2",children:[h.jsx("input",{className:`w-14 ${i?"":"invalid"}`,inputMode:"url",name:"connectConfirmUrl",onChange:F,placeholder:M(C.ENTER_URL),ref:f,type:"url",value:x.externalValue}),h.jsx("p",{className:"requirements w-full",role:"alert",children:M(C.ERROR_URL_IS_REQUIRED)})]})]}),!N.length&&!w&&h.jsx("div",{className:"mb-2",children:h.jsx("p",{children:h.jsx(OA,{children:M(C.ADD_SWML_SCRIPTS)})})})]})},nd=b.forwardRef(function({active:t,displayName:r,focus:s,handleOnClick:i,id:a},c){const u=!!i,f=u?`cursor-pointer transition-colors hover:bg-primary/5 focus:bg-primary/5 aria-selected:bg-primary/20 ${s?"bg-primary/5":""}`:"";return h.jsx("li",{"aria-selected":t,className:`relative select-none bg-background py-1 px-3 text-xs leading-6 ${f}`,id:a,onClick:i,ref:c,role:u?"option":"presentation",tabIndex:-1,children:r})}),OA=({children:e,className:t=""})=>h.jsx("a",{className:`w-fit text-foreground underline hover:text-foreground/80 ${t}`,href:"/relay-bins",target:"_blank",rel:"noopener noreferrer",children:e}),CA=({confirmId:e,confirmName:t,confirmUrl:r,enabled:s,handleOnChange:i,onCheck:a,valid:c})=>{const u=b.useId(),{validateCache:f}=Qg();return b.useEffect(()=>{s&&f()},[s,f]),h.jsxs(h.Fragment,{children:[h.jsx(Ol,{"aria-controls":u,"aria-expanded":s,checked:s,clickHandler:a,name:"connectConfirmEnabled",subtitle:M(C.SWML_TO_EXECUTE),title:M(C.ENABLE_WHISPER)}),s&&h.jsx("div",{id:u,children:h.jsx(TA,{onChange:i,confirmId:e,confirmName:t,confirmUrl:r,valid:c})})]})},AA={forwardAddress:{add:C.ADD_ADDRESS,call:C.CALL_ADDRESSES,optionNumber:C.ADDRESS_NUMBER,remove:C.REMOVE_ADDRESS,title:C.FORWARD_TO_ADDRESS},forwardPhone:{add:C.ADD_PHONE_NUMBER,call:C.CALL_NUMBERS,optionNumber:C.PHONE_NUMBER_NUMBER,remove:C.REMOVE_PHONE_NUMBER,title:C.FORWARD_TO_PHONE},forwardResource:{add:C.ADD_RESOURCE,call:C.CALL_RESOURCES,optionNumber:C.RESOURCE_NUMBER,remove:C.REMOVE_RESOURCE,title:C.FORWARD_TO_RESOURCE}},cE={parallel:C.SIMULTANEOUSLY,serial:C.SEQUENTIALLY},IA=()=>({connectConfirmDisplayName:"",connectConfirmEnabled:!1,connectConfirmId:"",connectConfirmUrl:"",connectFrom:"",connectTimeout:"",connectTo:"",id:Le()}),rd=({nodeType:e,nodeData:t,handleOnUpdate:r})=>{const{validateField:s}=It(e),i=b.useRef(),[a,c]=b.useState(["serial","parallel"].includes(t.callOrder)?t.callOrder:"serial"),u=AA[e],[f,p]=b.useState({callOrder:t.initial||s("callOrder",a),callStateEvents:t.initial||s("callStateEvents",a),callStateUrl:t.initial||s("callStateUrl",a),connections:t.connections?.map(D=>({connectConfirmId:s("connectConfirmId",D.connectConfirmId),connectConfirmUrl:s("connectConfirmUrl",D.connectConfirmUrl),connectFrom:s("connectFrom",D.connectFrom),connectTimeout:s("connectTimeout",D.connectTimeout),connectTo:s("connectTo",D.connectTo),initial:t.initial})),defaultFrom:t.initial||s("defaultFrom",t.defaultFrom),defaultTimeout:t.initial||s("defaultTimeout",t.defaultTimeout)}),m=D=>{D.preventDefault(),p({...f,connections:[...f.connections,{connectConfirmId:!0,connectConfirmUrl:!0,connectFrom:!0,connectTimeout:!0,connectTo:!0,initial:!0}]}),r({callOrder:a,connections:[...t.connections,IA()]})},E=D=>T=>{T.preventDefault();const A=[...f.connections];A.splice(D,1),p({...f,connections:A});const L=[...t.connections];L.splice(D,1),r({callOrder:L.length===1?"single":a,connections:L})},v=(D,T,A)=>{const L=[...t.connections],F=L[D];if(!F)throw new Error(`Option not found at index ${D}`);const K=T?.name,Q=T?.value,ee={...K?{[K]:Q}:{},...A,id:F.id},ne=[...f.connections],W=Object.keys(ee).reduce((j,B)=>{const U=ee[B],$=B;return j[$]=s(B,U),j},{initial:!1}),I=ne.map((j,B)=>B===D?{...j,...W}:j);p({...f,connections:I});const V=L.map(j=>j.id===ee.id?{...j,...ee}:j);r({connections:V,initial:!1})},x=D=>{const T=D.currentTarget.value;c(T),r({callOrder:T})},_=(D,T)=>{v(D,void 0,T)},w=(D,T)=>{_(D,{connectConfirmEnabled:T})},S=D=>T=>_(D,{...T}),N=(D,T)=>{const A=D.target,{name:L,value:F}=A;switch(L){case"callStateEvents":case"callStateUrl":case"defaultTimeout":case"defaultFrom":p({...f,[L]:s(L,F)}),r({initial:!1,[L]:F});break;case"connectFrom":case"connectTimeout":case"connectTo":if(T===void 0)throw new Error(`Option index not provided: ${L}`);v(T,{name:L,value:F});break;default:throw new Error(`Unhandled input name: ${L}`)}},O=({index:D,name:T})=>{const A=f.connections[D];return!!(A?.[T]||A?.initial)};return h.jsxs(_t,{title:M(u.title),formRef:i,children:[h.jsxs("div",{className:"border-b-4 border-foreground/10 px-3 pb-3",children:[h.jsxs("label",{className:"mb-2 block",children:[M(C.DEFAULT_FROM),h.jsx(Ys,{className:"w-full",direction:"from",name:"defaultFrom",onChange:N,placeholder:M(C.FROM),type:"tel",value:t.defaultFrom,valid:f.defaultFrom}),h.jsx("p",{className:"requirements w-full",role:"alert",children:M(C.ERROR_VALUE_IS_REQUIRED)})]}),h.jsxs("label",{className:"mb-2 block",children:[M(C.DEFAULT_TIMEOUT),h.jsxs("div",{className:"flex flex-wrap items-center gap-x-2",children:[h.jsx("input",{className:`w-14 ${f.defaultTimeout?"":"invalid"}`,inputMode:"numeric",min:0,name:"defaultTimeout",onChange:N,placeholder:M(C.SECONDS),type:"number",value:t.defaultTimeout}),h.jsx("p",{className:"requirements w-full",role:"alert",children:M(C.ERROR_NUMBER_IS_REQUIRED)})]})]}),h.jsxs("label",{className:"mb-2 block",children:[M(C.CALL_STATE_URL),h.jsx("input",{className:`w-full ${f.callStateUrl?"":"invalid"}`,name:"callStateUrl",onChange:N,placeholder:"https://example.com/api",type:"url",value:t.callStateUrl}),h.jsx("p",{className:"requirements w-full",role:"alert",children:M(C.ERROR_VALUE_IS_REQUIRED)})]}),h.jsxs("label",{className:"mb-2 block",children:[M(C.CALL_STATE_EVENTS),h.jsx("input",{className:`w-full ${f.callStateEvents?"":"invalid"}`,name:"callStateEvents",onChange:N,placeholder:"Created, ringing, answered, ended",type:"text",value:t.callStateEvents}),h.jsx("p",{className:"requirements w-full",role:"alert",children:M(C.ERROR_VALUE_IS_REQUIRED)})]})]}),h.jsx("ul",{className:"border-foreground-10 divide-y-4 divide-foreground/10 border-b-4 pt-2",children:t.connections?.map((D,T,A)=>h.jsx("li",{className:"flex flex-col gap-y-2 px-4",children:h.jsxs("fieldset",{children:[h.jsxs("div",{className:"item-center flex justify-between py-4",children:[h.jsxs("legend",{children:[h.jsx(Ce,{className:"pr-2 text-foreground/60",size:"xs",tag:"bars"}),h.jsx("span",{className:"text-xs font-semibold",children:M(u.optionNumber,{index:T+1})})]}),A.length>1&&h.jsx(Fo,{handleDelete:E(T),label:M(u.remove,{index:T+1}),size:"sm",show:!0})]}),h.jsxs("label",{className:"mb-1 block pl-2",children:[h.jsx("div",{className:"sr-only",children:M(C.TO)}),h.jsx(Ys,{className:"w-full",direction:"to",name:"connectTo",onChange:L=>N(L,T),type:e==="forwardPhone"?"tel":"text",valid:O({index:T,name:"connectTo"}),value:D.connectTo}),h.jsx("p",{className:"requirements",role:"alert",children:M(C.ERROR_VALUE_IS_REQUIRED)})]}),h.jsxs("label",{className:"mb-2 block pl-2",children:[h.jsx("div",{className:"sr-only",children:M(C.FROM)}),h.jsx(Ys,{className:"w-full",direction:"from",name:"connectFrom",onChange:L=>N(L,T),placeholder:M(C.FROM),type:"text",valid:O({index:T,name:"connectFrom"}),value:D.connectFrom}),h.jsx("p",{className:"requirements",role:"alert",children:M(C.ERROR_VALUE_IS_REQUIRED)})]}),h.jsxs("label",{className:"mb-2 block pl-2",children:[M(C.TIMEOUT),h.jsxs("div",{className:"flex flex-wrap items-center gap-x-2",children:[h.jsx("input",{className:`${O({index:T,name:"connectTimeout"})?"":"invalid"}`,inputMode:"numeric",min:0,name:"connectTimeout",onChange:L=>N(L,T),placeholder:M(C.SECONDS),type:"number",value:D.connectTimeout}),h.jsx("p",{className:"requirements w-full",role:"alert",children:M(C.ERROR_NUMBER_IS_REQUIRED)})]})]}),h.jsx("div",{className:"mb-2 block pl-2",children:h.jsx(CA,{confirmId:D.connectConfirmId,confirmName:D.connectConfirmDisplayName,confirmUrl:D.connectConfirmUrl,enabled:D.connectConfirmEnabled,handleOnChange:S(T),onCheck:()=>w(T,!D.connectConfirmEnabled),valid:O({index:T,name:"connectConfirmUrl"})&&O({index:T,name:"connectConfirmId"})})})]})},D.id))}),h.jsx("div",{className:"p-3 pb-6 text-right",children:h.jsx("button",{className:"rounded bg-foreground/10 py-1 px-2 font-medium",onClick:m,type:"button",children:M(u.add)})}),t.connections?.length>1&&h.jsx("div",{className:"mb-4 px-3",children:h.jsx(Tn,{className:"w-full",label:M(u.call),name:"callOrder",onChange:x,value:a,children:Object.keys(cE).map(D=>h.jsx("option",{value:D,children:M(cE[D])},D))})})]})},bA=()=>({command:"",digit:"",id:Le()}),LA=({nodeData:e,handleOnUpdate:t})=>{const{validateField:r}=It("promptPlay"),s=b.useRef(),[i,a]=b.useState({digitTimeout:e.initial||r("digitTimeout",e.digitTimeout),initialTimeout:e.initial||r("initialTimeout",e.initialTimeout),options:e.options.map(x=>({command:r("command",x.command),digit:r("digit",x.digit),initial:e.initial}))}),c=Er(e.options,"command"),u=Er(e.options,"digit"),f=x=>{x.preventDefault(),a({...i,options:[...i.options,{command:!0,digit:!0,initial:!0}]}),t({options:[...e.options,bA()]})},p=x=>_=>{_.preventDefault();const w=[...i.options];w.splice(x,1),a({...i,options:w});const S=[...e.options];S.splice(x,1),t({options:S})},m=(x,_)=>{const w=[...e.options];if(!w[x])throw new Error(`Option not found at index ${x}`);const{name:S,value:N}=_,O=[...i.options];O[x]={...O[x],initial:!1,[S]:r(S,N)},a({...i,options:O}),w[x]={...w[x],[S]:N},t({options:w})},E=(x,_)=>{const w=x.target,{name:S,value:N}=w;switch(t({initial:!1}),S){case"digit":case"command":_!==void 0&&m(_,{name:S,value:N});break;case"digitTimeout":case"initialTimeout":{a({...i,[S]:r(S,N)}),t({[S]:N});break}default:throw new Error(`Unhandled input field name: ${S}`)}},v=({index:x,name:_})=>{const w=i.options[x];if(w?.initial)return!0;if(!w?.[_])return!1;const S=e.options?.[x];return jt(S?.digit)||jt(S?.command)};return h.jsxs(_t,{formRef:s,title:M(C.GATHER_INPUT),children:[h.jsx("div",{className:"border-b-4 border-foreground/10 px-3 pb-3",children:h.jsx(oE,{handleOnUpdate:t,label:M(C.CHOOSE_OPTION_TTS_AUDIO),nodeData:e})}),h.jsx("ol",{className:"divide-y-4 divide-foreground/10 border-b-4 border-foreground/10",children:e.options.map((x,_,w)=>{const S=c(x.command),N=u(x.digit);return h.jsxs("li",{className:"flex pt-3",children:[h.jsx("div",{className:"w-8 shrink-0 text-center",children:h.jsx(Ce,{className:"text-foreground/60",size:"xs",tag:"bars"})}),h.jsxs("div",{className:"relative mr-3",children:[w.length>1&&h.jsx(Fo,{className:"absolute right-0 top-0",handleDelete:p(_),label:M(C.REMOVE_OPTION,{index:_+1}),size:"sm",show:!0}),h.jsxs("fieldset",{children:[h.jsx("legend",{className:"sr-only",children:M(C.OPTION_NUMBER,{index:_+1})}),h.jsxs("label",{className:"mb-2 block",children:[M(C.CALLER_PRESSES),h.jsx("input",{className:`${v({index:_,name:"digit"})&&!N?"":"invalid"}`,name:"digit",onChange:O=>E(O,_),placeholder:M(C.KEYPAD_VALUE),type:"text",value:x.digit}),h.jsx("p",{className:"requirements",role:"alert",children:M(N?C.ERROR_DUPLICATE_TELEPHONE_KEY:C.ERROR_TELEPHONE_KEY_REQUIRED)})]}),h.jsxs("label",{className:"mb-2 block",children:[M(C.OR_SAYS),h.jsx("input",{className:`w-full ${v({index:_,name:"command"})&&!S?"":"invalid"}`,name:"command",onChange:O=>E(O,_),placeholder:M(C.SPOKEN_PROMPT),type:"text",value:x.command}),h.jsx("p",{className:"requirements",role:"alert",children:M(S?C.ERROR_DUPLICATE_COMMAND:C.ERROR_TEXT_IS_REQUIRED)})]})]})]})]},x.id)})}),h.jsx("div",{className:"p-3 pb-6 text-right",children:h.jsx("button",{className:"rounded bg-foreground/10 py-1 px-2 font-medium",onClick:f,type:"button",children:M(C.ADD_OPTION)})}),h.jsxs("div",{className:"px-3",children:[h.jsxs("label",{className:"mb-2 block",children:[h.jsx("div",{className:"w-full",children:M(C.WAIT_FOR_INPUT)}),h.jsxs("div",{className:"flex flex-wrap items-center gap-x-2",children:[h.jsx("input",{className:`w-14 ${i.initialTimeout?"":"invalid"}`,inputMode:"numeric",min:He.MIN,max:He.MAX,name:"initialTimeout",onChange:E,placeholder:M(C.SECONDS),type:"number",value:e.initialTimeout}),h.jsx("p",{className:"requirements w-full",role:"alert",children:M(C.ERROR_NUMBER_MIN_MAX_IS_REQUIRED,{max:He.MAX,min:He.MIN})})]})]}),h.jsxs("label",{children:[h.jsx("div",{className:"w-full",children:M(C.WAIT_FOR_DIGIT)}),h.jsxs("div",{className:"flex flex-wrap items-center gap-x-2",children:[h.jsx("input",{className:`w-14 ${i.digitTimeout?"":"invalid"}`,inputMode:"numeric",min:He.MIN,max:He.MAX,name:"digitTimeout",onChange:E,placeholder:M(C.SECONDS),type:"number",value:e.digitTimeout}),h.jsx("p",{className:"requirements w-full",role:"alert",children:M(C.ERROR_NUMBER_MIN_MAX_IS_REQUIRED,{max:He.MAX,min:He.MIN})})]})]})]})]})},DA=({handleOnUpdate:e,nodeData:t})=>{const{validateField:r}=It("play"),[s,i]=b.useState({reason:t.initial||r("reason",t.reason)}),a=c=>{const u=c.target,{name:f,value:p}=u;switch(f){case"reason":i({...s,[f]:r(f,p)}),e({initial:!1,[f]:p});break;default:throw new Error(`Unhandled input name: ${f}`)}};return h.jsx(_t,{title:M(C.HANG_UP_CALL),children:h.jsx("div",{className:"mx-3",children:h.jsxs(Tn,{className:"w-full",label:`${M(C.REASON)} (${M(C.OPTIONAL)})`,name:"reason",onChange:a,value:t.reason,children:[h.jsx("option",{value:"",children:M(C.SELECT)}),Object.keys(qu).map(c=>h.jsx("option",{value:c,children:M(qu[c])},c))]})})})},kA=({nodeData:e,handleOnUpdate:t})=>{const r=b.useRef();return h.jsx(_t,{formRef:r,title:M(C.PLAY_AUDIO_TTS),children:h.jsx("div",{className:"mx-3",children:h.jsx(oE,{handleOnUpdate:t,label:M(C.CHOOSE_OPTION_TTS_AUDIO),nodeData:e,showDefaultOption:!0})})})},MA=({nodeData:e,handleOnUpdate:t})=>{const r=b.useRef(),{validateField:s}=It("recordCallStart"),[i,a]=b.useState({label:e.initial||s("label",e.label)}),[c,u]=b.useState(!1),{upsertEntry:f,isValueDuplicate:p}=Hu();b.useEffect(()=>{u(p(e.label,e.controlId))},[p,e.controlId,e.label]);const m=E=>{const v=E.target,{name:x,value:_}=v;a({...i,[x]:s(x,_)}),t({initial:!1,[x]:_}),f({controlId:e.controlId,label:_})};return h.jsxs(_t,{title:M(C.RECORD_CALL_START),formRef:r,children:[h.jsx("div",{className:"px-3 pb-3",children:h.jsxs("label",{children:[M(C.RECORDING_NAME),h.jsx("input",{className:`w-full ${i.label&&!c?"":"invalid"}`,name:"label",onChange:m,type:"text",value:e.label}),h.jsx("p",{className:"requirements",role:"alert",children:M(c?C.ERROR_DUPLICATE_RECORDING_LABEL:C.ERROR_RECORDING_LABEL_REQUIRED)})]})}),h.jsx("div",{className:"px-3",children:h.jsx(sE,{handleOnUpdate:t,nodeData:e,type:"call"})})]})},PA=({nodeData:e,handleOnUpdate:t})=>{const{validateField:r}=It("recordCallStop"),[s,i]=b.useState({controlId:e.initial||r("controlId",e.controlId)}),{getEntries:a}=Hu(),c=a().sort((f,p)=>f.label.toLowerCase().localeCompare(p.label.toLowerCase())),u=f=>{const p=f.target,{name:m,value:E}=p;i({...s,[m]:r(m,E)}),t({initial:!1,[m]:E})};return h.jsx(_t,{title:M(C.RECORD_CALL_STOP),children:h.jsx("div",{className:"px-3",children:c.length?h.jsxs(Tn,{className:`w-full ${s.controlId?"":"invalid"}`,label:M(C.RECORDING_NAME),name:"controlId",value:e.controlId,onChange:u,children:[h.jsx("option",{value:"",children:M(C.SELECT)}),c.map(f=>h.jsx("option",{value:f.controlId,children:f.label},f.controlId))]}):h.jsx("p",{role:"alert",className:"text-negative",children:M(C.ERROR_ADD_RECORDING_FIRST)})})})},UA=({nodeData:e,handleOnUpdate:t})=>h.jsx(_t,{title:M(C.VOICEMAIL_RECORDING),children:h.jsx("div",{className:"mx-3",children:h.jsx(sE,{handleOnUpdate:t,nodeData:e,type:"voicemail"})})}),FA=["GET","POST","PUT","DELETE"],jA=({nodeData:e,handleOnUpdate:t})=>{const{validateField:r}=It("request"),[s,i]=b.useState({body:e.initial||r("body",e.body),headers:e.initial||r("headers",e.headers),method:e.initial||r("method",e.method),saveVariables:e.initial||r("saveVariables",e.saveVariables),url:e.initial||r("url",e.url)}),a=f=>{const p=f.target,{name:m,value:E}=p;switch(t({initial:!1}),m){case"url":case"method":i({...s,[m]:r(m,E)}),t({[m]:E});break;case"headers":i({...s,[m]:r(m,E)}),t({[m]:E});break;case"body":i({...s,[m]:r(m,E)}),t({[m]:E});break;default:throw new Error(`Unhandled input name: ${m}`)}},c=f=>{const{name:p,value:m}=f.target;t({[p]:m})},u=f=>{const{name:p}=f.target,m=!e[p];t({[p]:m})};return h.jsx(_t,{title:M(C.REQUEST),children:h.jsxs("div",{className:"px-3",children:[h.jsxs("label",{className:"mb-2 block",children:[M(C.URL),h.jsx("input",{className:`w-full ${s.url?"":"invalid"}`,name:"url",onChange:a,placeholder:"https://u:p@example.com/api/status",type:"text",value:e.url}),h.jsx("p",{className:"requirements w-full",role:"alert",children:M(C.ERROR_VALUE_IS_REQUIRED)})]}),h.jsx("div",{className:"mb-1",children:h.jsx(Tn,{className:"w-full",label:M(C.METHOD),name:"method",onChange:c,value:e.method,children:FA.map(f=>h.jsx("option",{value:f,children:f},f))})}),h.jsx("div",{className:"mb-4",children:h.jsx(Ol,{checked:e.saveVariables,clickHandler:u,name:"saveVariables",subtitle:M(C.SAVE_VARIABLES_SUBTITLE),title:M(C.SAVE_VARIABLES)})}),h.jsx("label",{className:"mb-2 block",children:h.jsx($n,{errorText:M(C.ERROR_INVALID_JSON),inputMode:"text",label:M(C.REQUEST_HEADERS),name:"headers",onChange:a,placeholder:'{"Content-Type": "application/json", "X-Custom-Header": "foo"}',valid:s.headers,value:e.headers})}),h.jsx("label",{children:h.jsx($n,{errorText:M(C.ERROR_INVALID_JSON),inputMode:"text",label:M(C.REQUEST_BODY),name:"body",onChange:a,placeholder:M(C.STRING_OR_JSON),valid:s.body,value:e.body??""})})]})})},VA=({nodeData:e,handleOnUpdate:t})=>{const{validateField:r}=It("sendSms"),[s,i]=b.useState({body:e.initial||r("body",e.body),fromNumber:e.initial||r("fromNumber",e.fromNumber),toNumber:e.initial||r("toNumber",e.toNumber)}),a=c=>{const u=c.target,{name:f,value:p}=u;switch(f){case"body":case"fromNumber":case"toNumber":i({...s,[f]:r(f,p)}),t({initial:!1,[f]:p});break;default:throw new Error(`Unhandled input name: ${f}`)}};return h.jsx(_t,{title:M(C.SEND_SMS),children:h.jsxs("div",{className:"mx-3",children:[h.jsxs("label",{className:"mb-2 block",children:[M(C.TO_PHONE_NUMBER),h.jsx(Ys,{className:"w-full",direction:"to",name:"toNumber",onChange:a,placeholder:"+12405550000",type:"tel",valid:s.toNumber,value:e.toNumber}),h.jsx("p",{className:"requirements w-full",role:"alert",children:M(C.ERROR_VALUE_IS_REQUIRED)})]}),h.jsxs("label",{className:"mb-2 block",children:[M(C.FROM_PHONE_NUMBER),h.jsx(Ys,{className:"w-full",direction:"from",name:"fromNumber",onChange:a,placeholder:"+12405550000",type:"tel",valid:s.fromNumber,value:e.fromNumber}),h.jsx("p",{className:"requirements w-full",role:"alert",children:M(C.ERROR_VALUE_IS_REQUIRED)})]}),h.jsx("label",{children:h.jsx($n,{errorText:M(C.ERROR_VALUE_IS_REQUIRED),inputMode:"text",label:M(C.SMS_TEXT),name:"body",onChange:a,placeholder:M(C.WRITE_SOMETHING),valid:s.body,value:e.body})})]})})},$A=()=>({id:Le(),key:"",value:""}),HA=({nodeData:e,handleOnUpdate:t})=>{const{validateField:r}=It("set"),[s,i]=b.useState({variables:e.variables.map(E=>({key:e.initial||r("key",E.key),value:e.initial||r("value",E.value)}))}),a=Er(e.variables,"key"),c=E=>{E?.preventDefault(),i({...s,variables:[...s.variables,{key:!0,value:!0}]}),t({variables:[...e.variables,$A()]})},u=(E,v)=>{const x=[...e.variables];let _=x[E];if(!_)throw new Error(`Variable not found at index ${E}`);const{name:w,value:S}=v,N=[...s.variables];N[E]={...N[E],[w]:r(w,S)},i({...s,variables:N}),_={...x[E],[w]:S},x[E]=_,t({initial:!1,variables:x})},f=E=>v=>{v.preventDefault();const x=[...s.variables];x.splice(E,1),i({...s,variables:x});const _=[...e.variables];_.splice(E,1),t({variables:_})},p=(E,v)=>{const x=E.target,{name:_,value:w}=x;switch(_){case"key":case"value":v!==void 0&&u(v,{name:_,value:w});break;default:throw new Error(`Unhandled input name: ${_}`)}},m=({index:E,name:v})=>s.variables[E]?.[v];return h.jsxs(_t,{title:M(C.SET_VARIABLES),children:[h.jsx("ol",{className:"divide-y-4 divide-foreground/10 border-b-4 border-foreground/10",children:e.variables?.map((E,v,x)=>{const _=a(E.key);return h.jsxs("li",{className:"flex pt-3",children:[h.jsx("div",{className:"w-8 shrink-0 text-center",children:h.jsx(Ce,{className:"text-foreground/60",size:"xs",tag:"bars"})}),h.jsxs("div",{className:"relative mr-3",children:[x.length>1&&h.jsx(Fo,{className:"absolute right-0 top-0",handleDelete:f(v),label:M(C.REMOVE_VARIABLE,{index:v+1}),size:"sm",show:!0}),h.jsxs("fieldset",{children:[h.jsx("legend",{className:"sr-only",children:M(C.VARIABLE_NUMBER,{index:v+1})}),h.jsxs("label",{className:"mb-2 block",children:[M(C.KEY),h.jsx("input",{className:`w-full ${m({index:v,name:"key"})&&!_?"":"invalid"}`,name:"key",onChange:w=>p(w,v),type:"text",value:E.key}),h.jsx("p",{className:"requirements",role:"alert",children:M(_?C.ERROR_DUPLICATE_VARIABLE_KEY:C.ERROR_VARIABLE_KEY_REQUIRED)})]}),h.jsxs("label",{className:"mb-2 block",children:[M(C.VALUE),h.jsx("input",{className:`w-full ${m({index:v,name:"value"})?"":"invalid"}`,name:"value",onChange:w=>p(w,v),type:"text",value:E.value}),h.jsx("p",{className:"requirements",role:"alert",children:M(C.ERROR_TEXT_IS_REQUIRED)})]})]})]})]},E.id)})}),h.jsx("div",{className:"p-3 text-right",children:h.jsx("button",{className:"rounded bg-foreground/10 py-1 px-2 font-medium",onClick:c,type:"button",children:M(C.ADD_VARIABLE)})})]})},BA=e=>({id:Le(),key:e}),zA=({nodeData:e,handleOnUpdate:t})=>{const a={currentFocus:void 0,listOpen:!1,setVariablesList:ye(S=>S.nodes).reduce((S,N)=>{if(N.type==="set"){const O=N.data.variables.map(D=>({id:D.id,key:D.key}));return[...S,...O]}else if(N.type==="unset")return[...S,...N.data.variables];return S},[]).reduce((S,N)=>(S.find(O=>O.key===N.key)||S.push(N),S),[]).map(S=>({...S,selected:!!e.variables.find(N=>N.key===S.key)})).sort((S,N)=>S.key.toLowerCase().localeCompare(N.key.toLowerCase()))},[c,u]=ed(a),f=S=>c.setVariablesList.map(N=>N.id===S?{...N,selected:!N.selected}:N),p=S=>{const N=c.setVariablesList.find(O=>O.id===S);if(!N)throw new Error("Variable not found");if(N.selected)m(N.id);else{const O=[...e.variables,BA(N.key)];u({setVariablesList:f(N.id)}),t({variables:O})}},m=S=>{const N=c.setVariablesList.filter(O=>O.selected&&O.id!==S);u({setVariablesList:f(S)}),t({variables:N})},E=b.useRef(null);aE(E,()=>u({listOpen:!1}));const v=S=>{(S.key==="Escape"||S.key==="Esc")&&u({listOpen:!1})},x=(S,N)=>{S.preventDefault(),(S.key===" "||S.code==="Space"||S.key==="Enter")&&p(N),v(S)},_=()=>{u({listOpen:!c.listOpen})},w=e.variables.length;return h.jsx(_t,{title:M(C.UNSET_VARIABLES),children:h.jsxs("div",{className:"px-3",children:[h.jsxs("div",{className:"mb-2 flex flex-col",children:[h.jsx("label",{id:"listbox-label",className:"sr-only",children:M(C.SELECT_VARIABLES_TO_UNSET)}),h.jsxs("div",{className:"relative",ref:E,children:[h.jsx("button",{"aria-expanded":"true","aria-haspopup":"listbox","aria-labelledby":"listbox-label",className:`relative w-full cursor-pointer rounded-md border border-foreground/10 bg-transparent py-1.5 px-3 text-left
|
|
64
64
|
after:absolute after:top-[.725rem] after:right-3 after:h-0 after:w-0 after:border-[5px] after:border-t-[6px] after:border-b-0 after:border-r-transparent after:border-l-transparent after:border-t-foreground after:content-['']`,onClick:_,onKeyDown:v,type:"button",children:w>0?M(C.NUMBER_OF_VARIABLES_SELECTED,{count:w}):M(C.SELECT_VARIABLES)}),c.listOpen&&h.jsxs("ul",{"aria-activedescendant":c.currentFocus,"aria-labelledby":"listbox-label","aria-multiselectable":"true",className:"mt-1 max-h-60 w-full overflow-auto rounded-lg border border-foreground/10 bg-backgroundAlt py-1 shadow-xl",role:"listbox",children:[!c.setVariablesList.length&&h.jsx("li",{"aria-disabled":"true",className:"relative",role:"option",children:h.jsx("label",{className:"flex select-none items-center py-2 pl-3 pr-9",children:M(C.NO_VARIABLES_SET)})}),c.setVariablesList.map(S=>{if(S.key)return h.jsx("li",{"aria-selected":S.selected,className:"relative",id:S.id,role:"option",children:h.jsxs("label",{className:"flex select-none items-center py-2 pl-3 pr-9",children:[h.jsx("input",{checked:S.selected,className:"mr-2 h-4 w-4 rounded accent-primary",onChange:()=>p(S.id),onKeyDown:N=>x(N,S.id),type:"checkbox"}),S.key]})},S.id)})]})]})]}),w>0&&h.jsxs("section",{className:"pt-3",children:[h.jsx("h3",{className:"mb-2 text-xs font-medium text-foreground",children:M(C.UNSET_VARIABLES)}),h.jsx("ul",{className:"flex flex-wrap gap-2",children:c.setVariablesList.map(S=>S.selected&&h.jsx(HT,{handleClick:()=>m(S.id),children:S.key},S.id))})]})]})})},uE={aiAgent:({data:e,formUpdate:t})=>h.jsx(yA,{handleOnUpdate:t,nodeData:e}),cond:({data:e,formUpdate:t})=>h.jsx(SA,{handleOnUpdate:t,nodeData:e}),condRequest:({data:e,formUpdate:t})=>h.jsx(xA,{handleOnUpdate:t,nodeData:e}),executeSWML:({data:e,formUpdate:t})=>h.jsx(_A,{handleOnUpdate:t,nodeData:e}),forwardAddress:({data:e,formUpdate:t})=>h.jsx(rd,{handleOnUpdate:t,nodeData:e,nodeType:"forwardAddress"}),forwardPhone:({data:e,formUpdate:t})=>h.jsx(rd,{handleOnUpdate:t,nodeData:e,nodeType:"forwardPhone"}),forwardResource:({data:e,formUpdate:t})=>h.jsx(rd,{handleOnUpdate:t,nodeData:e,nodeType:"forwardResource"}),hangup:({data:e,formUpdate:t})=>h.jsx(DA,{handleOnUpdate:t,nodeData:e}),play:({data:e,formUpdate:t})=>h.jsx(kA,{handleOnUpdate:t,nodeData:e}),promptPlay:({data:e,formUpdate:t})=>h.jsx(LA,{handleOnUpdate:t,nodeData:e}),record:({data:e,formUpdate:t})=>h.jsx(UA,{handleOnUpdate:t,nodeData:e}),recordCallStart:({data:e,formUpdate:t})=>h.jsx(MA,{handleOnUpdate:t,nodeData:e}),recordCallStop:({data:e,formUpdate:t})=>h.jsx(PA,{handleOnUpdate:t,nodeData:e}),request:({data:e,formUpdate:t})=>h.jsx(jA,{handleOnUpdate:t,nodeData:e}),sendSms:({data:e,formUpdate:t})=>h.jsx(VA,{handleOnUpdate:t,nodeData:e}),set:({data:e,formUpdate:t})=>h.jsx(HA,{handleOnUpdate:t,nodeData:e}),unset:({data:e,formUpdate:t})=>h.jsx(zA,{handleOnUpdate:t,nodeData:e})},WA=(e,t)=>{if("options"in t)switch(e.type){case"promptPlay":case"cond":case"condRequest":return!0}return!1},GA=e=>{if(e in uE)return uE[e]},YA=()=>{const{partialUpdateNodeData:e,removeNode:t}=Ze(),r=ye(p=>p.selectedNode),s=r?.id,a=ye(p=>p.nodes).find(p=>p.id===s)?.data,{updateDynamicHandles:c}=aA(r);if(!(r&&a&&s))return null;const u=p=>{WA(r,p)&&c(p),e(s,p)},f=GA(r.type);return f?h.jsxs(Ds,{className:"nokey m-0 flex h-full w-[260px] flex-col overflow-hidden rounded-none border border-foreground/10 bg-background pt-4",position:"top-right",children:[h.jsx(f,{data:a,formUpdate:u},s),r.deletable!==!1&&h.jsx("div",{className:"border-t border-foreground/10 p-3",children:h.jsx(Fo,{handleDelete:()=>t(s),label:M(C.DELETE_NODE),show:!0,showLabel:!0})})]}):null},dE=b.forwardRef(function({animate:t=!0,children:r,className:s="",iconTag:i="circle-info",message:a,role:c="alertdialog",status:u},f){const m=u?{error:"bg-negative text-background",success:"bg-positive text-background"}[u]:"";return h.jsxs("div",{className:`flex items-center justify-between rounded-lg bg-foreground p-2
|
|
65
65
|
text-background shadow-lg transition-[box-shadow] hover:shadow-none
|
|
66
|
-
${m} ${t?"animate-from-bottom":""} ${s}`,ref:f,role:c,children:[h.jsxs("div",{className:"flex items-center justify-center gap-x-2",children:[h.jsx(Ce,{className:"flex-shrink-0 self-start",tag:i}),h.jsx("p",{className:"text-xs font-semibold",children:a})]}),r]})}),KA=()=>{const{addToast:e,restoreDeployedFlow:t,cancelDetachedMode:r}=Ze();if(!ye(c=>c.showDeployedHistoryToast))return null;const i=()=>{t(),e({message:M(C.VERSION_RESTORED),status:"success"})},a=()=>{r()};return h.jsx(dE,{animate:!1,className:"gap-x-14",message:M(C.PREVIEW_DEPLOYED_VERSION),role:"dialog",children:h.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-x-2 gap-y-1",children:[h.jsx("button",{className:"rounded bg-primary px-1.5 py-0.5 text-xs font-medium text-background transition-colors hover:bg-primary/90",onClick:i,children:M(C.RESTORE_THIS_VERSION)}),h.jsx("button",{className:"rounded bg-secondary/50 px-1.5 py-0.5 text-xs font-medium text-background transition-colors hover:bg-secondary/40",onClick:a,children:M(C.CANCEL)})]})})},fE=({onKeyPress:e})=>{const t=Oo(["Escape","Esc"]);return b.useEffect(()=>{t&&typeof e=="function"&&e()},[t,e]),{isPressed:t}},XA={offset:[0,.5,1],opacity:[1,0,0],pointerEvents:["none","none","auto"],transform:["scale(1.1) translateY(0%)","scale(0.5) translateY(-100%)"]},QA={duration:ZR*2,easing:"ease-in-out",fill:"forwards"},qA=({durationMs:e,id:t,permanent:r})=>{const s=e??JR,[i,a]=b.useState(null),{deleteToast:c}=Ze(),u=b.useCallback(()=>{let f;const p=()=>c(t);return i instanceof HTMLElement?(f=i.animate(XA,QA),f.addEventListener("finish",p,{once:!0})):p(),()=>f?.removeEventListener("finish",p)},[t,c,i]);return fE({onKeyPress:u}),b.useEffect(()=>{if(r)return;let f,p;const m=()=>{clearTimeout(f)},E=()=>{m(),f=setTimeout(()=>{p=u()},s)};return E(),i instanceof HTMLElement&&(i.addEventListener("mouseenter",m),i.addEventListener("mouseleave",E)),()=>{m(),i instanceof HTMLElement&&(i.removeEventListener("mouseenter",m),i.removeEventListener("mouseleave",E),p?.())}},[u,s,r,i]),{deleteToastCallback:u,setToastRef:a,toastRef:i}},pE=({durationMs:e,id:t,message:r,permanent:s,status:i})=>{const{deleteToastCallback:a,setToastRef:c}=qA({durationMs:e,id:t,permanent:s});return h.jsx(dE,{className:"w-full max-w-sm",iconTag:i==="success"?"circle-check":"circle-exclamation",message:r,ref:c,status:i,children:h.jsxs("button",{className:"flex-shrink-0 self-start opacity-40 transition-opacity hover:opacity-70",onClick:a,children:[h.jsx(Ce,{tag:"circle-xmark",size:"xl"}),h.jsx("span",{className:"sr-only",children:M(C.CLOSE)})]})})},ZA={error:pE,success:pE},JA=()=>{const e=ye(r=>r.toastsMap);if(e.size===0)return null;const t=Array.from(e.values());return h.jsx("div",{className:"flex w-full flex-col items-center gap-y-1",children:t.map(r=>{const s=ZA[r.status];return h.jsx(s,{durationMs:r.durationMs,id:r.id,message:r.message,permanent:r.permanent,status:r.status},r.id)})})},eI=({asRole:e="alert",open:t=!1,type:r="overlay"})=>{const[s,i]=te.useState(t);b.useEffect(()=>{i(t)},[t]);const a=b.useCallback(()=>i(!1),[]),c=b.useCallback(()=>i(!0),[]);return{asRole:e,closeContainer:a,isOpen:s,openContainer:c,type:r}},hE=b.createContext(null),od=()=>{const e=b.useContext(hE);if(e==null)throw new Error("Toast components must be wrapped in <ToastContainer />");return e},tI=({children:e,...t})=>{const r=eI(t);return h.jsx(hE.Provider,{value:r,children:e})},mE=({iconAs:e,title:t,children:r})=>{const{asRole:s}=od();return h.jsxs("div",{className:"max-w-xl rounded-lg bg-foreground p-4 text-background shadow-2xl transition-[transform,box-shadow] duration-500 will-change-transform hover:shadow-none",role:s,children:[h.jsxs("h2",{className:"text-lg font-semibold leading-6 tracking-wide",children:[h.jsx("span",{className:"mr-2",children:h.jsx(Ce,{tag:e??"circle-exclamation"})}),t]}),h.jsx("div",{className:"mt-2 text-sm leading-5",children:r})]})},nI=({children:e})=>{const{closeContainer:t,isOpen:r,type:s}=od(),{getRootElement:i}=Ze(),a=i(),c=b.useRef(null);return b.useEffect(()=>{if(!c.current)return;let u,f;const p=m=>{if(m.key==="Escape"&&t(),m.key==="Tab"){const E=document.activeElement?.shadowRoot?.activeElement;m.shiftKey?E===u&&(f?.focus(),m.preventDefault()):E===f&&(u?.focus(),m.preventDefault())}};if(s==="overlay"){const m=c.current.querySelectorAll("button");u=m[0],f=m[m.length-1],f?.focus(),document.addEventListener("keydown",p)}return()=>{document.removeEventListener("keydown",p)}},[t,s]),r?Bc.createPortal(h.jsx("section",{className:`flex justify-center ${s==="overlay"?"fixed top-0 z-50 h-full w-full items-start px-6 py-36 backdrop-blur-sm backdrop-grayscale":"absolute top-10 left-1/2 z-10 -translate-x-1/2 translate-y-1/2 items-center"}`,ref:s==="overlay"?c:void 0,children:e}),a):null},gE=({asRole:e,open:t,children:r,type:s})=>h.jsx(tI,{asRole:e,open:t,type:s,children:h.jsx(nI,{children:r})}),rI=()=>{const t=ye(r=>r.httpError)===Am;return t?h.jsx(gE,{asRole:"dialog",open:t,type:"overlay",children:h.jsx(mE,{title:M(C.DOCUMENT_OUT_OF_SYNC),children:h.jsx(oI,{})})}):null},oI=()=>{const{closeContainer:e}=od(),t=()=>{window.location.reload()};return h.jsxs(h.Fragment,{children:[Ul(C.TOAST_DOCUMENT_OUT_OF_SYNC),h.jsxs("div",{className:"mt-11 flex items-center justify-center gap-x-6",children:[h.jsx("button",{className:"rounded-md border border-background bg-foreground px-3.5 py-2.5 font-bold tracking-widest text-background",onClick:e,children:M(C.IGNORE)}),h.jsx("button",{className:"rounded-md border border-background bg-positive/70 px-3.5 py-2.5 font-bold tracking-widest text-background",onClick:t,children:M(C.RESYNC)})]})]})},sI=Qe(),iI=()=>{const e=ye(t=>t.showDeployWarning);return h.jsx(gE,{asRole:"dialog",open:e,type:"overlay",children:h.jsx(mE,{title:M(C.DEPLOY_WARNING),children:h.jsx(lI,{})})})},lI=()=>{const{deployFlow:e,setShowDeployWarning:t,setShowValidationWarnings:r}=Ze(),s=()=>{t(!1),r(!0)},i=()=>{t(!1)},a=()=>{e().catch(c=>{sI.error(c)}),i()};return h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"mb-4",children:Ul(C.TOAST_DEPLOY_WARNING)}),h.jsx(cg,{onClickListItem:s}),h.jsxs("div",{className:"mt-11 flex items-center justify-center gap-x-6",children:[h.jsx("button",{className:"rounded-md border border-background bg-foreground px-3.5 py-2.5 font-bold tracking-widest text-background",onClick:i,children:M(C.CANCEL)}),h.jsx("button",{className:"rounded-md border border-background bg-positive/70 px-3.5 py-2.5 font-bold tracking-widest text-background",onClick:a,children:M(C.DEPLOY)})]})]})},aI="react-flow__controls-button",cI="min-w-[3.625rem] cursor-auto select-auto text-center hover:bg-background active:bg-background",uI="hidden sm:flex",dI=b.forwardRef(function({asTag:t="div",children:r,className:s="",hiddenSmallScreen:i=!1,...a},c){const u=t,p=`${aI} ${u==="button"?"":cI} ${i?uI:""} ${s}`;return h.jsx(u,{className:p,ref:c,...a,children:r})}),fI=()=>{const e=ye(c=>c.showValidationWarnings),t=ye(c=>c.validationWarnings),r=ye(c=>c.detachedMode),{setShowValidationWarnings:s}=Ze(),i=()=>s(!e),a=()=>{e&&s(!1)};return!t.size||r?(a(),null):h.jsx(gr,{onOpenChange:s,open:e,outsidePress:!1,placement:"bottom-start",role:"dialog",trigger:h.jsxs(dI,{className:"text-xs",asTag:"button",onClick:i,hiddenSmallScreen:!0,children:[M(C.WARNING),h.jsxs("div",{className:"flex items-center justify-center pl-1",children:[h.jsx("span",{className:"sr-only",children:M(C.MORE_INFO_STATUS_ERROR)}),h.jsx(Ce,{className:"text-warning",tag:"circle-exclamation"})]})]}),children:h.jsx(cg,{children:h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("h2",{className:"text-xs font-semibold",children:[h.jsx(Ce,{className:"mr-1",tag:"circle-exclamation"}),M(C.CAUTION)]}),h.jsxs("button",{className:"my-0.5 rounded-md py-0.5 px-1.5",onClick:a,children:[h.jsx("span",{className:"sr-only",children:M(C.CLOSE)}),h.jsx(Ce,{tag:"xmark",size:"lg"})]})]})})})},pI=()=>{const e=ye(s=>s.isDraggingNode),t=ye(s=>s.showInteractiveControl),r=s=>{ye.setState({isInteractiveControlOn:s})};return h.jsx(MR,{className:`mt-2.5 rounded-[0.25rem] ${e?"group/control-buttons":""}`,position:"top-left",onInteractiveChange:r,showInteractive:t,children:h.jsx(fI,{})})},hI=".react-flow__panel",mI=16,EE={cursor:"no-drop",transform:"translate(0px, 0px) scale(1)",visibility:"hidden",zIndex:"5"},yE=e=>{const t=e.getBoundingClientRect();return{isCursorIntersecting:({clientX:r,clientY:s})=>t.top<=s&&t.bottom>=s&&t.left<=r&&t.right>=r}},gI=e=>{const t=e.querySelectorAll(hI);return Array.from(t).map(r=>yE(r).isCursorIntersecting)},EI=e=>({resetDragNodeStyles:()=>{Object.entries(EE).forEach(([t,r])=>{e.style[t]=r})},updateDragNodeStyles:({isOverDropTarget:t,scale:r,xPos:s,yPos:i})=>{e.style.visibility="visible",e.style.cursor=t?"grabbing":"no-drop",e.style.transform=`translate(${s}px, ${i}px) scale(${r})`}}),yI=({handleMouseMove:e,handleMouseUp:t,root:r})=>(r.addEventListener("mousemove",e),r.addEventListener("mouseup",t),{removeListeners:()=>{r.removeEventListener("mousemove",e),r.removeEventListener("mouseup",t)}}),vI=()=>{const e=b.useRef(null),t=ye(v=>v.dragNodeType),r=ye(v=>v.flowWrapperElement),s=ye(v=>v.viewport.zoom),{addNode:i,getRootElement:a,setDragNodeType:c}=Ze(),u=a();if(b.useEffect(()=>{if(e.current&&t&&r&&u){let v=!1;const x=mI*s,_=e.current,w=yE(r).isCursorIntersecting,S=gI(r),{resetDragNodeStyles:N,updateDragNodeStyles:O}=EI(_),{removeListeners:D}=yI({handleMouseMove:T=>{const{clientX:A,clientY:L}=T,F=A-x,K=L-x;v=w({clientX:A,clientY:L})&&!S.some(Q=>Q({clientX:A,clientY:L})),O({isOverDropTarget:v,scale:v?s:1,xPos:F,yPos:K})},handleMouseUp:T=>{if(v){const A=r.getBoundingClientRect();i({nodeType:t,x:T.clientX-A.left-x,y:T.clientY-A.top-x})}c(void 0)},root:u});return()=>{D(),N()}}},[i,t,r,u,c,s]),!t)return null;const f=tE[t],p=Fm[t](),m=Le(),E={...p,initial:!1,valid:!0};return h.jsx("section",{className:"react-flow__node fixed left-0 top-0",ref:e,style:EE,children:h.jsx(f,{data:E,dragging:!0,id:m,isConnectable:!0,selected:!0,type:t,xPos:0,yPos:0,zIndex:0})})},xI={};function vE(e,t){let r;try{r=e()}catch{return}return{getItem:i=>{var a;const c=f=>f===null?null:JSON.parse(f,void 0),u=(a=r.getItem(i))!=null?a:null;return u instanceof Promise?u.then(c):c(u)},setItem:(i,a)=>r.setItem(i,JSON.stringify(a,void 0)),removeItem:i=>r.removeItem(i)}}const ni=e=>t=>{try{const r=e(t);return r instanceof Promise?r:{then(s){return ni(s)(r)},catch(s){return this}}}catch(r){return{then(s){return this},catch(s){return ni(s)(r)}}}},SI=(e,t)=>(r,s,i)=>{let a={getStorage:()=>localStorage,serialize:JSON.stringify,deserialize:JSON.parse,partialize:S=>S,version:0,merge:(S,N)=>({...N,...S}),...t},c=!1;const u=new Set,f=new Set;let p;try{p=a.getStorage()}catch{}if(!p)return e((...S)=>{console.warn(`[zustand persist middleware] Unable to update item '${a.name}', the given storage is currently unavailable.`),r(...S)},s,i);const m=ni(a.serialize),E=()=>{const S=a.partialize({...s()});let N;const O=m({state:S,version:a.version}).then(D=>p.setItem(a.name,D)).catch(D=>{N=D});if(N)throw N;return O},v=i.setState;i.setState=(S,N)=>{v(S,N),E()};const x=e((...S)=>{r(...S),E()},s,i);let _;const w=()=>{var S;if(!p)return;c=!1,u.forEach(O=>O(s()));const N=((S=a.onRehydrateStorage)==null?void 0:S.call(a,s()))||void 0;return ni(p.getItem.bind(p))(a.name).then(O=>{if(O)return a.deserialize(O)}).then(O=>{if(O)if(typeof O.version=="number"&&O.version!==a.version){if(a.migrate)return a.migrate(O.state,O.version);console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return O.state}).then(O=>{var D;return _=a.merge(O,(D=s())!=null?D:x),r(_,!0),E()}).then(()=>{N?.(_,void 0),c=!0,f.forEach(O=>O(_))}).catch(O=>{N?.(void 0,O)})};return i.persist={setOptions:S=>{a={...a,...S},S.getStorage&&(p=S.getStorage())},clearStorage:()=>{p?.removeItem(a.name)},getOptions:()=>a,rehydrate:()=>w(),hasHydrated:()=>c,onHydrate:S=>(u.add(S),()=>{u.delete(S)}),onFinishHydration:S=>(f.add(S),()=>{f.delete(S)})},w(),_||x},_I=(e,t)=>(r,s,i)=>{let a={storage:vE(()=>localStorage),partialize:w=>w,version:0,merge:(w,S)=>({...S,...w}),...t},c=!1;const u=new Set,f=new Set;let p=a.storage;if(!p)return e((...w)=>{console.warn(`[zustand persist middleware] Unable to update item '${a.name}', the given storage is currently unavailable.`),r(...w)},s,i);const m=()=>{const w=a.partialize({...s()});return p.setItem(a.name,{state:w,version:a.version})},E=i.setState;i.setState=(w,S)=>{E(w,S),m()};const v=e((...w)=>{r(...w),m()},s,i);let x;const _=()=>{var w,S;if(!p)return;c=!1,u.forEach(O=>{var D;return O((D=s())!=null?D:v)});const N=((S=a.onRehydrateStorage)==null?void 0:S.call(a,(w=s())!=null?w:v))||void 0;return ni(p.getItem.bind(p))(a.name).then(O=>{if(O)if(typeof O.version=="number"&&O.version!==a.version){if(a.migrate)return a.migrate(O.state,O.version);console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return O.state}).then(O=>{var D;return x=a.merge(O,(D=s())!=null?D:v),r(x,!0),m()}).then(()=>{N?.(x,void 0),x=s(),c=!0,f.forEach(O=>O(x))}).catch(O=>{N?.(void 0,O)})};return i.persist={setOptions:w=>{a={...a,...w},w.storage&&(p=w.storage)},clearStorage:()=>{p?.removeItem(a.name)},getOptions:()=>a,rehydrate:()=>_(),hasHydrated:()=>c,onHydrate:w=>(u.add(w),()=>{u.delete(w)}),onFinishHydration:w=>(f.add(w),()=>{f.delete(w)})},a.skipHydration||_(),x||v},wI=(e,t)=>"getStorage"in t||"serialize"in t||"deserialize"in t?((xI?"staging":void 0)!=="production"&&console.warn("[DEPRECATED] `getStorage`, `serialize` and `deserialize` options are deprecated. Use `storage` option instead."),SI(e,t)):_I(e,t),xE=window,SE={showAllNodes:!1,showDevOptions:!1},Xr=Do()(wI((e,t)=>({...SE,actions:{getFlagNames:()=>{const r=t();return Object.keys(r).filter(s=>s!=="actions")},toggleFlag:r=>e(s=>({...s,[r]:!s[r]}))}}),{name:"flags",partialize:e=>Object.fromEntries(Object.entries(e).filter(([t])=>t!=="actions")),storage:vE(()=>localStorage),version:0})),_E=()=>Xr.getState().actions;Xr.subscribe(e=>{console.log("feature flags changed",e)});const NI=e=>{const t=(s,i)=>{Xr.setState(a=>({...a,[s]:i}))},r=s=>{const i=Xr.getState(),a={...s};return Object.entries(i).forEach(([c,u])=>{c in a&&typeof u=="boolean"&&(a[c]=u)}),a};if(xE){const s=new Proxy(r(e),{get:(i,a)=>Reflect.get(i,a),set:(i,a,c)=>{if(typeof c=="boolean"&&a in i)t(a,c);else throw new Error("unknown flag");return Reflect.set(i,a,c)}});xE.swFlags=s}},RI=()=>NI(SE),Bl={currentColor:{negative:"fill-current",primary:"fill-current"},light:{negative:"fill-negative",primary:"fill-primary"}},TI={"2xl":"w-[2em] h-[2em]","2xs":"w-[0.75em] h-[0.75em]",lg:"w-[1.25em] h-[1.25em]",md:"w-[1em] h-[1em]",sm:"w-[0.875em] h-[0.875em]",xl:"w-[1.5em] h-[1.5em]",xs:"w-[0.75em] h-[0.75em]"},OI=b.forwardRef(function({className:t="",size:r="md",type:s="light"},i){const a=TI[r];return h.jsxs("svg",{"aria-hidden":"true",className:`${a} ${t}`,focusable:"false",fill:"none",ref:i,role:"img",viewBox:"0 0 64 73",xmlns:"http://www.w3.org/2000/svg",children:[h.jsx("path",{d:"M63.9998 46.5209C63.9998 48.596 63.4369 49.9545 62.3171 51.0736C55.6065 57.7826 48.8931 64.4815 42.177 71.1703C39.841 73.495 36.4374 73.6097 34.1234 71.4843C31.6868 69.2442 31.5903 65.569 33.9726 63.1356C36.9983 60.0482 40.0681 57.003 43.132 53.9537C46.8137 50.2907 50.5034 46.6369 54.2012 42.9926C55.9925 41.2315 58.3929 40.7666 60.5902 41.7669C62.7876 42.7672 63.9315 44.5686 63.9998 46.5209Z",className:Bl[s].primary}),h.jsx("path",{d:"M0.000812669 25.3858C0.0329789 24.3372 0.589857 23.0088 1.68351 21.9159C8.37007 15.2378 15.058 8.56035 21.7472 1.88357C23.1384 0.492799 24.7789 -0.219695 26.739 0.0600696C29.061 0.402228 30.6834 1.69438 31.4393 3.92847C32.1952 6.16256 31.6725 8.18129 30.032 9.85183C26.8355 13.1003 23.5988 16.3166 20.3822 19.5329C16.868 23.0309 13.3444 26.5196 9.81152 29.9989C8.01423 31.762 5.61985 32.1947 3.41647 31.2307C1.27339 30.2988 -0.0373848 28.2438 0.000812669 25.3858Z",className:Bl[s].primary}),h.jsx("path",{d:"M4.59424 32.9836C5.35618 32.9494 5.98342 32.9675 6.60463 32.8849C8.18055 32.688 9.64041 31.953 10.738 30.8038C12.0206 29.4936 13.3093 28.1873 14.6241 26.8489C14.8714 27.0683 15.0262 27.191 15.1609 27.3279C20.1078 32.2791 25.054 37.2324 29.9995 42.1876C31.6219 43.8179 32.1909 45.7843 31.5395 47.9983C30.9123 50.1257 29.4507 51.4883 27.2835 51.9774C25.4078 52.398 23.6186 52.0398 22.2435 50.6751C16.3671 44.8484 10.551 38.9673 4.59424 32.9836Z",className:Bl[s].negative}),h.jsx("path",{d:"M59.4545 40.0944C56.4389 39.7865 54.2878 40.9519 52.4744 42.9585C51.4933 44.0454 50.4178 45.0477 49.3583 46.1164C49.1372 45.9152 48.9824 45.7964 48.8436 45.6555C43.8914 40.7003 38.9418 35.7464 33.9949 30.7938C32.3745 29.1635 31.8076 27.1931 32.4751 24.9791C33.1164 22.8537 34.5799 21.4951 36.7532 21.0181C38.6751 20.5955 40.4623 21.0181 41.8676 22.4109C47.6307 28.1229 53.3677 33.8571 59.0785 39.6134C59.163 39.6899 59.2273 39.7966 59.4545 40.0944Z",className:Bl[s].negative})]})}),CI={[C.FLOW_DATA_VERSION]:$s,[C.PKG_VERSION]:YR},AI=()=>{const e=()=>{r.current?.open===!1&&r.current.showModal()},t=()=>{r.current?.open&&r.current.close()},r=te.useRef(null);return h.jsxs(h.Fragment,{children:[h.jsxs("button",{className:"group flex items-center justify-center gap-x-2 text-foreground/50 transition-colors hover:text-foreground/70",onClick:e,children:[h.jsx(OI,{className:"text-foreground/40 transition-colors group-hover:text-foreground/50",size:"xl",type:"currentColor"}),h.jsx("span",{className:"text-xs font-semibold",children:M(C.ABOUT)})]}),h.jsx("dialog",{ref:r,className:"aspect-[5/4] w-72 max-w-xs overflow-hidden rounded-lg border border-foreground/10 bg-background text-foreground shadow-xl backdrop:backdrop-blur-sm backdrop:backdrop-brightness-95",children:h.jsxs("div",{className:"h-full px-2 pb-10",children:[h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsx("h2",{className:"text-2xl leading-10",children:M(C.ABOUT)}),h.jsxs("button",{className:"my-0.5 -mr-1.5 rounded-md py-0.5 px-1.5 ",onClick:t,children:[h.jsx("span",{className:"sr-only",children:M(C.CLOSE)}),h.jsx(Ce,{tag:"xmark",size:"lg"})]})]}),h.jsxs("div",{className:"h-full overflow-y-auto",children:[h.jsx("ul",{className:"mt-1 flex flex-col items-center justify-center text-sm",children:Object.entries(CI).map(([s,i])=>h.jsx("li",{className:"text-foreground/70",children:h.jsxs("p",{children:[M(s),": ",i]})},s))}),h.jsx("div",{className:"mt-6 flex items-center justify-center ",children:h.jsx("button",{className:"rounded-md border border-foreground/10 bg-positive px-3.5 py-2.5 font-bold tracking-widest text-background",onClick:t,children:M(C.CLOSE)})})]})]})})]})},II={deploy:C.STATUS_DEPLOY,deployed:C.STATUS_DEPLOYED,deploying:C.STATUS_DEPLOYING,error:C.STATUS_DEPLOY_ERROR},wE={deploy:"text-background border-hidden hover:bg-primary/90",deployed:"bg-background text-positive border-positive/20",deploying:"bg-background text-foreground/50 border-foreground/10",error:"bg-negative text-background border-hidden"},bI=()=>{const e=ye(O=>O.deployFlowStatus),t=ye(O=>O.deployFlowURL),r=ye(O=>O.detachedMode),s=ye(O=>O.documentVersion),i=ye(O=>O.httpError),a=ye(O=>O.saveFlowStatus),{deployFlow:c,getValidationWarnings:u,setShowDeployWarning:f}=Ze(),p={error:void 0,prevDocVersion:s},[m,E]=ed(p),v=II[e],x=async()=>{if(u().size>0)f(!0);else try{E({error:void 0}),await c()}catch(O){O instanceof Error?E({error:O.message}):E({error:"Failed to deploy!"})}};b.useEffect(()=>{a==="saved"&&s!==m.prevDocVersion&&E({prevDocVersion:s})},[m.prevDocVersion,s,a,E]);const _=a!=="saved"||e==="deployed"||e==="deploying",w=i==="document-sync"?wE.deploying:wE[e];let S="";e==="deploy"&&(S=a==="saved"?"bg-primary":"bg-focus");const N=`${S} ${w}`;return!t||r?null:h.jsxs("button",{"data-testid":"cfb__deploy-button",className:`flex items-center justify-center rounded border px-1.5 py-0.5
|
|
66
|
+
${m} ${t?"animate-from-bottom":""} ${s}`,ref:f,role:c,children:[h.jsxs("div",{className:"flex items-center justify-center gap-x-2",children:[h.jsx(Ce,{className:"flex-shrink-0 self-start",tag:i}),h.jsx("p",{className:"text-xs font-semibold",children:a})]}),r]})}),KA=()=>{const{addToast:e,restoreDeployedFlow:t,cancelDetachedMode:r}=Ze();if(!ye(c=>c.showDeployedHistoryToast))return null;const i=()=>{t(),e({message:M(C.VERSION_RESTORED),status:"success"})},a=()=>{r()};return h.jsx(dE,{animate:!1,className:"gap-x-14",message:M(C.PREVIEW_DEPLOYED_VERSION),role:"dialog",children:h.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-x-2 gap-y-1",children:[h.jsx("button",{className:"rounded bg-primary px-1.5 py-0.5 text-xs font-medium text-background transition-colors hover:bg-primary/90",onClick:i,children:M(C.RESTORE_THIS_VERSION)}),h.jsx("button",{className:"rounded bg-secondary/50 px-1.5 py-0.5 text-xs font-medium text-background transition-colors hover:bg-secondary/40",onClick:a,children:M(C.CANCEL)})]})})},fE=({onKeyPress:e})=>{const t=Oo(["Escape","Esc"]);return b.useEffect(()=>{t&&typeof e=="function"&&e()},[t,e]),{isPressed:t}},XA={offset:[0,.5,1],opacity:[1,0,0],pointerEvents:["none","none","auto"],transform:["scale(1.1) translateY(0%)","scale(0.5) translateY(-100%)"]},QA={duration:ZR*2,easing:"ease-in-out",fill:"forwards"},qA=({durationMs:e,id:t,permanent:r})=>{const s=e??JR,[i,a]=b.useState(null),{deleteToast:c}=Ze(),u=b.useCallback(()=>{let f;const p=()=>c(t);return i instanceof HTMLElement?(f=i.animate(XA,QA),f.addEventListener("finish",p,{once:!0})):p(),()=>f?.removeEventListener("finish",p)},[t,c,i]);return fE({onKeyPress:u}),b.useEffect(()=>{if(r)return;let f,p;const m=()=>{clearTimeout(f)},E=()=>{m(),f=setTimeout(()=>{p=u()},s)};return E(),i instanceof HTMLElement&&(i.addEventListener("mouseenter",m),i.addEventListener("mouseleave",E)),()=>{m(),i instanceof HTMLElement&&(i.removeEventListener("mouseenter",m),i.removeEventListener("mouseleave",E),p?.())}},[u,s,r,i]),{deleteToastCallback:u,setToastRef:a,toastRef:i}},pE=({durationMs:e,id:t,message:r,permanent:s,status:i})=>{const{deleteToastCallback:a,setToastRef:c}=qA({durationMs:e,id:t,permanent:s});return h.jsx(dE,{className:"w-full max-w-sm",iconTag:i==="success"?"circle-check":"circle-exclamation",message:r,ref:c,status:i,children:h.jsxs("button",{className:"flex-shrink-0 self-start opacity-40 transition-opacity hover:opacity-70",onClick:a,children:[h.jsx(Ce,{tag:"circle-xmark",size:"xl"}),h.jsx("span",{className:"sr-only",children:M(C.CLOSE)})]})})},ZA={error:pE,success:pE},JA=()=>{const e=ye(r=>r.toastsMap);if(e.size===0)return null;const t=Array.from(e.values());return h.jsx("div",{className:"flex w-full flex-col items-center gap-y-1",children:t.map(r=>{const s=ZA[r.status];return h.jsx(s,{durationMs:r.durationMs,id:r.id,message:r.message,permanent:r.permanent,status:r.status},r.id)})})},eI=({asRole:e="alert",open:t=!1,type:r="overlay"})=>{const[s,i]=te.useState(t);b.useEffect(()=>{i(t)},[t]);const a=b.useCallback(()=>i(!1),[]),c=b.useCallback(()=>i(!0),[]);return{asRole:e,closeContainer:a,isOpen:s,openContainer:c,type:r}},hE=b.createContext(null),od=()=>{const e=b.useContext(hE);if(e==null)throw new Error("Toast components must be wrapped in <ToastContainer />");return e},tI=({children:e,...t})=>{const r=eI(t);return h.jsx(hE.Provider,{value:r,children:e})},mE=({iconAs:e,title:t,children:r})=>{const{asRole:s}=od();return h.jsxs("div",{className:"max-w-xl rounded-lg bg-foreground p-4 text-background shadow-2xl transition-[transform,box-shadow] duration-500 will-change-transform hover:shadow-none",role:s,children:[h.jsxs("h2",{className:"text-lg font-semibold leading-6 tracking-wide",children:[h.jsx("span",{className:"mr-2",children:h.jsx(Ce,{tag:e??"circle-exclamation"})}),t]}),h.jsx("div",{className:"mt-2 text-sm leading-5",children:r})]})},nI=({children:e})=>{const{closeContainer:t,isOpen:r,type:s}=od(),{getRootElement:i}=Ze(),a=i(),c=b.useRef(null);return b.useEffect(()=>{if(!c.current)return;let u,f;const p=m=>{if(m.key==="Escape"&&t(),m.key==="Tab"){const E=document.activeElement?.shadowRoot?.activeElement;m.shiftKey?E===u&&(f?.focus(),m.preventDefault()):E===f&&(u?.focus(),m.preventDefault())}};if(s==="overlay"){const m=c.current.querySelectorAll("button");u=m[0],f=m[m.length-1],f?.focus(),document.addEventListener("keydown",p)}return()=>{document.removeEventListener("keydown",p)}},[t,s]),r?Bc.createPortal(h.jsx("section",{className:`flex justify-center ${s==="overlay"?"fixed top-0 z-50 h-full w-full items-start px-6 py-36 backdrop-blur-sm backdrop-grayscale":"absolute top-10 left-1/2 z-10 -translate-x-1/2 translate-y-1/2 items-center"}`,ref:s==="overlay"?c:void 0,children:e}),a):null},gE=({asRole:e,open:t,children:r,type:s})=>h.jsx(tI,{asRole:e,open:t,type:s,children:h.jsx(nI,{children:r})}),rI=()=>{const t=ye(r=>r.httpError)===Am;return t?h.jsx(gE,{asRole:"dialog",open:t,type:"overlay",children:h.jsx(mE,{title:M(C.DOCUMENT_OUT_OF_SYNC),children:h.jsx(oI,{})})}):null},oI=()=>{const{closeContainer:e}=od(),t=()=>{window.location.reload()};return h.jsxs(h.Fragment,{children:[Ul(C.TOAST_DOCUMENT_OUT_OF_SYNC),h.jsxs("div",{className:"mt-11 flex items-center justify-center gap-x-6",children:[h.jsx("button",{className:"rounded-md border border-background bg-foreground px-3.5 py-2.5 font-bold tracking-widest text-background",onClick:e,children:M(C.IGNORE)}),h.jsx("button",{className:"rounded-md border border-background bg-positive/70 px-3.5 py-2.5 font-bold tracking-widest text-background",onClick:t,children:M(C.RESYNC)})]})]})},sI=Qe(),iI=()=>{const e=ye(t=>t.showDeployWarning);return h.jsx(gE,{asRole:"dialog",open:e,type:"overlay",children:h.jsx(mE,{title:M(C.DEPLOY_WARNING),children:h.jsx(lI,{})})})},lI=()=>{const{deployFlow:e,setShowDeployWarning:t,setShowValidationWarnings:r}=Ze(),s=()=>{t(!1),r(!0)},i=()=>{t(!1)},a=()=>{e().catch(c=>{sI.error(c)}),i()};return h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"mb-4",children:Ul(C.TOAST_DEPLOY_WARNING)}),h.jsx(cg,{onClickListItem:s}),h.jsxs("div",{className:"mt-11 flex items-center justify-center gap-x-6",children:[h.jsx("button",{className:"rounded-md border border-background bg-foreground px-3.5 py-2.5 font-bold tracking-widest text-background",onClick:i,children:M(C.CANCEL)}),h.jsx("button",{className:"rounded-md border border-background bg-positive/70 px-3.5 py-2.5 font-bold tracking-widest text-background",onClick:a,children:M(C.DEPLOY)})]})]})},aI="react-flow__controls-button",cI="min-w-[3.625rem] cursor-auto select-auto text-center hover:bg-background active:bg-background",uI="hidden sm:flex",dI=b.forwardRef(function({asTag:t="div",children:r,className:s="",hiddenSmallScreen:i=!1,...a},c){const u=t,p=`${aI} ${u==="button"?"":cI} ${i?uI:""} ${s}`;return h.jsx(u,{className:p,ref:c,...a,children:r})}),fI=()=>{const e=ye(c=>c.showValidationWarnings),t=ye(c=>c.validationWarnings),r=ye(c=>c.detachedMode),{setShowValidationWarnings:s}=Ze(),i=()=>s(!e),a=()=>{e&&s(!1)};return!t.size||r?(a(),null):h.jsx(gr,{onOpenChange:s,open:e,outsidePress:!1,placement:"bottom-start",role:"dialog",trigger:h.jsxs(dI,{className:"text-xs",asTag:"button",onClick:i,hiddenSmallScreen:!0,children:[M(C.WARNING),h.jsxs("div",{className:"flex items-center justify-center pl-1",children:[h.jsx("span",{className:"sr-only",children:M(C.MORE_INFO_STATUS_ERROR)}),h.jsx(Ce,{className:"text-warning",tag:"circle-exclamation"})]})]}),children:h.jsx(cg,{children:h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("h2",{className:"text-xs font-semibold",children:[h.jsx(Ce,{className:"mr-1",tag:"circle-exclamation"}),M(C.CAUTION)]}),h.jsxs("button",{className:"my-0.5 rounded-md py-0.5 px-1.5",onClick:a,children:[h.jsx("span",{className:"sr-only",children:M(C.CLOSE)}),h.jsx(Ce,{tag:"xmark",size:"lg"})]})]})})})},pI=()=>{const e=ye(s=>s.isDraggingNode),t=ye(s=>s.showInteractiveControl),r=s=>{ye.setState({isInteractiveControlOn:s})};return h.jsx(MR,{className:`mt-2.5 rounded-[0.25rem] ${e?"group/control-buttons":""}`,position:"top-left",onInteractiveChange:r,showInteractive:t,children:h.jsx(fI,{})})},hI=".react-flow__panel",mI=16,EE={cursor:"no-drop",transform:"translate(0px, 0px) scale(1)",visibility:"hidden",zIndex:"5"},yE=e=>{const t=e.getBoundingClientRect();return{isCursorIntersecting:({clientX:r,clientY:s})=>t.top<=s&&t.bottom>=s&&t.left<=r&&t.right>=r}},gI=e=>{const t=e.querySelectorAll(hI);return Array.from(t).map(r=>yE(r).isCursorIntersecting)},EI=e=>({resetDragNodeStyles:()=>{Object.entries(EE).forEach(([t,r])=>{e.style[t]=r})},updateDragNodeStyles:({isOverDropTarget:t,scale:r,xPos:s,yPos:i})=>{e.style.visibility="visible",e.style.cursor=t?"grabbing":"no-drop",e.style.transform=`translate(${s}px, ${i}px) scale(${r})`}}),yI=({handleMouseMove:e,handleMouseUp:t,root:r})=>(r.addEventListener("mousemove",e),r.addEventListener("mouseup",t),{removeListeners:()=>{r.removeEventListener("mousemove",e),r.removeEventListener("mouseup",t)}}),vI=()=>{const e=b.useRef(null),t=ye(v=>v.dragNodeType),r=ye(v=>v.flowWrapperElement),s=ye(v=>v.viewport.zoom),{addNode:i,getRootElement:a,setDragNodeType:c}=Ze(),u=a();if(b.useEffect(()=>{if(e.current&&t&&r&&u){let v=!1;const x=mI*s,_=e.current,w=yE(r).isCursorIntersecting,S=gI(r),{resetDragNodeStyles:N,updateDragNodeStyles:O}=EI(_),{removeListeners:D}=yI({handleMouseMove:T=>{const{clientX:A,clientY:L}=T,F=A-x,K=L-x;v=w({clientX:A,clientY:L})&&!S.some(Q=>Q({clientX:A,clientY:L})),O({isOverDropTarget:v,scale:v?s:1,xPos:F,yPos:K})},handleMouseUp:T=>{if(v){const A=r.getBoundingClientRect();i({nodeType:t,x:T.clientX-A.left-x,y:T.clientY-A.top-x})}c(void 0)},root:u});return()=>{D(),N()}}},[i,t,r,u,c,s]),!t)return null;const f=tE[t],p=Fm[t](),m=Le(),E={...p,initial:!1,valid:!0};return h.jsx("section",{className:"react-flow__node fixed left-0 top-0",ref:e,style:EE,children:h.jsx(f,{data:E,dragging:!0,id:m,isConnectable:!0,selected:!0,type:t,xPos:0,yPos:0,zIndex:0})})},xI={};function vE(e,t){let r;try{r=e()}catch{return}return{getItem:i=>{var a;const c=f=>f===null?null:JSON.parse(f,void 0),u=(a=r.getItem(i))!=null?a:null;return u instanceof Promise?u.then(c):c(u)},setItem:(i,a)=>r.setItem(i,JSON.stringify(a,void 0)),removeItem:i=>r.removeItem(i)}}const ni=e=>t=>{try{const r=e(t);return r instanceof Promise?r:{then(s){return ni(s)(r)},catch(s){return this}}}catch(r){return{then(s){return this},catch(s){return ni(s)(r)}}}},SI=(e,t)=>(r,s,i)=>{let a={getStorage:()=>localStorage,serialize:JSON.stringify,deserialize:JSON.parse,partialize:S=>S,version:0,merge:(S,N)=>({...N,...S}),...t},c=!1;const u=new Set,f=new Set;let p;try{p=a.getStorage()}catch{}if(!p)return e((...S)=>{console.warn(`[zustand persist middleware] Unable to update item '${a.name}', the given storage is currently unavailable.`),r(...S)},s,i);const m=ni(a.serialize),E=()=>{const S=a.partialize({...s()});let N;const O=m({state:S,version:a.version}).then(D=>p.setItem(a.name,D)).catch(D=>{N=D});if(N)throw N;return O},v=i.setState;i.setState=(S,N)=>{v(S,N),E()};const x=e((...S)=>{r(...S),E()},s,i);let _;const w=()=>{var S;if(!p)return;c=!1,u.forEach(O=>O(s()));const N=((S=a.onRehydrateStorage)==null?void 0:S.call(a,s()))||void 0;return ni(p.getItem.bind(p))(a.name).then(O=>{if(O)return a.deserialize(O)}).then(O=>{if(O)if(typeof O.version=="number"&&O.version!==a.version){if(a.migrate)return a.migrate(O.state,O.version);console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return O.state}).then(O=>{var D;return _=a.merge(O,(D=s())!=null?D:x),r(_,!0),E()}).then(()=>{N?.(_,void 0),c=!0,f.forEach(O=>O(_))}).catch(O=>{N?.(void 0,O)})};return i.persist={setOptions:S=>{a={...a,...S},S.getStorage&&(p=S.getStorage())},clearStorage:()=>{p?.removeItem(a.name)},getOptions:()=>a,rehydrate:()=>w(),hasHydrated:()=>c,onHydrate:S=>(u.add(S),()=>{u.delete(S)}),onFinishHydration:S=>(f.add(S),()=>{f.delete(S)})},w(),_||x},_I=(e,t)=>(r,s,i)=>{let a={storage:vE(()=>localStorage),partialize:w=>w,version:0,merge:(w,S)=>({...S,...w}),...t},c=!1;const u=new Set,f=new Set;let p=a.storage;if(!p)return e((...w)=>{console.warn(`[zustand persist middleware] Unable to update item '${a.name}', the given storage is currently unavailable.`),r(...w)},s,i);const m=()=>{const w=a.partialize({...s()});return p.setItem(a.name,{state:w,version:a.version})},E=i.setState;i.setState=(w,S)=>{E(w,S),m()};const v=e((...w)=>{r(...w),m()},s,i);let x;const _=()=>{var w,S;if(!p)return;c=!1,u.forEach(O=>{var D;return O((D=s())!=null?D:v)});const N=((S=a.onRehydrateStorage)==null?void 0:S.call(a,(w=s())!=null?w:v))||void 0;return ni(p.getItem.bind(p))(a.name).then(O=>{if(O)if(typeof O.version=="number"&&O.version!==a.version){if(a.migrate)return a.migrate(O.state,O.version);console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return O.state}).then(O=>{var D;return x=a.merge(O,(D=s())!=null?D:v),r(x,!0),m()}).then(()=>{N?.(x,void 0),x=s(),c=!0,f.forEach(O=>O(x))}).catch(O=>{N?.(void 0,O)})};return i.persist={setOptions:w=>{a={...a,...w},w.storage&&(p=w.storage)},clearStorage:()=>{p?.removeItem(a.name)},getOptions:()=>a,rehydrate:()=>_(),hasHydrated:()=>c,onHydrate:w=>(u.add(w),()=>{u.delete(w)}),onFinishHydration:w=>(f.add(w),()=>{f.delete(w)})},a.skipHydration||_(),x||v},wI=(e,t)=>"getStorage"in t||"serialize"in t||"deserialize"in t?((xI?"production":void 0)!=="production"&&console.warn("[DEPRECATED] `getStorage`, `serialize` and `deserialize` options are deprecated. Use `storage` option instead."),SI(e,t)):_I(e,t),xE=window,SE={showAllNodes:!1,showDevOptions:!1},Xr=Do()(wI((e,t)=>({...SE,actions:{getFlagNames:()=>{const r=t();return Object.keys(r).filter(s=>s!=="actions")},toggleFlag:r=>e(s=>({...s,[r]:!s[r]}))}}),{name:"flags",partialize:e=>Object.fromEntries(Object.entries(e).filter(([t])=>t!=="actions")),storage:vE(()=>localStorage),version:0})),_E=()=>Xr.getState().actions;Xr.subscribe(e=>{console.log("feature flags changed",e)});const NI=e=>{const t=(s,i)=>{Xr.setState(a=>({...a,[s]:i}))},r=s=>{const i=Xr.getState(),a={...s};return Object.entries(i).forEach(([c,u])=>{c in a&&typeof u=="boolean"&&(a[c]=u)}),a};if(xE){const s=new Proxy(r(e),{get:(i,a)=>Reflect.get(i,a),set:(i,a,c)=>{if(typeof c=="boolean"&&a in i)t(a,c);else throw new Error("unknown flag");return Reflect.set(i,a,c)}});xE.swFlags=s}},RI=()=>NI(SE),Bl={currentColor:{negative:"fill-current",primary:"fill-current"},light:{negative:"fill-negative",primary:"fill-primary"}},TI={"2xl":"w-[2em] h-[2em]","2xs":"w-[0.75em] h-[0.75em]",lg:"w-[1.25em] h-[1.25em]",md:"w-[1em] h-[1em]",sm:"w-[0.875em] h-[0.875em]",xl:"w-[1.5em] h-[1.5em]",xs:"w-[0.75em] h-[0.75em]"},OI=b.forwardRef(function({className:t="",size:r="md",type:s="light"},i){const a=TI[r];return h.jsxs("svg",{"aria-hidden":"true",className:`${a} ${t}`,focusable:"false",fill:"none",ref:i,role:"img",viewBox:"0 0 64 73",xmlns:"http://www.w3.org/2000/svg",children:[h.jsx("path",{d:"M63.9998 46.5209C63.9998 48.596 63.4369 49.9545 62.3171 51.0736C55.6065 57.7826 48.8931 64.4815 42.177 71.1703C39.841 73.495 36.4374 73.6097 34.1234 71.4843C31.6868 69.2442 31.5903 65.569 33.9726 63.1356C36.9983 60.0482 40.0681 57.003 43.132 53.9537C46.8137 50.2907 50.5034 46.6369 54.2012 42.9926C55.9925 41.2315 58.3929 40.7666 60.5902 41.7669C62.7876 42.7672 63.9315 44.5686 63.9998 46.5209Z",className:Bl[s].primary}),h.jsx("path",{d:"M0.000812669 25.3858C0.0329789 24.3372 0.589857 23.0088 1.68351 21.9159C8.37007 15.2378 15.058 8.56035 21.7472 1.88357C23.1384 0.492799 24.7789 -0.219695 26.739 0.0600696C29.061 0.402228 30.6834 1.69438 31.4393 3.92847C32.1952 6.16256 31.6725 8.18129 30.032 9.85183C26.8355 13.1003 23.5988 16.3166 20.3822 19.5329C16.868 23.0309 13.3444 26.5196 9.81152 29.9989C8.01423 31.762 5.61985 32.1947 3.41647 31.2307C1.27339 30.2988 -0.0373848 28.2438 0.000812669 25.3858Z",className:Bl[s].primary}),h.jsx("path",{d:"M4.59424 32.9836C5.35618 32.9494 5.98342 32.9675 6.60463 32.8849C8.18055 32.688 9.64041 31.953 10.738 30.8038C12.0206 29.4936 13.3093 28.1873 14.6241 26.8489C14.8714 27.0683 15.0262 27.191 15.1609 27.3279C20.1078 32.2791 25.054 37.2324 29.9995 42.1876C31.6219 43.8179 32.1909 45.7843 31.5395 47.9983C30.9123 50.1257 29.4507 51.4883 27.2835 51.9774C25.4078 52.398 23.6186 52.0398 22.2435 50.6751C16.3671 44.8484 10.551 38.9673 4.59424 32.9836Z",className:Bl[s].negative}),h.jsx("path",{d:"M59.4545 40.0944C56.4389 39.7865 54.2878 40.9519 52.4744 42.9585C51.4933 44.0454 50.4178 45.0477 49.3583 46.1164C49.1372 45.9152 48.9824 45.7964 48.8436 45.6555C43.8914 40.7003 38.9418 35.7464 33.9949 30.7938C32.3745 29.1635 31.8076 27.1931 32.4751 24.9791C33.1164 22.8537 34.5799 21.4951 36.7532 21.0181C38.6751 20.5955 40.4623 21.0181 41.8676 22.4109C47.6307 28.1229 53.3677 33.8571 59.0785 39.6134C59.163 39.6899 59.2273 39.7966 59.4545 40.0944Z",className:Bl[s].negative})]})}),CI={[C.FLOW_DATA_VERSION]:$s,[C.PKG_VERSION]:YR},AI=()=>{const e=()=>{r.current?.open===!1&&r.current.showModal()},t=()=>{r.current?.open&&r.current.close()},r=te.useRef(null);return h.jsxs(h.Fragment,{children:[h.jsxs("button",{className:"group flex items-center justify-center gap-x-2 text-foreground/50 transition-colors hover:text-foreground/70",onClick:e,children:[h.jsx(OI,{className:"text-foreground/40 transition-colors group-hover:text-foreground/50",size:"xl",type:"currentColor"}),h.jsx("span",{className:"text-xs font-semibold",children:M(C.ABOUT)})]}),h.jsx("dialog",{ref:r,className:"aspect-[5/4] w-72 max-w-xs overflow-hidden rounded-lg border border-foreground/10 bg-background text-foreground shadow-xl backdrop:backdrop-blur-sm backdrop:backdrop-brightness-95",children:h.jsxs("div",{className:"h-full px-2 pb-10",children:[h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsx("h2",{className:"text-2xl leading-10",children:M(C.ABOUT)}),h.jsxs("button",{className:"my-0.5 -mr-1.5 rounded-md py-0.5 px-1.5 ",onClick:t,children:[h.jsx("span",{className:"sr-only",children:M(C.CLOSE)}),h.jsx(Ce,{tag:"xmark",size:"lg"})]})]}),h.jsxs("div",{className:"h-full overflow-y-auto",children:[h.jsx("ul",{className:"mt-1 flex flex-col items-center justify-center text-sm",children:Object.entries(CI).map(([s,i])=>h.jsx("li",{className:"text-foreground/70",children:h.jsxs("p",{children:[M(s),": ",i]})},s))}),h.jsx("div",{className:"mt-6 flex items-center justify-center ",children:h.jsx("button",{className:"rounded-md border border-foreground/10 bg-positive px-3.5 py-2.5 font-bold tracking-widest text-background",onClick:t,children:M(C.CLOSE)})})]})]})})]})},II={deploy:C.STATUS_DEPLOY,deployed:C.STATUS_DEPLOYED,deploying:C.STATUS_DEPLOYING,error:C.STATUS_DEPLOY_ERROR},wE={deploy:"text-background border-hidden hover:bg-primary/90",deployed:"bg-background text-positive border-positive/20",deploying:"bg-background text-foreground/50 border-foreground/10",error:"bg-negative text-background border-hidden"},bI=()=>{const e=ye(O=>O.deployFlowStatus),t=ye(O=>O.deployFlowURL),r=ye(O=>O.detachedMode),s=ye(O=>O.documentVersion),i=ye(O=>O.httpError),a=ye(O=>O.saveFlowStatus),{deployFlow:c,getValidationWarnings:u,setShowDeployWarning:f}=Ze(),p={error:void 0,prevDocVersion:s},[m,E]=ed(p),v=II[e],x=async()=>{if(u().size>0)f(!0);else try{E({error:void 0}),await c()}catch(O){O instanceof Error?E({error:O.message}):E({error:"Failed to deploy!"})}};b.useEffect(()=>{a==="saved"&&s!==m.prevDocVersion&&E({prevDocVersion:s})},[m.prevDocVersion,s,a,E]);const _=a!=="saved"||e==="deployed"||e==="deploying",w=i==="document-sync"?wE.deploying:wE[e];let S="";e==="deploy"&&(S=a==="saved"?"bg-primary":"bg-focus");const N=`${S} ${w}`;return!t||r?null:h.jsxs("button",{"data-testid":"cfb__deploy-button",className:`flex items-center justify-center rounded border px-1.5 py-0.5
|
|
67
67
|
text-xs font-medium transition-colors ${N}`,disabled:_,onClick:x,children:[M(v),h.jsx(gr,{placement:"right",trigger:h.jsx("span",{className:"flex items-center justify-center pl-1",role:"tooltip",tabIndex:0,children:e==="error"?h.jsx(Ce,{tag:"circle-exclamation"}):h.jsx(h.Fragment,{})}),children:e==="error"?M(C.MORE_INFO_DEPLOY_ERROR,{message:m.error}):M(C.MORE_INFO_DEPLOY)})]})},LI=()=>{const e=ye(t=>t.backButtonHref);return e?h.jsxs("a",{href:e,children:[h.jsx("span",{className:"sr-only",children:M(C.NAVIGATE_BACK)}),h.jsx(Ce,{tag:"arrow-left",className:"text-negative",size:"lg"})]}):null},DI=()=>{const e=ye(c=>c.showDeployedHistory),t=ye(c=>c.httpError==="document-sync"),{cancelDetachedMode:r,setShowDeployedHistory:s}=Ze(),i=()=>{e?r():s(!0)},a=e?"text-background bg-foreground":"text-foreground bg-foreground/10";return h.jsx(gr,{placement:"top",trigger:h.jsxs("button",{className:`flex items-center justify-center rounded border border-transparent p-1 transition-colors ${a}`,disabled:t,onClick:i,type:"button",children:[h.jsx("span",{className:"sr-only",children:M(C.VERSION_HISTORY)}),h.jsx(Ce,{tag:"clock-rotate-left",size:"xs"})]}),children:M(C.VERSION_HISTORY)})},kI=({isDisabled:e,isSelected:t,itemIndex:r,onClick:s,onSelected:i,relativeTimeSince:a,version:c})=>{const u=b.useRef(null),f=E=>{i(E)},p=()=>{t||(f(r),s(r))},m=E=>{E.preventDefault();const{key:v}=E;(v==="Enter"||v===" ")&&s(r),v==="ArrowUp"&&f(r-1),v==="ArrowDown"&&f(r+1)};return t&&(u.current?.focus({preventScroll:!0}),u.current?.scrollIntoView({block:"nearest"})),h.jsx("li",{className:`border-l-2 transition-colors ${t?"border-l-primary/50 bg-primary/10":"border-l-transparent bg-background hover:bg-primary/5"}`,children:h.jsxs("button",{"aria-selected":t?"true":"false",className:`flex w-full items-start gap-x-2 p-2 pr-4 ${e?"text-disabled":""}`,disabled:e,onClick:p,onKeyDown:m,type:"button",tabIndex:t?0:-1,ref:u,children:[h.jsx(Ce,{className:`p-1 ${t?"text-primary":"text-foreground/30"}`,tag:"dot-circle"}),h.jsxs("div",{className:"flex flex-col items-start justify-center",children:[h.jsx("h3",{className:"text-xs font-medium",children:M(C.VERSION_LIST_ITEM,{number:c})}),h.jsx("p",{className:"text-xxs",children:h.jsx("time",{children:a})})]})]})})},MI=200,NE=Qe(),PI=()=>{const e=ye(N=>N.deployedVersionsList),t=ye(N=>N.saveFlowStatus),r=ye(N=>N.showDeployedHistory),{cancelDetachedMode:s,getDeployedVersionsList:i,migrateAndLoadDeployedFlow:a}=Ze();fE({onKeyPress:r?s:void 0});const c=b.useRef(),[u,f]=b.useState("loading"),[p,m]=b.useState(null);p!==null&&!r&&m(null);const E=b.useCallback(N=>{N>=0&&N<=e.length-1?m(N):m(null)},[e.length]),v=b.useCallback(N=>{const O=c.current?.[N];O?(NE.info("load version",O.id),a(O)):NE.error("version not found")},[a]),x=b.useCallback(()=>{f("loading"),i({pageSize:MI}).then(N=>{f("loaded"),c.current=N}).catch(()=>{f("error"),c.current=void 0})},[i]);b.useLayoutEffect(()=>{r&&x()},[x,r]);const _=u==="error",w=e.length>0,S=t==="saved";return r?h.jsxs("div",{"data-testid":"cfb__deployed-versions-sidebar",className:"flex h-full flex-col py-3",children:[h.jsxs("section",{className:"flex items-center justify-between self-stretch px-4 pb-1",children:[h.jsxs("h2",{className:"flex items-center gap-1 text-tiny font-bold uppercase leading-none tracking-wide",children:[h.jsx(Ce,{className:"text-xs text-foreground/50",tag:"clock-rotate-left"}),M(C.VERSION_HISTORY)]}),h.jsxs("button",{className:"flex items-center justify-center px-0.5",onClick:s,type:"button",children:[h.jsx("span",{className:"sr-only",children:M(C.CLOSE)}),h.jsx(Ce,{tag:"xmark"})]})]}),h.jsxs("div",{className:`${w?"overflow-y-auto":"h-full"}`,children:[u!=="loaded"?h.jsxs("div",{className:`flex flex-col justify-center gap-y-4 p-4 text-sm leading-none tracking-wide text-foreground/50 ${w?"":"h-full"}`,children:[h.jsxs("div",{className:"flex flex-col items-center justify-center gap-y-2 gap-x-2",children:[_?h.jsx(Ce,{className:"text-negative",tag:"circle-exclamation"}):h.jsx(Ce,{className:"animate-spin",tag:"arrows-rotate"}),h.jsx("p",{"aria-live":_?"assertive":"polite",className:`${_?"text-negative":"font-bold uppercase text-foreground/50"}`,role:_?"alert":"status",children:M(_?C.ERROR_FETCHING_DEPLOYED_VERSIONS:C.STATUS_LOADING)})]}),_?h.jsx("div",{className:"flex w-full items-center justify-center",children:h.jsx("button",{className:"rounded border border-primary/50 bg-primary/10 px-3 py-1.5 text-sm font-bold leading-tight tracking-wider text-primary",onClick:x,type:"button",children:M(C.RESYNC)})}):null]}):null,!w&&u==="loaded"?h.jsx("div",{className:`flex h-full flex-col justify-center gap-y-4 p-4 text-sm leading-none tracking-wide text-foreground/50
|
|
68
68
|
`,children:h.jsxs("div",{className:"flex flex-col items-center justify-center gap-y-2 gap-x-2",children:[h.jsx(Ce,{tag:"circle-exclamation"}),Ul(C.NO_DEPLOYED_VERSIONS)]})}):null,w?h.jsx("ol",{children:e.map((N,O)=>h.jsx(kI,{itemIndex:O,isDisabled:!S,isSelected:O===p,onClick:v,onSelected:E,relativeTimeSince:N.relativeTimeSince,version:N.version},N.id))}):null]})]}):null},UI=()=>{const{getFlagNames:e}=_E();return h.jsxs("div",{className:"rounded-sm border border-gray-200 p-2",children:[h.jsx("h3",{className:"w-full",children:"Feature Flags"}),h.jsx("div",{className:"flex flex-col gap-y-2 py-2",children:e().map(t=>h.jsx(FI,{flagName:t},t))})]})},FI=({flagName:e})=>{const{toggleFlag:t}=_E(),s=Xr(i=>i[e])?"translate-x-5 bg-positive":"translate-x-0 bg-negative";return h.jsxs("label",{className:"flex cursor-pointer items-center",children:[h.jsxs("div",{className:"relative",children:[h.jsx("input",{type:"checkbox",className:"sr-only",onChange:()=>t(e)}),h.jsx("div",{className:"h-5 w-10 rounded-full bg-secondary/20",children:h.jsx("div",{className:`absolute left-1 top-1 h-3 w-3 rounded-full transition ${s}`})})]}),h.jsx("p",{className:"ml-3 text-sm font-medium",children:e})]})},jI=()=>{const[e,t]=b.useState(!1),r=()=>{t(s=>!s)};return h.jsx(gr,{open:e,onOpenChange:t,placement:"bottom",role:"dialog",trigger:h.jsxs("button",{className:"group flex items-center justify-center gap-x-2 text-foreground/50 transition-colors hover:text-foreground/70",onClick:r,children:[h.jsx(Ce,{className:"text-foreground/40 transition-colors group-hover:text-foreground/50",size:"xl",tag:"circle-question"}),h.jsxs("span",{className:"text-xs font-semibold",children:[M(C.HELP),h.jsx("span",{className:"sr-only",children:M(C.MORE_INFO_TESTING_YOUR_FLOW)})]})]}),children:h.jsxs("section",{className:"p-2",children:[h.jsx("h2",{className:"mb-4 text-2xl font-semibold",children:"Testing Your Call Flow"}),h.jsxs("div",{className:"text-sm",children:[h.jsx("p",{children:"To test the current working version (draft) of your Call Flow, follow these steps:"}),h.jsxs("ol",{className:"my-4 list-inside list-decimal",children:[h.jsxs("li",{className:"mb-2 list-item",children:["Go to the settings tab of the purchased phone number you want to use for testing: ",h.jsx("a",{className:"underline hover:text-background/80",href:"/phone_numbers",target:"_blank",rel:"noopener noreferrer",children:"Purchased Phone Numbers"})]}),h.jsxs("li",{className:"mb-2",children:["Choose the appropriate Call Flow for handling your calls: ",h.jsx("a",{className:"underline hover:text-background/80",href:"/call_flows",target:"_blank",rel:"noopener noreferrer",children:"Call Flows"})]}),h.jsx("li",{className:"mb-2",children:"Select the working version (draft) of the chosen Call Flow."}),h.jsx("li",{children:"When you make a call to the number, it should now execute the working version of your Call Flow upon answering."})]}),h.jsx("p",{className:"mt-4 mb-2",children:"In an upcoming update, you will be able to test your selected Call Flow directly from the Call Flow Builder, eliminating the need to manually associate the Call Flow with your number."})]})]})})},VI=(e,t)=>({label:M(Fl[e].label),nodes:Object.entries(Fl[e].nodes).reduce((r,[s,i])=>(((typeof i.active=="boolean"?i.active:i.active[GR])||t)&&r.push({deprecated:!!i.deprecated,title:M(i.label),type:s}),r),[]).sort((r,s)=>r.title.localeCompare(s.title))}),RE=Qe(),$I=["action","forwardTo","recording","input","decision"],HI=()=>{const e=Xr(c=>c.showAllNodes),t=ye(c=>c.isCanvasInteractive),{addNode:r,setDragNodeType:s}=Ze(),i=b.useCallback(c=>{c.preventDefault();const{nodeType:u}=c.currentTarget.dataset;u?r({nodeType:u}):RE.error("No nodeType found on click event")},[r]),a=b.useCallback(c=>{c.preventDefault();const{nodeType:u}=c.currentTarget.dataset;u?s(u):RE.error("No nodeType found on drag event")},[s]);return h.jsx("ul",{className:"py-3 px-2",id:"sidebar-node-list",children:$I.map(c=>h.jsx("li",{children:h.jsx(BI,{enableNodeButtons:t,group:c,handleOnClick:i,handleDragStart:a,showAllNodes:e})},c))})},BI=({enableNodeButtons:e=!0,group:t,handleOnClick:r,handleDragStart:s,showAllNodes:i})=>{const a=VI(t,i),c=`ngm-heading-${o1(a.label)}`;return h.jsxs(h.Fragment,{children:[h.jsx("h2",{className:"px-2 pb-1 text-tiny font-bold uppercase tracking-wide text-foreground/50",id:c,children:a.label}),h.jsx("ul",{"aria-labelledby":c,className:"flex flex-1 flex-col gap-y-1 pb-2",children:a.nodes.map(u=>h.jsx("li",{children:h.jsxs("button",{className:`flex w-full items-start gap-2 rounded-lg border border-dashed border-transparent bg-primary/5 p-2 transition-colors
|
|
69
69
|
hover:border-primary hover:bg-primary/20 enabled:hover:shadow-md`,"data-node-type":u.type,disabled:!e,draggable:e,onClick:e?r:void 0,onDragStart:e?s:void 0,children:[h.jsx(Ce,{tag:"circle-small",className:"text-primary"}),h.jsxs("span",{className:"text-left text-xs font-medium line-clamp-2",children:[u.title,u.deprecated&&h.jsxs("span",{className:"text-foreground/70",children:[" ",M(C.DEPRECATED)]})]})]})},u.type))})]})},zI=()=>{const{addToast:e,restoreDeployedFlow:t}=Ze(),r=ye(i=>i.workingFlowCopy),s=()=>{t(),e({message:M(C.VERSION_RESTORED),status:"success"})};return r?h.jsx("button",{className:`flex items-center justify-center rounded border bg-primary px-1.5 py-0.5 text-xs font-medium
|
|
70
|
-
text-background transition-colors hover:bg-primary/90`,onClick:s,children:M(C.RESTORE)}):null},WI={"awaiting-save":C.STATUS_SAVING,"document-sync":C.STATUS_LOCKED,error:C.STATUS_ERROR,initial:C.STATUS_LOADING,saved:C.STATUS_SAVED,saving:C.STATUS_SAVING},TE=e=>(e.preventDefault(),e.returnValue=""),OE=(e,t)=>e==="document-sync"?e:t,GI=()=>{const e=ye(v=>v.detachedMode),t=ye(v=>v.saveFlowStatus),r=ye(v=>v.httpError),[s,i]=b.useState(!0),[a,c]=b.useState(OE(r,t)),u=WI[a],f=t==="error"||r,p=OE(r,t),m=b.useRef(!1);b.useEffect(()=>{p==="initial"&&!m.current?(m.current=!0,c(p),i(!1),setTimeout(()=>{i(!0)},qR)):p!=="initial"&&s&&(m.current=!1,c(p))},[s,p]),b.useEffect(()=>{if(!(t==="saved"||r))return addEventListener("beforeunload",TE,{capture:!0}),()=>{removeEventListener("beforeunload",TE,{capture:!0})}},[r,t]);let E="";switch(!0){case f:E="px-1.5 py-0.5 bg-negative/20 text-negative";break;case a==="saved":E="text-foreground/50";break;default:E="px-1.5 py-0.5 bg-foreground/30 text-background"}return e?null:h.jsx("div",{"aria-live":f?"assertive":"polite","data-testid":"cfb__status",className:"flex",role:f?"alert":"status",children:h.jsxs("div",{className:`flex gap-x-1 rounded text-xxs ${E}`,children:[h.jsx("p",{children:u==="STATUS_SAVED"?h.jsx(YI,{}):M(u)}),f&&h.jsx(gr,{placement:"bottom",trigger:h.jsxs("div",{role:"tooltip",tabIndex:0,children:[h.jsx("span",{className:"sr-only",children:M(C.MORE_INFO_STATUS_ERROR)}),h.jsx(Ce,{tag:"circle-exclamation"})]}),children:M(r==="document-sync"?C.INFO_STATUS_ERROR_OUT_OF_SYNC:C.INFO_STATUS_ERROR)})]})})},YI=()=>{const e=ye(a=>a.documentLastUpdated),t=b.useCallback((a,...c)=>Mm(Bg(),{numeric:"always",style:"narrow"})(a,{excludeUnits:{second:!0},...c}),[]),r=e?t(e):void 0,[s,i]=b.useState(r);return b.useEffect(()=>{if(!e)return;const a=setInterval(()=>{i(t(e))},1e3);return()=>clearInterval(a)},[e,t]),h.jsxs(h.Fragment,{children:[M(C.SAVED)," ",h.jsx("time",{children:s})]})},KI=()=>{const e=Xr(c=>c.showDevOptions),{exportStoreData:t}=Ze(),r=ye(c=>c.flowTitle),s=ye(c=>c.showDeployedHistory),i=b.useRef(null),a=c=>{c.preventDefault(),i.current&&i.current.showModal()};return h.jsxs(h.Fragment,{children:[h.jsxs("section",{className:"hidden h-full w-1/6 min-w-[160px] shrink-0 flex-col bg-background text-foreground sm:flex",children:[h.jsxs("nav",{className:"flex shrink-0 items-center justify-between px-3 py-2",children:[h.jsx(LI,{}),e&&h.jsx("button",{className:"rounded bg-positive p-1 px-2 text-xs text-background",onClick:a,children:"Dev Options"})]}),h.jsx("section",{className:"px-2 py-2",children:h.jsxs("div",{className:"divide-y divide-foreground/10 rounded-lg border border-foreground/10",children:[h.jsx("h1",{className:"block w-full shrink-0 p-2 text-sm font-semibold leading-tight line-clamp-2",children:r||h.jsx(h.Fragment,{children:" "})}),h.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-x-1 gap-y-2 p-2",children:[h.jsx("div",{className:"flex-1",children:h.jsx(GI,{})}),h.jsxs("menu",{className:"flex items-center justify-center gap-x-1",children:[s?h.jsx(zI,{}):h.jsx(bI,{}),h.jsx(DI,{})]})]})]})}),h.jsxs("section",{className:"h-full overflow-y-auto",children:[s?null:h.jsx(HI,{}),h.jsx(PI,{})]}),h.jsx("section",{className:"flex flex-col items-start justify-center gap-y-5 px-2 pt-3 pb-4",children:h.jsxs("div",{className:"flex flex-col items-start justify-center gap-y-3 px-2",children:[h.jsx(AI,{}),h.jsx(jI,{})]})})]}),e&&h.jsx("dialog",{className:"z-50 my-10 rounded-lg border border-foreground/10 bg-background text-foreground",ref:i,children:h.jsx("form",{children:h.jsxs("fieldset",{children:[h.jsxs("legend",{className:"flex w-full justify-between pb-2",children:[h.jsx("h1",{className:"text-2xl leading-10",children:"Dev Options"}),h.jsxs("button",{className:"p-1 pt-0 font-semibold",formMethod:"dialog",children:[h.jsx("span",{className:"sr-only",children:"Close"}),h.jsx(Ce,{tag:"xmark",size:"lg"})]})]}),h.jsxs("div",{className:"mb-1 rounded-sm border border-gray-200 p-2",children:[h.jsx("h3",{className:"w-full",children:"Flow Data"}),h.jsx("div",{className:"flex flex-row gap-x-2 py-2",children:h.jsx("div",{className:"flex items-center",children:h.jsx("button",{type:"button",className:"rounded border bg-background px-2 py-1 text-sm hover:scale-105 hover:bg-background/80 active:scale-95",onClick:t,children:"View JSON File"})})})]}),h.jsx(UI,{})]})})})]})},XI=()=>{const e=b.useRef(null),[t,r]=b.useState(),[s,i]=b.useState(null);return b.useLayoutEffect(()=>(e.current=new ResizeObserver(([a])=>r(a)),s&&e.current.observe(s),()=>e.current?.disconnect()),[s]),{observerEntry:t,setTarget:i}},QI=({rootAppHeight:e,rootAppWidth:t})=>{ye.setState({rootAppHeight:e,rootAppWidth:t})},qI=()=>{const{observerEntry:e,setTarget:t}=XI();return b.useEffect(()=>{e&&(Qe().log("resized",{rootAppHeight:e.contentRect.height,rootAppWidth:e.contentRect.width}),QI({rootAppHeight:e.contentRect.height,rootAppWidth:e.contentRect.width}))},[e]),{rootTarget:t}};function ZI(){Qe().debug("Hello World!");const{rootTarget:e}=qI(),t=ye(i=>i.colorMode)??"",r=ye(i=>i.httpError),s=r!==void 0&&r!=="document-sync";return h.jsx(h.Fragment,{children:h.jsx("div",{className:`${t} flex h-full w-full bg-backgroundAlt text-foreground`,ref:e,children:s?h.jsx(OC,{errorType:r}):h.jsxs(h.Fragment,{children:[h.jsx(KI,{}),h.jsx(rI,{}),h.jsx(iI,{}),h.jsxs(hu,{children:[h.jsx(iA,{}),h.jsxs(oA,{children:[h.jsxs(Ds,{className:"z-50 m-0 mx-auto mt-2.5 flex w-full min-w-[320px] max-w-lg flex-col items-center gap-y-2 px-4",position:"top-center",children:[h.jsx(KA,{}),h.jsx(JA,{})]}),h.jsx(vI,{}),h.jsx(pI,{}),h.jsx(YA,{}),h.jsx(lA,{})]})]})]})})})}const JI='@font-face{font-family:SWInter;font-style:normal;font-weight:400;font-display:swap;src:url(//cdn.signalwire.com/fonts/inter/Inter-Regular.woff2) format("woff2"),url(//cdn.signalwire.com/fonts/inter/Inter-Regular.woff) format("woff")}@font-face{font-family:SWInter;font-style:normal;font-weight:500;font-display:swap;src:url(//cdn.signalwire.com/fonts/inter/Inter-Medium.woff2) format("woff2"),url(//cdn.signalwire.com/fonts/inter/Inter-Medium.woff) format("woff")}',CE=Qe(),e2=e=>{if(!e||!e.getFlowURL||!e.updateFlowURL)throw new TypeError("Invalid or missing required params")};function t2(e){e2(e);const{backButtonHref:t,deployFlowURL:r,getAiAgentsURL:s=`${window.location.origin}${mv}`,getFlowURL:i,getSwmlScriptsURL:a=`${window.location.origin}${gv}`,rootElementId:c="sw-cfb-root",styleHref:u="https://cdn.
|
|
70
|
+
text-background transition-colors hover:bg-primary/90`,onClick:s,children:M(C.RESTORE)}):null},WI={"awaiting-save":C.STATUS_SAVING,"document-sync":C.STATUS_LOCKED,error:C.STATUS_ERROR,initial:C.STATUS_LOADING,saved:C.STATUS_SAVED,saving:C.STATUS_SAVING},TE=e=>(e.preventDefault(),e.returnValue=""),OE=(e,t)=>e==="document-sync"?e:t,GI=()=>{const e=ye(v=>v.detachedMode),t=ye(v=>v.saveFlowStatus),r=ye(v=>v.httpError),[s,i]=b.useState(!0),[a,c]=b.useState(OE(r,t)),u=WI[a],f=t==="error"||r,p=OE(r,t),m=b.useRef(!1);b.useEffect(()=>{p==="initial"&&!m.current?(m.current=!0,c(p),i(!1),setTimeout(()=>{i(!0)},qR)):p!=="initial"&&s&&(m.current=!1,c(p))},[s,p]),b.useEffect(()=>{if(!(t==="saved"||r))return addEventListener("beforeunload",TE,{capture:!0}),()=>{removeEventListener("beforeunload",TE,{capture:!0})}},[r,t]);let E="";switch(!0){case f:E="px-1.5 py-0.5 bg-negative/20 text-negative";break;case a==="saved":E="text-foreground/50";break;default:E="px-1.5 py-0.5 bg-foreground/30 text-background"}return e?null:h.jsx("div",{"aria-live":f?"assertive":"polite","data-testid":"cfb__status",className:"flex",role:f?"alert":"status",children:h.jsxs("div",{className:`flex gap-x-1 rounded text-xxs ${E}`,children:[h.jsx("p",{children:u==="STATUS_SAVED"?h.jsx(YI,{}):M(u)}),f&&h.jsx(gr,{placement:"bottom",trigger:h.jsxs("div",{role:"tooltip",tabIndex:0,children:[h.jsx("span",{className:"sr-only",children:M(C.MORE_INFO_STATUS_ERROR)}),h.jsx(Ce,{tag:"circle-exclamation"})]}),children:M(r==="document-sync"?C.INFO_STATUS_ERROR_OUT_OF_SYNC:C.INFO_STATUS_ERROR)})]})})},YI=()=>{const e=ye(a=>a.documentLastUpdated),t=b.useCallback((a,...c)=>Mm(Bg(),{numeric:"always",style:"narrow"})(a,{excludeUnits:{second:!0},...c}),[]),r=e?t(e):void 0,[s,i]=b.useState(r);return b.useEffect(()=>{if(!e)return;const a=setInterval(()=>{i(t(e))},1e3);return()=>clearInterval(a)},[e,t]),h.jsxs(h.Fragment,{children:[M(C.SAVED)," ",h.jsx("time",{children:s})]})},KI=()=>{const e=Xr(c=>c.showDevOptions),{exportStoreData:t}=Ze(),r=ye(c=>c.flowTitle),s=ye(c=>c.showDeployedHistory),i=b.useRef(null),a=c=>{c.preventDefault(),i.current&&i.current.showModal()};return h.jsxs(h.Fragment,{children:[h.jsxs("section",{className:"hidden h-full w-1/6 min-w-[160px] shrink-0 flex-col bg-background text-foreground sm:flex",children:[h.jsxs("nav",{className:"flex shrink-0 items-center justify-between px-3 py-2",children:[h.jsx(LI,{}),e&&h.jsx("button",{className:"rounded bg-positive p-1 px-2 text-xs text-background",onClick:a,children:"Dev Options"})]}),h.jsx("section",{className:"px-2 py-2",children:h.jsxs("div",{className:"divide-y divide-foreground/10 rounded-lg border border-foreground/10",children:[h.jsx("h1",{className:"block w-full shrink-0 p-2 text-sm font-semibold leading-tight line-clamp-2",children:r||h.jsx(h.Fragment,{children:" "})}),h.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-x-1 gap-y-2 p-2",children:[h.jsx("div",{className:"flex-1",children:h.jsx(GI,{})}),h.jsxs("menu",{className:"flex items-center justify-center gap-x-1",children:[s?h.jsx(zI,{}):h.jsx(bI,{}),h.jsx(DI,{})]})]})]})}),h.jsxs("section",{className:"h-full overflow-y-auto",children:[s?null:h.jsx(HI,{}),h.jsx(PI,{})]}),h.jsx("section",{className:"flex flex-col items-start justify-center gap-y-5 px-2 pt-3 pb-4",children:h.jsxs("div",{className:"flex flex-col items-start justify-center gap-y-3 px-2",children:[h.jsx(AI,{}),h.jsx(jI,{})]})})]}),e&&h.jsx("dialog",{className:"z-50 my-10 rounded-lg border border-foreground/10 bg-background text-foreground",ref:i,children:h.jsx("form",{children:h.jsxs("fieldset",{children:[h.jsxs("legend",{className:"flex w-full justify-between pb-2",children:[h.jsx("h1",{className:"text-2xl leading-10",children:"Dev Options"}),h.jsxs("button",{className:"p-1 pt-0 font-semibold",formMethod:"dialog",children:[h.jsx("span",{className:"sr-only",children:"Close"}),h.jsx(Ce,{tag:"xmark",size:"lg"})]})]}),h.jsxs("div",{className:"mb-1 rounded-sm border border-gray-200 p-2",children:[h.jsx("h3",{className:"w-full",children:"Flow Data"}),h.jsx("div",{className:"flex flex-row gap-x-2 py-2",children:h.jsx("div",{className:"flex items-center",children:h.jsx("button",{type:"button",className:"rounded border bg-background px-2 py-1 text-sm hover:scale-105 hover:bg-background/80 active:scale-95",onClick:t,children:"View JSON File"})})})]}),h.jsx(UI,{})]})})})]})},XI=()=>{const e=b.useRef(null),[t,r]=b.useState(),[s,i]=b.useState(null);return b.useLayoutEffect(()=>(e.current=new ResizeObserver(([a])=>r(a)),s&&e.current.observe(s),()=>e.current?.disconnect()),[s]),{observerEntry:t,setTarget:i}},QI=({rootAppHeight:e,rootAppWidth:t})=>{ye.setState({rootAppHeight:e,rootAppWidth:t})},qI=()=>{const{observerEntry:e,setTarget:t}=XI();return b.useEffect(()=>{e&&(Qe().log("resized",{rootAppHeight:e.contentRect.height,rootAppWidth:e.contentRect.width}),QI({rootAppHeight:e.contentRect.height,rootAppWidth:e.contentRect.width}))},[e]),{rootTarget:t}};function ZI(){Qe().debug("Hello World!");const{rootTarget:e}=qI(),t=ye(i=>i.colorMode)??"",r=ye(i=>i.httpError),s=r!==void 0&&r!=="document-sync";return h.jsx(h.Fragment,{children:h.jsx("div",{className:`${t} flex h-full w-full bg-backgroundAlt text-foreground`,ref:e,children:s?h.jsx(OC,{errorType:r}):h.jsxs(h.Fragment,{children:[h.jsx(KI,{}),h.jsx(rI,{}),h.jsx(iI,{}),h.jsxs(hu,{children:[h.jsx(iA,{}),h.jsxs(oA,{children:[h.jsxs(Ds,{className:"z-50 m-0 mx-auto mt-2.5 flex w-full min-w-[320px] max-w-lg flex-col items-center gap-y-2 px-4",position:"top-center",children:[h.jsx(KA,{}),h.jsx(JA,{})]}),h.jsx(vI,{}),h.jsx(pI,{}),h.jsx(YA,{}),h.jsx(lA,{})]})]})]})})})}const JI='@font-face{font-family:SWInter;font-style:normal;font-weight:400;font-display:swap;src:url(//cdn.signalwire.com/fonts/inter/Inter-Regular.woff2) format("woff2"),url(//cdn.signalwire.com/fonts/inter/Inter-Regular.woff) format("woff")}@font-face{font-family:SWInter;font-style:normal;font-weight:500;font-display:swap;src:url(//cdn.signalwire.com/fonts/inter/Inter-Medium.woff2) format("woff2"),url(//cdn.signalwire.com/fonts/inter/Inter-Medium.woff) format("woff")}',CE=Qe(),e2=e=>{if(!e||!e.getFlowURL||!e.updateFlowURL)throw new TypeError("Invalid or missing required params")};function t2(e){e2(e);const{backButtonHref:t,deployFlowURL:r,getAiAgentsURL:s=`${window.location.origin}${mv}`,getFlowURL:i,getSwmlScriptsURL:a=`${window.location.origin}${gv}`,rootElementId:c="sw-cfb-root",styleHref:u="https://cdn.signalwire.com/npm/@signalwire/cfb@latest/dist/style.css",updateFlowURL:f,voicesURL:p="https://cdn.signalwire.com/npm/@signalwire/cfb@latest/dist/voices.json"}=e;Ju.getState().actions.init({voicesURL:p}).catch(v=>{CE.error("Error initializing voices",v)});const m=document.getElementById(c);if(ye.setState({backButtonHref:t,deployFlowURL:r,getFlowURL:i,rootElement:m,rootElementId:c,updateFlowURL:f}),s&&On.getState().actions.init({getAiAgentsURL:s}),a&&Bn.getState().actions.init({getSwmlScriptsURL:a}),iC().catch(v=>{CE.error("Error initializing i18n",v)}),RI(),!m)throw new Error(`Id: '${c}' not found in the DOM`);m.attachShadow({mode:"open"}),m.shadowRoot&&Yv.createRoot(m.shadowRoot).render(h.jsxs(b.StrictMode,{children:[h.jsx("link",{type:"text/css",rel:"stylesheet",href:u}),h.jsx(ZI,{})]}));const E=document.createElement("style");document.head.appendChild(E),E.appendChild(document.createTextNode(JI))}go.main=t2,Object.defineProperty(go,Symbol.toStringTag,{value:"Module"})});
|