@signalwire/cfb 0.0.13-dev.202401041539.62191c5.0 → 0.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/main.js +10 -10
  2. package/package.json +2 -2
package/dist/main.js CHANGED
@@ -1,5 +1,5 @@
1
1
  (function(Fr,qo){typeof exports=="object"&&typeof module<"u"?qo(exports):typeof define=="function"&&define.amd?define(["exports"],qo):(Fr=typeof globalThis<"u"?globalThis:Fr||self,qo(Fr.CFB={}))})(this,function(Fr){"use strict";/**
2
- * Visual Builder v0.0.12 [62191c5] (https://signalwire.com)
2
+ * Visual Builder v0.0.12 [62191c50] (https://signalwire.com)
3
3
  * Copyright 2018-2024 SignalWire.
4
4
  */
5
5
  function qo(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"&&!Array.isArray(r)){for(const o in r)if(o!=="default"&&!(o in e)){const s=Object.getOwnPropertyDescriptor(r,o);s&&Object.defineProperty(e,o,s.get?s:{enumerable:!0,get:()=>r[o]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}function Ba(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Xf={exports:{}},Ti={},Qf={exports:{}},oe={};/**
@@ -57,14 +57,14 @@ Error generating stack: `+s.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 zl=O,fR=dR;function pR(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var hR=typeof Object.is=="function"?Object.is:pR,mR=fR.useSyncExternalStore,gR=zl.useRef,ER=zl.useEffect,yR=zl.useMemo,vR=zl.useDebugValue;Ng.useSyncExternalStoreWithSelector=function(e,t,n,r,o){var s=gR(null);if(s.current===null){var i={hasValue:!1,value:null};s.current=i}else i=s.current;s=yR(function(){function a(h){if(!c){if(c=!0,u=h,h=r(h),o!==void 0&&i.hasValue){var E=i.value;if(o(E,h))return f=E}return f=h}if(E=f,hR(u,h))return E;var y=r(h);return o!==void 0&&o(E,y)?E:(u=h,f=y)}var c=!1,u,f,p=n===void 0?null:n;return[function(){return a(t())},p===null?void 0:function(){return a(p())}]},[t,n,r,o]);var l=mR(e,s[0],s[1]);return ER(function(){i.hasValue=!0,i.value=l},[l]),vR(l),l},Rg.exports=Ng;var _R=Rg.exports;const Tg=Ba(_R);var SR={VITE_BASE_URL:"",VITE_BASIC_AUTH:"signalwire:1aG93uXk",VITE_DEFAULT_STYLE_HREF:"https://cdn.swire.io/npm/@signalwire/cfb@dev/dist/style.css",VITE_DEFAULT_VOICES_URL:"https://cdn.signalwire.com/npm/@signalwire/cfb@dev/dist/voices.json",VITE_FLOW_DATA_VERSION:"0.0.10",VITE_IS_STAGING:"true",BASE_URL:"/cfb/",MODE:"staging",DEV:!1,PROD:!0,SSR:!1};const Ag=e=>{let t;const n=new Set,r=(a,c)=>{const u=typeof a=="function"?a(t):a;if(!Object.is(u,t)){const f=t;t=c??(typeof u!="object"||u===null)?u:Object.assign({},t,u),n.forEach(p=>p(t,f))}},o=()=>t,l={setState:r,getState:o,subscribe:a=>(n.add(a),()=>n.delete(a)),destroy:()=>{(SR?"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."),n.clear()}};return t=e(r,o,l),l},Ig=e=>e?Ag(e):Ag,{useDebugValue:xR}=H,{useSyncExternalStoreWithSelector:RR}=Tg;function Cg(e,t=e.getState,n){const r=RR(e.subscribe,e.getState,e.getServerState||e.getState,t,n);return xR(r),r}const Lg=(e,t)=>{const n=Ig(e),r=(o,s=t)=>Cg(n,o,s);return Object.assign(r,n),r},NR=(e,t)=>e?Lg(e,t):Lg;function Ge(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[r,o]of e)if(!Object.is(o,t.get(r)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r=0;r<n.length;r++)if(!Object.prototype.hasOwnProperty.call(t,n[r])||!Object.is(e[n[r]],t[n[r]]))return!1;return!0}var wR={value:()=>{}};function Wl(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new Gl(n)}function Gl(e){this._=e}function OR(e,t){return e.trim().split(/^|\s+/).map(function(n){var r="",o=n.indexOf(".");if(o>=0&&(r=n.slice(o+1),n=n.slice(0,o)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}Gl.prototype=Wl.prototype={constructor:Gl,on:function(e,t){var n=this._,r=OR(e+"",n),o,s=-1,i=r.length;if(arguments.length<2){for(;++s<i;)if((o=(e=r[s]).type)&&(o=TR(n[o],e.name)))return o;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++s<i;)if(o=(e=r[s]).type)n[o]=bg(n[o],e.name,t);else if(t==null)for(o in n)n[o]=bg(n[o],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Gl(e)},call:function(e,t){if((o=arguments.length-2)>0)for(var n=new Array(o),r=0,o,s;r<o;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(s=this._[e],r=0,o=s.length;r<o;++r)s[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var r=this._[e],o=0,s=r.length;o<s;++o)r[o].value.apply(t,n)}};function TR(e,t){for(var n=0,r=e.length,o;n<r;++n)if((o=e[n]).name===t)return o.value}function bg(e,t,n){for(var r=0,o=e.length;r<o;++r)if(e[r].name===t){e[r]=wR,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var pd="http://www.w3.org/1999/xhtml";const Dg={svg:"http://www.w3.org/2000/svg",xhtml:pd,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Yl(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Dg.hasOwnProperty(t)?{space:Dg[t],local:e}:e}function AR(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===pd&&t.documentElement.namespaceURI===pd?t.createElement(e):t.createElementNS(n,e)}}function IR(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function kg(e){var t=Yl(e);return(t.local?IR:AR)(t)}function CR(){}function hd(e){return e==null?CR:function(){return this.querySelector(e)}}function LR(e){typeof e!="function"&&(e=hd(e));for(var t=this._groups,n=t.length,r=new Array(n),o=0;o<n;++o)for(var s=t[o],i=s.length,l=r[o]=new Array(i),a,c,u=0;u<i;++u)(a=s[u])&&(c=e.call(a,a.__data__,u,s))&&("__data__"in a&&(c.__data__=a.__data__),l[u]=c);return new Et(r,this._parents)}function bR(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function DR(){return[]}function Pg(e){return e==null?DR:function(){return this.querySelectorAll(e)}}function kR(e){return function(){return bR(e.apply(this,arguments))}}function PR(e){typeof e=="function"?e=kR(e):e=Pg(e);for(var t=this._groups,n=t.length,r=[],o=[],s=0;s<n;++s)for(var i=t[s],l=i.length,a,c=0;c<l;++c)(a=i[c])&&(r.push(e.call(a,a.__data__,c,i)),o.push(a));return new Et(r,o)}function Mg(e){return function(){return this.matches(e)}}function Ug(e){return function(t){return t.matches(e)}}var MR=Array.prototype.find;function UR(e){return function(){return MR.call(this.children,e)}}function FR(){return this.firstElementChild}function jR(e){return this.select(e==null?FR:UR(typeof e=="function"?e:Ug(e)))}var VR=Array.prototype.filter;function $R(){return Array.from(this.children)}function HR(e){return function(){return VR.call(this.children,e)}}function BR(e){return this.selectAll(e==null?$R:HR(typeof e=="function"?e:Ug(e)))}function zR(e){typeof e!="function"&&(e=Mg(e));for(var t=this._groups,n=t.length,r=new Array(n),o=0;o<n;++o)for(var s=t[o],i=s.length,l=r[o]=[],a,c=0;c<i;++c)(a=s[c])&&e.call(a,a.__data__,c,s)&&l.push(a);return new Et(r,this._parents)}function Fg(e){return new Array(e.length)}function WR(){return new Et(this._enter||this._groups.map(Fg),this._parents)}function Kl(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Kl.prototype={constructor:Kl,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 GR(e){return function(){return e}}function YR(e,t,n,r,o,s){for(var i=0,l,a=t.length,c=s.length;i<c;++i)(l=t[i])?(l.__data__=s[i],r[i]=l):n[i]=new Kl(e,s[i]);for(;i<a;++i)(l=t[i])&&(o[i]=l)}function KR(e,t,n,r,o,s,i){var l,a,c=new Map,u=t.length,f=s.length,p=new Array(u),h;for(l=0;l<u;++l)(a=t[l])&&(p[l]=h=i.call(a,a.__data__,l,t)+"",c.has(h)?o[l]=a:c.set(h,a));for(l=0;l<f;++l)h=i.call(e,s[l],l,s)+"",(a=c.get(h))?(r[l]=a,a.__data__=s[l],c.delete(h)):n[l]=new Kl(e,s[l]);for(l=0;l<u;++l)(a=t[l])&&c.get(p[l])===a&&(o[l]=a)}function XR(e){return e.__data__}function QR(e,t){if(!arguments.length)return Array.from(this,XR);var n=t?KR:YR,r=this._parents,o=this._groups;typeof e!="function"&&(e=GR(e));for(var s=o.length,i=new Array(s),l=new Array(s),a=new Array(s),c=0;c<s;++c){var u=r[c],f=o[c],p=f.length,h=qR(e.call(u,u&&u.__data__,c,r)),E=h.length,y=l[c]=new Array(E),v=i[c]=new Array(E),m=a[c]=new Array(p);n(u,f,y,v,m,h,t);for(var g=0,S=0,_,x;g<E;++g)if(_=y[g]){for(g>=S&&(S=g+1);!(x=v[S])&&++S<E;);_._next=x||null}}return i=new Et(i,r),i._enter=l,i._exit=a,i}function qR(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function JR(){return new Et(this._exit||this._groups.map(Fg),this._parents)}function ZR(e,t,n){var r=this.enter(),o=this,s=this.exit();return typeof e=="function"?(r=e(r),r&&(r=r.selection())):r=r.append(e+""),t!=null&&(o=t(o),o&&(o=o.selection())),n==null?s.remove():n(s),r&&o?r.merge(o).order():o}function eN(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,o=n.length,s=r.length,i=Math.min(o,s),l=new Array(o),a=0;a<i;++a)for(var c=n[a],u=r[a],f=c.length,p=l[a]=new Array(f),h,E=0;E<f;++E)(h=c[E]||u[E])&&(p[E]=h);for(;a<o;++a)l[a]=n[a];return new Et(l,this._parents)}function tN(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],o=r.length-1,s=r[o],i;--o>=0;)(i=r[o])&&(s&&i.compareDocumentPosition(s)^4&&s.parentNode.insertBefore(i,s),s=i);return this}function nN(e){e||(e=rN);function t(f,p){return f&&p?e(f.__data__,p.__data__):!f-!p}for(var n=this._groups,r=n.length,o=new Array(r),s=0;s<r;++s){for(var i=n[s],l=i.length,a=o[s]=new Array(l),c,u=0;u<l;++u)(c=i[u])&&(a[u]=c);a.sort(t)}return new Et(o,this._parents).order()}function rN(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function oN(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function sN(){return Array.from(this)}function iN(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],o=0,s=r.length;o<s;++o){var i=r[o];if(i)return i}return null}function lN(){let e=0;for(const t of this)++e;return e}function aN(){return!this.node()}function cN(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var o=t[n],s=0,i=o.length,l;s<i;++s)(l=o[s])&&e.call(l,l.__data__,s,o);return this}function uN(e){return function(){this.removeAttribute(e)}}function dN(e){return function(){this.removeAttributeNS(e.space,e.local)}}function fN(e,t){return function(){this.setAttribute(e,t)}}function pN(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function hN(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function mN(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function gN(e,t){var n=Yl(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?dN:uN:typeof t=="function"?n.local?mN:hN:n.local?pN:fN)(n,t))}function jg(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function EN(e){return function(){this.style.removeProperty(e)}}function yN(e,t,n){return function(){this.style.setProperty(e,t,n)}}function vN(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function _N(e,t,n){return arguments.length>1?this.each((t==null?EN:typeof t=="function"?vN:yN)(e,t,n??"")):Eo(this.node(),e)}function Eo(e,t){return e.style.getPropertyValue(t)||jg(e).getComputedStyle(e,null).getPropertyValue(t)}function SN(e){return function(){delete this[e]}}function xN(e,t){return function(){this[e]=t}}function RN(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function NN(e,t){return arguments.length>1?this.each((t==null?SN:typeof t=="function"?RN:xN)(e,t)):this.node()[e]}function Vg(e){return e.trim().split(/^|\s+/)}function md(e){return e.classList||new $g(e)}function $g(e){this._node=e,this._names=Vg(e.getAttribute("class")||"")}$g.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 Hg(e,t){for(var n=md(e),r=-1,o=t.length;++r<o;)n.add(t[r])}function Bg(e,t){for(var n=md(e),r=-1,o=t.length;++r<o;)n.remove(t[r])}function wN(e){return function(){Hg(this,e)}}function ON(e){return function(){Bg(this,e)}}function TN(e,t){return function(){(t.apply(this,arguments)?Hg:Bg)(this,e)}}function AN(e,t){var n=Vg(e+"");if(arguments.length<2){for(var r=md(this.node()),o=-1,s=n.length;++o<s;)if(!r.contains(n[o]))return!1;return!0}return this.each((typeof t=="function"?TN:t?wN:ON)(n,t))}function IN(){this.textContent=""}function CN(e){return function(){this.textContent=e}}function LN(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function bN(e){return arguments.length?this.each(e==null?IN:(typeof e=="function"?LN:CN)(e)):this.node().textContent}function DN(){this.innerHTML=""}function kN(e){return function(){this.innerHTML=e}}function PN(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function MN(e){return arguments.length?this.each(e==null?DN:(typeof e=="function"?PN:kN)(e)):this.node().innerHTML}function UN(){this.nextSibling&&this.parentNode.appendChild(this)}function FN(){return this.each(UN)}function jN(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function VN(){return this.each(jN)}function $N(e){var t=typeof e=="function"?e:kg(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function HN(){return null}function BN(e,t){var n=typeof e=="function"?e:kg(e),r=t==null?HN:typeof t=="function"?t:hd(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function zN(){var e=this.parentNode;e&&e.removeChild(this)}function WN(){return this.each(zN)}function GN(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function YN(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function KN(e){return this.select(e?YN:GN)}function XN(e){return arguments.length?this.property("__data__",e):this.node().__data__}function QN(e){return function(t){e.call(this,t,this.__data__)}}function qN(e){return e.trim().split(/^|\s+/).map(function(t){var n="",r=t.indexOf(".");return r>=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function JN(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,o=t.length,s;n<o;++n)s=t[n],(!e.type||s.type===e.type)&&s.name===e.name?this.removeEventListener(s.type,s.listener,s.options):t[++r]=s;++r?t.length=r:delete this.__on}}}function ZN(e,t,n){return function(){var r=this.__on,o,s=QN(t);if(r){for(var i=0,l=r.length;i<l;++i)if((o=r[i]).type===e.type&&o.name===e.name){this.removeEventListener(o.type,o.listener,o.options),this.addEventListener(o.type,o.listener=s,o.options=n),o.value=t;return}}this.addEventListener(e.type,s,n),o={type:e.type,name:e.name,value:t,listener:s,options:n},r?r.push(o):this.__on=[o]}}function e1(e,t,n){var r=qN(e+""),o,s=r.length,i;if(arguments.length<2){var l=this.node().__on;if(l){for(var a=0,c=l.length,u;a<c;++a)for(o=0,u=l[a];o<s;++o)if((i=r[o]).type===u.type&&i.name===u.name)return u.value}return}for(l=t?ZN:JN,o=0;o<s;++o)this.each(l(r[o],t,n));return this}function zg(e,t,n){var r=jg(e),o=r.CustomEvent;typeof o=="function"?o=new o(t,n):(o=r.document.createEvent("Event"),n?(o.initEvent(t,n.bubbles,n.cancelable),o.detail=n.detail):o.initEvent(t,!1,!1)),e.dispatchEvent(o)}function t1(e,t){return function(){return zg(this,e,t)}}function n1(e,t){return function(){return zg(this,e,t.apply(this,arguments))}}function r1(e,t){return this.each((typeof t=="function"?n1:t1)(e,t))}function*o1(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],o=0,s=r.length,i;o<s;++o)(i=r[o])&&(yield i)}var Wg=[null];function Et(e,t){this._groups=e,this._parents=t}function Hs(){return new Et([[document.documentElement]],Wg)}function s1(){return this}Et.prototype=Hs.prototype={constructor:Et,select:LR,selectAll:PR,selectChild:jR,selectChildren:BR,filter:zR,data:QR,enter:WR,exit:JR,join:ZR,merge:eN,selection:s1,order:tN,sort:nN,call:oN,nodes:sN,node:iN,size:lN,empty:aN,each:cN,attr:gN,style:_N,property:NN,classed:AN,text:bN,html:MN,raise:FN,lower:VN,append:$N,insert:BN,remove:WN,clone:KN,datum:XN,on:e1,dispatch:r1,[Symbol.iterator]:o1};function jt(e){return typeof e=="string"?new Et([[document.querySelector(e)]],[document.documentElement]):new Et([[e]],Wg)}function i1(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Xt(e,t){if(e=i1(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var o=t.getBoundingClientRect();return[e.clientX-o.left-t.clientLeft,e.clientY-o.top-t.clientTop]}}return[e.pageX,e.pageY]}const l1={passive:!1},Bs={capture:!0,passive:!1};function gd(e){e.stopImmediatePropagation()}function yo(e){e.preventDefault(),e.stopImmediatePropagation()}function Gg(e){var t=e.document.documentElement,n=jt(e).on("dragstart.drag",yo,Bs);"onselectstart"in t?n.on("selectstart.drag",yo,Bs):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Yg(e,t){var n=e.document.documentElement,r=jt(e).on("dragstart.drag",null);t&&(r.on("click.drag",yo,Bs),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const Xl=e=>()=>e;function Ed(e,{sourceEvent:t,subject:n,target:r,identifier:o,active:s,x:i,y:l,dx:a,dy:c,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:o,enumerable:!0,configurable:!0},active:{value:s,enumerable:!0,configurable:!0},x:{value:i,enumerable:!0,configurable:!0},y:{value:l,enumerable:!0,configurable:!0},dx:{value:a,enumerable:!0,configurable:!0},dy:{value:c,enumerable:!0,configurable:!0},_:{value:u}})}Ed.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function a1(e){return!e.ctrlKey&&!e.button}function c1(){return this.parentNode}function u1(e,t){return t??{x:e.x,y:e.y}}function d1(){return navigator.maxTouchPoints||"ontouchstart"in this}function f1(){var e=a1,t=c1,n=u1,r=d1,o={},s=Wl("start","drag","end"),i=0,l,a,c,u,f=0;function p(_){_.on("mousedown.drag",h).filter(r).on("touchstart.drag",v).on("touchmove.drag",m,l1).on("touchend.drag touchcancel.drag",g).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(_,x){if(!(u||!e.call(this,_,x))){var R=S(this,t.call(this,_,x),_,x,"mouse");R&&(jt(_.view).on("mousemove.drag",E,Bs).on("mouseup.drag",y,Bs),Gg(_.view),gd(_),c=!1,l=_.clientX,a=_.clientY,R("start",_))}}function E(_){if(yo(_),!c){var x=_.clientX-l,R=_.clientY-a;c=x*x+R*R>f}o.mouse("drag",_)}function y(_){jt(_.view).on("mousemove.drag mouseup.drag",null),Yg(_.view,c),yo(_),o.mouse("end",_)}function v(_,x){if(e.call(this,_,x)){var R=_.changedTouches,T=t.call(this,_,x),L=R.length,P,I;for(P=0;P<L;++P)(I=S(this,T,_,x,R[P].identifier,R[P]))&&(gd(_),I("start",_,R[P]))}}function m(_){var x=_.changedTouches,R=x.length,T,L;for(T=0;T<R;++T)(L=o[x[T].identifier])&&(yo(_),L("drag",_,x[T]))}function g(_){var x=_.changedTouches,R=x.length,T,L;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),T=0;T<R;++T)(L=o[x[T].identifier])&&(gd(_),L("end",_,x[T]))}function S(_,x,R,T,L,P){var I=s.copy(),j=Xt(P||R,x),V,M,w;if((w=n.call(_,new Ed("beforestart",{sourceEvent:R,target:p,identifier:L,active:i,x:j[0],y:j[1],dx:0,dy:0,dispatch:I}),T))!=null)return V=w.x-j[0]||0,M=w.y-j[1]||0,function b(k,F,C){var D=j,U;switch(k){case"start":o[L]=b,U=i++;break;case"end":delete o[L],--i;case"drag":j=Xt(C||F,x),U=i;break}I.call(k,_,new Ed(k,{sourceEvent:F,subject:w,target:p,identifier:L,active:U,x:j[0]+V,y:j[1]+M,dx:j[0]-D[0],dy:j[1]-D[1],dispatch:I}),T)}}return p.filter=function(_){return arguments.length?(e=typeof _=="function"?_:Xl(!!_),p):e},p.container=function(_){return arguments.length?(t=typeof _=="function"?_:Xl(_),p):t},p.subject=function(_){return arguments.length?(n=typeof _=="function"?_:Xl(_),p):n},p.touchable=function(_){return arguments.length?(r=typeof _=="function"?_:Xl(!!_),p):r},p.on=function(){var _=s.on.apply(s,arguments);return _===s?p:_},p.clickDistance=function(_){return arguments.length?(f=(_=+_)*_,p):Math.sqrt(f)},p}function yd(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Kg(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function zs(){}var Ws=.7,Ql=1/Ws,vo="\\s*([+-]?\\d+)\\s*",Gs="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Qt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",p1=/^#([0-9a-f]{3,8})$/,h1=new RegExp(`^rgb\\(${vo},${vo},${vo}\\)$`),m1=new RegExp(`^rgb\\(${Qt},${Qt},${Qt}\\)$`),g1=new RegExp(`^rgba\\(${vo},${vo},${vo},${Gs}\\)$`),E1=new RegExp(`^rgba\\(${Qt},${Qt},${Qt},${Gs}\\)$`),y1=new RegExp(`^hsl\\(${Gs},${Qt},${Qt}\\)$`),v1=new RegExp(`^hsla\\(${Gs},${Qt},${Qt},${Gs}\\)$`),Xg={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};yd(zs,Ys,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Qg,formatHex:Qg,formatHex8:_1,formatHsl:S1,formatRgb:qg,toString:qg});function Qg(){return this.rgb().formatHex()}function _1(){return this.rgb().formatHex8()}function S1(){return nE(this).formatHsl()}function qg(){return this.rgb().formatRgb()}function Ys(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=p1.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?Jg(t):n===3?new st(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?ql(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?ql(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=h1.exec(e))?new st(t[1],t[2],t[3],1):(t=m1.exec(e))?new st(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=g1.exec(e))?ql(t[1],t[2],t[3],t[4]):(t=E1.exec(e))?ql(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=y1.exec(e))?tE(t[1],t[2]/100,t[3]/100,1):(t=v1.exec(e))?tE(t[1],t[2]/100,t[3]/100,t[4]):Xg.hasOwnProperty(e)?Jg(Xg[e]):e==="transparent"?new st(NaN,NaN,NaN,0):null}function Jg(e){return new st(e>>16&255,e>>8&255,e&255,1)}function ql(e,t,n,r){return r<=0&&(e=t=n=NaN),new st(e,t,n,r)}function x1(e){return e instanceof zs||(e=Ys(e)),e?(e=e.rgb(),new st(e.r,e.g,e.b,e.opacity)):new st}function vd(e,t,n,r){return arguments.length===1?x1(e):new st(e,t,n,r??1)}function st(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}yd(st,vd,Kg(zs,{brighter(e){return e=e==null?Ql:Math.pow(Ql,e),new st(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Ws:Math.pow(Ws,e),new st(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new st(yr(this.r),yr(this.g),yr(this.b),Jl(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:Zg,formatHex:Zg,formatHex8:R1,formatRgb:eE,toString:eE}));function Zg(){return`#${vr(this.r)}${vr(this.g)}${vr(this.b)}`}function R1(){return`#${vr(this.r)}${vr(this.g)}${vr(this.b)}${vr((isNaN(this.opacity)?1:this.opacity)*255)}`}function eE(){const e=Jl(this.opacity);return`${e===1?"rgb(":"rgba("}${yr(this.r)}, ${yr(this.g)}, ${yr(this.b)}${e===1?")":`, ${e})`}`}function Jl(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function yr(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function vr(e){return e=yr(e),(e<16?"0":"")+e.toString(16)}function tE(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Vt(e,t,n,r)}function nE(e){if(e instanceof Vt)return new Vt(e.h,e.s,e.l,e.opacity);if(e instanceof zs||(e=Ys(e)),!e)return new Vt;if(e instanceof Vt)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,o=Math.min(t,n,r),s=Math.max(t,n,r),i=NaN,l=s-o,a=(s+o)/2;return l?(t===s?i=(n-r)/l+(n<r)*6:n===s?i=(r-t)/l+2:i=(t-n)/l+4,l/=a<.5?s+o:2-s-o,i*=60):l=a>0&&a<1?0:i,new Vt(i,l,a,e.opacity)}function N1(e,t,n,r){return arguments.length===1?nE(e):new Vt(e,t,n,r??1)}function Vt(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}yd(Vt,N1,Kg(zs,{brighter(e){return e=e==null?Ql:Math.pow(Ql,e),new Vt(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Ws:Math.pow(Ws,e),new Vt(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,n=this.l,r=n+(n<.5?n:1-n)*t,o=2*n-r;return new st(_d(e>=240?e-240:e+120,o,r),_d(e,o,r),_d(e<120?e+240:e-120,o,r),this.opacity)},clamp(){return new Vt(rE(this.h),Zl(this.s),Zl(this.l),Jl(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=Jl(this.opacity);return`${e===1?"hsl(":"hsla("}${rE(this.h)}, ${Zl(this.s)*100}%, ${Zl(this.l)*100}%${e===1?")":`, ${e})`}`}}));function rE(e){return e=(e||0)%360,e<0?e+360:e}function Zl(e){return Math.max(0,Math.min(1,e||0))}function _d(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const oE=e=>()=>e;function w1(e,t){return function(n){return e+n*t}}function O1(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function T1(e){return(e=+e)==1?sE:function(t,n){return n-t?O1(t,n,e):oE(isNaN(t)?n:t)}}function sE(e,t){var n=t-e;return n?w1(e,n):oE(isNaN(e)?t:e)}const iE=function e(t){var n=T1(t);function r(o,s){var i=n((o=vd(o)).r,(s=vd(s)).r),l=n(o.g,s.g),a=n(o.b,s.b),c=sE(o.opacity,s.opacity);return function(u){return o.r=i(u),o.g=l(u),o.b=a(u),o.opacity=c(u),o+""}}return r.gamma=e,r}(1);function Hn(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var Sd=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,xd=new RegExp(Sd.source,"g");function A1(e){return function(){return e}}function I1(e){return function(t){return e(t)+""}}function C1(e,t){var n=Sd.lastIndex=xd.lastIndex=0,r,o,s,i=-1,l=[],a=[];for(e=e+"",t=t+"";(r=Sd.exec(e))&&(o=xd.exec(t));)(s=o.index)>n&&(s=t.slice(n,s),l[i]?l[i]+=s:l[++i]=s),(r=r[0])===(o=o[0])?l[i]?l[i]+=o:l[++i]=o:(l[++i]=null,a.push({i,x:Hn(r,o)})),n=xd.lastIndex;return n<t.length&&(s=t.slice(n),l[i]?l[i]+=s:l[++i]=s),l.length<2?a[0]?I1(a[0].x):A1(t):(t=a.length,function(c){for(var u=0,f;u<t;++u)l[(f=a[u]).i]=f.x(c);return l.join("")})}var lE=180/Math.PI,Rd={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function aE(e,t,n,r,o,s){var i,l,a;return(i=Math.sqrt(e*e+t*t))&&(e/=i,t/=i),(a=e*n+t*r)&&(n-=e*a,r-=t*a),(l=Math.sqrt(n*n+r*r))&&(n/=l,r/=l,a/=l),e*r<t*n&&(e=-e,t=-t,a=-a,i=-i),{translateX:o,translateY:s,rotate:Math.atan2(t,e)*lE,skewX:Math.atan(a)*lE,scaleX:i,scaleY:l}}var ea;function L1(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Rd:aE(t.a,t.b,t.c,t.d,t.e,t.f)}function b1(e){return e==null||(ea||(ea=document.createElementNS("http://www.w3.org/2000/svg","g")),ea.setAttribute("transform",e),!(e=ea.transform.baseVal.consolidate()))?Rd:(e=e.matrix,aE(e.a,e.b,e.c,e.d,e.e,e.f))}function cE(e,t,n,r){function o(c){return c.length?c.pop()+" ":""}function s(c,u,f,p,h,E){if(c!==f||u!==p){var y=h.push("translate(",null,t,null,n);E.push({i:y-4,x:Hn(c,f)},{i:y-2,x:Hn(u,p)})}else(f||p)&&h.push("translate("+f+t+p+n)}function i(c,u,f,p){c!==u?(c-u>180?u+=360:u-c>180&&(c+=360),p.push({i:f.push(o(f)+"rotate(",null,r)-2,x:Hn(c,u)})):u&&f.push(o(f)+"rotate("+u+r)}function l(c,u,f,p){c!==u?p.push({i:f.push(o(f)+"skewX(",null,r)-2,x:Hn(c,u)}):u&&f.push(o(f)+"skewX("+u+r)}function a(c,u,f,p,h,E){if(c!==f||u!==p){var y=h.push(o(h)+"scale(",null,",",null,")");E.push({i:y-4,x:Hn(c,f)},{i:y-2,x:Hn(u,p)})}else(f!==1||p!==1)&&h.push(o(h)+"scale("+f+","+p+")")}return function(c,u){var f=[],p=[];return c=e(c),u=e(u),s(c.translateX,c.translateY,u.translateX,u.translateY,f,p),i(c.rotate,u.rotate,f,p),l(c.skewX,u.skewX,f,p),a(c.scaleX,c.scaleY,u.scaleX,u.scaleY,f,p),c=u=null,function(h){for(var E=-1,y=p.length,v;++E<y;)f[(v=p[E]).i]=v.x(h);return f.join("")}}}var D1=cE(L1,"px, ","px)","deg)"),k1=cE(b1,", ",")",")"),P1=1e-12;function uE(e){return((e=Math.exp(e))+1/e)/2}function M1(e){return((e=Math.exp(e))-1/e)/2}function U1(e){return((e=Math.exp(2*e))-1)/(e+1)}const F1=function e(t,n,r){function o(s,i){var l=s[0],a=s[1],c=s[2],u=i[0],f=i[1],p=i[2],h=u-l,E=f-a,y=h*h+E*E,v,m;if(y<P1)m=Math.log(p/c)/t,v=function(T){return[l+T*h,a+T*E,c*Math.exp(t*T*m)]};else{var g=Math.sqrt(y),S=(p*p-c*c+r*y)/(2*c*n*g),_=(p*p-c*c-r*y)/(2*p*n*g),x=Math.log(Math.sqrt(S*S+1)-S),R=Math.log(Math.sqrt(_*_+1)-_);m=(R-x)/t,v=function(T){var L=T*m,P=uE(x),I=c/(n*g)*(P*U1(t*L+x)-M1(x));return[l+I*h,a+I*E,c*P/uE(t*L+x)]}}return v.duration=m*1e3*t/Math.SQRT2,v}return o.rho=function(s){var i=Math.max(.001,+s),l=i*i,a=l*l;return e(i,l,a)},o}(Math.SQRT2,2,4);var _o=0,Ks=0,Xs=0,dE=1e3,ta,Qs,na=0,_r=0,ra=0,qs=typeof performance=="object"&&performance.now?performance:Date,fE=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Nd(){return _r||(fE(j1),_r=qs.now()+ra)}function j1(){_r=0}function oa(){this._call=this._time=this._next=null}oa.prototype=pE.prototype={constructor:oa,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Nd():+n)+(t==null?0:+t),!this._next&&Qs!==this&&(Qs?Qs._next=this:ta=this,Qs=this),this._call=e,this._time=n,wd()},stop:function(){this._call&&(this._call=null,this._time=1/0,wd())}};function pE(e,t,n){var r=new oa;return r.restart(e,t,n),r}function V1(){Nd(),++_o;for(var e=ta,t;e;)(t=_r-e._time)>=0&&e._call.call(void 0,t),e=e._next;--_o}function hE(){_r=(na=qs.now())+ra,_o=Ks=0;try{V1()}finally{_o=0,H1(),_r=0}}function $1(){var e=qs.now(),t=e-na;t>dE&&(ra-=t,na=e)}function H1(){for(var e,t=ta,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:ta=n);Qs=e,wd(r)}function wd(e){if(!_o){Ks&&(Ks=clearTimeout(Ks));var t=e-_r;t>24?(e<1/0&&(Ks=setTimeout(hE,e-qs.now()-ra)),Xs&&(Xs=clearInterval(Xs))):(Xs||(na=qs.now(),Xs=setInterval($1,dE)),_o=1,fE(hE))}}function mE(e,t,n){var r=new oa;return t=t==null?0:+t,r.restart(o=>{r.stop(),e(o+t)},t,n),r}var B1=Wl("start","end","cancel","interrupt"),z1=[],gE=0,EE=1,Od=2,sa=3,yE=4,Td=5,ia=6;function la(e,t,n,r,o,s){var i=e.__transition;if(!i)e.__transition={};else if(n in i)return;W1(e,n,{name:t,index:r,group:o,on:B1,tween:z1,time:s.time,delay:s.delay,duration:s.duration,ease:s.ease,timer:null,state:gE})}function Ad(e,t){var n=$t(e,t);if(n.state>gE)throw new Error("too late; already scheduled");return n}function qt(e,t){var n=$t(e,t);if(n.state>sa)throw new Error("too late; already running");return n}function $t(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function W1(e,t,n){var r=e.__transition,o;r[t]=n,n.timer=pE(s,0,n.time);function s(c){n.state=EE,n.timer.restart(i,n.delay,n.time),n.delay<=c&&i(c-n.delay)}function i(c){var u,f,p,h;if(n.state!==EE)return a();for(u in r)if(h=r[u],h.name===n.name){if(h.state===sa)return mE(i);h.state===yE?(h.state=ia,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete r[u]):+u<t&&(h.state=ia,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete r[u])}if(mE(function(){n.state===sa&&(n.state=yE,n.timer.restart(l,n.delay,n.time),l(c))}),n.state=Od,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Od){for(n.state=sa,o=new Array(p=n.tween.length),u=0,f=-1;u<p;++u)(h=n.tween[u].value.call(e,e.__data__,n.index,n.group))&&(o[++f]=h);o.length=f+1}}function l(c){for(var u=c<n.duration?n.ease.call(null,c/n.duration):(n.timer.restart(a),n.state=Td,1),f=-1,p=o.length;++f<p;)o[f].call(e,u);n.state===Td&&(n.on.call("end",e,e.__data__,n.index,n.group),a())}function a(){n.state=ia,n.timer.stop(),delete r[t];for(var c in r)return;delete e.__transition}}function aa(e,t){var n=e.__transition,r,o,s=!0,i;if(n){t=t==null?null:t+"";for(i in n){if((r=n[i]).name!==t){s=!1;continue}o=r.state>Od&&r.state<Td,r.state=ia,r.timer.stop(),r.on.call(o?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[i]}s&&delete e.__transition}}function G1(e){return this.each(function(){aa(this,e)})}function Y1(e,t){var n,r;return function(){var o=qt(this,e),s=o.tween;if(s!==n){r=n=s;for(var i=0,l=r.length;i<l;++i)if(r[i].name===t){r=r.slice(),r.splice(i,1);break}}o.tween=r}}function K1(e,t,n){var r,o;if(typeof n!="function")throw new Error;return function(){var s=qt(this,e),i=s.tween;if(i!==r){o=(r=i).slice();for(var l={name:t,value:n},a=0,c=o.length;a<c;++a)if(o[a].name===t){o[a]=l;break}a===c&&o.push(l)}s.tween=o}}function X1(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=$t(this.node(),n).tween,o=0,s=r.length,i;o<s;++o)if((i=r[o]).name===e)return i.value;return null}return this.each((t==null?Y1:K1)(n,e,t))}function Id(e,t,n){var r=e._id;return e.each(function(){var o=qt(this,r);(o.value||(o.value={}))[t]=n.apply(this,arguments)}),function(o){return $t(o,r).value[t]}}function vE(e,t){var n;return(typeof t=="number"?Hn:t instanceof Ys?iE:(n=Ys(t))?(t=n,iE):C1)(e,t)}function Q1(e){return function(){this.removeAttribute(e)}}function q1(e){return function(){this.removeAttributeNS(e.space,e.local)}}function J1(e,t,n){var r,o=n+"",s;return function(){var i=this.getAttribute(e);return i===o?null:i===r?s:s=t(r=i,n)}}function Z1(e,t,n){var r,o=n+"",s;return function(){var i=this.getAttributeNS(e.space,e.local);return i===o?null:i===r?s:s=t(r=i,n)}}function ew(e,t,n){var r,o,s;return function(){var i,l=n(this),a;return l==null?void this.removeAttribute(e):(i=this.getAttribute(e),a=l+"",i===a?null:i===r&&a===o?s:(o=a,s=t(r=i,l)))}}function tw(e,t,n){var r,o,s;return function(){var i,l=n(this),a;return l==null?void this.removeAttributeNS(e.space,e.local):(i=this.getAttributeNS(e.space,e.local),a=l+"",i===a?null:i===r&&a===o?s:(o=a,s=t(r=i,l)))}}function nw(e,t){var n=Yl(e),r=n==="transform"?k1:vE;return this.attrTween(e,typeof t=="function"?(n.local?tw:ew)(n,r,Id(this,"attr."+e,t)):t==null?(n.local?q1:Q1)(n):(n.local?Z1:J1)(n,r,t))}function rw(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function ow(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function sw(e,t){var n,r;function o(){var s=t.apply(this,arguments);return s!==r&&(n=(r=s)&&ow(e,s)),n}return o._value=t,o}function iw(e,t){var n,r;function o(){var s=t.apply(this,arguments);return s!==r&&(n=(r=s)&&rw(e,s)),n}return o._value=t,o}function lw(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var r=Yl(e);return this.tween(n,(r.local?sw:iw)(r,t))}function aw(e,t){return function(){Ad(this,e).delay=+t.apply(this,arguments)}}function cw(e,t){return t=+t,function(){Ad(this,e).delay=t}}function uw(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?aw:cw)(t,e)):$t(this.node(),t).delay}function dw(e,t){return function(){qt(this,e).duration=+t.apply(this,arguments)}}function fw(e,t){return t=+t,function(){qt(this,e).duration=t}}function pw(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?dw:fw)(t,e)):$t(this.node(),t).duration}function hw(e,t){if(typeof t!="function")throw new Error;return function(){qt(this,e).ease=t}}function mw(e){var t=this._id;return arguments.length?this.each(hw(t,e)):$t(this.node(),t).ease}function gw(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;qt(this,e).ease=n}}function Ew(e){if(typeof e!="function")throw new Error;return this.each(gw(this._id,e))}function yw(e){typeof e!="function"&&(e=Mg(e));for(var t=this._groups,n=t.length,r=new Array(n),o=0;o<n;++o)for(var s=t[o],i=s.length,l=r[o]=[],a,c=0;c<i;++c)(a=s[c])&&e.call(a,a.__data__,c,s)&&l.push(a);return new hn(r,this._parents,this._name,this._id)}function vw(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,r=t.length,o=n.length,s=Math.min(r,o),i=new Array(r),l=0;l<s;++l)for(var a=t[l],c=n[l],u=a.length,f=i[l]=new Array(u),p,h=0;h<u;++h)(p=a[h]||c[h])&&(f[h]=p);for(;l<r;++l)i[l]=t[l];return new hn(i,this._parents,this._name,this._id)}function _w(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function Sw(e,t,n){var r,o,s=_w(t)?Ad:qt;return function(){var i=s(this,e),l=i.on;l!==r&&(o=(r=l).copy()).on(t,n),i.on=o}}function xw(e,t){var n=this._id;return arguments.length<2?$t(this.node(),n).on.on(e):this.each(Sw(n,e,t))}function Rw(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Nw(){return this.on("end.remove",Rw(this._id))}function ww(e){var t=this._name,n=this._id;typeof e!="function"&&(e=hd(e));for(var r=this._groups,o=r.length,s=new Array(o),i=0;i<o;++i)for(var l=r[i],a=l.length,c=s[i]=new Array(a),u,f,p=0;p<a;++p)(u=l[p])&&(f=e.call(u,u.__data__,p,l))&&("__data__"in u&&(f.__data__=u.__data__),c[p]=f,la(c[p],t,n,p,c,$t(u,n)));return new hn(s,this._parents,t,n)}function Ow(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Pg(e));for(var r=this._groups,o=r.length,s=[],i=[],l=0;l<o;++l)for(var a=r[l],c=a.length,u,f=0;f<c;++f)if(u=a[f]){for(var p=e.call(u,u.__data__,f,a),h,E=$t(u,n),y=0,v=p.length;y<v;++y)(h=p[y])&&la(h,t,n,y,p,E);s.push(p),i.push(u)}return new hn(s,i,t,n)}var Tw=Hs.prototype.constructor;function Aw(){return new Tw(this._groups,this._parents)}function Iw(e,t){var n,r,o;return function(){var s=Eo(this,e),i=(this.style.removeProperty(e),Eo(this,e));return s===i?null:s===n&&i===r?o:o=t(n=s,r=i)}}function _E(e){return function(){this.style.removeProperty(e)}}function Cw(e,t,n){var r,o=n+"",s;return function(){var i=Eo(this,e);return i===o?null:i===r?s:s=t(r=i,n)}}function Lw(e,t,n){var r,o,s;return function(){var i=Eo(this,e),l=n(this),a=l+"";return l==null&&(a=l=(this.style.removeProperty(e),Eo(this,e))),i===a?null:i===r&&a===o?s:(o=a,s=t(r=i,l))}}function bw(e,t){var n,r,o,s="style."+t,i="end."+s,l;return function(){var a=qt(this,e),c=a.on,u=a.value[s]==null?l||(l=_E(t)):void 0;(c!==n||o!==u)&&(r=(n=c).copy()).on(i,o=u),a.on=r}}function Dw(e,t,n){var r=(e+="")=="transform"?D1:vE;return t==null?this.styleTween(e,Iw(e,r)).on("end.style."+e,_E(e)):typeof t=="function"?this.styleTween(e,Lw(e,r,Id(this,"style."+e,t))).each(bw(this._id,e)):this.styleTween(e,Cw(e,r,t),n).on("end.style."+e,null)}function kw(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function Pw(e,t,n){var r,o;function s(){var i=t.apply(this,arguments);return i!==o&&(r=(o=i)&&kw(e,i,n)),r}return s._value=t,s}function Mw(e,t,n){var r="style."+(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;return this.tween(r,Pw(e,t,n??""))}function Uw(e){return function(){this.textContent=e}}function Fw(e){return function(){var t=e(this);this.textContent=t??""}}function jw(e){return this.tween("text",typeof e=="function"?Fw(Id(this,"text",e)):Uw(e==null?"":e+""))}function Vw(e){return function(t){this.textContent=e.call(this,t)}}function $w(e){var t,n;function r(){var o=e.apply(this,arguments);return o!==n&&(t=(n=o)&&Vw(o)),t}return r._value=e,r}function Hw(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,$w(e))}function Bw(){for(var e=this._name,t=this._id,n=SE(),r=this._groups,o=r.length,s=0;s<o;++s)for(var i=r[s],l=i.length,a,c=0;c<l;++c)if(a=i[c]){var u=$t(a,t);la(a,e,n,c,i,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new hn(r,this._parents,e,n)}function zw(){var e,t,n=this,r=n._id,o=n.size();return new Promise(function(s,i){var l={value:i},a={value:function(){--o===0&&s()}};n.each(function(){var c=qt(this,r),u=c.on;u!==e&&(t=(e=u).copy(),t._.cancel.push(l),t._.interrupt.push(l),t._.end.push(a)),c.on=t}),o===0&&s()})}var Ww=0;function hn(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function SE(){return++Ww}var mn=Hs.prototype;hn.prototype={constructor:hn,select:ww,selectAll:Ow,selectChild:mn.selectChild,selectChildren:mn.selectChildren,filter:yw,merge:vw,selection:Aw,transition:Bw,call:mn.call,nodes:mn.nodes,node:mn.node,size:mn.size,empty:mn.empty,each:mn.each,on:xw,attr:nw,attrTween:lw,style:Dw,styleTween:Mw,text:jw,textTween:Hw,remove:Nw,tween:X1,delay:uw,duration:pw,ease:mw,easeVarying:Ew,end:zw,[Symbol.iterator]:mn[Symbol.iterator]};function Gw(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Yw={time:null,delay:0,duration:250,ease:Gw};function Kw(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function Xw(e){var t,n;e instanceof hn?(t=e._id,e=e._name):(t=SE(),(n=Yw).time=Nd(),e=e==null?null:e+"");for(var r=this._groups,o=r.length,s=0;s<o;++s)for(var i=r[s],l=i.length,a,c=0;c<l;++c)(a=i[c])&&la(a,e,t,c,i,n||Kw(a,t));return new hn(r,this._parents,e,t)}Hs.prototype.interrupt=G1,Hs.prototype.transition=Xw;const ca=e=>()=>e;function Qw(e,{sourceEvent:t,target:n,transform:r,dispatch:o}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:o}})}function gn(e,t,n){this.k=e,this.x=t,this.y=n}gn.prototype={constructor:gn,scale:function(e){return e===1?this:new gn(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new gn(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 Bn=new gn(1,0,0);gn.prototype;function Cd(e){e.stopImmediatePropagation()}function Js(e){e.preventDefault(),e.stopImmediatePropagation()}function qw(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Jw(){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 xE(){return this.__zoom||Bn}function Zw(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function eO(){return navigator.maxTouchPoints||"ontouchstart"in this}function tO(e,t,n){var r=e.invertX(t[0][0])-n[0][0],o=e.invertX(t[1][0])-n[1][0],s=e.invertY(t[0][1])-n[0][1],i=e.invertY(t[1][1])-n[1][1];return e.translate(o>r?(r+o)/2:Math.min(0,r)||Math.max(0,o),i>s?(s+i)/2:Math.min(0,s)||Math.max(0,i))}function nO(){var e=qw,t=Jw,n=tO,r=Zw,o=eO,s=[0,1/0],i=[[-1/0,-1/0],[1/0,1/0]],l=250,a=F1,c=Wl("start","zoom","end"),u,f,p,h=500,E=150,y=0,v=10;function m(w){w.property("__zoom",xE).on("wheel.zoom",L,{passive:!1}).on("mousedown.zoom",P).on("dblclick.zoom",I).filter(o).on("touchstart.zoom",j).on("touchmove.zoom",V).on("touchend.zoom touchcancel.zoom",M).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}m.transform=function(w,b,k,F){var C=w.selection?w.selection():w;C.property("__zoom",xE),w!==C?x(w,b,k,F):C.interrupt().each(function(){R(this,arguments).event(F).start().zoom(null,typeof b=="function"?b.apply(this,arguments):b).end()})},m.scaleBy=function(w,b,k,F){m.scaleTo(w,function(){var C=this.__zoom.k,D=typeof b=="function"?b.apply(this,arguments):b;return C*D},k,F)},m.scaleTo=function(w,b,k,F){m.transform(w,function(){var C=t.apply(this,arguments),D=this.__zoom,U=k==null?_(C):typeof k=="function"?k.apply(this,arguments):k,$=D.invert(U),B=typeof b=="function"?b.apply(this,arguments):b;return n(S(g(D,B),U,$),C,i)},k,F)},m.translateBy=function(w,b,k,F){m.transform(w,function(){return n(this.__zoom.translate(typeof b=="function"?b.apply(this,arguments):b,typeof k=="function"?k.apply(this,arguments):k),t.apply(this,arguments),i)},null,F)},m.translateTo=function(w,b,k,F,C){m.transform(w,function(){var D=t.apply(this,arguments),U=this.__zoom,$=F==null?_(D):typeof F=="function"?F.apply(this,arguments):F;return n(Bn.translate($[0],$[1]).scale(U.k).translate(typeof b=="function"?-b.apply(this,arguments):-b,typeof k=="function"?-k.apply(this,arguments):-k),D,i)},F,C)};function g(w,b){return b=Math.max(s[0],Math.min(s[1],b)),b===w.k?w:new gn(b,w.x,w.y)}function S(w,b,k){var F=b[0]-k[0]*w.k,C=b[1]-k[1]*w.k;return F===w.x&&C===w.y?w:new gn(w.k,F,C)}function _(w){return[(+w[0][0]+ +w[1][0])/2,(+w[0][1]+ +w[1][1])/2]}function x(w,b,k,F){w.on("start.zoom",function(){R(this,arguments).event(F).start()}).on("interrupt.zoom end.zoom",function(){R(this,arguments).event(F).end()}).tween("zoom",function(){var C=this,D=arguments,U=R(C,D).event(F),$=t.apply(C,D),B=k==null?_($):typeof k=="function"?k.apply(C,D):k,W=Math.max($[1][0]-$[0][0],$[1][1]-$[0][1]),z=C.__zoom,Y=typeof b=="function"?b.apply(C,D):b,X=a(z.invert(B).concat(W/z.k),Y.invert(B).concat(W/Y.k));return function(Z){if(Z===1)Z=Y;else{var J=X(Z),te=W/J[2];Z=new gn(te,B[0]-J[0]*te,B[1]-J[1]*te)}U.zoom(null,Z)}})}function R(w,b,k){return!k&&w.__zooming||new T(w,b)}function T(w,b){this.that=w,this.args=b,this.active=0,this.sourceEvent=null,this.extent=t.apply(w,b),this.taps=0}T.prototype={event:function(w){return w&&(this.sourceEvent=w),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(w,b){return this.mouse&&w!=="mouse"&&(this.mouse[1]=b.invert(this.mouse[0])),this.touch0&&w!=="touch"&&(this.touch0[1]=b.invert(this.touch0[0])),this.touch1&&w!=="touch"&&(this.touch1[1]=b.invert(this.touch1[0])),this.that.__zoom=b,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(w){var b=jt(this.that).datum();c.call(w,this.that,new Qw(w,{sourceEvent:this.sourceEvent,target:m,type:w,transform:this.that.__zoom,dispatch:c}),b)}};function L(w,...b){if(!e.apply(this,arguments))return;var k=R(this,b).event(w),F=this.__zoom,C=Math.max(s[0],Math.min(s[1],F.k*Math.pow(2,r.apply(this,arguments)))),D=Xt(w);if(k.wheel)(k.mouse[0][0]!==D[0]||k.mouse[0][1]!==D[1])&&(k.mouse[1]=F.invert(k.mouse[0]=D)),clearTimeout(k.wheel);else{if(F.k===C)return;k.mouse=[D,F.invert(D)],aa(this),k.start()}Js(w),k.wheel=setTimeout(U,E),k.zoom("mouse",n(S(g(F,C),k.mouse[0],k.mouse[1]),k.extent,i));function U(){k.wheel=null,k.end()}}function P(w,...b){if(p||!e.apply(this,arguments))return;var k=w.currentTarget,F=R(this,b,!0).event(w),C=jt(w.view).on("mousemove.zoom",B,!0).on("mouseup.zoom",W,!0),D=Xt(w,k),U=w.clientX,$=w.clientY;Gg(w.view),Cd(w),F.mouse=[D,this.__zoom.invert(D)],aa(this),F.start();function B(z){if(Js(z),!F.moved){var Y=z.clientX-U,X=z.clientY-$;F.moved=Y*Y+X*X>y}F.event(z).zoom("mouse",n(S(F.that.__zoom,F.mouse[0]=Xt(z,k),F.mouse[1]),F.extent,i))}function W(z){C.on("mousemove.zoom mouseup.zoom",null),Yg(z.view,F.moved),Js(z),F.event(z).end()}}function I(w,...b){if(e.apply(this,arguments)){var k=this.__zoom,F=Xt(w.changedTouches?w.changedTouches[0]:w,this),C=k.invert(F),D=k.k*(w.shiftKey?.5:2),U=n(S(g(k,D),F,C),t.apply(this,b),i);Js(w),l>0?jt(this).transition().duration(l).call(x,U,F,w):jt(this).call(m.transform,U,F,w)}}function j(w,...b){if(e.apply(this,arguments)){var k=w.touches,F=k.length,C=R(this,b,w.changedTouches.length===F).event(w),D,U,$,B;for(Cd(w),U=0;U<F;++U)$=k[U],B=Xt($,this),B=[B,this.__zoom.invert(B),$.identifier],C.touch0?!C.touch1&&C.touch0[2]!==B[2]&&(C.touch1=B,C.taps=0):(C.touch0=B,D=!0,C.taps=1+!!u);u&&(u=clearTimeout(u)),D&&(C.taps<2&&(f=B[0],u=setTimeout(function(){u=null},h)),aa(this),C.start())}}function V(w,...b){if(this.__zooming){var k=R(this,b).event(w),F=w.changedTouches,C=F.length,D,U,$,B;for(Js(w),D=0;D<C;++D)U=F[D],$=Xt(U,this),k.touch0&&k.touch0[2]===U.identifier?k.touch0[0]=$:k.touch1&&k.touch1[2]===U.identifier&&(k.touch1[0]=$);if(U=k.that.__zoom,k.touch1){var W=k.touch0[0],z=k.touch0[1],Y=k.touch1[0],X=k.touch1[1],Z=(Z=Y[0]-W[0])*Z+(Z=Y[1]-W[1])*Z,J=(J=X[0]-z[0])*J+(J=X[1]-z[1])*J;U=g(U,Math.sqrt(Z/J)),$=[(W[0]+Y[0])/2,(W[1]+Y[1])/2],B=[(z[0]+X[0])/2,(z[1]+X[1])/2]}else if(k.touch0)$=k.touch0[0],B=k.touch0[1];else return;k.zoom("touch",n(S(U,$,B),k.extent,i))}}function M(w,...b){if(this.__zooming){var k=R(this,b).event(w),F=w.changedTouches,C=F.length,D,U;for(Cd(w),p&&clearTimeout(p),p=setTimeout(function(){p=null},h),D=0;D<C;++D)U=F[D],k.touch0&&k.touch0[2]===U.identifier?delete k.touch0:k.touch1&&k.touch1[2]===U.identifier&&delete k.touch1;if(k.touch1&&!k.touch0&&(k.touch0=k.touch1,delete k.touch1),k.touch0)k.touch0[1]=this.__zoom.invert(k.touch0[0]);else if(k.end(),k.taps===2&&(U=Xt(U,this),Math.hypot(f[0]-U[0],f[1]-U[1])<v)){var $=jt(this).on("dblclick.zoom");$&&$.apply(this,arguments)}}}return m.wheelDelta=function(w){return arguments.length?(r=typeof w=="function"?w:ca(+w),m):r},m.filter=function(w){return arguments.length?(e=typeof w=="function"?w:ca(!!w),m):e},m.touchable=function(w){return arguments.length?(o=typeof w=="function"?w:ca(!!w),m):o},m.extent=function(w){return arguments.length?(t=typeof w=="function"?w:ca([[+w[0][0],+w[0][1]],[+w[1][0],+w[1][1]]]),m):t},m.scaleExtent=function(w){return arguments.length?(s[0]=+w[0],s[1]=+w[1],m):[s[0],s[1]]},m.translateExtent=function(w){return arguments.length?(i[0][0]=+w[0][0],i[1][0]=+w[1][0],i[0][1]=+w[0][1],i[1][1]=+w[1][1],m):[[i[0][0],i[0][1]],[i[1][0],i[1][1]]]},m.constrain=function(w){return arguments.length?(n=w,m):n},m.duration=function(w){return arguments.length?(l=+w,m):l},m.interpolate=function(w){return arguments.length?(a=w,m):a},m.on=function(){var w=c.on.apply(c,arguments);return w===c?m:w},m.clickDistance=function(w){return arguments.length?(y=(w=+w)*w,m):Math.sqrt(y)},m.tapDistance=function(w){return arguments.length?(v=+w,m):v},m}const ua=O.createContext(null),rO=ua.Provider,En={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.`},RE=En.error001();function de(e,t){const n=O.useContext(ua);if(n===null)throw new Error(RE);return Cg(n,e,t)}const Ie=()=>{const e=O.useContext(ua);if(e===null)throw new Error(RE);return O.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe,destroy:e.destroy}),[e])},oO=e=>e.userSelectionActive?"none":"all";function Zs({position:e,children:t,className:n,style:r,...o}){const s=de(oO),i=`${e}`.split("-");return H.createElement("div",{className:Je(["react-flow__panel",n,...i]),style:{...r,pointerEvents:s},...o},t)}function sO({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:H.createElement(Zs,{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"},H.createElement("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution"},"React Flow"))}const iO=({x:e,y:t,label:n,labelStyle:r={},labelShowBg:o=!0,labelBgStyle:s={},labelBgPadding:i=[2,4],labelBgBorderRadius:l=2,children:a,className:c,...u})=>{const f=O.useRef(null),[p,h]=O.useState({x:0,y:0,width:0,height:0}),E=Je(["react-flow__edge-textwrapper",c]);return O.useEffect(()=>{if(f.current){const y=f.current.getBBox();h({x:y.x,y:y.y,width:y.width,height:y.height})}},[n]),typeof n>"u"||!n?null:H.createElement("g",{transform:`translate(${e-p.width/2} ${t-p.height/2})`,className:E,visibility:p.width?"visible":"hidden",...u},o&&H.createElement("rect",{width:p.width+2*i[0],x:-i[0],y:-i[1],height:p.height+2*i[1],className:"react-flow__edge-textbg",style:s,rx:l,ry:l}),H.createElement("text",{className:"react-flow__edge-text",y:p.height/2,dy:"0.3em",ref:f,style:r},n),a)};var lO=O.memo(iO);const Ld=e=>({width:e.offsetWidth,height:e.offsetHeight}),So=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),bd=(e={x:0,y:0},t)=>({x:So(e.x,t[0][0],t[1][0]),y:So(e.y,t[0][1],t[1][1])}),NE=(e,t,n)=>e<t?So(Math.abs(e-t),1,50)/50:e>n?-So(Math.abs(e-n),1,50)/50:0,wE=(e,t)=>{const n=NE(e.x,35,t.width-35)*20,r=NE(e.y,35,t.height-35)*20;return[n,r]},OE=e=>{var t;return((t=e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},aO=(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)}),Dd=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),cO=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),TE=e=>({...e.positionAbsolute||{x:0,y:0},width:e.width||0,height:e.height||0}),kd=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),r=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*r)},uO=e=>It(e.width)&&It(e.height)&&It(e.x)&&It(e.y),It=e=>!isNaN(e)&&isFinite(e),Ce=Symbol.for("internals"),AE=["Enter"," ","Escape"],dO=(e,t)=>{},fO=e=>"nativeEvent"in e;function Pd(e){var o,s;const t=fO(e)?e.nativeEvent:e,n=((s=(o=t.composedPath)==null?void 0:o.call(t))==null?void 0:s[0])||e.target;return["INPUT","SELECT","TEXTAREA"].includes(n==null?void 0:n.nodeName)||(n==null?void 0:n.hasAttribute("contenteditable"))||!!(n!=null&&n.closest(".nokey"))}const IE=e=>"clientX"in e,zn=(e,t)=>{var s,i;const n=IE(e),r=n?e.clientX:(s=e.touches)==null?void 0:s[0].clientX,o=n?e.clientY:(i=e.touches)==null?void 0:i[0].clientY;return{x:r-((t==null?void 0:t.left)??0),y:o-((t==null?void 0:t.top)??0)}},da=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0},xo=({id:e,path:t,labelX:n,labelY:r,label:o,labelStyle:s,labelShowBg:i,labelBgStyle:l,labelBgPadding:a,labelBgBorderRadius:c,style:u,markerEnd:f,markerStart:p,interactionWidth:h=20})=>H.createElement(H.Fragment,null,H.createElement("path",{id:e,style:u,d:t,fill:"none",className:"react-flow__edge-path",markerEnd:f,markerStart:p}),h&&H.createElement("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:h,className:"react-flow__edge-interaction"}),o&&It(n)&&It(r)?H.createElement(lO,{x:n,y:r,label:o,labelStyle:s,labelShowBg:i,labelBgStyle:l,labelBgPadding:a,labelBgBorderRadius:c}):null);xo.displayName="BaseEdge";function ei(e,t,n){return n===void 0?n:r=>{const o=t().edges.find(s=>s.id===e);o&&n(r,{...o})}}function CE({sourceX:e,sourceY:t,targetX:n,targetY:r}){const o=Math.abs(n-e)/2,s=n<e?n+o:n-o,i=Math.abs(r-t)/2,l=r<t?r+i:r-i;return[s,l,o,i]}function LE({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:o,sourceControlY:s,targetControlX:i,targetControlY:l}){const a=e*.125+o*.375+i*.375+n*.125,c=t*.125+s*.375+l*.375+r*.125,u=Math.abs(a-e),f=Math.abs(c-t);return[a,c,u,f]}var Wn;(function(e){e.Strict="strict",e.Loose="loose"})(Wn||(Wn={}));var Sr;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Sr||(Sr={}));var ti;(function(e){e.Partial="partial",e.Full="full"})(ti||(ti={}));var Gn;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Gn||(Gn={}));var ni;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(ni||(ni={}));var q;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(q||(q={}));function bE({pos:e,x1:t,y1:n,x2:r,y2:o}){return e===q.Left||e===q.Right?[.5*(t+r),n]:[t,.5*(n+o)]}function DE({sourceX:e,sourceY:t,sourcePosition:n=q.Bottom,targetX:r,targetY:o,targetPosition:s=q.Top}){const[i,l]=bE({pos:n,x1:e,y1:t,x2:r,y2:o}),[a,c]=bE({pos:s,x1:r,y1:o,x2:e,y2:t}),[u,f,p,h]=LE({sourceX:e,sourceY:t,targetX:r,targetY:o,sourceControlX:i,sourceControlY:l,targetControlX:a,targetControlY:c});return[`M${e},${t} C${i},${l} ${a},${c} ${r},${o}`,u,f,p,h]}const Md=O.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,sourcePosition:o=q.Bottom,targetPosition:s=q.Top,label:i,labelStyle:l,labelShowBg:a,labelBgStyle:c,labelBgPadding:u,labelBgBorderRadius:f,style:p,markerEnd:h,markerStart:E,interactionWidth:y})=>{const[v,m,g]=DE({sourceX:e,sourceY:t,sourcePosition:o,targetX:n,targetY:r,targetPosition:s});return H.createElement(xo,{path:v,labelX:m,labelY:g,label:i,labelStyle:l,labelShowBg:a,labelBgStyle:c,labelBgPadding:u,labelBgBorderRadius:f,style:p,markerEnd:h,markerStart:E,interactionWidth:y})});Md.displayName="SimpleBezierEdge";const kE={[q.Left]:{x:-1,y:0},[q.Right]:{x:1,y:0},[q.Top]:{x:0,y:-1},[q.Bottom]:{x:0,y:1}},pO=({source:e,sourcePosition:t=q.Bottom,target:n})=>t===q.Left||t===q.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},PE=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function hO({source:e,sourcePosition:t=q.Bottom,target:n,targetPosition:r=q.Top,center:o,offset:s}){const i=kE[t],l=kE[r],a={x:e.x+i.x*s,y:e.y+i.y*s},c={x:n.x+l.x*s,y:n.y+l.y*s},u=pO({source:a,sourcePosition:t,target:c}),f=u.x!==0?"x":"y",p=u[f];let h=[],E,y;const v={x:0,y:0},m={x:0,y:0},[g,S,_,x]=CE({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(i[f]*l[f]===-1){E=o.x||g,y=o.y||S;const T=[{x:E,y:a.y},{x:E,y:c.y}],L=[{x:a.x,y},{x:c.x,y}];i[f]===p?h=f==="x"?T:L:h=f==="x"?L:T}else{const T=[{x:a.x,y:c.y}],L=[{x:c.x,y:a.y}];if(f==="x"?h=i.x===p?L:T:h=i.y===p?T:L,t===r){const M=Math.abs(e[f]-n[f]);if(M<=s){const w=Math.min(s-1,s-M);i[f]===p?v[f]=(a[f]>e[f]?-1:1)*w:m[f]=(c[f]>n[f]?-1:1)*w}}if(t!==r){const M=f==="x"?"y":"x",w=i[f]===l[M],b=a[M]>c[M],k=a[M]<c[M];(i[f]===1&&(!w&&b||w&&k)||i[f]!==1&&(!w&&k||w&&b))&&(h=f==="x"?T:L)}const P={x:a.x+v.x,y:a.y+v.y},I={x:c.x+m.x,y:c.y+m.y},j=Math.max(Math.abs(P.x-h[0].x),Math.abs(I.x-h[0].x)),V=Math.max(Math.abs(P.y-h[0].y),Math.abs(I.y-h[0].y));j>=V?(E=(P.x+I.x)/2,y=h[0].y):(E=h[0].x,y=(P.y+I.y)/2)}return[[e,{x:a.x+v.x,y:a.y+v.y},...h,{x:c.x+m.x,y:c.y+m.y},n],E,y,_,x]}function mO(e,t,n,r){const o=Math.min(PE(e,t)/2,PE(t,n)/2,r),{x:s,y:i}=t;if(e.x===s&&s===n.x||e.y===i&&i===n.y)return`L${s} ${i}`;if(e.y===i){const c=e.x<n.x?-1:1,u=e.y<n.y?1:-1;return`L ${s+o*c},${i}Q ${s},${i} ${s},${i+o*u}`}const l=e.x<n.x?1:-1,a=e.y<n.y?-1:1;return`L ${s},${i+o*a}Q ${s},${i} ${s+o*l},${i}`}function ri({sourceX:e,sourceY:t,sourcePosition:n=q.Bottom,targetX:r,targetY:o,targetPosition:s=q.Top,borderRadius:i=5,centerX:l,centerY:a,offset:c=20}){const[u,f,p,h,E]=hO({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:o},targetPosition:s,center:{x:l,y:a},offset:c});return[u.reduce((v,m,g)=>{let S="";return g>0&&g<u.length-1?S=mO(u[g-1],m,u[g+1],i):S=`${g===0?"M":"L"}${m.x} ${m.y}`,v+=S,v},""),f,p,h,E]}const fa=O.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,label:o,labelStyle:s,labelShowBg:i,labelBgStyle:l,labelBgPadding:a,labelBgBorderRadius:c,style:u,sourcePosition:f=q.Bottom,targetPosition:p=q.Top,markerEnd:h,markerStart:E,pathOptions:y,interactionWidth:v})=>{const[m,g,S]=ri({sourceX:e,sourceY:t,sourcePosition:f,targetX:n,targetY:r,targetPosition:p,borderRadius:y==null?void 0:y.borderRadius,offset:y==null?void 0:y.offset});return H.createElement(xo,{path:m,labelX:g,labelY:S,label:o,labelStyle:s,labelShowBg:i,labelBgStyle:l,labelBgPadding:a,labelBgBorderRadius:c,style:u,markerEnd:h,markerStart:E,interactionWidth:v})});fa.displayName="SmoothStepEdge";const Ud=O.memo(e=>{var t;return H.createElement(fa,{...e,pathOptions:O.useMemo(()=>{var n;return{borderRadius:0,offset:(n=e.pathOptions)==null?void 0:n.offset}},[(t=e.pathOptions)==null?void 0:t.offset])})});Ud.displayName="StepEdge";function gO({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[o,s,i,l]=CE({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,o,s,i,l]}const Fd=O.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,label:o,labelStyle:s,labelShowBg:i,labelBgStyle:l,labelBgPadding:a,labelBgBorderRadius:c,style:u,markerEnd:f,markerStart:p,interactionWidth:h})=>{const[E,y,v]=gO({sourceX:e,sourceY:t,targetX:n,targetY:r});return H.createElement(xo,{path:E,labelX:y,labelY:v,label:o,labelStyle:s,labelShowBg:i,labelBgStyle:l,labelBgPadding:a,labelBgBorderRadius:c,style:u,markerEnd:f,markerStart:p,interactionWidth:h})});Fd.displayName="StraightEdge";function pa(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function ME({pos:e,x1:t,y1:n,x2:r,y2:o,c:s}){switch(e){case q.Left:return[t-pa(t-r,s),n];case q.Right:return[t+pa(r-t,s),n];case q.Top:return[t,n-pa(n-o,s)];case q.Bottom:return[t,n+pa(o-n,s)]}}function UE({sourceX:e,sourceY:t,sourcePosition:n=q.Bottom,targetX:r,targetY:o,targetPosition:s=q.Top,curvature:i=.25}){const[l,a]=ME({pos:n,x1:e,y1:t,x2:r,y2:o,c:i}),[c,u]=ME({pos:s,x1:r,y1:o,x2:e,y2:t,c:i}),[f,p,h,E]=LE({sourceX:e,sourceY:t,targetX:r,targetY:o,sourceControlX:l,sourceControlY:a,targetControlX:c,targetControlY:u});return[`M${e},${t} C${l},${a} ${c},${u} ${r},${o}`,f,p,h,E]}const ha=O.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,sourcePosition:o=q.Bottom,targetPosition:s=q.Top,label:i,labelStyle:l,labelShowBg:a,labelBgStyle:c,labelBgPadding:u,labelBgBorderRadius:f,style:p,markerEnd:h,markerStart:E,pathOptions:y,interactionWidth:v})=>{const[m,g,S]=UE({sourceX:e,sourceY:t,sourcePosition:o,targetX:n,targetY:r,targetPosition:s,curvature:y==null?void 0:y.curvature});return H.createElement(xo,{path:m,labelX:g,labelY:S,label:i,labelStyle:l,labelShowBg:a,labelBgStyle:c,labelBgPadding:u,labelBgBorderRadius:f,style:p,markerEnd:h,markerStart:E,interactionWidth:v})});ha.displayName="BezierEdge";const jd=O.createContext(null),EO=jd.Provider;jd.Consumer;const yO=()=>O.useContext(jd),vO=e=>"id"in e&&"source"in e&&"target"in e,FE=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`reactflow__edge-${e}${t||""}-${n}${r||""}`,Vd=(e,t)=>typeof e>"u"?"":typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`,_O=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),jE=(e,t)=>{if(!e.source||!e.target)return t;let n;return vO(e)?n={...e}:n={...e,id:FE(e)},_O(n,t)?t:t.concat(n)},SO=(e,t,n,r={shouldReplaceId:!0})=>{const{id:o,...s}=e;if(!t.source||!t.target||!n.find(a=>a.id===o))return n;const l={...s,id:r.shouldReplaceId?FE(t):o,source:t.source,target:t.target,sourceHandle:t.sourceHandle,targetHandle:t.targetHandle};return n.filter(a=>a.id!==o).concat(l)},$d=({x:e,y:t},[n,r,o],s,[i,l])=>{const a={x:(e-n)/o,y:(t-r)/o};return s?{x:i*Math.round(a.x/i),y:l*Math.round(a.y/l)}:a},VE=({x:e,y:t},[n,r,o])=>({x:e*o+n,y:t*o+r}),Ro=(e,t=[0,0])=>{if(!e)return{x:0,y:0,positionAbsolute:{x:0,y:0}};const n=(e.width??0)*t[0],r=(e.height??0)*t[1],o={x:e.position.x-n,y:e.position.y-r};return{...o,positionAbsolute:e.positionAbsolute?{x:e.positionAbsolute.x-n,y:e.positionAbsolute.y-r}:o}},Hd=(e,t=[0,0])=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((r,o)=>{const{x:s,y:i}=Ro(o,t).positionAbsolute;return aO(r,Dd({x:s,y:i,width:o.width||0,height:o.height||0}))},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return cO(n)},$E=(e,t,[n,r,o]=[0,0,1],s=!1,i=!1,l=[0,0])=>{const a={x:(t.x-n)/o,y:(t.y-r)/o,width:t.width/o,height:t.height/o},c=[];return e.forEach(u=>{const{width:f,height:p,selectable:h=!0,hidden:E=!1}=u;if(i&&!h||E)return!1;const{positionAbsolute:y}=Ro(u,l),v={x:y.x,y:y.y,width:f||0,height:p||0},m=kd(a,v),g=typeof f>"u"||typeof p>"u"||f===null||p===null,S=s&&m>0,_=(f||0)*(p||0);(g||S||m>=_||u.dragging)&&c.push(u)}),c},HE=(e,t)=>{const n=e.map(r=>r.id);return t.filter(r=>n.includes(r.source)||n.includes(r.target))},BE=(e,t,n,r,o,s=.1)=>{const i=t/(e.width*(1+s)),l=n/(e.height*(1+s)),a=Math.min(i,l),c=So(a,r,o),u=e.x+e.width/2,f=e.y+e.height/2,p=t/2-u*c,h=n/2-f*c;return{x:p,y:h,zoom:c}},xr=(e,t=0)=>e.transition().duration(t);function zE(e,t,n,r){return(t[n]||[]).reduce((o,s)=>{var i,l;return`${e.id}-${s.id}-${n}`!==r&&o.push({id:s.id||null,type:n,nodeId:e.id,x:(((i=e.positionAbsolute)==null?void 0:i.x)??0)+s.x+s.width/2,y:(((l=e.positionAbsolute)==null?void 0:l.y)??0)+s.y+s.height/2}),o},[])}function xO(e,t,n,r,o,s){const{x:i,y:l}=zn(e),c=t.elementsFromPoint(i,l).find(E=>E.classList.contains("react-flow__handle"));if(c){const E=c.getAttribute("data-nodeid");if(E){const y=Bd(void 0,c),v=c.getAttribute("data-handleid"),m=s({nodeId:E,id:v,type:y});if(m){const g=o.find(S=>S.nodeId===E&&S.type===y&&S.id===v);return{handle:{id:v,type:y,nodeId:E,x:(g==null?void 0:g.x)||n.x,y:(g==null?void 0:g.y)||n.y},validHandleResult:m}}}}let u=[],f=1/0;if(o.forEach(E=>{const y=Math.sqrt((E.x-n.x)**2+(E.y-n.y)**2);if(y<=r){const v=s(E);y<=f&&(y<f?u=[{handle:E,validHandleResult:v}]:y===f&&u.push({handle:E,validHandleResult:v}),f=y)}}),!u.length)return{handle:null,validHandleResult:WE()};if(u.length===1)return u[0];const p=u.some(({validHandleResult:E})=>E.isValid),h=u.some(({handle:E})=>E.type==="target");return u.find(({handle:E,validHandleResult:y})=>h?E.type==="target":p?y.isValid:!0)||u[0]}const RO={source:null,target:null,sourceHandle:null,targetHandle:null},WE=()=>({handleDomNode:null,isValid:!1,connection:RO,endHandle:null});function GE(e,t,n,r,o,s,i){const l=o==="target",a=i.querySelector(`.react-flow__handle[data-id="${e==null?void 0:e.nodeId}-${e==null?void 0:e.id}-${e==null?void 0:e.type}"]`),c={...WE(),handleDomNode:a};if(a){const u=Bd(void 0,a),f=a.getAttribute("data-nodeid"),p=a.getAttribute("data-handleid"),h=a.classList.contains("connectable"),E=a.classList.contains("connectableend"),y={source:l?f:n,sourceHandle:l?p:r,target:l?n:f,targetHandle:l?r:p};c.connection=y,h&&E&&(t===Wn.Strict?l&&u==="source"||!l&&u==="target":f!==n||p!==r)&&(c.endHandle={nodeId:f,handleId:p,type:u},c.isValid=s(y))}return c}function NO({nodes:e,nodeId:t,handleId:n,handleType:r}){return e.reduce((o,s)=>{if(s[Ce]){const{handleBounds:i}=s[Ce];let l=[],a=[];i&&(l=zE(s,i,"source",`${t}-${n}-${r}`),a=zE(s,i,"target",`${t}-${n}-${r}`)),o.push(...l,...a)}return o},[])}function Bd(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function zd(e){e==null||e.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function wO(e,t){let n=null;return t?n="valid":e&&!t&&(n="invalid"),n}function YE({event:e,handleId:t,nodeId:n,onConnect:r,isTarget:o,getState:s,setState:i,isValidConnection:l,edgeUpdaterType:a,onEdgeUpdateEnd:c}){const u=OE(e.target),{connectionMode:f,domNode:p,autoPanOnConnect:h,connectionRadius:E,onConnectStart:y,panBy:v,getNodes:m,cancelConnection:g}=s();let S=0,_;const{x,y:R}=zn(e),T=u==null?void 0:u.elementFromPoint(x,R),L=Bd(a,T),P=p==null?void 0:p.getBoundingClientRect();if(!P||!L)return;let I,j=zn(e,P),V=!1,M=null,w=!1,b=null;const k=NO({nodes:m(),nodeId:n,handleId:t,handleType:L}),F=()=>{if(!h)return;const[U,$]=wE(j,P);v({x:U,y:$}),S=requestAnimationFrame(F)};i({connectionPosition:j,connectionStatus:null,connectionNodeId:n,connectionHandleId:t,connectionHandleType:L,connectionStartHandle:{nodeId:n,handleId:t,type:L},connectionEndHandle:null}),y==null||y(e,{nodeId:n,handleId:t,handleType:L});function C(U){const{transform:$}=s();j=zn(U,P);const{handle:B,validHandleResult:W}=xO(U,u,$d(j,$,!1,[1,1]),E,k,z=>GE(z,f,n,t,o?"target":"source",l,u));if(_=B,V||(F(),V=!0),b=W.handleDomNode,M=W.connection,w=W.isValid,i({connectionPosition:_&&w?VE({x:_.x,y:_.y},$):j,connectionStatus:wO(!!_,w),connectionEndHandle:W.endHandle}),!_&&!w&&!b)return zd(I);M.source!==M.target&&b&&(zd(I),I=b,b.classList.add("connecting","react-flow__handle-connecting"),b.classList.toggle("valid",w),b.classList.toggle("react-flow__handle-valid",w))}function D(U){var $,B;(_||b)&&M&&w&&(r==null||r(M)),(B=($=s()).onConnectEnd)==null||B.call($,U),a&&(c==null||c(U)),zd(I),g(),cancelAnimationFrame(S),V=!1,w=!1,M=null,b=null,u.removeEventListener("mousemove",C),u.removeEventListener("mouseup",D),u.removeEventListener("touchmove",C),u.removeEventListener("touchend",D)}u.addEventListener("mousemove",C),u.addEventListener("mouseup",D),u.addEventListener("touchmove",C),u.addEventListener("touchend",D)}const KE=()=>!0,OO=e=>({connectionStartHandle:e.connectionStartHandle,connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName}),TO=(e,t,n)=>r=>{const{connectionStartHandle:o,connectionEndHandle:s,connectionClickStartHandle:i}=r;return{connecting:(o==null?void 0:o.nodeId)===e&&(o==null?void 0:o.handleId)===t&&(o==null?void 0:o.type)===n||(s==null?void 0:s.nodeId)===e&&(s==null?void 0:s.handleId)===t&&(s==null?void 0:s.type)===n,clickConnecting:(i==null?void 0:i.nodeId)===e&&(i==null?void 0:i.handleId)===t&&(i==null?void 0:i.type)===n}},XE=O.forwardRef(({type:e="source",position:t=q.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:o=!0,isConnectableEnd:s=!0,id:i,onConnect:l,children:a,className:c,onMouseDown:u,onTouchStart:f,...p},h)=>{var P,I;const E=i||null,y=e==="target",v=Ie(),m=yO(),{connectOnClick:g,noPanClassName:S}=de(OO,Ge),{connecting:_,clickConnecting:x}=de(TO(m,E,e),Ge);m||(I=(P=v.getState()).onError)==null||I.call(P,"010",En.error010());const R=j=>{const{defaultEdgeOptions:V,onConnect:M,hasDefaultEdges:w}=v.getState(),b={...V,...j};if(w){const{edges:k,setEdges:F}=v.getState();F(jE(b,k))}M==null||M(b),l==null||l(b)},T=j=>{if(!m)return;const V=IE(j);o&&(V&&j.button===0||!V)&&YE({event:j,handleId:E,nodeId:m,onConnect:R,isTarget:y,getState:v.getState,setState:v.setState,isValidConnection:n||v.getState().isValidConnection||KE}),V?u==null||u(j):f==null||f(j)},L=j=>{const{onClickConnectStart:V,onClickConnectEnd:M,connectionClickStartHandle:w,connectionMode:b,isValidConnection:k}=v.getState();if(!m||!w&&!o)return;if(!w){V==null||V(j,{nodeId:m,handleId:E,handleType:e}),v.setState({connectionClickStartHandle:{nodeId:m,type:e,handleId:E}});return}const F=OE(j.target),C=n||k||KE,{connection:D,isValid:U}=GE({nodeId:m,id:E,type:e},b,w.nodeId,w.handleId||null,w.type,C,F);U&&R(D),M==null||M(j),v.setState({connectionClickStartHandle:null})};return H.createElement("div",{"data-handleid":E,"data-nodeid":m,"data-handlepos":t,"data-id":`${m}-${E}-${e}`,className:Je(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",S,c,{source:!y,target:y,connectable:r,connectablestart:o,connectableend:s,connecting:x,connectionindicator:r&&(o&&!_||s&&_)}]),onMouseDown:T,onTouchStart:T,onClick:g?L:void 0,ref:h,...p},a)});XE.displayName="Handle";var No=O.memo(XE);const QE=({data:e,isConnectable:t,targetPosition:n=q.Top,sourcePosition:r=q.Bottom})=>H.createElement(H.Fragment,null,H.createElement(No,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,H.createElement(No,{type:"source",position:r,isConnectable:t}));QE.displayName="DefaultNode";var Wd=O.memo(QE);const qE=({data:e,isConnectable:t,sourcePosition:n=q.Bottom})=>H.createElement(H.Fragment,null,e==null?void 0:e.label,H.createElement(No,{type:"source",position:n,isConnectable:t}));qE.displayName="InputNode";var JE=O.memo(qE);const ZE=({data:e,isConnectable:t,targetPosition:n=q.Top})=>H.createElement(H.Fragment,null,H.createElement(No,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label);ZE.displayName="OutputNode";var e0=O.memo(ZE);const Gd=()=>null;Gd.displayName="GroupNode";const AO=e=>({selectedNodes:e.getNodes().filter(t=>t.selected),selectedEdges:e.edges.filter(t=>t.selected)}),ma=e=>e.id;function IO(e,t){return Ge(e.selectedNodes.map(ma),t.selectedNodes.map(ma))&&Ge(e.selectedEdges.map(ma),t.selectedEdges.map(ma))}const t0=O.memo(({onSelectionChange:e})=>{const t=Ie(),{selectedNodes:n,selectedEdges:r}=de(AO,IO);return O.useEffect(()=>{const o={nodes:n,edges:r};e==null||e(o),t.getState().onSelectionChange.forEach(s=>s(o))},[n,r,e]),null});t0.displayName="SelectionListener";const CO=e=>!!e.onSelectionChange;function LO({onSelectionChange:e}){const t=de(CO);return e||t?H.createElement(t0,{onSelectionChange:e}):null}const bO=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 wo(e,t){O.useEffect(()=>{typeof e<"u"&&t(e)},[e])}function ne(e,t,n){O.useEffect(()=>{typeof t<"u"&&n({[e]:t})},[t])}const DO=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:o,onConnectStart:s,onConnectEnd:i,onClickConnectStart:l,onClickConnectEnd:a,nodesDraggable:c,nodesConnectable:u,nodesFocusable:f,edgesFocusable:p,edgesUpdatable:h,elevateNodesOnSelect:E,minZoom:y,maxZoom:v,nodeExtent:m,onNodesChange:g,onEdgesChange:S,elementsSelectable:_,connectionMode:x,snapGrid:R,snapToGrid:T,translateExtent:L,connectOnClick:P,defaultEdgeOptions:I,fitView:j,fitViewOptions:V,onNodesDelete:M,onEdgesDelete:w,onNodeDrag:b,onNodeDragStart:k,onNodeDragStop:F,onSelectionDrag:C,onSelectionDragStart:D,onSelectionDragStop:U,noPanClassName:$,nodeOrigin:B,rfId:W,autoPanOnConnect:z,autoPanOnNodeDrag:Y,onError:X,connectionRadius:Z,isValidConnection:J,nodeDragThreshold:te})=>{const{setNodes:ce,setEdges:Re,setDefaultNodesAndEdges:Me,setMinZoom:tn,setMaxZoom:Le,setTranslateExtent:ye,setNodeExtent:ut,reset:St}=de(bO,Ge),ee=Ie();return O.useEffect(()=>{const Cr=r==null?void 0:r.map(Lr=>({...Lr,...I}));return Me(n,Cr),()=>{St()}},[]),ne("defaultEdgeOptions",I,ee.setState),ne("connectionMode",x,ee.setState),ne("onConnect",o,ee.setState),ne("onConnectStart",s,ee.setState),ne("onConnectEnd",i,ee.setState),ne("onClickConnectStart",l,ee.setState),ne("onClickConnectEnd",a,ee.setState),ne("nodesDraggable",c,ee.setState),ne("nodesConnectable",u,ee.setState),ne("nodesFocusable",f,ee.setState),ne("edgesFocusable",p,ee.setState),ne("edgesUpdatable",h,ee.setState),ne("elementsSelectable",_,ee.setState),ne("elevateNodesOnSelect",E,ee.setState),ne("snapToGrid",T,ee.setState),ne("snapGrid",R,ee.setState),ne("onNodesChange",g,ee.setState),ne("onEdgesChange",S,ee.setState),ne("connectOnClick",P,ee.setState),ne("fitViewOnInit",j,ee.setState),ne("fitViewOnInitOptions",V,ee.setState),ne("onNodesDelete",M,ee.setState),ne("onEdgesDelete",w,ee.setState),ne("onNodeDrag",b,ee.setState),ne("onNodeDragStart",k,ee.setState),ne("onNodeDragStop",F,ee.setState),ne("onSelectionDrag",C,ee.setState),ne("onSelectionDragStart",D,ee.setState),ne("onSelectionDragStop",U,ee.setState),ne("noPanClassName",$,ee.setState),ne("nodeOrigin",B,ee.setState),ne("rfId",W,ee.setState),ne("autoPanOnConnect",z,ee.setState),ne("autoPanOnNodeDrag",Y,ee.setState),ne("onError",X,ee.setState),ne("connectionRadius",Z,ee.setState),ne("isValidConnection",J,ee.setState),ne("nodeDragThreshold",te,ee.setState),wo(e,ce),wo(t,Re),wo(y,tn),wo(v,Le),wo(L,ye),wo(m,ut),null},n0={display:"none"},kO={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},r0="react-flow__node-desc",o0="react-flow__edge-desc",PO="react-flow__aria-live",MO=e=>e.ariaLiveMessage;function UO({rfId:e}){const t=de(MO);return H.createElement("div",{id:`${PO}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:kO},t)}function FO({rfId:e,disableKeyboardA11y:t}){return H.createElement(H.Fragment,null,H.createElement("div",{id:`${r0}-${e}`,style:n0},"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."," "),H.createElement("div",{id:`${o0}-${e}`,style:n0},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!t&&H.createElement(UO,{rfId:e}))}var Oo=(e=null,t={actInsideInputWithModifier:!0})=>{const[n,r]=O.useState(!1),o=O.useRef(!1),s=O.useRef(new Set([])),[i,l]=O.useMemo(()=>{if(e!==null){const c=(Array.isArray(e)?e:[e]).filter(f=>typeof f=="string").map(f=>f.split("+")),u=c.reduce((f,p)=>f.concat(...p),[]);return[c,u]}return[[],[]]},[e]);return O.useEffect(()=>{const a=typeof document<"u"?document:null,c=(t==null?void 0:t.target)||a;if(e!==null){const u=h=>{if(o.current=h.ctrlKey||h.metaKey||h.shiftKey,(!o.current||o.current&&!t.actInsideInputWithModifier)&&Pd(h))return!1;const y=i0(h.code,l);s.current.add(h[y]),s0(i,s.current,!1)&&(h.preventDefault(),r(!0))},f=h=>{if((!o.current||o.current&&!t.actInsideInputWithModifier)&&Pd(h))return!1;const y=i0(h.code,l);s0(i,s.current,!0)?(r(!1),s.current.clear()):s.current.delete(h[y]),h.key==="Meta"&&s.current.clear(),o.current=!1},p=()=>{s.current.clear(),r(!1)};return c==null||c.addEventListener("keydown",u),c==null||c.addEventListener("keyup",f),window.addEventListener("blur",p),()=>{c==null||c.removeEventListener("keydown",u),c==null||c.removeEventListener("keyup",f),window.removeEventListener("blur",p)}}},[e,r]),n};function s0(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(o=>t.has(o)))}function i0(e,t){return t.includes(e)?"code":"key"}function l0(e,t,n,r){var i,l;if(!e.parentNode)return n;const o=t.get(e.parentNode),s=Ro(o,r);return l0(o,t,{x:(n.x??0)+s.x,y:(n.y??0)+s.y,z:(((i=o[Ce])==null?void 0:i.z)??0)>(n.z??0)?((l=o[Ce])==null?void 0:l.z)??0:n.z??0},r)}function a0(e,t,n){e.forEach(r=>{var o;if(r.parentNode&&!e.has(r.parentNode))throw new Error(`Parent node ${r.parentNode} not found`);if(r.parentNode||n!=null&&n[r.id]){const{x:s,y:i,z:l}=l0(r,e,{...r.position,z:((o=r[Ce])==null?void 0:o.z)??0},t);r.positionAbsolute={x:s,y:i},r[Ce].z=l,n!=null&&n[r.id]&&(r[Ce].isParent=!0)}})}function Yd(e,t,n,r){const o=new Map,s={},i=r?1e3:0;return e.forEach(l=>{var f;const a=(It(l.zIndex)?l.zIndex:0)+(l.selected?i:0),c=t.get(l.id),u={width:c==null?void 0:c.width,height:c==null?void 0:c.height,...l,positionAbsolute:{x:l.position.x,y:l.position.y}};l.parentNode&&(u.parentNode=l.parentNode,s[l.parentNode]=!0),Object.defineProperty(u,Ce,{enumerable:!1,value:{handleBounds:(f=c==null?void 0:c[Ce])==null?void 0:f.handleBounds,z:a}}),o.set(l.id,u)}),a0(o,n,s),o}function c0(e,t={}){const{getNodes:n,width:r,height:o,minZoom:s,maxZoom:i,d3Zoom:l,d3Selection:a,fitViewOnInitDone:c,fitViewOnInit:u,nodeOrigin:f}=e(),p=t.initial&&!c&&u;if(l&&a&&(p||!t.initial)){const E=n().filter(v=>{var g;const m=t.includeHiddenNodes?v.width&&v.height:!v.hidden;return(g=t.nodes)!=null&&g.length?m&&t.nodes.some(S=>S.id===v.id):m}),y=E.every(v=>v.width&&v.height);if(E.length>0&&y){const v=Hd(E,f),{x:m,y:g,zoom:S}=BE(v,r,o,t.minZoom??s,t.maxZoom??i,t.padding??.1),_=Bn.translate(m,g).scale(S);return typeof t.duration=="number"&&t.duration>0?l.transform(xr(a,t.duration),_):l.transform(a,_),!0}}return!1}function jO(e,t){return e.forEach(n=>{const r=t.get(n.id);r&&t.set(r.id,{...r,[Ce]:r[Ce],selected:n.selected})}),new Map(t)}function VO(e,t){return t.map(n=>{const r=e.find(o=>o.id===n.id);return r&&(n.selected=r.selected),n})}function ga({changedNodes:e,changedEdges:t,get:n,set:r}){const{nodeInternals:o,edges:s,onNodesChange:i,onEdgesChange:l,hasDefaultNodes:a,hasDefaultEdges:c}=n();e!=null&&e.length&&(a&&r({nodeInternals:jO(e,o)}),i==null||i(e)),t!=null&&t.length&&(c&&r({edges:VO(t,s)}),l==null||l(t))}const To=()=>{},$O={zoomIn:To,zoomOut:To,zoomTo:To,getZoom:()=>1,setViewport:To,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:To,fitBounds:To,project:e=>e,screenToFlowPosition:e=>e,flowToScreenPosition:e=>e,viewportInitialized:!1},HO=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection}),BO=()=>{const e=Ie(),{d3Zoom:t,d3Selection:n}=de(HO,Ge);return O.useMemo(()=>n&&t?{zoomIn:o=>t.scaleBy(xr(n,o==null?void 0:o.duration),1.2),zoomOut:o=>t.scaleBy(xr(n,o==null?void 0:o.duration),1/1.2),zoomTo:(o,s)=>t.scaleTo(xr(n,s==null?void 0:s.duration),o),getZoom:()=>e.getState().transform[2],setViewport:(o,s)=>{const[i,l,a]=e.getState().transform,c=Bn.translate(o.x??i,o.y??l).scale(o.zoom??a);t.transform(xr(n,s==null?void 0:s.duration),c)},getViewport:()=>{const[o,s,i]=e.getState().transform;return{x:o,y:s,zoom:i}},fitView:o=>c0(e.getState,o),setCenter:(o,s,i)=>{const{width:l,height:a,maxZoom:c}=e.getState(),u=typeof(i==null?void 0:i.zoom)<"u"?i.zoom:c,f=l/2-o*u,p=a/2-s*u,h=Bn.translate(f,p).scale(u);t.transform(xr(n,i==null?void 0:i.duration),h)},fitBounds:(o,s)=>{const{width:i,height:l,minZoom:a,maxZoom:c}=e.getState(),{x:u,y:f,zoom:p}=BE(o,i,l,a,c,(s==null?void 0:s.padding)??.1),h=Bn.translate(u,f).scale(p);t.transform(xr(n,s==null?void 0:s.duration),h)},project:o=>{const{transform:s,snapToGrid:i,snapGrid:l}=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"),$d(o,s,i,l)},screenToFlowPosition:o=>{const{transform:s,snapToGrid:i,snapGrid:l,domNode:a}=e.getState();if(!a)return o;const{x:c,y:u}=a.getBoundingClientRect(),f={x:o.x-c,y:o.y-u};return $d(f,s,i,l)},flowToScreenPosition:o=>{const{transform:s,domNode:i}=e.getState();if(!i)return o;const{x:l,y:a}=i.getBoundingClientRect(),c=VE(o,s);return{x:c.x+l,y:c.y+a}},viewportInitialized:!0}:$O,[t,n])};function Kd(){const e=BO(),t=Ie(),n=O.useCallback(()=>t.getState().getNodes().map(y=>({...y})),[]),r=O.useCallback(y=>t.getState().nodeInternals.get(y),[]),o=O.useCallback(()=>{const{edges:y=[]}=t.getState();return y.map(v=>({...v}))},[]),s=O.useCallback(y=>{const{edges:v=[]}=t.getState();return v.find(m=>m.id===y)},[]),i=O.useCallback(y=>{const{getNodes:v,setNodes:m,hasDefaultNodes:g,onNodesChange:S}=t.getState(),_=v(),x=typeof y=="function"?y(_):y;if(g)m(x);else if(S){const R=x.length===0?_.map(T=>({type:"remove",id:T.id})):x.map(T=>({item:T,type:"reset"}));S(R)}},[]),l=O.useCallback(y=>{const{edges:v=[],setEdges:m,hasDefaultEdges:g,onEdgesChange:S}=t.getState(),_=typeof y=="function"?y(v):y;if(g)m(_);else if(S){const x=_.length===0?v.map(R=>({type:"remove",id:R.id})):_.map(R=>({item:R,type:"reset"}));S(x)}},[]),a=O.useCallback(y=>{const v=Array.isArray(y)?y:[y],{getNodes:m,setNodes:g,hasDefaultNodes:S,onNodesChange:_}=t.getState();if(S){const R=[...m(),...v];g(R)}else if(_){const x=v.map(R=>({item:R,type:"add"}));_(x)}},[]),c=O.useCallback(y=>{const v=Array.isArray(y)?y:[y],{edges:m=[],setEdges:g,hasDefaultEdges:S,onEdgesChange:_}=t.getState();if(S)g([...m,...v]);else if(_){const x=v.map(R=>({item:R,type:"add"}));_(x)}},[]),u=O.useCallback(()=>{const{getNodes:y,edges:v=[],transform:m}=t.getState(),[g,S,_]=m;return{nodes:y().map(x=>({...x})),edges:v.map(x=>({...x})),viewport:{x:g,y:S,zoom:_}}},[]),f=O.useCallback(({nodes:y,edges:v})=>{const{nodeInternals:m,getNodes:g,edges:S,hasDefaultNodes:_,hasDefaultEdges:x,onNodesDelete:R,onEdgesDelete:T,onNodesChange:L,onEdgesChange:P}=t.getState(),I=(y||[]).map(b=>b.id),j=(v||[]).map(b=>b.id),V=g().reduce((b,k)=>{const F=!I.includes(k.id)&&k.parentNode&&b.find(D=>D.id===k.parentNode);return(typeof k.deletable=="boolean"?k.deletable:!0)&&(I.includes(k.id)||F)&&b.push(k),b},[]),M=S.filter(b=>typeof b.deletable=="boolean"?b.deletable:!0),w=M.filter(b=>j.includes(b.id));if(V||w){const b=HE(V,M),k=[...w,...b],F=k.reduce((C,D)=>(C.includes(D.id)||C.push(D.id),C),[]);if((x||_)&&(x&&t.setState({edges:S.filter(C=>!F.includes(C.id))}),_&&(V.forEach(C=>{m.delete(C.id)}),t.setState({nodeInternals:new Map(m)}))),F.length>0&&(T==null||T(k),P&&P(F.map(C=>({id:C,type:"remove"})))),V.length>0&&(R==null||R(V),L)){const C=V.map(D=>({id:D.id,type:"remove"}));L(C)}}},[]),p=O.useCallback(y=>{const v=uO(y),m=v?null:t.getState().nodeInternals.get(y.id);return[v?y:TE(m),m,v]},[]),h=O.useCallback((y,v=!0,m)=>{const[g,S,_]=p(y);return g?(m||t.getState().getNodes()).filter(x=>{if(!_&&(x.id===S.id||!x.positionAbsolute))return!1;const R=TE(x),T=kd(R,g);return v&&T>0||T>=g.width*g.height}):[]},[]),E=O.useCallback((y,v,m=!0)=>{const[g]=p(y);if(!g)return!1;const S=kd(g,v);return m&&S>0||S>=g.width*g.height},[]);return O.useMemo(()=>({...e,getNodes:n,getNode:r,getEdges:o,getEdge:s,setNodes:i,setEdges:l,addNodes:a,addEdges:c,toObject:u,deleteElements:f,getIntersectingNodes:h,isNodeIntersecting:E}),[e,n,r,o,s,i,l,a,c,u,f,h,E])}const zO={actInsideInputWithModifier:!1};var WO=({deleteKeyCode:e,multiSelectionKeyCode:t})=>{const n=Ie(),{deleteElements:r}=Kd(),o=Oo(e,zO),s=Oo(t);O.useEffect(()=>{if(o){const{edges:i,getNodes:l}=n.getState(),a=l().filter(u=>u.selected),c=i.filter(u=>u.selected);r({nodes:a,edges:c}),n.setState({nodesSelectionActive:!1})}},[o]),O.useEffect(()=>{n.setState({multiSelectionActive:s})},[s])};function GO(e){const t=Ie();O.useEffect(()=>{let n;const r=()=>{var s,i;if(!e.current)return;const o=Ld(e.current);(o.height===0||o.width===0)&&((i=(s=t.getState()).onError)==null||i.call(s,"004",En.error004())),t.setState({width:o.width||500,height:o.height||500})};return r(),window.addEventListener("resize",r),e.current&&(n=new ResizeObserver(()=>r()),n.observe(e.current)),()=>{window.removeEventListener("resize",r),n&&e.current&&n.unobserve(e.current)}},[])}const Xd={position:"absolute",width:"100%",height:"100%",top:0,left:0},YO=(e,t)=>e.x!==t.x||e.y!==t.y||e.zoom!==t.k,Ea=e=>({x:e.x,y:e.y,zoom:e.k}),Ao=(e,t)=>e.target.closest(`.${t}`),u0=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),d0=e=>{const t=e.ctrlKey&&da()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t},KO=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection,d3ZoomHandler:e.d3ZoomHandler,userSelectionActive:e.userSelectionActive}),XO=({onMove:e,onMoveStart:t,onMoveEnd:n,onPaneContextMenu:r,zoomOnScroll:o=!0,zoomOnPinch:s=!0,panOnScroll:i=!1,panOnScrollSpeed:l=.5,panOnScrollMode:a=Sr.Free,zoomOnDoubleClick:c=!0,elementsSelectable:u,panOnDrag:f=!0,defaultViewport:p,translateExtent:h,minZoom:E,maxZoom:y,zoomActivationKeyCode:v,preventScrolling:m=!0,children:g,noWheelClassName:S,noPanClassName:_})=>{const x=O.useRef(),R=Ie(),T=O.useRef(!1),L=O.useRef(!1),P=O.useRef(null),I=O.useRef({x:0,y:0,zoom:0}),{d3Zoom:j,d3Selection:V,d3ZoomHandler:M,userSelectionActive:w}=de(KO,Ge),b=Oo(v),k=O.useRef(0),F=O.useRef(!1),C=O.useRef();return GO(P),O.useEffect(()=>{if(P.current){const D=P.current.getBoundingClientRect(),U=nO().scaleExtent([E,y]).translateExtent(h),$=jt(P.current).call(U),B=Bn.translate(p.x,p.y).scale(So(p.zoom,E,y)),W=[[0,0],[D.width,D.height]],z=U.constrain()(B,W,h);U.transform($,z),U.wheelDelta(d0),R.setState({d3Zoom:U,d3Selection:$,d3ZoomHandler:$.on("wheel.zoom"),transform:[z.x,z.y,z.k],domNode:P.current.closest(".react-flow")})}},[]),O.useEffect(()=>{V&&j&&(i&&!b&&!w?V.on("wheel.zoom",D=>{if(Ao(D,S))return!1;D.preventDefault(),D.stopImmediatePropagation();const U=V.property("__zoom").k||1,$=da();if(D.ctrlKey&&s&&$){const te=Xt(D),ce=d0(D),Re=U*Math.pow(2,ce);j.scaleTo(V,Re,te,D);return}const B=D.deltaMode===1?20:1;let W=a===Sr.Vertical?0:D.deltaX*B,z=a===Sr.Horizontal?0:D.deltaY*B;!$&&D.shiftKey&&a!==Sr.Vertical&&(W=D.deltaY*B,z=0),j.translateBy(V,-(W/U)*l,-(z/U)*l,{internal:!0});const Y=Ea(V.property("__zoom")),{onViewportChangeStart:X,onViewportChange:Z,onViewportChangeEnd:J}=R.getState();clearTimeout(C.current),F.current||(F.current=!0,t==null||t(D,Y),X==null||X(Y)),F.current&&(e==null||e(D,Y),Z==null||Z(Y),C.current=setTimeout(()=>{n==null||n(D,Y),J==null||J(Y),F.current=!1},150))},{passive:!1}):typeof M<"u"&&V.on("wheel.zoom",function(D,U){if(!m||Ao(D,S))return null;D.preventDefault(),M.call(this,D,U)},{passive:!1}))},[w,i,a,V,j,M,b,s,m,S,t,e,n]),O.useEffect(()=>{j&&j.on("start",D=>{var B,W;if(!D.sourceEvent||D.sourceEvent.internal)return null;k.current=(B=D.sourceEvent)==null?void 0:B.button;const{onViewportChangeStart:U}=R.getState(),$=Ea(D.transform);T.current=!0,I.current=$,((W=D.sourceEvent)==null?void 0:W.type)==="mousedown"&&R.setState({paneDragging:!0}),U==null||U($),t==null||t(D.sourceEvent,$)})},[j,t]),O.useEffect(()=>{j&&(w&&!T.current?j.on("zoom",null):w||j.on("zoom",D=>{var $;const{onViewportChange:U}=R.getState();if(R.setState({transform:[D.transform.x,D.transform.y,D.transform.k]}),L.current=!!(r&&u0(f,k.current??0)),(e||U)&&!(($=D.sourceEvent)!=null&&$.internal)){const B=Ea(D.transform);U==null||U(B),e==null||e(D.sourceEvent,B)}}))},[w,j,e,f,r]),O.useEffect(()=>{j&&j.on("end",D=>{if(!D.sourceEvent||D.sourceEvent.internal)return null;const{onViewportChangeEnd:U}=R.getState();if(T.current=!1,R.setState({paneDragging:!1}),r&&u0(f,k.current??0)&&!L.current&&r(D.sourceEvent),L.current=!1,(n||U)&&YO(I.current,D.transform)){const $=Ea(D.transform);I.current=$,clearTimeout(x.current),x.current=setTimeout(()=>{U==null||U($),n==null||n(D.sourceEvent,$)},i?150:0)}})},[j,i,f,n,r]),O.useEffect(()=>{j&&j.filter(D=>{const U=b||o,$=s&&D.ctrlKey;if((f===!0||Array.isArray(f)&&f.includes(1))&&D.button===1&&D.type==="mousedown"&&(Ao(D,"react-flow__node")||Ao(D,"react-flow__edge")))return!0;if(!f&&!U&&!i&&!c&&!s||w||!c&&D.type==="dblclick"||Ao(D,S)&&D.type==="wheel"||Ao(D,_)&&(D.type!=="wheel"||i&&D.type==="wheel"&&!b)||!s&&D.ctrlKey&&D.type==="wheel"||!U&&!i&&!$&&D.type==="wheel"||!f&&(D.type==="mousedown"||D.type==="touchstart")||Array.isArray(f)&&!f.includes(D.button)&&(D.type==="mousedown"||D.type==="touchstart"))return!1;const B=Array.isArray(f)&&f.includes(D.button)||!D.button||D.button<=1;return(!D.ctrlKey||D.type==="wheel")&&B})},[w,j,o,s,i,c,f,u,b]),H.createElement("div",{className:"react-flow__renderer",ref:P,style:Xd},g)},QO=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function qO(){const{userSelectionActive:e,userSelectionRect:t}=de(QO,Ge);return e&&t?H.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 f0(e,t){const n=e.find(r=>r.id===t.parentNode);if(n){const r=t.position.x+t.width-n.width,o=t.position.y+t.height-n.height;if(r>0||o>0||t.position.x<0||t.position.y<0){if(n.style={...n.style},n.style.width=n.style.width??n.width,n.style.height=n.style.height??n.height,r>0&&(n.style.width+=r),o>0&&(n.style.height+=o),t.position.x<0){const s=Math.abs(t.position.x);n.position.x=n.position.x-s,n.style.width+=s,t.position.x=0}if(t.position.y<0){const s=Math.abs(t.position.y);n.position.y=n.position.y-s,n.style.height+=s,t.position.y=0}n.width=n.style.width,n.height=n.style.height}}}function p0(e,t){if(e.some(r=>r.type==="reset"))return e.filter(r=>r.type==="reset").map(r=>r.item);const n=e.filter(r=>r.type==="add").map(r=>r.item);return t.reduce((r,o)=>{const s=e.filter(l=>l.id===o.id);if(s.length===0)return r.push(o),r;const i={...o};for(const l of s)if(l)switch(l.type){case"select":{i.selected=l.selected;break}case"position":{typeof l.position<"u"&&(i.position=l.position),typeof l.positionAbsolute<"u"&&(i.positionAbsolute=l.positionAbsolute),typeof l.dragging<"u"&&(i.dragging=l.dragging),i.expandParent&&f0(r,i);break}case"dimensions":{typeof l.dimensions<"u"&&(i.width=l.dimensions.width,i.height=l.dimensions.height),typeof l.updateStyle<"u"&&(i.style={...i.style||{},...l.dimensions}),typeof l.resizing=="boolean"&&(i.resizing=l.resizing),i.expandParent&&f0(r,i);break}case"remove":return r}return r.push(i),r},n)}function h0(e,t){return p0(e,t)}function JO(e,t){return p0(e,t)}const Yn=(e,t)=>({id:e,type:"select",selected:t});function Io(e,t){return e.reduce((n,r)=>{const o=t.includes(r.id);return!r.selected&&o?(r.selected=!0,n.push(Yn(r.id,!0))):r.selected&&!o&&(r.selected=!1,n.push(Yn(r.id,!1))),n},[])}const Qd=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},ZO=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging}),m0=O.memo(({isSelecting:e,selectionMode:t=ti.Full,panOnDrag:n,onSelectionStart:r,onSelectionEnd:o,onPaneClick:s,onPaneContextMenu:i,onPaneScroll:l,onPaneMouseEnter:a,onPaneMouseMove:c,onPaneMouseLeave:u,children:f})=>{const p=O.useRef(null),h=Ie(),E=O.useRef(0),y=O.useRef(0),v=O.useRef(),{userSelectionActive:m,elementsSelectable:g,dragging:S}=de(ZO,Ge),_=()=>{h.setState({userSelectionActive:!1,userSelectionRect:null}),E.current=0,y.current=0},x=M=>{s==null||s(M),h.getState().resetSelectedElements(),h.setState({nodesSelectionActive:!1})},R=M=>{if(Array.isArray(n)&&(n!=null&&n.includes(2))){M.preventDefault();return}i==null||i(M)},T=l?M=>l(M):void 0,L=M=>{const{resetSelectedElements:w,domNode:b}=h.getState();if(v.current=b==null?void 0:b.getBoundingClientRect(),!g||!e||M.button!==0||M.target!==p.current||!v.current)return;const{x:k,y:F}=zn(M,v.current);w(),h.setState({userSelectionRect:{width:0,height:0,startX:k,startY:F,x:k,y:F}}),r==null||r(M)},P=M=>{const{userSelectionRect:w,nodeInternals:b,edges:k,transform:F,onNodesChange:C,onEdgesChange:D,nodeOrigin:U,getNodes:$}=h.getState();if(!e||!v.current||!w)return;h.setState({userSelectionActive:!0,nodesSelectionActive:!1});const B=zn(M,v.current),W=w.startX??0,z=w.startY??0,Y={...w,x:B.x<W?B.x:W,y:B.y<z?B.y:z,width:Math.abs(B.x-W),height:Math.abs(B.y-z)},X=$(),Z=$E(b,Y,F,t===ti.Partial,!0,U),J=HE(Z,k).map(ce=>ce.id),te=Z.map(ce=>ce.id);if(E.current!==te.length){E.current=te.length;const ce=Io(X,te);ce.length&&(C==null||C(ce))}if(y.current!==J.length){y.current=J.length;const ce=Io(k,J);ce.length&&(D==null||D(ce))}h.setState({userSelectionRect:Y})},I=M=>{if(M.button!==0)return;const{userSelectionRect:w}=h.getState();!m&&w&&M.target===p.current&&(x==null||x(M)),h.setState({nodesSelectionActive:E.current>0}),_(),o==null||o(M)},j=M=>{m&&(h.setState({nodesSelectionActive:E.current>0}),o==null||o(M)),_()},V=g&&(e||m);return H.createElement("div",{className:Je(["react-flow__pane",{dragging:S,selection:e}]),onClick:V?void 0:Qd(x,p),onContextMenu:Qd(R,p),onWheel:Qd(T,p),onMouseEnter:V?void 0:a,onMouseDown:V?L:void 0,onMouseMove:V?P:c,onMouseUp:V?I:void 0,onMouseLeave:V?j:u,ref:p,style:Xd},f,H.createElement(qO,null))});m0.displayName="Pane";function g0(e,t){if(!e.parentNode)return!1;const n=t.get(e.parentNode);return n?n.selected?!0:g0(n,t):!1}function E0(e,t,n){let r=e;do{if(r!=null&&r.matches(t))return!0;if(r===n.current)return!1;r=r.parentElement}while(r);return!1}function eT(e,t,n,r){return Array.from(e.values()).filter(o=>(o.selected||o.id===r)&&(!o.parentNode||!g0(o,e))&&(o.draggable||t&&typeof o.draggable>"u")).map(o=>{var s,i;return{id:o.id,position:o.position||{x:0,y:0},positionAbsolute:o.positionAbsolute||{x:0,y:0},distance:{x:n.x-(((s=o.positionAbsolute)==null?void 0:s.x)??0),y:n.y-(((i=o.positionAbsolute)==null?void 0:i.y)??0)},delta:{x:0,y:0},extent:o.extent,parentNode:o.parentNode,width:o.width,height:o.height,expandParent:o.expandParent}})}function tT(e,t){return!t||t==="parent"?t:[t[0],[t[1][0]-(e.width||0),t[1][1]-(e.height||0)]]}function y0(e,t,n,r,o=[0,0],s){const i=tT(e,e.extent||r);let l=i;if(e.extent==="parent"&&!e.expandParent)if(e.parentNode&&e.width&&e.height){const u=n.get(e.parentNode),{x:f,y:p}=Ro(u,o).positionAbsolute;l=u&&It(f)&&It(p)&&It(u.width)&&It(u.height)?[[f+e.width*o[0],p+e.height*o[1]],[f+u.width-e.width+e.width*o[0],p+u.height-e.height+e.height*o[1]]]:l}else s==null||s("005",En.error005()),l=i;else if(e.extent&&e.parentNode&&e.extent!=="parent"){const u=n.get(e.parentNode),{x:f,y:p}=Ro(u,o).positionAbsolute;l=[[e.extent[0][0]+f,e.extent[0][1]+p],[e.extent[1][0]+f,e.extent[1][1]+p]]}let a={x:0,y:0};if(e.parentNode){const u=n.get(e.parentNode);a=Ro(u,o).positionAbsolute}const c=l&&l!=="parent"?bd(t,l):t;return{position:{x:c.x-a.x,y:c.y-a.y},positionAbsolute:c}}function qd({nodeId:e,dragItems:t,nodeInternals:n}){const r=t.map(o=>({...n.get(o.id),position:o.position,positionAbsolute:o.positionAbsolute}));return[e?r.find(o=>o.id===e):r[0],r]}const v0=(e,t,n,r)=>{const o=t.querySelectorAll(e);if(!o||!o.length)return null;const s=Array.from(o),i=t.getBoundingClientRect(),l={x:i.width*r[0],y:i.height*r[1]};return s.map(a=>{const c=a.getBoundingClientRect();return{id:a.getAttribute("data-handleid"),position:a.getAttribute("data-handlepos"),x:(c.left-i.left-l.x)/n,y:(c.top-i.top-l.y)/n,...Ld(a)}})};function oi(e,t,n){return n===void 0?n:r=>{const o=t().nodeInternals.get(e);o&&n(r,{...o})}}function Jd({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:o,unselectNodesAndEdges:s,multiSelectionActive:i,nodeInternals:l,onError:a}=t.getState(),c=l.get(e);if(!c){a==null||a("012",En.error012(e));return}t.setState({nodesSelectionActive:!1}),c.selected?(n||c.selected&&i)&&(s({nodes:[c],edges:[]}),requestAnimationFrame(()=>{var u;return(u=r==null?void 0:r.current)==null?void 0:u.blur()})):o([e])}function nT(){const e=Ie();return O.useCallback(({sourceEvent:n})=>{const{transform:r,snapGrid:o,snapToGrid:s}=e.getState(),i=n.touches?n.touches[0].clientX:n.clientX,l=n.touches?n.touches[0].clientY:n.clientY,a={x:(i-r[0])/r[2],y:(l-r[1])/r[2]};return{xSnapped:s?o[0]*Math.round(a.x/o[0]):a.x,ySnapped:s?o[1]*Math.round(a.y/o[1]):a.y,...a}},[])}function Zd(e){return(t,n,r)=>e==null?void 0:e(t,r)}function _0({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:o,isSelectable:s,selectNodesOnDrag:i}){const l=Ie(),[a,c]=O.useState(!1),u=O.useRef([]),f=O.useRef({x:null,y:null}),p=O.useRef(0),h=O.useRef(null),E=O.useRef({x:0,y:0}),y=O.useRef(null),v=O.useRef(!1),m=O.useRef(!1),g=nT();return O.useEffect(()=>{if(e!=null&&e.current){const S=jt(e.current),_=({x:T,y:L})=>{const{nodeInternals:P,onNodeDrag:I,onSelectionDrag:j,updateNodePositions:V,nodeExtent:M,snapGrid:w,snapToGrid:b,nodeOrigin:k,onError:F}=l.getState();f.current={x:T,y:L};let C=!1,D={x:0,y:0,x2:0,y2:0};if(u.current.length>1&&M){const $=Hd(u.current,k);D=Dd($)}if(u.current=u.current.map($=>{const B={x:T-$.distance.x,y:L-$.distance.y};b&&(B.x=w[0]*Math.round(B.x/w[0]),B.y=w[1]*Math.round(B.y/w[1]));const W=[[M[0][0],M[0][1]],[M[1][0],M[1][1]]];u.current.length>1&&M&&!$.extent&&(W[0][0]=$.positionAbsolute.x-D.x+M[0][0],W[1][0]=$.positionAbsolute.x+($.width??0)-D.x2+M[1][0],W[0][1]=$.positionAbsolute.y-D.y+M[0][1],W[1][1]=$.positionAbsolute.y+($.height??0)-D.y2+M[1][1]);const z=y0($,B,P,W,k,F);return C=C||$.position.x!==z.position.x||$.position.y!==z.position.y,$.position=z.position,$.positionAbsolute=z.positionAbsolute,$}),!C)return;V(u.current,!0,!0),c(!0);const U=o?I:Zd(j);if(U&&y.current){const[$,B]=qd({nodeId:o,dragItems:u.current,nodeInternals:P});U(y.current,$,B)}},x=()=>{if(!h.current)return;const[T,L]=wE(E.current,h.current);if(T!==0||L!==0){const{transform:P,panBy:I}=l.getState();f.current.x=(f.current.x??0)-T/P[2],f.current.y=(f.current.y??0)-L/P[2],I({x:T,y:L})&&_(f.current)}p.current=requestAnimationFrame(x)},R=T=>{var k;const{nodeInternals:L,multiSelectionActive:P,nodesDraggable:I,unselectNodesAndEdges:j,onNodeDragStart:V,onSelectionDragStart:M}=l.getState();m.current=!0;const w=o?V:Zd(M);(!i||!s)&&!P&&o&&((k=L.get(o))!=null&&k.selected||j()),o&&s&&i&&Jd({id:o,store:l,nodeRef:e});const b=g(T);if(f.current=b,u.current=eT(L,I,b,o),w&&u.current){const[F,C]=qd({nodeId:o,dragItems:u.current,nodeInternals:L});w(T.sourceEvent,F,C)}};if(t)S.on(".drag",null);else{const T=f1().on("start",L=>{const{domNode:P,nodeDragThreshold:I}=l.getState();I===0&&R(L);const j=g(L);f.current=j,h.current=(P==null?void 0:P.getBoundingClientRect())||null,E.current=zn(L.sourceEvent,h.current)}).on("drag",L=>{var V,M;const P=g(L),{autoPanOnNodeDrag:I,nodeDragThreshold:j}=l.getState();if(!v.current&&m.current&&I&&(v.current=!0,x()),!m.current){const w=P.xSnapped-(((V=f==null?void 0:f.current)==null?void 0:V.x)??0),b=P.ySnapped-(((M=f==null?void 0:f.current)==null?void 0:M.y)??0);Math.sqrt(w*w+b*b)>j&&R(L)}(f.current.x!==P.xSnapped||f.current.y!==P.ySnapped)&&u.current&&m.current&&(y.current=L.sourceEvent,E.current=zn(L.sourceEvent,h.current),_(P))}).on("end",L=>{if(m.current&&(c(!1),v.current=!1,m.current=!1,cancelAnimationFrame(p.current),u.current)){const{updateNodePositions:P,nodeInternals:I,onNodeDragStop:j,onSelectionDragStop:V}=l.getState(),M=o?j:Zd(V);if(P(u.current,!1,!1),M){const[w,b]=qd({nodeId:o,dragItems:u.current,nodeInternals:I});M(L.sourceEvent,w,b)}}}).filter(L=>{const P=L.target;return!L.button&&(!n||!E0(P,`.${n}`,e))&&(!r||E0(P,r,e))});return S.call(T),()=>{S.on(".drag",null)}}}},[e,t,n,r,s,l,o,i,g]),a}function S0(){const e=Ie();return O.useCallback(n=>{const{nodeInternals:r,nodeExtent:o,updateNodePositions:s,getNodes:i,snapToGrid:l,snapGrid:a,onError:c,nodesDraggable:u}=e.getState(),f=i().filter(g=>g.selected&&(g.draggable||u&&typeof g.draggable>"u")),p=l?a[0]:5,h=l?a[1]:5,E=n.isShiftPressed?4:1,y=n.x*p*E,v=n.y*h*E,m=f.map(g=>{if(g.positionAbsolute){const S={x:g.positionAbsolute.x+y,y:g.positionAbsolute.y+v};l&&(S.x=a[0]*Math.round(S.x/a[0]),S.y=a[1]*Math.round(S.y/a[1]));const{positionAbsolute:_,position:x}=y0(g,S,r,o,void 0,c);g.position=x,g.positionAbsolute=_}return g});s(m,!0,!1)},[])}const Co={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var si=e=>{const t=({id:n,type:r,data:o,xPos:s,yPos:i,xPosOrigin:l,yPosOrigin:a,selected:c,onClick:u,onMouseEnter:f,onMouseMove:p,onMouseLeave:h,onContextMenu:E,onDoubleClick:y,style:v,className:m,isDraggable:g,isSelectable:S,isConnectable:_,isFocusable:x,selectNodesOnDrag:R,sourcePosition:T,targetPosition:L,hidden:P,resizeObserver:I,dragHandle:j,zIndex:V,isParent:M,noDragClassName:w,noPanClassName:b,initialized:k,disableKeyboardA11y:F,ariaLabel:C,rfId:D})=>{const U=Ie(),$=O.useRef(null),B=O.useRef(T),W=O.useRef(L),z=O.useRef(r),Y=S||g||u||f||p||h,X=S0(),Z=oi(n,U.getState,f),J=oi(n,U.getState,p),te=oi(n,U.getState,h),ce=oi(n,U.getState,E),Re=oi(n,U.getState,y),Me=ye=>{const{nodeDragThreshold:ut}=U.getState();if(S&&(!R||!g||ut>0)&&Jd({id:n,store:U,nodeRef:$}),u){const St=U.getState().nodeInternals.get(n);St&&u(ye,{...St})}},tn=ye=>{if(!Pd(ye))if(AE.includes(ye.key)&&S){const ut=ye.key==="Escape";Jd({id:n,store:U,unselect:ut,nodeRef:$})}else!F&&g&&c&&Object.prototype.hasOwnProperty.call(Co,ye.key)&&(U.setState({ariaLiveMessage:`Moved selected node ${ye.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~s}, y: ${~~i}`}),X({x:Co[ye.key].x,y:Co[ye.key].y,isShiftPressed:ye.shiftKey}))};O.useEffect(()=>{if($.current&&!P){const ye=$.current;return I==null||I.observe(ye),()=>I==null?void 0:I.unobserve(ye)}},[P]),O.useEffect(()=>{const ye=z.current!==r,ut=B.current!==T,St=W.current!==L;$.current&&(ye||ut||St)&&(ye&&(z.current=r),ut&&(B.current=T),St&&(W.current=L),U.getState().updateNodeDimensions([{id:n,nodeElement:$.current,forceUpdate:!0}]))},[n,r,T,L]);const Le=_0({nodeRef:$,disabled:P||!g,noDragClassName:w,handleSelector:j,nodeId:n,isSelectable:S,selectNodesOnDrag:R});return P?null:H.createElement("div",{className:Je(["react-flow__node",`react-flow__node-${r}`,{[b]:g},m,{selected:c,selectable:S,parent:M,dragging:Le}]),ref:$,style:{zIndex:V,transform:`translate(${l}px,${a}px)`,pointerEvents:Y?"all":"none",visibility:k?"visible":"hidden",...v},"data-id":n,"data-testid":`rf__node-${n}`,onMouseEnter:Z,onMouseMove:J,onMouseLeave:te,onContextMenu:ce,onClick:Me,onDoubleClick:Re,onKeyDown:x?tn:void 0,tabIndex:x?0:void 0,role:x?"button":void 0,"aria-describedby":F?void 0:`${r0}-${D}`,"aria-label":C},H.createElement(EO,{value:n},H.createElement(e,{id:n,data:o,type:r,xPos:s,yPos:i,selected:c,isConnectable:_,sourcePosition:T,targetPosition:L,dragging:Le,dragHandle:j,zIndex:V})))};return t.displayName="NodeWrapper",O.memo(t)};const rT=e=>{const t=e.getNodes().filter(n=>n.selected);return{...Hd(t,e.nodeOrigin),transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`,userSelectionActive:e.userSelectionActive}};function oT({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=Ie(),{width:o,height:s,x:i,y:l,transformString:a,userSelectionActive:c}=de(rT,Ge),u=S0(),f=O.useRef(null);if(O.useEffect(()=>{var E;n||(E=f.current)==null||E.focus({preventScroll:!0})},[n]),_0({nodeRef:f}),c||!o||!s)return null;const p=e?E=>{const y=r.getState().getNodes().filter(v=>v.selected);e(E,y)}:void 0,h=E=>{Object.prototype.hasOwnProperty.call(Co,E.key)&&u({x:Co[E.key].x,y:Co[E.key].y,isShiftPressed:E.shiftKey})};return H.createElement("div",{className:Je(["react-flow__nodesselection","react-flow__container",t]),style:{transform:a}},H.createElement("div",{ref:f,className:"react-flow__nodesselection-rect",onContextMenu:p,tabIndex:n?void 0:-1,onKeyDown:n?void 0:h,style:{width:o,height:s,top:l,left:i}}))}var sT=O.memo(oT);const iT=e=>e.nodesSelectionActive,x0=({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:o,onPaneContextMenu:s,onPaneScroll:i,deleteKeyCode:l,onMove:a,onMoveStart:c,onMoveEnd:u,selectionKeyCode:f,selectionOnDrag:p,selectionMode:h,onSelectionStart:E,onSelectionEnd:y,multiSelectionKeyCode:v,panActivationKeyCode:m,zoomActivationKeyCode:g,elementsSelectable:S,zoomOnScroll:_,zoomOnPinch:x,panOnScroll:R,panOnScrollSpeed:T,panOnScrollMode:L,zoomOnDoubleClick:P,panOnDrag:I,defaultViewport:j,translateExtent:V,minZoom:M,maxZoom:w,preventScrolling:b,onSelectionContextMenu:k,noWheelClassName:F,noPanClassName:C,disableKeyboardA11y:D})=>{const U=de(iT),$=Oo(f),B=Oo(m),W=B||I,z=B||R,Y=$||p&&W!==!0;return WO({deleteKeyCode:l,multiSelectionKeyCode:v}),H.createElement(XO,{onMove:a,onMoveStart:c,onMoveEnd:u,onPaneContextMenu:s,elementsSelectable:S,zoomOnScroll:_,zoomOnPinch:x,panOnScroll:z,panOnScrollSpeed:T,panOnScrollMode:L,zoomOnDoubleClick:P,panOnDrag:!$&&W,defaultViewport:j,translateExtent:V,minZoom:M,maxZoom:w,zoomActivationKeyCode:g,preventScrolling:b,noWheelClassName:F,noPanClassName:C},H.createElement(m0,{onSelectionStart:E,onSelectionEnd:y,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:o,onPaneContextMenu:s,onPaneScroll:i,panOnDrag:W,isSelecting:!!Y,selectionMode:h},e,U&&H.createElement(sT,{onSelectionContextMenu:k,noPanClassName:C,disableKeyboardA11y:D})))};x0.displayName="FlowRenderer";var lT=O.memo(x0);function aT(e){return de(O.useCallback(n=>e?$E(n.nodeInternals,{x:0,y:0,width:n.width,height:n.height},n.transform,!0):n.getNodes(),[e]))}function cT(e){const t={input:si(e.input||JE),default:si(e.default||Wd),output:si(e.output||e0),group:si(e.group||Gd)},n={},r=Object.keys(e).filter(o=>!["input","default","output","group"].includes(o)).reduce((o,s)=>(o[s]=si(e[s]||Wd),o),n);return{...t,...r}}const uT=({x:e,y:t,width:n,height:r,origin:o})=>!n||!r?{x:e,y:t}:o[0]<0||o[1]<0||o[0]>1||o[1]>1?{x:e,y:t}:{x:e-n*o[0],y:t-r*o[1]},dT=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,updateNodeDimensions:e.updateNodeDimensions,onError:e.onError}),R0=e=>{const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:o,updateNodeDimensions:s,onError:i}=de(dT,Ge),l=aT(e.onlyRenderVisibleElements),a=O.useRef(),c=O.useMemo(()=>{if(typeof ResizeObserver>"u")return null;const u=new ResizeObserver(f=>{const p=f.map(h=>({id:h.target.getAttribute("data-id"),nodeElement:h.target,forceUpdate:!0}));s(p)});return a.current=u,u},[]);return O.useEffect(()=>()=>{var u;(u=a==null?void 0:a.current)==null||u.disconnect()},[]),H.createElement("div",{className:"react-flow__nodes",style:Xd},l.map(u=>{var x,R;let f=u.type||"default";e.nodeTypes[f]||(i==null||i("003",En.error003(f)),f="default");const p=e.nodeTypes[f]||e.nodeTypes.default,h=!!(u.draggable||t&&typeof u.draggable>"u"),E=!!(u.selectable||o&&typeof u.selectable>"u"),y=!!(u.connectable||n&&typeof u.connectable>"u"),v=!!(u.focusable||r&&typeof u.focusable>"u"),m=e.nodeExtent?bd(u.positionAbsolute,e.nodeExtent):u.positionAbsolute,g=(m==null?void 0:m.x)??0,S=(m==null?void 0:m.y)??0,_=uT({x:g,y:S,width:u.width??0,height:u.height??0,origin:e.nodeOrigin});return H.createElement(p,{key:u.id,id:u.id,className:u.className,style:u.style,type:f,data:u.data,sourcePosition:u.sourcePosition||q.Bottom,targetPosition:u.targetPosition||q.Top,hidden:u.hidden,xPos:g,yPos:S,xPosOrigin:_.x,yPosOrigin:_.y,selectNodesOnDrag:e.selectNodesOnDrag,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,selected:!!u.selected,isDraggable:h,isSelectable:E,isConnectable:y,isFocusable:v,resizeObserver:c,dragHandle:u.dragHandle,zIndex:((x=u[Ce])==null?void 0:x.z)??0,isParent:!!((R=u[Ce])!=null&&R.isParent),noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,initialized:!!u.width&&!!u.height,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,ariaLabel:u.ariaLabel})}))};R0.displayName="NodeRenderer";var fT=O.memo(R0);const pT=(e,t,n)=>n===q.Left?e-t:n===q.Right?e+t:e,hT=(e,t,n)=>n===q.Top?e-t:n===q.Bottom?e+t:e,N0="react-flow__edgeupdater",w0=({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:o,onMouseEnter:s,onMouseOut:i,type:l})=>H.createElement("circle",{onMouseDown:o,onMouseEnter:s,onMouseOut:i,className:Je([N0,`${N0}-${l}`]),cx:pT(t,r,e),cy:hT(n,r,e),r,stroke:"transparent",fill:"transparent"}),mT=()=>!0;var Lo=e=>{const t=({id:n,className:r,type:o,data:s,onClick:i,onEdgeDoubleClick:l,selected:a,animated:c,label:u,labelStyle:f,labelShowBg:p,labelBgStyle:h,labelBgPadding:E,labelBgBorderRadius:y,style:v,source:m,target:g,sourceX:S,sourceY:_,targetX:x,targetY:R,sourcePosition:T,targetPosition:L,elementsSelectable:P,hidden:I,sourceHandleId:j,targetHandleId:V,onContextMenu:M,onMouseEnter:w,onMouseMove:b,onMouseLeave:k,edgeUpdaterRadius:F,onEdgeUpdate:C,onEdgeUpdateStart:D,onEdgeUpdateEnd:U,markerEnd:$,markerStart:B,rfId:W,ariaLabel:z,isFocusable:Y,isUpdatable:X,pathOptions:Z,interactionWidth:J})=>{const te=O.useRef(null),[ce,Re]=O.useState(!1),[Me,tn]=O.useState(!1),Le=Ie(),ye=O.useMemo(()=>`url(#${Vd(B,W)})`,[B,W]),ut=O.useMemo(()=>`url(#${Vd($,W)})`,[$,W]);if(I)return null;const St=Ye=>{var nn;const{edges:xt,addSelectedEdges:kr,unselectNodesAndEdges:Pr,multiSelectionActive:Mr}=Le.getState(),Sn=xt.find(wi=>wi.id===n);Sn&&(P&&(Le.setState({nodesSelectionActive:!1}),Sn.selected&&Mr?(Pr({nodes:[],edges:[Sn]}),(nn=te.current)==null||nn.blur()):kr([n])),i&&i(Ye,Sn))},ee=ei(n,Le.getState,l),Cr=ei(n,Le.getState,M),Lr=ei(n,Le.getState,w),Ri=ei(n,Le.getState,b),Ko=ei(n,Le.getState,k),br=(Ye,xt)=>{if(Ye.button!==0)return;const{edges:kr,isValidConnection:Pr}=Le.getState(),Mr=xt?g:m,Sn=(xt?V:j)||null,nn=xt?"target":"source",wi=Pr||mT,Gf=xt,Oi=kr.find(Ur=>Ur.id===n);tn(!0),D==null||D(Ye,Oi,nn);const Yf=Ur=>{tn(!1),U==null||U(Ur,Oi,nn)};YE({event:Ye,handleId:Sn,nodeId:Mr,onConnect:Ur=>C==null?void 0:C(Oi,Ur),isTarget:Gf,getState:Le.getState,setState:Le.setState,isValidConnection:wi,edgeUpdaterType:nn,onEdgeUpdateEnd:Yf})},tr=Ye=>br(Ye,!0),Xo=Ye=>br(Ye,!1),nr=()=>Re(!0),Dr=()=>Re(!1),Ni=!P&&!i,Qo=Ye=>{var xt;if(AE.includes(Ye.key)&&P){const{unselectNodesAndEdges:kr,addSelectedEdges:Pr,edges:Mr}=Le.getState();Ye.key==="Escape"?((xt=te.current)==null||xt.blur(),kr({edges:[Mr.find(nn=>nn.id===n)]})):Pr([n])}};return H.createElement("g",{className:Je(["react-flow__edge",`react-flow__edge-${o}`,r,{selected:a,animated:c,inactive:Ni,updating:ce}]),onClick:St,onDoubleClick:ee,onContextMenu:Cr,onMouseEnter:Lr,onMouseMove:Ri,onMouseLeave:Ko,onKeyDown:Y?Qo:void 0,tabIndex:Y?0:void 0,role:Y?"button":"img","data-testid":`rf__edge-${n}`,"aria-label":z===null?void 0:z||`Edge from ${m} to ${g}`,"aria-describedby":Y?`${o0}-${W}`:void 0,ref:te},!Me&&H.createElement(e,{id:n,source:m,target:g,selected:a,animated:c,label:u,labelStyle:f,labelShowBg:p,labelBgStyle:h,labelBgPadding:E,labelBgBorderRadius:y,data:s,style:v,sourceX:S,sourceY:_,targetX:x,targetY:R,sourcePosition:T,targetPosition:L,sourceHandleId:j,targetHandleId:V,markerStart:ye,markerEnd:ut,pathOptions:Z,interactionWidth:J}),X&&H.createElement(H.Fragment,null,(X==="source"||X===!0)&&H.createElement(w0,{position:T,centerX:S,centerY:_,radius:F,onMouseDown:tr,onMouseEnter:nr,onMouseOut:Dr,type:"source"}),(X==="target"||X===!0)&&H.createElement(w0,{position:L,centerX:x,centerY:R,radius:F,onMouseDown:Xo,onMouseEnter:nr,onMouseOut:Dr,type:"target"})))};return t.displayName="EdgeWrapper",O.memo(t)};function gT(e){const t={default:Lo(e.default||ha),straight:Lo(e.bezier||Fd),step:Lo(e.step||Ud),smoothstep:Lo(e.step||fa),simplebezier:Lo(e.simplebezier||Md)},n={},r=Object.keys(e).filter(o=>!["default","bezier"].includes(o)).reduce((o,s)=>(o[s]=Lo(e[s]||ha),o),n);return{...t,...r}}function O0(e,t,n=null){const r=((n==null?void 0:n.x)||0)+t.x,o=((n==null?void 0:n.y)||0)+t.y,s=(n==null?void 0:n.width)||t.width,i=(n==null?void 0:n.height)||t.height;switch(e){case q.Top:return{x:r+s/2,y:o};case q.Right:return{x:r+s,y:o+i/2};case q.Bottom:return{x:r+s/2,y:o+i};case q.Left:return{x:r,y:o+i/2}}}function T0(e,t){return e?e.length===1||!t?e[0]:t&&e.find(n=>n.id===t)||null:null}const ET=(e,t,n,r,o,s)=>{const i=O0(n,e,t),l=O0(s,r,o);return{sourceX:i.x,sourceY:i.y,targetX:l.x,targetY:l.y}};function yT({sourcePos:e,targetPos:t,sourceWidth:n,sourceHeight:r,targetWidth:o,targetHeight:s,width:i,height:l,transform:a}){const c={x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x+n,t.x+o),y2:Math.max(e.y+r,t.y+s)};c.x===c.x2&&(c.x2+=1),c.y===c.y2&&(c.y2+=1);const u=Dd({x:(0-a[0])/a[2],y:(0-a[1])/a[2],width:i/a[2],height:l/a[2]}),f=Math.max(0,Math.min(u.x2,c.x2)-Math.max(u.x,c.x)),p=Math.max(0,Math.min(u.y2,c.y2)-Math.max(u.y,c.y));return Math.ceil(f*p)>0}function A0(e){var r,o,s,i,l;const t=((r=e==null?void 0:e[Ce])==null?void 0:r.handleBounds)||null,n=t&&(e==null?void 0:e.width)&&(e==null?void 0:e.height)&&typeof((o=e==null?void 0:e.positionAbsolute)==null?void 0:o.x)<"u"&&typeof((s=e==null?void 0:e.positionAbsolute)==null?void 0:s.y)<"u";return[{x:((i=e==null?void 0:e.positionAbsolute)==null?void 0:i.x)||0,y:((l=e==null?void 0:e.positionAbsolute)==null?void 0:l.y)||0,width:(e==null?void 0:e.width)||0,height:(e==null?void 0:e.height)||0},t,!!n]}const vT=[{level:0,isMaxLevel:!0,edges:[]}];function _T(e,t,n=!1){let r=-1;const o=e.reduce((i,l)=>{var u,f;const a=It(l.zIndex);let c=a?l.zIndex:0;if(n){const p=t.get(l.target),h=t.get(l.source),E=l.selected||(p==null?void 0:p.selected)||(h==null?void 0:h.selected),y=Math.max(((u=h==null?void 0:h[Ce])==null?void 0:u.z)||0,((f=p==null?void 0:p[Ce])==null?void 0:f.z)||0,1e3);c=(a?l.zIndex:0)+(E?y:0)}return i[c]?i[c].push(l):i[c]=[l],r=c>r?c:r,i},{}),s=Object.entries(o).map(([i,l])=>{const a=+i;return{edges:l,level:a,isMaxLevel:a===r}});return s.length===0?vT:s}function ST(e,t,n){const r=de(O.useCallback(o=>e?o.edges.filter(s=>{const i=t.get(s.source),l=t.get(s.target);return(i==null?void 0:i.width)&&(i==null?void 0:i.height)&&(l==null?void 0:l.width)&&(l==null?void 0:l.height)&&yT({sourcePos:i.positionAbsolute||{x:0,y:0},targetPos:l.positionAbsolute||{x:0,y:0},sourceWidth:i.width,sourceHeight:i.height,targetWidth:l.width,targetHeight:l.height,width:o.width,height:o.height,transform:o.transform})}):o.edges,[e,t]));return _T(r,t,n)}const xT=({color:e="none",strokeWidth:t=1})=>H.createElement("polyline",{style:{stroke:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),RT=({color:e="none",strokeWidth:t=1})=>H.createElement("polyline",{style:{stroke:e,fill:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"}),I0={[ni.Arrow]:xT,[ni.ArrowClosed]:RT};function NT(e){const t=Ie();return O.useMemo(()=>{var o,s;return Object.prototype.hasOwnProperty.call(I0,e)?I0[e]:((s=(o=t.getState()).onError)==null||s.call(o,"009",En.error009(e)),null)},[e])}const wT=({id:e,type:t,color:n,width:r=12.5,height:o=12.5,markerUnits:s="strokeWidth",strokeWidth:i,orient:l="auto-start-reverse"})=>{const a=NT(t);return a?H.createElement("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${r}`,markerHeight:`${o}`,viewBox:"-10 -10 20 20",markerUnits:s,orient:l,refX:"0",refY:"0"},H.createElement(a,{color:n,strokeWidth:i})):null},OT=({defaultColor:e,rfId:t})=>n=>{const r=[];return n.edges.reduce((o,s)=>([s.markerStart,s.markerEnd].forEach(i=>{if(i&&typeof i=="object"){const l=Vd(i,t);r.includes(l)||(o.push({id:l,color:i.color||e,...i}),r.push(l))}}),o),[]).sort((o,s)=>o.id.localeCompare(s.id))},C0=({defaultColor:e,rfId:t})=>{const n=de(O.useCallback(OT({defaultColor:e,rfId:t}),[e,t]),(r,o)=>!(r.length!==o.length||r.some((s,i)=>s.id!==o[i].id)));return H.createElement("defs",null,n.map(r=>H.createElement(wT,{id:r.id,key:r.id,type:r.type,color:r.color,width:r.width,height:r.height,markerUnits:r.markerUnits,strokeWidth:r.strokeWidth,orient:r.orient})))};C0.displayName="MarkerDefinitions";var TT=O.memo(C0);const AT=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}),L0=({defaultMarkerColor:e,onlyRenderVisibleElements:t,elevateEdgesOnSelect:n,rfId:r,edgeTypes:o,noPanClassName:s,onEdgeUpdate:i,onEdgeContextMenu:l,onEdgeMouseEnter:a,onEdgeMouseMove:c,onEdgeMouseLeave:u,onEdgeClick:f,edgeUpdaterRadius:p,onEdgeDoubleClick:h,onEdgeUpdateStart:E,onEdgeUpdateEnd:y,children:v})=>{const{edgesFocusable:m,edgesUpdatable:g,elementsSelectable:S,width:_,height:x,connectionMode:R,nodeInternals:T,onError:L}=de(AT,Ge),P=ST(t,T,n);return _?H.createElement(H.Fragment,null,P.map(({level:I,edges:j,isMaxLevel:V})=>H.createElement("svg",{key:I,style:{zIndex:I},width:_,height:x,className:"react-flow__edges react-flow__container"},V&&H.createElement(TT,{defaultColor:e,rfId:r}),H.createElement("g",null,j.map(M=>{const[w,b,k]=A0(T.get(M.source)),[F,C,D]=A0(T.get(M.target));if(!k||!D)return null;let U=M.type||"default";o[U]||(L==null||L("011",En.error011(U)),U="default");const $=o[U]||o.default,B=R===Wn.Strict?C.target:(C.target??[]).concat(C.source??[]),W=T0(b.source,M.sourceHandle),z=T0(B,M.targetHandle),Y=(W==null?void 0:W.position)||q.Bottom,X=(z==null?void 0:z.position)||q.Top,Z=!!(M.focusable||m&&typeof M.focusable>"u"),J=typeof i<"u"&&(M.updatable||g&&typeof M.updatable>"u");if(!W||!z)return L==null||L("008",En.error008(W,M)),null;const{sourceX:te,sourceY:ce,targetX:Re,targetY:Me}=ET(w,W,Y,F,z,X);return H.createElement($,{key:M.id,id:M.id,className:Je([M.className,s]),type:U,data:M.data,selected:!!M.selected,animated:!!M.animated,hidden:!!M.hidden,label:M.label,labelStyle:M.labelStyle,labelShowBg:M.labelShowBg,labelBgStyle:M.labelBgStyle,labelBgPadding:M.labelBgPadding,labelBgBorderRadius:M.labelBgBorderRadius,style:M.style,source:M.source,target:M.target,sourceHandleId:M.sourceHandle,targetHandleId:M.targetHandle,markerEnd:M.markerEnd,markerStart:M.markerStart,sourceX:te,sourceY:ce,targetX:Re,targetY:Me,sourcePosition:Y,targetPosition:X,elementsSelectable:S,onEdgeUpdate:i,onContextMenu:l,onMouseEnter:a,onMouseMove:c,onMouseLeave:u,onClick:f,edgeUpdaterRadius:p,onEdgeDoubleClick:h,onEdgeUpdateStart:E,onEdgeUpdateEnd:y,rfId:r,ariaLabel:M.ariaLabel,isFocusable:Z,isUpdatable:J,pathOptions:"pathOptions"in M?M.pathOptions:void 0,interactionWidth:M.interactionWidth})})))),v):null};L0.displayName="EdgeRenderer";var IT=O.memo(L0);const CT=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function LT({children:e}){const t=de(CT);return H.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:t}},e)}function bT(e){const t=Kd(),n=O.useRef(!1);O.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const DT={[q.Left]:q.Right,[q.Right]:q.Left,[q.Top]:q.Bottom,[q.Bottom]:q.Top},b0=({nodeId:e,handleType:t,style:n,type:r=Gn.Bezier,CustomComponent:o,connectionStatus:s})=>{var R,T,L;const{fromNode:i,handleId:l,toX:a,toY:c,connectionMode:u}=de(O.useCallback(P=>({fromNode:P.nodeInternals.get(e),handleId:P.connectionHandleId,toX:(P.connectionPosition.x-P.transform[0])/P.transform[2],toY:(P.connectionPosition.y-P.transform[1])/P.transform[2],connectionMode:P.connectionMode}),[e]),Ge),f=(R=i==null?void 0:i[Ce])==null?void 0:R.handleBounds;let p=f==null?void 0:f[t];if(u===Wn.Loose&&(p=p||(f==null?void 0:f[t==="source"?"target":"source"])),!i||!p)return null;const h=l?p.find(P=>P.id===l):p[0],E=h?h.x+h.width/2:(i.width??0)/2,y=h?h.y+h.height/2:i.height??0,v=(((T=i.positionAbsolute)==null?void 0:T.x)??0)+E,m=(((L=i.positionAbsolute)==null?void 0:L.y)??0)+y,g=h==null?void 0:h.position,S=g?DT[g]:null;if(!g||!S)return null;if(o)return H.createElement(o,{connectionLineType:r,connectionLineStyle:n,fromNode:i,fromHandle:h,fromX:v,fromY:m,toX:a,toY:c,fromPosition:g,toPosition:S,connectionStatus:s});let _="";const x={sourceX:v,sourceY:m,sourcePosition:g,targetX:a,targetY:c,targetPosition:S};return r===Gn.Bezier?[_]=UE(x):r===Gn.Step?[_]=ri({...x,borderRadius:0}):r===Gn.SmoothStep?[_]=ri(x):r===Gn.SimpleBezier?[_]=DE(x):_=`M${v},${m} ${a},${c}`,H.createElement("path",{d:_,fill:"none",className:"react-flow__connection-path",style:n})};b0.displayName="ConnectionLine";const kT=e=>({nodeId:e.connectionNodeId,handleType:e.connectionHandleType,nodesConnectable:e.nodesConnectable,connectionStatus:e.connectionStatus,width:e.width,height:e.height});function PT({containerStyle:e,style:t,type:n,component:r}){const{nodeId:o,handleType:s,nodesConnectable:i,width:l,height:a,connectionStatus:c}=de(kT,Ge);return!(o&&s&&l&&i)?null:H.createElement("svg",{style:e,width:l,height:a,className:"react-flow__edges react-flow__connectionline react-flow__container"},H.createElement("g",{className:Je(["react-flow__connection",c])},H.createElement(b0,{nodeId:o,handleType:s,style:t,type:n,CustomComponent:r,connectionStatus:c})))}function D0(e,t){return O.useRef(null),Ie(),O.useMemo(()=>t(e),[e])}const k0=({nodeTypes:e,edgeTypes:t,onMove:n,onMoveStart:r,onMoveEnd:o,onInit:s,onNodeClick:i,onEdgeClick:l,onNodeDoubleClick:a,onEdgeDoubleClick:c,onNodeMouseEnter:u,onNodeMouseMove:f,onNodeMouseLeave:p,onNodeContextMenu:h,onSelectionContextMenu:E,onSelectionStart:y,onSelectionEnd:v,connectionLineType:m,connectionLineStyle:g,connectionLineComponent:S,connectionLineContainerStyle:_,selectionKeyCode:x,selectionOnDrag:R,selectionMode:T,multiSelectionKeyCode:L,panActivationKeyCode:P,zoomActivationKeyCode:I,deleteKeyCode:j,onlyRenderVisibleElements:V,elementsSelectable:M,selectNodesOnDrag:w,defaultViewport:b,translateExtent:k,minZoom:F,maxZoom:C,preventScrolling:D,defaultMarkerColor:U,zoomOnScroll:$,zoomOnPinch:B,panOnScroll:W,panOnScrollSpeed:z,panOnScrollMode:Y,zoomOnDoubleClick:X,panOnDrag:Z,onPaneClick:J,onPaneMouseEnter:te,onPaneMouseMove:ce,onPaneMouseLeave:Re,onPaneScroll:Me,onPaneContextMenu:tn,onEdgeUpdate:Le,onEdgeContextMenu:ye,onEdgeMouseEnter:ut,onEdgeMouseMove:St,onEdgeMouseLeave:ee,edgeUpdaterRadius:Cr,onEdgeUpdateStart:Lr,onEdgeUpdateEnd:Ri,noDragClassName:Ko,noWheelClassName:br,noPanClassName:tr,elevateEdgesOnSelect:Xo,disableKeyboardA11y:nr,nodeOrigin:Dr,nodeExtent:Ni,rfId:Qo})=>{const Ye=D0(e,cT),xt=D0(t,gT);return bT(s),H.createElement(lT,{onPaneClick:J,onPaneMouseEnter:te,onPaneMouseMove:ce,onPaneMouseLeave:Re,onPaneContextMenu:tn,onPaneScroll:Me,deleteKeyCode:j,selectionKeyCode:x,selectionOnDrag:R,selectionMode:T,onSelectionStart:y,onSelectionEnd:v,multiSelectionKeyCode:L,panActivationKeyCode:P,zoomActivationKeyCode:I,elementsSelectable:M,onMove:n,onMoveStart:r,onMoveEnd:o,zoomOnScroll:$,zoomOnPinch:B,zoomOnDoubleClick:X,panOnScroll:W,panOnScrollSpeed:z,panOnScrollMode:Y,panOnDrag:Z,defaultViewport:b,translateExtent:k,minZoom:F,maxZoom:C,onSelectionContextMenu:E,preventScrolling:D,noDragClassName:Ko,noWheelClassName:br,noPanClassName:tr,disableKeyboardA11y:nr},H.createElement(LT,null,H.createElement(IT,{edgeTypes:xt,onEdgeClick:l,onEdgeDoubleClick:c,onEdgeUpdate:Le,onlyRenderVisibleElements:V,onEdgeContextMenu:ye,onEdgeMouseEnter:ut,onEdgeMouseMove:St,onEdgeMouseLeave:ee,onEdgeUpdateStart:Lr,onEdgeUpdateEnd:Ri,edgeUpdaterRadius:Cr,defaultMarkerColor:U,noPanClassName:tr,elevateEdgesOnSelect:!!Xo,disableKeyboardA11y:nr,rfId:Qo},H.createElement(PT,{style:g,type:m,component:S,containerStyle:_})),H.createElement("div",{className:"react-flow__edgelabel-renderer"}),H.createElement(fT,{nodeTypes:Ye,onNodeClick:i,onNodeDoubleClick:a,onNodeMouseEnter:u,onNodeMouseMove:f,onNodeMouseLeave:p,onNodeContextMenu:h,selectNodesOnDrag:w,onlyRenderVisibleElements:V,noPanClassName:tr,noDragClassName:Ko,disableKeyboardA11y:nr,nodeOrigin:Dr,nodeExtent:Ni,rfId:Qo})))};k0.displayName="GraphView";var MT=O.memo(k0);const ef=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Kn={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:ef,nodeExtent:ef,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:Wn.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:dO,isValidConnection:void 0},UT=()=>NR((e,t)=>({...Kn,setNodes:n=>{const{nodeInternals:r,nodeOrigin:o,elevateNodesOnSelect:s}=t();e({nodeInternals:Yd(n,r,o,s)})},getNodes:()=>Array.from(t().nodeInternals.values()),setEdges:n=>{const{defaultEdgeOptions:r={}}=t();e({edges:n.map(o=>({...r,...o}))})},setDefaultNodesAndEdges:(n,r)=>{const o=typeof n<"u",s=typeof r<"u",i=o?Yd(n,new Map,t().nodeOrigin,t().elevateNodesOnSelect):new Map;e({nodeInternals:i,edges:s?r:[],hasDefaultNodes:o,hasDefaultEdges:s})},updateNodeDimensions:n=>{const{onNodesChange:r,nodeInternals:o,fitViewOnInit:s,fitViewOnInitDone:i,fitViewOnInitOptions:l,domNode:a,nodeOrigin:c}=t(),u=a==null?void 0:a.querySelector(".react-flow__viewport");if(!u)return;const f=window.getComputedStyle(u),{m22:p}=new window.DOMMatrixReadOnly(f.transform),h=n.reduce((y,v)=>{const m=o.get(v.id);if(m){const g=Ld(v.nodeElement);!!(g.width&&g.height&&(m.width!==g.width||m.height!==g.height||v.forceUpdate))&&(o.set(m.id,{...m,[Ce]:{...m[Ce],handleBounds:{source:v0(".source",v.nodeElement,p,c),target:v0(".target",v.nodeElement,p,c)}},...g}),y.push({id:m.id,type:"dimensions",dimensions:g}))}return y},[]);a0(o,c);const E=i||s&&!i&&c0(t,{initial:!0,...l});e({nodeInternals:new Map(o),fitViewOnInitDone:E}),(h==null?void 0:h.length)>0&&(r==null||r(h))},updateNodePositions:(n,r=!0,o=!1)=>{const{triggerNodeChanges:s}=t(),i=n.map(l=>{const a={id:l.id,type:"position",dragging:o};return r&&(a.positionAbsolute=l.positionAbsolute,a.position=l.position),a});s(i)},triggerNodeChanges:n=>{const{onNodesChange:r,nodeInternals:o,hasDefaultNodes:s,nodeOrigin:i,getNodes:l,elevateNodesOnSelect:a}=t();if(n!=null&&n.length){if(s){const c=h0(n,l()),u=Yd(c,o,i,a);e({nodeInternals:u})}r==null||r(n)}},addSelectedNodes:n=>{const{multiSelectionActive:r,edges:o,getNodes:s}=t();let i,l=null;r?i=n.map(a=>Yn(a,!0)):(i=Io(s(),n),l=Io(o,[])),ga({changedNodes:i,changedEdges:l,get:t,set:e})},addSelectedEdges:n=>{const{multiSelectionActive:r,edges:o,getNodes:s}=t();let i,l=null;r?i=n.map(a=>Yn(a,!0)):(i=Io(o,n),l=Io(s(),[])),ga({changedNodes:l,changedEdges:i,get:t,set:e})},unselectNodesAndEdges:({nodes:n,edges:r}={})=>{const{edges:o,getNodes:s}=t(),i=n||s(),l=r||o,a=i.map(u=>(u.selected=!1,Yn(u.id,!1))),c=l.map(u=>Yn(u.id,!1));ga({changedNodes:a,changedEdges:c,get:t,set:e})},setMinZoom:n=>{const{d3Zoom:r,maxZoom:o}=t();r==null||r.scaleExtent([n,o]),e({minZoom:n})},setMaxZoom:n=>{const{d3Zoom:r,minZoom:o}=t();r==null||r.scaleExtent([o,n]),e({maxZoom:n})},setTranslateExtent:n=>{var r;(r=t().d3Zoom)==null||r.translateExtent(n),e({translateExtent:n})},resetSelectedElements:()=>{const{edges:n,getNodes:r}=t(),s=r().filter(l=>l.selected).map(l=>Yn(l.id,!1)),i=n.filter(l=>l.selected).map(l=>Yn(l.id,!1));ga({changedNodes:s,changedEdges:i,get:t,set:e})},setNodeExtent:n=>{const{nodeInternals:r}=t();r.forEach(o=>{o.positionAbsolute=bd(o.position,n)}),e({nodeExtent:n,nodeInternals:new Map(r)})},panBy:n=>{const{transform:r,width:o,height:s,d3Zoom:i,d3Selection:l,translateExtent:a}=t();if(!i||!l||!n.x&&!n.y)return!1;const c=Bn.translate(r[0]+n.x,r[1]+n.y).scale(r[2]),u=[[0,0],[o,s]],f=i==null?void 0:i.constrain()(c,u,a);return i.transform(l,f),r[0]!==f.x||r[1]!==f.y||r[2]!==f.k},cancelConnection:()=>e({connectionNodeId:Kn.connectionNodeId,connectionHandleId:Kn.connectionHandleId,connectionHandleType:Kn.connectionHandleType,connectionStatus:Kn.connectionStatus,connectionStartHandle:Kn.connectionStartHandle,connectionEndHandle:Kn.connectionEndHandle}),reset:()=>e({...Kn})}),Object.is),tf=({children:e})=>{const t=O.useRef(null);return t.current||(t.current=UT()),H.createElement(rO,{value:t.current},e)};tf.displayName="ReactFlowProvider";const P0=({children:e})=>O.useContext(ua)?H.createElement(H.Fragment,null,e):H.createElement(tf,null,e);P0.displayName="ReactFlowWrapper";const FT={input:JE,default:Wd,output:e0,group:Gd},jT={default:ha,straight:Fd,step:Ud,smoothstep:fa,simplebezier:Md},VT=[0,0],$T=[15,15],HT={x:0,y:0,zoom:1},BT={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},M0=O.forwardRef(({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:o,nodeTypes:s=FT,edgeTypes:i=jT,onNodeClick:l,onEdgeClick:a,onInit:c,onMove:u,onMoveStart:f,onMoveEnd:p,onConnect:h,onConnectStart:E,onConnectEnd:y,onClickConnectStart:v,onClickConnectEnd:m,onNodeMouseEnter:g,onNodeMouseMove:S,onNodeMouseLeave:_,onNodeContextMenu:x,onNodeDoubleClick:R,onNodeDragStart:T,onNodeDrag:L,onNodeDragStop:P,onNodesDelete:I,onEdgesDelete:j,onSelectionChange:V,onSelectionDragStart:M,onSelectionDrag:w,onSelectionDragStop:b,onSelectionContextMenu:k,onSelectionStart:F,onSelectionEnd:C,connectionMode:D=Wn.Strict,connectionLineType:U=Gn.Bezier,connectionLineStyle:$,connectionLineComponent:B,connectionLineContainerStyle:W,deleteKeyCode:z="Backspace",selectionKeyCode:Y="Shift",selectionOnDrag:X=!1,selectionMode:Z=ti.Full,panActivationKeyCode:J="Space",multiSelectionKeyCode:te=da()?"Meta":"Control",zoomActivationKeyCode:ce=da()?"Meta":"Control",snapToGrid:Re=!1,snapGrid:Me=$T,onlyRenderVisibleElements:tn=!1,selectNodesOnDrag:Le=!0,nodesDraggable:ye,nodesConnectable:ut,nodesFocusable:St,nodeOrigin:ee=VT,edgesFocusable:Cr,edgesUpdatable:Lr,elementsSelectable:Ri,defaultViewport:Ko=HT,minZoom:br=.5,maxZoom:tr=2,translateExtent:Xo=ef,preventScrolling:nr=!0,nodeExtent:Dr,defaultMarkerColor:Ni="#b1b1b7",zoomOnScroll:Qo=!0,zoomOnPinch:Ye=!0,panOnScroll:xt=!1,panOnScrollSpeed:kr=.5,panOnScrollMode:Pr=Sr.Free,zoomOnDoubleClick:Mr=!0,panOnDrag:Sn=!0,onPaneClick:nn,onPaneMouseEnter:wi,onPaneMouseMove:Gf,onPaneMouseLeave:Oi,onPaneScroll:Yf,onPaneContextMenu:zv,children:Ur,onEdgeUpdate:xD,onEdgeContextMenu:RD,onEdgeDoubleClick:ND,onEdgeMouseEnter:wD,onEdgeMouseMove:OD,onEdgeMouseLeave:TD,onEdgeUpdateStart:AD,onEdgeUpdateEnd:ID,edgeUpdaterRadius:CD=10,onNodesChange:LD,onEdgesChange:bD,noDragClassName:DD="nodrag",noWheelClassName:kD="nowheel",noPanClassName:Wv="nopan",fitView:PD=!1,fitViewOptions:MD,connectOnClick:UD=!0,attributionPosition:FD,proOptions:jD,defaultEdgeOptions:VD,elevateNodesOnSelect:$D=!0,elevateEdgesOnSelect:HD=!1,disableKeyboardA11y:Gv=!1,autoPanOnConnect:BD=!0,autoPanOnNodeDrag:zD=!0,connectionRadius:WD=20,isValidConnection:GD,onError:YD,style:KD,id:Yv,nodeDragThreshold:XD,...QD},qD)=>{const Kf=Yv||"1";return H.createElement("div",{...QD,style:{...KD,...BT},ref:qD,className:Je(["react-flow",o]),"data-testid":"rf__wrapper",id:Yv},H.createElement(P0,null,H.createElement(MT,{onInit:c,onMove:u,onMoveStart:f,onMoveEnd:p,onNodeClick:l,onEdgeClick:a,onNodeMouseEnter:g,onNodeMouseMove:S,onNodeMouseLeave:_,onNodeContextMenu:x,onNodeDoubleClick:R,nodeTypes:s,edgeTypes:i,connectionLineType:U,connectionLineStyle:$,connectionLineComponent:B,connectionLineContainerStyle:W,selectionKeyCode:Y,selectionOnDrag:X,selectionMode:Z,deleteKeyCode:z,multiSelectionKeyCode:te,panActivationKeyCode:J,zoomActivationKeyCode:ce,onlyRenderVisibleElements:tn,selectNodesOnDrag:Le,defaultViewport:Ko,translateExtent:Xo,minZoom:br,maxZoom:tr,preventScrolling:nr,zoomOnScroll:Qo,zoomOnPinch:Ye,zoomOnDoubleClick:Mr,panOnScroll:xt,panOnScrollSpeed:kr,panOnScrollMode:Pr,panOnDrag:Sn,onPaneClick:nn,onPaneMouseEnter:wi,onPaneMouseMove:Gf,onPaneMouseLeave:Oi,onPaneScroll:Yf,onPaneContextMenu:zv,onSelectionContextMenu:k,onSelectionStart:F,onSelectionEnd:C,onEdgeUpdate:xD,onEdgeContextMenu:RD,onEdgeDoubleClick:ND,onEdgeMouseEnter:wD,onEdgeMouseMove:OD,onEdgeMouseLeave:TD,onEdgeUpdateStart:AD,onEdgeUpdateEnd:ID,edgeUpdaterRadius:CD,defaultMarkerColor:Ni,noDragClassName:DD,noWheelClassName:kD,noPanClassName:Wv,elevateEdgesOnSelect:HD,rfId:Kf,disableKeyboardA11y:Gv,nodeOrigin:ee,nodeExtent:Dr}),H.createElement(DO,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:h,onConnectStart:E,onConnectEnd:y,onClickConnectStart:v,onClickConnectEnd:m,nodesDraggable:ye,nodesConnectable:ut,nodesFocusable:St,edgesFocusable:Cr,edgesUpdatable:Lr,elementsSelectable:Ri,elevateNodesOnSelect:$D,minZoom:br,maxZoom:tr,nodeExtent:Dr,onNodesChange:LD,onEdgesChange:bD,snapToGrid:Re,snapGrid:Me,connectionMode:D,translateExtent:Xo,connectOnClick:UD,defaultEdgeOptions:VD,fitView:PD,fitViewOptions:MD,onNodesDelete:I,onEdgesDelete:j,onNodeDragStart:T,onNodeDrag:L,onNodeDragStop:P,onSelectionDrag:w,onSelectionDragStart:M,onSelectionDragStop:b,noPanClassName:Wv,nodeOrigin:ee,rfId:Kf,autoPanOnConnect:BD,autoPanOnNodeDrag:zD,onError:YD,connectionRadius:WD,isValidConnection:GD,nodeDragThreshold:XD}),H.createElement(LO,{onSelectionChange:V}),Ur,H.createElement(sO,{proOptions:jD,position:FD}),H.createElement(FO,{rfId:Kf,disableKeyboardA11y:Gv})))});M0.displayName="ReactFlow";const zT=e=>{var t;return(t=e.domNode)==null?void 0:t.querySelector(".react-flow__edgelabel-renderer")};function WT({children:e}){const t=de(zT);return t?Bl.createPortal(e,t):null}function GT(){const e=Ie();return O.useCallback(t=>{const{domNode:n,updateNodeDimensions:r}=e.getState(),s=(Array.isArray(t)?t:[t]).reduce((i,l)=>{const a=n==null?void 0:n.querySelector(`.react-flow__node[data-id="${l}"]`);return a&&i.push({id:l,nodeElement:a,forceUpdate:!0}),i},[]);requestAnimationFrame(()=>r(s))},[])}function YT({onStart:e,onChange:t,onEnd:n}){const r=Ie();O.useEffect(()=>{r.setState({onViewportChangeStart:e})},[e]),O.useEffect(()=>{r.setState({onViewportChange:t})},[t]),O.useEffect(()=>{r.setState({onViewportChangeEnd:n})},[n])}const KT=e=>t=>t.nodeInternals.size===0?!1:t.getNodes().filter(n=>e.includeHiddenNodes?!0:!n.hidden).every(n=>{var r;return((r=n[Ce])==null?void 0:r.handleBounds)!==void 0}),XT={includeHiddenNodes:!1};function QT(e=XT){return de(KT(e))}function qT(){return H.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},H.createElement("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"}))}function JT(){return H.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},H.createElement("path",{d:"M0 0h32v4.2H0z"}))}function ZT(){return H.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30"},H.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 eA(){return H.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},H.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 tA(){return H.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},H.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 ii=({children:e,className:t,...n})=>H.createElement("button",{type:"button",className:Je(["react-flow__controls-button",t]),...n},e);ii.displayName="ControlButton";const nA=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom}),U0=({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:o,onZoomIn:s,onZoomOut:i,onFitView:l,onInteractiveChange:a,className:c,children:u,position:f="bottom-left"})=>{const p=Ie(),[h,E]=O.useState(!1),{isInteractive:y,minZoomReached:v,maxZoomReached:m}=de(nA,Ge),{zoomIn:g,zoomOut:S,fitView:_}=Kd();if(O.useEffect(()=>{E(!0)},[]),!h)return null;const x=()=>{g(),s==null||s()},R=()=>{S(),i==null||i()},T=()=>{_(o),l==null||l()},L=()=>{p.setState({nodesDraggable:!y,nodesConnectable:!y,elementsSelectable:!y}),a==null||a(!y)};return H.createElement(Zs,{className:Je(["react-flow__controls",c]),position:f,style:e,"data-testid":"rf__controls"},t&&H.createElement(H.Fragment,null,H.createElement(ii,{onClick:x,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:m},H.createElement(qT,null)),H.createElement(ii,{onClick:R,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:v},H.createElement(JT,null))),n&&H.createElement(ii,{className:"react-flow__controls-fitview",onClick:T,title:"fit view","aria-label":"fit view"},H.createElement(ZT,null)),r&&H.createElement(ii,{className:"react-flow__controls-interactive",onClick:L,title:"toggle interactivity","aria-label":"toggle interactivity"},y?H.createElement(tA,null):H.createElement(eA,null)),u)};U0.displayName="Controls";var rA=O.memo(U0),Ct;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Ct||(Ct={}));function oA({color:e,dimensions:t,lineWidth:n}){return H.createElement("path",{stroke:e,strokeWidth:n,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`})}function sA({color:e,radius:t}){return H.createElement("circle",{cx:t,cy:t,r:t,fill:e})}const iA={[Ct.Dots]:"#91919a",[Ct.Lines]:"#eee",[Ct.Cross]:"#e2e2e2"},lA={[Ct.Dots]:1,[Ct.Lines]:1,[Ct.Cross]:6},aA=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function F0({id:e,variant:t=Ct.Dots,gap:n=20,size:r,lineWidth:o=1,offset:s=2,color:i,style:l,className:a}){const c=O.useRef(null),{transform:u,patternId:f}=de(aA,Ge),p=i||iA[t],h=r||lA[t],E=t===Ct.Dots,y=t===Ct.Cross,v=Array.isArray(n)?n:[n,n],m=[v[0]*u[2]||1,v[1]*u[2]||1],g=h*u[2],S=y?[g,g]:m,_=E?[g/s,g/s]:[S[0]/s,S[1]/s];return H.createElement("svg",{className:Je(["react-flow__background",a]),style:{...l,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:c,"data-testid":"rf__background"},H.createElement("pattern",{id:f+e,x:u[0]%m[0],y:u[1]%m[1],width:m[0],height:m[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${_[0]},-${_[1]})`},E?H.createElement(sA,{color:p,radius:g/s}):H.createElement(oA,{dimensions:S,color:p,lineWidth:o})),H.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${f+e})`}))}F0.displayName="Background";var cA=O.memo(F0),j0={VITE_BASE_URL:"",VITE_BASIC_AUTH:"signalwire:1aG93uXk",VITE_DEFAULT_STYLE_HREF:"https://cdn.swire.io/npm/@signalwire/cfb@dev/dist/style.css",VITE_DEFAULT_VOICES_URL:"https://cdn.signalwire.com/npm/@signalwire/cfb@dev/dist/voices.json",VITE_FLOW_DATA_VERSION:"0.0.10",VITE_IS_STAGING:"true",BASE_URL:"/cfb/",MODE:"staging",DEV:!1,PROD:!0,SSR:!1};const{useDebugValue:uA}=H,{useSyncExternalStoreWithSelector:dA}=Tg;let V0=!1;function fA(e,t=e.getState,n){(j0?"staging":void 0)!=="production"&&n&&!V0&&(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"),V0=!0);const r=dA(e.subscribe,e.getState,e.getServerState||e.getState,t,n);return uA(r),r}const $0=e=>{(j0?"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"?Ig(e):e,n=(r,o)=>fA(t,r,o);return Object.assign(n,t),n},bo=e=>e?$0(e):$0,pA=!1,hA="staging",mA="0.0.12",li="0.0.10",H0=230,gA=640,B0=20,Do={markerEnd:{height:20,type:ni.ArrowClosed,width:20},style:{stroke:"inherit",strokeWidth:1.5},type:"floating"},EA="422",yA="404",z0="document-sync",nf=1e3,vA=1e3,_A=300,SA=5e3,W0=300,xA="Shift+Backspace",RA="Meta",NA="Shift",ya=25,rf={duration:nf,includeHiddenNodes:!1,padding:.3},of=()=>{const e={},t=document.querySelector('meta[name="csrf-token"]');return t&&(e["X-CSRF-Token"]=t==null?void 0:t.content),e},wA=(e,t)=>{var s;const n=new Blob([JSON.stringify({edges:t,nodes:e},null,2)],{type:"application/json"}),r=window.URL.createObjectURL(n),o=window.open();(s=o==null?void 0:o.location)!=null&&s.href&&(o.location.href=r)},G0=e=>({...e,...Do}),Y0=e=>e.type==="handleCall"?{...e,deletable:!1}:e,K0=e=>e==="success"?"positive":"negative",OA=e=>e.toLowerCase().replace(/ /g,"-"),yt=e=>typeof e=="string"?e.trim():e,X0=(e,t,n)=>e.sort((r,o)=>{const s=n?r[n]:r,i=n?o[n]:o;if(typeof s=="string"&&typeof i=="string")return t==="asc"?s.toLowerCase().localeCompare(i.toLowerCase()):i.toLowerCase().localeCompare(s.toLowerCase());if(typeof s=="number"&&typeof i=="number")return t==="asc"?s-i:i-s;throw new Error(`sort fn can only sort strings & numbers, but got ${typeof s} and ${typeof i}`)}),TA=e=>{try{return new URL(e).pathname.split("/").at(-1)}catch{return""}};function Q0(e,t){const n=[{divisor:1,threshold:60,unit:"second"},{divisor:60,threshold:3600,unit:"minute"},{divisor:3600,threshold:86400,unit:"hour"},{divisor:86400,threshold:86400,unit:"day"}],r=new Intl.RelativeTimeFormat(e,{numeric:"always",...t});return function(s,i={}){const{excludeUnits:l={}}=i,a=new Date().getTime(),c=new Date(s).getTime(),u=Math.floor((a-c)/1e3),f=n.filter(({unit:y})=>!l[y]),{divisor:p,unit:h}=f.find(({threshold:y})=>Math.abs(u)<y)??f[f.length-1],E=Math.floor(u/p);return r.format(-E,h)}}function q0(e){return new Promise(t=>setTimeout(t,e))}const AA=(e,t,n)=>{const r=e==="ArrowDown";if(!t)return r?n[0]:n[n.length-1];const o=n.findIndex(l=>l.id===t),s=r?o+1:o-1;if(s<0||s>=n.length)return;const i=n[s];if(!i)throw new Error(`Could not find option at index ${s}`);return i},J0=(e,t,n)=>{const r=e.find(o=>{if(t in o)return o[t]===n});if(!r)throw new Error(`Could not find option with id ${t}`);return r},IA=e=>Object.keys(e),sf=()=>({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"}]}),Z0={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:()=>({...sf(),destinationType:"address"}),forwardPhone:()=>({...sf(),destinationType:"phone"}),forwardResource:()=>({...sf(),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:[]})},CA={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 va{constructor(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.init(t,n)}init(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.prefix=n.prefix||"i18next:",this.logger=t||CA,this.options=n,this.debug=n.debug}log(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return this.forward(n,"log","",!0)}warn(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return this.forward(n,"warn","",!0)}error(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return this.forward(n,"error","")}deprecate(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return this.forward(n,"warn","WARNING DEPRECATED: ",!0)}forward(t,n,r,o){return o&&!this.debug?null:(typeof t[0]=="string"&&(t[0]=`${r}${this.prefix} ${t[0]}`),this.logger[n](t))}create(t){return new va(this.logger,{prefix:`${this.prefix}:${t}:`,...this.options})}clone(t){return t=t||this.options,t.prefix=t.prefix||this.prefix,new va(this.logger,t)}}var Jt=new va;class _a{constructor(){this.observers={}}on(t,n){return t.split(" ").forEach(r=>{this.observers[r]=this.observers[r]||[],this.observers[r].push(n)}),this}off(t,n){if(this.observers[t]){if(!n){delete this.observers[t];return}this.observers[t]=this.observers[t].filter(r=>r!==n)}}emit(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];this.observers[t]&&[].concat(this.observers[t]).forEach(i=>{i(...r)}),this.observers["*"]&&[].concat(this.observers["*"]).forEach(i=>{i.apply(i,[t,...r])})}}function ai(){let e,t;const n=new Promise((r,o)=>{e=r,t=o});return n.resolve=e,n.reject=t,n}function ey(e){return e==null?"":""+e}function LA(e,t,n){e.forEach(r=>{t[r]&&(n[r]=t[r])})}function lf(e,t,n){function r(i){return i&&i.indexOf("###")>-1?i.replace(/###/g,"."):i}function o(){return!e||typeof e=="string"}const s=typeof t!="string"?[].concat(t):t.split(".");for(;s.length>1;){if(o())return{};const i=r(s.shift());!e[i]&&n&&(e[i]=new n),Object.prototype.hasOwnProperty.call(e,i)?e=e[i]:e={}}return o()?{}:{obj:e,k:r(s.shift())}}function ty(e,t,n){const{obj:r,k:o}=lf(e,t,Object);r[o]=n}function bA(e,t,n,r){const{obj:o,k:s}=lf(e,t,Object);o[s]=o[s]||[],r&&(o[s]=o[s].concat(n)),r||o[s].push(n)}function Sa(e,t){const{obj:n,k:r}=lf(e,t);if(n)return n[r]}function DA(e,t,n){const r=Sa(e,n);return r!==void 0?r:Sa(t,n)}function ny(e,t,n){for(const r in t)r!=="__proto__"&&r!=="constructor"&&(r in e?typeof e[r]=="string"||e[r]instanceof String||typeof t[r]=="string"||t[r]instanceof String?n&&(e[r]=t[r]):ny(e[r],t[r],n):e[r]=t[r]);return e}function ko(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}var kA={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};function PA(e){return typeof e=="string"?e.replace(/[&<>"'\/]/g,t=>kA[t]):e}const MA=[" ",",","?","!",";"];function UA(e,t,n){t=t||"",n=n||"";const r=MA.filter(i=>t.indexOf(i)<0&&n.indexOf(i)<0);if(r.length===0)return!0;const o=new RegExp(`(${r.map(i=>i==="?"?"\\?":i).join("|")})`);let s=!o.test(e);if(!s){const i=e.indexOf(n);i>0&&!o.test(e.substring(0,i))&&(s=!0)}return s}function xa(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:".";if(!e)return;if(e[t])return e[t];const r=t.split(n);let o=e;for(let s=0;s<r.length;++s){if(!o||typeof o[r[s]]=="string"&&s+1<r.length)return;if(o[r[s]]===void 0){let i=2,l=r.slice(s,s+i).join(n),a=o[l];for(;a===void 0&&r.length>s+i;)i++,l=r.slice(s,s+i).join(n),a=o[l];if(a===void 0)return;if(a===null)return null;if(t.endsWith(l)){if(typeof a=="string")return a;if(l&&typeof a[l]=="string")return a[l]}const c=r.slice(s+i).join(n);return c?xa(a,c,n):void 0}o=o[r[s]]}return o}function Ra(e){return e&&e.indexOf("_")>0?e.replace("_","-"):e}class ry extends _a{constructor(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{ns:["translation"],defaultNS:"translation"};super(),this.data=t||{},this.options=n,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 n=this.options.ns.indexOf(t);n>-1&&this.options.ns.splice(n,1)}getResource(t,n,r){let o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};const s=o.keySeparator!==void 0?o.keySeparator:this.options.keySeparator,i=o.ignoreJSONStructure!==void 0?o.ignoreJSONStructure:this.options.ignoreJSONStructure;let l=[t,n];r&&typeof r!="string"&&(l=l.concat(r)),r&&typeof r=="string"&&(l=l.concat(s?r.split(s):r)),t.indexOf(".")>-1&&(l=t.split("."));const a=Sa(this.data,l);return a||!i||typeof r!="string"?a:xa(this.data&&this.data[t]&&this.data[t][n],r,s)}addResource(t,n,r,o){let s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{silent:!1};const i=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator;let l=[t,n];r&&(l=l.concat(i?r.split(i):r)),t.indexOf(".")>-1&&(l=t.split("."),o=n,n=l[1]),this.addNamespaces(n),ty(this.data,l,o),s.silent||this.emit("added",t,n,r,o)}addResources(t,n,r){let o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{silent:!1};for(const s in r)(typeof r[s]=="string"||Object.prototype.toString.apply(r[s])==="[object Array]")&&this.addResource(t,n,s,r[s],{silent:!0});o.silent||this.emit("added",t,n,r)}addResourceBundle(t,n,r,o,s){let i=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{silent:!1},l=[t,n];t.indexOf(".")>-1&&(l=t.split("."),o=r,r=n,n=l[1]),this.addNamespaces(n);let a=Sa(this.data,l)||{};o?ny(a,r,s):a={...a,...r},ty(this.data,l,a),i.silent||this.emit("added",t,n,r)}removeResourceBundle(t,n){this.hasResourceBundle(t,n)&&delete this.data[t][n],this.removeNamespaces(n),this.emit("removed",t,n)}hasResourceBundle(t,n){return this.getResource(t,n)!==void 0}getResourceBundle(t,n){return n||(n=this.options.defaultNS),this.options.compatibilityAPI==="v1"?{...this.getResource(t,n)}:this.getResource(t,n)}getDataByLanguage(t){return this.data[t]}hasLanguageSomeTranslations(t){const n=this.getDataByLanguage(t);return!!(n&&Object.keys(n)||[]).find(o=>n[o]&&Object.keys(n[o]).length>0)}toJSON(){return this.data}}var oy={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,n,r,o){return e.forEach(s=>{this.processors[s]&&(t=this.processors[s].process(t,n,r,o))}),t}};const sy={};class Na extends _a{constructor(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),LA(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],t,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=Jt.create("translator")}changeLanguage(t){t&&(this.language=t)}exists(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}};if(t==null)return!1;const r=this.resolve(t,n);return r&&r.res!==void 0}extractFromKey(t,n){let r=n.nsSeparator!==void 0?n.nsSeparator:this.options.nsSeparator;r===void 0&&(r=":");const o=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let s=n.ns||this.options.defaultNS||[];const i=r&&t.indexOf(r)>-1,l=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!UA(t,r,o);if(i&&!l){const a=t.match(this.interpolator.nestingRegexp);if(a&&a.length>0)return{key:t,namespaces:s};const c=t.split(r);(r!==o||r===o&&this.options.ns.indexOf(c[0])>-1)&&(s=c.shift()),t=c.join(o)}return typeof s=="string"&&(s=[s]),{key:t,namespaces:s}}translate(t,n,r){if(typeof n!="object"&&this.options.overloadTranslationOptionHandler&&(n=this.options.overloadTranslationOptionHandler(arguments)),typeof n=="object"&&(n={...n}),n||(n={}),t==null)return"";Array.isArray(t)||(t=[String(t)]);const o=n.returnDetails!==void 0?n.returnDetails:this.options.returnDetails,s=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator,{key:i,namespaces:l}=this.extractFromKey(t[t.length-1],n),a=l[l.length-1],c=n.lng||this.language,u=n.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(c&&c.toLowerCase()==="cimode"){if(u){const _=n.nsSeparator||this.options.nsSeparator;return o?{res:`${a}${_}${i}`,usedKey:i,exactUsedKey:i,usedLng:c,usedNS:a,usedParams:this.getUsedParamsDetails(n)}:`${a}${_}${i}`}return o?{res:i,usedKey:i,exactUsedKey:i,usedLng:c,usedNS:a,usedParams:this.getUsedParamsDetails(n)}:i}const f=this.resolve(t,n);let p=f&&f.res;const h=f&&f.usedKey||i,E=f&&f.exactUsedKey||i,y=Object.prototype.toString.apply(p),v=["[object Number]","[object Function]","[object RegExp]"],m=n.joinArrays!==void 0?n.joinArrays:this.options.joinArrays,g=!this.i18nFormat||this.i18nFormat.handleAsObject;if(g&&p&&(typeof p!="string"&&typeof p!="boolean"&&typeof p!="number")&&v.indexOf(y)<0&&!(typeof m=="string"&&y==="[object Array]")){if(!n.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const _=this.options.returnedObjectHandler?this.options.returnedObjectHandler(h,p,{...n,ns:l}):`key '${i} (${this.language})' returned an object instead of string.`;return o?(f.res=_,f.usedParams=this.getUsedParamsDetails(n),f):_}if(s){const _=y==="[object Array]",x=_?[]:{},R=_?E:h;for(const T in p)if(Object.prototype.hasOwnProperty.call(p,T)){const L=`${R}${s}${T}`;x[T]=this.translate(L,{...n,joinArrays:!1,ns:l}),x[T]===L&&(x[T]=p[T])}p=x}}else if(g&&typeof m=="string"&&y==="[object Array]")p=p.join(m),p&&(p=this.extendTranslation(p,t,n,r));else{let _=!1,x=!1;const R=n.count!==void 0&&typeof n.count!="string",T=Na.hasDefaultValue(n),L=R?this.pluralResolver.getSuffix(c,n.count,n):"",P=n.ordinal&&R?this.pluralResolver.getSuffix(c,n.count,{ordinal:!1}):"",I=n[`defaultValue${L}`]||n[`defaultValue${P}`]||n.defaultValue;!this.isValidLookup(p)&&T&&(_=!0,p=I),this.isValidLookup(p)||(x=!0,p=i);const V=(n.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&x?void 0:p,M=T&&I!==p&&this.options.updateMissing;if(x||_||M){if(this.logger.log(M?"updateKey":"missingKey",c,a,i,M?I:p),s){const F=this.resolve(i,{...n,keySeparator:!1});F&&F.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 w=[];const b=this.languageUtils.getFallbackCodes(this.options.fallbackLng,n.lng||this.language);if(this.options.saveMissingTo==="fallback"&&b&&b[0])for(let F=0;F<b.length;F++)w.push(b[F]);else this.options.saveMissingTo==="all"?w=this.languageUtils.toResolveHierarchy(n.lng||this.language):w.push(n.lng||this.language);const k=(F,C,D)=>{const U=T&&D!==p?D:V;this.options.missingKeyHandler?this.options.missingKeyHandler(F,a,C,U,M,n):this.backendConnector&&this.backendConnector.saveMissing&&this.backendConnector.saveMissing(F,a,C,U,M,n),this.emit("missingKey",F,a,C,p)};this.options.saveMissing&&(this.options.saveMissingPlurals&&R?w.forEach(F=>{this.pluralResolver.getSuffixes(F,n).forEach(C=>{k([F],i+C,n[`defaultValue${C}`]||I)})}):k(w,i,I))}p=this.extendTranslation(p,t,n,f,r),x&&p===i&&this.options.appendNamespaceToMissingKey&&(p=`${a}:${i}`),(x||_)&&this.options.parseMissingKeyHandler&&(this.options.compatibilityAPI!=="v1"?p=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${a}:${i}`:i,_?p:void 0):p=this.options.parseMissingKeyHandler(p))}return o?(f.res=p,f.usedParams=this.getUsedParamsDetails(n),f):p}extendTranslation(t,n,r,o,s){var i=this;if(this.i18nFormat&&this.i18nFormat.parse)t=this.i18nFormat.parse(t,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||o.usedLng,o.usedNS,o.usedKey,{resolved:o});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init({...r,interpolation:{...this.options.interpolation,...r.interpolation}});const c=typeof t=="string"&&(r&&r.interpolation&&r.interpolation.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let u;if(c){const p=t.match(this.interpolator.nestingRegexp);u=p&&p.length}let f=r.replace&&typeof r.replace!="string"?r.replace:r;if(this.options.interpolation.defaultVariables&&(f={...this.options.interpolation.defaultVariables,...f}),t=this.interpolator.interpolate(t,f,r.lng||this.language,r),c){const p=t.match(this.interpolator.nestingRegexp),h=p&&p.length;u<h&&(r.nest=!1)}!r.lng&&this.options.compatibilityAPI!=="v1"&&o&&o.res&&(r.lng=o.usedLng),r.nest!==!1&&(t=this.interpolator.nest(t,function(){for(var p=arguments.length,h=new Array(p),E=0;E<p;E++)h[E]=arguments[E];return s&&s[0]===h[0]&&!r.context?(i.logger.warn(`It seems you are nesting recursively key: ${h[0]} in key: ${n[0]}`),null):i.translate(...h,n)},r)),r.interpolation&&this.interpolator.reset()}const l=r.postProcess||this.options.postProcess,a=typeof l=="string"?[l]:l;return t!=null&&a&&a.length&&r.applyPostProcessor!==!1&&(t=oy.handle(a,t,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...o,usedParams:this.getUsedParamsDetails(r)},...r}:r,this)),t}resolve(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r,o,s,i,l;return typeof t=="string"&&(t=[t]),t.forEach(a=>{if(this.isValidLookup(r))return;const c=this.extractFromKey(a,n),u=c.key;o=u;let f=c.namespaces;this.options.fallbackNS&&(f=f.concat(this.options.fallbackNS));const p=n.count!==void 0&&typeof n.count!="string",h=p&&!n.ordinal&&n.count===0&&this.pluralResolver.shouldUseIntlApi(),E=n.context!==void 0&&(typeof n.context=="string"||typeof n.context=="number")&&n.context!=="",y=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);f.forEach(v=>{this.isValidLookup(r)||(l=v,!sy[`${y[0]}-${v}`]&&this.utils&&this.utils.hasLoadedNamespace&&!this.utils.hasLoadedNamespace(l)&&(sy[`${y[0]}-${v}`]=!0,this.logger.warn(`key "${o}" for languages "${y.join(", ")}" won't get resolved as namespace "${l}" 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!!!")),y.forEach(m=>{if(this.isValidLookup(r))return;i=m;const g=[u];if(this.i18nFormat&&this.i18nFormat.addLookupKeys)this.i18nFormat.addLookupKeys(g,u,m,v,n);else{let _;p&&(_=this.pluralResolver.getSuffix(m,n.count,n));const x=`${this.options.pluralSeparator}zero`,R=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(p&&(g.push(u+_),n.ordinal&&_.indexOf(R)===0&&g.push(u+_.replace(R,this.options.pluralSeparator)),h&&g.push(u+x)),E){const T=`${u}${this.options.contextSeparator}${n.context}`;g.push(T),p&&(g.push(T+_),n.ordinal&&_.indexOf(R)===0&&g.push(T+_.replace(R,this.options.pluralSeparator)),h&&g.push(T+x))}}let S;for(;S=g.pop();)this.isValidLookup(r)||(s=S,r=this.getResource(m,v,S,n))}))})}),{res:r,usedKey:o,exactUsedKey:s,usedLng:i,usedNS:l}}isValidLookup(t){return t!==void 0&&!(!this.options.returnNull&&t===null)&&!(!this.options.returnEmptyString&&t==="")}getResource(t,n,r){let o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return this.i18nFormat&&this.i18nFormat.getResource?this.i18nFormat.getResource(t,n,r,o):this.resourceStore.getResource(t,n,r,o)}getUsedParamsDetails(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const n=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],r=t.replace&&typeof t.replace!="string";let o=r?t.replace:t;if(r&&typeof t.count<"u"&&(o.count=t.count),this.options.interpolation.defaultVariables&&(o={...this.options.interpolation.defaultVariables,...o}),!r){o={...o};for(const s of n)delete o[s]}return o}static hasDefaultValue(t){const n="defaultValue";for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&n===r.substring(0,n.length)&&t[r]!==void 0)return!0;return!1}}function af(e){return e.charAt(0).toUpperCase()+e.slice(1)}class iy{constructor(t){this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Jt.create("languageUtils")}getScriptPartFromCode(t){if(t=Ra(t),!t||t.indexOf("-")<0)return null;const n=t.split("-");return n.length===2||(n.pop(),n[n.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(n.join("-"))}getLanguagePartFromCode(t){if(t=Ra(t),!t||t.indexOf("-")<0)return t;const n=t.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(t){if(typeof t=="string"&&t.indexOf("-")>-1){const n=["hans","hant","latn","cyrl","cans","mong","arab"];let r=t.split("-");return this.options.lowerCaseLng?r=r.map(o=>o.toLowerCase()):r.length===2?(r[0]=r[0].toLowerCase(),r[1]=r[1].toUpperCase(),n.indexOf(r[1].toLowerCase())>-1&&(r[1]=af(r[1].toLowerCase()))):r.length===3&&(r[0]=r[0].toLowerCase(),r[1].length===2&&(r[1]=r[1].toUpperCase()),r[0]!=="sgn"&&r[2].length===2&&(r[2]=r[2].toUpperCase()),n.indexOf(r[1].toLowerCase())>-1&&(r[1]=af(r[1].toLowerCase())),n.indexOf(r[2].toLowerCase())>-1&&(r[2]=af(r[2].toLowerCase()))),r.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 n;return t.forEach(r=>{if(n)return;const o=this.formatLanguageCode(r);(!this.options.supportedLngs||this.isSupportedCode(o))&&(n=o)}),!n&&this.options.supportedLngs&&t.forEach(r=>{if(n)return;const o=this.getLanguagePartFromCode(r);if(this.isSupportedCode(o))return n=o;n=this.options.supportedLngs.find(s=>{if(s===o)return s;if(!(s.indexOf("-")<0&&o.indexOf("-")<0)&&s.indexOf(o)===0)return s})}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n}getFallbackCodes(t,n){if(!t)return[];if(typeof t=="function"&&(t=t(n)),typeof t=="string"&&(t=[t]),Object.prototype.toString.apply(t)==="[object Array]")return t;if(!n)return t.default||[];let r=t[n];return r||(r=t[this.getScriptPartFromCode(n)]),r||(r=t[this.formatLanguageCode(n)]),r||(r=t[this.getLanguagePartFromCode(n)]),r||(r=t.default),r||[]}toResolveHierarchy(t,n){const r=this.getFallbackCodes(n||this.options.fallbackLng||[],t),o=[],s=i=>{i&&(this.isSupportedCode(i)?o.push(i):this.logger.warn(`rejecting language code not found in supportedLngs: ${i}`))};return typeof t=="string"&&(t.indexOf("-")>-1||t.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&s(this.formatLanguageCode(t)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&s(this.getScriptPartFromCode(t)),this.options.load!=="currentOnly"&&s(this.getLanguagePartFromCode(t))):typeof t=="string"&&s(this.formatLanguageCode(t)),r.forEach(i=>{o.indexOf(i)<0&&s(this.formatLanguageCode(i))}),o}}let FA=[{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}],jA={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 VA=["v1","v2","v3"],$A=["v4"],ly={zero:0,one:1,two:2,few:3,many:4,other:5};function HA(){const e={};return FA.forEach(t=>{t.lngs.forEach(n=>{e[n]={numbers:t.nr,plurals:jA[t.fc]}})}),e}class BA{constructor(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.languageUtils=t,this.options=n,this.logger=Jt.create("pluralResolver"),(!this.options.compatibilityJSON||$A.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=HA()}addRule(t,n){this.rules[t]=n}getRule(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(this.shouldUseIntlApi())try{return new Intl.PluralRules(Ra(t),{type:n.ordinal?"ordinal":"cardinal"})}catch{return}return this.rules[t]||this.rules[this.languageUtils.getLanguagePartFromCode(t)]}needsPlural(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const r=this.getRule(t,n);return this.shouldUseIntlApi()?r&&r.resolvedOptions().pluralCategories.length>1:r&&r.numbers.length>1}getPluralFormsOfKey(t,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return this.getSuffixes(t,r).map(o=>`${n}${o}`)}getSuffixes(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const r=this.getRule(t,n);return r?this.shouldUseIntlApi()?r.resolvedOptions().pluralCategories.sort((o,s)=>ly[o]-ly[s]).map(o=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${o}`):r.numbers.map(o=>this.getSuffix(t,o,n)):[]}getSuffix(t,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const o=this.getRule(t,r);return o?this.shouldUseIntlApi()?`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${o.select(n)}`:this.getSuffixRetroCompatible(o,n):(this.logger.warn(`no plural rule found for: ${t}`),"")}getSuffixRetroCompatible(t,n){const r=t.noAbs?t.plurals(n):t.plurals(Math.abs(n));let o=t.numbers[r];this.options.simplifyPluralSuffix&&t.numbers.length===2&&t.numbers[0]===1&&(o===2?o="plural":o===1&&(o=""));const s=()=>this.options.prepend&&o.toString()?this.options.prepend+o.toString():o.toString();return this.options.compatibilityJSON==="v1"?o===1?"":typeof o=="number"?`_plural_${o.toString()}`:s():this.options.compatibilityJSON==="v2"||this.options.simplifyPluralSuffix&&t.numbers.length===2&&t.numbers[0]===1?s():this.options.prepend&&r.toString()?this.options.prepend+r.toString():r.toString()}shouldUseIntlApi(){return!VA.includes(this.options.compatibilityJSON)}}function ay(e,t,n){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:".",o=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,s=DA(e,t,n);return!s&&o&&typeof n=="string"&&(s=xa(e,n,r),s===void 0&&(s=xa(t,n,r))),s}class zA{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=Jt.create("interpolator"),this.options=t,this.format=t.interpolation&&t.interpolation.format||(n=>n),this.init(t)}init(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};t.interpolation||(t.interpolation={escapeValue:!0});const n=t.interpolation;this.escape=n.escape!==void 0?n.escape:PA,this.escapeValue=n.escapeValue!==void 0?n.escapeValue:!0,this.useRawValueToEscape=n.useRawValueToEscape!==void 0?n.useRawValueToEscape:!1,this.prefix=n.prefix?ko(n.prefix):n.prefixEscaped||"{{",this.suffix=n.suffix?ko(n.suffix):n.suffixEscaped||"}}",this.formatSeparator=n.formatSeparator?n.formatSeparator:n.formatSeparator||",",this.unescapePrefix=n.unescapeSuffix?"":n.unescapePrefix||"-",this.unescapeSuffix=this.unescapePrefix?"":n.unescapeSuffix||"",this.nestingPrefix=n.nestingPrefix?ko(n.nestingPrefix):n.nestingPrefixEscaped||ko("$t("),this.nestingSuffix=n.nestingSuffix?ko(n.nestingSuffix):n.nestingSuffixEscaped||ko(")"),this.nestingOptionsSeparator=n.nestingOptionsSeparator?n.nestingOptionsSeparator:n.nestingOptionsSeparator||",",this.maxReplaces=n.maxReplaces?n.maxReplaces:1e3,this.alwaysFormat=n.alwaysFormat!==void 0?n.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 n=`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`;this.regexpUnescape=new RegExp(n,"g");const r=`${this.nestingPrefix}(.+?)${this.nestingSuffix}`;this.nestingRegexp=new RegExp(r,"g")}interpolate(t,n,r,o){let s,i,l;const a=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{};function c(E){return E.replace(/\$/g,"$$$$")}const u=E=>{if(E.indexOf(this.formatSeparator)<0){const g=ay(n,a,E,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(g,void 0,r,{...o,...n,interpolationkey:E}):g}const y=E.split(this.formatSeparator),v=y.shift().trim(),m=y.join(this.formatSeparator).trim();return this.format(ay(n,a,v,this.options.keySeparator,this.options.ignoreJSONStructure),m,r,{...o,...n,interpolationkey:v})};this.resetRegExp();const f=o&&o.missingInterpolationHandler||this.options.missingInterpolationHandler,p=o&&o.interpolation&&o.interpolation.skipOnVariables!==void 0?o.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:E=>c(E)},{regex:this.regexp,safeValue:E=>this.escapeValue?c(this.escape(E)):c(E)}].forEach(E=>{for(l=0;s=E.regex.exec(t);){const y=s[1].trim();if(i=u(y),i===void 0)if(typeof f=="function"){const m=f(t,s,o);i=typeof m=="string"?m:""}else if(o&&Object.prototype.hasOwnProperty.call(o,y))i="";else if(p){i=s[0];continue}else this.logger.warn(`missed to pass in variable ${y} for interpolating ${t}`),i="";else typeof i!="string"&&!this.useRawValueToEscape&&(i=ey(i));const v=E.safeValue(i);if(t=t.replace(s[0],v),p?(E.regex.lastIndex+=i.length,E.regex.lastIndex-=s[0].length):E.regex.lastIndex=0,l++,l>=this.maxReplaces)break}}),t}nest(t,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},o,s,i;function l(a,c){const u=this.nestingOptionsSeparator;if(a.indexOf(u)<0)return a;const f=a.split(new RegExp(`${u}[ ]*{`));let p=`{${f[1]}`;a=f[0],p=this.interpolate(p,i);const h=p.match(/'/g),E=p.match(/"/g);(h&&h.length%2===0&&!E||E.length%2!==0)&&(p=p.replace(/'/g,'"'));try{i=JSON.parse(p),c&&(i={...c,...i})}catch(y){return this.logger.warn(`failed parsing options string in nesting for key ${a}`,y),`${a}${u}${p}`}return delete i.defaultValue,a}for(;o=this.nestingRegexp.exec(t);){let a=[];i={...r},i=i.replace&&typeof i.replace!="string"?i.replace:i,i.applyPostProcessor=!1,delete i.defaultValue;let c=!1;if(o[0].indexOf(this.formatSeparator)!==-1&&!/{.*}/.test(o[1])){const u=o[1].split(this.formatSeparator).map(f=>f.trim());o[1]=u.shift(),a=u,c=!0}if(s=n(l.call(this,o[1].trim(),i),i),s&&o[0]===t&&typeof s!="string")return s;typeof s!="string"&&(s=ey(s)),s||(this.logger.warn(`missed to resolve ${o[1]} for nesting ${t}`),s=""),c&&(s=a.reduce((u,f)=>this.format(u,f,r.lng,{...r,interpolationkey:o[1].trim()}),s.trim())),t=t.replace(o[0],s),this.regexp.lastIndex=0}return t}}function WA(e){let t=e.toLowerCase().trim();const n={};if(e.indexOf("(")>-1){const r=e.split("(");t=r[0].toLowerCase().trim();const o=r[1].substring(0,r[1].length-1);t==="currency"&&o.indexOf(":")<0?n.currency||(n.currency=o.trim()):t==="relativetime"&&o.indexOf(":")<0?n.range||(n.range=o.trim()):o.split(";").forEach(i=>{if(!i)return;const[l,...a]=i.split(":"),c=a.join(":").trim().replace(/^'+|'+$/g,"");n[l.trim()]||(n[l.trim()]=c),c==="false"&&(n[l.trim()]=!1),c==="true"&&(n[l.trim()]=!0),isNaN(c)||(n[l.trim()]=parseInt(c,10))})}return{formatName:t,formatOptions:n}}function Po(e){const t={};return function(r,o,s){const i=o+JSON.stringify(s);let l=t[i];return l||(l=e(Ra(o),s),t[i]=l),l(r)}}class GA{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=Jt.create("formatter"),this.options=t,this.formats={number:Po((n,r)=>{const o=new Intl.NumberFormat(n,{...r});return s=>o.format(s)}),currency:Po((n,r)=>{const o=new Intl.NumberFormat(n,{...r,style:"currency"});return s=>o.format(s)}),datetime:Po((n,r)=>{const o=new Intl.DateTimeFormat(n,{...r});return s=>o.format(s)}),relativetime:Po((n,r)=>{const o=new Intl.RelativeTimeFormat(n,{...r});return s=>o.format(s,r.range||"day")}),list:Po((n,r)=>{const o=new Intl.ListFormat(n,{...r});return s=>o.format(s)})},this.init(t)}init(t){const r=(arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}}).interpolation;this.formatSeparator=r.formatSeparator?r.formatSeparator:r.formatSeparator||","}add(t,n){this.formats[t.toLowerCase().trim()]=n}addCached(t,n){this.formats[t.toLowerCase().trim()]=Po(n)}format(t,n,r){let o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return n.split(this.formatSeparator).reduce((l,a)=>{const{formatName:c,formatOptions:u}=WA(a);if(this.formats[c]){let f=l;try{const p=o&&o.formatParams&&o.formatParams[o.interpolationkey]||{},h=p.locale||p.lng||o.locale||o.lng||r;f=this.formats[c](l,h,{...u,...o,...p})}catch(p){this.logger.warn(p)}return f}else this.logger.warn(`there was no format function for ${c}`);return l},t)}}function YA(e,t){e.pending[t]!==void 0&&(delete e.pending[t],e.pendingCount--)}class KA extends _a{constructor(t,n,r){let o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};super(),this.backend=t,this.store=n,this.services=r,this.languageUtils=r.languageUtils,this.options=o,this.logger=Jt.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=o.maxParallelReads||10,this.readingCalls=0,this.maxRetries=o.maxRetries>=0?o.maxRetries:5,this.retryTimeout=o.retryTimeout>=1?o.retryTimeout:350,this.state={},this.queue=[],this.backend&&this.backend.init&&this.backend.init(r,o.backend,o)}queueLoad(t,n,r,o){const s={},i={},l={},a={};return t.forEach(c=>{let u=!0;n.forEach(f=>{const p=`${c}|${f}`;!r.reload&&this.store.hasResourceBundle(c,f)?this.state[p]=2:this.state[p]<0||(this.state[p]===1?i[p]===void 0&&(i[p]=!0):(this.state[p]=1,u=!1,i[p]===void 0&&(i[p]=!0),s[p]===void 0&&(s[p]=!0),a[f]===void 0&&(a[f]=!0)))}),u||(l[c]=!0)}),(Object.keys(s).length||Object.keys(i).length)&&this.queue.push({pending:i,pendingCount:Object.keys(i).length,loaded:{},errors:[],callback:o}),{toLoad:Object.keys(s),pending:Object.keys(i),toLoadLanguages:Object.keys(l),toLoadNamespaces:Object.keys(a)}}loaded(t,n,r){const o=t.split("|"),s=o[0],i=o[1];n&&this.emit("failedLoading",s,i,n),r&&this.store.addResourceBundle(s,i,r),this.state[t]=n?-1:2;const l={};this.queue.forEach(a=>{bA(a.loaded,[s],i),YA(a,t),n&&a.errors.push(n),a.pendingCount===0&&!a.done&&(Object.keys(a.loaded).forEach(c=>{l[c]||(l[c]={});const u=a.loaded[c];u.length&&u.forEach(f=>{l[c][f]===void 0&&(l[c][f]=!0)})}),a.done=!0,a.errors.length?a.callback(a.errors):a.callback())}),this.emit("loaded",l),this.queue=this.queue.filter(a=>!a.done)}read(t,n,r){let o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:this.retryTimeout,i=arguments.length>5?arguments[5]:void 0;if(!t.length)return i(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:t,ns:n,fcName:r,tried:o,wait:s,callback:i});return}this.readingCalls++;const l=(c,u)=>{if(this.readingCalls--,this.waitingReads.length>0){const f=this.waitingReads.shift();this.read(f.lng,f.ns,f.fcName,f.tried,f.wait,f.callback)}if(c&&u&&o<this.maxRetries){setTimeout(()=>{this.read.call(this,t,n,r,o+1,s*2,i)},s);return}i(c,u)},a=this.backend[r].bind(this.backend);if(a.length===2){try{const c=a(t,n);c&&typeof c.then=="function"?c.then(u=>l(null,u)).catch(l):l(null,c)}catch(c){l(c)}return}return a(t,n,l)}prepareLoading(t,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},o=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."),o&&o();typeof t=="string"&&(t=this.languageUtils.toResolveHierarchy(t)),typeof n=="string"&&(n=[n]);const s=this.queueLoad(t,n,r,o);if(!s.toLoad.length)return s.pending.length||o(),null;s.toLoad.forEach(i=>{this.loadOne(i)})}load(t,n,r){this.prepareLoading(t,n,{},r)}reload(t,n,r){this.prepareLoading(t,n,{reload:!0},r)}loadOne(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";const r=t.split("|"),o=r[0],s=r[1];this.read(o,s,"read",void 0,void 0,(i,l)=>{i&&this.logger.warn(`${n}loading namespace ${s} for language ${o} failed`,i),!i&&l&&this.logger.log(`${n}loaded namespace ${s} for language ${o}`,l),this.loaded(t,i,l)})}saveMissing(t,n,r,o,s){let i=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{},l=arguments.length>6&&arguments[6]!==void 0?arguments[6]:()=>{};if(this.services.utils&&this.services.utils.hasLoadedNamespace&&!this.services.utils.hasLoadedNamespace(n)){this.logger.warn(`did not save key "${r}" as the namespace "${n}" 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(!(r==null||r==="")){if(this.backend&&this.backend.create){const a={...i,isUpdate:s},c=this.backend.create.bind(this.backend);if(c.length<6)try{let u;c.length===5?u=c(t,n,r,o,a):u=c(t,n,r,o),u&&typeof u.then=="function"?u.then(f=>l(null,f)).catch(l):l(null,u)}catch(u){l(u)}else c(t,n,r,o,l,a)}!t||!t[0]||this.store.addResource(t[0],n,r,o)}}}function cy(){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 n={};if(typeof t[1]=="object"&&(n=t[1]),typeof t[1]=="string"&&(n.defaultValue=t[1]),typeof t[2]=="string"&&(n.tDescription=t[2]),typeof t[2]=="object"||typeof t[3]=="object"){const r=t[3]||t[2];Object.keys(r).forEach(o=>{n[o]=r[o]})}return n},interpolation:{escapeValue:!0,format:(e,t,n,r)=>e,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0}}}function uy(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 wa(){}function XA(e){Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(n=>{typeof e[n]=="function"&&(e[n]=e[n].bind(e))})}class ci extends _a{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;if(super(),this.options=uy(t),this.services={},this.logger=Jt,this.modules={external:[]},XA(this),n&&!this.isInitialized&&!t.isClone){if(!this.options.initImmediate)return this.init(t,n),this;setTimeout(()=>{this.init(t,n)},0)}}init(){var t=this;let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;typeof n=="function"&&(r=n,n={}),!n.defaultNS&&n.defaultNS!==!1&&n.ns&&(typeof n.ns=="string"?n.defaultNS=n.ns:n.ns.indexOf("translation")<0&&(n.defaultNS=n.ns[0]));const o=cy();this.options={...o,...this.options,...uy(n)},this.options.compatibilityAPI!=="v1"&&(this.options.interpolation={...o.interpolation,...this.options.interpolation}),n.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=n.keySeparator),n.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=n.nsSeparator);function s(u){return u?typeof u=="function"?new u:u:null}if(!this.options.isClone){this.modules.logger?Jt.init(s(this.modules.logger),this.options):Jt.init(null,this.options);let u;this.modules.formatter?u=this.modules.formatter:typeof Intl<"u"&&(u=GA);const f=new iy(this.options);this.store=new ry(this.options.resources,this.options);const p=this.services;p.logger=Jt,p.resourceStore=this.store,p.languageUtils=f,p.pluralResolver=new BA(f,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),u&&(!this.options.interpolation.format||this.options.interpolation.format===o.interpolation.format)&&(p.formatter=s(u),p.formatter.init(p,this.options),this.options.interpolation.format=p.formatter.format.bind(p.formatter)),p.interpolator=new zA(this.options),p.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},p.backendConnector=new KA(s(this.modules.backend),p.resourceStore,p,this.options),p.backendConnector.on("*",function(h){for(var E=arguments.length,y=new Array(E>1?E-1:0),v=1;v<E;v++)y[v-1]=arguments[v];t.emit(h,...y)}),this.modules.languageDetector&&(p.languageDetector=s(this.modules.languageDetector),p.languageDetector.init&&p.languageDetector.init(p,this.options.detection,this.options)),this.modules.i18nFormat&&(p.i18nFormat=s(this.modules.i18nFormat),p.i18nFormat.init&&p.i18nFormat.init(this)),this.translator=new Na(this.services,this.options),this.translator.on("*",function(h){for(var E=arguments.length,y=new Array(E>1?E-1:0),v=1;v<E;v++)y[v-1]=arguments[v];t.emit(h,...y)}),this.modules.external.forEach(h=>{h.init&&h.init(this)})}if(this.format=this.options.interpolation.format,r||(r=wa),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const u=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);u.length>0&&u[0]!=="dev"&&(this.options.lng=u[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(u=>{this[u]=function(){return t.store[u](...arguments)}}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(u=>{this[u]=function(){return t.store[u](...arguments),t}});const a=ai(),c=()=>{const u=(f,p)=>{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),a.resolve(p),r(f,p)};if(this.languages&&this.options.compatibilityAPI!=="v1"&&!this.isInitialized)return u(null,this.t.bind(this));this.changeLanguage(this.options.lng,u)};return this.options.resources||!this.options.initImmediate?c():setTimeout(c,0),a}loadResources(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:wa;const o=typeof t=="string"?t:this.language;if(typeof t=="function"&&(r=t),!this.options.resources||this.options.partialBundledLanguages){if(o&&o.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return r();const s=[],i=l=>{if(!l||l==="cimode")return;this.services.languageUtils.toResolveHierarchy(l).forEach(c=>{c!=="cimode"&&s.indexOf(c)<0&&s.push(c)})};o?i(o):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(a=>i(a)),this.options.preload&&this.options.preload.forEach(l=>i(l)),this.services.backendConnector.load(s,this.options.ns,l=>{!l&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),r(l)})}else r(null)}reloadResources(t,n,r){const o=ai();return t||(t=this.languages),n||(n=this.options.ns),r||(r=wa),this.services.backendConnector.reload(t,n,s=>{o.resolve(),r(s)}),o}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"&&oy.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 n=0;n<this.languages.length;n++){const r=this.languages[n];if(!(["cimode","dev"].indexOf(r)>-1)&&this.store.hasLanguageSomeTranslations(r)){this.resolvedLanguage=r;break}}}changeLanguage(t,n){var r=this;this.isLanguageChangingTo=t;const o=ai();this.emit("languageChanging",t);const s=a=>{this.language=a,this.languages=this.services.languageUtils.toResolveHierarchy(a),this.resolvedLanguage=void 0,this.setResolvedLanguage(a)},i=(a,c)=>{c?(s(c),this.translator.changeLanguage(c),this.isLanguageChangingTo=void 0,this.emit("languageChanged",c),this.logger.log("languageChanged",c)):this.isLanguageChangingTo=void 0,o.resolve(function(){return r.t(...arguments)}),n&&n(a,function(){return r.t(...arguments)})},l=a=>{!t&&!a&&this.services.languageDetector&&(a=[]);const c=typeof a=="string"?a:this.services.languageUtils.getBestMatchFromCodes(a);c&&(this.language||s(c),this.translator.language||this.translator.changeLanguage(c),this.services.languageDetector&&this.services.languageDetector.cacheUserLanguage&&this.services.languageDetector.cacheUserLanguage(c)),this.loadResources(c,u=>{i(u,c)})};return!t&&this.services.languageDetector&&!this.services.languageDetector.async?l(this.services.languageDetector.detect()):!t&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(l):this.services.languageDetector.detect(l):l(t),o}getFixedT(t,n,r){var o=this;const s=function(i,l){let a;if(typeof l!="object"){for(var c=arguments.length,u=new Array(c>2?c-2:0),f=2;f<c;f++)u[f-2]=arguments[f];a=o.options.overloadTranslationOptionHandler([i,l].concat(u))}else a={...l};a.lng=a.lng||s.lng,a.lngs=a.lngs||s.lngs,a.ns=a.ns||s.ns,a.keyPrefix=a.keyPrefix||r||s.keyPrefix;const p=o.options.keySeparator||".";let h;return a.keyPrefix&&Array.isArray(i)?h=i.map(E=>`${a.keyPrefix}${p}${E}`):h=a.keyPrefix?`${a.keyPrefix}${p}${i}`:i,o.t(h,a)};return typeof t=="string"?s.lng=t:s.lngs=t,s.ns=n,s.keyPrefix=r,s}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 n=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 r=n.lng||this.resolvedLanguage||this.languages[0],o=this.options?this.options.fallbackLng:!1,s=this.languages[this.languages.length-1];if(r.toLowerCase()==="cimode")return!0;const i=(l,a)=>{const c=this.services.backendConnector.state[`${l}|${a}`];return c===-1||c===2};if(n.precheck){const l=n.precheck(this,i);if(l!==void 0)return l}return!!(this.hasResourceBundle(r,t)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||i(r,t)&&(!o||i(s,t)))}loadNamespaces(t,n){const r=ai();return this.options.ns?(typeof t=="string"&&(t=[t]),t.forEach(o=>{this.options.ns.indexOf(o)<0&&this.options.ns.push(o)}),this.loadResources(o=>{r.resolve(),n&&n(o)}),r):(n&&n(),Promise.resolve())}loadLanguages(t,n){const r=ai();typeof t=="string"&&(t=[t]);const o=this.options.preload||[],s=t.filter(i=>o.indexOf(i)<0);return s.length?(this.options.preload=o.concat(s),this.loadResources(i=>{r.resolve(),n&&n(i)}),r):(n&&n(),Promise.resolve())}dir(t){if(t||(t=this.resolvedLanguage||(this.languages&&this.languages.length>0?this.languages[0]:this.language)),!t)return"rtl";const n=["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"],r=this.services&&this.services.languageUtils||new iy(cy());return n.indexOf(r.getLanguagePartFromCode(t))>-1||t.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;return new ci(t,n)}cloneInstance(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:wa;const r=t.forkResourceStore;r&&delete t.forkResourceStore;const o={...this.options,...t,isClone:!0},s=new ci(o);return(t.debug!==void 0||t.prefix!==void 0)&&(s.logger=s.logger.clone(t)),["store","services","language"].forEach(l=>{s[l]=this[l]}),s.services={...this.services},s.services.utils={hasLoadedNamespace:s.hasLoadedNamespace.bind(s)},r&&(s.store=new ry(this.store.data,o),s.services.resourceStore=s.store),s.translator=new Na(s.services,o),s.translator.on("*",function(l){for(var a=arguments.length,c=new Array(a>1?a-1:0),u=1;u<a;u++)c[u-1]=arguments[u];s.emit(l,...c)}),s.init(o,n),s.translator.options=o,s.translator.backendConnector.services.utils={hasLoadedNamespace:s.hasLoadedNamespace.bind(s)},s}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const Ve=ci.createInstance();Ve.createInstance=ci.createInstance,Ve.createInstance,Ve.dir,Ve.init,Ve.loadResources,Ve.reloadResources,Ve.use,Ve.changeLanguage,Ve.getFixedT;const A=Ve.t;Ve.exists,Ve.setDefaultNamespace,Ve.hasLoadedNamespace,Ve.loadNamespaces,Ve.loadLanguages;function QA(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ui(e){"@babel/helpers - typeof";return ui=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},ui(e)}function qA(e,t){if(ui(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(ui(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function JA(e){var t=qA(e,"string");return ui(t)=="symbol"?t:String(t)}function dy(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,JA(r.key),r)}}function ZA(e,t,n){return t&&dy(e.prototype,t),n&&dy(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}var fy=[],eI=fy.forEach,tI=fy.slice;function nI(e){return eI.call(tI.call(arguments,1),function(t){if(t)for(var n in t)e[n]===void 0&&(e[n]=t[n])}),e}var py=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,rI=function(t,n,r){var o=r||{};o.path=o.path||"/";var s=encodeURIComponent(n),i="".concat(t,"=").concat(s);if(o.maxAge>0){var l=o.maxAge-0;if(Number.isNaN(l))throw new Error("maxAge should be a Number");i+="; Max-Age=".concat(Math.floor(l))}if(o.domain){if(!py.test(o.domain))throw new TypeError("option domain is invalid");i+="; Domain=".concat(o.domain)}if(o.path){if(!py.test(o.path))throw new TypeError("option path is invalid");i+="; Path=".concat(o.path)}if(o.expires){if(typeof o.expires.toUTCString!="function")throw new TypeError("option expires is invalid");i+="; Expires=".concat(o.expires.toUTCString())}if(o.httpOnly&&(i+="; HttpOnly"),o.secure&&(i+="; Secure"),o.sameSite){var a=typeof o.sameSite=="string"?o.sameSite.toLowerCase():o.sameSite;switch(a){case!0:i+="; SameSite=Strict";break;case"lax":i+="; SameSite=Lax";break;case"strict":i+="; SameSite=Strict";break;case"none":i+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}}return i},hy={create:function(t,n,r,o){var s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{path:"/",sameSite:"strict"};r&&(s.expires=new Date,s.expires.setTime(s.expires.getTime()+r*60*1e3)),o&&(s.domain=o),document.cookie=rI(t,encodeURIComponent(n),s)},read:function(t){for(var n="".concat(t,"="),r=document.cookie.split(";"),o=0;o<r.length;o++){for(var s=r[o];s.charAt(0)===" ";)s=s.substring(1,s.length);if(s.indexOf(n)===0)return s.substring(n.length,s.length)}return null},remove:function(t){this.create(t,"",-1)}},oI={name:"cookie",lookup:function(t){var n;if(t.lookupCookie&&typeof document<"u"){var r=hy.read(t.lookupCookie);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupCookie&&typeof document<"u"&&hy.create(n.lookupCookie,t,n.cookieMinutes,n.cookieDomain,n.cookieOptions)}},sI={name:"querystring",lookup:function(t){var n;if(typeof window<"u"){var r=window.location.search;!window.location.search&&window.location.hash&&window.location.hash.indexOf("?")>-1&&(r=window.location.hash.substring(window.location.hash.indexOf("?")));for(var o=r.substring(1),s=o.split("&"),i=0;i<s.length;i++){var l=s[i].indexOf("=");if(l>0){var a=s[i].substring(0,l);a===t.lookupQuerystring&&(n=s[i].substring(l+1))}}}return n}},di=null,my=function(){if(di!==null)return di;try{di=window!=="undefined"&&window.localStorage!==null;var t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{di=!1}return di},iI={name:"localStorage",lookup:function(t){var n;if(t.lookupLocalStorage&&my()){var r=window.localStorage.getItem(t.lookupLocalStorage);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupLocalStorage&&my()&&window.localStorage.setItem(n.lookupLocalStorage,t)}},fi=null,gy=function(){if(fi!==null)return fi;try{fi=window!=="undefined"&&window.sessionStorage!==null;var t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{fi=!1}return fi},lI={name:"sessionStorage",lookup:function(t){var n;if(t.lookupSessionStorage&&gy()){var r=window.sessionStorage.getItem(t.lookupSessionStorage);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupSessionStorage&&gy()&&window.sessionStorage.setItem(n.lookupSessionStorage,t)}},aI={name:"navigator",lookup:function(t){var n=[];if(typeof navigator<"u"){if(navigator.languages)for(var r=0;r<navigator.languages.length;r++)n.push(navigator.languages[r]);navigator.userLanguage&&n.push(navigator.userLanguage),navigator.language&&n.push(navigator.language)}return n.length>0?n:void 0}},cI={name:"htmlTag",lookup:function(t){var n,r=t.htmlTag||(typeof document<"u"?document.documentElement:null);return r&&typeof r.getAttribute=="function"&&(n=r.getAttribute("lang")),n}},uI={name:"path",lookup:function(t){var n;if(typeof window<"u"){var r=window.location.pathname.match(/\/([a-zA-Z-]*)/g);if(r instanceof Array)if(typeof t.lookupFromPathIndex=="number"){if(typeof r[t.lookupFromPathIndex]!="string")return;n=r[t.lookupFromPathIndex].replace("/","")}else n=r[0].replace("/","")}return n}},dI={name:"subdomain",lookup:function(t){var n=typeof t.lookupFromSubdomainIndex=="number"?t.lookupFromSubdomainIndex+1:1,r=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(r)return r[n]}};function fI(){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 Ey=function(){function e(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};QA(this,e),this.type="languageDetector",this.detectors={},this.init(t,n)}return ZA(e,[{key:"init",value:function(n){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.services=n||{languageUtils:{}},this.options=nI(r,this.options||{},fI()),typeof this.options.convertDetectedLanguage=="string"&&this.options.convertDetectedLanguage.indexOf("15897")>-1&&(this.options.convertDetectedLanguage=function(s){return s.replace("-","_")}),this.options.lookupFromUrlIndex&&(this.options.lookupFromPathIndex=this.options.lookupFromUrlIndex),this.i18nOptions=o,this.addDetector(oI),this.addDetector(sI),this.addDetector(iI),this.addDetector(lI),this.addDetector(aI),this.addDetector(cI),this.addDetector(uI),this.addDetector(dI)}},{key:"addDetector",value:function(n){this.detectors[n.name]=n}},{key:"detect",value:function(n){var r=this;n||(n=this.options.order);var o=[];return n.forEach(function(s){if(r.detectors[s]){var i=r.detectors[s].lookup(r.options);i&&typeof i=="string"&&(i=[i]),i&&(o=o.concat(i))}}),o=o.map(function(s){return r.options.convertDetectedLanguage(s)}),this.services.languageUtils.getBestMatchFromCodes?o:o.length>0?o[0]:null}},{key:"cacheUserLanguage",value:function(n,r){var o=this;r||(r=this.options.caches),r&&(this.options.excludeCacheFor&&this.options.excludeCacheFor.indexOf(n)>-1||r.forEach(function(s){o.detectors[s]&&o.detectors[s].cacheUserLanguage(n,o.options)}))}}]),e}();Ey.type="languageDetector";function cf(){return cf=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},cf.apply(this,arguments)}var pI={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};const hI=Ba(pI);var mI=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;function yy(e){var t={type:"tag",name:"",voidElement:!1,attrs:{},children:[]},n=e.match(/<\/?([^\s]+?)[/\s>]/);if(n&&(t.name=n[1],(hI[n[1]]||e.charAt(e.length-2)==="/")&&(t.voidElement=!0),t.name.startsWith("!--"))){var r=e.indexOf("-->");return{type:"comment",comment:r!==-1?e.slice(4,r):""}}for(var o=new RegExp(mI),s=null;(s=o.exec(e))!==null;)if(s[0].trim())if(s[1]){var i=s[1].trim(),l=[i,""];i.indexOf("=")>-1&&(l=i.split("=")),t.attrs[l[0]]=l[1],o.lastIndex--}else s[2]&&(t.attrs[s[2]]=s[3].trim().substring(1,s[3].length-1));return t}var gI=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,EI=/^\s*$/,yI=Object.create(null);function vy(e,t){switch(t.type){case"text":return e+t.content;case"tag":return e+="<"+t.name+(t.attrs?function(n){var r=[];for(var o in n)r.push(o+'="'+n[o]+'"');return r.length?" "+r.join(" "):""}(t.attrs):"")+(t.voidElement?"/>":">"),t.voidElement?e:e+t.children.reduce(vy,"")+"</"+t.name+">";case"comment":return e+"<!--"+t.comment+"-->"}}var vI={parse:function(e,t){t||(t={}),t.components||(t.components=yI);var n,r=[],o=[],s=-1,i=!1;if(e.indexOf("<")!==0){var l=e.indexOf("<");r.push({type:"text",content:l===-1?e:e.substring(0,l)})}return e.replace(gI,function(a,c){if(i){if(a!=="</"+n.name+">")return;i=!1}var u,f=a.charAt(1)!=="/",p=a.startsWith("<!--"),h=c+a.length,E=e.charAt(h);if(p){var y=yy(a);return s<0?(r.push(y),r):((u=o[s]).children.push(y),r)}if(f&&(s++,(n=yy(a)).type==="tag"&&t.components[n.name]&&(n.type="component",i=!0),n.voidElement||i||!E||E==="<"||n.children.push({type:"text",content:e.slice(h,e.indexOf("<",h))}),s===0&&r.push(n),(u=o[s-1])&&u.children.push(n),o[s]=n),(!f||n.voidElement)&&(s>-1&&(n.voidElement||n.name===a.slice(2,-1))&&(s--,n=s===-1?r:o[s]),!i&&E!=="<"&&E)){u=s===-1?r:o[s].children;var v=e.indexOf("<",h),m=e.slice(h,v===-1?void 0:v);EI.test(m)&&(m=" "),(v>-1&&s+u.length>=0||m!==" ")&&u.push({type:"text",content:m})}}),r},stringify:function(e){return e.reduce(function(t,n){return t+vy("",n)},"")}};function Oa(){if(console&&console.warn){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];typeof t[0]=="string"&&(t[0]=`react-i18next:: ${t[0]}`),console.warn(...t)}}const _y={};function _I(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];typeof t[0]=="string"&&_y[t[0]]||(typeof t[0]=="string"&&(_y[t[0]]=new Date),Oa(...t))}const SI=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,xI={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},RI=e=>xI[e];let uf={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:e=>e.replace(SI,RI)};function NI(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};uf={...uf,...e}}function wI(){return uf}let Sy;function OI(e){Sy=e}function xy(){return Sy}function df(e,t){if(!e)return!1;const n=e.props?e.props.children:e.children;return t?n.length>0:!!n}function ff(e){if(!e)return[];const t=e.props?e.props.children:e.children;return e.props&&e.props.i18nIsDynamicList?Mo(t):t}function TI(e){return Object.prototype.toString.call(e)!=="[object Array]"?!1:e.every(t=>O.isValidElement(t))}function Mo(e){return Array.isArray(e)?e:[e]}function AI(e,t){const n={...t};return n.props=Object.assign(e.props,t.props),n}function Ry(e,t){if(!e)return"";let n="";const r=Mo(e),o=t.transSupportBasicHtmlNodes&&t.transKeepBasicHtmlNodesFor?t.transKeepBasicHtmlNodesFor:[];return r.forEach((s,i)=>{if(typeof s=="string")n+=`${s}`;else if(O.isValidElement(s)){const l=Object.keys(s.props).length,a=o.indexOf(s.type)>-1,c=s.props.children;if(!c&&a&&l===0)n+=`<${s.type}/>`;else if(!c&&(!a||l!==0))n+=`<${i}></${i}>`;else if(s.props.i18nIsDynamicList)n+=`<${i}></${i}>`;else if(a&&l===1&&typeof c=="string")n+=`<${s.type}>${c}</${s.type}>`;else{const u=Ry(c,t);n+=`<${i}>${u}</${i}>`}}else if(s===null)Oa("Trans: the passed in value is invalid - seems you passed in a null child.");else if(typeof s=="object"){const{format:l,...a}=s,c=Object.keys(a);if(c.length===1){const u=l?`${c[0]}, ${l}`:c[0];n+=`{{${u}}}`}else Oa("react-i18next: the passed in object contained more than one variable - the object should look like {{ value, format }} where format is optional.",s)}else Oa("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}}.",s)}),n}function II(e,t,n,r,o,s){if(t==="")return[];const i=r.transKeepBasicHtmlNodesFor||[],l=t&&new RegExp(i.map(v=>`<${v}`).join("|")).test(t);if(!e&&!l&&!s)return[t];const a={};function c(v){Mo(v).forEach(g=>{typeof g!="string"&&(df(g)?c(ff(g)):typeof g=="object"&&!O.isValidElement(g)&&Object.assign(a,g))})}c(e);const u=vI.parse(`<0>${t}</0>`),f={...a,...o};function p(v,m,g){const S=ff(v),_=E(S,m.children,g);return TI(S)&&_.length===0||v.props&&v.props.i18nIsDynamicList?S:_}function h(v,m,g,S,_){v.dummy?(v.children=m,g.push(O.cloneElement(v,{key:S},_?void 0:m))):g.push(...O.Children.map([v],x=>{const R={...x.props};return delete R.i18nIsDynamicList,H.createElement(x.type,cf({},R,{key:S,ref:x.ref},_?{}:{children:m}))}))}function E(v,m,g){const S=Mo(v);return Mo(m).reduce((x,R,T)=>{const L=R.children&&R.children[0]&&R.children[0].content&&n.services.interpolator.interpolate(R.children[0].content,f,n.language);if(R.type==="tag"){let P=S[parseInt(R.name,10)];g.length===1&&!P&&(P=g[0][R.name]),P||(P={});const I=Object.keys(R.attrs).length!==0?AI({props:R.attrs},P):P,j=O.isValidElement(I),V=j&&df(R,!0)&&!R.voidElement,M=l&&typeof I=="object"&&I.dummy&&!j,w=typeof e=="object"&&e!==null&&Object.hasOwnProperty.call(e,R.name);if(typeof I=="string"){const b=n.services.interpolator.interpolate(I,f,n.language);x.push(b)}else if(df(I)||V){const b=p(I,R,g);h(I,b,x,T)}else if(M){const b=E(S,R.children,g);h(I,b,x,T)}else if(Number.isNaN(parseFloat(R.name)))if(w){const b=p(I,R,g);h(I,b,x,T,R.voidElement)}else if(r.transSupportBasicHtmlNodes&&i.indexOf(R.name)>-1)if(R.voidElement)x.push(O.createElement(R.name,{key:`${R.name}-${T}`}));else{const b=E(S,R.children,g);x.push(O.createElement(R.name,{key:`${R.name}-${T}`},b))}else if(R.voidElement)x.push(`<${R.name} />`);else{const b=E(S,R.children,g);x.push(`<${R.name}>${b}</${R.name}>`)}else if(typeof I=="object"&&!j){const b=R.children[0]?L:null;b&&x.push(b)}else h(I,L,x,T,R.children.length!==1||!L)}else if(R.type==="text"){const P=r.transWrapTextNodes,I=s?r.unescape(n.services.interpolator.interpolate(R.content,f,n.language)):n.services.interpolator.interpolate(R.content,f,n.language);P?x.push(O.createElement(P,{key:`${R.name}-${T}`},I)):x.push(I)}return x},[])}const y=E([{dummy:!0,children:e||[]}],u,Mo(e||[]));return ff(y[0])}function CI(e){let{children:t,count:n,parent:r,i18nKey:o,context:s,tOptions:i={},values:l,defaults:a,components:c,ns:u,i18n:f,t:p,shouldUnescape:h,...E}=e;const y=f||xy();if(!y)return _I("You will need to pass in an i18next instance by using i18nextReactModule"),t;const v=p||y.t.bind(y)||(V=>V);s&&(i.context=s);const m={...wI(),...y.options&&y.options.react};let g=u||v.ns||y.options&&y.options.defaultNS;g=typeof g=="string"?[g]:g||["translation"];const S=Ry(t,m),_=a||S||m.transEmptyNodeValue||o,{hashTransKey:x}=m,R=o||(x?x(S||_):S||_);y.options&&y.options.interpolation&&y.options.interpolation.defaultVariables&&(l=l&&Object.keys(l).length>0?{...l,...y.options.interpolation.defaultVariables}:{...y.options.interpolation.defaultVariables});const T=l?i.interpolation:{interpolation:{...i.interpolation,prefix:"#$?",suffix:"?$#"}},L={...i,count:n,...l,...T,defaultValue:_,ns:g},P=R?v(R,L):_;c&&Object.keys(c).forEach(V=>{const M=c[V];if(typeof M.type=="function"||!M.props||!M.props.children||P.indexOf(`${V}/>`)<0&&P.indexOf(`${V} />`)<0)return;function w(){return H.createElement(H.Fragment,null,M)}c[V]=H.createElement(w,null)});const I=II(c||t,P,y,m,L,h),j=r!==void 0?r:m.defaultTransParent;return j?O.createElement(j,E,I):I}const LI={type:"3rdParty",init(e){NI(e.options.react),OI(e)}},bI=O.createContext();function DI(e){let{children:t,count:n,parent:r,i18nKey:o,context:s,tOptions:i={},values:l,defaults:a,components:c,ns:u,i18n:f,t:p,shouldUnescape:h,...E}=e;const{i18n:y,defaultNS:v}=O.useContext(bI)||{},m=f||y||xy(),g=p||m&&m.t.bind(m);return CI({children:t,count:n,parent:r,i18nKey:o,context:s,tOptions:i,values:l,defaults:a,components:c,ns:u||g&&g.ns||v||m&&m.options&&m.options.defaultNS,i18n:m,t:p,shouldUnescape:h,...E})}var kI={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"]},PI={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"]},MI={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"]},UI={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"]},FI=UI,jI={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"]},VI={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"]},$I={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"]},HI={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"]},BI={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"]},zI={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"]},WI={prefix:"fas",iconName:"circle-small",icon:[320,512,[],"e122","M0 256a160 160 0 1 1 320 0A160 160 0 1 1 0 256z"]},GI={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"]},YI={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"]},KI={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"]},XI={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"]},QI={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"]},qI={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 JI={"arrow-left":zI,"arrow-right":HI,"arrow-turn-down-right":$I,"arrows-rotate":VI,bars:PI,bolt:YI,"circle-check":jI,"circle-exclamation":MI,"circle-info":GI,"circle-question":BI,"circle-small":WI,"circle-xmark":qI,"clock-rotate-left":XI,"dot-circle":FI,"trash-can":kI,"triangle-exclamation":QI,xmark:KI},re=O.forwardRef(function({className:t="",size:n="",tag:r},o){const s=JI[r];return s?d.jsx("svg",{"aria-hidden":"true","data-prefix":s.prefix,"data-icon":r,className:`svg-inline--fa fa-${r} ${n?`fa-${n}`:""} ${t}`,focusable:"false",ref:o,role:"img",viewBox:`0 0 ${s.icon[0]} ${s.icon[1]}`,xmlns:"http://www.w3.org/2000/svg",children:d.jsx("path",{d:s.icon[4],fill:"currentColor"})}):(Ne().debug(`Unknown icon: ${r}`),null)}),Uo=({className:e="",confirm:t=!0,handleDelete:n,label:r,scale:o=1,show:s=!0,showLabel:i=!1,size:l})=>{const[a,c]=O.useState(!1),[u,f]=O.useState(o);o!==u&&(c(!1),f(o));const p=E=>{E.preventDefault(),c(y=>!y)},h=E=>{E.preventDefault(),n(E)};return d.jsx(Zn,{enable:t,open:a,onOpenChange:c,placement:"top",scale:o,trigger:d.jsxs("button",{className:`${s?"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:E=>p(E),type:"button",children:[d.jsx(re,{tag:"trash-can",size:l})," ",d.jsx("span",{className:`${i?"whitespace-nowrap text-foreground/40 underline hover:text-negative":"sr-only"}`,children:r})]}),children:d.jsxs("div",{className:"text-xs font-semibold",children:[d.jsx("p",{className:"w-full pb-2 text-center",children:A(N.ARE_YOU_SURE)}),d.jsxs("div",{className:"align-center flex justify-between gap-2",children:[d.jsx("button",{className:"rounded bg-secondary py-1 px-2",onClick:E=>p(E),children:A(N.CANCEL)}),d.jsx("button",{className:"rounded bg-negative py-1 px-2",onClick:E=>h(E),children:A(N.DELETE)})]})]})})},ZI=e=>{const t=Q(n=>n.viewport.zoom);return d.jsx(Uo,{scale:t,...e})},eC=Ne(),tC=100,nC=100,Ny=({children:e,className:t="",onClickListItem:n})=>{const r=Q(c=>c.nodes),o=Q(c=>c.reactFlowInstance),s=Q(c=>c.validationWarnings),{setSelectedNodes:i}=Te();if(s.size===0)return null;const l=Array.from(s.values());l.sort((c,u)=>A(c.nodeTitle).toLowerCase().localeCompare(A(u.nodeTitle).toLowerCase()));const a=c=>{var h,E;const u=r.find(y=>y.id===c);if(!u){eC.error(`Node with id ${c} not found`);return}const f=((h=o==null?void 0:o.getNode(c))==null?void 0:h.height)??nC,p=((E=o==null?void 0:o.getNode(c))==null?void 0:E.width)??H0;o==null||o.fitBounds({height:f+tC,width:p,x:u.position.x,y:u.position.y},{duration:nf}),setTimeout(()=>i([u.id]),nf),n==null||n()};return d.jsxs("div",{className:`hidden max-h-60 flex-col sm:flex ${t}`,children:[e,d.jsxs("p",{className:"mb-2 text-xs",children:[A(N.NUMBER_OF_VALIDATION_WARNINGS,{count:l.length}),":"]}),d.jsx("div",{className:"flex-auto overflow-y-auto",children:d.jsx("ol",{className:"list-inside",children:l.map(c=>d.jsxs("li",{className:"mb-2 text-xs",children:[d.jsx("button",{className:"text-warning underline",onClick:()=>a(c.nodeId),children:A(c.nodeTitle)}),d.jsxs("ol",{className:"my-1 ml-4 flex list-inside flex-col gap-y-1",children:[!c.connected&&d.jsx("li",{children:A(N.NOT_CONNECTED_TO_FLOW)}),!c.valid&&d.jsx("li",{children:A(N.INVALID_SETTINGS)})]})]},c.id))})})]})},pi=e=>{const{className:t="",direction:n="from",valid:r=!0,...o}=e,s=n==="from";return d.jsxs("div",{className:`relative ${t} ${r?"":"invalid"}`,children:[d.jsx("input",{className:`w-full !pl-5 ${r?"":"invalid"}`,placeholder:A(s?N.FROM:N.TO),...o}),d.jsx(re,{className:"absolute left-[.25rem] top-[.5rem] text-foreground/40",tag:s?"arrow-left":"arrow-right"})]})},rC=({children:e})=>d.jsx("span",{className:"whitespace-wrap inline-block",children:d.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})}),Lt=({children:e})=>d.jsxs("section",{className:"flex gap-2 overflow-hidden px-4 pb-3 text-xs leading-5",children:[d.jsx("div",{className:"shrink-0 pl-1 text-secondary",children:d.jsx(re,{size:"lg",tag:"arrow-turn-down-right"})}),d.jsx("div",{className:"w-full overflow-hidden",children:e})]}),oC=({connected:e=!1,deletable:t=!0,isRoot:n=!1,nodeId:r,nodeTitle:o,selected:s=!1})=>{const{removeNode:i}=Te(),l=Q(c=>c.isEdgeConnecting),a=(c=>c?"bg-positive/10 text-positive":e?"bg-focus/30 text-primary":"bg-foreground/10 text-foreground/50")(n);return d.jsxs("div",{className:"flex w-full items-center justify-start gap-x-2 p-4",children:[d.jsx("div",{className:`${a} flex h-5 w-5 shrink-0 items-center justify-center rounded-full`,children:d.jsx(re,{tag:"circle-small"})}),d.jsxs("div",{className:"flex-1",children:[d.jsx("h2",{className:"text-xs font-semibold",children:o}),!e&&d.jsxs("div",{className:"flex items-center justify-start text-tiny font-semibold leading-[14px] text-secondary",children:[d.jsx(re,{className:"px-1 text-warning",size:"lg",tag:"bolt"}),A(N.NOT_CONNECTED_TO_FLOW)]})]}),t&&!l&&d.jsx(ZI,{handleDelete:()=>i(r),label:A(N.REMOVE_NODE,{title:o}),show:s})]})},sC=({valid:e})=>e?null:d.jsx("div",{className:"m-4 mt-0 inline-block",children:d.jsxs("div",{className:"flex items-start justify-start gap-2 rounded bg-negative/10 px-2 py-1 text-xs text-negative",children:[d.jsx(Zn,{placement:"bottom",trigger:d.jsx("div",{role:"tooltip",tabIndex:0,children:d.jsx(re,{size:"lg",tag:"triangle-exclamation"})}),children:A(N.INFO_INVALID_SETTINGS)}),A(N.INVALID_SETTINGS)]})}),iC=({nodeId:e,valid:t})=>{const{deleteValidationWarning:n,getTargetEdges:r,partialUpdateValidationWarning:o}=Te(),[s,i]=O.useState(!1);return O.useEffect(()=>{let l;const a=()=>{n(e),typeof l=="function"&&l()},c=()=>{const u=Q.getState().nodes.find(f=>f.id===e);if(!u)a();else{const f=r(e).length>0;i(f),o(e,{connected:f,nodeId:e,nodeType:u.type,valid:t})}};return c(),l=Q.subscribe((u,f)=>{const p=u.nodes.length!==f.nodes.length,h=u.edges.length!==f.edges.length,E=u.isEdgeUpdateSuccessful!==f.isEdgeUpdateSuccessful;(h||p||E)&&c()}),()=>{a()}},[n,r,e,o,t]),{isConnectedToFlow:s}},lC=({id:e,isConnectable:t})=>{if(!e)throw new Error("TargetHandle: id is required");return d.jsx("div",{className:"absolute left-0 top-5 h-3 w-3 -translate-x-1/2",children:d.jsx(No,{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:q.Left,type:"target"})})},$e=({children:e,id:t,isConnectable:n=!0,isRoot:r=!1,nodeTitle:o,selected:s,deletable:i=!0,showValidation:l=!0,target:a=!0,valid:c=!0})=>{const{isConnectedToFlow:u}=iC({nodeId:t,valid:c});return d.jsx("section",{className:`${s?"!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:d.jsxs("div",{className:"group/node-wrapper relative rounded-xl bg-background",style:{width:H0},children:[a&&t&&d.jsx(lC,{id:t,isConnectable:n}),d.jsx(oC,{connected:!a||u,deletable:i,isRoot:r,nodeId:t,nodeTitle:o,selected:s}),l&&d.jsx(sC,{valid:c}),e]})})},aC=({children:e,handleClick:t,...n})=>{const r=o=>{(o.key==="Backspace"||o.key==="Delete")&&(o.stopPropagation(),t==null||t())};return d.jsx("li",{role:"presentation",children:d.jsxs("div",{className:"flex items-center gap-2 rounded-lg bg-primary/20 p-1 pl-2 text-xs font-medium text-foreground",role:"option","aria-selected":"true",tabIndex:0,children:[e,d.jsxs("button",{className:"px-1",onClick:t,onKeyDown:r,type:"button",...n,children:[d.jsx("span",{className:"sr-only",children:"Remove"}),d.jsx(re,{tag:"xmark",size:"xs"})]})]})})},wy=({data:e})=>{let t=e.selected&&e[e.selected].trim();return t&&e.selected==="url"&&(t=TA(t)||A(N.PLAY_AUDIO)),t?d.jsx(Lt,{children:d.jsx("div",{className:"max-w-max",children:e.selected==="url"?d.jsx("a",{className:"break-words text-primary underline line-clamp-2",href:e.url,target:"_blank",rel:"noopener noreferrer",children:t}):d.jsx("p",{className:"break-words line-clamp-2",children:t})})}):null},Oy=e=>{const{children:t,className:n="",disabled:r=!1,...o}=e;return d.jsxs("div",{className:`chevron-down relative mb-2 after:rotate-0 after:transition-transform focus-within:after:rotate-180
61
- ${r?"after:border-t-foreground/40":"after:border-t-foreground"}`,children:[d.jsx("select",{className:`pr-8 ${n}`,disabled:r,...o,children:t}),d.jsx("p",{className:"requirements w-full",role:"alert",children:A(N.ERROR_SELECTION_REQUIRED)})]})},Zt=e=>{const{label:t="",id:n="",...r}=e,o=O.useId(),s=n||o;return d.jsxs(d.Fragment,{children:[t&&d.jsx("label",{className:"block pb-1 font-medium",htmlFor:s,children:t}),d.jsx(Oy,{id:s,...r})]})},cC=({label:e,vars:t={}})=>d.jsx(DI,{components:{a:d.jsx("a",{className:"underline hover:text-background/80",href:t.linkTo||"#",target:"_blank",rel:"noopener noreferrer"}),code:d.jsx(rC,{}),p:d.jsx("p",{className:"mb-2"})},i18nKey:e}),uC={disabled:"border-disabled cursor-not-allowed",negative:"border-negative hover:bg-negative",positive:"border-positive hover:bg-positive"},Ht=({color:e="positive",enabled:t=!0,id:n,isConnectable:r})=>{if(!n)throw new Error("SourceHandle: id is required");const o=t?e:"disabled",s=Q(u=>u.updatingSourceHandleId),a=!Q(u=>u.edges.some(f=>f.sourceHandle===n))||s===n,c=a&&r&&t;return d.jsx("div",{className:`absolute right-0 top-1/2 h-3 w-3 -translate-y-1/2 translate-x-1/2 ${c?"":"nodrag cursor-not-allowed"}`,children:d.jsx(No,{className:`-right-[2px] h-full w-full border-2 bg-background transition-colors ${uC[o]??""}`,id:n,isConnectable:a&&r&&t,position:q.Right,type:"source"})})},Fo=({children:e})=>d.jsx("div",{className:"flex w-full flex-col items-start text-xs",children:e}),Bt=({color:e="positive",enabled:t=!0,id:n,isConnectable:r,optionSubtitle:o="",optionTitle:s})=>d.jsxs("div",{className:"relative w-full min-w-[104px] whitespace-nowrap border-t border-foreground/10 py-3",children:[d.jsx("div",{className:"flex flex-col items-start justify-center px-4",children:d.jsxs("div",{className:`${t?"":"text-disabled"} min-h-[1rem] w-full overflow-hidden`,children:[s,o?d.jsx("span",{className:"block text-xxs text-secondary",children:o}):null]})}),d.jsx(Ht,{color:e,enabled:t,id:n,isConnectable:r})]}),dC=({checked:e=!1,name:t,onClick:n,...r})=>d.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:n,role:"switch",type:"button",...r,children:[d.jsx("span",{className:"sr-only",children:A(e?N.ON:N.OFF)}),d.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`})]}),Ta=({checked:e,clickHandler:t,name:n,subtitle:r,title:o,...s})=>d.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[d.jsxs("div",{className:"flex flex-grow flex-col",children:[d.jsx("span",{className:"text-xs font-medium",children:o}),r&&d.jsx("span",{className:"text-xxs text-foreground/50",children:r})]}),d.jsx(dC,{checked:e,name:n,onClick:t,...s})]}),yn=({errorText:e,label:t,name:n,onChange:r,required:o,valid:s,value:i,...l})=>d.jsxs(d.Fragment,{children:[t!=null&&t.trim()?d.jsx("div",{className:"pb-1",children:t}):null,d.jsx("textarea",{"aria-invalid":s?void 0:"true",className:`peer min-h-[77px] w-full resize-y ${s?"":"invalid"}`,inputMode:"text",minLength:1,name:n,onChange:r,required:o,value:i,...l}),d.jsx("p",{className:"requirements",role:"alert",children:e})]});function Xn(e){return Ty(e)?(e.nodeName||"").toLowerCase():"#document"}function it(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function vn(e){var t;return(t=(Ty(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Ty(e){return e instanceof Node||e instanceof it(e).Node}function ge(e){return e instanceof Element||e instanceof it(e).Element}function vt(e){return e instanceof HTMLElement||e instanceof it(e).HTMLElement}function pf(e){return typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof it(e).ShadowRoot}function hi(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=_t(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!["inline","contents"].includes(o)}function fC(e){return["table","td","th"].includes(Xn(e))}function hf(e){const t=mf(),n=_t(e);return n.transform!=="none"||n.perspective!=="none"||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||["transform","perspective","filter"].some(r=>(n.willChange||"").includes(r))||["paint","layout","strict","content"].some(r=>(n.contain||"").includes(r))}function pC(e){let t=Rr(e);for(;vt(t)&&!jo(t);){if(hf(t))return t;t=Rr(t)}return null}function mf(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function jo(e){return["html","body","#document"].includes(Xn(e))}function _t(e){return it(e).getComputedStyle(e)}function Aa(e){return ge(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.pageXOffset,scrollTop:e.pageYOffset}}function Rr(e){if(Xn(e)==="html")return e;const t=e.assignedSlot||e.parentNode||pf(e)&&e.host||vn(e);return pf(t)?t.host:t}function Ay(e){const t=Rr(e);return jo(t)?e.ownerDocument?e.ownerDocument.body:e.body:vt(t)&&hi(t)?t:Ay(t)}function Qn(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=Ay(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=it(o);return s?t.concat(i,i.visualViewport||[],hi(o)?o:[],i.frameElement&&n?Qn(i.frameElement):[]):t.concat(o,Qn(o,[],n))}function Iy(e){let t=e.activeElement;for(;((n=t)==null||(n=n.shadowRoot)==null?void 0:n.activeElement)!=null;){var n;t=t.shadowRoot.activeElement}return t}function qn(e,t){if(!e||!t)return!1;const n=t.getRootNode&&t.getRootNode();if(e.contains(t))return!0;if(n&&pf(n)){let r=t;for(;r;){if(e===r)return!0;r=r.parentNode||r.host}}return!1}function Cy(){const e=navigator.userAgentData;return e!=null&&e.platform?e.platform:navigator.platform}function hC(){const e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(t=>{let{brand:n,version:r}=t;return n+"/"+r}).join(" "):navigator.userAgent}function mC(e){return!EC()&&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 gC(){return/apple/i.test(navigator.vendor)}function EC(){const e=/android/i;return e.test(Cy())||e.test(hC())}function yC(){return Cy().toLowerCase().startsWith("mac")&&!navigator.maxTouchPoints}function Ly(e,t){const n=["mouse","pen"];return t||n.push("",void 0),n.includes(e)}function vC(e){return"nativeEvent"in e}function _C(e){return e.matches("html,body")}function Nr(e){return(e==null?void 0:e.ownerDocument)||document}function gf(e,t){if(t==null)return!1;if("composedPath"in e)return e.composedPath().includes(t);const n=e;return n.target!=null&&t.contains(n.target)}function wr(e){return"composedPath"in e?e.composedPath()[0]:e.target}const SC="input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";function xC(e){return vt(e)&&e.matches(SC)}const Vo=Math.min,Or=Math.max,Ia=Math.round,Ca=Math.floor,Jn=e=>({x:e,y:e}),RC={left:"right",right:"left",bottom:"top",top:"bottom"},NC={start:"end",end:"start"};function Ef(e,t,n){return Or(e,Vo(t,n))}function mi(e,t){return typeof e=="function"?e(t):e}function Tr(e){return e.split("-")[0]}function gi(e){return e.split("-")[1]}function by(e){return e==="x"?"y":"x"}function yf(e){return e==="y"?"height":"width"}function La(e){return["top","bottom"].includes(Tr(e))?"y":"x"}function vf(e){return by(La(e))}function wC(e,t,n){n===void 0&&(n=!1);const r=gi(e),o=vf(e),s=yf(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=ba(i)),[i,ba(i)]}function OC(e){const t=ba(e);return[_f(e),t,_f(t)]}function _f(e){return e.replace(/start|end/g,t=>NC[t])}function TC(e,t,n){const r=["left","right"],o=["right","left"],s=["top","bottom"],i=["bottom","top"];switch(e){case"top":case"bottom":return n?t?o:r:t?r:o;case"left":case"right":return t?s:i;default:return[]}}function AC(e,t,n,r){const o=gi(e);let s=TC(Tr(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(_f)))),s}function ba(e){return e.replace(/left|right|bottom|top/g,t=>RC[t])}function IC(e){return{top:0,right:0,bottom:0,left:0,...e}}function Dy(e){return typeof e!="number"?IC(e):{top:e,right:e,bottom:e,left:e}}function Da(e){return{...e,top:e.y,left:e.x,right:e.x+e.width,bottom:e.y+e.height}}function ky(e,t,n){let{reference:r,floating:o}=e;const s=La(t),i=vf(t),l=yf(i),a=Tr(t),c=s==="y",u=r.x+r.width/2-o.width/2,f=r.y+r.height/2-o.height/2,p=r[l]/2-o[l]/2;let h;switch(a){case"top":h={x:u,y:r.y-o.height};break;case"bottom":h={x:u,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y:f};break;case"left":h={x:r.x-o.width,y:f};break;default:h={x:r.x,y:r.y}}switch(gi(t)){case"start":h[i]-=p*(n&&c?-1:1);break;case"end":h[i]+=p*(n&&c?-1:1);break}return h}const CC=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,l=s.filter(Boolean),a=await(i.isRTL==null?void 0:i.isRTL(t));let c=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:u,y:f}=ky(c,r,a),p=r,h={},E=0;for(let y=0;y<l.length;y++){const{name:v,fn:m}=l[y],{x:g,y:S,data:_,reset:x}=await m({x:u,y:f,initialPlacement:r,placement:p,strategy:o,middlewareData:h,rects:c,platform:i,elements:{reference:e,floating:t}});if(u=g??u,f=S??f,h={...h,[v]:{...h[v],..._}},x&&E<=50){E++,typeof x=="object"&&(x.placement&&(p=x.placement),x.rects&&(c=x.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):x.rects),{x:u,y:f}=ky(c,p,a)),y=-1;continue}}return{x:u,y:f,placement:p,strategy:o,middlewareData:h}};async function Py(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:l,strategy:a}=e,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:f="floating",altBoundary:p=!1,padding:h=0}=mi(t,e),E=Dy(h),v=l[p?f==="floating"?"reference":"floating":f],m=Da(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(v)))==null||n?v:v.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(l.floating)),boundary:c,rootBoundary:u,strategy:a})),g=f==="floating"?{...i.floating,x:r,y:o}:i.reference,S=await(s.getOffsetParent==null?void 0:s.getOffsetParent(l.floating)),_=await(s.isElement==null?void 0:s.isElement(S))?await(s.getScale==null?void 0:s.getScale(S))||{x:1,y:1}:{x:1,y:1},x=Da(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({rect:g,offsetParent:S,strategy:a}):g);return{top:(m.top-x.top+E.top)/_.y,bottom:(x.bottom-m.bottom+E.bottom)/_.y,left:(m.left-x.left+E.left)/_.x,right:(x.right-m.right+E.right)/_.x}}const My=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:l,middlewareData:a}=t,{element:c,padding:u=0}=mi(e,t)||{};if(c==null)return{};const f=Dy(u),p={x:n,y:r},h=vf(o),E=yf(h),y=await i.getDimensions(c),v=h==="y",m=v?"top":"left",g=v?"bottom":"right",S=v?"clientHeight":"clientWidth",_=s.reference[E]+s.reference[h]-p[h]-s.floating[E],x=p[h]-s.reference[h],R=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c));let T=R?R[S]:0;(!T||!await(i.isElement==null?void 0:i.isElement(R)))&&(T=l.floating[S]||s.floating[E]);const L=_/2-x/2,P=T/2-y[E]/2-1,I=Vo(f[m],P),j=Vo(f[g],P),V=I,M=T-y[E]-j,w=T/2-y[E]/2+L,b=Ef(V,w,M),k=!a.arrow&&gi(o)!=null&&w!=b&&s.reference[E]/2-(w<V?I:j)-y[E]/2<0,F=k?w<V?w-V:w-M:0;return{[h]:p[h]+F,data:{[h]:b,centerOffset:w-b-F,...k&&{alignmentOffset:F}},reset:k}}}),LC=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:l,platform:a,elements:c}=t,{mainAxis:u=!0,crossAxis:f=!0,fallbackPlacements:p,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:E="none",flipAlignment:y=!0,...v}=mi(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const m=Tr(o),g=Tr(l)===l,S=await(a.isRTL==null?void 0:a.isRTL(c.floating)),_=p||(g||!y?[ba(l)]:OC(l));!p&&E!=="none"&&_.push(...AC(l,y,E,S));const x=[l,..._],R=await Py(t,v),T=[];let L=((r=s.flip)==null?void 0:r.overflows)||[];if(u&&T.push(R[m]),f){const V=wC(o,i,S);T.push(R[V[0]],R[V[1]])}if(L=[...L,{placement:o,overflows:T}],!T.every(V=>V<=0)){var P,I;const V=(((P=s.flip)==null?void 0:P.index)||0)+1,M=x[V];if(M)return{data:{index:V,overflows:L},reset:{placement:M}};let w=(I=L.filter(b=>b.overflows[0]<=0).sort((b,k)=>b.overflows[1]-k.overflows[1])[0])==null?void 0:I.placement;if(!w)switch(h){case"bestFit":{var j;const b=(j=L.map(k=>[k.placement,k.overflows.filter(F=>F>0).reduce((F,C)=>F+C,0)]).sort((k,F)=>k[1]-F[1])[0])==null?void 0:j[0];b&&(w=b);break}case"initialPlacement":w=l;break}if(o!==w)return{reset:{placement:w}}}return{}}}};async function bC(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=Tr(n),l=gi(n),a=La(n)==="y",c=["left","top"].includes(i)?-1:1,u=s&&a?-1:1,f=mi(t,e);let{mainAxis:p,crossAxis:h,alignmentAxis:E}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...f};return l&&typeof E=="number"&&(h=l==="end"?E*-1:E),a?{x:h*u,y:p*c}:{x:p*c,y:h*u}}const DC=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:s,placement:i,middlewareData:l}=t,a=await bC(t,e);return i===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:o+a.x,y:s+a.y,data:{...a,placement:i}}}}},kC=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:s=!0,crossAxis:i=!1,limiter:l={fn:v=>{let{x:m,y:g}=v;return{x:m,y:g}}},...a}=mi(e,t),c={x:n,y:r},u=await Py(t,a),f=La(Tr(o)),p=by(f);let h=c[p],E=c[f];if(s){const v=p==="y"?"top":"left",m=p==="y"?"bottom":"right",g=h+u[v],S=h-u[m];h=Ef(g,h,S)}if(i){const v=f==="y"?"top":"left",m=f==="y"?"bottom":"right",g=E+u[v],S=E-u[m];E=Ef(g,E,S)}const y=l.fn({...t,[p]:h,[f]:E});return{...y,data:{x:y.x-n,y:y.y-r}}}}};function Uy(e){const t=_t(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=vt(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,l=Ia(n)!==s||Ia(r)!==i;return l&&(n=s,r=i),{width:n,height:r,$:l}}function Sf(e){return ge(e)?e:e.contextElement}function $o(e){const t=Sf(e);if(!vt(t))return Jn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=Uy(t);let i=(s?Ia(n.width):n.width)/r,l=(s?Ia(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!l||!Number.isFinite(l))&&(l=1),{x:i,y:l}}const PC=Jn(0);function Fy(e){const t=it(e);return!mf()||!t.visualViewport?PC:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function MC(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==it(e)?!1:t}function Ar(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=Sf(e);let i=Jn(1);t&&(r?ge(r)&&(i=$o(r)):i=$o(e));const l=MC(s,n,r)?Fy(s):Jn(0);let a=(o.left+l.x)/i.x,c=(o.top+l.y)/i.y,u=o.width/i.x,f=o.height/i.y;if(s){const p=it(s),h=r&&ge(r)?it(r):r;let E=p.frameElement;for(;E&&r&&h!==p;){const y=$o(E),v=E.getBoundingClientRect(),m=_t(E),g=v.left+(E.clientLeft+parseFloat(m.paddingLeft))*y.x,S=v.top+(E.clientTop+parseFloat(m.paddingTop))*y.y;a*=y.x,c*=y.y,u*=y.x,f*=y.y,a+=g,c+=S,E=it(E).frameElement}}return Da({width:u,height:f,x:a,y:c})}function UC(e){let{rect:t,offsetParent:n,strategy:r}=e;const o=vt(n),s=vn(n);if(n===s)return t;let i={scrollLeft:0,scrollTop:0},l=Jn(1);const a=Jn(0);if((o||!o&&r!=="fixed")&&((Xn(n)!=="body"||hi(s))&&(i=Aa(n)),vt(n))){const c=Ar(n);l=$o(n),a.x=c.x+n.clientLeft,a.y=c.y+n.clientTop}return{width:t.width*l.x,height:t.height*l.y,x:t.x*l.x-i.scrollLeft*l.x+a.x,y:t.y*l.y-i.scrollTop*l.y+a.y}}function FC(e){return Array.from(e.getClientRects())}function jy(e){return Ar(vn(e)).left+Aa(e).scrollLeft}function jC(e){const t=vn(e),n=Aa(e),r=e.ownerDocument.body,o=Or(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Or(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+jy(e);const l=-n.scrollTop;return _t(r).direction==="rtl"&&(i+=Or(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:l}}function VC(e,t){const n=it(e),r=vn(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,l=0,a=0;if(o){s=o.width,i=o.height;const c=mf();(!c||c&&t==="fixed")&&(l=o.offsetLeft,a=o.offsetTop)}return{width:s,height:i,x:l,y:a}}function $C(e,t){const n=Ar(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=vt(e)?$o(e):Jn(1),i=e.clientWidth*s.x,l=e.clientHeight*s.y,a=o*s.x,c=r*s.y;return{width:i,height:l,x:a,y:c}}function Vy(e,t,n){let r;if(t==="viewport")r=VC(e,n);else if(t==="document")r=jC(vn(e));else if(ge(t))r=$C(t,n);else{const o=Fy(e);r={...t,x:t.x-o.x,y:t.y-o.y}}return Da(r)}function $y(e,t){const n=Rr(e);return n===t||!ge(n)||jo(n)?!1:_t(n).position==="fixed"||$y(n,t)}function HC(e,t){const n=t.get(e);if(n)return n;let r=Qn(e,[],!1).filter(l=>ge(l)&&Xn(l)!=="body"),o=null;const s=_t(e).position==="fixed";let i=s?Rr(e):e;for(;ge(i)&&!jo(i);){const l=_t(i),a=hf(i);!a&&l.position==="fixed"&&(o=null),(s?!a&&!o:!a&&l.position==="static"&&!!o&&["absolute","fixed"].includes(o.position)||hi(i)&&!a&&$y(e,i))?r=r.filter(u=>u!==i):o=l,i=Rr(i)}return t.set(e,r),r}function BC(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?HC(t,this._c):[].concat(n),r],l=i[0],a=i.reduce((c,u)=>{const f=Vy(t,u,o);return c.top=Or(f.top,c.top),c.right=Vo(f.right,c.right),c.bottom=Vo(f.bottom,c.bottom),c.left=Or(f.left,c.left),c},Vy(t,l,o));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}}function zC(e){return Uy(e)}function WC(e,t,n){const r=vt(t),o=vn(t),s=n==="fixed",i=Ar(e,!0,s,t);let l={scrollLeft:0,scrollTop:0};const a=Jn(0);if(r||!r&&!s)if((Xn(t)!=="body"||hi(o))&&(l=Aa(t)),r){const c=Ar(t,!0,s,t);a.x=c.x+t.clientLeft,a.y=c.y+t.clientTop}else o&&(a.x=jy(o));return{x:i.left+l.scrollLeft-a.x,y:i.top+l.scrollTop-a.y,width:i.width,height:i.height}}function Hy(e,t){return!vt(e)||_t(e).position==="fixed"?null:t?t(e):e.offsetParent}function By(e,t){const n=it(e);if(!vt(e))return n;let r=Hy(e,t);for(;r&&fC(r)&&_t(r).position==="static";)r=Hy(r,t);return r&&(Xn(r)==="html"||Xn(r)==="body"&&_t(r).position==="static"&&!hf(r))?n:r||pC(e)||n}const GC=async function(e){let{reference:t,floating:n,strategy:r}=e;const o=this.getOffsetParent||By,s=this.getDimensions;return{reference:WC(t,await o(n),r),floating:{x:0,y:0,...await s(n)}}};function YC(e){return _t(e).direction==="rtl"}const KC={convertOffsetParentRelativeRectToViewportRelativeRect:UC,getDocumentElement:vn,getClippingRect:BC,getOffsetParent:By,getElementRects:GC,getClientRects:FC,getDimensions:zC,getScale:$o,isElement:ge,isRTL:YC};function XC(e,t){let n=null,r;const o=vn(e);function s(){clearTimeout(r),n&&n.disconnect(),n=null}function i(l,a){l===void 0&&(l=!1),a===void 0&&(a=1),s();const{left:c,top:u,width:f,height:p}=e.getBoundingClientRect();if(l||t(),!f||!p)return;const h=Ca(u),E=Ca(o.clientWidth-(c+f)),y=Ca(o.clientHeight-(u+p)),v=Ca(c),g={rootMargin:-h+"px "+-E+"px "+-y+"px "+-v+"px",threshold:Or(0,Vo(1,a))||1};let S=!0;function _(x){const R=x[0].intersectionRatio;if(R!==a){if(!S)return i();R?i(!1,R):r=setTimeout(()=>{i(!1,1e-7)},100)}S=!1}try{n=new IntersectionObserver(_,{...g,root:o.ownerDocument})}catch{n=new IntersectionObserver(_,g)}n.observe(e)}return i(!0),s}function QC(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:a=!1}=r,c=Sf(e),u=o||s?[...c?Qn(c):[],...Qn(t)]:[];u.forEach(m=>{o&&m.addEventListener("scroll",n,{passive:!0}),s&&m.addEventListener("resize",n)});const f=c&&l?XC(c,n):null;let p=-1,h=null;i&&(h=new ResizeObserver(m=>{let[g]=m;g&&g.target===c&&h&&(h.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{h&&h.observe(t)})),n()}),c&&!a&&h.observe(c),h.observe(t));let E,y=a?Ar(e):null;a&&v();function v(){const m=Ar(e);y&&(m.x!==y.x||m.y!==y.y||m.width!==y.width||m.height!==y.height)&&n(),y=m,E=requestAnimationFrame(v)}return n(),()=>{u.forEach(m=>{o&&m.removeEventListener("scroll",n),s&&m.removeEventListener("resize",n)}),f&&f(),h&&h.disconnect(),h=null,a&&cancelAnimationFrame(E)}}const qC=(e,t,n)=>{const r=new Map,o={platform:KC,...n},s={...o.platform,_c:r};return CC(e,t,{...o,platform:s})},JC=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?My({element:r.current,padding:o}).fn(n):{}:r?My({element:r,padding:o}).fn(n):{}}}};var ka=typeof document<"u"?O.useLayoutEffect:O.useEffect;function Pa(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 n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!=t.length)return!1;for(r=n;r--!==0;)if(!Pa(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const s=o[r];if(!(s==="_owner"&&e.$$typeof)&&!Pa(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function zy(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Wy(e,t){const n=zy(e);return Math.round(t*n)/n}function Gy(e){const t=O.useRef(e);return ka(()=>{t.current=e}),t}function ZC(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:l=!0,whileElementsMounted:a,open:c}=e,[u,f]=O.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[p,h]=O.useState(r);Pa(p,r)||h(r);const[E,y]=O.useState(null),[v,m]=O.useState(null),g=O.useCallback(k=>{k!=R.current&&(R.current=k,y(k))},[y]),S=O.useCallback(k=>{k!==T.current&&(T.current=k,m(k))},[m]),_=s||E,x=i||v,R=O.useRef(null),T=O.useRef(null),L=O.useRef(u),P=Gy(a),I=Gy(o),j=O.useCallback(()=>{if(!R.current||!T.current)return;const k={placement:t,strategy:n,middleware:p};I.current&&(k.platform=I.current),qC(R.current,T.current,k).then(F=>{const C={...F,isPositioned:!0};V.current&&!Pa(L.current,C)&&(L.current=C,Bl.flushSync(()=>{f(C)}))})},[p,t,n,I]);ka(()=>{c===!1&&L.current.isPositioned&&(L.current.isPositioned=!1,f(k=>({...k,isPositioned:!1})))},[c]);const V=O.useRef(!1);ka(()=>(V.current=!0,()=>{V.current=!1}),[]),ka(()=>{if(_&&(R.current=_),x&&(T.current=x),_&&x){if(P.current)return P.current(_,x,j);j()}},[_,x,j,P]);const M=O.useMemo(()=>({reference:R,floating:T,setReference:g,setFloating:S}),[g,S]),w=O.useMemo(()=>({reference:_,floating:x}),[_,x]),b=O.useMemo(()=>{const k={position:n,left:0,top:0};if(!w.floating)return k;const F=Wy(w.floating,u.x),C=Wy(w.floating,u.y);return l?{...k,transform:"translate("+F+"px, "+C+"px)",...zy(w.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:F,top:C}},[n,l,w.floating,u.x,u.y]);return O.useMemo(()=>({...u,update:j,refs:M,elements:w,floatingStyles:b}),[u,j,M,w,b])}function Yy(e){return O.useMemo(()=>e.every(t=>t==null)?null:t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})},e)}const e2=lp.useInsertionEffect||(e=>e());function Ho(e){const t=O.useRef(()=>{});return e2(()=>{t.current=e}),O.useCallback(function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return t.current==null?void 0:t.current(...r)},[])}var Ei=typeof document<"u"?O.useLayoutEffect:O.useEffect;let xf=!1,t2=0;const Ky=()=>"floating-ui-"+t2++;function n2(){const[e,t]=O.useState(()=>xf?Ky():void 0);return Ei(()=>{e==null&&t(Ky())},[]),O.useEffect(()=>{xf||(xf=!0)},[]),e}const Xy=lp.useId||n2;function r2(){const e=new Map;return{emit(t,n){var r;(r=e.get(t))==null||r.forEach(o=>o(n))},on(t,n){e.set(t,[...e.get(t)||[],n])},off(t,n){var r;e.set(t,((r=e.get(t))==null?void 0:r.filter(o=>o!==n))||[])}}}const o2=O.createContext(null),s2=O.createContext(null),Rf=()=>{var e;return((e=O.useContext(o2))==null?void 0:e.id)||null},Nf=()=>O.useContext(s2);function wf(e){return"data-floating-ui-"+e}function Qy(e){const t=O.useRef(e);return Ei(()=>{t.current=e}),t}const qy=wf("safe-polygon");function Of(e,t,n){return n&&!Ly(n)?0:typeof e=="number"?e:e==null?void 0:e[t]}function i2(e,t){t===void 0&&(t={});const{open:n,onOpenChange:r,dataRef:o,events:s,elements:{domReference:i,floating:l},refs:a}=e,{enabled:c=!0,delay:u=0,handleClose:f=null,mouseOnly:p=!1,restMs:h=0,move:E=!0}=t,y=Nf(),v=Rf(),m=Qy(f),g=Qy(u),S=O.useRef(),_=O.useRef(),x=O.useRef(),R=O.useRef(),T=O.useRef(!0),L=O.useRef(!1),P=O.useRef(()=>{}),I=O.useCallback(()=>{var w;const b=(w=o.current.openEvent)==null?void 0:w.type;return(b==null?void 0:b.includes("mouse"))&&b!=="mousedown"},[o]);O.useEffect(()=>{if(!c)return;function w(b){let{open:k}=b;k||(clearTimeout(_.current),clearTimeout(R.current),T.current=!0)}return s.on("openchange",w),()=>{s.off("openchange",w)}},[c,s]),O.useEffect(()=>{if(!c||!m.current||!n)return;function w(k){I()&&r(!1,k,"hover")}const b=Nr(l).documentElement;return b.addEventListener("mouseleave",w),()=>{b.removeEventListener("mouseleave",w)}},[l,n,r,c,m,o,I]);const j=O.useCallback(function(w,b,k){b===void 0&&(b=!0),k===void 0&&(k="hover");const F=Of(g.current,"close",S.current);F&&!x.current?(clearTimeout(_.current),_.current=setTimeout(()=>r(!1,w,k),F)):b&&(clearTimeout(_.current),r(!1,w,k))},[g,r]),V=O.useCallback(()=>{P.current(),x.current=void 0},[]),M=O.useCallback(()=>{if(L.current){const w=Nr(a.floating.current).body;w.style.pointerEvents="",w.removeAttribute(qy),L.current=!1}},[a]);return O.useEffect(()=>{if(!c)return;function w(){return o.current.openEvent?["click","mousedown"].includes(o.current.openEvent.type):!1}function b(C){if(clearTimeout(_.current),T.current=!1,p&&!Ly(S.current)||h>0&&Of(g.current,"open")===0)return;const D=Of(g.current,"open",S.current);D?_.current=setTimeout(()=>{r(!0,C,"hover")},D):r(!0,C,"hover")}function k(C){if(w())return;P.current();const D=Nr(l);if(clearTimeout(R.current),m.current){n||clearTimeout(_.current),x.current=m.current({...e,tree:y,x:C.clientX,y:C.clientY,onClose(){M(),V(),j(C,!0,"safe-polygon")}});const $=x.current;D.addEventListener("mousemove",$),P.current=()=>{D.removeEventListener("mousemove",$)};return}(S.current==="touch"?!qn(l,C.relatedTarget):!0)&&j(C)}function F(C){w()||m.current==null||m.current({...e,tree:y,x:C.clientX,y:C.clientY,onClose(){M(),V(),j(C)}})(C)}if(ge(i)){const C=i;return n&&C.addEventListener("mouseleave",F),l==null||l.addEventListener("mouseleave",F),E&&C.addEventListener("mousemove",b,{once:!0}),C.addEventListener("mouseenter",b),C.addEventListener("mouseleave",k),()=>{n&&C.removeEventListener("mouseleave",F),l==null||l.removeEventListener("mouseleave",F),E&&C.removeEventListener("mousemove",b),C.removeEventListener("mouseenter",b),C.removeEventListener("mouseleave",k)}}},[i,l,c,e,p,h,E,j,V,M,r,n,y,g,m,o]),Ei(()=>{var w;if(c&&n&&(w=m.current)!=null&&w.__options.blockPointerEvents&&I()){const k=Nr(l).body;if(k.setAttribute(qy,""),k.style.pointerEvents="none",L.current=!0,ge(i)&&l){var b;const F=i,C=y==null||(b=y.nodesRef.current.find(D=>D.id===v))==null||(b=b.context)==null?void 0:b.elements.floating;return C&&(C.style.pointerEvents=""),F.style.pointerEvents="auto",l.style.pointerEvents="auto",()=>{F.style.pointerEvents="",l.style.pointerEvents=""}}}},[c,n,v,l,i,y,m,o,I]),Ei(()=>{n||(S.current=void 0,V(),M())},[n,V,M]),O.useEffect(()=>()=>{V(),clearTimeout(_.current),clearTimeout(R.current),M()},[c,i,V,M]),O.useMemo(()=>{if(!c)return{};function w(b){S.current=b.pointerType}return{reference:{onPointerDown:w,onPointerEnter:w,onMouseMove(b){n||h===0||(clearTimeout(R.current),R.current=setTimeout(()=>{T.current||r(!0,b.nativeEvent,"hover")},h))}},floating:{onMouseEnter(){clearTimeout(_.current)},onMouseLeave(b){j(b.nativeEvent,!1)}}}},[c,h,n,r,j])}function Ma(e,t){let n=e.filter(o=>{var s;return o.parentId===t&&((s=o.context)==null?void 0:s.open)}),r=n;for(;r.length;)r=e.filter(o=>{var s;return(s=r)==null?void 0:s.some(i=>{var l;return o.parentId===i.id&&((l=o.context)==null?void 0:l.open)})}),n=n.concat(r);return n}const l2={pointerdown:"onPointerDown",mousedown:"onMouseDown",click:"onClick"},a2={pointerdown:"onPointerDownCapture",mousedown:"onMouseDownCapture",click:"onClickCapture"},Jy=e=>{var t,n;return{escapeKey:typeof e=="boolean"?e:(t=e==null?void 0:e.escapeKey)!=null?t:!1,outsidePress:typeof e=="boolean"?e:(n=e==null?void 0:e.outsidePress)!=null?n:!0}};function c2(e,t){t===void 0&&(t={});const{open:n,onOpenChange:r,nodeId:o,elements:{reference:s,domReference:i,floating:l},dataRef:a}=e,{enabled:c=!0,escapeKey:u=!0,outsidePress:f=!0,outsidePressEvent:p="pointerdown",referencePress:h=!1,referencePressEvent:E="pointerdown",ancestorScroll:y=!1,bubbles:v,capture:m}=t,g=Nf(),S=Ho(typeof f=="function"?f:()=>!1),_=typeof f=="function"?S:f,x=O.useRef(!1),R=O.useRef(!1),{escapeKey:T,outsidePress:L}=Jy(v),{escapeKey:P,outsidePress:I}=Jy(m),j=Ho(b=>{if(!n||!c||!u||b.key!=="Escape")return;const k=g?Ma(g.nodesRef.current,o):[];if(!T&&(b.stopPropagation(),k.length>0)){let F=!0;if(k.forEach(C=>{var D;if((D=C.context)!=null&&D.open&&!C.context.dataRef.current.__escapeKeyBubbles){F=!1;return}}),!F)return}r(!1,vC(b)?b.nativeEvent:b,"escape-key")}),V=Ho(b=>{var k;const F=()=>{var C;j(b),(C=wr(b))==null||C.removeEventListener("keydown",F)};(k=wr(b))==null||k.addEventListener("keydown",F)}),M=Ho(b=>{const k=x.current;x.current=!1;const F=R.current;if(R.current=!1,p==="click"&&F||k||typeof _=="function"&&!_(b))return;const C=wr(b),D="["+wf("inert")+"]",U=Nr(l).querySelectorAll(D);let $=ge(C)?C:null;for(;$&&!jo($);){const z=Rr($);if(jo(z)||!ge(z))break;$=z}if(U.length&&ge(C)&&!_C(C)&&!qn(C,l)&&Array.from(U).every(z=>!qn($,z)))return;if(vt(C)&&l){const z=C.clientWidth>0&&C.scrollWidth>C.clientWidth,Y=C.clientHeight>0&&C.scrollHeight>C.clientHeight;let X=Y&&b.offsetX>C.clientWidth;if(Y&&_t(C).direction==="rtl"&&(X=b.offsetX<=C.offsetWidth-C.clientWidth),X||z&&b.offsetY>C.clientHeight)return}const B=g&&Ma(g.nodesRef.current,o).some(z=>{var Y;return gf(b,(Y=z.context)==null?void 0:Y.elements.floating)});if(gf(b,l)||gf(b,i)||B)return;const W=g?Ma(g.nodesRef.current,o):[];if(W.length>0){let z=!0;if(W.forEach(Y=>{var X;if((X=Y.context)!=null&&X.open&&!Y.context.dataRef.current.__outsidePressBubbles){z=!1;return}}),!z)return}r(!1,b,"outside-press")}),w=Ho(b=>{var k;const F=()=>{var C;M(b),(C=wr(b))==null||C.removeEventListener(p,F)};(k=wr(b))==null||k.addEventListener(p,F)});return O.useEffect(()=>{if(!n||!c)return;a.current.__escapeKeyBubbles=T,a.current.__outsidePressBubbles=L;function b(C){r(!1,C,"ancestor-scroll")}const k=Nr(l);u&&k.addEventListener("keydown",P?V:j,P),_&&k.addEventListener(p,I?w:M,I);let F=[];return y&&(ge(i)&&(F=Qn(i)),ge(l)&&(F=F.concat(Qn(l))),!ge(s)&&s&&s.contextElement&&(F=F.concat(Qn(s.contextElement)))),F=F.filter(C=>{var D;return C!==((D=k.defaultView)==null?void 0:D.visualViewport)}),F.forEach(C=>{C.addEventListener("scroll",b,{passive:!0})}),()=>{u&&k.removeEventListener("keydown",P?V:j,P),_&&k.removeEventListener(p,I?w:M,I),F.forEach(C=>{C.removeEventListener("scroll",b)})}},[a,l,i,s,u,_,p,n,r,y,c,T,L,j,P,V,M,I,w]),O.useEffect(()=>{x.current=!1},[_,p]),O.useMemo(()=>c?{reference:{onKeyDown:j,[l2[E]]:b=>{h&&r(!1,b.nativeEvent,"reference-press")}},floating:{onKeyDown:j,onMouseDown(){R.current=!0},onMouseUp(){R.current=!0},[a2[p]]:()=>{x.current=!0}}}:{},[c,h,p,E,r,j])}function u2(e){var t;e===void 0&&(e={});const{open:n=!1,onOpenChange:r,nodeId:o}=e,[s,i]=O.useState(null),l=((t=e.elements)==null?void 0:t.reference)||s,a=ZC(e),c=Nf(),u=Rf()!=null,f=Ho((x,R,T)=>{x&&(h.current.openEvent=R),E.emit("openchange",{open:x,event:R,reason:T,nested:u}),r==null||r(x,R,T)}),p=O.useRef(null),h=O.useRef({}),E=O.useState(()=>r2())[0],y=Xy(),v=O.useCallback(x=>{const R=ge(x)?{getBoundingClientRect:()=>x.getBoundingClientRect(),contextElement:x}:x;a.refs.setReference(R)},[a.refs]),m=O.useCallback(x=>{(ge(x)||x===null)&&(p.current=x,i(x)),(ge(a.refs.reference.current)||a.refs.reference.current===null||x!==null&&!ge(x))&&a.refs.setReference(x)},[a.refs]),g=O.useMemo(()=>({...a.refs,setReference:m,setPositionReference:v,domReference:p}),[a.refs,m,v]),S=O.useMemo(()=>({...a.elements,domReference:l}),[a.elements,l]),_=O.useMemo(()=>({...a,refs:g,elements:S,dataRef:h,nodeId:o,floatingId:y,events:E,open:n,onOpenChange:f}),[a,o,y,E,n,f,g,S]);return Ei(()=>{const x=c==null?void 0:c.nodesRef.current.find(R=>R.id===o);x&&(x.context=_)}),O.useMemo(()=>({...a,context:_,refs:g,elements:S}),[a,g,S,_])}function d2(e,t){t===void 0&&(t={});const{open:n,onOpenChange:r,events:o,refs:s,elements:{floating:i,domReference:l}}=e,{enabled:a=!0,visibleOnly:c=!0}=t,u=O.useRef(!1),f=O.useRef(),p=O.useRef(!0);return O.useEffect(()=>{if(!a)return;const h=it(l);function E(){!n&&vt(l)&&l===Iy(Nr(l))&&(u.current=!0)}function y(){p.current=!0}return h.addEventListener("blur",E),h.addEventListener("keydown",y,!0),()=>{h.removeEventListener("blur",E),h.removeEventListener("keydown",y,!0)}},[i,l,n,a]),O.useEffect(()=>{if(!a)return;function h(E){let{reason:y}=E;(y==="reference-press"||y==="escape-key")&&(u.current=!0)}return o.on("openchange",h),()=>{o.off("openchange",h)}},[o,a]),O.useEffect(()=>()=>{clearTimeout(f.current)},[]),O.useMemo(()=>a?{reference:{onPointerDown(h){mC(h.nativeEvent)||(p.current=!1)},onMouseLeave(){u.current=!1},onFocus(h){if(u.current)return;const E=wr(h.nativeEvent);if(c&&ge(E))try{if(gC()&&yC())throw Error();if(!E.matches(":focus-visible"))return}catch{if(!p.current&&!xC(E))return}r(!0,h.nativeEvent,"focus")},onBlur(h){u.current=!1;const E=h.relatedTarget,y=ge(E)&&E.hasAttribute(wf("focus-guard"))&&E.getAttribute("data-type")==="outside";f.current=window.setTimeout(()=>{const v=Iy(l?l.ownerDocument:document);!E&&v===l||qn(s.floating.current,E)||qn(l,E)||y||r(!1,h.nativeEvent,"focus")})}}}:{},[a,c,l,s,r])}const Zy="active",ev="selected";function Tf(e,t,n){const r=new Map,o=n==="item";let s=e;if(o&&e){const{[Zy]:i,[ev]:l,...a}=e;s=a}return{...n==="floating"&&{tabIndex:-1},...s,...t.map(i=>{const l=i?i[n]:null;return typeof l=="function"?e?l(e):null:l}).concat(e).reduce((i,l)=>(l&&Object.entries(l).forEach(a=>{let[c,u]=a;if(!(o&&[Zy,ev].includes(c)))if(c.indexOf("on")===0){if(r.has(c)||r.set(c,[]),typeof u=="function"){var f;(f=r.get(c))==null||f.push(u),i[c]=function(){for(var p,h=arguments.length,E=new Array(h),y=0;y<h;y++)E[y]=arguments[y];return(p=r.get(c))==null?void 0:p.map(v=>v(...E)).find(v=>v!==void 0)}}}else i[c]=u}),i),{})}}function f2(e){e===void 0&&(e=[]);const t=e,n=O.useCallback(s=>Tf(s,e,"reference"),t),r=O.useCallback(s=>Tf(s,e,"floating"),t),o=O.useCallback(s=>Tf(s,e,"item"),e.map(s=>s==null?void 0:s.item));return O.useMemo(()=>({getReferenceProps:n,getFloatingProps:r,getItemProps:o}),[n,r,o])}const p2=new Map([["select","listbox"],["combobox","listbox"],["label",!1]]);function h2(e,t){var n;t===void 0&&(t={});const{open:r,floatingId:o}=e,{enabled:s=!0,role:i="dialog"}=t,l=(n=p2.get(i))!=null?n:i,a=Xy(),u=Rf()!=null;return O.useMemo(()=>{if(!s)return{};const f={id:o,...l&&{role:l}};return l==="tooltip"||i==="label"?{reference:{["aria-"+(i==="label"?"labelledby":"describedby")]:r?o:void 0},floating:f}:{reference:{"aria-expanded":r?"true":"false","aria-haspopup":l==="alertdialog"?"dialog":l,"aria-controls":r?o:void 0,...l==="listbox"&&{role:"combobox"},...l==="menu"&&{id:a},...l==="menu"&&u&&{role:"menuitem"},...i==="select"&&{"aria-autocomplete":"none"},...i==="combobox"&&{"aria-autocomplete":"list"}},floating:{...f,...l==="menu"&&{"aria-labelledby":a}},item(p){let{active:h,selected:E}=p;const y={role:"option",...h&&{id:o+"-option"}};switch(i){case"select":return{...y,"aria-selected":h&&E};case"combobox":return{...y,...h&&{"aria-selected":!0}}}return{}}}},[s,i,l,r,o,a,u])}function tv(e,t){const[n,r]=e;let o=!1;const s=t.length;for(let i=0,l=s-1;i<s;l=i++){const[a,c]=t[i]||[0,0],[u,f]=t[l]||[0,0];c>=r!=f>=r&&n<=(u-a)*(r-c)/(f-c)+a&&(o=!o)}return o}function m2(e,t){return e[0]>=t.x&&e[0]<=t.x+t.width&&e[1]>=t.y&&e[1]<=t.y+t.height}function g2(e){e===void 0&&(e={});const{buffer:t=.5,blockPointerEvents:n=!1,requireIntent:r=!0}=e;let o,s=!1,i=null,l=null,a=performance.now();function c(f,p){const h=performance.now(),E=h-a;if(i===null||l===null||E===0)return i=f,l=p,a=h,null;const y=f-i,v=p-l,g=Math.sqrt(y*y+v*v)/E;return i=f,l=p,a=h,g}const u=f=>{let{x:p,y:h,placement:E,elements:y,onClose:v,nodeId:m,tree:g}=f;return function(_){function x(){clearTimeout(o),v()}if(clearTimeout(o),!y.domReference||!y.floating||E==null||p==null||h==null)return;const{clientX:R,clientY:T}=_,L=[R,T],P=wr(_),I=_.type==="mouseleave",j=qn(y.floating,P),V=qn(y.domReference,P),M=y.domReference.getBoundingClientRect(),w=y.floating.getBoundingClientRect(),b=E.split("-")[0],k=p>w.right-w.width/2,F=h>w.bottom-w.height/2,C=m2(L,M),D=w.width>M.width,U=w.height>M.height,$=(D?M:w).left,B=(D?M:w).right,W=(U?M:w).top,z=(U?M:w).bottom;if(j&&(s=!0,!I))return;if(V&&(s=!1),V&&!I){s=!0;return}if(I&&ge(_.relatedTarget)&&qn(y.floating,_.relatedTarget)||g&&Ma(g.nodesRef.current,m).some(Z=>{let{context:J}=Z;return J==null?void 0:J.open}))return;if(b==="top"&&h>=M.bottom-1||b==="bottom"&&h<=M.top+1||b==="left"&&p>=M.right-1||b==="right"&&p<=M.left+1)return x();let Y=[];switch(b){case"top":Y=[[$,M.top+1],[$,w.bottom-1],[B,w.bottom-1],[B,M.top+1]];break;case"bottom":Y=[[$,w.top+1],[$,M.bottom-1],[B,M.bottom-1],[B,w.top+1]];break;case"left":Y=[[w.right-1,z],[w.right-1,W],[M.left+1,W],[M.left+1,z]];break;case"right":Y=[[M.right-1,z],[M.right-1,W],[w.left+1,W],[w.left+1,z]];break}function X(Z){let[J,te]=Z;switch(b){case"top":{const ce=[D?J+t/2:k?J+t*4:J-t*4,te+t+1],Re=[D?J-t/2:k?J+t*4:J-t*4,te+t+1],Me=[[w.left,k||D?w.bottom-t:w.top],[w.right,k?D?w.bottom-t:w.top:w.bottom-t]];return[ce,Re,...Me]}case"bottom":{const ce=[D?J+t/2:k?J+t*4:J-t*4,te-t],Re=[D?J-t/2:k?J+t*4:J-t*4,te-t],Me=[[w.left,k||D?w.top+t:w.bottom],[w.right,k?D?w.top+t:w.bottom:w.top+t]];return[ce,Re,...Me]}case"left":{const ce=[J+t+1,U?te+t/2:F?te+t*4:te-t*4],Re=[J+t+1,U?te-t/2:F?te+t*4:te-t*4];return[...[[F||U?w.right-t:w.left,w.top],[F?U?w.right-t:w.left:w.right-t,w.bottom]],ce,Re]}case"right":{const ce=[J-t,U?te+t/2:F?te+t*4:te-t*4],Re=[J-t,U?te-t/2:F?te+t*4:te-t*4],Me=[[F||U?w.left+t:w.right,w.top],[F?U?w.left+t:w.right:w.left+t,w.bottom]];return[ce,Re,...Me]}}}if(!tv([R,T],Y)){if(s&&!C)return x();if(!I&&r){const Z=c(_.clientX,_.clientY);if(Z!==null&&Z<.1)return x()}tv([R,T],X([p,h]))?!s&&r&&(o=window.setTimeout(x,40)):x()}}};return u.__options={blockPointerEvents:n},u}function E2({arrowPadding:e,escapeKey:t=!0,initialOpen:n=!1,keepOpenOverContent:r=!1,onOpenChange:o,open:s,outsidePress:i=!0,placement:l,role:a="tooltip"}){const c=Q(R=>R.rootElementId),u=O.useRef(null),[f,p]=O.useState(n),h=s??f,E=o??p,y=u2({middleware:[DC(8),LC({boundary:document.querySelector(`#${c}`)||void 0}),kC({padding:4}),JC({element:u,padding:e??{bottom:0,left:8,right:8,top:8}})],onOpenChange:E,open:h,placement:l,strategy:"fixed",whileElementsMounted:QC}),v=y.context,m=i2(v,{enabled:s==null,handleClose:r?g2():null,move:!1}),g=d2(v,{enabled:s==null}),S=c2(v,{escapeKey:t,outsidePress:i}),_=h2(v,{role:a}),x=f2([m,g,S,_]);return O.useMemo(()=>({arrowRef:u,open:h,setOpen:E,...x,...y}),[h,E,x,y])}const nv=H.createContext(null),Af=()=>{const e=H.useContext(nv);if(e==null)throw new Error("Tooltip components must be wrapped in <Tooltip />");return e},y2=({children:e,...t})=>{const n=E2(t);return d.jsx(nv.Provider,{value:n,children:e})},v2={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"},_2=()=>{var i,l;const e=Af(),[t,n]=O.useState(e.middlewareData.arrow);O.useEffect(()=>{e.middlewareData.arrow&&n(e.middlewareData.arrow)},[e.middlewareData.arrow]);const r={left:(t==null?void 0:t.x)!=null?`${t==null?void 0:t.x}px`:"",top:(t==null?void 0:t.y)!=null?`${t==null?void 0:t.y}px`:""},o=((l=(i=e.placement)==null?void 0:i.split("-"))==null?void 0:l[0])||"top",s=`${v2[o]}`;return d.jsx("div",{ref:e.arrowRef,style:r,className:`tooltip-arrow absolute h-2 w-2 rotate-45 bg-inherit
60
+ */var zl=O,fR=dR;function pR(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var hR=typeof Object.is=="function"?Object.is:pR,mR=fR.useSyncExternalStore,gR=zl.useRef,ER=zl.useEffect,yR=zl.useMemo,vR=zl.useDebugValue;Ng.useSyncExternalStoreWithSelector=function(e,t,n,r,o){var s=gR(null);if(s.current===null){var i={hasValue:!1,value:null};s.current=i}else i=s.current;s=yR(function(){function a(h){if(!c){if(c=!0,u=h,h=r(h),o!==void 0&&i.hasValue){var E=i.value;if(o(E,h))return f=E}return f=h}if(E=f,hR(u,h))return E;var y=r(h);return o!==void 0&&o(E,y)?E:(u=h,f=y)}var c=!1,u,f,p=n===void 0?null:n;return[function(){return a(t())},p===null?void 0:function(){return a(p())}]},[t,n,r,o]);var l=mR(e,s[0],s[1]);return ER(function(){i.hasValue=!0,i.value=l},[l]),vR(l),l},Rg.exports=Ng;var _R=Rg.exports;const Tg=Ba(_R);var SR={VITE_APP_VERSION_HASH:"1510b28",VITE_BASE_URL:"http://localhost:8080",VITE_BASIC_AUTH:"7bfc11e6-4eee-4015-9289-20a6baf44443:PTf2c0aaa85a8064ee8ed44bc969a75280710be8d4b27af8a8",VITE_FLOW_DATA_VERSION:"0.0.10",VITE_DEFAULT_STYLE_HREF:"https://cdn.signalwire.com/npm/@signalwire/cfb@latest/dist/style.css",VITE_DEFAULT_VOICES_URL:"https://cdn.signalwire.com/npm/@signalwire/cfb@latest/dist/voices.json",BASE_URL:"/cfb/",MODE:"production",DEV:!1,PROD:!0,SSR:!1};const Ag=e=>{let t;const n=new Set,r=(a,c)=>{const u=typeof a=="function"?a(t):a;if(!Object.is(u,t)){const f=t;t=c??(typeof u!="object"||u===null)?u:Object.assign({},t,u),n.forEach(p=>p(t,f))}},o=()=>t,l={setState:r,getState:o,subscribe:a=>(n.add(a),()=>n.delete(a)),destroy:()=>{(SR?"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."),n.clear()}};return t=e(r,o,l),l},Ig=e=>e?Ag(e):Ag,{useDebugValue:xR}=H,{useSyncExternalStoreWithSelector:RR}=Tg;function Cg(e,t=e.getState,n){const r=RR(e.subscribe,e.getState,e.getServerState||e.getState,t,n);return xR(r),r}const Lg=(e,t)=>{const n=Ig(e),r=(o,s=t)=>Cg(n,o,s);return Object.assign(r,n),r},NR=(e,t)=>e?Lg(e,t):Lg;function Ge(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[r,o]of e)if(!Object.is(o,t.get(r)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r=0;r<n.length;r++)if(!Object.prototype.hasOwnProperty.call(t,n[r])||!Object.is(e[n[r]],t[n[r]]))return!1;return!0}var wR={value:()=>{}};function Wl(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new Gl(n)}function Gl(e){this._=e}function OR(e,t){return e.trim().split(/^|\s+/).map(function(n){var r="",o=n.indexOf(".");if(o>=0&&(r=n.slice(o+1),n=n.slice(0,o)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}Gl.prototype=Wl.prototype={constructor:Gl,on:function(e,t){var n=this._,r=OR(e+"",n),o,s=-1,i=r.length;if(arguments.length<2){for(;++s<i;)if((o=(e=r[s]).type)&&(o=TR(n[o],e.name)))return o;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++s<i;)if(o=(e=r[s]).type)n[o]=bg(n[o],e.name,t);else if(t==null)for(o in n)n[o]=bg(n[o],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Gl(e)},call:function(e,t){if((o=arguments.length-2)>0)for(var n=new Array(o),r=0,o,s;r<o;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(s=this._[e],r=0,o=s.length;r<o;++r)s[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var r=this._[e],o=0,s=r.length;o<s;++o)r[o].value.apply(t,n)}};function TR(e,t){for(var n=0,r=e.length,o;n<r;++n)if((o=e[n]).name===t)return o.value}function bg(e,t,n){for(var r=0,o=e.length;r<o;++r)if(e[r].name===t){e[r]=wR,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var pd="http://www.w3.org/1999/xhtml";const Dg={svg:"http://www.w3.org/2000/svg",xhtml:pd,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Yl(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Dg.hasOwnProperty(t)?{space:Dg[t],local:e}:e}function AR(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===pd&&t.documentElement.namespaceURI===pd?t.createElement(e):t.createElementNS(n,e)}}function IR(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function kg(e){var t=Yl(e);return(t.local?IR:AR)(t)}function CR(){}function hd(e){return e==null?CR:function(){return this.querySelector(e)}}function LR(e){typeof e!="function"&&(e=hd(e));for(var t=this._groups,n=t.length,r=new Array(n),o=0;o<n;++o)for(var s=t[o],i=s.length,l=r[o]=new Array(i),a,c,u=0;u<i;++u)(a=s[u])&&(c=e.call(a,a.__data__,u,s))&&("__data__"in a&&(c.__data__=a.__data__),l[u]=c);return new Et(r,this._parents)}function bR(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function DR(){return[]}function Pg(e){return e==null?DR:function(){return this.querySelectorAll(e)}}function kR(e){return function(){return bR(e.apply(this,arguments))}}function PR(e){typeof e=="function"?e=kR(e):e=Pg(e);for(var t=this._groups,n=t.length,r=[],o=[],s=0;s<n;++s)for(var i=t[s],l=i.length,a,c=0;c<l;++c)(a=i[c])&&(r.push(e.call(a,a.__data__,c,i)),o.push(a));return new Et(r,o)}function Mg(e){return function(){return this.matches(e)}}function Ug(e){return function(t){return t.matches(e)}}var MR=Array.prototype.find;function UR(e){return function(){return MR.call(this.children,e)}}function FR(){return this.firstElementChild}function jR(e){return this.select(e==null?FR:UR(typeof e=="function"?e:Ug(e)))}var VR=Array.prototype.filter;function $R(){return Array.from(this.children)}function HR(e){return function(){return VR.call(this.children,e)}}function BR(e){return this.selectAll(e==null?$R:HR(typeof e=="function"?e:Ug(e)))}function zR(e){typeof e!="function"&&(e=Mg(e));for(var t=this._groups,n=t.length,r=new Array(n),o=0;o<n;++o)for(var s=t[o],i=s.length,l=r[o]=[],a,c=0;c<i;++c)(a=s[c])&&e.call(a,a.__data__,c,s)&&l.push(a);return new Et(r,this._parents)}function Fg(e){return new Array(e.length)}function WR(){return new Et(this._enter||this._groups.map(Fg),this._parents)}function Kl(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Kl.prototype={constructor:Kl,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 GR(e){return function(){return e}}function YR(e,t,n,r,o,s){for(var i=0,l,a=t.length,c=s.length;i<c;++i)(l=t[i])?(l.__data__=s[i],r[i]=l):n[i]=new Kl(e,s[i]);for(;i<a;++i)(l=t[i])&&(o[i]=l)}function KR(e,t,n,r,o,s,i){var l,a,c=new Map,u=t.length,f=s.length,p=new Array(u),h;for(l=0;l<u;++l)(a=t[l])&&(p[l]=h=i.call(a,a.__data__,l,t)+"",c.has(h)?o[l]=a:c.set(h,a));for(l=0;l<f;++l)h=i.call(e,s[l],l,s)+"",(a=c.get(h))?(r[l]=a,a.__data__=s[l],c.delete(h)):n[l]=new Kl(e,s[l]);for(l=0;l<u;++l)(a=t[l])&&c.get(p[l])===a&&(o[l]=a)}function XR(e){return e.__data__}function QR(e,t){if(!arguments.length)return Array.from(this,XR);var n=t?KR:YR,r=this._parents,o=this._groups;typeof e!="function"&&(e=GR(e));for(var s=o.length,i=new Array(s),l=new Array(s),a=new Array(s),c=0;c<s;++c){var u=r[c],f=o[c],p=f.length,h=qR(e.call(u,u&&u.__data__,c,r)),E=h.length,y=l[c]=new Array(E),v=i[c]=new Array(E),m=a[c]=new Array(p);n(u,f,y,v,m,h,t);for(var g=0,S=0,_,x;g<E;++g)if(_=y[g]){for(g>=S&&(S=g+1);!(x=v[S])&&++S<E;);_._next=x||null}}return i=new Et(i,r),i._enter=l,i._exit=a,i}function qR(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function JR(){return new Et(this._exit||this._groups.map(Fg),this._parents)}function ZR(e,t,n){var r=this.enter(),o=this,s=this.exit();return typeof e=="function"?(r=e(r),r&&(r=r.selection())):r=r.append(e+""),t!=null&&(o=t(o),o&&(o=o.selection())),n==null?s.remove():n(s),r&&o?r.merge(o).order():o}function eN(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,o=n.length,s=r.length,i=Math.min(o,s),l=new Array(o),a=0;a<i;++a)for(var c=n[a],u=r[a],f=c.length,p=l[a]=new Array(f),h,E=0;E<f;++E)(h=c[E]||u[E])&&(p[E]=h);for(;a<o;++a)l[a]=n[a];return new Et(l,this._parents)}function tN(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],o=r.length-1,s=r[o],i;--o>=0;)(i=r[o])&&(s&&i.compareDocumentPosition(s)^4&&s.parentNode.insertBefore(i,s),s=i);return this}function nN(e){e||(e=rN);function t(f,p){return f&&p?e(f.__data__,p.__data__):!f-!p}for(var n=this._groups,r=n.length,o=new Array(r),s=0;s<r;++s){for(var i=n[s],l=i.length,a=o[s]=new Array(l),c,u=0;u<l;++u)(c=i[u])&&(a[u]=c);a.sort(t)}return new Et(o,this._parents).order()}function rN(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function oN(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function sN(){return Array.from(this)}function iN(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],o=0,s=r.length;o<s;++o){var i=r[o];if(i)return i}return null}function lN(){let e=0;for(const t of this)++e;return e}function aN(){return!this.node()}function cN(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var o=t[n],s=0,i=o.length,l;s<i;++s)(l=o[s])&&e.call(l,l.__data__,s,o);return this}function uN(e){return function(){this.removeAttribute(e)}}function dN(e){return function(){this.removeAttributeNS(e.space,e.local)}}function fN(e,t){return function(){this.setAttribute(e,t)}}function pN(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function hN(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function mN(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function gN(e,t){var n=Yl(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?dN:uN:typeof t=="function"?n.local?mN:hN:n.local?pN:fN)(n,t))}function jg(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function EN(e){return function(){this.style.removeProperty(e)}}function yN(e,t,n){return function(){this.style.setProperty(e,t,n)}}function vN(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function _N(e,t,n){return arguments.length>1?this.each((t==null?EN:typeof t=="function"?vN:yN)(e,t,n??"")):Eo(this.node(),e)}function Eo(e,t){return e.style.getPropertyValue(t)||jg(e).getComputedStyle(e,null).getPropertyValue(t)}function SN(e){return function(){delete this[e]}}function xN(e,t){return function(){this[e]=t}}function RN(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function NN(e,t){return arguments.length>1?this.each((t==null?SN:typeof t=="function"?RN:xN)(e,t)):this.node()[e]}function Vg(e){return e.trim().split(/^|\s+/)}function md(e){return e.classList||new $g(e)}function $g(e){this._node=e,this._names=Vg(e.getAttribute("class")||"")}$g.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 Hg(e,t){for(var n=md(e),r=-1,o=t.length;++r<o;)n.add(t[r])}function Bg(e,t){for(var n=md(e),r=-1,o=t.length;++r<o;)n.remove(t[r])}function wN(e){return function(){Hg(this,e)}}function ON(e){return function(){Bg(this,e)}}function TN(e,t){return function(){(t.apply(this,arguments)?Hg:Bg)(this,e)}}function AN(e,t){var n=Vg(e+"");if(arguments.length<2){for(var r=md(this.node()),o=-1,s=n.length;++o<s;)if(!r.contains(n[o]))return!1;return!0}return this.each((typeof t=="function"?TN:t?wN:ON)(n,t))}function IN(){this.textContent=""}function CN(e){return function(){this.textContent=e}}function LN(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function bN(e){return arguments.length?this.each(e==null?IN:(typeof e=="function"?LN:CN)(e)):this.node().textContent}function DN(){this.innerHTML=""}function kN(e){return function(){this.innerHTML=e}}function PN(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function MN(e){return arguments.length?this.each(e==null?DN:(typeof e=="function"?PN:kN)(e)):this.node().innerHTML}function UN(){this.nextSibling&&this.parentNode.appendChild(this)}function FN(){return this.each(UN)}function jN(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function VN(){return this.each(jN)}function $N(e){var t=typeof e=="function"?e:kg(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function HN(){return null}function BN(e,t){var n=typeof e=="function"?e:kg(e),r=t==null?HN:typeof t=="function"?t:hd(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function zN(){var e=this.parentNode;e&&e.removeChild(this)}function WN(){return this.each(zN)}function GN(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function YN(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function KN(e){return this.select(e?YN:GN)}function XN(e){return arguments.length?this.property("__data__",e):this.node().__data__}function QN(e){return function(t){e.call(this,t,this.__data__)}}function qN(e){return e.trim().split(/^|\s+/).map(function(t){var n="",r=t.indexOf(".");return r>=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function JN(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,o=t.length,s;n<o;++n)s=t[n],(!e.type||s.type===e.type)&&s.name===e.name?this.removeEventListener(s.type,s.listener,s.options):t[++r]=s;++r?t.length=r:delete this.__on}}}function ZN(e,t,n){return function(){var r=this.__on,o,s=QN(t);if(r){for(var i=0,l=r.length;i<l;++i)if((o=r[i]).type===e.type&&o.name===e.name){this.removeEventListener(o.type,o.listener,o.options),this.addEventListener(o.type,o.listener=s,o.options=n),o.value=t;return}}this.addEventListener(e.type,s,n),o={type:e.type,name:e.name,value:t,listener:s,options:n},r?r.push(o):this.__on=[o]}}function e1(e,t,n){var r=qN(e+""),o,s=r.length,i;if(arguments.length<2){var l=this.node().__on;if(l){for(var a=0,c=l.length,u;a<c;++a)for(o=0,u=l[a];o<s;++o)if((i=r[o]).type===u.type&&i.name===u.name)return u.value}return}for(l=t?ZN:JN,o=0;o<s;++o)this.each(l(r[o],t,n));return this}function zg(e,t,n){var r=jg(e),o=r.CustomEvent;typeof o=="function"?o=new o(t,n):(o=r.document.createEvent("Event"),n?(o.initEvent(t,n.bubbles,n.cancelable),o.detail=n.detail):o.initEvent(t,!1,!1)),e.dispatchEvent(o)}function t1(e,t){return function(){return zg(this,e,t)}}function n1(e,t){return function(){return zg(this,e,t.apply(this,arguments))}}function r1(e,t){return this.each((typeof t=="function"?n1:t1)(e,t))}function*o1(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],o=0,s=r.length,i;o<s;++o)(i=r[o])&&(yield i)}var Wg=[null];function Et(e,t){this._groups=e,this._parents=t}function Hs(){return new Et([[document.documentElement]],Wg)}function s1(){return this}Et.prototype=Hs.prototype={constructor:Et,select:LR,selectAll:PR,selectChild:jR,selectChildren:BR,filter:zR,data:QR,enter:WR,exit:JR,join:ZR,merge:eN,selection:s1,order:tN,sort:nN,call:oN,nodes:sN,node:iN,size:lN,empty:aN,each:cN,attr:gN,style:_N,property:NN,classed:AN,text:bN,html:MN,raise:FN,lower:VN,append:$N,insert:BN,remove:WN,clone:KN,datum:XN,on:e1,dispatch:r1,[Symbol.iterator]:o1};function jt(e){return typeof e=="string"?new Et([[document.querySelector(e)]],[document.documentElement]):new Et([[e]],Wg)}function i1(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Xt(e,t){if(e=i1(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var o=t.getBoundingClientRect();return[e.clientX-o.left-t.clientLeft,e.clientY-o.top-t.clientTop]}}return[e.pageX,e.pageY]}const l1={passive:!1},Bs={capture:!0,passive:!1};function gd(e){e.stopImmediatePropagation()}function yo(e){e.preventDefault(),e.stopImmediatePropagation()}function Gg(e){var t=e.document.documentElement,n=jt(e).on("dragstart.drag",yo,Bs);"onselectstart"in t?n.on("selectstart.drag",yo,Bs):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Yg(e,t){var n=e.document.documentElement,r=jt(e).on("dragstart.drag",null);t&&(r.on("click.drag",yo,Bs),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const Xl=e=>()=>e;function Ed(e,{sourceEvent:t,subject:n,target:r,identifier:o,active:s,x:i,y:l,dx:a,dy:c,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:o,enumerable:!0,configurable:!0},active:{value:s,enumerable:!0,configurable:!0},x:{value:i,enumerable:!0,configurable:!0},y:{value:l,enumerable:!0,configurable:!0},dx:{value:a,enumerable:!0,configurable:!0},dy:{value:c,enumerable:!0,configurable:!0},_:{value:u}})}Ed.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function a1(e){return!e.ctrlKey&&!e.button}function c1(){return this.parentNode}function u1(e,t){return t??{x:e.x,y:e.y}}function d1(){return navigator.maxTouchPoints||"ontouchstart"in this}function f1(){var e=a1,t=c1,n=u1,r=d1,o={},s=Wl("start","drag","end"),i=0,l,a,c,u,f=0;function p(_){_.on("mousedown.drag",h).filter(r).on("touchstart.drag",v).on("touchmove.drag",m,l1).on("touchend.drag touchcancel.drag",g).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(_,x){if(!(u||!e.call(this,_,x))){var R=S(this,t.call(this,_,x),_,x,"mouse");R&&(jt(_.view).on("mousemove.drag",E,Bs).on("mouseup.drag",y,Bs),Gg(_.view),gd(_),c=!1,l=_.clientX,a=_.clientY,R("start",_))}}function E(_){if(yo(_),!c){var x=_.clientX-l,R=_.clientY-a;c=x*x+R*R>f}o.mouse("drag",_)}function y(_){jt(_.view).on("mousemove.drag mouseup.drag",null),Yg(_.view,c),yo(_),o.mouse("end",_)}function v(_,x){if(e.call(this,_,x)){var R=_.changedTouches,T=t.call(this,_,x),L=R.length,P,I;for(P=0;P<L;++P)(I=S(this,T,_,x,R[P].identifier,R[P]))&&(gd(_),I("start",_,R[P]))}}function m(_){var x=_.changedTouches,R=x.length,T,L;for(T=0;T<R;++T)(L=o[x[T].identifier])&&(yo(_),L("drag",_,x[T]))}function g(_){var x=_.changedTouches,R=x.length,T,L;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),T=0;T<R;++T)(L=o[x[T].identifier])&&(gd(_),L("end",_,x[T]))}function S(_,x,R,T,L,P){var I=s.copy(),j=Xt(P||R,x),V,M,w;if((w=n.call(_,new Ed("beforestart",{sourceEvent:R,target:p,identifier:L,active:i,x:j[0],y:j[1],dx:0,dy:0,dispatch:I}),T))!=null)return V=w.x-j[0]||0,M=w.y-j[1]||0,function b(k,F,C){var D=j,U;switch(k){case"start":o[L]=b,U=i++;break;case"end":delete o[L],--i;case"drag":j=Xt(C||F,x),U=i;break}I.call(k,_,new Ed(k,{sourceEvent:F,subject:w,target:p,identifier:L,active:U,x:j[0]+V,y:j[1]+M,dx:j[0]-D[0],dy:j[1]-D[1],dispatch:I}),T)}}return p.filter=function(_){return arguments.length?(e=typeof _=="function"?_:Xl(!!_),p):e},p.container=function(_){return arguments.length?(t=typeof _=="function"?_:Xl(_),p):t},p.subject=function(_){return arguments.length?(n=typeof _=="function"?_:Xl(_),p):n},p.touchable=function(_){return arguments.length?(r=typeof _=="function"?_:Xl(!!_),p):r},p.on=function(){var _=s.on.apply(s,arguments);return _===s?p:_},p.clickDistance=function(_){return arguments.length?(f=(_=+_)*_,p):Math.sqrt(f)},p}function yd(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Kg(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function zs(){}var Ws=.7,Ql=1/Ws,vo="\\s*([+-]?\\d+)\\s*",Gs="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Qt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",p1=/^#([0-9a-f]{3,8})$/,h1=new RegExp(`^rgb\\(${vo},${vo},${vo}\\)$`),m1=new RegExp(`^rgb\\(${Qt},${Qt},${Qt}\\)$`),g1=new RegExp(`^rgba\\(${vo},${vo},${vo},${Gs}\\)$`),E1=new RegExp(`^rgba\\(${Qt},${Qt},${Qt},${Gs}\\)$`),y1=new RegExp(`^hsl\\(${Gs},${Qt},${Qt}\\)$`),v1=new RegExp(`^hsla\\(${Gs},${Qt},${Qt},${Gs}\\)$`),Xg={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};yd(zs,Ys,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Qg,formatHex:Qg,formatHex8:_1,formatHsl:S1,formatRgb:qg,toString:qg});function Qg(){return this.rgb().formatHex()}function _1(){return this.rgb().formatHex8()}function S1(){return nE(this).formatHsl()}function qg(){return this.rgb().formatRgb()}function Ys(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=p1.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?Jg(t):n===3?new st(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?ql(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?ql(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=h1.exec(e))?new st(t[1],t[2],t[3],1):(t=m1.exec(e))?new st(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=g1.exec(e))?ql(t[1],t[2],t[3],t[4]):(t=E1.exec(e))?ql(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=y1.exec(e))?tE(t[1],t[2]/100,t[3]/100,1):(t=v1.exec(e))?tE(t[1],t[2]/100,t[3]/100,t[4]):Xg.hasOwnProperty(e)?Jg(Xg[e]):e==="transparent"?new st(NaN,NaN,NaN,0):null}function Jg(e){return new st(e>>16&255,e>>8&255,e&255,1)}function ql(e,t,n,r){return r<=0&&(e=t=n=NaN),new st(e,t,n,r)}function x1(e){return e instanceof zs||(e=Ys(e)),e?(e=e.rgb(),new st(e.r,e.g,e.b,e.opacity)):new st}function vd(e,t,n,r){return arguments.length===1?x1(e):new st(e,t,n,r??1)}function st(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}yd(st,vd,Kg(zs,{brighter(e){return e=e==null?Ql:Math.pow(Ql,e),new st(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Ws:Math.pow(Ws,e),new st(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new st(yr(this.r),yr(this.g),yr(this.b),Jl(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:Zg,formatHex:Zg,formatHex8:R1,formatRgb:eE,toString:eE}));function Zg(){return`#${vr(this.r)}${vr(this.g)}${vr(this.b)}`}function R1(){return`#${vr(this.r)}${vr(this.g)}${vr(this.b)}${vr((isNaN(this.opacity)?1:this.opacity)*255)}`}function eE(){const e=Jl(this.opacity);return`${e===1?"rgb(":"rgba("}${yr(this.r)}, ${yr(this.g)}, ${yr(this.b)}${e===1?")":`, ${e})`}`}function Jl(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function yr(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function vr(e){return e=yr(e),(e<16?"0":"")+e.toString(16)}function tE(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Vt(e,t,n,r)}function nE(e){if(e instanceof Vt)return new Vt(e.h,e.s,e.l,e.opacity);if(e instanceof zs||(e=Ys(e)),!e)return new Vt;if(e instanceof Vt)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,o=Math.min(t,n,r),s=Math.max(t,n,r),i=NaN,l=s-o,a=(s+o)/2;return l?(t===s?i=(n-r)/l+(n<r)*6:n===s?i=(r-t)/l+2:i=(t-n)/l+4,l/=a<.5?s+o:2-s-o,i*=60):l=a>0&&a<1?0:i,new Vt(i,l,a,e.opacity)}function N1(e,t,n,r){return arguments.length===1?nE(e):new Vt(e,t,n,r??1)}function Vt(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}yd(Vt,N1,Kg(zs,{brighter(e){return e=e==null?Ql:Math.pow(Ql,e),new Vt(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Ws:Math.pow(Ws,e),new Vt(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,n=this.l,r=n+(n<.5?n:1-n)*t,o=2*n-r;return new st(_d(e>=240?e-240:e+120,o,r),_d(e,o,r),_d(e<120?e+240:e-120,o,r),this.opacity)},clamp(){return new Vt(rE(this.h),Zl(this.s),Zl(this.l),Jl(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=Jl(this.opacity);return`${e===1?"hsl(":"hsla("}${rE(this.h)}, ${Zl(this.s)*100}%, ${Zl(this.l)*100}%${e===1?")":`, ${e})`}`}}));function rE(e){return e=(e||0)%360,e<0?e+360:e}function Zl(e){return Math.max(0,Math.min(1,e||0))}function _d(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const oE=e=>()=>e;function w1(e,t){return function(n){return e+n*t}}function O1(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function T1(e){return(e=+e)==1?sE:function(t,n){return n-t?O1(t,n,e):oE(isNaN(t)?n:t)}}function sE(e,t){var n=t-e;return n?w1(e,n):oE(isNaN(e)?t:e)}const iE=function e(t){var n=T1(t);function r(o,s){var i=n((o=vd(o)).r,(s=vd(s)).r),l=n(o.g,s.g),a=n(o.b,s.b),c=sE(o.opacity,s.opacity);return function(u){return o.r=i(u),o.g=l(u),o.b=a(u),o.opacity=c(u),o+""}}return r.gamma=e,r}(1);function Hn(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var Sd=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,xd=new RegExp(Sd.source,"g");function A1(e){return function(){return e}}function I1(e){return function(t){return e(t)+""}}function C1(e,t){var n=Sd.lastIndex=xd.lastIndex=0,r,o,s,i=-1,l=[],a=[];for(e=e+"",t=t+"";(r=Sd.exec(e))&&(o=xd.exec(t));)(s=o.index)>n&&(s=t.slice(n,s),l[i]?l[i]+=s:l[++i]=s),(r=r[0])===(o=o[0])?l[i]?l[i]+=o:l[++i]=o:(l[++i]=null,a.push({i,x:Hn(r,o)})),n=xd.lastIndex;return n<t.length&&(s=t.slice(n),l[i]?l[i]+=s:l[++i]=s),l.length<2?a[0]?I1(a[0].x):A1(t):(t=a.length,function(c){for(var u=0,f;u<t;++u)l[(f=a[u]).i]=f.x(c);return l.join("")})}var lE=180/Math.PI,Rd={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function aE(e,t,n,r,o,s){var i,l,a;return(i=Math.sqrt(e*e+t*t))&&(e/=i,t/=i),(a=e*n+t*r)&&(n-=e*a,r-=t*a),(l=Math.sqrt(n*n+r*r))&&(n/=l,r/=l,a/=l),e*r<t*n&&(e=-e,t=-t,a=-a,i=-i),{translateX:o,translateY:s,rotate:Math.atan2(t,e)*lE,skewX:Math.atan(a)*lE,scaleX:i,scaleY:l}}var ea;function L1(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Rd:aE(t.a,t.b,t.c,t.d,t.e,t.f)}function b1(e){return e==null||(ea||(ea=document.createElementNS("http://www.w3.org/2000/svg","g")),ea.setAttribute("transform",e),!(e=ea.transform.baseVal.consolidate()))?Rd:(e=e.matrix,aE(e.a,e.b,e.c,e.d,e.e,e.f))}function cE(e,t,n,r){function o(c){return c.length?c.pop()+" ":""}function s(c,u,f,p,h,E){if(c!==f||u!==p){var y=h.push("translate(",null,t,null,n);E.push({i:y-4,x:Hn(c,f)},{i:y-2,x:Hn(u,p)})}else(f||p)&&h.push("translate("+f+t+p+n)}function i(c,u,f,p){c!==u?(c-u>180?u+=360:u-c>180&&(c+=360),p.push({i:f.push(o(f)+"rotate(",null,r)-2,x:Hn(c,u)})):u&&f.push(o(f)+"rotate("+u+r)}function l(c,u,f,p){c!==u?p.push({i:f.push(o(f)+"skewX(",null,r)-2,x:Hn(c,u)}):u&&f.push(o(f)+"skewX("+u+r)}function a(c,u,f,p,h,E){if(c!==f||u!==p){var y=h.push(o(h)+"scale(",null,",",null,")");E.push({i:y-4,x:Hn(c,f)},{i:y-2,x:Hn(u,p)})}else(f!==1||p!==1)&&h.push(o(h)+"scale("+f+","+p+")")}return function(c,u){var f=[],p=[];return c=e(c),u=e(u),s(c.translateX,c.translateY,u.translateX,u.translateY,f,p),i(c.rotate,u.rotate,f,p),l(c.skewX,u.skewX,f,p),a(c.scaleX,c.scaleY,u.scaleX,u.scaleY,f,p),c=u=null,function(h){for(var E=-1,y=p.length,v;++E<y;)f[(v=p[E]).i]=v.x(h);return f.join("")}}}var D1=cE(L1,"px, ","px)","deg)"),k1=cE(b1,", ",")",")"),P1=1e-12;function uE(e){return((e=Math.exp(e))+1/e)/2}function M1(e){return((e=Math.exp(e))-1/e)/2}function U1(e){return((e=Math.exp(2*e))-1)/(e+1)}const F1=function e(t,n,r){function o(s,i){var l=s[0],a=s[1],c=s[2],u=i[0],f=i[1],p=i[2],h=u-l,E=f-a,y=h*h+E*E,v,m;if(y<P1)m=Math.log(p/c)/t,v=function(T){return[l+T*h,a+T*E,c*Math.exp(t*T*m)]};else{var g=Math.sqrt(y),S=(p*p-c*c+r*y)/(2*c*n*g),_=(p*p-c*c-r*y)/(2*p*n*g),x=Math.log(Math.sqrt(S*S+1)-S),R=Math.log(Math.sqrt(_*_+1)-_);m=(R-x)/t,v=function(T){var L=T*m,P=uE(x),I=c/(n*g)*(P*U1(t*L+x)-M1(x));return[l+I*h,a+I*E,c*P/uE(t*L+x)]}}return v.duration=m*1e3*t/Math.SQRT2,v}return o.rho=function(s){var i=Math.max(.001,+s),l=i*i,a=l*l;return e(i,l,a)},o}(Math.SQRT2,2,4);var _o=0,Ks=0,Xs=0,dE=1e3,ta,Qs,na=0,_r=0,ra=0,qs=typeof performance=="object"&&performance.now?performance:Date,fE=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Nd(){return _r||(fE(j1),_r=qs.now()+ra)}function j1(){_r=0}function oa(){this._call=this._time=this._next=null}oa.prototype=pE.prototype={constructor:oa,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Nd():+n)+(t==null?0:+t),!this._next&&Qs!==this&&(Qs?Qs._next=this:ta=this,Qs=this),this._call=e,this._time=n,wd()},stop:function(){this._call&&(this._call=null,this._time=1/0,wd())}};function pE(e,t,n){var r=new oa;return r.restart(e,t,n),r}function V1(){Nd(),++_o;for(var e=ta,t;e;)(t=_r-e._time)>=0&&e._call.call(void 0,t),e=e._next;--_o}function hE(){_r=(na=qs.now())+ra,_o=Ks=0;try{V1()}finally{_o=0,H1(),_r=0}}function $1(){var e=qs.now(),t=e-na;t>dE&&(ra-=t,na=e)}function H1(){for(var e,t=ta,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:ta=n);Qs=e,wd(r)}function wd(e){if(!_o){Ks&&(Ks=clearTimeout(Ks));var t=e-_r;t>24?(e<1/0&&(Ks=setTimeout(hE,e-qs.now()-ra)),Xs&&(Xs=clearInterval(Xs))):(Xs||(na=qs.now(),Xs=setInterval($1,dE)),_o=1,fE(hE))}}function mE(e,t,n){var r=new oa;return t=t==null?0:+t,r.restart(o=>{r.stop(),e(o+t)},t,n),r}var B1=Wl("start","end","cancel","interrupt"),z1=[],gE=0,EE=1,Od=2,sa=3,yE=4,Td=5,ia=6;function la(e,t,n,r,o,s){var i=e.__transition;if(!i)e.__transition={};else if(n in i)return;W1(e,n,{name:t,index:r,group:o,on:B1,tween:z1,time:s.time,delay:s.delay,duration:s.duration,ease:s.ease,timer:null,state:gE})}function Ad(e,t){var n=$t(e,t);if(n.state>gE)throw new Error("too late; already scheduled");return n}function qt(e,t){var n=$t(e,t);if(n.state>sa)throw new Error("too late; already running");return n}function $t(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function W1(e,t,n){var r=e.__transition,o;r[t]=n,n.timer=pE(s,0,n.time);function s(c){n.state=EE,n.timer.restart(i,n.delay,n.time),n.delay<=c&&i(c-n.delay)}function i(c){var u,f,p,h;if(n.state!==EE)return a();for(u in r)if(h=r[u],h.name===n.name){if(h.state===sa)return mE(i);h.state===yE?(h.state=ia,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete r[u]):+u<t&&(h.state=ia,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete r[u])}if(mE(function(){n.state===sa&&(n.state=yE,n.timer.restart(l,n.delay,n.time),l(c))}),n.state=Od,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Od){for(n.state=sa,o=new Array(p=n.tween.length),u=0,f=-1;u<p;++u)(h=n.tween[u].value.call(e,e.__data__,n.index,n.group))&&(o[++f]=h);o.length=f+1}}function l(c){for(var u=c<n.duration?n.ease.call(null,c/n.duration):(n.timer.restart(a),n.state=Td,1),f=-1,p=o.length;++f<p;)o[f].call(e,u);n.state===Td&&(n.on.call("end",e,e.__data__,n.index,n.group),a())}function a(){n.state=ia,n.timer.stop(),delete r[t];for(var c in r)return;delete e.__transition}}function aa(e,t){var n=e.__transition,r,o,s=!0,i;if(n){t=t==null?null:t+"";for(i in n){if((r=n[i]).name!==t){s=!1;continue}o=r.state>Od&&r.state<Td,r.state=ia,r.timer.stop(),r.on.call(o?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[i]}s&&delete e.__transition}}function G1(e){return this.each(function(){aa(this,e)})}function Y1(e,t){var n,r;return function(){var o=qt(this,e),s=o.tween;if(s!==n){r=n=s;for(var i=0,l=r.length;i<l;++i)if(r[i].name===t){r=r.slice(),r.splice(i,1);break}}o.tween=r}}function K1(e,t,n){var r,o;if(typeof n!="function")throw new Error;return function(){var s=qt(this,e),i=s.tween;if(i!==r){o=(r=i).slice();for(var l={name:t,value:n},a=0,c=o.length;a<c;++a)if(o[a].name===t){o[a]=l;break}a===c&&o.push(l)}s.tween=o}}function X1(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=$t(this.node(),n).tween,o=0,s=r.length,i;o<s;++o)if((i=r[o]).name===e)return i.value;return null}return this.each((t==null?Y1:K1)(n,e,t))}function Id(e,t,n){var r=e._id;return e.each(function(){var o=qt(this,r);(o.value||(o.value={}))[t]=n.apply(this,arguments)}),function(o){return $t(o,r).value[t]}}function vE(e,t){var n;return(typeof t=="number"?Hn:t instanceof Ys?iE:(n=Ys(t))?(t=n,iE):C1)(e,t)}function Q1(e){return function(){this.removeAttribute(e)}}function q1(e){return function(){this.removeAttributeNS(e.space,e.local)}}function J1(e,t,n){var r,o=n+"",s;return function(){var i=this.getAttribute(e);return i===o?null:i===r?s:s=t(r=i,n)}}function Z1(e,t,n){var r,o=n+"",s;return function(){var i=this.getAttributeNS(e.space,e.local);return i===o?null:i===r?s:s=t(r=i,n)}}function ew(e,t,n){var r,o,s;return function(){var i,l=n(this),a;return l==null?void this.removeAttribute(e):(i=this.getAttribute(e),a=l+"",i===a?null:i===r&&a===o?s:(o=a,s=t(r=i,l)))}}function tw(e,t,n){var r,o,s;return function(){var i,l=n(this),a;return l==null?void this.removeAttributeNS(e.space,e.local):(i=this.getAttributeNS(e.space,e.local),a=l+"",i===a?null:i===r&&a===o?s:(o=a,s=t(r=i,l)))}}function nw(e,t){var n=Yl(e),r=n==="transform"?k1:vE;return this.attrTween(e,typeof t=="function"?(n.local?tw:ew)(n,r,Id(this,"attr."+e,t)):t==null?(n.local?q1:Q1)(n):(n.local?Z1:J1)(n,r,t))}function rw(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function ow(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function sw(e,t){var n,r;function o(){var s=t.apply(this,arguments);return s!==r&&(n=(r=s)&&ow(e,s)),n}return o._value=t,o}function iw(e,t){var n,r;function o(){var s=t.apply(this,arguments);return s!==r&&(n=(r=s)&&rw(e,s)),n}return o._value=t,o}function lw(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var r=Yl(e);return this.tween(n,(r.local?sw:iw)(r,t))}function aw(e,t){return function(){Ad(this,e).delay=+t.apply(this,arguments)}}function cw(e,t){return t=+t,function(){Ad(this,e).delay=t}}function uw(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?aw:cw)(t,e)):$t(this.node(),t).delay}function dw(e,t){return function(){qt(this,e).duration=+t.apply(this,arguments)}}function fw(e,t){return t=+t,function(){qt(this,e).duration=t}}function pw(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?dw:fw)(t,e)):$t(this.node(),t).duration}function hw(e,t){if(typeof t!="function")throw new Error;return function(){qt(this,e).ease=t}}function mw(e){var t=this._id;return arguments.length?this.each(hw(t,e)):$t(this.node(),t).ease}function gw(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;qt(this,e).ease=n}}function Ew(e){if(typeof e!="function")throw new Error;return this.each(gw(this._id,e))}function yw(e){typeof e!="function"&&(e=Mg(e));for(var t=this._groups,n=t.length,r=new Array(n),o=0;o<n;++o)for(var s=t[o],i=s.length,l=r[o]=[],a,c=0;c<i;++c)(a=s[c])&&e.call(a,a.__data__,c,s)&&l.push(a);return new hn(r,this._parents,this._name,this._id)}function vw(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,r=t.length,o=n.length,s=Math.min(r,o),i=new Array(r),l=0;l<s;++l)for(var a=t[l],c=n[l],u=a.length,f=i[l]=new Array(u),p,h=0;h<u;++h)(p=a[h]||c[h])&&(f[h]=p);for(;l<r;++l)i[l]=t[l];return new hn(i,this._parents,this._name,this._id)}function _w(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function Sw(e,t,n){var r,o,s=_w(t)?Ad:qt;return function(){var i=s(this,e),l=i.on;l!==r&&(o=(r=l).copy()).on(t,n),i.on=o}}function xw(e,t){var n=this._id;return arguments.length<2?$t(this.node(),n).on.on(e):this.each(Sw(n,e,t))}function Rw(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Nw(){return this.on("end.remove",Rw(this._id))}function ww(e){var t=this._name,n=this._id;typeof e!="function"&&(e=hd(e));for(var r=this._groups,o=r.length,s=new Array(o),i=0;i<o;++i)for(var l=r[i],a=l.length,c=s[i]=new Array(a),u,f,p=0;p<a;++p)(u=l[p])&&(f=e.call(u,u.__data__,p,l))&&("__data__"in u&&(f.__data__=u.__data__),c[p]=f,la(c[p],t,n,p,c,$t(u,n)));return new hn(s,this._parents,t,n)}function Ow(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Pg(e));for(var r=this._groups,o=r.length,s=[],i=[],l=0;l<o;++l)for(var a=r[l],c=a.length,u,f=0;f<c;++f)if(u=a[f]){for(var p=e.call(u,u.__data__,f,a),h,E=$t(u,n),y=0,v=p.length;y<v;++y)(h=p[y])&&la(h,t,n,y,p,E);s.push(p),i.push(u)}return new hn(s,i,t,n)}var Tw=Hs.prototype.constructor;function Aw(){return new Tw(this._groups,this._parents)}function Iw(e,t){var n,r,o;return function(){var s=Eo(this,e),i=(this.style.removeProperty(e),Eo(this,e));return s===i?null:s===n&&i===r?o:o=t(n=s,r=i)}}function _E(e){return function(){this.style.removeProperty(e)}}function Cw(e,t,n){var r,o=n+"",s;return function(){var i=Eo(this,e);return i===o?null:i===r?s:s=t(r=i,n)}}function Lw(e,t,n){var r,o,s;return function(){var i=Eo(this,e),l=n(this),a=l+"";return l==null&&(a=l=(this.style.removeProperty(e),Eo(this,e))),i===a?null:i===r&&a===o?s:(o=a,s=t(r=i,l))}}function bw(e,t){var n,r,o,s="style."+t,i="end."+s,l;return function(){var a=qt(this,e),c=a.on,u=a.value[s]==null?l||(l=_E(t)):void 0;(c!==n||o!==u)&&(r=(n=c).copy()).on(i,o=u),a.on=r}}function Dw(e,t,n){var r=(e+="")=="transform"?D1:vE;return t==null?this.styleTween(e,Iw(e,r)).on("end.style."+e,_E(e)):typeof t=="function"?this.styleTween(e,Lw(e,r,Id(this,"style."+e,t))).each(bw(this._id,e)):this.styleTween(e,Cw(e,r,t),n).on("end.style."+e,null)}function kw(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function Pw(e,t,n){var r,o;function s(){var i=t.apply(this,arguments);return i!==o&&(r=(o=i)&&kw(e,i,n)),r}return s._value=t,s}function Mw(e,t,n){var r="style."+(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;return this.tween(r,Pw(e,t,n??""))}function Uw(e){return function(){this.textContent=e}}function Fw(e){return function(){var t=e(this);this.textContent=t??""}}function jw(e){return this.tween("text",typeof e=="function"?Fw(Id(this,"text",e)):Uw(e==null?"":e+""))}function Vw(e){return function(t){this.textContent=e.call(this,t)}}function $w(e){var t,n;function r(){var o=e.apply(this,arguments);return o!==n&&(t=(n=o)&&Vw(o)),t}return r._value=e,r}function Hw(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,$w(e))}function Bw(){for(var e=this._name,t=this._id,n=SE(),r=this._groups,o=r.length,s=0;s<o;++s)for(var i=r[s],l=i.length,a,c=0;c<l;++c)if(a=i[c]){var u=$t(a,t);la(a,e,n,c,i,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new hn(r,this._parents,e,n)}function zw(){var e,t,n=this,r=n._id,o=n.size();return new Promise(function(s,i){var l={value:i},a={value:function(){--o===0&&s()}};n.each(function(){var c=qt(this,r),u=c.on;u!==e&&(t=(e=u).copy(),t._.cancel.push(l),t._.interrupt.push(l),t._.end.push(a)),c.on=t}),o===0&&s()})}var Ww=0;function hn(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function SE(){return++Ww}var mn=Hs.prototype;hn.prototype={constructor:hn,select:ww,selectAll:Ow,selectChild:mn.selectChild,selectChildren:mn.selectChildren,filter:yw,merge:vw,selection:Aw,transition:Bw,call:mn.call,nodes:mn.nodes,node:mn.node,size:mn.size,empty:mn.empty,each:mn.each,on:xw,attr:nw,attrTween:lw,style:Dw,styleTween:Mw,text:jw,textTween:Hw,remove:Nw,tween:X1,delay:uw,duration:pw,ease:mw,easeVarying:Ew,end:zw,[Symbol.iterator]:mn[Symbol.iterator]};function Gw(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Yw={time:null,delay:0,duration:250,ease:Gw};function Kw(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function Xw(e){var t,n;e instanceof hn?(t=e._id,e=e._name):(t=SE(),(n=Yw).time=Nd(),e=e==null?null:e+"");for(var r=this._groups,o=r.length,s=0;s<o;++s)for(var i=r[s],l=i.length,a,c=0;c<l;++c)(a=i[c])&&la(a,e,t,c,i,n||Kw(a,t));return new hn(r,this._parents,e,t)}Hs.prototype.interrupt=G1,Hs.prototype.transition=Xw;const ca=e=>()=>e;function Qw(e,{sourceEvent:t,target:n,transform:r,dispatch:o}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:o}})}function gn(e,t,n){this.k=e,this.x=t,this.y=n}gn.prototype={constructor:gn,scale:function(e){return e===1?this:new gn(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new gn(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 Bn=new gn(1,0,0);gn.prototype;function Cd(e){e.stopImmediatePropagation()}function Js(e){e.preventDefault(),e.stopImmediatePropagation()}function qw(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Jw(){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 xE(){return this.__zoom||Bn}function Zw(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function eO(){return navigator.maxTouchPoints||"ontouchstart"in this}function tO(e,t,n){var r=e.invertX(t[0][0])-n[0][0],o=e.invertX(t[1][0])-n[1][0],s=e.invertY(t[0][1])-n[0][1],i=e.invertY(t[1][1])-n[1][1];return e.translate(o>r?(r+o)/2:Math.min(0,r)||Math.max(0,o),i>s?(s+i)/2:Math.min(0,s)||Math.max(0,i))}function nO(){var e=qw,t=Jw,n=tO,r=Zw,o=eO,s=[0,1/0],i=[[-1/0,-1/0],[1/0,1/0]],l=250,a=F1,c=Wl("start","zoom","end"),u,f,p,h=500,E=150,y=0,v=10;function m(w){w.property("__zoom",xE).on("wheel.zoom",L,{passive:!1}).on("mousedown.zoom",P).on("dblclick.zoom",I).filter(o).on("touchstart.zoom",j).on("touchmove.zoom",V).on("touchend.zoom touchcancel.zoom",M).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}m.transform=function(w,b,k,F){var C=w.selection?w.selection():w;C.property("__zoom",xE),w!==C?x(w,b,k,F):C.interrupt().each(function(){R(this,arguments).event(F).start().zoom(null,typeof b=="function"?b.apply(this,arguments):b).end()})},m.scaleBy=function(w,b,k,F){m.scaleTo(w,function(){var C=this.__zoom.k,D=typeof b=="function"?b.apply(this,arguments):b;return C*D},k,F)},m.scaleTo=function(w,b,k,F){m.transform(w,function(){var C=t.apply(this,arguments),D=this.__zoom,U=k==null?_(C):typeof k=="function"?k.apply(this,arguments):k,$=D.invert(U),B=typeof b=="function"?b.apply(this,arguments):b;return n(S(g(D,B),U,$),C,i)},k,F)},m.translateBy=function(w,b,k,F){m.transform(w,function(){return n(this.__zoom.translate(typeof b=="function"?b.apply(this,arguments):b,typeof k=="function"?k.apply(this,arguments):k),t.apply(this,arguments),i)},null,F)},m.translateTo=function(w,b,k,F,C){m.transform(w,function(){var D=t.apply(this,arguments),U=this.__zoom,$=F==null?_(D):typeof F=="function"?F.apply(this,arguments):F;return n(Bn.translate($[0],$[1]).scale(U.k).translate(typeof b=="function"?-b.apply(this,arguments):-b,typeof k=="function"?-k.apply(this,arguments):-k),D,i)},F,C)};function g(w,b){return b=Math.max(s[0],Math.min(s[1],b)),b===w.k?w:new gn(b,w.x,w.y)}function S(w,b,k){var F=b[0]-k[0]*w.k,C=b[1]-k[1]*w.k;return F===w.x&&C===w.y?w:new gn(w.k,F,C)}function _(w){return[(+w[0][0]+ +w[1][0])/2,(+w[0][1]+ +w[1][1])/2]}function x(w,b,k,F){w.on("start.zoom",function(){R(this,arguments).event(F).start()}).on("interrupt.zoom end.zoom",function(){R(this,arguments).event(F).end()}).tween("zoom",function(){var C=this,D=arguments,U=R(C,D).event(F),$=t.apply(C,D),B=k==null?_($):typeof k=="function"?k.apply(C,D):k,W=Math.max($[1][0]-$[0][0],$[1][1]-$[0][1]),z=C.__zoom,Y=typeof b=="function"?b.apply(C,D):b,X=a(z.invert(B).concat(W/z.k),Y.invert(B).concat(W/Y.k));return function(Z){if(Z===1)Z=Y;else{var J=X(Z),te=W/J[2];Z=new gn(te,B[0]-J[0]*te,B[1]-J[1]*te)}U.zoom(null,Z)}})}function R(w,b,k){return!k&&w.__zooming||new T(w,b)}function T(w,b){this.that=w,this.args=b,this.active=0,this.sourceEvent=null,this.extent=t.apply(w,b),this.taps=0}T.prototype={event:function(w){return w&&(this.sourceEvent=w),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(w,b){return this.mouse&&w!=="mouse"&&(this.mouse[1]=b.invert(this.mouse[0])),this.touch0&&w!=="touch"&&(this.touch0[1]=b.invert(this.touch0[0])),this.touch1&&w!=="touch"&&(this.touch1[1]=b.invert(this.touch1[0])),this.that.__zoom=b,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(w){var b=jt(this.that).datum();c.call(w,this.that,new Qw(w,{sourceEvent:this.sourceEvent,target:m,type:w,transform:this.that.__zoom,dispatch:c}),b)}};function L(w,...b){if(!e.apply(this,arguments))return;var k=R(this,b).event(w),F=this.__zoom,C=Math.max(s[0],Math.min(s[1],F.k*Math.pow(2,r.apply(this,arguments)))),D=Xt(w);if(k.wheel)(k.mouse[0][0]!==D[0]||k.mouse[0][1]!==D[1])&&(k.mouse[1]=F.invert(k.mouse[0]=D)),clearTimeout(k.wheel);else{if(F.k===C)return;k.mouse=[D,F.invert(D)],aa(this),k.start()}Js(w),k.wheel=setTimeout(U,E),k.zoom("mouse",n(S(g(F,C),k.mouse[0],k.mouse[1]),k.extent,i));function U(){k.wheel=null,k.end()}}function P(w,...b){if(p||!e.apply(this,arguments))return;var k=w.currentTarget,F=R(this,b,!0).event(w),C=jt(w.view).on("mousemove.zoom",B,!0).on("mouseup.zoom",W,!0),D=Xt(w,k),U=w.clientX,$=w.clientY;Gg(w.view),Cd(w),F.mouse=[D,this.__zoom.invert(D)],aa(this),F.start();function B(z){if(Js(z),!F.moved){var Y=z.clientX-U,X=z.clientY-$;F.moved=Y*Y+X*X>y}F.event(z).zoom("mouse",n(S(F.that.__zoom,F.mouse[0]=Xt(z,k),F.mouse[1]),F.extent,i))}function W(z){C.on("mousemove.zoom mouseup.zoom",null),Yg(z.view,F.moved),Js(z),F.event(z).end()}}function I(w,...b){if(e.apply(this,arguments)){var k=this.__zoom,F=Xt(w.changedTouches?w.changedTouches[0]:w,this),C=k.invert(F),D=k.k*(w.shiftKey?.5:2),U=n(S(g(k,D),F,C),t.apply(this,b),i);Js(w),l>0?jt(this).transition().duration(l).call(x,U,F,w):jt(this).call(m.transform,U,F,w)}}function j(w,...b){if(e.apply(this,arguments)){var k=w.touches,F=k.length,C=R(this,b,w.changedTouches.length===F).event(w),D,U,$,B;for(Cd(w),U=0;U<F;++U)$=k[U],B=Xt($,this),B=[B,this.__zoom.invert(B),$.identifier],C.touch0?!C.touch1&&C.touch0[2]!==B[2]&&(C.touch1=B,C.taps=0):(C.touch0=B,D=!0,C.taps=1+!!u);u&&(u=clearTimeout(u)),D&&(C.taps<2&&(f=B[0],u=setTimeout(function(){u=null},h)),aa(this),C.start())}}function V(w,...b){if(this.__zooming){var k=R(this,b).event(w),F=w.changedTouches,C=F.length,D,U,$,B;for(Js(w),D=0;D<C;++D)U=F[D],$=Xt(U,this),k.touch0&&k.touch0[2]===U.identifier?k.touch0[0]=$:k.touch1&&k.touch1[2]===U.identifier&&(k.touch1[0]=$);if(U=k.that.__zoom,k.touch1){var W=k.touch0[0],z=k.touch0[1],Y=k.touch1[0],X=k.touch1[1],Z=(Z=Y[0]-W[0])*Z+(Z=Y[1]-W[1])*Z,J=(J=X[0]-z[0])*J+(J=X[1]-z[1])*J;U=g(U,Math.sqrt(Z/J)),$=[(W[0]+Y[0])/2,(W[1]+Y[1])/2],B=[(z[0]+X[0])/2,(z[1]+X[1])/2]}else if(k.touch0)$=k.touch0[0],B=k.touch0[1];else return;k.zoom("touch",n(S(U,$,B),k.extent,i))}}function M(w,...b){if(this.__zooming){var k=R(this,b).event(w),F=w.changedTouches,C=F.length,D,U;for(Cd(w),p&&clearTimeout(p),p=setTimeout(function(){p=null},h),D=0;D<C;++D)U=F[D],k.touch0&&k.touch0[2]===U.identifier?delete k.touch0:k.touch1&&k.touch1[2]===U.identifier&&delete k.touch1;if(k.touch1&&!k.touch0&&(k.touch0=k.touch1,delete k.touch1),k.touch0)k.touch0[1]=this.__zoom.invert(k.touch0[0]);else if(k.end(),k.taps===2&&(U=Xt(U,this),Math.hypot(f[0]-U[0],f[1]-U[1])<v)){var $=jt(this).on("dblclick.zoom");$&&$.apply(this,arguments)}}}return m.wheelDelta=function(w){return arguments.length?(r=typeof w=="function"?w:ca(+w),m):r},m.filter=function(w){return arguments.length?(e=typeof w=="function"?w:ca(!!w),m):e},m.touchable=function(w){return arguments.length?(o=typeof w=="function"?w:ca(!!w),m):o},m.extent=function(w){return arguments.length?(t=typeof w=="function"?w:ca([[+w[0][0],+w[0][1]],[+w[1][0],+w[1][1]]]),m):t},m.scaleExtent=function(w){return arguments.length?(s[0]=+w[0],s[1]=+w[1],m):[s[0],s[1]]},m.translateExtent=function(w){return arguments.length?(i[0][0]=+w[0][0],i[1][0]=+w[1][0],i[0][1]=+w[0][1],i[1][1]=+w[1][1],m):[[i[0][0],i[0][1]],[i[1][0],i[1][1]]]},m.constrain=function(w){return arguments.length?(n=w,m):n},m.duration=function(w){return arguments.length?(l=+w,m):l},m.interpolate=function(w){return arguments.length?(a=w,m):a},m.on=function(){var w=c.on.apply(c,arguments);return w===c?m:w},m.clickDistance=function(w){return arguments.length?(y=(w=+w)*w,m):Math.sqrt(y)},m.tapDistance=function(w){return arguments.length?(v=+w,m):v},m}const ua=O.createContext(null),rO=ua.Provider,En={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.`},RE=En.error001();function de(e,t){const n=O.useContext(ua);if(n===null)throw new Error(RE);return Cg(n,e,t)}const Ie=()=>{const e=O.useContext(ua);if(e===null)throw new Error(RE);return O.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe,destroy:e.destroy}),[e])},oO=e=>e.userSelectionActive?"none":"all";function Zs({position:e,children:t,className:n,style:r,...o}){const s=de(oO),i=`${e}`.split("-");return H.createElement("div",{className:Je(["react-flow__panel",n,...i]),style:{...r,pointerEvents:s},...o},t)}function sO({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:H.createElement(Zs,{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"},H.createElement("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution"},"React Flow"))}const iO=({x:e,y:t,label:n,labelStyle:r={},labelShowBg:o=!0,labelBgStyle:s={},labelBgPadding:i=[2,4],labelBgBorderRadius:l=2,children:a,className:c,...u})=>{const f=O.useRef(null),[p,h]=O.useState({x:0,y:0,width:0,height:0}),E=Je(["react-flow__edge-textwrapper",c]);return O.useEffect(()=>{if(f.current){const y=f.current.getBBox();h({x:y.x,y:y.y,width:y.width,height:y.height})}},[n]),typeof n>"u"||!n?null:H.createElement("g",{transform:`translate(${e-p.width/2} ${t-p.height/2})`,className:E,visibility:p.width?"visible":"hidden",...u},o&&H.createElement("rect",{width:p.width+2*i[0],x:-i[0],y:-i[1],height:p.height+2*i[1],className:"react-flow__edge-textbg",style:s,rx:l,ry:l}),H.createElement("text",{className:"react-flow__edge-text",y:p.height/2,dy:"0.3em",ref:f,style:r},n),a)};var lO=O.memo(iO);const Ld=e=>({width:e.offsetWidth,height:e.offsetHeight}),So=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),bd=(e={x:0,y:0},t)=>({x:So(e.x,t[0][0],t[1][0]),y:So(e.y,t[0][1],t[1][1])}),NE=(e,t,n)=>e<t?So(Math.abs(e-t),1,50)/50:e>n?-So(Math.abs(e-n),1,50)/50:0,wE=(e,t)=>{const n=NE(e.x,35,t.width-35)*20,r=NE(e.y,35,t.height-35)*20;return[n,r]},OE=e=>{var t;return((t=e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},aO=(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)}),Dd=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),cO=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),TE=e=>({...e.positionAbsolute||{x:0,y:0},width:e.width||0,height:e.height||0}),kd=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),r=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*r)},uO=e=>It(e.width)&&It(e.height)&&It(e.x)&&It(e.y),It=e=>!isNaN(e)&&isFinite(e),Ce=Symbol.for("internals"),AE=["Enter"," ","Escape"],dO=(e,t)=>{},fO=e=>"nativeEvent"in e;function Pd(e){var o,s;const t=fO(e)?e.nativeEvent:e,n=((s=(o=t.composedPath)==null?void 0:o.call(t))==null?void 0:s[0])||e.target;return["INPUT","SELECT","TEXTAREA"].includes(n==null?void 0:n.nodeName)||(n==null?void 0:n.hasAttribute("contenteditable"))||!!(n!=null&&n.closest(".nokey"))}const IE=e=>"clientX"in e,zn=(e,t)=>{var s,i;const n=IE(e),r=n?e.clientX:(s=e.touches)==null?void 0:s[0].clientX,o=n?e.clientY:(i=e.touches)==null?void 0:i[0].clientY;return{x:r-((t==null?void 0:t.left)??0),y:o-((t==null?void 0:t.top)??0)}},da=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0},xo=({id:e,path:t,labelX:n,labelY:r,label:o,labelStyle:s,labelShowBg:i,labelBgStyle:l,labelBgPadding:a,labelBgBorderRadius:c,style:u,markerEnd:f,markerStart:p,interactionWidth:h=20})=>H.createElement(H.Fragment,null,H.createElement("path",{id:e,style:u,d:t,fill:"none",className:"react-flow__edge-path",markerEnd:f,markerStart:p}),h&&H.createElement("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:h,className:"react-flow__edge-interaction"}),o&&It(n)&&It(r)?H.createElement(lO,{x:n,y:r,label:o,labelStyle:s,labelShowBg:i,labelBgStyle:l,labelBgPadding:a,labelBgBorderRadius:c}):null);xo.displayName="BaseEdge";function ei(e,t,n){return n===void 0?n:r=>{const o=t().edges.find(s=>s.id===e);o&&n(r,{...o})}}function CE({sourceX:e,sourceY:t,targetX:n,targetY:r}){const o=Math.abs(n-e)/2,s=n<e?n+o:n-o,i=Math.abs(r-t)/2,l=r<t?r+i:r-i;return[s,l,o,i]}function LE({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:o,sourceControlY:s,targetControlX:i,targetControlY:l}){const a=e*.125+o*.375+i*.375+n*.125,c=t*.125+s*.375+l*.375+r*.125,u=Math.abs(a-e),f=Math.abs(c-t);return[a,c,u,f]}var Wn;(function(e){e.Strict="strict",e.Loose="loose"})(Wn||(Wn={}));var Sr;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Sr||(Sr={}));var ti;(function(e){e.Partial="partial",e.Full="full"})(ti||(ti={}));var Gn;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Gn||(Gn={}));var ni;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(ni||(ni={}));var q;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(q||(q={}));function bE({pos:e,x1:t,y1:n,x2:r,y2:o}){return e===q.Left||e===q.Right?[.5*(t+r),n]:[t,.5*(n+o)]}function DE({sourceX:e,sourceY:t,sourcePosition:n=q.Bottom,targetX:r,targetY:o,targetPosition:s=q.Top}){const[i,l]=bE({pos:n,x1:e,y1:t,x2:r,y2:o}),[a,c]=bE({pos:s,x1:r,y1:o,x2:e,y2:t}),[u,f,p,h]=LE({sourceX:e,sourceY:t,targetX:r,targetY:o,sourceControlX:i,sourceControlY:l,targetControlX:a,targetControlY:c});return[`M${e},${t} C${i},${l} ${a},${c} ${r},${o}`,u,f,p,h]}const Md=O.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,sourcePosition:o=q.Bottom,targetPosition:s=q.Top,label:i,labelStyle:l,labelShowBg:a,labelBgStyle:c,labelBgPadding:u,labelBgBorderRadius:f,style:p,markerEnd:h,markerStart:E,interactionWidth:y})=>{const[v,m,g]=DE({sourceX:e,sourceY:t,sourcePosition:o,targetX:n,targetY:r,targetPosition:s});return H.createElement(xo,{path:v,labelX:m,labelY:g,label:i,labelStyle:l,labelShowBg:a,labelBgStyle:c,labelBgPadding:u,labelBgBorderRadius:f,style:p,markerEnd:h,markerStart:E,interactionWidth:y})});Md.displayName="SimpleBezierEdge";const kE={[q.Left]:{x:-1,y:0},[q.Right]:{x:1,y:0},[q.Top]:{x:0,y:-1},[q.Bottom]:{x:0,y:1}},pO=({source:e,sourcePosition:t=q.Bottom,target:n})=>t===q.Left||t===q.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},PE=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function hO({source:e,sourcePosition:t=q.Bottom,target:n,targetPosition:r=q.Top,center:o,offset:s}){const i=kE[t],l=kE[r],a={x:e.x+i.x*s,y:e.y+i.y*s},c={x:n.x+l.x*s,y:n.y+l.y*s},u=pO({source:a,sourcePosition:t,target:c}),f=u.x!==0?"x":"y",p=u[f];let h=[],E,y;const v={x:0,y:0},m={x:0,y:0},[g,S,_,x]=CE({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(i[f]*l[f]===-1){E=o.x||g,y=o.y||S;const T=[{x:E,y:a.y},{x:E,y:c.y}],L=[{x:a.x,y},{x:c.x,y}];i[f]===p?h=f==="x"?T:L:h=f==="x"?L:T}else{const T=[{x:a.x,y:c.y}],L=[{x:c.x,y:a.y}];if(f==="x"?h=i.x===p?L:T:h=i.y===p?T:L,t===r){const M=Math.abs(e[f]-n[f]);if(M<=s){const w=Math.min(s-1,s-M);i[f]===p?v[f]=(a[f]>e[f]?-1:1)*w:m[f]=(c[f]>n[f]?-1:1)*w}}if(t!==r){const M=f==="x"?"y":"x",w=i[f]===l[M],b=a[M]>c[M],k=a[M]<c[M];(i[f]===1&&(!w&&b||w&&k)||i[f]!==1&&(!w&&k||w&&b))&&(h=f==="x"?T:L)}const P={x:a.x+v.x,y:a.y+v.y},I={x:c.x+m.x,y:c.y+m.y},j=Math.max(Math.abs(P.x-h[0].x),Math.abs(I.x-h[0].x)),V=Math.max(Math.abs(P.y-h[0].y),Math.abs(I.y-h[0].y));j>=V?(E=(P.x+I.x)/2,y=h[0].y):(E=h[0].x,y=(P.y+I.y)/2)}return[[e,{x:a.x+v.x,y:a.y+v.y},...h,{x:c.x+m.x,y:c.y+m.y},n],E,y,_,x]}function mO(e,t,n,r){const o=Math.min(PE(e,t)/2,PE(t,n)/2,r),{x:s,y:i}=t;if(e.x===s&&s===n.x||e.y===i&&i===n.y)return`L${s} ${i}`;if(e.y===i){const c=e.x<n.x?-1:1,u=e.y<n.y?1:-1;return`L ${s+o*c},${i}Q ${s},${i} ${s},${i+o*u}`}const l=e.x<n.x?1:-1,a=e.y<n.y?-1:1;return`L ${s},${i+o*a}Q ${s},${i} ${s+o*l},${i}`}function ri({sourceX:e,sourceY:t,sourcePosition:n=q.Bottom,targetX:r,targetY:o,targetPosition:s=q.Top,borderRadius:i=5,centerX:l,centerY:a,offset:c=20}){const[u,f,p,h,E]=hO({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:o},targetPosition:s,center:{x:l,y:a},offset:c});return[u.reduce((v,m,g)=>{let S="";return g>0&&g<u.length-1?S=mO(u[g-1],m,u[g+1],i):S=`${g===0?"M":"L"}${m.x} ${m.y}`,v+=S,v},""),f,p,h,E]}const fa=O.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,label:o,labelStyle:s,labelShowBg:i,labelBgStyle:l,labelBgPadding:a,labelBgBorderRadius:c,style:u,sourcePosition:f=q.Bottom,targetPosition:p=q.Top,markerEnd:h,markerStart:E,pathOptions:y,interactionWidth:v})=>{const[m,g,S]=ri({sourceX:e,sourceY:t,sourcePosition:f,targetX:n,targetY:r,targetPosition:p,borderRadius:y==null?void 0:y.borderRadius,offset:y==null?void 0:y.offset});return H.createElement(xo,{path:m,labelX:g,labelY:S,label:o,labelStyle:s,labelShowBg:i,labelBgStyle:l,labelBgPadding:a,labelBgBorderRadius:c,style:u,markerEnd:h,markerStart:E,interactionWidth:v})});fa.displayName="SmoothStepEdge";const Ud=O.memo(e=>{var t;return H.createElement(fa,{...e,pathOptions:O.useMemo(()=>{var n;return{borderRadius:0,offset:(n=e.pathOptions)==null?void 0:n.offset}},[(t=e.pathOptions)==null?void 0:t.offset])})});Ud.displayName="StepEdge";function gO({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[o,s,i,l]=CE({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,o,s,i,l]}const Fd=O.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,label:o,labelStyle:s,labelShowBg:i,labelBgStyle:l,labelBgPadding:a,labelBgBorderRadius:c,style:u,markerEnd:f,markerStart:p,interactionWidth:h})=>{const[E,y,v]=gO({sourceX:e,sourceY:t,targetX:n,targetY:r});return H.createElement(xo,{path:E,labelX:y,labelY:v,label:o,labelStyle:s,labelShowBg:i,labelBgStyle:l,labelBgPadding:a,labelBgBorderRadius:c,style:u,markerEnd:f,markerStart:p,interactionWidth:h})});Fd.displayName="StraightEdge";function pa(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function ME({pos:e,x1:t,y1:n,x2:r,y2:o,c:s}){switch(e){case q.Left:return[t-pa(t-r,s),n];case q.Right:return[t+pa(r-t,s),n];case q.Top:return[t,n-pa(n-o,s)];case q.Bottom:return[t,n+pa(o-n,s)]}}function UE({sourceX:e,sourceY:t,sourcePosition:n=q.Bottom,targetX:r,targetY:o,targetPosition:s=q.Top,curvature:i=.25}){const[l,a]=ME({pos:n,x1:e,y1:t,x2:r,y2:o,c:i}),[c,u]=ME({pos:s,x1:r,y1:o,x2:e,y2:t,c:i}),[f,p,h,E]=LE({sourceX:e,sourceY:t,targetX:r,targetY:o,sourceControlX:l,sourceControlY:a,targetControlX:c,targetControlY:u});return[`M${e},${t} C${l},${a} ${c},${u} ${r},${o}`,f,p,h,E]}const ha=O.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,sourcePosition:o=q.Bottom,targetPosition:s=q.Top,label:i,labelStyle:l,labelShowBg:a,labelBgStyle:c,labelBgPadding:u,labelBgBorderRadius:f,style:p,markerEnd:h,markerStart:E,pathOptions:y,interactionWidth:v})=>{const[m,g,S]=UE({sourceX:e,sourceY:t,sourcePosition:o,targetX:n,targetY:r,targetPosition:s,curvature:y==null?void 0:y.curvature});return H.createElement(xo,{path:m,labelX:g,labelY:S,label:i,labelStyle:l,labelShowBg:a,labelBgStyle:c,labelBgPadding:u,labelBgBorderRadius:f,style:p,markerEnd:h,markerStart:E,interactionWidth:v})});ha.displayName="BezierEdge";const jd=O.createContext(null),EO=jd.Provider;jd.Consumer;const yO=()=>O.useContext(jd),vO=e=>"id"in e&&"source"in e&&"target"in e,FE=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`reactflow__edge-${e}${t||""}-${n}${r||""}`,Vd=(e,t)=>typeof e>"u"?"":typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`,_O=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),jE=(e,t)=>{if(!e.source||!e.target)return t;let n;return vO(e)?n={...e}:n={...e,id:FE(e)},_O(n,t)?t:t.concat(n)},SO=(e,t,n,r={shouldReplaceId:!0})=>{const{id:o,...s}=e;if(!t.source||!t.target||!n.find(a=>a.id===o))return n;const l={...s,id:r.shouldReplaceId?FE(t):o,source:t.source,target:t.target,sourceHandle:t.sourceHandle,targetHandle:t.targetHandle};return n.filter(a=>a.id!==o).concat(l)},$d=({x:e,y:t},[n,r,o],s,[i,l])=>{const a={x:(e-n)/o,y:(t-r)/o};return s?{x:i*Math.round(a.x/i),y:l*Math.round(a.y/l)}:a},VE=({x:e,y:t},[n,r,o])=>({x:e*o+n,y:t*o+r}),Ro=(e,t=[0,0])=>{if(!e)return{x:0,y:0,positionAbsolute:{x:0,y:0}};const n=(e.width??0)*t[0],r=(e.height??0)*t[1],o={x:e.position.x-n,y:e.position.y-r};return{...o,positionAbsolute:e.positionAbsolute?{x:e.positionAbsolute.x-n,y:e.positionAbsolute.y-r}:o}},Hd=(e,t=[0,0])=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((r,o)=>{const{x:s,y:i}=Ro(o,t).positionAbsolute;return aO(r,Dd({x:s,y:i,width:o.width||0,height:o.height||0}))},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return cO(n)},$E=(e,t,[n,r,o]=[0,0,1],s=!1,i=!1,l=[0,0])=>{const a={x:(t.x-n)/o,y:(t.y-r)/o,width:t.width/o,height:t.height/o},c=[];return e.forEach(u=>{const{width:f,height:p,selectable:h=!0,hidden:E=!1}=u;if(i&&!h||E)return!1;const{positionAbsolute:y}=Ro(u,l),v={x:y.x,y:y.y,width:f||0,height:p||0},m=kd(a,v),g=typeof f>"u"||typeof p>"u"||f===null||p===null,S=s&&m>0,_=(f||0)*(p||0);(g||S||m>=_||u.dragging)&&c.push(u)}),c},HE=(e,t)=>{const n=e.map(r=>r.id);return t.filter(r=>n.includes(r.source)||n.includes(r.target))},BE=(e,t,n,r,o,s=.1)=>{const i=t/(e.width*(1+s)),l=n/(e.height*(1+s)),a=Math.min(i,l),c=So(a,r,o),u=e.x+e.width/2,f=e.y+e.height/2,p=t/2-u*c,h=n/2-f*c;return{x:p,y:h,zoom:c}},xr=(e,t=0)=>e.transition().duration(t);function zE(e,t,n,r){return(t[n]||[]).reduce((o,s)=>{var i,l;return`${e.id}-${s.id}-${n}`!==r&&o.push({id:s.id||null,type:n,nodeId:e.id,x:(((i=e.positionAbsolute)==null?void 0:i.x)??0)+s.x+s.width/2,y:(((l=e.positionAbsolute)==null?void 0:l.y)??0)+s.y+s.height/2}),o},[])}function xO(e,t,n,r,o,s){const{x:i,y:l}=zn(e),c=t.elementsFromPoint(i,l).find(E=>E.classList.contains("react-flow__handle"));if(c){const E=c.getAttribute("data-nodeid");if(E){const y=Bd(void 0,c),v=c.getAttribute("data-handleid"),m=s({nodeId:E,id:v,type:y});if(m){const g=o.find(S=>S.nodeId===E&&S.type===y&&S.id===v);return{handle:{id:v,type:y,nodeId:E,x:(g==null?void 0:g.x)||n.x,y:(g==null?void 0:g.y)||n.y},validHandleResult:m}}}}let u=[],f=1/0;if(o.forEach(E=>{const y=Math.sqrt((E.x-n.x)**2+(E.y-n.y)**2);if(y<=r){const v=s(E);y<=f&&(y<f?u=[{handle:E,validHandleResult:v}]:y===f&&u.push({handle:E,validHandleResult:v}),f=y)}}),!u.length)return{handle:null,validHandleResult:WE()};if(u.length===1)return u[0];const p=u.some(({validHandleResult:E})=>E.isValid),h=u.some(({handle:E})=>E.type==="target");return u.find(({handle:E,validHandleResult:y})=>h?E.type==="target":p?y.isValid:!0)||u[0]}const RO={source:null,target:null,sourceHandle:null,targetHandle:null},WE=()=>({handleDomNode:null,isValid:!1,connection:RO,endHandle:null});function GE(e,t,n,r,o,s,i){const l=o==="target",a=i.querySelector(`.react-flow__handle[data-id="${e==null?void 0:e.nodeId}-${e==null?void 0:e.id}-${e==null?void 0:e.type}"]`),c={...WE(),handleDomNode:a};if(a){const u=Bd(void 0,a),f=a.getAttribute("data-nodeid"),p=a.getAttribute("data-handleid"),h=a.classList.contains("connectable"),E=a.classList.contains("connectableend"),y={source:l?f:n,sourceHandle:l?p:r,target:l?n:f,targetHandle:l?r:p};c.connection=y,h&&E&&(t===Wn.Strict?l&&u==="source"||!l&&u==="target":f!==n||p!==r)&&(c.endHandle={nodeId:f,handleId:p,type:u},c.isValid=s(y))}return c}function NO({nodes:e,nodeId:t,handleId:n,handleType:r}){return e.reduce((o,s)=>{if(s[Ce]){const{handleBounds:i}=s[Ce];let l=[],a=[];i&&(l=zE(s,i,"source",`${t}-${n}-${r}`),a=zE(s,i,"target",`${t}-${n}-${r}`)),o.push(...l,...a)}return o},[])}function Bd(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function zd(e){e==null||e.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function wO(e,t){let n=null;return t?n="valid":e&&!t&&(n="invalid"),n}function YE({event:e,handleId:t,nodeId:n,onConnect:r,isTarget:o,getState:s,setState:i,isValidConnection:l,edgeUpdaterType:a,onEdgeUpdateEnd:c}){const u=OE(e.target),{connectionMode:f,domNode:p,autoPanOnConnect:h,connectionRadius:E,onConnectStart:y,panBy:v,getNodes:m,cancelConnection:g}=s();let S=0,_;const{x,y:R}=zn(e),T=u==null?void 0:u.elementFromPoint(x,R),L=Bd(a,T),P=p==null?void 0:p.getBoundingClientRect();if(!P||!L)return;let I,j=zn(e,P),V=!1,M=null,w=!1,b=null;const k=NO({nodes:m(),nodeId:n,handleId:t,handleType:L}),F=()=>{if(!h)return;const[U,$]=wE(j,P);v({x:U,y:$}),S=requestAnimationFrame(F)};i({connectionPosition:j,connectionStatus:null,connectionNodeId:n,connectionHandleId:t,connectionHandleType:L,connectionStartHandle:{nodeId:n,handleId:t,type:L},connectionEndHandle:null}),y==null||y(e,{nodeId:n,handleId:t,handleType:L});function C(U){const{transform:$}=s();j=zn(U,P);const{handle:B,validHandleResult:W}=xO(U,u,$d(j,$,!1,[1,1]),E,k,z=>GE(z,f,n,t,o?"target":"source",l,u));if(_=B,V||(F(),V=!0),b=W.handleDomNode,M=W.connection,w=W.isValid,i({connectionPosition:_&&w?VE({x:_.x,y:_.y},$):j,connectionStatus:wO(!!_,w),connectionEndHandle:W.endHandle}),!_&&!w&&!b)return zd(I);M.source!==M.target&&b&&(zd(I),I=b,b.classList.add("connecting","react-flow__handle-connecting"),b.classList.toggle("valid",w),b.classList.toggle("react-flow__handle-valid",w))}function D(U){var $,B;(_||b)&&M&&w&&(r==null||r(M)),(B=($=s()).onConnectEnd)==null||B.call($,U),a&&(c==null||c(U)),zd(I),g(),cancelAnimationFrame(S),V=!1,w=!1,M=null,b=null,u.removeEventListener("mousemove",C),u.removeEventListener("mouseup",D),u.removeEventListener("touchmove",C),u.removeEventListener("touchend",D)}u.addEventListener("mousemove",C),u.addEventListener("mouseup",D),u.addEventListener("touchmove",C),u.addEventListener("touchend",D)}const KE=()=>!0,OO=e=>({connectionStartHandle:e.connectionStartHandle,connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName}),TO=(e,t,n)=>r=>{const{connectionStartHandle:o,connectionEndHandle:s,connectionClickStartHandle:i}=r;return{connecting:(o==null?void 0:o.nodeId)===e&&(o==null?void 0:o.handleId)===t&&(o==null?void 0:o.type)===n||(s==null?void 0:s.nodeId)===e&&(s==null?void 0:s.handleId)===t&&(s==null?void 0:s.type)===n,clickConnecting:(i==null?void 0:i.nodeId)===e&&(i==null?void 0:i.handleId)===t&&(i==null?void 0:i.type)===n}},XE=O.forwardRef(({type:e="source",position:t=q.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:o=!0,isConnectableEnd:s=!0,id:i,onConnect:l,children:a,className:c,onMouseDown:u,onTouchStart:f,...p},h)=>{var P,I;const E=i||null,y=e==="target",v=Ie(),m=yO(),{connectOnClick:g,noPanClassName:S}=de(OO,Ge),{connecting:_,clickConnecting:x}=de(TO(m,E,e),Ge);m||(I=(P=v.getState()).onError)==null||I.call(P,"010",En.error010());const R=j=>{const{defaultEdgeOptions:V,onConnect:M,hasDefaultEdges:w}=v.getState(),b={...V,...j};if(w){const{edges:k,setEdges:F}=v.getState();F(jE(b,k))}M==null||M(b),l==null||l(b)},T=j=>{if(!m)return;const V=IE(j);o&&(V&&j.button===0||!V)&&YE({event:j,handleId:E,nodeId:m,onConnect:R,isTarget:y,getState:v.getState,setState:v.setState,isValidConnection:n||v.getState().isValidConnection||KE}),V?u==null||u(j):f==null||f(j)},L=j=>{const{onClickConnectStart:V,onClickConnectEnd:M,connectionClickStartHandle:w,connectionMode:b,isValidConnection:k}=v.getState();if(!m||!w&&!o)return;if(!w){V==null||V(j,{nodeId:m,handleId:E,handleType:e}),v.setState({connectionClickStartHandle:{nodeId:m,type:e,handleId:E}});return}const F=OE(j.target),C=n||k||KE,{connection:D,isValid:U}=GE({nodeId:m,id:E,type:e},b,w.nodeId,w.handleId||null,w.type,C,F);U&&R(D),M==null||M(j),v.setState({connectionClickStartHandle:null})};return H.createElement("div",{"data-handleid":E,"data-nodeid":m,"data-handlepos":t,"data-id":`${m}-${E}-${e}`,className:Je(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",S,c,{source:!y,target:y,connectable:r,connectablestart:o,connectableend:s,connecting:x,connectionindicator:r&&(o&&!_||s&&_)}]),onMouseDown:T,onTouchStart:T,onClick:g?L:void 0,ref:h,...p},a)});XE.displayName="Handle";var No=O.memo(XE);const QE=({data:e,isConnectable:t,targetPosition:n=q.Top,sourcePosition:r=q.Bottom})=>H.createElement(H.Fragment,null,H.createElement(No,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,H.createElement(No,{type:"source",position:r,isConnectable:t}));QE.displayName="DefaultNode";var Wd=O.memo(QE);const qE=({data:e,isConnectable:t,sourcePosition:n=q.Bottom})=>H.createElement(H.Fragment,null,e==null?void 0:e.label,H.createElement(No,{type:"source",position:n,isConnectable:t}));qE.displayName="InputNode";var JE=O.memo(qE);const ZE=({data:e,isConnectable:t,targetPosition:n=q.Top})=>H.createElement(H.Fragment,null,H.createElement(No,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label);ZE.displayName="OutputNode";var e0=O.memo(ZE);const Gd=()=>null;Gd.displayName="GroupNode";const AO=e=>({selectedNodes:e.getNodes().filter(t=>t.selected),selectedEdges:e.edges.filter(t=>t.selected)}),ma=e=>e.id;function IO(e,t){return Ge(e.selectedNodes.map(ma),t.selectedNodes.map(ma))&&Ge(e.selectedEdges.map(ma),t.selectedEdges.map(ma))}const t0=O.memo(({onSelectionChange:e})=>{const t=Ie(),{selectedNodes:n,selectedEdges:r}=de(AO,IO);return O.useEffect(()=>{const o={nodes:n,edges:r};e==null||e(o),t.getState().onSelectionChange.forEach(s=>s(o))},[n,r,e]),null});t0.displayName="SelectionListener";const CO=e=>!!e.onSelectionChange;function LO({onSelectionChange:e}){const t=de(CO);return e||t?H.createElement(t0,{onSelectionChange:e}):null}const bO=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 wo(e,t){O.useEffect(()=>{typeof e<"u"&&t(e)},[e])}function ne(e,t,n){O.useEffect(()=>{typeof t<"u"&&n({[e]:t})},[t])}const DO=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:o,onConnectStart:s,onConnectEnd:i,onClickConnectStart:l,onClickConnectEnd:a,nodesDraggable:c,nodesConnectable:u,nodesFocusable:f,edgesFocusable:p,edgesUpdatable:h,elevateNodesOnSelect:E,minZoom:y,maxZoom:v,nodeExtent:m,onNodesChange:g,onEdgesChange:S,elementsSelectable:_,connectionMode:x,snapGrid:R,snapToGrid:T,translateExtent:L,connectOnClick:P,defaultEdgeOptions:I,fitView:j,fitViewOptions:V,onNodesDelete:M,onEdgesDelete:w,onNodeDrag:b,onNodeDragStart:k,onNodeDragStop:F,onSelectionDrag:C,onSelectionDragStart:D,onSelectionDragStop:U,noPanClassName:$,nodeOrigin:B,rfId:W,autoPanOnConnect:z,autoPanOnNodeDrag:Y,onError:X,connectionRadius:Z,isValidConnection:J,nodeDragThreshold:te})=>{const{setNodes:ce,setEdges:Re,setDefaultNodesAndEdges:Me,setMinZoom:tn,setMaxZoom:Le,setTranslateExtent:ye,setNodeExtent:ut,reset:St}=de(bO,Ge),ee=Ie();return O.useEffect(()=>{const Cr=r==null?void 0:r.map(Lr=>({...Lr,...I}));return Me(n,Cr),()=>{St()}},[]),ne("defaultEdgeOptions",I,ee.setState),ne("connectionMode",x,ee.setState),ne("onConnect",o,ee.setState),ne("onConnectStart",s,ee.setState),ne("onConnectEnd",i,ee.setState),ne("onClickConnectStart",l,ee.setState),ne("onClickConnectEnd",a,ee.setState),ne("nodesDraggable",c,ee.setState),ne("nodesConnectable",u,ee.setState),ne("nodesFocusable",f,ee.setState),ne("edgesFocusable",p,ee.setState),ne("edgesUpdatable",h,ee.setState),ne("elementsSelectable",_,ee.setState),ne("elevateNodesOnSelect",E,ee.setState),ne("snapToGrid",T,ee.setState),ne("snapGrid",R,ee.setState),ne("onNodesChange",g,ee.setState),ne("onEdgesChange",S,ee.setState),ne("connectOnClick",P,ee.setState),ne("fitViewOnInit",j,ee.setState),ne("fitViewOnInitOptions",V,ee.setState),ne("onNodesDelete",M,ee.setState),ne("onEdgesDelete",w,ee.setState),ne("onNodeDrag",b,ee.setState),ne("onNodeDragStart",k,ee.setState),ne("onNodeDragStop",F,ee.setState),ne("onSelectionDrag",C,ee.setState),ne("onSelectionDragStart",D,ee.setState),ne("onSelectionDragStop",U,ee.setState),ne("noPanClassName",$,ee.setState),ne("nodeOrigin",B,ee.setState),ne("rfId",W,ee.setState),ne("autoPanOnConnect",z,ee.setState),ne("autoPanOnNodeDrag",Y,ee.setState),ne("onError",X,ee.setState),ne("connectionRadius",Z,ee.setState),ne("isValidConnection",J,ee.setState),ne("nodeDragThreshold",te,ee.setState),wo(e,ce),wo(t,Re),wo(y,tn),wo(v,Le),wo(L,ye),wo(m,ut),null},n0={display:"none"},kO={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},r0="react-flow__node-desc",o0="react-flow__edge-desc",PO="react-flow__aria-live",MO=e=>e.ariaLiveMessage;function UO({rfId:e}){const t=de(MO);return H.createElement("div",{id:`${PO}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:kO},t)}function FO({rfId:e,disableKeyboardA11y:t}){return H.createElement(H.Fragment,null,H.createElement("div",{id:`${r0}-${e}`,style:n0},"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."," "),H.createElement("div",{id:`${o0}-${e}`,style:n0},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!t&&H.createElement(UO,{rfId:e}))}var Oo=(e=null,t={actInsideInputWithModifier:!0})=>{const[n,r]=O.useState(!1),o=O.useRef(!1),s=O.useRef(new Set([])),[i,l]=O.useMemo(()=>{if(e!==null){const c=(Array.isArray(e)?e:[e]).filter(f=>typeof f=="string").map(f=>f.split("+")),u=c.reduce((f,p)=>f.concat(...p),[]);return[c,u]}return[[],[]]},[e]);return O.useEffect(()=>{const a=typeof document<"u"?document:null,c=(t==null?void 0:t.target)||a;if(e!==null){const u=h=>{if(o.current=h.ctrlKey||h.metaKey||h.shiftKey,(!o.current||o.current&&!t.actInsideInputWithModifier)&&Pd(h))return!1;const y=i0(h.code,l);s.current.add(h[y]),s0(i,s.current,!1)&&(h.preventDefault(),r(!0))},f=h=>{if((!o.current||o.current&&!t.actInsideInputWithModifier)&&Pd(h))return!1;const y=i0(h.code,l);s0(i,s.current,!0)?(r(!1),s.current.clear()):s.current.delete(h[y]),h.key==="Meta"&&s.current.clear(),o.current=!1},p=()=>{s.current.clear(),r(!1)};return c==null||c.addEventListener("keydown",u),c==null||c.addEventListener("keyup",f),window.addEventListener("blur",p),()=>{c==null||c.removeEventListener("keydown",u),c==null||c.removeEventListener("keyup",f),window.removeEventListener("blur",p)}}},[e,r]),n};function s0(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(o=>t.has(o)))}function i0(e,t){return t.includes(e)?"code":"key"}function l0(e,t,n,r){var i,l;if(!e.parentNode)return n;const o=t.get(e.parentNode),s=Ro(o,r);return l0(o,t,{x:(n.x??0)+s.x,y:(n.y??0)+s.y,z:(((i=o[Ce])==null?void 0:i.z)??0)>(n.z??0)?((l=o[Ce])==null?void 0:l.z)??0:n.z??0},r)}function a0(e,t,n){e.forEach(r=>{var o;if(r.parentNode&&!e.has(r.parentNode))throw new Error(`Parent node ${r.parentNode} not found`);if(r.parentNode||n!=null&&n[r.id]){const{x:s,y:i,z:l}=l0(r,e,{...r.position,z:((o=r[Ce])==null?void 0:o.z)??0},t);r.positionAbsolute={x:s,y:i},r[Ce].z=l,n!=null&&n[r.id]&&(r[Ce].isParent=!0)}})}function Yd(e,t,n,r){const o=new Map,s={},i=r?1e3:0;return e.forEach(l=>{var f;const a=(It(l.zIndex)?l.zIndex:0)+(l.selected?i:0),c=t.get(l.id),u={width:c==null?void 0:c.width,height:c==null?void 0:c.height,...l,positionAbsolute:{x:l.position.x,y:l.position.y}};l.parentNode&&(u.parentNode=l.parentNode,s[l.parentNode]=!0),Object.defineProperty(u,Ce,{enumerable:!1,value:{handleBounds:(f=c==null?void 0:c[Ce])==null?void 0:f.handleBounds,z:a}}),o.set(l.id,u)}),a0(o,n,s),o}function c0(e,t={}){const{getNodes:n,width:r,height:o,minZoom:s,maxZoom:i,d3Zoom:l,d3Selection:a,fitViewOnInitDone:c,fitViewOnInit:u,nodeOrigin:f}=e(),p=t.initial&&!c&&u;if(l&&a&&(p||!t.initial)){const E=n().filter(v=>{var g;const m=t.includeHiddenNodes?v.width&&v.height:!v.hidden;return(g=t.nodes)!=null&&g.length?m&&t.nodes.some(S=>S.id===v.id):m}),y=E.every(v=>v.width&&v.height);if(E.length>0&&y){const v=Hd(E,f),{x:m,y:g,zoom:S}=BE(v,r,o,t.minZoom??s,t.maxZoom??i,t.padding??.1),_=Bn.translate(m,g).scale(S);return typeof t.duration=="number"&&t.duration>0?l.transform(xr(a,t.duration),_):l.transform(a,_),!0}}return!1}function jO(e,t){return e.forEach(n=>{const r=t.get(n.id);r&&t.set(r.id,{...r,[Ce]:r[Ce],selected:n.selected})}),new Map(t)}function VO(e,t){return t.map(n=>{const r=e.find(o=>o.id===n.id);return r&&(n.selected=r.selected),n})}function ga({changedNodes:e,changedEdges:t,get:n,set:r}){const{nodeInternals:o,edges:s,onNodesChange:i,onEdgesChange:l,hasDefaultNodes:a,hasDefaultEdges:c}=n();e!=null&&e.length&&(a&&r({nodeInternals:jO(e,o)}),i==null||i(e)),t!=null&&t.length&&(c&&r({edges:VO(t,s)}),l==null||l(t))}const To=()=>{},$O={zoomIn:To,zoomOut:To,zoomTo:To,getZoom:()=>1,setViewport:To,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:To,fitBounds:To,project:e=>e,screenToFlowPosition:e=>e,flowToScreenPosition:e=>e,viewportInitialized:!1},HO=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection}),BO=()=>{const e=Ie(),{d3Zoom:t,d3Selection:n}=de(HO,Ge);return O.useMemo(()=>n&&t?{zoomIn:o=>t.scaleBy(xr(n,o==null?void 0:o.duration),1.2),zoomOut:o=>t.scaleBy(xr(n,o==null?void 0:o.duration),1/1.2),zoomTo:(o,s)=>t.scaleTo(xr(n,s==null?void 0:s.duration),o),getZoom:()=>e.getState().transform[2],setViewport:(o,s)=>{const[i,l,a]=e.getState().transform,c=Bn.translate(o.x??i,o.y??l).scale(o.zoom??a);t.transform(xr(n,s==null?void 0:s.duration),c)},getViewport:()=>{const[o,s,i]=e.getState().transform;return{x:o,y:s,zoom:i}},fitView:o=>c0(e.getState,o),setCenter:(o,s,i)=>{const{width:l,height:a,maxZoom:c}=e.getState(),u=typeof(i==null?void 0:i.zoom)<"u"?i.zoom:c,f=l/2-o*u,p=a/2-s*u,h=Bn.translate(f,p).scale(u);t.transform(xr(n,i==null?void 0:i.duration),h)},fitBounds:(o,s)=>{const{width:i,height:l,minZoom:a,maxZoom:c}=e.getState(),{x:u,y:f,zoom:p}=BE(o,i,l,a,c,(s==null?void 0:s.padding)??.1),h=Bn.translate(u,f).scale(p);t.transform(xr(n,s==null?void 0:s.duration),h)},project:o=>{const{transform:s,snapToGrid:i,snapGrid:l}=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"),$d(o,s,i,l)},screenToFlowPosition:o=>{const{transform:s,snapToGrid:i,snapGrid:l,domNode:a}=e.getState();if(!a)return o;const{x:c,y:u}=a.getBoundingClientRect(),f={x:o.x-c,y:o.y-u};return $d(f,s,i,l)},flowToScreenPosition:o=>{const{transform:s,domNode:i}=e.getState();if(!i)return o;const{x:l,y:a}=i.getBoundingClientRect(),c=VE(o,s);return{x:c.x+l,y:c.y+a}},viewportInitialized:!0}:$O,[t,n])};function Kd(){const e=BO(),t=Ie(),n=O.useCallback(()=>t.getState().getNodes().map(y=>({...y})),[]),r=O.useCallback(y=>t.getState().nodeInternals.get(y),[]),o=O.useCallback(()=>{const{edges:y=[]}=t.getState();return y.map(v=>({...v}))},[]),s=O.useCallback(y=>{const{edges:v=[]}=t.getState();return v.find(m=>m.id===y)},[]),i=O.useCallback(y=>{const{getNodes:v,setNodes:m,hasDefaultNodes:g,onNodesChange:S}=t.getState(),_=v(),x=typeof y=="function"?y(_):y;if(g)m(x);else if(S){const R=x.length===0?_.map(T=>({type:"remove",id:T.id})):x.map(T=>({item:T,type:"reset"}));S(R)}},[]),l=O.useCallback(y=>{const{edges:v=[],setEdges:m,hasDefaultEdges:g,onEdgesChange:S}=t.getState(),_=typeof y=="function"?y(v):y;if(g)m(_);else if(S){const x=_.length===0?v.map(R=>({type:"remove",id:R.id})):_.map(R=>({item:R,type:"reset"}));S(x)}},[]),a=O.useCallback(y=>{const v=Array.isArray(y)?y:[y],{getNodes:m,setNodes:g,hasDefaultNodes:S,onNodesChange:_}=t.getState();if(S){const R=[...m(),...v];g(R)}else if(_){const x=v.map(R=>({item:R,type:"add"}));_(x)}},[]),c=O.useCallback(y=>{const v=Array.isArray(y)?y:[y],{edges:m=[],setEdges:g,hasDefaultEdges:S,onEdgesChange:_}=t.getState();if(S)g([...m,...v]);else if(_){const x=v.map(R=>({item:R,type:"add"}));_(x)}},[]),u=O.useCallback(()=>{const{getNodes:y,edges:v=[],transform:m}=t.getState(),[g,S,_]=m;return{nodes:y().map(x=>({...x})),edges:v.map(x=>({...x})),viewport:{x:g,y:S,zoom:_}}},[]),f=O.useCallback(({nodes:y,edges:v})=>{const{nodeInternals:m,getNodes:g,edges:S,hasDefaultNodes:_,hasDefaultEdges:x,onNodesDelete:R,onEdgesDelete:T,onNodesChange:L,onEdgesChange:P}=t.getState(),I=(y||[]).map(b=>b.id),j=(v||[]).map(b=>b.id),V=g().reduce((b,k)=>{const F=!I.includes(k.id)&&k.parentNode&&b.find(D=>D.id===k.parentNode);return(typeof k.deletable=="boolean"?k.deletable:!0)&&(I.includes(k.id)||F)&&b.push(k),b},[]),M=S.filter(b=>typeof b.deletable=="boolean"?b.deletable:!0),w=M.filter(b=>j.includes(b.id));if(V||w){const b=HE(V,M),k=[...w,...b],F=k.reduce((C,D)=>(C.includes(D.id)||C.push(D.id),C),[]);if((x||_)&&(x&&t.setState({edges:S.filter(C=>!F.includes(C.id))}),_&&(V.forEach(C=>{m.delete(C.id)}),t.setState({nodeInternals:new Map(m)}))),F.length>0&&(T==null||T(k),P&&P(F.map(C=>({id:C,type:"remove"})))),V.length>0&&(R==null||R(V),L)){const C=V.map(D=>({id:D.id,type:"remove"}));L(C)}}},[]),p=O.useCallback(y=>{const v=uO(y),m=v?null:t.getState().nodeInternals.get(y.id);return[v?y:TE(m),m,v]},[]),h=O.useCallback((y,v=!0,m)=>{const[g,S,_]=p(y);return g?(m||t.getState().getNodes()).filter(x=>{if(!_&&(x.id===S.id||!x.positionAbsolute))return!1;const R=TE(x),T=kd(R,g);return v&&T>0||T>=g.width*g.height}):[]},[]),E=O.useCallback((y,v,m=!0)=>{const[g]=p(y);if(!g)return!1;const S=kd(g,v);return m&&S>0||S>=g.width*g.height},[]);return O.useMemo(()=>({...e,getNodes:n,getNode:r,getEdges:o,getEdge:s,setNodes:i,setEdges:l,addNodes:a,addEdges:c,toObject:u,deleteElements:f,getIntersectingNodes:h,isNodeIntersecting:E}),[e,n,r,o,s,i,l,a,c,u,f,h,E])}const zO={actInsideInputWithModifier:!1};var WO=({deleteKeyCode:e,multiSelectionKeyCode:t})=>{const n=Ie(),{deleteElements:r}=Kd(),o=Oo(e,zO),s=Oo(t);O.useEffect(()=>{if(o){const{edges:i,getNodes:l}=n.getState(),a=l().filter(u=>u.selected),c=i.filter(u=>u.selected);r({nodes:a,edges:c}),n.setState({nodesSelectionActive:!1})}},[o]),O.useEffect(()=>{n.setState({multiSelectionActive:s})},[s])};function GO(e){const t=Ie();O.useEffect(()=>{let n;const r=()=>{var s,i;if(!e.current)return;const o=Ld(e.current);(o.height===0||o.width===0)&&((i=(s=t.getState()).onError)==null||i.call(s,"004",En.error004())),t.setState({width:o.width||500,height:o.height||500})};return r(),window.addEventListener("resize",r),e.current&&(n=new ResizeObserver(()=>r()),n.observe(e.current)),()=>{window.removeEventListener("resize",r),n&&e.current&&n.unobserve(e.current)}},[])}const Xd={position:"absolute",width:"100%",height:"100%",top:0,left:0},YO=(e,t)=>e.x!==t.x||e.y!==t.y||e.zoom!==t.k,Ea=e=>({x:e.x,y:e.y,zoom:e.k}),Ao=(e,t)=>e.target.closest(`.${t}`),u0=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),d0=e=>{const t=e.ctrlKey&&da()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t},KO=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection,d3ZoomHandler:e.d3ZoomHandler,userSelectionActive:e.userSelectionActive}),XO=({onMove:e,onMoveStart:t,onMoveEnd:n,onPaneContextMenu:r,zoomOnScroll:o=!0,zoomOnPinch:s=!0,panOnScroll:i=!1,panOnScrollSpeed:l=.5,panOnScrollMode:a=Sr.Free,zoomOnDoubleClick:c=!0,elementsSelectable:u,panOnDrag:f=!0,defaultViewport:p,translateExtent:h,minZoom:E,maxZoom:y,zoomActivationKeyCode:v,preventScrolling:m=!0,children:g,noWheelClassName:S,noPanClassName:_})=>{const x=O.useRef(),R=Ie(),T=O.useRef(!1),L=O.useRef(!1),P=O.useRef(null),I=O.useRef({x:0,y:0,zoom:0}),{d3Zoom:j,d3Selection:V,d3ZoomHandler:M,userSelectionActive:w}=de(KO,Ge),b=Oo(v),k=O.useRef(0),F=O.useRef(!1),C=O.useRef();return GO(P),O.useEffect(()=>{if(P.current){const D=P.current.getBoundingClientRect(),U=nO().scaleExtent([E,y]).translateExtent(h),$=jt(P.current).call(U),B=Bn.translate(p.x,p.y).scale(So(p.zoom,E,y)),W=[[0,0],[D.width,D.height]],z=U.constrain()(B,W,h);U.transform($,z),U.wheelDelta(d0),R.setState({d3Zoom:U,d3Selection:$,d3ZoomHandler:$.on("wheel.zoom"),transform:[z.x,z.y,z.k],domNode:P.current.closest(".react-flow")})}},[]),O.useEffect(()=>{V&&j&&(i&&!b&&!w?V.on("wheel.zoom",D=>{if(Ao(D,S))return!1;D.preventDefault(),D.stopImmediatePropagation();const U=V.property("__zoom").k||1,$=da();if(D.ctrlKey&&s&&$){const te=Xt(D),ce=d0(D),Re=U*Math.pow(2,ce);j.scaleTo(V,Re,te,D);return}const B=D.deltaMode===1?20:1;let W=a===Sr.Vertical?0:D.deltaX*B,z=a===Sr.Horizontal?0:D.deltaY*B;!$&&D.shiftKey&&a!==Sr.Vertical&&(W=D.deltaY*B,z=0),j.translateBy(V,-(W/U)*l,-(z/U)*l,{internal:!0});const Y=Ea(V.property("__zoom")),{onViewportChangeStart:X,onViewportChange:Z,onViewportChangeEnd:J}=R.getState();clearTimeout(C.current),F.current||(F.current=!0,t==null||t(D,Y),X==null||X(Y)),F.current&&(e==null||e(D,Y),Z==null||Z(Y),C.current=setTimeout(()=>{n==null||n(D,Y),J==null||J(Y),F.current=!1},150))},{passive:!1}):typeof M<"u"&&V.on("wheel.zoom",function(D,U){if(!m||Ao(D,S))return null;D.preventDefault(),M.call(this,D,U)},{passive:!1}))},[w,i,a,V,j,M,b,s,m,S,t,e,n]),O.useEffect(()=>{j&&j.on("start",D=>{var B,W;if(!D.sourceEvent||D.sourceEvent.internal)return null;k.current=(B=D.sourceEvent)==null?void 0:B.button;const{onViewportChangeStart:U}=R.getState(),$=Ea(D.transform);T.current=!0,I.current=$,((W=D.sourceEvent)==null?void 0:W.type)==="mousedown"&&R.setState({paneDragging:!0}),U==null||U($),t==null||t(D.sourceEvent,$)})},[j,t]),O.useEffect(()=>{j&&(w&&!T.current?j.on("zoom",null):w||j.on("zoom",D=>{var $;const{onViewportChange:U}=R.getState();if(R.setState({transform:[D.transform.x,D.transform.y,D.transform.k]}),L.current=!!(r&&u0(f,k.current??0)),(e||U)&&!(($=D.sourceEvent)!=null&&$.internal)){const B=Ea(D.transform);U==null||U(B),e==null||e(D.sourceEvent,B)}}))},[w,j,e,f,r]),O.useEffect(()=>{j&&j.on("end",D=>{if(!D.sourceEvent||D.sourceEvent.internal)return null;const{onViewportChangeEnd:U}=R.getState();if(T.current=!1,R.setState({paneDragging:!1}),r&&u0(f,k.current??0)&&!L.current&&r(D.sourceEvent),L.current=!1,(n||U)&&YO(I.current,D.transform)){const $=Ea(D.transform);I.current=$,clearTimeout(x.current),x.current=setTimeout(()=>{U==null||U($),n==null||n(D.sourceEvent,$)},i?150:0)}})},[j,i,f,n,r]),O.useEffect(()=>{j&&j.filter(D=>{const U=b||o,$=s&&D.ctrlKey;if((f===!0||Array.isArray(f)&&f.includes(1))&&D.button===1&&D.type==="mousedown"&&(Ao(D,"react-flow__node")||Ao(D,"react-flow__edge")))return!0;if(!f&&!U&&!i&&!c&&!s||w||!c&&D.type==="dblclick"||Ao(D,S)&&D.type==="wheel"||Ao(D,_)&&(D.type!=="wheel"||i&&D.type==="wheel"&&!b)||!s&&D.ctrlKey&&D.type==="wheel"||!U&&!i&&!$&&D.type==="wheel"||!f&&(D.type==="mousedown"||D.type==="touchstart")||Array.isArray(f)&&!f.includes(D.button)&&(D.type==="mousedown"||D.type==="touchstart"))return!1;const B=Array.isArray(f)&&f.includes(D.button)||!D.button||D.button<=1;return(!D.ctrlKey||D.type==="wheel")&&B})},[w,j,o,s,i,c,f,u,b]),H.createElement("div",{className:"react-flow__renderer",ref:P,style:Xd},g)},QO=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function qO(){const{userSelectionActive:e,userSelectionRect:t}=de(QO,Ge);return e&&t?H.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 f0(e,t){const n=e.find(r=>r.id===t.parentNode);if(n){const r=t.position.x+t.width-n.width,o=t.position.y+t.height-n.height;if(r>0||o>0||t.position.x<0||t.position.y<0){if(n.style={...n.style},n.style.width=n.style.width??n.width,n.style.height=n.style.height??n.height,r>0&&(n.style.width+=r),o>0&&(n.style.height+=o),t.position.x<0){const s=Math.abs(t.position.x);n.position.x=n.position.x-s,n.style.width+=s,t.position.x=0}if(t.position.y<0){const s=Math.abs(t.position.y);n.position.y=n.position.y-s,n.style.height+=s,t.position.y=0}n.width=n.style.width,n.height=n.style.height}}}function p0(e,t){if(e.some(r=>r.type==="reset"))return e.filter(r=>r.type==="reset").map(r=>r.item);const n=e.filter(r=>r.type==="add").map(r=>r.item);return t.reduce((r,o)=>{const s=e.filter(l=>l.id===o.id);if(s.length===0)return r.push(o),r;const i={...o};for(const l of s)if(l)switch(l.type){case"select":{i.selected=l.selected;break}case"position":{typeof l.position<"u"&&(i.position=l.position),typeof l.positionAbsolute<"u"&&(i.positionAbsolute=l.positionAbsolute),typeof l.dragging<"u"&&(i.dragging=l.dragging),i.expandParent&&f0(r,i);break}case"dimensions":{typeof l.dimensions<"u"&&(i.width=l.dimensions.width,i.height=l.dimensions.height),typeof l.updateStyle<"u"&&(i.style={...i.style||{},...l.dimensions}),typeof l.resizing=="boolean"&&(i.resizing=l.resizing),i.expandParent&&f0(r,i);break}case"remove":return r}return r.push(i),r},n)}function h0(e,t){return p0(e,t)}function JO(e,t){return p0(e,t)}const Yn=(e,t)=>({id:e,type:"select",selected:t});function Io(e,t){return e.reduce((n,r)=>{const o=t.includes(r.id);return!r.selected&&o?(r.selected=!0,n.push(Yn(r.id,!0))):r.selected&&!o&&(r.selected=!1,n.push(Yn(r.id,!1))),n},[])}const Qd=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},ZO=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging}),m0=O.memo(({isSelecting:e,selectionMode:t=ti.Full,panOnDrag:n,onSelectionStart:r,onSelectionEnd:o,onPaneClick:s,onPaneContextMenu:i,onPaneScroll:l,onPaneMouseEnter:a,onPaneMouseMove:c,onPaneMouseLeave:u,children:f})=>{const p=O.useRef(null),h=Ie(),E=O.useRef(0),y=O.useRef(0),v=O.useRef(),{userSelectionActive:m,elementsSelectable:g,dragging:S}=de(ZO,Ge),_=()=>{h.setState({userSelectionActive:!1,userSelectionRect:null}),E.current=0,y.current=0},x=M=>{s==null||s(M),h.getState().resetSelectedElements(),h.setState({nodesSelectionActive:!1})},R=M=>{if(Array.isArray(n)&&(n!=null&&n.includes(2))){M.preventDefault();return}i==null||i(M)},T=l?M=>l(M):void 0,L=M=>{const{resetSelectedElements:w,domNode:b}=h.getState();if(v.current=b==null?void 0:b.getBoundingClientRect(),!g||!e||M.button!==0||M.target!==p.current||!v.current)return;const{x:k,y:F}=zn(M,v.current);w(),h.setState({userSelectionRect:{width:0,height:0,startX:k,startY:F,x:k,y:F}}),r==null||r(M)},P=M=>{const{userSelectionRect:w,nodeInternals:b,edges:k,transform:F,onNodesChange:C,onEdgesChange:D,nodeOrigin:U,getNodes:$}=h.getState();if(!e||!v.current||!w)return;h.setState({userSelectionActive:!0,nodesSelectionActive:!1});const B=zn(M,v.current),W=w.startX??0,z=w.startY??0,Y={...w,x:B.x<W?B.x:W,y:B.y<z?B.y:z,width:Math.abs(B.x-W),height:Math.abs(B.y-z)},X=$(),Z=$E(b,Y,F,t===ti.Partial,!0,U),J=HE(Z,k).map(ce=>ce.id),te=Z.map(ce=>ce.id);if(E.current!==te.length){E.current=te.length;const ce=Io(X,te);ce.length&&(C==null||C(ce))}if(y.current!==J.length){y.current=J.length;const ce=Io(k,J);ce.length&&(D==null||D(ce))}h.setState({userSelectionRect:Y})},I=M=>{if(M.button!==0)return;const{userSelectionRect:w}=h.getState();!m&&w&&M.target===p.current&&(x==null||x(M)),h.setState({nodesSelectionActive:E.current>0}),_(),o==null||o(M)},j=M=>{m&&(h.setState({nodesSelectionActive:E.current>0}),o==null||o(M)),_()},V=g&&(e||m);return H.createElement("div",{className:Je(["react-flow__pane",{dragging:S,selection:e}]),onClick:V?void 0:Qd(x,p),onContextMenu:Qd(R,p),onWheel:Qd(T,p),onMouseEnter:V?void 0:a,onMouseDown:V?L:void 0,onMouseMove:V?P:c,onMouseUp:V?I:void 0,onMouseLeave:V?j:u,ref:p,style:Xd},f,H.createElement(qO,null))});m0.displayName="Pane";function g0(e,t){if(!e.parentNode)return!1;const n=t.get(e.parentNode);return n?n.selected?!0:g0(n,t):!1}function E0(e,t,n){let r=e;do{if(r!=null&&r.matches(t))return!0;if(r===n.current)return!1;r=r.parentElement}while(r);return!1}function eT(e,t,n,r){return Array.from(e.values()).filter(o=>(o.selected||o.id===r)&&(!o.parentNode||!g0(o,e))&&(o.draggable||t&&typeof o.draggable>"u")).map(o=>{var s,i;return{id:o.id,position:o.position||{x:0,y:0},positionAbsolute:o.positionAbsolute||{x:0,y:0},distance:{x:n.x-(((s=o.positionAbsolute)==null?void 0:s.x)??0),y:n.y-(((i=o.positionAbsolute)==null?void 0:i.y)??0)},delta:{x:0,y:0},extent:o.extent,parentNode:o.parentNode,width:o.width,height:o.height,expandParent:o.expandParent}})}function tT(e,t){return!t||t==="parent"?t:[t[0],[t[1][0]-(e.width||0),t[1][1]-(e.height||0)]]}function y0(e,t,n,r,o=[0,0],s){const i=tT(e,e.extent||r);let l=i;if(e.extent==="parent"&&!e.expandParent)if(e.parentNode&&e.width&&e.height){const u=n.get(e.parentNode),{x:f,y:p}=Ro(u,o).positionAbsolute;l=u&&It(f)&&It(p)&&It(u.width)&&It(u.height)?[[f+e.width*o[0],p+e.height*o[1]],[f+u.width-e.width+e.width*o[0],p+u.height-e.height+e.height*o[1]]]:l}else s==null||s("005",En.error005()),l=i;else if(e.extent&&e.parentNode&&e.extent!=="parent"){const u=n.get(e.parentNode),{x:f,y:p}=Ro(u,o).positionAbsolute;l=[[e.extent[0][0]+f,e.extent[0][1]+p],[e.extent[1][0]+f,e.extent[1][1]+p]]}let a={x:0,y:0};if(e.parentNode){const u=n.get(e.parentNode);a=Ro(u,o).positionAbsolute}const c=l&&l!=="parent"?bd(t,l):t;return{position:{x:c.x-a.x,y:c.y-a.y},positionAbsolute:c}}function qd({nodeId:e,dragItems:t,nodeInternals:n}){const r=t.map(o=>({...n.get(o.id),position:o.position,positionAbsolute:o.positionAbsolute}));return[e?r.find(o=>o.id===e):r[0],r]}const v0=(e,t,n,r)=>{const o=t.querySelectorAll(e);if(!o||!o.length)return null;const s=Array.from(o),i=t.getBoundingClientRect(),l={x:i.width*r[0],y:i.height*r[1]};return s.map(a=>{const c=a.getBoundingClientRect();return{id:a.getAttribute("data-handleid"),position:a.getAttribute("data-handlepos"),x:(c.left-i.left-l.x)/n,y:(c.top-i.top-l.y)/n,...Ld(a)}})};function oi(e,t,n){return n===void 0?n:r=>{const o=t().nodeInternals.get(e);o&&n(r,{...o})}}function Jd({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:o,unselectNodesAndEdges:s,multiSelectionActive:i,nodeInternals:l,onError:a}=t.getState(),c=l.get(e);if(!c){a==null||a("012",En.error012(e));return}t.setState({nodesSelectionActive:!1}),c.selected?(n||c.selected&&i)&&(s({nodes:[c],edges:[]}),requestAnimationFrame(()=>{var u;return(u=r==null?void 0:r.current)==null?void 0:u.blur()})):o([e])}function nT(){const e=Ie();return O.useCallback(({sourceEvent:n})=>{const{transform:r,snapGrid:o,snapToGrid:s}=e.getState(),i=n.touches?n.touches[0].clientX:n.clientX,l=n.touches?n.touches[0].clientY:n.clientY,a={x:(i-r[0])/r[2],y:(l-r[1])/r[2]};return{xSnapped:s?o[0]*Math.round(a.x/o[0]):a.x,ySnapped:s?o[1]*Math.round(a.y/o[1]):a.y,...a}},[])}function Zd(e){return(t,n,r)=>e==null?void 0:e(t,r)}function _0({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:o,isSelectable:s,selectNodesOnDrag:i}){const l=Ie(),[a,c]=O.useState(!1),u=O.useRef([]),f=O.useRef({x:null,y:null}),p=O.useRef(0),h=O.useRef(null),E=O.useRef({x:0,y:0}),y=O.useRef(null),v=O.useRef(!1),m=O.useRef(!1),g=nT();return O.useEffect(()=>{if(e!=null&&e.current){const S=jt(e.current),_=({x:T,y:L})=>{const{nodeInternals:P,onNodeDrag:I,onSelectionDrag:j,updateNodePositions:V,nodeExtent:M,snapGrid:w,snapToGrid:b,nodeOrigin:k,onError:F}=l.getState();f.current={x:T,y:L};let C=!1,D={x:0,y:0,x2:0,y2:0};if(u.current.length>1&&M){const $=Hd(u.current,k);D=Dd($)}if(u.current=u.current.map($=>{const B={x:T-$.distance.x,y:L-$.distance.y};b&&(B.x=w[0]*Math.round(B.x/w[0]),B.y=w[1]*Math.round(B.y/w[1]));const W=[[M[0][0],M[0][1]],[M[1][0],M[1][1]]];u.current.length>1&&M&&!$.extent&&(W[0][0]=$.positionAbsolute.x-D.x+M[0][0],W[1][0]=$.positionAbsolute.x+($.width??0)-D.x2+M[1][0],W[0][1]=$.positionAbsolute.y-D.y+M[0][1],W[1][1]=$.positionAbsolute.y+($.height??0)-D.y2+M[1][1]);const z=y0($,B,P,W,k,F);return C=C||$.position.x!==z.position.x||$.position.y!==z.position.y,$.position=z.position,$.positionAbsolute=z.positionAbsolute,$}),!C)return;V(u.current,!0,!0),c(!0);const U=o?I:Zd(j);if(U&&y.current){const[$,B]=qd({nodeId:o,dragItems:u.current,nodeInternals:P});U(y.current,$,B)}},x=()=>{if(!h.current)return;const[T,L]=wE(E.current,h.current);if(T!==0||L!==0){const{transform:P,panBy:I}=l.getState();f.current.x=(f.current.x??0)-T/P[2],f.current.y=(f.current.y??0)-L/P[2],I({x:T,y:L})&&_(f.current)}p.current=requestAnimationFrame(x)},R=T=>{var k;const{nodeInternals:L,multiSelectionActive:P,nodesDraggable:I,unselectNodesAndEdges:j,onNodeDragStart:V,onSelectionDragStart:M}=l.getState();m.current=!0;const w=o?V:Zd(M);(!i||!s)&&!P&&o&&((k=L.get(o))!=null&&k.selected||j()),o&&s&&i&&Jd({id:o,store:l,nodeRef:e});const b=g(T);if(f.current=b,u.current=eT(L,I,b,o),w&&u.current){const[F,C]=qd({nodeId:o,dragItems:u.current,nodeInternals:L});w(T.sourceEvent,F,C)}};if(t)S.on(".drag",null);else{const T=f1().on("start",L=>{const{domNode:P,nodeDragThreshold:I}=l.getState();I===0&&R(L);const j=g(L);f.current=j,h.current=(P==null?void 0:P.getBoundingClientRect())||null,E.current=zn(L.sourceEvent,h.current)}).on("drag",L=>{var V,M;const P=g(L),{autoPanOnNodeDrag:I,nodeDragThreshold:j}=l.getState();if(!v.current&&m.current&&I&&(v.current=!0,x()),!m.current){const w=P.xSnapped-(((V=f==null?void 0:f.current)==null?void 0:V.x)??0),b=P.ySnapped-(((M=f==null?void 0:f.current)==null?void 0:M.y)??0);Math.sqrt(w*w+b*b)>j&&R(L)}(f.current.x!==P.xSnapped||f.current.y!==P.ySnapped)&&u.current&&m.current&&(y.current=L.sourceEvent,E.current=zn(L.sourceEvent,h.current),_(P))}).on("end",L=>{if(m.current&&(c(!1),v.current=!1,m.current=!1,cancelAnimationFrame(p.current),u.current)){const{updateNodePositions:P,nodeInternals:I,onNodeDragStop:j,onSelectionDragStop:V}=l.getState(),M=o?j:Zd(V);if(P(u.current,!1,!1),M){const[w,b]=qd({nodeId:o,dragItems:u.current,nodeInternals:I});M(L.sourceEvent,w,b)}}}).filter(L=>{const P=L.target;return!L.button&&(!n||!E0(P,`.${n}`,e))&&(!r||E0(P,r,e))});return S.call(T),()=>{S.on(".drag",null)}}}},[e,t,n,r,s,l,o,i,g]),a}function S0(){const e=Ie();return O.useCallback(n=>{const{nodeInternals:r,nodeExtent:o,updateNodePositions:s,getNodes:i,snapToGrid:l,snapGrid:a,onError:c,nodesDraggable:u}=e.getState(),f=i().filter(g=>g.selected&&(g.draggable||u&&typeof g.draggable>"u")),p=l?a[0]:5,h=l?a[1]:5,E=n.isShiftPressed?4:1,y=n.x*p*E,v=n.y*h*E,m=f.map(g=>{if(g.positionAbsolute){const S={x:g.positionAbsolute.x+y,y:g.positionAbsolute.y+v};l&&(S.x=a[0]*Math.round(S.x/a[0]),S.y=a[1]*Math.round(S.y/a[1]));const{positionAbsolute:_,position:x}=y0(g,S,r,o,void 0,c);g.position=x,g.positionAbsolute=_}return g});s(m,!0,!1)},[])}const Co={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var si=e=>{const t=({id:n,type:r,data:o,xPos:s,yPos:i,xPosOrigin:l,yPosOrigin:a,selected:c,onClick:u,onMouseEnter:f,onMouseMove:p,onMouseLeave:h,onContextMenu:E,onDoubleClick:y,style:v,className:m,isDraggable:g,isSelectable:S,isConnectable:_,isFocusable:x,selectNodesOnDrag:R,sourcePosition:T,targetPosition:L,hidden:P,resizeObserver:I,dragHandle:j,zIndex:V,isParent:M,noDragClassName:w,noPanClassName:b,initialized:k,disableKeyboardA11y:F,ariaLabel:C,rfId:D})=>{const U=Ie(),$=O.useRef(null),B=O.useRef(T),W=O.useRef(L),z=O.useRef(r),Y=S||g||u||f||p||h,X=S0(),Z=oi(n,U.getState,f),J=oi(n,U.getState,p),te=oi(n,U.getState,h),ce=oi(n,U.getState,E),Re=oi(n,U.getState,y),Me=ye=>{const{nodeDragThreshold:ut}=U.getState();if(S&&(!R||!g||ut>0)&&Jd({id:n,store:U,nodeRef:$}),u){const St=U.getState().nodeInternals.get(n);St&&u(ye,{...St})}},tn=ye=>{if(!Pd(ye))if(AE.includes(ye.key)&&S){const ut=ye.key==="Escape";Jd({id:n,store:U,unselect:ut,nodeRef:$})}else!F&&g&&c&&Object.prototype.hasOwnProperty.call(Co,ye.key)&&(U.setState({ariaLiveMessage:`Moved selected node ${ye.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~s}, y: ${~~i}`}),X({x:Co[ye.key].x,y:Co[ye.key].y,isShiftPressed:ye.shiftKey}))};O.useEffect(()=>{if($.current&&!P){const ye=$.current;return I==null||I.observe(ye),()=>I==null?void 0:I.unobserve(ye)}},[P]),O.useEffect(()=>{const ye=z.current!==r,ut=B.current!==T,St=W.current!==L;$.current&&(ye||ut||St)&&(ye&&(z.current=r),ut&&(B.current=T),St&&(W.current=L),U.getState().updateNodeDimensions([{id:n,nodeElement:$.current,forceUpdate:!0}]))},[n,r,T,L]);const Le=_0({nodeRef:$,disabled:P||!g,noDragClassName:w,handleSelector:j,nodeId:n,isSelectable:S,selectNodesOnDrag:R});return P?null:H.createElement("div",{className:Je(["react-flow__node",`react-flow__node-${r}`,{[b]:g},m,{selected:c,selectable:S,parent:M,dragging:Le}]),ref:$,style:{zIndex:V,transform:`translate(${l}px,${a}px)`,pointerEvents:Y?"all":"none",visibility:k?"visible":"hidden",...v},"data-id":n,"data-testid":`rf__node-${n}`,onMouseEnter:Z,onMouseMove:J,onMouseLeave:te,onContextMenu:ce,onClick:Me,onDoubleClick:Re,onKeyDown:x?tn:void 0,tabIndex:x?0:void 0,role:x?"button":void 0,"aria-describedby":F?void 0:`${r0}-${D}`,"aria-label":C},H.createElement(EO,{value:n},H.createElement(e,{id:n,data:o,type:r,xPos:s,yPos:i,selected:c,isConnectable:_,sourcePosition:T,targetPosition:L,dragging:Le,dragHandle:j,zIndex:V})))};return t.displayName="NodeWrapper",O.memo(t)};const rT=e=>{const t=e.getNodes().filter(n=>n.selected);return{...Hd(t,e.nodeOrigin),transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`,userSelectionActive:e.userSelectionActive}};function oT({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=Ie(),{width:o,height:s,x:i,y:l,transformString:a,userSelectionActive:c}=de(rT,Ge),u=S0(),f=O.useRef(null);if(O.useEffect(()=>{var E;n||(E=f.current)==null||E.focus({preventScroll:!0})},[n]),_0({nodeRef:f}),c||!o||!s)return null;const p=e?E=>{const y=r.getState().getNodes().filter(v=>v.selected);e(E,y)}:void 0,h=E=>{Object.prototype.hasOwnProperty.call(Co,E.key)&&u({x:Co[E.key].x,y:Co[E.key].y,isShiftPressed:E.shiftKey})};return H.createElement("div",{className:Je(["react-flow__nodesselection","react-flow__container",t]),style:{transform:a}},H.createElement("div",{ref:f,className:"react-flow__nodesselection-rect",onContextMenu:p,tabIndex:n?void 0:-1,onKeyDown:n?void 0:h,style:{width:o,height:s,top:l,left:i}}))}var sT=O.memo(oT);const iT=e=>e.nodesSelectionActive,x0=({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:o,onPaneContextMenu:s,onPaneScroll:i,deleteKeyCode:l,onMove:a,onMoveStart:c,onMoveEnd:u,selectionKeyCode:f,selectionOnDrag:p,selectionMode:h,onSelectionStart:E,onSelectionEnd:y,multiSelectionKeyCode:v,panActivationKeyCode:m,zoomActivationKeyCode:g,elementsSelectable:S,zoomOnScroll:_,zoomOnPinch:x,panOnScroll:R,panOnScrollSpeed:T,panOnScrollMode:L,zoomOnDoubleClick:P,panOnDrag:I,defaultViewport:j,translateExtent:V,minZoom:M,maxZoom:w,preventScrolling:b,onSelectionContextMenu:k,noWheelClassName:F,noPanClassName:C,disableKeyboardA11y:D})=>{const U=de(iT),$=Oo(f),B=Oo(m),W=B||I,z=B||R,Y=$||p&&W!==!0;return WO({deleteKeyCode:l,multiSelectionKeyCode:v}),H.createElement(XO,{onMove:a,onMoveStart:c,onMoveEnd:u,onPaneContextMenu:s,elementsSelectable:S,zoomOnScroll:_,zoomOnPinch:x,panOnScroll:z,panOnScrollSpeed:T,panOnScrollMode:L,zoomOnDoubleClick:P,panOnDrag:!$&&W,defaultViewport:j,translateExtent:V,minZoom:M,maxZoom:w,zoomActivationKeyCode:g,preventScrolling:b,noWheelClassName:F,noPanClassName:C},H.createElement(m0,{onSelectionStart:E,onSelectionEnd:y,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:o,onPaneContextMenu:s,onPaneScroll:i,panOnDrag:W,isSelecting:!!Y,selectionMode:h},e,U&&H.createElement(sT,{onSelectionContextMenu:k,noPanClassName:C,disableKeyboardA11y:D})))};x0.displayName="FlowRenderer";var lT=O.memo(x0);function aT(e){return de(O.useCallback(n=>e?$E(n.nodeInternals,{x:0,y:0,width:n.width,height:n.height},n.transform,!0):n.getNodes(),[e]))}function cT(e){const t={input:si(e.input||JE),default:si(e.default||Wd),output:si(e.output||e0),group:si(e.group||Gd)},n={},r=Object.keys(e).filter(o=>!["input","default","output","group"].includes(o)).reduce((o,s)=>(o[s]=si(e[s]||Wd),o),n);return{...t,...r}}const uT=({x:e,y:t,width:n,height:r,origin:o})=>!n||!r?{x:e,y:t}:o[0]<0||o[1]<0||o[0]>1||o[1]>1?{x:e,y:t}:{x:e-n*o[0],y:t-r*o[1]},dT=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,updateNodeDimensions:e.updateNodeDimensions,onError:e.onError}),R0=e=>{const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:o,updateNodeDimensions:s,onError:i}=de(dT,Ge),l=aT(e.onlyRenderVisibleElements),a=O.useRef(),c=O.useMemo(()=>{if(typeof ResizeObserver>"u")return null;const u=new ResizeObserver(f=>{const p=f.map(h=>({id:h.target.getAttribute("data-id"),nodeElement:h.target,forceUpdate:!0}));s(p)});return a.current=u,u},[]);return O.useEffect(()=>()=>{var u;(u=a==null?void 0:a.current)==null||u.disconnect()},[]),H.createElement("div",{className:"react-flow__nodes",style:Xd},l.map(u=>{var x,R;let f=u.type||"default";e.nodeTypes[f]||(i==null||i("003",En.error003(f)),f="default");const p=e.nodeTypes[f]||e.nodeTypes.default,h=!!(u.draggable||t&&typeof u.draggable>"u"),E=!!(u.selectable||o&&typeof u.selectable>"u"),y=!!(u.connectable||n&&typeof u.connectable>"u"),v=!!(u.focusable||r&&typeof u.focusable>"u"),m=e.nodeExtent?bd(u.positionAbsolute,e.nodeExtent):u.positionAbsolute,g=(m==null?void 0:m.x)??0,S=(m==null?void 0:m.y)??0,_=uT({x:g,y:S,width:u.width??0,height:u.height??0,origin:e.nodeOrigin});return H.createElement(p,{key:u.id,id:u.id,className:u.className,style:u.style,type:f,data:u.data,sourcePosition:u.sourcePosition||q.Bottom,targetPosition:u.targetPosition||q.Top,hidden:u.hidden,xPos:g,yPos:S,xPosOrigin:_.x,yPosOrigin:_.y,selectNodesOnDrag:e.selectNodesOnDrag,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,selected:!!u.selected,isDraggable:h,isSelectable:E,isConnectable:y,isFocusable:v,resizeObserver:c,dragHandle:u.dragHandle,zIndex:((x=u[Ce])==null?void 0:x.z)??0,isParent:!!((R=u[Ce])!=null&&R.isParent),noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,initialized:!!u.width&&!!u.height,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,ariaLabel:u.ariaLabel})}))};R0.displayName="NodeRenderer";var fT=O.memo(R0);const pT=(e,t,n)=>n===q.Left?e-t:n===q.Right?e+t:e,hT=(e,t,n)=>n===q.Top?e-t:n===q.Bottom?e+t:e,N0="react-flow__edgeupdater",w0=({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:o,onMouseEnter:s,onMouseOut:i,type:l})=>H.createElement("circle",{onMouseDown:o,onMouseEnter:s,onMouseOut:i,className:Je([N0,`${N0}-${l}`]),cx:pT(t,r,e),cy:hT(n,r,e),r,stroke:"transparent",fill:"transparent"}),mT=()=>!0;var Lo=e=>{const t=({id:n,className:r,type:o,data:s,onClick:i,onEdgeDoubleClick:l,selected:a,animated:c,label:u,labelStyle:f,labelShowBg:p,labelBgStyle:h,labelBgPadding:E,labelBgBorderRadius:y,style:v,source:m,target:g,sourceX:S,sourceY:_,targetX:x,targetY:R,sourcePosition:T,targetPosition:L,elementsSelectable:P,hidden:I,sourceHandleId:j,targetHandleId:V,onContextMenu:M,onMouseEnter:w,onMouseMove:b,onMouseLeave:k,edgeUpdaterRadius:F,onEdgeUpdate:C,onEdgeUpdateStart:D,onEdgeUpdateEnd:U,markerEnd:$,markerStart:B,rfId:W,ariaLabel:z,isFocusable:Y,isUpdatable:X,pathOptions:Z,interactionWidth:J})=>{const te=O.useRef(null),[ce,Re]=O.useState(!1),[Me,tn]=O.useState(!1),Le=Ie(),ye=O.useMemo(()=>`url(#${Vd(B,W)})`,[B,W]),ut=O.useMemo(()=>`url(#${Vd($,W)})`,[$,W]);if(I)return null;const St=Ye=>{var nn;const{edges:xt,addSelectedEdges:kr,unselectNodesAndEdges:Pr,multiSelectionActive:Mr}=Le.getState(),Sn=xt.find(wi=>wi.id===n);Sn&&(P&&(Le.setState({nodesSelectionActive:!1}),Sn.selected&&Mr?(Pr({nodes:[],edges:[Sn]}),(nn=te.current)==null||nn.blur()):kr([n])),i&&i(Ye,Sn))},ee=ei(n,Le.getState,l),Cr=ei(n,Le.getState,M),Lr=ei(n,Le.getState,w),Ri=ei(n,Le.getState,b),Ko=ei(n,Le.getState,k),br=(Ye,xt)=>{if(Ye.button!==0)return;const{edges:kr,isValidConnection:Pr}=Le.getState(),Mr=xt?g:m,Sn=(xt?V:j)||null,nn=xt?"target":"source",wi=Pr||mT,Gf=xt,Oi=kr.find(Ur=>Ur.id===n);tn(!0),D==null||D(Ye,Oi,nn);const Yf=Ur=>{tn(!1),U==null||U(Ur,Oi,nn)};YE({event:Ye,handleId:Sn,nodeId:Mr,onConnect:Ur=>C==null?void 0:C(Oi,Ur),isTarget:Gf,getState:Le.getState,setState:Le.setState,isValidConnection:wi,edgeUpdaterType:nn,onEdgeUpdateEnd:Yf})},tr=Ye=>br(Ye,!0),Xo=Ye=>br(Ye,!1),nr=()=>Re(!0),Dr=()=>Re(!1),Ni=!P&&!i,Qo=Ye=>{var xt;if(AE.includes(Ye.key)&&P){const{unselectNodesAndEdges:kr,addSelectedEdges:Pr,edges:Mr}=Le.getState();Ye.key==="Escape"?((xt=te.current)==null||xt.blur(),kr({edges:[Mr.find(nn=>nn.id===n)]})):Pr([n])}};return H.createElement("g",{className:Je(["react-flow__edge",`react-flow__edge-${o}`,r,{selected:a,animated:c,inactive:Ni,updating:ce}]),onClick:St,onDoubleClick:ee,onContextMenu:Cr,onMouseEnter:Lr,onMouseMove:Ri,onMouseLeave:Ko,onKeyDown:Y?Qo:void 0,tabIndex:Y?0:void 0,role:Y?"button":"img","data-testid":`rf__edge-${n}`,"aria-label":z===null?void 0:z||`Edge from ${m} to ${g}`,"aria-describedby":Y?`${o0}-${W}`:void 0,ref:te},!Me&&H.createElement(e,{id:n,source:m,target:g,selected:a,animated:c,label:u,labelStyle:f,labelShowBg:p,labelBgStyle:h,labelBgPadding:E,labelBgBorderRadius:y,data:s,style:v,sourceX:S,sourceY:_,targetX:x,targetY:R,sourcePosition:T,targetPosition:L,sourceHandleId:j,targetHandleId:V,markerStart:ye,markerEnd:ut,pathOptions:Z,interactionWidth:J}),X&&H.createElement(H.Fragment,null,(X==="source"||X===!0)&&H.createElement(w0,{position:T,centerX:S,centerY:_,radius:F,onMouseDown:tr,onMouseEnter:nr,onMouseOut:Dr,type:"source"}),(X==="target"||X===!0)&&H.createElement(w0,{position:L,centerX:x,centerY:R,radius:F,onMouseDown:Xo,onMouseEnter:nr,onMouseOut:Dr,type:"target"})))};return t.displayName="EdgeWrapper",O.memo(t)};function gT(e){const t={default:Lo(e.default||ha),straight:Lo(e.bezier||Fd),step:Lo(e.step||Ud),smoothstep:Lo(e.step||fa),simplebezier:Lo(e.simplebezier||Md)},n={},r=Object.keys(e).filter(o=>!["default","bezier"].includes(o)).reduce((o,s)=>(o[s]=Lo(e[s]||ha),o),n);return{...t,...r}}function O0(e,t,n=null){const r=((n==null?void 0:n.x)||0)+t.x,o=((n==null?void 0:n.y)||0)+t.y,s=(n==null?void 0:n.width)||t.width,i=(n==null?void 0:n.height)||t.height;switch(e){case q.Top:return{x:r+s/2,y:o};case q.Right:return{x:r+s,y:o+i/2};case q.Bottom:return{x:r+s/2,y:o+i};case q.Left:return{x:r,y:o+i/2}}}function T0(e,t){return e?e.length===1||!t?e[0]:t&&e.find(n=>n.id===t)||null:null}const ET=(e,t,n,r,o,s)=>{const i=O0(n,e,t),l=O0(s,r,o);return{sourceX:i.x,sourceY:i.y,targetX:l.x,targetY:l.y}};function yT({sourcePos:e,targetPos:t,sourceWidth:n,sourceHeight:r,targetWidth:o,targetHeight:s,width:i,height:l,transform:a}){const c={x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x+n,t.x+o),y2:Math.max(e.y+r,t.y+s)};c.x===c.x2&&(c.x2+=1),c.y===c.y2&&(c.y2+=1);const u=Dd({x:(0-a[0])/a[2],y:(0-a[1])/a[2],width:i/a[2],height:l/a[2]}),f=Math.max(0,Math.min(u.x2,c.x2)-Math.max(u.x,c.x)),p=Math.max(0,Math.min(u.y2,c.y2)-Math.max(u.y,c.y));return Math.ceil(f*p)>0}function A0(e){var r,o,s,i,l;const t=((r=e==null?void 0:e[Ce])==null?void 0:r.handleBounds)||null,n=t&&(e==null?void 0:e.width)&&(e==null?void 0:e.height)&&typeof((o=e==null?void 0:e.positionAbsolute)==null?void 0:o.x)<"u"&&typeof((s=e==null?void 0:e.positionAbsolute)==null?void 0:s.y)<"u";return[{x:((i=e==null?void 0:e.positionAbsolute)==null?void 0:i.x)||0,y:((l=e==null?void 0:e.positionAbsolute)==null?void 0:l.y)||0,width:(e==null?void 0:e.width)||0,height:(e==null?void 0:e.height)||0},t,!!n]}const vT=[{level:0,isMaxLevel:!0,edges:[]}];function _T(e,t,n=!1){let r=-1;const o=e.reduce((i,l)=>{var u,f;const a=It(l.zIndex);let c=a?l.zIndex:0;if(n){const p=t.get(l.target),h=t.get(l.source),E=l.selected||(p==null?void 0:p.selected)||(h==null?void 0:h.selected),y=Math.max(((u=h==null?void 0:h[Ce])==null?void 0:u.z)||0,((f=p==null?void 0:p[Ce])==null?void 0:f.z)||0,1e3);c=(a?l.zIndex:0)+(E?y:0)}return i[c]?i[c].push(l):i[c]=[l],r=c>r?c:r,i},{}),s=Object.entries(o).map(([i,l])=>{const a=+i;return{edges:l,level:a,isMaxLevel:a===r}});return s.length===0?vT:s}function ST(e,t,n){const r=de(O.useCallback(o=>e?o.edges.filter(s=>{const i=t.get(s.source),l=t.get(s.target);return(i==null?void 0:i.width)&&(i==null?void 0:i.height)&&(l==null?void 0:l.width)&&(l==null?void 0:l.height)&&yT({sourcePos:i.positionAbsolute||{x:0,y:0},targetPos:l.positionAbsolute||{x:0,y:0},sourceWidth:i.width,sourceHeight:i.height,targetWidth:l.width,targetHeight:l.height,width:o.width,height:o.height,transform:o.transform})}):o.edges,[e,t]));return _T(r,t,n)}const xT=({color:e="none",strokeWidth:t=1})=>H.createElement("polyline",{style:{stroke:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),RT=({color:e="none",strokeWidth:t=1})=>H.createElement("polyline",{style:{stroke:e,fill:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"}),I0={[ni.Arrow]:xT,[ni.ArrowClosed]:RT};function NT(e){const t=Ie();return O.useMemo(()=>{var o,s;return Object.prototype.hasOwnProperty.call(I0,e)?I0[e]:((s=(o=t.getState()).onError)==null||s.call(o,"009",En.error009(e)),null)},[e])}const wT=({id:e,type:t,color:n,width:r=12.5,height:o=12.5,markerUnits:s="strokeWidth",strokeWidth:i,orient:l="auto-start-reverse"})=>{const a=NT(t);return a?H.createElement("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${r}`,markerHeight:`${o}`,viewBox:"-10 -10 20 20",markerUnits:s,orient:l,refX:"0",refY:"0"},H.createElement(a,{color:n,strokeWidth:i})):null},OT=({defaultColor:e,rfId:t})=>n=>{const r=[];return n.edges.reduce((o,s)=>([s.markerStart,s.markerEnd].forEach(i=>{if(i&&typeof i=="object"){const l=Vd(i,t);r.includes(l)||(o.push({id:l,color:i.color||e,...i}),r.push(l))}}),o),[]).sort((o,s)=>o.id.localeCompare(s.id))},C0=({defaultColor:e,rfId:t})=>{const n=de(O.useCallback(OT({defaultColor:e,rfId:t}),[e,t]),(r,o)=>!(r.length!==o.length||r.some((s,i)=>s.id!==o[i].id)));return H.createElement("defs",null,n.map(r=>H.createElement(wT,{id:r.id,key:r.id,type:r.type,color:r.color,width:r.width,height:r.height,markerUnits:r.markerUnits,strokeWidth:r.strokeWidth,orient:r.orient})))};C0.displayName="MarkerDefinitions";var TT=O.memo(C0);const AT=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}),L0=({defaultMarkerColor:e,onlyRenderVisibleElements:t,elevateEdgesOnSelect:n,rfId:r,edgeTypes:o,noPanClassName:s,onEdgeUpdate:i,onEdgeContextMenu:l,onEdgeMouseEnter:a,onEdgeMouseMove:c,onEdgeMouseLeave:u,onEdgeClick:f,edgeUpdaterRadius:p,onEdgeDoubleClick:h,onEdgeUpdateStart:E,onEdgeUpdateEnd:y,children:v})=>{const{edgesFocusable:m,edgesUpdatable:g,elementsSelectable:S,width:_,height:x,connectionMode:R,nodeInternals:T,onError:L}=de(AT,Ge),P=ST(t,T,n);return _?H.createElement(H.Fragment,null,P.map(({level:I,edges:j,isMaxLevel:V})=>H.createElement("svg",{key:I,style:{zIndex:I},width:_,height:x,className:"react-flow__edges react-flow__container"},V&&H.createElement(TT,{defaultColor:e,rfId:r}),H.createElement("g",null,j.map(M=>{const[w,b,k]=A0(T.get(M.source)),[F,C,D]=A0(T.get(M.target));if(!k||!D)return null;let U=M.type||"default";o[U]||(L==null||L("011",En.error011(U)),U="default");const $=o[U]||o.default,B=R===Wn.Strict?C.target:(C.target??[]).concat(C.source??[]),W=T0(b.source,M.sourceHandle),z=T0(B,M.targetHandle),Y=(W==null?void 0:W.position)||q.Bottom,X=(z==null?void 0:z.position)||q.Top,Z=!!(M.focusable||m&&typeof M.focusable>"u"),J=typeof i<"u"&&(M.updatable||g&&typeof M.updatable>"u");if(!W||!z)return L==null||L("008",En.error008(W,M)),null;const{sourceX:te,sourceY:ce,targetX:Re,targetY:Me}=ET(w,W,Y,F,z,X);return H.createElement($,{key:M.id,id:M.id,className:Je([M.className,s]),type:U,data:M.data,selected:!!M.selected,animated:!!M.animated,hidden:!!M.hidden,label:M.label,labelStyle:M.labelStyle,labelShowBg:M.labelShowBg,labelBgStyle:M.labelBgStyle,labelBgPadding:M.labelBgPadding,labelBgBorderRadius:M.labelBgBorderRadius,style:M.style,source:M.source,target:M.target,sourceHandleId:M.sourceHandle,targetHandleId:M.targetHandle,markerEnd:M.markerEnd,markerStart:M.markerStart,sourceX:te,sourceY:ce,targetX:Re,targetY:Me,sourcePosition:Y,targetPosition:X,elementsSelectable:S,onEdgeUpdate:i,onContextMenu:l,onMouseEnter:a,onMouseMove:c,onMouseLeave:u,onClick:f,edgeUpdaterRadius:p,onEdgeDoubleClick:h,onEdgeUpdateStart:E,onEdgeUpdateEnd:y,rfId:r,ariaLabel:M.ariaLabel,isFocusable:Z,isUpdatable:J,pathOptions:"pathOptions"in M?M.pathOptions:void 0,interactionWidth:M.interactionWidth})})))),v):null};L0.displayName="EdgeRenderer";var IT=O.memo(L0);const CT=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function LT({children:e}){const t=de(CT);return H.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:t}},e)}function bT(e){const t=Kd(),n=O.useRef(!1);O.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const DT={[q.Left]:q.Right,[q.Right]:q.Left,[q.Top]:q.Bottom,[q.Bottom]:q.Top},b0=({nodeId:e,handleType:t,style:n,type:r=Gn.Bezier,CustomComponent:o,connectionStatus:s})=>{var R,T,L;const{fromNode:i,handleId:l,toX:a,toY:c,connectionMode:u}=de(O.useCallback(P=>({fromNode:P.nodeInternals.get(e),handleId:P.connectionHandleId,toX:(P.connectionPosition.x-P.transform[0])/P.transform[2],toY:(P.connectionPosition.y-P.transform[1])/P.transform[2],connectionMode:P.connectionMode}),[e]),Ge),f=(R=i==null?void 0:i[Ce])==null?void 0:R.handleBounds;let p=f==null?void 0:f[t];if(u===Wn.Loose&&(p=p||(f==null?void 0:f[t==="source"?"target":"source"])),!i||!p)return null;const h=l?p.find(P=>P.id===l):p[0],E=h?h.x+h.width/2:(i.width??0)/2,y=h?h.y+h.height/2:i.height??0,v=(((T=i.positionAbsolute)==null?void 0:T.x)??0)+E,m=(((L=i.positionAbsolute)==null?void 0:L.y)??0)+y,g=h==null?void 0:h.position,S=g?DT[g]:null;if(!g||!S)return null;if(o)return H.createElement(o,{connectionLineType:r,connectionLineStyle:n,fromNode:i,fromHandle:h,fromX:v,fromY:m,toX:a,toY:c,fromPosition:g,toPosition:S,connectionStatus:s});let _="";const x={sourceX:v,sourceY:m,sourcePosition:g,targetX:a,targetY:c,targetPosition:S};return r===Gn.Bezier?[_]=UE(x):r===Gn.Step?[_]=ri({...x,borderRadius:0}):r===Gn.SmoothStep?[_]=ri(x):r===Gn.SimpleBezier?[_]=DE(x):_=`M${v},${m} ${a},${c}`,H.createElement("path",{d:_,fill:"none",className:"react-flow__connection-path",style:n})};b0.displayName="ConnectionLine";const kT=e=>({nodeId:e.connectionNodeId,handleType:e.connectionHandleType,nodesConnectable:e.nodesConnectable,connectionStatus:e.connectionStatus,width:e.width,height:e.height});function PT({containerStyle:e,style:t,type:n,component:r}){const{nodeId:o,handleType:s,nodesConnectable:i,width:l,height:a,connectionStatus:c}=de(kT,Ge);return!(o&&s&&l&&i)?null:H.createElement("svg",{style:e,width:l,height:a,className:"react-flow__edges react-flow__connectionline react-flow__container"},H.createElement("g",{className:Je(["react-flow__connection",c])},H.createElement(b0,{nodeId:o,handleType:s,style:t,type:n,CustomComponent:r,connectionStatus:c})))}function D0(e,t){return O.useRef(null),Ie(),O.useMemo(()=>t(e),[e])}const k0=({nodeTypes:e,edgeTypes:t,onMove:n,onMoveStart:r,onMoveEnd:o,onInit:s,onNodeClick:i,onEdgeClick:l,onNodeDoubleClick:a,onEdgeDoubleClick:c,onNodeMouseEnter:u,onNodeMouseMove:f,onNodeMouseLeave:p,onNodeContextMenu:h,onSelectionContextMenu:E,onSelectionStart:y,onSelectionEnd:v,connectionLineType:m,connectionLineStyle:g,connectionLineComponent:S,connectionLineContainerStyle:_,selectionKeyCode:x,selectionOnDrag:R,selectionMode:T,multiSelectionKeyCode:L,panActivationKeyCode:P,zoomActivationKeyCode:I,deleteKeyCode:j,onlyRenderVisibleElements:V,elementsSelectable:M,selectNodesOnDrag:w,defaultViewport:b,translateExtent:k,minZoom:F,maxZoom:C,preventScrolling:D,defaultMarkerColor:U,zoomOnScroll:$,zoomOnPinch:B,panOnScroll:W,panOnScrollSpeed:z,panOnScrollMode:Y,zoomOnDoubleClick:X,panOnDrag:Z,onPaneClick:J,onPaneMouseEnter:te,onPaneMouseMove:ce,onPaneMouseLeave:Re,onPaneScroll:Me,onPaneContextMenu:tn,onEdgeUpdate:Le,onEdgeContextMenu:ye,onEdgeMouseEnter:ut,onEdgeMouseMove:St,onEdgeMouseLeave:ee,edgeUpdaterRadius:Cr,onEdgeUpdateStart:Lr,onEdgeUpdateEnd:Ri,noDragClassName:Ko,noWheelClassName:br,noPanClassName:tr,elevateEdgesOnSelect:Xo,disableKeyboardA11y:nr,nodeOrigin:Dr,nodeExtent:Ni,rfId:Qo})=>{const Ye=D0(e,cT),xt=D0(t,gT);return bT(s),H.createElement(lT,{onPaneClick:J,onPaneMouseEnter:te,onPaneMouseMove:ce,onPaneMouseLeave:Re,onPaneContextMenu:tn,onPaneScroll:Me,deleteKeyCode:j,selectionKeyCode:x,selectionOnDrag:R,selectionMode:T,onSelectionStart:y,onSelectionEnd:v,multiSelectionKeyCode:L,panActivationKeyCode:P,zoomActivationKeyCode:I,elementsSelectable:M,onMove:n,onMoveStart:r,onMoveEnd:o,zoomOnScroll:$,zoomOnPinch:B,zoomOnDoubleClick:X,panOnScroll:W,panOnScrollSpeed:z,panOnScrollMode:Y,panOnDrag:Z,defaultViewport:b,translateExtent:k,minZoom:F,maxZoom:C,onSelectionContextMenu:E,preventScrolling:D,noDragClassName:Ko,noWheelClassName:br,noPanClassName:tr,disableKeyboardA11y:nr},H.createElement(LT,null,H.createElement(IT,{edgeTypes:xt,onEdgeClick:l,onEdgeDoubleClick:c,onEdgeUpdate:Le,onlyRenderVisibleElements:V,onEdgeContextMenu:ye,onEdgeMouseEnter:ut,onEdgeMouseMove:St,onEdgeMouseLeave:ee,onEdgeUpdateStart:Lr,onEdgeUpdateEnd:Ri,edgeUpdaterRadius:Cr,defaultMarkerColor:U,noPanClassName:tr,elevateEdgesOnSelect:!!Xo,disableKeyboardA11y:nr,rfId:Qo},H.createElement(PT,{style:g,type:m,component:S,containerStyle:_})),H.createElement("div",{className:"react-flow__edgelabel-renderer"}),H.createElement(fT,{nodeTypes:Ye,onNodeClick:i,onNodeDoubleClick:a,onNodeMouseEnter:u,onNodeMouseMove:f,onNodeMouseLeave:p,onNodeContextMenu:h,selectNodesOnDrag:w,onlyRenderVisibleElements:V,noPanClassName:tr,noDragClassName:Ko,disableKeyboardA11y:nr,nodeOrigin:Dr,nodeExtent:Ni,rfId:Qo})))};k0.displayName="GraphView";var MT=O.memo(k0);const ef=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Kn={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:ef,nodeExtent:ef,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:Wn.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:dO,isValidConnection:void 0},UT=()=>NR((e,t)=>({...Kn,setNodes:n=>{const{nodeInternals:r,nodeOrigin:o,elevateNodesOnSelect:s}=t();e({nodeInternals:Yd(n,r,o,s)})},getNodes:()=>Array.from(t().nodeInternals.values()),setEdges:n=>{const{defaultEdgeOptions:r={}}=t();e({edges:n.map(o=>({...r,...o}))})},setDefaultNodesAndEdges:(n,r)=>{const o=typeof n<"u",s=typeof r<"u",i=o?Yd(n,new Map,t().nodeOrigin,t().elevateNodesOnSelect):new Map;e({nodeInternals:i,edges:s?r:[],hasDefaultNodes:o,hasDefaultEdges:s})},updateNodeDimensions:n=>{const{onNodesChange:r,nodeInternals:o,fitViewOnInit:s,fitViewOnInitDone:i,fitViewOnInitOptions:l,domNode:a,nodeOrigin:c}=t(),u=a==null?void 0:a.querySelector(".react-flow__viewport");if(!u)return;const f=window.getComputedStyle(u),{m22:p}=new window.DOMMatrixReadOnly(f.transform),h=n.reduce((y,v)=>{const m=o.get(v.id);if(m){const g=Ld(v.nodeElement);!!(g.width&&g.height&&(m.width!==g.width||m.height!==g.height||v.forceUpdate))&&(o.set(m.id,{...m,[Ce]:{...m[Ce],handleBounds:{source:v0(".source",v.nodeElement,p,c),target:v0(".target",v.nodeElement,p,c)}},...g}),y.push({id:m.id,type:"dimensions",dimensions:g}))}return y},[]);a0(o,c);const E=i||s&&!i&&c0(t,{initial:!0,...l});e({nodeInternals:new Map(o),fitViewOnInitDone:E}),(h==null?void 0:h.length)>0&&(r==null||r(h))},updateNodePositions:(n,r=!0,o=!1)=>{const{triggerNodeChanges:s}=t(),i=n.map(l=>{const a={id:l.id,type:"position",dragging:o};return r&&(a.positionAbsolute=l.positionAbsolute,a.position=l.position),a});s(i)},triggerNodeChanges:n=>{const{onNodesChange:r,nodeInternals:o,hasDefaultNodes:s,nodeOrigin:i,getNodes:l,elevateNodesOnSelect:a}=t();if(n!=null&&n.length){if(s){const c=h0(n,l()),u=Yd(c,o,i,a);e({nodeInternals:u})}r==null||r(n)}},addSelectedNodes:n=>{const{multiSelectionActive:r,edges:o,getNodes:s}=t();let i,l=null;r?i=n.map(a=>Yn(a,!0)):(i=Io(s(),n),l=Io(o,[])),ga({changedNodes:i,changedEdges:l,get:t,set:e})},addSelectedEdges:n=>{const{multiSelectionActive:r,edges:o,getNodes:s}=t();let i,l=null;r?i=n.map(a=>Yn(a,!0)):(i=Io(o,n),l=Io(s(),[])),ga({changedNodes:l,changedEdges:i,get:t,set:e})},unselectNodesAndEdges:({nodes:n,edges:r}={})=>{const{edges:o,getNodes:s}=t(),i=n||s(),l=r||o,a=i.map(u=>(u.selected=!1,Yn(u.id,!1))),c=l.map(u=>Yn(u.id,!1));ga({changedNodes:a,changedEdges:c,get:t,set:e})},setMinZoom:n=>{const{d3Zoom:r,maxZoom:o}=t();r==null||r.scaleExtent([n,o]),e({minZoom:n})},setMaxZoom:n=>{const{d3Zoom:r,minZoom:o}=t();r==null||r.scaleExtent([o,n]),e({maxZoom:n})},setTranslateExtent:n=>{var r;(r=t().d3Zoom)==null||r.translateExtent(n),e({translateExtent:n})},resetSelectedElements:()=>{const{edges:n,getNodes:r}=t(),s=r().filter(l=>l.selected).map(l=>Yn(l.id,!1)),i=n.filter(l=>l.selected).map(l=>Yn(l.id,!1));ga({changedNodes:s,changedEdges:i,get:t,set:e})},setNodeExtent:n=>{const{nodeInternals:r}=t();r.forEach(o=>{o.positionAbsolute=bd(o.position,n)}),e({nodeExtent:n,nodeInternals:new Map(r)})},panBy:n=>{const{transform:r,width:o,height:s,d3Zoom:i,d3Selection:l,translateExtent:a}=t();if(!i||!l||!n.x&&!n.y)return!1;const c=Bn.translate(r[0]+n.x,r[1]+n.y).scale(r[2]),u=[[0,0],[o,s]],f=i==null?void 0:i.constrain()(c,u,a);return i.transform(l,f),r[0]!==f.x||r[1]!==f.y||r[2]!==f.k},cancelConnection:()=>e({connectionNodeId:Kn.connectionNodeId,connectionHandleId:Kn.connectionHandleId,connectionHandleType:Kn.connectionHandleType,connectionStatus:Kn.connectionStatus,connectionStartHandle:Kn.connectionStartHandle,connectionEndHandle:Kn.connectionEndHandle}),reset:()=>e({...Kn})}),Object.is),tf=({children:e})=>{const t=O.useRef(null);return t.current||(t.current=UT()),H.createElement(rO,{value:t.current},e)};tf.displayName="ReactFlowProvider";const P0=({children:e})=>O.useContext(ua)?H.createElement(H.Fragment,null,e):H.createElement(tf,null,e);P0.displayName="ReactFlowWrapper";const FT={input:JE,default:Wd,output:e0,group:Gd},jT={default:ha,straight:Fd,step:Ud,smoothstep:fa,simplebezier:Md},VT=[0,0],$T=[15,15],HT={x:0,y:0,zoom:1},BT={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},M0=O.forwardRef(({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:o,nodeTypes:s=FT,edgeTypes:i=jT,onNodeClick:l,onEdgeClick:a,onInit:c,onMove:u,onMoveStart:f,onMoveEnd:p,onConnect:h,onConnectStart:E,onConnectEnd:y,onClickConnectStart:v,onClickConnectEnd:m,onNodeMouseEnter:g,onNodeMouseMove:S,onNodeMouseLeave:_,onNodeContextMenu:x,onNodeDoubleClick:R,onNodeDragStart:T,onNodeDrag:L,onNodeDragStop:P,onNodesDelete:I,onEdgesDelete:j,onSelectionChange:V,onSelectionDragStart:M,onSelectionDrag:w,onSelectionDragStop:b,onSelectionContextMenu:k,onSelectionStart:F,onSelectionEnd:C,connectionMode:D=Wn.Strict,connectionLineType:U=Gn.Bezier,connectionLineStyle:$,connectionLineComponent:B,connectionLineContainerStyle:W,deleteKeyCode:z="Backspace",selectionKeyCode:Y="Shift",selectionOnDrag:X=!1,selectionMode:Z=ti.Full,panActivationKeyCode:J="Space",multiSelectionKeyCode:te=da()?"Meta":"Control",zoomActivationKeyCode:ce=da()?"Meta":"Control",snapToGrid:Re=!1,snapGrid:Me=$T,onlyRenderVisibleElements:tn=!1,selectNodesOnDrag:Le=!0,nodesDraggable:ye,nodesConnectable:ut,nodesFocusable:St,nodeOrigin:ee=VT,edgesFocusable:Cr,edgesUpdatable:Lr,elementsSelectable:Ri,defaultViewport:Ko=HT,minZoom:br=.5,maxZoom:tr=2,translateExtent:Xo=ef,preventScrolling:nr=!0,nodeExtent:Dr,defaultMarkerColor:Ni="#b1b1b7",zoomOnScroll:Qo=!0,zoomOnPinch:Ye=!0,panOnScroll:xt=!1,panOnScrollSpeed:kr=.5,panOnScrollMode:Pr=Sr.Free,zoomOnDoubleClick:Mr=!0,panOnDrag:Sn=!0,onPaneClick:nn,onPaneMouseEnter:wi,onPaneMouseMove:Gf,onPaneMouseLeave:Oi,onPaneScroll:Yf,onPaneContextMenu:zv,children:Ur,onEdgeUpdate:ND,onEdgeContextMenu:wD,onEdgeDoubleClick:OD,onEdgeMouseEnter:TD,onEdgeMouseMove:AD,onEdgeMouseLeave:ID,onEdgeUpdateStart:CD,onEdgeUpdateEnd:LD,edgeUpdaterRadius:bD=10,onNodesChange:DD,onEdgesChange:kD,noDragClassName:PD="nodrag",noWheelClassName:MD="nowheel",noPanClassName:Wv="nopan",fitView:UD=!1,fitViewOptions:FD,connectOnClick:jD=!0,attributionPosition:VD,proOptions:$D,defaultEdgeOptions:HD,elevateNodesOnSelect:BD=!0,elevateEdgesOnSelect:zD=!1,disableKeyboardA11y:Gv=!1,autoPanOnConnect:WD=!0,autoPanOnNodeDrag:GD=!0,connectionRadius:YD=20,isValidConnection:KD,onError:XD,style:QD,id:Yv,nodeDragThreshold:qD,...JD},ZD)=>{const Kf=Yv||"1";return H.createElement("div",{...JD,style:{...QD,...BT},ref:ZD,className:Je(["react-flow",o]),"data-testid":"rf__wrapper",id:Yv},H.createElement(P0,null,H.createElement(MT,{onInit:c,onMove:u,onMoveStart:f,onMoveEnd:p,onNodeClick:l,onEdgeClick:a,onNodeMouseEnter:g,onNodeMouseMove:S,onNodeMouseLeave:_,onNodeContextMenu:x,onNodeDoubleClick:R,nodeTypes:s,edgeTypes:i,connectionLineType:U,connectionLineStyle:$,connectionLineComponent:B,connectionLineContainerStyle:W,selectionKeyCode:Y,selectionOnDrag:X,selectionMode:Z,deleteKeyCode:z,multiSelectionKeyCode:te,panActivationKeyCode:J,zoomActivationKeyCode:ce,onlyRenderVisibleElements:tn,selectNodesOnDrag:Le,defaultViewport:Ko,translateExtent:Xo,minZoom:br,maxZoom:tr,preventScrolling:nr,zoomOnScroll:Qo,zoomOnPinch:Ye,zoomOnDoubleClick:Mr,panOnScroll:xt,panOnScrollSpeed:kr,panOnScrollMode:Pr,panOnDrag:Sn,onPaneClick:nn,onPaneMouseEnter:wi,onPaneMouseMove:Gf,onPaneMouseLeave:Oi,onPaneScroll:Yf,onPaneContextMenu:zv,onSelectionContextMenu:k,onSelectionStart:F,onSelectionEnd:C,onEdgeUpdate:ND,onEdgeContextMenu:wD,onEdgeDoubleClick:OD,onEdgeMouseEnter:TD,onEdgeMouseMove:AD,onEdgeMouseLeave:ID,onEdgeUpdateStart:CD,onEdgeUpdateEnd:LD,edgeUpdaterRadius:bD,defaultMarkerColor:Ni,noDragClassName:PD,noWheelClassName:MD,noPanClassName:Wv,elevateEdgesOnSelect:zD,rfId:Kf,disableKeyboardA11y:Gv,nodeOrigin:ee,nodeExtent:Dr}),H.createElement(DO,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:h,onConnectStart:E,onConnectEnd:y,onClickConnectStart:v,onClickConnectEnd:m,nodesDraggable:ye,nodesConnectable:ut,nodesFocusable:St,edgesFocusable:Cr,edgesUpdatable:Lr,elementsSelectable:Ri,elevateNodesOnSelect:BD,minZoom:br,maxZoom:tr,nodeExtent:Dr,onNodesChange:DD,onEdgesChange:kD,snapToGrid:Re,snapGrid:Me,connectionMode:D,translateExtent:Xo,connectOnClick:jD,defaultEdgeOptions:HD,fitView:UD,fitViewOptions:FD,onNodesDelete:I,onEdgesDelete:j,onNodeDragStart:T,onNodeDrag:L,onNodeDragStop:P,onSelectionDrag:w,onSelectionDragStart:M,onSelectionDragStop:b,noPanClassName:Wv,nodeOrigin:ee,rfId:Kf,autoPanOnConnect:WD,autoPanOnNodeDrag:GD,onError:XD,connectionRadius:YD,isValidConnection:KD,nodeDragThreshold:qD}),H.createElement(LO,{onSelectionChange:V}),Ur,H.createElement(sO,{proOptions:$D,position:VD}),H.createElement(FO,{rfId:Kf,disableKeyboardA11y:Gv})))});M0.displayName="ReactFlow";const zT=e=>{var t;return(t=e.domNode)==null?void 0:t.querySelector(".react-flow__edgelabel-renderer")};function WT({children:e}){const t=de(zT);return t?Bl.createPortal(e,t):null}function GT(){const e=Ie();return O.useCallback(t=>{const{domNode:n,updateNodeDimensions:r}=e.getState(),s=(Array.isArray(t)?t:[t]).reduce((i,l)=>{const a=n==null?void 0:n.querySelector(`.react-flow__node[data-id="${l}"]`);return a&&i.push({id:l,nodeElement:a,forceUpdate:!0}),i},[]);requestAnimationFrame(()=>r(s))},[])}function YT({onStart:e,onChange:t,onEnd:n}){const r=Ie();O.useEffect(()=>{r.setState({onViewportChangeStart:e})},[e]),O.useEffect(()=>{r.setState({onViewportChange:t})},[t]),O.useEffect(()=>{r.setState({onViewportChangeEnd:n})},[n])}const KT=e=>t=>t.nodeInternals.size===0?!1:t.getNodes().filter(n=>e.includeHiddenNodes?!0:!n.hidden).every(n=>{var r;return((r=n[Ce])==null?void 0:r.handleBounds)!==void 0}),XT={includeHiddenNodes:!1};function QT(e=XT){return de(KT(e))}function qT(){return H.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},H.createElement("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"}))}function JT(){return H.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},H.createElement("path",{d:"M0 0h32v4.2H0z"}))}function ZT(){return H.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30"},H.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 eA(){return H.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},H.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 tA(){return H.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},H.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 ii=({children:e,className:t,...n})=>H.createElement("button",{type:"button",className:Je(["react-flow__controls-button",t]),...n},e);ii.displayName="ControlButton";const nA=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom}),U0=({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:o,onZoomIn:s,onZoomOut:i,onFitView:l,onInteractiveChange:a,className:c,children:u,position:f="bottom-left"})=>{const p=Ie(),[h,E]=O.useState(!1),{isInteractive:y,minZoomReached:v,maxZoomReached:m}=de(nA,Ge),{zoomIn:g,zoomOut:S,fitView:_}=Kd();if(O.useEffect(()=>{E(!0)},[]),!h)return null;const x=()=>{g(),s==null||s()},R=()=>{S(),i==null||i()},T=()=>{_(o),l==null||l()},L=()=>{p.setState({nodesDraggable:!y,nodesConnectable:!y,elementsSelectable:!y}),a==null||a(!y)};return H.createElement(Zs,{className:Je(["react-flow__controls",c]),position:f,style:e,"data-testid":"rf__controls"},t&&H.createElement(H.Fragment,null,H.createElement(ii,{onClick:x,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:m},H.createElement(qT,null)),H.createElement(ii,{onClick:R,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:v},H.createElement(JT,null))),n&&H.createElement(ii,{className:"react-flow__controls-fitview",onClick:T,title:"fit view","aria-label":"fit view"},H.createElement(ZT,null)),r&&H.createElement(ii,{className:"react-flow__controls-interactive",onClick:L,title:"toggle interactivity","aria-label":"toggle interactivity"},y?H.createElement(tA,null):H.createElement(eA,null)),u)};U0.displayName="Controls";var rA=O.memo(U0),Ct;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Ct||(Ct={}));function oA({color:e,dimensions:t,lineWidth:n}){return H.createElement("path",{stroke:e,strokeWidth:n,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`})}function sA({color:e,radius:t}){return H.createElement("circle",{cx:t,cy:t,r:t,fill:e})}const iA={[Ct.Dots]:"#91919a",[Ct.Lines]:"#eee",[Ct.Cross]:"#e2e2e2"},lA={[Ct.Dots]:1,[Ct.Lines]:1,[Ct.Cross]:6},aA=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function F0({id:e,variant:t=Ct.Dots,gap:n=20,size:r,lineWidth:o=1,offset:s=2,color:i,style:l,className:a}){const c=O.useRef(null),{transform:u,patternId:f}=de(aA,Ge),p=i||iA[t],h=r||lA[t],E=t===Ct.Dots,y=t===Ct.Cross,v=Array.isArray(n)?n:[n,n],m=[v[0]*u[2]||1,v[1]*u[2]||1],g=h*u[2],S=y?[g,g]:m,_=E?[g/s,g/s]:[S[0]/s,S[1]/s];return H.createElement("svg",{className:Je(["react-flow__background",a]),style:{...l,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:c,"data-testid":"rf__background"},H.createElement("pattern",{id:f+e,x:u[0]%m[0],y:u[1]%m[1],width:m[0],height:m[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${_[0]},-${_[1]})`},E?H.createElement(sA,{color:p,radius:g/s}):H.createElement(oA,{dimensions:S,color:p,lineWidth:o})),H.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${f+e})`}))}F0.displayName="Background";var cA=O.memo(F0),j0={VITE_APP_VERSION_HASH:"1510b28",VITE_BASE_URL:"http://localhost:8080",VITE_BASIC_AUTH:"7bfc11e6-4eee-4015-9289-20a6baf44443:PTf2c0aaa85a8064ee8ed44bc969a75280710be8d4b27af8a8",VITE_FLOW_DATA_VERSION:"0.0.10",VITE_DEFAULT_STYLE_HREF:"https://cdn.signalwire.com/npm/@signalwire/cfb@latest/dist/style.css",VITE_DEFAULT_VOICES_URL:"https://cdn.signalwire.com/npm/@signalwire/cfb@latest/dist/voices.json",BASE_URL:"/cfb/",MODE:"production",DEV:!1,PROD:!0,SSR:!1};const{useDebugValue:uA}=H,{useSyncExternalStoreWithSelector:dA}=Tg;let V0=!1;function fA(e,t=e.getState,n){(j0?"production":void 0)!=="production"&&n&&!V0&&(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"),V0=!0);const r=dA(e.subscribe,e.getState,e.getServerState||e.getState,t,n);return uA(r),r}const $0=e=>{(j0?"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"?Ig(e):e,n=(r,o)=>fA(t,r,o);return Object.assign(n,t),n},bo=e=>e?$0(e):$0;var pA={VITE_APP_VERSION_HASH:"1510b28",VITE_BASE_URL:"http://localhost:8080",VITE_BASIC_AUTH:"7bfc11e6-4eee-4015-9289-20a6baf44443:PTf2c0aaa85a8064ee8ed44bc969a75280710be8d4b27af8a8",VITE_FLOW_DATA_VERSION:"0.0.10",VITE_DEFAULT_STYLE_HREF:"https://cdn.signalwire.com/npm/@signalwire/cfb@latest/dist/style.css",VITE_DEFAULT_VOICES_URL:"https://cdn.signalwire.com/npm/@signalwire/cfb@latest/dist/voices.json",BASE_URL:"/cfb/",MODE:"production",DEV:!1,PROD:!0,SSR:!1};const hA=!1,mA=pA.VITE_IS_STAGING,gA=mA?"staging":"prod",EA="0.0.12",li="0.0.10",H0=230,yA=640,B0=20,Do={markerEnd:{height:20,type:ni.ArrowClosed,width:20},style:{stroke:"inherit",strokeWidth:1.5},type:"floating"},vA="422",_A="404",z0="document-sync",nf=1e3,SA=1e3,xA=300,RA=5e3,W0=300,NA="Shift+Backspace",wA="Meta",OA="Shift",ya=25,rf={duration:nf,includeHiddenNodes:!1,padding:.3},of=()=>{const e={},t=document.querySelector('meta[name="csrf-token"]');return t&&(e["X-CSRF-Token"]=t==null?void 0:t.content),e},TA=(e,t)=>{var s;const n=new Blob([JSON.stringify({edges:t,nodes:e},null,2)],{type:"application/json"}),r=window.URL.createObjectURL(n),o=window.open();(s=o==null?void 0:o.location)!=null&&s.href&&(o.location.href=r)},G0=e=>({...e,...Do}),Y0=e=>e.type==="handleCall"?{...e,deletable:!1}:e,K0=e=>e==="success"?"positive":"negative",AA=e=>e.toLowerCase().replace(/ /g,"-"),yt=e=>typeof e=="string"?e.trim():e,X0=(e,t,n)=>e.sort((r,o)=>{const s=n?r[n]:r,i=n?o[n]:o;if(typeof s=="string"&&typeof i=="string")return t==="asc"?s.toLowerCase().localeCompare(i.toLowerCase()):i.toLowerCase().localeCompare(s.toLowerCase());if(typeof s=="number"&&typeof i=="number")return t==="asc"?s-i:i-s;throw new Error(`sort fn can only sort strings & numbers, but got ${typeof s} and ${typeof i}`)}),IA=e=>{try{return new URL(e).pathname.split("/").at(-1)}catch{return""}};function Q0(e,t){const n=[{divisor:1,threshold:60,unit:"second"},{divisor:60,threshold:3600,unit:"minute"},{divisor:3600,threshold:86400,unit:"hour"},{divisor:86400,threshold:86400,unit:"day"}],r=new Intl.RelativeTimeFormat(e,{numeric:"always",...t});return function(s,i={}){const{excludeUnits:l={}}=i,a=new Date().getTime(),c=new Date(s).getTime(),u=Math.floor((a-c)/1e3),f=n.filter(({unit:y})=>!l[y]),{divisor:p,unit:h}=f.find(({threshold:y})=>Math.abs(u)<y)??f[f.length-1],E=Math.floor(u/p);return r.format(-E,h)}}function q0(e){return new Promise(t=>setTimeout(t,e))}const CA=(e,t,n)=>{const r=e==="ArrowDown";if(!t)return r?n[0]:n[n.length-1];const o=n.findIndex(l=>l.id===t),s=r?o+1:o-1;if(s<0||s>=n.length)return;const i=n[s];if(!i)throw new Error(`Could not find option at index ${s}`);return i},J0=(e,t,n)=>{const r=e.find(o=>{if(t in o)return o[t]===n});if(!r)throw new Error(`Could not find option with id ${t}`);return r},LA=e=>Object.keys(e),sf=()=>({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"}]}),Z0={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:()=>({...sf(),destinationType:"address"}),forwardPhone:()=>({...sf(),destinationType:"phone"}),forwardResource:()=>({...sf(),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:[]})},bA={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 va{constructor(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.init(t,n)}init(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.prefix=n.prefix||"i18next:",this.logger=t||bA,this.options=n,this.debug=n.debug}log(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return this.forward(n,"log","",!0)}warn(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return this.forward(n,"warn","",!0)}error(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return this.forward(n,"error","")}deprecate(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return this.forward(n,"warn","WARNING DEPRECATED: ",!0)}forward(t,n,r,o){return o&&!this.debug?null:(typeof t[0]=="string"&&(t[0]=`${r}${this.prefix} ${t[0]}`),this.logger[n](t))}create(t){return new va(this.logger,{prefix:`${this.prefix}:${t}:`,...this.options})}clone(t){return t=t||this.options,t.prefix=t.prefix||this.prefix,new va(this.logger,t)}}var Jt=new va;class _a{constructor(){this.observers={}}on(t,n){return t.split(" ").forEach(r=>{this.observers[r]=this.observers[r]||[],this.observers[r].push(n)}),this}off(t,n){if(this.observers[t]){if(!n){delete this.observers[t];return}this.observers[t]=this.observers[t].filter(r=>r!==n)}}emit(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];this.observers[t]&&[].concat(this.observers[t]).forEach(i=>{i(...r)}),this.observers["*"]&&[].concat(this.observers["*"]).forEach(i=>{i.apply(i,[t,...r])})}}function ai(){let e,t;const n=new Promise((r,o)=>{e=r,t=o});return n.resolve=e,n.reject=t,n}function ey(e){return e==null?"":""+e}function DA(e,t,n){e.forEach(r=>{t[r]&&(n[r]=t[r])})}function lf(e,t,n){function r(i){return i&&i.indexOf("###")>-1?i.replace(/###/g,"."):i}function o(){return!e||typeof e=="string"}const s=typeof t!="string"?[].concat(t):t.split(".");for(;s.length>1;){if(o())return{};const i=r(s.shift());!e[i]&&n&&(e[i]=new n),Object.prototype.hasOwnProperty.call(e,i)?e=e[i]:e={}}return o()?{}:{obj:e,k:r(s.shift())}}function ty(e,t,n){const{obj:r,k:o}=lf(e,t,Object);r[o]=n}function kA(e,t,n,r){const{obj:o,k:s}=lf(e,t,Object);o[s]=o[s]||[],r&&(o[s]=o[s].concat(n)),r||o[s].push(n)}function Sa(e,t){const{obj:n,k:r}=lf(e,t);if(n)return n[r]}function PA(e,t,n){const r=Sa(e,n);return r!==void 0?r:Sa(t,n)}function ny(e,t,n){for(const r in t)r!=="__proto__"&&r!=="constructor"&&(r in e?typeof e[r]=="string"||e[r]instanceof String||typeof t[r]=="string"||t[r]instanceof String?n&&(e[r]=t[r]):ny(e[r],t[r],n):e[r]=t[r]);return e}function ko(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}var MA={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};function UA(e){return typeof e=="string"?e.replace(/[&<>"'\/]/g,t=>MA[t]):e}const FA=[" ",",","?","!",";"];function jA(e,t,n){t=t||"",n=n||"";const r=FA.filter(i=>t.indexOf(i)<0&&n.indexOf(i)<0);if(r.length===0)return!0;const o=new RegExp(`(${r.map(i=>i==="?"?"\\?":i).join("|")})`);let s=!o.test(e);if(!s){const i=e.indexOf(n);i>0&&!o.test(e.substring(0,i))&&(s=!0)}return s}function xa(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:".";if(!e)return;if(e[t])return e[t];const r=t.split(n);let o=e;for(let s=0;s<r.length;++s){if(!o||typeof o[r[s]]=="string"&&s+1<r.length)return;if(o[r[s]]===void 0){let i=2,l=r.slice(s,s+i).join(n),a=o[l];for(;a===void 0&&r.length>s+i;)i++,l=r.slice(s,s+i).join(n),a=o[l];if(a===void 0)return;if(a===null)return null;if(t.endsWith(l)){if(typeof a=="string")return a;if(l&&typeof a[l]=="string")return a[l]}const c=r.slice(s+i).join(n);return c?xa(a,c,n):void 0}o=o[r[s]]}return o}function Ra(e){return e&&e.indexOf("_")>0?e.replace("_","-"):e}class ry extends _a{constructor(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{ns:["translation"],defaultNS:"translation"};super(),this.data=t||{},this.options=n,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 n=this.options.ns.indexOf(t);n>-1&&this.options.ns.splice(n,1)}getResource(t,n,r){let o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};const s=o.keySeparator!==void 0?o.keySeparator:this.options.keySeparator,i=o.ignoreJSONStructure!==void 0?o.ignoreJSONStructure:this.options.ignoreJSONStructure;let l=[t,n];r&&typeof r!="string"&&(l=l.concat(r)),r&&typeof r=="string"&&(l=l.concat(s?r.split(s):r)),t.indexOf(".")>-1&&(l=t.split("."));const a=Sa(this.data,l);return a||!i||typeof r!="string"?a:xa(this.data&&this.data[t]&&this.data[t][n],r,s)}addResource(t,n,r,o){let s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{silent:!1};const i=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator;let l=[t,n];r&&(l=l.concat(i?r.split(i):r)),t.indexOf(".")>-1&&(l=t.split("."),o=n,n=l[1]),this.addNamespaces(n),ty(this.data,l,o),s.silent||this.emit("added",t,n,r,o)}addResources(t,n,r){let o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{silent:!1};for(const s in r)(typeof r[s]=="string"||Object.prototype.toString.apply(r[s])==="[object Array]")&&this.addResource(t,n,s,r[s],{silent:!0});o.silent||this.emit("added",t,n,r)}addResourceBundle(t,n,r,o,s){let i=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{silent:!1},l=[t,n];t.indexOf(".")>-1&&(l=t.split("."),o=r,r=n,n=l[1]),this.addNamespaces(n);let a=Sa(this.data,l)||{};o?ny(a,r,s):a={...a,...r},ty(this.data,l,a),i.silent||this.emit("added",t,n,r)}removeResourceBundle(t,n){this.hasResourceBundle(t,n)&&delete this.data[t][n],this.removeNamespaces(n),this.emit("removed",t,n)}hasResourceBundle(t,n){return this.getResource(t,n)!==void 0}getResourceBundle(t,n){return n||(n=this.options.defaultNS),this.options.compatibilityAPI==="v1"?{...this.getResource(t,n)}:this.getResource(t,n)}getDataByLanguage(t){return this.data[t]}hasLanguageSomeTranslations(t){const n=this.getDataByLanguage(t);return!!(n&&Object.keys(n)||[]).find(o=>n[o]&&Object.keys(n[o]).length>0)}toJSON(){return this.data}}var oy={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,n,r,o){return e.forEach(s=>{this.processors[s]&&(t=this.processors[s].process(t,n,r,o))}),t}};const sy={};class Na extends _a{constructor(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),DA(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],t,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=Jt.create("translator")}changeLanguage(t){t&&(this.language=t)}exists(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}};if(t==null)return!1;const r=this.resolve(t,n);return r&&r.res!==void 0}extractFromKey(t,n){let r=n.nsSeparator!==void 0?n.nsSeparator:this.options.nsSeparator;r===void 0&&(r=":");const o=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let s=n.ns||this.options.defaultNS||[];const i=r&&t.indexOf(r)>-1,l=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!jA(t,r,o);if(i&&!l){const a=t.match(this.interpolator.nestingRegexp);if(a&&a.length>0)return{key:t,namespaces:s};const c=t.split(r);(r!==o||r===o&&this.options.ns.indexOf(c[0])>-1)&&(s=c.shift()),t=c.join(o)}return typeof s=="string"&&(s=[s]),{key:t,namespaces:s}}translate(t,n,r){if(typeof n!="object"&&this.options.overloadTranslationOptionHandler&&(n=this.options.overloadTranslationOptionHandler(arguments)),typeof n=="object"&&(n={...n}),n||(n={}),t==null)return"";Array.isArray(t)||(t=[String(t)]);const o=n.returnDetails!==void 0?n.returnDetails:this.options.returnDetails,s=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator,{key:i,namespaces:l}=this.extractFromKey(t[t.length-1],n),a=l[l.length-1],c=n.lng||this.language,u=n.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(c&&c.toLowerCase()==="cimode"){if(u){const _=n.nsSeparator||this.options.nsSeparator;return o?{res:`${a}${_}${i}`,usedKey:i,exactUsedKey:i,usedLng:c,usedNS:a,usedParams:this.getUsedParamsDetails(n)}:`${a}${_}${i}`}return o?{res:i,usedKey:i,exactUsedKey:i,usedLng:c,usedNS:a,usedParams:this.getUsedParamsDetails(n)}:i}const f=this.resolve(t,n);let p=f&&f.res;const h=f&&f.usedKey||i,E=f&&f.exactUsedKey||i,y=Object.prototype.toString.apply(p),v=["[object Number]","[object Function]","[object RegExp]"],m=n.joinArrays!==void 0?n.joinArrays:this.options.joinArrays,g=!this.i18nFormat||this.i18nFormat.handleAsObject;if(g&&p&&(typeof p!="string"&&typeof p!="boolean"&&typeof p!="number")&&v.indexOf(y)<0&&!(typeof m=="string"&&y==="[object Array]")){if(!n.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const _=this.options.returnedObjectHandler?this.options.returnedObjectHandler(h,p,{...n,ns:l}):`key '${i} (${this.language})' returned an object instead of string.`;return o?(f.res=_,f.usedParams=this.getUsedParamsDetails(n),f):_}if(s){const _=y==="[object Array]",x=_?[]:{},R=_?E:h;for(const T in p)if(Object.prototype.hasOwnProperty.call(p,T)){const L=`${R}${s}${T}`;x[T]=this.translate(L,{...n,joinArrays:!1,ns:l}),x[T]===L&&(x[T]=p[T])}p=x}}else if(g&&typeof m=="string"&&y==="[object Array]")p=p.join(m),p&&(p=this.extendTranslation(p,t,n,r));else{let _=!1,x=!1;const R=n.count!==void 0&&typeof n.count!="string",T=Na.hasDefaultValue(n),L=R?this.pluralResolver.getSuffix(c,n.count,n):"",P=n.ordinal&&R?this.pluralResolver.getSuffix(c,n.count,{ordinal:!1}):"",I=n[`defaultValue${L}`]||n[`defaultValue${P}`]||n.defaultValue;!this.isValidLookup(p)&&T&&(_=!0,p=I),this.isValidLookup(p)||(x=!0,p=i);const V=(n.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&x?void 0:p,M=T&&I!==p&&this.options.updateMissing;if(x||_||M){if(this.logger.log(M?"updateKey":"missingKey",c,a,i,M?I:p),s){const F=this.resolve(i,{...n,keySeparator:!1});F&&F.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 w=[];const b=this.languageUtils.getFallbackCodes(this.options.fallbackLng,n.lng||this.language);if(this.options.saveMissingTo==="fallback"&&b&&b[0])for(let F=0;F<b.length;F++)w.push(b[F]);else this.options.saveMissingTo==="all"?w=this.languageUtils.toResolveHierarchy(n.lng||this.language):w.push(n.lng||this.language);const k=(F,C,D)=>{const U=T&&D!==p?D:V;this.options.missingKeyHandler?this.options.missingKeyHandler(F,a,C,U,M,n):this.backendConnector&&this.backendConnector.saveMissing&&this.backendConnector.saveMissing(F,a,C,U,M,n),this.emit("missingKey",F,a,C,p)};this.options.saveMissing&&(this.options.saveMissingPlurals&&R?w.forEach(F=>{this.pluralResolver.getSuffixes(F,n).forEach(C=>{k([F],i+C,n[`defaultValue${C}`]||I)})}):k(w,i,I))}p=this.extendTranslation(p,t,n,f,r),x&&p===i&&this.options.appendNamespaceToMissingKey&&(p=`${a}:${i}`),(x||_)&&this.options.parseMissingKeyHandler&&(this.options.compatibilityAPI!=="v1"?p=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${a}:${i}`:i,_?p:void 0):p=this.options.parseMissingKeyHandler(p))}return o?(f.res=p,f.usedParams=this.getUsedParamsDetails(n),f):p}extendTranslation(t,n,r,o,s){var i=this;if(this.i18nFormat&&this.i18nFormat.parse)t=this.i18nFormat.parse(t,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||o.usedLng,o.usedNS,o.usedKey,{resolved:o});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init({...r,interpolation:{...this.options.interpolation,...r.interpolation}});const c=typeof t=="string"&&(r&&r.interpolation&&r.interpolation.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let u;if(c){const p=t.match(this.interpolator.nestingRegexp);u=p&&p.length}let f=r.replace&&typeof r.replace!="string"?r.replace:r;if(this.options.interpolation.defaultVariables&&(f={...this.options.interpolation.defaultVariables,...f}),t=this.interpolator.interpolate(t,f,r.lng||this.language,r),c){const p=t.match(this.interpolator.nestingRegexp),h=p&&p.length;u<h&&(r.nest=!1)}!r.lng&&this.options.compatibilityAPI!=="v1"&&o&&o.res&&(r.lng=o.usedLng),r.nest!==!1&&(t=this.interpolator.nest(t,function(){for(var p=arguments.length,h=new Array(p),E=0;E<p;E++)h[E]=arguments[E];return s&&s[0]===h[0]&&!r.context?(i.logger.warn(`It seems you are nesting recursively key: ${h[0]} in key: ${n[0]}`),null):i.translate(...h,n)},r)),r.interpolation&&this.interpolator.reset()}const l=r.postProcess||this.options.postProcess,a=typeof l=="string"?[l]:l;return t!=null&&a&&a.length&&r.applyPostProcessor!==!1&&(t=oy.handle(a,t,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...o,usedParams:this.getUsedParamsDetails(r)},...r}:r,this)),t}resolve(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r,o,s,i,l;return typeof t=="string"&&(t=[t]),t.forEach(a=>{if(this.isValidLookup(r))return;const c=this.extractFromKey(a,n),u=c.key;o=u;let f=c.namespaces;this.options.fallbackNS&&(f=f.concat(this.options.fallbackNS));const p=n.count!==void 0&&typeof n.count!="string",h=p&&!n.ordinal&&n.count===0&&this.pluralResolver.shouldUseIntlApi(),E=n.context!==void 0&&(typeof n.context=="string"||typeof n.context=="number")&&n.context!=="",y=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);f.forEach(v=>{this.isValidLookup(r)||(l=v,!sy[`${y[0]}-${v}`]&&this.utils&&this.utils.hasLoadedNamespace&&!this.utils.hasLoadedNamespace(l)&&(sy[`${y[0]}-${v}`]=!0,this.logger.warn(`key "${o}" for languages "${y.join(", ")}" won't get resolved as namespace "${l}" 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!!!")),y.forEach(m=>{if(this.isValidLookup(r))return;i=m;const g=[u];if(this.i18nFormat&&this.i18nFormat.addLookupKeys)this.i18nFormat.addLookupKeys(g,u,m,v,n);else{let _;p&&(_=this.pluralResolver.getSuffix(m,n.count,n));const x=`${this.options.pluralSeparator}zero`,R=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(p&&(g.push(u+_),n.ordinal&&_.indexOf(R)===0&&g.push(u+_.replace(R,this.options.pluralSeparator)),h&&g.push(u+x)),E){const T=`${u}${this.options.contextSeparator}${n.context}`;g.push(T),p&&(g.push(T+_),n.ordinal&&_.indexOf(R)===0&&g.push(T+_.replace(R,this.options.pluralSeparator)),h&&g.push(T+x))}}let S;for(;S=g.pop();)this.isValidLookup(r)||(s=S,r=this.getResource(m,v,S,n))}))})}),{res:r,usedKey:o,exactUsedKey:s,usedLng:i,usedNS:l}}isValidLookup(t){return t!==void 0&&!(!this.options.returnNull&&t===null)&&!(!this.options.returnEmptyString&&t==="")}getResource(t,n,r){let o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return this.i18nFormat&&this.i18nFormat.getResource?this.i18nFormat.getResource(t,n,r,o):this.resourceStore.getResource(t,n,r,o)}getUsedParamsDetails(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const n=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],r=t.replace&&typeof t.replace!="string";let o=r?t.replace:t;if(r&&typeof t.count<"u"&&(o.count=t.count),this.options.interpolation.defaultVariables&&(o={...this.options.interpolation.defaultVariables,...o}),!r){o={...o};for(const s of n)delete o[s]}return o}static hasDefaultValue(t){const n="defaultValue";for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&n===r.substring(0,n.length)&&t[r]!==void 0)return!0;return!1}}function af(e){return e.charAt(0).toUpperCase()+e.slice(1)}class iy{constructor(t){this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Jt.create("languageUtils")}getScriptPartFromCode(t){if(t=Ra(t),!t||t.indexOf("-")<0)return null;const n=t.split("-");return n.length===2||(n.pop(),n[n.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(n.join("-"))}getLanguagePartFromCode(t){if(t=Ra(t),!t||t.indexOf("-")<0)return t;const n=t.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(t){if(typeof t=="string"&&t.indexOf("-")>-1){const n=["hans","hant","latn","cyrl","cans","mong","arab"];let r=t.split("-");return this.options.lowerCaseLng?r=r.map(o=>o.toLowerCase()):r.length===2?(r[0]=r[0].toLowerCase(),r[1]=r[1].toUpperCase(),n.indexOf(r[1].toLowerCase())>-1&&(r[1]=af(r[1].toLowerCase()))):r.length===3&&(r[0]=r[0].toLowerCase(),r[1].length===2&&(r[1]=r[1].toUpperCase()),r[0]!=="sgn"&&r[2].length===2&&(r[2]=r[2].toUpperCase()),n.indexOf(r[1].toLowerCase())>-1&&(r[1]=af(r[1].toLowerCase())),n.indexOf(r[2].toLowerCase())>-1&&(r[2]=af(r[2].toLowerCase()))),r.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 n;return t.forEach(r=>{if(n)return;const o=this.formatLanguageCode(r);(!this.options.supportedLngs||this.isSupportedCode(o))&&(n=o)}),!n&&this.options.supportedLngs&&t.forEach(r=>{if(n)return;const o=this.getLanguagePartFromCode(r);if(this.isSupportedCode(o))return n=o;n=this.options.supportedLngs.find(s=>{if(s===o)return s;if(!(s.indexOf("-")<0&&o.indexOf("-")<0)&&s.indexOf(o)===0)return s})}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n}getFallbackCodes(t,n){if(!t)return[];if(typeof t=="function"&&(t=t(n)),typeof t=="string"&&(t=[t]),Object.prototype.toString.apply(t)==="[object Array]")return t;if(!n)return t.default||[];let r=t[n];return r||(r=t[this.getScriptPartFromCode(n)]),r||(r=t[this.formatLanguageCode(n)]),r||(r=t[this.getLanguagePartFromCode(n)]),r||(r=t.default),r||[]}toResolveHierarchy(t,n){const r=this.getFallbackCodes(n||this.options.fallbackLng||[],t),o=[],s=i=>{i&&(this.isSupportedCode(i)?o.push(i):this.logger.warn(`rejecting language code not found in supportedLngs: ${i}`))};return typeof t=="string"&&(t.indexOf("-")>-1||t.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&s(this.formatLanguageCode(t)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&s(this.getScriptPartFromCode(t)),this.options.load!=="currentOnly"&&s(this.getLanguagePartFromCode(t))):typeof t=="string"&&s(this.formatLanguageCode(t)),r.forEach(i=>{o.indexOf(i)<0&&s(this.formatLanguageCode(i))}),o}}let VA=[{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}],$A={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 HA=["v1","v2","v3"],BA=["v4"],ly={zero:0,one:1,two:2,few:3,many:4,other:5};function zA(){const e={};return VA.forEach(t=>{t.lngs.forEach(n=>{e[n]={numbers:t.nr,plurals:$A[t.fc]}})}),e}class WA{constructor(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.languageUtils=t,this.options=n,this.logger=Jt.create("pluralResolver"),(!this.options.compatibilityJSON||BA.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=zA()}addRule(t,n){this.rules[t]=n}getRule(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(this.shouldUseIntlApi())try{return new Intl.PluralRules(Ra(t),{type:n.ordinal?"ordinal":"cardinal"})}catch{return}return this.rules[t]||this.rules[this.languageUtils.getLanguagePartFromCode(t)]}needsPlural(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const r=this.getRule(t,n);return this.shouldUseIntlApi()?r&&r.resolvedOptions().pluralCategories.length>1:r&&r.numbers.length>1}getPluralFormsOfKey(t,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return this.getSuffixes(t,r).map(o=>`${n}${o}`)}getSuffixes(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const r=this.getRule(t,n);return r?this.shouldUseIntlApi()?r.resolvedOptions().pluralCategories.sort((o,s)=>ly[o]-ly[s]).map(o=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${o}`):r.numbers.map(o=>this.getSuffix(t,o,n)):[]}getSuffix(t,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const o=this.getRule(t,r);return o?this.shouldUseIntlApi()?`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${o.select(n)}`:this.getSuffixRetroCompatible(o,n):(this.logger.warn(`no plural rule found for: ${t}`),"")}getSuffixRetroCompatible(t,n){const r=t.noAbs?t.plurals(n):t.plurals(Math.abs(n));let o=t.numbers[r];this.options.simplifyPluralSuffix&&t.numbers.length===2&&t.numbers[0]===1&&(o===2?o="plural":o===1&&(o=""));const s=()=>this.options.prepend&&o.toString()?this.options.prepend+o.toString():o.toString();return this.options.compatibilityJSON==="v1"?o===1?"":typeof o=="number"?`_plural_${o.toString()}`:s():this.options.compatibilityJSON==="v2"||this.options.simplifyPluralSuffix&&t.numbers.length===2&&t.numbers[0]===1?s():this.options.prepend&&r.toString()?this.options.prepend+r.toString():r.toString()}shouldUseIntlApi(){return!HA.includes(this.options.compatibilityJSON)}}function ay(e,t,n){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:".",o=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,s=PA(e,t,n);return!s&&o&&typeof n=="string"&&(s=xa(e,n,r),s===void 0&&(s=xa(t,n,r))),s}class GA{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=Jt.create("interpolator"),this.options=t,this.format=t.interpolation&&t.interpolation.format||(n=>n),this.init(t)}init(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};t.interpolation||(t.interpolation={escapeValue:!0});const n=t.interpolation;this.escape=n.escape!==void 0?n.escape:UA,this.escapeValue=n.escapeValue!==void 0?n.escapeValue:!0,this.useRawValueToEscape=n.useRawValueToEscape!==void 0?n.useRawValueToEscape:!1,this.prefix=n.prefix?ko(n.prefix):n.prefixEscaped||"{{",this.suffix=n.suffix?ko(n.suffix):n.suffixEscaped||"}}",this.formatSeparator=n.formatSeparator?n.formatSeparator:n.formatSeparator||",",this.unescapePrefix=n.unescapeSuffix?"":n.unescapePrefix||"-",this.unescapeSuffix=this.unescapePrefix?"":n.unescapeSuffix||"",this.nestingPrefix=n.nestingPrefix?ko(n.nestingPrefix):n.nestingPrefixEscaped||ko("$t("),this.nestingSuffix=n.nestingSuffix?ko(n.nestingSuffix):n.nestingSuffixEscaped||ko(")"),this.nestingOptionsSeparator=n.nestingOptionsSeparator?n.nestingOptionsSeparator:n.nestingOptionsSeparator||",",this.maxReplaces=n.maxReplaces?n.maxReplaces:1e3,this.alwaysFormat=n.alwaysFormat!==void 0?n.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 n=`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`;this.regexpUnescape=new RegExp(n,"g");const r=`${this.nestingPrefix}(.+?)${this.nestingSuffix}`;this.nestingRegexp=new RegExp(r,"g")}interpolate(t,n,r,o){let s,i,l;const a=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{};function c(E){return E.replace(/\$/g,"$$$$")}const u=E=>{if(E.indexOf(this.formatSeparator)<0){const g=ay(n,a,E,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(g,void 0,r,{...o,...n,interpolationkey:E}):g}const y=E.split(this.formatSeparator),v=y.shift().trim(),m=y.join(this.formatSeparator).trim();return this.format(ay(n,a,v,this.options.keySeparator,this.options.ignoreJSONStructure),m,r,{...o,...n,interpolationkey:v})};this.resetRegExp();const f=o&&o.missingInterpolationHandler||this.options.missingInterpolationHandler,p=o&&o.interpolation&&o.interpolation.skipOnVariables!==void 0?o.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:E=>c(E)},{regex:this.regexp,safeValue:E=>this.escapeValue?c(this.escape(E)):c(E)}].forEach(E=>{for(l=0;s=E.regex.exec(t);){const y=s[1].trim();if(i=u(y),i===void 0)if(typeof f=="function"){const m=f(t,s,o);i=typeof m=="string"?m:""}else if(o&&Object.prototype.hasOwnProperty.call(o,y))i="";else if(p){i=s[0];continue}else this.logger.warn(`missed to pass in variable ${y} for interpolating ${t}`),i="";else typeof i!="string"&&!this.useRawValueToEscape&&(i=ey(i));const v=E.safeValue(i);if(t=t.replace(s[0],v),p?(E.regex.lastIndex+=i.length,E.regex.lastIndex-=s[0].length):E.regex.lastIndex=0,l++,l>=this.maxReplaces)break}}),t}nest(t,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},o,s,i;function l(a,c){const u=this.nestingOptionsSeparator;if(a.indexOf(u)<0)return a;const f=a.split(new RegExp(`${u}[ ]*{`));let p=`{${f[1]}`;a=f[0],p=this.interpolate(p,i);const h=p.match(/'/g),E=p.match(/"/g);(h&&h.length%2===0&&!E||E.length%2!==0)&&(p=p.replace(/'/g,'"'));try{i=JSON.parse(p),c&&(i={...c,...i})}catch(y){return this.logger.warn(`failed parsing options string in nesting for key ${a}`,y),`${a}${u}${p}`}return delete i.defaultValue,a}for(;o=this.nestingRegexp.exec(t);){let a=[];i={...r},i=i.replace&&typeof i.replace!="string"?i.replace:i,i.applyPostProcessor=!1,delete i.defaultValue;let c=!1;if(o[0].indexOf(this.formatSeparator)!==-1&&!/{.*}/.test(o[1])){const u=o[1].split(this.formatSeparator).map(f=>f.trim());o[1]=u.shift(),a=u,c=!0}if(s=n(l.call(this,o[1].trim(),i),i),s&&o[0]===t&&typeof s!="string")return s;typeof s!="string"&&(s=ey(s)),s||(this.logger.warn(`missed to resolve ${o[1]} for nesting ${t}`),s=""),c&&(s=a.reduce((u,f)=>this.format(u,f,r.lng,{...r,interpolationkey:o[1].trim()}),s.trim())),t=t.replace(o[0],s),this.regexp.lastIndex=0}return t}}function YA(e){let t=e.toLowerCase().trim();const n={};if(e.indexOf("(")>-1){const r=e.split("(");t=r[0].toLowerCase().trim();const o=r[1].substring(0,r[1].length-1);t==="currency"&&o.indexOf(":")<0?n.currency||(n.currency=o.trim()):t==="relativetime"&&o.indexOf(":")<0?n.range||(n.range=o.trim()):o.split(";").forEach(i=>{if(!i)return;const[l,...a]=i.split(":"),c=a.join(":").trim().replace(/^'+|'+$/g,"");n[l.trim()]||(n[l.trim()]=c),c==="false"&&(n[l.trim()]=!1),c==="true"&&(n[l.trim()]=!0),isNaN(c)||(n[l.trim()]=parseInt(c,10))})}return{formatName:t,formatOptions:n}}function Po(e){const t={};return function(r,o,s){const i=o+JSON.stringify(s);let l=t[i];return l||(l=e(Ra(o),s),t[i]=l),l(r)}}class KA{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=Jt.create("formatter"),this.options=t,this.formats={number:Po((n,r)=>{const o=new Intl.NumberFormat(n,{...r});return s=>o.format(s)}),currency:Po((n,r)=>{const o=new Intl.NumberFormat(n,{...r,style:"currency"});return s=>o.format(s)}),datetime:Po((n,r)=>{const o=new Intl.DateTimeFormat(n,{...r});return s=>o.format(s)}),relativetime:Po((n,r)=>{const o=new Intl.RelativeTimeFormat(n,{...r});return s=>o.format(s,r.range||"day")}),list:Po((n,r)=>{const o=new Intl.ListFormat(n,{...r});return s=>o.format(s)})},this.init(t)}init(t){const r=(arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}}).interpolation;this.formatSeparator=r.formatSeparator?r.formatSeparator:r.formatSeparator||","}add(t,n){this.formats[t.toLowerCase().trim()]=n}addCached(t,n){this.formats[t.toLowerCase().trim()]=Po(n)}format(t,n,r){let o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return n.split(this.formatSeparator).reduce((l,a)=>{const{formatName:c,formatOptions:u}=YA(a);if(this.formats[c]){let f=l;try{const p=o&&o.formatParams&&o.formatParams[o.interpolationkey]||{},h=p.locale||p.lng||o.locale||o.lng||r;f=this.formats[c](l,h,{...u,...o,...p})}catch(p){this.logger.warn(p)}return f}else this.logger.warn(`there was no format function for ${c}`);return l},t)}}function XA(e,t){e.pending[t]!==void 0&&(delete e.pending[t],e.pendingCount--)}class QA extends _a{constructor(t,n,r){let o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};super(),this.backend=t,this.store=n,this.services=r,this.languageUtils=r.languageUtils,this.options=o,this.logger=Jt.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=o.maxParallelReads||10,this.readingCalls=0,this.maxRetries=o.maxRetries>=0?o.maxRetries:5,this.retryTimeout=o.retryTimeout>=1?o.retryTimeout:350,this.state={},this.queue=[],this.backend&&this.backend.init&&this.backend.init(r,o.backend,o)}queueLoad(t,n,r,o){const s={},i={},l={},a={};return t.forEach(c=>{let u=!0;n.forEach(f=>{const p=`${c}|${f}`;!r.reload&&this.store.hasResourceBundle(c,f)?this.state[p]=2:this.state[p]<0||(this.state[p]===1?i[p]===void 0&&(i[p]=!0):(this.state[p]=1,u=!1,i[p]===void 0&&(i[p]=!0),s[p]===void 0&&(s[p]=!0),a[f]===void 0&&(a[f]=!0)))}),u||(l[c]=!0)}),(Object.keys(s).length||Object.keys(i).length)&&this.queue.push({pending:i,pendingCount:Object.keys(i).length,loaded:{},errors:[],callback:o}),{toLoad:Object.keys(s),pending:Object.keys(i),toLoadLanguages:Object.keys(l),toLoadNamespaces:Object.keys(a)}}loaded(t,n,r){const o=t.split("|"),s=o[0],i=o[1];n&&this.emit("failedLoading",s,i,n),r&&this.store.addResourceBundle(s,i,r),this.state[t]=n?-1:2;const l={};this.queue.forEach(a=>{kA(a.loaded,[s],i),XA(a,t),n&&a.errors.push(n),a.pendingCount===0&&!a.done&&(Object.keys(a.loaded).forEach(c=>{l[c]||(l[c]={});const u=a.loaded[c];u.length&&u.forEach(f=>{l[c][f]===void 0&&(l[c][f]=!0)})}),a.done=!0,a.errors.length?a.callback(a.errors):a.callback())}),this.emit("loaded",l),this.queue=this.queue.filter(a=>!a.done)}read(t,n,r){let o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:this.retryTimeout,i=arguments.length>5?arguments[5]:void 0;if(!t.length)return i(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:t,ns:n,fcName:r,tried:o,wait:s,callback:i});return}this.readingCalls++;const l=(c,u)=>{if(this.readingCalls--,this.waitingReads.length>0){const f=this.waitingReads.shift();this.read(f.lng,f.ns,f.fcName,f.tried,f.wait,f.callback)}if(c&&u&&o<this.maxRetries){setTimeout(()=>{this.read.call(this,t,n,r,o+1,s*2,i)},s);return}i(c,u)},a=this.backend[r].bind(this.backend);if(a.length===2){try{const c=a(t,n);c&&typeof c.then=="function"?c.then(u=>l(null,u)).catch(l):l(null,c)}catch(c){l(c)}return}return a(t,n,l)}prepareLoading(t,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},o=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."),o&&o();typeof t=="string"&&(t=this.languageUtils.toResolveHierarchy(t)),typeof n=="string"&&(n=[n]);const s=this.queueLoad(t,n,r,o);if(!s.toLoad.length)return s.pending.length||o(),null;s.toLoad.forEach(i=>{this.loadOne(i)})}load(t,n,r){this.prepareLoading(t,n,{},r)}reload(t,n,r){this.prepareLoading(t,n,{reload:!0},r)}loadOne(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";const r=t.split("|"),o=r[0],s=r[1];this.read(o,s,"read",void 0,void 0,(i,l)=>{i&&this.logger.warn(`${n}loading namespace ${s} for language ${o} failed`,i),!i&&l&&this.logger.log(`${n}loaded namespace ${s} for language ${o}`,l),this.loaded(t,i,l)})}saveMissing(t,n,r,o,s){let i=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{},l=arguments.length>6&&arguments[6]!==void 0?arguments[6]:()=>{};if(this.services.utils&&this.services.utils.hasLoadedNamespace&&!this.services.utils.hasLoadedNamespace(n)){this.logger.warn(`did not save key "${r}" as the namespace "${n}" 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(!(r==null||r==="")){if(this.backend&&this.backend.create){const a={...i,isUpdate:s},c=this.backend.create.bind(this.backend);if(c.length<6)try{let u;c.length===5?u=c(t,n,r,o,a):u=c(t,n,r,o),u&&typeof u.then=="function"?u.then(f=>l(null,f)).catch(l):l(null,u)}catch(u){l(u)}else c(t,n,r,o,l,a)}!t||!t[0]||this.store.addResource(t[0],n,r,o)}}}function cy(){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 n={};if(typeof t[1]=="object"&&(n=t[1]),typeof t[1]=="string"&&(n.defaultValue=t[1]),typeof t[2]=="string"&&(n.tDescription=t[2]),typeof t[2]=="object"||typeof t[3]=="object"){const r=t[3]||t[2];Object.keys(r).forEach(o=>{n[o]=r[o]})}return n},interpolation:{escapeValue:!0,format:(e,t,n,r)=>e,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0}}}function uy(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 wa(){}function qA(e){Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(n=>{typeof e[n]=="function"&&(e[n]=e[n].bind(e))})}class ci extends _a{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;if(super(),this.options=uy(t),this.services={},this.logger=Jt,this.modules={external:[]},qA(this),n&&!this.isInitialized&&!t.isClone){if(!this.options.initImmediate)return this.init(t,n),this;setTimeout(()=>{this.init(t,n)},0)}}init(){var t=this;let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;typeof n=="function"&&(r=n,n={}),!n.defaultNS&&n.defaultNS!==!1&&n.ns&&(typeof n.ns=="string"?n.defaultNS=n.ns:n.ns.indexOf("translation")<0&&(n.defaultNS=n.ns[0]));const o=cy();this.options={...o,...this.options,...uy(n)},this.options.compatibilityAPI!=="v1"&&(this.options.interpolation={...o.interpolation,...this.options.interpolation}),n.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=n.keySeparator),n.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=n.nsSeparator);function s(u){return u?typeof u=="function"?new u:u:null}if(!this.options.isClone){this.modules.logger?Jt.init(s(this.modules.logger),this.options):Jt.init(null,this.options);let u;this.modules.formatter?u=this.modules.formatter:typeof Intl<"u"&&(u=KA);const f=new iy(this.options);this.store=new ry(this.options.resources,this.options);const p=this.services;p.logger=Jt,p.resourceStore=this.store,p.languageUtils=f,p.pluralResolver=new WA(f,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),u&&(!this.options.interpolation.format||this.options.interpolation.format===o.interpolation.format)&&(p.formatter=s(u),p.formatter.init(p,this.options),this.options.interpolation.format=p.formatter.format.bind(p.formatter)),p.interpolator=new GA(this.options),p.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},p.backendConnector=new QA(s(this.modules.backend),p.resourceStore,p,this.options),p.backendConnector.on("*",function(h){for(var E=arguments.length,y=new Array(E>1?E-1:0),v=1;v<E;v++)y[v-1]=arguments[v];t.emit(h,...y)}),this.modules.languageDetector&&(p.languageDetector=s(this.modules.languageDetector),p.languageDetector.init&&p.languageDetector.init(p,this.options.detection,this.options)),this.modules.i18nFormat&&(p.i18nFormat=s(this.modules.i18nFormat),p.i18nFormat.init&&p.i18nFormat.init(this)),this.translator=new Na(this.services,this.options),this.translator.on("*",function(h){for(var E=arguments.length,y=new Array(E>1?E-1:0),v=1;v<E;v++)y[v-1]=arguments[v];t.emit(h,...y)}),this.modules.external.forEach(h=>{h.init&&h.init(this)})}if(this.format=this.options.interpolation.format,r||(r=wa),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const u=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);u.length>0&&u[0]!=="dev"&&(this.options.lng=u[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(u=>{this[u]=function(){return t.store[u](...arguments)}}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(u=>{this[u]=function(){return t.store[u](...arguments),t}});const a=ai(),c=()=>{const u=(f,p)=>{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),a.resolve(p),r(f,p)};if(this.languages&&this.options.compatibilityAPI!=="v1"&&!this.isInitialized)return u(null,this.t.bind(this));this.changeLanguage(this.options.lng,u)};return this.options.resources||!this.options.initImmediate?c():setTimeout(c,0),a}loadResources(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:wa;const o=typeof t=="string"?t:this.language;if(typeof t=="function"&&(r=t),!this.options.resources||this.options.partialBundledLanguages){if(o&&o.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return r();const s=[],i=l=>{if(!l||l==="cimode")return;this.services.languageUtils.toResolveHierarchy(l).forEach(c=>{c!=="cimode"&&s.indexOf(c)<0&&s.push(c)})};o?i(o):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(a=>i(a)),this.options.preload&&this.options.preload.forEach(l=>i(l)),this.services.backendConnector.load(s,this.options.ns,l=>{!l&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),r(l)})}else r(null)}reloadResources(t,n,r){const o=ai();return t||(t=this.languages),n||(n=this.options.ns),r||(r=wa),this.services.backendConnector.reload(t,n,s=>{o.resolve(),r(s)}),o}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"&&oy.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 n=0;n<this.languages.length;n++){const r=this.languages[n];if(!(["cimode","dev"].indexOf(r)>-1)&&this.store.hasLanguageSomeTranslations(r)){this.resolvedLanguage=r;break}}}changeLanguage(t,n){var r=this;this.isLanguageChangingTo=t;const o=ai();this.emit("languageChanging",t);const s=a=>{this.language=a,this.languages=this.services.languageUtils.toResolveHierarchy(a),this.resolvedLanguage=void 0,this.setResolvedLanguage(a)},i=(a,c)=>{c?(s(c),this.translator.changeLanguage(c),this.isLanguageChangingTo=void 0,this.emit("languageChanged",c),this.logger.log("languageChanged",c)):this.isLanguageChangingTo=void 0,o.resolve(function(){return r.t(...arguments)}),n&&n(a,function(){return r.t(...arguments)})},l=a=>{!t&&!a&&this.services.languageDetector&&(a=[]);const c=typeof a=="string"?a:this.services.languageUtils.getBestMatchFromCodes(a);c&&(this.language||s(c),this.translator.language||this.translator.changeLanguage(c),this.services.languageDetector&&this.services.languageDetector.cacheUserLanguage&&this.services.languageDetector.cacheUserLanguage(c)),this.loadResources(c,u=>{i(u,c)})};return!t&&this.services.languageDetector&&!this.services.languageDetector.async?l(this.services.languageDetector.detect()):!t&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(l):this.services.languageDetector.detect(l):l(t),o}getFixedT(t,n,r){var o=this;const s=function(i,l){let a;if(typeof l!="object"){for(var c=arguments.length,u=new Array(c>2?c-2:0),f=2;f<c;f++)u[f-2]=arguments[f];a=o.options.overloadTranslationOptionHandler([i,l].concat(u))}else a={...l};a.lng=a.lng||s.lng,a.lngs=a.lngs||s.lngs,a.ns=a.ns||s.ns,a.keyPrefix=a.keyPrefix||r||s.keyPrefix;const p=o.options.keySeparator||".";let h;return a.keyPrefix&&Array.isArray(i)?h=i.map(E=>`${a.keyPrefix}${p}${E}`):h=a.keyPrefix?`${a.keyPrefix}${p}${i}`:i,o.t(h,a)};return typeof t=="string"?s.lng=t:s.lngs=t,s.ns=n,s.keyPrefix=r,s}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 n=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 r=n.lng||this.resolvedLanguage||this.languages[0],o=this.options?this.options.fallbackLng:!1,s=this.languages[this.languages.length-1];if(r.toLowerCase()==="cimode")return!0;const i=(l,a)=>{const c=this.services.backendConnector.state[`${l}|${a}`];return c===-1||c===2};if(n.precheck){const l=n.precheck(this,i);if(l!==void 0)return l}return!!(this.hasResourceBundle(r,t)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||i(r,t)&&(!o||i(s,t)))}loadNamespaces(t,n){const r=ai();return this.options.ns?(typeof t=="string"&&(t=[t]),t.forEach(o=>{this.options.ns.indexOf(o)<0&&this.options.ns.push(o)}),this.loadResources(o=>{r.resolve(),n&&n(o)}),r):(n&&n(),Promise.resolve())}loadLanguages(t,n){const r=ai();typeof t=="string"&&(t=[t]);const o=this.options.preload||[],s=t.filter(i=>o.indexOf(i)<0);return s.length?(this.options.preload=o.concat(s),this.loadResources(i=>{r.resolve(),n&&n(i)}),r):(n&&n(),Promise.resolve())}dir(t){if(t||(t=this.resolvedLanguage||(this.languages&&this.languages.length>0?this.languages[0]:this.language)),!t)return"rtl";const n=["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"],r=this.services&&this.services.languageUtils||new iy(cy());return n.indexOf(r.getLanguagePartFromCode(t))>-1||t.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;return new ci(t,n)}cloneInstance(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:wa;const r=t.forkResourceStore;r&&delete t.forkResourceStore;const o={...this.options,...t,isClone:!0},s=new ci(o);return(t.debug!==void 0||t.prefix!==void 0)&&(s.logger=s.logger.clone(t)),["store","services","language"].forEach(l=>{s[l]=this[l]}),s.services={...this.services},s.services.utils={hasLoadedNamespace:s.hasLoadedNamespace.bind(s)},r&&(s.store=new ry(this.store.data,o),s.services.resourceStore=s.store),s.translator=new Na(s.services,o),s.translator.on("*",function(l){for(var a=arguments.length,c=new Array(a>1?a-1:0),u=1;u<a;u++)c[u-1]=arguments[u];s.emit(l,...c)}),s.init(o,n),s.translator.options=o,s.translator.backendConnector.services.utils={hasLoadedNamespace:s.hasLoadedNamespace.bind(s)},s}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const Ve=ci.createInstance();Ve.createInstance=ci.createInstance,Ve.createInstance,Ve.dir,Ve.init,Ve.loadResources,Ve.reloadResources,Ve.use,Ve.changeLanguage,Ve.getFixedT;const A=Ve.t;Ve.exists,Ve.setDefaultNamespace,Ve.hasLoadedNamespace,Ve.loadNamespaces,Ve.loadLanguages;function JA(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ui(e){"@babel/helpers - typeof";return ui=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},ui(e)}function ZA(e,t){if(ui(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(ui(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function eI(e){var t=ZA(e,"string");return ui(t)=="symbol"?t:String(t)}function dy(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,eI(r.key),r)}}function tI(e,t,n){return t&&dy(e.prototype,t),n&&dy(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}var fy=[],nI=fy.forEach,rI=fy.slice;function oI(e){return nI.call(rI.call(arguments,1),function(t){if(t)for(var n in t)e[n]===void 0&&(e[n]=t[n])}),e}var py=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,sI=function(t,n,r){var o=r||{};o.path=o.path||"/";var s=encodeURIComponent(n),i="".concat(t,"=").concat(s);if(o.maxAge>0){var l=o.maxAge-0;if(Number.isNaN(l))throw new Error("maxAge should be a Number");i+="; Max-Age=".concat(Math.floor(l))}if(o.domain){if(!py.test(o.domain))throw new TypeError("option domain is invalid");i+="; Domain=".concat(o.domain)}if(o.path){if(!py.test(o.path))throw new TypeError("option path is invalid");i+="; Path=".concat(o.path)}if(o.expires){if(typeof o.expires.toUTCString!="function")throw new TypeError("option expires is invalid");i+="; Expires=".concat(o.expires.toUTCString())}if(o.httpOnly&&(i+="; HttpOnly"),o.secure&&(i+="; Secure"),o.sameSite){var a=typeof o.sameSite=="string"?o.sameSite.toLowerCase():o.sameSite;switch(a){case!0:i+="; SameSite=Strict";break;case"lax":i+="; SameSite=Lax";break;case"strict":i+="; SameSite=Strict";break;case"none":i+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}}return i},hy={create:function(t,n,r,o){var s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{path:"/",sameSite:"strict"};r&&(s.expires=new Date,s.expires.setTime(s.expires.getTime()+r*60*1e3)),o&&(s.domain=o),document.cookie=sI(t,encodeURIComponent(n),s)},read:function(t){for(var n="".concat(t,"="),r=document.cookie.split(";"),o=0;o<r.length;o++){for(var s=r[o];s.charAt(0)===" ";)s=s.substring(1,s.length);if(s.indexOf(n)===0)return s.substring(n.length,s.length)}return null},remove:function(t){this.create(t,"",-1)}},iI={name:"cookie",lookup:function(t){var n;if(t.lookupCookie&&typeof document<"u"){var r=hy.read(t.lookupCookie);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupCookie&&typeof document<"u"&&hy.create(n.lookupCookie,t,n.cookieMinutes,n.cookieDomain,n.cookieOptions)}},lI={name:"querystring",lookup:function(t){var n;if(typeof window<"u"){var r=window.location.search;!window.location.search&&window.location.hash&&window.location.hash.indexOf("?")>-1&&(r=window.location.hash.substring(window.location.hash.indexOf("?")));for(var o=r.substring(1),s=o.split("&"),i=0;i<s.length;i++){var l=s[i].indexOf("=");if(l>0){var a=s[i].substring(0,l);a===t.lookupQuerystring&&(n=s[i].substring(l+1))}}}return n}},di=null,my=function(){if(di!==null)return di;try{di=window!=="undefined"&&window.localStorage!==null;var t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{di=!1}return di},aI={name:"localStorage",lookup:function(t){var n;if(t.lookupLocalStorage&&my()){var r=window.localStorage.getItem(t.lookupLocalStorage);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupLocalStorage&&my()&&window.localStorage.setItem(n.lookupLocalStorage,t)}},fi=null,gy=function(){if(fi!==null)return fi;try{fi=window!=="undefined"&&window.sessionStorage!==null;var t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{fi=!1}return fi},cI={name:"sessionStorage",lookup:function(t){var n;if(t.lookupSessionStorage&&gy()){var r=window.sessionStorage.getItem(t.lookupSessionStorage);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupSessionStorage&&gy()&&window.sessionStorage.setItem(n.lookupSessionStorage,t)}},uI={name:"navigator",lookup:function(t){var n=[];if(typeof navigator<"u"){if(navigator.languages)for(var r=0;r<navigator.languages.length;r++)n.push(navigator.languages[r]);navigator.userLanguage&&n.push(navigator.userLanguage),navigator.language&&n.push(navigator.language)}return n.length>0?n:void 0}},dI={name:"htmlTag",lookup:function(t){var n,r=t.htmlTag||(typeof document<"u"?document.documentElement:null);return r&&typeof r.getAttribute=="function"&&(n=r.getAttribute("lang")),n}},fI={name:"path",lookup:function(t){var n;if(typeof window<"u"){var r=window.location.pathname.match(/\/([a-zA-Z-]*)/g);if(r instanceof Array)if(typeof t.lookupFromPathIndex=="number"){if(typeof r[t.lookupFromPathIndex]!="string")return;n=r[t.lookupFromPathIndex].replace("/","")}else n=r[0].replace("/","")}return n}},pI={name:"subdomain",lookup:function(t){var n=typeof t.lookupFromSubdomainIndex=="number"?t.lookupFromSubdomainIndex+1:1,r=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(r)return r[n]}};function hI(){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 Ey=function(){function e(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};JA(this,e),this.type="languageDetector",this.detectors={},this.init(t,n)}return tI(e,[{key:"init",value:function(n){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.services=n||{languageUtils:{}},this.options=oI(r,this.options||{},hI()),typeof this.options.convertDetectedLanguage=="string"&&this.options.convertDetectedLanguage.indexOf("15897")>-1&&(this.options.convertDetectedLanguage=function(s){return s.replace("-","_")}),this.options.lookupFromUrlIndex&&(this.options.lookupFromPathIndex=this.options.lookupFromUrlIndex),this.i18nOptions=o,this.addDetector(iI),this.addDetector(lI),this.addDetector(aI),this.addDetector(cI),this.addDetector(uI),this.addDetector(dI),this.addDetector(fI),this.addDetector(pI)}},{key:"addDetector",value:function(n){this.detectors[n.name]=n}},{key:"detect",value:function(n){var r=this;n||(n=this.options.order);var o=[];return n.forEach(function(s){if(r.detectors[s]){var i=r.detectors[s].lookup(r.options);i&&typeof i=="string"&&(i=[i]),i&&(o=o.concat(i))}}),o=o.map(function(s){return r.options.convertDetectedLanguage(s)}),this.services.languageUtils.getBestMatchFromCodes?o:o.length>0?o[0]:null}},{key:"cacheUserLanguage",value:function(n,r){var o=this;r||(r=this.options.caches),r&&(this.options.excludeCacheFor&&this.options.excludeCacheFor.indexOf(n)>-1||r.forEach(function(s){o.detectors[s]&&o.detectors[s].cacheUserLanguage(n,o.options)}))}}]),e}();Ey.type="languageDetector";function cf(){return cf=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},cf.apply(this,arguments)}var mI={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};const gI=Ba(mI);var EI=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;function yy(e){var t={type:"tag",name:"",voidElement:!1,attrs:{},children:[]},n=e.match(/<\/?([^\s]+?)[/\s>]/);if(n&&(t.name=n[1],(gI[n[1]]||e.charAt(e.length-2)==="/")&&(t.voidElement=!0),t.name.startsWith("!--"))){var r=e.indexOf("-->");return{type:"comment",comment:r!==-1?e.slice(4,r):""}}for(var o=new RegExp(EI),s=null;(s=o.exec(e))!==null;)if(s[0].trim())if(s[1]){var i=s[1].trim(),l=[i,""];i.indexOf("=")>-1&&(l=i.split("=")),t.attrs[l[0]]=l[1],o.lastIndex--}else s[2]&&(t.attrs[s[2]]=s[3].trim().substring(1,s[3].length-1));return t}var yI=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,vI=/^\s*$/,_I=Object.create(null);function vy(e,t){switch(t.type){case"text":return e+t.content;case"tag":return e+="<"+t.name+(t.attrs?function(n){var r=[];for(var o in n)r.push(o+'="'+n[o]+'"');return r.length?" "+r.join(" "):""}(t.attrs):"")+(t.voidElement?"/>":">"),t.voidElement?e:e+t.children.reduce(vy,"")+"</"+t.name+">";case"comment":return e+"<!--"+t.comment+"-->"}}var SI={parse:function(e,t){t||(t={}),t.components||(t.components=_I);var n,r=[],o=[],s=-1,i=!1;if(e.indexOf("<")!==0){var l=e.indexOf("<");r.push({type:"text",content:l===-1?e:e.substring(0,l)})}return e.replace(yI,function(a,c){if(i){if(a!=="</"+n.name+">")return;i=!1}var u,f=a.charAt(1)!=="/",p=a.startsWith("<!--"),h=c+a.length,E=e.charAt(h);if(p){var y=yy(a);return s<0?(r.push(y),r):((u=o[s]).children.push(y),r)}if(f&&(s++,(n=yy(a)).type==="tag"&&t.components[n.name]&&(n.type="component",i=!0),n.voidElement||i||!E||E==="<"||n.children.push({type:"text",content:e.slice(h,e.indexOf("<",h))}),s===0&&r.push(n),(u=o[s-1])&&u.children.push(n),o[s]=n),(!f||n.voidElement)&&(s>-1&&(n.voidElement||n.name===a.slice(2,-1))&&(s--,n=s===-1?r:o[s]),!i&&E!=="<"&&E)){u=s===-1?r:o[s].children;var v=e.indexOf("<",h),m=e.slice(h,v===-1?void 0:v);vI.test(m)&&(m=" "),(v>-1&&s+u.length>=0||m!==" ")&&u.push({type:"text",content:m})}}),r},stringify:function(e){return e.reduce(function(t,n){return t+vy("",n)},"")}};function Oa(){if(console&&console.warn){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];typeof t[0]=="string"&&(t[0]=`react-i18next:: ${t[0]}`),console.warn(...t)}}const _y={};function xI(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];typeof t[0]=="string"&&_y[t[0]]||(typeof t[0]=="string"&&(_y[t[0]]=new Date),Oa(...t))}const RI=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,NI={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},wI=e=>NI[e];let uf={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:e=>e.replace(RI,wI)};function OI(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};uf={...uf,...e}}function TI(){return uf}let Sy;function AI(e){Sy=e}function xy(){return Sy}function df(e,t){if(!e)return!1;const n=e.props?e.props.children:e.children;return t?n.length>0:!!n}function ff(e){if(!e)return[];const t=e.props?e.props.children:e.children;return e.props&&e.props.i18nIsDynamicList?Mo(t):t}function II(e){return Object.prototype.toString.call(e)!=="[object Array]"?!1:e.every(t=>O.isValidElement(t))}function Mo(e){return Array.isArray(e)?e:[e]}function CI(e,t){const n={...t};return n.props=Object.assign(e.props,t.props),n}function Ry(e,t){if(!e)return"";let n="";const r=Mo(e),o=t.transSupportBasicHtmlNodes&&t.transKeepBasicHtmlNodesFor?t.transKeepBasicHtmlNodesFor:[];return r.forEach((s,i)=>{if(typeof s=="string")n+=`${s}`;else if(O.isValidElement(s)){const l=Object.keys(s.props).length,a=o.indexOf(s.type)>-1,c=s.props.children;if(!c&&a&&l===0)n+=`<${s.type}/>`;else if(!c&&(!a||l!==0))n+=`<${i}></${i}>`;else if(s.props.i18nIsDynamicList)n+=`<${i}></${i}>`;else if(a&&l===1&&typeof c=="string")n+=`<${s.type}>${c}</${s.type}>`;else{const u=Ry(c,t);n+=`<${i}>${u}</${i}>`}}else if(s===null)Oa("Trans: the passed in value is invalid - seems you passed in a null child.");else if(typeof s=="object"){const{format:l,...a}=s,c=Object.keys(a);if(c.length===1){const u=l?`${c[0]}, ${l}`:c[0];n+=`{{${u}}}`}else Oa("react-i18next: the passed in object contained more than one variable - the object should look like {{ value, format }} where format is optional.",s)}else Oa("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}}.",s)}),n}function LI(e,t,n,r,o,s){if(t==="")return[];const i=r.transKeepBasicHtmlNodesFor||[],l=t&&new RegExp(i.map(v=>`<${v}`).join("|")).test(t);if(!e&&!l&&!s)return[t];const a={};function c(v){Mo(v).forEach(g=>{typeof g!="string"&&(df(g)?c(ff(g)):typeof g=="object"&&!O.isValidElement(g)&&Object.assign(a,g))})}c(e);const u=SI.parse(`<0>${t}</0>`),f={...a,...o};function p(v,m,g){const S=ff(v),_=E(S,m.children,g);return II(S)&&_.length===0||v.props&&v.props.i18nIsDynamicList?S:_}function h(v,m,g,S,_){v.dummy?(v.children=m,g.push(O.cloneElement(v,{key:S},_?void 0:m))):g.push(...O.Children.map([v],x=>{const R={...x.props};return delete R.i18nIsDynamicList,H.createElement(x.type,cf({},R,{key:S,ref:x.ref},_?{}:{children:m}))}))}function E(v,m,g){const S=Mo(v);return Mo(m).reduce((x,R,T)=>{const L=R.children&&R.children[0]&&R.children[0].content&&n.services.interpolator.interpolate(R.children[0].content,f,n.language);if(R.type==="tag"){let P=S[parseInt(R.name,10)];g.length===1&&!P&&(P=g[0][R.name]),P||(P={});const I=Object.keys(R.attrs).length!==0?CI({props:R.attrs},P):P,j=O.isValidElement(I),V=j&&df(R,!0)&&!R.voidElement,M=l&&typeof I=="object"&&I.dummy&&!j,w=typeof e=="object"&&e!==null&&Object.hasOwnProperty.call(e,R.name);if(typeof I=="string"){const b=n.services.interpolator.interpolate(I,f,n.language);x.push(b)}else if(df(I)||V){const b=p(I,R,g);h(I,b,x,T)}else if(M){const b=E(S,R.children,g);h(I,b,x,T)}else if(Number.isNaN(parseFloat(R.name)))if(w){const b=p(I,R,g);h(I,b,x,T,R.voidElement)}else if(r.transSupportBasicHtmlNodes&&i.indexOf(R.name)>-1)if(R.voidElement)x.push(O.createElement(R.name,{key:`${R.name}-${T}`}));else{const b=E(S,R.children,g);x.push(O.createElement(R.name,{key:`${R.name}-${T}`},b))}else if(R.voidElement)x.push(`<${R.name} />`);else{const b=E(S,R.children,g);x.push(`<${R.name}>${b}</${R.name}>`)}else if(typeof I=="object"&&!j){const b=R.children[0]?L:null;b&&x.push(b)}else h(I,L,x,T,R.children.length!==1||!L)}else if(R.type==="text"){const P=r.transWrapTextNodes,I=s?r.unescape(n.services.interpolator.interpolate(R.content,f,n.language)):n.services.interpolator.interpolate(R.content,f,n.language);P?x.push(O.createElement(P,{key:`${R.name}-${T}`},I)):x.push(I)}return x},[])}const y=E([{dummy:!0,children:e||[]}],u,Mo(e||[]));return ff(y[0])}function bI(e){let{children:t,count:n,parent:r,i18nKey:o,context:s,tOptions:i={},values:l,defaults:a,components:c,ns:u,i18n:f,t:p,shouldUnescape:h,...E}=e;const y=f||xy();if(!y)return xI("You will need to pass in an i18next instance by using i18nextReactModule"),t;const v=p||y.t.bind(y)||(V=>V);s&&(i.context=s);const m={...TI(),...y.options&&y.options.react};let g=u||v.ns||y.options&&y.options.defaultNS;g=typeof g=="string"?[g]:g||["translation"];const S=Ry(t,m),_=a||S||m.transEmptyNodeValue||o,{hashTransKey:x}=m,R=o||(x?x(S||_):S||_);y.options&&y.options.interpolation&&y.options.interpolation.defaultVariables&&(l=l&&Object.keys(l).length>0?{...l,...y.options.interpolation.defaultVariables}:{...y.options.interpolation.defaultVariables});const T=l?i.interpolation:{interpolation:{...i.interpolation,prefix:"#$?",suffix:"?$#"}},L={...i,count:n,...l,...T,defaultValue:_,ns:g},P=R?v(R,L):_;c&&Object.keys(c).forEach(V=>{const M=c[V];if(typeof M.type=="function"||!M.props||!M.props.children||P.indexOf(`${V}/>`)<0&&P.indexOf(`${V} />`)<0)return;function w(){return H.createElement(H.Fragment,null,M)}c[V]=H.createElement(w,null)});const I=LI(c||t,P,y,m,L,h),j=r!==void 0?r:m.defaultTransParent;return j?O.createElement(j,E,I):I}const DI={type:"3rdParty",init(e){OI(e.options.react),AI(e)}},kI=O.createContext();function PI(e){let{children:t,count:n,parent:r,i18nKey:o,context:s,tOptions:i={},values:l,defaults:a,components:c,ns:u,i18n:f,t:p,shouldUnescape:h,...E}=e;const{i18n:y,defaultNS:v}=O.useContext(kI)||{},m=f||y||xy(),g=p||m&&m.t.bind(m);return bI({children:t,count:n,parent:r,i18nKey:o,context:s,tOptions:i,values:l,defaults:a,components:c,ns:u||g&&g.ns||v||m&&m.options&&m.options.defaultNS,i18n:m,t:p,shouldUnescape:h,...E})}var MI={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"]},UI={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"]},FI={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"]},jI={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"]},VI=jI,$I={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"]},HI={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"]},BI={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"]},zI={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"]},WI={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"]},GI={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"]},YI={prefix:"fas",iconName:"circle-small",icon:[320,512,[],"e122","M0 256a160 160 0 1 1 320 0A160 160 0 1 1 0 256z"]},KI={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"]},XI={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"]},QI={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"]},qI={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"]},JI={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"]},ZI={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 eC={"arrow-left":GI,"arrow-right":zI,"arrow-turn-down-right":BI,"arrows-rotate":HI,bars:UI,bolt:XI,"circle-check":$I,"circle-exclamation":FI,"circle-info":KI,"circle-question":WI,"circle-small":YI,"circle-xmark":ZI,"clock-rotate-left":qI,"dot-circle":VI,"trash-can":MI,"triangle-exclamation":JI,xmark:QI},re=O.forwardRef(function({className:t="",size:n="",tag:r},o){const s=eC[r];return s?d.jsx("svg",{"aria-hidden":"true","data-prefix":s.prefix,"data-icon":r,className:`svg-inline--fa fa-${r} ${n?`fa-${n}`:""} ${t}`,focusable:"false",ref:o,role:"img",viewBox:`0 0 ${s.icon[0]} ${s.icon[1]}`,xmlns:"http://www.w3.org/2000/svg",children:d.jsx("path",{d:s.icon[4],fill:"currentColor"})}):(Ne().debug(`Unknown icon: ${r}`),null)}),Uo=({className:e="",confirm:t=!0,handleDelete:n,label:r,scale:o=1,show:s=!0,showLabel:i=!1,size:l})=>{const[a,c]=O.useState(!1),[u,f]=O.useState(o);o!==u&&(c(!1),f(o));const p=E=>{E.preventDefault(),c(y=>!y)},h=E=>{E.preventDefault(),n(E)};return d.jsx(Zn,{enable:t,open:a,onOpenChange:c,placement:"top",scale:o,trigger:d.jsxs("button",{className:`${s?"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:E=>p(E),type:"button",children:[d.jsx(re,{tag:"trash-can",size:l})," ",d.jsx("span",{className:`${i?"whitespace-nowrap text-foreground/40 underline hover:text-negative":"sr-only"}`,children:r})]}),children:d.jsxs("div",{className:"text-xs font-semibold",children:[d.jsx("p",{className:"w-full pb-2 text-center",children:A(N.ARE_YOU_SURE)}),d.jsxs("div",{className:"align-center flex justify-between gap-2",children:[d.jsx("button",{className:"rounded bg-secondary py-1 px-2",onClick:E=>p(E),children:A(N.CANCEL)}),d.jsx("button",{className:"rounded bg-negative py-1 px-2",onClick:E=>h(E),children:A(N.DELETE)})]})]})})},tC=e=>{const t=Q(n=>n.viewport.zoom);return d.jsx(Uo,{scale:t,...e})},nC=Ne(),rC=100,oC=100,Ny=({children:e,className:t="",onClickListItem:n})=>{const r=Q(c=>c.nodes),o=Q(c=>c.reactFlowInstance),s=Q(c=>c.validationWarnings),{setSelectedNodes:i}=Te();if(s.size===0)return null;const l=Array.from(s.values());l.sort((c,u)=>A(c.nodeTitle).toLowerCase().localeCompare(A(u.nodeTitle).toLowerCase()));const a=c=>{var h,E;const u=r.find(y=>y.id===c);if(!u){nC.error(`Node with id ${c} not found`);return}const f=((h=o==null?void 0:o.getNode(c))==null?void 0:h.height)??oC,p=((E=o==null?void 0:o.getNode(c))==null?void 0:E.width)??H0;o==null||o.fitBounds({height:f+rC,width:p,x:u.position.x,y:u.position.y},{duration:nf}),setTimeout(()=>i([u.id]),nf),n==null||n()};return d.jsxs("div",{className:`hidden max-h-60 flex-col sm:flex ${t}`,children:[e,d.jsxs("p",{className:"mb-2 text-xs",children:[A(N.NUMBER_OF_VALIDATION_WARNINGS,{count:l.length}),":"]}),d.jsx("div",{className:"flex-auto overflow-y-auto",children:d.jsx("ol",{className:"list-inside",children:l.map(c=>d.jsxs("li",{className:"mb-2 text-xs",children:[d.jsx("button",{className:"text-warning underline",onClick:()=>a(c.nodeId),children:A(c.nodeTitle)}),d.jsxs("ol",{className:"my-1 ml-4 flex list-inside flex-col gap-y-1",children:[!c.connected&&d.jsx("li",{children:A(N.NOT_CONNECTED_TO_FLOW)}),!c.valid&&d.jsx("li",{children:A(N.INVALID_SETTINGS)})]})]},c.id))})})]})},pi=e=>{const{className:t="",direction:n="from",valid:r=!0,...o}=e,s=n==="from";return d.jsxs("div",{className:`relative ${t} ${r?"":"invalid"}`,children:[d.jsx("input",{className:`w-full !pl-5 ${r?"":"invalid"}`,placeholder:A(s?N.FROM:N.TO),...o}),d.jsx(re,{className:"absolute left-[.25rem] top-[.5rem] text-foreground/40",tag:s?"arrow-left":"arrow-right"})]})},sC=({children:e})=>d.jsx("span",{className:"whitespace-wrap inline-block",children:d.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})}),Lt=({children:e})=>d.jsxs("section",{className:"flex gap-2 overflow-hidden px-4 pb-3 text-xs leading-5",children:[d.jsx("div",{className:"shrink-0 pl-1 text-secondary",children:d.jsx(re,{size:"lg",tag:"arrow-turn-down-right"})}),d.jsx("div",{className:"w-full overflow-hidden",children:e})]}),iC=({connected:e=!1,deletable:t=!0,isRoot:n=!1,nodeId:r,nodeTitle:o,selected:s=!1})=>{const{removeNode:i}=Te(),l=Q(c=>c.isEdgeConnecting),a=(c=>c?"bg-positive/10 text-positive":e?"bg-focus/30 text-primary":"bg-foreground/10 text-foreground/50")(n);return d.jsxs("div",{className:"flex w-full items-center justify-start gap-x-2 p-4",children:[d.jsx("div",{className:`${a} flex h-5 w-5 shrink-0 items-center justify-center rounded-full`,children:d.jsx(re,{tag:"circle-small"})}),d.jsxs("div",{className:"flex-1",children:[d.jsx("h2",{className:"text-xs font-semibold",children:o}),!e&&d.jsxs("div",{className:"flex items-center justify-start text-tiny font-semibold leading-[14px] text-secondary",children:[d.jsx(re,{className:"px-1 text-warning",size:"lg",tag:"bolt"}),A(N.NOT_CONNECTED_TO_FLOW)]})]}),t&&!l&&d.jsx(tC,{handleDelete:()=>i(r),label:A(N.REMOVE_NODE,{title:o}),show:s})]})},lC=({valid:e})=>e?null:d.jsx("div",{className:"m-4 mt-0 inline-block",children:d.jsxs("div",{className:"flex items-start justify-start gap-2 rounded bg-negative/10 px-2 py-1 text-xs text-negative",children:[d.jsx(Zn,{placement:"bottom",trigger:d.jsx("div",{role:"tooltip",tabIndex:0,children:d.jsx(re,{size:"lg",tag:"triangle-exclamation"})}),children:A(N.INFO_INVALID_SETTINGS)}),A(N.INVALID_SETTINGS)]})}),aC=({nodeId:e,valid:t})=>{const{deleteValidationWarning:n,getTargetEdges:r,partialUpdateValidationWarning:o}=Te(),[s,i]=O.useState(!1);return O.useEffect(()=>{let l;const a=()=>{n(e),typeof l=="function"&&l()},c=()=>{const u=Q.getState().nodes.find(f=>f.id===e);if(!u)a();else{const f=r(e).length>0;i(f),o(e,{connected:f,nodeId:e,nodeType:u.type,valid:t})}};return c(),l=Q.subscribe((u,f)=>{const p=u.nodes.length!==f.nodes.length,h=u.edges.length!==f.edges.length,E=u.isEdgeUpdateSuccessful!==f.isEdgeUpdateSuccessful;(h||p||E)&&c()}),()=>{a()}},[n,r,e,o,t]),{isConnectedToFlow:s}},cC=({id:e,isConnectable:t})=>{if(!e)throw new Error("TargetHandle: id is required");return d.jsx("div",{className:"absolute left-0 top-5 h-3 w-3 -translate-x-1/2",children:d.jsx(No,{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:q.Left,type:"target"})})},$e=({children:e,id:t,isConnectable:n=!0,isRoot:r=!1,nodeTitle:o,selected:s,deletable:i=!0,showValidation:l=!0,target:a=!0,valid:c=!0})=>{const{isConnectedToFlow:u}=aC({nodeId:t,valid:c});return d.jsx("section",{className:`${s?"!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:d.jsxs("div",{className:"group/node-wrapper relative rounded-xl bg-background",style:{width:H0},children:[a&&t&&d.jsx(cC,{id:t,isConnectable:n}),d.jsx(iC,{connected:!a||u,deletable:i,isRoot:r,nodeId:t,nodeTitle:o,selected:s}),l&&d.jsx(lC,{valid:c}),e]})})},uC=({children:e,handleClick:t,...n})=>{const r=o=>{(o.key==="Backspace"||o.key==="Delete")&&(o.stopPropagation(),t==null||t())};return d.jsx("li",{role:"presentation",children:d.jsxs("div",{className:"flex items-center gap-2 rounded-lg bg-primary/20 p-1 pl-2 text-xs font-medium text-foreground",role:"option","aria-selected":"true",tabIndex:0,children:[e,d.jsxs("button",{className:"px-1",onClick:t,onKeyDown:r,type:"button",...n,children:[d.jsx("span",{className:"sr-only",children:"Remove"}),d.jsx(re,{tag:"xmark",size:"xs"})]})]})})},wy=({data:e})=>{let t=e.selected&&e[e.selected].trim();return t&&e.selected==="url"&&(t=IA(t)||A(N.PLAY_AUDIO)),t?d.jsx(Lt,{children:d.jsx("div",{className:"max-w-max",children:e.selected==="url"?d.jsx("a",{className:"break-words text-primary underline line-clamp-2",href:e.url,target:"_blank",rel:"noopener noreferrer",children:t}):d.jsx("p",{className:"break-words line-clamp-2",children:t})})}):null},Oy=e=>{const{children:t,className:n="",disabled:r=!1,...o}=e;return d.jsxs("div",{className:`chevron-down relative mb-2 after:rotate-0 after:transition-transform focus-within:after:rotate-180
61
+ ${r?"after:border-t-foreground/40":"after:border-t-foreground"}`,children:[d.jsx("select",{className:`pr-8 ${n}`,disabled:r,...o,children:t}),d.jsx("p",{className:"requirements w-full",role:"alert",children:A(N.ERROR_SELECTION_REQUIRED)})]})},Zt=e=>{const{label:t="",id:n="",...r}=e,o=O.useId(),s=n||o;return d.jsxs(d.Fragment,{children:[t&&d.jsx("label",{className:"block pb-1 font-medium",htmlFor:s,children:t}),d.jsx(Oy,{id:s,...r})]})},dC=({label:e,vars:t={}})=>d.jsx(PI,{components:{a:d.jsx("a",{className:"underline hover:text-background/80",href:t.linkTo||"#",target:"_blank",rel:"noopener noreferrer"}),code:d.jsx(sC,{}),p:d.jsx("p",{className:"mb-2"})},i18nKey:e}),fC={disabled:"border-disabled cursor-not-allowed",negative:"border-negative hover:bg-negative",positive:"border-positive hover:bg-positive"},Ht=({color:e="positive",enabled:t=!0,id:n,isConnectable:r})=>{if(!n)throw new Error("SourceHandle: id is required");const o=t?e:"disabled",s=Q(u=>u.updatingSourceHandleId),a=!Q(u=>u.edges.some(f=>f.sourceHandle===n))||s===n,c=a&&r&&t;return d.jsx("div",{className:`absolute right-0 top-1/2 h-3 w-3 -translate-y-1/2 translate-x-1/2 ${c?"":"nodrag cursor-not-allowed"}`,children:d.jsx(No,{className:`-right-[2px] h-full w-full border-2 bg-background transition-colors ${fC[o]??""}`,id:n,isConnectable:a&&r&&t,position:q.Right,type:"source"})})},Fo=({children:e})=>d.jsx("div",{className:"flex w-full flex-col items-start text-xs",children:e}),Bt=({color:e="positive",enabled:t=!0,id:n,isConnectable:r,optionSubtitle:o="",optionTitle:s})=>d.jsxs("div",{className:"relative w-full min-w-[104px] whitespace-nowrap border-t border-foreground/10 py-3",children:[d.jsx("div",{className:"flex flex-col items-start justify-center px-4",children:d.jsxs("div",{className:`${t?"":"text-disabled"} min-h-[1rem] w-full overflow-hidden`,children:[s,o?d.jsx("span",{className:"block text-xxs text-secondary",children:o}):null]})}),d.jsx(Ht,{color:e,enabled:t,id:n,isConnectable:r})]}),pC=({checked:e=!1,name:t,onClick:n,...r})=>d.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:n,role:"switch",type:"button",...r,children:[d.jsx("span",{className:"sr-only",children:A(e?N.ON:N.OFF)}),d.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`})]}),Ta=({checked:e,clickHandler:t,name:n,subtitle:r,title:o,...s})=>d.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[d.jsxs("div",{className:"flex flex-grow flex-col",children:[d.jsx("span",{className:"text-xs font-medium",children:o}),r&&d.jsx("span",{className:"text-xxs text-foreground/50",children:r})]}),d.jsx(pC,{checked:e,name:n,onClick:t,...s})]}),yn=({errorText:e,label:t,name:n,onChange:r,required:o,valid:s,value:i,...l})=>d.jsxs(d.Fragment,{children:[t!=null&&t.trim()?d.jsx("div",{className:"pb-1",children:t}):null,d.jsx("textarea",{"aria-invalid":s?void 0:"true",className:`peer min-h-[77px] w-full resize-y ${s?"":"invalid"}`,inputMode:"text",minLength:1,name:n,onChange:r,required:o,value:i,...l}),d.jsx("p",{className:"requirements",role:"alert",children:e})]});function Xn(e){return Ty(e)?(e.nodeName||"").toLowerCase():"#document"}function it(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function vn(e){var t;return(t=(Ty(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Ty(e){return e instanceof Node||e instanceof it(e).Node}function ge(e){return e instanceof Element||e instanceof it(e).Element}function vt(e){return e instanceof HTMLElement||e instanceof it(e).HTMLElement}function pf(e){return typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof it(e).ShadowRoot}function hi(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=_t(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!["inline","contents"].includes(o)}function hC(e){return["table","td","th"].includes(Xn(e))}function hf(e){const t=mf(),n=_t(e);return n.transform!=="none"||n.perspective!=="none"||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||["transform","perspective","filter"].some(r=>(n.willChange||"").includes(r))||["paint","layout","strict","content"].some(r=>(n.contain||"").includes(r))}function mC(e){let t=Rr(e);for(;vt(t)&&!jo(t);){if(hf(t))return t;t=Rr(t)}return null}function mf(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function jo(e){return["html","body","#document"].includes(Xn(e))}function _t(e){return it(e).getComputedStyle(e)}function Aa(e){return ge(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.pageXOffset,scrollTop:e.pageYOffset}}function Rr(e){if(Xn(e)==="html")return e;const t=e.assignedSlot||e.parentNode||pf(e)&&e.host||vn(e);return pf(t)?t.host:t}function Ay(e){const t=Rr(e);return jo(t)?e.ownerDocument?e.ownerDocument.body:e.body:vt(t)&&hi(t)?t:Ay(t)}function Qn(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=Ay(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=it(o);return s?t.concat(i,i.visualViewport||[],hi(o)?o:[],i.frameElement&&n?Qn(i.frameElement):[]):t.concat(o,Qn(o,[],n))}function Iy(e){let t=e.activeElement;for(;((n=t)==null||(n=n.shadowRoot)==null?void 0:n.activeElement)!=null;){var n;t=t.shadowRoot.activeElement}return t}function qn(e,t){if(!e||!t)return!1;const n=t.getRootNode&&t.getRootNode();if(e.contains(t))return!0;if(n&&pf(n)){let r=t;for(;r;){if(e===r)return!0;r=r.parentNode||r.host}}return!1}function Cy(){const e=navigator.userAgentData;return e!=null&&e.platform?e.platform:navigator.platform}function gC(){const e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(t=>{let{brand:n,version:r}=t;return n+"/"+r}).join(" "):navigator.userAgent}function EC(e){return!vC()&&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 yC(){return/apple/i.test(navigator.vendor)}function vC(){const e=/android/i;return e.test(Cy())||e.test(gC())}function _C(){return Cy().toLowerCase().startsWith("mac")&&!navigator.maxTouchPoints}function Ly(e,t){const n=["mouse","pen"];return t||n.push("",void 0),n.includes(e)}function SC(e){return"nativeEvent"in e}function xC(e){return e.matches("html,body")}function Nr(e){return(e==null?void 0:e.ownerDocument)||document}function gf(e,t){if(t==null)return!1;if("composedPath"in e)return e.composedPath().includes(t);const n=e;return n.target!=null&&t.contains(n.target)}function wr(e){return"composedPath"in e?e.composedPath()[0]:e.target}const RC="input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";function NC(e){return vt(e)&&e.matches(RC)}const Vo=Math.min,Or=Math.max,Ia=Math.round,Ca=Math.floor,Jn=e=>({x:e,y:e}),wC={left:"right",right:"left",bottom:"top",top:"bottom"},OC={start:"end",end:"start"};function Ef(e,t,n){return Or(e,Vo(t,n))}function mi(e,t){return typeof e=="function"?e(t):e}function Tr(e){return e.split("-")[0]}function gi(e){return e.split("-")[1]}function by(e){return e==="x"?"y":"x"}function yf(e){return e==="y"?"height":"width"}function La(e){return["top","bottom"].includes(Tr(e))?"y":"x"}function vf(e){return by(La(e))}function TC(e,t,n){n===void 0&&(n=!1);const r=gi(e),o=vf(e),s=yf(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=ba(i)),[i,ba(i)]}function AC(e){const t=ba(e);return[_f(e),t,_f(t)]}function _f(e){return e.replace(/start|end/g,t=>OC[t])}function IC(e,t,n){const r=["left","right"],o=["right","left"],s=["top","bottom"],i=["bottom","top"];switch(e){case"top":case"bottom":return n?t?o:r:t?r:o;case"left":case"right":return t?s:i;default:return[]}}function CC(e,t,n,r){const o=gi(e);let s=IC(Tr(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(_f)))),s}function ba(e){return e.replace(/left|right|bottom|top/g,t=>wC[t])}function LC(e){return{top:0,right:0,bottom:0,left:0,...e}}function Dy(e){return typeof e!="number"?LC(e):{top:e,right:e,bottom:e,left:e}}function Da(e){return{...e,top:e.y,left:e.x,right:e.x+e.width,bottom:e.y+e.height}}function ky(e,t,n){let{reference:r,floating:o}=e;const s=La(t),i=vf(t),l=yf(i),a=Tr(t),c=s==="y",u=r.x+r.width/2-o.width/2,f=r.y+r.height/2-o.height/2,p=r[l]/2-o[l]/2;let h;switch(a){case"top":h={x:u,y:r.y-o.height};break;case"bottom":h={x:u,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y:f};break;case"left":h={x:r.x-o.width,y:f};break;default:h={x:r.x,y:r.y}}switch(gi(t)){case"start":h[i]-=p*(n&&c?-1:1);break;case"end":h[i]+=p*(n&&c?-1:1);break}return h}const bC=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,l=s.filter(Boolean),a=await(i.isRTL==null?void 0:i.isRTL(t));let c=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:u,y:f}=ky(c,r,a),p=r,h={},E=0;for(let y=0;y<l.length;y++){const{name:v,fn:m}=l[y],{x:g,y:S,data:_,reset:x}=await m({x:u,y:f,initialPlacement:r,placement:p,strategy:o,middlewareData:h,rects:c,platform:i,elements:{reference:e,floating:t}});if(u=g??u,f=S??f,h={...h,[v]:{...h[v],..._}},x&&E<=50){E++,typeof x=="object"&&(x.placement&&(p=x.placement),x.rects&&(c=x.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):x.rects),{x:u,y:f}=ky(c,p,a)),y=-1;continue}}return{x:u,y:f,placement:p,strategy:o,middlewareData:h}};async function Py(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:l,strategy:a}=e,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:f="floating",altBoundary:p=!1,padding:h=0}=mi(t,e),E=Dy(h),v=l[p?f==="floating"?"reference":"floating":f],m=Da(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(v)))==null||n?v:v.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(l.floating)),boundary:c,rootBoundary:u,strategy:a})),g=f==="floating"?{...i.floating,x:r,y:o}:i.reference,S=await(s.getOffsetParent==null?void 0:s.getOffsetParent(l.floating)),_=await(s.isElement==null?void 0:s.isElement(S))?await(s.getScale==null?void 0:s.getScale(S))||{x:1,y:1}:{x:1,y:1},x=Da(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({rect:g,offsetParent:S,strategy:a}):g);return{top:(m.top-x.top+E.top)/_.y,bottom:(x.bottom-m.bottom+E.bottom)/_.y,left:(m.left-x.left+E.left)/_.x,right:(x.right-m.right+E.right)/_.x}}const My=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:l,middlewareData:a}=t,{element:c,padding:u=0}=mi(e,t)||{};if(c==null)return{};const f=Dy(u),p={x:n,y:r},h=vf(o),E=yf(h),y=await i.getDimensions(c),v=h==="y",m=v?"top":"left",g=v?"bottom":"right",S=v?"clientHeight":"clientWidth",_=s.reference[E]+s.reference[h]-p[h]-s.floating[E],x=p[h]-s.reference[h],R=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c));let T=R?R[S]:0;(!T||!await(i.isElement==null?void 0:i.isElement(R)))&&(T=l.floating[S]||s.floating[E]);const L=_/2-x/2,P=T/2-y[E]/2-1,I=Vo(f[m],P),j=Vo(f[g],P),V=I,M=T-y[E]-j,w=T/2-y[E]/2+L,b=Ef(V,w,M),k=!a.arrow&&gi(o)!=null&&w!=b&&s.reference[E]/2-(w<V?I:j)-y[E]/2<0,F=k?w<V?w-V:w-M:0;return{[h]:p[h]+F,data:{[h]:b,centerOffset:w-b-F,...k&&{alignmentOffset:F}},reset:k}}}),DC=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:l,platform:a,elements:c}=t,{mainAxis:u=!0,crossAxis:f=!0,fallbackPlacements:p,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:E="none",flipAlignment:y=!0,...v}=mi(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const m=Tr(o),g=Tr(l)===l,S=await(a.isRTL==null?void 0:a.isRTL(c.floating)),_=p||(g||!y?[ba(l)]:AC(l));!p&&E!=="none"&&_.push(...CC(l,y,E,S));const x=[l,..._],R=await Py(t,v),T=[];let L=((r=s.flip)==null?void 0:r.overflows)||[];if(u&&T.push(R[m]),f){const V=TC(o,i,S);T.push(R[V[0]],R[V[1]])}if(L=[...L,{placement:o,overflows:T}],!T.every(V=>V<=0)){var P,I;const V=(((P=s.flip)==null?void 0:P.index)||0)+1,M=x[V];if(M)return{data:{index:V,overflows:L},reset:{placement:M}};let w=(I=L.filter(b=>b.overflows[0]<=0).sort((b,k)=>b.overflows[1]-k.overflows[1])[0])==null?void 0:I.placement;if(!w)switch(h){case"bestFit":{var j;const b=(j=L.map(k=>[k.placement,k.overflows.filter(F=>F>0).reduce((F,C)=>F+C,0)]).sort((k,F)=>k[1]-F[1])[0])==null?void 0:j[0];b&&(w=b);break}case"initialPlacement":w=l;break}if(o!==w)return{reset:{placement:w}}}return{}}}};async function kC(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=Tr(n),l=gi(n),a=La(n)==="y",c=["left","top"].includes(i)?-1:1,u=s&&a?-1:1,f=mi(t,e);let{mainAxis:p,crossAxis:h,alignmentAxis:E}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...f};return l&&typeof E=="number"&&(h=l==="end"?E*-1:E),a?{x:h*u,y:p*c}:{x:p*c,y:h*u}}const PC=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:s,placement:i,middlewareData:l}=t,a=await kC(t,e);return i===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:o+a.x,y:s+a.y,data:{...a,placement:i}}}}},MC=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:s=!0,crossAxis:i=!1,limiter:l={fn:v=>{let{x:m,y:g}=v;return{x:m,y:g}}},...a}=mi(e,t),c={x:n,y:r},u=await Py(t,a),f=La(Tr(o)),p=by(f);let h=c[p],E=c[f];if(s){const v=p==="y"?"top":"left",m=p==="y"?"bottom":"right",g=h+u[v],S=h-u[m];h=Ef(g,h,S)}if(i){const v=f==="y"?"top":"left",m=f==="y"?"bottom":"right",g=E+u[v],S=E-u[m];E=Ef(g,E,S)}const y=l.fn({...t,[p]:h,[f]:E});return{...y,data:{x:y.x-n,y:y.y-r}}}}};function Uy(e){const t=_t(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=vt(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,l=Ia(n)!==s||Ia(r)!==i;return l&&(n=s,r=i),{width:n,height:r,$:l}}function Sf(e){return ge(e)?e:e.contextElement}function $o(e){const t=Sf(e);if(!vt(t))return Jn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=Uy(t);let i=(s?Ia(n.width):n.width)/r,l=(s?Ia(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!l||!Number.isFinite(l))&&(l=1),{x:i,y:l}}const UC=Jn(0);function Fy(e){const t=it(e);return!mf()||!t.visualViewport?UC:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function FC(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==it(e)?!1:t}function Ar(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=Sf(e);let i=Jn(1);t&&(r?ge(r)&&(i=$o(r)):i=$o(e));const l=FC(s,n,r)?Fy(s):Jn(0);let a=(o.left+l.x)/i.x,c=(o.top+l.y)/i.y,u=o.width/i.x,f=o.height/i.y;if(s){const p=it(s),h=r&&ge(r)?it(r):r;let E=p.frameElement;for(;E&&r&&h!==p;){const y=$o(E),v=E.getBoundingClientRect(),m=_t(E),g=v.left+(E.clientLeft+parseFloat(m.paddingLeft))*y.x,S=v.top+(E.clientTop+parseFloat(m.paddingTop))*y.y;a*=y.x,c*=y.y,u*=y.x,f*=y.y,a+=g,c+=S,E=it(E).frameElement}}return Da({width:u,height:f,x:a,y:c})}function jC(e){let{rect:t,offsetParent:n,strategy:r}=e;const o=vt(n),s=vn(n);if(n===s)return t;let i={scrollLeft:0,scrollTop:0},l=Jn(1);const a=Jn(0);if((o||!o&&r!=="fixed")&&((Xn(n)!=="body"||hi(s))&&(i=Aa(n)),vt(n))){const c=Ar(n);l=$o(n),a.x=c.x+n.clientLeft,a.y=c.y+n.clientTop}return{width:t.width*l.x,height:t.height*l.y,x:t.x*l.x-i.scrollLeft*l.x+a.x,y:t.y*l.y-i.scrollTop*l.y+a.y}}function VC(e){return Array.from(e.getClientRects())}function jy(e){return Ar(vn(e)).left+Aa(e).scrollLeft}function $C(e){const t=vn(e),n=Aa(e),r=e.ownerDocument.body,o=Or(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Or(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+jy(e);const l=-n.scrollTop;return _t(r).direction==="rtl"&&(i+=Or(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:l}}function HC(e,t){const n=it(e),r=vn(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,l=0,a=0;if(o){s=o.width,i=o.height;const c=mf();(!c||c&&t==="fixed")&&(l=o.offsetLeft,a=o.offsetTop)}return{width:s,height:i,x:l,y:a}}function BC(e,t){const n=Ar(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=vt(e)?$o(e):Jn(1),i=e.clientWidth*s.x,l=e.clientHeight*s.y,a=o*s.x,c=r*s.y;return{width:i,height:l,x:a,y:c}}function Vy(e,t,n){let r;if(t==="viewport")r=HC(e,n);else if(t==="document")r=$C(vn(e));else if(ge(t))r=BC(t,n);else{const o=Fy(e);r={...t,x:t.x-o.x,y:t.y-o.y}}return Da(r)}function $y(e,t){const n=Rr(e);return n===t||!ge(n)||jo(n)?!1:_t(n).position==="fixed"||$y(n,t)}function zC(e,t){const n=t.get(e);if(n)return n;let r=Qn(e,[],!1).filter(l=>ge(l)&&Xn(l)!=="body"),o=null;const s=_t(e).position==="fixed";let i=s?Rr(e):e;for(;ge(i)&&!jo(i);){const l=_t(i),a=hf(i);!a&&l.position==="fixed"&&(o=null),(s?!a&&!o:!a&&l.position==="static"&&!!o&&["absolute","fixed"].includes(o.position)||hi(i)&&!a&&$y(e,i))?r=r.filter(u=>u!==i):o=l,i=Rr(i)}return t.set(e,r),r}function WC(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?zC(t,this._c):[].concat(n),r],l=i[0],a=i.reduce((c,u)=>{const f=Vy(t,u,o);return c.top=Or(f.top,c.top),c.right=Vo(f.right,c.right),c.bottom=Vo(f.bottom,c.bottom),c.left=Or(f.left,c.left),c},Vy(t,l,o));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}}function GC(e){return Uy(e)}function YC(e,t,n){const r=vt(t),o=vn(t),s=n==="fixed",i=Ar(e,!0,s,t);let l={scrollLeft:0,scrollTop:0};const a=Jn(0);if(r||!r&&!s)if((Xn(t)!=="body"||hi(o))&&(l=Aa(t)),r){const c=Ar(t,!0,s,t);a.x=c.x+t.clientLeft,a.y=c.y+t.clientTop}else o&&(a.x=jy(o));return{x:i.left+l.scrollLeft-a.x,y:i.top+l.scrollTop-a.y,width:i.width,height:i.height}}function Hy(e,t){return!vt(e)||_t(e).position==="fixed"?null:t?t(e):e.offsetParent}function By(e,t){const n=it(e);if(!vt(e))return n;let r=Hy(e,t);for(;r&&hC(r)&&_t(r).position==="static";)r=Hy(r,t);return r&&(Xn(r)==="html"||Xn(r)==="body"&&_t(r).position==="static"&&!hf(r))?n:r||mC(e)||n}const KC=async function(e){let{reference:t,floating:n,strategy:r}=e;const o=this.getOffsetParent||By,s=this.getDimensions;return{reference:YC(t,await o(n),r),floating:{x:0,y:0,...await s(n)}}};function XC(e){return _t(e).direction==="rtl"}const QC={convertOffsetParentRelativeRectToViewportRelativeRect:jC,getDocumentElement:vn,getClippingRect:WC,getOffsetParent:By,getElementRects:KC,getClientRects:VC,getDimensions:GC,getScale:$o,isElement:ge,isRTL:XC};function qC(e,t){let n=null,r;const o=vn(e);function s(){clearTimeout(r),n&&n.disconnect(),n=null}function i(l,a){l===void 0&&(l=!1),a===void 0&&(a=1),s();const{left:c,top:u,width:f,height:p}=e.getBoundingClientRect();if(l||t(),!f||!p)return;const h=Ca(u),E=Ca(o.clientWidth-(c+f)),y=Ca(o.clientHeight-(u+p)),v=Ca(c),g={rootMargin:-h+"px "+-E+"px "+-y+"px "+-v+"px",threshold:Or(0,Vo(1,a))||1};let S=!0;function _(x){const R=x[0].intersectionRatio;if(R!==a){if(!S)return i();R?i(!1,R):r=setTimeout(()=>{i(!1,1e-7)},100)}S=!1}try{n=new IntersectionObserver(_,{...g,root:o.ownerDocument})}catch{n=new IntersectionObserver(_,g)}n.observe(e)}return i(!0),s}function JC(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:a=!1}=r,c=Sf(e),u=o||s?[...c?Qn(c):[],...Qn(t)]:[];u.forEach(m=>{o&&m.addEventListener("scroll",n,{passive:!0}),s&&m.addEventListener("resize",n)});const f=c&&l?qC(c,n):null;let p=-1,h=null;i&&(h=new ResizeObserver(m=>{let[g]=m;g&&g.target===c&&h&&(h.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{h&&h.observe(t)})),n()}),c&&!a&&h.observe(c),h.observe(t));let E,y=a?Ar(e):null;a&&v();function v(){const m=Ar(e);y&&(m.x!==y.x||m.y!==y.y||m.width!==y.width||m.height!==y.height)&&n(),y=m,E=requestAnimationFrame(v)}return n(),()=>{u.forEach(m=>{o&&m.removeEventListener("scroll",n),s&&m.removeEventListener("resize",n)}),f&&f(),h&&h.disconnect(),h=null,a&&cancelAnimationFrame(E)}}const ZC=(e,t,n)=>{const r=new Map,o={platform:QC,...n},s={...o.platform,_c:r};return bC(e,t,{...o,platform:s})},e2=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?My({element:r.current,padding:o}).fn(n):{}:r?My({element:r,padding:o}).fn(n):{}}}};var ka=typeof document<"u"?O.useLayoutEffect:O.useEffect;function Pa(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 n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!=t.length)return!1;for(r=n;r--!==0;)if(!Pa(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const s=o[r];if(!(s==="_owner"&&e.$$typeof)&&!Pa(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function zy(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Wy(e,t){const n=zy(e);return Math.round(t*n)/n}function Gy(e){const t=O.useRef(e);return ka(()=>{t.current=e}),t}function t2(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:l=!0,whileElementsMounted:a,open:c}=e,[u,f]=O.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[p,h]=O.useState(r);Pa(p,r)||h(r);const[E,y]=O.useState(null),[v,m]=O.useState(null),g=O.useCallback(k=>{k!=R.current&&(R.current=k,y(k))},[y]),S=O.useCallback(k=>{k!==T.current&&(T.current=k,m(k))},[m]),_=s||E,x=i||v,R=O.useRef(null),T=O.useRef(null),L=O.useRef(u),P=Gy(a),I=Gy(o),j=O.useCallback(()=>{if(!R.current||!T.current)return;const k={placement:t,strategy:n,middleware:p};I.current&&(k.platform=I.current),ZC(R.current,T.current,k).then(F=>{const C={...F,isPositioned:!0};V.current&&!Pa(L.current,C)&&(L.current=C,Bl.flushSync(()=>{f(C)}))})},[p,t,n,I]);ka(()=>{c===!1&&L.current.isPositioned&&(L.current.isPositioned=!1,f(k=>({...k,isPositioned:!1})))},[c]);const V=O.useRef(!1);ka(()=>(V.current=!0,()=>{V.current=!1}),[]),ka(()=>{if(_&&(R.current=_),x&&(T.current=x),_&&x){if(P.current)return P.current(_,x,j);j()}},[_,x,j,P]);const M=O.useMemo(()=>({reference:R,floating:T,setReference:g,setFloating:S}),[g,S]),w=O.useMemo(()=>({reference:_,floating:x}),[_,x]),b=O.useMemo(()=>{const k={position:n,left:0,top:0};if(!w.floating)return k;const F=Wy(w.floating,u.x),C=Wy(w.floating,u.y);return l?{...k,transform:"translate("+F+"px, "+C+"px)",...zy(w.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:F,top:C}},[n,l,w.floating,u.x,u.y]);return O.useMemo(()=>({...u,update:j,refs:M,elements:w,floatingStyles:b}),[u,j,M,w,b])}function Yy(e){return O.useMemo(()=>e.every(t=>t==null)?null:t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})},e)}const n2=lp.useInsertionEffect||(e=>e());function Ho(e){const t=O.useRef(()=>{});return n2(()=>{t.current=e}),O.useCallback(function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return t.current==null?void 0:t.current(...r)},[])}var Ei=typeof document<"u"?O.useLayoutEffect:O.useEffect;let xf=!1,r2=0;const Ky=()=>"floating-ui-"+r2++;function o2(){const[e,t]=O.useState(()=>xf?Ky():void 0);return Ei(()=>{e==null&&t(Ky())},[]),O.useEffect(()=>{xf||(xf=!0)},[]),e}const Xy=lp.useId||o2;function s2(){const e=new Map;return{emit(t,n){var r;(r=e.get(t))==null||r.forEach(o=>o(n))},on(t,n){e.set(t,[...e.get(t)||[],n])},off(t,n){var r;e.set(t,((r=e.get(t))==null?void 0:r.filter(o=>o!==n))||[])}}}const i2=O.createContext(null),l2=O.createContext(null),Rf=()=>{var e;return((e=O.useContext(i2))==null?void 0:e.id)||null},Nf=()=>O.useContext(l2);function wf(e){return"data-floating-ui-"+e}function Qy(e){const t=O.useRef(e);return Ei(()=>{t.current=e}),t}const qy=wf("safe-polygon");function Of(e,t,n){return n&&!Ly(n)?0:typeof e=="number"?e:e==null?void 0:e[t]}function a2(e,t){t===void 0&&(t={});const{open:n,onOpenChange:r,dataRef:o,events:s,elements:{domReference:i,floating:l},refs:a}=e,{enabled:c=!0,delay:u=0,handleClose:f=null,mouseOnly:p=!1,restMs:h=0,move:E=!0}=t,y=Nf(),v=Rf(),m=Qy(f),g=Qy(u),S=O.useRef(),_=O.useRef(),x=O.useRef(),R=O.useRef(),T=O.useRef(!0),L=O.useRef(!1),P=O.useRef(()=>{}),I=O.useCallback(()=>{var w;const b=(w=o.current.openEvent)==null?void 0:w.type;return(b==null?void 0:b.includes("mouse"))&&b!=="mousedown"},[o]);O.useEffect(()=>{if(!c)return;function w(b){let{open:k}=b;k||(clearTimeout(_.current),clearTimeout(R.current),T.current=!0)}return s.on("openchange",w),()=>{s.off("openchange",w)}},[c,s]),O.useEffect(()=>{if(!c||!m.current||!n)return;function w(k){I()&&r(!1,k,"hover")}const b=Nr(l).documentElement;return b.addEventListener("mouseleave",w),()=>{b.removeEventListener("mouseleave",w)}},[l,n,r,c,m,o,I]);const j=O.useCallback(function(w,b,k){b===void 0&&(b=!0),k===void 0&&(k="hover");const F=Of(g.current,"close",S.current);F&&!x.current?(clearTimeout(_.current),_.current=setTimeout(()=>r(!1,w,k),F)):b&&(clearTimeout(_.current),r(!1,w,k))},[g,r]),V=O.useCallback(()=>{P.current(),x.current=void 0},[]),M=O.useCallback(()=>{if(L.current){const w=Nr(a.floating.current).body;w.style.pointerEvents="",w.removeAttribute(qy),L.current=!1}},[a]);return O.useEffect(()=>{if(!c)return;function w(){return o.current.openEvent?["click","mousedown"].includes(o.current.openEvent.type):!1}function b(C){if(clearTimeout(_.current),T.current=!1,p&&!Ly(S.current)||h>0&&Of(g.current,"open")===0)return;const D=Of(g.current,"open",S.current);D?_.current=setTimeout(()=>{r(!0,C,"hover")},D):r(!0,C,"hover")}function k(C){if(w())return;P.current();const D=Nr(l);if(clearTimeout(R.current),m.current){n||clearTimeout(_.current),x.current=m.current({...e,tree:y,x:C.clientX,y:C.clientY,onClose(){M(),V(),j(C,!0,"safe-polygon")}});const $=x.current;D.addEventListener("mousemove",$),P.current=()=>{D.removeEventListener("mousemove",$)};return}(S.current==="touch"?!qn(l,C.relatedTarget):!0)&&j(C)}function F(C){w()||m.current==null||m.current({...e,tree:y,x:C.clientX,y:C.clientY,onClose(){M(),V(),j(C)}})(C)}if(ge(i)){const C=i;return n&&C.addEventListener("mouseleave",F),l==null||l.addEventListener("mouseleave",F),E&&C.addEventListener("mousemove",b,{once:!0}),C.addEventListener("mouseenter",b),C.addEventListener("mouseleave",k),()=>{n&&C.removeEventListener("mouseleave",F),l==null||l.removeEventListener("mouseleave",F),E&&C.removeEventListener("mousemove",b),C.removeEventListener("mouseenter",b),C.removeEventListener("mouseleave",k)}}},[i,l,c,e,p,h,E,j,V,M,r,n,y,g,m,o]),Ei(()=>{var w;if(c&&n&&(w=m.current)!=null&&w.__options.blockPointerEvents&&I()){const k=Nr(l).body;if(k.setAttribute(qy,""),k.style.pointerEvents="none",L.current=!0,ge(i)&&l){var b;const F=i,C=y==null||(b=y.nodesRef.current.find(D=>D.id===v))==null||(b=b.context)==null?void 0:b.elements.floating;return C&&(C.style.pointerEvents=""),F.style.pointerEvents="auto",l.style.pointerEvents="auto",()=>{F.style.pointerEvents="",l.style.pointerEvents=""}}}},[c,n,v,l,i,y,m,o,I]),Ei(()=>{n||(S.current=void 0,V(),M())},[n,V,M]),O.useEffect(()=>()=>{V(),clearTimeout(_.current),clearTimeout(R.current),M()},[c,i,V,M]),O.useMemo(()=>{if(!c)return{};function w(b){S.current=b.pointerType}return{reference:{onPointerDown:w,onPointerEnter:w,onMouseMove(b){n||h===0||(clearTimeout(R.current),R.current=setTimeout(()=>{T.current||r(!0,b.nativeEvent,"hover")},h))}},floating:{onMouseEnter(){clearTimeout(_.current)},onMouseLeave(b){j(b.nativeEvent,!1)}}}},[c,h,n,r,j])}function Ma(e,t){let n=e.filter(o=>{var s;return o.parentId===t&&((s=o.context)==null?void 0:s.open)}),r=n;for(;r.length;)r=e.filter(o=>{var s;return(s=r)==null?void 0:s.some(i=>{var l;return o.parentId===i.id&&((l=o.context)==null?void 0:l.open)})}),n=n.concat(r);return n}const c2={pointerdown:"onPointerDown",mousedown:"onMouseDown",click:"onClick"},u2={pointerdown:"onPointerDownCapture",mousedown:"onMouseDownCapture",click:"onClickCapture"},Jy=e=>{var t,n;return{escapeKey:typeof e=="boolean"?e:(t=e==null?void 0:e.escapeKey)!=null?t:!1,outsidePress:typeof e=="boolean"?e:(n=e==null?void 0:e.outsidePress)!=null?n:!0}};function d2(e,t){t===void 0&&(t={});const{open:n,onOpenChange:r,nodeId:o,elements:{reference:s,domReference:i,floating:l},dataRef:a}=e,{enabled:c=!0,escapeKey:u=!0,outsidePress:f=!0,outsidePressEvent:p="pointerdown",referencePress:h=!1,referencePressEvent:E="pointerdown",ancestorScroll:y=!1,bubbles:v,capture:m}=t,g=Nf(),S=Ho(typeof f=="function"?f:()=>!1),_=typeof f=="function"?S:f,x=O.useRef(!1),R=O.useRef(!1),{escapeKey:T,outsidePress:L}=Jy(v),{escapeKey:P,outsidePress:I}=Jy(m),j=Ho(b=>{if(!n||!c||!u||b.key!=="Escape")return;const k=g?Ma(g.nodesRef.current,o):[];if(!T&&(b.stopPropagation(),k.length>0)){let F=!0;if(k.forEach(C=>{var D;if((D=C.context)!=null&&D.open&&!C.context.dataRef.current.__escapeKeyBubbles){F=!1;return}}),!F)return}r(!1,SC(b)?b.nativeEvent:b,"escape-key")}),V=Ho(b=>{var k;const F=()=>{var C;j(b),(C=wr(b))==null||C.removeEventListener("keydown",F)};(k=wr(b))==null||k.addEventListener("keydown",F)}),M=Ho(b=>{const k=x.current;x.current=!1;const F=R.current;if(R.current=!1,p==="click"&&F||k||typeof _=="function"&&!_(b))return;const C=wr(b),D="["+wf("inert")+"]",U=Nr(l).querySelectorAll(D);let $=ge(C)?C:null;for(;$&&!jo($);){const z=Rr($);if(jo(z)||!ge(z))break;$=z}if(U.length&&ge(C)&&!xC(C)&&!qn(C,l)&&Array.from(U).every(z=>!qn($,z)))return;if(vt(C)&&l){const z=C.clientWidth>0&&C.scrollWidth>C.clientWidth,Y=C.clientHeight>0&&C.scrollHeight>C.clientHeight;let X=Y&&b.offsetX>C.clientWidth;if(Y&&_t(C).direction==="rtl"&&(X=b.offsetX<=C.offsetWidth-C.clientWidth),X||z&&b.offsetY>C.clientHeight)return}const B=g&&Ma(g.nodesRef.current,o).some(z=>{var Y;return gf(b,(Y=z.context)==null?void 0:Y.elements.floating)});if(gf(b,l)||gf(b,i)||B)return;const W=g?Ma(g.nodesRef.current,o):[];if(W.length>0){let z=!0;if(W.forEach(Y=>{var X;if((X=Y.context)!=null&&X.open&&!Y.context.dataRef.current.__outsidePressBubbles){z=!1;return}}),!z)return}r(!1,b,"outside-press")}),w=Ho(b=>{var k;const F=()=>{var C;M(b),(C=wr(b))==null||C.removeEventListener(p,F)};(k=wr(b))==null||k.addEventListener(p,F)});return O.useEffect(()=>{if(!n||!c)return;a.current.__escapeKeyBubbles=T,a.current.__outsidePressBubbles=L;function b(C){r(!1,C,"ancestor-scroll")}const k=Nr(l);u&&k.addEventListener("keydown",P?V:j,P),_&&k.addEventListener(p,I?w:M,I);let F=[];return y&&(ge(i)&&(F=Qn(i)),ge(l)&&(F=F.concat(Qn(l))),!ge(s)&&s&&s.contextElement&&(F=F.concat(Qn(s.contextElement)))),F=F.filter(C=>{var D;return C!==((D=k.defaultView)==null?void 0:D.visualViewport)}),F.forEach(C=>{C.addEventListener("scroll",b,{passive:!0})}),()=>{u&&k.removeEventListener("keydown",P?V:j,P),_&&k.removeEventListener(p,I?w:M,I),F.forEach(C=>{C.removeEventListener("scroll",b)})}},[a,l,i,s,u,_,p,n,r,y,c,T,L,j,P,V,M,I,w]),O.useEffect(()=>{x.current=!1},[_,p]),O.useMemo(()=>c?{reference:{onKeyDown:j,[c2[E]]:b=>{h&&r(!1,b.nativeEvent,"reference-press")}},floating:{onKeyDown:j,onMouseDown(){R.current=!0},onMouseUp(){R.current=!0},[u2[p]]:()=>{x.current=!0}}}:{},[c,h,p,E,r,j])}function f2(e){var t;e===void 0&&(e={});const{open:n=!1,onOpenChange:r,nodeId:o}=e,[s,i]=O.useState(null),l=((t=e.elements)==null?void 0:t.reference)||s,a=t2(e),c=Nf(),u=Rf()!=null,f=Ho((x,R,T)=>{x&&(h.current.openEvent=R),E.emit("openchange",{open:x,event:R,reason:T,nested:u}),r==null||r(x,R,T)}),p=O.useRef(null),h=O.useRef({}),E=O.useState(()=>s2())[0],y=Xy(),v=O.useCallback(x=>{const R=ge(x)?{getBoundingClientRect:()=>x.getBoundingClientRect(),contextElement:x}:x;a.refs.setReference(R)},[a.refs]),m=O.useCallback(x=>{(ge(x)||x===null)&&(p.current=x,i(x)),(ge(a.refs.reference.current)||a.refs.reference.current===null||x!==null&&!ge(x))&&a.refs.setReference(x)},[a.refs]),g=O.useMemo(()=>({...a.refs,setReference:m,setPositionReference:v,domReference:p}),[a.refs,m,v]),S=O.useMemo(()=>({...a.elements,domReference:l}),[a.elements,l]),_=O.useMemo(()=>({...a,refs:g,elements:S,dataRef:h,nodeId:o,floatingId:y,events:E,open:n,onOpenChange:f}),[a,o,y,E,n,f,g,S]);return Ei(()=>{const x=c==null?void 0:c.nodesRef.current.find(R=>R.id===o);x&&(x.context=_)}),O.useMemo(()=>({...a,context:_,refs:g,elements:S}),[a,g,S,_])}function p2(e,t){t===void 0&&(t={});const{open:n,onOpenChange:r,events:o,refs:s,elements:{floating:i,domReference:l}}=e,{enabled:a=!0,visibleOnly:c=!0}=t,u=O.useRef(!1),f=O.useRef(),p=O.useRef(!0);return O.useEffect(()=>{if(!a)return;const h=it(l);function E(){!n&&vt(l)&&l===Iy(Nr(l))&&(u.current=!0)}function y(){p.current=!0}return h.addEventListener("blur",E),h.addEventListener("keydown",y,!0),()=>{h.removeEventListener("blur",E),h.removeEventListener("keydown",y,!0)}},[i,l,n,a]),O.useEffect(()=>{if(!a)return;function h(E){let{reason:y}=E;(y==="reference-press"||y==="escape-key")&&(u.current=!0)}return o.on("openchange",h),()=>{o.off("openchange",h)}},[o,a]),O.useEffect(()=>()=>{clearTimeout(f.current)},[]),O.useMemo(()=>a?{reference:{onPointerDown(h){EC(h.nativeEvent)||(p.current=!1)},onMouseLeave(){u.current=!1},onFocus(h){if(u.current)return;const E=wr(h.nativeEvent);if(c&&ge(E))try{if(yC()&&_C())throw Error();if(!E.matches(":focus-visible"))return}catch{if(!p.current&&!NC(E))return}r(!0,h.nativeEvent,"focus")},onBlur(h){u.current=!1;const E=h.relatedTarget,y=ge(E)&&E.hasAttribute(wf("focus-guard"))&&E.getAttribute("data-type")==="outside";f.current=window.setTimeout(()=>{const v=Iy(l?l.ownerDocument:document);!E&&v===l||qn(s.floating.current,E)||qn(l,E)||y||r(!1,h.nativeEvent,"focus")})}}}:{},[a,c,l,s,r])}const Zy="active",ev="selected";function Tf(e,t,n){const r=new Map,o=n==="item";let s=e;if(o&&e){const{[Zy]:i,[ev]:l,...a}=e;s=a}return{...n==="floating"&&{tabIndex:-1},...s,...t.map(i=>{const l=i?i[n]:null;return typeof l=="function"?e?l(e):null:l}).concat(e).reduce((i,l)=>(l&&Object.entries(l).forEach(a=>{let[c,u]=a;if(!(o&&[Zy,ev].includes(c)))if(c.indexOf("on")===0){if(r.has(c)||r.set(c,[]),typeof u=="function"){var f;(f=r.get(c))==null||f.push(u),i[c]=function(){for(var p,h=arguments.length,E=new Array(h),y=0;y<h;y++)E[y]=arguments[y];return(p=r.get(c))==null?void 0:p.map(v=>v(...E)).find(v=>v!==void 0)}}}else i[c]=u}),i),{})}}function h2(e){e===void 0&&(e=[]);const t=e,n=O.useCallback(s=>Tf(s,e,"reference"),t),r=O.useCallback(s=>Tf(s,e,"floating"),t),o=O.useCallback(s=>Tf(s,e,"item"),e.map(s=>s==null?void 0:s.item));return O.useMemo(()=>({getReferenceProps:n,getFloatingProps:r,getItemProps:o}),[n,r,o])}const m2=new Map([["select","listbox"],["combobox","listbox"],["label",!1]]);function g2(e,t){var n;t===void 0&&(t={});const{open:r,floatingId:o}=e,{enabled:s=!0,role:i="dialog"}=t,l=(n=m2.get(i))!=null?n:i,a=Xy(),u=Rf()!=null;return O.useMemo(()=>{if(!s)return{};const f={id:o,...l&&{role:l}};return l==="tooltip"||i==="label"?{reference:{["aria-"+(i==="label"?"labelledby":"describedby")]:r?o:void 0},floating:f}:{reference:{"aria-expanded":r?"true":"false","aria-haspopup":l==="alertdialog"?"dialog":l,"aria-controls":r?o:void 0,...l==="listbox"&&{role:"combobox"},...l==="menu"&&{id:a},...l==="menu"&&u&&{role:"menuitem"},...i==="select"&&{"aria-autocomplete":"none"},...i==="combobox"&&{"aria-autocomplete":"list"}},floating:{...f,...l==="menu"&&{"aria-labelledby":a}},item(p){let{active:h,selected:E}=p;const y={role:"option",...h&&{id:o+"-option"}};switch(i){case"select":return{...y,"aria-selected":h&&E};case"combobox":return{...y,...h&&{"aria-selected":!0}}}return{}}}},[s,i,l,r,o,a,u])}function tv(e,t){const[n,r]=e;let o=!1;const s=t.length;for(let i=0,l=s-1;i<s;l=i++){const[a,c]=t[i]||[0,0],[u,f]=t[l]||[0,0];c>=r!=f>=r&&n<=(u-a)*(r-c)/(f-c)+a&&(o=!o)}return o}function E2(e,t){return e[0]>=t.x&&e[0]<=t.x+t.width&&e[1]>=t.y&&e[1]<=t.y+t.height}function y2(e){e===void 0&&(e={});const{buffer:t=.5,blockPointerEvents:n=!1,requireIntent:r=!0}=e;let o,s=!1,i=null,l=null,a=performance.now();function c(f,p){const h=performance.now(),E=h-a;if(i===null||l===null||E===0)return i=f,l=p,a=h,null;const y=f-i,v=p-l,g=Math.sqrt(y*y+v*v)/E;return i=f,l=p,a=h,g}const u=f=>{let{x:p,y:h,placement:E,elements:y,onClose:v,nodeId:m,tree:g}=f;return function(_){function x(){clearTimeout(o),v()}if(clearTimeout(o),!y.domReference||!y.floating||E==null||p==null||h==null)return;const{clientX:R,clientY:T}=_,L=[R,T],P=wr(_),I=_.type==="mouseleave",j=qn(y.floating,P),V=qn(y.domReference,P),M=y.domReference.getBoundingClientRect(),w=y.floating.getBoundingClientRect(),b=E.split("-")[0],k=p>w.right-w.width/2,F=h>w.bottom-w.height/2,C=E2(L,M),D=w.width>M.width,U=w.height>M.height,$=(D?M:w).left,B=(D?M:w).right,W=(U?M:w).top,z=(U?M:w).bottom;if(j&&(s=!0,!I))return;if(V&&(s=!1),V&&!I){s=!0;return}if(I&&ge(_.relatedTarget)&&qn(y.floating,_.relatedTarget)||g&&Ma(g.nodesRef.current,m).some(Z=>{let{context:J}=Z;return J==null?void 0:J.open}))return;if(b==="top"&&h>=M.bottom-1||b==="bottom"&&h<=M.top+1||b==="left"&&p>=M.right-1||b==="right"&&p<=M.left+1)return x();let Y=[];switch(b){case"top":Y=[[$,M.top+1],[$,w.bottom-1],[B,w.bottom-1],[B,M.top+1]];break;case"bottom":Y=[[$,w.top+1],[$,M.bottom-1],[B,M.bottom-1],[B,w.top+1]];break;case"left":Y=[[w.right-1,z],[w.right-1,W],[M.left+1,W],[M.left+1,z]];break;case"right":Y=[[M.right-1,z],[M.right-1,W],[w.left+1,W],[w.left+1,z]];break}function X(Z){let[J,te]=Z;switch(b){case"top":{const ce=[D?J+t/2:k?J+t*4:J-t*4,te+t+1],Re=[D?J-t/2:k?J+t*4:J-t*4,te+t+1],Me=[[w.left,k||D?w.bottom-t:w.top],[w.right,k?D?w.bottom-t:w.top:w.bottom-t]];return[ce,Re,...Me]}case"bottom":{const ce=[D?J+t/2:k?J+t*4:J-t*4,te-t],Re=[D?J-t/2:k?J+t*4:J-t*4,te-t],Me=[[w.left,k||D?w.top+t:w.bottom],[w.right,k?D?w.top+t:w.bottom:w.top+t]];return[ce,Re,...Me]}case"left":{const ce=[J+t+1,U?te+t/2:F?te+t*4:te-t*4],Re=[J+t+1,U?te-t/2:F?te+t*4:te-t*4];return[...[[F||U?w.right-t:w.left,w.top],[F?U?w.right-t:w.left:w.right-t,w.bottom]],ce,Re]}case"right":{const ce=[J-t,U?te+t/2:F?te+t*4:te-t*4],Re=[J-t,U?te-t/2:F?te+t*4:te-t*4],Me=[[F||U?w.left+t:w.right,w.top],[F?U?w.left+t:w.right:w.left+t,w.bottom]];return[ce,Re,...Me]}}}if(!tv([R,T],Y)){if(s&&!C)return x();if(!I&&r){const Z=c(_.clientX,_.clientY);if(Z!==null&&Z<.1)return x()}tv([R,T],X([p,h]))?!s&&r&&(o=window.setTimeout(x,40)):x()}}};return u.__options={blockPointerEvents:n},u}function v2({arrowPadding:e,escapeKey:t=!0,initialOpen:n=!1,keepOpenOverContent:r=!1,onOpenChange:o,open:s,outsidePress:i=!0,placement:l,role:a="tooltip"}){const c=Q(R=>R.rootElementId),u=O.useRef(null),[f,p]=O.useState(n),h=s??f,E=o??p,y=f2({middleware:[PC(8),DC({boundary:document.querySelector(`#${c}`)||void 0}),MC({padding:4}),e2({element:u,padding:e??{bottom:0,left:8,right:8,top:8}})],onOpenChange:E,open:h,placement:l,strategy:"fixed",whileElementsMounted:JC}),v=y.context,m=a2(v,{enabled:s==null,handleClose:r?y2():null,move:!1}),g=p2(v,{enabled:s==null}),S=d2(v,{escapeKey:t,outsidePress:i}),_=g2(v,{role:a}),x=h2([m,g,S,_]);return O.useMemo(()=>({arrowRef:u,open:h,setOpen:E,...x,...y}),[h,E,x,y])}const nv=H.createContext(null),Af=()=>{const e=H.useContext(nv);if(e==null)throw new Error("Tooltip components must be wrapped in <Tooltip />");return e},_2=({children:e,...t})=>{const n=v2(t);return d.jsx(nv.Provider,{value:n,children:e})},S2={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"},x2=()=>{var i,l;const e=Af(),[t,n]=O.useState(e.middlewareData.arrow);O.useEffect(()=>{e.middlewareData.arrow&&n(e.middlewareData.arrow)},[e.middlewareData.arrow]);const r={left:(t==null?void 0:t.x)!=null?`${t==null?void 0:t.x}px`:"",top:(t==null?void 0:t.y)!=null?`${t==null?void 0:t.y}px`:""},o=((l=(i=e.placement)==null?void 0:i.split("-"))==null?void 0:l[0])||"top",s=`${S2[o]}`;return d.jsx("div",{ref:e.arrowRef,style:r,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
- ${s}`})},S2=H.forwardRef(function(t,n){const{children:r,style:o,...s}=t,i=Af(),l=Yy([i.refs.setFloating,n]);return i.open?d.jsxs("div",{className:"relative max-w-md rounded-md bg-foreground p-2 text-sm text-background shadow-sm",ref:l,style:{left:i.x??0,position:i.strategy,top:i.y??0,visibility:i.x==null?"hidden":"visible",zIndex:10,...o},...i.getFloatingProps(s),children:[d.jsx("div",{className:"overflow-hidden",children:r}),d.jsx(_2,{})]}):null}),x2=O.forwardRef(function({children:t,asChild:n=!1,...r},o){const s=Af(),i=Yy([s.refs.setReference,o,t==null?void 0:t.ref]);return n&&O.isValidElement(t)?O.cloneElement(t,s.getReferenceProps({ref:i,...r,...t.props,"data-state":s.open?"open":"closed"})):d.jsx("button",{ref:i,"data-state":s.open?"open":"closed",...s.getReferenceProps(r),children:t})}),rv={bottom:"top",left:"right",right:"left",top:"bottom"},Zn=({asChild:e=!0,children:t,enable:n=!0,placement:r="right",scale:o=1,trigger:s=d.jsx(re,{tag:"circle-info"}),...i})=>{let l=r.split("-")[0];return l=Object.keys(rv).includes(l)?l:"right",n?d.jsxs(y2,{...i,placement:r,children:[d.jsx(x2,{asChild:e,children:s}),d.jsx(S2,{style:o!==1?{transform:`scale(${o})`,transformOrigin:rv[l]}:void 0,children:t})]}):d.jsx(d.Fragment,{children:s})},R2={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"},N={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_DEPLOY:"INFO_DEPLOY",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:"PHONE_NUMBER",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:"RECORDING",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_KEY:"VARIABLE_KEY",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"},N2={order:["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag","path","subdomain"],lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupQuerystring:"lng",lookupSessionStorage:"i18nextLng",caches:["localStorage","cookie"],excludeCacheFor:["cimode"]},w2={"en-US":{translation:R2}},O2=async()=>{await Ve.use(Ey).use(LI).init({debug:pA,detection:N2,fallbackLng:"en-US",interpolation:{escapeValue:!1},keySeparator:!1,resources:w2})};function Ua(e,t){return d.jsx(cC,{label:e,vars:t})}const ov=()=>Ve.resolvedLanguage,T2={entries:[],nextLabelIndex:0},Bo=bo((e,t)=>({...T2,actions:{getEntries(){return t().entries},getEntryValue(n){var r;return(r=t().entries.find(o=>o.controlId===n))==null?void 0:r.label},getGeneratedLabel(){let n="",r=t().nextLabelIndex;do r++,n=A(N.RECORDING_NAME_DEFAULT,{index:r});while(this.isValueDuplicate(n));return e({nextLabelIndex:r}),n},isKeyDuplicate(n){return t().entries.some(r=>r.controlId===n)},isValueDuplicate(n,r){const o=n.trim();return!!t().entries.reduce((i,l)=>{const{label:a,controlId:c}=l;return a!==""&&a===o&&(!r||c!==r)?[...i,l]:i},[]).length},removeEntry(n){e(r=>({entries:r.entries.filter(o=>o.controlId!==n)}))},upsertEntry:n=>{const{actions:r}=t(),{isKeyDuplicate:o}=r;e(s=>{let i=[...s.entries];const l=n.label.trim(),a=!!l;return(o(n.controlId)||!a)&&(i=i.filter(c=>c.controlId!==n.controlId)),a&&i.push({...n,label:l}),{entries:i}})}}})),If=()=>Bo.getState().actions,sv=e=>{const t=[];e.forEach(n=>{n.type==="recordCallStart"&&n.data.controlId&&n.data.label&&t.push({controlId:n.data.controlId,label:n.data.label})}),Bo.setState({entries:t,nextLabelIndex:t.length})},A2=(e,t)=>{const n=[];return t.forEach(r=>{r.type==="recordCallStart"&&r.data.controlId&&(n.push(r.data.controlId),Bo.getState().actions.removeEntry(r.data.controlId))}),n.length?e.reduce((r,o)=>o.type==="recordCallStop"&&n.includes(o.data.controlId)?[...r,{...o,data:{...o.data,controlId:""}}]:r,[]):[]},iv={recordCallStart:e=>{const t=Bo.getState().actions.getGeneratedLabel();return Bo.getState().actions.upsertEntry({controlId:e.data.controlId,label:t}),{...e,data:{...e.data,label:t}}}},I2=e=>typeof e=="object"&&e!==null&&Object.keys(e).length>0,C2=e=>iv[e.type]!==void 0,lv=(e,t={})=>{const{deletable:n=!0,position:r={x:300,y:250},selected:o=!0}=t,s=()=>({data:{initial:!0,valid:!1},deletable:n,id:le(),position:r,selected:o,type:e}),i=(c,u)=>({...c,data:{...c.data,...u}});let l=s();const a=Z0[e]();return I2(a)&&(l=i(l,a)),C2(l)&&(l=iv[l.type](l)),l},Fa={action:{label:N.ACTION,nodes:{answer:{active:!0,label:N.ANSWER_CALL},hangup:{active:!0,infoLabel:N.INFO_NODE_HANG_UP,label:N.HANG_UP_CALL},play:{active:!0,infoLabel:N.INFO_NODE_PLAY,label:N.PLAY_AUDIO_TTS},sendSms:{active:!0,infoLabel:N.INFO_NODE_SEND_SMS,label:N.SEND_SMS}}},decision:{label:N.DECISION,nodes:{cond:{active:!0,infoLabel:N.INFO_NODE_COND,label:N.CONDITIONS},executeSWML:{active:!0,infoLabel:N.INFO_NODE_EXECUTE_SWML,label:N.EXECUTE_SWML},set:{active:!0,infoLabel:N.INFO_NODE_SET_VARIABLES,label:N.SET_VARIABLES},unset:{active:!0,infoLabel:N.INFO_NODE_UNSET_VARIABLES,label:N.UNSET_VARIABLES}}},forwardTo:{label:N.FORWARD,nodes:{forwardAddress:{active:!1,infoLabel:N.INFO_NODE_FORWARD_TO_ADDRESS,label:N.FORWARD_TO_ADDRESS},forwardPhone:{active:!0,infoLabel:N.INFO_NODE_FORWARD_TO_PHONE,label:N.FORWARD_TO_PHONE},forwardResource:{active:!1,infoLabel:N.INFO_NODE_FORWARD_TO_RESOURCE,label:N.FORWARD_TO_RESOURCE}}},hidden:{label:N.HIDDEN,nodes:{handleCall:{active:!0,label:N.HANDLE_CALL}}},input:{label:N.INPUT,nodes:{aiAgent:{active:!0,infoLabel:N.INFO_NODE_AI_AGENT,label:N.AI_AGENT},condRequest:{active:!0,infoLabel:N.INFO_NODE_CONDREQUEST,label:N.REQUEST},promptPlay:{active:!0,infoLabel:N.INFO_NODE_GATHER_INPUT,label:N.GATHER_INPUT},request:{active:!1,deprecated:!0,infoLabel:N.INFO_NODE_REQUEST,label:N.REQUEST}}},recording:{label:N.RECORD,nodes:{record:{active:!0,infoLabel:N.INFO_NODE_RECORD,label:N.VOICEMAIL_RECORDING},recordCallStart:{active:!0,infoLabel:N.INFO_NODE_RECORD_CALL_START,label:N.RECORD_CALL_START},recordCallStop:{active:!0,infoLabel:N.INFO_NODE_RECORD_CALL_STOP,label:N.RECORD_CALL_STOP}}}},L2=Object.entries(Fa).reduce((e,[,{nodes:t}])=>(Object.entries(t).forEach(([n,{label:r}])=>{e.set(n,r)}),e),new Map),b2=Object.entries(Fa).reduce((e,[,{nodes:t}])=>(Object.entries(t).forEach(([n,{infoLabel:r}])=>{e.set(n,r)}),e),new Map),ja=Ne(),D2={aiAgentMap:new Map,error:"",status:"initial"},k2=(e,t)=>({...D2,actions:{fetchAiAgents:async()=>{try{const{actions:n}=t(),{getAiAgents:r}=n;if(!r){ja.error("getAiAgents is not defined");return}e({status:"loading"});const o=await r(),s=X0(o.data,"asc","display_name"),i=new Map(s.map(l=>[l.id,l]));e({aiAgentMap:i,error:"",status:"loaded"})}catch(n){let r="Unknown error";ja.error("Error fetching aiAgents ",n),n instanceof Error&&(r=n.message),e({aiAgentMap:new Map,error:r,status:"error"})}},init:({getAiAgentsURL:n})=>{if(!n){ja.error("getAiAgentsURL is not defined");return}const r=nc({getAiAgentsURL:n,headers:of()}),o=async()=>await r.getAiAgents();e(s=>({...s,actions:{...s.actions,getAiAgents:o}}))}}}),av=(e,t)=>{if(e.find(r=>r.type==="aiAgent")){const{fetchAiAgents:r}=en.getState().actions;r().then(()=>{const{aiAgentMap:o,status:s}=en.getState();s==="loaded"&&e.forEach(i=>{if(i.data&&"agent"in i.data){const l=o.has(i.data.agent);l||t(i.id,{agent:l?i.data.agent:"",valid:l})}})}).catch(o=>ja.error("Error rehydrating AiAgentStore",o))}},en=bo()(k2),P2=()=>en.getState().actions;window.__useAiAgentStore=en;const M2=e=>!!(e&&e>=gA),U2=e=>(t,n,r)=>(r.setState=(o,s,...i)=>{const{edges:l,detachedMode:a,httpError:c,initializing:u,isCanvasInteractive:f,isInteractiveControlOn:p,nodes:h,rootAppWidth:E,viewportChanging:y}=n(),v=typeof o=="function"?o(n()):o,m=["detachedMode","httpError","initializing","isInteractiveControlOn","rootAppWidth","viewportChanging"],g="initializing"in v?v.initializing:u;if(m.some(S=>S in v)){const S=M2("rootAppWidth"in v?v.rootAppWidth:E),_="isInteractiveControlOn"in v?v.isInteractiveControlOn:p,x="detachedMode"in v?v.detachedMode:a,R=("httpError"in v?v.httpError:c)===z0,T="viewportChanging"in v?v.viewportChanging:y;if(v.isCanvasInteractive=!!(S&&_&&!x&&!g&&!R&&!T),v.showInteractiveControl=S&&!R&&!x,f&&!v.isCanvasInteractive){const L="nodes"in v?v.nodes:h;v.nodes=L.map(I=>({...I,selected:!1}));const P="edges"in v?v.edges:l;v.edges=P.map(I=>({...I,selected:!1})),v.selectedNode=void 0}}t(v,s,...i)},e(r.setState,n,r)),cv=1e3,yi=Ne(),F2=e=>(t,n,r)=>{let o,s;const i=async()=>{const{httpService:l,nodes:a,edges:c,documentVersion:u}=n();t({dataHandlingStatus:"saving",saveFlowStatus:"saving"}),clearTimeout(s);try{if(!l)throw new Error("Missing httpService");const f=await l.putFlow({documentVersion:u,edges:c,flowDataVersion:li,nodes:a}),p={documentLastUpdated:f.updated_at,documentVersion:f.document_version},h=n().dataHandlingStatus;switch(h){case"saving":t({...p,dataHandlingStatus:"queueing",deployFlowStatus:"deploy",saveFlowStatus:"saved"});break;case"holding":t({...p,saveFlowStatus:"awaiting-save"}),yi.debug("Setting up a new save for held changes"),s=setTimeout(()=>{i().catch(E=>{yi.error("Error Save Flow",E)})},cv);break;default:yi.debug("Invalid dataHandlingStatus",h)}}catch(f){yi.error("Put Flow",f),f instanceof Error&&f.message.includes(EA)?t({dataHandlingStatus:"holding",httpError:"document-sync",saveFlowStatus:"error"}):t({dataHandlingStatus:"queueing",saveFlowStatus:"error"})}};return r.setState=(l,a,...c)=>{const{dataHandlingStatus:u,detachedMode:f,initializing:p,saveFlowStatus:h}=n(),E=typeof l=="function"?l(n()):l,y="initializing"in E?E.initializing:p,v="detachedMode"in E?E.detachedMode:f;!y&&!v&&(E.nodes||E.edges)?u==="queueing"?(E.saveFlowStatus="awaiting-save",t(E,a,...c),clearTimeout(o),o=setTimeout(()=>{i().catch(g=>{yi.error("Error Save Flow",g)})},cv)):(E.dataHandlingStatus="holding",t(E,a,...c)):"initializing"in E&&!E.initializing?(E.dataHandlingStatus="queueing",h!=="error"&&(E.saveFlowStatus="saved"),t(E,a,...c)):t(E,a,...c)},e(r.setState,n,r)},Va=Ne(),j2={cachedResults:new Map,error:"",results:[],status:"initial",swmlScriptMap:new Map},V2={ids:"ids",name:"name"},$2=(e,t)=>({...j2,actions:{buildParamsFromQuery:n=>{const{searchParams:r}=new URL(n,window.location.href);return IA(V2).reduce((s,i)=>{const l=r.get(i);return l&&(i==="ids"?s[i]=l.split(","):s[i]=l),s},{})},buildQueryFromParams:n=>{const r=ec(window.location.origin,{...n}),{search:o}=new URL(r);return`/${o}`},fetchSwmlScript:async n=>{try{const{actions:r}=t(),{getSwmlScripts:o,updateMapAndCache:s}=r;if(!o){Va.error("getSwmlScripts is not defined");return}e({status:"loading"});const i=await o(n),l=X0(i.data,"asc","display_name"),a=new Map(l.map(c=>[c.id,{displayName:c.display_name,id:c.id,requestUrl:c.request_url}]));s(a,n),e({error:"",results:Array.from(a.values()),status:"loaded"})}catch(r){let o="Unknown error";Va.error("Error fetching swmlScripts ",r),r instanceof Error&&(o=r.message),e({error:o,status:"error"})}},getCachedResults:n=>{const{cachedResults:r,swmlScriptMap:o}=t(),s=r.get(n);if(s)return s.reduce((i,l)=>{const a=o.get(l);return a&&i.push(a),i},[])},init:({getSwmlScriptsURL:n})=>{if(!n){Va.error("getSwmlScriptsURL is not defined");return}const r=nc({getSwmlScriptsURL:n,headers:of()}),o=async s=>await r.getSwmlScripts(s);e(s=>({...s,actions:{...s.actions,getSwmlScripts:o}}))},setResults:n=>{e({results:n})},updateConnection:(n,r)=>{if(n.connectConfirmId!=="external"){const o=r.get(n.connectConfirmId),s={...n};if(o&&o.displayName!==n.connectConfirmDisplayName)return s.connectConfirmDisplayName=o.displayName,s;if(!o)return s.connectConfirmId="",s.connectConfirmUrl="",s}},updateMapAndCache:(n,r)=>{const{actions:o,cachedResults:s,swmlScriptMap:i}=t(),{buildQueryFromParams:l}=o,a=r==null?void 0:r.ids,c=l(r),u=s.get(c),f=(u==null?void 0:u.filter(y=>n.has(y)))??[],p=(a==null?void 0:a.filter(y=>!n.has(y)))??[],h=[...new Set([...p,...f])];h.length>0&&(Array.from(s.entries()).forEach(([v,m])=>{if(v===r){const g=m.filter(S=>!h.includes(S));s.set(v,g)}}),h.forEach(v=>{i.delete(v)})),n.forEach((y,v)=>{i.set(v,y)});const E=Array.from(n.keys());s.set(c,E),e({cachedResults:new Map(s),swmlScriptMap:new Map(i)})},validateCache:(()=>{let n;return()=>{n&&clearTimeout(n),n=setTimeout(async()=>{const{actions:o,swmlScriptMap:s}=t(),{fetchSwmlScript:i}=o,l=Array.from(s.keys());l.length>0&&i&&await i({ids:l})},W0)}})(),validateScriptsFromNodes:(n,r)=>{const{actions:o}=t(),{fetchSwmlScript:s}=o,i=new Set,l=n.filter(c=>uv(c)&&"connections"in c.data&&c.data.connections.some(u=>u.connectConfirmEnabled));if(l.length===0)return;const a=(c,u)=>l.forEach(f=>{const p=f.data.connections.map(h=>c(h)??h);typeof u=="function"&&u(p,f)});a(c=>{c.connectConfirmId!==""&&c.connectConfirmId!=="external"&&c.connectConfirmEnabled&&i.add(c.connectConfirmId)}),i.size!==0&&s({ids:Array.from(i.values())}).then(()=>{const{actions:c,swmlScriptMap:u,status:f}=_n.getState(),{updateConnection:p}=c;f==="loaded"&&a(h=>{const E=p(h,u);return E||h},(h,E)=>{r(E.id,{connections:h})})}).catch(c=>Va.error("Error rehydrating SwmlScriptStore",c))}}}),uv=e=>e.type==="forwardAddress"||e.type==="forwardPhone"||e.type==="forwardResource",H2=(e,t)=>{if(e.some(uv)){const{validateScriptsFromNodes:r}=_n.getState().actions;r(e,t)}},_n=bo()($2),dv=()=>_n.getState().actions;window.__useSwmlScriptStore=_n;const fv=500,B2=100,Oe=Ne(),z2=lv("handleCall",{deletable:!1,position:{x:300,y:100}}),Cf={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},W2=(e,t)=>({...Cf,actions:{addNode:({nodeType:n,x:r=150,y:o=150})=>{Oe.debug("Add Node",n);const{nodes:s,reactFlowInstance:i}=t();if(!i)throw new Error("ReactFlowInstance not found");const l=lv(n,{position:i.project({x:r,y:o})}),a=s.map(c=>({...c,selected:!1}));a.push(l),e({nodes:a,selectedNode:l})},addToast:n=>{const{toastsMap:r}=t(),o=le();r.set(o,{...n,id:o}),e({toastsMap:new Map(r)})},cancelDetachedMode:async()=>{const{actions:n,workingFlowCopy:r}=t(),{cleanUpDetachedMode:o}=n;if(r){const{edges:s,nodes:i,saveFlowStatus:l}=r;e({edges:[],initializing:!0,nodes:[]}),await q0(fv),e({edges:s,nodes:i,saveFlowStatus:l})}else Oe.error("There was no working flow to restore");o()},cleanUpDetachedMode:()=>{e({detachedMode:!1,showDeployedHistory:!1,showDeployedHistoryToast:!1,workingFlowCopy:void 0})},deleteToast:n=>{const{toastsMap:r}=t();r.delete(n)&&e({toastsMap:new Map(r)})},deleteValidationWarning:n=>{const{validationWarnings:r}=t();r.delete(n)&&e({validationWarnings:new Map(r)})},deployFlow:async()=>{Oe.info("Deploying..."),e({deployFlowStatus:"deploying"});try{const{httpService:n,documentVersion:r}=t();if(!n)throw new Error("Missing httpService");const o=await n.deployFlow({documentVersion:r});Oe.info("Deploy response",o),e({deployFlowStatus:"deployed"})}catch(n){throw Oe.info("Deploy error",n),e({deployFlowStatus:"error"}),n}},exportStoreData:()=>{const{nodes:n,edges:r}=t();wA(n,r)},getDeployedVersionsList:async n=>{try{const{httpService:r}=t();if(!r)throw new Error("Missing httpService");const o=await r.getFlowVersions(n),s=Q0(ov());return e({deployedVersionsList:o.map((i,l)=>({id:i.id,relativeTimeSince:s(i.created_at),version:(o.length-l).toFixed(1)}))}),o}catch(r){throw Oe.error("Could not get deployed versions",r),e({deployedVersionsList:[]}),r}},getNodeType:n=>{const r=t().nodes.find(o=>o.id===n);return r==null?void 0:r.type},getRootElement:()=>{const{rootElement:n,rootElementId:r}=t();if(!n)throw new Error(`Root element not found for ID ${r}`);return n.shadowRoot?n.shadowRoot.getRootNode():n},getTargetEdges:n=>t().edges.filter(r=>{const o=r.target===n,s=r.source!==r.target;return o&&s}),getValidationWarnings:()=>t().validationWarnings,migrateAndLoadDeployedFlow:async n=>{const{actions:r,workingFlowCopy:o}=t(),{partialUpdateNodeData:s,saveWorkingFlowCopy:i}=r,a=new pp({dbRecord:n}).migrateTo(li),{flow_data:c}=a;if(!c)Oe.error("Cannot load flow: missing flowData",c);else{o||i();const u=c.nodes.map(Y0),f=c.edges.map(G0);e({detachedMode:!0,edges:[],initializing:!0,nodes:[]}),await q0(fv),e({edges:f,nodes:u,showDeployedHistoryToast:!0}),sv(u),av(u,s)}},onConnect:n=>{Oe.debug("onConnect"),e({edges:jE(n,t().edges)})},onConnectEnd:()=>{Oe.debug("onConnectEnd"),e({isEdgeConnecting:!1})},onConnectStart:()=>{Oe.debug("onConnectStart"),e({isEdgeConnecting:!0})},onEdgeUpdate:(n,r)=>{Oe.debug("onEdgeUpdate"),e({edges:SO(n,r,t().edges),isEdgeUpdateSuccessful:!0})},onEdgeUpdateEnd:(n,r)=>{var o;Oe.debug("onEdgeUpdateEnd"),t().isEdgeUpdateSuccessful?e({isEdgeUpdateSuccessful:!0}):(o=t().reactFlowInstance)==null||o.deleteElements({edges:[{id:r.id}]}),e({updatingSourceHandleId:void 0})},onEdgeUpdateStart:(n,r)=>{Oe.debug("onEdgeUpdateStart"),e({isEdgeUpdateSuccessful:!1,updatingSourceHandleId:r.sourceHandle??void 0})},onEdgesChange:n=>{e({edges:JO(n,t().edges)})},onEdgesDelete:n=>{Oe.debug("onEdgesDelete [noop]",n)},onInit:async n=>{const{actions:r,deployFlowURL:o,getFlowURL:s,updateFlowURL:i}=t(),{partialUpdateNodeData:l}=r;Oe.log("onInit",{getFlowURL:s,updateFlowURL:i});try{const a=nc({deployFlowURL:o,getFlowURL:s,headers:of(),updateFlowURL:i}),[c,u]=await Promise.all([a.getFlow(),a.getFlowVersions({pageSize:1})]),p=new pp({dbRecord:c}).migrateTo(li),{document_version:h,flow_data:E,id:y,title:v,updated_at:m}=p;if(u.length&&u[0]){const{document_version:S}=u[0];S===h&&e({deployFlowStatus:"deployed"})}let g=E;g||(g={edges:Cf.edges,flowDataVersion:li,nodes:Cf.nodes.concat([z2])}),e({documentLastUpdated:m,documentVersion:h,edges:g.edges.map(G0),flowId:y,flowTitle:v,httpService:a,nodes:g.nodes.map(Y0),reactFlowInstance:n}),sv(g.nodes),av(g.nodes,l),H2(g.nodes,l)}catch(a){Oe.error("Could not load flow. URL:",s);let c="unknown";a instanceof Error&&a.message.includes(yA)&&(c="not-found"),e({httpError:c})}},onNodeDragStart:()=>{e({isDraggingNode:!0})},onNodeDragStop:()=>{e({isDraggingNode:!1})},onNodesChange:n=>{const r=n.filter(o=>o.type!=="dimensions");r.length>0&&e({nodes:h0(r,t().nodes)})},onNodesDelete:n=>{Oe.debug("onNodesDelete");const{actions:r}=t(),{partialUpdateNodeData:o}=r;A2(t().nodes,n).forEach(i=>{o(i.id,i.data)})},onSelectionChange:({nodes:n})=>{e({selectedNode:n.find(r=>r.selected)})},onViewportChange:(()=>{let n;function r(o){n&&clearTimeout(n),n=setTimeout(()=>{e({viewportChanging:!1})},B2),e({viewport:{...o},viewportChanging:!0})}return r})(),onViewportChangeEnd:()=>{},onViewportChangeStart:()=>{},partialUpdateNodeData:(n,r)=>{var i;Oe.debug("partialUpdateNodeData",n,r);const o=[],s=t().nodes.map(l=>{if(l.id===n){if("options"in r&&"options"in l.data){const a=l.data.options.map(u=>u.id),c=r.options.map(u=>u.id);o.push(...a.filter(u=>!c.includes(u)))}return{...l,data:{...l.data,...r}}}return l});if(o.length){const l=t().edges.filter(a=>a.sourceHandle&&o.includes(a.sourceHandle));Oe.debug("Remove orphaned edges",{edgesToDelete:l,sourceHandleDeleted:o}),(i=t().reactFlowInstance)==null||i.deleteElements({edges:l})}e({nodes:s})},partialUpdateValidationWarning:(n,r)=>{const{validationWarnings:o}=t(),s=l=>l.connected===!1||l.valid===!1,i=o.get(n);if(r.nodeType!=="handleCall"&&!i&&s(r)){const l=L2.get(r.nodeType),a={connected:r.connected,id:le(),nodeId:r.nodeId,nodeTitle:l,nodeType:r.nodeType,valid:r.valid};o.set(n,a)}else if(i){const l={...i,...r};s(l)?o.set(n,l):o.delete(n)}e({validationWarnings:new Map(o)})},removeEdge:n=>{Oe.debug("removeEdge",n);const r=t().reactFlowInstance;r&&r.deleteElements({edges:[{id:n}]})},removeNode:n=>{Oe.debug("removeNode",n);const r=t().reactFlowInstance;r&&r.deleteElements({nodes:[{id:n}]})},restoreDeployedFlow:()=>{const{actions:n,edges:r,nodes:o}=t(),{cleanUpDetachedMode:s}=n;e({detachedMode:!1,edges:r,nodes:o}),s()},saveWorkingFlowCopy:()=>{const{edges:n,nodes:r,saveFlowStatus:o}=t();e({workingFlowCopy:{edges:n,nodes:r,saveFlowStatus:o}})},setColorMode:n=>{e({colorMode:n})},setDragNodeType:n=>{e({dragNodeType:n})},setFlowWrapperElement:n=>{e({flowWrapperElement:n||void 0})},setInitializing:n=>{e({initializing:n})},setSelectedNodes:n=>{const{nodes:r}=t(),o=r.map(s=>({...s,selected:n.includes(s.id)}));e({nodes:o})},setShowDeployWarning:n=>{e({showDeployWarning:n})},setShowDeployedHistory:n=>{e({showDeployedHistory:n})},setShowValidationWarnings:n=>{e({showValidationWarnings:n})},setViewportChanging:n=>{e({viewportChanging:n})}}}),Q=bo()(U2(F2(W2))),Te=()=>Q.getState().actions;window.__useRFStore=Q;const G2={"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"}},Y2=({errorType:e})=>{const t=Q(s=>s.backButtonHref),{title:n,message:r,status:o}=G2[e];return d.jsx("section",{className:"flex min-h-full w-full items-center justify-center bg-background px-6",children:d.jsxs("div",{className:"text-center",children:[o&&d.jsx("p",{className:"text-2xl font-semibold text-foreground/50",children:o}),d.jsx("h1",{className:"mt-4 text-3xl font-bold tracking-tight text-foreground",children:n}),d.jsx("p",{className:"mt-6 leading-7 text-foreground",children:r}),t&&d.jsx("div",{className:"mt-8 flex items-center justify-center gap-x-6",children:d.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:A(N.GO_BACK)})})]})})},pv=({height:e,strokeWidth:t,toX:n,toY:r,width:o})=>d.jsx("svg",{x:n-o*t/2,y:r-e*t/2,height:e*t,width:o*t,viewBox:`-${o/2} -${e/2} ${o} ${e}`,children:d.jsx("g",{children:d.jsx("polyline",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:t,points:"-5,-4 0,0 -5,4 -5,-4"})})}),K2=({fromHandle:e,fromNode:t,fromPosition:n,fromX:r,fromY:o,toPosition:s,toX:i,toY:l})=>{if(!t)return null;const[a]=ri({borderRadius:B0,sourcePosition:n,sourceX:r,sourceY:o,targetPosition:s,targetX:i,targetY:l}),{height:c,strokeWidth:u,width:f}={...Do.markerEnd,...Do.style},p=(e==null?void 0:e.position)===q.Left,h=p?r:i,E=p?o:l;return d.jsxs("g",{className:"cfb-connection-line",children:[d.jsx("path",{fill:"none",strokeWidth:u,className:"animated",d:a}),d.jsx(pv,{height:c,strokeWidth:u,toX:h,toY:E,width:f}),p&&d.jsx("circle",{cx:i-2,cy:l,fill:"none",r:4,strokeWidth:u})]})};function X2({isCircular:e=!1,targetNode:t,targetX:n,targetY:r}){const{width:o,height:s,position:i}=t,l=o??0,a=s??0,c=l/2;return e?{tx:i.x+c,ty:i.y+a}:{tx:n,ty:r}}const Q2=e=>{const t={...e,interactionWidth:40},{id:n,source:r,target:o,sourcePosition:s,sourceX:i,sourceY:l,targetX:a,targetY:c}=t,{removeEdge:u}=Te(),f=O.useRef(null),p=de(O.useCallback(I=>I.nodeInternals.get(r),[r])),h=de(O.useCallback(I=>I.nodeInternals.get(o),[o]));if(!p||!h)return null;const E=r===o,{tx:y,ty:v}=X2({isCircular:E,targetNode:h,targetX:a,targetY:c}),[m,g,S]=ri({borderRadius:B0,sourcePosition:s,sourceX:i,sourceY:l,targetPosition:E?q.Bottom:q.Left,targetX:y,targetY:v}),_=(I,j)=>{I.stopPropagation(),u(j)},x=I=>{var j,V,M;(j=I.currentTarget)==null||j.classList.add("highlight"),(V=f.current)==null||V.classList.add("animate-delay-opacity","flex"),(M=f.current)==null||M.classList.remove("hidden")},R=I=>{var j,V,M;(j=I.currentTarget)==null||j.classList.remove("highlight"),(V=f.current)==null||V.classList.remove("animate-delay-opacity","flex"),(M=f.current)==null||M.classList.add("hidden")},{height:T,strokeWidth:L,width:P}={...Do.markerEnd,...Do.style};return d.jsxs("g",{onMouseEnter:x,onMouseLeave:R,children:[d.jsx(xo,{path:m,...t}),d.jsx(pv,{height:T,strokeWidth:L,toX:y,toY:v,width:P}),d.jsx(WT,{children:d.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:I=>_(I,n),ref:f,style:{transform:`translate(-50%, -50%) translate(${g}px,${S}px)`},children:[d.jsx(re,{tag:"trash-can",className:"py-0.5 px-1.5 text-background"}),d.jsx("span",{className:"sr-only",children:A(N.REMOVE_EDGE)})]})})]})},q2=/^[\w\d -']+$/,J2=/^\d+$/,Z2=/^\d|\*|#$/,eL=/^[\d*#$]{0,12}$/,tL=/^.{1,20}$/,zo={MAX:3600,MIN:0},nL=/^[a-z0-9_]{1,20}$/,Ee={MAX:99,MIN:1},Wo=e=>t=>!!e.exec(t),Lf=e=>{if(!yt(e))return!0;try{return!!new URL(e)}catch{return!1}},lt=e=>yt(e)?Wo(J2)(e):!0,rL=e=>yt(e)?Wo(Z2)(e):!0,oL=e=>yt(e)?Wo(q2)(e):!0,sL=e=>yt(e)?Wo(nL)(e):!0,hv=e=>yt(e)?Wo(eL)(e):!0,iL=e=>yt(e)?Wo(tL)(e):!0,$a=e=>{if(!yt(e))return!0;try{return JSON.parse(e),!0}catch{return!1}},ae=e=>!!yt(e),vi=(e,t)=>{if(typeof e=="string"&&!yt(e))return!0;const n=typeof e!="number"?parseInt(e,10):e;return!Number.isNaN(n)&&n>=t},_i=(e,t)=>{if(typeof e=="string"&&!yt(e))return!0;const n=typeof e!="number"?parseInt(e,10):e;return!Number.isNaN(n)&&n<=t},er=(e,t)=>{const n=new Set,r=e.reduce((o,s)=>{const i=s[t];if(typeof i=="string"){const l=i.trim();l&&(n.has(l)&&o.add(l),n.add(l))}return o},new Set);return o=>r.has(o.trim())},Go={aiAgent:{fieldValidators:{agent:[ae]},validate:e=>Yo({nodeData:e,nodeType:"aiAgent"}),validateField:(e,t)=>ie({name:e,nodeType:"aiAgent",value:t})},cond:{fieldValidators:{value:[ae]},validate:e=>Df("cond",e),validateField:(e,t)=>ie({name:e,nodeType:"cond",value:t})},condRequest:{fieldValidators:{body:[],headers:[$a],method:[ae],saveVariables:[],url:[ae],value:[ae]},validate:e=>{const t=e,n=[];return["body","headers","method","saveVariables","url"].forEach(o=>{ie({name:o,nodeType:"condRequest",value:t[o]})||n.push(o)}),[...n,...Df("condRequest",e)]},validateField:(e,t)=>ie({name:e,nodeType:"condRequest",value:t})},executeSWML:{fieldValidators:{dest:[ae],meta:[$a],params:[$a]},validate:e=>{const t=e,n=[];return["dest","params","meta"].forEach(o=>{ie({name:o,nodeType:"executeSWML",value:t[o]})||n.push(o)}),[...n,...Df("executeSWML",e)]},validateField:(e,t)=>ie({name:e,nodeType:"executeSWML",value:t})},forwardAddress:{fieldValidators:{callOrder:[],callStateEvents:[],callStateUrl:[],connectConfirmDisplayName:[],connectConfirmEnabled:[],connectConfirmId:[ae],connectConfirmUrl:[ae,Lf],connectFrom:[],connectTimeout:[lt],connectTo:[ae],defaultFrom:[],defaultTimeout:[lt],sessionTimeout:[lt]},validate:e=>kf("forwardAddress",e),validateField:(e,t)=>ie({name:e,nodeType:"forwardAddress",value:t})},forwardPhone:{fieldValidators:{callOrder:[],callStateEvents:[],callStateUrl:[],connectConfirmDisplayName:[],connectConfirmEnabled:[],connectConfirmId:[ae],connectConfirmUrl:[ae,Lf],connectFrom:[],connectTimeout:[lt],connectTo:[ae],defaultFrom:[],defaultTimeout:[lt],sessionTimeout:[lt]},validate:e=>kf("forwardPhone",e),validateField:(e,t)=>ie({name:e,nodeType:"forwardPhone",value:t})},forwardResource:{fieldValidators:{callOrder:[],callStateEvents:[],callStateUrl:[],connectConfirmDisplayName:[],connectConfirmEnabled:[],connectConfirmId:[ae],connectConfirmUrl:[ae,Lf],connectFrom:[],connectTimeout:[lt],connectTo:[ae],defaultFrom:[],defaultTimeout:[lt],sessionTimeout:[lt]},validate:e=>kf("forwardResource",e),validateField:(e,t)=>ie({name:e,nodeType:"forwardResource",value:t})},hangup:{fieldValidators:{reason:[]},validate:e=>Pf("hangup",e),validateField:(e,t)=>ie({name:e,nodeType:"hangup",value:t})},play:{fieldValidators:{selected:[ae],text:[ae],url:[ae]},validate:e=>Pf("play",e),validateField:(e,t)=>ie({name:e,nodeType:"play",value:t})},promptPlay:{fieldValidators:{command:[oL],digit:[rL],digitTimeout:[lt,{test:vi,testValue:Ee.MIN},{test:_i,testValue:Ee.MAX}],initialTimeout:[lt,{test:vi,testValue:Ee.MIN},{test:_i,testValue:Ee.MAX}],selected:[ae],text:[ae],url:[ae]},validate:e=>{const t="promptPlay",n=e,r=er(n.options,"command"),o=er(n.options,"digit"),s=Pf("promptPlay",n),i=Za(n.initialTimeout);i!=null&&i.trim()&&!ie({name:"initialTimeout",nodeType:t,value:i})&&s.push("initialTimeout");const l=Za(n.digitTimeout);return l!=null&&l.trim()&&!ie({name:"digitTimeout",nodeType:t,value:l})&&s.push("digitTimeout"),n.options.forEach(a=>{const c=ie({name:"command",nodeType:t,value:a.command})&&!r(a.command),u=ie({name:"digit",nodeType:t,value:a.digit})&&!o(a.digit);c&&u&&(a.command||a.digit)||s.push(`option_${a.id}`)}),s},validateField:(e,t)=>ie({name:e,nodeType:"promptPlay",value:t})},record:{fieldValidators:{beep:[],endSilenceTimeout:[lt,{test:vi,testValue:Ee.MIN},{test:_i,testValue:Ee.MAX}],format:[ae],initialTimeout:[lt,{test:vi,testValue:Ee.MIN},{test:_i,testValue:Ee.MAX}],maxLength:[lt,{test:vi,testValue:zo.MIN},{test:_i,testValue:zo.MAX}],stereo:[],terminators:[hv]},validate:e=>Yo({nodeData:e,nodeType:"record"}),validateField:(e,t)=>ie({name:e,nodeType:"record",value:t})},recordCallStart:{fieldValidators:{beep:[],controlId:[],format:[ae],label:[ae,iL],stereo:[],terminators:[hv]},validate:e=>Yo({nodeData:e,nodeType:"recordCallStart"}),validateField:(e,t)=>ie({name:e,nodeType:"recordCallStart",value:t})},recordCallStop:{fieldValidators:{controlId:[ae]},validate:e=>Yo({nodeData:e,nodeType:"recordCallStop"}),validateField:(e,t)=>ie({name:e,nodeType:"recordCallStop",value:t})},request:{fieldValidators:{body:[],headers:[$a],method:[ae],saveVariables:[],url:[ae]},validate:e=>Yo({nodeData:e,nodeType:"request"}),validateField:(e,t)=>ie({name:e,nodeType:"request",value:t})},sendSms:{fieldValidators:{body:[ae],fromNumber:[ae],toNumber:[ae]},validate:e=>Yo({nodeData:e,nodeType:"sendSms"}),validateField:(e,t)=>ie({name:e,nodeType:"sendSms",value:t})},set:{fieldValidators:{key:[ae,sL],value:[]},validate:e=>{const t=e,n="set",r=[],o=er(t.variables,"key");return t.variables.forEach(s=>{const i=ie({name:"key",nodeType:n,value:s.key})&&!o(s.key),l=ie({name:"value",nodeType:n,value:s.value});i&&l||r.push(`variable_${s.id}`)}),r},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})}},at=e=>{const t=Go==null?void 0:Go[e];return{validate:t==null?void 0:t.validate,validateField:t==null?void 0:t.validateField}},mv=(e,t)=>{var r;const n=(r=Go[e])==null?void 0:r.validate;return n===void 0?[]:n(t)},bf=(e,t)=>{var n;return!e||!t?!1:((n=mv(e,t))==null?void 0:n.length)===0},lL=e=>{var t;return(t=Go[e])==null?void 0:t.fieldValidators},ie=({name:e,nodeType:t,value:n})=>{var s;let r=!0;const o=(s=lL(t))==null?void 0:s[e];return o==null||o.forEach(i=>{typeof i=="function"?r=r&&i(n):r=r&&i.test(n,i.testValue)}),r},Yo=({nodeData:e,nodeType:t})=>{var o;const n=((o=Go[t])==null?void 0:o.fieldValidators)??{},r=[];return Object.keys(n).forEach(s=>{const i=s;ie({name:s,nodeType:t,value:(e==null?void 0:e[i])??""})||r.push(s)}),r},Df=(e,t)=>{const n=t,r=[];return n.options.forEach(o=>{ie({name:"value",nodeType:e,value:o.value})||r.push(`condition_${o.id}`)}),r},kf=(e,t)=>{var s;const n=[];["callOrder","callStateEvents","callStateUrl","defaultFrom","defaultTimeout"].forEach(i=>{ie({name:i,nodeType:e,value:t[i]})||n.push(i)});const o=["connectFrom","connectTo","connectTimeout","connectConfirmUrl","connectConfirmId"];return(s=t.connections)==null||s.forEach(i=>{o.forEach(l=>{!i.connectConfirmEnabled&&(l==="connectConfirmUrl"||l==="connectConfirmId")||ie({name:l,nodeType:e,value:i[l]})||n.push(`${l}_${i.id}`)})}),n},Pf=(e,t)=>{const n=[];return ie({name:"selected",nodeType:e,value:t==null?void 0:t.selected})||n.push("selected"),t.selected==="url"?ie({name:"url",nodeType:e,value:t.url})||n.push("url"):t.selected==="text"&&(ie({name:"text",nodeType:e,value:t.text})||n.push("text")),n},ct=({data:e,id:t})=>{const n=Q(l=>l.isCanvasInteractive),{getNodeType:r,partialUpdateNodeData:o}=Te(),{isValueDuplicate:s}=If(),i=r(t);return O.useEffect(()=>{if(i&&n){let l=bf(i,e);i==="recordCallStart"&&"label"in e&&(l=l&&!s(e.label,e.controlId)),l!==e.valid&&o(t,{valid:l})}},[e,t,n,s,o,i]),O.useEffect(()=>{if(i==="aiAgent"&&n){const l=en.subscribe(a=>{if(a.status==="loaded"&&"agent"in e){const c=a.aiAgentMap.has(e.agent),u=c&&bf(i,e);u!==e.valid&&o(t,{agent:c?e.agent:"",valid:u})}});return()=>{l()}}},[e,t,n,o,i]),O.useEffect(()=>{if((a=>(i==="forwardAddress"||i==="forwardPhone"||i==="forwardResource")&&"connections"in a)(e)&&n){const a=_n.subscribe(c=>{if(c.status==="loaded"){let u=!0;const f=e.connections.map(h=>{const E=c.actions.updateConnection(h,c.swmlScriptMap);return E?(u=!1,E):h}),p=u&&bf(i,e);p!==e.valid&&o(t,{connections:f,valid:p})}});return()=>{a()}}},[e,t,n,o,i]),{getInvalidFields:()=>!i||e.valid?[]:mv(i,e),valid:()=>e.valid}},aL=({data:e,id:t,isConnectable:n,selected:r})=>{ct({data:e,id:t});const o=en(i=>i.aiAgentMap.get(e.agent)),s=o==null?void 0:o.display_name;return d.jsxs($e,{id:t,isConnectable:n,nodeTitle:A(N.AI_AGENT),selected:r,valid:e.valid,children:[s&&d.jsx(Lt,{children:d.jsx("p",{className:"truncate text-xs",children:s})}),d.jsx(Ht,{id:t,color:"positive",isConnectable:n})]})},cL=({data:e,id:t,isConnectable:n,selected:r})=>d.jsx($e,{id:t,isConnectable:n,nodeTitle:A(N.ANSWER_CALL),selected:r,valid:e.valid,children:d.jsx(Ht,{id:t,isConnectable:n,color:"positive"})}),uL=({id:e,data:t,isConnectable:n,selected:r})=>(ct({data:t,id:e}),d.jsx($e,{id:e,isConnectable:n,nodeTitle:A(N.CONDITIONS),selected:r,valid:t.valid,children:d.jsxs(Fo,{children:[t.options.map((o,s)=>{const i=o.value.trim();return d.jsx(Bt,{color:"positive",enabled:!!i,id:o.id,isConnectable:n,optionTitle:i?d.jsx("div",{className:"truncate",children:i}):A(N.CONDITION_NUMBER,{index:s+1})},o.id)}),d.jsx(Bt,{color:"negative",id:t.fallback,isConnectable:n,optionTitle:A(N.ELSE)})]})})),dL=({data:e,id:t,isConnectable:n,selected:r})=>{var s;ct({data:e,id:t});const o=e.url.trim();return d.jsxs($e,{id:t,isConnectable:n,nodeTitle:A(N.REQUEST),selected:r,valid:e.valid,children:[o&&d.jsx(Lt,{children:d.jsx("div",{className:"break-all line-clamp-3",children:o})}),d.jsxs(Fo,{children:[(s=e==null?void 0:e.options)==null?void 0:s.map((i,l)=>{const a=i.value.trim();return d.jsx(Bt,{color:"positive",enabled:!!a,id:i.id,isConnectable:n,optionTitle:a?d.jsx("div",{className:"truncate",children:a}):A(N.CONDITION_NUMBER,{index:l+1})},i.id)}),d.jsx(Bt,{color:"negative",id:e.fallback,isConnectable:n,optionTitle:A(N.ELSE)}),d.jsx(Bt,{color:"negative",id:e.error,isConnectable:n,optionTitle:A(N.FAILURE)})]})]})},fL=({data:e,id:t,isConnectable:n,selected:r})=>{var s;ct({data:e,id:t});const o=e.dest.trim();return d.jsxs($e,{id:t,isConnectable:n,nodeTitle:A(N.EXECUTE_SWML),selected:r,valid:e.valid,children:[o&&d.jsx(Lt,{children:d.jsx("div",{className:"break-all line-clamp-3",children:o})}),d.jsxs(Fo,{children:[(s=e==null?void 0:e.options)==null?void 0:s.map((i,l)=>{const a=i.value.trim();return d.jsx(Bt,{color:"positive",enabled:!!a,id:i.id,isConnectable:n,optionTitle:a?d.jsx("div",{className:"truncate",children:a}):A(N.CONDITION_NUMBER,{index:l+1})},i.id)}),d.jsx(Bt,{color:"negative",id:e.fallback,isConnectable:n,optionTitle:A(N.ELSE)})]})]})},Mf=3,pL={busy:N.BUSY,decline:N.DECLINE,error:N.ERROR,noAnswer:N.NO_ANSWER,success:N.SUCCESS},hL={address:N.FORWARD_TO_ADDRESS,phone:N.FORWARD_TO_PHONE,resource:N.FORWARD_TO_RESOURCE},Uf=({id:e,data:t,isConnectable:n,selected:r})=>{ct({data:t,id:e});const o=t.connections.filter(i=>i.connectTo),s=o.slice(0,Mf);return d.jsxs($e,{id:e,isConnectable:n,nodeTitle:A(hL[t.destinationType]),selected:r,valid:t.valid,children:[o.length?d.jsxs(Lt,{children:[d.jsx("ul",{children:s.map(i=>d.jsx("li",{className:"pb-2",children:d.jsx("div",{className:"max-w-max truncate rounded bg-secondary/20 px-1 ",children:i.connectTo})},`node-${i.id}`))}),o.length>Mf&&d.jsx("div",{children:`+ ${A(N.MORE_WITH_COUNT,{count:o.length-Mf})}`})]}):null,d.jsx(Fo,{children:t.options.map(i=>d.jsx(Bt,{color:K0(i.result),id:i.id,isConnectable:n,optionTitle:A(pL[i.result])},i.id))})]})},mL=({id:e,data:t,isConnectable:n,selected:r})=>{ct({data:t,id:e});const o=er(t.options,"command"),s=er(t.options,"digit");return d.jsxs($e,{id:e,isConnectable:n,nodeTitle:A(N.GATHER_INPUT),selected:r,valid:t.valid,children:[d.jsx(wy,{data:t}),d.jsxs(Fo,{children:[t.options.map((i,l)=>{const a=i.command.trim(),c=i.digit.trim(),u=!!(a||c)&&!o(i.command)&&!s(i.digit),f=d.jsxs("div",{className:"flex gap-1",children:[A(N.CALLER_PRESSES)," ",d.jsx("span",{className:"truncate rounded bg-secondary/20 px-1",children:c})]}),p=y=>d.jsxs("div",{className:"flex",children:[A(y?N.CALLER_SAYS:N.OR_CALLER_SAYS)," '",d.jsx("span",{className:"truncate",children:a}),"'"]});let h=A(N.OPTION_NUMBER,{index:l+1}),E="";switch(!0){case!!(a&&!c):h=p(!0);break;case!!(!a&&c):h=f;break;case!!(a&&c):h=f,E=p(!1);break}return d.jsx(Bt,{color:"positive",enabled:u,id:i.id,isConnectable:n,optionTitle:h,optionSubtitle:E},i.id)}),t.results.map(i=>d.jsx(Bt,{color:"negative",id:i.id,isConnectable:n,optionTitle:i.result==="no_input"?A(N.NO_INPUT):A(N.UNKNOWN)},i.id))]})]})},gL=({id:e,isConnectable:t,selected:n})=>d.jsx($e,{id:e,isConnectable:t,isRoot:!0,nodeTitle:A(N.HANDLE_CALL),selected:n,deletable:!1,showValidation:!1,target:!1,children:d.jsx(Ht,{id:e,color:"positive",isConnectable:t})}),Ff={busy:N.BUSY,decline:N.DECLINE,hangup:N.HANG_UP},EL=({data:e,id:t,isConnectable:n,selected:r})=>d.jsx($e,{id:t,isConnectable:n,nodeTitle:A(N.HANG_UP_CALL),selected:r,valid:e.valid,children:e.reason&&d.jsx(Lt,{children:d.jsx("p",{children:A(Ff[e.reason])})})}),yL=({data:e,id:t,isConnectable:n,selected:r})=>(ct({data:e,id:t}),d.jsxs($e,{id:t,isConnectable:n,nodeTitle:A(N.PLAY_AUDIO_TTS),selected:r,valid:e.valid,children:[d.jsx(wy,{data:e}),d.jsx(Ht,{id:t,isConnectable:n})]})),vL=({data:e,id:t,isConnectable:n,selected:r})=>{const{label:o,valid:s}=e;return ct({data:e,id:t}),d.jsxs($e,{id:t,isConnectable:n,nodeTitle:A(N.RECORD_CALL_START),selected:r,valid:s,children:[o&&s&&d.jsx(Lt,{children:d.jsx("p",{className:"truncate text-xs leading-5",children:o})}),d.jsx(Ht,{id:t,isConnectable:n,color:"positive"})]})},_L=({data:e,id:t,isConnectable:n,selected:r})=>{var i;ct({data:e,id:t});const o=(i=Bo(l=>l.entries))==null?void 0:i.find(l=>l.controlId===e.controlId),s=o==null?void 0:o.label;return d.jsxs($e,{id:t,isConnectable:n,nodeTitle:A(N.RECORD_CALL_STOP),selected:r,valid:e.valid,children:[s&&d.jsx(Lt,{children:d.jsx("p",{className:"truncate text-xs leading-5",children:s})}),d.jsx(Ht,{id:t,color:"positive",isConnectable:n})]})},SL=({data:e,id:t,isConnectable:n,selected:r})=>{ct({data:e,id:t});const o=new Set(e.terminators);return d.jsxs($e,{id:t,isConnectable:n,nodeTitle:A(N.VOICEMAIL_RECORDING),selected:r,valid:e.valid,children:[e.terminators?d.jsxs(Lt,{children:[A(N.TERMINATORS),":"," ",d.jsx("ul",{className:"inline-flex flex-wrap justify-start gap-1",children:[...o].sort().map((s,i)=>d.jsx("li",{className:"rounded bg-secondary/20 px-1",children:s},`${i}-${s}`))})]}):null,d.jsx(Ht,{id:t,isConnectable:n,color:"positive"})]})},xL={failed:N.FAILED,success:N.SUCCESS},gv={aiAgent:aL,answer:cL,cond:uL,condRequest:dL,executeSWML:fL,forwardAddress:Uf,forwardPhone:Uf,forwardResource:Uf,handleCall:gL,hangup:EL,play:yL,promptPlay:mL,record:SL,recordCallStart:vL,recordCallStop:_L,request:({data:e,id:t,isConnectable:n,selected:r})=>{var o;return ct({data:e,id:t}),d.jsxs($e,{id:t,isConnectable:n,nodeTitle:A(N.REQUEST),selected:r,valid:e.valid,children:[d.jsx("p",{className:"p-4 pt-0 text-xs text-negative",children:A(N.DEPRECATED)}),d.jsx(Fo,{children:(o=e==null?void 0:e.options)==null?void 0:o.map(s=>d.jsx(Bt,{color:K0(s.result),id:s.id,isConnectable:n,optionTitle:A(xL[s.result])},s.id))})]})},sendSms:({data:e,id:t,isConnectable:n,selected:r})=>(ct({data:e,id:t}),d.jsxs($e,{id:t,isConnectable:n,nodeTitle:A(N.SEND_SMS),selected:r,valid:e.valid,children:[e.body&&d.jsx(Lt,{children:d.jsx("p",{className:"break-words line-clamp-3",children:e.body})}),d.jsx(Ht,{id:t,isConnectable:n})]})),set:({id:e,data:t,isConnectable:n,selected:r})=>{const{getInvalidFields:o}=ct({data:t,id:e}),s=o().reduce((l,a)=>(a.startsWith("variable_")&&l.push(a.replace("variable_","")),l),[]),i=t.variables.filter(l=>!!l.key);return d.jsxs($e,{id:e,isConnectable:n,nodeTitle:A(N.SET_VARIABLES),selected:r,valid:t.valid,children:[i.length>0&&d.jsx(Lt,{children:d.jsx("ul",{className:"flex flex-col",children:i.map(l=>d.jsxs("li",{className:"flex w-full gap-1 pb-2",children:[d.jsx("div",{className:`max-w-[50%] shrink-0 truncate rounded px-1 ${s.includes(l.id)?"bg-negative/10 text-negative":"bg-secondary/20"}`,children:l.key}),"=",l.value&&d.jsx("div",{className:"truncate",children:l.value})]},l.id))})}),d.jsx(Ht,{id:e,isConnectable:n,color:"positive"})]})},unset:({id:e,data:t,isConnectable:n,selected:r})=>{ct({data:t,id:e});const o=t.variables.filter(s=>!!s.key);return d.jsxs($e,{id:e,isConnectable:n,nodeTitle:A(N.UNSET_VARIABLES),selected:r,valid:t.valid,children:[o.length>0&&d.jsx(Lt,{children:d.jsx("ul",{children:o.map(s=>d.jsx("li",{className:"pb-2",children:d.jsx("div",{className:"max-w-max truncate rounded bg-secondary/20 px-1",children:s.key})},s.id))})}),d.jsx(Ht,{id:e,isConnectable:n,color:"positive"})]})}},RL={floating:Q2},NL=({children:e})=>{const t=Q(S=>S.nodes),n=Q(S=>S.edges),r=Q(S=>S.isCanvasInteractive),{onConnect:o,onConnectEnd:s,onConnectStart:i,onEdgesChange:l,onEdgesDelete:a,onEdgeUpdate:c,onEdgeUpdateEnd:u,onEdgeUpdateStart:f,onInit:p,onNodeDragStart:h,onNodeDragStop:E,onNodesChange:y,onNodesDelete:v,onSelectionChange:m,setFlowWrapperElement:g}=Te();return d.jsx("div",{className:"bg-sw-white !h-auto w-full",ref:S=>g(S),children:d.jsxs(M0,{attributionPosition:"bottom-left",connectionLineComponent:K2,connectionMode:Wn.Strict,deleteKeyCode:r?xA:null,defaultEdgeOptions:Do,edges:n,edgeTypes:RL,elementsSelectable:r,fitViewOptions:rf,multiSelectionKeyCode:r?RA:null,nodes:t,nodesConnectable:r,nodesDraggable:r,nodeTypes:gv,onConnect:o,onConnectEnd:s,onConnectStart:i,onEdgesChange:l,onEdgesDelete:a,onEdgeUpdate:r?c:void 0,onEdgeUpdateEnd:u,onEdgeUpdateStart:f,onInit:p,onNodeDragStart:h,onNodeDragStop:E,onNodesChange:y,onNodesDelete:v,onSelectionChange:m,selectionKeyCode:r?NA:null,snapGrid:[ya,ya],snapToGrid:!0,children:[d.jsx(cA,{className:"bg-background-alt text-grid",color:"currentColor",gap:[ya,ya],variant:Ct.Dots}),e]})})},wL=()=>{const e=Q(l=>l.initializing),t=Q(l=>l.reactFlowInstance),{setInitializing:n,setViewportChanging:r}=Te(),o=O.useRef(!1),s=QT({includeHiddenNodes:!0}),i=O.useMemo(()=>()=>{t==null||t.fitView(rf)},[t]);O.useEffect(()=>{let l;e?!o.current&&!s?o.current=!0:o.current&&s&&(clearTimeout(l),r(!0),i(),l=setTimeout(()=>{r(!1)},rf.duration),n(!1),o.current=!1):o.current=!1},[e,i,s,n,r])},OL=()=>{const{onViewportChange:e,onViewportChangeEnd:t,onViewportChangeStart:n}=Te();return wL(),YT({onChange:e,onEnd:t,onStart:n}),null},TL=()=>{const e=Q(n=>n.selectedNode),t=e?b2.get(e.type):void 0;return t?d.jsx(Zs,{className:"z-40 max-w-[40%] rounded-md bg-background",position:"bottom-center",children:d.jsxs("div",{className:"justify-left flex items-center gap-2 rounded-md bg-primary/10 p-3 py-4","data-testid":"cfb__info",children:[d.jsx(re,{className:"shrink-0 text-primary",tag:"circle-info",size:"xl"}),d.jsx("div",{className:"text-xs font-medium",children:Ua(t)})]})}):null},AL=e=>{var s;const t=O.useRef(),n=GT(),r=e&&"options"in e.data?(s=e.data.options)==null?void 0:s.length:0;return t.current=r,{updateDynamicHandles:i=>{"options"in i&&i.options.length!==t.current&&(e&&n(e.id),t.current=i.options.length)}}},IL="/hello/.test('%{foo}')",CL=()=>({id:le(),value:""}),jf=({nodeData:e,handleOnUpdate:t,placeholder:n=IL})=>{const{validateField:r}=at("cond"),[o,s]=O.useState({options:e.options.map(f=>({id:!0,initial:e.initial,value:r("value",f.value)}))}),i=f=>{f.preventDefault(),s({...o,options:[...o.options,{initial:!0,value:!0}]}),t({options:[...e.options,CL()]})},l=f=>p=>{p.preventDefault();const h=[...o.options];h.splice(f,1),s({...o,options:h});const E=[...e.options];E.splice(f,1),t({options:E})},a=(f,p)=>{const h=[...e.options];if(!h[f])throw new Error(`Option not found at index ${f}`);const{name:E,value:y}=p,v=[...o.options];v[f]={...v[f],initial:!1,[E]:r(E,y)},s({...o,options:v}),h[f]={...h[f],[E]:y},t({options:h})},c=(f,p)=>{const h=f.target,{name:E,value:y}=h;switch(t({initial:!1}),E){case"value":p!==void 0&&a(p,{name:E,value:y});break;default:Ne().error(`Unhandled input name: ${E}`)}},u=({index:f,name:p})=>{const h=o.options[f];return(h==null?void 0:h[p])||(h==null?void 0:h.initial)};return d.jsxs(d.Fragment,{children:[d.jsx("ol",{className:"divide-y-4 divide-foreground/10 border-b-4 border-foreground/10",children:e.options.map((f,p,h)=>d.jsxs("li",{className:"flex pt-3",children:[d.jsx("div",{className:"w-8 shrink-0 text-center",children:d.jsx(re,{className:"text-foreground/60",size:"xs",tag:"bars"})}),d.jsxs("div",{className:"relative mr-3",children:[h.length>1&&d.jsx(Uo,{className:"absolute right-0 top-0",handleDelete:l(p),label:A(N.REMOVE_CONDITION,{index:p+1}),size:"sm",show:!0}),d.jsxs("label",{className:"mb-2 block",children:[A(N.CONDITION_NUMBER,{index:p+1}),d.jsx("input",{className:`w-full ${u({index:p,name:"value"})?"":"invalid"}`,name:"value",onChange:E=>c(E,p),placeholder:n,type:"text",value:f.value}),d.jsx("p",{className:"requirements",role:"alert",children:A(N.ERROR_VALUE_IS_REQUIRED)})]})]})]},f.id))}),d.jsx("div",{className:"p-3 text-right",children:d.jsx("button",{className:"rounded bg-foreground/10 py-1 px-2 font-medium",onClick:i,type:"button",children:A(N.ADD_CONDITION)})})]})},LL=Ne(),Si=(e,t)=>[e,t].filter(Boolean).join("-").toLowerCase(),bL={idsByKey:{},languageById:{},voiceById:{}},DL=(e,t)=>({...bL,actions:{getGenderByKeys:({languageId:n})=>{const{idsByKey:r}=t(),o=(n==null?void 0:n.split(",").map(i=>Si(i)))??[];if(!o.length)return["female","male"];const s=new Set;return o.forEach(i=>{var l;return(l=r[i])==null?void 0:l.forEach(a=>{a.gender&&s.add(a.gender)})}),Array.from(s).sort((i,l)=>i.toLowerCase().localeCompare(l.toLowerCase()))},getLanguages:()=>Object.values(t().languageById).sort((n,r)=>n.name.toLowerCase().localeCompare(r.name.toLowerCase())),getVoicesByKeys:({languageId:n,gender:r})=>{const{voiceById:o,idsByKey:s}=t(),i=(n==null?void 0:n.split(",").map(a=>Si(a,r)))??[];let l=[];return!i.length||i[0]===""?l=Object.values(o):i.forEach(a=>{l=l.concat(s[a]??[])}),l.sort((a,c)=>{const u=/^\w{2,3}-\w{2,}-.+/;return a.name.match(u)&&!c.name.match(u)?1:!a.name.match(u)&&c.name.match(u)?-1:a.name.toLowerCase().localeCompare(c.name.toLowerCase())})},init:async({voicesURL:n="/cfb/voices.json"})=>{try{LL.debug("Load voicesURL",n);const o=await(await fetch(n)).json(),s={},i={},l={};o.forEach(a=>{var v,m,g;const c=!!a.premium,u=a.signalwire_id,f=a.gender.toLowerCase(),p={gender:f,id:u,key:`${a.language_code}-${f}-${a.signalwire_id}`,name:`${a.friendly_name.trim()} ${c?"(premium)":""}`,premium:c};s[u]=p,i[a.language_code]={id:a.language_code,name:a.language};const h=Si(a.language_code);h in l||(l[h]=[]),(v=l[h])==null||v.push(p);const E=Si(f);E in l||(l[E]=[]),(m=l[E])==null||m.push(p);const y=Si(a.language_code,f);y in l||(l[y]=[]),(g=l[y])==null||g.push(p)}),e({idsByKey:l,languageById:i,voiceById:s})}catch(r){console.error("Error",r)}}}}),Vf=bo()(DL),kL=()=>Vf.getState().actions;window.__useVoiceStore=Vf;const Ev=e=>d.jsx("option",{value:e.id,children:e.name},e.key??e.id),PL=({onChange:e,languageId:t,gender:n,voiceId:r})=>{const{getLanguages:o,getVoicesByKeys:s,getGenderByKeys:i}=kL();return d.jsxs(d.Fragment,{children:[d.jsxs(Zt,{className:"w-full",label:A(N.LANGUAGE),name:"language",onChange:e,value:t??"",children:[d.jsx("option",{value:"",children:A(N.SELECT)}),o().map(Ev)]}),d.jsxs(Zt,{className:"w-full capitalize",label:A(N.GENDER),name:"gender",onChange:e,value:n??"",children:[d.jsx("option",{value:"",children:A(N.SELECT)}),i({languageId:t}).map(l=>d.jsx("option",{value:l,children:l},l))]}),d.jsxs(Zt,{className:"w-full",label:A(N.VOICE),name:"voice",onChange:e,value:r??"",children:[d.jsx("option",{value:"",children:A(N.SELECT)}),s({gender:n,languageId:t}).map(Ev)]})]})},yv={text:N.TEXT_TO_SPEECH,url:N.PLAY_AUDIO_FILE},vv=({handleOnUpdate:e,label:t,nodeData:n,showDefaultOption:r})=>{const{validateField:o}=at("play"),[s,i]=O.useState({gender:!0,language:!0,selected:n.initial||o("selected",n.selected),text:n.initial||o("text",n.text),url:n.initial||o("url",n.url),voice:!0}),l=n.selected;O.useEffect(()=>{!l&&!r&&e({selected:"url"})},[e,l,r]);const a=u=>{const f=u.target,{name:p,value:h}=f;switch(p){case"selected":case"text":case"url":i({...s,[p]:o(p,h)}),e({initial:!1,[p]:h});break;default:throw new Error(`Unhandled input name: ${p}`)}},c=u=>{const f=u.target,{name:p,value:h}=f;switch(p){case"language":e({gender:void 0,language:h,voice:void 0});break;case"gender":e({gender:h,voice:void 0});break;default:e({[p]:h})}};return d.jsxs(d.Fragment,{children:[d.jsxs("label",{className:"mb-2",children:[d.jsx("span",{className:"sr-only",children:t}),d.jsxs(Oy,{className:`w-full ${s.selected?"":"invalid"}`,name:"selected",onChange:a,value:l,children:[r&&d.jsx("option",{value:"",children:A(N.SELECT)}),Object.keys(yv).map(u=>d.jsx("option",{value:u,children:A(yv[u])},u))]})]}),l&&d.jsx(ML,{nodeData:n,onChange:a,voiceSettingsChangeHandler:c,selected:l,valid:s[l]})]})},ML=({nodeData:e,onChange:t,voiceSettingsChangeHandler:n,selected:r,valid:o})=>{const s=e[r],l={text:d.jsxs(d.Fragment,{children:[d.jsx(PL,{onChange:n,languageId:e.language,gender:e.gender,voiceId:e.voice}),d.jsx(yn,{errorText:A(N.ERROR_VALUE_IS_REQUIRED),inputMode:"text",label:A(N.TEXT),name:r,onChange:t,placeholder:A(N.WRITE_SOMETHING),valid:o,value:s})]}),url:d.jsx(yn,{errorText:A(N.ERROR_URL_IS_REQUIRED),inputMode:"url",label:A(N.AUDIO_FILE),name:r,onChange:t,placeholder:A(N.ENTER_URL),valid:o,value:s})}[r];return d.jsx(d.Fragment,{children:l})},UL=[{field:"stereo",subtitle:N.STEREO_SUBTITLE,title:N.STEREO},{field:"beep",subtitle:N.BEEP_SUBTITLE,title:N.BEEP}],_v=({handleOnUpdate:e,nodeData:t,type:n})=>{const{validateField:r}=at("record"),[o,s]=O.useState({beep:!0,endSilenceTimeout:t.initial||r("endSilenceTimeout",t.endSilenceTimeout),format:!0,initialTimeout:t.initial||r("initialTimeout",t.initialTimeout),maxLength:t.initial||r("maxLength",t.maxLength),stereo:!0,terminators:t.initial||r("terminators",t.terminators)});t.format||e({format:"mp3"});const i=a=>{const c=a.target.name;e({[c]:!t[c]})},l=a=>{const c=a.target,{name:u,value:f}=c;switch(u){case"endSilenceTimeout":case"format":case"initialTimeout":case"maxLength":case"terminators":s({...o,[u]:r(u,f)}),e({initial:!1,[u]:f});break;default:throw new Error(`Unhandled input name: ${u}`)}};return d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"mb-2",children:UL.map(a=>{const c=t[a.field];return d.jsx("div",{children:d.jsx(Ta,{checked:c,clickHandler:i,name:a.field,subtitle:A(a.subtitle),title:A(a.title)})},a.field)})}),d.jsxs("label",{className:"mb-2 block",children:[A(N.TERMINATORS),d.jsx("span",{className:"block text-xxs text-foreground/50",children:A(N.SEPARATE_WITH_COMMAS)}),d.jsx("input",{className:`w-full ${o.terminators?"":"invalid"}`,name:"terminators",onChange:l,placeholder:"#*0",type:"text",value:t.terminators}),d.jsx("p",{className:"requirements",role:"alert",children:A(N.ERROR_TERMINATORS)})]}),n==="voicemail"&&d.jsxs(d.Fragment,{children:[d.jsxs("label",{className:"mb-2 block",children:[d.jsx("div",{className:"w-full",children:A(N.MAXIMUM_RECORDING_LENGTH)}),d.jsxs("div",{className:"flex flex-wrap items-center gap-x-2",children:[d.jsx("input",{className:`w-14 ${o.maxLength?"":"invalid"}`,inputMode:"numeric",min:zo.MIN,max:zo.MAX,name:"maxLength",onChange:l,placeholder:A(N.SECONDS),type:"number",value:t.maxLength}),d.jsx("p",{className:"requirements w-full",role:"alert",children:A(N.ERROR_NUMBER_MIN_MAX_IS_REQUIRED,{max:zo.MAX,min:zo.MIN})})]})]}),d.jsxs("label",{className:"mb-2 block",children:[d.jsx("div",{className:"w-full",children:A(N.INITIAL_TIMEOUT)}),d.jsxs("div",{className:"flex flex-wrap items-center gap-x-2",children:[d.jsx("input",{className:`w-14 ${o.initialTimeout?"":"invalid"}`,inputMode:"numeric",min:Ee.MIN,max:Ee.MAX,name:"initialTimeout",onChange:l,placeholder:A(N.SECONDS),type:"number",value:t.initialTimeout}),d.jsx("p",{className:"requirements w-full",role:"alert",children:A(N.ERROR_NUMBER_MIN_MAX_IS_REQUIRED,{max:Ee.MAX,min:Ee.MIN})})]})]}),d.jsxs("label",{className:"mb-2 block",children:[d.jsx("div",{className:"w-full",children:A(N.END_SILENCE_TIMEOUT)}),d.jsxs("div",{className:"flex flex-wrap items-center gap-x-2",children:[d.jsx("input",{className:`w-14 ${o.endSilenceTimeout?"":"invalid"}`,inputMode:"numeric",min:Ee.MIN,max:Ee.MAX,name:"endSilenceTimeout",onChange:l,placeholder:A(N.SECONDS),type:"number",value:t.endSilenceTimeout}),d.jsx("p",{className:"requirements w-full",role:"alert",children:A(N.ERROR_NUMBER_MIN_MAX_IS_REQUIRED,{max:Ee.MAX,min:Ee.MIN})})]})]})]}),d.jsxs(Zt,{className:"w-full",label:A(N.FORMAT),name:"format",onChange:l,value:t.format,children:[d.jsx("option",{value:"mp3",children:"MP3"}),d.jsx("option",{value:"wav",children:"WAV"})]})]})},Ze=({children:e,formRef:t,handleOnChange:n=()=>null,title:r})=>d.jsxs("div",{className:"flex flex-col overflow-hidden","data-testid":"cfb__settings",children:[d.jsxs("div",{className:"flex w-full items-center justify-start gap-x-2 px-4 pb-3",children:[d.jsx("div",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-focus/30 text-primary",children:d.jsx(re,{tag:"circle-small"})}),d.jsx("div",{className:"flex-1",children:d.jsx("h2",{className:"text-xs font-semibold",children:r})})]}),d.jsx("form",{className:"flex h-full flex-col overflow-hidden text-xs",noValidate:!0,onChange:n,ref:t,children:d.jsx("div",{className:"flex-1 overflow-y-auto pt-1 pb-4",children:e})})]}),FL=({nodeData:e,handleOnUpdate:t})=>{const{validateField:n}=at("aiAgent"),[r,o]=O.useState({agent:e.initial||n("agent",e.agent)}),s=en(y=>y.aiAgentMap.values()),i=en(y=>y.error),l=en(y=>y.status),{fetchAiAgents:a}=P2();O.useEffect(()=>{a()},[a]);const c=Array.from(s),u=l==="loading",f=!!i||l==="error",p=f||l==="initial",h=y=>{const v=y.target,{name:m,value:g}=v;o({...r,[m]:n(m,g)}),t({initial:!1,[m]:g})},E=O.useId();return d.jsx(Ze,{title:A(N.AI_AGENT),children:d.jsx("div",{className:"mx-3",children:!f&&c.length?d.jsxs("div",{className:"relative",children:[d.jsxs(Zt,{id:E,className:`${r.agent?"":"invalid"}`,disabled:p,label:A(N.AI_AGENT_NAME),name:"agent",onChange:h,value:e.agent,children:[d.jsx("option",{value:"",children:A(N.SELECT)}),c.map(y=>d.jsx("option",{value:y.id,children:y.display_name},y.id))]}),d.jsx(Sv,{className:"absolute top-0 right-0 mx-1",handleClickResync:a,isLoading:u}),e.agent&&d.jsx("p",{children:d.jsx(xv,{agent:e.agent,mode:"edit",className:"mb-2",children:A(N.EDIT_SELECTED_AI_AGENT)})})]}):d.jsxs("div",{className:"flex items-end justify-between",children:[d.jsx("p",{role:"alert",className:"text-negative",children:f?d.jsx(d.Fragment,{children:A(N.ERROR_FETCHING_AI_AGENTS)}):d.jsxs(d.Fragment,{children:[A(N.ERROR_ADD_AI_AGENT_FIRST),d.jsx(xv,{mode:"add",className:"mt-2 block",children:A(N.ADD_AI_AGENT)})]})}),d.jsx(Sv,{className:"mx-1",handleClickResync:a,isLoading:u})]})})})},Sv=({className:e="",isLoading:t,handleClickResync:n})=>d.jsx(Zn,{placement:"bottom-end",trigger:d.jsxs("button",{className:`overflow-hidden ${t?"text-disabled":""} ${e}`,disabled:t,onClick:n,type:"button",children:[d.jsx(re,{className:`${t?"animate-spin":""}`,tag:"arrows-rotate"}),d.jsx("span",{className:"sr-only",children:A(N.RESYNC_AI_AGENTS)})]}),children:d.jsx("p",{className:"text-sm",children:A(N.RESYNC_AI_AGENTS)})}),xv=({agent:e="",children:t,className:n="",mode:r})=>{const o={add:"",edit:`${e}/edit`};return d.jsx("a",{className:`w-fit text-foreground underline hover:text-foreground/80 ${n}`,href:`/ai_agents/${o[r]}`,target:"_blank",rel:"noopener noreferrer",children:t})},jL=["GET","POST","PUT","DELETE"],VL=({nodeData:e,handleOnUpdate:t})=>{const{validateField:n}=at("condRequest"),[r,o]=O.useState({body:e.initial||n("body",e.body),headers:e.initial||n("headers",e.headers),method:e.initial||n("method",e.method),saveVariables:e.initial||n("saveVariables",e.saveVariables),url:e.initial||n("url",e.url)}),s=a=>{const c=a.target,{name:u,value:f}=c;switch(t({initial:!1}),u){case"url":case"method":o({...r,[u]:n(u,f)}),t({[u]:f});break;case"headers":o({...r,[u]:n(u,f)}),t({[u]:f});break;case"body":o({...r,[u]:n(u,f)}),t({[u]:f});break;default:throw new Error(`Unhandled input name: ${u}`)}},i=a=>{const{name:c,value:u}=a.target;t({[c]:u})},l=a=>{const{name:c}=a.target,u=!e[c];t({[c]:u})};return d.jsxs(Ze,{title:A(N.REQUEST),children:[d.jsxs("div",{className:"border-b-4 border-foreground/10 px-3",children:[d.jsxs("label",{className:"mb-2 block",children:[A(N.URL),d.jsx("input",{className:`w-full ${r.url?"":"invalid"}`,name:"url",onChange:s,placeholder:"https://u:p@example.com/api/status",type:"text",value:e.url}),d.jsx("p",{className:"requirements w-full",role:"alert",children:A(N.ERROR_VALUE_IS_REQUIRED)})]}),d.jsx("div",{className:"mb-1",children:d.jsx(Zt,{className:"w-full",label:A(N.METHOD),name:"method",onChange:i,value:e.method,children:jL.map(a=>d.jsx("option",{value:a,children:a},a))})}),d.jsx("div",{className:"mb-4",children:d.jsx(Ta,{checked:e.saveVariables,clickHandler:l,name:"saveVariables",subtitle:A(N.SAVE_VARIABLES_SUBTITLE),title:A(N.SAVE_VARIABLES)})}),d.jsx("label",{className:"mb-2 block",children:d.jsx(yn,{errorText:A(N.ERROR_INVALID_JSON),inputMode:"text",label:A(N.REQUEST_HEADERS),name:"headers",onChange:s,placeholder:'{"Content-Type": "application/json", "X-Custom-Header": "foo"}',valid:r.headers,value:e.headers})}),d.jsx("label",{className:"mb-2 block",children:d.jsx(yn,{errorText:A(N.ERROR_INVALID_JSON),inputMode:"text",label:A(N.REQUEST_BODY),name:"body",onChange:s,placeholder:A(N.STRING_OR_JSON),valid:r.body,value:e.body??""})})]}),d.jsx(jf,{nodeData:e,handleOnUpdate:t})]})},$L=({nodeData:e,handleOnUpdate:t})=>{const n=O.useRef();return d.jsx(Ze,{formRef:n,title:A(N.CONDITIONS),children:d.jsx("div",{children:d.jsx(jf,{nodeData:e,handleOnUpdate:t})})})},HL=({nodeData:e,handleOnUpdate:t})=>{const{validateField:n}=at("executeSWML"),[r,o]=O.useState({dest:e.initial||n("dest",e.dest),meta:e.initial||n("meta",e.meta),params:e.initial||n("params",e.params)}),s=i=>{const l=i.target,{name:a,value:c}=l;switch(t({initial:!1}),a){case"dest":case"params":case"meta":o({...r,[a]:n(a,c)}),t({[a]:c});break;default:throw new Error(`Unhandled input name: ${a}`)}};return d.jsxs(Ze,{title:A(N.EXECUTE_SWML),children:[d.jsxs("div",{className:"border-b-4 border-foreground/10 px-3",children:[d.jsxs("label",{className:"mb-2 block",children:[A(N.URL),d.jsx("input",{className:`w-full ${r.dest?"":"invalid"}`,name:"dest",onChange:s,placeholder:"https://u:p@test.com/go.swml",type:"text",value:e.dest}),d.jsx("p",{className:"requirements w-full",role:"alert",children:A(N.ERROR_VALUE_IS_REQUIRED)})]}),d.jsx("label",{className:"mb-2 block",children:d.jsx(yn,{errorText:A(N.ERROR_INVALID_JSON),inputMode:"text",label:A(N.PARAMS),name:"params",onChange:s,placeholder:'{"Content-Type": "application/json", "X-Custom-Header": "foo"}',valid:r.params,value:e.params??""})}),d.jsx("label",{className:"mb-2 block",children:d.jsx(yn,{errorText:A(N.ERROR_INVALID_JSON),inputMode:"text",label:A(N.META),name:"meta",onChange:s,placeholder:A(N.JSON_OBJECT),valid:r.meta,value:e.meta??""})})]}),d.jsx(jf,{nodeData:e,handleOnUpdate:t,placeholder:"return_value === '1'"})]})},Rv=(e,t)=>{O.useEffect(()=>{var o;const n=(o=e.current)==null?void 0:o.getRootNode(),r=s=>{var l;const i=s.target;i instanceof Node&&!((l=e.current)!=null&&l.contains(i))&&t(s)};return n&&n.addEventListener("pointerdown",r),()=>{n&&n.removeEventListener("pointerdown",r)}},[e,t])},$f=e=>{const[t,n]=O.useReducer((r,o)=>({...r,...o}),e);return[t,n]},BL=Ne(),zL=({enable:e,searchParams:t})=>{const n=_n(f=>f.results),r=_n(f=>f.status),o=_n(f=>f.error),{buildParamsFromQuery:s,buildQueryFromParams:i,getCachedResults:l,fetchSwmlScript:a,setResults:c}=dv(),u=i(t);return O.useEffect(()=>{if(!e)return;const f=l(u);f&&c(f);const p=s(u),h=setTimeout(()=>{a(p).catch(E=>{BL.error("Error fetching swml scripts",E)})},W0);return()=>clearTimeout(h)},[s,i,e,a,l,u,c]),[n,r,o]},Hf=e=>e==="external",WL={externalValue:"",focusedId:"",focusedName:"",open:!1,query:""},GL=({confirmId:e,confirmName:t,confirmUrl:n,onChange:r,valid:o})=>{var B;const s={displayName:A(N.EXTERNAL_URL),id:"external"},i=O.useRef(null),l=O.useRef(null),a=O.useRef(null),c=O.useRef({}),u=O.useId(),f=O.useId(),p=O.useId(),[h,E]=$f({...WL,externalValue:Hf(e)?n:"",query:t??""}),y=Hf(e),v=h.query===""||h.query.toLocaleLowerCase()===t.toLocaleLowerCase(),[m,g]=zL({enable:h.open&&!h.focusedName,searchParams:{name:v?"":h.query}}),S=[{displayName:A(N.EXTERNAL_URL),id:s.id},...m],_=v?S:m,x=()=>E({focusedId:"",focusedName:""}),R=W=>{E({open:!0,query:W.target.value}),x()},T=W=>{E({externalValue:W.target.value}),r({connectConfirmDisplayName:s.displayName,connectConfirmId:s.id,connectConfirmUrl:W.target.value})},L=()=>{E({focusedId:e,open:!0}),j()},P=()=>{E({open:!1}),x()},I=()=>h.open?P():L(),j=()=>{var W;(W=l.current)==null||W.focus()},V=W=>{const z=J0(S,"id",W);E({query:z.displayName});const Y=X=>"requestUrl"in X?X.requestUrl:h.externalValue;r({connectConfirmDisplayName:z.displayName,connectConfirmId:z.id,connectConfirmUrl:Y(z)}),P()},M=W=>{j(),V(W)},w=W=>{const z=h.focusedId||e||"",Y=AA(W,z,_),X=Y&&c.current[Y==null?void 0:Y.id];if(X){X==null||X.focus({preventScroll:!0}),X==null||X.scrollIntoView({block:"nearest"});const Z=J0(S,"id",X.id);E({focusedId:Z.id,focusedName:Z.displayName}),l.current&&(l.current.value=Z.displayName)}else j();h.open||L()},b=()=>{c.current[h.focusedId]&&V(h.focusedId)},k=()=>{h.query!==t&&E({query:t}),P()},F=W=>{const{key:z}=W;switch(z){case"ArrowDown":case"ArrowUp":W.preventDefault(),w(z),j();break;case"Enter":W.preventDefault(),b();break;case"Escape":W.preventDefault(),k();break}};O.useEffect(()=>{y&&a.current&&a.current.focus()},[y]),Rv(i,P);const C=h.open&&!_.length,D=g==="loading"&&C,U=g==="error",$=t&&e===""&&n==="";return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:`relative mb-2 block ${U?"after:border-t-foreground/40":"after:border-t-foreground"}`,ref:i,children:[d.jsx("label",{className:"block pb-1 font-medium",id:f,htmlFor:u,children:A(N.HANDLE_VIA)}),d.jsxs("div",{className:"relative pb-1",children:[d.jsx("input",{"aria-activedescendant":h.open?h.focusedId:void 0,"aria-invalid":C,"aria-autocomplete":"list","aria-controls":h.open?u:void 0,"aria-expanded":h.open,"aria-labelledby":f,autoComplete:"off",className:`${U||$?"invalid":""} rounded-md border border-foreground !p-2 !pr-8`,disabled:U,onChange:R,onClick:L,onKeyDown:F,placeholder:h.open?A(N.SEARCH_FOR_INTERNAL_SCRIPT):A(N.EXTERNAL_OR_INTERNAL_RESOURCE),ref:l,role:"combobox",type:"text",value:h.focusedName||h.query}),d.jsxs("button",{"aria-controls":h.open?u:void 0,"aria-expanded":h.open,"aria-haspopup":"listbox","aria-labelledby":`${f} ${p}`,className:`${h.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:U,id:p,onClick:I,tabIndex:-1,type:"button",children:[D&&d.jsx(re,{className:"absolute top-3 right-7 animate-spin",tag:"arrows-rotate",size:"xs"}),d.jsx("span",{className:"sr-only",children:A(h.open?N.TOGGLE_CLOSE:N.TOGGLE_OPEN)})]}),d.jsxs("p",{className:"requirements w-full",role:"alert",children:[$&&A(N.SCRIPT_NOT_FOUND),U&&A(N.ERROR_FETCHING_SWML_SCRIPTS)]})]}),!U&&h.open&&d.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":f,id:u,role:"listbox",onKeyDown:F,children:_.length?d.jsxs(d.Fragment,{children:[_.length===1&&Hf((B=_==null?void 0:_[0])==null?void 0:B.id)&&(g==="loaded"||g==="loading")&&d.jsx(Bf,{displayName:A(g==="loading"?N.STATUS_LOADING:N.NO_SCRIPTS_FOUND)}),_.map(({displayName:W,id:z},Y)=>{const X=e===z,Z=h.focusedId?h.focusedId===z:Y===0;return d.jsx(Bf,{active:X,focus:Z,displayName:W,handleOnClick:()=>M(z),id:z,ref:J=>c.current[z]=J},z)})]}):d.jsx(Bf,{displayName:A(D?N.STATUS_LOADING:N.NO_RESULTS)})})]}),y&&d.jsxs("label",{className:"mb-2 block",children:[d.jsx("span",{className:"sr-only",children:A(N.EXTERNAL_OPTION_LABEL)}),d.jsxs("div",{className:"flex flex-wrap items-center gap-x-2",children:[d.jsx("input",{className:`w-14 ${o?"":"invalid"}`,inputMode:"url",name:"connectConfirmUrl",onChange:T,placeholder:A(N.ENTER_URL),ref:a,type:"url",value:h.externalValue}),d.jsx("p",{className:"requirements w-full",role:"alert",children:A(N.ERROR_URL_IS_REQUIRED)})]})]}),!m.length&&!y&&d.jsx("div",{className:"mb-2",children:d.jsx("p",{children:d.jsx(YL,{children:A(N.ADD_SWML_SCRIPTS)})})})]})},Bf=O.forwardRef(function({active:t,displayName:n,focus:r,handleOnClick:o,id:s},i){const l=!!o,a=l?`cursor-pointer transition-colors hover:bg-primary/5 focus:bg-primary/5 aria-selected:bg-primary/20 ${r?"bg-primary/5":""}`:"";return d.jsx("li",{"aria-selected":t,className:`relative select-none bg-background py-1 px-3 text-xs leading-6 ${a}`,id:s,onClick:o,ref:i,role:l?"option":"presentation",tabIndex:-1,children:n})}),YL=({children:e,className:t=""})=>d.jsx("a",{className:`w-fit text-foreground underline hover:text-foreground/80 ${t}`,href:"/relay-bins",target:"_blank",rel:"noopener noreferrer",children:e}),KL=({confirmId:e,confirmName:t,confirmUrl:n,enabled:r,handleOnChange:o,onCheck:s,valid:i})=>{const l=O.useId(),{validateCache:a}=dv();return O.useEffect(()=>{r&&a()},[r,a]),d.jsxs(d.Fragment,{children:[d.jsx(Ta,{"aria-controls":l,"aria-expanded":r,checked:r,clickHandler:s,name:"connectConfirmEnabled",subtitle:A(N.SWML_TO_EXECUTE),title:A(N.ENABLE_WHISPER)}),r&&d.jsx("div",{id:l,children:d.jsx(GL,{onChange:o,confirmId:e,confirmName:t,confirmUrl:n,valid:i})})]})},XL={forwardAddress:{add:N.ADD_ADDRESS,call:N.CALL_ADDRESSES,optionNumber:N.ADDRESS_NUMBER,remove:N.REMOVE_ADDRESS,title:N.FORWARD_TO_ADDRESS},forwardPhone:{add:N.ADD_PHONE_NUMBER,call:N.CALL_NUMBERS,optionNumber:N.PHONE_NUMBER_NUMBER,remove:N.REMOVE_PHONE_NUMBER,title:N.FORWARD_TO_PHONE},forwardResource:{add:N.ADD_RESOURCE,call:N.CALL_RESOURCES,optionNumber:N.RESOURCE_NUMBER,remove:N.REMOVE_RESOURCE,title:N.FORWARD_TO_RESOURCE}},Nv={parallel:N.SIMULTANEOUSLY,serial:N.SEQUENTIALLY},QL=()=>({connectConfirmDisplayName:"",connectConfirmEnabled:!1,connectConfirmId:"",connectConfirmUrl:"",connectFrom:"",connectTimeout:"",connectTo:"",id:le()}),zf=({nodeType:e,nodeData:t,handleOnUpdate:n})=>{var S,_,x;const{validateField:r}=at(e),o=O.useRef(),[s,i]=O.useState(["serial","parallel"].includes(t.callOrder)?t.callOrder:"serial"),l=XL[e],[a,c]=O.useState({callOrder:t.initial||r("callOrder",s),callStateEvents:t.initial||r("callStateEvents",s),callStateUrl:t.initial||r("callStateUrl",s),connections:(S=t.connections)==null?void 0:S.map(R=>({connectConfirmId:r("connectConfirmId",R.connectConfirmId),connectConfirmUrl:r("connectConfirmUrl",R.connectConfirmUrl),connectFrom:r("connectFrom",R.connectFrom),connectTimeout:r("connectTimeout",R.connectTimeout),connectTo:r("connectTo",R.connectTo),initial:t.initial})),defaultFrom:t.initial||r("defaultFrom",t.defaultFrom),defaultTimeout:t.initial||r("defaultTimeout",t.defaultTimeout)}),u=R=>{R.preventDefault(),c({...a,connections:[...a.connections,{connectConfirmId:!0,connectConfirmUrl:!0,connectFrom:!0,connectTimeout:!0,connectTo:!0,initial:!0}]}),n({callOrder:s,connections:[...t.connections,QL()]})},f=R=>T=>{T.preventDefault();const L=[...a.connections];L.splice(R,1),c({...a,connections:L});const P=[...t.connections];P.splice(R,1),n({callOrder:P.length===1?"single":s,connections:P})},p=(R,T,L)=>{const P=[...t.connections],I=P[R];if(!I)throw new Error(`Option not found at index ${R}`);const j=T==null?void 0:T.name,V=T==null?void 0:T.value,w={...j?{[j]:V}:{},...L,id:I.id},b=[...a.connections],k=Object.keys(w).reduce((D,U)=>{const $=w[U],B=U;return D[B]=r(U,$),D},{initial:!1}),F=b.map((D,U)=>U===R?{...D,...k}:D);c({...a,connections:F});const C=P.map(D=>D.id===w.id?{...D,...w}:D);n({connections:C,initial:!1})},h=R=>{const T=R.currentTarget.value;i(T),n({callOrder:T})},E=(R,T)=>{p(R,void 0,T)},y=(R,T)=>{E(R,{connectConfirmEnabled:T})},v=R=>T=>E(R,{...T}),m=(R,T)=>{const L=R.target,{name:P,value:I}=L;switch(P){case"callStateEvents":case"callStateUrl":case"defaultTimeout":case"defaultFrom":c({...a,[P]:r(P,I)}),n({initial:!1,[P]:I});break;case"connectFrom":case"connectTimeout":case"connectTo":if(T===void 0)throw new Error(`Option index not provided: ${P}`);p(T,{name:P,value:I});break;default:throw new Error(`Unhandled input name: ${P}`)}},g=({index:R,name:T})=>{const L=a.connections[R];return!!(L!=null&&L[T]||L!=null&&L.initial)};return d.jsxs(Ze,{title:A(l.title),formRef:o,children:[d.jsxs("div",{className:"border-b-4 border-foreground/10 px-3 pb-3",children:[d.jsxs("label",{className:"mb-2 block",children:[A(N.DEFAULT_FROM),d.jsx(pi,{className:"w-full",direction:"from",name:"defaultFrom",onChange:m,placeholder:A(N.FROM),type:"tel",value:t.defaultFrom,valid:a.defaultFrom}),d.jsx("p",{className:"requirements w-full",role:"alert",children:A(N.ERROR_VALUE_IS_REQUIRED)})]}),d.jsxs("label",{className:"mb-2 block",children:[A(N.DEFAULT_TIMEOUT),d.jsxs("div",{className:"flex flex-wrap items-center gap-x-2",children:[d.jsx("input",{className:`w-14 ${a.defaultTimeout?"":"invalid"}`,inputMode:"numeric",min:0,name:"defaultTimeout",onChange:m,placeholder:A(N.SECONDS),type:"number",value:t.defaultTimeout}),d.jsx("p",{className:"requirements w-full",role:"alert",children:A(N.ERROR_NUMBER_IS_REQUIRED)})]})]}),d.jsxs("label",{className:"mb-2 block",children:[A(N.CALL_STATE_URL),d.jsx("input",{className:`w-full ${a.callStateUrl?"":"invalid"}`,name:"callStateUrl",onChange:m,placeholder:"https://example.com/api",type:"url",value:t.callStateUrl}),d.jsx("p",{className:"requirements w-full",role:"alert",children:A(N.ERROR_VALUE_IS_REQUIRED)})]}),d.jsxs("label",{className:"mb-2 block",children:[A(N.CALL_STATE_EVENTS),d.jsx("input",{className:`w-full ${a.callStateEvents?"":"invalid"}`,name:"callStateEvents",onChange:m,placeholder:"Created, ringing, answered, ended",type:"text",value:t.callStateEvents}),d.jsx("p",{className:"requirements w-full",role:"alert",children:A(N.ERROR_VALUE_IS_REQUIRED)})]})]}),d.jsx("ul",{className:"border-foreground-10 divide-y-4 divide-foreground/10 border-b-4 pt-2",children:(_=t.connections)==null?void 0:_.map((R,T,L)=>d.jsx("li",{className:"flex flex-col gap-y-2 px-4",children:d.jsxs("fieldset",{children:[d.jsxs("div",{className:"item-center flex justify-between py-4",children:[d.jsxs("legend",{children:[d.jsx(re,{className:"pr-2 text-foreground/60",size:"xs",tag:"bars"}),d.jsx("span",{className:"text-xs font-semibold",children:A(l.optionNumber,{index:T+1})})]}),L.length>1&&d.jsx(Uo,{handleDelete:f(T),label:A(l.remove,{index:T+1}),size:"sm",show:!0})]}),d.jsxs("label",{className:"mb-1 block pl-2",children:[d.jsx("div",{className:"sr-only",children:A(N.TO)}),d.jsx(pi,{className:"w-full",direction:"to",name:"connectTo",onChange:P=>m(P,T),type:e==="forwardPhone"?"tel":"text",valid:g({index:T,name:"connectTo"}),value:R.connectTo}),d.jsx("p",{className:"requirements",role:"alert",children:A(N.ERROR_VALUE_IS_REQUIRED)})]}),d.jsxs("label",{className:"mb-2 block pl-2",children:[d.jsx("div",{className:"sr-only",children:A(N.FROM)}),d.jsx(pi,{className:"w-full",direction:"from",name:"connectFrom",onChange:P=>m(P,T),placeholder:A(N.FROM),type:"text",valid:g({index:T,name:"connectFrom"}),value:R.connectFrom}),d.jsx("p",{className:"requirements",role:"alert",children:A(N.ERROR_VALUE_IS_REQUIRED)})]}),d.jsxs("label",{className:"mb-2 block pl-2",children:[A(N.TIMEOUT),d.jsxs("div",{className:"flex flex-wrap items-center gap-x-2",children:[d.jsx("input",{className:`${g({index:T,name:"connectTimeout"})?"":"invalid"}`,inputMode:"numeric",min:0,name:"connectTimeout",onChange:P=>m(P,T),placeholder:A(N.SECONDS),type:"number",value:R.connectTimeout}),d.jsx("p",{className:"requirements w-full",role:"alert",children:A(N.ERROR_NUMBER_IS_REQUIRED)})]})]}),d.jsx("div",{className:"mb-2 block pl-2",children:d.jsx(KL,{confirmId:R.connectConfirmId,confirmName:R.connectConfirmDisplayName,confirmUrl:R.connectConfirmUrl,enabled:R.connectConfirmEnabled,handleOnChange:v(T),onCheck:()=>y(T,!R.connectConfirmEnabled),valid:g({index:T,name:"connectConfirmUrl"})&&g({index:T,name:"connectConfirmId"})})})]})},R.id))}),d.jsx("div",{className:"p-3 pb-6 text-right",children:d.jsx("button",{className:"rounded bg-foreground/10 py-1 px-2 font-medium",onClick:u,type:"button",children:A(l.add)})}),((x=t.connections)==null?void 0:x.length)>1&&d.jsx("div",{className:"mb-4 px-3",children:d.jsx(Zt,{className:"w-full",label:A(l.call),name:"callOrder",onChange:h,value:s,children:Object.keys(Nv).map(R=>d.jsx("option",{value:R,children:A(Nv[R])},R))})})]})},qL=()=>({command:"",digit:"",id:le()}),JL=({nodeData:e,handleOnUpdate:t})=>{const{validateField:n}=at("promptPlay"),r=O.useRef(),[o,s]=O.useState({digitTimeout:e.initial||n("digitTimeout",e.digitTimeout),initialTimeout:e.initial||n("initialTimeout",e.initialTimeout),options:e.options.map(h=>({command:n("command",h.command),digit:n("digit",h.digit),initial:e.initial}))}),i=er(e.options,"command"),l=er(e.options,"digit"),a=h=>{h.preventDefault(),s({...o,options:[...o.options,{command:!0,digit:!0,initial:!0}]}),t({options:[...e.options,qL()]})},c=h=>E=>{E.preventDefault();const y=[...o.options];y.splice(h,1),s({...o,options:y});const v=[...e.options];v.splice(h,1),t({options:v})},u=(h,E)=>{const y=[...e.options];if(!y[h])throw new Error(`Option not found at index ${h}`);const{name:v,value:m}=E,g=[...o.options];g[h]={...g[h],initial:!1,[v]:n(v,m)},s({...o,options:g}),y[h]={...y[h],[v]:m},t({options:y})},f=(h,E)=>{const y=h.target,{name:v,value:m}=y;switch(t({initial:!1}),v){case"digit":case"command":E!==void 0&&u(E,{name:v,value:m});break;case"digitTimeout":case"initialTimeout":{s({...o,[v]:n(v,m)}),t({[v]:m});break}default:throw new Error(`Unhandled input field name: ${v}`)}},p=({index:h,name:E})=>{var m;const y=o.options[h];if(y!=null&&y.initial)return!0;if(!(y!=null&&y[E]))return!1;const v=(m=e.options)==null?void 0:m[h];return yt(v==null?void 0:v.digit)||yt(v==null?void 0:v.command)};return d.jsxs(Ze,{formRef:r,title:A(N.GATHER_INPUT),children:[d.jsx("div",{className:"border-b-4 border-foreground/10 px-3 pb-3",children:d.jsx(vv,{handleOnUpdate:t,label:A(N.CHOOSE_OPTION_TTS_AUDIO),nodeData:e})}),d.jsx("ol",{className:"divide-y-4 divide-foreground/10 border-b-4 border-foreground/10",children:e.options.map((h,E,y)=>{const v=i(h.command),m=l(h.digit);return d.jsxs("li",{className:"flex pt-3",children:[d.jsx("div",{className:"w-8 shrink-0 text-center",children:d.jsx(re,{className:"text-foreground/60",size:"xs",tag:"bars"})}),d.jsxs("div",{className:"relative mr-3",children:[y.length>1&&d.jsx(Uo,{className:"absolute right-0 top-0",handleDelete:c(E),label:A(N.REMOVE_OPTION,{index:E+1}),size:"sm",show:!0}),d.jsxs("fieldset",{children:[d.jsx("legend",{className:"sr-only",children:A(N.OPTION_NUMBER,{index:E+1})}),d.jsxs("label",{className:"mb-2 block",children:[A(N.CALLER_PRESSES),d.jsx("input",{className:`${p({index:E,name:"digit"})&&!m?"":"invalid"}`,name:"digit",onChange:g=>f(g,E),placeholder:A(N.KEYPAD_VALUE),type:"text",value:h.digit}),d.jsx("p",{className:"requirements",role:"alert",children:A(m?N.ERROR_DUPLICATE_TELEPHONE_KEY:N.ERROR_TELEPHONE_KEY_REQUIRED)})]}),d.jsxs("label",{className:"mb-2 block",children:[A(N.OR_SAYS),d.jsx("input",{className:`w-full ${p({index:E,name:"command"})&&!v?"":"invalid"}`,name:"command",onChange:g=>f(g,E),placeholder:A(N.SPOKEN_PROMPT),type:"text",value:h.command}),d.jsx("p",{className:"requirements",role:"alert",children:A(v?N.ERROR_DUPLICATE_COMMAND:N.ERROR_TEXT_IS_REQUIRED)})]})]})]})]},h.id)})}),d.jsx("div",{className:"p-3 pb-6 text-right",children:d.jsx("button",{className:"rounded bg-foreground/10 py-1 px-2 font-medium",onClick:a,type:"button",children:A(N.ADD_OPTION)})}),d.jsxs("div",{className:"px-3",children:[d.jsxs("label",{className:"mb-2 block",children:[d.jsx("div",{className:"w-full",children:A(N.WAIT_FOR_INPUT)}),d.jsxs("div",{className:"flex flex-wrap items-center gap-x-2",children:[d.jsx("input",{className:`w-14 ${o.initialTimeout?"":"invalid"}`,inputMode:"numeric",min:Ee.MIN,max:Ee.MAX,name:"initialTimeout",onChange:f,placeholder:A(N.SECONDS),type:"number",value:e.initialTimeout}),d.jsx("p",{className:"requirements w-full",role:"alert",children:A(N.ERROR_NUMBER_MIN_MAX_IS_REQUIRED,{max:Ee.MAX,min:Ee.MIN})})]})]}),d.jsxs("label",{children:[d.jsx("div",{className:"w-full",children:A(N.WAIT_FOR_DIGIT)}),d.jsxs("div",{className:"flex flex-wrap items-center gap-x-2",children:[d.jsx("input",{className:`w-14 ${o.digitTimeout?"":"invalid"}`,inputMode:"numeric",min:Ee.MIN,max:Ee.MAX,name:"digitTimeout",onChange:f,placeholder:A(N.SECONDS),type:"number",value:e.digitTimeout}),d.jsx("p",{className:"requirements w-full",role:"alert",children:A(N.ERROR_NUMBER_MIN_MAX_IS_REQUIRED,{max:Ee.MAX,min:Ee.MIN})})]})]})]})]})},ZL=({handleOnUpdate:e,nodeData:t})=>{const{validateField:n}=at("play"),[r,o]=O.useState({reason:t.initial||n("reason",t.reason)}),s=i=>{const l=i.target,{name:a,value:c}=l;switch(a){case"reason":o({...r,[a]:n(a,c)}),e({initial:!1,[a]:c});break;default:throw new Error(`Unhandled input name: ${a}`)}};return d.jsx(Ze,{title:A(N.HANG_UP_CALL),children:d.jsx("div",{className:"mx-3",children:d.jsxs(Zt,{className:"w-full",label:`${A(N.REASON)} (${A(N.OPTIONAL)})`,name:"reason",onChange:s,value:t.reason,children:[d.jsx("option",{value:"",children:A(N.SELECT)}),Object.keys(Ff).map(i=>d.jsx("option",{value:i,children:A(Ff[i])},i))]})})})},eb=({nodeData:e,handleOnUpdate:t})=>{const n=O.useRef();return d.jsx(Ze,{formRef:n,title:A(N.PLAY_AUDIO_TTS),children:d.jsx("div",{className:"mx-3",children:d.jsx(vv,{handleOnUpdate:t,label:A(N.CHOOSE_OPTION_TTS_AUDIO),nodeData:e,showDefaultOption:!0})})})},tb=({nodeData:e,handleOnUpdate:t})=>{const n=O.useRef(),{validateField:r}=at("recordCallStart"),[o,s]=O.useState({label:e.initial||r("label",e.label)}),[i,l]=O.useState(!1),{upsertEntry:a,isValueDuplicate:c}=If();O.useEffect(()=>{l(c(e.label,e.controlId))},[c,e.controlId,e.label]);const u=f=>{const p=f.target,{name:h,value:E}=p;s({...o,[h]:r(h,E)}),t({initial:!1,[h]:E}),a({controlId:e.controlId,label:E})};return d.jsxs(Ze,{title:A(N.RECORD_CALL_START),formRef:n,children:[d.jsx("div",{className:"px-3 pb-3",children:d.jsxs("label",{children:[A(N.RECORDING_NAME),d.jsx("input",{className:`w-full ${o.label&&!i?"":"invalid"}`,name:"label",onChange:u,type:"text",value:e.label}),d.jsx("p",{className:"requirements",role:"alert",children:A(i?N.ERROR_DUPLICATE_RECORDING_LABEL:N.ERROR_RECORDING_LABEL_REQUIRED)})]})}),d.jsx("div",{className:"px-3",children:d.jsx(_v,{handleOnUpdate:t,nodeData:e,type:"call"})})]})},nb=({nodeData:e,handleOnUpdate:t})=>{const{validateField:n}=at("recordCallStop"),[r,o]=O.useState({controlId:e.initial||n("controlId",e.controlId)}),{getEntries:s}=If(),i=s().sort((a,c)=>a.label.toLowerCase().localeCompare(c.label.toLowerCase())),l=a=>{const c=a.target,{name:u,value:f}=c;o({...r,[u]:n(u,f)}),t({initial:!1,[u]:f})};return d.jsx(Ze,{title:A(N.RECORD_CALL_STOP),children:d.jsx("div",{className:"px-3",children:i.length?d.jsxs(Zt,{className:`w-full ${r.controlId?"":"invalid"}`,label:A(N.RECORDING_NAME),name:"controlId",value:e.controlId,onChange:l,children:[d.jsx("option",{value:"",children:A(N.SELECT)}),i.map(a=>d.jsx("option",{value:a.controlId,children:a.label},a.controlId))]}):d.jsx("p",{role:"alert",className:"text-negative",children:A(N.ERROR_ADD_RECORDING_FIRST)})})})},rb=({nodeData:e,handleOnUpdate:t})=>d.jsx(Ze,{title:A(N.VOICEMAIL_RECORDING),children:d.jsx("div",{className:"mx-3",children:d.jsx(_v,{handleOnUpdate:t,nodeData:e,type:"voicemail"})})}),ob=["GET","POST","PUT","DELETE"],sb=({nodeData:e,handleOnUpdate:t})=>{const{validateField:n}=at("request"),[r,o]=O.useState({body:e.initial||n("body",e.body),headers:e.initial||n("headers",e.headers),method:e.initial||n("method",e.method),saveVariables:e.initial||n("saveVariables",e.saveVariables),url:e.initial||n("url",e.url)}),s=a=>{const c=a.target,{name:u,value:f}=c;switch(t({initial:!1}),u){case"url":case"method":o({...r,[u]:n(u,f)}),t({[u]:f});break;case"headers":o({...r,[u]:n(u,f)}),t({[u]:f});break;case"body":o({...r,[u]:n(u,f)}),t({[u]:f});break;default:throw new Error(`Unhandled input name: ${u}`)}},i=a=>{const{name:c,value:u}=a.target;t({[c]:u})},l=a=>{const{name:c}=a.target,u=!e[c];t({[c]:u})};return d.jsx(Ze,{title:A(N.REQUEST),children:d.jsxs("div",{className:"px-3",children:[d.jsxs("label",{className:"mb-2 block",children:[A(N.URL),d.jsx("input",{className:`w-full ${r.url?"":"invalid"}`,name:"url",onChange:s,placeholder:"https://u:p@example.com/api/status",type:"text",value:e.url}),d.jsx("p",{className:"requirements w-full",role:"alert",children:A(N.ERROR_VALUE_IS_REQUIRED)})]}),d.jsx("div",{className:"mb-1",children:d.jsx(Zt,{className:"w-full",label:A(N.METHOD),name:"method",onChange:i,value:e.method,children:ob.map(a=>d.jsx("option",{value:a,children:a},a))})}),d.jsx("div",{className:"mb-4",children:d.jsx(Ta,{checked:e.saveVariables,clickHandler:l,name:"saveVariables",subtitle:A(N.SAVE_VARIABLES_SUBTITLE),title:A(N.SAVE_VARIABLES)})}),d.jsx("label",{className:"mb-2 block",children:d.jsx(yn,{errorText:A(N.ERROR_INVALID_JSON),inputMode:"text",label:A(N.REQUEST_HEADERS),name:"headers",onChange:s,placeholder:'{"Content-Type": "application/json", "X-Custom-Header": "foo"}',valid:r.headers,value:e.headers})}),d.jsx("label",{children:d.jsx(yn,{errorText:A(N.ERROR_INVALID_JSON),inputMode:"text",label:A(N.REQUEST_BODY),name:"body",onChange:s,placeholder:A(N.STRING_OR_JSON),valid:r.body,value:e.body??""})})]})})},ib=({nodeData:e,handleOnUpdate:t})=>{const{validateField:n}=at("sendSms"),[r,o]=O.useState({body:e.initial||n("body",e.body),fromNumber:e.initial||n("fromNumber",e.fromNumber),toNumber:e.initial||n("toNumber",e.toNumber)}),s=i=>{const l=i.target,{name:a,value:c}=l;switch(a){case"body":case"fromNumber":case"toNumber":o({...r,[a]:n(a,c)}),t({initial:!1,[a]:c});break;default:throw new Error(`Unhandled input name: ${a}`)}};return d.jsx(Ze,{title:A(N.SEND_SMS),children:d.jsxs("div",{className:"mx-3",children:[d.jsxs("label",{className:"mb-2 block",children:[A(N.TO_PHONE_NUMBER),d.jsx(pi,{className:"w-full",direction:"to",name:"toNumber",onChange:s,placeholder:"+12405550000",type:"tel",valid:r.toNumber,value:e.toNumber}),d.jsx("p",{className:"requirements w-full",role:"alert",children:A(N.ERROR_VALUE_IS_REQUIRED)})]}),d.jsxs("label",{className:"mb-2 block",children:[A(N.FROM_PHONE_NUMBER),d.jsx(pi,{className:"w-full",direction:"from",name:"fromNumber",onChange:s,placeholder:"+12405550000",type:"tel",valid:r.fromNumber,value:e.fromNumber}),d.jsx("p",{className:"requirements w-full",role:"alert",children:A(N.ERROR_VALUE_IS_REQUIRED)})]}),d.jsx("label",{children:d.jsx(yn,{errorText:A(N.ERROR_VALUE_IS_REQUIRED),inputMode:"text",label:A(N.SMS_TEXT),name:"body",onChange:s,placeholder:A(N.WRITE_SOMETHING),valid:r.body,value:e.body})})]})})},lb=()=>({id:le(),key:"",value:""}),ab=({nodeData:e,handleOnUpdate:t})=>{var f;const{validateField:n}=at("set"),[r,o]=O.useState({variables:e.variables.map(p=>({key:e.initial||n("key",p.key),value:e.initial||n("value",p.value)}))}),s=er(e.variables,"key"),i=p=>{p==null||p.preventDefault(),o({...r,variables:[...r.variables,{key:!0,value:!0}]}),t({variables:[...e.variables,lb()]})},l=(p,h)=>{const E=[...e.variables];let y=E[p];if(!y)throw new Error(`Variable not found at index ${p}`);const{name:v,value:m}=h,g=[...r.variables];g[p]={...g[p],[v]:n(v,m)},o({...r,variables:g}),y={...E[p],[v]:m},E[p]=y,t({initial:!1,variables:E})},a=p=>h=>{h.preventDefault();const E=[...r.variables];E.splice(p,1),o({...r,variables:E});const y=[...e.variables];y.splice(p,1),t({variables:y})},c=(p,h)=>{const E=p.target,{name:y,value:v}=E;switch(y){case"key":case"value":h!==void 0&&l(h,{name:y,value:v});break;default:throw new Error(`Unhandled input name: ${y}`)}},u=({index:p,name:h})=>{const E=r.variables[p];return E==null?void 0:E[h]};return d.jsxs(Ze,{title:A(N.SET_VARIABLES),children:[d.jsx("ol",{className:"divide-y-4 divide-foreground/10 border-b-4 border-foreground/10",children:(f=e.variables)==null?void 0:f.map((p,h,E)=>{const y=s(p.key);return d.jsxs("li",{className:"flex pt-3",children:[d.jsx("div",{className:"w-8 shrink-0 text-center",children:d.jsx(re,{className:"text-foreground/60",size:"xs",tag:"bars"})}),d.jsxs("div",{className:"relative mr-3",children:[E.length>1&&d.jsx(Uo,{className:"absolute right-0 top-0",handleDelete:a(h),label:A(N.REMOVE_VARIABLE,{index:h+1}),size:"sm",show:!0}),d.jsxs("fieldset",{children:[d.jsx("legend",{className:"sr-only",children:A(N.VARIABLE_NUMBER,{index:h+1})}),d.jsxs("label",{className:"mb-2 block",children:[A(N.KEY),d.jsx("input",{className:`w-full ${u({index:h,name:"key"})&&!y?"":"invalid"}`,name:"key",onChange:v=>c(v,h),type:"text",value:p.key}),d.jsx("p",{className:"requirements",role:"alert",children:A(y?N.ERROR_DUPLICATE_VARIABLE_KEY:N.ERROR_VARIABLE_KEY_REQUIRED)})]}),d.jsxs("label",{className:"mb-2 block",children:[A(N.VALUE),d.jsx("input",{className:`w-full ${u({index:h,name:"value"})?"":"invalid"}`,name:"value",onChange:v=>c(v,h),type:"text",value:p.value}),d.jsx("p",{className:"requirements",role:"alert",children:A(N.ERROR_TEXT_IS_REQUIRED)})]})]})]})]},p.id)})}),d.jsx("div",{className:"p-3 text-right",children:d.jsx("button",{className:"rounded bg-foreground/10 py-1 px-2 font-medium",onClick:i,type:"button",children:A(N.ADD_VARIABLE)})})]})},cb=e=>({id:le(),key:e}),ub=({nodeData:e,handleOnUpdate:t})=>{const s={currentFocus:void 0,listOpen:!1,setVariablesList:Q(v=>v.nodes).reduce((v,m)=>{if(m.type==="set"){const g=m.data.variables.map(S=>({id:S.id,key:S.key}));return[...v,...g]}else if(m.type==="unset")return[...v,...m.data.variables];return v},[]).reduce((v,m)=>(v.find(g=>g.key===m.key)||v.push(m),v),[]).map(v=>({...v,selected:!!e.variables.find(m=>m.key===v.key)})).sort((v,m)=>v.key.toLowerCase().localeCompare(m.key.toLowerCase()))},[i,l]=$f(s),a=v=>i.setVariablesList.map(m=>m.id===v?{...m,selected:!m.selected}:m),c=v=>{const m=i.setVariablesList.find(g=>g.id===v);if(!m)throw new Error("Variable not found");if(m.selected)u(m.id);else{const g=[...e.variables,cb(m.key)];l({setVariablesList:a(m.id)}),t({variables:g})}},u=v=>{const m=i.setVariablesList.filter(g=>g.selected&&g.id!==v);l({setVariablesList:a(v)}),t({variables:m})},f=O.useRef(null);Rv(f,()=>l({listOpen:!1}));const p=v=>{(v.key==="Escape"||v.key==="Esc")&&l({listOpen:!1})},h=(v,m)=>{v.preventDefault(),(v.key===" "||v.code==="Space"||v.key==="Enter")&&c(m),p(v)},E=()=>{l({listOpen:!i.listOpen})},y=e.variables.length;return d.jsx(Ze,{title:A(N.UNSET_VARIABLES),children:d.jsxs("div",{className:"px-3",children:[d.jsxs("div",{className:"mb-2 flex flex-col",children:[d.jsx("label",{id:"listbox-label",className:"sr-only",children:A(N.SELECT_VARIABLES_TO_UNSET)}),d.jsxs("div",{className:"relative",ref:f,children:[d.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
- 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:E,onKeyDown:p,type:"button",children:y>0?A(N.NUMBER_OF_VARIABLES_SELECTED,{count:y}):A(N.SELECT_VARIABLES)}),i.listOpen&&d.jsxs("ul",{"aria-activedescendant":i.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:[!i.setVariablesList.length&&d.jsx("li",{"aria-disabled":"true",className:"relative",role:"option",children:d.jsx("label",{className:"flex select-none items-center py-2 pl-3 pr-9",children:A(N.NO_VARIABLES_SET)})}),i.setVariablesList.map(v=>{if(v.key)return d.jsx("li",{"aria-selected":v.selected,className:"relative",id:v.id,role:"option",children:d.jsxs("label",{className:"flex select-none items-center py-2 pl-3 pr-9",children:[d.jsx("input",{checked:v.selected,className:"mr-2 h-4 w-4 rounded accent-primary",onChange:()=>c(v.id),onKeyDown:m=>h(m,v.id),type:"checkbox"}),v.key]})},v.id)})]})]})]}),y>0&&d.jsxs("section",{className:"pt-3",children:[d.jsx("h3",{className:"mb-2 text-xs font-medium text-foreground",children:A(N.UNSET_VARIABLES)}),d.jsx("ul",{className:"flex flex-wrap gap-2",children:i.setVariablesList.map(v=>v.selected&&d.jsx(aC,{handleClick:()=>u(v.id),children:v.key},v.id))})]})]})})},wv={aiAgent:({data:e,formUpdate:t})=>d.jsx(FL,{handleOnUpdate:t,nodeData:e}),cond:({data:e,formUpdate:t})=>d.jsx($L,{handleOnUpdate:t,nodeData:e}),condRequest:({data:e,formUpdate:t})=>d.jsx(VL,{handleOnUpdate:t,nodeData:e}),executeSWML:({data:e,formUpdate:t})=>d.jsx(HL,{handleOnUpdate:t,nodeData:e}),forwardAddress:({data:e,formUpdate:t})=>d.jsx(zf,{handleOnUpdate:t,nodeData:e,nodeType:"forwardAddress"}),forwardPhone:({data:e,formUpdate:t})=>d.jsx(zf,{handleOnUpdate:t,nodeData:e,nodeType:"forwardPhone"}),forwardResource:({data:e,formUpdate:t})=>d.jsx(zf,{handleOnUpdate:t,nodeData:e,nodeType:"forwardResource"}),hangup:({data:e,formUpdate:t})=>d.jsx(ZL,{handleOnUpdate:t,nodeData:e}),play:({data:e,formUpdate:t})=>d.jsx(eb,{handleOnUpdate:t,nodeData:e}),promptPlay:({data:e,formUpdate:t})=>d.jsx(JL,{handleOnUpdate:t,nodeData:e}),record:({data:e,formUpdate:t})=>d.jsx(rb,{handleOnUpdate:t,nodeData:e}),recordCallStart:({data:e,formUpdate:t})=>d.jsx(tb,{handleOnUpdate:t,nodeData:e}),recordCallStop:({data:e,formUpdate:t})=>d.jsx(nb,{handleOnUpdate:t,nodeData:e}),request:({data:e,formUpdate:t})=>d.jsx(sb,{handleOnUpdate:t,nodeData:e}),sendSms:({data:e,formUpdate:t})=>d.jsx(ib,{handleOnUpdate:t,nodeData:e}),set:({data:e,formUpdate:t})=>d.jsx(ab,{handleOnUpdate:t,nodeData:e}),unset:({data:e,formUpdate:t})=>d.jsx(ub,{handleOnUpdate:t,nodeData:e})},db=(e,t)=>{if("options"in t)switch(e.type){case"promptPlay":case"cond":case"condRequest":return!0}return!1},fb=e=>{if(e in wv)return wv[e]},pb=()=>{var c;const{partialUpdateNodeData:e,removeNode:t}=Te(),n=Q(u=>u.selectedNode),r=n==null?void 0:n.id,s=(c=Q(u=>u.nodes).find(u=>u.id===r))==null?void 0:c.data,{updateDynamicHandles:i}=AL(n);if(!(n&&s&&r))return null;const l=u=>{db(n,u)&&i(u),e(r,u)},a=fb(n.type);return a?d.jsxs(Zs,{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:[d.jsx(a,{data:s,formUpdate:l},r),n.deletable!==!1&&d.jsx("div",{className:"border-t border-foreground/10 p-3",children:d.jsx(Uo,{handleDelete:()=>t(r),label:A(N.DELETE_NODE),show:!0,showLabel:!0})})]}):null},Ov=O.forwardRef(function({animate:t=!0,children:n,className:r="",iconTag:o="circle-info",message:s,role:i="alertdialog",status:l},a){const u=l?{error:"bg-negative text-background",success:"bg-positive text-background"}[l]:"";return d.jsxs("div",{className:`flex items-center justify-between rounded-lg bg-foreground p-2
63
+ ${s}`})},R2=H.forwardRef(function(t,n){const{children:r,style:o,...s}=t,i=Af(),l=Yy([i.refs.setFloating,n]);return i.open?d.jsxs("div",{className:"relative max-w-md rounded-md bg-foreground p-2 text-sm text-background shadow-sm",ref:l,style:{left:i.x??0,position:i.strategy,top:i.y??0,visibility:i.x==null?"hidden":"visible",zIndex:10,...o},...i.getFloatingProps(s),children:[d.jsx("div",{className:"overflow-hidden",children:r}),d.jsx(x2,{})]}):null}),N2=O.forwardRef(function({children:t,asChild:n=!1,...r},o){const s=Af(),i=Yy([s.refs.setReference,o,t==null?void 0:t.ref]);return n&&O.isValidElement(t)?O.cloneElement(t,s.getReferenceProps({ref:i,...r,...t.props,"data-state":s.open?"open":"closed"})):d.jsx("button",{ref:i,"data-state":s.open?"open":"closed",...s.getReferenceProps(r),children:t})}),rv={bottom:"top",left:"right",right:"left",top:"bottom"},Zn=({asChild:e=!0,children:t,enable:n=!0,placement:r="right",scale:o=1,trigger:s=d.jsx(re,{tag:"circle-info"}),...i})=>{let l=r.split("-")[0];return l=Object.keys(rv).includes(l)?l:"right",n?d.jsxs(_2,{...i,placement:r,children:[d.jsx(N2,{asChild:e,children:s}),d.jsx(R2,{style:o!==1?{transform:`scale(${o})`,transformOrigin:rv[l]}:void 0,children:t})]}):d.jsx(d.Fragment,{children:s})},w2={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"},N={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_DEPLOY:"INFO_DEPLOY",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:"PHONE_NUMBER",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:"RECORDING",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_KEY:"VARIABLE_KEY",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"},O2={order:["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag","path","subdomain"],lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupQuerystring:"lng",lookupSessionStorage:"i18nextLng",caches:["localStorage","cookie"],excludeCacheFor:["cimode"]},T2={"en-US":{translation:w2}},A2=async()=>{await Ve.use(Ey).use(DI).init({debug:hA,detection:O2,fallbackLng:"en-US",interpolation:{escapeValue:!1},keySeparator:!1,resources:T2})};function Ua(e,t){return d.jsx(dC,{label:e,vars:t})}const ov=()=>Ve.resolvedLanguage,I2={entries:[],nextLabelIndex:0},Bo=bo((e,t)=>({...I2,actions:{getEntries(){return t().entries},getEntryValue(n){var r;return(r=t().entries.find(o=>o.controlId===n))==null?void 0:r.label},getGeneratedLabel(){let n="",r=t().nextLabelIndex;do r++,n=A(N.RECORDING_NAME_DEFAULT,{index:r});while(this.isValueDuplicate(n));return e({nextLabelIndex:r}),n},isKeyDuplicate(n){return t().entries.some(r=>r.controlId===n)},isValueDuplicate(n,r){const o=n.trim();return!!t().entries.reduce((i,l)=>{const{label:a,controlId:c}=l;return a!==""&&a===o&&(!r||c!==r)?[...i,l]:i},[]).length},removeEntry(n){e(r=>({entries:r.entries.filter(o=>o.controlId!==n)}))},upsertEntry:n=>{const{actions:r}=t(),{isKeyDuplicate:o}=r;e(s=>{let i=[...s.entries];const l=n.label.trim(),a=!!l;return(o(n.controlId)||!a)&&(i=i.filter(c=>c.controlId!==n.controlId)),a&&i.push({...n,label:l}),{entries:i}})}}})),If=()=>Bo.getState().actions,sv=e=>{const t=[];e.forEach(n=>{n.type==="recordCallStart"&&n.data.controlId&&n.data.label&&t.push({controlId:n.data.controlId,label:n.data.label})}),Bo.setState({entries:t,nextLabelIndex:t.length})},C2=(e,t)=>{const n=[];return t.forEach(r=>{r.type==="recordCallStart"&&r.data.controlId&&(n.push(r.data.controlId),Bo.getState().actions.removeEntry(r.data.controlId))}),n.length?e.reduce((r,o)=>o.type==="recordCallStop"&&n.includes(o.data.controlId)?[...r,{...o,data:{...o.data,controlId:""}}]:r,[]):[]},iv={recordCallStart:e=>{const t=Bo.getState().actions.getGeneratedLabel();return Bo.getState().actions.upsertEntry({controlId:e.data.controlId,label:t}),{...e,data:{...e.data,label:t}}}},L2=e=>typeof e=="object"&&e!==null&&Object.keys(e).length>0,b2=e=>iv[e.type]!==void 0,lv=(e,t={})=>{const{deletable:n=!0,position:r={x:300,y:250},selected:o=!0}=t,s=()=>({data:{initial:!0,valid:!1},deletable:n,id:le(),position:r,selected:o,type:e}),i=(c,u)=>({...c,data:{...c.data,...u}});let l=s();const a=Z0[e]();return L2(a)&&(l=i(l,a)),b2(l)&&(l=iv[l.type](l)),l},Fa={action:{label:N.ACTION,nodes:{answer:{active:!0,label:N.ANSWER_CALL},hangup:{active:!0,infoLabel:N.INFO_NODE_HANG_UP,label:N.HANG_UP_CALL},play:{active:!0,infoLabel:N.INFO_NODE_PLAY,label:N.PLAY_AUDIO_TTS},sendSms:{active:!0,infoLabel:N.INFO_NODE_SEND_SMS,label:N.SEND_SMS}}},decision:{label:N.DECISION,nodes:{cond:{active:!0,infoLabel:N.INFO_NODE_COND,label:N.CONDITIONS},executeSWML:{active:!0,infoLabel:N.INFO_NODE_EXECUTE_SWML,label:N.EXECUTE_SWML},set:{active:!0,infoLabel:N.INFO_NODE_SET_VARIABLES,label:N.SET_VARIABLES},unset:{active:!0,infoLabel:N.INFO_NODE_UNSET_VARIABLES,label:N.UNSET_VARIABLES}}},forwardTo:{label:N.FORWARD,nodes:{forwardAddress:{active:!1,infoLabel:N.INFO_NODE_FORWARD_TO_ADDRESS,label:N.FORWARD_TO_ADDRESS},forwardPhone:{active:!0,infoLabel:N.INFO_NODE_FORWARD_TO_PHONE,label:N.FORWARD_TO_PHONE},forwardResource:{active:!1,infoLabel:N.INFO_NODE_FORWARD_TO_RESOURCE,label:N.FORWARD_TO_RESOURCE}}},hidden:{label:N.HIDDEN,nodes:{handleCall:{active:!0,label:N.HANDLE_CALL}}},input:{label:N.INPUT,nodes:{aiAgent:{active:!0,infoLabel:N.INFO_NODE_AI_AGENT,label:N.AI_AGENT},condRequest:{active:!0,infoLabel:N.INFO_NODE_CONDREQUEST,label:N.REQUEST},promptPlay:{active:!0,infoLabel:N.INFO_NODE_GATHER_INPUT,label:N.GATHER_INPUT},request:{active:!1,deprecated:!0,infoLabel:N.INFO_NODE_REQUEST,label:N.REQUEST}}},recording:{label:N.RECORD,nodes:{record:{active:!0,infoLabel:N.INFO_NODE_RECORD,label:N.VOICEMAIL_RECORDING},recordCallStart:{active:!0,infoLabel:N.INFO_NODE_RECORD_CALL_START,label:N.RECORD_CALL_START},recordCallStop:{active:!0,infoLabel:N.INFO_NODE_RECORD_CALL_STOP,label:N.RECORD_CALL_STOP}}}},D2=Object.entries(Fa).reduce((e,[,{nodes:t}])=>(Object.entries(t).forEach(([n,{label:r}])=>{e.set(n,r)}),e),new Map),k2=Object.entries(Fa).reduce((e,[,{nodes:t}])=>(Object.entries(t).forEach(([n,{infoLabel:r}])=>{e.set(n,r)}),e),new Map),ja=Ne(),P2={aiAgentMap:new Map,error:"",status:"initial"},M2=(e,t)=>({...P2,actions:{fetchAiAgents:async()=>{try{const{actions:n}=t(),{getAiAgents:r}=n;if(!r){ja.error("getAiAgents is not defined");return}e({status:"loading"});const o=await r(),s=X0(o.data,"asc","display_name"),i=new Map(s.map(l=>[l.id,l]));e({aiAgentMap:i,error:"",status:"loaded"})}catch(n){let r="Unknown error";ja.error("Error fetching aiAgents ",n),n instanceof Error&&(r=n.message),e({aiAgentMap:new Map,error:r,status:"error"})}},init:({getAiAgentsURL:n})=>{if(!n){ja.error("getAiAgentsURL is not defined");return}const r=nc({getAiAgentsURL:n,headers:of()}),o=async()=>await r.getAiAgents();e(s=>({...s,actions:{...s.actions,getAiAgents:o}}))}}}),av=(e,t)=>{if(e.find(r=>r.type==="aiAgent")){const{fetchAiAgents:r}=en.getState().actions;r().then(()=>{const{aiAgentMap:o,status:s}=en.getState();s==="loaded"&&e.forEach(i=>{if(i.data&&"agent"in i.data){const l=o.has(i.data.agent);l||t(i.id,{agent:l?i.data.agent:"",valid:l})}})}).catch(o=>ja.error("Error rehydrating AiAgentStore",o))}},en=bo()(M2),U2=()=>en.getState().actions;window.__useAiAgentStore=en;const F2=e=>!!(e&&e>=yA),j2=e=>(t,n,r)=>(r.setState=(o,s,...i)=>{const{edges:l,detachedMode:a,httpError:c,initializing:u,isCanvasInteractive:f,isInteractiveControlOn:p,nodes:h,rootAppWidth:E,viewportChanging:y}=n(),v=typeof o=="function"?o(n()):o,m=["detachedMode","httpError","initializing","isInteractiveControlOn","rootAppWidth","viewportChanging"],g="initializing"in v?v.initializing:u;if(m.some(S=>S in v)){const S=F2("rootAppWidth"in v?v.rootAppWidth:E),_="isInteractiveControlOn"in v?v.isInteractiveControlOn:p,x="detachedMode"in v?v.detachedMode:a,R=("httpError"in v?v.httpError:c)===z0,T="viewportChanging"in v?v.viewportChanging:y;if(v.isCanvasInteractive=!!(S&&_&&!x&&!g&&!R&&!T),v.showInteractiveControl=S&&!R&&!x,f&&!v.isCanvasInteractive){const L="nodes"in v?v.nodes:h;v.nodes=L.map(I=>({...I,selected:!1}));const P="edges"in v?v.edges:l;v.edges=P.map(I=>({...I,selected:!1})),v.selectedNode=void 0}}t(v,s,...i)},e(r.setState,n,r)),cv=1e3,yi=Ne(),V2=e=>(t,n,r)=>{let o,s;const i=async()=>{const{httpService:l,nodes:a,edges:c,documentVersion:u}=n();t({dataHandlingStatus:"saving",saveFlowStatus:"saving"}),clearTimeout(s);try{if(!l)throw new Error("Missing httpService");const f=await l.putFlow({documentVersion:u,edges:c,flowDataVersion:li,nodes:a}),p={documentLastUpdated:f.updated_at,documentVersion:f.document_version},h=n().dataHandlingStatus;switch(h){case"saving":t({...p,dataHandlingStatus:"queueing",deployFlowStatus:"deploy",saveFlowStatus:"saved"});break;case"holding":t({...p,saveFlowStatus:"awaiting-save"}),yi.debug("Setting up a new save for held changes"),s=setTimeout(()=>{i().catch(E=>{yi.error("Error Save Flow",E)})},cv);break;default:yi.debug("Invalid dataHandlingStatus",h)}}catch(f){yi.error("Put Flow",f),f instanceof Error&&f.message.includes(vA)?t({dataHandlingStatus:"holding",httpError:"document-sync",saveFlowStatus:"error"}):t({dataHandlingStatus:"queueing",saveFlowStatus:"error"})}};return r.setState=(l,a,...c)=>{const{dataHandlingStatus:u,detachedMode:f,initializing:p,saveFlowStatus:h}=n(),E=typeof l=="function"?l(n()):l,y="initializing"in E?E.initializing:p,v="detachedMode"in E?E.detachedMode:f;!y&&!v&&(E.nodes||E.edges)?u==="queueing"?(E.saveFlowStatus="awaiting-save",t(E,a,...c),clearTimeout(o),o=setTimeout(()=>{i().catch(g=>{yi.error("Error Save Flow",g)})},cv)):(E.dataHandlingStatus="holding",t(E,a,...c)):"initializing"in E&&!E.initializing?(E.dataHandlingStatus="queueing",h!=="error"&&(E.saveFlowStatus="saved"),t(E,a,...c)):t(E,a,...c)},e(r.setState,n,r)},Va=Ne(),$2={cachedResults:new Map,error:"",results:[],status:"initial",swmlScriptMap:new Map},H2={ids:"ids",name:"name"},B2=(e,t)=>({...$2,actions:{buildParamsFromQuery:n=>{const{searchParams:r}=new URL(n,window.location.href);return LA(H2).reduce((s,i)=>{const l=r.get(i);return l&&(i==="ids"?s[i]=l.split(","):s[i]=l),s},{})},buildQueryFromParams:n=>{const r=ec(window.location.origin,{...n}),{search:o}=new URL(r);return`/${o}`},fetchSwmlScript:async n=>{try{const{actions:r}=t(),{getSwmlScripts:o,updateMapAndCache:s}=r;if(!o){Va.error("getSwmlScripts is not defined");return}e({status:"loading"});const i=await o(n),l=X0(i.data,"asc","display_name"),a=new Map(l.map(c=>[c.id,{displayName:c.display_name,id:c.id,requestUrl:c.request_url}]));s(a,n),e({error:"",results:Array.from(a.values()),status:"loaded"})}catch(r){let o="Unknown error";Va.error("Error fetching swmlScripts ",r),r instanceof Error&&(o=r.message),e({error:o,status:"error"})}},getCachedResults:n=>{const{cachedResults:r,swmlScriptMap:o}=t(),s=r.get(n);if(s)return s.reduce((i,l)=>{const a=o.get(l);return a&&i.push(a),i},[])},init:({getSwmlScriptsURL:n})=>{if(!n){Va.error("getSwmlScriptsURL is not defined");return}const r=nc({getSwmlScriptsURL:n,headers:of()}),o=async s=>await r.getSwmlScripts(s);e(s=>({...s,actions:{...s.actions,getSwmlScripts:o}}))},setResults:n=>{e({results:n})},updateConnection:(n,r)=>{if(n.connectConfirmId!=="external"){const o=r.get(n.connectConfirmId),s={...n};if(o&&o.displayName!==n.connectConfirmDisplayName)return s.connectConfirmDisplayName=o.displayName,s;if(!o)return s.connectConfirmId="",s.connectConfirmUrl="",s}},updateMapAndCache:(n,r)=>{const{actions:o,cachedResults:s,swmlScriptMap:i}=t(),{buildQueryFromParams:l}=o,a=r==null?void 0:r.ids,c=l(r),u=s.get(c),f=(u==null?void 0:u.filter(y=>n.has(y)))??[],p=(a==null?void 0:a.filter(y=>!n.has(y)))??[],h=[...new Set([...p,...f])];h.length>0&&(Array.from(s.entries()).forEach(([v,m])=>{if(v===r){const g=m.filter(S=>!h.includes(S));s.set(v,g)}}),h.forEach(v=>{i.delete(v)})),n.forEach((y,v)=>{i.set(v,y)});const E=Array.from(n.keys());s.set(c,E),e({cachedResults:new Map(s),swmlScriptMap:new Map(i)})},validateCache:(()=>{let n;return()=>{n&&clearTimeout(n),n=setTimeout(async()=>{const{actions:o,swmlScriptMap:s}=t(),{fetchSwmlScript:i}=o,l=Array.from(s.keys());l.length>0&&i&&await i({ids:l})},W0)}})(),validateScriptsFromNodes:(n,r)=>{const{actions:o}=t(),{fetchSwmlScript:s}=o,i=new Set,l=n.filter(c=>uv(c)&&"connections"in c.data&&c.data.connections.some(u=>u.connectConfirmEnabled));if(l.length===0)return;const a=(c,u)=>l.forEach(f=>{const p=f.data.connections.map(h=>c(h)??h);typeof u=="function"&&u(p,f)});a(c=>{c.connectConfirmId!==""&&c.connectConfirmId!=="external"&&c.connectConfirmEnabled&&i.add(c.connectConfirmId)}),i.size!==0&&s({ids:Array.from(i.values())}).then(()=>{const{actions:c,swmlScriptMap:u,status:f}=_n.getState(),{updateConnection:p}=c;f==="loaded"&&a(h=>{const E=p(h,u);return E||h},(h,E)=>{r(E.id,{connections:h})})}).catch(c=>Va.error("Error rehydrating SwmlScriptStore",c))}}}),uv=e=>e.type==="forwardAddress"||e.type==="forwardPhone"||e.type==="forwardResource",z2=(e,t)=>{if(e.some(uv)){const{validateScriptsFromNodes:r}=_n.getState().actions;r(e,t)}},_n=bo()(B2),dv=()=>_n.getState().actions;window.__useSwmlScriptStore=_n;const fv=500,W2=100,Oe=Ne(),G2=lv("handleCall",{deletable:!1,position:{x:300,y:100}}),Cf={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},Y2=(e,t)=>({...Cf,actions:{addNode:({nodeType:n,x:r=150,y:o=150})=>{Oe.debug("Add Node",n);const{nodes:s,reactFlowInstance:i}=t();if(!i)throw new Error("ReactFlowInstance not found");const l=lv(n,{position:i.project({x:r,y:o})}),a=s.map(c=>({...c,selected:!1}));a.push(l),e({nodes:a,selectedNode:l})},addToast:n=>{const{toastsMap:r}=t(),o=le();r.set(o,{...n,id:o}),e({toastsMap:new Map(r)})},cancelDetachedMode:async()=>{const{actions:n,workingFlowCopy:r}=t(),{cleanUpDetachedMode:o}=n;if(r){const{edges:s,nodes:i,saveFlowStatus:l}=r;e({edges:[],initializing:!0,nodes:[]}),await q0(fv),e({edges:s,nodes:i,saveFlowStatus:l})}else Oe.error("There was no working flow to restore");o()},cleanUpDetachedMode:()=>{e({detachedMode:!1,showDeployedHistory:!1,showDeployedHistoryToast:!1,workingFlowCopy:void 0})},deleteToast:n=>{const{toastsMap:r}=t();r.delete(n)&&e({toastsMap:new Map(r)})},deleteValidationWarning:n=>{const{validationWarnings:r}=t();r.delete(n)&&e({validationWarnings:new Map(r)})},deployFlow:async()=>{Oe.info("Deploying..."),e({deployFlowStatus:"deploying"});try{const{httpService:n,documentVersion:r}=t();if(!n)throw new Error("Missing httpService");const o=await n.deployFlow({documentVersion:r});Oe.info("Deploy response",o),e({deployFlowStatus:"deployed"})}catch(n){throw Oe.info("Deploy error",n),e({deployFlowStatus:"error"}),n}},exportStoreData:()=>{const{nodes:n,edges:r}=t();TA(n,r)},getDeployedVersionsList:async n=>{try{const{httpService:r}=t();if(!r)throw new Error("Missing httpService");const o=await r.getFlowVersions(n),s=Q0(ov());return e({deployedVersionsList:o.map((i,l)=>({id:i.id,relativeTimeSince:s(i.created_at),version:(o.length-l).toFixed(1)}))}),o}catch(r){throw Oe.error("Could not get deployed versions",r),e({deployedVersionsList:[]}),r}},getNodeType:n=>{const r=t().nodes.find(o=>o.id===n);return r==null?void 0:r.type},getRootElement:()=>{const{rootElement:n,rootElementId:r}=t();if(!n)throw new Error(`Root element not found for ID ${r}`);return n.shadowRoot?n.shadowRoot.getRootNode():n},getTargetEdges:n=>t().edges.filter(r=>{const o=r.target===n,s=r.source!==r.target;return o&&s}),getValidationWarnings:()=>t().validationWarnings,migrateAndLoadDeployedFlow:async n=>{const{actions:r,workingFlowCopy:o}=t(),{partialUpdateNodeData:s,saveWorkingFlowCopy:i}=r,a=new pp({dbRecord:n}).migrateTo(li),{flow_data:c}=a;if(!c)Oe.error("Cannot load flow: missing flowData",c);else{o||i();const u=c.nodes.map(Y0),f=c.edges.map(G0);e({detachedMode:!0,edges:[],initializing:!0,nodes:[]}),await q0(fv),e({edges:f,nodes:u,showDeployedHistoryToast:!0}),sv(u),av(u,s)}},onConnect:n=>{Oe.debug("onConnect"),e({edges:jE(n,t().edges)})},onConnectEnd:()=>{Oe.debug("onConnectEnd"),e({isEdgeConnecting:!1})},onConnectStart:()=>{Oe.debug("onConnectStart"),e({isEdgeConnecting:!0})},onEdgeUpdate:(n,r)=>{Oe.debug("onEdgeUpdate"),e({edges:SO(n,r,t().edges),isEdgeUpdateSuccessful:!0})},onEdgeUpdateEnd:(n,r)=>{var o;Oe.debug("onEdgeUpdateEnd"),t().isEdgeUpdateSuccessful?e({isEdgeUpdateSuccessful:!0}):(o=t().reactFlowInstance)==null||o.deleteElements({edges:[{id:r.id}]}),e({updatingSourceHandleId:void 0})},onEdgeUpdateStart:(n,r)=>{Oe.debug("onEdgeUpdateStart"),e({isEdgeUpdateSuccessful:!1,updatingSourceHandleId:r.sourceHandle??void 0})},onEdgesChange:n=>{e({edges:JO(n,t().edges)})},onEdgesDelete:n=>{Oe.debug("onEdgesDelete [noop]",n)},onInit:async n=>{const{actions:r,deployFlowURL:o,getFlowURL:s,updateFlowURL:i}=t(),{partialUpdateNodeData:l}=r;Oe.log("onInit",{getFlowURL:s,updateFlowURL:i});try{const a=nc({deployFlowURL:o,getFlowURL:s,headers:of(),updateFlowURL:i}),[c,u]=await Promise.all([a.getFlow(),a.getFlowVersions({pageSize:1})]),p=new pp({dbRecord:c}).migrateTo(li),{document_version:h,flow_data:E,id:y,title:v,updated_at:m}=p;if(u.length&&u[0]){const{document_version:S}=u[0];S===h&&e({deployFlowStatus:"deployed"})}let g=E;g||(g={edges:Cf.edges,flowDataVersion:li,nodes:Cf.nodes.concat([G2])}),e({documentLastUpdated:m,documentVersion:h,edges:g.edges.map(G0),flowId:y,flowTitle:v,httpService:a,nodes:g.nodes.map(Y0),reactFlowInstance:n}),sv(g.nodes),av(g.nodes,l),z2(g.nodes,l)}catch(a){Oe.error("Could not load flow. URL:",s);let c="unknown";a instanceof Error&&a.message.includes(_A)&&(c="not-found"),e({httpError:c})}},onNodeDragStart:()=>{e({isDraggingNode:!0})},onNodeDragStop:()=>{e({isDraggingNode:!1})},onNodesChange:n=>{const r=n.filter(o=>o.type!=="dimensions");r.length>0&&e({nodes:h0(r,t().nodes)})},onNodesDelete:n=>{Oe.debug("onNodesDelete");const{actions:r}=t(),{partialUpdateNodeData:o}=r;C2(t().nodes,n).forEach(i=>{o(i.id,i.data)})},onSelectionChange:({nodes:n})=>{e({selectedNode:n.find(r=>r.selected)})},onViewportChange:(()=>{let n;function r(o){n&&clearTimeout(n),n=setTimeout(()=>{e({viewportChanging:!1})},W2),e({viewport:{...o},viewportChanging:!0})}return r})(),onViewportChangeEnd:()=>{},onViewportChangeStart:()=>{},partialUpdateNodeData:(n,r)=>{var i;Oe.debug("partialUpdateNodeData",n,r);const o=[],s=t().nodes.map(l=>{if(l.id===n){if("options"in r&&"options"in l.data){const a=l.data.options.map(u=>u.id),c=r.options.map(u=>u.id);o.push(...a.filter(u=>!c.includes(u)))}return{...l,data:{...l.data,...r}}}return l});if(o.length){const l=t().edges.filter(a=>a.sourceHandle&&o.includes(a.sourceHandle));Oe.debug("Remove orphaned edges",{edgesToDelete:l,sourceHandleDeleted:o}),(i=t().reactFlowInstance)==null||i.deleteElements({edges:l})}e({nodes:s})},partialUpdateValidationWarning:(n,r)=>{const{validationWarnings:o}=t(),s=l=>l.connected===!1||l.valid===!1,i=o.get(n);if(r.nodeType!=="handleCall"&&!i&&s(r)){const l=D2.get(r.nodeType),a={connected:r.connected,id:le(),nodeId:r.nodeId,nodeTitle:l,nodeType:r.nodeType,valid:r.valid};o.set(n,a)}else if(i){const l={...i,...r};s(l)?o.set(n,l):o.delete(n)}e({validationWarnings:new Map(o)})},removeEdge:n=>{Oe.debug("removeEdge",n);const r=t().reactFlowInstance;r&&r.deleteElements({edges:[{id:n}]})},removeNode:n=>{Oe.debug("removeNode",n);const r=t().reactFlowInstance;r&&r.deleteElements({nodes:[{id:n}]})},restoreDeployedFlow:()=>{const{actions:n,edges:r,nodes:o}=t(),{cleanUpDetachedMode:s}=n;e({detachedMode:!1,edges:r,nodes:o}),s()},saveWorkingFlowCopy:()=>{const{edges:n,nodes:r,saveFlowStatus:o}=t();e({workingFlowCopy:{edges:n,nodes:r,saveFlowStatus:o}})},setColorMode:n=>{e({colorMode:n})},setDragNodeType:n=>{e({dragNodeType:n})},setFlowWrapperElement:n=>{e({flowWrapperElement:n||void 0})},setInitializing:n=>{e({initializing:n})},setSelectedNodes:n=>{const{nodes:r}=t(),o=r.map(s=>({...s,selected:n.includes(s.id)}));e({nodes:o})},setShowDeployWarning:n=>{e({showDeployWarning:n})},setShowDeployedHistory:n=>{e({showDeployedHistory:n})},setShowValidationWarnings:n=>{e({showValidationWarnings:n})},setViewportChanging:n=>{e({viewportChanging:n})}}}),Q=bo()(j2(V2(Y2))),Te=()=>Q.getState().actions;window.__useRFStore=Q;const K2={"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"}},X2=({errorType:e})=>{const t=Q(s=>s.backButtonHref),{title:n,message:r,status:o}=K2[e];return d.jsx("section",{className:"flex min-h-full w-full items-center justify-center bg-background px-6",children:d.jsxs("div",{className:"text-center",children:[o&&d.jsx("p",{className:"text-2xl font-semibold text-foreground/50",children:o}),d.jsx("h1",{className:"mt-4 text-3xl font-bold tracking-tight text-foreground",children:n}),d.jsx("p",{className:"mt-6 leading-7 text-foreground",children:r}),t&&d.jsx("div",{className:"mt-8 flex items-center justify-center gap-x-6",children:d.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:A(N.GO_BACK)})})]})})},pv=({height:e,strokeWidth:t,toX:n,toY:r,width:o})=>d.jsx("svg",{x:n-o*t/2,y:r-e*t/2,height:e*t,width:o*t,viewBox:`-${o/2} -${e/2} ${o} ${e}`,children:d.jsx("g",{children:d.jsx("polyline",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:t,points:"-5,-4 0,0 -5,4 -5,-4"})})}),Q2=({fromHandle:e,fromNode:t,fromPosition:n,fromX:r,fromY:o,toPosition:s,toX:i,toY:l})=>{if(!t)return null;const[a]=ri({borderRadius:B0,sourcePosition:n,sourceX:r,sourceY:o,targetPosition:s,targetX:i,targetY:l}),{height:c,strokeWidth:u,width:f}={...Do.markerEnd,...Do.style},p=(e==null?void 0:e.position)===q.Left,h=p?r:i,E=p?o:l;return d.jsxs("g",{className:"cfb-connection-line",children:[d.jsx("path",{fill:"none",strokeWidth:u,className:"animated",d:a}),d.jsx(pv,{height:c,strokeWidth:u,toX:h,toY:E,width:f}),p&&d.jsx("circle",{cx:i-2,cy:l,fill:"none",r:4,strokeWidth:u})]})};function q2({isCircular:e=!1,targetNode:t,targetX:n,targetY:r}){const{width:o,height:s,position:i}=t,l=o??0,a=s??0,c=l/2;return e?{tx:i.x+c,ty:i.y+a}:{tx:n,ty:r}}const J2=e=>{const t={...e,interactionWidth:40},{id:n,source:r,target:o,sourcePosition:s,sourceX:i,sourceY:l,targetX:a,targetY:c}=t,{removeEdge:u}=Te(),f=O.useRef(null),p=de(O.useCallback(I=>I.nodeInternals.get(r),[r])),h=de(O.useCallback(I=>I.nodeInternals.get(o),[o]));if(!p||!h)return null;const E=r===o,{tx:y,ty:v}=q2({isCircular:E,targetNode:h,targetX:a,targetY:c}),[m,g,S]=ri({borderRadius:B0,sourcePosition:s,sourceX:i,sourceY:l,targetPosition:E?q.Bottom:q.Left,targetX:y,targetY:v}),_=(I,j)=>{I.stopPropagation(),u(j)},x=I=>{var j,V,M;(j=I.currentTarget)==null||j.classList.add("highlight"),(V=f.current)==null||V.classList.add("animate-delay-opacity","flex"),(M=f.current)==null||M.classList.remove("hidden")},R=I=>{var j,V,M;(j=I.currentTarget)==null||j.classList.remove("highlight"),(V=f.current)==null||V.classList.remove("animate-delay-opacity","flex"),(M=f.current)==null||M.classList.add("hidden")},{height:T,strokeWidth:L,width:P}={...Do.markerEnd,...Do.style};return d.jsxs("g",{onMouseEnter:x,onMouseLeave:R,children:[d.jsx(xo,{path:m,...t}),d.jsx(pv,{height:T,strokeWidth:L,toX:y,toY:v,width:P}),d.jsx(WT,{children:d.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:I=>_(I,n),ref:f,style:{transform:`translate(-50%, -50%) translate(${g}px,${S}px)`},children:[d.jsx(re,{tag:"trash-can",className:"py-0.5 px-1.5 text-background"}),d.jsx("span",{className:"sr-only",children:A(N.REMOVE_EDGE)})]})})]})},Z2=/^[\w\d -']+$/,eL=/^\d+$/,tL=/^\d|\*|#$/,nL=/^[\d*#$]{0,12}$/,rL=/^.{1,20}$/,zo={MAX:3600,MIN:0},oL=/^[a-z0-9_]{1,20}$/,Ee={MAX:99,MIN:1},Wo=e=>t=>!!e.exec(t),Lf=e=>{if(!yt(e))return!0;try{return!!new URL(e)}catch{return!1}},lt=e=>yt(e)?Wo(eL)(e):!0,sL=e=>yt(e)?Wo(tL)(e):!0,iL=e=>yt(e)?Wo(Z2)(e):!0,lL=e=>yt(e)?Wo(oL)(e):!0,hv=e=>yt(e)?Wo(nL)(e):!0,aL=e=>yt(e)?Wo(rL)(e):!0,$a=e=>{if(!yt(e))return!0;try{return JSON.parse(e),!0}catch{return!1}},ae=e=>!!yt(e),vi=(e,t)=>{if(typeof e=="string"&&!yt(e))return!0;const n=typeof e!="number"?parseInt(e,10):e;return!Number.isNaN(n)&&n>=t},_i=(e,t)=>{if(typeof e=="string"&&!yt(e))return!0;const n=typeof e!="number"?parseInt(e,10):e;return!Number.isNaN(n)&&n<=t},er=(e,t)=>{const n=new Set,r=e.reduce((o,s)=>{const i=s[t];if(typeof i=="string"){const l=i.trim();l&&(n.has(l)&&o.add(l),n.add(l))}return o},new Set);return o=>r.has(o.trim())},Go={aiAgent:{fieldValidators:{agent:[ae]},validate:e=>Yo({nodeData:e,nodeType:"aiAgent"}),validateField:(e,t)=>ie({name:e,nodeType:"aiAgent",value:t})},cond:{fieldValidators:{value:[ae]},validate:e=>Df("cond",e),validateField:(e,t)=>ie({name:e,nodeType:"cond",value:t})},condRequest:{fieldValidators:{body:[],headers:[$a],method:[ae],saveVariables:[],url:[ae],value:[ae]},validate:e=>{const t=e,n=[];return["body","headers","method","saveVariables","url"].forEach(o=>{ie({name:o,nodeType:"condRequest",value:t[o]})||n.push(o)}),[...n,...Df("condRequest",e)]},validateField:(e,t)=>ie({name:e,nodeType:"condRequest",value:t})},executeSWML:{fieldValidators:{dest:[ae],meta:[$a],params:[$a]},validate:e=>{const t=e,n=[];return["dest","params","meta"].forEach(o=>{ie({name:o,nodeType:"executeSWML",value:t[o]})||n.push(o)}),[...n,...Df("executeSWML",e)]},validateField:(e,t)=>ie({name:e,nodeType:"executeSWML",value:t})},forwardAddress:{fieldValidators:{callOrder:[],callStateEvents:[],callStateUrl:[],connectConfirmDisplayName:[],connectConfirmEnabled:[],connectConfirmId:[ae],connectConfirmUrl:[ae,Lf],connectFrom:[],connectTimeout:[lt],connectTo:[ae],defaultFrom:[],defaultTimeout:[lt],sessionTimeout:[lt]},validate:e=>kf("forwardAddress",e),validateField:(e,t)=>ie({name:e,nodeType:"forwardAddress",value:t})},forwardPhone:{fieldValidators:{callOrder:[],callStateEvents:[],callStateUrl:[],connectConfirmDisplayName:[],connectConfirmEnabled:[],connectConfirmId:[ae],connectConfirmUrl:[ae,Lf],connectFrom:[],connectTimeout:[lt],connectTo:[ae],defaultFrom:[],defaultTimeout:[lt],sessionTimeout:[lt]},validate:e=>kf("forwardPhone",e),validateField:(e,t)=>ie({name:e,nodeType:"forwardPhone",value:t})},forwardResource:{fieldValidators:{callOrder:[],callStateEvents:[],callStateUrl:[],connectConfirmDisplayName:[],connectConfirmEnabled:[],connectConfirmId:[ae],connectConfirmUrl:[ae,Lf],connectFrom:[],connectTimeout:[lt],connectTo:[ae],defaultFrom:[],defaultTimeout:[lt],sessionTimeout:[lt]},validate:e=>kf("forwardResource",e),validateField:(e,t)=>ie({name:e,nodeType:"forwardResource",value:t})},hangup:{fieldValidators:{reason:[]},validate:e=>Pf("hangup",e),validateField:(e,t)=>ie({name:e,nodeType:"hangup",value:t})},play:{fieldValidators:{selected:[ae],text:[ae],url:[ae]},validate:e=>Pf("play",e),validateField:(e,t)=>ie({name:e,nodeType:"play",value:t})},promptPlay:{fieldValidators:{command:[iL],digit:[sL],digitTimeout:[lt,{test:vi,testValue:Ee.MIN},{test:_i,testValue:Ee.MAX}],initialTimeout:[lt,{test:vi,testValue:Ee.MIN},{test:_i,testValue:Ee.MAX}],selected:[ae],text:[ae],url:[ae]},validate:e=>{const t="promptPlay",n=e,r=er(n.options,"command"),o=er(n.options,"digit"),s=Pf("promptPlay",n),i=Za(n.initialTimeout);i!=null&&i.trim()&&!ie({name:"initialTimeout",nodeType:t,value:i})&&s.push("initialTimeout");const l=Za(n.digitTimeout);return l!=null&&l.trim()&&!ie({name:"digitTimeout",nodeType:t,value:l})&&s.push("digitTimeout"),n.options.forEach(a=>{const c=ie({name:"command",nodeType:t,value:a.command})&&!r(a.command),u=ie({name:"digit",nodeType:t,value:a.digit})&&!o(a.digit);c&&u&&(a.command||a.digit)||s.push(`option_${a.id}`)}),s},validateField:(e,t)=>ie({name:e,nodeType:"promptPlay",value:t})},record:{fieldValidators:{beep:[],endSilenceTimeout:[lt,{test:vi,testValue:Ee.MIN},{test:_i,testValue:Ee.MAX}],format:[ae],initialTimeout:[lt,{test:vi,testValue:Ee.MIN},{test:_i,testValue:Ee.MAX}],maxLength:[lt,{test:vi,testValue:zo.MIN},{test:_i,testValue:zo.MAX}],stereo:[],terminators:[hv]},validate:e=>Yo({nodeData:e,nodeType:"record"}),validateField:(e,t)=>ie({name:e,nodeType:"record",value:t})},recordCallStart:{fieldValidators:{beep:[],controlId:[],format:[ae],label:[ae,aL],stereo:[],terminators:[hv]},validate:e=>Yo({nodeData:e,nodeType:"recordCallStart"}),validateField:(e,t)=>ie({name:e,nodeType:"recordCallStart",value:t})},recordCallStop:{fieldValidators:{controlId:[ae]},validate:e=>Yo({nodeData:e,nodeType:"recordCallStop"}),validateField:(e,t)=>ie({name:e,nodeType:"recordCallStop",value:t})},request:{fieldValidators:{body:[],headers:[$a],method:[ae],saveVariables:[],url:[ae]},validate:e=>Yo({nodeData:e,nodeType:"request"}),validateField:(e,t)=>ie({name:e,nodeType:"request",value:t})},sendSms:{fieldValidators:{body:[ae],fromNumber:[ae],toNumber:[ae]},validate:e=>Yo({nodeData:e,nodeType:"sendSms"}),validateField:(e,t)=>ie({name:e,nodeType:"sendSms",value:t})},set:{fieldValidators:{key:[ae,lL],value:[]},validate:e=>{const t=e,n="set",r=[],o=er(t.variables,"key");return t.variables.forEach(s=>{const i=ie({name:"key",nodeType:n,value:s.key})&&!o(s.key),l=ie({name:"value",nodeType:n,value:s.value});i&&l||r.push(`variable_${s.id}`)}),r},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})}},at=e=>{const t=Go==null?void 0:Go[e];return{validate:t==null?void 0:t.validate,validateField:t==null?void 0:t.validateField}},mv=(e,t)=>{var r;const n=(r=Go[e])==null?void 0:r.validate;return n===void 0?[]:n(t)},bf=(e,t)=>{var n;return!e||!t?!1:((n=mv(e,t))==null?void 0:n.length)===0},cL=e=>{var t;return(t=Go[e])==null?void 0:t.fieldValidators},ie=({name:e,nodeType:t,value:n})=>{var s;let r=!0;const o=(s=cL(t))==null?void 0:s[e];return o==null||o.forEach(i=>{typeof i=="function"?r=r&&i(n):r=r&&i.test(n,i.testValue)}),r},Yo=({nodeData:e,nodeType:t})=>{var o;const n=((o=Go[t])==null?void 0:o.fieldValidators)??{},r=[];return Object.keys(n).forEach(s=>{const i=s;ie({name:s,nodeType:t,value:(e==null?void 0:e[i])??""})||r.push(s)}),r},Df=(e,t)=>{const n=t,r=[];return n.options.forEach(o=>{ie({name:"value",nodeType:e,value:o.value})||r.push(`condition_${o.id}`)}),r},kf=(e,t)=>{var s;const n=[];["callOrder","callStateEvents","callStateUrl","defaultFrom","defaultTimeout"].forEach(i=>{ie({name:i,nodeType:e,value:t[i]})||n.push(i)});const o=["connectFrom","connectTo","connectTimeout","connectConfirmUrl","connectConfirmId"];return(s=t.connections)==null||s.forEach(i=>{o.forEach(l=>{!i.connectConfirmEnabled&&(l==="connectConfirmUrl"||l==="connectConfirmId")||ie({name:l,nodeType:e,value:i[l]})||n.push(`${l}_${i.id}`)})}),n},Pf=(e,t)=>{const n=[];return ie({name:"selected",nodeType:e,value:t==null?void 0:t.selected})||n.push("selected"),t.selected==="url"?ie({name:"url",nodeType:e,value:t.url})||n.push("url"):t.selected==="text"&&(ie({name:"text",nodeType:e,value:t.text})||n.push("text")),n},ct=({data:e,id:t})=>{const n=Q(l=>l.isCanvasInteractive),{getNodeType:r,partialUpdateNodeData:o}=Te(),{isValueDuplicate:s}=If(),i=r(t);return O.useEffect(()=>{if(i&&n){let l=bf(i,e);i==="recordCallStart"&&"label"in e&&(l=l&&!s(e.label,e.controlId)),l!==e.valid&&o(t,{valid:l})}},[e,t,n,s,o,i]),O.useEffect(()=>{if(i==="aiAgent"&&n){const l=en.subscribe(a=>{if(a.status==="loaded"&&"agent"in e){const c=a.aiAgentMap.has(e.agent),u=c&&bf(i,e);u!==e.valid&&o(t,{agent:c?e.agent:"",valid:u})}});return()=>{l()}}},[e,t,n,o,i]),O.useEffect(()=>{if((a=>(i==="forwardAddress"||i==="forwardPhone"||i==="forwardResource")&&"connections"in a)(e)&&n){const a=_n.subscribe(c=>{if(c.status==="loaded"){let u=!0;const f=e.connections.map(h=>{const E=c.actions.updateConnection(h,c.swmlScriptMap);return E?(u=!1,E):h}),p=u&&bf(i,e);p!==e.valid&&o(t,{connections:f,valid:p})}});return()=>{a()}}},[e,t,n,o,i]),{getInvalidFields:()=>!i||e.valid?[]:mv(i,e),valid:()=>e.valid}},uL=({data:e,id:t,isConnectable:n,selected:r})=>{ct({data:e,id:t});const o=en(i=>i.aiAgentMap.get(e.agent)),s=o==null?void 0:o.display_name;return d.jsxs($e,{id:t,isConnectable:n,nodeTitle:A(N.AI_AGENT),selected:r,valid:e.valid,children:[s&&d.jsx(Lt,{children:d.jsx("p",{className:"truncate text-xs",children:s})}),d.jsx(Ht,{id:t,color:"positive",isConnectable:n})]})},dL=({data:e,id:t,isConnectable:n,selected:r})=>d.jsx($e,{id:t,isConnectable:n,nodeTitle:A(N.ANSWER_CALL),selected:r,valid:e.valid,children:d.jsx(Ht,{id:t,isConnectable:n,color:"positive"})}),fL=({id:e,data:t,isConnectable:n,selected:r})=>(ct({data:t,id:e}),d.jsx($e,{id:e,isConnectable:n,nodeTitle:A(N.CONDITIONS),selected:r,valid:t.valid,children:d.jsxs(Fo,{children:[t.options.map((o,s)=>{const i=o.value.trim();return d.jsx(Bt,{color:"positive",enabled:!!i,id:o.id,isConnectable:n,optionTitle:i?d.jsx("div",{className:"truncate",children:i}):A(N.CONDITION_NUMBER,{index:s+1})},o.id)}),d.jsx(Bt,{color:"negative",id:t.fallback,isConnectable:n,optionTitle:A(N.ELSE)})]})})),pL=({data:e,id:t,isConnectable:n,selected:r})=>{var s;ct({data:e,id:t});const o=e.url.trim();return d.jsxs($e,{id:t,isConnectable:n,nodeTitle:A(N.REQUEST),selected:r,valid:e.valid,children:[o&&d.jsx(Lt,{children:d.jsx("div",{className:"break-all line-clamp-3",children:o})}),d.jsxs(Fo,{children:[(s=e==null?void 0:e.options)==null?void 0:s.map((i,l)=>{const a=i.value.trim();return d.jsx(Bt,{color:"positive",enabled:!!a,id:i.id,isConnectable:n,optionTitle:a?d.jsx("div",{className:"truncate",children:a}):A(N.CONDITION_NUMBER,{index:l+1})},i.id)}),d.jsx(Bt,{color:"negative",id:e.fallback,isConnectable:n,optionTitle:A(N.ELSE)}),d.jsx(Bt,{color:"negative",id:e.error,isConnectable:n,optionTitle:A(N.FAILURE)})]})]})},hL=({data:e,id:t,isConnectable:n,selected:r})=>{var s;ct({data:e,id:t});const o=e.dest.trim();return d.jsxs($e,{id:t,isConnectable:n,nodeTitle:A(N.EXECUTE_SWML),selected:r,valid:e.valid,children:[o&&d.jsx(Lt,{children:d.jsx("div",{className:"break-all line-clamp-3",children:o})}),d.jsxs(Fo,{children:[(s=e==null?void 0:e.options)==null?void 0:s.map((i,l)=>{const a=i.value.trim();return d.jsx(Bt,{color:"positive",enabled:!!a,id:i.id,isConnectable:n,optionTitle:a?d.jsx("div",{className:"truncate",children:a}):A(N.CONDITION_NUMBER,{index:l+1})},i.id)}),d.jsx(Bt,{color:"negative",id:e.fallback,isConnectable:n,optionTitle:A(N.ELSE)})]})]})},Mf=3,mL={busy:N.BUSY,decline:N.DECLINE,error:N.ERROR,noAnswer:N.NO_ANSWER,success:N.SUCCESS},gL={address:N.FORWARD_TO_ADDRESS,phone:N.FORWARD_TO_PHONE,resource:N.FORWARD_TO_RESOURCE},Uf=({id:e,data:t,isConnectable:n,selected:r})=>{ct({data:t,id:e});const o=t.connections.filter(i=>i.connectTo),s=o.slice(0,Mf);return d.jsxs($e,{id:e,isConnectable:n,nodeTitle:A(gL[t.destinationType]),selected:r,valid:t.valid,children:[o.length?d.jsxs(Lt,{children:[d.jsx("ul",{children:s.map(i=>d.jsx("li",{className:"pb-2",children:d.jsx("div",{className:"max-w-max truncate rounded bg-secondary/20 px-1 ",children:i.connectTo})},`node-${i.id}`))}),o.length>Mf&&d.jsx("div",{children:`+ ${A(N.MORE_WITH_COUNT,{count:o.length-Mf})}`})]}):null,d.jsx(Fo,{children:t.options.map(i=>d.jsx(Bt,{color:K0(i.result),id:i.id,isConnectable:n,optionTitle:A(mL[i.result])},i.id))})]})},EL=({id:e,data:t,isConnectable:n,selected:r})=>{ct({data:t,id:e});const o=er(t.options,"command"),s=er(t.options,"digit");return d.jsxs($e,{id:e,isConnectable:n,nodeTitle:A(N.GATHER_INPUT),selected:r,valid:t.valid,children:[d.jsx(wy,{data:t}),d.jsxs(Fo,{children:[t.options.map((i,l)=>{const a=i.command.trim(),c=i.digit.trim(),u=!!(a||c)&&!o(i.command)&&!s(i.digit),f=d.jsxs("div",{className:"flex gap-1",children:[A(N.CALLER_PRESSES)," ",d.jsx("span",{className:"truncate rounded bg-secondary/20 px-1",children:c})]}),p=y=>d.jsxs("div",{className:"flex",children:[A(y?N.CALLER_SAYS:N.OR_CALLER_SAYS)," '",d.jsx("span",{className:"truncate",children:a}),"'"]});let h=A(N.OPTION_NUMBER,{index:l+1}),E="";switch(!0){case!!(a&&!c):h=p(!0);break;case!!(!a&&c):h=f;break;case!!(a&&c):h=f,E=p(!1);break}return d.jsx(Bt,{color:"positive",enabled:u,id:i.id,isConnectable:n,optionTitle:h,optionSubtitle:E},i.id)}),t.results.map(i=>d.jsx(Bt,{color:"negative",id:i.id,isConnectable:n,optionTitle:i.result==="no_input"?A(N.NO_INPUT):A(N.UNKNOWN)},i.id))]})]})},yL=({id:e,isConnectable:t,selected:n})=>d.jsx($e,{id:e,isConnectable:t,isRoot:!0,nodeTitle:A(N.HANDLE_CALL),selected:n,deletable:!1,showValidation:!1,target:!1,children:d.jsx(Ht,{id:e,color:"positive",isConnectable:t})}),Ff={busy:N.BUSY,decline:N.DECLINE,hangup:N.HANG_UP},vL=({data:e,id:t,isConnectable:n,selected:r})=>d.jsx($e,{id:t,isConnectable:n,nodeTitle:A(N.HANG_UP_CALL),selected:r,valid:e.valid,children:e.reason&&d.jsx(Lt,{children:d.jsx("p",{children:A(Ff[e.reason])})})}),_L=({data:e,id:t,isConnectable:n,selected:r})=>(ct({data:e,id:t}),d.jsxs($e,{id:t,isConnectable:n,nodeTitle:A(N.PLAY_AUDIO_TTS),selected:r,valid:e.valid,children:[d.jsx(wy,{data:e}),d.jsx(Ht,{id:t,isConnectable:n})]})),SL=({data:e,id:t,isConnectable:n,selected:r})=>{const{label:o,valid:s}=e;return ct({data:e,id:t}),d.jsxs($e,{id:t,isConnectable:n,nodeTitle:A(N.RECORD_CALL_START),selected:r,valid:s,children:[o&&s&&d.jsx(Lt,{children:d.jsx("p",{className:"truncate text-xs leading-5",children:o})}),d.jsx(Ht,{id:t,isConnectable:n,color:"positive"})]})},xL=({data:e,id:t,isConnectable:n,selected:r})=>{var i;ct({data:e,id:t});const o=(i=Bo(l=>l.entries))==null?void 0:i.find(l=>l.controlId===e.controlId),s=o==null?void 0:o.label;return d.jsxs($e,{id:t,isConnectable:n,nodeTitle:A(N.RECORD_CALL_STOP),selected:r,valid:e.valid,children:[s&&d.jsx(Lt,{children:d.jsx("p",{className:"truncate text-xs leading-5",children:s})}),d.jsx(Ht,{id:t,color:"positive",isConnectable:n})]})},RL=({data:e,id:t,isConnectable:n,selected:r})=>{ct({data:e,id:t});const o=new Set(e.terminators);return d.jsxs($e,{id:t,isConnectable:n,nodeTitle:A(N.VOICEMAIL_RECORDING),selected:r,valid:e.valid,children:[e.terminators?d.jsxs(Lt,{children:[A(N.TERMINATORS),":"," ",d.jsx("ul",{className:"inline-flex flex-wrap justify-start gap-1",children:[...o].sort().map((s,i)=>d.jsx("li",{className:"rounded bg-secondary/20 px-1",children:s},`${i}-${s}`))})]}):null,d.jsx(Ht,{id:t,isConnectable:n,color:"positive"})]})},NL={failed:N.FAILED,success:N.SUCCESS},gv={aiAgent:uL,answer:dL,cond:fL,condRequest:pL,executeSWML:hL,forwardAddress:Uf,forwardPhone:Uf,forwardResource:Uf,handleCall:yL,hangup:vL,play:_L,promptPlay:EL,record:RL,recordCallStart:SL,recordCallStop:xL,request:({data:e,id:t,isConnectable:n,selected:r})=>{var o;return ct({data:e,id:t}),d.jsxs($e,{id:t,isConnectable:n,nodeTitle:A(N.REQUEST),selected:r,valid:e.valid,children:[d.jsx("p",{className:"p-4 pt-0 text-xs text-negative",children:A(N.DEPRECATED)}),d.jsx(Fo,{children:(o=e==null?void 0:e.options)==null?void 0:o.map(s=>d.jsx(Bt,{color:K0(s.result),id:s.id,isConnectable:n,optionTitle:A(NL[s.result])},s.id))})]})},sendSms:({data:e,id:t,isConnectable:n,selected:r})=>(ct({data:e,id:t}),d.jsxs($e,{id:t,isConnectable:n,nodeTitle:A(N.SEND_SMS),selected:r,valid:e.valid,children:[e.body&&d.jsx(Lt,{children:d.jsx("p",{className:"break-words line-clamp-3",children:e.body})}),d.jsx(Ht,{id:t,isConnectable:n})]})),set:({id:e,data:t,isConnectable:n,selected:r})=>{const{getInvalidFields:o}=ct({data:t,id:e}),s=o().reduce((l,a)=>(a.startsWith("variable_")&&l.push(a.replace("variable_","")),l),[]),i=t.variables.filter(l=>!!l.key);return d.jsxs($e,{id:e,isConnectable:n,nodeTitle:A(N.SET_VARIABLES),selected:r,valid:t.valid,children:[i.length>0&&d.jsx(Lt,{children:d.jsx("ul",{className:"flex flex-col",children:i.map(l=>d.jsxs("li",{className:"flex w-full gap-1 pb-2",children:[d.jsx("div",{className:`max-w-[50%] shrink-0 truncate rounded px-1 ${s.includes(l.id)?"bg-negative/10 text-negative":"bg-secondary/20"}`,children:l.key}),"=",l.value&&d.jsx("div",{className:"truncate",children:l.value})]},l.id))})}),d.jsx(Ht,{id:e,isConnectable:n,color:"positive"})]})},unset:({id:e,data:t,isConnectable:n,selected:r})=>{ct({data:t,id:e});const o=t.variables.filter(s=>!!s.key);return d.jsxs($e,{id:e,isConnectable:n,nodeTitle:A(N.UNSET_VARIABLES),selected:r,valid:t.valid,children:[o.length>0&&d.jsx(Lt,{children:d.jsx("ul",{children:o.map(s=>d.jsx("li",{className:"pb-2",children:d.jsx("div",{className:"max-w-max truncate rounded bg-secondary/20 px-1",children:s.key})},s.id))})}),d.jsx(Ht,{id:e,isConnectable:n,color:"positive"})]})}},wL={floating:J2},OL=({children:e})=>{const t=Q(S=>S.nodes),n=Q(S=>S.edges),r=Q(S=>S.isCanvasInteractive),{onConnect:o,onConnectEnd:s,onConnectStart:i,onEdgesChange:l,onEdgesDelete:a,onEdgeUpdate:c,onEdgeUpdateEnd:u,onEdgeUpdateStart:f,onInit:p,onNodeDragStart:h,onNodeDragStop:E,onNodesChange:y,onNodesDelete:v,onSelectionChange:m,setFlowWrapperElement:g}=Te();return d.jsx("div",{className:"bg-sw-white !h-auto w-full",ref:S=>g(S),children:d.jsxs(M0,{attributionPosition:"bottom-left",connectionLineComponent:Q2,connectionMode:Wn.Strict,deleteKeyCode:r?NA:null,defaultEdgeOptions:Do,edges:n,edgeTypes:wL,elementsSelectable:r,fitViewOptions:rf,multiSelectionKeyCode:r?wA:null,nodes:t,nodesConnectable:r,nodesDraggable:r,nodeTypes:gv,onConnect:o,onConnectEnd:s,onConnectStart:i,onEdgesChange:l,onEdgesDelete:a,onEdgeUpdate:r?c:void 0,onEdgeUpdateEnd:u,onEdgeUpdateStart:f,onInit:p,onNodeDragStart:h,onNodeDragStop:E,onNodesChange:y,onNodesDelete:v,onSelectionChange:m,selectionKeyCode:r?OA:null,snapGrid:[ya,ya],snapToGrid:!0,children:[d.jsx(cA,{className:"bg-background-alt text-grid",color:"currentColor",gap:[ya,ya],variant:Ct.Dots}),e]})})},TL=()=>{const e=Q(l=>l.initializing),t=Q(l=>l.reactFlowInstance),{setInitializing:n,setViewportChanging:r}=Te(),o=O.useRef(!1),s=QT({includeHiddenNodes:!0}),i=O.useMemo(()=>()=>{t==null||t.fitView(rf)},[t]);O.useEffect(()=>{let l;e?!o.current&&!s?o.current=!0:o.current&&s&&(clearTimeout(l),r(!0),i(),l=setTimeout(()=>{r(!1)},rf.duration),n(!1),o.current=!1):o.current=!1},[e,i,s,n,r])},AL=()=>{const{onViewportChange:e,onViewportChangeEnd:t,onViewportChangeStart:n}=Te();return TL(),YT({onChange:e,onEnd:t,onStart:n}),null},IL=()=>{const e=Q(n=>n.selectedNode),t=e?k2.get(e.type):void 0;return t?d.jsx(Zs,{className:"z-40 max-w-[40%] rounded-md bg-background",position:"bottom-center",children:d.jsxs("div",{className:"justify-left flex items-center gap-2 rounded-md bg-primary/10 p-3 py-4","data-testid":"cfb__info",children:[d.jsx(re,{className:"shrink-0 text-primary",tag:"circle-info",size:"xl"}),d.jsx("div",{className:"text-xs font-medium",children:Ua(t)})]})}):null},CL=e=>{var s;const t=O.useRef(),n=GT(),r=e&&"options"in e.data?(s=e.data.options)==null?void 0:s.length:0;return t.current=r,{updateDynamicHandles:i=>{"options"in i&&i.options.length!==t.current&&(e&&n(e.id),t.current=i.options.length)}}},LL="/hello/.test('%{foo}')",bL=()=>({id:le(),value:""}),jf=({nodeData:e,handleOnUpdate:t,placeholder:n=LL})=>{const{validateField:r}=at("cond"),[o,s]=O.useState({options:e.options.map(f=>({id:!0,initial:e.initial,value:r("value",f.value)}))}),i=f=>{f.preventDefault(),s({...o,options:[...o.options,{initial:!0,value:!0}]}),t({options:[...e.options,bL()]})},l=f=>p=>{p.preventDefault();const h=[...o.options];h.splice(f,1),s({...o,options:h});const E=[...e.options];E.splice(f,1),t({options:E})},a=(f,p)=>{const h=[...e.options];if(!h[f])throw new Error(`Option not found at index ${f}`);const{name:E,value:y}=p,v=[...o.options];v[f]={...v[f],initial:!1,[E]:r(E,y)},s({...o,options:v}),h[f]={...h[f],[E]:y},t({options:h})},c=(f,p)=>{const h=f.target,{name:E,value:y}=h;switch(t({initial:!1}),E){case"value":p!==void 0&&a(p,{name:E,value:y});break;default:Ne().error(`Unhandled input name: ${E}`)}},u=({index:f,name:p})=>{const h=o.options[f];return(h==null?void 0:h[p])||(h==null?void 0:h.initial)};return d.jsxs(d.Fragment,{children:[d.jsx("ol",{className:"divide-y-4 divide-foreground/10 border-b-4 border-foreground/10",children:e.options.map((f,p,h)=>d.jsxs("li",{className:"flex pt-3",children:[d.jsx("div",{className:"w-8 shrink-0 text-center",children:d.jsx(re,{className:"text-foreground/60",size:"xs",tag:"bars"})}),d.jsxs("div",{className:"relative mr-3",children:[h.length>1&&d.jsx(Uo,{className:"absolute right-0 top-0",handleDelete:l(p),label:A(N.REMOVE_CONDITION,{index:p+1}),size:"sm",show:!0}),d.jsxs("label",{className:"mb-2 block",children:[A(N.CONDITION_NUMBER,{index:p+1}),d.jsx("input",{className:`w-full ${u({index:p,name:"value"})?"":"invalid"}`,name:"value",onChange:E=>c(E,p),placeholder:n,type:"text",value:f.value}),d.jsx("p",{className:"requirements",role:"alert",children:A(N.ERROR_VALUE_IS_REQUIRED)})]})]})]},f.id))}),d.jsx("div",{className:"p-3 text-right",children:d.jsx("button",{className:"rounded bg-foreground/10 py-1 px-2 font-medium",onClick:i,type:"button",children:A(N.ADD_CONDITION)})})]})},DL=Ne(),Si=(e,t)=>[e,t].filter(Boolean).join("-").toLowerCase(),kL={idsByKey:{},languageById:{},voiceById:{}},PL=(e,t)=>({...kL,actions:{getGenderByKeys:({languageId:n})=>{const{idsByKey:r}=t(),o=(n==null?void 0:n.split(",").map(i=>Si(i)))??[];if(!o.length)return["female","male"];const s=new Set;return o.forEach(i=>{var l;return(l=r[i])==null?void 0:l.forEach(a=>{a.gender&&s.add(a.gender)})}),Array.from(s).sort((i,l)=>i.toLowerCase().localeCompare(l.toLowerCase()))},getLanguages:()=>Object.values(t().languageById).sort((n,r)=>n.name.toLowerCase().localeCompare(r.name.toLowerCase())),getVoicesByKeys:({languageId:n,gender:r})=>{const{voiceById:o,idsByKey:s}=t(),i=(n==null?void 0:n.split(",").map(a=>Si(a,r)))??[];let l=[];return!i.length||i[0]===""?l=Object.values(o):i.forEach(a=>{l=l.concat(s[a]??[])}),l.sort((a,c)=>{const u=/^\w{2,3}-\w{2,}-.+/;return a.name.match(u)&&!c.name.match(u)?1:!a.name.match(u)&&c.name.match(u)?-1:a.name.toLowerCase().localeCompare(c.name.toLowerCase())})},init:async({voicesURL:n="/cfb/voices.json"})=>{try{DL.debug("Load voicesURL",n);const o=await(await fetch(n)).json(),s={},i={},l={};o.forEach(a=>{var v,m,g;const c=!!a.premium,u=a.signalwire_id,f=a.gender.toLowerCase(),p={gender:f,id:u,key:`${a.language_code}-${f}-${a.signalwire_id}`,name:`${a.friendly_name.trim()} ${c?"(premium)":""}`,premium:c};s[u]=p,i[a.language_code]={id:a.language_code,name:a.language};const h=Si(a.language_code);h in l||(l[h]=[]),(v=l[h])==null||v.push(p);const E=Si(f);E in l||(l[E]=[]),(m=l[E])==null||m.push(p);const y=Si(a.language_code,f);y in l||(l[y]=[]),(g=l[y])==null||g.push(p)}),e({idsByKey:l,languageById:i,voiceById:s})}catch(r){console.error("Error",r)}}}}),Vf=bo()(PL),ML=()=>Vf.getState().actions;window.__useVoiceStore=Vf;const Ev=e=>d.jsx("option",{value:e.id,children:e.name},e.key??e.id),UL=({onChange:e,languageId:t,gender:n,voiceId:r})=>{const{getLanguages:o,getVoicesByKeys:s,getGenderByKeys:i}=ML();return d.jsxs(d.Fragment,{children:[d.jsxs(Zt,{className:"w-full",label:A(N.LANGUAGE),name:"language",onChange:e,value:t??"",children:[d.jsx("option",{value:"",children:A(N.SELECT)}),o().map(Ev)]}),d.jsxs(Zt,{className:"w-full capitalize",label:A(N.GENDER),name:"gender",onChange:e,value:n??"",children:[d.jsx("option",{value:"",children:A(N.SELECT)}),i({languageId:t}).map(l=>d.jsx("option",{value:l,children:l},l))]}),d.jsxs(Zt,{className:"w-full",label:A(N.VOICE),name:"voice",onChange:e,value:r??"",children:[d.jsx("option",{value:"",children:A(N.SELECT)}),s({gender:n,languageId:t}).map(Ev)]})]})},yv={text:N.TEXT_TO_SPEECH,url:N.PLAY_AUDIO_FILE},vv=({handleOnUpdate:e,label:t,nodeData:n,showDefaultOption:r})=>{const{validateField:o}=at("play"),[s,i]=O.useState({gender:!0,language:!0,selected:n.initial||o("selected",n.selected),text:n.initial||o("text",n.text),url:n.initial||o("url",n.url),voice:!0}),l=n.selected;O.useEffect(()=>{!l&&!r&&e({selected:"url"})},[e,l,r]);const a=u=>{const f=u.target,{name:p,value:h}=f;switch(p){case"selected":case"text":case"url":i({...s,[p]:o(p,h)}),e({initial:!1,[p]:h});break;default:throw new Error(`Unhandled input name: ${p}`)}},c=u=>{const f=u.target,{name:p,value:h}=f;switch(p){case"language":e({gender:void 0,language:h,voice:void 0});break;case"gender":e({gender:h,voice:void 0});break;default:e({[p]:h})}};return d.jsxs(d.Fragment,{children:[d.jsxs("label",{className:"mb-2",children:[d.jsx("span",{className:"sr-only",children:t}),d.jsxs(Oy,{className:`w-full ${s.selected?"":"invalid"}`,name:"selected",onChange:a,value:l,children:[r&&d.jsx("option",{value:"",children:A(N.SELECT)}),Object.keys(yv).map(u=>d.jsx("option",{value:u,children:A(yv[u])},u))]})]}),l&&d.jsx(FL,{nodeData:n,onChange:a,voiceSettingsChangeHandler:c,selected:l,valid:s[l]})]})},FL=({nodeData:e,onChange:t,voiceSettingsChangeHandler:n,selected:r,valid:o})=>{const s=e[r],l={text:d.jsxs(d.Fragment,{children:[d.jsx(UL,{onChange:n,languageId:e.language,gender:e.gender,voiceId:e.voice}),d.jsx(yn,{errorText:A(N.ERROR_VALUE_IS_REQUIRED),inputMode:"text",label:A(N.TEXT),name:r,onChange:t,placeholder:A(N.WRITE_SOMETHING),valid:o,value:s})]}),url:d.jsx(yn,{errorText:A(N.ERROR_URL_IS_REQUIRED),inputMode:"url",label:A(N.AUDIO_FILE),name:r,onChange:t,placeholder:A(N.ENTER_URL),valid:o,value:s})}[r];return d.jsx(d.Fragment,{children:l})},jL=[{field:"stereo",subtitle:N.STEREO_SUBTITLE,title:N.STEREO},{field:"beep",subtitle:N.BEEP_SUBTITLE,title:N.BEEP}],_v=({handleOnUpdate:e,nodeData:t,type:n})=>{const{validateField:r}=at("record"),[o,s]=O.useState({beep:!0,endSilenceTimeout:t.initial||r("endSilenceTimeout",t.endSilenceTimeout),format:!0,initialTimeout:t.initial||r("initialTimeout",t.initialTimeout),maxLength:t.initial||r("maxLength",t.maxLength),stereo:!0,terminators:t.initial||r("terminators",t.terminators)});t.format||e({format:"mp3"});const i=a=>{const c=a.target.name;e({[c]:!t[c]})},l=a=>{const c=a.target,{name:u,value:f}=c;switch(u){case"endSilenceTimeout":case"format":case"initialTimeout":case"maxLength":case"terminators":s({...o,[u]:r(u,f)}),e({initial:!1,[u]:f});break;default:throw new Error(`Unhandled input name: ${u}`)}};return d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"mb-2",children:jL.map(a=>{const c=t[a.field];return d.jsx("div",{children:d.jsx(Ta,{checked:c,clickHandler:i,name:a.field,subtitle:A(a.subtitle),title:A(a.title)})},a.field)})}),d.jsxs("label",{className:"mb-2 block",children:[A(N.TERMINATORS),d.jsx("span",{className:"block text-xxs text-foreground/50",children:A(N.SEPARATE_WITH_COMMAS)}),d.jsx("input",{className:`w-full ${o.terminators?"":"invalid"}`,name:"terminators",onChange:l,placeholder:"#*0",type:"text",value:t.terminators}),d.jsx("p",{className:"requirements",role:"alert",children:A(N.ERROR_TERMINATORS)})]}),n==="voicemail"&&d.jsxs(d.Fragment,{children:[d.jsxs("label",{className:"mb-2 block",children:[d.jsx("div",{className:"w-full",children:A(N.MAXIMUM_RECORDING_LENGTH)}),d.jsxs("div",{className:"flex flex-wrap items-center gap-x-2",children:[d.jsx("input",{className:`w-14 ${o.maxLength?"":"invalid"}`,inputMode:"numeric",min:zo.MIN,max:zo.MAX,name:"maxLength",onChange:l,placeholder:A(N.SECONDS),type:"number",value:t.maxLength}),d.jsx("p",{className:"requirements w-full",role:"alert",children:A(N.ERROR_NUMBER_MIN_MAX_IS_REQUIRED,{max:zo.MAX,min:zo.MIN})})]})]}),d.jsxs("label",{className:"mb-2 block",children:[d.jsx("div",{className:"w-full",children:A(N.INITIAL_TIMEOUT)}),d.jsxs("div",{className:"flex flex-wrap items-center gap-x-2",children:[d.jsx("input",{className:`w-14 ${o.initialTimeout?"":"invalid"}`,inputMode:"numeric",min:Ee.MIN,max:Ee.MAX,name:"initialTimeout",onChange:l,placeholder:A(N.SECONDS),type:"number",value:t.initialTimeout}),d.jsx("p",{className:"requirements w-full",role:"alert",children:A(N.ERROR_NUMBER_MIN_MAX_IS_REQUIRED,{max:Ee.MAX,min:Ee.MIN})})]})]}),d.jsxs("label",{className:"mb-2 block",children:[d.jsx("div",{className:"w-full",children:A(N.END_SILENCE_TIMEOUT)}),d.jsxs("div",{className:"flex flex-wrap items-center gap-x-2",children:[d.jsx("input",{className:`w-14 ${o.endSilenceTimeout?"":"invalid"}`,inputMode:"numeric",min:Ee.MIN,max:Ee.MAX,name:"endSilenceTimeout",onChange:l,placeholder:A(N.SECONDS),type:"number",value:t.endSilenceTimeout}),d.jsx("p",{className:"requirements w-full",role:"alert",children:A(N.ERROR_NUMBER_MIN_MAX_IS_REQUIRED,{max:Ee.MAX,min:Ee.MIN})})]})]})]}),d.jsxs(Zt,{className:"w-full",label:A(N.FORMAT),name:"format",onChange:l,value:t.format,children:[d.jsx("option",{value:"mp3",children:"MP3"}),d.jsx("option",{value:"wav",children:"WAV"})]})]})},Ze=({children:e,formRef:t,handleOnChange:n=()=>null,title:r})=>d.jsxs("div",{className:"flex flex-col overflow-hidden","data-testid":"cfb__settings",children:[d.jsxs("div",{className:"flex w-full items-center justify-start gap-x-2 px-4 pb-3",children:[d.jsx("div",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-focus/30 text-primary",children:d.jsx(re,{tag:"circle-small"})}),d.jsx("div",{className:"flex-1",children:d.jsx("h2",{className:"text-xs font-semibold",children:r})})]}),d.jsx("form",{className:"flex h-full flex-col overflow-hidden text-xs",noValidate:!0,onChange:n,ref:t,children:d.jsx("div",{className:"flex-1 overflow-y-auto pt-1 pb-4",children:e})})]}),VL=({nodeData:e,handleOnUpdate:t})=>{const{validateField:n}=at("aiAgent"),[r,o]=O.useState({agent:e.initial||n("agent",e.agent)}),s=en(y=>y.aiAgentMap.values()),i=en(y=>y.error),l=en(y=>y.status),{fetchAiAgents:a}=U2();O.useEffect(()=>{a()},[a]);const c=Array.from(s),u=l==="loading",f=!!i||l==="error",p=f||l==="initial",h=y=>{const v=y.target,{name:m,value:g}=v;o({...r,[m]:n(m,g)}),t({initial:!1,[m]:g})},E=O.useId();return d.jsx(Ze,{title:A(N.AI_AGENT),children:d.jsx("div",{className:"mx-3",children:!f&&c.length?d.jsxs("div",{className:"relative",children:[d.jsxs(Zt,{id:E,className:`${r.agent?"":"invalid"}`,disabled:p,label:A(N.AI_AGENT_NAME),name:"agent",onChange:h,value:e.agent,children:[d.jsx("option",{value:"",children:A(N.SELECT)}),c.map(y=>d.jsx("option",{value:y.id,children:y.display_name},y.id))]}),d.jsx(Sv,{className:"absolute top-0 right-0 mx-1",handleClickResync:a,isLoading:u}),e.agent&&d.jsx("p",{children:d.jsx(xv,{agent:e.agent,mode:"edit",className:"mb-2",children:A(N.EDIT_SELECTED_AI_AGENT)})})]}):d.jsxs("div",{className:"flex items-end justify-between",children:[d.jsx("p",{role:"alert",className:"text-negative",children:f?d.jsx(d.Fragment,{children:A(N.ERROR_FETCHING_AI_AGENTS)}):d.jsxs(d.Fragment,{children:[A(N.ERROR_ADD_AI_AGENT_FIRST),d.jsx(xv,{mode:"add",className:"mt-2 block",children:A(N.ADD_AI_AGENT)})]})}),d.jsx(Sv,{className:"mx-1",handleClickResync:a,isLoading:u})]})})})},Sv=({className:e="",isLoading:t,handleClickResync:n})=>d.jsx(Zn,{placement:"bottom-end",trigger:d.jsxs("button",{className:`overflow-hidden ${t?"text-disabled":""} ${e}`,disabled:t,onClick:n,type:"button",children:[d.jsx(re,{className:`${t?"animate-spin":""}`,tag:"arrows-rotate"}),d.jsx("span",{className:"sr-only",children:A(N.RESYNC_AI_AGENTS)})]}),children:d.jsx("p",{className:"text-sm",children:A(N.RESYNC_AI_AGENTS)})}),xv=({agent:e="",children:t,className:n="",mode:r})=>{const o={add:"",edit:`${e}/edit`};return d.jsx("a",{className:`w-fit text-foreground underline hover:text-foreground/80 ${n}`,href:`/ai_agents/${o[r]}`,target:"_blank",rel:"noopener noreferrer",children:t})},$L=["GET","POST","PUT","DELETE"],HL=({nodeData:e,handleOnUpdate:t})=>{const{validateField:n}=at("condRequest"),[r,o]=O.useState({body:e.initial||n("body",e.body),headers:e.initial||n("headers",e.headers),method:e.initial||n("method",e.method),saveVariables:e.initial||n("saveVariables",e.saveVariables),url:e.initial||n("url",e.url)}),s=a=>{const c=a.target,{name:u,value:f}=c;switch(t({initial:!1}),u){case"url":case"method":o({...r,[u]:n(u,f)}),t({[u]:f});break;case"headers":o({...r,[u]:n(u,f)}),t({[u]:f});break;case"body":o({...r,[u]:n(u,f)}),t({[u]:f});break;default:throw new Error(`Unhandled input name: ${u}`)}},i=a=>{const{name:c,value:u}=a.target;t({[c]:u})},l=a=>{const{name:c}=a.target,u=!e[c];t({[c]:u})};return d.jsxs(Ze,{title:A(N.REQUEST),children:[d.jsxs("div",{className:"border-b-4 border-foreground/10 px-3",children:[d.jsxs("label",{className:"mb-2 block",children:[A(N.URL),d.jsx("input",{className:`w-full ${r.url?"":"invalid"}`,name:"url",onChange:s,placeholder:"https://u:p@example.com/api/status",type:"text",value:e.url}),d.jsx("p",{className:"requirements w-full",role:"alert",children:A(N.ERROR_VALUE_IS_REQUIRED)})]}),d.jsx("div",{className:"mb-1",children:d.jsx(Zt,{className:"w-full",label:A(N.METHOD),name:"method",onChange:i,value:e.method,children:$L.map(a=>d.jsx("option",{value:a,children:a},a))})}),d.jsx("div",{className:"mb-4",children:d.jsx(Ta,{checked:e.saveVariables,clickHandler:l,name:"saveVariables",subtitle:A(N.SAVE_VARIABLES_SUBTITLE),title:A(N.SAVE_VARIABLES)})}),d.jsx("label",{className:"mb-2 block",children:d.jsx(yn,{errorText:A(N.ERROR_INVALID_JSON),inputMode:"text",label:A(N.REQUEST_HEADERS),name:"headers",onChange:s,placeholder:'{"Content-Type": "application/json", "X-Custom-Header": "foo"}',valid:r.headers,value:e.headers})}),d.jsx("label",{className:"mb-2 block",children:d.jsx(yn,{errorText:A(N.ERROR_INVALID_JSON),inputMode:"text",label:A(N.REQUEST_BODY),name:"body",onChange:s,placeholder:A(N.STRING_OR_JSON),valid:r.body,value:e.body??""})})]}),d.jsx(jf,{nodeData:e,handleOnUpdate:t})]})},BL=({nodeData:e,handleOnUpdate:t})=>{const n=O.useRef();return d.jsx(Ze,{formRef:n,title:A(N.CONDITIONS),children:d.jsx("div",{children:d.jsx(jf,{nodeData:e,handleOnUpdate:t})})})},zL=({nodeData:e,handleOnUpdate:t})=>{const{validateField:n}=at("executeSWML"),[r,o]=O.useState({dest:e.initial||n("dest",e.dest),meta:e.initial||n("meta",e.meta),params:e.initial||n("params",e.params)}),s=i=>{const l=i.target,{name:a,value:c}=l;switch(t({initial:!1}),a){case"dest":case"params":case"meta":o({...r,[a]:n(a,c)}),t({[a]:c});break;default:throw new Error(`Unhandled input name: ${a}`)}};return d.jsxs(Ze,{title:A(N.EXECUTE_SWML),children:[d.jsxs("div",{className:"border-b-4 border-foreground/10 px-3",children:[d.jsxs("label",{className:"mb-2 block",children:[A(N.URL),d.jsx("input",{className:`w-full ${r.dest?"":"invalid"}`,name:"dest",onChange:s,placeholder:"https://u:p@test.com/go.swml",type:"text",value:e.dest}),d.jsx("p",{className:"requirements w-full",role:"alert",children:A(N.ERROR_VALUE_IS_REQUIRED)})]}),d.jsx("label",{className:"mb-2 block",children:d.jsx(yn,{errorText:A(N.ERROR_INVALID_JSON),inputMode:"text",label:A(N.PARAMS),name:"params",onChange:s,placeholder:'{"Content-Type": "application/json", "X-Custom-Header": "foo"}',valid:r.params,value:e.params??""})}),d.jsx("label",{className:"mb-2 block",children:d.jsx(yn,{errorText:A(N.ERROR_INVALID_JSON),inputMode:"text",label:A(N.META),name:"meta",onChange:s,placeholder:A(N.JSON_OBJECT),valid:r.meta,value:e.meta??""})})]}),d.jsx(jf,{nodeData:e,handleOnUpdate:t,placeholder:"return_value === '1'"})]})},Rv=(e,t)=>{O.useEffect(()=>{var o;const n=(o=e.current)==null?void 0:o.getRootNode(),r=s=>{var l;const i=s.target;i instanceof Node&&!((l=e.current)!=null&&l.contains(i))&&t(s)};return n&&n.addEventListener("pointerdown",r),()=>{n&&n.removeEventListener("pointerdown",r)}},[e,t])},$f=e=>{const[t,n]=O.useReducer((r,o)=>({...r,...o}),e);return[t,n]},WL=Ne(),GL=({enable:e,searchParams:t})=>{const n=_n(f=>f.results),r=_n(f=>f.status),o=_n(f=>f.error),{buildParamsFromQuery:s,buildQueryFromParams:i,getCachedResults:l,fetchSwmlScript:a,setResults:c}=dv(),u=i(t);return O.useEffect(()=>{if(!e)return;const f=l(u);f&&c(f);const p=s(u),h=setTimeout(()=>{a(p).catch(E=>{WL.error("Error fetching swml scripts",E)})},W0);return()=>clearTimeout(h)},[s,i,e,a,l,u,c]),[n,r,o]},Hf=e=>e==="external",YL={externalValue:"",focusedId:"",focusedName:"",open:!1,query:""},KL=({confirmId:e,confirmName:t,confirmUrl:n,onChange:r,valid:o})=>{var B;const s={displayName:A(N.EXTERNAL_URL),id:"external"},i=O.useRef(null),l=O.useRef(null),a=O.useRef(null),c=O.useRef({}),u=O.useId(),f=O.useId(),p=O.useId(),[h,E]=$f({...YL,externalValue:Hf(e)?n:"",query:t??""}),y=Hf(e),v=h.query===""||h.query.toLocaleLowerCase()===t.toLocaleLowerCase(),[m,g]=GL({enable:h.open&&!h.focusedName,searchParams:{name:v?"":h.query}}),S=[{displayName:A(N.EXTERNAL_URL),id:s.id},...m],_=v?S:m,x=()=>E({focusedId:"",focusedName:""}),R=W=>{E({open:!0,query:W.target.value}),x()},T=W=>{E({externalValue:W.target.value}),r({connectConfirmDisplayName:s.displayName,connectConfirmId:s.id,connectConfirmUrl:W.target.value})},L=()=>{E({focusedId:e,open:!0}),j()},P=()=>{E({open:!1}),x()},I=()=>h.open?P():L(),j=()=>{var W;(W=l.current)==null||W.focus()},V=W=>{const z=J0(S,"id",W);E({query:z.displayName});const Y=X=>"requestUrl"in X?X.requestUrl:h.externalValue;r({connectConfirmDisplayName:z.displayName,connectConfirmId:z.id,connectConfirmUrl:Y(z)}),P()},M=W=>{j(),V(W)},w=W=>{const z=h.focusedId||e||"",Y=CA(W,z,_),X=Y&&c.current[Y==null?void 0:Y.id];if(X){X==null||X.focus({preventScroll:!0}),X==null||X.scrollIntoView({block:"nearest"});const Z=J0(S,"id",X.id);E({focusedId:Z.id,focusedName:Z.displayName}),l.current&&(l.current.value=Z.displayName)}else j();h.open||L()},b=()=>{c.current[h.focusedId]&&V(h.focusedId)},k=()=>{h.query!==t&&E({query:t}),P()},F=W=>{const{key:z}=W;switch(z){case"ArrowDown":case"ArrowUp":W.preventDefault(),w(z),j();break;case"Enter":W.preventDefault(),b();break;case"Escape":W.preventDefault(),k();break}};O.useEffect(()=>{y&&a.current&&a.current.focus()},[y]),Rv(i,P);const C=h.open&&!_.length,D=g==="loading"&&C,U=g==="error",$=t&&e===""&&n==="";return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:`relative mb-2 block ${U?"after:border-t-foreground/40":"after:border-t-foreground"}`,ref:i,children:[d.jsx("label",{className:"block pb-1 font-medium",id:f,htmlFor:u,children:A(N.HANDLE_VIA)}),d.jsxs("div",{className:"relative pb-1",children:[d.jsx("input",{"aria-activedescendant":h.open?h.focusedId:void 0,"aria-invalid":C,"aria-autocomplete":"list","aria-controls":h.open?u:void 0,"aria-expanded":h.open,"aria-labelledby":f,autoComplete:"off",className:`${U||$?"invalid":""} rounded-md border border-foreground !p-2 !pr-8`,disabled:U,onChange:R,onClick:L,onKeyDown:F,placeholder:h.open?A(N.SEARCH_FOR_INTERNAL_SCRIPT):A(N.EXTERNAL_OR_INTERNAL_RESOURCE),ref:l,role:"combobox",type:"text",value:h.focusedName||h.query}),d.jsxs("button",{"aria-controls":h.open?u:void 0,"aria-expanded":h.open,"aria-haspopup":"listbox","aria-labelledby":`${f} ${p}`,className:`${h.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:U,id:p,onClick:I,tabIndex:-1,type:"button",children:[D&&d.jsx(re,{className:"absolute top-3 right-7 animate-spin",tag:"arrows-rotate",size:"xs"}),d.jsx("span",{className:"sr-only",children:A(h.open?N.TOGGLE_CLOSE:N.TOGGLE_OPEN)})]}),d.jsxs("p",{className:"requirements w-full",role:"alert",children:[$&&A(N.SCRIPT_NOT_FOUND),U&&A(N.ERROR_FETCHING_SWML_SCRIPTS)]})]}),!U&&h.open&&d.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":f,id:u,role:"listbox",onKeyDown:F,children:_.length?d.jsxs(d.Fragment,{children:[_.length===1&&Hf((B=_==null?void 0:_[0])==null?void 0:B.id)&&(g==="loaded"||g==="loading")&&d.jsx(Bf,{displayName:A(g==="loading"?N.STATUS_LOADING:N.NO_SCRIPTS_FOUND)}),_.map(({displayName:W,id:z},Y)=>{const X=e===z,Z=h.focusedId?h.focusedId===z:Y===0;return d.jsx(Bf,{active:X,focus:Z,displayName:W,handleOnClick:()=>M(z),id:z,ref:J=>c.current[z]=J},z)})]}):d.jsx(Bf,{displayName:A(D?N.STATUS_LOADING:N.NO_RESULTS)})})]}),y&&d.jsxs("label",{className:"mb-2 block",children:[d.jsx("span",{className:"sr-only",children:A(N.EXTERNAL_OPTION_LABEL)}),d.jsxs("div",{className:"flex flex-wrap items-center gap-x-2",children:[d.jsx("input",{className:`w-14 ${o?"":"invalid"}`,inputMode:"url",name:"connectConfirmUrl",onChange:T,placeholder:A(N.ENTER_URL),ref:a,type:"url",value:h.externalValue}),d.jsx("p",{className:"requirements w-full",role:"alert",children:A(N.ERROR_URL_IS_REQUIRED)})]})]}),!m.length&&!y&&d.jsx("div",{className:"mb-2",children:d.jsx("p",{children:d.jsx(XL,{children:A(N.ADD_SWML_SCRIPTS)})})})]})},Bf=O.forwardRef(function({active:t,displayName:n,focus:r,handleOnClick:o,id:s},i){const l=!!o,a=l?`cursor-pointer transition-colors hover:bg-primary/5 focus:bg-primary/5 aria-selected:bg-primary/20 ${r?"bg-primary/5":""}`:"";return d.jsx("li",{"aria-selected":t,className:`relative select-none bg-background py-1 px-3 text-xs leading-6 ${a}`,id:s,onClick:o,ref:i,role:l?"option":"presentation",tabIndex:-1,children:n})}),XL=({children:e,className:t=""})=>d.jsx("a",{className:`w-fit text-foreground underline hover:text-foreground/80 ${t}`,href:"/relay-bins",target:"_blank",rel:"noopener noreferrer",children:e}),QL=({confirmId:e,confirmName:t,confirmUrl:n,enabled:r,handleOnChange:o,onCheck:s,valid:i})=>{const l=O.useId(),{validateCache:a}=dv();return O.useEffect(()=>{r&&a()},[r,a]),d.jsxs(d.Fragment,{children:[d.jsx(Ta,{"aria-controls":l,"aria-expanded":r,checked:r,clickHandler:s,name:"connectConfirmEnabled",subtitle:A(N.SWML_TO_EXECUTE),title:A(N.ENABLE_WHISPER)}),r&&d.jsx("div",{id:l,children:d.jsx(KL,{onChange:o,confirmId:e,confirmName:t,confirmUrl:n,valid:i})})]})},qL={forwardAddress:{add:N.ADD_ADDRESS,call:N.CALL_ADDRESSES,optionNumber:N.ADDRESS_NUMBER,remove:N.REMOVE_ADDRESS,title:N.FORWARD_TO_ADDRESS},forwardPhone:{add:N.ADD_PHONE_NUMBER,call:N.CALL_NUMBERS,optionNumber:N.PHONE_NUMBER_NUMBER,remove:N.REMOVE_PHONE_NUMBER,title:N.FORWARD_TO_PHONE},forwardResource:{add:N.ADD_RESOURCE,call:N.CALL_RESOURCES,optionNumber:N.RESOURCE_NUMBER,remove:N.REMOVE_RESOURCE,title:N.FORWARD_TO_RESOURCE}},Nv={parallel:N.SIMULTANEOUSLY,serial:N.SEQUENTIALLY},JL=()=>({connectConfirmDisplayName:"",connectConfirmEnabled:!1,connectConfirmId:"",connectConfirmUrl:"",connectFrom:"",connectTimeout:"",connectTo:"",id:le()}),zf=({nodeType:e,nodeData:t,handleOnUpdate:n})=>{var S,_,x;const{validateField:r}=at(e),o=O.useRef(),[s,i]=O.useState(["serial","parallel"].includes(t.callOrder)?t.callOrder:"serial"),l=qL[e],[a,c]=O.useState({callOrder:t.initial||r("callOrder",s),callStateEvents:t.initial||r("callStateEvents",s),callStateUrl:t.initial||r("callStateUrl",s),connections:(S=t.connections)==null?void 0:S.map(R=>({connectConfirmId:r("connectConfirmId",R.connectConfirmId),connectConfirmUrl:r("connectConfirmUrl",R.connectConfirmUrl),connectFrom:r("connectFrom",R.connectFrom),connectTimeout:r("connectTimeout",R.connectTimeout),connectTo:r("connectTo",R.connectTo),initial:t.initial})),defaultFrom:t.initial||r("defaultFrom",t.defaultFrom),defaultTimeout:t.initial||r("defaultTimeout",t.defaultTimeout)}),u=R=>{R.preventDefault(),c({...a,connections:[...a.connections,{connectConfirmId:!0,connectConfirmUrl:!0,connectFrom:!0,connectTimeout:!0,connectTo:!0,initial:!0}]}),n({callOrder:s,connections:[...t.connections,JL()]})},f=R=>T=>{T.preventDefault();const L=[...a.connections];L.splice(R,1),c({...a,connections:L});const P=[...t.connections];P.splice(R,1),n({callOrder:P.length===1?"single":s,connections:P})},p=(R,T,L)=>{const P=[...t.connections],I=P[R];if(!I)throw new Error(`Option not found at index ${R}`);const j=T==null?void 0:T.name,V=T==null?void 0:T.value,w={...j?{[j]:V}:{},...L,id:I.id},b=[...a.connections],k=Object.keys(w).reduce((D,U)=>{const $=w[U],B=U;return D[B]=r(U,$),D},{initial:!1}),F=b.map((D,U)=>U===R?{...D,...k}:D);c({...a,connections:F});const C=P.map(D=>D.id===w.id?{...D,...w}:D);n({connections:C,initial:!1})},h=R=>{const T=R.currentTarget.value;i(T),n({callOrder:T})},E=(R,T)=>{p(R,void 0,T)},y=(R,T)=>{E(R,{connectConfirmEnabled:T})},v=R=>T=>E(R,{...T}),m=(R,T)=>{const L=R.target,{name:P,value:I}=L;switch(P){case"callStateEvents":case"callStateUrl":case"defaultTimeout":case"defaultFrom":c({...a,[P]:r(P,I)}),n({initial:!1,[P]:I});break;case"connectFrom":case"connectTimeout":case"connectTo":if(T===void 0)throw new Error(`Option index not provided: ${P}`);p(T,{name:P,value:I});break;default:throw new Error(`Unhandled input name: ${P}`)}},g=({index:R,name:T})=>{const L=a.connections[R];return!!(L!=null&&L[T]||L!=null&&L.initial)};return d.jsxs(Ze,{title:A(l.title),formRef:o,children:[d.jsxs("div",{className:"border-b-4 border-foreground/10 px-3 pb-3",children:[d.jsxs("label",{className:"mb-2 block",children:[A(N.DEFAULT_FROM),d.jsx(pi,{className:"w-full",direction:"from",name:"defaultFrom",onChange:m,placeholder:A(N.FROM),type:"tel",value:t.defaultFrom,valid:a.defaultFrom}),d.jsx("p",{className:"requirements w-full",role:"alert",children:A(N.ERROR_VALUE_IS_REQUIRED)})]}),d.jsxs("label",{className:"mb-2 block",children:[A(N.DEFAULT_TIMEOUT),d.jsxs("div",{className:"flex flex-wrap items-center gap-x-2",children:[d.jsx("input",{className:`w-14 ${a.defaultTimeout?"":"invalid"}`,inputMode:"numeric",min:0,name:"defaultTimeout",onChange:m,placeholder:A(N.SECONDS),type:"number",value:t.defaultTimeout}),d.jsx("p",{className:"requirements w-full",role:"alert",children:A(N.ERROR_NUMBER_IS_REQUIRED)})]})]}),d.jsxs("label",{className:"mb-2 block",children:[A(N.CALL_STATE_URL),d.jsx("input",{className:`w-full ${a.callStateUrl?"":"invalid"}`,name:"callStateUrl",onChange:m,placeholder:"https://example.com/api",type:"url",value:t.callStateUrl}),d.jsx("p",{className:"requirements w-full",role:"alert",children:A(N.ERROR_VALUE_IS_REQUIRED)})]}),d.jsxs("label",{className:"mb-2 block",children:[A(N.CALL_STATE_EVENTS),d.jsx("input",{className:`w-full ${a.callStateEvents?"":"invalid"}`,name:"callStateEvents",onChange:m,placeholder:"Created, ringing, answered, ended",type:"text",value:t.callStateEvents}),d.jsx("p",{className:"requirements w-full",role:"alert",children:A(N.ERROR_VALUE_IS_REQUIRED)})]})]}),d.jsx("ul",{className:"border-foreground-10 divide-y-4 divide-foreground/10 border-b-4 pt-2",children:(_=t.connections)==null?void 0:_.map((R,T,L)=>d.jsx("li",{className:"flex flex-col gap-y-2 px-4",children:d.jsxs("fieldset",{children:[d.jsxs("div",{className:"item-center flex justify-between py-4",children:[d.jsxs("legend",{children:[d.jsx(re,{className:"pr-2 text-foreground/60",size:"xs",tag:"bars"}),d.jsx("span",{className:"text-xs font-semibold",children:A(l.optionNumber,{index:T+1})})]}),L.length>1&&d.jsx(Uo,{handleDelete:f(T),label:A(l.remove,{index:T+1}),size:"sm",show:!0})]}),d.jsxs("label",{className:"mb-1 block pl-2",children:[d.jsx("div",{className:"sr-only",children:A(N.TO)}),d.jsx(pi,{className:"w-full",direction:"to",name:"connectTo",onChange:P=>m(P,T),type:e==="forwardPhone"?"tel":"text",valid:g({index:T,name:"connectTo"}),value:R.connectTo}),d.jsx("p",{className:"requirements",role:"alert",children:A(N.ERROR_VALUE_IS_REQUIRED)})]}),d.jsxs("label",{className:"mb-2 block pl-2",children:[d.jsx("div",{className:"sr-only",children:A(N.FROM)}),d.jsx(pi,{className:"w-full",direction:"from",name:"connectFrom",onChange:P=>m(P,T),placeholder:A(N.FROM),type:"text",valid:g({index:T,name:"connectFrom"}),value:R.connectFrom}),d.jsx("p",{className:"requirements",role:"alert",children:A(N.ERROR_VALUE_IS_REQUIRED)})]}),d.jsxs("label",{className:"mb-2 block pl-2",children:[A(N.TIMEOUT),d.jsxs("div",{className:"flex flex-wrap items-center gap-x-2",children:[d.jsx("input",{className:`${g({index:T,name:"connectTimeout"})?"":"invalid"}`,inputMode:"numeric",min:0,name:"connectTimeout",onChange:P=>m(P,T),placeholder:A(N.SECONDS),type:"number",value:R.connectTimeout}),d.jsx("p",{className:"requirements w-full",role:"alert",children:A(N.ERROR_NUMBER_IS_REQUIRED)})]})]}),d.jsx("div",{className:"mb-2 block pl-2",children:d.jsx(QL,{confirmId:R.connectConfirmId,confirmName:R.connectConfirmDisplayName,confirmUrl:R.connectConfirmUrl,enabled:R.connectConfirmEnabled,handleOnChange:v(T),onCheck:()=>y(T,!R.connectConfirmEnabled),valid:g({index:T,name:"connectConfirmUrl"})&&g({index:T,name:"connectConfirmId"})})})]})},R.id))}),d.jsx("div",{className:"p-3 pb-6 text-right",children:d.jsx("button",{className:"rounded bg-foreground/10 py-1 px-2 font-medium",onClick:u,type:"button",children:A(l.add)})}),((x=t.connections)==null?void 0:x.length)>1&&d.jsx("div",{className:"mb-4 px-3",children:d.jsx(Zt,{className:"w-full",label:A(l.call),name:"callOrder",onChange:h,value:s,children:Object.keys(Nv).map(R=>d.jsx("option",{value:R,children:A(Nv[R])},R))})})]})},ZL=()=>({command:"",digit:"",id:le()}),eb=({nodeData:e,handleOnUpdate:t})=>{const{validateField:n}=at("promptPlay"),r=O.useRef(),[o,s]=O.useState({digitTimeout:e.initial||n("digitTimeout",e.digitTimeout),initialTimeout:e.initial||n("initialTimeout",e.initialTimeout),options:e.options.map(h=>({command:n("command",h.command),digit:n("digit",h.digit),initial:e.initial}))}),i=er(e.options,"command"),l=er(e.options,"digit"),a=h=>{h.preventDefault(),s({...o,options:[...o.options,{command:!0,digit:!0,initial:!0}]}),t({options:[...e.options,ZL()]})},c=h=>E=>{E.preventDefault();const y=[...o.options];y.splice(h,1),s({...o,options:y});const v=[...e.options];v.splice(h,1),t({options:v})},u=(h,E)=>{const y=[...e.options];if(!y[h])throw new Error(`Option not found at index ${h}`);const{name:v,value:m}=E,g=[...o.options];g[h]={...g[h],initial:!1,[v]:n(v,m)},s({...o,options:g}),y[h]={...y[h],[v]:m},t({options:y})},f=(h,E)=>{const y=h.target,{name:v,value:m}=y;switch(t({initial:!1}),v){case"digit":case"command":E!==void 0&&u(E,{name:v,value:m});break;case"digitTimeout":case"initialTimeout":{s({...o,[v]:n(v,m)}),t({[v]:m});break}default:throw new Error(`Unhandled input field name: ${v}`)}},p=({index:h,name:E})=>{var m;const y=o.options[h];if(y!=null&&y.initial)return!0;if(!(y!=null&&y[E]))return!1;const v=(m=e.options)==null?void 0:m[h];return yt(v==null?void 0:v.digit)||yt(v==null?void 0:v.command)};return d.jsxs(Ze,{formRef:r,title:A(N.GATHER_INPUT),children:[d.jsx("div",{className:"border-b-4 border-foreground/10 px-3 pb-3",children:d.jsx(vv,{handleOnUpdate:t,label:A(N.CHOOSE_OPTION_TTS_AUDIO),nodeData:e})}),d.jsx("ol",{className:"divide-y-4 divide-foreground/10 border-b-4 border-foreground/10",children:e.options.map((h,E,y)=>{const v=i(h.command),m=l(h.digit);return d.jsxs("li",{className:"flex pt-3",children:[d.jsx("div",{className:"w-8 shrink-0 text-center",children:d.jsx(re,{className:"text-foreground/60",size:"xs",tag:"bars"})}),d.jsxs("div",{className:"relative mr-3",children:[y.length>1&&d.jsx(Uo,{className:"absolute right-0 top-0",handleDelete:c(E),label:A(N.REMOVE_OPTION,{index:E+1}),size:"sm",show:!0}),d.jsxs("fieldset",{children:[d.jsx("legend",{className:"sr-only",children:A(N.OPTION_NUMBER,{index:E+1})}),d.jsxs("label",{className:"mb-2 block",children:[A(N.CALLER_PRESSES),d.jsx("input",{className:`${p({index:E,name:"digit"})&&!m?"":"invalid"}`,name:"digit",onChange:g=>f(g,E),placeholder:A(N.KEYPAD_VALUE),type:"text",value:h.digit}),d.jsx("p",{className:"requirements",role:"alert",children:A(m?N.ERROR_DUPLICATE_TELEPHONE_KEY:N.ERROR_TELEPHONE_KEY_REQUIRED)})]}),d.jsxs("label",{className:"mb-2 block",children:[A(N.OR_SAYS),d.jsx("input",{className:`w-full ${p({index:E,name:"command"})&&!v?"":"invalid"}`,name:"command",onChange:g=>f(g,E),placeholder:A(N.SPOKEN_PROMPT),type:"text",value:h.command}),d.jsx("p",{className:"requirements",role:"alert",children:A(v?N.ERROR_DUPLICATE_COMMAND:N.ERROR_TEXT_IS_REQUIRED)})]})]})]})]},h.id)})}),d.jsx("div",{className:"p-3 pb-6 text-right",children:d.jsx("button",{className:"rounded bg-foreground/10 py-1 px-2 font-medium",onClick:a,type:"button",children:A(N.ADD_OPTION)})}),d.jsxs("div",{className:"px-3",children:[d.jsxs("label",{className:"mb-2 block",children:[d.jsx("div",{className:"w-full",children:A(N.WAIT_FOR_INPUT)}),d.jsxs("div",{className:"flex flex-wrap items-center gap-x-2",children:[d.jsx("input",{className:`w-14 ${o.initialTimeout?"":"invalid"}`,inputMode:"numeric",min:Ee.MIN,max:Ee.MAX,name:"initialTimeout",onChange:f,placeholder:A(N.SECONDS),type:"number",value:e.initialTimeout}),d.jsx("p",{className:"requirements w-full",role:"alert",children:A(N.ERROR_NUMBER_MIN_MAX_IS_REQUIRED,{max:Ee.MAX,min:Ee.MIN})})]})]}),d.jsxs("label",{children:[d.jsx("div",{className:"w-full",children:A(N.WAIT_FOR_DIGIT)}),d.jsxs("div",{className:"flex flex-wrap items-center gap-x-2",children:[d.jsx("input",{className:`w-14 ${o.digitTimeout?"":"invalid"}`,inputMode:"numeric",min:Ee.MIN,max:Ee.MAX,name:"digitTimeout",onChange:f,placeholder:A(N.SECONDS),type:"number",value:e.digitTimeout}),d.jsx("p",{className:"requirements w-full",role:"alert",children:A(N.ERROR_NUMBER_MIN_MAX_IS_REQUIRED,{max:Ee.MAX,min:Ee.MIN})})]})]})]})]})},tb=({handleOnUpdate:e,nodeData:t})=>{const{validateField:n}=at("play"),[r,o]=O.useState({reason:t.initial||n("reason",t.reason)}),s=i=>{const l=i.target,{name:a,value:c}=l;switch(a){case"reason":o({...r,[a]:n(a,c)}),e({initial:!1,[a]:c});break;default:throw new Error(`Unhandled input name: ${a}`)}};return d.jsx(Ze,{title:A(N.HANG_UP_CALL),children:d.jsx("div",{className:"mx-3",children:d.jsxs(Zt,{className:"w-full",label:`${A(N.REASON)} (${A(N.OPTIONAL)})`,name:"reason",onChange:s,value:t.reason,children:[d.jsx("option",{value:"",children:A(N.SELECT)}),Object.keys(Ff).map(i=>d.jsx("option",{value:i,children:A(Ff[i])},i))]})})})},nb=({nodeData:e,handleOnUpdate:t})=>{const n=O.useRef();return d.jsx(Ze,{formRef:n,title:A(N.PLAY_AUDIO_TTS),children:d.jsx("div",{className:"mx-3",children:d.jsx(vv,{handleOnUpdate:t,label:A(N.CHOOSE_OPTION_TTS_AUDIO),nodeData:e,showDefaultOption:!0})})})},rb=({nodeData:e,handleOnUpdate:t})=>{const n=O.useRef(),{validateField:r}=at("recordCallStart"),[o,s]=O.useState({label:e.initial||r("label",e.label)}),[i,l]=O.useState(!1),{upsertEntry:a,isValueDuplicate:c}=If();O.useEffect(()=>{l(c(e.label,e.controlId))},[c,e.controlId,e.label]);const u=f=>{const p=f.target,{name:h,value:E}=p;s({...o,[h]:r(h,E)}),t({initial:!1,[h]:E}),a({controlId:e.controlId,label:E})};return d.jsxs(Ze,{title:A(N.RECORD_CALL_START),formRef:n,children:[d.jsx("div",{className:"px-3 pb-3",children:d.jsxs("label",{children:[A(N.RECORDING_NAME),d.jsx("input",{className:`w-full ${o.label&&!i?"":"invalid"}`,name:"label",onChange:u,type:"text",value:e.label}),d.jsx("p",{className:"requirements",role:"alert",children:A(i?N.ERROR_DUPLICATE_RECORDING_LABEL:N.ERROR_RECORDING_LABEL_REQUIRED)})]})}),d.jsx("div",{className:"px-3",children:d.jsx(_v,{handleOnUpdate:t,nodeData:e,type:"call"})})]})},ob=({nodeData:e,handleOnUpdate:t})=>{const{validateField:n}=at("recordCallStop"),[r,o]=O.useState({controlId:e.initial||n("controlId",e.controlId)}),{getEntries:s}=If(),i=s().sort((a,c)=>a.label.toLowerCase().localeCompare(c.label.toLowerCase())),l=a=>{const c=a.target,{name:u,value:f}=c;o({...r,[u]:n(u,f)}),t({initial:!1,[u]:f})};return d.jsx(Ze,{title:A(N.RECORD_CALL_STOP),children:d.jsx("div",{className:"px-3",children:i.length?d.jsxs(Zt,{className:`w-full ${r.controlId?"":"invalid"}`,label:A(N.RECORDING_NAME),name:"controlId",value:e.controlId,onChange:l,children:[d.jsx("option",{value:"",children:A(N.SELECT)}),i.map(a=>d.jsx("option",{value:a.controlId,children:a.label},a.controlId))]}):d.jsx("p",{role:"alert",className:"text-negative",children:A(N.ERROR_ADD_RECORDING_FIRST)})})})},sb=({nodeData:e,handleOnUpdate:t})=>d.jsx(Ze,{title:A(N.VOICEMAIL_RECORDING),children:d.jsx("div",{className:"mx-3",children:d.jsx(_v,{handleOnUpdate:t,nodeData:e,type:"voicemail"})})}),ib=["GET","POST","PUT","DELETE"],lb=({nodeData:e,handleOnUpdate:t})=>{const{validateField:n}=at("request"),[r,o]=O.useState({body:e.initial||n("body",e.body),headers:e.initial||n("headers",e.headers),method:e.initial||n("method",e.method),saveVariables:e.initial||n("saveVariables",e.saveVariables),url:e.initial||n("url",e.url)}),s=a=>{const c=a.target,{name:u,value:f}=c;switch(t({initial:!1}),u){case"url":case"method":o({...r,[u]:n(u,f)}),t({[u]:f});break;case"headers":o({...r,[u]:n(u,f)}),t({[u]:f});break;case"body":o({...r,[u]:n(u,f)}),t({[u]:f});break;default:throw new Error(`Unhandled input name: ${u}`)}},i=a=>{const{name:c,value:u}=a.target;t({[c]:u})},l=a=>{const{name:c}=a.target,u=!e[c];t({[c]:u})};return d.jsx(Ze,{title:A(N.REQUEST),children:d.jsxs("div",{className:"px-3",children:[d.jsxs("label",{className:"mb-2 block",children:[A(N.URL),d.jsx("input",{className:`w-full ${r.url?"":"invalid"}`,name:"url",onChange:s,placeholder:"https://u:p@example.com/api/status",type:"text",value:e.url}),d.jsx("p",{className:"requirements w-full",role:"alert",children:A(N.ERROR_VALUE_IS_REQUIRED)})]}),d.jsx("div",{className:"mb-1",children:d.jsx(Zt,{className:"w-full",label:A(N.METHOD),name:"method",onChange:i,value:e.method,children:ib.map(a=>d.jsx("option",{value:a,children:a},a))})}),d.jsx("div",{className:"mb-4",children:d.jsx(Ta,{checked:e.saveVariables,clickHandler:l,name:"saveVariables",subtitle:A(N.SAVE_VARIABLES_SUBTITLE),title:A(N.SAVE_VARIABLES)})}),d.jsx("label",{className:"mb-2 block",children:d.jsx(yn,{errorText:A(N.ERROR_INVALID_JSON),inputMode:"text",label:A(N.REQUEST_HEADERS),name:"headers",onChange:s,placeholder:'{"Content-Type": "application/json", "X-Custom-Header": "foo"}',valid:r.headers,value:e.headers})}),d.jsx("label",{children:d.jsx(yn,{errorText:A(N.ERROR_INVALID_JSON),inputMode:"text",label:A(N.REQUEST_BODY),name:"body",onChange:s,placeholder:A(N.STRING_OR_JSON),valid:r.body,value:e.body??""})})]})})},ab=({nodeData:e,handleOnUpdate:t})=>{const{validateField:n}=at("sendSms"),[r,o]=O.useState({body:e.initial||n("body",e.body),fromNumber:e.initial||n("fromNumber",e.fromNumber),toNumber:e.initial||n("toNumber",e.toNumber)}),s=i=>{const l=i.target,{name:a,value:c}=l;switch(a){case"body":case"fromNumber":case"toNumber":o({...r,[a]:n(a,c)}),t({initial:!1,[a]:c});break;default:throw new Error(`Unhandled input name: ${a}`)}};return d.jsx(Ze,{title:A(N.SEND_SMS),children:d.jsxs("div",{className:"mx-3",children:[d.jsxs("label",{className:"mb-2 block",children:[A(N.TO_PHONE_NUMBER),d.jsx(pi,{className:"w-full",direction:"to",name:"toNumber",onChange:s,placeholder:"+12405550000",type:"tel",valid:r.toNumber,value:e.toNumber}),d.jsx("p",{className:"requirements w-full",role:"alert",children:A(N.ERROR_VALUE_IS_REQUIRED)})]}),d.jsxs("label",{className:"mb-2 block",children:[A(N.FROM_PHONE_NUMBER),d.jsx(pi,{className:"w-full",direction:"from",name:"fromNumber",onChange:s,placeholder:"+12405550000",type:"tel",valid:r.fromNumber,value:e.fromNumber}),d.jsx("p",{className:"requirements w-full",role:"alert",children:A(N.ERROR_VALUE_IS_REQUIRED)})]}),d.jsx("label",{children:d.jsx(yn,{errorText:A(N.ERROR_VALUE_IS_REQUIRED),inputMode:"text",label:A(N.SMS_TEXT),name:"body",onChange:s,placeholder:A(N.WRITE_SOMETHING),valid:r.body,value:e.body})})]})})},cb=()=>({id:le(),key:"",value:""}),ub=({nodeData:e,handleOnUpdate:t})=>{var f;const{validateField:n}=at("set"),[r,o]=O.useState({variables:e.variables.map(p=>({key:e.initial||n("key",p.key),value:e.initial||n("value",p.value)}))}),s=er(e.variables,"key"),i=p=>{p==null||p.preventDefault(),o({...r,variables:[...r.variables,{key:!0,value:!0}]}),t({variables:[...e.variables,cb()]})},l=(p,h)=>{const E=[...e.variables];let y=E[p];if(!y)throw new Error(`Variable not found at index ${p}`);const{name:v,value:m}=h,g=[...r.variables];g[p]={...g[p],[v]:n(v,m)},o({...r,variables:g}),y={...E[p],[v]:m},E[p]=y,t({initial:!1,variables:E})},a=p=>h=>{h.preventDefault();const E=[...r.variables];E.splice(p,1),o({...r,variables:E});const y=[...e.variables];y.splice(p,1),t({variables:y})},c=(p,h)=>{const E=p.target,{name:y,value:v}=E;switch(y){case"key":case"value":h!==void 0&&l(h,{name:y,value:v});break;default:throw new Error(`Unhandled input name: ${y}`)}},u=({index:p,name:h})=>{const E=r.variables[p];return E==null?void 0:E[h]};return d.jsxs(Ze,{title:A(N.SET_VARIABLES),children:[d.jsx("ol",{className:"divide-y-4 divide-foreground/10 border-b-4 border-foreground/10",children:(f=e.variables)==null?void 0:f.map((p,h,E)=>{const y=s(p.key);return d.jsxs("li",{className:"flex pt-3",children:[d.jsx("div",{className:"w-8 shrink-0 text-center",children:d.jsx(re,{className:"text-foreground/60",size:"xs",tag:"bars"})}),d.jsxs("div",{className:"relative mr-3",children:[E.length>1&&d.jsx(Uo,{className:"absolute right-0 top-0",handleDelete:a(h),label:A(N.REMOVE_VARIABLE,{index:h+1}),size:"sm",show:!0}),d.jsxs("fieldset",{children:[d.jsx("legend",{className:"sr-only",children:A(N.VARIABLE_NUMBER,{index:h+1})}),d.jsxs("label",{className:"mb-2 block",children:[A(N.KEY),d.jsx("input",{className:`w-full ${u({index:h,name:"key"})&&!y?"":"invalid"}`,name:"key",onChange:v=>c(v,h),type:"text",value:p.key}),d.jsx("p",{className:"requirements",role:"alert",children:A(y?N.ERROR_DUPLICATE_VARIABLE_KEY:N.ERROR_VARIABLE_KEY_REQUIRED)})]}),d.jsxs("label",{className:"mb-2 block",children:[A(N.VALUE),d.jsx("input",{className:`w-full ${u({index:h,name:"value"})?"":"invalid"}`,name:"value",onChange:v=>c(v,h),type:"text",value:p.value}),d.jsx("p",{className:"requirements",role:"alert",children:A(N.ERROR_TEXT_IS_REQUIRED)})]})]})]})]},p.id)})}),d.jsx("div",{className:"p-3 text-right",children:d.jsx("button",{className:"rounded bg-foreground/10 py-1 px-2 font-medium",onClick:i,type:"button",children:A(N.ADD_VARIABLE)})})]})},db=e=>({id:le(),key:e}),fb=({nodeData:e,handleOnUpdate:t})=>{const s={currentFocus:void 0,listOpen:!1,setVariablesList:Q(v=>v.nodes).reduce((v,m)=>{if(m.type==="set"){const g=m.data.variables.map(S=>({id:S.id,key:S.key}));return[...v,...g]}else if(m.type==="unset")return[...v,...m.data.variables];return v},[]).reduce((v,m)=>(v.find(g=>g.key===m.key)||v.push(m),v),[]).map(v=>({...v,selected:!!e.variables.find(m=>m.key===v.key)})).sort((v,m)=>v.key.toLowerCase().localeCompare(m.key.toLowerCase()))},[i,l]=$f(s),a=v=>i.setVariablesList.map(m=>m.id===v?{...m,selected:!m.selected}:m),c=v=>{const m=i.setVariablesList.find(g=>g.id===v);if(!m)throw new Error("Variable not found");if(m.selected)u(m.id);else{const g=[...e.variables,db(m.key)];l({setVariablesList:a(m.id)}),t({variables:g})}},u=v=>{const m=i.setVariablesList.filter(g=>g.selected&&g.id!==v);l({setVariablesList:a(v)}),t({variables:m})},f=O.useRef(null);Rv(f,()=>l({listOpen:!1}));const p=v=>{(v.key==="Escape"||v.key==="Esc")&&l({listOpen:!1})},h=(v,m)=>{v.preventDefault(),(v.key===" "||v.code==="Space"||v.key==="Enter")&&c(m),p(v)},E=()=>{l({listOpen:!i.listOpen})},y=e.variables.length;return d.jsx(Ze,{title:A(N.UNSET_VARIABLES),children:d.jsxs("div",{className:"px-3",children:[d.jsxs("div",{className:"mb-2 flex flex-col",children:[d.jsx("label",{id:"listbox-label",className:"sr-only",children:A(N.SELECT_VARIABLES_TO_UNSET)}),d.jsxs("div",{className:"relative",ref:f,children:[d.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
+ 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:E,onKeyDown:p,type:"button",children:y>0?A(N.NUMBER_OF_VARIABLES_SELECTED,{count:y}):A(N.SELECT_VARIABLES)}),i.listOpen&&d.jsxs("ul",{"aria-activedescendant":i.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:[!i.setVariablesList.length&&d.jsx("li",{"aria-disabled":"true",className:"relative",role:"option",children:d.jsx("label",{className:"flex select-none items-center py-2 pl-3 pr-9",children:A(N.NO_VARIABLES_SET)})}),i.setVariablesList.map(v=>{if(v.key)return d.jsx("li",{"aria-selected":v.selected,className:"relative",id:v.id,role:"option",children:d.jsxs("label",{className:"flex select-none items-center py-2 pl-3 pr-9",children:[d.jsx("input",{checked:v.selected,className:"mr-2 h-4 w-4 rounded accent-primary",onChange:()=>c(v.id),onKeyDown:m=>h(m,v.id),type:"checkbox"}),v.key]})},v.id)})]})]})]}),y>0&&d.jsxs("section",{className:"pt-3",children:[d.jsx("h3",{className:"mb-2 text-xs font-medium text-foreground",children:A(N.UNSET_VARIABLES)}),d.jsx("ul",{className:"flex flex-wrap gap-2",children:i.setVariablesList.map(v=>v.selected&&d.jsx(uC,{handleClick:()=>u(v.id),children:v.key},v.id))})]})]})})},wv={aiAgent:({data:e,formUpdate:t})=>d.jsx(VL,{handleOnUpdate:t,nodeData:e}),cond:({data:e,formUpdate:t})=>d.jsx(BL,{handleOnUpdate:t,nodeData:e}),condRequest:({data:e,formUpdate:t})=>d.jsx(HL,{handleOnUpdate:t,nodeData:e}),executeSWML:({data:e,formUpdate:t})=>d.jsx(zL,{handleOnUpdate:t,nodeData:e}),forwardAddress:({data:e,formUpdate:t})=>d.jsx(zf,{handleOnUpdate:t,nodeData:e,nodeType:"forwardAddress"}),forwardPhone:({data:e,formUpdate:t})=>d.jsx(zf,{handleOnUpdate:t,nodeData:e,nodeType:"forwardPhone"}),forwardResource:({data:e,formUpdate:t})=>d.jsx(zf,{handleOnUpdate:t,nodeData:e,nodeType:"forwardResource"}),hangup:({data:e,formUpdate:t})=>d.jsx(tb,{handleOnUpdate:t,nodeData:e}),play:({data:e,formUpdate:t})=>d.jsx(nb,{handleOnUpdate:t,nodeData:e}),promptPlay:({data:e,formUpdate:t})=>d.jsx(eb,{handleOnUpdate:t,nodeData:e}),record:({data:e,formUpdate:t})=>d.jsx(sb,{handleOnUpdate:t,nodeData:e}),recordCallStart:({data:e,formUpdate:t})=>d.jsx(rb,{handleOnUpdate:t,nodeData:e}),recordCallStop:({data:e,formUpdate:t})=>d.jsx(ob,{handleOnUpdate:t,nodeData:e}),request:({data:e,formUpdate:t})=>d.jsx(lb,{handleOnUpdate:t,nodeData:e}),sendSms:({data:e,formUpdate:t})=>d.jsx(ab,{handleOnUpdate:t,nodeData:e}),set:({data:e,formUpdate:t})=>d.jsx(ub,{handleOnUpdate:t,nodeData:e}),unset:({data:e,formUpdate:t})=>d.jsx(fb,{handleOnUpdate:t,nodeData:e})},pb=(e,t)=>{if("options"in t)switch(e.type){case"promptPlay":case"cond":case"condRequest":return!0}return!1},hb=e=>{if(e in wv)return wv[e]},mb=()=>{var c;const{partialUpdateNodeData:e,removeNode:t}=Te(),n=Q(u=>u.selectedNode),r=n==null?void 0:n.id,s=(c=Q(u=>u.nodes).find(u=>u.id===r))==null?void 0:c.data,{updateDynamicHandles:i}=CL(n);if(!(n&&s&&r))return null;const l=u=>{pb(n,u)&&i(u),e(r,u)},a=hb(n.type);return a?d.jsxs(Zs,{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:[d.jsx(a,{data:s,formUpdate:l},r),n.deletable!==!1&&d.jsx("div",{className:"border-t border-foreground/10 p-3",children:d.jsx(Uo,{handleDelete:()=>t(r),label:A(N.DELETE_NODE),show:!0,showLabel:!0})})]}):null},Ov=O.forwardRef(function({animate:t=!0,children:n,className:r="",iconTag:o="circle-info",message:s,role:i="alertdialog",status:l},a){const u=l?{error:"bg-negative text-background",success:"bg-positive text-background"}[l]:"";return d.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
- ${u} ${t?"animate-from-bottom":""} ${r}`,ref:a,role:i,children:[d.jsxs("div",{className:"flex items-center justify-center gap-x-2",children:[d.jsx(re,{className:"flex-shrink-0 self-start",tag:o}),d.jsx("p",{className:"text-xs font-semibold",children:s})]}),n]})}),hb=()=>{const{addToast:e,restoreDeployedFlow:t,cancelDetachedMode:n}=Te();if(!Q(i=>i.showDeployedHistoryToast))return null;const o=()=>{t(),e({message:A(N.VERSION_RESTORED),status:"success"})},s=()=>{n()};return d.jsx(Ov,{animate:!1,className:"gap-x-14",message:A(N.PREVIEW_DEPLOYED_VERSION),role:"dialog",children:d.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-x-2 gap-y-1",children:[d.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:o,children:A(N.RESTORE_THIS_VERSION)}),d.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:s,children:A(N.CANCEL)})]})})},Tv=({onKeyPress:e})=>{const t=Oo(["Escape","Esc"]);return O.useEffect(()=>{t&&typeof e=="function"&&e()},[t,e]),{isPressed:t}},mb={offset:[0,.5,1],opacity:[1,0,0],pointerEvents:["none","none","auto"],transform:["scale(1.1) translateY(0%)","scale(0.5) translateY(-100%)"]},gb={duration:_A*2,easing:"ease-in-out",fill:"forwards"},Eb=({durationMs:e,id:t,permanent:n})=>{const r=e??SA,[o,s]=O.useState(null),{deleteToast:i}=Te(),l=O.useCallback(()=>{let a;const c=()=>i(t);return o instanceof HTMLElement?(a=o.animate(mb,gb),a.addEventListener("finish",c,{once:!0})):c(),()=>a==null?void 0:a.removeEventListener("finish",c)},[t,i,o]);return Tv({onKeyPress:l}),O.useEffect(()=>{if(n)return;let a,c;const u=()=>{clearTimeout(a)},f=()=>{u(),a=setTimeout(()=>{c=l()},r)};return f(),o instanceof HTMLElement&&(o.addEventListener("mouseenter",u),o.addEventListener("mouseleave",f)),()=>{u(),o instanceof HTMLElement&&(o.removeEventListener("mouseenter",u),o.removeEventListener("mouseleave",f),c==null||c())}},[l,r,n,o]),{deleteToastCallback:l,setToastRef:s,toastRef:o}},Av=({durationMs:e,id:t,message:n,permanent:r,status:o})=>{const{deleteToastCallback:s,setToastRef:i}=Eb({durationMs:e,id:t,permanent:r});return d.jsx(Ov,{className:"w-full max-w-sm",iconTag:o==="success"?"circle-check":"circle-exclamation",message:n,ref:i,status:o,children:d.jsxs("button",{className:"flex-shrink-0 self-start opacity-40 transition-opacity hover:opacity-70",onClick:s,children:[d.jsx(re,{tag:"circle-xmark",size:"xl"}),d.jsx("span",{className:"sr-only",children:A(N.CLOSE)})]})})},yb={error:Av,success:Av},vb=()=>{const e=Q(n=>n.toastsMap);if(e.size===0)return null;const t=Array.from(e.values());return d.jsx("div",{className:"flex w-full flex-col items-center gap-y-1",children:t.map(n=>{const r=yb[n.status];return d.jsx(r,{durationMs:n.durationMs,id:n.id,message:n.message,permanent:n.permanent,status:n.status},n.id)})})},_b=({asRole:e="alert",open:t=!1,type:n="overlay"})=>{const[r,o]=H.useState(t);O.useEffect(()=>{o(t)},[t]);const s=O.useCallback(()=>o(!1),[]),i=O.useCallback(()=>o(!0),[]);return{asRole:e,closeContainer:s,isOpen:r,openContainer:i,type:n}},Iv=O.createContext(null),Wf=()=>{const e=O.useContext(Iv);if(e==null)throw new Error("Toast components must be wrapped in <ToastContainer />");return e},Sb=({children:e,...t})=>{const n=_b(t);return d.jsx(Iv.Provider,{value:n,children:e})},Cv=({iconAs:e,title:t,children:n})=>{const{asRole:r}=Wf();return d.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:r,children:[d.jsxs("h2",{className:"text-lg font-semibold leading-6 tracking-wide",children:[d.jsx("span",{className:"mr-2",children:d.jsx(re,{tag:e??"circle-exclamation"})}),t]}),d.jsx("div",{className:"mt-2 text-sm leading-5",children:n})]})},xb=({children:e})=>{const{closeContainer:t,isOpen:n,type:r}=Wf(),{getRootElement:o}=Te(),s=o(),i=O.useRef(null);return O.useEffect(()=>{if(!i.current)return;let l,a;const c=u=>{var f,p;if(u.key==="Escape"&&t(),u.key==="Tab"){const h=(p=(f=document.activeElement)==null?void 0:f.shadowRoot)==null?void 0:p.activeElement;u.shiftKey?h===l&&(a==null||a.focus(),u.preventDefault()):h===a&&(l==null||l.focus(),u.preventDefault())}};if(r==="overlay"){const u=i.current.querySelectorAll("button");l=u[0],a=u[u.length-1],a==null||a.focus(),document.addEventListener("keydown",c)}return()=>{document.removeEventListener("keydown",c)}},[t,r]),n?Bl.createPortal(d.jsx("section",{className:`flex justify-center ${r==="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:r==="overlay"?i:void 0,children:e}),s):null},Lv=({asRole:e,open:t,children:n,type:r})=>d.jsx(Sb,{asRole:e,open:t,type:r,children:d.jsx(xb,{children:n})}),Rb=()=>{const t=Q(n=>n.httpError)===z0;return t?d.jsx(Lv,{asRole:"dialog",open:t,type:"overlay",children:d.jsx(Cv,{title:A(N.DOCUMENT_OUT_OF_SYNC),children:d.jsx(Nb,{})})}):null},Nb=()=>{const{closeContainer:e}=Wf(),t=()=>{window.location.reload()};return d.jsxs(d.Fragment,{children:[Ua(N.TOAST_DOCUMENT_OUT_OF_SYNC),d.jsxs("div",{className:"mt-11 flex items-center justify-center gap-x-6",children:[d.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:A(N.IGNORE)}),d.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:A(N.RESYNC)})]})]})},wb=Ne(),Ob=()=>{const e=Q(t=>t.showDeployWarning);return d.jsx(Lv,{asRole:"dialog",open:e,type:"overlay",children:d.jsx(Cv,{title:A(N.DEPLOY_WARNING),children:d.jsx(Tb,{})})})},Tb=()=>{const{deployFlow:e,setShowDeployWarning:t,setShowValidationWarnings:n}=Te(),r=()=>{t(!1),n(!0)},o=()=>{t(!1)},s=()=>{e().catch(i=>{wb.error(i)}),o()};return d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"mb-4",children:Ua(N.TOAST_DEPLOY_WARNING)}),d.jsx(Ny,{onClickListItem:r}),d.jsxs("div",{className:"mt-11 flex items-center justify-center gap-x-6",children:[d.jsx("button",{className:"rounded-md border border-background bg-foreground px-3.5 py-2.5 font-bold tracking-widest text-background",onClick:o,children:A(N.CANCEL)}),d.jsx("button",{className:"rounded-md border border-background bg-positive/70 px-3.5 py-2.5 font-bold tracking-widest text-background",onClick:s,children:A(N.DEPLOY)})]})]})},Ab="react-flow__controls-button",Ib="min-w-[3.625rem] cursor-auto select-auto text-center hover:bg-background active:bg-background",Cb="hidden sm:flex",Lb=O.forwardRef(function({asTag:t="div",children:n,className:r="",hiddenSmallScreen:o=!1,...s},i){const l=t,c=`${Ab} ${l==="button"?"":Ib} ${o?Cb:""} ${r}`;return d.jsx(l,{className:c,ref:i,...s,children:n})}),bb=()=>{const e=Q(i=>i.showValidationWarnings),t=Q(i=>i.validationWarnings),n=Q(i=>i.detachedMode),{setShowValidationWarnings:r}=Te(),o=()=>r(!e),s=()=>{e&&r(!1)};return!t.size||n?(s(),null):d.jsx(Zn,{onOpenChange:r,open:e,outsidePress:!1,placement:"bottom-start",role:"dialog",trigger:d.jsxs(Lb,{className:"text-xs",asTag:"button",onClick:o,hiddenSmallScreen:!0,children:[A(N.WARNING),d.jsxs("div",{className:"flex items-center justify-center pl-1",children:[d.jsx("span",{className:"sr-only",children:A(N.MORE_INFO_STATUS_ERROR)}),d.jsx(re,{className:"text-warning",tag:"circle-exclamation"})]})]}),children:d.jsx(Ny,{children:d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsxs("h2",{className:"text-xs font-semibold",children:[d.jsx(re,{className:"mr-1",tag:"circle-exclamation"}),A(N.CAUTION)]}),d.jsxs("button",{className:"my-0.5 rounded-md py-0.5 px-1.5",onClick:s,children:[d.jsx("span",{className:"sr-only",children:A(N.CLOSE)}),d.jsx(re,{tag:"xmark",size:"lg"})]})]})})})},Db=()=>{const e=Q(r=>r.isDraggingNode),t=Q(r=>r.showInteractiveControl),n=r=>{Q.setState({isInteractiveControlOn:r})};return d.jsx(rA,{className:`mt-2.5 rounded-[0.25rem] ${e?"group/control-buttons":""}`,position:"top-left",onInteractiveChange:n,showInteractive:t,children:d.jsx(bb,{})})},kb=".react-flow__panel",Pb=16,bv={cursor:"no-drop",transform:"translate(0px, 0px) scale(1)",visibility:"hidden",zIndex:"5"},Dv=e=>{const t=e.getBoundingClientRect();return{isCursorIntersecting:({clientX:n,clientY:r})=>t.top<=r&&t.bottom>=r&&t.left<=n&&t.right>=n}},Mb=e=>{const t=e.querySelectorAll(kb);return Array.from(t).map(n=>Dv(n).isCursorIntersecting)},Ub=e=>({resetDragNodeStyles:()=>{Object.entries(bv).forEach(([t,n])=>{e.style[t]=n})},updateDragNodeStyles:({isOverDropTarget:t,scale:n,xPos:r,yPos:o})=>{e.style.visibility="visible",e.style.cursor=t?"grabbing":"no-drop",e.style.transform=`translate(${r}px, ${o}px) scale(${n})`}}),Fb=({handleMouseMove:e,handleMouseUp:t,root:n})=>(n.addEventListener("mousemove",e),n.addEventListener("mouseup",t),{removeListeners:()=>{n.removeEventListener("mousemove",e),n.removeEventListener("mouseup",t)}}),jb=()=>{const e=O.useRef(null),t=Q(p=>p.dragNodeType),n=Q(p=>p.flowWrapperElement),r=Q(p=>p.viewport.zoom),{addNode:o,getRootElement:s,setDragNodeType:i}=Te(),l=s();if(O.useEffect(()=>{if(e.current&&t&&n&&l){let p=!1;const h=Pb*r,E=e.current,y=Dv(n).isCursorIntersecting,v=Mb(n),{resetDragNodeStyles:m,updateDragNodeStyles:g}=Ub(E),{removeListeners:S}=Fb({handleMouseMove:_=>{const{clientX:x,clientY:R}=_,T=x-h,L=R-h;p=y({clientX:x,clientY:R})&&!v.some(P=>P({clientX:x,clientY:R})),g({isOverDropTarget:p,scale:p?r:1,xPos:T,yPos:L})},handleMouseUp:_=>{if(p){const x=n.getBoundingClientRect();o({nodeType:t,x:_.clientX-x.left-h,y:_.clientY-x.top-h})}i(void 0)},root:l});return()=>{S(),m()}}},[o,t,n,l,i,r]),!t)return null;const a=gv[t],c=Z0[t](),u=le(),f={...c,initial:!1,valid:!0};return d.jsx("section",{className:"react-flow__node fixed left-0 top-0",ref:e,style:bv,children:d.jsx(a,{data:f,dragging:!0,id:u,isConnectable:!0,selected:!0,type:t,xPos:0,yPos:0,zIndex:0})})};var Vb={VITE_BASE_URL:"",VITE_BASIC_AUTH:"signalwire:1aG93uXk",VITE_DEFAULT_STYLE_HREF:"https://cdn.swire.io/npm/@signalwire/cfb@dev/dist/style.css",VITE_DEFAULT_VOICES_URL:"https://cdn.signalwire.com/npm/@signalwire/cfb@dev/dist/voices.json",VITE_FLOW_DATA_VERSION:"0.0.10",VITE_IS_STAGING:"true",BASE_URL:"/cfb/",MODE:"staging",DEV:!1,PROD:!0,SSR:!1};function kv(e,t){let n;try{n=e()}catch{return}return{getItem:o=>{var s;const i=a=>a===null?null:JSON.parse(a,t==null?void 0:t.reviver),l=(s=n.getItem(o))!=null?s:null;return l instanceof Promise?l.then(i):i(l)},setItem:(o,s)=>n.setItem(o,JSON.stringify(s,t==null?void 0:t.replacer)),removeItem:o=>n.removeItem(o)}}const xi=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then(r){return xi(r)(n)},catch(r){return this}}}catch(n){return{then(r){return this},catch(r){return xi(r)(n)}}}},$b=(e,t)=>(n,r,o)=>{let s={getStorage:()=>localStorage,serialize:JSON.stringify,deserialize:JSON.parse,partialize:v=>v,version:0,merge:(v,m)=>({...m,...v}),...t},i=!1;const l=new Set,a=new Set;let c;try{c=s.getStorage()}catch{}if(!c)return e((...v)=>{console.warn(`[zustand persist middleware] Unable to update item '${s.name}', the given storage is currently unavailable.`),n(...v)},r,o);const u=xi(s.serialize),f=()=>{const v=s.partialize({...r()});let m;const g=u({state:v,version:s.version}).then(S=>c.setItem(s.name,S)).catch(S=>{m=S});if(m)throw m;return g},p=o.setState;o.setState=(v,m)=>{p(v,m),f()};const h=e((...v)=>{n(...v),f()},r,o);let E;const y=()=>{var v;if(!c)return;i=!1,l.forEach(g=>g(r()));const m=((v=s.onRehydrateStorage)==null?void 0:v.call(s,r()))||void 0;return xi(c.getItem.bind(c))(s.name).then(g=>{if(g)return s.deserialize(g)}).then(g=>{if(g)if(typeof g.version=="number"&&g.version!==s.version){if(s.migrate)return s.migrate(g.state,g.version);console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return g.state}).then(g=>{var S;return E=s.merge(g,(S=r())!=null?S:h),n(E,!0),f()}).then(()=>{m==null||m(E,void 0),i=!0,a.forEach(g=>g(E))}).catch(g=>{m==null||m(void 0,g)})};return o.persist={setOptions:v=>{s={...s,...v},v.getStorage&&(c=v.getStorage())},clearStorage:()=>{c==null||c.removeItem(s.name)},getOptions:()=>s,rehydrate:()=>y(),hasHydrated:()=>i,onHydrate:v=>(l.add(v),()=>{l.delete(v)}),onFinishHydration:v=>(a.add(v),()=>{a.delete(v)})},y(),E||h},Hb=(e,t)=>(n,r,o)=>{let s={storage:kv(()=>localStorage),partialize:y=>y,version:0,merge:(y,v)=>({...v,...y}),...t},i=!1;const l=new Set,a=new Set;let c=s.storage;if(!c)return e((...y)=>{console.warn(`[zustand persist middleware] Unable to update item '${s.name}', the given storage is currently unavailable.`),n(...y)},r,o);const u=()=>{const y=s.partialize({...r()});return c.setItem(s.name,{state:y,version:s.version})},f=o.setState;o.setState=(y,v)=>{f(y,v),u()};const p=e((...y)=>{n(...y),u()},r,o);let h;const E=()=>{var y,v;if(!c)return;i=!1,l.forEach(g=>{var S;return g((S=r())!=null?S:p)});const m=((v=s.onRehydrateStorage)==null?void 0:v.call(s,(y=r())!=null?y:p))||void 0;return xi(c.getItem.bind(c))(s.name).then(g=>{if(g)if(typeof g.version=="number"&&g.version!==s.version){if(s.migrate)return s.migrate(g.state,g.version);console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return g.state}).then(g=>{var S;return h=s.merge(g,(S=r())!=null?S:p),n(h,!0),u()}).then(()=>{m==null||m(h,void 0),h=r(),i=!0,a.forEach(g=>g(h))}).catch(g=>{m==null||m(void 0,g)})};return o.persist={setOptions:y=>{s={...s,...y},y.storage&&(c=y.storage)},clearStorage:()=>{c==null||c.removeItem(s.name)},getOptions:()=>s,rehydrate:()=>E(),hasHydrated:()=>i,onHydrate:y=>(l.add(y),()=>{l.delete(y)}),onFinishHydration:y=>(a.add(y),()=>{a.delete(y)})},s.skipHydration||E(),h||p},Bb=(e,t)=>"getStorage"in t||"serialize"in t||"deserialize"in t?((Vb?"staging":void 0)!=="production"&&console.warn("[DEPRECATED] `getStorage`, `serialize` and `deserialize` options are deprecated. Use `storage` option instead."),$b(e,t)):Hb(e,t),Pv=window,Mv={showAllNodes:!1,showDevOptions:!1},Ir=bo()(Bb((e,t)=>({...Mv,actions:{getFlagNames:()=>{const n=t();return Object.keys(n).filter(r=>r!=="actions")},toggleFlag:n=>e(r=>({...r,[n]:!r[n]}))}}),{name:"flags",partialize:e=>Object.fromEntries(Object.entries(e).filter(([t])=>t!=="actions")),storage:kv(()=>localStorage),version:0})),Uv=()=>Ir.getState().actions;Ir.subscribe(e=>{console.log("feature flags changed",e)});const zb=e=>{const t=(r,o)=>{Ir.setState(s=>({...s,[r]:o}))},n=r=>{const o=Ir.getState(),s={...r};return Object.entries(o).forEach(([i,l])=>{i in s&&typeof l=="boolean"&&(s[i]=l)}),s};if(Pv){const r=new Proxy(n(e),{get:(o,s)=>Reflect.get(o,s),set:(o,s,i)=>{if(typeof i=="boolean"&&s in o)t(s,i);else throw new Error("unknown flag");return Reflect.set(o,s,i)}});Pv.swFlags=r}},Wb=()=>zb(Mv),Ha={currentColor:{negative:"fill-current",primary:"fill-current"},light:{negative:"fill-negative",primary:"fill-primary"}},Gb={"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]"},Yb=O.forwardRef(function({className:t="",size:n="md",type:r="light"},o){const s=Gb[n];return d.jsxs("svg",{"aria-hidden":"true",className:`${s} ${t}`,focusable:"false",fill:"none",ref:o,role:"img",viewBox:"0 0 64 73",xmlns:"http://www.w3.org/2000/svg",children:[d.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:Ha[r].primary}),d.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:Ha[r].primary}),d.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:Ha[r].negative}),d.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:Ha[r].negative})]})}),Kb={[N.FLOW_DATA_VERSION]:li,[N.PKG_VERSION]:mA},Xb=()=>{const e=()=>{var r;((r=n.current)==null?void 0:r.open)===!1&&n.current.showModal()},t=()=>{var r;(r=n.current)!=null&&r.open&&n.current.close()},n=H.useRef(null);return d.jsxs(d.Fragment,{children:[d.jsxs("button",{className:"group flex items-center justify-center gap-x-2 text-foreground/50 transition-colors hover:text-foreground/70",onClick:e,children:[d.jsx(Yb,{className:"text-foreground/40 transition-colors group-hover:text-foreground/50",size:"xl",type:"currentColor"}),d.jsx("span",{className:"text-xs font-semibold",children:A(N.ABOUT)})]}),d.jsx("dialog",{ref:n,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:d.jsxs("div",{className:"h-full px-2 pb-10",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("h2",{className:"text-2xl leading-10",children:A(N.ABOUT)}),d.jsxs("button",{className:"my-0.5 -mr-1.5 rounded-md py-0.5 px-1.5 ",onClick:t,children:[d.jsx("span",{className:"sr-only",children:A(N.CLOSE)}),d.jsx(re,{tag:"xmark",size:"lg"})]})]}),d.jsxs("div",{className:"h-full overflow-y-auto",children:[d.jsx("ul",{className:"mt-1 flex flex-col items-center justify-center text-sm",children:Object.entries(Kb).map(([r,o])=>d.jsx("li",{className:"text-foreground/70",children:d.jsxs("p",{children:[A(r),": ",o]})},r))}),d.jsx("div",{className:"mt-6 flex items-center justify-center ",children:d.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:A(N.CLOSE)})})]})]})})]})},Qb={deploy:N.STATUS_DEPLOY,deployed:N.STATUS_DEPLOYED,deploying:N.STATUS_DEPLOYING,error:N.STATUS_DEPLOY_ERROR},Fv={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"},qb=()=>{const e=Q(g=>g.deployFlowStatus),t=Q(g=>g.deployFlowURL),n=Q(g=>g.detachedMode),r=Q(g=>g.documentVersion),o=Q(g=>g.httpError),s=Q(g=>g.saveFlowStatus),{deployFlow:i,getValidationWarnings:l,setShowDeployWarning:a}=Te(),c={error:void 0,prevDocVersion:r},[u,f]=$f(c),p=Qb[e],h=async()=>{if(l().size>0)a(!0);else try{f({error:void 0}),await i()}catch(g){g instanceof Error?f({error:g.message}):f({error:"Failed to deploy!"})}};O.useEffect(()=>{s==="saved"&&r!==u.prevDocVersion&&f({prevDocVersion:r})},[u.prevDocVersion,r,s,f]);const E=s!=="saved"||e==="deployed"||e==="deploying",y=o==="document-sync"?Fv.deploying:Fv[e];let v="";e==="deploy"&&(v=s==="saved"?"bg-primary":"bg-focus");const m=`${v} ${y}`;return!t||n?null:d.jsxs("button",{"data-testid":"cfb__deploy-button",className:`flex items-center justify-center rounded border px-1.5 py-0.5
67
- text-xs font-medium transition-colors ${m}`,disabled:E,onClick:h,children:[A(p),d.jsx(Zn,{placement:"right",trigger:d.jsx("span",{className:"flex items-center justify-center pl-1",role:"tooltip",tabIndex:0,children:e==="error"?d.jsx(re,{tag:"circle-exclamation"}):d.jsx(d.Fragment,{})}),children:e==="error"?A(N.MORE_INFO_DEPLOY_ERROR,{message:u.error}):A(N.MORE_INFO_DEPLOY)})]})},Jb=()=>{const e=Q(t=>t.backButtonHref);return e?d.jsxs("a",{href:e,children:[d.jsx("span",{className:"sr-only",children:A(N.NAVIGATE_BACK)}),d.jsx(re,{tag:"arrow-left",className:"text-negative",size:"lg"})]}):null},Zb=()=>{const e=Q(i=>i.showDeployedHistory),t=Q(i=>i.httpError==="document-sync"),{cancelDetachedMode:n,setShowDeployedHistory:r}=Te(),o=()=>{e?n():r(!0)},s=e?"text-background bg-foreground":"text-foreground bg-foreground/10";return d.jsx(Zn,{placement:"top",trigger:d.jsxs("button",{className:`flex items-center justify-center rounded border border-transparent p-1 transition-colors ${s}`,disabled:t,onClick:o,type:"button",children:[d.jsx("span",{className:"sr-only",children:A(N.VERSION_HISTORY)}),d.jsx(re,{tag:"clock-rotate-left",size:"xs"})]}),children:A(N.VERSION_HISTORY)})},eD=({isDisabled:e,isSelected:t,itemIndex:n,onClick:r,onSelected:o,relativeTimeSince:s,version:i})=>{var f,p;const l=O.useRef(null),a=h=>{o(h)},c=()=>{t||(a(n),r(n))},u=h=>{h.preventDefault();const{key:E}=h;(E==="Enter"||E===" ")&&r(n),E==="ArrowUp"&&a(n-1),E==="ArrowDown"&&a(n+1)};return t&&((f=l.current)==null||f.focus({preventScroll:!0}),(p=l.current)==null||p.scrollIntoView({block:"nearest"})),d.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"}`,role:"presentation",children:d.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:c,onKeyDown:u,type:"button",tabIndex:t?0:-1,ref:l,children:[d.jsx(re,{className:`p-1 ${t?"text-primary":"text-foreground/30"}`,tag:"dot-circle"}),d.jsxs("div",{className:"flex flex-col items-start justify-center",children:[d.jsx("h3",{className:"text-xs font-medium",children:A(N.VERSION_LIST_ITEM,{number:i})}),d.jsx("p",{className:"text-xxs",children:d.jsx("time",{children:s})})]})]})})},tD=200,jv=Ne(),nD=()=>{const e=Q(m=>m.deployedVersionsList),t=Q(m=>m.saveFlowStatus),n=Q(m=>m.showDeployedHistory),{cancelDetachedMode:r,getDeployedVersionsList:o,migrateAndLoadDeployedFlow:s}=Te();Tv({onKeyPress:n?r:void 0});const i=O.useRef(),[l,a]=O.useState("loading"),[c,u]=O.useState(null);c!==null&&!n&&u(null);const f=O.useCallback(m=>{m>=0&&m<=e.length-1?u(m):u(null)},[e.length]),p=O.useCallback(m=>{var S;const g=(S=i.current)==null?void 0:S[m];g?(jv.info("load version",g.id),s(g)):jv.error("version not found")},[s]),h=O.useCallback(()=>{a("loading"),o({pageSize:tD}).then(m=>{a("loaded"),i.current=m}).catch(()=>{a("error"),i.current=void 0})},[o]);O.useLayoutEffect(()=>{n&&h()},[h,n]);const E=l==="error",y=e.length>0,v=t==="saved";return n?d.jsxs("div",{"data-testid":"cfb__deployed-versions-sidebar",className:"flex h-full flex-col py-3",children:[d.jsxs("section",{className:"flex items-center justify-between self-stretch px-4 pb-1",children:[d.jsxs("h2",{className:"flex items-center gap-1 text-tiny font-bold uppercase leading-none tracking-wide",children:[d.jsx(re,{className:"text-xs text-foreground/50",tag:"clock-rotate-left"}),A(N.VERSION_HISTORY)]}),d.jsxs("button",{className:"flex items-center justify-center px-0.5",onClick:r,type:"button",children:[d.jsx("span",{className:"sr-only",children:A(N.CLOSE)}),d.jsx(re,{tag:"xmark"})]})]}),d.jsxs("div",{className:`${y?"overflow-y-auto":"h-full"}`,children:[l!=="loaded"?d.jsxs("div",{className:`flex flex-col justify-center gap-y-4 p-4 text-sm leading-none tracking-wide text-foreground/50 ${y?"":"h-full"}`,children:[d.jsxs("div",{className:"flex flex-col items-center justify-center gap-y-2 gap-x-2",children:[E?d.jsx(re,{className:"text-negative",tag:"circle-exclamation"}):d.jsx(re,{className:"animate-spin",tag:"arrows-rotate"}),d.jsx("p",{"aria-live":E?"assertive":"polite",className:`${E?"text-negative":"font-bold uppercase text-foreground/50"}`,role:E?"alert":"status",children:A(E?N.ERROR_FETCHING_DEPLOYED_VERSIONS:N.STATUS_LOADING)})]}),E?d.jsx("div",{className:"flex w-full items-center justify-center",children:d.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:h,type:"button",children:A(N.RESYNC)})}):null]}):null,!y&&l==="loaded"?d.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
- `,children:d.jsxs("div",{className:"flex flex-col items-center justify-center gap-y-2 gap-x-2",children:[d.jsx(re,{tag:"circle-exclamation"}),Ua(N.NO_DEPLOYED_VERSIONS)]})}):null,y?d.jsx("ol",{children:e.map((m,g)=>d.jsx(eD,{itemIndex:g,isDisabled:!v,isSelected:g===c,onClick:p,onSelected:f,relativeTimeSince:m.relativeTimeSince,version:m.version},m.id))}):null]})]}):null},rD=()=>{const{getFlagNames:e}=Uv();return d.jsxs("div",{className:"rounded-sm border border-gray-200 p-2",children:[d.jsx("h3",{className:"w-full",children:"Feature Flags"}),d.jsx("div",{className:"flex flex-col gap-y-2 py-2",children:e().map(t=>d.jsx(oD,{flagName:t},t))})]})},oD=({flagName:e})=>{const{toggleFlag:t}=Uv(),r=Ir(o=>o[e])?"translate-x-5 bg-positive":"translate-x-0 bg-negative";return d.jsxs("label",{className:"flex cursor-pointer items-center",children:[d.jsxs("div",{className:"relative",children:[d.jsx("input",{type:"checkbox",className:"sr-only",onChange:()=>t(e)}),d.jsx("div",{className:"h-5 w-10 rounded-full bg-secondary/20",children:d.jsx("div",{className:`absolute left-1 top-1 h-3 w-3 rounded-full transition ${r}`})})]}),d.jsx("p",{className:"ml-3 text-sm font-medium",children:e})]})},sD=()=>{const[e,t]=O.useState(!1),n=()=>{t(r=>!r)};return d.jsx(Zn,{open:e,onOpenChange:t,placement:"bottom",role:"dialog",trigger:d.jsxs("button",{className:"group flex items-center justify-center gap-x-2 text-foreground/50 transition-colors hover:text-foreground/70",onClick:n,children:[d.jsx(re,{className:"text-foreground/40 transition-colors group-hover:text-foreground/50",size:"xl",tag:"circle-question"}),d.jsxs("span",{className:"text-xs font-semibold",children:[A(N.HELP),d.jsx("span",{className:"sr-only",children:A(N.MORE_INFO_TESTING_YOUR_FLOW)})]})]}),children:d.jsxs("section",{className:"p-2",children:[d.jsx("h2",{className:"mb-4 text-2xl font-semibold",children:"Testing Your Call Flow"}),d.jsxs("div",{className:"text-sm",children:[d.jsx("p",{children:"To test the current working version (draft) of your Call Flow, follow these steps:"}),d.jsxs("ol",{className:"my-4 list-inside list-decimal",children:[d.jsxs("li",{className:"mb-2 list-item",children:["Go to the settings tab of the purchased phone number you want to use for testing:  ",d.jsx("a",{className:"underline hover:text-background/80",href:"/phone_numbers",target:"_blank",rel:"noopener noreferrer",children:"Purchased Phone Numbers"})]}),d.jsxs("li",{className:"mb-2",children:["Choose the appropriate Call Flow for handling your calls:  ",d.jsx("a",{className:"underline hover:text-background/80",href:"/call_flows",target:"_blank",rel:"noopener noreferrer",children:"Call Flows"})]}),d.jsx("li",{className:"mb-2",children:"Select the working version (draft) of the chosen Call Flow."}),d.jsx("li",{children:"When you make a call to the number, it should now execute the working version of your Call Flow upon answering."})]}),d.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."})]})]})})},iD=(e,t)=>({label:A(Fa[e].label),nodes:Object.entries(Fa[e].nodes).reduce((n,[r,o])=>(((typeof o.active=="boolean"?o.active:o.active[hA])||t)&&n.push({deprecated:!!o.deprecated,title:A(o.label),type:r}),n),[]).sort((n,r)=>n.title.localeCompare(r.title))}),Vv=Ne(),lD=["action","forwardTo","recording","input","decision"],aD=()=>{const e=Ir(i=>i.showAllNodes),t=Q(i=>i.isCanvasInteractive),{addNode:n,setDragNodeType:r}=Te(),o=O.useCallback(i=>{i.preventDefault();const{nodeType:l}=i.currentTarget.dataset;l?n({nodeType:l}):Vv.error("No nodeType found on click event")},[n]),s=O.useCallback(i=>{i.preventDefault();const{nodeType:l}=i.currentTarget.dataset;l?r(l):Vv.error("No nodeType found on drag event")},[r]);return d.jsx("ul",{className:"py-3 px-2",id:"sidebar-node-list",children:lD.map(i=>d.jsx("li",{children:d.jsx(cD,{enableNodeButtons:t,group:i,handleOnClick:o,handleDragStart:s,showAllNodes:e})},i))})},cD=({enableNodeButtons:e=!0,group:t,handleOnClick:n,handleDragStart:r,showAllNodes:o})=>{const s=iD(t,o),i=`ngm-heading-${OA(s.label)}`;return d.jsxs(d.Fragment,{children:[d.jsx("h2",{className:"px-2 pb-1 text-tiny font-bold uppercase tracking-wide text-foreground/50",id:i,children:s.label}),d.jsx("ul",{"aria-labelledby":i,className:"flex flex-1 flex-col gap-y-1 pb-2",children:s.nodes.map(l=>d.jsx("li",{children:d.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
- hover:border-primary hover:bg-primary/20 enabled:hover:shadow-md`,"data-node-type":l.type,disabled:!e,draggable:e,onClick:e?n:void 0,onDragStart:e?r:void 0,children:[d.jsx(re,{tag:"circle-small",className:"text-primary"}),d.jsxs("span",{className:"text-left text-xs font-medium line-clamp-2",children:[l.title,l.deprecated&&d.jsxs("span",{className:"text-foreground/70",children:[" ",A(N.DEPRECATED)]})]})]})},l.type))})]})},uD=()=>{const{addToast:e,restoreDeployedFlow:t}=Te(),n=Q(o=>o.workingFlowCopy),r=()=>{t(),e({message:A(N.VERSION_RESTORED),status:"success"})};return n?d.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:r,children:A(N.RESTORE)}):null},dD={"awaiting-save":N.STATUS_SAVING,"document-sync":N.STATUS_LOCKED,error:N.STATUS_ERROR,initial:N.STATUS_LOADING,saved:N.STATUS_SAVED,saving:N.STATUS_SAVING},$v=e=>(e.preventDefault(),e.returnValue=""),Hv=(e,t)=>e==="document-sync"?e:t,fD=()=>{const e=Q(p=>p.detachedMode),t=Q(p=>p.saveFlowStatus),n=Q(p=>p.httpError),[r,o]=O.useState(!0),[s,i]=O.useState(Hv(n,t)),l=dD[s],a=t==="error"||n,c=Hv(n,t),u=O.useRef(!1);O.useEffect(()=>{c==="initial"&&!u.current?(u.current=!0,i(c),o(!1),setTimeout(()=>{o(!0)},vA)):c!=="initial"&&r&&(u.current=!1,i(c))},[r,c]),O.useEffect(()=>{if(!(t==="saved"||n))return addEventListener("beforeunload",$v,{capture:!0}),()=>{removeEventListener("beforeunload",$v,{capture:!0})}},[n,t]);let f="";switch(!0){case a:f="px-1.5 py-0.5 bg-negative/20 text-negative";break;case s==="saved":f="text-foreground/50";break;default:f="px-1.5 py-0.5 bg-foreground/30 text-background"}return e?null:d.jsx("div",{"aria-live":a?"assertive":"polite","data-testid":"cfb__status",className:"flex",role:a?"alert":"status",children:d.jsxs("div",{className:`flex gap-x-1 rounded text-xxs ${f}`,children:[d.jsx("p",{children:l==="STATUS_SAVED"?d.jsx(pD,{}):A(l)}),a&&d.jsx(Zn,{placement:"bottom",trigger:d.jsxs("div",{role:"tooltip",tabIndex:0,children:[d.jsx("span",{className:"sr-only",children:A(N.MORE_INFO_STATUS_ERROR)}),d.jsx(re,{tag:"circle-exclamation"})]}),children:A(n==="document-sync"?N.INFO_STATUS_ERROR_OUT_OF_SYNC:N.INFO_STATUS_ERROR)})]})})},pD=()=>{const e=Q(s=>s.documentLastUpdated),t=O.useCallback((s,...i)=>Q0(ov(),{numeric:"always",style:"narrow"})(s,{excludeUnits:{second:!0},...i}),[]),n=e?t(e):void 0,[r,o]=O.useState(n);return O.useEffect(()=>{if(!e)return;const s=setInterval(()=>{o(t(e))},1e3);return()=>clearInterval(s)},[e,t]),d.jsxs(d.Fragment,{children:[A(N.SAVED)," ",d.jsx("time",{children:r})]})},hD=()=>{const e=Ir(i=>i.showDevOptions),{exportStoreData:t}=Te(),n=Q(i=>i.flowTitle),r=Q(i=>i.showDeployedHistory),o=O.useRef(null),s=i=>{i.preventDefault(),o.current&&o.current.showModal()};return d.jsxs(d.Fragment,{children:[d.jsxs("section",{className:"hidden h-full w-1/6 min-w-[160px] shrink-0 flex-col bg-background text-foreground sm:flex",children:[d.jsxs("nav",{className:"flex shrink-0 items-center justify-between px-3 py-2",children:[d.jsx(Jb,{}),e&&d.jsx("button",{className:"rounded bg-positive p-1 px-2 text-xs text-background",onClick:s,children:"Dev Options"})]}),d.jsx("section",{className:"px-2 py-2",children:d.jsxs("div",{className:"divide-y divide-foreground/10 rounded-lg border border-foreground/10",children:[d.jsx("h1",{className:"block w-full shrink-0 p-2 text-sm font-semibold leading-tight line-clamp-2",children:n||d.jsx(d.Fragment,{children:" "})}),d.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-x-1 gap-y-2 p-2",children:[d.jsx("div",{className:"flex-1",children:d.jsx(fD,{})}),d.jsxs("menu",{className:"flex items-center justify-center gap-x-1",children:[r?d.jsx(uD,{}):d.jsx(qb,{}),d.jsx(Zb,{})]})]})]})}),d.jsxs("section",{className:"h-full overflow-y-auto",children:[r?null:d.jsx(aD,{}),d.jsx(nD,{})]}),d.jsx("section",{className:"flex flex-col items-start justify-center gap-y-5 px-2 pt-3 pb-4",children:d.jsxs("div",{className:"flex flex-col items-start justify-center gap-y-3 px-2",children:[d.jsx(Xb,{}),d.jsx(sD,{})]})})]}),e&&d.jsx("dialog",{className:"z-50 my-10 rounded-lg border border-foreground/10 bg-background text-foreground",ref:o,children:d.jsx("form",{children:d.jsxs("fieldset",{children:[d.jsxs("legend",{className:"flex w-full justify-between pb-2",children:[d.jsx("h1",{className:"text-2xl leading-10",children:"Dev Options"}),d.jsxs("button",{className:"p-1 pt-0 font-semibold",formMethod:"dialog",children:[d.jsx("span",{className:"sr-only",children:"Close"}),d.jsx(re,{tag:"xmark",size:"lg"})]})]}),d.jsxs("div",{className:"mb-1 rounded-sm border border-gray-200 p-2",children:[d.jsx("h3",{className:"w-full",children:"Flow Data"}),d.jsx("div",{className:"flex flex-row gap-x-2 py-2",children:d.jsx("div",{className:"flex items-center",children:d.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"})})})]}),d.jsx(rD,{})]})})})]})},mD=()=>{const e=O.useRef(null),[t,n]=O.useState(),[r,o]=O.useState(null);return O.useLayoutEffect(()=>(e.current=new ResizeObserver(([s])=>n(s)),r&&e.current.observe(r),()=>{var s;return(s=e.current)==null?void 0:s.disconnect()}),[r]),{observerEntry:t,setTarget:o}},gD=({rootAppHeight:e,rootAppWidth:t})=>{Q.setState({rootAppHeight:e,rootAppWidth:t})},ED=()=>{const{observerEntry:e,setTarget:t}=mD();return O.useEffect(()=>{e&&(Ne().log("resized",{rootAppHeight:e.contentRect.height,rootAppWidth:e.contentRect.width}),gD({rootAppHeight:e.contentRect.height,rootAppWidth:e.contentRect.width}))},[e]),{rootTarget:t}};function yD(){Ne().debug("Hello World!");const{rootTarget:e}=ED(),t=Q(o=>o.colorMode)??"",n=Q(o=>o.httpError),r=n!==void 0&&n!=="document-sync";return d.jsx(d.Fragment,{children:d.jsx("div",{className:`${t} flex h-full w-full bg-backgroundAlt text-foreground`,ref:e,children:r?d.jsx(Y2,{errorType:n}):d.jsxs(d.Fragment,{children:[d.jsx(hD,{}),d.jsx(Rb,{}),d.jsx(Ob,{}),d.jsxs(tf,{children:[d.jsx(OL,{}),d.jsxs(NL,{children:[d.jsxs(Zs,{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:[d.jsx(hb,{}),d.jsx(vb,{})]}),d.jsx(jb,{}),d.jsx(Db,{}),d.jsx(pb,{}),d.jsx(TL,{})]})]})]})})})}const vD='@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")}',Bv=Ne(),_D=e=>{if(!e||!e.getFlowURL||!e.updateFlowURL)throw new TypeError("Invalid or missing required params")};function SD(e){_D(e);const{backButtonHref:t,deployFlowURL:n,getAiAgentsURL:r=`${window.location.origin}${T_}`,getFlowURL:o,getSwmlScriptsURL:s=`${window.location.origin}${A_}`,rootElementId:i="sw-cfb-root",styleHref:l="https://cdn.swire.io/npm/@signalwire/cfb@dev/dist/style.css",updateFlowURL:a,voicesURL:c="https://cdn.signalwire.com/npm/@signalwire/cfb@dev/dist/voices.json"}=e;Vf.getState().actions.init({voicesURL:c}).catch(p=>{Bv.error("Error initializing voices",p)});const u=document.getElementById(i);if(Q.setState({backButtonHref:t,deployFlowURL:n,getFlowURL:o,rootElement:u,rootElementId:i,updateFlowURL:a}),r&&en.getState().actions.init({getAiAgentsURL:r}),s&&_n.getState().actions.init({getSwmlScriptsURL:s}),O2().catch(p=>{Bv.error("Error initializing i18n",p)}),Wb(),!u)throw new Error(`Id: '${i}' not found in the DOM`);u.attachShadow({mode:"open"}),u.shadowRoot&&oc.createRoot(u.shadowRoot).render(d.jsxs(O.StrictMode,{children:[d.jsx("link",{type:"text/css",rel:"stylesheet",href:l}),d.jsx(yD,{})]}));const f=document.createElement("style");document.head.appendChild(f),f.appendChild(document.createTextNode(vD))}Fr.main=SD,Object.defineProperty(Fr,Symbol.toStringTag,{value:"Module"})});
66
+ ${u} ${t?"animate-from-bottom":""} ${r}`,ref:a,role:i,children:[d.jsxs("div",{className:"flex items-center justify-center gap-x-2",children:[d.jsx(re,{className:"flex-shrink-0 self-start",tag:o}),d.jsx("p",{className:"text-xs font-semibold",children:s})]}),n]})}),gb=()=>{const{addToast:e,restoreDeployedFlow:t,cancelDetachedMode:n}=Te();if(!Q(i=>i.showDeployedHistoryToast))return null;const o=()=>{t(),e({message:A(N.VERSION_RESTORED),status:"success"})},s=()=>{n()};return d.jsx(Ov,{animate:!1,className:"gap-x-14",message:A(N.PREVIEW_DEPLOYED_VERSION),role:"dialog",children:d.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-x-2 gap-y-1",children:[d.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:o,children:A(N.RESTORE_THIS_VERSION)}),d.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:s,children:A(N.CANCEL)})]})})},Tv=({onKeyPress:e})=>{const t=Oo(["Escape","Esc"]);return O.useEffect(()=>{t&&typeof e=="function"&&e()},[t,e]),{isPressed:t}},Eb={offset:[0,.5,1],opacity:[1,0,0],pointerEvents:["none","none","auto"],transform:["scale(1.1) translateY(0%)","scale(0.5) translateY(-100%)"]},yb={duration:xA*2,easing:"ease-in-out",fill:"forwards"},vb=({durationMs:e,id:t,permanent:n})=>{const r=e??RA,[o,s]=O.useState(null),{deleteToast:i}=Te(),l=O.useCallback(()=>{let a;const c=()=>i(t);return o instanceof HTMLElement?(a=o.animate(Eb,yb),a.addEventListener("finish",c,{once:!0})):c(),()=>a==null?void 0:a.removeEventListener("finish",c)},[t,i,o]);return Tv({onKeyPress:l}),O.useEffect(()=>{if(n)return;let a,c;const u=()=>{clearTimeout(a)},f=()=>{u(),a=setTimeout(()=>{c=l()},r)};return f(),o instanceof HTMLElement&&(o.addEventListener("mouseenter",u),o.addEventListener("mouseleave",f)),()=>{u(),o instanceof HTMLElement&&(o.removeEventListener("mouseenter",u),o.removeEventListener("mouseleave",f),c==null||c())}},[l,r,n,o]),{deleteToastCallback:l,setToastRef:s,toastRef:o}},Av=({durationMs:e,id:t,message:n,permanent:r,status:o})=>{const{deleteToastCallback:s,setToastRef:i}=vb({durationMs:e,id:t,permanent:r});return d.jsx(Ov,{className:"w-full max-w-sm",iconTag:o==="success"?"circle-check":"circle-exclamation",message:n,ref:i,status:o,children:d.jsxs("button",{className:"flex-shrink-0 self-start opacity-40 transition-opacity hover:opacity-70",onClick:s,children:[d.jsx(re,{tag:"circle-xmark",size:"xl"}),d.jsx("span",{className:"sr-only",children:A(N.CLOSE)})]})})},_b={error:Av,success:Av},Sb=()=>{const e=Q(n=>n.toastsMap);if(e.size===0)return null;const t=Array.from(e.values());return d.jsx("div",{className:"flex w-full flex-col items-center gap-y-1",children:t.map(n=>{const r=_b[n.status];return d.jsx(r,{durationMs:n.durationMs,id:n.id,message:n.message,permanent:n.permanent,status:n.status},n.id)})})},xb=({asRole:e="alert",open:t=!1,type:n="overlay"})=>{const[r,o]=H.useState(t);O.useEffect(()=>{o(t)},[t]);const s=O.useCallback(()=>o(!1),[]),i=O.useCallback(()=>o(!0),[]);return{asRole:e,closeContainer:s,isOpen:r,openContainer:i,type:n}},Iv=O.createContext(null),Wf=()=>{const e=O.useContext(Iv);if(e==null)throw new Error("Toast components must be wrapped in <ToastContainer />");return e},Rb=({children:e,...t})=>{const n=xb(t);return d.jsx(Iv.Provider,{value:n,children:e})},Cv=({iconAs:e,title:t,children:n})=>{const{asRole:r}=Wf();return d.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:r,children:[d.jsxs("h2",{className:"text-lg font-semibold leading-6 tracking-wide",children:[d.jsx("span",{className:"mr-2",children:d.jsx(re,{tag:e??"circle-exclamation"})}),t]}),d.jsx("div",{className:"mt-2 text-sm leading-5",children:n})]})},Nb=({children:e})=>{const{closeContainer:t,isOpen:n,type:r}=Wf(),{getRootElement:o}=Te(),s=o(),i=O.useRef(null);return O.useEffect(()=>{if(!i.current)return;let l,a;const c=u=>{var f,p;if(u.key==="Escape"&&t(),u.key==="Tab"){const h=(p=(f=document.activeElement)==null?void 0:f.shadowRoot)==null?void 0:p.activeElement;u.shiftKey?h===l&&(a==null||a.focus(),u.preventDefault()):h===a&&(l==null||l.focus(),u.preventDefault())}};if(r==="overlay"){const u=i.current.querySelectorAll("button");l=u[0],a=u[u.length-1],a==null||a.focus(),document.addEventListener("keydown",c)}return()=>{document.removeEventListener("keydown",c)}},[t,r]),n?Bl.createPortal(d.jsx("section",{className:`flex justify-center ${r==="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:r==="overlay"?i:void 0,children:e}),s):null},Lv=({asRole:e,open:t,children:n,type:r})=>d.jsx(Rb,{asRole:e,open:t,type:r,children:d.jsx(Nb,{children:n})}),wb=()=>{const t=Q(n=>n.httpError)===z0;return t?d.jsx(Lv,{asRole:"dialog",open:t,type:"overlay",children:d.jsx(Cv,{title:A(N.DOCUMENT_OUT_OF_SYNC),children:d.jsx(Ob,{})})}):null},Ob=()=>{const{closeContainer:e}=Wf(),t=()=>{window.location.reload()};return d.jsxs(d.Fragment,{children:[Ua(N.TOAST_DOCUMENT_OUT_OF_SYNC),d.jsxs("div",{className:"mt-11 flex items-center justify-center gap-x-6",children:[d.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:A(N.IGNORE)}),d.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:A(N.RESYNC)})]})]})},Tb=Ne(),Ab=()=>{const e=Q(t=>t.showDeployWarning);return d.jsx(Lv,{asRole:"dialog",open:e,type:"overlay",children:d.jsx(Cv,{title:A(N.DEPLOY_WARNING),children:d.jsx(Ib,{})})})},Ib=()=>{const{deployFlow:e,setShowDeployWarning:t,setShowValidationWarnings:n}=Te(),r=()=>{t(!1),n(!0)},o=()=>{t(!1)},s=()=>{e().catch(i=>{Tb.error(i)}),o()};return d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"mb-4",children:Ua(N.TOAST_DEPLOY_WARNING)}),d.jsx(Ny,{onClickListItem:r}),d.jsxs("div",{className:"mt-11 flex items-center justify-center gap-x-6",children:[d.jsx("button",{className:"rounded-md border border-background bg-foreground px-3.5 py-2.5 font-bold tracking-widest text-background",onClick:o,children:A(N.CANCEL)}),d.jsx("button",{className:"rounded-md border border-background bg-positive/70 px-3.5 py-2.5 font-bold tracking-widest text-background",onClick:s,children:A(N.DEPLOY)})]})]})},Cb="react-flow__controls-button",Lb="min-w-[3.625rem] cursor-auto select-auto text-center hover:bg-background active:bg-background",bb="hidden sm:flex",Db=O.forwardRef(function({asTag:t="div",children:n,className:r="",hiddenSmallScreen:o=!1,...s},i){const l=t,c=`${Cb} ${l==="button"?"":Lb} ${o?bb:""} ${r}`;return d.jsx(l,{className:c,ref:i,...s,children:n})}),kb=()=>{const e=Q(i=>i.showValidationWarnings),t=Q(i=>i.validationWarnings),n=Q(i=>i.detachedMode),{setShowValidationWarnings:r}=Te(),o=()=>r(!e),s=()=>{e&&r(!1)};return!t.size||n?(s(),null):d.jsx(Zn,{onOpenChange:r,open:e,outsidePress:!1,placement:"bottom-start",role:"dialog",trigger:d.jsxs(Db,{className:"text-xs",asTag:"button",onClick:o,hiddenSmallScreen:!0,children:[A(N.WARNING),d.jsxs("div",{className:"flex items-center justify-center pl-1",children:[d.jsx("span",{className:"sr-only",children:A(N.MORE_INFO_STATUS_ERROR)}),d.jsx(re,{className:"text-warning",tag:"circle-exclamation"})]})]}),children:d.jsx(Ny,{children:d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsxs("h2",{className:"text-xs font-semibold",children:[d.jsx(re,{className:"mr-1",tag:"circle-exclamation"}),A(N.CAUTION)]}),d.jsxs("button",{className:"my-0.5 rounded-md py-0.5 px-1.5",onClick:s,children:[d.jsx("span",{className:"sr-only",children:A(N.CLOSE)}),d.jsx(re,{tag:"xmark",size:"lg"})]})]})})})},Pb=()=>{const e=Q(r=>r.isDraggingNode),t=Q(r=>r.showInteractiveControl),n=r=>{Q.setState({isInteractiveControlOn:r})};return d.jsx(rA,{className:`mt-2.5 rounded-[0.25rem] ${e?"group/control-buttons":""}`,position:"top-left",onInteractiveChange:n,showInteractive:t,children:d.jsx(kb,{})})},Mb=".react-flow__panel",Ub=16,bv={cursor:"no-drop",transform:"translate(0px, 0px) scale(1)",visibility:"hidden",zIndex:"5"},Dv=e=>{const t=e.getBoundingClientRect();return{isCursorIntersecting:({clientX:n,clientY:r})=>t.top<=r&&t.bottom>=r&&t.left<=n&&t.right>=n}},Fb=e=>{const t=e.querySelectorAll(Mb);return Array.from(t).map(n=>Dv(n).isCursorIntersecting)},jb=e=>({resetDragNodeStyles:()=>{Object.entries(bv).forEach(([t,n])=>{e.style[t]=n})},updateDragNodeStyles:({isOverDropTarget:t,scale:n,xPos:r,yPos:o})=>{e.style.visibility="visible",e.style.cursor=t?"grabbing":"no-drop",e.style.transform=`translate(${r}px, ${o}px) scale(${n})`}}),Vb=({handleMouseMove:e,handleMouseUp:t,root:n})=>(n.addEventListener("mousemove",e),n.addEventListener("mouseup",t),{removeListeners:()=>{n.removeEventListener("mousemove",e),n.removeEventListener("mouseup",t)}}),$b=()=>{const e=O.useRef(null),t=Q(p=>p.dragNodeType),n=Q(p=>p.flowWrapperElement),r=Q(p=>p.viewport.zoom),{addNode:o,getRootElement:s,setDragNodeType:i}=Te(),l=s();if(O.useEffect(()=>{if(e.current&&t&&n&&l){let p=!1;const h=Ub*r,E=e.current,y=Dv(n).isCursorIntersecting,v=Fb(n),{resetDragNodeStyles:m,updateDragNodeStyles:g}=jb(E),{removeListeners:S}=Vb({handleMouseMove:_=>{const{clientX:x,clientY:R}=_,T=x-h,L=R-h;p=y({clientX:x,clientY:R})&&!v.some(P=>P({clientX:x,clientY:R})),g({isOverDropTarget:p,scale:p?r:1,xPos:T,yPos:L})},handleMouseUp:_=>{if(p){const x=n.getBoundingClientRect();o({nodeType:t,x:_.clientX-x.left-h,y:_.clientY-x.top-h})}i(void 0)},root:l});return()=>{S(),m()}}},[o,t,n,l,i,r]),!t)return null;const a=gv[t],c=Z0[t](),u=le(),f={...c,initial:!1,valid:!0};return d.jsx("section",{className:"react-flow__node fixed left-0 top-0",ref:e,style:bv,children:d.jsx(a,{data:f,dragging:!0,id:u,isConnectable:!0,selected:!0,type:t,xPos:0,yPos:0,zIndex:0})})};var Hb={VITE_APP_VERSION_HASH:"1510b28",VITE_BASE_URL:"http://localhost:8080",VITE_BASIC_AUTH:"7bfc11e6-4eee-4015-9289-20a6baf44443:PTf2c0aaa85a8064ee8ed44bc969a75280710be8d4b27af8a8",VITE_FLOW_DATA_VERSION:"0.0.10",VITE_DEFAULT_STYLE_HREF:"https://cdn.signalwire.com/npm/@signalwire/cfb@latest/dist/style.css",VITE_DEFAULT_VOICES_URL:"https://cdn.signalwire.com/npm/@signalwire/cfb@latest/dist/voices.json",BASE_URL:"/cfb/",MODE:"production",DEV:!1,PROD:!0,SSR:!1};function kv(e,t){let n;try{n=e()}catch{return}return{getItem:o=>{var s;const i=a=>a===null?null:JSON.parse(a,t==null?void 0:t.reviver),l=(s=n.getItem(o))!=null?s:null;return l instanceof Promise?l.then(i):i(l)},setItem:(o,s)=>n.setItem(o,JSON.stringify(s,t==null?void 0:t.replacer)),removeItem:o=>n.removeItem(o)}}const xi=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then(r){return xi(r)(n)},catch(r){return this}}}catch(n){return{then(r){return this},catch(r){return xi(r)(n)}}}},Bb=(e,t)=>(n,r,o)=>{let s={getStorage:()=>localStorage,serialize:JSON.stringify,deserialize:JSON.parse,partialize:v=>v,version:0,merge:(v,m)=>({...m,...v}),...t},i=!1;const l=new Set,a=new Set;let c;try{c=s.getStorage()}catch{}if(!c)return e((...v)=>{console.warn(`[zustand persist middleware] Unable to update item '${s.name}', the given storage is currently unavailable.`),n(...v)},r,o);const u=xi(s.serialize),f=()=>{const v=s.partialize({...r()});let m;const g=u({state:v,version:s.version}).then(S=>c.setItem(s.name,S)).catch(S=>{m=S});if(m)throw m;return g},p=o.setState;o.setState=(v,m)=>{p(v,m),f()};const h=e((...v)=>{n(...v),f()},r,o);let E;const y=()=>{var v;if(!c)return;i=!1,l.forEach(g=>g(r()));const m=((v=s.onRehydrateStorage)==null?void 0:v.call(s,r()))||void 0;return xi(c.getItem.bind(c))(s.name).then(g=>{if(g)return s.deserialize(g)}).then(g=>{if(g)if(typeof g.version=="number"&&g.version!==s.version){if(s.migrate)return s.migrate(g.state,g.version);console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return g.state}).then(g=>{var S;return E=s.merge(g,(S=r())!=null?S:h),n(E,!0),f()}).then(()=>{m==null||m(E,void 0),i=!0,a.forEach(g=>g(E))}).catch(g=>{m==null||m(void 0,g)})};return o.persist={setOptions:v=>{s={...s,...v},v.getStorage&&(c=v.getStorage())},clearStorage:()=>{c==null||c.removeItem(s.name)},getOptions:()=>s,rehydrate:()=>y(),hasHydrated:()=>i,onHydrate:v=>(l.add(v),()=>{l.delete(v)}),onFinishHydration:v=>(a.add(v),()=>{a.delete(v)})},y(),E||h},zb=(e,t)=>(n,r,o)=>{let s={storage:kv(()=>localStorage),partialize:y=>y,version:0,merge:(y,v)=>({...v,...y}),...t},i=!1;const l=new Set,a=new Set;let c=s.storage;if(!c)return e((...y)=>{console.warn(`[zustand persist middleware] Unable to update item '${s.name}', the given storage is currently unavailable.`),n(...y)},r,o);const u=()=>{const y=s.partialize({...r()});return c.setItem(s.name,{state:y,version:s.version})},f=o.setState;o.setState=(y,v)=>{f(y,v),u()};const p=e((...y)=>{n(...y),u()},r,o);let h;const E=()=>{var y,v;if(!c)return;i=!1,l.forEach(g=>{var S;return g((S=r())!=null?S:p)});const m=((v=s.onRehydrateStorage)==null?void 0:v.call(s,(y=r())!=null?y:p))||void 0;return xi(c.getItem.bind(c))(s.name).then(g=>{if(g)if(typeof g.version=="number"&&g.version!==s.version){if(s.migrate)return s.migrate(g.state,g.version);console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return g.state}).then(g=>{var S;return h=s.merge(g,(S=r())!=null?S:p),n(h,!0),u()}).then(()=>{m==null||m(h,void 0),h=r(),i=!0,a.forEach(g=>g(h))}).catch(g=>{m==null||m(void 0,g)})};return o.persist={setOptions:y=>{s={...s,...y},y.storage&&(c=y.storage)},clearStorage:()=>{c==null||c.removeItem(s.name)},getOptions:()=>s,rehydrate:()=>E(),hasHydrated:()=>i,onHydrate:y=>(l.add(y),()=>{l.delete(y)}),onFinishHydration:y=>(a.add(y),()=>{a.delete(y)})},s.skipHydration||E(),h||p},Wb=(e,t)=>"getStorage"in t||"serialize"in t||"deserialize"in t?((Hb?"production":void 0)!=="production"&&console.warn("[DEPRECATED] `getStorage`, `serialize` and `deserialize` options are deprecated. Use `storage` option instead."),Bb(e,t)):zb(e,t),Pv=window,Mv={showAllNodes:!1,showDevOptions:!1},Ir=bo()(Wb((e,t)=>({...Mv,actions:{getFlagNames:()=>{const n=t();return Object.keys(n).filter(r=>r!=="actions")},toggleFlag:n=>e(r=>({...r,[n]:!r[n]}))}}),{name:"flags",partialize:e=>Object.fromEntries(Object.entries(e).filter(([t])=>t!=="actions")),storage:kv(()=>localStorage),version:0})),Uv=()=>Ir.getState().actions;Ir.subscribe(e=>{console.log("feature flags changed",e)});const Gb=e=>{const t=(r,o)=>{Ir.setState(s=>({...s,[r]:o}))},n=r=>{const o=Ir.getState(),s={...r};return Object.entries(o).forEach(([i,l])=>{i in s&&typeof l=="boolean"&&(s[i]=l)}),s};if(Pv){const r=new Proxy(n(e),{get:(o,s)=>Reflect.get(o,s),set:(o,s,i)=>{if(typeof i=="boolean"&&s in o)t(s,i);else throw new Error("unknown flag");return Reflect.set(o,s,i)}});Pv.swFlags=r}},Yb=()=>Gb(Mv),Ha={currentColor:{negative:"fill-current",primary:"fill-current"},light:{negative:"fill-negative",primary:"fill-primary"}},Kb={"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]"},Xb=O.forwardRef(function({className:t="",size:n="md",type:r="light"},o){const s=Kb[n];return d.jsxs("svg",{"aria-hidden":"true",className:`${s} ${t}`,focusable:"false",fill:"none",ref:o,role:"img",viewBox:"0 0 64 73",xmlns:"http://www.w3.org/2000/svg",children:[d.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:Ha[r].primary}),d.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:Ha[r].primary}),d.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:Ha[r].negative}),d.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:Ha[r].negative})]})}),Qb={[N.FLOW_DATA_VERSION]:li,[N.PKG_VERSION]:EA},qb=()=>{const e=()=>{var r;((r=n.current)==null?void 0:r.open)===!1&&n.current.showModal()},t=()=>{var r;(r=n.current)!=null&&r.open&&n.current.close()},n=H.useRef(null);return d.jsxs(d.Fragment,{children:[d.jsxs("button",{className:"group flex items-center justify-center gap-x-2 text-foreground/50 transition-colors hover:text-foreground/70",onClick:e,children:[d.jsx(Xb,{className:"text-foreground/40 transition-colors group-hover:text-foreground/50",size:"xl",type:"currentColor"}),d.jsx("span",{className:"text-xs font-semibold",children:A(N.ABOUT)})]}),d.jsx("dialog",{ref:n,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:d.jsxs("div",{className:"h-full px-2 pb-10",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("h2",{className:"text-2xl leading-10",children:A(N.ABOUT)}),d.jsxs("button",{className:"my-0.5 -mr-1.5 rounded-md py-0.5 px-1.5 ",onClick:t,children:[d.jsx("span",{className:"sr-only",children:A(N.CLOSE)}),d.jsx(re,{tag:"xmark",size:"lg"})]})]}),d.jsxs("div",{className:"h-full overflow-y-auto",children:[d.jsx("ul",{className:"mt-1 flex flex-col items-center justify-center text-sm",children:Object.entries(Qb).map(([r,o])=>d.jsx("li",{className:"text-foreground/70",children:d.jsxs("p",{children:[A(r),": ",o]})},r))}),d.jsx("div",{className:"mt-6 flex items-center justify-center ",children:d.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:A(N.CLOSE)})})]})]})})]})},Jb={deploy:N.STATUS_DEPLOY,deployed:N.STATUS_DEPLOYED,deploying:N.STATUS_DEPLOYING,error:N.STATUS_DEPLOY_ERROR},Fv={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"},Zb=()=>{const e=Q(g=>g.deployFlowStatus),t=Q(g=>g.deployFlowURL),n=Q(g=>g.detachedMode),r=Q(g=>g.documentVersion),o=Q(g=>g.httpError),s=Q(g=>g.saveFlowStatus),{deployFlow:i,getValidationWarnings:l,setShowDeployWarning:a}=Te(),c={error:void 0,prevDocVersion:r},[u,f]=$f(c),p=Jb[e],h=async()=>{if(l().size>0)a(!0);else try{f({error:void 0}),await i()}catch(g){g instanceof Error?f({error:g.message}):f({error:"Failed to deploy!"})}};O.useEffect(()=>{s==="saved"&&r!==u.prevDocVersion&&f({prevDocVersion:r})},[u.prevDocVersion,r,s,f]);const E=s!=="saved"||e==="deployed"||e==="deploying",y=o==="document-sync"?Fv.deploying:Fv[e];let v="";e==="deploy"&&(v=s==="saved"?"bg-primary":"bg-focus");const m=`${v} ${y}`;return!t||n?null:d.jsxs("button",{"data-testid":"cfb__deploy-button",className:`flex items-center justify-center rounded border px-1.5 py-0.5
67
+ text-xs font-medium transition-colors ${m}`,disabled:E,onClick:h,children:[A(p),d.jsx(Zn,{placement:"right",trigger:d.jsx("span",{className:"flex items-center justify-center pl-1",role:"tooltip",tabIndex:0,children:e==="error"?d.jsx(re,{tag:"circle-exclamation"}):d.jsx(d.Fragment,{})}),children:e==="error"?A(N.MORE_INFO_DEPLOY_ERROR,{message:u.error}):A(N.MORE_INFO_DEPLOY)})]})},eD=()=>{const e=Q(t=>t.backButtonHref);return e?d.jsxs("a",{href:e,children:[d.jsx("span",{className:"sr-only",children:A(N.NAVIGATE_BACK)}),d.jsx(re,{tag:"arrow-left",className:"text-negative",size:"lg"})]}):null},tD=()=>{const e=Q(i=>i.showDeployedHistory),t=Q(i=>i.httpError==="document-sync"),{cancelDetachedMode:n,setShowDeployedHistory:r}=Te(),o=()=>{e?n():r(!0)},s=e?"text-background bg-foreground":"text-foreground bg-foreground/10";return d.jsx(Zn,{placement:"top",trigger:d.jsxs("button",{className:`flex items-center justify-center rounded border border-transparent p-1 transition-colors ${s}`,disabled:t,onClick:o,type:"button",children:[d.jsx("span",{className:"sr-only",children:A(N.VERSION_HISTORY)}),d.jsx(re,{tag:"clock-rotate-left",size:"xs"})]}),children:A(N.VERSION_HISTORY)})},nD=({isDisabled:e,isSelected:t,itemIndex:n,onClick:r,onSelected:o,relativeTimeSince:s,version:i})=>{var f,p;const l=O.useRef(null),a=h=>{o(h)},c=()=>{t||(a(n),r(n))},u=h=>{h.preventDefault();const{key:E}=h;(E==="Enter"||E===" ")&&r(n),E==="ArrowUp"&&a(n-1),E==="ArrowDown"&&a(n+1)};return t&&((f=l.current)==null||f.focus({preventScroll:!0}),(p=l.current)==null||p.scrollIntoView({block:"nearest"})),d.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"}`,role:"presentation",children:d.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:c,onKeyDown:u,type:"button",tabIndex:t?0:-1,ref:l,children:[d.jsx(re,{className:`p-1 ${t?"text-primary":"text-foreground/30"}`,tag:"dot-circle"}),d.jsxs("div",{className:"flex flex-col items-start justify-center",children:[d.jsx("h3",{className:"text-xs font-medium",children:A(N.VERSION_LIST_ITEM,{number:i})}),d.jsx("p",{className:"text-xxs",children:d.jsx("time",{children:s})})]})]})})},rD=200,jv=Ne(),oD=()=>{const e=Q(m=>m.deployedVersionsList),t=Q(m=>m.saveFlowStatus),n=Q(m=>m.showDeployedHistory),{cancelDetachedMode:r,getDeployedVersionsList:o,migrateAndLoadDeployedFlow:s}=Te();Tv({onKeyPress:n?r:void 0});const i=O.useRef(),[l,a]=O.useState("loading"),[c,u]=O.useState(null);c!==null&&!n&&u(null);const f=O.useCallback(m=>{m>=0&&m<=e.length-1?u(m):u(null)},[e.length]),p=O.useCallback(m=>{var S;const g=(S=i.current)==null?void 0:S[m];g?(jv.info("load version",g.id),s(g)):jv.error("version not found")},[s]),h=O.useCallback(()=>{a("loading"),o({pageSize:rD}).then(m=>{a("loaded"),i.current=m}).catch(()=>{a("error"),i.current=void 0})},[o]);O.useLayoutEffect(()=>{n&&h()},[h,n]);const E=l==="error",y=e.length>0,v=t==="saved";return n?d.jsxs("div",{"data-testid":"cfb__deployed-versions-sidebar",className:"flex h-full flex-col py-3",children:[d.jsxs("section",{className:"flex items-center justify-between self-stretch px-4 pb-1",children:[d.jsxs("h2",{className:"flex items-center gap-1 text-tiny font-bold uppercase leading-none tracking-wide",children:[d.jsx(re,{className:"text-xs text-foreground/50",tag:"clock-rotate-left"}),A(N.VERSION_HISTORY)]}),d.jsxs("button",{className:"flex items-center justify-center px-0.5",onClick:r,type:"button",children:[d.jsx("span",{className:"sr-only",children:A(N.CLOSE)}),d.jsx(re,{tag:"xmark"})]})]}),d.jsxs("div",{className:`${y?"overflow-y-auto":"h-full"}`,children:[l!=="loaded"?d.jsxs("div",{className:`flex flex-col justify-center gap-y-4 p-4 text-sm leading-none tracking-wide text-foreground/50 ${y?"":"h-full"}`,children:[d.jsxs("div",{className:"flex flex-col items-center justify-center gap-y-2 gap-x-2",children:[E?d.jsx(re,{className:"text-negative",tag:"circle-exclamation"}):d.jsx(re,{className:"animate-spin",tag:"arrows-rotate"}),d.jsx("p",{"aria-live":E?"assertive":"polite",className:`${E?"text-negative":"font-bold uppercase text-foreground/50"}`,role:E?"alert":"status",children:A(E?N.ERROR_FETCHING_DEPLOYED_VERSIONS:N.STATUS_LOADING)})]}),E?d.jsx("div",{className:"flex w-full items-center justify-center",children:d.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:h,type:"button",children:A(N.RESYNC)})}):null]}):null,!y&&l==="loaded"?d.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
+ `,children:d.jsxs("div",{className:"flex flex-col items-center justify-center gap-y-2 gap-x-2",children:[d.jsx(re,{tag:"circle-exclamation"}),Ua(N.NO_DEPLOYED_VERSIONS)]})}):null,y?d.jsx("ol",{children:e.map((m,g)=>d.jsx(nD,{itemIndex:g,isDisabled:!v,isSelected:g===c,onClick:p,onSelected:f,relativeTimeSince:m.relativeTimeSince,version:m.version},m.id))}):null]})]}):null},sD=()=>{const{getFlagNames:e}=Uv();return d.jsxs("div",{className:"rounded-sm border border-gray-200 p-2",children:[d.jsx("h3",{className:"w-full",children:"Feature Flags"}),d.jsx("div",{className:"flex flex-col gap-y-2 py-2",children:e().map(t=>d.jsx(iD,{flagName:t},t))})]})},iD=({flagName:e})=>{const{toggleFlag:t}=Uv(),r=Ir(o=>o[e])?"translate-x-5 bg-positive":"translate-x-0 bg-negative";return d.jsxs("label",{className:"flex cursor-pointer items-center",children:[d.jsxs("div",{className:"relative",children:[d.jsx("input",{type:"checkbox",className:"sr-only",onChange:()=>t(e)}),d.jsx("div",{className:"h-5 w-10 rounded-full bg-secondary/20",children:d.jsx("div",{className:`absolute left-1 top-1 h-3 w-3 rounded-full transition ${r}`})})]}),d.jsx("p",{className:"ml-3 text-sm font-medium",children:e})]})},lD=()=>{const[e,t]=O.useState(!1),n=()=>{t(r=>!r)};return d.jsx(Zn,{open:e,onOpenChange:t,placement:"bottom",role:"dialog",trigger:d.jsxs("button",{className:"group flex items-center justify-center gap-x-2 text-foreground/50 transition-colors hover:text-foreground/70",onClick:n,children:[d.jsx(re,{className:"text-foreground/40 transition-colors group-hover:text-foreground/50",size:"xl",tag:"circle-question"}),d.jsxs("span",{className:"text-xs font-semibold",children:[A(N.HELP),d.jsx("span",{className:"sr-only",children:A(N.MORE_INFO_TESTING_YOUR_FLOW)})]})]}),children:d.jsxs("section",{className:"p-2",children:[d.jsx("h2",{className:"mb-4 text-2xl font-semibold",children:"Testing Your Call Flow"}),d.jsxs("div",{className:"text-sm",children:[d.jsx("p",{children:"To test the current working version (draft) of your Call Flow, follow these steps:"}),d.jsxs("ol",{className:"my-4 list-inside list-decimal",children:[d.jsxs("li",{className:"mb-2 list-item",children:["Go to the settings tab of the purchased phone number you want to use for testing:  ",d.jsx("a",{className:"underline hover:text-background/80",href:"/phone_numbers",target:"_blank",rel:"noopener noreferrer",children:"Purchased Phone Numbers"})]}),d.jsxs("li",{className:"mb-2",children:["Choose the appropriate Call Flow for handling your calls:  ",d.jsx("a",{className:"underline hover:text-background/80",href:"/call_flows",target:"_blank",rel:"noopener noreferrer",children:"Call Flows"})]}),d.jsx("li",{className:"mb-2",children:"Select the working version (draft) of the chosen Call Flow."}),d.jsx("li",{children:"When you make a call to the number, it should now execute the working version of your Call Flow upon answering."})]}),d.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."})]})]})})},aD=(e,t)=>({label:A(Fa[e].label),nodes:Object.entries(Fa[e].nodes).reduce((n,[r,o])=>(((typeof o.active=="boolean"?o.active:o.active[gA])||t)&&n.push({deprecated:!!o.deprecated,title:A(o.label),type:r}),n),[]).sort((n,r)=>n.title.localeCompare(r.title))}),Vv=Ne(),cD=["action","forwardTo","recording","input","decision"],uD=()=>{const e=Ir(i=>i.showAllNodes),t=Q(i=>i.isCanvasInteractive),{addNode:n,setDragNodeType:r}=Te(),o=O.useCallback(i=>{i.preventDefault();const{nodeType:l}=i.currentTarget.dataset;l?n({nodeType:l}):Vv.error("No nodeType found on click event")},[n]),s=O.useCallback(i=>{i.preventDefault();const{nodeType:l}=i.currentTarget.dataset;l?r(l):Vv.error("No nodeType found on drag event")},[r]);return d.jsx("ul",{className:"py-3 px-2",id:"sidebar-node-list",children:cD.map(i=>d.jsx("li",{children:d.jsx(dD,{enableNodeButtons:t,group:i,handleOnClick:o,handleDragStart:s,showAllNodes:e})},i))})},dD=({enableNodeButtons:e=!0,group:t,handleOnClick:n,handleDragStart:r,showAllNodes:o})=>{const s=aD(t,o),i=`ngm-heading-${AA(s.label)}`;return d.jsxs(d.Fragment,{children:[d.jsx("h2",{className:"px-2 pb-1 text-tiny font-bold uppercase tracking-wide text-foreground/50",id:i,children:s.label}),d.jsx("ul",{"aria-labelledby":i,className:"flex flex-1 flex-col gap-y-1 pb-2",children:s.nodes.map(l=>d.jsx("li",{children:d.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
+ hover:border-primary hover:bg-primary/20 enabled:hover:shadow-md`,"data-node-type":l.type,disabled:!e,draggable:e,onClick:e?n:void 0,onDragStart:e?r:void 0,children:[d.jsx(re,{tag:"circle-small",className:"text-primary"}),d.jsxs("span",{className:"text-left text-xs font-medium line-clamp-2",children:[l.title,l.deprecated&&d.jsxs("span",{className:"text-foreground/70",children:[" ",A(N.DEPRECATED)]})]})]})},l.type))})]})},fD=()=>{const{addToast:e,restoreDeployedFlow:t}=Te(),n=Q(o=>o.workingFlowCopy),r=()=>{t(),e({message:A(N.VERSION_RESTORED),status:"success"})};return n?d.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:r,children:A(N.RESTORE)}):null},pD={"awaiting-save":N.STATUS_SAVING,"document-sync":N.STATUS_LOCKED,error:N.STATUS_ERROR,initial:N.STATUS_LOADING,saved:N.STATUS_SAVED,saving:N.STATUS_SAVING},$v=e=>(e.preventDefault(),e.returnValue=""),Hv=(e,t)=>e==="document-sync"?e:t,hD=()=>{const e=Q(p=>p.detachedMode),t=Q(p=>p.saveFlowStatus),n=Q(p=>p.httpError),[r,o]=O.useState(!0),[s,i]=O.useState(Hv(n,t)),l=pD[s],a=t==="error"||n,c=Hv(n,t),u=O.useRef(!1);O.useEffect(()=>{c==="initial"&&!u.current?(u.current=!0,i(c),o(!1),setTimeout(()=>{o(!0)},SA)):c!=="initial"&&r&&(u.current=!1,i(c))},[r,c]),O.useEffect(()=>{if(!(t==="saved"||n))return addEventListener("beforeunload",$v,{capture:!0}),()=>{removeEventListener("beforeunload",$v,{capture:!0})}},[n,t]);let f="";switch(!0){case a:f="px-1.5 py-0.5 bg-negative/20 text-negative";break;case s==="saved":f="text-foreground/50";break;default:f="px-1.5 py-0.5 bg-foreground/30 text-background"}return e?null:d.jsx("div",{"aria-live":a?"assertive":"polite","data-testid":"cfb__status",className:"flex",role:a?"alert":"status",children:d.jsxs("div",{className:`flex gap-x-1 rounded text-xxs ${f}`,children:[d.jsx("p",{children:l==="STATUS_SAVED"?d.jsx(mD,{}):A(l)}),a&&d.jsx(Zn,{placement:"bottom",trigger:d.jsxs("div",{role:"tooltip",tabIndex:0,children:[d.jsx("span",{className:"sr-only",children:A(N.MORE_INFO_STATUS_ERROR)}),d.jsx(re,{tag:"circle-exclamation"})]}),children:A(n==="document-sync"?N.INFO_STATUS_ERROR_OUT_OF_SYNC:N.INFO_STATUS_ERROR)})]})})},mD=()=>{const e=Q(s=>s.documentLastUpdated),t=O.useCallback((s,...i)=>Q0(ov(),{numeric:"always",style:"narrow"})(s,{excludeUnits:{second:!0},...i}),[]),n=e?t(e):void 0,[r,o]=O.useState(n);return O.useEffect(()=>{if(!e)return;const s=setInterval(()=>{o(t(e))},1e3);return()=>clearInterval(s)},[e,t]),d.jsxs(d.Fragment,{children:[A(N.SAVED)," ",d.jsx("time",{children:r})]})},gD=()=>{const e=Ir(i=>i.showDevOptions),{exportStoreData:t}=Te(),n=Q(i=>i.flowTitle),r=Q(i=>i.showDeployedHistory),o=O.useRef(null),s=i=>{i.preventDefault(),o.current&&o.current.showModal()};return d.jsxs(d.Fragment,{children:[d.jsxs("section",{className:"hidden h-full w-1/6 min-w-[160px] shrink-0 flex-col bg-background text-foreground sm:flex",children:[d.jsxs("nav",{className:"flex shrink-0 items-center justify-between px-3 py-2",children:[d.jsx(eD,{}),e&&d.jsx("button",{className:"rounded bg-positive p-1 px-2 text-xs text-background",onClick:s,children:"Dev Options"})]}),d.jsx("section",{className:"px-2 py-2",children:d.jsxs("div",{className:"divide-y divide-foreground/10 rounded-lg border border-foreground/10",children:[d.jsx("h1",{className:"block w-full shrink-0 p-2 text-sm font-semibold leading-tight line-clamp-2",children:n||d.jsx(d.Fragment,{children:" "})}),d.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-x-1 gap-y-2 p-2",children:[d.jsx("div",{className:"flex-1",children:d.jsx(hD,{})}),d.jsxs("menu",{className:"flex items-center justify-center gap-x-1",children:[r?d.jsx(fD,{}):d.jsx(Zb,{}),d.jsx(tD,{})]})]})]})}),d.jsxs("section",{className:"h-full overflow-y-auto",children:[r?null:d.jsx(uD,{}),d.jsx(oD,{})]}),d.jsx("section",{className:"flex flex-col items-start justify-center gap-y-5 px-2 pt-3 pb-4",children:d.jsxs("div",{className:"flex flex-col items-start justify-center gap-y-3 px-2",children:[d.jsx(qb,{}),d.jsx(lD,{})]})})]}),e&&d.jsx("dialog",{className:"z-50 my-10 rounded-lg border border-foreground/10 bg-background text-foreground",ref:o,children:d.jsx("form",{children:d.jsxs("fieldset",{children:[d.jsxs("legend",{className:"flex w-full justify-between pb-2",children:[d.jsx("h1",{className:"text-2xl leading-10",children:"Dev Options"}),d.jsxs("button",{className:"p-1 pt-0 font-semibold",formMethod:"dialog",children:[d.jsx("span",{className:"sr-only",children:"Close"}),d.jsx(re,{tag:"xmark",size:"lg"})]})]}),d.jsxs("div",{className:"mb-1 rounded-sm border border-gray-200 p-2",children:[d.jsx("h3",{className:"w-full",children:"Flow Data"}),d.jsx("div",{className:"flex flex-row gap-x-2 py-2",children:d.jsx("div",{className:"flex items-center",children:d.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"})})})]}),d.jsx(sD,{})]})})})]})},ED=()=>{const e=O.useRef(null),[t,n]=O.useState(),[r,o]=O.useState(null);return O.useLayoutEffect(()=>(e.current=new ResizeObserver(([s])=>n(s)),r&&e.current.observe(r),()=>{var s;return(s=e.current)==null?void 0:s.disconnect()}),[r]),{observerEntry:t,setTarget:o}},yD=({rootAppHeight:e,rootAppWidth:t})=>{Q.setState({rootAppHeight:e,rootAppWidth:t})},vD=()=>{const{observerEntry:e,setTarget:t}=ED();return O.useEffect(()=>{e&&(Ne().log("resized",{rootAppHeight:e.contentRect.height,rootAppWidth:e.contentRect.width}),yD({rootAppHeight:e.contentRect.height,rootAppWidth:e.contentRect.width}))},[e]),{rootTarget:t}};function _D(){Ne().debug("Hello World!");const{rootTarget:e}=vD(),t=Q(o=>o.colorMode)??"",n=Q(o=>o.httpError),r=n!==void 0&&n!=="document-sync";return d.jsx(d.Fragment,{children:d.jsx("div",{className:`${t} flex h-full w-full bg-backgroundAlt text-foreground`,ref:e,children:r?d.jsx(X2,{errorType:n}):d.jsxs(d.Fragment,{children:[d.jsx(gD,{}),d.jsx(wb,{}),d.jsx(Ab,{}),d.jsxs(tf,{children:[d.jsx(AL,{}),d.jsxs(OL,{children:[d.jsxs(Zs,{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:[d.jsx(gb,{}),d.jsx(Sb,{})]}),d.jsx($b,{}),d.jsx(Pb,{}),d.jsx(mb,{}),d.jsx(IL,{})]})]})]})})})}const SD='@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")}',Bv=Ne(),xD=e=>{if(!e||!e.getFlowURL||!e.updateFlowURL)throw new TypeError("Invalid or missing required params")};function RD(e){xD(e);const{backButtonHref:t,deployFlowURL:n,getAiAgentsURL:r=`${window.location.origin}${T_}`,getFlowURL:o,getSwmlScriptsURL:s=`${window.location.origin}${A_}`,rootElementId:i="sw-cfb-root",styleHref:l="https://cdn.signalwire.com/npm/@signalwire/cfb@latest/dist/style.css",updateFlowURL:a,voicesURL:c="https://cdn.signalwire.com/npm/@signalwire/cfb@latest/dist/voices.json"}=e;Vf.getState().actions.init({voicesURL:c}).catch(p=>{Bv.error("Error initializing voices",p)});const u=document.getElementById(i);if(Q.setState({backButtonHref:t,deployFlowURL:n,getFlowURL:o,rootElement:u,rootElementId:i,updateFlowURL:a}),r&&en.getState().actions.init({getAiAgentsURL:r}),s&&_n.getState().actions.init({getSwmlScriptsURL:s}),A2().catch(p=>{Bv.error("Error initializing i18n",p)}),Yb(),!u)throw new Error(`Id: '${i}' not found in the DOM`);u.attachShadow({mode:"open"}),u.shadowRoot&&oc.createRoot(u.shadowRoot).render(d.jsxs(O.StrictMode,{children:[d.jsx("link",{type:"text/css",rel:"stylesheet",href:l}),d.jsx(_D,{})]}));const f=document.createElement("style");document.head.appendChild(f),f.appendChild(document.createTextNode(SD))}Fr.main=RD,Object.defineProperty(Fr,Symbol.toStringTag,{value:"Module"})});