@zuplo/editor 1.0.36080536493 → 1.0.36130159178

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["static/js/editor.main-B7ZQNwu9.js","static/js/chunk-6hGRweTZ.js","static/js/preload-helper-DxkSl20Q.js","static/js/editor.api2-DJi3_-IJ.js","static/css/editor-DU9oqspw.css","static/js/workers-CfQPK2eg.js","static/js/monaco.contribution-CZRO3JpP.js","static/js/McpCapabilityFilterDesigner-6lZzsEzv.js","static/js/dist-CGGP2WKw.js","static/js/GraphiQLConsole-DMOxH2wu.js","static/js/esm-BrawuL7Q.js","static/js/definition-C7QrKMH2.js","static/css/GraphiQLConsole-C4zv7lh0.css"])))=>i.map(i=>d[i]);
2
- import{a as e,i as t,n,o as r,r as i,t as a}from"./chunk-6hGRweTZ.js";import{$ as o,$n as s,$t as c,A as l,An as u,At as d,B as f,Bn as p,Bt as m,C as h,Cn as g,Ct as _,D as v,Dn as y,Dt as b,E as x,En as S,Et as C,F as w,Fn as T,Ft as E,G as D,Gn as O,Gt as k,H as A,Hn as j,Ht as M,I as N,In as P,It as F,J as I,Jn as L,Jt as R,K as z,Kn as B,Kt as ee,L as te,Ln as V,Lt as ne,M as re,Mn as ie,Mt as ae,N as oe,Nn as se,Nt as ce,O as le,On as ue,Ot as de,P as fe,Pn as pe,Pt as me,Q as he,Qn as ge,Qt as _e,R as ve,Rn as ye,Rt as be,S as xe,Sn as Se,St as Ce,T as we,Tn as Te,U as Ee,Un as De,Ut as Oe,V as ke,Vn as Ae,Vt as je,W as Me,Wn as Ne,Wt as Pe,X as Fe,Xn as Ie,Xt as Le,Y as Re,Yn as ze,Yt as Be,Z as Ve,Zn as He,Zt as Ue,_n as We,_t as Ge,a as Ke,an as qe,ar as Je,at as Ye,b as Xe,bn as Ze,bt as Qe,c as $e,cn as et,ct as tt,d as nt,dn as rt,dt as it,en as at,er as ot,et as st,fn as ct,ft as lt,gn as ut,gt as dt,hn as ft,ht as pt,i as mt,in as ht,ir as gt,it as _t,j as vt,jn as yt,jt as bt,k as xt,kn as St,kt as Ct,l as wt,ln as Tt,lt as Et,mn as Dt,mt as Ot,n as kt,nn as At,nr as jt,nt as Mt,o as Nt,on as Pt,or as Ft,ot as It,pn as Lt,pt as Rt,q as zt,qn as Bt,qt as Vt,r as Ht,rn as Ut,rr as Wt,rt as Gt,s as Kt,sn as qt,sr as Jt,st as Yt,t as Xt,tn as Zt,tr as Qt,tt as $t,u as en,un as tn,ut as nn,vn as rn,vt as an,w as on,wn as sn,wt as cn,x as ln,xn as un,xt as dn,y as fn,yn as pn,yt as mn,z as hn,zn as gn,zt as _n}from"./dist-CGGP2WKw.js";import{t as vn}from"./preload-helper-DxkSl20Q.js";import{$ as yn,C as bn,E as xn,F as Sn,G as Cn,I as wn,J as Tn,K as En,M as Dn,O as On,P as kn,Q as An,S as jn,V as Mn,X as eee,Y as Nn,Z as Pn,_ as Fn,a as In,at as Ln,b as Rn,c as tee,ct as zn,d as Bn,et as Vn,f as nee,h as Hn,i as Un,k as Wn,l as Gn,lt as Kn,m as qn,n as Jn,nt as Yn,o as Xn,p as Zn,r as Qn,rt as $n,s as er,st as tr,t as nr,tt as rr,ut as ir,w as ar,x as or,y as sr}from"./definition-C7QrKMH2.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var cr=a((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m)if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),ree=a(((e,t)=>{t.exports=cr()})),lr=a((e=>{var t=ree(),n=Jt(),r=Ft();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function d(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=d(e),t!==null)return t;e=e.sibling}return null}var f=Object.assign,p=Symbol.for(`react.element`),m=Symbol.for(`react.transitional.element`),h=Symbol.for(`react.portal`),g=Symbol.for(`react.fragment`),_=Symbol.for(`react.strict_mode`),v=Symbol.for(`react.profiler`),y=Symbol.for(`react.consumer`),b=Symbol.for(`react.context`),x=Symbol.for(`react.forward_ref`),S=Symbol.for(`react.suspense`),C=Symbol.for(`react.suspense_list`),w=Symbol.for(`react.memo`),T=Symbol.for(`react.lazy`),E=Symbol.for(`react.activity`),D=Symbol.for(`react.memo_cache_sentinel`),O=Symbol.iterator;function k(e){return typeof e!=`object`||!e?null:(e=O&&e[O]||e[`@@iterator`],typeof e==`function`?e:null)}var A=Symbol.for(`react.client.reference`);function j(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===A?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case g:return`Fragment`;case v:return`Profiler`;case _:return`StrictMode`;case S:return`Suspense`;case C:return`SuspenseList`;case E:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case h:return`Portal`;case b:return e.displayName||`Context`;case y:return(e._context.displayName||`Context`)+`.Consumer`;case x:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case w:return t=e.displayName||null,t===null?j(e.type)||`Memo`:t;case T:t=e._payload,e=e._init;try{return j(e(t))}catch{}}return null}var M=Array.isArray,N=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,P=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F={pending:!1,data:null,method:null,action:null},I=[],L=-1;function R(e){return{current:e}}function z(e){0>L||(e.current=I[L],I[L]=null,L--)}function B(e,t){L++,I[L]=e.current,e.current=t}var ee=R(null),te=R(null),V=R(null),ne=R(null);function re(e,t){switch(B(V,t),B(te,e),B(ee,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Ld(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Ld(t),e=Rd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}z(ee),B(ee,e)}function ie(){z(ee),z(te),z(V)}function ae(e){e.memoizedState!==null&&B(ne,e);var t=ee.current,n=Rd(t,e.type);t!==n&&(B(te,e),B(ee,n))}function oe(e){te.current===e&&(z(ee),z(te)),ne.current===e&&(z(ne),Vf._currentValue=F)}var se,ce;function le(e){if(se===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);se=t&&t[1]||``,ce=-1<e.stack.indexOf(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["static/js/editor.main-B7ZQNwu9.js","static/js/chunk-6hGRweTZ.js","static/js/preload-helper-DxkSl20Q.js","static/js/editor.api2-DJi3_-IJ.js","static/css/editor-DU9oqspw.css","static/js/workers-CfQPK2eg.js","static/js/monaco.contribution-CZRO3JpP.js","static/js/McpCapabilityFilterDesigner-DXYtp7x8.js","static/js/dist-BoQgQekX.js","static/js/GraphiQLConsole-PIko1Gzn.js","static/js/esm-B20_T2Iv.js","static/js/definition-C7QrKMH2.js","static/css/GraphiQLConsole-C4zv7lh0.css"])))=>i.map(i=>d[i]);
2
+ import{a as e,i as t,n,o as r,r as i,t as a}from"./chunk-6hGRweTZ.js";import{$ as o,$n as s,$t as c,A as l,An as u,At as d,B as f,Bn as p,Bt as m,C as h,Cn as g,Ct as _,D as v,Dn as y,Dt as b,E as x,En as S,Et as C,F as w,Fn as T,Ft as E,G as D,Gn as O,Gt as k,H as A,Hn as j,Ht as M,I as N,In as P,It as F,J as I,Jn as L,Jt as R,K as z,Kn as B,Kt as ee,L as te,Ln as V,Lt as ne,M as re,Mn as ie,Mt as ae,N as oe,Nn as se,Nt as ce,O as le,On as ue,Ot as de,P as fe,Pn as pe,Pt as me,Q as he,Qn as ge,Qt as _e,R as ve,Rn as ye,Rt as be,S as xe,Sn as Se,St as Ce,T as we,Tn as Te,U as Ee,Un as De,Ut as Oe,V as ke,Vn as Ae,Vt as je,W as Me,Wn as Ne,Wt as Pe,X as Fe,Xn as Ie,Xt as Le,Y as Re,Yn as ze,Yt as Be,Z as Ve,Zn as He,Zt as Ue,_n as We,_t as Ge,a as Ke,an as qe,ar as Je,at as Ye,b as Xe,bn as Ze,bt as Qe,c as $e,cn as et,ct as tt,d as nt,dn as rt,dt as it,en as at,er as ot,et as st,fn as ct,ft as lt,gn as ut,gt as dt,hn as ft,ht as pt,i as mt,in as ht,ir as gt,it as _t,j as vt,jn as yt,jt as bt,k as xt,kn as St,kt as Ct,l as wt,ln as Tt,lt as Et,mn as Dt,mt as Ot,n as kt,nn as At,nr as jt,nt as Mt,o as Nt,on as Pt,or as Ft,ot as It,pn as Lt,pt as Rt,q as zt,qn as Bt,qt as Vt,r as Ht,rn as Ut,rr as Wt,rt as Gt,s as Kt,sn as qt,sr as Jt,st as Yt,t as Xt,tn as Zt,tr as Qt,tt as $t,u as en,un as tn,ut as nn,vn as rn,vt as an,w as on,wn as sn,wt as cn,x as ln,xn as un,xt as dn,y as fn,yn as pn,yt as mn,z as hn,zn as gn,zt as _n}from"./dist-BoQgQekX.js";import{t as vn}from"./preload-helper-DxkSl20Q.js";import{$ as yn,C as bn,E as xn,F as Sn,G as Cn,I as wn,J as Tn,K as En,M as Dn,O as On,P as kn,Q as An,S as jn,V as Mn,X as eee,Y as Nn,Z as Pn,_ as Fn,a as In,at as Ln,b as Rn,c as tee,ct as zn,d as Bn,et as Vn,f as nee,h as Hn,i as Un,k as Wn,l as Gn,lt as Kn,m as qn,n as Jn,nt as Yn,o as Xn,p as Zn,r as Qn,rt as $n,s as er,st as tr,t as nr,tt as rr,ut as ir,w as ar,x as or,y as sr}from"./definition-C7QrKMH2.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var cr=a((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m)if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),ree=a(((e,t)=>{t.exports=cr()})),lr=a((e=>{var t=ree(),n=Jt(),r=Ft();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function d(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=d(e),t!==null)return t;e=e.sibling}return null}var f=Object.assign,p=Symbol.for(`react.element`),m=Symbol.for(`react.transitional.element`),h=Symbol.for(`react.portal`),g=Symbol.for(`react.fragment`),_=Symbol.for(`react.strict_mode`),v=Symbol.for(`react.profiler`),y=Symbol.for(`react.consumer`),b=Symbol.for(`react.context`),x=Symbol.for(`react.forward_ref`),S=Symbol.for(`react.suspense`),C=Symbol.for(`react.suspense_list`),w=Symbol.for(`react.memo`),T=Symbol.for(`react.lazy`),E=Symbol.for(`react.activity`),D=Symbol.for(`react.memo_cache_sentinel`),O=Symbol.iterator;function k(e){return typeof e!=`object`||!e?null:(e=O&&e[O]||e[`@@iterator`],typeof e==`function`?e:null)}var A=Symbol.for(`react.client.reference`);function j(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===A?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case g:return`Fragment`;case v:return`Profiler`;case _:return`StrictMode`;case S:return`Suspense`;case C:return`SuspenseList`;case E:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case h:return`Portal`;case b:return e.displayName||`Context`;case y:return(e._context.displayName||`Context`)+`.Consumer`;case x:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case w:return t=e.displayName||null,t===null?j(e.type)||`Memo`:t;case T:t=e._payload,e=e._init;try{return j(e(t))}catch{}}return null}var M=Array.isArray,N=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,P=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F={pending:!1,data:null,method:null,action:null},I=[],L=-1;function R(e){return{current:e}}function z(e){0>L||(e.current=I[L],I[L]=null,L--)}function B(e,t){L++,I[L]=e.current,e.current=t}var ee=R(null),te=R(null),V=R(null),ne=R(null);function re(e,t){switch(B(V,t),B(te,e),B(ee,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Ld(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Ld(t),e=Rd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}z(ee),B(ee,e)}function ie(){z(ee),z(te),z(V)}function ae(e){e.memoizedState!==null&&B(ne,e);var t=ee.current,n=Rd(t,e.type);t!==n&&(B(te,e),B(ee,n))}function oe(e){te.current===e&&(z(ee),z(te)),ne.current===e&&(z(ne),Vf._currentValue=F)}var se,ce;function le(e){if(se===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);se=t&&t[1]||``,ce=-1<e.stack.indexOf(`
3
3
  at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
4
4
  `+se+e+ce}var ue=!1;function de(e,t){if(!e||ue)return``;ue=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,`props`,{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,`name`,{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
5
5
  `),l=s.split(`
@@ -247,10 +247,10 @@ You can add a description to the \`${uL}\` by passing a \`${mL}\` component as a
247
247
  Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${uL}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component.
248
248
 
249
249
  For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return H.useEffect(()=>{document.getElementById(e.current?.getAttribute(`aria-describedby`))||console.warn(t)},[t,e]),null},XRe=sL,ZRe=cL,QRe=lL,$Re=dL,eze=gL,tze=vL,nze=pL,rze=hL;function ize({...e}){return(0,U.jsx)(XRe,{"data-slot":`alert-dialog`,...e})}function aze({...e}){return(0,U.jsx)(ZRe,{"data-slot":`alert-dialog-portal`,...e})}function oze({className:e,...t}){return(0,U.jsx)(QRe,{"data-slot":`alert-dialog-overlay`,className:W(`data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50`,e),...t})}function sze({className:e,...t}){return(0,U.jsxs)(aze,{children:[(0,U.jsx)(oze,{}),(0,U.jsx)($Re,{"data-slot":`alert-dialog-content`,className:W(`bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg`,e),...t})]})}function cze({className:e,...t}){return(0,U.jsx)(`div`,{"data-slot":`alert-dialog-header`,className:W(`flex flex-col gap-2 text-center sm:text-left`,e),...t})}function lze({className:e,...t}){return(0,U.jsx)(`div`,{"data-slot":`alert-dialog-footer`,className:W(`flex flex-col-reverse gap-2 sm:flex-row sm:justify-end`,e),...t})}function uze({className:e,...t}){return(0,U.jsx)(nze,{"data-slot":`alert-dialog-title`,className:W(`text-lg font-semibold`,e),...t})}function dze({className:e,...t}){return(0,U.jsx)(rze,{"data-slot":`alert-dialog-description`,className:W(`text-muted-foreground text-sm`,e),...t})}function fze({className:e,variant:t,...n}){return(0,U.jsx)(eze,{className:W(Hb({variant:t}),e),...n})}function pze({className:e,...t}){return(0,U.jsx)(tze,{className:W(Hb({variant:`outline`}),e),...t})}var yL=({open:e,onOpenChange:t,title:n,description:r,actionLabel:i,variant:a,isPending:o,onConfirm:s,contentClassName:c})=>(0,U.jsx)(ize,{open:e,onOpenChange:t,children:(0,U.jsxs)(sze,{className:c,children:[(0,U.jsxs)(cze,{children:[(0,U.jsx)(uze,{children:n}),(0,U.jsx)(dze,{children:r})]}),(0,U.jsxs)(lze,{children:[(0,U.jsx)(pze,{disabled:o??!1,children:`Cancel`}),(0,U.jsx)(fze,{variant:a,disabled:o,onClick:e=>{e.preventDefault(),s()},children:(0,U.jsx)(HI,{loading:o??!1,children:i})})]})]})});function bL({open:e,onOpenChange:t,onDiscard:n}){return(0,U.jsx)(yL,{open:e,onOpenChange:t,title:`Unsaved changes`,description:`You have unsaved changes. Are you sure you want to discard them?`,actionLabel:`Discard`,variant:`destructive`,onConfirm:n,contentClassName:`w-[420px]`})}function xL(e,t){let[n,r]=(0,H.useState)(!1);return{showConfirm:n,setShowConfirm:r,guardedClose:(0,H.useCallback)(()=>{e?r(!0):t()},[e,t]),handleDiscard:(0,H.useCallback)(()=>{r(!1),t()},[t])}}var SL=({error:e,size:t=24})=>{switch(e.status){case 401:return(0,U.jsx)(yf,{size:t});case 403:return(0,U.jsx)($u,{size:t});case 404:return(0,U.jsx)(dd,{size:t});default:return(0,U.jsx)(vd,{size:t})}},mze=({error:e})=>(0,U.jsx)(`div`,{className:`flex items-center gap-2 rounded-full border-2 border-neutral-100 bg-neutral-50 text-neutral-300 p-4`,children:(0,U.jsx)(SL,{error:e})}),hze=({error:e})=>{switch(e.status){case 401:return(0,U.jsx)(hT,{href:`https://zuplo.com/docs/articles/accounts/managing-account-members`,children:`Learn more about Managing Account Members`});default:return null}},gze=({error:e,title:t=`Unable to access`,children:n,className:r,variant:i=`default`})=>(0,U.jsxs)(Ub,{variant:i,className:W(`w-full flex items-center gap-8`,r),children:[(0,U.jsx)(mze,{error:e}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,U.jsx)(Wb,{children:t}),(0,U.jsxs)(Gb,{className:`flex flex-col gap-2`,children:[ux(e),(0,U.jsx)(hze,{error:e}),n]})]})]}),CL=({successMessage:e}={})=>{let t=Ep();return{onSuccess:n=>{t.success(n??e,{icon:(0,U.jsx)(fd,{size:18})})},onError:e=>t.error(ux(e),{icon:e instanceof s?(0,U.jsx)(SL,{error:e,size:18}):(0,U.jsx)(vd,{size:18})})}},wL=(e,t,n)=>ox(je.consumersForBucket(e,t),n),_ze=()=>{let e=bt(),t=CL();return Oe({mutationFn:t=>e.fetch(ae.consumers.createConsumer(t)),onSuccess:()=>t.onSuccess(`Consumer created`),onError:t.onError})},vze=()=>{let e=bt(),t=CL();return Oe({mutationFn:async t=>{await e.fetch(ae.consumers.updateConsumer(t))},onSuccess:()=>t.onSuccess(`Consumer updated`),onError:t.onError})},TL=(e,t,n)=>ox(je.consumer(e,t),n),EL=({text:e,className:t=``})=>e.length>0?(0,U.jsx)(`div`,{className:(0,zI.default)(`text-red-700 mt-2 text-xs`,t),children:e}):null,DL=e=>e.toLowerCase().replace(/[\s_]+/g,`-`).replace(/[^a-zA-Z\d\s_]+/g,`-`).trim(),yze=({consumer:e={sub:``,externalUsers:[],metadata:`{}`},children:t,title:n,allowSubjectChange:r=!0,onSubmit:i,open:a,onOpenChange:o,error:s,bucketId:c,environmentType:l})=>{let{control:u,register:d,handleSubmit:f,formState:{errors:p,isDirty:m},reset:h,resetField:g}=vA({defaultValues:{...e,externalUsers:(e.externalUsers??[]).map(e=>e.email).join(`, `)},mode:`onBlur`,resolver:xA(Tze)}),[_,v]=(0,H.useState)(!1),y=(0,H.useId)(),b=xL(m,(0,H.useCallback)(()=>o(!1),[o]));(0,H.useEffect)(()=>{a||h()},[a,h]);let x=!!(e.id&&c),S=(0,U.jsxs)(`form`,{id:y,onSubmit:f(async e=>{try{v(!0);let t=e.externalUsers.length>0?e.externalUsers.split(`,`).filter(e=>e.trim().length>0).map(e=>({email:e.trim()})):[];await i({...e,externalUsers:t}),o(!1)}finally{v(!1)}}),className:`space-y-5`,children:[(0,U.jsx)(SA,{error:s}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`label`,{className:`block text-sm font-medium mb-1.5`,htmlFor:`${y}-sub`,children:`Subject`}),(0,U.jsx)(gT,{type:`text`,autoComplete:`off`,placeholder:`my-consumer-subject`,id:`${y}-sub`,disabled:!r,"data-test":`consumer-subject`,...d(`sub`,{onChange:e=>{e.target.value=DL(e.target.value)}})}),p.sub?.message&&(0,U.jsx)(EL,{text:p.sub.message})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`label`,{className:`block text-sm font-medium mb-1.5`,htmlFor:`${y}-externalUsers`,children:[`Key managers`,` `,(0,U.jsx)(`span`,{className:`font-normal text-muted-foreground`,children:`— emails separated by commas`})]}),(0,U.jsx)(gT,{className:UI,type:`text`,autoComplete:`off`,placeholder:`manager@example.com, other-manager@example.com`,id:`${y}-externalUsers`,"data-test":`key-managers`,...d(`externalUsers`)}),p.externalUsers?.message&&(0,U.jsx)(EL,{text:p.externalUsers.message})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`label`,{className:`block text-sm font-medium mb-1.5`,htmlFor:`${y}-metadata`,children:[`Metadata`,` `,(0,U.jsx)(`span`,{className:`font-normal text-muted-foreground`,children:`— must be valid JSON`})]}),(0,U.jsx)(`div`,{className:`h-44 overflow-hidden rounded-md border px-0.5 py-1 shadow-xs`,children:(0,U.jsx)(Ek,{control:u,name:`metadata`,render:({field:{onChange:e,value:t}})=>(0,U.jsx)(rL,{className:UI,language:`json`,options:{autoIndent:`full`,formatOnPaste:!0,formatOnType:!0,lineNumbers:`off`,minimap:{enabled:!1},scrollBeyondLastLine:!1},onMount:async e=>{await e.getAction(`editor.action.formatDocument`)?.run(),g(`metadata`,{defaultValue:e.getValue(),keepDirty:!1})},value:t,onChange:e})})}),p.metadata?.message&&(0,U.jsx)(EL,{text:p.metadata.message})]})]});return(0,U.jsxs)(ow,{open:a,onOpenChange:e=>{e?o(!0):b.guardedClose()},children:[t&&(0,U.jsx)(sw,{asChild:!0,children:t}),(0,U.jsxs)(lw,{className:`sm:max-w-(--breakpoint-md)`,children:[(0,U.jsxs)(uw,{children:[(0,U.jsx)(fw,{children:n}),e.id?(0,U.jsx)(pw,{className:`font-mono text-xs`,children:e.sub}):null]}),x&&c?(0,U.jsxs)(hj,{defaultValue:`general`,children:[(0,U.jsxs)(gj,{variant:`underline`,children:[(0,U.jsxs)(_j,{variant:`underline`,value:`general`,children:[(0,U.jsx)(qf,{size:15}),`General`]}),(0,U.jsxs)(_j,{variant:`underline`,value:`api-keys`,"data-test":`consumer-api-keys-tab`,children:[(0,U.jsx)(mf,{size:15}),`API Keys`]})]}),(0,U.jsxs)(`div`,{className:`mt-4 h-[26rem] overflow-y-auto`,children:[(0,U.jsx)(vj,{value:`general`,forceMount:!0,children:S}),(0,U.jsx)(vj,{value:`api-keys`,children:(0,U.jsx)(bze,{bucketId:c,environmentType:l,consumer:e,onConsumerCreated:()=>o(!1)})})]})]}):(0,U.jsx)(`div`,{className:`mt-1`,children:S}),(0,U.jsxs)(dw,{children:[(0,U.jsx)(cw,{asChild:!0,children:(0,U.jsx)(X,{variant:`outline`,"data-test":`cancel-create-consumer-btn`,children:`Cancel`})}),(0,U.jsx)(X,{type:`submit`,form:y,disabled:_,"data-test":`save-consumer-btn`,children:(0,U.jsx)(HI,{loading:_,children:`Save consumer`})})]})]}),(0,U.jsx)(bL,{open:b.showConfirm,onOpenChange:b.setShowConfirm,onDiscard:b.handleDiscard})]})},bze=({bucketId:e,environmentType:t,consumer:n,onConsumerCreated:r})=>{let[i,a]=(0,H.useState)(!1),[o,s]=(0,H.useState)(!1),c=TL(e,n.sub,{useErrorBoundary:!1}),l=c.data?.apiKeys??[];return(0,U.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,U.jsxs)(X,{variant:`outline`,size:`sm`,className:`self-start`,"data-test":`add-consumer-api-key-btn`,onClick:()=>a(!0),children:[(0,U.jsx)(Mf,{className:`size-3.5`}),`Add key`]}),c.isLoading?(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,U.jsx)(bD,{className:`h-14 w-full`}),(0,U.jsx)(bD,{className:`h-14 w-full`})]}):c.isError?(0,U.jsx)(SA,{error:c.error}):l.length===0?(0,U.jsx)(`p`,{className:`py-4 text-center text-sm text-muted-foreground`,children:`This consumer has no API keys.`}):(0,U.jsx)(CA,{className:`divide-y overflow-hidden bg-surface-sunken`,children:l.map(e=>(0,U.jsx)(wze,{apiKey:e},e.id))}),(0,U.jsx)(Sze,{open:i,onOpenChange:a,onCreateConsumer:()=>{a(!1),s(!0)}}),(0,U.jsx)(Cze,{open:o,onOpenChange:s,bucketId:e,environmentType:t,consumer:n,onCreated:r})]})},xze=e=>{let t=e.match(/^(.*)-(\d+)$/);return t?`${t[1]}-${Number(t[2])+1}`:`${e}-1`},Sze=({open:e,onOpenChange:t,onCreateConsumer:n})=>(0,U.jsx)(ow,{open:e,onOpenChange:t,children:(0,U.jsxs)(lw,{children:[(0,U.jsxs)(uw,{children:[(0,U.jsx)(fw,{children:`Add another key?`}),(0,U.jsx)(pw,{children:`A consumer is a single identity. Every key on it authenticates as the same subject, so extra keys can't be told apart in analytics. If you want a key that stands on its own, create a separate consumer instead — it gets its own key, and you can tell the two apart in reports.`})]}),(0,U.jsxs)(dw,{children:[(0,U.jsx)(cw,{asChild:!0,children:(0,U.jsx)(X,{variant:`outline`,children:`Cancel`})}),(0,U.jsxs)(X,{"data-test":`add-key-create-consumer-btn`,onClick:n,children:[(0,U.jsx)(Nd,{className:`size-3.5`}),`Create new consumer`]})]})]})}),Cze=({open:e,onOpenChange:t,bucketId:n,environmentType:r,consumer:i,onCreated:a})=>{let{account:o,project:s}=sx([]),[c,l]=(0,H.useState)(``),u=_ze(),d=(0,H.useId)(),f=!!(o&&s&&r);return(0,H.useEffect)(()=>{e&&l(xze(i.sub))},[e,i.sub]),(0,U.jsx)(ow,{open:e,onOpenChange:t,children:(0,U.jsxs)(lw,{children:[(0,U.jsxs)(uw,{children:[(0,U.jsx)(fw,{children:`Create new consumer`}),(0,U.jsxs)(pw,{children:[`Creates a new consumer with the same metadata and key managers as`,(0,U.jsxs)(`span`,{className:`font-mono`,children:[` `,i.sub]}),`, and its own new API key. Give it a distinct subject.`]})]}),(0,U.jsx)(SA,{error:u.error}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`label`,{className:`block text-sm font-medium mb-1.5`,htmlFor:d,children:`Subject`}),(0,U.jsx)(gT,{id:d,type:`text`,autoComplete:`off`,placeholder:`my-consumer-subject`,"data-test":`duplicate-consumer-subject`,value:c,onChange:e=>l(DL(e.target.value))})]}),(0,U.jsxs)(dw,{children:[(0,U.jsx)(X,{variant:`outline`,onClick:()=>t(!1),disabled:u.isPending,children:`Cancel`}),(0,U.jsx)(X,{"data-test":`confirm-duplicate-consumer-btn`,disabled:u.isPending||c.length===0||!f,onClick:async()=>{if(!(!o||!s||!r))try{await u.mutateAsync({bucketId:n,accountName:o,projectName:s,environmentType:r,consumer:{sub:c,externalUsers:i.externalUsers??[],metadata:i.metadata}}),t(!1),a()}catch{}},children:(0,U.jsx)(HI,{loading:u.isPending,children:`Create consumer`})})]})]})})},OL=e=>new Date(e).toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`}),wze=({apiKey:e})=>{let[t,n]=(0,H.useState)(!1),r=e.expiresOn!=null&&Date.parse(e.expiresOn)<=Date.now();return(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5 p-3`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 w-full max-w-md items-center gap-0.5 rounded-md border bg-surface-muted py-0.5 pl-1.5 pr-1`,children:[(0,U.jsx)(ANe,{className:`min-w-0 flex-1 border-0 bg-transparent px-1 text-xs leading-6`,mask:`••••••••••••••••••••••••`,reveal:t,secret:e.key}),(0,U.jsx)(X,{variant:`ghost`,size:`icon-xs`,"aria-pressed":t,"aria-label":t?`Hide API key`:`Show API key`,title:t?`Hide API key`:`Show API key`,className:`shrink-0 text-muted-foreground hover:text-foreground`,onClick:()=>n(!t),children:t?(0,U.jsx)(Hd,{className:`size-3.5`}):(0,U.jsx)(Ud,{className:`size-3.5`})}),(0,U.jsx)(GI,{title:`Copy API key`,className:`flex size-6 shrink-0 items-center justify-center rounded-md hover:bg-accent`,textToCopy:e.key})]}),r&&(0,U.jsx)(rT,{variant:`destructive`,children:`Expired`})]}),(0,U.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`Created `,OL(e.createdOn),e.expiresOn?` · ${r?`Expired`:`Expires`} ${OL(e.expiresOn)}`:null]})]})},Tze=Ym({id:Gm().optional(),metadata:Gm().superRefine((e,t)=>{try{JSON.parse(e)}catch{return t.addIssue({code:K.custom,message:`Metadata needs to be a valid JSON`}),!1}}).optional(),externalUsers:Gm().superRefine((e,t)=>{if(e.length===0)return!0;let n=e.split(`,`).map(e=>e.trim()),r=n.filter((e,t)=>t!==n.indexOf(e)&&e.length>0);if(r.length>0)return t.addIssue({code:K.custom,message:`email ${r[0]} is duplicated`}),!1;let i=Gm().email();return n.forEach(e=>{if(!i.safeParse(e.trim()).success)return e.trim().length===0?!0:(t.addIssue({code:K.custom,message:`${e} is not a valid email`}),!1)}),!0}),sub:Gm().min(1,`Subject is required`).regex(/^[a-z0-9-_:]+$/,{message:`Subject can only use lowercase alphanumeric characters separated by dashes.`}).max(128,{message:`Subject must contain at most 128 characters`})});function Eze(e){if(typeof e!=`object`||!e)return null;let t=e,n=typeof t.sub==`string`?t.sub:void 0,r=typeof t.bucketId==`string`?t.bucketId:void 0;return!n||!r?null:{sub:n,bucketId:r,description:typeof t.description==`string`?t.description:void 0}}function Dze({data:e}){let[t,n]=(0,H.useState)(!1),{logEvent:r}=S(),{account:i,project:a}=sx([]),o=vze(),s=wL(e.bucketId,{name:e.sub},{enabled:t,useErrorBoundary:!1,refetchOnMount:!1,refetchOnWindowFocus:!1}),c=s.data?.data.find(t=>t.sub===e.sub),l=t&&(s.isLoading||s.isFetching),u=t&&!s.isFetching&&(s.isError||s.data!=null&&!c);return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(VMe,{sub:e.sub,description:e.description,loading:l,errorText:u?`Couldn’t load consumer “${e.sub}” — it may have been deleted.`:void 0,onOpen:()=>{r(`agent-z-consumer-card-clicked`,{account:i,project:a}),n(!0),(s.isError||s.data&&!c)&&s.refetch()}}),c?(0,U.jsx)(yze,{title:`Change consumer`,allowSubjectChange:!1,bucketId:e.bucketId,consumer:c,open:t,onOpenChange:n,error:o.error,onSubmit:async t=>{await o.mutateAsync({consumer:t,bucketId:e.bucketId}),r(`consumer-updated`,{account:i,project:a}),s.refetch()}},`${c.id??e.sub}:${s.dataUpdatedAt}`):null]})}var kL=function(e){return e.PRODUCTION=`PRODUCTION`,e.PREVIEW=`PREVIEW`,e.WORKING_COPY=`WORKING_COPY`,e}({});function AL(e,...t){return e==null?!1:t.includes(e)}var jL=({children:e,onClose:t,isOpen:n,title:r,showTitle:i=!0,className:a})=>{let o=(0,H.useRef)(null);return(0,U.jsx)(ow,{open:n,onOpenChange:e=>{e||t(!1)},children:(0,U.jsxs)(lw,{ref:o,className:W(`max-h-[calc(100vh-4rem)] overflow-y-auto`,a),onOpenAutoFocus:e=>{o.current?.contains(document.activeElement)||(e.preventDefault(),o.current?.focus())},children:[(0,U.jsx)(fw,{className:W(i?`text-xl font-medium`:`sr-only`),children:r}),e]})})},ML=`__NULL_BRANCH`,NL=e=>{let t=[];return e.production&&t.push(`production`),e.preview&&t.push(`preview`),e.workingCopy&&t.push(`working-copy`),t},Oze=/^[^0-9a-z\W][A-Z0-9_]*$/,kze=`Name must be SCREAMING_SNAKE_CASE and must start with a letter`,Aze=e=>e.toUpperCase().replace(/[^A-Z0-9_]/g,`_`),jze=/^(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(.*)$/,PL=e=>{let t=[];for(let n of e.split(/\r?\n/)){let e=n.trim();if(e===``||e.startsWith(`#`))continue;let r=jze.exec(e);if(!r)return null;let i=Aze(r[1]),a=r[2].trim();if(a.startsWith(`"`)&&a.endsWith(`"`)&&a.length>=2)a=a.slice(1,-1).replace(/\\n/g,`
250
- `);else if(a.startsWith(`'`)&&a.endsWith(`'`)&&a.length>=2)a=a.slice(1,-1);else{let e=a.search(/\s#/);e>=0&&(a=a.slice(0,e).trimEnd())}t.push({name:i,value:a})}return t.length>0?t:null},[FL,Mze]=V(`Tooltip`,[nt]),IL=nt(),LL=`TooltipProvider`,Nze=700,RL=`tooltip.open`,[Pze,zL]=FL(LL),BL=e=>{let{__scopeTooltip:t,delayDuration:n=Nze,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=H.useRef(!0),s=H.useRef(!1),c=H.useRef(0);return H.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,U.jsx)(Pze,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:H.useCallback(()=>{window.clearTimeout(c.current),o.current=!1},[]),onClose:H.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:s,onPointerInTransitChange:H.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})};BL.displayName=LL;var VL=`Tooltip`,[Fze,HL]=FL(VL),UL=e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=zL(VL,e.__scopeTooltip),l=IL(t),[u,d]=H.useState(null),f=Ct(),p=H.useRef(0),m=o??c.disableHoverableContent,h=s??c.delayDuration,g=H.useRef(!1),[_,v]=yt({prop:r,defaultProp:i??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(RL))):c.onClose(),a?.(e)},caller:VL}),y=H.useMemo(()=>_?g.current?`delayed-open`:`instant-open`:`closed`,[_]),b=H.useCallback(()=>{window.clearTimeout(p.current),p.current=0,g.current=!1,v(!0)},[v]),x=H.useCallback(()=>{window.clearTimeout(p.current),p.current=0,v(!1)},[v]),S=H.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{g.current=!0,v(!0),p.current=0},h)},[h,v]);return H.useEffect(()=>()=>{p.current&&=(window.clearTimeout(p.current),0)},[]),(0,U.jsx)(en,{...l,children:(0,U.jsx)(Fze,{scope:t,contentId:f,open:_,stateAttribute:y,trigger:u,onTriggerChange:d,onTriggerEnter:H.useCallback(()=>{c.isOpenDelayedRef.current?S():b()},[c.isOpenDelayedRef,S,b]),onTriggerLeave:H.useCallback(()=>{m?x():(window.clearTimeout(p.current),p.current=0)},[x,m]),onOpen:b,onClose:x,disableHoverableContent:m,children:n})})};UL.displayName=VL;var WL=`TooltipTrigger`,GL=H.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=HL(WL,n),a=zL(WL,n),o=IL(n),s=p(t,H.useRef(null),i.onTriggerChange),c=H.useRef(!1),l=H.useRef(!1),u=H.useCallback(()=>c.current=!1,[]);return H.useEffect(()=>()=>document.removeEventListener(`pointerup`,u),[u]),(0,U.jsx)(Kt,{asChild:!0,...o,children:(0,U.jsx)(cn.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:d(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:d(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:d(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:d(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:d(e.onBlur,i.onClose),onClick:d(e.onClick,i.onClose)})})});GL.displayName=WL;var KL=`TooltipPortal`,[Ize,Lze]=FL(KL,{forceMount:void 0}),qL=e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=HL(KL,t);return(0,U.jsx)(Ize,{scope:t,forceMount:n,children:(0,U.jsx)(Ce,{present:n||a.open,children:(0,U.jsx)(_,{asChild:!0,container:i,children:r})})})};qL.displayName=KL;var JL=`TooltipContent`,YL=H.forwardRef((e,t)=>{let n=Lze(JL,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=HL(JL,e.__scopeTooltip);return(0,U.jsx)(Ce,{present:r||o.open,children:o.disableHoverableContent?(0,U.jsx)(XL,{side:i,...a,ref:t}):(0,U.jsx)(Rze,{side:i,...a,ref:t})})}),Rze=H.forwardRef((e,t)=>{let n=HL(JL,e.__scopeTooltip),r=zL(JL,e.__scopeTooltip),i=H.useRef(null),a=p(t,i),[o,s]=H.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:d}=r,f=H.useCallback(()=>{s(null),d(!1)},[d]),m=H.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=Uze(r,Hze(r,n.getBoundingClientRect())),a=Wze(t.getBoundingClientRect());s(Kze([...i,...a])),d(!0)},[d]);return H.useEffect(()=>()=>f(),[f]),H.useEffect(()=>{if(c&&u){let e=e=>m(e,u),t=e=>m(e,c);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,m,f]),H.useEffect(()=>{if(o){let e=e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!Gze(n,o);r?f():i&&(f(),l())};return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,U.jsx)(XL,{...e,ref:a})}),[zze,Bze]=FL(VL,{isInside:!1}),Vze=b(`TooltipContent`),XL=H.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...s}=e,c=HL(JL,n),l=IL(n),{onClose:u}=c;return H.useEffect(()=>(document.addEventListener(RL,u),()=>document.removeEventListener(RL,u)),[u]),H.useEffect(()=>{if(c.trigger){let e=e=>{e.target?.contains(c.trigger)&&u()};return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[c.trigger,u]),(0,U.jsx)(T,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,U.jsxs)(wt,{"data-state":c.stateAttribute,...l,...s,ref:t,style:{...s.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[(0,U.jsx)(Vze,{children:r}),(0,U.jsx)(zze,{scope:n,isInside:!0,children:(0,U.jsx)(Ke,{id:c.contentId,role:`tooltip`,children:i||r})})]})})});YL.displayName=JL;var ZL=`TooltipArrow`,QL=H.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=IL(n);return Bze(ZL,n).isInside?null:(0,U.jsx)($e,{...i,...r,ref:t})});QL.displayName=ZL;function Hze(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}function Uze(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function Wze(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function Gze(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function Kze(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:e.y>t.y?1:0),qze(t)}function qze(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var $L=BL,eR=UL,tR=GL,nR=qL,rR=YL,iR=QL;function aR({delayDuration:e=0,...t}){return(0,U.jsx)($L,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function oR({...e}){return(0,U.jsx)(aR,{children:(0,U.jsx)(eR,{"data-slot":`tooltip`,...e})})}function sR({...e}){return(0,U.jsx)(tR,{"data-slot":`tooltip-trigger`,...e})}function cR({className:e,sideOffset:t=0,children:n,...r}){return(0,U.jsx)(nR,{children:(0,U.jsxs)(rR,{"data-slot":`tooltip-content`,sideOffset:t,className:W(`bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance`,e),...r,children:[n,(0,U.jsx)(iR,{className:`bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]`})]})})}var lR=({className:e,...t})=>(0,U.jsx)(iR,{...t,className:W(`fill-white -translate-y-px drop-shadow-md [clip-path:inset(0_-10px_-10px_-10px)]`,e)}),uR=({children:e,content:t,open:n,defaultOpen:r,onOpenChange:i,side:a=`top`,align:o=`center`,className:s,asChild:c=!0,...l})=>t?(0,U.jsxs)(eR,{open:n,defaultOpen:r,onOpenChange:i,children:[(0,U.jsx)(tR,{asChild:c,children:e}),(0,U.jsxs)(cR,{side:a,align:o,className:s,...l,children:[t,(0,U.jsx)(lR,{})]})]}):e,dR=e=>{switch(e){case kL.WORKING_COPY:return`Development`;case kL.PRODUCTION:return`Production`;case kL.PREVIEW:return`Preview`;default:return e}},Jze=({env:e})=>dR(e),Yze={[kL.PRODUCTION]:`bg-amber-50 text-amber-800 ring-amber-200 dark:bg-amber-900/30 dark:text-amber-200 dark:ring-amber-800/60`,[kL.PREVIEW]:`bg-blue-50 text-blue-700 ring-blue-200 dark:bg-blue-900/30 dark:text-blue-200 dark:ring-blue-800/60`,[kL.WORKING_COPY]:`bg-muted text-muted-foreground ring-border`},Xze=({environmentType:e,className:t})=>{if(!e)return null;let n=e,r=Yze[n];return r?(0,U.jsx)(`span`,{className:W(`inline-flex shrink-0 items-center rounded-full px-2 py-0.5 text-[10px] font-medium tracking-wide ring-1 ring-inset`,r,t),children:dR(n)}):null},Zze=[kL.WORKING_COPY,kL.PRODUCTION,kL.PREVIEW],fR=({environments:e,value:t,onValueChange:n,disabled:r,placeholder:i=`Select an environment`,getOptionValue:a=e=>e.name,sentinel:o,className:s,triggerClassName:c,triggerSize:l=`default`,modal:u=!1,showTriggerBadge:d=!0,id:f,...p})=>{let[m,h]=H.useState(!1),g=H.useMemo(()=>{let t=new Map;for(let n of e){if(!n.environmentType)continue;let e=n.environmentType,r=t.get(e)??[];r.push(n),t.set(e,r)}return Zze.flatMap(e=>{let n=t.get(e);return n&&n.length>0?[{type:e,envs:n}]:[]})},[e]),_=H.useMemo(()=>e.find(e=>a(e)===t),[e,t,a]),v=o!=null&&o.value===t,y=()=>v?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Qu,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,U.jsx)(`span`,{className:`truncate text-sm`,children:o?.label})]}):_?(0,U.jsx)(Qze,{env:_,showBadge:d}):(0,U.jsx)(`span`,{className:`text-muted-foreground text-sm`,children:i});return(0,U.jsxs)(Vw,{open:m,onOpenChange:h,modal:u,children:[(0,U.jsx)(Hw,{asChild:!0,children:(0,U.jsxs)(X,{id:f,type:`button`,variant:`outline`,role:`combobox`,"aria-expanded":m,disabled:r,size:l,className:W(`border-input font-normal w-full justify-between`,c),"data-test":p[`data-test`],children:[(0,U.jsx)(`div`,{className:`flex items-center gap-2 min-w-0 flex-1`,children:y()}),(0,U.jsx)(pd,{className:`ml-2 size-4 shrink-0 opacity-50`})]})}),(0,U.jsx)(Uw,{className:W(`min-w-[320px] w-(--radix-popover-trigger-width) max-w-[480px] p-0 rounded-md shadow-md`,s),side:`bottom`,align:`start`,children:(0,U.jsxs)(mw,{filter:(e,t)=>{let n=e.toLowerCase(),r=t.toLowerCase().trim();return!r||n.startsWith(`__sentinel__`)||n.includes(r)?1:0},children:[(0,U.jsx)(hw,{placeholder:`Search environments...`,className:`h-10`}),(0,U.jsxs)(gw,{className:`max-h-[360px]`,children:[(0,U.jsx)(_w,{className:`py-6 text-center text-sm text-muted-foreground`,children:`No environments match.`}),o&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(vw,{children:(0,U.jsxs)(yw,{value:`__sentinel__ ${o.label}`,onSelect:()=>{n(o.value),h(!1)},className:`flex items-center gap-2.5 px-2.5 py-2 cursor-pointer data-[selected=true]:bg-accent`,children:[(0,U.jsx)(Qu,{className:W(`size-3.5 shrink-0`,t===o.value?`text-foreground`:`text-muted-foreground`)}),(0,U.jsx)(`span`,{className:W(`flex-1 truncate text-sm`,t===o.value&&`font-medium`),children:o.label}),(0,U.jsx)(fd,{className:W(`size-4 shrink-0 text-muted-foreground`,t===o.value?`opacity-100`:`opacity-0`)})]})}),g.length>0&&(0,U.jsx)(SEe,{})]}),g.map(({type:e,envs:r})=>(0,U.jsx)(vw,{heading:dR(e),children:r.map(e=>{let r=a(e);return(0,U.jsx)($ze,{env:e,isSelected:!v&&r===t,onPick:()=>{n(r),h(!1)}},e.name)})},e))]})]})})]})},Qze=({env:e,showBadge:t})=>{let n=e.environmentType,r=n===kL.WORKING_COPY,i=r?Tb:of,a=r?`working copy`:e.branchName??e.label;return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(i,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,U.jsx)(`span`,{className:W(`truncate min-w-0 flex-1 text-sm text-left`,r?``:`font-mono`),children:a}),t&&(0,U.jsx)(Xze,{environmentType:n,className:`ml-1`})]})},$ze=({env:e,isSelected:t,onPick:n})=>{let r=e.environmentType===kL.WORKING_COPY,i=r?Tb:of,a=r?`working copy`:e.branchName??e.label;return(0,U.jsxs)(yw,{value:[e.branchName,e.name,e.label,dR(e.environmentType)].filter(Boolean).join(` `),onSelect:n,className:`flex items-center gap-2.5 px-2.5 py-2 cursor-pointer data-[selected=true]:bg-accent`,children:[(0,U.jsx)(i,{strokeWidth:1.5,className:W(`size-3.5 shrink-0`,t?`text-foreground`:`text-muted-foreground`)}),(0,U.jsx)(`span`,{className:W(`flex-1 min-w-0 truncate text-sm`,r?``:`font-mono`,t&&`font-medium`),children:a}),(0,U.jsx)(fd,{className:W(`size-4 shrink-0 text-muted-foreground`,t?`opacity-100`:`opacity-0`)})]})},pR=({previewEnvironments:e,defaultBranch:t,personalOverrideEnabled:n=!0})=>{let{register:r,watch:i,setValue:a,getValues:o,control:s}=_k(),c=i(`personalOverride`),l=i(`preview`),u=i(`workingCopy`),d=o(),f=d.production||d.preview||d.workingCopy;return(0,U.jsxs)(`div`,{className:`flex flex-col gap-3 mt-4`,children:[(0,U.jsx)(`div`,{className:`text-sm font-medium`,children:`Environments`}),(0,U.jsx)(mR,{id:`production`,testId:`production-checkbox`,register:r(`production`),title:`Production`,description:t?(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,U.jsx)(of,{className:`size-3`}),(0,U.jsx)(`span`,{className:`font-mono`,children:t})]}):`The branch deployed to production`}),(0,U.jsx)(mR,{id:`preview`,testId:`preview-checkbox`,register:r(`preview`),title:`Preview`,description:(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,U.jsx)(of,{className:`size-3`}),`All non-production branches`]}),action:(0,U.jsx)(Ek,{control:s,name:`targetBranch`,render:({field:t})=>(0,U.jsx)(fR,{environments:e,value:t.value??`__NULL_BRANCH`,onValueChange:t.onChange,disabled:!l,getOptionValue:e=>e.branchName??``,sentinel:{value:ML,label:`All other branches`},triggerClassName:`w-72 h-10`,showTriggerBadge:!1,"data-test":`preview-branch-picker`})})}),(0,U.jsx)(mR,{id:`workingCopy`,testId:`working-copy-checkbox`,register:r(`workingCopy`),title:`Development`,description:(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,U.jsx)(Tb,{className:`size-3`}),`Your Working Copy & Local Dev`]}),action:u&&n&&(0,U.jsx)(`button`,{type:`button`,"data-test":`personal-override-button`,className:`text-xs text-zuplo-pink hover:underline whitespace-nowrap`,onClick:()=>{a(`personalOverride`,!c,{shouldDirty:!0,shouldTouch:!0})},children:c?`Clear personal override`:`Set personal override`})}),u&&n&&c&&(0,U.jsxs)(`div`,{className:`ml-7 rounded-md border border-dashed bg-muted/40 p-3 flex flex-col gap-1.5`,children:[(0,U.jsx)(`label`,{htmlFor:`personal-value`,className:`text-sm font-medium`,children:`Personal override`}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Only applied in your own Working Copy & Local Dev. Other developers won’t see this value.`}),(0,U.jsx)(gT,{id:`personal-value`,"data-test":`personal-override-input`,...r(`personalValue`)})]}),!f&&(0,U.jsx)(Ub,{children:(0,U.jsx)(Gb,{children:`You must select at least one environment`})})]})},mR=({id:e,testId:t,register:n,title:r,description:i,action:a})=>(0,U.jsxs)(`div`,{className:W(`flex min-h-16 items-center gap-3 rounded-md border bg-background px-4 py-3`,`transition-colors hover:border-foreground/20`),children:[(0,U.jsx)(`input`,{id:e,"data-test":t,type:`checkbox`,className:`size-4 rounded-sm border border-gray-300 shadow-sm shrink-0`,...n}),(0,U.jsxs)(`label`,{htmlFor:e,className:`flex-1 min-w-0 cursor-pointer`,children:[(0,U.jsx)(`div`,{className:`text-sm font-medium leading-tight`,children:r}),(0,U.jsx)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:i})]}),a&&(0,U.jsx)(`div`,{className:`shrink-0`,children:a})]}),eBe=()=>{let{register:e}=_k();return(0,U.jsxs)(`div`,{className:`flex flex-col`,children:[(0,U.jsx)(`span`,{className:`text-sm`,children:`Name`}),(0,U.jsx)(`div`,{className:`flex flex-col gap-2`,children:(0,U.jsx)(gT,{id:`name`,...e(`name`,{disabled:!0}),title:`Name cannot be changed, create a new variable instead`,type:`text`,"data-test":`variable-name-input`})})]})},hR=`whitespace-break-spaces break-all`,gR=({value:e,className:t,disabled:n,...r})=>{let i=(0,H.useRef)(null);return(0,U.jsxs)(`div`,{className:W(`rounded-sm border border-border w-full relative max-h-48`,n&&`bg-gray-100 dark:bg-neutral-800`,t),children:[(0,U.jsxs)(`pre`,{className:W(`font-mono text-zuplo-pink p-2 overflow-y-auto overflow-x-hidden max-h-[inherit] text-sm`,hR,n&&`invisible`),ref:i,children:[[...e].map((e,t)=>{switch(e){case`
250
+ `);else if(a.startsWith(`'`)&&a.endsWith(`'`)&&a.length>=2)a=a.slice(1,-1);else{let e=a.search(/\s#/);e>=0&&(a=a.slice(0,e).trimEnd())}t.push({name:i,value:a})}return t.length>0?t:null},[FL,Mze]=V(`Tooltip`,[nt]),IL=nt(),LL=`TooltipProvider`,Nze=700,RL=`tooltip.open`,[Pze,zL]=FL(LL),BL=e=>{let{__scopeTooltip:t,delayDuration:n=Nze,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=H.useRef(!0),s=H.useRef(!1),c=H.useRef(0);return H.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,U.jsx)(Pze,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:H.useCallback(()=>{window.clearTimeout(c.current),o.current=!1},[]),onClose:H.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:s,onPointerInTransitChange:H.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})};BL.displayName=LL;var VL=`Tooltip`,[Fze,HL]=FL(VL),UL=e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=zL(VL,e.__scopeTooltip),l=IL(t),[u,d]=H.useState(null),f=Ct(),p=H.useRef(0),m=o??c.disableHoverableContent,h=s??c.delayDuration,g=H.useRef(!1),[_,v]=yt({prop:r,defaultProp:i??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(RL))):c.onClose(),a?.(e)},caller:VL}),y=H.useMemo(()=>_?g.current?`delayed-open`:`instant-open`:`closed`,[_]),b=H.useCallback(()=>{window.clearTimeout(p.current),p.current=0,g.current=!1,v(!0)},[v]),x=H.useCallback(()=>{window.clearTimeout(p.current),p.current=0,v(!1)},[v]),S=H.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{g.current=!0,v(!0),p.current=0},h)},[h,v]);return H.useEffect(()=>()=>{p.current&&=(window.clearTimeout(p.current),0)},[]),(0,U.jsx)(en,{...l,children:(0,U.jsx)(Fze,{scope:t,contentId:f,open:_,stateAttribute:y,trigger:u,onTriggerChange:d,onTriggerEnter:H.useCallback(()=>{c.isOpenDelayedRef.current?S():b()},[c.isOpenDelayedRef,S,b]),onTriggerLeave:H.useCallback(()=>{m?x():(window.clearTimeout(p.current),p.current=0)},[x,m]),onOpen:b,onClose:x,disableHoverableContent:m,children:n})})};UL.displayName=VL;var WL=`TooltipTrigger`,GL=H.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=HL(WL,n),a=zL(WL,n),o=IL(n),s=p(t,H.useRef(null),i.onTriggerChange),c=H.useRef(!1),l=H.useRef(!1),u=H.useCallback(()=>c.current=!1,[]);return H.useEffect(()=>()=>document.removeEventListener(`pointerup`,u),[u]),(0,U.jsx)(Kt,{asChild:!0,...o,children:(0,U.jsx)(cn.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:d(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:d(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:d(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:d(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:d(e.onBlur,i.onClose),onClick:d(e.onClick,i.onClose)})})});GL.displayName=WL;var KL=`TooltipPortal`,[Ize,Lze]=FL(KL,{forceMount:void 0}),qL=e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=HL(KL,t);return(0,U.jsx)(Ize,{scope:t,forceMount:n,children:(0,U.jsx)(Ce,{present:n||a.open,children:(0,U.jsx)(_,{asChild:!0,container:i,children:r})})})};qL.displayName=KL;var JL=`TooltipContent`,YL=H.forwardRef((e,t)=>{let n=Lze(JL,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=HL(JL,e.__scopeTooltip);return(0,U.jsx)(Ce,{present:r||o.open,children:o.disableHoverableContent?(0,U.jsx)(XL,{side:i,...a,ref:t}):(0,U.jsx)(Rze,{side:i,...a,ref:t})})}),Rze=H.forwardRef((e,t)=>{let n=HL(JL,e.__scopeTooltip),r=zL(JL,e.__scopeTooltip),i=H.useRef(null),a=p(t,i),[o,s]=H.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:d}=r,f=H.useCallback(()=>{s(null),d(!1)},[d]),m=H.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=Uze(r,Hze(r,n.getBoundingClientRect())),a=Wze(t.getBoundingClientRect());s(Kze([...i,...a])),d(!0)},[d]);return H.useEffect(()=>()=>f(),[f]),H.useEffect(()=>{if(c&&u){let e=e=>m(e,u),t=e=>m(e,c);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,m,f]),H.useEffect(()=>{if(o){let e=e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!Gze(n,o);r?f():i&&(f(),l())};return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,U.jsx)(XL,{...e,ref:a})}),[zze,Bze]=FL(VL,{isInside:!1}),Vze=b(`TooltipContent`),XL=H.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...s}=e,c=HL(JL,n),l=IL(n),{onClose:u}=c;return H.useEffect(()=>(document.addEventListener(RL,u),()=>document.removeEventListener(RL,u)),[u]),H.useEffect(()=>{if(c.trigger){let e=e=>{e.target?.contains(c.trigger)&&u()};return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[c.trigger,u]),(0,U.jsx)(T,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,U.jsxs)(wt,{"data-state":c.stateAttribute,...l,...s,ref:t,style:{...s.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[(0,U.jsx)(Vze,{children:r}),(0,U.jsx)(zze,{scope:n,isInside:!0,children:(0,U.jsx)(Ke,{id:c.contentId,role:`tooltip`,children:i||r})})]})})});YL.displayName=JL;var ZL=`TooltipArrow`,QL=H.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=IL(n);return Bze(ZL,n).isInside?null:(0,U.jsx)($e,{...i,...r,ref:t})});QL.displayName=ZL;function Hze(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}function Uze(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function Wze(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function Gze(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function Kze(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:e.y>t.y?1:0),qze(t)}function qze(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var $L=BL,eR=UL,tR=GL,nR=qL,rR=YL,iR=QL;function aR({delayDuration:e=0,...t}){return(0,U.jsx)($L,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function oR({...e}){return(0,U.jsx)(aR,{children:(0,U.jsx)(eR,{"data-slot":`tooltip`,...e})})}function sR({...e}){return(0,U.jsx)(tR,{"data-slot":`tooltip-trigger`,...e})}function cR({className:e,sideOffset:t=0,children:n,...r}){return(0,U.jsx)(nR,{children:(0,U.jsxs)(rR,{"data-slot":`tooltip-content`,sideOffset:t,className:W(`bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance`,e),...r,children:[n,(0,U.jsx)(iR,{className:`bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]`})]})})}var lR=({className:e,...t})=>(0,U.jsx)(iR,{...t,className:W(`fill-white -translate-y-px drop-shadow-md [clip-path:inset(0_-10px_-10px_-10px)]`,e)}),uR=({children:e,content:t,open:n,defaultOpen:r,onOpenChange:i,side:a=`top`,align:o=`center`,className:s,asChild:c=!0,...l})=>t?(0,U.jsxs)(eR,{open:n,defaultOpen:r,onOpenChange:i,children:[(0,U.jsx)(tR,{asChild:c,children:e}),(0,U.jsxs)(cR,{side:a,align:o,className:s,...l,children:[t,(0,U.jsx)(lR,{})]})]}):e,dR=e=>{switch(e){case kL.WORKING_COPY:return`Development`;case kL.PRODUCTION:return`Production`;case kL.PREVIEW:return`Preview`;default:return e}},Jze=({env:e})=>dR(e),Yze={[kL.PRODUCTION]:`bg-amber-50 text-amber-800 ring-amber-200 dark:bg-amber-900/30 dark:text-amber-200 dark:ring-amber-800/60`,[kL.PREVIEW]:`bg-blue-50 text-blue-700 ring-blue-200 dark:bg-blue-900/30 dark:text-blue-200 dark:ring-blue-800/60`,[kL.WORKING_COPY]:`bg-muted text-muted-foreground ring-border`},Xze=({environmentType:e,className:t})=>{if(!e)return null;let n=e,r=Yze[n];return r?(0,U.jsx)(`span`,{className:W(`inline-flex shrink-0 items-center rounded-full px-2 py-0.5 text-[10px] font-medium tracking-wide ring-1 ring-inset`,r,t),children:dR(n)}):null},Zze=[kL.WORKING_COPY,kL.PRODUCTION,kL.PREVIEW],fR=({environments:e,value:t,onValueChange:n,disabled:r,placeholder:i=`Select an environment`,getOptionValue:a=e=>e.name,sentinel:o,unmatchedValueHint:s,className:c,triggerClassName:l,triggerSize:u=`default`,modal:d=!1,showTriggerBadge:f=!0,id:p,...m})=>{let[h,g]=H.useState(!1),_=H.useMemo(()=>{let t=new Map;for(let n of e){if(!n.environmentType)continue;let e=n.environmentType,r=t.get(e)??[];r.push(n),t.set(e,r)}return Zze.flatMap(e=>{let n=t.get(e);return n&&n.length>0?[{type:e,envs:n}]:[]})},[e]),v=H.useMemo(()=>e.find(e=>a(e)===t),[e,t,a]),y=o!=null&&o.value===t,b=()=>y?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Qu,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,U.jsx)(`span`,{className:`truncate text-sm`,children:o?.label})]}):v?(0,U.jsx)(Qze,{env:v,showBadge:f}):t&&s?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(of,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,U.jsx)(`span`,{className:`truncate min-w-0 flex-1 text-sm text-left font-mono`,children:t}),(0,U.jsx)(`span`,{className:`shrink-0 text-xs text-warning-foreground`,children:s})]}):(0,U.jsx)(`span`,{className:`text-muted-foreground text-sm`,children:i});return(0,U.jsxs)(Vw,{open:h,onOpenChange:g,modal:d,children:[(0,U.jsx)(Hw,{asChild:!0,children:(0,U.jsxs)(X,{id:p,type:`button`,variant:`outline`,role:`combobox`,"aria-expanded":h,disabled:r,size:u,className:W(`border-input font-normal w-full justify-between`,l),"data-test":m[`data-test`],children:[(0,U.jsx)(`div`,{className:`flex items-center gap-2 min-w-0 flex-1`,children:b()}),(0,U.jsx)(pd,{className:`ml-2 size-4 shrink-0 opacity-50`})]})}),(0,U.jsx)(Uw,{className:W(`min-w-[320px] w-(--radix-popover-trigger-width) max-w-[480px] p-0 rounded-md shadow-md`,c),side:`bottom`,align:`start`,children:(0,U.jsxs)(mw,{filter:(e,t)=>{let n=e.toLowerCase(),r=t.toLowerCase().trim();return!r||n.startsWith(`__sentinel__`)||n.includes(r)?1:0},children:[(0,U.jsx)(hw,{placeholder:`Search environments...`,className:`h-10`}),(0,U.jsxs)(gw,{className:`max-h-[360px]`,children:[(0,U.jsx)(_w,{className:`py-6 text-center text-sm text-muted-foreground`,children:`No environments match.`}),o&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(vw,{children:(0,U.jsxs)(yw,{value:`__sentinel__ ${o.label}`,onSelect:()=>{n(o.value),g(!1)},className:`flex items-center gap-2.5 px-2.5 py-2 cursor-pointer data-[selected=true]:bg-accent`,children:[(0,U.jsx)(Qu,{className:W(`size-3.5 shrink-0`,t===o.value?`text-foreground`:`text-muted-foreground`)}),(0,U.jsx)(`span`,{className:W(`flex-1 truncate text-sm`,t===o.value&&`font-medium`),children:o.label}),(0,U.jsx)(fd,{className:W(`size-4 shrink-0 text-muted-foreground`,t===o.value?`opacity-100`:`opacity-0`)})]})}),_.length>0&&(0,U.jsx)(SEe,{})]}),_.map(({type:e,envs:r})=>(0,U.jsx)(vw,{heading:dR(e),children:r.map(e=>{let r=a(e);return(0,U.jsx)($ze,{env:e,isSelected:!y&&r===t,onPick:()=>{n(r),g(!1)}},e.name)})},e))]})]})})]})},Qze=({env:e,showBadge:t})=>{let n=e.environmentType,r=n===kL.WORKING_COPY,i=r?Tb:of,a=r?`working copy`:e.branchName??e.label;return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(i,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,U.jsx)(`span`,{className:W(`truncate min-w-0 flex-1 text-sm text-left`,r?``:`font-mono`),children:a}),t&&(0,U.jsx)(Xze,{environmentType:n,className:`ml-1`})]})},$ze=({env:e,isSelected:t,onPick:n})=>{let r=e.environmentType===kL.WORKING_COPY,i=r?Tb:of,a=r?`working copy`:e.branchName??e.label;return(0,U.jsxs)(yw,{value:[e.branchName,e.name,e.label,dR(e.environmentType)].filter(Boolean).join(` `),onSelect:n,className:`flex items-center gap-2.5 px-2.5 py-2 cursor-pointer data-[selected=true]:bg-accent`,children:[(0,U.jsx)(i,{strokeWidth:1.5,className:W(`size-3.5 shrink-0`,t?`text-foreground`:`text-muted-foreground`)}),(0,U.jsx)(`span`,{className:W(`flex-1 min-w-0 truncate text-sm`,r?``:`font-mono`,t&&`font-medium`),children:a}),(0,U.jsx)(fd,{className:W(`size-4 shrink-0 text-muted-foreground`,t?`opacity-100`:`opacity-0`)})]})},pR=({previewEnvironments:e,environmentsLoaded:t=!1,defaultBranch:n,personalOverrideEnabled:r=!0})=>{let{register:i,watch:a,setValue:o,getValues:s,control:c}=_k(),l=a(`personalOverride`),u=a(`preview`),d=a(`workingCopy`),f=a(`targetBranch`),p=t&&u&&f&&f!==`__NULL_BRANCH`&&!e.some(e=>e.branchName===f)?f:null,m=s(),h=m.production||m.preview||m.workingCopy;return(0,U.jsxs)(`div`,{className:`flex flex-col gap-3 mt-4`,children:[(0,U.jsx)(`div`,{className:`text-sm font-medium`,children:`Environments`}),(0,U.jsx)(mR,{id:`production`,testId:`production-checkbox`,register:i(`production`),title:`Production`,description:n?(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,U.jsx)(of,{className:`size-3`}),(0,U.jsx)(`span`,{className:`font-mono`,children:n})]}):`The branch deployed to production`}),(0,U.jsx)(mR,{id:`preview`,testId:`preview-checkbox`,register:i(`preview`),title:`Preview`,description:(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,U.jsx)(of,{className:`size-3`}),`All non-production branches`]}),action:(0,U.jsx)(Ek,{control:c,name:`targetBranch`,render:({field:n})=>(0,U.jsx)(fR,{environments:e,value:n.value??`__NULL_BRANCH`,onValueChange:n.onChange,disabled:!u,getOptionValue:e=>e.branchName??``,sentinel:{value:ML,label:`All other branches`},unmatchedValueHint:t?`Not found`:void 0,triggerClassName:`w-72 h-10`,showTriggerBadge:!1,"data-test":`preview-branch-picker`})})}),p&&(0,U.jsx)(Ub,{variant:`warning`,"data-test":`stale-target-branch-warning`,children:(0,U.jsx)(Gb,{children:(0,U.jsxs)(`span`,{children:[`No environment for branch`,` `,(0,U.jsx)(`span`,{className:`font-mono`,children:p}),` exists. This variable is not used by your other preview environments, and only applies again if that branch is deployed. Choose another branch, or delete the variable if it is no longer needed.`]})})}),(0,U.jsx)(mR,{id:`workingCopy`,testId:`working-copy-checkbox`,register:i(`workingCopy`),title:`Development`,description:(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,U.jsx)(Tb,{className:`size-3`}),`Your Working Copy & Local Dev`]}),action:d&&r&&(0,U.jsx)(`button`,{type:`button`,"data-test":`personal-override-button`,className:`text-xs text-zuplo-pink hover:underline whitespace-nowrap`,onClick:()=>{o(`personalOverride`,!l,{shouldDirty:!0,shouldTouch:!0})},children:l?`Clear personal override`:`Set personal override`})}),d&&r&&l&&(0,U.jsxs)(`div`,{className:`ml-7 rounded-md border border-dashed bg-muted/40 p-3 flex flex-col gap-1.5`,children:[(0,U.jsx)(`label`,{htmlFor:`personal-value`,className:`text-sm font-medium`,children:`Personal override`}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Only applied in your own Working Copy & Local Dev. Other developers won’t see this value.`}),(0,U.jsx)(gT,{id:`personal-value`,"data-test":`personal-override-input`,...i(`personalValue`)})]}),!h&&(0,U.jsx)(Ub,{children:(0,U.jsx)(Gb,{children:`You must select at least one environment`})})]})},mR=({id:e,testId:t,register:n,title:r,description:i,action:a})=>(0,U.jsxs)(`div`,{className:W(`flex min-h-16 items-center gap-3 rounded-md border bg-background px-4 py-3`,`transition-colors hover:border-foreground/20`),children:[(0,U.jsx)(`input`,{id:e,"data-test":t,type:`checkbox`,className:`size-4 rounded-sm border border-gray-300 shadow-sm shrink-0`,...n}),(0,U.jsxs)(`label`,{htmlFor:e,className:`flex-1 min-w-0 cursor-pointer`,children:[(0,U.jsx)(`div`,{className:`text-sm font-medium leading-tight`,children:r}),(0,U.jsx)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:i})]}),a&&(0,U.jsx)(`div`,{className:`shrink-0`,children:a})]}),eBe=()=>{let{register:e}=_k();return(0,U.jsxs)(`div`,{className:`flex flex-col`,children:[(0,U.jsx)(`span`,{className:`text-sm`,children:`Name`}),(0,U.jsx)(`div`,{className:`flex flex-col gap-2`,children:(0,U.jsx)(gT,{id:`name`,...e(`name`,{disabled:!0}),title:`Name cannot be changed, create a new variable instead`,type:`text`,"data-test":`variable-name-input`})})]})},hR=`whitespace-break-spaces break-all`,gR=({value:e,className:t,disabled:n,...r})=>{let i=(0,H.useRef)(null);return(0,U.jsxs)(`div`,{className:W(`rounded-sm border border-border w-full relative max-h-48`,n&&`bg-gray-100 dark:bg-neutral-800`,t),children:[(0,U.jsxs)(`pre`,{className:W(`font-mono text-zuplo-pink p-2 overflow-y-auto overflow-x-hidden max-h-[inherit] text-sm`,hR,n&&`invisible`),ref:i,children:[[...e].map((e,t)=>{switch(e){case`
251
251
  `:return(0,U.jsxs)(H.Fragment,{children:[(0,U.jsx)(`span`,{className:`inline-block w-0 translate-x-[0.5px] text-zuplo-pink`,children:`↵`}),`
252
252
  `]},t);case` `:return(0,U.jsx)(`span`,{className:`text-gray-300 dark:text-neutral-600`,children:`␣`},t)}return(0,U.jsx)(`span`,{className:`invisible`,children:e},t)}),`
253
- `]}),(0,U.jsx)(`textarea`,{onScroll:e=>{e.target instanceof HTMLTextAreaElement&&i.current?.scrollTo({top:e.target.scrollTop,left:e.target.scrollLeft,behavior:`instant`})},spellCheck:!1,disabled:n,...r,className:W(`absolute top-0 left-0 h-full flex-1 border min-w-0 block p-2 rounded-sm`,`bg-transparent border-0 w-full font-mono text-sm overflow-y-auto overflow-x-hidden resize-none outline-hidden`,hR,`disabled:opacity-50 disabled:hover:cursor-not-allowed disabled:cursor-not-allowed`),value:e})]})},tBe=`•`.repeat(12),_R=`env-var-secret-value-hint`,nBe=({variable:e,previewEnvironments:t,defaultBranch:n,onClose:r,isSaving:i,error:a,onSubmit:o})=>{let s=vA({defaultValues:{preview:e.targets.includes(`preview`),production:e.targets.includes(`production`),workingCopy:e.targets.includes(`working-copy`),name:e.name,isSecret:e.type===`secret`,value:e.type===`secret`?``:e.value??null,personalOverride:e.personalValue!==void 0,personalValue:e.personalValue??null,targetBranch:e.targetBranch??`__NULL_BRANCH`},mode:`onChange`}),{getValues:c,control:l,register:u}=s,d=e.type===`secret`,{isValid:f,dirtyFields:p,touchedFields:m}=Ck({control:l}),h=c(),g=h.production||h.preview||h.workingCopy,_=!i&&g&&f,v=()=>{o(c(),p,m)};return(0,U.jsx)(vk,{...s,children:(0,U.jsx)(jL,{isOpen:!0,className:`sm:max-w-2xl`,onClose:r,title:`Edit environment variable`,children:(0,U.jsx)(`div`,{className:`flex flex-col`,children:(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,U.jsx)(SA,{error:a}),(0,U.jsx)(eBe,{}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`span`,{className:`text-sm`,children:`Value`}),(0,U.jsx)(Ek,{control:l,name:`value`,render:({field:{value:e,...t}})=>(0,U.jsx)(gR,{...t,value:e??``,"aria-label":`Value`,"aria-describedby":d?_R:void 0,placeholder:d?tBe:void 0,"data-test":`variable-value-input`})}),d&&(0,U.jsx)(`p`,{id:_R,className:`text-xs text-muted-foreground mt-1`,"data-test":`secret-value-hint`,children:`The current value is hidden and can’t be shown again. Leave this blank to keep it, or type a new value to replace it.`})]}),(0,U.jsxs)(`label`,{className:W(`flex flex-row border rounded-sm p-4 gap-4`,`bg-gray-100 dark:bg-neutral-800 border-border opacity-30`),children:[(0,U.jsx)(`input`,{...u(`isSecret`),id:`is-secret`,disabled:!0,className:`rounded-sm border border-border shadow-sm mt-0.5`,type:`checkbox`,"data-test":`is-secret-checkbox`}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`span`,{className:`whitespace-nowrap`,children:`Secret`}),(0,U.jsx)(`div`,{className:`text-sm`,children:`Secrets are environment variables that are encrypted and not visible after they are set. Secrets are used for storing sensitive information like API keys and auth token.`})]})]}),(0,U.jsx)(pR,{previewEnvironments:t,defaultBranch:n}),(0,U.jsxs)(`div`,{className:`flex flex-row space-x-2 mt-3 justify-between`,children:[(0,U.jsx)(X,{onClick:()=>r(),variant:`secondary`,children:`Cancel`}),(0,U.jsxs)(X,{disabled:!_,type:`button`,"data-test":`save-variable`,onClick:v,children:[i&&(0,U.jsx)(WI,{borderPositionAndSize:`w-4 h-4 border-2 border-white mr-2`}),`Save`]})]})]})})})})},vR=(e,t,n)=>ox(je.environmentVariables(e,t),{...n,extractData:!0}),yR=()=>{let e=bt();return Oe({mutationFn:async t=>{await e.fetch(ae.environmentVariables.updateEnvironmentVariable(t))}})},rBe=()=>{let e=bt();return Oe({mutationFn:async t=>await e.fetch(ae.environmentVariables.createEnvironmentVariable(t))})},iBe=()=>{let e=bt();return Oe({mutationFn:async t=>{await e.fetch(ae.environmentVariables.deleteEnvironmentVariable(t))}})};function bR({variable:e,previewEnvironments:t,onClose:n,account:r,project:i}){let a=Ep(),{logEvent:o,captureException:s}=S(),c=yR(),l=(e,t,s)=>{o(`env-var-edited`,{type:e,targets:t.join(`,`),personalOverride:`${s}`,account:r,project:i.name});let c=t.filter(e=>e!==`working-copy`);i.sourceRepoUrl!=null&&c.length>0&&a.success(`Redeploy your project to apply changes.`,{title:`Redeploy required`,icon:(0,U.jsx)(Ff,{className:`h-6 w-6`})}),n()};return(0,U.jsx)(nBe,{variable:e,previewEnvironments:t,defaultBranch:i.defaultBranch,onSubmit:(t,n,a)=>{let u=NL(t),d={id:e.id,name:e.name,value:n.value?t.value??void 0:void 0,targets:a.production||a.preview||a.workingCopy?u:void 0};if(n.targetBranch){let e=t.targetBranch;d.targetBranch=e===`__NULL_BRANCH`?null:e}a.preview&&t.preview===!1&&(d.targetBranch=null),n.personalOverride&&t.personalOverride&&(d.personalValue=``),n.personalValue&&(d.personalValue=t.personalValue),(n.workingCopy&&t.workingCopy===!1||n.personalOverride&&t.personalOverride===!1)&&(d.personalValue=null),c.mutate({accountName:r,projectName:i.name,variableData:d},{onSuccess:()=>l(d.type??`config`,d.targets??e.targets,t.personalOverride),onError:e=>{o(`env-var-edit-failed`,{account:r,project:i.name}),s(e)}})},onClose:n,isSaving:c.isPending,error:c.error})}var xR={name:``,value:``,isSecret:!1},SR=`grid grid-cols-[minmax(0,2fr)_minmax(0,3fr)_3rem_2.25rem] gap-2`,aBe=({previewEnvironments:e,defaultBranch:t,initialName:n,onSubmit:r,onClose:i,onPasteParsed:a})=>{let o=vA({defaultValues:{variables:[{...xR,name:n??``}],production:!0,preview:!0,workingCopy:!0,targetBranch:ML,personalOverride:!1,personalValue:null},mode:`onChange`}),{control:s,register:c,getValues:l,setValue:u,watch:d,trigger:f}=o,{fields:p,append:m,remove:h,replace:g}=_A({control:s,name:`variables`}),{isValid:_,errors:v}=Ck({control:s}),[y,b]=(0,H.useState)(!1),[x,S]=(0,H.useState)(null),[C,w]=(0,H.useState)(null),[T,E]=(0,H.useState)(new Set),D=(0,H.useRef)(null);(0,H.useEffect)(()=>{x!=null&&D.current?.scrollIntoView?.({block:`nearest`})},[x]),(0,H.useEffect)(()=>{n&&f()},[n,f]);let O=d(`variables`),k=d(`production`),A=d(`preview`),j=d(`workingCopy`),M=k||A||j,N=O.filter(e=>e.name.trim()!==``).length,P=!y&&M&&_&&N>0,F=e=>{e>1&&l(`personalOverride`)&&(u(`personalOverride`,!1),u(`personalValue`,null))},I=(e,t)=>{let n=l(`variables`).map(e=>({...e})),r=n[e]?.name.trim()===``?e:null;for(let e of t){let t=n.findIndex((t,n)=>n!==r&&t.name!==``&&t.name===e.name);t>=0?n[t].value=e.value:r==null?n.push({...e,isSecret:!1}):(n[r]={...n[r],...e},r=null)}g(n),F(n.length),a?.(t.length)},L=e=>t=>{let n=PL(t.clipboardData.getData(`text`));n&&(t.preventDefault(),I(e,n))},R=e=>t=>{let n=t.clipboardData.getData(`text`),r=PL(n);if(!r)return;let i=l(`variables.${e}.name`);r.length===1&&!/\r?\n/.test(n.trim())&&i.trim()!==``||(t.preventDefault(),I(e,r))},z=()=>{m({...xR}),F(p.length+1)},B=async()=>{b(!0),S(null),w(null);try{let e=await r(l());if(e.savedNames.length>0&&E(t=>new Set([...t,...e.savedNames])),e.error==null)return;S(e.error),w(e.failedName??null)}finally{b(!1)}};return(0,U.jsx)(vk,{...o,children:(0,U.jsx)(ow,{open:!0,onOpenChange:e=>!e&&i(),children:(0,U.jsxs)(lw,{className:`flex max-h-[85vh] flex-col gap-0 p-0 sm:max-w-3xl`,children:[(0,U.jsxs)(uw,{className:`border-b px-6 py-4`,children:[(0,U.jsx)(fw,{children:`Add Environment Variables`}),(0,U.jsxs)(pw,{children:[`Add one or more variables. Pasting the contents of a`,` `,(0,U.jsx)(`span`,{className:`font-mono`,children:`.env`}),` file (or any`,` `,(0,U.jsx)(`span`,{className:`font-mono`,children:`KEY=VALUE`}),` lines) into a field fills the form automatically.`]})]}),(0,U.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto px-6 py-4`,children:[x!=null&&(0,U.jsx)(`div`,{ref:D,children:(0,U.jsx)(SA,{error:x,className:`mb-0`})}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,U.jsxs)(`div`,{className:`${SR} text-sm font-medium`,children:[(0,U.jsx)(`span`,{children:`Name`}),(0,U.jsx)(`span`,{children:`Value`}),(0,U.jsx)(`span`,{className:`text-center`,children:`Secret`}),(0,U.jsx)(`span`,{})]}),p.map((e,t)=>{let n=v.variables?.[t]?.name?.message,r=O[t]?.name??``,i=C!=null&&r===C,a=r!==``&&T.has(r)&&!i;return(0,U.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,U.jsxs)(`div`,{className:`${SR} items-start`,children:[(0,U.jsx)(gT,{placeholder:`EXAMPLE_NAME`,"aria-invalid":n||i?!0:void 0,onInput:e=>{let t=e.target,n=t.selectionStart;t.value=t.value.toUpperCase().replace(/[^A-Z0-9_]/g,`_`),t.setSelectionRange(n,n)},onPaste:L(t),"data-test":`variable-name-input-${t}`,...c(`variables.${t}.name`,{validate:(e,n)=>{let r=e.trim();return r===``?n.variables[t]?.value?`Name is required`:!0:Oze.test(r)?n.variables.filter(e=>e.name.trim()===r).length>1?`Duplicate variable name`:!0:kze}})}),(0,U.jsx)(Ek,{control:s,name:`variables.${t}.value`,render:({field:{value:e,...n}})=>(0,U.jsx)(gR,{...n,value:e??``,onPaste:R(t),className:`max-h-32`,"data-test":`variable-value-input-${t}`})}),(0,U.jsx)(Ek,{control:s,name:`variables.${t}.isSecret`,render:({field:{value:e,onChange:n}})=>(0,U.jsx)(X,{type:`button`,variant:`ghost`,size:`icon-sm`,className:W(`mt-0.5 justify-self-center`,!e&&`text-muted-foreground`),"aria-pressed":e,"aria-label":`Secret`,disabled:a,title:a?`Already saved — a variable's type cannot be changed`:e?`Secret — the value will be encrypted and hidden once saved`:`Not a secret — click to make this variable a secret`,"data-test":`variable-secret-toggle-${t}`,onClick:()=>n(!e),children:e?(0,U.jsx)(yf,{className:`size-4`}):(0,U.jsx)(_ee,{className:`size-4`})})}),(0,U.jsx)(X,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`mt-0.5`,disabled:p.length===1,title:`Remove variable`,"data-test":`remove-variable-${t}`,onClick:()=>h(t),children:(0,U.jsx)(op,{className:`size-4`})})]}),(n||i)&&(0,U.jsx)(`p`,{className:`text-xs text-destructive`,"data-test":`variable-name-error-${t}`,children:n??`This variable failed to save — see the error above.`}),a&&!n&&(0,U.jsxs)(`p`,{className:`inline-flex items-center gap-1 text-xs text-muted-foreground`,"data-test":`variable-saved-${t}`,children:[(0,U.jsx)(fd,{className:`size-3`}),`Saved — saving again updates it`]})]},e.id)}),(0,U.jsx)(`div`,{children:(0,U.jsxs)(X,{type:`button`,variant:`outline`,size:`sm`,"data-test":`add-another-variable`,onClick:z,children:[(0,U.jsx)(Mf,{className:`size-4`}),`Add another`]})}),(0,U.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Variables marked as `,(0,U.jsx)(yf,{className:`inline size-3`}),` `,`secret are encrypted and not visible after they are set — use them for sensitive information like API keys and auth tokens.`]})]}),(0,U.jsx)(pR,{previewEnvironments:e,defaultBranch:t,personalOverrideEnabled:p.length===1})]}),(0,U.jsxs)(dw,{className:`border-t px-6 py-4 sm:justify-between`,children:[(0,U.jsx)(X,{variant:`secondary`,onClick:()=>i(),children:`Cancel`}),(0,U.jsxs)(X,{disabled:!P,type:`button`,"data-test":`save-variable`,onClick:B,children:[y&&(0,U.jsx)(WI,{borderPositionAndSize:`w-4 h-4 border-2 border-white mr-2`}),N>1?`Save ${N} variables`:`Save`]})]})]})})})},CR=({previewEnvironments:e,account:t,project:n,initialName:r,onClose:i})=>{let{logEvent:a,captureException:o}=S(),s=Ep(),c=rBe(),l=yR(),u=(0,H.useRef)(new Map),d=(e,t)=>{let r=t.filter(e=>e!==`working-copy`);n.sourceRepoUrl!=null&&r.length>0&&s.success(`Redeploy your environment to apply changes.`,{title:e===1?`Environment variable created`:`${e} environment variables created`}),i()};return(0,U.jsx)(aBe,{previewEnvironments:e,defaultBranch:n.defaultBranch,initialName:r,onSubmit:async e=>{let r=e.variables.filter(e=>e.name.trim()!==``),i=NL(e),s=e.preview&&e.targetBranch!==`__NULL_BRANCH`?e.targetBranch??void 0:void 0,f=r.length===1&&e.workingCopy&&e.personalOverride?e.personalValue??``:void 0,p=[];for(let e of r){let d=u.current.get(e.name),m=e.isSecret?`secret`:`config`;try{if(d!=null)await l.mutateAsync({accountName:t,projectName:n.name,variableData:{id:d,name:e.name,value:e.value,targets:i,targetBranch:s??null,personalValue:f??null}});else{let o=await c.mutateAsync({accountName:t,projectName:n.name,variableData:{name:e.name,value:e.value,type:m,targets:i,targetBranch:s,personalValue:f}});o?.id&&u.current.set(e.name,o.id),a(`env-var-created`,{type:m,targets:i.join(`,`),personalOverride:`${f!==void 0}`,batchSize:`${r.length}`,account:t,project:n.name})}}catch(r){return a(`env-var-creation-failed`,{account:t,project:n.name}),o(r),{savedNames:p,failedName:e.name,error:r}}p.push(e.name)}return d(p.length,i),{savedNames:p,error:null}},onClose:i,onPasteParsed:e=>a(`env-vars-pasted`,{count:`${e}`,account:t,project:n.name})})},wR=(e,t,n)=>k({...m.deployments.list(e,t),...n,select:e=>e.data}),TR=(e,t={})=>Aee({...m.deployments.versions.list(e),...t,select:e=>({...e,data:e.data?.map(e=>({...e,stages:[...e.stages].sort((e,t)=>e.stage.localeCompare(t.stage))}))})}),ER=(e,t={})=>Pe(TR(e,t));function oBe(e){if(typeof e!=`object`||!e)return null;let t=e,n=typeof t.name==`string`?t.name:void 0;return n?{name:n,description:typeof t.description==`string`?t.description:void 0}:null}function sBe({data:e}){let[t,n]=(0,H.useState)(!1),{logEvent:r}=S(),{account:i,project:a}=sx([]),o=!!(i&&a),s=Kw(i??``,{enabled:t&&o,throwOnError:!1,refetchOnMount:!1,refetchOnWindowFocus:!1}),c=s.data?.find(e=>e.name===a),l=vR(i??``,a??``,{enabled:t&&o,useErrorBoundary:!1,refetchOnMount:!1,refetchOnWindowFocus:!1}),u=l.data?.find(t=>t.name===e.name),d=wR(i??``,a??``,{enabled:t&&o}),f=d.data?.filter(e=>!AL(e.environmentType,kL.PRODUCTION,kL.WORKING_COPY))??[],p=t&&!l.isFetching&&l.data!=null&&!u,m=t&&(!l.isFetching&&l.isError||!d.isFetching&&d.isError||!s.isFetching&&s.isError),h=!!(c&&d.data),g=t&&!m&&!(u&&h)&&!(p&&h);return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(UMe,{name:e.name,description:e.description,loading:g,disabled:!o,errorText:m?`Couldn’t load variable “${e.name}” — please try again.`:void 0,onOpen:()=>{o&&(r(`agent-z-env-var-card-clicked`,{account:i,project:a}),n(!0),l.isError&&l.refetch(),d.isError&&d.refetch(),s.isError&&s.refetch())}}),t&&u&&c&&d.data?(0,U.jsx)(bR,{account:i??``,project:c,variable:u,previewEnvironments:f,onClose:()=>n(!1)},`${u.id}:${l.dataUpdatedAt}`):null,t&&p&&c&&d.data?(0,U.jsx)(CR,{account:i??``,project:c,previewEnvironments:f,initialName:e.name,onClose:()=>n(!1)}):null]})}var DR=`~working-copy`,OR=`$import(@zuplo/runtime)`;function cBe(e){if(typeof e!=`object`||!e)return null;let t=e,n=typeof t.path==`string`?t.path:void 0;return n?{path:n,label:typeof t.label==`string`?t.label:void 0,description:typeof t.description==`string`?t.description:void 0}:null}function lBe({data:e}){let t=ao(),{account:n,project:r}=sx([]),{logEvent:i}=S(),a=!!(n&&r);return(0,U.jsx)(WMe,{path:e.path,label:e.label,description:e.description,disabled:!a,onOpen:()=>{!n||!r||(i(`agent-z-file-link-clicked`,{account:n,project:r}),t(`${ri(rx.Code,{account:n,project:r,environment:DR})}?path=${encodeURIComponent(e.path)}`))}})}function uBe(e){if(typeof e!=`object`||!e)return null;let t=e,n=typeof t.ticketId==`string`?t.ticketId.trim():``;if(!n)return null;let r=typeof t.subject==`string`?t.subject.trim():``,i=typeof t.status==`string`&&t.status in vO?t.status:void 0;return{ticketId:n,subject:r||void 0,status:i,description:typeof t.description==`string`?t.description:void 0}}function dBe({data:e}){let t=ao(),{account:n,project:r}=sx([]),{logEvent:i}=S();return(0,U.jsx)(QMe,{data:e,disabled:!n,onOpen:()=>{n&&(i(`agent-z-support-ticket-opened`,{account:n,project:r,ticketId:e.ticketId}),t(yO(n,e.ticketId)))}})}var kR=[{id:`tools-list`,method:`tools/list`,label:`List tools`},{id:`tools-call`,method:`tools/call`,label:`Call tool`,params:{name:``,arguments:{}}},{id:`prompts-list`,method:`prompts/list`,label:`List prompts`},{id:`prompts-get`,method:`prompts/get`,label:`Get prompt`,params:{name:``,arguments:{}}},{id:`resources-list`,method:`resources/list`,label:`List resources`},{id:`resources-read`,method:`resources/read`,label:`Read resource`,params:{uri:``}},{id:`initialize`,method:`initialize`,label:`Initialize`,params:{protocolVersion:vg,capabilities:{},clientInfo:{name:`zuplo-portal-playground`,version:`1.0.0`}}},{id:`ping`,method:`ping`,label:`Ping`}],fBe=kR[0];function AR(e){let t={jsonrpc:`2.0`,id:1,method:e.method};return e.params&&(t.params=e.params),JSON.stringify(t,null,2)}var jR=AR(fBe);function MR(e){if(!e?.trim())return!1;try{let t=JSON.parse(e);return!!t&&typeof t==`object`&&t.jsonrpc===`2.0`&&typeof t.method==`string`}catch{return!1}}function pBe(e){if(!e||typeof e!=`object`)return null;if(e.default!==void 0)return e.default;if(Array.isArray(e.examples)&&e.examples.length>0)return e.examples[0];if(Array.isArray(e.enum)&&e.enum.length>0)return e.enum[0];switch(Array.isArray(e.type)?e.type[0]:e.type){case`string`:return``;case`number`:case`integer`:return 0;case`boolean`:return!1;case`array`:return[];case`object`:return NR(e);default:return null}}function NR(e){let t={},n=e?.properties;if(!n)return t;for(let[e,r]of Object.entries(n))t[e]=pBe(r);return t}function mBe(e){return NR(e)}function hBe(e){let t={jsonrpc:`2.0`,id:1,method:`tools/call`,params:{name:e.name,arguments:mBe(e.inputSchema)}};return JSON.stringify(t,null,2)}function gBe(e){let t=e.trim();if(!t)return[];let n=[];try{n.push(JSON.parse(t))}catch{for(let e of t.split(/\r?\n/)){let t=e.trim();if(!t.startsWith(`data:`))continue;let r=t.slice(5).trim();if(!(!r||r===`[DONE]`))try{n.push(JSON.parse(r))}catch{}}}return n.flatMap(e=>Array.isArray(e)?e:[e])}function _Be(e){if(!e||typeof e!=`object`)return[];let t=e.name;if(typeof t!=`string`)return[];let n=e.description;return[{name:t,...typeof n==`string`?{description:n}:{},inputSchema:e.inputSchema}]}function vBe(e){let t=gBe(e);if(t.length===0)return{ok:!1,error:`Couldn't read the MCP server's response.`};for(let e of t){let t=e&&typeof e==`object`?e.error:void 0;if(t){let e=t.message;return{ok:!1,error:typeof e==`string`?e:`The MCP server returned an error.`}}}for(let e of t){let t=e?.result?.tools;if(Array.isArray(t))return{ok:!0,tools:t.flatMap(_Be)}}return{ok:!1,error:`The server didn't return any tools.`}}var PR=[`GET`,`POST`,`PUT`,`DELETE`,`PATCH`,`QUERY`,`HEAD`,`CONNECT`,`OPTIONS`,`TRACE`],FR={GET:`text-emerald-600 dark:text-emerald-400`,POST:`text-amber-600 dark:text-amber-400`,PUT:`text-blue-600 dark:text-blue-400`,PATCH:`text-violet-600 dark:text-violet-400`,DELETE:`text-red-600 dark:text-red-400`,QUERY:`text-indigo-600 dark:text-indigo-400`,HEAD:`text-teal-600 dark:text-teal-400`},IR=e=>![`GET`,`HEAD`].includes(e),LR={none:`None`,json:`JSON`,text:`Text`,form:`Form`,graphql:`GraphQL`,mcp:`MCP`},yBe={none:void 0,json:`application/json`,text:`text/plain`,form:`application/x-www-form-urlencoded`,graphql:`application/json`,mcp:`application/json`},bBe={none:void 0,json:`json`,text:void 0,form:void 0,graphql:`graphql`,mcp:`json`},xBe=e=>{let t=Object.keys(e).find(e=>e.toLowerCase()===`content-type`);return t?e[t]:void 0},SBe=e=>{if(!e?.trim())return!1;try{let t=JSON.parse(e);return!!t&&typeof t==`object`&&typeof t.query==`string`}catch{return!1}},RR=e=>{if(!IR(e.method))return`none`;let t=xBe(e.headers??{});return t?.startsWith(`application/x-www-form-urlencoded`)?`form`:t?.startsWith(`application/json`)?MR(e.body)?`mcp`:SBe(e.body)?`graphql`:`json`:t?.startsWith(`text/`)||e.body?`text`:`none`},zR=e=>`'${e.replace(/'/g,`'\\''`)}'`,CBe=(e,t,n,r)=>{let i=[`curl -X ${e} ${zR(t)}`];for(let[e,t]of Object.entries(n))i.push(` -H ${zR(`${e}: ${t}`)}`);return r&&IR(e)&&i.push(` --data ${zR(r)}`),i.join(` \\
253
+ `]}),(0,U.jsx)(`textarea`,{onScroll:e=>{e.target instanceof HTMLTextAreaElement&&i.current?.scrollTo({top:e.target.scrollTop,left:e.target.scrollLeft,behavior:`instant`})},spellCheck:!1,disabled:n,...r,className:W(`absolute top-0 left-0 h-full flex-1 border min-w-0 block p-2 rounded-sm`,`bg-transparent border-0 w-full font-mono text-sm overflow-y-auto overflow-x-hidden resize-none outline-hidden`,hR,`disabled:opacity-50 disabled:hover:cursor-not-allowed disabled:cursor-not-allowed`),value:e})]})},tBe=`•`.repeat(12),_R=`env-var-secret-value-hint`,nBe=({variable:e,previewEnvironments:t,environmentsLoaded:n=!1,defaultBranch:r,onClose:i,isSaving:a,error:o,onSubmit:s})=>{let c=vA({defaultValues:{preview:e.targets.includes(`preview`),production:e.targets.includes(`production`),workingCopy:e.targets.includes(`working-copy`),name:e.name,isSecret:e.type===`secret`,value:e.type===`secret`?``:e.value??null,personalOverride:e.personalValue!==void 0,personalValue:e.personalValue??null,targetBranch:e.targetBranch??`__NULL_BRANCH`},mode:`onChange`}),{getValues:l,control:u,register:d}=c,f=e.type===`secret`,{isValid:p,dirtyFields:m,touchedFields:h}=Ck({control:u}),g=l(),_=g.production||g.preview||g.workingCopy,v=!a&&_&&p,y=()=>{s(l(),m,h)};return(0,U.jsx)(vk,{...c,children:(0,U.jsx)(jL,{isOpen:!0,className:`sm:max-w-2xl`,onClose:i,title:`Edit environment variable`,children:(0,U.jsx)(`div`,{className:`flex flex-col`,children:(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,U.jsx)(SA,{error:o}),(0,U.jsx)(eBe,{}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`span`,{className:`text-sm`,children:`Value`}),(0,U.jsx)(Ek,{control:u,name:`value`,render:({field:{value:e,...t}})=>(0,U.jsx)(gR,{...t,value:e??``,"aria-label":`Value`,"aria-describedby":f?_R:void 0,placeholder:f?tBe:void 0,"data-test":`variable-value-input`})}),f&&(0,U.jsx)(`p`,{id:_R,className:`text-xs text-muted-foreground mt-1`,"data-test":`secret-value-hint`,children:`The current value is hidden and can’t be shown again. Leave this blank to keep it, or type a new value to replace it.`})]}),(0,U.jsxs)(`label`,{className:W(`flex flex-row border rounded-sm p-4 gap-4`,`bg-gray-100 dark:bg-neutral-800 border-border opacity-30`),children:[(0,U.jsx)(`input`,{...d(`isSecret`),id:`is-secret`,disabled:!0,className:`rounded-sm border border-border shadow-sm mt-0.5`,type:`checkbox`,"data-test":`is-secret-checkbox`}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`span`,{className:`whitespace-nowrap`,children:`Secret`}),(0,U.jsx)(`div`,{className:`text-sm`,children:`Secrets are environment variables that are encrypted and not visible after they are set. Secrets are used for storing sensitive information like API keys and auth token.`})]})]}),(0,U.jsx)(pR,{previewEnvironments:t,environmentsLoaded:n,defaultBranch:r}),(0,U.jsxs)(`div`,{className:`flex flex-row space-x-2 mt-3 justify-between`,children:[(0,U.jsx)(X,{onClick:()=>i(),variant:`secondary`,children:`Cancel`}),(0,U.jsxs)(X,{disabled:!v,type:`button`,"data-test":`save-variable`,onClick:y,children:[a&&(0,U.jsx)(WI,{borderPositionAndSize:`w-4 h-4 border-2 border-white mr-2`}),`Save`]})]})]})})})})},vR=(e,t,n)=>ox(je.environmentVariables(e,t),{...n,extractData:!0}),yR=()=>{let e=bt();return Oe({mutationFn:async t=>{await e.fetch(ae.environmentVariables.updateEnvironmentVariable(t))}})},rBe=()=>{let e=bt();return Oe({mutationFn:async t=>await e.fetch(ae.environmentVariables.createEnvironmentVariable(t))})},iBe=()=>{let e=bt();return Oe({mutationFn:async t=>{await e.fetch(ae.environmentVariables.deleteEnvironmentVariable(t))}})};function bR({variable:e,previewEnvironments:t,environmentsLoaded:n=!1,onClose:r,account:i,project:a}){let o=Ep(),{logEvent:s,captureException:c}=S(),l=yR(),u=(e,t,n)=>{s(`env-var-edited`,{type:e,targets:t.join(`,`),personalOverride:`${n}`,account:i,project:a.name});let c=t.filter(e=>e!==`working-copy`);a.sourceRepoUrl!=null&&c.length>0&&o.success(`Redeploy your project to apply changes.`,{title:`Redeploy required`,icon:(0,U.jsx)(Ff,{className:`h-6 w-6`})}),r()};return(0,U.jsx)(nBe,{variable:e,previewEnvironments:t,environmentsLoaded:n,defaultBranch:a.defaultBranch,onSubmit:(t,n,r)=>{let o=NL(t),d={id:e.id,name:e.name,value:n.value?t.value??void 0:void 0,targets:r.production||r.preview||r.workingCopy?o:void 0};if(n.targetBranch){let e=t.targetBranch;d.targetBranch=e===`__NULL_BRANCH`?null:e}r.preview&&t.preview===!1&&(d.targetBranch=null),n.personalOverride&&t.personalOverride&&(d.personalValue=``),n.personalValue&&(d.personalValue=t.personalValue),(n.workingCopy&&t.workingCopy===!1||n.personalOverride&&t.personalOverride===!1)&&(d.personalValue=null),l.mutate({accountName:i,projectName:a.name,variableData:d},{onSuccess:()=>u(d.type??`config`,d.targets??e.targets,t.personalOverride),onError:e=>{s(`env-var-edit-failed`,{account:i,project:a.name}),c(e)}})},onClose:r,isSaving:l.isPending,error:l.error})}var xR={name:``,value:``,isSecret:!1},SR=`grid grid-cols-[minmax(0,2fr)_minmax(0,3fr)_3rem_2.25rem] gap-2`,aBe=({previewEnvironments:e,defaultBranch:t,initialName:n,onSubmit:r,onClose:i,onPasteParsed:a})=>{let o=vA({defaultValues:{variables:[{...xR,name:n??``}],production:!0,preview:!0,workingCopy:!0,targetBranch:ML,personalOverride:!1,personalValue:null},mode:`onChange`}),{control:s,register:c,getValues:l,setValue:u,watch:d,trigger:f}=o,{fields:p,append:m,remove:h,replace:g}=_A({control:s,name:`variables`}),{isValid:_,errors:v}=Ck({control:s}),[y,b]=(0,H.useState)(!1),[x,S]=(0,H.useState)(null),[C,w]=(0,H.useState)(null),[T,E]=(0,H.useState)(new Set),D=(0,H.useRef)(null);(0,H.useEffect)(()=>{x!=null&&D.current?.scrollIntoView?.({block:`nearest`})},[x]),(0,H.useEffect)(()=>{n&&f()},[n,f]);let O=d(`variables`),k=d(`production`),A=d(`preview`),j=d(`workingCopy`),M=k||A||j,N=O.filter(e=>e.name.trim()!==``).length,P=!y&&M&&_&&N>0,F=e=>{e>1&&l(`personalOverride`)&&(u(`personalOverride`,!1),u(`personalValue`,null))},I=(e,t)=>{let n=l(`variables`).map(e=>({...e})),r=n[e]?.name.trim()===``?e:null;for(let e of t){let t=n.findIndex((t,n)=>n!==r&&t.name!==``&&t.name===e.name);t>=0?n[t].value=e.value:r==null?n.push({...e,isSecret:!1}):(n[r]={...n[r],...e},r=null)}g(n),F(n.length),a?.(t.length)},L=e=>t=>{let n=PL(t.clipboardData.getData(`text`));n&&(t.preventDefault(),I(e,n))},R=e=>t=>{let n=t.clipboardData.getData(`text`),r=PL(n);if(!r)return;let i=l(`variables.${e}.name`);r.length===1&&!/\r?\n/.test(n.trim())&&i.trim()!==``||(t.preventDefault(),I(e,r))},z=()=>{m({...xR}),F(p.length+1)},B=async()=>{b(!0),S(null),w(null);try{let e=await r(l());if(e.savedNames.length>0&&E(t=>new Set([...t,...e.savedNames])),e.error==null)return;S(e.error),w(e.failedName??null)}finally{b(!1)}};return(0,U.jsx)(vk,{...o,children:(0,U.jsx)(ow,{open:!0,onOpenChange:e=>!e&&i(),children:(0,U.jsxs)(lw,{className:`flex max-h-[85vh] flex-col gap-0 p-0 sm:max-w-3xl`,children:[(0,U.jsxs)(uw,{className:`border-b px-6 py-4`,children:[(0,U.jsx)(fw,{children:`Add Environment Variables`}),(0,U.jsxs)(pw,{children:[`Add one or more variables. Pasting the contents of a`,` `,(0,U.jsx)(`span`,{className:`font-mono`,children:`.env`}),` file (or any`,` `,(0,U.jsx)(`span`,{className:`font-mono`,children:`KEY=VALUE`}),` lines) into a field fills the form automatically.`]})]}),(0,U.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto px-6 py-4`,children:[x!=null&&(0,U.jsx)(`div`,{ref:D,children:(0,U.jsx)(SA,{error:x,className:`mb-0`})}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,U.jsxs)(`div`,{className:`${SR} text-sm font-medium`,children:[(0,U.jsx)(`span`,{children:`Name`}),(0,U.jsx)(`span`,{children:`Value`}),(0,U.jsx)(`span`,{className:`text-center`,children:`Secret`}),(0,U.jsx)(`span`,{})]}),p.map((e,t)=>{let n=v.variables?.[t]?.name?.message,r=O[t]?.name??``,i=C!=null&&r===C,a=r!==``&&T.has(r)&&!i;return(0,U.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,U.jsxs)(`div`,{className:`${SR} items-start`,children:[(0,U.jsx)(gT,{placeholder:`EXAMPLE_NAME`,"aria-invalid":n||i?!0:void 0,onInput:e=>{let t=e.target,n=t.selectionStart;t.value=t.value.toUpperCase().replace(/[^A-Z0-9_]/g,`_`),t.setSelectionRange(n,n)},onPaste:L(t),"data-test":`variable-name-input-${t}`,...c(`variables.${t}.name`,{validate:(e,n)=>{let r=e.trim();return r===``?n.variables[t]?.value?`Name is required`:!0:Oze.test(r)?n.variables.filter(e=>e.name.trim()===r).length>1?`Duplicate variable name`:!0:kze}})}),(0,U.jsx)(Ek,{control:s,name:`variables.${t}.value`,render:({field:{value:e,...n}})=>(0,U.jsx)(gR,{...n,value:e??``,onPaste:R(t),className:`max-h-32`,"data-test":`variable-value-input-${t}`})}),(0,U.jsx)(Ek,{control:s,name:`variables.${t}.isSecret`,render:({field:{value:e,onChange:n}})=>(0,U.jsx)(X,{type:`button`,variant:`ghost`,size:`icon-sm`,className:W(`mt-0.5 justify-self-center`,!e&&`text-muted-foreground`),"aria-pressed":e,"aria-label":`Secret`,disabled:a,title:a?`Already saved — a variable's type cannot be changed`:e?`Secret — the value will be encrypted and hidden once saved`:`Not a secret — click to make this variable a secret`,"data-test":`variable-secret-toggle-${t}`,onClick:()=>n(!e),children:e?(0,U.jsx)(yf,{className:`size-4`}):(0,U.jsx)(_ee,{className:`size-4`})})}),(0,U.jsx)(X,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`mt-0.5`,disabled:p.length===1,title:`Remove variable`,"data-test":`remove-variable-${t}`,onClick:()=>h(t),children:(0,U.jsx)(op,{className:`size-4`})})]}),(n||i)&&(0,U.jsx)(`p`,{className:`text-xs text-destructive`,"data-test":`variable-name-error-${t}`,children:n??`This variable failed to save — see the error above.`}),a&&!n&&(0,U.jsxs)(`p`,{className:`inline-flex items-center gap-1 text-xs text-muted-foreground`,"data-test":`variable-saved-${t}`,children:[(0,U.jsx)(fd,{className:`size-3`}),`Saved — saving again updates it`]})]},e.id)}),(0,U.jsx)(`div`,{children:(0,U.jsxs)(X,{type:`button`,variant:`outline`,size:`sm`,"data-test":`add-another-variable`,onClick:z,children:[(0,U.jsx)(Mf,{className:`size-4`}),`Add another`]})}),(0,U.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Variables marked as `,(0,U.jsx)(yf,{className:`inline size-3`}),` `,`secret are encrypted and not visible after they are set — use them for sensitive information like API keys and auth tokens.`]})]}),(0,U.jsx)(pR,{previewEnvironments:e,defaultBranch:t,personalOverrideEnabled:p.length===1})]}),(0,U.jsxs)(dw,{className:`border-t px-6 py-4 sm:justify-between`,children:[(0,U.jsx)(X,{variant:`secondary`,onClick:()=>i(),children:`Cancel`}),(0,U.jsxs)(X,{disabled:!P,type:`button`,"data-test":`save-variable`,onClick:B,children:[y&&(0,U.jsx)(WI,{borderPositionAndSize:`w-4 h-4 border-2 border-white mr-2`}),N>1?`Save ${N} variables`:`Save`]})]})]})})})},CR=({previewEnvironments:e,account:t,project:n,initialName:r,onClose:i})=>{let{logEvent:a,captureException:o}=S(),s=Ep(),c=rBe(),l=yR(),u=(0,H.useRef)(new Map),d=(e,t)=>{let r=t.filter(e=>e!==`working-copy`);n.sourceRepoUrl!=null&&r.length>0&&s.success(`Redeploy your environment to apply changes.`,{title:e===1?`Environment variable created`:`${e} environment variables created`}),i()};return(0,U.jsx)(aBe,{previewEnvironments:e,defaultBranch:n.defaultBranch,initialName:r,onSubmit:async e=>{let r=e.variables.filter(e=>e.name.trim()!==``),i=NL(e),s=e.preview&&e.targetBranch!==`__NULL_BRANCH`?e.targetBranch??void 0:void 0,f=r.length===1&&e.workingCopy&&e.personalOverride?e.personalValue??``:void 0,p=[];for(let e of r){let d=u.current.get(e.name),m=e.isSecret?`secret`:`config`;try{if(d!=null)await l.mutateAsync({accountName:t,projectName:n.name,variableData:{id:d,name:e.name,value:e.value,targets:i,targetBranch:s??null,personalValue:f??null}});else{let o=await c.mutateAsync({accountName:t,projectName:n.name,variableData:{name:e.name,value:e.value,type:m,targets:i,targetBranch:s,personalValue:f}});o?.id&&u.current.set(e.name,o.id),a(`env-var-created`,{type:m,targets:i.join(`,`),personalOverride:`${f!==void 0}`,batchSize:`${r.length}`,account:t,project:n.name})}}catch(r){return a(`env-var-creation-failed`,{account:t,project:n.name}),o(r),{savedNames:p,failedName:e.name,error:r}}p.push(e.name)}return d(p.length,i),{savedNames:p,error:null}},onClose:i,onPasteParsed:e=>a(`env-vars-pasted`,{count:`${e}`,account:t,project:n.name})})},wR=(e,t,n)=>k({...m.deployments.list(e,t),...n,select:e=>e.data}),TR=(e,t={})=>Aee({...m.deployments.versions.list(e),...t,select:e=>({...e,data:e.data?.map(e=>({...e,stages:[...e.stages].sort((e,t)=>e.stage.localeCompare(t.stage))}))})}),ER=(e,t={})=>Pe(TR(e,t));function oBe(e){if(typeof e!=`object`||!e)return null;let t=e,n=typeof t.name==`string`?t.name:void 0;return n?{name:n,description:typeof t.description==`string`?t.description:void 0}:null}function sBe({data:e}){let[t,n]=(0,H.useState)(!1),{logEvent:r}=S(),{account:i,project:a}=sx([]),o=!!(i&&a),s=Kw(i??``,{enabled:t&&o,throwOnError:!1,refetchOnMount:!1,refetchOnWindowFocus:!1}),c=s.data?.find(e=>e.name===a),l=vR(i??``,a??``,{enabled:t&&o,useErrorBoundary:!1,refetchOnMount:!1,refetchOnWindowFocus:!1}),u=l.data?.find(t=>t.name===e.name),d=wR(i??``,a??``,{enabled:t&&o}),f=d.data?.filter(e=>!AL(e.environmentType,kL.PRODUCTION,kL.WORKING_COPY))??[],p=t&&!l.isFetching&&l.data!=null&&!u,m=t&&(!l.isFetching&&l.isError||!d.isFetching&&d.isError||!s.isFetching&&s.isError),h=!!(c&&d.data),g=t&&!m&&!(u&&h)&&!(p&&h);return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(UMe,{name:e.name,description:e.description,loading:g,disabled:!o,errorText:m?`Couldn’t load variable “${e.name}” — please try again.`:void 0,onOpen:()=>{o&&(r(`agent-z-env-var-card-clicked`,{account:i,project:a}),n(!0),l.isError&&l.refetch(),d.isError&&d.refetch(),s.isError&&s.refetch())}}),t&&u&&c&&d.data?(0,U.jsx)(bR,{account:i??``,project:c,variable:u,previewEnvironments:f,environmentsLoaded:!0,onClose:()=>n(!1)},`${u.id}:${l.dataUpdatedAt}`):null,t&&p&&c&&d.data?(0,U.jsx)(CR,{account:i??``,project:c,previewEnvironments:f,initialName:e.name,onClose:()=>n(!1)}):null]})}var DR=`~working-copy`,OR=`$import(@zuplo/runtime)`;function cBe(e){if(typeof e!=`object`||!e)return null;let t=e,n=typeof t.path==`string`?t.path:void 0;return n?{path:n,label:typeof t.label==`string`?t.label:void 0,description:typeof t.description==`string`?t.description:void 0}:null}function lBe({data:e}){let t=ao(),{account:n,project:r}=sx([]),{logEvent:i}=S(),a=!!(n&&r);return(0,U.jsx)(WMe,{path:e.path,label:e.label,description:e.description,disabled:!a,onOpen:()=>{!n||!r||(i(`agent-z-file-link-clicked`,{account:n,project:r}),t(`${ri(rx.Code,{account:n,project:r,environment:DR})}?path=${encodeURIComponent(e.path)}`))}})}function uBe(e){if(typeof e!=`object`||!e)return null;let t=e,n=typeof t.ticketId==`string`?t.ticketId.trim():``;if(!n)return null;let r=typeof t.subject==`string`?t.subject.trim():``,i=typeof t.status==`string`&&t.status in vO?t.status:void 0;return{ticketId:n,subject:r||void 0,status:i,description:typeof t.description==`string`?t.description:void 0}}function dBe({data:e}){let t=ao(),{account:n,project:r}=sx([]),{logEvent:i}=S();return(0,U.jsx)(QMe,{data:e,disabled:!n,onOpen:()=>{n&&(i(`agent-z-support-ticket-opened`,{account:n,project:r,ticketId:e.ticketId}),t(yO(n,e.ticketId)))}})}var kR=[{id:`tools-list`,method:`tools/list`,label:`List tools`},{id:`tools-call`,method:`tools/call`,label:`Call tool`,params:{name:``,arguments:{}}},{id:`prompts-list`,method:`prompts/list`,label:`List prompts`},{id:`prompts-get`,method:`prompts/get`,label:`Get prompt`,params:{name:``,arguments:{}}},{id:`resources-list`,method:`resources/list`,label:`List resources`},{id:`resources-read`,method:`resources/read`,label:`Read resource`,params:{uri:``}},{id:`initialize`,method:`initialize`,label:`Initialize`,params:{protocolVersion:vg,capabilities:{},clientInfo:{name:`zuplo-portal-playground`,version:`1.0.0`}}},{id:`ping`,method:`ping`,label:`Ping`}],fBe=kR[0];function AR(e){let t={jsonrpc:`2.0`,id:1,method:e.method};return e.params&&(t.params=e.params),JSON.stringify(t,null,2)}var jR=AR(fBe);function MR(e){if(!e?.trim())return!1;try{let t=JSON.parse(e);return!!t&&typeof t==`object`&&t.jsonrpc===`2.0`&&typeof t.method==`string`}catch{return!1}}function pBe(e){if(!e||typeof e!=`object`)return null;if(e.default!==void 0)return e.default;if(Array.isArray(e.examples)&&e.examples.length>0)return e.examples[0];if(Array.isArray(e.enum)&&e.enum.length>0)return e.enum[0];switch(Array.isArray(e.type)?e.type[0]:e.type){case`string`:return``;case`number`:case`integer`:return 0;case`boolean`:return!1;case`array`:return[];case`object`:return NR(e);default:return null}}function NR(e){let t={},n=e?.properties;if(!n)return t;for(let[e,r]of Object.entries(n))t[e]=pBe(r);return t}function mBe(e){return NR(e)}function hBe(e){let t={jsonrpc:`2.0`,id:1,method:`tools/call`,params:{name:e.name,arguments:mBe(e.inputSchema)}};return JSON.stringify(t,null,2)}function gBe(e){let t=e.trim();if(!t)return[];let n=[];try{n.push(JSON.parse(t))}catch{for(let e of t.split(/\r?\n/)){let t=e.trim();if(!t.startsWith(`data:`))continue;let r=t.slice(5).trim();if(!(!r||r===`[DONE]`))try{n.push(JSON.parse(r))}catch{}}}return n.flatMap(e=>Array.isArray(e)?e:[e])}function _Be(e){if(!e||typeof e!=`object`)return[];let t=e.name;if(typeof t!=`string`)return[];let n=e.description;return[{name:t,...typeof n==`string`?{description:n}:{},inputSchema:e.inputSchema}]}function vBe(e){let t=gBe(e);if(t.length===0)return{ok:!1,error:`Couldn't read the MCP server's response.`};for(let e of t){let t=e&&typeof e==`object`?e.error:void 0;if(t){let e=t.message;return{ok:!1,error:typeof e==`string`?e:`The MCP server returned an error.`}}}for(let e of t){let t=e?.result?.tools;if(Array.isArray(t))return{ok:!0,tools:t.flatMap(_Be)}}return{ok:!1,error:`The server didn't return any tools.`}}var PR=[`GET`,`POST`,`PUT`,`DELETE`,`PATCH`,`QUERY`,`HEAD`,`CONNECT`,`OPTIONS`,`TRACE`],FR={GET:`text-emerald-600 dark:text-emerald-400`,POST:`text-amber-600 dark:text-amber-400`,PUT:`text-blue-600 dark:text-blue-400`,PATCH:`text-violet-600 dark:text-violet-400`,DELETE:`text-red-600 dark:text-red-400`,QUERY:`text-indigo-600 dark:text-indigo-400`,HEAD:`text-teal-600 dark:text-teal-400`},IR=e=>![`GET`,`HEAD`].includes(e),LR={none:`None`,json:`JSON`,text:`Text`,form:`Form`,graphql:`GraphQL`,mcp:`MCP`},yBe={none:void 0,json:`application/json`,text:`text/plain`,form:`application/x-www-form-urlencoded`,graphql:`application/json`,mcp:`application/json`},bBe={none:void 0,json:`json`,text:void 0,form:void 0,graphql:`graphql`,mcp:`json`},xBe=e=>{let t=Object.keys(e).find(e=>e.toLowerCase()===`content-type`);return t?e[t]:void 0},SBe=e=>{if(!e?.trim())return!1;try{let t=JSON.parse(e);return!!t&&typeof t==`object`&&typeof t.query==`string`}catch{return!1}},RR=e=>{if(!IR(e.method))return`none`;let t=xBe(e.headers??{});return t?.startsWith(`application/x-www-form-urlencoded`)?`form`:t?.startsWith(`application/json`)?MR(e.body)?`mcp`:SBe(e.body)?`graphql`:`json`:t?.startsWith(`text/`)||e.body?`text`:`none`},zR=e=>`'${e.replace(/'/g,`'\\''`)}'`,CBe=(e,t,n,r)=>{let i=[`curl -X ${e} ${zR(t)}`];for(let[e,t]of Object.entries(n))i.push(` -H ${zR(`${e}: ${t}`)}`);return r&&IR(e)&&i.push(` --data ${zR(r)}`),i.join(` \\
254
254
  `)},wBe=(e,t,n,r)=>{let i={method:e};return Object.keys(n).length>0&&(i.headers=n),r&&IR(e)&&(i.body=r),`await fetch(${JSON.stringify(t)}, ${JSON.stringify(i,null,2)});`},TBe=(e,t,n,r)=>{let i=t,a=``;try{let e=new URL(t);a=e.host,i=`${e.pathname}${e.search}`||`/`}catch{}let o=[`${e} ${i} HTTP/1.1`];a&&o.push(`Host: ${a}`);for(let[e,t]of Object.entries(n))o.push(`${e}: ${t}`);let s=o.join(`
255
255
  `);return r&&IR(e)&&(s+=`\n\n${r}`),s},BR=(e,t)=>{let n=e.trim();if(t&&n.startsWith(t)){let e=n.slice(t.length);return e===``?`/`:e.startsWith(`/`)?e:`/${e}`}try{let e=new URL(n);return`${e.pathname||`/`}${e.search}${e.hash}`}catch{return n.startsWith(`/`)?n:`/${n}`}},VR=`SAVED_TESTS`,HR=()=>{let e=localStorage.getItem(VR);if(!e)return{data:[]};try{return JSON.parse(e)}catch{return{data:[]}}},UR=e=>{let t=JSON.stringify(e);localStorage.setItem(VR,t)},WR=class{writeTest=e=>{let t=HR(),n=t.data.findIndex(t=>e.account===t.account&&e.project===t.project&&e.environment===t.environment&&e.operationId===t.operationId);n===-1?t.data.push(e):t.data[n]=e,UR(t)};getTest=(e,t,n,r)=>HR().data.find(i=>i.account===e&&i.project===t&&i.environment===n&&i.operationId===r);optTestOutOfLocalSaving=(e,t,n,r)=>{let i={account:e,project:t,environment:n,operationId:r,shouldSaveTest:!1};this.writeTest(i)};deleteTest=(e,t,n,r)=>{let i=HR(),a=i.data.findIndex(i=>e===i.account&&t===i.project&&n===i.environment&&r===i.operationId);a!==-1&&(i.data.splice(a,1),UR(i))}},EBe={FIRST_200_TEST:`✨`},DBe=()=>({celebrate:(e,t)=>{e===`FIRST_200_TEST`&&t?.status&&t&&localStorage.getItem(`FIRST_200_TEST`)===null&&t.status.toString().substring(0,1)===`2`&&(new nT().addConfetti({emojis:[EBe.FIRST_200_TEST]}),localStorage.setItem(`FIRST_200_TEST`,`true`))}}),GR=()=>{let e=bt({cache:`no-store`}),t=async(t,n)=>{let r=await e.fetch(ae.testDesigner.makeTestRequest({...t,buildId:n}));if(!r.ok)throw await F(r);return r};return async e=>{let n=e.buildId??Ht(e.environmentName),r=await t(e,n);return n&&E(await r.clone().json().catch(()=>void 0))?(kt(e.environmentName),t(e,void 0)):r}},OBe=e=>e.some(e=>e.status===`failed`)?`failed`:e.some(e=>e.status===`in-progress`)?`in-progress`:e.some(e=>e.status===`success`)?`success`:`idle`,kBe=3,ABe=async({getLatestBuild:e,getServingBuildId:t,getCachedServingBuildId:n,addressBuildDirectly:r,setPhase:i,delay:a,now:o,isCancelled:s,isSkipped:c,pollMs:l,timeoutMs:u})=>{let d=o()+u,f=`idle`,p=e=>{e!==f&&(f=e,i(e))},m=!1,h=!1,g=0,_=()=>(p(`executing`),h=!0,`ready`);try{for(;!s();){if(c())return`ready`;let i;try{i=await e()}catch{if(o()>=d)return`timeout`;await a(l);continue}if(!i)return`ready`;let s=OBe(i.stages);if(s===`in-progress`)m=!0,p(`waiting-for-build`);else if(s===`failed`)return m?`build-failed`:`ready`;else if(s===`success`){if(r?.(i.id))return m?_():`ready`;if(!m&&n()===i.id)return`ready`;p(`verifying-deployment`);let e=await t().catch(()=>void 0);if(e===i.id)return _();if(e===void 0){if(g+=1,g>=kBe)return _()}else g=0}else return`ready`;if(o()>=d)return`timeout`;await a(l)}return`timeout`}finally{h||p(`idle`)}},KR=(e,t=`api`)=>jBe(e,t)?.url,jBe=(e,t=`api`)=>e.deploymentVersion?.stages.find(e=>e.stage===t),MBe=e=>{if(typeof e!=`string`)return;let t;try{t=JSON.parse(e)}catch{return}if(typeof t!=`object`||!t)return;let n=t;if(typeof n.buildId==`string`)return n;let r=n.trace?.buildId;return typeof r==`string`?{buildId:r}:void 0},NBe=e=>{let t=KR(e),n=k({...TR(e.name),enabled:!t});return t||(n.data?.data?.flatMap(e=>e.stages).find(e=>e.stage===`api`&&e.url)?.url??void 0)},qR=async(e,t,n)=>{let r=MBe((await(await e({environmentName:t,overrideUrl:n,testRequest:{description:``,pathname:`/__zuplo/build`,method:`GET`,headers:{}}})).json()).body);if(!r)throw Error(`Failed to fetch build info`);return r},JR=3e4,PBe=(e,t)=>{let n=GR(),r=e?.replace(/\/$/,``);return k({queryKey:[`gateway-build`,r],queryFn:async()=>{if(!r)throw Error(`Failed to fetch build info`);return qR(n,t,r)},enabled:!!r,staleTime:15e3,refetchInterval:JR,retry:!1})},FBe=2e3,IBe=120*1e3,LBe=(e,t)=>{let n=At(),r=GR(),[i,a]=(0,H.useState)(`idle`),o=(0,H.useRef)(!1);(0,H.useEffect)(()=>(o.current=!1,()=>{o.current=!0}),[]);let s=(0,H.useRef)(0),c=(0,H.useRef)(null),l=(0,H.useCallback)(()=>{c.current?.abort()},[]),u=e.name,d=e.environmentType,f=t?.replace(/\/$/,``);return{phase:i,awaitReady:(0,H.useCallback)(e=>{if(!f)return Promise.resolve(`ready`);s.current+=1;let t=s.current,i=e=>{s.current===t&&a(e)};i(`idle`);let l=new AbortController;c.current=l;let p=l.signal;return ABe({getLatestBuild:async()=>{let e=(await n.fetchQuery(TR(u))).data?.[0];if(e)return{id:e.id,stages:e.stages.filter(e=>e.stage===`api`)}},getServingBuildId:async()=>(await qR(r,u,f)).buildId,getCachedServingBuildId:()=>n.getQueryData([`gateway-build`,f])?.buildId,addressBuildDirectly:e=>d===kL.WORKING_COPY?(mt(u,e),!0):!1,setPhase:i,delay:t=>new Promise(n=>{if(e?.aborted||p.aborted){n();return}let r=setTimeout(n,t),i=()=>{clearTimeout(r),n()};e?.addEventListener(`abort`,i,{once:!0}),p.addEventListener(`abort`,i,{once:!0})}),now:()=>Date.now(),isCancelled:()=>o.current||(e?.aborted??!1),isSkipped:()=>p.aborted,pollMs:FBe,timeoutMs:IBe})},[n,r,u,d,f]),skip:l}};function YR(e,t){let n=({className:n,...r})=>{let i=typeof t==`function`?t({...r,className:n}):W(t,n);return H.createElement(e,{...r,className:i})};return n.displayName=typeof e==`string`?`VariantComponent(${e})`:`VariantComponent(${e.displayName??e.name??`Component`})`,n}var XR=e=>{let t=(0,H.useRef)(e);return t.current=e,(0,H.useEffect)(()=>{t.current=e},[e]),t};function RBe(){let e=navigator.userAgent.toLowerCase();if(e.indexOf(`win`)!==-1)return`windows`;if(e.indexOf(`mac`)!==-1)return`apple`;if(e.indexOf(`linux`)!==-1)return`linux`;if(e.indexOf(`x11`)!==-1)return`unix`}function ZR(){return RBe()===`apple`}var zBe={other:{alt:`Alt`,meta:`Ctrl`,ctrl:`Ctrl`,shift:`⇧`,option:`Alt`,enter:`⏎`},apple:{alt:`⌥`,meta:`⌘`,ctrl:`Ctrl`,shift:`⇧`,option:`⌥`,enter:`⏎`}},BBe=e=>{if(!(e instanceof HTMLElement))return!1;if(e instanceof HTMLTextAreaElement)return!e.disabled&&!e.readOnly;if(e instanceof HTMLInputElement)return[`button`,`checkbox`,`color`,`file`,`hidden`,`image`,`radio`,`range`,`reset`,`submit`].includes(e.type.toLowerCase())?!1:!e.disabled&&!e.readOnly;if(e instanceof HTMLSelectElement)return!e.disabled;if(e.isContentEditable)return!0;let t=e.getAttribute(`role`)??``;return!![`textbox`,`searchbox`,`combobox`,`spinbutton`].includes(t)},VBe=(e,t)=>{if(!e||!t)return!1;let n=e.toLowerCase(),r=t.toLowerCase();if(/^[a-z]$/.test(n))return r===`key${n}`;if(/^[0-9]$/.test(n))return r===`digit${n}`||r===`numpad${n}`;let i={enter:[`enter`,`numpadenter`],escape:[`escape`],space:[`space`],tab:[`tab`],backspace:[`backspace`],delete:[`delete`],arrowup:[`arrowup`],arrowdown:[`arrowdown`],arrowleft:[`arrowleft`],arrowright:[`arrowright`],home:[`home`],end:[`end`],pageup:[`pageup`],pagedown:[`pagedown`],"/":[`slash`],"\\":[`backslash`],"[":[`bracketleft`],"]":[`bracketright`],";":[`semicolon`],"'":[`quote`],",":[`comma`],".":[`period`],"-":[`minus`],"=":[`equal`],"`":[`backquote`]};return/^f([1-9]|1[0-2])$/.test(n)?r===n:i[n]?i[n].includes(r):r===n},QR=e=>{let t=e.toLowerCase().trim().split(`+`).filter(Boolean),n=zBe[ZR()?`apple`:`other`];return t.map(e=>n[e]??e.toUpperCase()).join(``)},$R=(e,t,n)=>{if(!e||typeof e!=`string`||e.trim()===``)throw Error(`Invalid hotkey: must be a non-empty string`);let r=e.toLowerCase().trim().split(`+`).filter(Boolean);if(r.length===0)throw Error(`Invalid hotkey: no valid keys found`);let i=r.includes(`shift`),a=r.includes(`option`)||r.includes(`alt`),o=r.includes(`meta`),s=o&&ZR(),c=r.includes(`ctrl`)||o&&!ZR(),l=r[r.length-1],u=XR(t),d=n?.allowRepeat??!1,f=n?.enabled??!0;return(0,H.useEffect)(()=>{if(!f)return;let e=e=>{if(!d&&e.repeat||e.isComposing)return;let t=VBe(l,e.code),n=s||c||a||i;if(t&&e.metaKey===s&&e.shiftKey===i&&e.altKey===a&&e.ctrlKey===c){if(l===`tab`&&!n||BBe(e.target)&&!n)return;e.preventDefault(),u.current()}};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}},[l,s,i,a,c,u,d,f]),{trigger:()=>u.current(),label:QR(e)}},ez=({onPress:e,hotkey:t})=>{let{label:n}=$R(t,e);return n.split(``).map(e=>(0,U.jsx)(`kbd`,{className:`font-[system-ui] text-xs`,children:e},e))},tz=YR(`div`,`ml-1.5 inline-flex gap-px text-sm border bg-white/10 px-1 py-px rounded-sm border-border/30`),HBe=e=>{if(!e)return;let t=e.match(/error code:\s*(\d{3,4})/i);return t?Number(t[1]):void 0},UBe=(e,t)=>{let n=t.toLowerCase();return Object.entries(e).find(([e])=>e.toLowerCase()===n)?.[1]},WBe=e=>{if(e)try{return new URL(e).host}catch{return}},nz,rz=`HoverCard`,[iz,GBe]=V(rz,[nt]),az=nt(),[KBe,oz]=iz(rz),sz=e=>{let{__scopeHoverCard:t,children:n,open:r,defaultOpen:i,onOpenChange:a,openDelay:o=700,closeDelay:s=300}=e,c=az(t),l=H.useRef(0),u=H.useRef(0),d=H.useRef(!1),f=H.useRef(!1),[p,m]=yt({prop:r,defaultProp:i??!1,onChange:a,caller:rz}),h=H.useCallback(()=>{clearTimeout(u.current),l.current=window.setTimeout(()=>m(!0),o)},[o,m]),g=H.useCallback(()=>{clearTimeout(l.current),!d.current&&!f.current&&(u.current=window.setTimeout(()=>m(!1),s))},[s,m]),_=H.useCallback(()=>m(!1),[m]);return H.useEffect(()=>()=>{clearTimeout(l.current),clearTimeout(u.current)},[]),(0,U.jsx)(KBe,{scope:t,open:p,onOpenChange:m,onOpen:h,onClose:g,onDismiss:_,hasSelectionRef:d,isPointerDownOnContentRef:f,children:(0,U.jsx)(en,{...c,children:n})})};sz.displayName=rz;var cz=`HoverCardTrigger`,lz=H.forwardRef((e,t)=>{let{__scopeHoverCard:n,...r}=e,i=oz(cz,n),a=az(n);return(0,U.jsx)(Kt,{asChild:!0,...a,children:(0,U.jsx)(cn.a,{"data-state":i.open?`open`:`closed`,...r,ref:t,onPointerEnter:d(e.onPointerEnter,mz(i.onOpen)),onPointerLeave:d(e.onPointerLeave,mz(i.onClose)),onFocus:d(e.onFocus,i.onOpen),onBlur:d(e.onBlur,i.onClose),onTouchStart:d(e.onTouchStart,e=>e.preventDefault())})})});lz.displayName=cz;var uz=`HoverCardPortal`,[qBe,JBe]=iz(uz,{forceMount:void 0}),dz=e=>{let{__scopeHoverCard:t,forceMount:n,children:r,container:i}=e,a=oz(uz,t);return(0,U.jsx)(qBe,{scope:t,forceMount:n,children:(0,U.jsx)(Ce,{present:n||a.open,children:(0,U.jsx)(_,{asChild:!0,container:i,children:r})})})};dz.displayName=uz;var fz=`HoverCardContent`,pz=H.forwardRef((e,t)=>{let n=JBe(fz,e.__scopeHoverCard),{forceMount:r=n.forceMount,...i}=e,a=oz(fz,e.__scopeHoverCard);return(0,U.jsx)(Ce,{present:r||a.open,children:(0,U.jsx)(YBe,{"data-state":a.open?`open`:`closed`,...i,onPointerEnter:d(e.onPointerEnter,mz(a.onOpen)),onPointerLeave:d(e.onPointerLeave,mz(a.onClose)),ref:t})})});pz.displayName=fz;var YBe=H.forwardRef((e,t)=>{let{__scopeHoverCard:n,onEscapeKeyDown:r,onPointerDownOutside:i,onFocusOutside:a,onInteractOutside:o,...s}=e,c=oz(fz,n),l=az(n),u=H.useRef(null),f=p(t,u),[m,h]=H.useState(!1);return H.useEffect(()=>{if(m){let e=document.body;return nz=e.style.userSelect||e.style.webkitUserSelect,e.style.userSelect=`none`,e.style.webkitUserSelect=`none`,()=>{e.style.userSelect=nz,e.style.webkitUserSelect=nz}}},[m]),H.useEffect(()=>{if(u.current){let e=()=>{h(!1),c.isPointerDownOnContentRef.current=!1,setTimeout(()=>{document.getSelection()?.toString()!==``&&(c.hasSelectionRef.current=!0)})};return document.addEventListener(`pointerup`,e),()=>{document.removeEventListener(`pointerup`,e),c.hasSelectionRef.current=!1,c.isPointerDownOnContentRef.current=!1}}},[c.isPointerDownOnContentRef,c.hasSelectionRef]),H.useEffect(()=>{u.current&&QBe(u.current).forEach(e=>e.setAttribute(`tabindex`,`-1`))}),(0,U.jsx)(T,{asChild:!0,disableOutsidePointerEvents:!1,onInteractOutside:o,onEscapeKeyDown:r,onPointerDownOutside:i,onFocusOutside:d(a,e=>{e.preventDefault()}),onDismiss:c.onDismiss,children:(0,U.jsx)(wt,{...l,...s,onPointerDown:d(s.onPointerDown,e=>{e.currentTarget.contains(e.target)&&h(!0),c.hasSelectionRef.current=!1,c.isPointerDownOnContentRef.current=!0}),ref:f,style:{...s.style,userSelect:m?`text`:void 0,WebkitUserSelect:m?`text`:void 0,"--radix-hover-card-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-hover-card-content-available-width":`var(--radix-popper-available-width)`,"--radix-hover-card-content-available-height":`var(--radix-popper-available-height)`,"--radix-hover-card-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-hover-card-trigger-height":`var(--radix-popper-anchor-height)`}})})}),XBe=`HoverCardArrow`,ZBe=H.forwardRef((e,t)=>{let{__scopeHoverCard:n,...r}=e,i=az(n);return(0,U.jsx)($e,{...i,...r,ref:t})});ZBe.displayName=XBe;function mz(e){return t=>t.pointerType===`touch`?void 0:e()}function QBe(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});for(;n.nextNode();)t.push(n.currentNode);return t}var $Be=sz,eVe=lz,tVe=dz,nVe=pz;function hz({...e}){return(0,U.jsx)($Be,{"data-slot":`hover-card`,...e})}function gz({...e}){return(0,U.jsx)(eVe,{"data-slot":`hover-card-trigger`,...e})}function _z({className:e,align:t=`center`,sideOffset:n=4,...r}){return(0,U.jsx)(tVe,{"data-slot":`hover-card-portal`,children:(0,U.jsx)(nVe,{"data-slot":`hover-card-content`,align:t,sideOffset:n,className:W(`bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-64 origin-(--radix-hover-card-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden`,e),...r})})}var vz=a(((e,t)=>{t.exports=Array.isArray})),yz=a(((e,t)=>{t.exports=typeof global==`object`&&global&&global.Object===Object&&global})),bz=a(((e,t)=>{var n=yz(),r=typeof self==`object`&&self&&self.Object===Object&&self;t.exports=n||r||Function(`return this`)()})),xz=a(((e,t)=>{t.exports=bz().Symbol})),rVe=a(((e,t)=>{var n=xz(),r=Object.prototype,i=r.hasOwnProperty,a=r.toString,o=n?n.toStringTag:void 0;function s(e){var t=i.call(e,o),n=e[o];try{e[o]=void 0;var r=!0}catch{}var s=a.call(e);return r&&(t?e[o]=n:delete e[o]),s}t.exports=s})),iVe=a(((e,t)=>{var n=Object.prototype.toString;function r(e){return n.call(e)}t.exports=r})),Sz=a(((e,t)=>{var n=xz(),r=rVe(),i=iVe(),a=`[object Null]`,o=`[object Undefined]`,s=n?n.toStringTag:void 0;function c(e){return e==null?e===void 0?o:a:s&&s in Object(e)?r(e):i(e)}t.exports=c})),Cz=a(((e,t)=>{function n(e){return typeof e==`object`&&!!e}t.exports=n})),wz=a(((e,t)=>{var n=Sz(),r=Cz(),i=`[object Symbol]`;function a(e){return typeof e==`symbol`||r(e)&&n(e)==i}t.exports=a})),Tz=a(((e,t)=>{var n=vz(),r=wz(),i=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,a=/^\w*$/;function o(e,t){if(n(e))return!1;var o=typeof e;return o==`number`||o==`symbol`||o==`boolean`||e==null||r(e)?!0:a.test(e)||!i.test(e)||t!=null&&e in Object(t)}t.exports=o})),Ez=a(((e,t)=>{function n(e){var t=typeof e;return e!=null&&(t==`object`||t==`function`)}t.exports=n})),Dz=a(((e,t)=>{var n=Sz(),r=Ez(),i=`[object AsyncFunction]`,a=`[object Function]`,o=`[object GeneratorFunction]`,s=`[object Proxy]`;function c(e){if(!r(e))return!1;var t=n(e);return t==a||t==o||t==i||t==s}t.exports=c})),aVe=a(((e,t)=>{t.exports=bz()[`__core-js_shared__`]})),oVe=a(((e,t)=>{var n=aVe(),r=function(){var e=/[^.]+$/.exec(n&&n.keys&&n.keys.IE_PROTO||``);return e?`Symbol(src)_1.`+e:``}();function i(e){return!!r&&r in e}t.exports=i})),Oz=a(((e,t)=>{var n=Function.prototype.toString;function r(e){if(e!=null){try{return n.call(e)}catch{}try{return e+``}catch{}}return``}t.exports=r})),sVe=a(((e,t)=>{var n=Dz(),r=oVe(),i=Ez(),a=Oz(),o=/[\\^$.*+?()[\]{}|]/g,s=/^\[object .+?Constructor\]$/,c=Function.prototype,l=Object.prototype,u=c.toString,d=l.hasOwnProperty,f=RegExp(`^`+u.call(d).replace(o,`\\$&`).replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,`$1.*?`)+`$`);function p(e){return!i(e)||r(e)?!1:(n(e)?f:s).test(a(e))}t.exports=p})),cVe=a(((e,t)=>{function n(e,t){return e?.[t]}t.exports=n})),kz=a(((e,t)=>{var n=sVe(),r=cVe();function i(e,t){var i=r(e,t);return n(i)?i:void 0}t.exports=i})),Az=a(((e,t)=>{t.exports=kz()(Object,`create`)})),lVe=a(((e,t)=>{var n=Az();function r(){this.__data__=n?n(null):{},this.size=0}t.exports=r})),uVe=a(((e,t)=>{function n(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}t.exports=n})),dVe=a(((e,t)=>{var n=Az(),r=`__lodash_hash_undefined__`,i=Object.prototype.hasOwnProperty;function a(e){var t=this.__data__;if(n){var a=t[e];return a===r?void 0:a}return i.call(t,e)?t[e]:void 0}t.exports=a})),fVe=a(((e,t)=>{var n=Az(),r=Object.prototype.hasOwnProperty;function i(e){var t=this.__data__;return n?t[e]!==void 0:r.call(t,e)}t.exports=i})),pVe=a(((e,t)=>{var n=Az(),r=`__lodash_hash_undefined__`;function i(e,t){var i=this.__data__;return this.size+=this.has(e)?0:1,i[e]=n&&t===void 0?r:t,this}t.exports=i})),mVe=a(((e,t)=>{var n=lVe(),r=uVe(),i=dVe(),a=fVe(),o=pVe();function s(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}s.prototype.clear=n,s.prototype.delete=r,s.prototype.get=i,s.prototype.has=a,s.prototype.set=o,t.exports=s})),hVe=a(((e,t)=>{function n(){this.__data__=[],this.size=0}t.exports=n})),jz=a(((e,t)=>{function n(e,t){return e===t||e!==e&&t!==t}t.exports=n})),Mz=a(((e,t)=>{var n=jz();function r(e,t){for(var r=e.length;r--;)if(n(e[r][0],t))return r;return-1}t.exports=r})),gVe=a(((e,t)=>{var n=Mz(),r=Array.prototype.splice;function i(e){var t=this.__data__,i=n(t,e);return i<0?!1:(i==t.length-1?t.pop():r.call(t,i,1),--this.size,!0)}t.exports=i})),_Ve=a(((e,t)=>{var n=Mz();function r(e){var t=this.__data__,r=n(t,e);return r<0?void 0:t[r][1]}t.exports=r})),vVe=a(((e,t)=>{var n=Mz();function r(e){return n(this.__data__,e)>-1}t.exports=r})),yVe=a(((e,t)=>{var n=Mz();function r(e,t){var r=this.__data__,i=n(r,e);return i<0?(++this.size,r.push([e,t])):r[i][1]=t,this}t.exports=r})),Nz=a(((e,t)=>{var n=hVe(),r=gVe(),i=_Ve(),a=vVe(),o=yVe();function s(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}s.prototype.clear=n,s.prototype.delete=r,s.prototype.get=i,s.prototype.has=a,s.prototype.set=o,t.exports=s})),Pz=a(((e,t)=>{t.exports=kz()(bz(),`Map`)})),bVe=a(((e,t)=>{var n=mVe(),r=Nz(),i=Pz();function a(){this.size=0,this.__data__={hash:new n,map:new(i||r),string:new n}}t.exports=a})),xVe=a(((e,t)=>{function n(e){var t=typeof e;return t==`string`||t==`number`||t==`symbol`||t==`boolean`?e!==`__proto__`:e===null}t.exports=n})),Fz=a(((e,t)=>{var n=xVe();function r(e,t){var r=e.__data__;return n(t)?r[typeof t==`string`?`string`:`hash`]:r.map}t.exports=r})),SVe=a(((e,t)=>{var n=Fz();function r(e){var t=n(this,e).delete(e);return this.size-=t?1:0,t}t.exports=r})),CVe=a(((e,t)=>{var n=Fz();function r(e){return n(this,e).get(e)}t.exports=r})),wVe=a(((e,t)=>{var n=Fz();function r(e){return n(this,e).has(e)}t.exports=r})),TVe=a(((e,t)=>{var n=Fz();function r(e,t){var r=n(this,e),i=r.size;return r.set(e,t),this.size+=r.size==i?0:1,this}t.exports=r})),Iz=a(((e,t)=>{var n=bVe(),r=SVe(),i=CVe(),a=wVe(),o=TVe();function s(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}s.prototype.clear=n,s.prototype.delete=r,s.prototype.get=i,s.prototype.has=a,s.prototype.set=o,t.exports=s})),Lz=a(((e,t)=>{var n=Iz(),r=`Expected a function`;function i(e,t){if(typeof e!=`function`||t!=null&&typeof t!=`function`)throw TypeError(r);var a=function(){var n=arguments,r=t?t.apply(this,n):n[0],i=a.cache;if(i.has(r))return i.get(r);var o=e.apply(this,n);return a.cache=i.set(r,o)||i,o};return a.cache=new(i.Cache||n),a}i.Cache=n,t.exports=i})),EVe=a(((e,t)=>{var n=Lz(),r=500;function i(e){var t=n(e,function(e){return i.size===r&&i.clear(),e}),i=t.cache;return t}t.exports=i})),DVe=a(((e,t)=>{var n=EVe(),r=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,i=/\\(\\)?/g;t.exports=n(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(``),e.replace(r,function(e,n,r,a){t.push(r?a.replace(i,`$1`):n||e)}),t})})),Rz=a(((e,t)=>{function n(e,t){for(var n=-1,r=e==null?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i}t.exports=n})),OVe=a(((e,t)=>{var n=xz(),r=Rz(),i=vz(),a=wz(),o=1/0,s=n?n.prototype:void 0,c=s?s.toString:void 0;function l(e){if(typeof e==`string`)return e;if(i(e))return r(e,l)+``;if(a(e))return c?c.call(e):``;var t=e+``;return t==`0`&&1/e==-o?`-0`:t}t.exports=l})),zz=a(((e,t)=>{var n=OVe();function r(e){return e==null?``:n(e)}t.exports=r})),Bz=a(((e,t)=>{var n=vz(),r=Tz(),i=DVe(),a=zz();function o(e,t){return n(e)?e:r(e,t)?[e]:i(a(e))}t.exports=o})),Vz=a(((e,t)=>{var n=wz(),r=1/0;function i(e){if(typeof e==`string`||n(e))return e;var t=e+``;return t==`0`&&1/e==-r?`-0`:t}t.exports=i})),Hz=a(((e,t)=>{var n=Bz(),r=Vz();function i(e,t){t=n(t,e);for(var i=0,a=t.length;e!=null&&i<a;)e=e[r(t[i++])];return i&&i==a?e:void 0}t.exports=i})),Uz=a(((e,t)=>{var n=Hz();function r(e,t,r){var i=e==null?void 0:n(e,t);return i===void 0?r:i}t.exports=r})),kVe=a(((e,t)=>{function n(e){return e==null}t.exports=n})),AVe=a(((e,t)=>{var n=Sz(),r=vz(),i=Cz(),a=`[object String]`;function o(e){return typeof e==`string`||!r(e)&&i(e)&&n(e)==a}t.exports=o})),jVe=a((e=>{var t=Symbol.for(`react.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.provider`),s=Symbol.for(`react.context`),c=Symbol.for(`react.server_context`),l=Symbol.for(`react.forward_ref`),u=Symbol.for(`react.suspense`),d=Symbol.for(`react.suspense_list`),f=Symbol.for(`react.memo`),p=Symbol.for(`react.lazy`);function m(e){if(typeof e==`object`&&e){var m=e.$$typeof;switch(m){case t:switch(e=e.type,e){case r:case a:case i:case u:case d:return e;default:switch(e&&=e.$$typeof,e){case c:case s:case l:case p:case f:case o:return e;default:return m}}case n:return m}}}e.isFragment=function(e){return m(e)===r}})),MVe=a(((e,t)=>{t.exports=jVe()})),Wz=a(((e,t)=>{var n=Sz(),r=Cz(),i=`[object Number]`;function a(e){return typeof e==`number`||r(e)&&n(e)==i}t.exports=a})),NVe=a(((e,t)=>{var n=Wz();function r(e){return n(e)&&e!=+e}t.exports=r})),Gz=r(AVe()),Kz=r(NVe()),qz=r(Uz()),PVe=r(Wz()),Jz=function(e){return e===0?0:e>0?1:-1},Yz=function(e){return(0,Gz.default)(e)&&e.indexOf(`%`)===e.length-1},Xz=function(e){return(0,PVe.default)(e)&&!(0,Kz.default)(e)},Zz=function(e){return Xz(e)||(0,Gz.default)(e)},FVe=0,Qz=function(e){var t=++FVe;return`${e||``}${t}`},$z=function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(!Xz(e)&&!(0,Gz.default)(e))return n;var i;if(Yz(e)){var a=e.indexOf(`%`);i=t*parseFloat(e.slice(0,a))/100}else i=+e;return(0,Kz.default)(i)&&(i=n),r&&i>t&&(i=t),i},eB=function(e){if(!e)return null;var t=Object.keys(e);return t&&t.length?e[t[0]]:null},IVe=function(e){if(!Array.isArray(e))return!1;for(var t=e.length,n={},r=0;r<t;r++)if(!n[e[r]])n[e[r]]=!0;else return!0;return!1},tB=function(e,t){return Xz(e)&&Xz(t)?function(n){return e+n*(t-e)}:function(){return t}};function nB(e,t,n){return!e||!e.length?null:e.find(function(e){return e&&(typeof t==`function`?t(e):(0,qz.default)(e,t))===n})}function rB(e,t){for(var n in e)if({}.hasOwnProperty.call(e,n)&&(!{}.hasOwnProperty.call(t,n)||e[n]!==t[n]))return!1;for(var r in t)if({}.hasOwnProperty.call(t,r)&&!{}.hasOwnProperty.call(e,r))return!1;return!0}var iB=r(Ez());function aB(e){"@babel/helpers - typeof";return aB=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},aB(e)}var LVe=[`viewBox`,`children`],RVe=`aria-activedescendant.aria-atomic.aria-autocomplete.aria-busy.aria-checked.aria-colcount.aria-colindex.aria-colspan.aria-controls.aria-current.aria-describedby.aria-details.aria-disabled.aria-errormessage.aria-expanded.aria-flowto.aria-haspopup.aria-hidden.aria-invalid.aria-keyshortcuts.aria-label.aria-labelledby.aria-level.aria-live.aria-modal.aria-multiline.aria-multiselectable.aria-orientation.aria-owns.aria-placeholder.aria-posinset.aria-pressed.aria-readonly.aria-relevant.aria-required.aria-roledescription.aria-rowcount.aria-rowindex.aria-rowspan.aria-selected.aria-setsize.aria-sort.aria-valuemax.aria-valuemin.aria-valuenow.aria-valuetext.className.color.height.id.lang.max.media.method.min.name.style.target.width.role.tabIndex.accentHeight.accumulate.additive.alignmentBaseline.allowReorder.alphabetic.amplitude.arabicForm.ascent.attributeName.attributeType.autoReverse.azimuth.baseFrequency.baselineShift.baseProfile.bbox.begin.bias.by.calcMode.capHeight.clip.clipPath.clipPathUnits.clipRule.colorInterpolation.colorInterpolationFilters.colorProfile.colorRendering.contentScriptType.contentStyleType.cursor.cx.cy.d.decelerate.descent.diffuseConstant.direction.display.divisor.dominantBaseline.dur.dx.dy.edgeMode.elevation.enableBackground.end.exponent.externalResourcesRequired.fill.fillOpacity.fillRule.filter.filterRes.filterUnits.floodColor.floodOpacity.focusable.fontFamily.fontSize.fontSizeAdjust.fontStretch.fontStyle.fontVariant.fontWeight.format.from.fx.fy.g1.g2.glyphName.glyphOrientationHorizontal.glyphOrientationVertical.glyphRef.gradientTransform.gradientUnits.hanging.horizAdvX.horizOriginX.href.ideographic.imageRendering.in2.in.intercept.k1.k2.k3.k4.k.kernelMatrix.kernelUnitLength.kerning.keyPoints.keySplines.keyTimes.lengthAdjust.letterSpacing.lightingColor.limitingConeAngle.local.markerEnd.markerHeight.markerMid.markerStart.markerUnits.markerWidth.mask.maskContentUnits.maskUnits.mathematical.mode.numOctaves.offset.opacity.operator.order.orient.orientation.origin.overflow.overlinePosition.overlineThickness.paintOrder.panose1.pathLength.patternContentUnits.patternTransform.patternUnits.pointerEvents.pointsAtX.pointsAtY.pointsAtZ.preserveAlpha.preserveAspectRatio.primitiveUnits.r.radius.refX.refY.renderingIntent.repeatCount.repeatDur.requiredExtensions.requiredFeatures.restart.result.rotate.rx.ry.seed.shapeRendering.slope.spacing.specularConstant.specularExponent.speed.spreadMethod.startOffset.stdDeviation.stemh.stemv.stitchTiles.stopColor.stopOpacity.strikethroughPosition.strikethroughThickness.string.stroke.strokeDasharray.strokeDashoffset.strokeLinecap.strokeLinejoin.strokeMiterlimit.strokeOpacity.strokeWidth.surfaceScale.systemLanguage.tableValues.targetX.targetY.textAnchor.textDecoration.textLength.textRendering.to.transform.u1.u2.underlinePosition.underlineThickness.unicode.unicodeBidi.unicodeRange.unitsPerEm.vAlphabetic.values.vectorEffect.version.vertAdvY.vertOriginX.vertOriginY.vHanging.vIdeographic.viewTarget.visibility.vMathematical.widths.wordSpacing.writingMode.x1.x2.x.xChannelSelector.xHeight.xlinkActuate.xlinkArcrole.xlinkHref.xlinkRole.xlinkShow.xlinkTitle.xlinkType.xmlBase.xmlLang.xmlns.xmlnsXlink.xmlSpace.y1.y2.y.yChannelSelector.z.zoomAndPan.ref.key.angle`.split(`.`),oB=[`points`,`pathLength`],zVe={svg:LVe,polygon:oB,polyline:oB},sB=`dangerouslySetInnerHTML.onCopy.onCopyCapture.onCut.onCutCapture.onPaste.onPasteCapture.onCompositionEnd.onCompositionEndCapture.onCompositionStart.onCompositionStartCapture.onCompositionUpdate.onCompositionUpdateCapture.onFocus.onFocusCapture.onBlur.onBlurCapture.onChange.onChangeCapture.onBeforeInput.onBeforeInputCapture.onInput.onInputCapture.onReset.onResetCapture.onSubmit.onSubmitCapture.onInvalid.onInvalidCapture.onLoad.onLoadCapture.onError.onErrorCapture.onKeyDown.onKeyDownCapture.onKeyPress.onKeyPressCapture.onKeyUp.onKeyUpCapture.onAbort.onAbortCapture.onCanPlay.onCanPlayCapture.onCanPlayThrough.onCanPlayThroughCapture.onDurationChange.onDurationChangeCapture.onEmptied.onEmptiedCapture.onEncrypted.onEncryptedCapture.onEnded.onEndedCapture.onLoadedData.onLoadedDataCapture.onLoadedMetadata.onLoadedMetadataCapture.onLoadStart.onLoadStartCapture.onPause.onPauseCapture.onPlay.onPlayCapture.onPlaying.onPlayingCapture.onProgress.onProgressCapture.onRateChange.onRateChangeCapture.onSeeked.onSeekedCapture.onSeeking.onSeekingCapture.onStalled.onStalledCapture.onSuspend.onSuspendCapture.onTimeUpdate.onTimeUpdateCapture.onVolumeChange.onVolumeChangeCapture.onWaiting.onWaitingCapture.onAuxClick.onAuxClickCapture.onClick.onClickCapture.onContextMenu.onContextMenuCapture.onDoubleClick.onDoubleClickCapture.onDrag.onDragCapture.onDragEnd.onDragEndCapture.onDragEnter.onDragEnterCapture.onDragExit.onDragExitCapture.onDragLeave.onDragLeaveCapture.onDragOver.onDragOverCapture.onDragStart.onDragStartCapture.onDrop.onDropCapture.onMouseDown.onMouseDownCapture.onMouseEnter.onMouseLeave.onMouseMove.onMouseMoveCapture.onMouseOut.onMouseOutCapture.onMouseOver.onMouseOverCapture.onMouseUp.onMouseUpCapture.onSelect.onSelectCapture.onTouchCancel.onTouchCancelCapture.onTouchEnd.onTouchEndCapture.onTouchMove.onTouchMoveCapture.onTouchStart.onTouchStartCapture.onPointerDown.onPointerDownCapture.onPointerMove.onPointerMoveCapture.onPointerUp.onPointerUpCapture.onPointerCancel.onPointerCancelCapture.onPointerEnter.onPointerEnterCapture.onPointerLeave.onPointerLeaveCapture.onPointerOver.onPointerOverCapture.onPointerOut.onPointerOutCapture.onGotPointerCapture.onGotPointerCaptureCapture.onLostPointerCapture.onLostPointerCaptureCapture.onScroll.onScrollCapture.onWheel.onWheelCapture.onAnimationStart.onAnimationStartCapture.onAnimationEnd.onAnimationEndCapture.onAnimationIteration.onAnimationIterationCapture.onTransitionEnd.onTransitionEndCapture`.split(`.`),cB=function(e,t){if(!e||typeof e==`function`||typeof e==`boolean`)return null;var n=e;if((0,H.isValidElement)(e)&&(n=e.props),!(0,iB.default)(n))return null;var r={};return Object.keys(n).forEach(function(e){sB.includes(e)&&(r[e]=t||function(t){return n[e](n,t)})}),r},BVe=function(e,t,n){return function(r){return e(t,n,r),null}},lB=function(e,t,n){if(!(0,iB.default)(e)||aB(e)!==`object`)return null;var r=null;return Object.keys(e).forEach(function(i){var a=e[i];sB.includes(i)&&typeof a==`function`&&(r||={},r[i]=BVe(a,t,n))}),r},uB=r(kVe()),dB=r(Dz()),VVe=MVe(),HVe=[`children`],UVe=[`children`];function fB(e,t){if(e==null)return{};var n=WVe(e,t),r,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++)r=a[i],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function WVe(e,t){if(e==null)return{};var n={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}var pB={click:`onClick`,mousedown:`onMouseDown`,mouseup:`onMouseUp`,mouseover:`onMouseOver`,mousemove:`onMouseMove`,mouseout:`onMouseOut`,mouseenter:`onMouseEnter`,mouseleave:`onMouseLeave`,touchcancel:`onTouchCancel`,touchend:`onTouchEnd`,touchmove:`onTouchMove`,touchstart:`onTouchStart`,contextmenu:`onContextMenu`,dblclick:`onDoubleClick`},mB=function(e){return typeof e==`string`?e:e?e.displayName||e.name||`Component`:``},hB=null,gB=null,_B=function e(t){if(t===hB&&Array.isArray(gB))return gB;var n=[];return H.Children.forEach(t,function(t){(0,uB.default)(t)||((0,VVe.isFragment)(t)?n=n.concat(e(t.props.children)):n.push(t))}),gB=n,hB=t,n};function vB(e,t){var n=[],r=[];return r=Array.isArray(t)?t.map(function(e){return mB(e)}):[mB(t)],_B(e).forEach(function(e){var t=(0,qz.default)(e,`type.displayName`)||(0,qz.default)(e,`type.name`);r.indexOf(t)!==-1&&n.push(e)}),n}function yB(e,t){var n=vB(e,t);return n&&n[0]}var bB=function(e){if(!e||!e.props)return!1;var t=e.props,n=t.width,r=t.height;return!(!Xz(n)||n<=0||!Xz(r)||r<=0)},GVe=`a.altGlyph.altGlyphDef.altGlyphItem.animate.animateColor.animateMotion.animateTransform.circle.clipPath.color-profile.cursor.defs.desc.ellipse.feBlend.feColormatrix.feComponentTransfer.feComposite.feConvolveMatrix.feDiffuseLighting.feDisplacementMap.feDistantLight.feFlood.feFuncA.feFuncB.feFuncG.feFuncR.feGaussianBlur.feImage.feMerge.feMergeNode.feMorphology.feOffset.fePointLight.feSpecularLighting.feSpotLight.feTile.feTurbulence.filter.font.font-face.font-face-format.font-face-name.font-face-url.foreignObject.g.glyph.glyphRef.hkern.image.line.lineGradient.marker.mask.metadata.missing-glyph.mpath.path.pattern.polygon.polyline.radialGradient.rect.script.set.stop.style.svg.switch.symbol.text.textPath.title.tref.tspan.use.view.vkern`.split(`.`),KVe=function(e){return e&&e.type&&(0,Gz.default)(e.type)&&GVe.indexOf(e.type)>=0},qVe=function(e,t,n,r){var i=zVe?.[r]??[];return t.startsWith(`data-`)||!(0,dB.default)(e)&&(r&&i.includes(t)||RVe.includes(t))||n&&sB.includes(t)},xB=function(e,t,n){if(!e||typeof e==`function`||typeof e==`boolean`)return null;var r=e;if((0,H.isValidElement)(e)&&(r=e.props),!(0,iB.default)(r))return null;var i={};return Object.keys(r).forEach(function(e){qVe(r?.[e],e,t,n)&&(i[e]=r[e])}),i},SB=function e(t,n){if(t===n)return!0;var r=H.Children.count(t);if(r!==H.Children.count(n))return!1;if(r===0)return!0;if(r===1)return CB(Array.isArray(t)?t[0]:t,Array.isArray(n)?n[0]:n);for(var i=0;i<r;i++){var a=t[i],o=n[i];if(Array.isArray(a)||Array.isArray(o)){if(!e(a,o))return!1}else if(!CB(a,o))return!1}return!0},CB=function(e,t){if((0,uB.default)(e)&&(0,uB.default)(t))return!0;if(!(0,uB.default)(e)&&!(0,uB.default)(t)){var n=e.props||{},r=n.children,i=fB(n,HVe),a=t.props||{},o=a.children,s=fB(a,UVe);return r&&o?rB(i,s)&&SB(r,o):!r&&!o?rB(i,s):!1}return!1},wB=function(e,t){var n=[],r={};return _B(e).forEach(function(e,i){if(KVe(e))n.push(e);else if(e){var a=mB(e.type),o=t[a]||{},s=o.handler,c=o.once;if(s&&(!c||!r[a])){var l=s(e,a,i);n.push(l),r[a]=!0}}}),n},JVe=function(e){var t=e&&e.type;return t&&pB[t]?pB[t]:null},YVe=function(e,t){return _B(t).indexOf(e)},XVe=[`children`,`width`,`height`,`viewBox`,`className`,`style`,`title`,`desc`];function TB(){return TB=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},TB.apply(this,arguments)}function ZVe(e,t){if(e==null)return{};var n=QVe(e,t),r,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++)r=a[i],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function QVe(e,t){if(e==null)return{};var n={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}function EB(e){var t=e.children,n=e.width,r=e.height,i=e.viewBox,a=e.className,o=e.style,s=e.title,c=e.desc,l=ZVe(e,XVe),u=i||{width:n,height:r,x:0,y:0},d=xl(`recharts-surface`,a);return H.createElement(`svg`,TB({},xB(l,!0,`svg`),{className:d,width:n,height:r,style:o,viewBox:`${u.x} ${u.y} ${u.width} ${u.height}`}),H.createElement(`title`,null,s),H.createElement(`desc`,null,c),t)}var $Ve=[`children`,`className`];function DB(){return DB=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},DB.apply(this,arguments)}function eHe(e,t){if(e==null)return{};var n=tHe(e,t),r,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++)r=a[i],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function tHe(e,t){if(e==null)return{};var n={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}var OB=H.forwardRef(function(e,t){var n=e.children,r=e.className,i=eHe(e,$Ve),a=xl(`recharts-layer`,r);return H.createElement(`g`,DB({className:a},xB(i,!0),{ref:t}),n)}),nHe=!1,kB=function(e,t){var n=[...arguments].slice(2);if(nHe&&typeof console<`u`&&console.warn&&(t===void 0&&console.warn(`LogUtils requires an error message argument`),!e))if(t===void 0)console.warn(`Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.`);else{var r=0;console.warn(t.replace(/%s/g,function(){return n[r++]}))}},rHe=a(((e,t)=>{function n(e,t,n){var r=-1,i=e.length;t<0&&(t=-t>i?0:i+t),n=n>i?i:n,n<0&&(n+=i),i=t>n?0:n-t>>>0,t>>>=0;for(var a=Array(i);++r<i;)a[r]=e[r+t];return a}t.exports=n})),iHe=a(((e,t)=>{var n=rHe();function r(e,t,r){var i=e.length;return r=r===void 0?i:r,!t&&r>=i?e:n(e,t,r)}t.exports=r})),AB=a(((e,t)=>{var n=RegExp(`[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]`);function r(e){return n.test(e)}t.exports=r})),aHe=a(((e,t)=>{function n(e){return e.split(``)}t.exports=n})),oHe=a(((e,t)=>{var n=`\\ud800-\\udfff`,r=`\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff`,i=`\\ufe0e\\ufe0f`,a=`[`+n+`]`,o=`[`+r+`]`,s=`\\ud83c[\\udffb-\\udfff]`,c=`(?:`+o+`|`+s+`)`,l=`[^`+n+`]`,u=`(?:\\ud83c[\\udde6-\\uddff]){2}`,d=`[\\ud800-\\udbff][\\udc00-\\udfff]`,f=`\\u200d`,p=c+`?`,m=`[`+i+`]?`,h=`(?:`+f+`(?:`+[l,u,d].join(`|`)+`)`+m+p+`)*`,g=m+p+h,_=`(?:`+[l+o+`?`,o,u,d,a].join(`|`)+`)`,v=RegExp(s+`(?=`+s+`)|`+_+g,`g`);function y(e){return e.match(v)||[]}t.exports=y})),sHe=a(((e,t)=>{var n=aHe(),r=AB(),i=oHe();function a(e){return r(e)?i(e):n(e)}t.exports=a})),cHe=a(((e,t)=>{var n=iHe(),r=AB(),i=sHe(),a=zz();function o(e){return function(t){t=a(t);var o=r(t)?i(t):void 0,s=o?o[0]:t.charAt(0),c=o?n(o,1).join(``):t.slice(1);return s[e]()+c}}t.exports=o})),lHe=a(((e,t)=>{t.exports=cHe()(`toUpperCase`)}));function jB(e){return function(){return e}}var MB=Math.cos,NB=Math.sin,PB=Math.sqrt,FB=Math.PI;FB/2;var IB=2*FB,LB=Math.PI,RB=2*LB,zB=1e-6,uHe=RB-zB;function BB(e){this._+=e[0];for(let t=1,n=e.length;t<n;++t)this._+=arguments[t]+e[t]}function dHe(e){let t=Math.floor(e);if(!(t>=0))throw Error(`invalid digits: ${e}`);if(t>15)return BB;let n=10**t;return function(e){this._+=e[0];for(let t=1,r=e.length;t<r;++t)this._+=Math.round(arguments[t]*n)/n+e[t]}}var VB=class{constructor(e){this._x0=this._y0=this._x1=this._y1=null,this._=``,this._append=e==null?BB:dHe(e)}moveTo(e,t){this._append`M${this._x0=this._x1=+e},${this._y0=this._y1=+t}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`)}lineTo(e,t){this._append`L${this._x1=+e},${this._y1=+t}`}quadraticCurveTo(e,t,n,r){this._append`Q${+e},${+t},${this._x1=+n},${this._y1=+r}`}bezierCurveTo(e,t,n,r,i,a){this._append`C${+e},${+t},${+n},${+r},${this._x1=+i},${this._y1=+a}`}arcTo(e,t,n,r,i){if(e=+e,t=+t,n=+n,r=+r,i=+i,i<0)throw Error(`negative radius: ${i}`);let a=this._x1,o=this._y1,s=n-e,c=r-t,l=a-e,u=o-t,d=l*l+u*u;if(this._x1===null)this._append`M${this._x1=e},${this._y1=t}`;else if(d>zB)if(!(Math.abs(u*s-c*l)>zB)||!i)this._append`L${this._x1=e},${this._y1=t}`;else{let f=n-a,p=r-o,m=s*s+c*c,h=f*f+p*p,g=Math.sqrt(m),_=Math.sqrt(d),v=i*Math.tan((LB-Math.acos((m+d-h)/(2*g*_)))/2),y=v/_,b=v/g;Math.abs(y-1)>zB&&this._append`L${e+y*l},${t+y*u}`,this._append`A${i},${i},0,0,${+(u*f>l*p)},${this._x1=e+b*s},${this._y1=t+b*c}`}}arc(e,t,n,r,i,a){if(e=+e,t=+t,n=+n,a=!!a,n<0)throw Error(`negative radius: ${n}`);let o=n*Math.cos(r),s=n*Math.sin(r),c=e+o,l=t+s,u=1^a,d=a?r-i:i-r;this._x1===null?this._append`M${c},${l}`:(Math.abs(this._x1-c)>zB||Math.abs(this._y1-l)>zB)&&this._append`L${c},${l}`,n&&(d<0&&(d=d%RB+RB),d>uHe?this._append`A${n},${n},0,1,${u},${e-o},${t-s}A${n},${n},0,1,${u},${this._x1=c},${this._y1=l}`:d>zB&&this._append`A${n},${n},0,${+(d>=LB)},${u},${this._x1=e+n*Math.cos(i)},${this._y1=t+n*Math.sin(i)}`)}rect(e,t,n,r){this._append`M${this._x0=this._x1=+e},${this._y0=this._y1=+t}h${n=+n}v${+r}h${-n}Z`}toString(){return this._}};function fHe(){return new VB}fHe.prototype=VB.prototype;function HB(e){let t=3;return e.digits=function(n){if(!arguments.length)return t;if(n==null)t=null;else{let e=Math.floor(n);if(!(e>=0))throw RangeError(`invalid digits: ${n}`);t=e}return e},()=>new VB(t)}Array.prototype.slice;function UB(e){return typeof e==`object`&&`length`in e?e:Array.from(e)}function WB(e){this._context=e}WB.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:this._context.lineTo(e,t);break}}};function GB(e){return new WB(e)}function KB(e){return e[0]}function qB(e){return e[1]}function JB(e,t){var n=jB(!0),r=null,i=GB,a=null,o=HB(s);e=typeof e==`function`?e:e===void 0?KB:jB(e),t=typeof t==`function`?t:t===void 0?qB:jB(t);function s(s){var c,l=(s=UB(s)).length,u,d=!1,f;for(r??(a=i(f=o())),c=0;c<=l;++c)!(c<l&&n(u=s[c],c,s))===d&&((d=!d)?a.lineStart():a.lineEnd()),d&&a.point(+e(u,c,s),+t(u,c,s));if(f)return a=null,f+``||null}return s.x=function(t){return arguments.length?(e=typeof t==`function`?t:jB(+t),s):e},s.y=function(e){return arguments.length?(t=typeof e==`function`?e:jB(+e),s):t},s.defined=function(e){return arguments.length?(n=typeof e==`function`?e:jB(!!e),s):n},s.curve=function(e){return arguments.length?(i=e,r!=null&&(a=i(r)),s):i},s.context=function(e){return arguments.length?(e==null?r=a=null:a=i(r=e),s):r},s}function YB(e,t,n){var r=null,i=jB(!0),a=null,o=GB,s=null,c=HB(l);e=typeof e==`function`?e:e===void 0?KB:jB(+e),t=typeof t==`function`?t:jB(t===void 0?0:+t),n=typeof n==`function`?n:n===void 0?qB:jB(+n);function l(l){var u,d,f,p=(l=UB(l)).length,m,h=!1,g,_=Array(p),v=Array(p);for(a??(s=o(g=c())),u=0;u<=p;++u){if(!(u<p&&i(m=l[u],u,l))===h)if(h=!h)d=u,s.areaStart(),s.lineStart();else{for(s.lineEnd(),s.lineStart(),f=u-1;f>=d;--f)s.point(_[f],v[f]);s.lineEnd(),s.areaEnd()}h&&(_[u]=+e(m,u,l),v[u]=+t(m,u,l),s.point(r?+r(m,u,l):_[u],n?+n(m,u,l):v[u]))}if(g)return s=null,g+``||null}function u(){return JB().defined(i).curve(o).context(a)}return l.x=function(t){return arguments.length?(e=typeof t==`function`?t:jB(+t),r=null,l):e},l.x0=function(t){return arguments.length?(e=typeof t==`function`?t:jB(+t),l):e},l.x1=function(e){return arguments.length?(r=e==null?null:typeof e==`function`?e:jB(+e),l):r},l.y=function(e){return arguments.length?(t=typeof e==`function`?e:jB(+e),n=null,l):t},l.y0=function(e){return arguments.length?(t=typeof e==`function`?e:jB(+e),l):t},l.y1=function(e){return arguments.length?(n=e==null?null:typeof e==`function`?e:jB(+e),l):n},l.lineX0=l.lineY0=function(){return u().x(e).y(t)},l.lineY1=function(){return u().x(e).y(n)},l.lineX1=function(){return u().x(r).y(t)},l.defined=function(e){return arguments.length?(i=typeof e==`function`?e:jB(!!e),l):i},l.curve=function(e){return arguments.length?(o=e,a!=null&&(s=o(a)),l):o},l.context=function(e){return arguments.length?(e==null?a=s=null:s=o(a=e),l):a},l}var XB=class{constructor(e,t){this._context=e,this._x=t}areaStart(){this._line=0}areaEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line}point(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:this._x?this._context.bezierCurveTo(this._x0=(this._x0+e)/2,this._y0,this._x0,t,e,t):this._context.bezierCurveTo(this._x0,this._y0=(this._y0+t)/2,e,this._y0,e,t);break}this._x0=e,this._y0=t}};function pHe(e){return new XB(e,!0)}function mHe(e){return new XB(e,!1)}var ZB={draw(e,t){let n=PB(t/FB);e.moveTo(n,0),e.arc(0,0,n,0,IB)}},hHe={draw(e,t){let n=PB(t/5)/2;e.moveTo(-3*n,-n),e.lineTo(-n,-n),e.lineTo(-n,-3*n),e.lineTo(n,-3*n),e.lineTo(n,-n),e.lineTo(3*n,-n),e.lineTo(3*n,n),e.lineTo(n,n),e.lineTo(n,3*n),e.lineTo(-n,3*n),e.lineTo(-n,n),e.lineTo(-3*n,n),e.closePath()}},QB=PB(1/3),gHe=QB*2,_He={draw(e,t){let n=PB(t/gHe),r=n*QB;e.moveTo(0,-n),e.lineTo(r,0),e.lineTo(0,n),e.lineTo(-r,0),e.closePath()}},vHe={draw(e,t){let n=PB(t),r=-n/2;e.rect(r,r,n,n)}},yHe=.8908130915292852,$B=NB(FB/10)/NB(7*FB/10),bHe=NB(IB/10)*$B,xHe=-MB(IB/10)*$B,SHe={draw(e,t){let n=PB(t*yHe),r=bHe*n,i=xHe*n;e.moveTo(0,-n),e.lineTo(r,i);for(let t=1;t<5;++t){let a=IB*t/5,o=MB(a),s=NB(a);e.lineTo(s*n,-o*n),e.lineTo(o*r-s*i,s*r+o*i)}e.closePath()}},eV=PB(3),CHe={draw(e,t){let n=-PB(t/(eV*3));e.moveTo(0,n*2),e.lineTo(-eV*n,-n),e.lineTo(eV*n,-n),e.closePath()}},tV=-.5,nV=PB(3)/2,rV=1/PB(12),wHe=(rV/2+1)*3,THe={draw(e,t){let n=PB(t/wHe),r=n/2,i=n*rV,a=r,o=n*rV+n,s=-a,c=o;e.moveTo(r,i),e.lineTo(a,o),e.lineTo(s,c),e.lineTo(tV*r-nV*i,nV*r+tV*i),e.lineTo(tV*a-nV*o,nV*a+tV*o),e.lineTo(tV*s-nV*c,nV*s+tV*c),e.lineTo(tV*r+nV*i,tV*i-nV*r),e.lineTo(tV*a+nV*o,tV*o-nV*a),e.lineTo(tV*s+nV*c,tV*c-nV*s),e.closePath()}};function EHe(e,t){let n=null,r=HB(i);e=typeof e==`function`?e:jB(e||ZB),t=typeof t==`function`?t:jB(t===void 0?64:+t);function i(){let i;if(n||=i=r(),e.apply(this,arguments).draw(n,+t.apply(this,arguments)),i)return n=null,i+``||null}return i.type=function(t){return arguments.length?(e=typeof t==`function`?t:jB(t),i):e},i.size=function(e){return arguments.length?(t=typeof e==`function`?e:jB(+e),i):t},i.context=function(e){return arguments.length?(n=e??null,i):n},i}function iV(){}function aV(e,t,n){e._context.bezierCurveTo((2*e._x0+e._x1)/3,(2*e._y0+e._y1)/3,(e._x0+2*e._x1)/3,(e._y0+2*e._y1)/3,(e._x0+4*e._x1+t)/6,(e._y0+4*e._y1+n)/6)}function oV(e){this._context=e}oV.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:aV(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:aV(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function DHe(e){return new oV(e)}function sV(e){this._context=e}sV.prototype={areaStart:iV,areaEnd:iV,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._y0=this._y1=this._y2=this._y3=this._y4=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:this._context.moveTo(this._x2,this._y2),this._context.closePath();break;case 2:this._context.moveTo((this._x2+2*this._x3)/3,(this._y2+2*this._y3)/3),this._context.lineTo((this._x3+2*this._x2)/3,(this._y3+2*this._y2)/3),this._context.closePath();break;case 3:this.point(this._x2,this._y2),this.point(this._x3,this._y3),this.point(this._x4,this._y4);break}},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._x2=e,this._y2=t;break;case 1:this._point=2,this._x3=e,this._y3=t;break;case 2:this._point=3,this._x4=e,this._y4=t,this._context.moveTo((this._x0+4*this._x1+e)/6,(this._y0+4*this._y1+t)/6);break;default:aV(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function OHe(e){return new sV(e)}function cV(e){this._context=e}cV.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===3)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;var n=(this._x0+4*this._x1+e)/6,r=(this._y0+4*this._y1+t)/6;this._line?this._context.lineTo(n,r):this._context.moveTo(n,r);break;case 3:this._point=4;default:aV(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function kHe(e){return new cV(e)}function lV(e){this._context=e}lV.prototype={areaStart:iV,areaEnd:iV,lineStart:function(){this._point=0},lineEnd:function(){this._point&&this._context.closePath()},point:function(e,t){e=+e,t=+t,this._point?this._context.lineTo(e,t):(this._point=1,this._context.moveTo(e,t))}};function AHe(e){return new lV(e)}function uV(e){return e<0?-1:1}function dV(e,t,n){var r=e._x1-e._x0,i=t-e._x1,a=(e._y1-e._y0)/(r||i<0&&-0),o=(n-e._y1)/(i||r<0&&-0),s=(a*i+o*r)/(r+i);return(uV(a)+uV(o))*Math.min(Math.abs(a),Math.abs(o),.5*Math.abs(s))||0}function fV(e,t){var n=e._x1-e._x0;return n?(3*(e._y1-e._y0)/n-t)/2:t}function pV(e,t,n){var r=e._x0,i=e._y0,a=e._x1,o=e._y1,s=(a-r)/3;e._context.bezierCurveTo(r+s,i+s*t,a-s,o-s*n,a,o)}function mV(e){this._context=e}mV.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:pV(this,this._t0,fV(this,this._t0));break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){var n=NaN;if(e=+e,t=+t,!(e===this._x1&&t===this._y1)){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,pV(this,fV(this,n=dV(this,e,t)),n);break;default:pV(this,this._t0,n=dV(this,e,t));break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t,this._t0=n}}};function hV(e){this._context=new gV(e)}(hV.prototype=Object.create(mV.prototype)).point=function(e,t){mV.prototype.point.call(this,t,e)};function gV(e){this._context=e}gV.prototype={moveTo:function(e,t){this._context.moveTo(t,e)},closePath:function(){this._context.closePath()},lineTo:function(e,t){this._context.lineTo(t,e)},bezierCurveTo:function(e,t,n,r,i,a){this._context.bezierCurveTo(t,e,r,n,a,i)}};function jHe(e){return new mV(e)}function MHe(e){return new hV(e)}function _V(e){this._context=e}_V.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=[],this._y=[]},lineEnd:function(){var e=this._x,t=this._y,n=e.length;if(n)if(this._line?this._context.lineTo(e[0],t[0]):this._context.moveTo(e[0],t[0]),n===2)this._context.lineTo(e[1],t[1]);else for(var r=vV(e),i=vV(t),a=0,o=1;o<n;++a,++o)this._context.bezierCurveTo(r[0][a],i[0][a],r[1][a],i[1][a],e[o],t[o]);(this._line||this._line!==0&&n===1)&&this._context.closePath(),this._line=1-this._line,this._x=this._y=null},point:function(e,t){this._x.push(+e),this._y.push(+t)}};function vV(e){var t,n=e.length-1,r,i=Array(n),a=Array(n),o=Array(n);for(i[0]=0,a[0]=2,o[0]=e[0]+2*e[1],t=1;t<n-1;++t)i[t]=1,a[t]=4,o[t]=4*e[t]+2*e[t+1];for(i[n-1]=2,a[n-1]=7,o[n-1]=8*e[n-1]+e[n],t=1;t<n;++t)r=i[t]/a[t-1],a[t]-=r,o[t]-=r*o[t-1];for(i[n-1]=o[n-1]/a[n-1],t=n-2;t>=0;--t)i[t]=(o[t]-i[t+1])/a[t];for(a[n-1]=(e[n]+i[n-1])/2,t=0;t<n-1;++t)a[t]=2*e[t+1]-i[t+1];return[i,a]}function NHe(e){return new _V(e)}function yV(e,t){this._context=e,this._t=t}yV.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=this._y=NaN,this._point=0},lineEnd:function(){0<this._t&&this._t<1&&this._point===2&&this._context.lineTo(this._x,this._y),(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line>=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:if(this._t<=0)this._context.lineTo(this._x,t),this._context.lineTo(e,t);else{var n=this._x*(1-this._t)+e*this._t;this._context.lineTo(n,this._y),this._context.lineTo(n,t)}break}this._x=e,this._y=t}};function PHe(e){return new yV(e,.5)}function FHe(e){return new yV(e,0)}function IHe(e){return new yV(e,1)}function bV(e,t){if((o=e.length)>1)for(var n=1,r,i,a=e[t[0]],o,s=a.length;n<o;++n)for(i=a,a=e[t[n]],r=0;r<s;++r)a[r][1]+=a[r][0]=isNaN(i[r][1])?i[r][0]:i[r][1]}function xV(e){for(var t=e.length,n=Array(t);--t>=0;)n[t]=t;return n}function LHe(e,t){return e[t]}function RHe(e){let t=[];return t.key=e,t}function zHe(){var e=jB([]),t=xV,n=bV,r=LHe;function i(i){var a=Array.from(e.apply(this,arguments),RHe),o,s=a.length,c=-1,l;for(let e of i)for(o=0,++c;o<s;++o)(a[o][c]=[0,+r(e,a[o].key,c,i)]).data=e;for(o=0,l=UB(t(a));o<s;++o)a[l[o]].index=o;return n(a,l),a}return i.keys=function(t){return arguments.length?(e=typeof t==`function`?t:jB(Array.from(t)),i):e},i.value=function(e){return arguments.length?(r=typeof e==`function`?e:jB(+e),i):r},i.order=function(e){return arguments.length?(t=e==null?xV:typeof e==`function`?e:jB(Array.from(e)),i):t},i.offset=function(e){return arguments.length?(n=e??bV,i):n},i}function BHe(e,t){if((r=e.length)>0){for(var n,r,i=0,a=e[0].length,o;i<a;++i){for(o=n=0;n<r;++n)o+=e[n][i][1]||0;if(o)for(n=0;n<r;++n)e[n][i][1]/=o}bV(e,t)}}function VHe(e,t){if((i=e.length)>0){for(var n=0,r=e[t[0]],i,a=r.length;n<a;++n){for(var o=0,s=0;o<i;++o)s+=e[o][n][1]||0;r[n][1]+=r[n][0]=-s/2}bV(e,t)}}function HHe(e,t){if(!(!((o=e.length)>0)||!((a=(i=e[t[0]]).length)>0))){for(var n=0,r=1,i,a,o;r<a;++r){for(var s=0,c=0,l=0;s<o;++s){for(var u=e[t[s]],d=u[r][1]||0,f=(d-(u[r-1][1]||0))/2,p=0;p<s;++p){var m=e[t[p]],h=m[r][1]||0,g=m[r-1][1]||0;f+=h-g}c+=d,l+=f*d}i[r-1][1]+=i[r-1][0]=n,c&&(n-=l/c)}i[r-1][1]+=i[r-1][0]=n,bV(e,t)}}var SV=r(lHe());function CV(e){"@babel/helpers - typeof";return CV=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},CV(e)}var UHe=[`type`,`size`,`sizeType`];function wV(){return wV=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},wV.apply(this,arguments)}function TV(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function EV(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?TV(Object(n),!0).forEach(function(t){WHe(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):TV(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function WHe(e,t,n){return t=GHe(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function GHe(e){var t=KHe(e,`string`);return CV(t)==`symbol`?t:t+``}function KHe(e,t){if(CV(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(CV(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function qHe(e,t){if(e==null)return{};var n=JHe(e,t),r,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++)r=a[i],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function JHe(e,t){if(e==null)return{};var n={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}var DV={symbolCircle:ZB,symbolCross:hHe,symbolDiamond:_He,symbolSquare:vHe,symbolStar:SHe,symbolTriangle:CHe,symbolWye:THe},YHe=Math.PI/180,XHe=function(e){return DV[`symbol${(0,SV.default)(e)}`]||ZB},ZHe=function(e,t,n){if(t===`area`)return e;switch(n){case`cross`:return 5*e*e/9;case`diamond`:return .5*e*e/Math.sqrt(3);case`square`:return e*e;case`star`:var r=18*YHe;return 1.25*e*e*(Math.tan(r)-Math.tan(r*2)*Math.tan(r)**2);case`triangle`:return Math.sqrt(3)*e*e/4;case`wye`:return(21-10*Math.sqrt(3))*e*e/8;default:return Math.PI*e*e/4}},QHe=function(e,t){DV[`symbol${(0,SV.default)(e)}`]=t},OV=function(e){var t=e.type,n=t===void 0?`circle`:t,r=e.size,i=r===void 0?64:r,a=e.sizeType,o=a===void 0?`area`:a,s=EV(EV({},qHe(e,UHe)),{},{type:n,size:i,sizeType:o}),c=function(){var e=XHe(n);return EHe().type(e).size(ZHe(i,o,n))()},l=s.className,u=s.cx,d=s.cy,f=xB(s,!0);return u===+u&&d===+d&&i===+i?H.createElement(`path`,wV({},f,{className:xl(`recharts-symbols`,l),transform:`translate(${u}, ${d})`,d:c()})):null};OV.registerSymbol=QHe;function kV(e){"@babel/helpers - typeof";return kV=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},kV(e)}function AV(){return AV=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},AV.apply(this,arguments)}function jV(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function $He(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?jV(Object(n),!0).forEach(function(t){IV(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):jV(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function eUe(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function MV(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,LV(r.key),r)}}function tUe(e,t,n){return t&&MV(e.prototype,t),n&&MV(e,n),Object.defineProperty(e,`prototype`,{writable:!1}),e}function nUe(e,t,n){return t=PV(t),rUe(e,NV()?Reflect.construct(t,n||[],PV(e).constructor):t.apply(e,n))}function rUe(e,t){if(t&&(kV(t)===`object`||typeof t==`function`))return t;if(t!==void 0)throw TypeError(`Derived constructors may only return object or undefined`);return iUe(e)}function iUe(e){if(e===void 0)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return e}function NV(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(NV=function(){return!!e})()}function PV(e){return PV=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},PV(e)}function aUe(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Super expression must either be null or a function`);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,`prototype`,{writable:!1}),t&&FV(e,t)}function FV(e,t){return FV=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},FV(e,t)}function IV(e,t,n){return t=LV(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function LV(e){var t=oUe(e,`string`);return kV(t)==`symbol`?t:t+``}function oUe(e,t){if(kV(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(kV(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var RV=32,zV=function(e){function t(){return eUe(this,t),nUe(this,t,arguments)}return aUe(t,e),tUe(t,[{key:`renderIcon`,value:function(e){var t=this.props.inactiveColor,n=RV/2,r=RV/6,i=RV/3,a=e.inactive?t:e.color;if(e.type===`plainline`)return H.createElement(`line`,{strokeWidth:4,fill:`none`,stroke:a,strokeDasharray:e.payload.strokeDasharray,x1:0,y1:n,x2:RV,y2:n,className:`recharts-legend-icon`});if(e.type===`line`)return H.createElement(`path`,{strokeWidth:4,fill:`none`,stroke:a,d:`M0,${n}h${i}
256
256
  A${r},${r},0,1,1,${2*i},${n}
@@ -482,7 +482,7 @@ export function runtimeInit(runtime: RuntimeExtensions) {
482
482
  `,`
483
483
  +`).split(`
484
484
  `));return[t,t.reduce((e,t)=>e.concat(...t),[])]}return[[],[]]},[e]);return(0,H.useEffect)(()=>{let n=t?.target??WDt,c=t?.actInsideInputWithModifier??!0;if(e!==null){let e=e=>{if(i.current=e.ctrlKey||e.metaKey||e.shiftKey||e.altKey,(!i.current||i.current&&!c)&&JTt(e))return!1;let n=KDt(e.code,s);if(a.current.add(e[n]),GDt(o,a.current,!1)){let n=e.composedPath?.()?.[0]||e.target,a=n?.nodeName===`BUTTON`||n?.nodeName===`A`;t.preventDefault!==!1&&(i.current||!a)&&e.preventDefault(),r(!0)}},l=e=>{let t=KDt(e.code,s);GDt(o,a.current,!0)?(r(!1),a.current.clear()):a.current.delete(e[t]),e.key===`Meta`&&a.current.clear(),i.current=!1},u=()=>{a.current.clear(),r(!1)};return n?.addEventListener(`keydown`,e),n?.addEventListener(`keyup`,l),window.addEventListener(`blur`,u),window.addEventListener(`contextmenu`,u),()=>{n?.removeEventListener(`keydown`,e),n?.removeEventListener(`keyup`,l),window.removeEventListener(`blur`,u),window.removeEventListener(`contextmenu`,u)}}},[e,r]),n}function GDt(e,t,n){return e.filter(e=>n||e.length===t.size).some(e=>e.every(e=>t.has(e)))}function KDt(e,t){return t.includes(e)?`code`:`key`}var qDt=()=>{let e=p4();return(0,H.useMemo)(()=>({zoomIn:t=>{let{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):Promise.resolve(!1)},zoomOut:t=>{let{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):Promise.resolve(!1)},zoomTo:(t,n)=>{let{panZoom:r}=e.getState();return r?r.scaleTo(t,n):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{let{transform:[r,i,a],panZoom:o}=e.getState();return o?(await o.setViewport({x:t.x??r,y:t.y??i,zoom:t.zoom??a},n),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{let[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},setCenter:async(t,n,r)=>e.getState().setCenter(t,n,r),fitBounds:async(t,n)=>{let{width:r,height:i,minZoom:a,maxZoom:o,panZoom:s}=e.getState(),c=L2(t,r,i,a,o,n?.padding??.1);return s?(await s.setViewport(c,{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(t,n={})=>{let{transform:r,snapGrid:i,snapToGrid:a,domNode:o}=e.getState();if(!o)return t;let{x:s,y:c}=o.getBoundingClientRect(),l={x:t.x-s,y:t.y-c},u=n.snapGrid??i;return P2(l,r,n.snapToGrid??a,u)},flowToScreenPosition:t=>{let{transform:n,domNode:r}=e.getState();if(!r)return t;let{x:i,y:a}=r.getBoundingClientRect(),o=F2(t,n);return{x:o.x+i,y:o.y+a}}}),[])};function JDt(e,t){let n=[],r=new Map,i=[];for(let t of e)if(t.type===`add`){i.push(t);continue}else if(t.type===`remove`||t.type===`replace`)r.set(t.id,[t]);else{let e=r.get(t.id);e?e.push(t):r.set(t.id,[t])}for(let e of t){let t=r.get(e.id);if(!t){n.push(e);continue}if(t[0].type===`remove`)continue;if(t[0].type===`replace`){n.push({...t[0].item});continue}let i={...e};for(let e of t)YDt(e,i);n.push(i)}return i.length&&i.forEach(e=>{e.index===void 0?n.push({...e.item}):n.splice(e.index,0,{...e.item})}),n}function YDt(e,t){switch(e.type){case`select`:t.selected=e.selected;break;case`position`:e.position!==void 0&&(t.position=e.position),e.dragging!==void 0&&(t.dragging=e.dragging);break;case`dimensions`:e.dimensions!==void 0&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes===`width`)&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes===`height`)&&(t.height=e.dimensions.height))),typeof e.resizing==`boolean`&&(t.resizing=e.resizing);break}}function XDt(e,t){return JDt(e,t)}function ZDt(e,t){return JDt(e,t)}function v4(e,t){return{id:e,type:`select`,selected:t}}function y4(e,t=new Set,n=!1){let r=[];for(let[i,a]of e){let e=t.has(i);!(a.selected===void 0&&!e)&&a.selected!==e&&(n&&(a.selected=e),r.push(v4(a.id,e)))}return r}function QDt({items:e=[],lookup:t}){let n=[],r=new Map(e.map(e=>[e.id,e]));for(let[r,i]of e.entries()){let e=t.get(i.id),a=e?.internals?.userNode??e;a!==void 0&&a!==i&&n.push({id:i.id,item:i,type:`replace`}),a===void 0&&n.push({item:i,type:`add`,index:r})}for(let[e]of t)r.get(e)===void 0&&n.push({id:e,type:`remove`});return n}function $Dt(e){return{id:e.id,type:`remove`}}var eOt=e=>ETt(e),tOt=e=>TTt(e);function nOt(e){return(0,H.forwardRef)(e)}function rOt(e){let[t,n]=(0,H.useState)(BigInt(0)),[r]=(0,H.useState)(()=>iOt(()=>n(e=>e+BigInt(1))));return g4(()=>{let t=r.get();t.length&&(e(t),r.reset())},[t]),r}function iOt(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}var aOt=(0,H.createContext)(null);function oOt({children:e}){let t=p4(),n=rOt((0,H.useCallback)(e=>{let{nodes:n=[],setNodes:r,hasDefaultNodes:i,onNodesChange:a,nodeLookup:o,fitViewQueued:s,onNodesChangeMiddlewareMap:c}=t.getState(),l=n;for(let t of e)l=typeof t==`function`?t(l):t;let u=QDt({items:l,lookup:o});for(let e of c.values())u=e(u);i&&r(l),u.length>0?a?.(u):s&&window.requestAnimationFrame(()=>{let{fitViewQueued:e,nodes:n,setNodes:r}=t.getState();e&&r(n)})},[])),r=rOt((0,H.useCallback)(e=>{let{edges:n=[],setEdges:r,hasDefaultEdges:i,onEdgesChange:a,edgeLookup:o}=t.getState(),s=n;for(let t of e)s=typeof t==`function`?t(s):t;i?r(s):a&&a(QDt({items:s,lookup:o}))},[])),i=(0,H.useMemo)(()=>({nodeQueue:n,edgeQueue:r}),[]);return(0,U.jsx)(aOt.Provider,{value:i,children:e})}function sOt(){let e=(0,H.useContext)(aOt);if(!e)throw Error(`useBatchContext must be used within a BatchProvider`);return e}var cOt=e=>!!e.panZoom;function b4(){let e=qDt(),t=p4(),n=sOt(),r=f4(cOt),i=(0,H.useMemo)(()=>{let e=e=>t.getState().nodeLookup.get(e),r=e=>{n.nodeQueue.push(e)},i=e=>{n.edgeQueue.push(e)},a=e=>{let{nodeLookup:n,nodeOrigin:r}=t.getState(),i=eOt(e)?e:n.get(e.id),a=i.parentId?HTt(i.position,i.measured,i.parentId,n,r):i.position;return k2({...i,position:a,width:i.measured?.width??i.width,height:i.measured?.height??i.height})},o=(e,t,n={replace:!1})=>{r(r=>r.map(r=>{if(r.id===e){let e=typeof t==`function`?t(r):t;return n.replace&&eOt(e)?e:{...r,...e}}return r}))},s=(e,t,n={replace:!1})=>{i(r=>r.map(r=>{if(r.id===e){let e=typeof t==`function`?t(r):t;return n.replace&&tOt(e)?e:{...r,...e}}return r}))};return{getNodes:()=>t.getState().nodes.map(e=>({...e})),getNode:t=>e(t)?.internals.userNode,getInternalNode:e,getEdges:()=>{let{edges:e=[]}=t.getState();return e.map(e=>({...e}))},getEdge:e=>t.getState().edgeLookup.get(e),setNodes:r,setEdges:i,addNodes:e=>{let t=Array.isArray(e)?e:[e];n.nodeQueue.push(e=>[...e,...t])},addEdges:e=>{let t=Array.isArray(e)?e:[e];n.edgeQueue.push(e=>[...e,...t])},toObject:()=>{let{nodes:e=[],edges:n=[],transform:r}=t.getState(),[i,a,o]=r;return{nodes:e.map(e=>({...e})),edges:n.map(e=>({...e})),viewport:{x:i,y:a,zoom:o}}},deleteElements:async({nodes:e=[],edges:n=[]})=>{let{nodes:r,edges:i,onNodesDelete:a,onEdgesDelete:o,triggerNodeChanges:s,triggerEdgeChanges:c,onDelete:l,onBeforeDelete:u}=t.getState(),{nodes:d,edges:f}=await MTt({nodesToRemove:e,edgesToRemove:n,nodes:r,edges:i,onBeforeDelete:u}),p=f.length>0,m=d.length>0;if(p){let e=f.map($Dt);o?.(f),c(e)}if(m){let e=d.map($Dt);a?.(d),s(e)}return(m||p)&&l?.({nodes:d,edges:f}),{deletedNodes:d,deletedEdges:f}},getIntersectingNodes:(e,n=!0,r)=>{let i=LTt(e),o=i?e:a(e),s=r!==void 0;return o?(r||t.getState().nodes).filter(r=>{let a=t.getState().nodeLookup.get(r.id);if(a&&!i&&(r.id===e.id||!a.internals.positionAbsolute))return!1;let c=k2(s?r:a),l=j2(c,o);return n&&l>0||l>=c.width*c.height||l>=o.width*o.height}):[]},isNodeIntersecting:(e,t,n=!0)=>{let r=LTt(e)?e:a(e);if(!r)return!1;let i=j2(r,t);return n&&i>0||i>=t.width*t.height||i>=r.width*r.height},updateNode:o,updateNodeData:(e,t,n={replace:!1})=>{o(e,e=>{let r=typeof t==`function`?t(e):t;return n.replace?{...e,data:r}:{...e,data:{...e.data,...r}}},n)},updateEdge:s,updateEdgeData:(e,t,n={replace:!1})=>{s(e,e=>{let r=typeof t==`function`?t(e):t;return n.replace?{...e,data:r}:{...e,data:{...e.data,...r}}},n)},getNodesBounds:e=>{let{nodeLookup:n,nodeOrigin:r}=t.getState();return DTt(e,{nodeLookup:n,nodeOrigin:r})},getHandleConnections:({type:e,id:n,nodeId:r})=>Array.from(t.getState().connectionLookup.get(`${r}-${e}${n?`-${n}`:``}`)?.values()??[]),getNodeConnections:({type:e,handleId:n,nodeId:r})=>Array.from(t.getState().connectionLookup.get(`${r}${e?n?`-${e}-${n}`:`-${e}`:``}`)?.values()??[]),fitView:async e=>{let r=t.getState().fitViewResolver??WTt();return t.setState({fitViewQueued:!0,fitViewOptions:e,fitViewResolver:r}),n.nodeQueue.push(e=>[...e]),r.promise}}},[]);return(0,H.useMemo)(()=>({...i,...e,viewportInitialized:r}),[r])}var lOt=e=>e.selected,uOt=typeof window<`u`?window:void 0;function dOt({deleteKeyCode:e,multiSelectionKeyCode:t}){let n=p4(),{deleteElements:r}=b4(),i=_4(e,{actInsideInputWithModifier:!1}),a=_4(t,{target:uOt});(0,H.useEffect)(()=>{if(i){let{edges:e,nodes:t}=n.getState();r({nodes:t.filter(lOt),edges:e.filter(lOt)}),n.setState({nodesSelectionActive:!1})}},[i]),(0,H.useEffect)(()=>{n.setState({multiSelectionActive:a})},[a])}function fOt(e){let t=p4();(0,H.useEffect)(()=>{let n=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;let n=H2(e.current);(n.height===0||n.width===0)&&t.getState().onError?.(`004`,f2.error004()),t.setState({width:n.width||500,height:n.height||500})};if(e.current){n(),window.addEventListener(`resize`,n);let t=new ResizeObserver(()=>n());return t.observe(e.current),()=>{window.removeEventListener(`resize`,n),t&&e.current&&t.unobserve(e.current)}}},[])}var x4={position:`absolute`,width:`100%`,height:`100%`,top:0,left:0},pOt=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function mOt({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:i=.5,panOnScrollMode:a=h2.Free,zoomOnDoubleClick:o=!0,panOnDrag:s=!0,defaultViewport:c,translateExtent:l,minZoom:u,maxZoom:d,zoomActivationKeyCode:f,preventScrolling:p=!0,children:m,noWheelClassName:h,noPanClassName:g,onViewportChange:_,isControlledViewport:v,paneClickDistance:y,selectionOnDrag:b}){let x=p4(),S=(0,H.useRef)(null),{userSelectionActive:C,lib:w,connectionInProgress:T}=f4(pOt,u4),E=_4(f),D=(0,H.useRef)();fOt(S);let O=(0,H.useCallback)(e=>{_?.({x:e[0],y:e[1],zoom:e[2]}),v||x.setState({transform:e})},[_,v]);return(0,H.useEffect)(()=>{if(S.current){D.current=$Et({domNode:S.current,minZoom:u,maxZoom:d,translateExtent:l,viewport:c,onDraggingChange:e=>x.setState(t=>t.paneDragging===e?t:{paneDragging:e}),onPanZoomStart:(e,t)=>{let{onViewportChangeStart:n,onMoveStart:r}=x.getState();r?.(e,t),n?.(t)},onPanZoom:(e,t)=>{let{onViewportChange:n,onMove:r}=x.getState();r?.(e,t),n?.(t)},onPanZoomEnd:(e,t)=>{let{onViewportChangeEnd:n,onMoveEnd:r}=x.getState();r?.(e,t),n?.(t)}});let{x:e,y:t,zoom:n}=D.current.getViewport();return x.setState({panZoom:D.current,transform:[e,t,n],domNode:S.current.closest(`.react-flow`)}),()=>{D.current?.destroy()}}},[]),(0,H.useEffect)(()=>{D.current?.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panOnScrollSpeed:i,panOnScrollMode:a,zoomOnDoubleClick:o,panOnDrag:s,zoomActivationKeyPressed:E,preventScrolling:p,noPanClassName:g,userSelectionActive:C,noWheelClassName:h,lib:w,onTransformChange:O,connectionInProgress:T,selectionOnDrag:b,paneClickDistance:y})},[e,t,n,r,i,a,o,s,E,p,g,C,h,w,O,T,b,y]),(0,U.jsx)(`div`,{className:`react-flow__renderer`,ref:S,style:x4,children:m})}var hOt=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function gOt(){let{userSelectionActive:e,userSelectionRect:t}=f4(hOt,u4);return e&&t?(0,U.jsx)(`div`,{className:`react-flow__selection react-flow__container`,style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}var S4=(e,t)=>n=>{n.target===t.current&&e?.(n)},_Ot=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function vOt({isSelecting:e,selectionKeyPressed:t,selectionMode:n=g2.Full,panOnDrag:r,paneClickDistance:i,selectionOnDrag:a,onSelectionStart:o,onSelectionEnd:s,onPaneClick:c,onPaneContextMenu:l,onPaneScroll:u,onPaneMouseEnter:d,onPaneMouseMove:f,onPaneMouseLeave:p,children:m}){let h=p4(),{userSelectionActive:g,elementsSelectable:_,dragging:v,connectionInProgress:y}=f4(_Ot,u4),b=_&&(e||g),x=(0,H.useRef)(null),S=(0,H.useRef)(),C=(0,H.useRef)(new Set),w=(0,H.useRef)(new Set),T=(0,H.useRef)(!1),E=e=>{if(T.current||y){T.current=!1;return}c?.(e),h.getState().resetSelectedElements(),h.setState({nodesSelectionActive:!1})},D=e=>{if(Array.isArray(r)&&r?.includes(2)){e.preventDefault();return}l?.(e)},O=u?e=>u(e):void 0;return(0,U.jsxs)(`div`,{className:o0([`react-flow__pane`,{draggable:r===!0||Array.isArray(r)&&r.includes(0),dragging:v,selection:e}]),onClick:b?void 0:S4(E,x),onContextMenu:S4(D,x),onWheel:S4(O,x),onPointerEnter:b?void 0:d,onPointerMove:b?e=>{let{userSelectionRect:r,transform:a,nodeLookup:s,edgeLookup:c,connectionLookup:l,triggerNodeChanges:u,triggerEdgeChanges:d,defaultEdgeOptions:f,resetSelectedElements:p}=h.getState();if(!S.current||!r)return;let{x:m,y:g}=U2(e.nativeEvent,S.current),{startX:_,startY:v}=r;if(!T.current){let n=t?0:i;if(Math.hypot(m-_,g-v)<=n)return;p(),o?.(e)}T.current=!0;let y={startX:_,startY:v,x:m<_?m:_,y:g<v?g:v,width:Math.abs(m-_),height:Math.abs(g-v)},b=C.current,x=w.current;C.current=new Set(C2(s,y,a,n===g2.Partial,!0).map(e=>e.id)),w.current=new Set;let E=f?.selectable??!0;for(let e of C.current){let t=l.get(e);if(t)for(let{edgeId:e}of t.values()){let t=c.get(e);t&&(t.selectable??E)&&w.current.add(e)}}UTt(b,C.current)||u(y4(s,C.current,!0)),UTt(x,w.current)||d(y4(c,w.current)),h.setState({userSelectionRect:y,userSelectionActive:!0,nodesSelectionActive:!1})}:f,onPointerUp:b?e=>{e.button===0&&(e.target?.releasePointerCapture?.(e.pointerId),!g&&e.target===x.current&&h.getState().userSelectionRect&&E?.(e),h.setState({userSelectionActive:!1,userSelectionRect:null}),T.current&&(s?.(e),h.setState({nodesSelectionActive:C.current.size>0})))}:void 0,onPointerDownCapture:b?n=>{let{domNode:r}=h.getState();if(S.current=r?.getBoundingClientRect(),!S.current)return;let i=n.target===x.current;if(!i&&n.target.closest(`.nokey`)||!e||!(a&&i||t)||n.button!==0||!n.isPrimary)return;n.target?.setPointerCapture?.(n.pointerId),T.current=!1;let{x:o,y:s}=U2(n.nativeEvent,S.current);h.setState({userSelectionRect:{width:0,height:0,startX:o,startY:s,x:o,y:s}}),i||(n.stopPropagation(),n.preventDefault())}:void 0,onClickCapture:b?e=>{T.current&&=(e.stopPropagation(),!1)}:void 0,onPointerLeave:p,ref:x,style:x4,children:[m,(0,U.jsx)(gOt,{})]})}function C4({id:e,store:t,unselect:n=!1,nodeRef:r}){let{addSelectedNodes:i,unselectNodesAndEdges:a,multiSelectionActive:o,nodeLookup:s,onError:c}=t.getState(),l=s.get(e);if(!l){c?.(`012`,f2.error012(e));return}t.setState({nodesSelectionActive:!1}),l.selected?(n||l.selected&&o)&&(a({nodes:[l],edges:[]}),requestAnimationFrame(()=>r?.current?.blur())):i([e])}function yOt({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:i,isSelectable:a,nodeClickDistance:o}){let s=p4(),[c,l]=(0,H.useState)(!1),u=(0,H.useRef)();return(0,H.useEffect)(()=>{u.current=NEt({getStoreItems:()=>s.getState(),onNodeMouseDown:t=>{C4({id:t,store:s,nodeRef:e})},onDragStart:()=>{l(!0)},onDragStop:()=>{l(!1)}})},[]),(0,H.useEffect)(()=>{if(!(t||!e.current||!u.current))return u.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:a,nodeId:i,nodeClickDistance:o}),()=>{u.current?.destroy()}},[n,r,t,a,e,i,o]),c}var bOt=e=>t=>t.selected&&(t.draggable||e&&t.draggable===void 0);function xOt(){let e=p4();return(0,H.useCallback)(t=>{let{nodeExtent:n,snapToGrid:r,snapGrid:i,nodesDraggable:a,onError:o,updateNodePositions:s,nodeLookup:c,nodeOrigin:l}=e.getState(),u=new Map,d=bOt(a),f=r?i[0]:5,p=r?i[1]:5,m=t.direction.x*f*t.factor,h=t.direction.y*p*t.factor;for(let[,e]of c){if(!d(e))continue;let t={x:e.internals.positionAbsolute.x+m,y:e.internals.positionAbsolute.y+h};r&&(t=N2(t,i));let{position:a,positionAbsolute:s}=jTt({nodeId:e.id,nextPosition:t,nodeLookup:c,nodeExtent:n,nodeOrigin:l,onError:o});e.position=a,e.internals.positionAbsolute=s,u.set(e.id,e)}s(u)},[])}var w4=(0,H.createContext)(null),SOt=w4.Provider;w4.Consumer;var COt=()=>(0,H.useContext)(w4),wOt=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),TOt=(e,t,n)=>r=>{let{connectionClickStartHandle:i,connectionMode:a,connection:o}=r,{fromHandle:s,toHandle:c,isValid:l}=o,u=c?.nodeId===e&&c?.id===t&&c?.type===n;return{connectingFrom:s?.nodeId===e&&s?.id===t&&s?.type===n,connectingTo:u,clickConnecting:i?.nodeId===e&&i?.id===t&&i?.type===n,isPossibleEndHandle:a===m2.Strict?s?.type!==n:e!==s?.nodeId||t!==s?.id,connectionInProcess:!!s,clickConnectionInProcess:!!i,valid:u&&l}};function EOt({type:e=`source`,position:t=y2.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:i=!0,isConnectableEnd:a=!0,id:o,onConnect:s,children:c,className:l,onMouseDown:u,onTouchStart:d,...f},p){let m=o||null,h=e===`target`,g=p4(),_=COt(),{connectOnClick:v,noPanClassName:y,rfId:b}=f4(wOt,u4),{connectingFrom:x,connectingTo:S,clickConnecting:C,isPossibleEndHandle:w,connectionInProcess:T,clickConnectionInProcess:E,valid:D}=f4(TOt(_,m,e),u4);_||g.getState().onError?.(`010`,f2.error010());let O=e=>{let{defaultEdgeOptions:t,onConnect:n,hasDefaultEdges:r}=g.getState(),i={...t,...e};if(r){let{edges:e,setEdges:t}=g.getState();t(aEt(i,e))}n?.(i),s?.(i)},k=e=>{if(!_)return;let t=YTt(e.nativeEvent);if(i&&(t&&e.button===0||!t)){let t=g.getState();t4.onPointerDown(e.nativeEvent,{handleDomNode:e.currentTarget,autoPanOnConnect:t.autoPanOnConnect,connectionMode:t.connectionMode,connectionRadius:t.connectionRadius,domNode:t.domNode,nodeLookup:t.nodeLookup,lib:t.lib,isTarget:h,handleId:m,nodeId:_,flowId:t.rfId,panBy:t.panBy,cancelConnection:t.cancelConnection,onConnectStart:t.onConnectStart,onConnectEnd:(...e)=>g.getState().onConnectEnd?.(...e),updateConnection:t.updateConnection,onConnect:O,isValidConnection:n||((...e)=>g.getState().isValidConnection?.(...e)??!0),getTransform:()=>g.getState().transform,getFromHandle:()=>g.getState().connection.fromHandle,autoPanSpeed:t.autoPanSpeed,dragThreshold:t.connectionDragThreshold})}t?u?.(e):d?.(e)},A=t=>{let{onClickConnectStart:r,onClickConnectEnd:a,connectionClickStartHandle:o,connectionMode:s,isValidConnection:c,lib:l,rfId:u,nodeLookup:d,connection:f}=g.getState();if(!_||!o&&!i)return;if(!o){r?.(t.nativeEvent,{nodeId:_,handleId:m,handleType:e}),g.setState({connectionClickStartHandle:{nodeId:_,type:e,id:m}});return}let p=KTt(t.target),h=n||c,{connection:v,isValid:y}=t4.isValid(t.nativeEvent,{handle:{nodeId:_,id:m,type:e},connectionMode:s,fromNodeId:o.nodeId,fromHandleId:o.id||null,fromType:o.type,isValidConnection:h,flowId:u,doc:p,lib:l,nodeLookup:d});y&&v&&O(v);let b=structuredClone(f);delete b.inProgress,b.toPosition=b.toHandle?b.toHandle.position:null,a?.(t,b),g.setState({connectionClickStartHandle:null})};return(0,U.jsx)(`div`,{"data-handleid":m,"data-nodeid":_,"data-handlepos":t,"data-id":`${b}-${_}-${m}-${e}`,className:o0([`react-flow__handle`,`react-flow__handle-${t}`,`nodrag`,y,l,{source:!h,target:h,connectable:r,connectablestart:i,connectableend:a,clickconnecting:C,connectingfrom:x,connectingto:S,valid:D,connectionindicator:r&&(!T||w)&&(T||E?a:i)}]),onMouseDown:k,onTouchStart:k,onClick:v?A:void 0,ref:p,...f,children:c})}var T4=(0,H.memo)(nOt(EOt));function DOt({data:e,isConnectable:t,sourcePosition:n=y2.Bottom}){return(0,U.jsxs)(U.Fragment,{children:[e?.label,(0,U.jsx)(T4,{type:`source`,position:n,isConnectable:t})]})}function OOt({data:e,isConnectable:t,targetPosition:n=y2.Top,sourcePosition:r=y2.Bottom}){return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(T4,{type:`target`,position:n,isConnectable:t}),e?.label,(0,U.jsx)(T4,{type:`source`,position:r,isConnectable:t})]})}function kOt(){return null}function AOt({data:e,isConnectable:t,targetPosition:n=y2.Top}){return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(T4,{type:`target`,position:n,isConnectable:t}),e?.label]})}var E4={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},jOt={input:DOt,default:OOt,output:AOt,group:kOt};function MOt(e){return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??e.style?.width,height:e.height??e.initialHeight??e.style?.height}:{width:e.width??e.style?.width,height:e.height??e.style?.height}}var NOt=e=>{let{width:t,height:n,x:r,y:i}=S2(e.nodeLookup,{filter:e=>!!e.selected});return{width:M2(t)?t:null,height:M2(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${r}px,${i}px)`}};function POt({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){let r=p4(),{width:i,height:a,transformString:o,userSelectionActive:s}=f4(NOt,u4),c=xOt(),l=(0,H.useRef)(null);(0,H.useEffect)(()=>{n||l.current?.focus({preventScroll:!0})},[n]);let u=!s&&i!==null&&a!==null;if(yOt({nodeRef:l,disabled:!u}),!u)return null;let d=e?t=>{e(t,r.getState().nodes.filter(e=>e.selected))}:void 0;return(0,U.jsx)(`div`,{className:o0([`react-flow__nodesselection`,`react-flow__container`,t]),style:{transform:o},children:(0,U.jsx)(`div`,{ref:l,className:`react-flow__nodesselection-rect`,onContextMenu:d,tabIndex:n?void 0:-1,onKeyDown:n?void 0:e=>{Object.prototype.hasOwnProperty.call(E4,e.key)&&(e.preventDefault(),c({direction:E4[e.key],factor:e.shiftKey?4:1}))},style:{width:i,height:a}})})}var FOt=typeof window<`u`?window:void 0,IOt=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function LOt({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:o,paneClickDistance:s,deleteKeyCode:c,selectionKeyCode:l,selectionOnDrag:u,selectionMode:d,onSelectionStart:f,onSelectionEnd:p,multiSelectionKeyCode:m,panActivationKeyCode:h,zoomActivationKeyCode:g,elementsSelectable:_,zoomOnScroll:v,zoomOnPinch:y,panOnScroll:b,panOnScrollSpeed:x,panOnScrollMode:S,zoomOnDoubleClick:C,panOnDrag:w,defaultViewport:T,translateExtent:E,minZoom:D,maxZoom:O,preventScrolling:k,onSelectionContextMenu:A,noWheelClassName:j,noPanClassName:M,disableKeyboardA11y:N,onViewportChange:P,isControlledViewport:F}){let{nodesSelectionActive:I,userSelectionActive:L}=f4(IOt,u4),R=_4(l,{target:FOt}),z=_4(h,{target:FOt}),B=z||w,ee=z||b,te=u&&B!==!0,V=R||L||te;return dOt({deleteKeyCode:c,multiSelectionKeyCode:m}),(0,U.jsx)(mOt,{onPaneContextMenu:a,elementsSelectable:_,zoomOnScroll:v,zoomOnPinch:y,panOnScroll:ee,panOnScrollSpeed:x,panOnScrollMode:S,zoomOnDoubleClick:C,panOnDrag:!R&&B,defaultViewport:T,translateExtent:E,minZoom:D,maxZoom:O,zoomActivationKeyCode:g,preventScrolling:k,noWheelClassName:j,noPanClassName:M,onViewportChange:P,isControlledViewport:F,paneClickDistance:s,selectionOnDrag:te,children:(0,U.jsxs)(vOt,{onSelectionStart:f,onSelectionEnd:p,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:o,panOnDrag:B,isSelecting:!!V,selectionMode:d,selectionKeyPressed:R,paneClickDistance:s,selectionOnDrag:te,children:[e,I&&(0,U.jsx)(POt,{onSelectionContextMenu:A,noPanClassName:M,disableKeyboardA11y:N})]})})}LOt.displayName=`FlowRenderer`;var ROt=(0,H.memo)(LOt),zOt=e=>t=>e?C2(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(e=>e.id):Array.from(t.nodeLookup.keys());function BOt(e){return f4((0,H.useCallback)(zOt(e),[e]),u4)}var VOt=e=>e.updateNodeInternals;function HOt(){let e=f4(VOt),[t]=(0,H.useState)(()=>typeof ResizeObserver>`u`?null:new ResizeObserver(t=>{let n=new Map;t.forEach(e=>{let t=e.target.getAttribute(`data-id`);n.set(t,{id:t,nodeElement:e.target,force:!0})}),e(n)}));return(0,H.useEffect)(()=>()=>{t?.disconnect()},[t]),t}function UOt({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){let i=p4(),a=(0,H.useRef)(null),o=(0,H.useRef)(null),s=(0,H.useRef)(e.sourcePosition),c=(0,H.useRef)(e.targetPosition),l=(0,H.useRef)(t),u=n&&!!e.internals.handleBounds;return(0,H.useEffect)(()=>{a.current&&!e.hidden&&(!u||o.current!==a.current)&&(o.current&&r?.unobserve(o.current),r?.observe(a.current),o.current=a.current)},[u,e.hidden]),(0,H.useEffect)(()=>()=>{o.current&&=(r?.unobserve(o.current),null)},[]),(0,H.useEffect)(()=>{if(a.current){let n=l.current!==t,r=s.current!==e.sourcePosition,o=c.current!==e.targetPosition;(n||r||o)&&(l.current=t,s.current=e.sourcePosition,c.current=e.targetPosition,i.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:a.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),a}function WOt({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:i,onContextMenu:a,onDoubleClick:o,nodesDraggable:s,elementsSelectable:c,nodesConnectable:l,nodesFocusable:u,resizeObserver:d,noDragClassName:f,noPanClassName:p,disableKeyboardA11y:m,rfId:h,nodeTypes:g,nodeClickDistance:_,onError:v}){let{node:y,internals:b,isParent:x}=f4(t=>{let n=t.nodeLookup.get(e),r=t.parentLookup.has(e);return{node:n,internals:n.internals,isParent:r}},u4),S=y.type||`default`,C=g?.[S]||jOt[S];C===void 0&&(v?.(`003`,f2.error003(S)),S=`default`,C=g?.default||jOt.default);let w=!!(y.draggable||s&&y.draggable===void 0),T=!!(y.selectable||c&&y.selectable===void 0),E=!!(y.connectable||l&&y.connectable===void 0),D=!!(y.focusable||u&&y.focusable===void 0),O=p4(),k=VTt(y),A=UOt({node:y,nodeType:S,hasDimensions:k,resizeObserver:d}),j=yOt({nodeRef:A,disabled:y.hidden||!w,noDragClassName:f,handleSelector:y.dragHandle,nodeId:e,isSelectable:T,nodeClickDistance:_}),M=xOt();if(y.hidden)return null;let N=B2(y),P=MOt(y),F=T||w||t||n||r||i,I=n?e=>n(e,{...b.userNode}):void 0,L=r?e=>r(e,{...b.userNode}):void 0,R=i?e=>i(e,{...b.userNode}):void 0,z=a?e=>a(e,{...b.userNode}):void 0,B=o?e=>o(e,{...b.userNode}):void 0,ee=n=>{let{selectNodesOnDrag:r,nodeDragThreshold:i}=O.getState();T&&(!r||!w||i>0)&&C4({id:e,store:O,nodeRef:A}),t&&t(n,{...b.userNode})},te=t=>{if(!(JTt(t.nativeEvent)||m)){if(bTt.includes(t.key)&&T)C4({id:e,store:O,unselect:t.key===`Escape`,nodeRef:A});else if(w&&y.selected&&Object.prototype.hasOwnProperty.call(E4,t.key)){t.preventDefault();let{ariaLabelConfig:e}=O.getState();O.setState({ariaLiveMessage:e[`node.a11yDescription.ariaLiveMessage`]({direction:t.key.replace(`Arrow`,``).toLowerCase(),x:~~b.positionAbsolute.x,y:~~b.positionAbsolute.y})}),M({direction:E4[t.key],factor:t.shiftKey?4:1})}}},V=()=>{if(m||!A.current?.matches(`:focus-visible`))return;let{transform:t,width:n,height:r,autoPanOnNodeFocus:i,setCenter:a}=O.getState();i&&(C2(new Map([[e,y]]),{x:0,y:0,width:n,height:r},t,!0).length>0||a(y.position.x+N.width/2,y.position.y+N.height/2,{zoom:t[2]}))};return(0,U.jsx)(`div`,{className:o0([`react-flow__node`,`react-flow__node-${S}`,{[p]:w},y.className,{selected:y.selected,selectable:T,parent:x,draggable:w,dragging:j}]),ref:A,style:{zIndex:b.z,transform:`translate(${b.positionAbsolute.x}px,${b.positionAbsolute.y}px)`,pointerEvents:F?`all`:`none`,visibility:k?`visible`:`hidden`,...y.style,...P},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:I,onMouseMove:L,onMouseLeave:R,onContextMenu:z,onClick:ee,onDoubleClick:B,onKeyDown:D?te:void 0,tabIndex:D?0:void 0,onFocus:D?V:void 0,role:y.ariaRole??(D?`group`:void 0),"aria-roledescription":`node`,"aria-describedby":m?void 0:`${CDt}-${h}`,"aria-label":y.ariaLabel,...y.domAttributes,children:(0,U.jsx)(SOt,{value:e,children:(0,U.jsx)(C,{id:e,data:y.data,type:S,positionAbsoluteX:b.positionAbsolute.x,positionAbsoluteY:b.positionAbsolute.y,selected:y.selected??!1,selectable:T,draggable:w,deletable:y.deletable??!0,isConnectable:E,sourcePosition:y.sourcePosition,targetPosition:y.targetPosition,dragging:j,dragHandle:y.dragHandle,zIndex:b.z,parentId:y.parentId,...N})})})}var GOt=(0,H.memo)(WOt),KOt=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function qOt(e){let{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:i,onError:a}=f4(KOt,u4),o=BOt(e.onlyRenderVisibleElements),s=HOt();return(0,U.jsx)(`div`,{className:`react-flow__nodes`,style:x4,children:o.map(o=>(0,U.jsx)(GOt,{id:o,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:s,nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:i,nodeClickDistance:e.nodeClickDistance,onError:a},o))})}qOt.displayName=`NodeRenderer`;var JOt=(0,H.memo)(qOt);function YOt(e){return f4((0,H.useCallback)(t=>{if(!e)return t.edges.map(e=>e.id);let n=[];if(t.width&&t.height)for(let e of t.edges){let r=t.nodeLookup.get(e.source),i=t.nodeLookup.get(e.target);r&&i&&nEt({sourceNode:r,targetNode:i,width:t.width,height:t.height,transform:t.transform})&&n.push(e.id)}return n},[e]),u4)}var XOt=({color:e=`none`,strokeWidth:t=1})=>(0,U.jsx)(`polyline`,{className:`arrow`,style:{strokeWidth:t,...e&&{stroke:e}},strokeLinecap:`round`,fill:`none`,strokeLinejoin:`round`,points:`-5,-4 0,0 -5,4`}),ZOt=({color:e=`none`,strokeWidth:t=1})=>(0,U.jsx)(`polyline`,{className:`arrowclosed`,style:{strokeWidth:t,...e&&{stroke:e,fill:e}},strokeLinecap:`round`,strokeLinejoin:`round`,points:`-5,-4 0,0 -5,4 -5,-4`}),QOt={[v2.Arrow]:XOt,[v2.ArrowClosed]:ZOt};function $Ot(e){let t=p4();return(0,H.useMemo)(()=>Object.prototype.hasOwnProperty.call(QOt,e)?QOt[e]:(t.getState().onError?.(`009`,f2.error009(e)),null),[e])}var ekt=({id:e,type:t,color:n,width:r=12.5,height:i=12.5,markerUnits:a=`strokeWidth`,strokeWidth:o,orient:s=`auto-start-reverse`})=>{let c=$Ot(t);return c?(0,U.jsx)(`marker`,{className:`react-flow__arrowhead`,id:e,markerWidth:`${r}`,markerHeight:`${i}`,viewBox:`-10 -10 20 20`,markerUnits:a,orient:s,refX:`0`,refY:`0`,children:(0,U.jsx)(c,{color:n,strokeWidth:o})}):null},tkt=({defaultColor:e,rfId:t})=>{let n=f4(e=>e.edges),r=f4(e=>e.defaultEdgeOptions),i=(0,H.useMemo)(()=>gEt(n,{id:t,defaultColor:e,defaultMarkerStart:r?.markerStart,defaultMarkerEnd:r?.markerEnd}),[n,r,t,e]);return i.length?(0,U.jsx)(`svg`,{className:`react-flow__marker`,"aria-hidden":`true`,children:(0,U.jsx)(`defs`,{children:i.map(e=>(0,U.jsx)(ekt,{id:e.id,type:e.type,color:e.color,width:e.width,height:e.height,markerUnits:e.markerUnits,strokeWidth:e.strokeWidth,orient:e.orient},e.id))})}):null};tkt.displayName=`MarkerDefinitions`;var nkt=(0,H.memo)(tkt);function rkt({x:e,y:t,label:n,labelStyle:r,labelShowBg:i=!0,labelBgStyle:a,labelBgPadding:o=[2,4],labelBgBorderRadius:s=2,children:c,className:l,...u}){let[d,f]=(0,H.useState)({x:1,y:0,width:0,height:0}),p=o0([`react-flow__edge-textwrapper`,l]),m=(0,H.useRef)(null);return(0,H.useEffect)(()=>{if(m.current){let e=m.current.getBBox();f({x:e.x,y:e.y,width:e.width,height:e.height})}},[n]),n?(0,U.jsxs)(`g`,{transform:`translate(${e-d.width/2} ${t-d.height/2})`,className:p,visibility:d.width?`visible`:`hidden`,...u,children:[i&&(0,U.jsx)(`rect`,{width:d.width+2*o[0],x:-o[0],y:-o[1],height:d.height+2*o[1],className:`react-flow__edge-textbg`,style:a,rx:s,ry:s}),(0,U.jsx)(`text`,{className:`react-flow__edge-text`,y:d.height/2,dy:`0.3em`,ref:m,style:r,children:n}),c]}):null}rkt.displayName=`EdgeText`;var ikt=(0,H.memo)(rkt);function D4({path:e,labelX:t,labelY:n,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:o,labelBgPadding:s,labelBgBorderRadius:c,interactionWidth:l=20,...u}){return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{...u,d:e,fill:`none`,className:o0([`react-flow__edge-path`,u.className])}),l?(0,U.jsx)(`path`,{d:e,fill:`none`,strokeOpacity:0,strokeWidth:l,className:`react-flow__edge-interaction`}):null,r&&M2(t)&&M2(n)?(0,U.jsx)(ikt,{x:t,y:n,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:o,labelBgPadding:s,labelBgBorderRadius:c}):null]})}function akt({pos:e,x1:t,y1:n,x2:r,y2:i}){return e===y2.Left||e===y2.Right?[.5*(t+r),n]:[t,.5*(n+i)]}function okt({sourceX:e,sourceY:t,sourcePosition:n=y2.Bottom,targetX:r,targetY:i,targetPosition:a=y2.Top}){let[o,s]=akt({pos:n,x1:e,y1:t,x2:r,y2:i}),[c,l]=akt({pos:a,x1:r,y1:i,x2:e,y2:t}),[u,d,f,p]=ZTt({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:o,sourceControlY:s,targetControlX:c,targetControlY:l});return[`M${e},${t} C${o},${s} ${c},${l} ${r},${i}`,u,d,f,p]}function skt(e){return(0,H.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,sourcePosition:o,targetPosition:s,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:_})=>{let[v,y,b]=okt({sourceX:n,sourceY:r,sourcePosition:o,targetX:i,targetY:a,targetPosition:s});return(0,U.jsx)(D4,{id:e.isInternal?void 0:t,path:v,labelX:y,labelY:b,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:_})})}var ckt=skt({isInternal:!1}),lkt=skt({isInternal:!0});ckt.displayName=`SimpleBezierEdge`,lkt.displayName=`SimpleBezierEdgeInternal`;function ukt(e){return(0,H.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,sourcePosition:p=y2.Bottom,targetPosition:m=y2.Top,markerEnd:h,markerStart:g,pathOptions:_,interactionWidth:v})=>{let[y,b,x]=G2({sourceX:n,sourceY:r,sourcePosition:p,targetX:i,targetY:a,targetPosition:m,borderRadius:_?.borderRadius,offset:_?.offset,stepPosition:_?.stepPosition});return(0,U.jsx)(D4,{id:e.isInternal?void 0:t,path:y,labelX:b,labelY:x,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:h,markerStart:g,interactionWidth:v})})}var dkt=ukt({isInternal:!1}),fkt=ukt({isInternal:!0});dkt.displayName=`SmoothStepEdge`,fkt.displayName=`SmoothStepEdgeInternal`;function pkt(e){return(0,H.memo)(({id:t,...n})=>{let r=e.isInternal?void 0:t;return(0,U.jsx)(dkt,{...n,id:r,pathOptions:(0,H.useMemo)(()=>({borderRadius:0,offset:n.pathOptions?.offset}),[n.pathOptions?.offset])})})}var mkt=pkt({isInternal:!1}),hkt=pkt({isInternal:!0});mkt.displayName=`StepEdge`,hkt.displayName=`StepEdgeInternal`;function gkt(e){return(0,H.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:p,markerStart:m,interactionWidth:h})=>{let[g,_,v]=oEt({sourceX:n,sourceY:r,targetX:i,targetY:a});return(0,U.jsx)(D4,{id:e.isInternal?void 0:t,path:g,labelX:_,labelY:v,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:p,markerStart:m,interactionWidth:h})})}var _kt=gkt({isInternal:!1}),vkt=gkt({isInternal:!0});_kt.displayName=`StraightEdge`,vkt.displayName=`StraightEdgeInternal`;function ykt(e){return(0,H.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,sourcePosition:o=y2.Bottom,targetPosition:s=y2.Top,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,pathOptions:_,interactionWidth:v})=>{let[y,b,x]=$Tt({sourceX:n,sourceY:r,sourcePosition:o,targetX:i,targetY:a,targetPosition:s,curvature:_?.curvature});return(0,U.jsx)(D4,{id:e.isInternal?void 0:t,path:y,labelX:b,labelY:x,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:v})})}var bkt=ykt({isInternal:!1}),xkt=ykt({isInternal:!0});bkt.displayName=`BezierEdge`,xkt.displayName=`BezierEdgeInternal`;var Skt={default:xkt,straight:vkt,step:hkt,smoothstep:fkt,simplebezier:lkt},Ckt={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},wkt=(e,t,n)=>n===y2.Left?e-t:n===y2.Right?e+t:e,Tkt=(e,t,n)=>n===y2.Top?e-t:n===y2.Bottom?e+t:e,Ekt=`react-flow__edgeupdater`;function Dkt({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:i,onMouseEnter:a,onMouseOut:o,type:s}){return(0,U.jsx)(`circle`,{onMouseDown:i,onMouseEnter:a,onMouseOut:o,className:o0([Ekt,`${Ekt}-${s}`]),cx:wkt(t,r,e),cy:Tkt(n,r,e),r,stroke:`transparent`,fill:`transparent`})}function Okt({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:i,targetX:a,targetY:o,sourcePosition:s,targetPosition:c,onReconnect:l,onReconnectStart:u,onReconnectEnd:d,setReconnecting:f,setUpdateHover:p}){let m=p4(),h=(e,t)=>{if(e.button!==0)return;let{autoPanOnConnect:r,domNode:i,connectionMode:a,connectionRadius:o,lib:s,onConnectStart:c,cancelConnection:p,nodeLookup:h,rfId:g,panBy:_,updateConnection:v}=m.getState(),y=t.type===`target`;t4.onPointerDown(e.nativeEvent,{autoPanOnConnect:r,connectionMode:a,connectionRadius:o,domNode:i,handleId:t.id,nodeId:t.nodeId,nodeLookup:h,isTarget:y,edgeUpdaterType:t.type,lib:s,flowId:g,cancelConnection:p,panBy:_,isValidConnection:(...e)=>m.getState().isValidConnection?.(...e)??!0,onConnect:e=>l?.(n,e),onConnectStart:(r,i)=>{f(!0),u?.(e,n,t.type),c?.(r,i)},onConnectEnd:(...e)=>m.getState().onConnectEnd?.(...e),onReconnectEnd:(e,r)=>{f(!1),d?.(e,n,t.type,r)},updateConnection:v,getTransform:()=>m.getState().transform,getFromHandle:()=>m.getState().connection.fromHandle,dragThreshold:m.getState().connectionDragThreshold,handleDomNode:e.currentTarget})},g=e=>h(e,{nodeId:n.target,id:n.targetHandle??null,type:`target`}),_=e=>h(e,{nodeId:n.source,id:n.sourceHandle??null,type:`source`}),v=()=>p(!0),y=()=>p(!1);return(0,U.jsxs)(U.Fragment,{children:[(e===!0||e===`source`)&&(0,U.jsx)(Dkt,{position:s,centerX:r,centerY:i,radius:t,onMouseDown:g,onMouseEnter:v,onMouseOut:y,type:`source`}),(e===!0||e===`target`)&&(0,U.jsx)(Dkt,{position:c,centerX:a,centerY:o,radius:t,onMouseDown:_,onMouseEnter:v,onMouseOut:y,type:`target`})]})}function kkt({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:i,onDoubleClick:a,onContextMenu:o,onMouseEnter:s,onMouseMove:c,onMouseLeave:l,reconnectRadius:u,onReconnect:d,onReconnectStart:f,onReconnectEnd:p,rfId:m,edgeTypes:h,noPanClassName:g,onError:_,disableKeyboardA11y:v}){let y=f4(t=>t.edgeLookup.get(e)),b=f4(e=>e.defaultEdgeOptions);y=b?{...b,...y}:y;let x=y.type||`default`,S=h?.[x]||Skt[x];S===void 0&&(_?.(`011`,f2.error011(x)),x=`default`,S=h?.default||Skt.default);let C=!!(y.focusable||t&&y.focusable===void 0),w=d!==void 0&&(y.reconnectable||n&&y.reconnectable===void 0),T=!!(y.selectable||r&&y.selectable===void 0),E=(0,H.useRef)(null),[D,O]=(0,H.useState)(!1),[k,A]=(0,H.useState)(!1),j=p4(),{zIndex:M,sourceX:N,sourceY:P,targetX:F,targetY:I,sourcePosition:L,targetPosition:R}=f4((0,H.useCallback)(t=>{let n=t.nodeLookup.get(y.source),r=t.nodeLookup.get(y.target);if(!n||!r)return{zIndex:y.zIndex,...Ckt};let i=pEt({id:e,sourceNode:n,targetNode:r,sourceHandle:y.sourceHandle||null,targetHandle:y.targetHandle||null,connectionMode:t.connectionMode,onError:_});return{zIndex:tEt({selected:y.selected,zIndex:y.zIndex,sourceNode:n,targetNode:r,elevateOnSelect:t.elevateEdgesOnSelect,zIndexMode:t.zIndexMode}),...i||Ckt}},[y.source,y.target,y.sourceHandle,y.targetHandle,y.selected,y.zIndex]),u4),z=(0,H.useMemo)(()=>y.markerStart?`url('#${q2(y.markerStart,m)}')`:void 0,[y.markerStart,m]),B=(0,H.useMemo)(()=>y.markerEnd?`url('#${q2(y.markerEnd,m)}')`:void 0,[y.markerEnd,m]);if(y.hidden||N===null||P===null||F===null||I===null)return null;let ee=t=>{let{addSelectedEdges:n,unselectNodesAndEdges:r,multiSelectionActive:a}=j.getState();T&&(j.setState({nodesSelectionActive:!1}),y.selected&&a?(r({nodes:[],edges:[y]}),E.current?.blur()):n([e])),i&&i(t,y)},te=a?e=>{a(e,{...y})}:void 0,V=o?e=>{o(e,{...y})}:void 0,ne=s?e=>{s(e,{...y})}:void 0,re=c?e=>{c(e,{...y})}:void 0,ie=l?e=>{l(e,{...y})}:void 0;return(0,U.jsx)(`svg`,{style:{zIndex:M},children:(0,U.jsxs)(`g`,{className:o0([`react-flow__edge`,`react-flow__edge-${x}`,y.className,g,{selected:y.selected,animated:y.animated,inactive:!T&&!i,updating:D,selectable:T}]),onClick:ee,onDoubleClick:te,onContextMenu:V,onMouseEnter:ne,onMouseMove:re,onMouseLeave:ie,onKeyDown:C?t=>{if(!v&&bTt.includes(t.key)&&T){let{unselectNodesAndEdges:n,addSelectedEdges:r}=j.getState();t.key===`Escape`?(E.current?.blur(),n({edges:[y]})):r([e])}}:void 0,tabIndex:C?0:void 0,role:y.ariaRole??(C?`group`:`img`),"aria-roledescription":`edge`,"data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":y.ariaLabel===null?void 0:y.ariaLabel||`Edge from ${y.source} to ${y.target}`,"aria-describedby":C?`${wDt}-${m}`:void 0,ref:E,...y.domAttributes,children:[!k&&(0,U.jsx)(S,{id:e,source:y.source,target:y.target,type:y.type,selected:y.selected,animated:y.animated,selectable:T,deletable:y.deletable??!0,label:y.label,labelStyle:y.labelStyle,labelShowBg:y.labelShowBg,labelBgStyle:y.labelBgStyle,labelBgPadding:y.labelBgPadding,labelBgBorderRadius:y.labelBgBorderRadius,sourceX:N,sourceY:P,targetX:F,targetY:I,sourcePosition:L,targetPosition:R,data:y.data,style:y.style,sourceHandleId:y.sourceHandle,targetHandleId:y.targetHandle,markerStart:z,markerEnd:B,pathOptions:`pathOptions`in y?y.pathOptions:void 0,interactionWidth:y.interactionWidth}),w&&(0,U.jsx)(Okt,{edge:y,isReconnectable:w,reconnectRadius:u,onReconnect:d,onReconnectStart:f,onReconnectEnd:p,sourceX:N,sourceY:P,targetX:F,targetY:I,sourcePosition:L,targetPosition:R,setUpdateHover:O,setReconnecting:A})]})})}var Akt=(0,H.memo)(kkt),jkt=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function Mkt({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:i,onReconnect:a,onEdgeContextMenu:o,onEdgeMouseEnter:s,onEdgeMouseMove:c,onEdgeMouseLeave:l,onEdgeClick:u,reconnectRadius:d,onEdgeDoubleClick:f,onReconnectStart:p,onReconnectEnd:m,disableKeyboardA11y:h}){let{edgesFocusable:g,edgesReconnectable:_,elementsSelectable:v,onError:y}=f4(jkt,u4),b=YOt(t);return(0,U.jsxs)(`div`,{className:`react-flow__edges`,children:[(0,U.jsx)(nkt,{defaultColor:e,rfId:n}),b.map(e=>(0,U.jsx)(Akt,{id:e,edgesFocusable:g,edgesReconnectable:_,elementsSelectable:v,noPanClassName:i,onReconnect:a,onContextMenu:o,onMouseEnter:s,onMouseMove:c,onMouseLeave:l,onClick:u,reconnectRadius:d,onDoubleClick:f,onReconnectStart:p,onReconnectEnd:m,rfId:n,onError:y,edgeTypes:r,disableKeyboardA11y:h},e))]})}Mkt.displayName=`EdgeRenderer`;var Nkt=(0,H.memo)(Mkt),Pkt=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function Fkt({children:e}){return(0,U.jsx)(`div`,{className:`react-flow__viewport xyflow__viewport react-flow__container`,style:{transform:f4(Pkt)},children:e})}function Ikt(e){let t=b4(),n=(0,H.useRef)(!1);(0,H.useEffect)(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}var Lkt=e=>e.panZoom?.syncViewport;function Rkt(e){let t=f4(Lkt),n=p4();return(0,H.useEffect)(()=>{e&&(t?.(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function zkt(e){return e.connection.inProgress?{...e.connection,to:P2(e.connection.to,e.transform)}:{...e.connection}}function Bkt(e){return e?t=>e(zkt(t)):zkt}function Vkt(e){return f4(Bkt(e),u4)}var Hkt=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function Ukt({containerStyle:e,style:t,type:n,component:r}){let{nodesConnectable:i,width:a,height:o,isValid:s,inProgress:c}=f4(Hkt,u4);return a&&i&&c?(0,U.jsx)(`svg`,{style:e,width:a,height:o,className:`react-flow__connectionline react-flow__container`,children:(0,U.jsx)(`g`,{className:o0([`react-flow__connection`,wTt(s)]),children:(0,U.jsx)(Wkt,{style:t,type:n,CustomComponent:r,isValid:s})})}):null}var Wkt=({style:e,type:t=_2.Bezier,CustomComponent:n,isValid:r})=>{let{inProgress:i,from:a,fromNode:o,fromHandle:s,fromPosition:c,to:l,toNode:u,toHandle:d,toPosition:f,pointer:p}=Vkt();if(!i)return;if(n)return(0,U.jsx)(n,{connectionLineType:t,connectionLineStyle:e,fromNode:o,fromHandle:s,fromX:a.x,fromY:a.y,toX:l.x,toY:l.y,fromPosition:c,toPosition:f,connectionStatus:wTt(r),toNode:u,toHandle:d,pointer:p});let m=``,h={sourceX:a.x,sourceY:a.y,sourcePosition:c,targetX:l.x,targetY:l.y,targetPosition:f};switch(t){case _2.Bezier:[m]=$Tt(h);break;case _2.SimpleBezier:[m]=okt(h);break;case _2.Step:[m]=G2({...h,borderRadius:0});break;case _2.SmoothStep:[m]=G2(h);break;default:[m]=oEt(h)}return(0,U.jsx)(`path`,{d:m,fill:`none`,className:`react-flow__connection-path`,style:e})};Wkt.displayName=`ConnectionLine`;var Gkt={};function Kkt(e=Gkt){(0,H.useRef)(e),p4(),(0,H.useEffect)(()=>{},[e])}function qkt(){p4(),(0,H.useRef)(!1),(0,H.useEffect)(()=>{},[])}function Jkt({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:i,onNodeDoubleClick:a,onEdgeDoubleClick:o,onNodeMouseEnter:s,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,onSelectionContextMenu:d,onSelectionStart:f,onSelectionEnd:p,connectionLineType:m,connectionLineStyle:h,connectionLineComponent:g,connectionLineContainerStyle:_,selectionKeyCode:v,selectionOnDrag:y,selectionMode:b,multiSelectionKeyCode:x,panActivationKeyCode:S,zoomActivationKeyCode:C,deleteKeyCode:w,onlyRenderVisibleElements:T,elementsSelectable:E,defaultViewport:D,translateExtent:O,minZoom:k,maxZoom:A,preventScrolling:j,defaultMarkerColor:M,zoomOnScroll:N,zoomOnPinch:P,panOnScroll:F,panOnScrollSpeed:I,panOnScrollMode:L,zoomOnDoubleClick:R,panOnDrag:z,onPaneClick:B,onPaneMouseEnter:ee,onPaneMouseMove:te,onPaneMouseLeave:V,onPaneScroll:ne,onPaneContextMenu:re,paneClickDistance:ie,nodeClickDistance:ae,onEdgeContextMenu:oe,onEdgeMouseEnter:se,onEdgeMouseMove:ce,onEdgeMouseLeave:le,reconnectRadius:ue,onReconnect:de,onReconnectStart:fe,onReconnectEnd:pe,noDragClassName:me,noWheelClassName:he,noPanClassName:ge,disableKeyboardA11y:_e,nodeExtent:ve,rfId:ye,viewport:be,onViewportChange:xe}){return Kkt(e),Kkt(t),qkt(),Ikt(n),Rkt(be),(0,U.jsx)(ROt,{onPaneClick:B,onPaneMouseEnter:ee,onPaneMouseMove:te,onPaneMouseLeave:V,onPaneContextMenu:re,onPaneScroll:ne,paneClickDistance:ie,deleteKeyCode:w,selectionKeyCode:v,selectionOnDrag:y,selectionMode:b,onSelectionStart:f,onSelectionEnd:p,multiSelectionKeyCode:x,panActivationKeyCode:S,zoomActivationKeyCode:C,elementsSelectable:E,zoomOnScroll:N,zoomOnPinch:P,zoomOnDoubleClick:R,panOnScroll:F,panOnScrollSpeed:I,panOnScrollMode:L,panOnDrag:z,defaultViewport:D,translateExtent:O,minZoom:k,maxZoom:A,onSelectionContextMenu:d,preventScrolling:j,noDragClassName:me,noWheelClassName:he,noPanClassName:ge,disableKeyboardA11y:_e,onViewportChange:xe,isControlledViewport:!!be,children:(0,U.jsxs)(Fkt,{children:[(0,U.jsx)(Nkt,{edgeTypes:t,onEdgeClick:i,onEdgeDoubleClick:o,onReconnect:de,onReconnectStart:fe,onReconnectEnd:pe,onlyRenderVisibleElements:T,onEdgeContextMenu:oe,onEdgeMouseEnter:se,onEdgeMouseMove:ce,onEdgeMouseLeave:le,reconnectRadius:ue,defaultMarkerColor:M,noPanClassName:ge,disableKeyboardA11y:_e,rfId:ye}),(0,U.jsx)(Ukt,{style:h,type:m,component:g,containerStyle:_}),(0,U.jsx)(`div`,{className:`react-flow__edgelabel-renderer`}),(0,U.jsx)(JOt,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:a,onNodeMouseEnter:s,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,nodeClickDistance:ae,onlyRenderVisibleElements:T,noPanClassName:ge,noDragClassName:me,disableKeyboardA11y:_e,nodeExtent:ve,rfId:ye}),(0,U.jsx)(`div`,{className:`react-flow__viewport-portal`})]})})}Jkt.displayName=`GraphView`;var Ykt=(0,H.memo)(Jkt),Xkt=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c=.5,maxZoom:l=2,nodeOrigin:u,nodeExtent:d,zIndexMode:f=`basic`}={})=>{let p=new Map,m=new Map,h=new Map,g=new Map,_=r??t??[],v=n??e??[],y=u??[0,0],b=d??p2;OEt(h,g,_);let{nodesInitialized:x}=Z2(v,p,m,{nodeOrigin:y,nodeExtent:b,zIndexMode:f}),S=[0,0,1];if(o&&i&&a){let{x:e,y:t,zoom:n}=L2(S2(p,{filter:e=>!!((e.width||e.initialWidth)&&(e.height||e.initialHeight))}),i,a,c,l,s?.padding??.1);S=[e,t,n]}return{rfId:`1`,width:i??0,height:a??0,transform:S,nodes:v,nodesInitialized:x,nodeLookup:p,parentLookup:m,edges:_,edgeLookup:g,connectionLookup:h,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:c,maxZoom:l,translateExtent:p2,nodeExtent:b,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:m2.Strict,domNode:null,paneDragging:!1,noPanClassName:`nopan`,nodeOrigin:y,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:o??!1,fitViewOptions:s,fitViewResolver:null,connection:{...STt},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:``,autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:RTt,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:`react`,debug:!1,ariaLabelConfig:xTt,zIndexMode:f,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},Zkt=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c,maxZoom:l,nodeOrigin:u,nodeExtent:d,zIndexMode:f})=>vDt((p,m)=>{async function h(){let{nodeLookup:e,panZoom:t,fitViewOptions:n,fitViewResolver:r,width:i,height:a,minZoom:o,maxZoom:s}=m();t&&(await ATt({nodes:e,width:i,height:a,panZoom:t,minZoom:o,maxZoom:s},n),r?.resolve(!0),p({fitViewResolver:null}))}return{...Xkt({nodes:e,edges:t,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c,maxZoom:l,nodeOrigin:u,nodeExtent:d,defaultNodes:n,defaultEdges:r,zIndexMode:f}),setNodes:e=>{let{nodeLookup:t,parentLookup:n,nodeOrigin:r,elevateNodesOnSelect:i,fitViewQueued:a,zIndexMode:o,nodesSelectionActive:s}=m(),{nodesInitialized:c,hasSelectedNodes:l}=Z2(e,t,n,{nodeOrigin:r,nodeExtent:d,elevateNodesOnSelect:i,checkEquality:!0,zIndexMode:o}),u=s&&l;a&&c?(h(),p({nodes:e,nodesInitialized:c,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:u})):p({nodes:e,nodesInitialized:c,nodesSelectionActive:u})},setEdges:e=>{let{connectionLookup:t,edgeLookup:n}=m();OEt(t,n,e),p({edges:e})},setDefaultNodesAndEdges:(e,t)=>{if(e){let{setNodes:t}=m();t(e),p({hasDefaultNodes:!0})}if(t){let{setEdges:e}=m();e(t),p({hasDefaultEdges:!0})}},updateNodeInternals:e=>{let{triggerNodeChanges:t,nodeLookup:n,parentLookup:r,domNode:i,nodeOrigin:a,nodeExtent:o,debug:s,fitViewQueued:c,zIndexMode:l}=m(),{changes:u,updatedInternals:d}=TEt(e,n,r,i,a,o,l);d&&(bEt(n,r,{nodeOrigin:a,nodeExtent:o,zIndexMode:l}),c?(h(),p({fitViewQueued:!1,fitViewOptions:void 0})):p({}),u?.length>0&&(s&&console.log(`React Flow: trigger node changes`,u),t?.(u)))},updateNodePositions:(e,t=!1)=>{let n=[],r=[],{nodeLookup:i,triggerNodeChanges:a,connection:o,updateConnection:s,onNodesChangeMiddlewareMap:c}=m();for(let[a,c]of e){let e=i.get(a),l=!!(e?.expandParent&&e?.parentId&&c?.position),u={id:a,type:`position`,position:l?{x:Math.max(0,c.position.x),y:Math.max(0,c.position.y)}:c.position,dragging:t};if(e&&o.inProgress&&o.fromNode.id===e.id){let t=K2(e,o.fromHandle,y2.Left,!0);s({...o,from:t})}l&&e.parentId&&n.push({id:a,parentId:e.parentId,rect:{...c.internals.positionAbsolute,width:c.measured.width??0,height:c.measured.height??0}}),r.push(u)}if(n.length>0){let{parentLookup:e,nodeOrigin:t}=m(),a=$2(n,i,e,t);r.push(...a)}for(let e of c.values())r=e(r);a(r)},triggerNodeChanges:e=>{let{onNodesChange:t,setNodes:n,nodes:r,hasDefaultNodes:i,debug:a}=m();e?.length&&(i&&n(XDt(e,r)),a&&console.log(`React Flow: trigger node changes`,e),t?.(e))},triggerEdgeChanges:e=>{let{onEdgesChange:t,setEdges:n,edges:r,hasDefaultEdges:i,debug:a}=m();e?.length&&(i&&n(ZDt(e,r)),a&&console.log(`React Flow: trigger edge changes`,e),t?.(e))},addSelectedNodes:e=>{let{multiSelectionActive:t,edgeLookup:n,nodeLookup:r,triggerNodeChanges:i,triggerEdgeChanges:a}=m();if(t){i(e.map(e=>v4(e,!0)));return}i(y4(r,new Set([...e]),!0)),a(y4(n))},addSelectedEdges:e=>{let{multiSelectionActive:t,edgeLookup:n,nodeLookup:r,triggerNodeChanges:i,triggerEdgeChanges:a}=m();if(t){a(e.map(e=>v4(e,!0)));return}a(y4(n,new Set([...e]))),i(y4(r,new Set,!0))},unselectNodesAndEdges:({nodes:e,edges:t}={})=>{let{edges:n,nodes:r,nodeLookup:i,triggerNodeChanges:a,triggerEdgeChanges:o}=m(),s=e||r,c=t||n,l=[];for(let e of s){if(!e.selected)continue;let t=i.get(e.id);t&&(t.selected=!1),l.push(v4(e.id,!1))}let u=[];for(let e of c)e.selected&&u.push(v4(e.id,!1));a(l),o(u)},setMinZoom:e=>{let{panZoom:t,maxZoom:n}=m();t?.setScaleExtent([e,n]),p({minZoom:e})},setMaxZoom:e=>{let{panZoom:t,minZoom:n}=m();t?.setScaleExtent([n,e]),p({maxZoom:e})},setTranslateExtent:e=>{m().panZoom?.setTranslateExtent(e),p({translateExtent:e})},resetSelectedElements:()=>{let{edges:e,nodes:t,triggerNodeChanges:n,triggerEdgeChanges:r,elementsSelectable:i}=m();if(!i)return;let a=t.reduce((e,t)=>t.selected?[...e,v4(t.id,!1)]:e,[]),o=e.reduce((e,t)=>t.selected?[...e,v4(t.id,!1)]:e,[]);n(a),r(o)},setNodeExtent:e=>{let{nodes:t,nodeLookup:n,parentLookup:r,nodeOrigin:i,elevateNodesOnSelect:a,nodeExtent:o,zIndexMode:s}=m();e[0][0]===o[0][0]&&e[0][1]===o[0][1]&&e[1][0]===o[1][0]&&e[1][1]===o[1][1]||(Z2(t,n,r,{nodeOrigin:i,nodeExtent:e,elevateNodesOnSelect:a,checkEquality:!1,zIndexMode:s}),p({nodeExtent:e}))},panBy:e=>{let{transform:t,width:n,height:r,panZoom:i,translateExtent:a}=m();return EEt({delta:e,panZoom:i,transform:t,translateExtent:a,width:n,height:r})},setCenter:async(e,t,n)=>{let{width:r,height:i,maxZoom:a,panZoom:o}=m();if(!o)return Promise.resolve(!1);let s=n?.zoom===void 0?a:n.zoom;return await o.setViewport({x:r/2-e*s,y:i/2-t*s,zoom:s},{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{p({connection:{...STt}})},updateConnection:e=>{p({connection:e})},reset:()=>p({...Xkt()})}},Object.is);function Qkt({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:i,initialHeight:a,initialMinZoom:o,initialMaxZoom:s,initialFitViewOptions:c,fitView:l,nodeOrigin:u,nodeExtent:d,zIndexMode:f,children:p}){let[m]=(0,H.useState)(()=>Zkt({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:l,minZoom:o,maxZoom:s,fitViewOptions:c,nodeOrigin:u,nodeExtent:d,zIndexMode:f}));return(0,U.jsx)(yDt,{value:m,children:(0,U.jsx)(oOt,{children:p})})}function $kt({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:i,width:a,height:o,fitView:s,fitViewOptions:c,minZoom:l,maxZoom:u,nodeOrigin:d,nodeExtent:f,zIndexMode:p}){return(0,H.useContext)(d4)?(0,U.jsx)(U.Fragment,{children:e}):(0,U.jsx)(Qkt,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:i,initialWidth:a,initialHeight:o,fitView:s,initialFitViewOptions:c,initialMinZoom:l,initialMaxZoom:u,nodeOrigin:d,nodeExtent:f,zIndexMode:p,children:e})}var eAt={width:`100%`,height:`100%`,overflow:`hidden`,position:`relative`,zIndex:0};function tAt({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:i,nodeTypes:a,edgeTypes:o,onNodeClick:s,onEdgeClick:c,onInit:l,onMove:u,onMoveStart:d,onMoveEnd:f,onConnect:p,onConnectStart:m,onConnectEnd:h,onClickConnectStart:g,onClickConnectEnd:_,onNodeMouseEnter:v,onNodeMouseMove:y,onNodeMouseLeave:b,onNodeContextMenu:x,onNodeDoubleClick:S,onNodeDragStart:C,onNodeDrag:w,onNodeDragStop:T,onNodesDelete:E,onEdgesDelete:D,onDelete:O,onSelectionChange:k,onSelectionDragStart:A,onSelectionDrag:j,onSelectionDragStop:M,onSelectionContextMenu:N,onSelectionStart:P,onSelectionEnd:F,onBeforeDelete:I,connectionMode:L,connectionLineType:R=_2.Bezier,connectionLineStyle:z,connectionLineComponent:B,connectionLineContainerStyle:ee,deleteKeyCode:te=`Backspace`,selectionKeyCode:V=`Shift`,selectionOnDrag:ne=!1,selectionMode:re=g2.Full,panActivationKeyCode:ie=`Space`,multiSelectionKeyCode:ae=R2()?`Meta`:`Control`,zoomActivationKeyCode:oe=R2()?`Meta`:`Control`,snapToGrid:se,snapGrid:ce,onlyRenderVisibleElements:le=!1,selectNodesOnDrag:ue,nodesDraggable:de,autoPanOnNodeFocus:fe,nodesConnectable:pe,nodesFocusable:me,nodeOrigin:he=IDt,edgesFocusable:ge,edgesReconnectable:_e,elementsSelectable:ve=!0,defaultViewport:ye=LDt,minZoom:be=.5,maxZoom:xe=2,translateExtent:Se=p2,preventScrolling:Ce=!0,nodeExtent:we,defaultMarkerColor:Te=`#b1b1b7`,zoomOnScroll:Ee=!0,zoomOnPinch:De=!0,panOnScroll:Oe=!1,panOnScrollSpeed:ke=.5,panOnScrollMode:Ae=h2.Free,zoomOnDoubleClick:je=!0,panOnDrag:Me=!0,onPaneClick:Ne,onPaneMouseEnter:Pe,onPaneMouseMove:Fe,onPaneMouseLeave:Ie,onPaneScroll:Le,onPaneContextMenu:Re,paneClickDistance:ze=1,nodeClickDistance:Be=0,children:Ve,onReconnect:He,onReconnectStart:Ue,onReconnectEnd:We,onEdgeContextMenu:Ge,onEdgeDoubleClick:Ke,onEdgeMouseEnter:qe,onEdgeMouseMove:Je,onEdgeMouseLeave:Ye,reconnectRadius:Xe=10,onNodesChange:Ze,onEdgesChange:Qe,noDragClassName:$e=`nodrag`,noWheelClassName:et=`nowheel`,noPanClassName:tt=`nopan`,fitView:nt,fitViewOptions:rt,connectOnClick:it,attributionPosition:at,proOptions:ot,defaultEdgeOptions:st,elevateNodesOnSelect:ct=!0,elevateEdgesOnSelect:lt=!1,disableKeyboardA11y:ut=!1,autoPanOnConnect:dt,autoPanOnNodeDrag:ft,autoPanSpeed:pt,connectionRadius:mt,isValidConnection:ht,onError:gt,style:_t,id:vt,nodeDragThreshold:yt,connectionDragThreshold:bt,viewport:xt,onViewportChange:St,width:Ct,height:wt,colorMode:Tt=`light`,debug:Et,onScroll:Dt,ariaLabelConfig:Ot,zIndexMode:kt=`basic`,...At},jt){let Mt=vt||`1`,Nt=UDt(Tt),Pt=(0,H.useCallback)(e=>{e.currentTarget.scrollTo({top:0,left:0,behavior:`instant`}),Dt?.(e)},[Dt]);return(0,U.jsx)(`div`,{"data-testid":`rf__wrapper`,...At,onScroll:Pt,style:{..._t,...eAt},ref:jt,className:o0([`react-flow`,i,Nt]),id:vt,role:`application`,children:(0,U.jsxs)($kt,{nodes:e,edges:t,width:Ct,height:wt,fitView:nt,fitViewOptions:rt,minZoom:be,maxZoom:xe,nodeOrigin:he,nodeExtent:we,zIndexMode:kt,children:[(0,U.jsx)(VDt,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:p,onConnectStart:m,onConnectEnd:h,onClickConnectStart:g,onClickConnectEnd:_,nodesDraggable:de,autoPanOnNodeFocus:fe,nodesConnectable:pe,nodesFocusable:me,edgesFocusable:ge,edgesReconnectable:_e,elementsSelectable:ve,elevateNodesOnSelect:ct,elevateEdgesOnSelect:lt,minZoom:be,maxZoom:xe,nodeExtent:we,onNodesChange:Ze,onEdgesChange:Qe,snapToGrid:se,snapGrid:ce,connectionMode:L,translateExtent:Se,connectOnClick:it,defaultEdgeOptions:st,fitView:nt,fitViewOptions:rt,onNodesDelete:E,onEdgesDelete:D,onDelete:O,onNodeDragStart:C,onNodeDrag:w,onNodeDragStop:T,onSelectionDrag:j,onSelectionDragStart:A,onSelectionDragStop:M,onMove:u,onMoveStart:d,onMoveEnd:f,noPanClassName:tt,nodeOrigin:he,rfId:Mt,autoPanOnConnect:dt,autoPanOnNodeDrag:ft,autoPanSpeed:pt,onError:gt,connectionRadius:mt,isValidConnection:ht,selectNodesOnDrag:ue,nodeDragThreshold:yt,connectionDragThreshold:bt,onBeforeDelete:I,debug:Et,ariaLabelConfig:Ot,zIndexMode:kt}),(0,U.jsx)(Ykt,{onInit:l,onNodeClick:s,onEdgeClick:c,onNodeMouseEnter:v,onNodeMouseMove:y,onNodeMouseLeave:b,onNodeContextMenu:x,onNodeDoubleClick:S,nodeTypes:a,edgeTypes:o,connectionLineType:R,connectionLineStyle:z,connectionLineComponent:B,connectionLineContainerStyle:ee,selectionKeyCode:V,selectionOnDrag:ne,selectionMode:re,deleteKeyCode:te,multiSelectionKeyCode:ae,panActivationKeyCode:ie,zoomActivationKeyCode:oe,onlyRenderVisibleElements:le,defaultViewport:ye,translateExtent:Se,minZoom:be,maxZoom:xe,preventScrolling:Ce,zoomOnScroll:Ee,zoomOnPinch:De,zoomOnDoubleClick:je,panOnScroll:Oe,panOnScrollSpeed:ke,panOnScrollMode:Ae,panOnDrag:Me,onPaneClick:Ne,onPaneMouseEnter:Pe,onPaneMouseMove:Fe,onPaneMouseLeave:Ie,onPaneScroll:Le,onPaneContextMenu:Re,paneClickDistance:ze,nodeClickDistance:Be,onSelectionContextMenu:N,onSelectionStart:P,onSelectionEnd:F,onReconnect:He,onReconnectStart:Ue,onReconnectEnd:We,onEdgeContextMenu:Ge,onEdgeDoubleClick:Ke,onEdgeMouseEnter:qe,onEdgeMouseMove:Je,onEdgeMouseLeave:Ye,reconnectRadius:Xe,defaultMarkerColor:Te,noDragClassName:$e,noWheelClassName:et,noPanClassName:tt,rfId:Mt,disableKeyboardA11y:ut,nodeExtent:we,viewport:xt,onViewportChange:St}),(0,U.jsx)(FDt,{onSelectionChange:k}),Ve,(0,U.jsx)(ADt,{proOptions:ot,position:at}),(0,U.jsx)(kDt,{rfId:Mt,disableKeyboardA11y:ut})]})})}var nAt=nOt(tAt);f2.error014();function rAt({dimensions:e,lineWidth:t,variant:n,className:r}){return(0,U.jsx)(`path`,{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:o0([`react-flow__background-pattern`,n,r])})}function iAt({radius:e,className:t}){return(0,U.jsx)(`circle`,{cx:e,cy:e,r:e,className:o0([`react-flow__background-pattern`,`dots`,t])})}var O4;(function(e){e.Lines=`lines`,e.Dots=`dots`,e.Cross=`cross`})(O4||={});var aAt={[O4.Dots]:1,[O4.Lines]:1,[O4.Cross]:6},oAt=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function sAt({id:e,variant:t=O4.Dots,gap:n=20,size:r,lineWidth:i=1,offset:a=0,color:o,bgColor:s,style:c,className:l,patternClassName:u}){let d=(0,H.useRef)(null),{transform:f,patternId:p}=f4(oAt,u4),m=r||aAt[t],h=t===O4.Dots,g=t===O4.Cross,_=Array.isArray(n)?n:[n,n],v=[_[0]*f[2]||1,_[1]*f[2]||1],y=m*f[2],b=Array.isArray(a)?a:[a,a],x=g?[y,y]:v,S=[b[0]*f[2]||1+x[0]/2,b[1]*f[2]||1+x[1]/2],C=`${p}${e||``}`;return(0,U.jsxs)(`svg`,{className:o0([`react-flow__background`,l]),style:{...c,...x4,"--xy-background-color-props":s,"--xy-background-pattern-color-props":o},ref:d,"data-testid":`rf__background`,children:[(0,U.jsx)(`pattern`,{id:C,x:f[0]%v[0],y:f[1]%v[1],width:v[0],height:v[1],patternUnits:`userSpaceOnUse`,patternTransform:`translate(-${S[0]},-${S[1]})`,children:h?(0,U.jsx)(iAt,{radius:y/2,className:u}):(0,U.jsx)(rAt,{dimensions:x,lineWidth:i,variant:t,className:u})}),(0,U.jsx)(`rect`,{x:`0`,y:`0`,width:`100%`,height:`100%`,fill:`url(#${C})`})]})}sAt.displayName=`Background`;var cAt=(0,H.memo)(sAt);function lAt(){return(0,U.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 32`,children:(0,U.jsx)(`path`,{d:`M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z`})})}function uAt(){return(0,U.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 5`,children:(0,U.jsx)(`path`,{d:`M0 0h32v4.2H0z`})})}function dAt(){return(0,U.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 30`,children:(0,U.jsx)(`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 fAt(){return(0,U.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 25 32`,children:(0,U.jsx)(`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 pAt(){return(0,U.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 25 32`,children:(0,U.jsx)(`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`})})}function k4({children:e,className:t,...n}){return(0,U.jsx)(`button`,{type:`button`,className:o0([`react-flow__controls-button`,t]),...n,children:e})}var mAt=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function hAt({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:i,onZoomIn:a,onZoomOut:o,onFitView:s,onInteractiveChange:c,className:l,children:u,position:d=`bottom-left`,orientation:f=`vertical`,"aria-label":p}){let m=p4(),{isInteractive:h,minZoomReached:g,maxZoomReached:_,ariaLabelConfig:v}=f4(mAt,u4),{zoomIn:y,zoomOut:b,fitView:x}=b4(),S=()=>{y(),a?.()},C=()=>{b(),o?.()},w=()=>{x(i),s?.()},T=()=>{m.setState({nodesDraggable:!h,nodesConnectable:!h,elementsSelectable:!h}),c?.(!h)};return(0,U.jsxs)(m4,{className:o0([`react-flow__controls`,f===`horizontal`?`horizontal`:`vertical`,l]),position:d,style:e,"data-testid":`rf__controls`,"aria-label":p??v[`controls.ariaLabel`],children:[t&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(k4,{onClick:S,className:`react-flow__controls-zoomin`,title:v[`controls.zoomIn.ariaLabel`],"aria-label":v[`controls.zoomIn.ariaLabel`],disabled:_,children:(0,U.jsx)(lAt,{})}),(0,U.jsx)(k4,{onClick:C,className:`react-flow__controls-zoomout`,title:v[`controls.zoomOut.ariaLabel`],"aria-label":v[`controls.zoomOut.ariaLabel`],disabled:g,children:(0,U.jsx)(uAt,{})})]}),n&&(0,U.jsx)(k4,{className:`react-flow__controls-fitview`,onClick:w,title:v[`controls.fitView.ariaLabel`],"aria-label":v[`controls.fitView.ariaLabel`],children:(0,U.jsx)(dAt,{})}),r&&(0,U.jsx)(k4,{className:`react-flow__controls-interactive`,onClick:T,title:v[`controls.interactive.ariaLabel`],"aria-label":v[`controls.interactive.ariaLabel`],children:h?(0,U.jsx)(pAt,{}):(0,U.jsx)(fAt,{})}),u]})}hAt.displayName=`Controls`,(0,H.memo)(hAt);function gAt({id:e,x:t,y:n,width:r,height:i,style:a,color:o,strokeColor:s,strokeWidth:c,className:l,borderRadius:u,shapeRendering:d,selected:f,onClick:p}){let{background:m,backgroundColor:h}=a||{},g=o||m||h;return(0,U.jsx)(`rect`,{className:o0([`react-flow__minimap-node`,{selected:f},l]),x:t,y:n,rx:u,ry:u,width:r,height:i,style:{fill:g,stroke:s,strokeWidth:c},shapeRendering:d,onClick:p?t=>p(t,e):void 0})}var _At=(0,H.memo)(gAt),vAt=e=>e.nodes.map(e=>e.id),A4=e=>e instanceof Function?e:()=>e;function yAt({nodeStrokeColor:e,nodeColor:t,nodeClassName:n=``,nodeBorderRadius:r=5,nodeStrokeWidth:i,nodeComponent:a=_At,onClick:o}){let s=f4(vAt,u4),c=A4(t),l=A4(e),u=A4(n),d=typeof window>`u`||window.chrome?`crispEdges`:`geometricPrecision`;return(0,U.jsx)(U.Fragment,{children:s.map(e=>(0,U.jsx)(xAt,{id:e,nodeColorFunc:c,nodeStrokeColorFunc:l,nodeClassNameFunc:u,nodeBorderRadius:r,nodeStrokeWidth:i,NodeComponent:a,onClick:o,shapeRendering:d},e))})}function bAt({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:i,nodeStrokeWidth:a,shapeRendering:o,NodeComponent:s,onClick:c}){let{node:l,x:u,y:d,width:f,height:p}=f4(t=>{let n=t.nodeLookup.get(e);if(!n)return{node:void 0,x:0,y:0,width:0,height:0};let r=n.internals.userNode,{x:i,y:a}=n.internals.positionAbsolute,{width:o,height:s}=B2(r);return{node:r,x:i,y:a,width:o,height:s}},u4);return!l||l.hidden||!VTt(l)?null:(0,U.jsx)(s,{x:u,y:d,width:f,height:p,style:l.style,selected:!!l.selected,className:r(l),color:t(l),borderRadius:i,strokeColor:n(l),strokeWidth:a,shapeRendering:o,onClick:c,id:l.id})}var xAt=(0,H.memo)(bAt),SAt=(0,H.memo)(yAt),CAt=200,wAt=150,TAt=e=>!e.hidden,EAt=e=>{let t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:t,boundingRect:e.nodeLookup.size>0?ITt(S2(e.nodeLookup,{filter:TAt}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},DAt=`react-flow__minimap-desc`;function OAt({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:i=``,nodeBorderRadius:a=5,nodeStrokeWidth:o,nodeComponent:s,bgColor:c,maskColor:l,maskStrokeColor:u,maskStrokeWidth:d,position:f=`bottom-right`,onClick:p,onNodeClick:m,pannable:h=!1,zoomable:g=!1,ariaLabel:_,inversePan:v,zoomStep:y=1,offsetScale:b=5}){let x=p4(),S=(0,H.useRef)(null),{boundingRect:C,viewBB:w,rfId:T,panZoom:E,translateExtent:D,flowWidth:O,flowHeight:k,ariaLabelConfig:A}=f4(EAt,u4),j=e?.width??CAt,M=e?.height??wAt,N=C.width/j,P=C.height/M,F=Math.max(N,P),I=F*j,L=F*M,R=b*F,z=C.x-(I-C.width)/2-R,B=C.y-(L-C.height)/2-R,ee=I+R*2,te=L+R*2,V=`${DAt}-${T}`,ne=(0,H.useRef)(0),re=(0,H.useRef)();ne.current=F,(0,H.useEffect)(()=>{if(S.current&&E)return re.current=UEt({domNode:S.current,panZoom:E,getTransform:()=>x.getState().transform,getViewScale:()=>ne.current}),()=>{re.current?.destroy()}},[E]),(0,H.useEffect)(()=>{re.current?.update({translateExtent:D,width:O,height:k,inversePan:v,pannable:h,zoomStep:y,zoomable:g})},[h,g,v,y,D,O,k]);let ie=p?e=>{let[t,n]=re.current?.pointer(e)||[0,0];p(e,{x:t,y:n})}:void 0,ae=m?(0,H.useCallback)((e,t)=>{let n=x.getState().nodeLookup.get(t).internals.userNode;m(e,n)},[]):void 0,oe=_??A[`minimap.ariaLabel`];return(0,U.jsx)(m4,{position:f,style:{...e,"--xy-minimap-background-color-props":typeof c==`string`?c:void 0,"--xy-minimap-mask-background-color-props":typeof l==`string`?l:void 0,"--xy-minimap-mask-stroke-color-props":typeof u==`string`?u:void 0,"--xy-minimap-mask-stroke-width-props":typeof d==`number`?d*F:void 0,"--xy-minimap-node-background-color-props":typeof r==`string`?r:void 0,"--xy-minimap-node-stroke-color-props":typeof n==`string`?n:void 0,"--xy-minimap-node-stroke-width-props":typeof o==`number`?o:void 0},className:o0([`react-flow__minimap`,t]),"data-testid":`rf__minimap`,children:(0,U.jsxs)(`svg`,{width:j,height:M,viewBox:`${z} ${B} ${ee} ${te}`,className:`react-flow__minimap-svg`,role:`img`,"aria-labelledby":V,ref:S,onClick:ie,children:[oe&&(0,U.jsx)(`title`,{id:V,children:oe}),(0,U.jsx)(SAt,{onClick:ae,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:a,nodeClassName:i,nodeStrokeWidth:o,nodeComponent:s}),(0,U.jsx)(`path`,{className:`react-flow__minimap-mask`,d:`M${z-R},${B-R}h${ee+R*2}v${te+R*2}h${-ee-R*2}z
485
- M${w.x},${w.y}h${w.width}v${w.height}h${-w.width}z`,fillRule:`evenodd`,pointerEvents:`none`})]})})}OAt.displayName=`MiniMap`,(0,H.memo)(OAt);var kAt=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,AAt={[o4.Line]:`right`,[o4.Handle]:`bottom-right`};function jAt({nodeId:e,position:t,variant:n=o4.Handle,className:r,style:i=void 0,children:a,color:o,minWidth:s=10,minHeight:c=10,maxWidth:l=Number.MAX_VALUE,maxHeight:u=Number.MAX_VALUE,keepAspectRatio:d=!1,resizeDirection:f,autoScale:p=!0,shouldResize:m,onResizeStart:h,onResize:g,onResizeEnd:_}){let v=COt(),y=typeof e==`string`?e:v,b=p4(),x=(0,H.useRef)(null),S=n===o4.Handle,C=f4((0,H.useCallback)(kAt(S&&p),[S,p]),u4),w=(0,H.useRef)(null),T=t??AAt[n];return(0,H.useEffect)(()=>{if(!(!x.current||!y))return w.current||=cDt({domNode:x.current,nodeId:y,getStoreItems:()=>{let{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:i,domNode:a}=b.getState();return{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:i,paneDomNode:a}},onChange:(e,t)=>{let{triggerNodeChanges:n,nodeLookup:r,parentLookup:i,nodeOrigin:a}=b.getState(),o=[],s={x:e.x,y:e.y},c=r.get(y);if(c&&c.expandParent&&c.parentId){let t=c.origin??a,n=e.width??c.measured.width??0,l=e.height??c.measured.height??0,u=$2([{id:c.id,parentId:c.parentId,rect:{width:n,height:l,...HTt({x:e.x??c.position.x,y:e.y??c.position.y},{width:n,height:l},c.parentId,r,t)}}],r,i,a);o.push(...u),s.x=e.x?Math.max(t[0]*n,e.x):void 0,s.y=e.y?Math.max(t[1]*l,e.y):void 0}if(s.x!==void 0&&s.y!==void 0){let e={id:y,type:`position`,position:{...s}};o.push(e)}if(e.width!==void 0&&e.height!==void 0){let t={id:y,type:`dimensions`,resizing:!0,setAttributes:f?f===`horizontal`?`width`:`height`:!0,dimensions:{width:e.width,height:e.height}};o.push(t)}for(let e of t){let t={...e,type:`position`};o.push(t)}n(o)},onEnd:({width:e,height:t})=>{let n={id:y,type:`dimensions`,resizing:!1,dimensions:{width:e,height:t}};b.getState().triggerNodeChanges([n])}}),w.current.update({controlPosition:T,boundaries:{minWidth:s,minHeight:c,maxWidth:l,maxHeight:u},keepAspectRatio:d,resizeDirection:f,onResizeStart:h,onResize:g,onResizeEnd:_,shouldResize:m}),()=>{w.current?.destroy()}},[T,s,c,l,u,d,h,g,_,m]),(0,U.jsx)(`div`,{className:o0([`react-flow__resize-control`,`nodrag`,...T.split(`-`),n,r]),ref:x,style:{...i,scale:C,...o&&{[S?`backgroundColor`:`borderColor`]:o}},children:a})}(0,H.memo)(jAt);function j4({value:e,onValueChange:t,options:n,columns:r=2,layout:i=`cards`,idPrefix:a=`wizard-choice`,ariaLabel:o,className:s}){return(0,U.jsx)(ixt,{value:e,onValueChange:e=>t(e),"aria-label":o,className:W(i===`list`?`flex flex-col gap-2`:[`grid gap-3`,r===1&&`grid-cols-1`,r===2&&`grid-cols-2`,r===3&&`grid-cols-3`],s),children:n.map(t=>{let n=`${a}-${t.value}`,r=e===t.value,o=W(`rounded-md border transition-colors`,t.disabled?`cursor-not-allowed opacity-60`:`cursor-pointer`,r?`border-zuplo-600 bg-zuplo-50 dark:bg-zuplo-950/40`:`bg-card hover:bg-neutral-50 dark:hover:bg-neutral-800/60`);return i===`list`?(0,U.jsxs)(yT,{htmlFor:n,className:W(`flex items-center gap-3 px-3 py-2.5`,o),children:[(0,U.jsx)(a0,{value:t.value,id:n,disabled:t.disabled}),t.icon,(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5 sm:flex-row sm:items-center sm:gap-3`,children:[(0,U.jsx)(`div`,{className:`text-sm font-medium sm:w-56 sm:shrink-0`,children:t.title}),t.description&&(0,U.jsx)(`div`,{className:`min-w-0 flex-1 text-xs leading-snug text-muted-foreground`,children:t.description})]})]},t.value):(0,U.jsxs)(yT,{htmlFor:n,className:W(`flex flex-col gap-1.5 p-3`,o),children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(a0,{value:t.value,id:n,disabled:t.disabled}),t.icon,(0,U.jsx)(`div`,{className:`text-sm font-medium`,children:t.title})]}),t.description&&(0,U.jsx)(`div`,{className:`text-xs leading-relaxed text-muted-foreground`,children:t.description})]},t.value)})})}var M4=({tiles:e,selectedId:t,onSelect:n,fallbackIcon:r,columns:i=4,emptyState:a,className:o})=>{let[s,c]=(0,H.useState)(()=>new Set);return(0,U.jsxs)(`div`,{className:W(`grid auto-rows-min gap-2 p-0.5`,i===4?`grid-cols-4`:`grid-cols-3`,o),children:[e.map(e=>{let i=t===e.id,a=s.has(e.id)||!e.iconUrl;return(0,U.jsxs)(`button`,{type:`button`,onClick:()=>n(e.id),"aria-pressed":i,className:W(`flex flex-col items-center justify-center gap-1.5 rounded-md border bg-card p-2 text-center transition-colors hover:bg-neutral-50 dark:hover:bg-neutral-800/60`,i?`border-zuplo-600 bg-zuplo-50 dark:bg-zuplo-950/40`:`border-border`),children:[a?r:(0,U.jsx)(`img`,{src:e.iconUrl,alt:``,className:`size-7 object-contain brightness-0 dark:invert`,onError:()=>c(t=>new Set(t).add(e.id))}),(0,U.jsx)(`span`,{className:`w-full truncate text-xs leading-tight`,children:e.name})]},e.id)}),e.length===0&&a&&(0,U.jsx)(`div`,{className:`col-span-full py-6 text-center text-sm text-muted-foreground`,children:a})]})},MAt=`#ff00bd`,NAt=`#98036a`,PAt=`#fff0fc`,FAt=`#9ca3af`,IAt=`#6b7280`,LAt=`#f7f9fb`,N4=152,P4=60,RAt={client:rd,gateway:dp,origin:Hf},zAt=`!h-0 !min-h-0 !w-0 !min-w-0 !border-0 !bg-transparent`,BAt={box:({data:e})=>{let{label:t,kind:n,emphasis:r}=e,i=RAt[n];return(0,U.jsxs)(`div`,{className:W(`flex flex-col items-center justify-center gap-1.5 rounded-lg border bg-card px-2 text-center shadow-xs`,r?`border-zuplo-600`:`border-neutral-300 dark:border-neutral-600`),style:{width:N4,height:P4},children:[(0,U.jsx)(T4,{type:`target`,position:y2.Left,isConnectable:!1,className:zAt}),(0,U.jsx)(i,{"aria-hidden":`true`,strokeWidth:1.75,className:W(`size-[18px] shrink-0`,r?`text-zuplo-600`:`text-muted-foreground`)}),(0,U.jsx)(`span`,{className:`text-xs font-medium leading-tight text-muted-foreground`,children:t}),(0,U.jsx)(T4,{type:`source`,position:y2.Right,isConnectable:!1,className:zAt})]})}},F4=[{id:`client`,type:`box`,position:{x:0,y:0},width:N4,height:P4,initialWidth:N4,initialHeight:P4,data:{label:`MCP Client`,kind:`client`,emphasis:!1},draggable:!1,selectable:!1},{id:`gateway`,type:`box`,position:{x:270,y:0},width:N4,height:P4,initialWidth:N4,initialHeight:P4,data:{label:`Zuplo MCP Gateway`,kind:`gateway`,emphasis:!0},draggable:!1,selectable:!1},{id:`origin`,type:`box`,position:{x:540,y:0},width:N4,height:P4,initialWidth:N4,initialHeight:P4,data:{label:`Origin MCP Server`,kind:`origin`,emphasis:!1},draggable:!1,selectable:!1}],VAt=e=>{let t=(e,t,n,r,i)=>({id:e,source:t,target:n,type:`smoothstep`,label:r,animated:!1,style:{stroke:i?MAt:FAt,strokeWidth:i?2:1.5},labelStyle:{fill:i?NAt:IAt,fontWeight:i?600:500,fontSize:11},labelBgStyle:{fill:i?PAt:LAt,fillOpacity:.95},labelBgPadding:[6,3],labelBgBorderRadius:4,markerEnd:{type:v2.ArrowClosed,width:14,height:14,color:i?MAt:FAt}});return[t(`inbound`,`client`,`gateway`,`Inbound auth`,e===`inbound`),t(`outbound`,`gateway`,`origin`,`Outbound auth`,e===`outbound`)]},I4={minX:Math.min(...F4.map(e=>e.position.x)),minY:Math.min(...F4.map(e=>e.position.y)),maxX:Math.max(...F4.map(e=>e.position.x+(e.width??N4))),maxY:Math.max(...F4.map(e=>e.position.y+(e.height??P4)))},HAt=I4.maxX-I4.minX,UAt=I4.maxY-I4.minY,WAt=.5,GAt=1.2,KAt=.12;function qAt(e,t){let n=Math.min(e/HAt,t/UAt),r=Math.min(GAt,Math.max(WAt,n*(1-KAt*2)));return{x:(e-HAt*r)/2-I4.minX*r,y:(t-UAt*r)/2-I4.minY*r,zoom:r}}var JAt=({active:e})=>{let t=(0,H.useMemo)(()=>VAt(e),[e]),n=(0,H.useRef)(null),r=(0,H.useRef)(null),i=(0,H.useCallback)(()=>{let e=n.current,t=e?.clientWidth??0,i=e?.clientHeight??0;t>0&&i>0&&r.current?.setViewport(qAt(t,i))},[]),a=(0,H.useCallback)(e=>{r.current=e,i()},[i]);return(0,H.useLayoutEffect)(()=>{let e=n.current;if(!e||typeof ResizeObserver>`u`)return;let t=0,r=new ResizeObserver(()=>{cancelAnimationFrame(t),t=requestAnimationFrame(i)});return r.observe(e),()=>{cancelAnimationFrame(t),r.disconnect()}},[i]),(0,U.jsx)(`div`,{ref:n,role:`img`,"aria-label":`MCP request flow, configuring ${e} authentication`,className:`h-36 w-full overflow-hidden rounded-md border border-border`,children:(0,U.jsx)(nAt,{nodes:F4,edges:t,nodeTypes:BAt,onInit:a,minZoom:WAt,maxZoom:GAt,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,edgesFocusable:!1,nodesFocusable:!1,panOnDrag:!1,panOnScroll:!1,zoomOnScroll:!1,zoomOnPinch:!1,zoomOnDoubleClick:!1,preventScrolling:!1,proOptions:{hideAttribution:!0},style:{backgroundColor:LAt},children:(0,U.jsx)(cAt,{variant:O4.Dots,gap:16,size:1,color:`#dbe1e8`})})})};function L4(e){return e&&e.length>0?e:void 0}function R4(e){return e&&Object.keys(e).length>0?e:void 0}function YAt(e){let t=new Set;for(let n of e??[]){let e=n.trim();e&&t.add(e)}return[...t]}function z4(e,t){if(t!==`rolesAndGroups`)return{};if(e.public===!0)return{public:!0};let n=YAt(e.roles),r=YAt(e.groups);return{...n.length>0?{roles:n}:{},...r.length>0?{groups:r}:{}}}function XAt(e){let t=e&&typeof e==`object`?e:{};return{accessControlMode:t.accessControl?.mode===`rolesAndGroups`?`rolesAndGroups`:`allPublic`,catalog:{tools:B4(t.tools,`name`,e=>({name:e})),prompts:B4(t.prompts,`name`,e=>({name:e})),resources:B4(t.resources,`uri`,e=>({uri:e,name:e})),resourceTemplates:B4(t.resourceTemplates,`uriTemplate`,e=>({uriTemplate:e,name:e}))}}}function B4(e,t,n){return Array.isArray(e)?e.flatMap(e=>{if(typeof e==`string`)return e.length>0?[n(e)]:[];if(!e||typeof e!=`object`)return[];let{public:r,...i}=e,a=i[t];if(typeof a!=`string`||a.length===0)return[];let o=i.name;return[{...i,...t!==`name`&&typeof o!=`string`?{name:a}:{},...r===!0?{public:!0}:{}}]}):[]}function V4(e){return ZAt(e.catalog,e.accessControlMode)}function ZAt(e,t=`allPublic`){return{...t===`rolesAndGroups`?{accessControl:{mode:t}}:{},tools:e.tools.flatMap(e=>{let n=L4(e.name);if(!n)return[];let r=L4(e.description),i=R4(e.annotations),a=R4(e._meta);return[{name:n,...r?{description:r}:{},...i?{annotations:i}:{},...a?{_meta:a}:{},...z4(e,t)}]}),prompts:e.prompts.flatMap(e=>{let n=L4(e.name);if(!n)return[];let r=L4(e.description),i=R4(e._meta);return[{name:n,...r?{description:r}:{},...i?{_meta:i}:{},...z4(e,t)}]}),resources:e.resources.flatMap(e=>{let n=L4(e.uri);if(!n)return[];let r=L4(e.name),i=L4(e.description),a=L4(e.mimeType),o=R4(e._meta);return[{uri:n,...r?{name:r}:{},...i?{description:i}:{},...a?{mimeType:a}:{},...o?{_meta:o}:{},...z4(e,t)}]}),resourceTemplates:e.resourceTemplates.flatMap(e=>{let n=L4(e.uriTemplate);if(!n)return[];let r=L4(e.name),i=L4(e.description),a=L4(e.mimeType),o=R4(e._meta);return[{uriTemplate:n,...r?{name:r}:{},...i?{description:i}:{},...a?{mimeType:a}:{},...o?{_meta:o}:{},...z4(e,t)}]})}}var H4=e=>`/mcp-idp-icons/${e}.svg`,U4=[{id:`auth0`,label:`Auth0`,description:`Auth0 by Okta`,iconUrl:H4(`auth0`),policyModule:`$import(@zuplo/runtime/mcp-gateway)`,policyType:`mcp-auth0-oauth-inbound`,policyExport:`McpAuth0OAuthInboundPolicy`,suggestedPolicyName:`mcp-auth0-inbound`,fields:[{key:`auth0Domain`,label:`Auth0 Domain`,defaultValue:`$env(MCP_AUTH0_DOMAIN)`,helpText:`Auth0 tenant domain, for example acme.us.auth0.com.`,required:!0},{key:`audience`,label:`Audience`,defaultValue:``,helpText:`Optional Auth0 API audience.`,required:!1},{key:`clientId`,label:`Client ID`,defaultValue:`$env(MCP_AUTH0_CLIENT_ID)`,helpText:`Use an environment variable for deployable configs.`,required:!0},{key:`clientSecret`,label:`Client Secret`,defaultValue:`$env(MCP_AUTH0_CLIENT_SECRET)`,helpText:`Use an environment variable; do not commit secrets.`,required:!0}]},{id:`workos`,label:`WorkOS`,description:`WorkOS User Management`,iconUrl:H4(`workos`),policyModule:`$import(@zuplo/runtime/mcp-gateway)`,policyType:`mcp-workos-oauth-inbound`,policyExport:`McpWorkosOAuthInboundPolicy`,suggestedPolicyName:`mcp-workos-inbound`,fields:[{key:`clientId`,label:`Client ID`,defaultValue:`$env(WORKOS_CLIENT_ID)`,helpText:`WorkOS User Management client ID.`,required:!0},{key:`clientSecret`,label:`Client Secret`,defaultValue:`$env(WORKOS_CLIENT_SECRET)`,helpText:`Use an environment variable; do not commit secrets.`,required:!0}]},{id:`google`,label:`Google`,description:`Google OAuth`,iconUrl:H4(`google`),policyModule:`$import(@zuplo/runtime/mcp-gateway)`,policyType:`mcp-google-oauth-inbound`,policyExport:`McpGoogleOAuthInboundPolicy`,suggestedPolicyName:`mcp-google-inbound`,fields:[{key:`clientId`,label:`Client ID`,defaultValue:`$env(GOOGLE_CLIENT_ID)`,helpText:`Google OAuth client ID.`,required:!0},{key:`clientSecret`,label:`Client Secret`,defaultValue:`$env(GOOGLE_CLIENT_SECRET)`,helpText:`Use an environment variable; do not commit secrets.`,required:!0}]},{id:`okta`,label:`Okta`,description:`Okta OIDC`,iconUrl:H4(`okta`),policyModule:`$import(@zuplo/runtime/mcp-gateway)`,policyType:`mcp-okta-oauth-inbound`,policyExport:`McpOktaOAuthInboundPolicy`,suggestedPolicyName:`mcp-okta-inbound`,fields:[{key:`oktaDomain`,label:`Okta Domain`,defaultValue:`$env(OKTA_DOMAIN)`,helpText:`Okta org domain, for example acme.okta.com.`,required:!0},{key:`authorizationServerId`,label:`Authorization Server ID`,defaultValue:``,helpText:`Optional. Use default for Okta's default custom authorization server.`,required:!1},{key:`clientId`,label:`Client ID`,defaultValue:`$env(OKTA_CLIENT_ID)`,helpText:`Okta OIDC application client ID.`,required:!0},{key:`clientSecret`,label:`Client Secret`,defaultValue:`$env(OKTA_CLIENT_SECRET)`,helpText:`Use an environment variable; do not commit secrets.`,required:!0}]},{id:`entra`,label:`Microsoft Entra`,description:`Microsoft Entra ID`,iconUrl:H4(`entra`),policyModule:`$import(@zuplo/runtime/mcp-gateway)`,policyType:`mcp-entra-oauth-inbound`,policyExport:`McpEntraOAuthInboundPolicy`,suggestedPolicyName:`mcp-entra-inbound`,fields:[{key:`tenantId`,label:`Tenant ID`,defaultValue:`$env(ENTRA_TENANT_ID)`,helpText:`Microsoft Entra tenant UUID.`,required:!0},{key:`clientId`,label:`Client ID`,defaultValue:`$env(ENTRA_CLIENT_ID)`,helpText:`Microsoft Entra application client ID.`,required:!0},{key:`clientSecret`,label:`Client Secret`,defaultValue:`$env(ENTRA_CLIENT_SECRET)`,helpText:`Use an environment variable; do not commit secrets.`,required:!0}]},{id:`cognito`,label:`Cognito`,description:`Amazon Cognito`,iconUrl:H4(`cognito`),policyModule:`$import(@zuplo/runtime/mcp-gateway)`,policyType:`mcp-cognito-oauth-inbound`,policyExport:`McpCognitoOAuthInboundPolicy`,suggestedPolicyName:`mcp-cognito-inbound`,fields:[{key:`awsRegion`,label:`AWS Region`,defaultValue:`$env(COGNITO_AWS_REGION)`,helpText:`AWS region containing the Cognito user pool.`,required:!0},{key:`userPoolId`,label:`User Pool ID`,defaultValue:`$env(COGNITO_USER_POOL_ID)`,helpText:`Cognito user pool ID, for example us-east-1_AbCdEf123.`,required:!0},{key:`userPoolDomain`,label:`User Pool Domain`,defaultValue:`$env(COGNITO_USER_POOL_DOMAIN)`,helpText:`Hosted UI domain without https:// or a path.`,required:!0},{key:`clientId`,label:`Client ID`,defaultValue:`$env(COGNITO_CLIENT_ID)`,helpText:`Cognito app client ID.`,required:!0},{key:`clientSecret`,label:`Client Secret`,defaultValue:`$env(COGNITO_CLIENT_SECRET)`,helpText:`Use an environment variable; do not commit secrets.`,required:!0}]},{id:`clerk`,label:`Clerk`,description:`Clerk OAuth`,iconUrl:H4(`clerk`),policyModule:`$import(@zuplo/runtime/mcp-gateway)`,policyType:`mcp-clerk-oauth-inbound`,policyExport:`McpClerkOAuthInboundPolicy`,suggestedPolicyName:`mcp-clerk-inbound`,fields:[{key:`frontendApiUrl`,label:`Frontend API URL`,defaultValue:`$env(CLERK_FRONTEND_API_URL)`,helpText:`Clerk Frontend API URL origin, without a path.`,required:!0},{key:`clientId`,label:`Client ID`,defaultValue:`$env(CLERK_CLIENT_ID)`,helpText:`Clerk OAuth application client ID.`,required:!0},{key:`clientSecret`,label:`Client Secret`,defaultValue:`$env(CLERK_CLIENT_SECRET)`,helpText:`Use an environment variable; do not commit secrets.`,required:!0}]},{id:`keycloak`,label:`Keycloak`,description:`Keycloak OIDC`,iconUrl:H4(`keycloak`),policyModule:`$import(@zuplo/runtime/mcp-gateway)`,policyType:`mcp-keycloak-oauth-inbound`,policyExport:`McpKeycloakOAuthInboundPolicy`,suggestedPolicyName:`mcp-keycloak-inbound`,fields:[{key:`keycloakBaseUrl`,label:`Keycloak Base URL`,defaultValue:`$env(KEYCLOAK_BASE_URL)`,helpText:`Server root URL, without /realms/{realm}.`,required:!0},{key:`realm`,label:`Realm`,defaultValue:`$env(KEYCLOAK_REALM)`,helpText:`Keycloak realm name.`,required:!0},{key:`clientId`,label:`Client ID`,defaultValue:`$env(KEYCLOAK_CLIENT_ID)`,helpText:`Keycloak OIDC client ID.`,required:!0},{key:`clientSecret`,label:`Client Secret`,defaultValue:`$env(KEYCLOAK_CLIENT_SECRET)`,helpText:`Use an environment variable; do not commit secrets.`,required:!0}]},{id:`logto`,label:`Logto`,description:`Logto OIDC`,iconUrl:H4(`logto`),policyModule:`$import(@zuplo/runtime/mcp-gateway)`,policyType:`mcp-logto-oauth-inbound`,policyExport:`McpLogtoOAuthInboundPolicy`,suggestedPolicyName:`mcp-logto-inbound`,fields:[{key:`logtoEndpoint`,label:`Logto Endpoint`,defaultValue:`$env(LOGTO_ENDPOINT)`,helpText:`Logto tenant endpoint or custom domain, without /oidc.`,required:!0},{key:`clientId`,label:`Client ID`,defaultValue:`$env(LOGTO_CLIENT_ID)`,helpText:`Logto application client ID.`,required:!0},{key:`clientSecret`,label:`Client Secret`,defaultValue:`$env(LOGTO_CLIENT_SECRET)`,helpText:`Use an environment variable; do not commit secrets.`,required:!0}]},{id:`onelogin`,label:`OneLogin`,description:`OneLogin OIDC`,iconUrl:H4(`onelogin`),policyModule:`$import(@zuplo/runtime/mcp-gateway)`,policyType:`mcp-onelogin-oauth-inbound`,policyExport:`McpOneLoginOAuthInboundPolicy`,suggestedPolicyName:`mcp-onelogin-inbound`,fields:[{key:`oneLoginSubdomain`,label:`OneLogin Subdomain`,defaultValue:`$env(ONELOGIN_SUBDOMAIN)`,helpText:`Account subdomain, without .onelogin.com.`,required:!0},{key:`clientId`,label:`Client ID`,defaultValue:`$env(ONELOGIN_CLIENT_ID)`,helpText:`OneLogin OIDC application client ID.`,required:!0},{key:`clientSecret`,label:`Client Secret`,defaultValue:`$env(ONELOGIN_CLIENT_SECRET)`,helpText:`Use an environment variable; do not commit secrets.`,required:!0}]},{id:`ping`,label:`Ping`,description:`PingOne OIDC`,iconUrl:H4(`ping`),policyModule:`$import(@zuplo/runtime/mcp-gateway)`,policyType:`mcp-ping-oauth-inbound`,policyExport:`McpPingOAuthInboundPolicy`,suggestedPolicyName:`mcp-ping-inbound`,fields:[{key:`environmentId`,label:`Environment ID`,defaultValue:`$env(PING_ENVIRONMENT_ID)`,helpText:`PingOne environment ID. Not used when custom domain is set.`,required:!1},{key:`region`,label:`Region`,defaultValue:`north-america`,helpText:`PingOne geography. Ignored when custom domain is set.`,required:!1},{key:`customDomain`,label:`Custom Domain`,defaultValue:``,helpText:`Optional PingOne custom domain without https://.`,required:!1},{key:`clientId`,label:`Client ID`,defaultValue:`$env(PING_CLIENT_ID)`,helpText:`PingOne OIDC application client ID.`,required:!0},{key:`clientSecret`,label:`Client Secret`,defaultValue:`$env(PING_CLIENT_SECRET)`,helpText:`Use an environment variable; do not commit secrets.`,required:!0}]},{id:`custom-oauth`,label:`Custom OAuth`,description:`Any OAuth 2.0 / OIDC identity provider`,iconUrl:`https://cdn.zuplo.com/portal/policy-icons/mcp-oauth-inbound.svg`,policyModule:`$import(@zuplo/runtime/mcp-gateway)`,policyType:`mcp-oauth-inbound`,policyExport:`McpOAuthInboundPolicy`,suggestedPolicyName:`mcp-oauth-inbound`,fields:[],defaultOptions:{oidc:{issuer:`https://my-tenant.us.auth0.com/`,jwksUrl:`https://my-tenant.us.auth0.com/.well-known/jwks.json`,audience:`https://gateway.example.com`},browserLogin:{url:`https://my-tenant.us.auth0.com/authorize`,tokenUrl:`https://my-tenant.us.auth0.com/oauth/token`,clientId:`$env(MCP_OAUTH_CLIENT_ID)`,clientSecret:`$env(MCP_OAUTH_CLIENT_SECRET)`,scope:`openid profile email`,pkce:`none`}}}];function W4(e){return U4.find(t=>t.id===e)}function QAt(e){return Object.fromEntries(e.fields.map(e=>[e.key,e.defaultValue]))}var $At=`Most Used`,ejt=`Other`,tjt=[`rate-limit`,`api-key`],njt=[{name:`Rate Limiting & Quotas`,baseIds:[`rate-limit`,`complex-rate-limit`,`quota`]},{name:`Authentication`,baseIds:[`api-key`,`basic-auth`,`mtls-auth`,`ldap-auth`,`open-id-jwt-auth`,`okta-jwt-auth`,`auth0-jwt-auth`,`clerk-jwt-auth`,`cognito-jwt-auth`,`firebase-jwt`,`supabase-jwt-auth`,`propel-auth-jwt`,`curity-phantom-token`,`stripe-webhook-verification`,`web-bot-auth`]},{name:`Authorization`,baseIds:[`jwt-scopes`,`openfga-authz`,`okta-fga-authz`,`axiomatics-authz`,`authzen`,`geo-filter`,`require-origin`]},{name:`MCP Authentication`,baseIds:[`mcp-oauth`,`mcp-auth0-oauth`,`mcp-clerk-oauth`,`mcp-cognito-oauth`,`mcp-entra-oauth`,`mcp-google-oauth`,`mcp-keycloak-oauth`,`mcp-logto-oauth`,`mcp-okta-oauth`,`mcp-onelogin-oauth`,`mcp-ping-oauth`,`mcp-workos-oauth`,`mcp-token-exchange`,`mcp-capability-filter`]},{name:`AI Gateway`,baseIds:[`ai-gateway-model-filtering-v2`,`ai-gateway-fallback-model-v2`,`ai-gateway-metering-v2`,`ai-gateway-semantic-cache-v2`,`ai-gateway-dlp`,`ai-gateway-smart-router`,`akamai-ai-firewall-v2`,`comet-opik-tracing-v2`,`galileo-tracing-v2`]},{name:`AI & Security`,baseIds:[`prompt-injection`,`bot-detection`,`akamai-firewall-for-ai`,`secret-masking`]},{name:`Caching`,baseIds:[`caching`,`semantic-cache`]},{name:`Transformations`,baseIds:[`xml-to-json`,`formdata-to-json`,`set-body`,`set-headers`,`set-query-params`,`set-status`,`remove-headers`,`remove-query-params`,`clear-headers`,`query-param-to-header`,`replace-string`,`change-method`]},{name:`Validation`,baseIds:[`validate-json-schema`,`request-validation`,`request-size-limit`]},{name:`Traffic Management`,baseIds:[`traffic-splitting`,`brownout`,`sleep`,`mock-api`,`http-deprecation`]},{name:`GraphQL`,baseIds:[`graphql-complexity-limit`,`graphql-disable-introspection`,`graphql-introspection-filter`]},{name:`Monetization & Metering`,baseIds:[`monetization`,`openmeter`,`amberflo-metering`,`moesif`,`readme-metrics`]},{name:`Logging & Tracing`,baseIds:[`audit-log`]},{name:`Upstream Auth`,baseIds:[`set-upstream-api-key`,`upstream-azure-ad-service-auth`,`upstream-firebase-admin-auth`,`upstream-firebase-user-auth`,`upstream-gcp-federated-auth`,`upstream-gcp-jwt`,`upstream-gcp-service-auth`,`upstream-zuplo-jwt-auth`]},{name:`Custom & Composite`,baseIds:[`custom-code`,`composite`]}],rjt=/-(inbound|outbound|internal)$/,G4=e=>e.replace(rjt,``),K4=new Map;for(let e of njt)for(let t of e.baseIds)K4.has(t)||K4.set(t,e.name);var ijt=e=>K4.get(G4(e.id))??`Other`,ajt=e=>K4.get(G4(e))===`Authentication`,ojt=e=>tjt.includes(G4(e.id)),sjt=e=>{let t=new Map,n=[];for(let r of e){ojt(r)&&n.push(r);let e=ijt(r),i=t.get(e);i?i.push(r):t.set(e,[r])}let r=[];n.length>0&&r.push({name:$At,policies:n});for(let{name:e}of njt){let n=t.get(e);n&&n.length>0&&r.push({name:e,policies:n})}let i=t.get(ejt);return i&&i.length>0&&r.push({name:ejt,policies:i}),r},cjt=[...U4.map(e=>e.policyType)];function ljt(e){return cjt.includes(e)||ajt(e)}var q4=`mcp-token-exchange-inbound`,J4=`mcp-capability-filter-inbound`,ujt=`set-upstream-api-key-inbound`,djt=`remove-headers-inbound`;function Y4(e){if(!e||typeof e!=`object`)return!1;let t=e.headers;if(!Array.isArray(t)||t.length!==1)return!1;let[n]=t;return typeof n==`string`&&n.toLowerCase()===`authorization`}var fjt=e=>e.toLowerCase().replaceAll(` `,`-`),X4=({name:e,onChangeName:t,disabled:n,policies:r})=>{let[i,a]=(0,H.useState)(null);return(0,U.jsxs)(`div`,{className:`grid grid-cols-12 text-sm gap-2 items-center pt-1`,children:[(0,U.jsx)(`label`,{className:`col-span-1`,children:`Name`}),(0,U.jsx)(`div`,{className:`col-span-11`,children:(0,U.jsx)(gT,{type:`text`,id:`route-handler`,"data-test":`policy-picker-name-input`,name:`route-handler`,value:e??``,disabled:n,onChange:e=>{let n=e.currentTarget.value,i=fjt(n.toLowerCase());a(byt(i,r)),t(i)},"aria-describedby":`email-description`})}),i&&(0,U.jsx)(`div`,{className:`col-span-11 col-start-2 mt-1 text-red-600`,children:i})]})},pjt=({documentationSrc:e,className:t})=>(0,U.jsx)(`div`,{className:W(`prose prose-neutral prose-sm dark:prose-invert z-10 prose-headings:mt-2 prose-headings:text-sm max-w-full [&_li>div]:inline [&_li>div>p]:inline [&_code::before]:content-none [&_code::after]:content-none`,t),dangerouslySetInnerHTML:{__html:e}}),mjt=({documentationSrc:e})=>(0,U.jsxs)(`div`,{className:`px-4 py-2 border-t h-full overflow-y-auto h-[stretch]`,children:[(0,U.jsx)(`h3`,{className:`text-lg font-medium text-foreground`,children:`Documentation`}),(0,U.jsx)(pjt,{documentationSrc:e})]}),hjt={[J4]:(0,H.lazy)(()=>vn(()=>import(`./McpCapabilityFilterDesigner-6lZzsEzv.js`),__vite__mapDeps([7,1,8,2])))};function gjt(e){return e?hjt[e]:void 0}var _jt=(e=!1)=>async({queryKey:t})=>{let[n]=t;if(typeof n!=`string`)throw new ot({type:`https://zup.fail/invalid-query-key`,title:`Invalid query key`});let r=new Request(n),i;try{i=await fetch(r)}catch(e){throw e instanceof TypeError?new ot({type:`https://zup.fail/api-request-failed`,title:`API request failed`,status:500,instance:n}):e}if(!i.ok){let e=new s(`Error while making request. Please try again or contact support if the problem persists.`);throw await e.tryReadResponse(i),e}try{return await(e?i.clone().json():i.clone().text())}catch(e){let t=await i.clone().text();throw Wt.captureException(e,{message:`Failed to parse response of ${n} to JSON`,responseText:t,status:i.status,requestUrl:n}),e}};function Z4(e,{json:t,...n}={}){return k({queryKey:[e.url],queryFn:_jt(t),...n})}var Q4=(e={})=>Z4(je.cdnContent(`/portal/policies.v6.json`),{...e,json:!0}),vjt=(e,t={})=>Z4({url:e??``},{...t,enabled:!!e&&t.enabled!==!1,json:!0}),yjt={type:`object`,properties:{handler:{type:`object`,properties:{options:{type:`object`,title:`Ensure Gateway Internal Invocation Only`,"x-no-options":!0,description:`Accepts only requests this gateway made itself with context.invokeRoute, and answers anything that arrived over the network with 403 Forbidden.
485
+ M${w.x},${w.y}h${w.width}v${w.height}h${-w.width}z`,fillRule:`evenodd`,pointerEvents:`none`})]})})}OAt.displayName=`MiniMap`,(0,H.memo)(OAt);var kAt=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,AAt={[o4.Line]:`right`,[o4.Handle]:`bottom-right`};function jAt({nodeId:e,position:t,variant:n=o4.Handle,className:r,style:i=void 0,children:a,color:o,minWidth:s=10,minHeight:c=10,maxWidth:l=Number.MAX_VALUE,maxHeight:u=Number.MAX_VALUE,keepAspectRatio:d=!1,resizeDirection:f,autoScale:p=!0,shouldResize:m,onResizeStart:h,onResize:g,onResizeEnd:_}){let v=COt(),y=typeof e==`string`?e:v,b=p4(),x=(0,H.useRef)(null),S=n===o4.Handle,C=f4((0,H.useCallback)(kAt(S&&p),[S,p]),u4),w=(0,H.useRef)(null),T=t??AAt[n];return(0,H.useEffect)(()=>{if(!(!x.current||!y))return w.current||=cDt({domNode:x.current,nodeId:y,getStoreItems:()=>{let{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:i,domNode:a}=b.getState();return{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:i,paneDomNode:a}},onChange:(e,t)=>{let{triggerNodeChanges:n,nodeLookup:r,parentLookup:i,nodeOrigin:a}=b.getState(),o=[],s={x:e.x,y:e.y},c=r.get(y);if(c&&c.expandParent&&c.parentId){let t=c.origin??a,n=e.width??c.measured.width??0,l=e.height??c.measured.height??0,u=$2([{id:c.id,parentId:c.parentId,rect:{width:n,height:l,...HTt({x:e.x??c.position.x,y:e.y??c.position.y},{width:n,height:l},c.parentId,r,t)}}],r,i,a);o.push(...u),s.x=e.x?Math.max(t[0]*n,e.x):void 0,s.y=e.y?Math.max(t[1]*l,e.y):void 0}if(s.x!==void 0&&s.y!==void 0){let e={id:y,type:`position`,position:{...s}};o.push(e)}if(e.width!==void 0&&e.height!==void 0){let t={id:y,type:`dimensions`,resizing:!0,setAttributes:f?f===`horizontal`?`width`:`height`:!0,dimensions:{width:e.width,height:e.height}};o.push(t)}for(let e of t){let t={...e,type:`position`};o.push(t)}n(o)},onEnd:({width:e,height:t})=>{let n={id:y,type:`dimensions`,resizing:!1,dimensions:{width:e,height:t}};b.getState().triggerNodeChanges([n])}}),w.current.update({controlPosition:T,boundaries:{minWidth:s,minHeight:c,maxWidth:l,maxHeight:u},keepAspectRatio:d,resizeDirection:f,onResizeStart:h,onResize:g,onResizeEnd:_,shouldResize:m}),()=>{w.current?.destroy()}},[T,s,c,l,u,d,h,g,_,m]),(0,U.jsx)(`div`,{className:o0([`react-flow__resize-control`,`nodrag`,...T.split(`-`),n,r]),ref:x,style:{...i,scale:C,...o&&{[S?`backgroundColor`:`borderColor`]:o}},children:a})}(0,H.memo)(jAt);function j4({value:e,onValueChange:t,options:n,columns:r=2,layout:i=`cards`,idPrefix:a=`wizard-choice`,ariaLabel:o,className:s}){return(0,U.jsx)(ixt,{value:e,onValueChange:e=>t(e),"aria-label":o,className:W(i===`list`?`flex flex-col gap-2`:[`grid gap-3`,r===1&&`grid-cols-1`,r===2&&`grid-cols-2`,r===3&&`grid-cols-3`],s),children:n.map(t=>{let n=`${a}-${t.value}`,r=e===t.value,o=W(`rounded-md border transition-colors`,t.disabled?`cursor-not-allowed opacity-60`:`cursor-pointer`,r?`border-zuplo-600 bg-zuplo-50 dark:bg-zuplo-950/40`:`bg-card hover:bg-neutral-50 dark:hover:bg-neutral-800/60`);return i===`list`?(0,U.jsxs)(yT,{htmlFor:n,className:W(`flex items-center gap-3 px-3 py-2.5`,o),children:[(0,U.jsx)(a0,{value:t.value,id:n,disabled:t.disabled}),t.icon,(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5 sm:flex-row sm:items-center sm:gap-3`,children:[(0,U.jsx)(`div`,{className:`text-sm font-medium sm:w-56 sm:shrink-0`,children:t.title}),t.description&&(0,U.jsx)(`div`,{className:`min-w-0 flex-1 text-xs leading-snug text-muted-foreground`,children:t.description})]})]},t.value):(0,U.jsxs)(yT,{htmlFor:n,className:W(`flex flex-col gap-1.5 p-3`,o),children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(a0,{value:t.value,id:n,disabled:t.disabled}),t.icon,(0,U.jsx)(`div`,{className:`text-sm font-medium`,children:t.title})]}),t.description&&(0,U.jsx)(`div`,{className:`text-xs leading-relaxed text-muted-foreground`,children:t.description})]},t.value)})})}var M4=({tiles:e,selectedId:t,onSelect:n,fallbackIcon:r,columns:i=4,emptyState:a,className:o})=>{let[s,c]=(0,H.useState)(()=>new Set);return(0,U.jsxs)(`div`,{className:W(`grid auto-rows-min gap-2 p-0.5`,i===4?`grid-cols-4`:`grid-cols-3`,o),children:[e.map(e=>{let i=t===e.id,a=s.has(e.id)||!e.iconUrl;return(0,U.jsxs)(`button`,{type:`button`,onClick:()=>n(e.id),"aria-pressed":i,className:W(`flex flex-col items-center justify-center gap-1.5 rounded-md border bg-card p-2 text-center transition-colors hover:bg-neutral-50 dark:hover:bg-neutral-800/60`,i?`border-zuplo-600 bg-zuplo-50 dark:bg-zuplo-950/40`:`border-border`),children:[a?r:(0,U.jsx)(`img`,{src:e.iconUrl,alt:``,className:`size-7 object-contain brightness-0 dark:invert`,onError:()=>c(t=>new Set(t).add(e.id))}),(0,U.jsx)(`span`,{className:`w-full truncate text-xs leading-tight`,children:e.name})]},e.id)}),e.length===0&&a&&(0,U.jsx)(`div`,{className:`col-span-full py-6 text-center text-sm text-muted-foreground`,children:a})]})},MAt=`#ff00bd`,NAt=`#98036a`,PAt=`#fff0fc`,FAt=`#9ca3af`,IAt=`#6b7280`,LAt=`#f7f9fb`,N4=152,P4=60,RAt={client:rd,gateway:dp,origin:Hf},zAt=`!h-0 !min-h-0 !w-0 !min-w-0 !border-0 !bg-transparent`,BAt={box:({data:e})=>{let{label:t,kind:n,emphasis:r}=e,i=RAt[n];return(0,U.jsxs)(`div`,{className:W(`flex flex-col items-center justify-center gap-1.5 rounded-lg border bg-card px-2 text-center shadow-xs`,r?`border-zuplo-600`:`border-neutral-300 dark:border-neutral-600`),style:{width:N4,height:P4},children:[(0,U.jsx)(T4,{type:`target`,position:y2.Left,isConnectable:!1,className:zAt}),(0,U.jsx)(i,{"aria-hidden":`true`,strokeWidth:1.75,className:W(`size-[18px] shrink-0`,r?`text-zuplo-600`:`text-muted-foreground`)}),(0,U.jsx)(`span`,{className:`text-xs font-medium leading-tight text-muted-foreground`,children:t}),(0,U.jsx)(T4,{type:`source`,position:y2.Right,isConnectable:!1,className:zAt})]})}},F4=[{id:`client`,type:`box`,position:{x:0,y:0},width:N4,height:P4,initialWidth:N4,initialHeight:P4,data:{label:`MCP Client`,kind:`client`,emphasis:!1},draggable:!1,selectable:!1},{id:`gateway`,type:`box`,position:{x:270,y:0},width:N4,height:P4,initialWidth:N4,initialHeight:P4,data:{label:`Zuplo MCP Gateway`,kind:`gateway`,emphasis:!0},draggable:!1,selectable:!1},{id:`origin`,type:`box`,position:{x:540,y:0},width:N4,height:P4,initialWidth:N4,initialHeight:P4,data:{label:`Origin MCP Server`,kind:`origin`,emphasis:!1},draggable:!1,selectable:!1}],VAt=e=>{let t=(e,t,n,r,i)=>({id:e,source:t,target:n,type:`smoothstep`,label:r,animated:!1,style:{stroke:i?MAt:FAt,strokeWidth:i?2:1.5},labelStyle:{fill:i?NAt:IAt,fontWeight:i?600:500,fontSize:11},labelBgStyle:{fill:i?PAt:LAt,fillOpacity:.95},labelBgPadding:[6,3],labelBgBorderRadius:4,markerEnd:{type:v2.ArrowClosed,width:14,height:14,color:i?MAt:FAt}});return[t(`inbound`,`client`,`gateway`,`Inbound auth`,e===`inbound`),t(`outbound`,`gateway`,`origin`,`Outbound auth`,e===`outbound`)]},I4={minX:Math.min(...F4.map(e=>e.position.x)),minY:Math.min(...F4.map(e=>e.position.y)),maxX:Math.max(...F4.map(e=>e.position.x+(e.width??N4))),maxY:Math.max(...F4.map(e=>e.position.y+(e.height??P4)))},HAt=I4.maxX-I4.minX,UAt=I4.maxY-I4.minY,WAt=.5,GAt=1.2,KAt=.12;function qAt(e,t){let n=Math.min(e/HAt,t/UAt),r=Math.min(GAt,Math.max(WAt,n*(1-KAt*2)));return{x:(e-HAt*r)/2-I4.minX*r,y:(t-UAt*r)/2-I4.minY*r,zoom:r}}var JAt=({active:e})=>{let t=(0,H.useMemo)(()=>VAt(e),[e]),n=(0,H.useRef)(null),r=(0,H.useRef)(null),i=(0,H.useCallback)(()=>{let e=n.current,t=e?.clientWidth??0,i=e?.clientHeight??0;t>0&&i>0&&r.current?.setViewport(qAt(t,i))},[]),a=(0,H.useCallback)(e=>{r.current=e,i()},[i]);return(0,H.useLayoutEffect)(()=>{let e=n.current;if(!e||typeof ResizeObserver>`u`)return;let t=0,r=new ResizeObserver(()=>{cancelAnimationFrame(t),t=requestAnimationFrame(i)});return r.observe(e),()=>{cancelAnimationFrame(t),r.disconnect()}},[i]),(0,U.jsx)(`div`,{ref:n,role:`img`,"aria-label":`MCP request flow, configuring ${e} authentication`,className:`h-36 w-full overflow-hidden rounded-md border border-border`,children:(0,U.jsx)(nAt,{nodes:F4,edges:t,nodeTypes:BAt,onInit:a,minZoom:WAt,maxZoom:GAt,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,edgesFocusable:!1,nodesFocusable:!1,panOnDrag:!1,panOnScroll:!1,zoomOnScroll:!1,zoomOnPinch:!1,zoomOnDoubleClick:!1,preventScrolling:!1,proOptions:{hideAttribution:!0},style:{backgroundColor:LAt},children:(0,U.jsx)(cAt,{variant:O4.Dots,gap:16,size:1,color:`#dbe1e8`})})})};function L4(e){return e&&e.length>0?e:void 0}function R4(e){return e&&Object.keys(e).length>0?e:void 0}function YAt(e){let t=new Set;for(let n of e??[]){let e=n.trim();e&&t.add(e)}return[...t]}function z4(e,t){if(t!==`rolesAndGroups`)return{};if(e.public===!0)return{public:!0};let n=YAt(e.roles),r=YAt(e.groups);return{...n.length>0?{roles:n}:{},...r.length>0?{groups:r}:{}}}function XAt(e){let t=e&&typeof e==`object`?e:{};return{accessControlMode:t.accessControl?.mode===`rolesAndGroups`?`rolesAndGroups`:`allPublic`,catalog:{tools:B4(t.tools,`name`,e=>({name:e})),prompts:B4(t.prompts,`name`,e=>({name:e})),resources:B4(t.resources,`uri`,e=>({uri:e,name:e})),resourceTemplates:B4(t.resourceTemplates,`uriTemplate`,e=>({uriTemplate:e,name:e}))}}}function B4(e,t,n){return Array.isArray(e)?e.flatMap(e=>{if(typeof e==`string`)return e.length>0?[n(e)]:[];if(!e||typeof e!=`object`)return[];let{public:r,...i}=e,a=i[t];if(typeof a!=`string`||a.length===0)return[];let o=i.name;return[{...i,...t!==`name`&&typeof o!=`string`?{name:a}:{},...r===!0?{public:!0}:{}}]}):[]}function V4(e){return ZAt(e.catalog,e.accessControlMode)}function ZAt(e,t=`allPublic`){return{...t===`rolesAndGroups`?{accessControl:{mode:t}}:{},tools:e.tools.flatMap(e=>{let n=L4(e.name);if(!n)return[];let r=L4(e.description),i=R4(e.annotations),a=R4(e._meta);return[{name:n,...r?{description:r}:{},...i?{annotations:i}:{},...a?{_meta:a}:{},...z4(e,t)}]}),prompts:e.prompts.flatMap(e=>{let n=L4(e.name);if(!n)return[];let r=L4(e.description),i=R4(e._meta);return[{name:n,...r?{description:r}:{},...i?{_meta:i}:{},...z4(e,t)}]}),resources:e.resources.flatMap(e=>{let n=L4(e.uri);if(!n)return[];let r=L4(e.name),i=L4(e.description),a=L4(e.mimeType),o=R4(e._meta);return[{uri:n,...r?{name:r}:{},...i?{description:i}:{},...a?{mimeType:a}:{},...o?{_meta:o}:{},...z4(e,t)}]}),resourceTemplates:e.resourceTemplates.flatMap(e=>{let n=L4(e.uriTemplate);if(!n)return[];let r=L4(e.name),i=L4(e.description),a=L4(e.mimeType),o=R4(e._meta);return[{uriTemplate:n,...r?{name:r}:{},...i?{description:i}:{},...a?{mimeType:a}:{},...o?{_meta:o}:{},...z4(e,t)}]})}}var H4=e=>`/mcp-idp-icons/${e}.svg`,U4=[{id:`auth0`,label:`Auth0`,description:`Auth0 by Okta`,iconUrl:H4(`auth0`),policyModule:`$import(@zuplo/runtime/mcp-gateway)`,policyType:`mcp-auth0-oauth-inbound`,policyExport:`McpAuth0OAuthInboundPolicy`,suggestedPolicyName:`mcp-auth0-inbound`,fields:[{key:`auth0Domain`,label:`Auth0 Domain`,defaultValue:`$env(MCP_AUTH0_DOMAIN)`,helpText:`Auth0 tenant domain, for example acme.us.auth0.com.`,required:!0},{key:`audience`,label:`Audience`,defaultValue:``,helpText:`Optional Auth0 API audience.`,required:!1},{key:`clientId`,label:`Client ID`,defaultValue:`$env(MCP_AUTH0_CLIENT_ID)`,helpText:`Use an environment variable for deployable configs.`,required:!0},{key:`clientSecret`,label:`Client Secret`,defaultValue:`$env(MCP_AUTH0_CLIENT_SECRET)`,helpText:`Use an environment variable; do not commit secrets.`,required:!0}]},{id:`workos`,label:`WorkOS`,description:`WorkOS User Management`,iconUrl:H4(`workos`),policyModule:`$import(@zuplo/runtime/mcp-gateway)`,policyType:`mcp-workos-oauth-inbound`,policyExport:`McpWorkosOAuthInboundPolicy`,suggestedPolicyName:`mcp-workos-inbound`,fields:[{key:`clientId`,label:`Client ID`,defaultValue:`$env(WORKOS_CLIENT_ID)`,helpText:`WorkOS User Management client ID.`,required:!0},{key:`clientSecret`,label:`Client Secret`,defaultValue:`$env(WORKOS_CLIENT_SECRET)`,helpText:`Use an environment variable; do not commit secrets.`,required:!0}]},{id:`google`,label:`Google`,description:`Google OAuth`,iconUrl:H4(`google`),policyModule:`$import(@zuplo/runtime/mcp-gateway)`,policyType:`mcp-google-oauth-inbound`,policyExport:`McpGoogleOAuthInboundPolicy`,suggestedPolicyName:`mcp-google-inbound`,fields:[{key:`clientId`,label:`Client ID`,defaultValue:`$env(GOOGLE_CLIENT_ID)`,helpText:`Google OAuth client ID.`,required:!0},{key:`clientSecret`,label:`Client Secret`,defaultValue:`$env(GOOGLE_CLIENT_SECRET)`,helpText:`Use an environment variable; do not commit secrets.`,required:!0}]},{id:`okta`,label:`Okta`,description:`Okta OIDC`,iconUrl:H4(`okta`),policyModule:`$import(@zuplo/runtime/mcp-gateway)`,policyType:`mcp-okta-oauth-inbound`,policyExport:`McpOktaOAuthInboundPolicy`,suggestedPolicyName:`mcp-okta-inbound`,fields:[{key:`oktaDomain`,label:`Okta Domain`,defaultValue:`$env(OKTA_DOMAIN)`,helpText:`Okta org domain, for example acme.okta.com.`,required:!0},{key:`authorizationServerId`,label:`Authorization Server ID`,defaultValue:``,helpText:`Optional. Use default for Okta's default custom authorization server.`,required:!1},{key:`clientId`,label:`Client ID`,defaultValue:`$env(OKTA_CLIENT_ID)`,helpText:`Okta OIDC application client ID.`,required:!0},{key:`clientSecret`,label:`Client Secret`,defaultValue:`$env(OKTA_CLIENT_SECRET)`,helpText:`Use an environment variable; do not commit secrets.`,required:!0}]},{id:`entra`,label:`Microsoft Entra`,description:`Microsoft Entra ID`,iconUrl:H4(`entra`),policyModule:`$import(@zuplo/runtime/mcp-gateway)`,policyType:`mcp-entra-oauth-inbound`,policyExport:`McpEntraOAuthInboundPolicy`,suggestedPolicyName:`mcp-entra-inbound`,fields:[{key:`tenantId`,label:`Tenant ID`,defaultValue:`$env(ENTRA_TENANT_ID)`,helpText:`Microsoft Entra tenant UUID.`,required:!0},{key:`clientId`,label:`Client ID`,defaultValue:`$env(ENTRA_CLIENT_ID)`,helpText:`Microsoft Entra application client ID.`,required:!0},{key:`clientSecret`,label:`Client Secret`,defaultValue:`$env(ENTRA_CLIENT_SECRET)`,helpText:`Use an environment variable; do not commit secrets.`,required:!0}]},{id:`cognito`,label:`Cognito`,description:`Amazon Cognito`,iconUrl:H4(`cognito`),policyModule:`$import(@zuplo/runtime/mcp-gateway)`,policyType:`mcp-cognito-oauth-inbound`,policyExport:`McpCognitoOAuthInboundPolicy`,suggestedPolicyName:`mcp-cognito-inbound`,fields:[{key:`awsRegion`,label:`AWS Region`,defaultValue:`$env(COGNITO_AWS_REGION)`,helpText:`AWS region containing the Cognito user pool.`,required:!0},{key:`userPoolId`,label:`User Pool ID`,defaultValue:`$env(COGNITO_USER_POOL_ID)`,helpText:`Cognito user pool ID, for example us-east-1_AbCdEf123.`,required:!0},{key:`userPoolDomain`,label:`User Pool Domain`,defaultValue:`$env(COGNITO_USER_POOL_DOMAIN)`,helpText:`Hosted UI domain without https:// or a path.`,required:!0},{key:`clientId`,label:`Client ID`,defaultValue:`$env(COGNITO_CLIENT_ID)`,helpText:`Cognito app client ID.`,required:!0},{key:`clientSecret`,label:`Client Secret`,defaultValue:`$env(COGNITO_CLIENT_SECRET)`,helpText:`Use an environment variable; do not commit secrets.`,required:!0}]},{id:`clerk`,label:`Clerk`,description:`Clerk OAuth`,iconUrl:H4(`clerk`),policyModule:`$import(@zuplo/runtime/mcp-gateway)`,policyType:`mcp-clerk-oauth-inbound`,policyExport:`McpClerkOAuthInboundPolicy`,suggestedPolicyName:`mcp-clerk-inbound`,fields:[{key:`frontendApiUrl`,label:`Frontend API URL`,defaultValue:`$env(CLERK_FRONTEND_API_URL)`,helpText:`Clerk Frontend API URL origin, without a path.`,required:!0},{key:`clientId`,label:`Client ID`,defaultValue:`$env(CLERK_CLIENT_ID)`,helpText:`Clerk OAuth application client ID.`,required:!0},{key:`clientSecret`,label:`Client Secret`,defaultValue:`$env(CLERK_CLIENT_SECRET)`,helpText:`Use an environment variable; do not commit secrets.`,required:!0}]},{id:`keycloak`,label:`Keycloak`,description:`Keycloak OIDC`,iconUrl:H4(`keycloak`),policyModule:`$import(@zuplo/runtime/mcp-gateway)`,policyType:`mcp-keycloak-oauth-inbound`,policyExport:`McpKeycloakOAuthInboundPolicy`,suggestedPolicyName:`mcp-keycloak-inbound`,fields:[{key:`keycloakBaseUrl`,label:`Keycloak Base URL`,defaultValue:`$env(KEYCLOAK_BASE_URL)`,helpText:`Server root URL, without /realms/{realm}.`,required:!0},{key:`realm`,label:`Realm`,defaultValue:`$env(KEYCLOAK_REALM)`,helpText:`Keycloak realm name.`,required:!0},{key:`clientId`,label:`Client ID`,defaultValue:`$env(KEYCLOAK_CLIENT_ID)`,helpText:`Keycloak OIDC client ID.`,required:!0},{key:`clientSecret`,label:`Client Secret`,defaultValue:`$env(KEYCLOAK_CLIENT_SECRET)`,helpText:`Use an environment variable; do not commit secrets.`,required:!0}]},{id:`logto`,label:`Logto`,description:`Logto OIDC`,iconUrl:H4(`logto`),policyModule:`$import(@zuplo/runtime/mcp-gateway)`,policyType:`mcp-logto-oauth-inbound`,policyExport:`McpLogtoOAuthInboundPolicy`,suggestedPolicyName:`mcp-logto-inbound`,fields:[{key:`logtoEndpoint`,label:`Logto Endpoint`,defaultValue:`$env(LOGTO_ENDPOINT)`,helpText:`Logto tenant endpoint or custom domain, without /oidc.`,required:!0},{key:`clientId`,label:`Client ID`,defaultValue:`$env(LOGTO_CLIENT_ID)`,helpText:`Logto application client ID.`,required:!0},{key:`clientSecret`,label:`Client Secret`,defaultValue:`$env(LOGTO_CLIENT_SECRET)`,helpText:`Use an environment variable; do not commit secrets.`,required:!0}]},{id:`onelogin`,label:`OneLogin`,description:`OneLogin OIDC`,iconUrl:H4(`onelogin`),policyModule:`$import(@zuplo/runtime/mcp-gateway)`,policyType:`mcp-onelogin-oauth-inbound`,policyExport:`McpOneLoginOAuthInboundPolicy`,suggestedPolicyName:`mcp-onelogin-inbound`,fields:[{key:`oneLoginSubdomain`,label:`OneLogin Subdomain`,defaultValue:`$env(ONELOGIN_SUBDOMAIN)`,helpText:`Account subdomain, without .onelogin.com.`,required:!0},{key:`clientId`,label:`Client ID`,defaultValue:`$env(ONELOGIN_CLIENT_ID)`,helpText:`OneLogin OIDC application client ID.`,required:!0},{key:`clientSecret`,label:`Client Secret`,defaultValue:`$env(ONELOGIN_CLIENT_SECRET)`,helpText:`Use an environment variable; do not commit secrets.`,required:!0}]},{id:`ping`,label:`Ping`,description:`PingOne OIDC`,iconUrl:H4(`ping`),policyModule:`$import(@zuplo/runtime/mcp-gateway)`,policyType:`mcp-ping-oauth-inbound`,policyExport:`McpPingOAuthInboundPolicy`,suggestedPolicyName:`mcp-ping-inbound`,fields:[{key:`environmentId`,label:`Environment ID`,defaultValue:`$env(PING_ENVIRONMENT_ID)`,helpText:`PingOne environment ID. Not used when custom domain is set.`,required:!1},{key:`region`,label:`Region`,defaultValue:`north-america`,helpText:`PingOne geography. Ignored when custom domain is set.`,required:!1},{key:`customDomain`,label:`Custom Domain`,defaultValue:``,helpText:`Optional PingOne custom domain without https://.`,required:!1},{key:`clientId`,label:`Client ID`,defaultValue:`$env(PING_CLIENT_ID)`,helpText:`PingOne OIDC application client ID.`,required:!0},{key:`clientSecret`,label:`Client Secret`,defaultValue:`$env(PING_CLIENT_SECRET)`,helpText:`Use an environment variable; do not commit secrets.`,required:!0}]},{id:`custom-oauth`,label:`Custom OAuth`,description:`Any OAuth 2.0 / OIDC identity provider`,iconUrl:`https://cdn.zuplo.com/portal/policy-icons/mcp-oauth-inbound.svg`,policyModule:`$import(@zuplo/runtime/mcp-gateway)`,policyType:`mcp-oauth-inbound`,policyExport:`McpOAuthInboundPolicy`,suggestedPolicyName:`mcp-oauth-inbound`,fields:[],defaultOptions:{oidc:{issuer:`https://my-tenant.us.auth0.com/`,jwksUrl:`https://my-tenant.us.auth0.com/.well-known/jwks.json`,audience:`https://gateway.example.com`},browserLogin:{url:`https://my-tenant.us.auth0.com/authorize`,tokenUrl:`https://my-tenant.us.auth0.com/oauth/token`,clientId:`$env(MCP_OAUTH_CLIENT_ID)`,clientSecret:`$env(MCP_OAUTH_CLIENT_SECRET)`,scope:`openid profile email`,pkce:`none`}}}];function W4(e){return U4.find(t=>t.id===e)}function QAt(e){return Object.fromEntries(e.fields.map(e=>[e.key,e.defaultValue]))}var $At=`Most Used`,ejt=`Other`,tjt=[`rate-limit`,`api-key`],njt=[{name:`Rate Limiting & Quotas`,baseIds:[`rate-limit`,`complex-rate-limit`,`quota`]},{name:`Authentication`,baseIds:[`api-key`,`basic-auth`,`mtls-auth`,`ldap-auth`,`open-id-jwt-auth`,`okta-jwt-auth`,`auth0-jwt-auth`,`clerk-jwt-auth`,`cognito-jwt-auth`,`firebase-jwt`,`supabase-jwt-auth`,`propel-auth-jwt`,`curity-phantom-token`,`stripe-webhook-verification`,`web-bot-auth`]},{name:`Authorization`,baseIds:[`jwt-scopes`,`openfga-authz`,`okta-fga-authz`,`axiomatics-authz`,`authzen`,`geo-filter`,`require-origin`]},{name:`MCP Authentication`,baseIds:[`mcp-oauth`,`mcp-auth0-oauth`,`mcp-clerk-oauth`,`mcp-cognito-oauth`,`mcp-entra-oauth`,`mcp-google-oauth`,`mcp-keycloak-oauth`,`mcp-logto-oauth`,`mcp-okta-oauth`,`mcp-onelogin-oauth`,`mcp-ping-oauth`,`mcp-workos-oauth`,`mcp-token-exchange`,`mcp-capability-filter`]},{name:`AI Gateway`,baseIds:[`ai-gateway-model-filtering-v2`,`ai-gateway-fallback-model-v2`,`ai-gateway-metering-v2`,`ai-gateway-semantic-cache-v2`,`ai-gateway-dlp`,`ai-gateway-smart-router`,`akamai-ai-firewall-v2`,`comet-opik-tracing-v2`,`galileo-tracing-v2`]},{name:`AI & Security`,baseIds:[`prompt-injection`,`bot-detection`,`akamai-firewall-for-ai`,`secret-masking`]},{name:`Caching`,baseIds:[`caching`,`semantic-cache`]},{name:`Transformations`,baseIds:[`xml-to-json`,`formdata-to-json`,`set-body`,`set-headers`,`set-query-params`,`set-status`,`remove-headers`,`remove-query-params`,`clear-headers`,`query-param-to-header`,`replace-string`,`change-method`]},{name:`Validation`,baseIds:[`validate-json-schema`,`request-validation`,`request-size-limit`]},{name:`Traffic Management`,baseIds:[`traffic-splitting`,`brownout`,`sleep`,`mock-api`,`http-deprecation`]},{name:`GraphQL`,baseIds:[`graphql-complexity-limit`,`graphql-disable-introspection`,`graphql-introspection-filter`]},{name:`Monetization & Metering`,baseIds:[`monetization`,`openmeter`,`amberflo-metering`,`moesif`,`readme-metrics`]},{name:`Logging & Tracing`,baseIds:[`audit-log`]},{name:`Upstream Auth`,baseIds:[`set-upstream-api-key`,`upstream-azure-ad-service-auth`,`upstream-firebase-admin-auth`,`upstream-firebase-user-auth`,`upstream-gcp-federated-auth`,`upstream-gcp-jwt`,`upstream-gcp-service-auth`,`upstream-zuplo-jwt-auth`]},{name:`Custom & Composite`,baseIds:[`custom-code`,`composite`]}],rjt=/-(inbound|outbound|internal)$/,G4=e=>e.replace(rjt,``),K4=new Map;for(let e of njt)for(let t of e.baseIds)K4.has(t)||K4.set(t,e.name);var ijt=e=>K4.get(G4(e.id))??`Other`,ajt=e=>K4.get(G4(e))===`Authentication`,ojt=e=>tjt.includes(G4(e.id)),sjt=e=>{let t=new Map,n=[];for(let r of e){ojt(r)&&n.push(r);let e=ijt(r),i=t.get(e);i?i.push(r):t.set(e,[r])}let r=[];n.length>0&&r.push({name:$At,policies:n});for(let{name:e}of njt){let n=t.get(e);n&&n.length>0&&r.push({name:e,policies:n})}let i=t.get(ejt);return i&&i.length>0&&r.push({name:ejt,policies:i}),r},cjt=[...U4.map(e=>e.policyType)];function ljt(e){return cjt.includes(e)||ajt(e)}var q4=`mcp-token-exchange-inbound`,J4=`mcp-capability-filter-inbound`,ujt=`set-upstream-api-key-inbound`,djt=`remove-headers-inbound`;function Y4(e){if(!e||typeof e!=`object`)return!1;let t=e.headers;if(!Array.isArray(t)||t.length!==1)return!1;let[n]=t;return typeof n==`string`&&n.toLowerCase()===`authorization`}var fjt=e=>e.toLowerCase().replaceAll(` `,`-`),X4=({name:e,onChangeName:t,disabled:n,policies:r})=>{let[i,a]=(0,H.useState)(null);return(0,U.jsxs)(`div`,{className:`grid grid-cols-12 text-sm gap-2 items-center pt-1`,children:[(0,U.jsx)(`label`,{className:`col-span-1`,children:`Name`}),(0,U.jsx)(`div`,{className:`col-span-11`,children:(0,U.jsx)(gT,{type:`text`,id:`route-handler`,"data-test":`policy-picker-name-input`,name:`route-handler`,value:e??``,disabled:n,onChange:e=>{let n=e.currentTarget.value,i=fjt(n.toLowerCase());a(byt(i,r)),t(i)},"aria-describedby":`email-description`})}),i&&(0,U.jsx)(`div`,{className:`col-span-11 col-start-2 mt-1 text-red-600`,children:i})]})},pjt=({documentationSrc:e,className:t})=>(0,U.jsx)(`div`,{className:W(`prose prose-neutral prose-sm dark:prose-invert z-10 prose-headings:mt-2 prose-headings:text-sm max-w-full [&_li>div]:inline [&_li>div>p]:inline [&_code::before]:content-none [&_code::after]:content-none`,t),dangerouslySetInnerHTML:{__html:e}}),mjt=({documentationSrc:e})=>(0,U.jsxs)(`div`,{className:`px-4 py-2 border-t h-full overflow-y-auto h-[stretch]`,children:[(0,U.jsx)(`h3`,{className:`text-lg font-medium text-foreground`,children:`Documentation`}),(0,U.jsx)(pjt,{documentationSrc:e})]}),hjt={[J4]:(0,H.lazy)(()=>vn(()=>import(`./McpCapabilityFilterDesigner-DXYtp7x8.js`),__vite__mapDeps([7,1,8,2])))};function gjt(e){return e?hjt[e]:void 0}var _jt=(e=!1)=>async({queryKey:t})=>{let[n]=t;if(typeof n!=`string`)throw new ot({type:`https://zup.fail/invalid-query-key`,title:`Invalid query key`});let r=new Request(n),i;try{i=await fetch(r)}catch(e){throw e instanceof TypeError?new ot({type:`https://zup.fail/api-request-failed`,title:`API request failed`,status:500,instance:n}):e}if(!i.ok){let e=new s(`Error while making request. Please try again or contact support if the problem persists.`);throw await e.tryReadResponse(i),e}try{return await(e?i.clone().json():i.clone().text())}catch(e){let t=await i.clone().text();throw Wt.captureException(e,{message:`Failed to parse response of ${n} to JSON`,responseText:t,status:i.status,requestUrl:n}),e}};function Z4(e,{json:t,...n}={}){return k({queryKey:[e.url],queryFn:_jt(t),...n})}var Q4=(e={})=>Z4(je.cdnContent(`/portal/policies.v6.json`),{...e,json:!0}),vjt=(e,t={})=>Z4({url:e??``},{...t,enabled:!!e&&t.enabled!==!1,json:!0}),yjt={type:`object`,properties:{handler:{type:`object`,properties:{options:{type:`object`,title:`Ensure Gateway Internal Invocation Only`,"x-no-options":!0,description:`Accepts only requests this gateway made itself with context.invokeRoute, and answers anything that arrived over the network with 403 Forbidden.
486
486
 
487
487
  Put it on an app that nothing outside the gateway calls — the classifier app behind Smart Router or Prompt Injection Protection, say — in place of API Key Authentication. Those calls never leave the gateway, so a key on them protects nothing; this checks the one thing that does, that the request started inside the deployment.`,additionalProperties:!1,properties:{}}}}}},bjt={"ai-gateway-internal-only-inbound":yjt},xjt=e=>e?bjt[e]:void 0;function Sjt(e){return e[`x-no-options`]===!0&&!!e.description}function Cjt(e){let t=e?.properties?.handler?.properties?.options;if(!(!t||t.type!==`object`)&&(Sjt(t)||!(!t.properties||Object.keys(t.properties).length===0)))return t}function wjt(e){let t=Ejt(e);if(t){let e=t.every(e3),n=t.some(e3);return e?`string-array`:n?`multiline-text`:`text`}if(e.oneOf||e.anyOf||e.allOf||e.const)return`json`;if(e.enum)return e.enum.every(e=>typeof e==`string`)?`select`:`json`;if(typeof e.type!=`string`)return`json`;switch(e.type){case`boolean`:return`boolean`;case`number`:case`integer`:return`number`;case`string`:return`text`;case`array`:{let t=e.items;if(t&&!Array.isArray(t)){if(t.type===`string`&&!t.oneOf&&!t.anyOf&&!t.allOf)return`string-array`;if(t.type===`object`&&t.properties&&Object.keys(t.properties).length>0)return`object-array`}return`json`}case`object`:{if(e.properties&&Object.keys(e.properties).length>0)return`object`;let t=e.additionalProperties;return t&&typeof t==`object`&&(t.type===`string`||t.type===`number`||t.type===`integer`)?`record`:`json`}default:return`json`}}function $4(e,t){return e.required?.includes(t)??!1}function Tjt(e){return e[`x-advanced`]===!0||e[`x-show-example`]===!1}function Ejt(e){if(e.allOf||e.const||e.enum)return;let t=e.oneOf??e.anyOf;if(!(!t||t.length===0)&&t.every(e=>Djt(e)||e3(e)))return t}function Djt(e){return e.type===`string`&&!e.enum&&!e.const&&!e.oneOf&&!e.anyOf&&!e.allOf}function e3(e){let t=e.items;return e.type===`array`&&!!t&&!Array.isArray(t)&&Djt(t)&&!e.oneOf&&!e.anyOf&&!e.allOf}var Ojt=()=>{let e=(0,H.useContext)(Dp);return!!(e?.account&&e?.project)},kjt=({children:e,onInject:t,isEnabled:n=!0})=>{let r=Ojt();return!n||!r?(0,U.jsx)(`div`,{className:`relative w-full`,children:e}):(0,U.jsx)(Ajt,{onInject:t,children:e})},Ajt=({children:e,onInject:t})=>{let n=Op([`account`,`project`]),r=vR(n.account.name,n.project.name);return(0,U.jsxs)(ow,{children:[(0,U.jsxs)(`div`,{className:`relative w-full`,children:[e,(0,U.jsx)(sw,{asChild:!0,children:(0,U.jsx)(X,{variant:`ghost`,size:`icon-sm`,className:`flex-none ml-1 absolute top-1 right-1 bg-card`,title:`Select environment variable`,children:(0,U.jsx)(mee,{className:`w-4`})})})]}),(0,U.jsxs)(lw,{children:[(0,U.jsxs)(uw,{children:[(0,U.jsx)(fw,{children:`Environment Variables`}),(0,U.jsx)(pw,{asChild:!0,children:(0,U.jsxs)(CA,{className:`mt-4 divide-y divide-double bg-gray-50 dark:bg-neutral-900 max-h-96 overflow-y-auto`,children:[r.isPending?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(bD,{className:`h-6 w-2/3 m-1`}),(0,U.jsx)(bD,{className:`h-6 w-2/3 m-1`}),(0,U.jsx)(bD,{className:`h-6 w-2/3 m-1`})]}):r.data?.length===0&&(0,U.jsx)(`div`,{className:`p-2`,children:`No environment variables`}),r.data?.map(e=>(0,U.jsxs)(`div`,{className:`p-2 py-3 flex justify-between items-center`,children:[(0,U.jsx)(`div`,{children:e.name}),(0,U.jsx)(cw,{asChild:!0,children:(0,U.jsx)(X,{variant:`outline`,size:`xs`,className:`flex-none`,onClick:()=>t(e,`$env(${e.name})`),children:`Use`})})]},e.id))]})})]}),(0,U.jsx)(dw,{children:(0,U.jsx)(cw,{children:(0,U.jsx)(X,{type:`submit`,variant:`outline`,children:`Close`})})})]})]})},t3=(0,H.createContext)(!0),n3=(0,H.createContext)([]),r3=({schema:e,value:t,onChange:n,disabled:r,allowEnvVariables:i,fieldControls:a})=>{let o=(0,H.useContext)(t3),s=i??o,c=(0,H.useContext)(n3),l=a??c,u=(e,r)=>{if(r===void 0){let{[e]:r,...i}=t;n(i)}else n({...t,[e]:r})},d=(n,i)=>(0,U.jsx)(Mjt,{name:n,schema:i,parentSchema:e,required:$4(e,n),value:t[n],onChange:e=>u(n,e),disabled:r},n),f=Object.entries(e.properties??{}),p=(t,n)=>Tjt(n)&&!$4(e,t),m=f.filter(([e,t])=>p(e,t)),h=f.filter(([e,t])=>!p(e,t)),g=[...h.filter(([t])=>$4(e,t)),...h.filter(([t])=>!$4(e,t))];return(0,U.jsx)(t3.Provider,{value:s,children:(0,U.jsx)(n3.Provider,{value:l,children:(0,U.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[f.length===0&&(0,U.jsxs)(`div`,{className:`rounded-md border bg-surface-muted px-4 py-3`,children:[(0,U.jsx)(`p`,{className:`text-sm font-medium`,children:`This policy has no options`}),e.description&&(0,U.jsx)(`p`,{className:`mt-1 whitespace-pre-line text-sm text-muted-foreground`,children:e.description})]}),g.map(([e,t])=>d(e,t)),m.length>0&&(0,U.jsx)(jjt,{defaultOpen:m.some(([e])=>t[e]!==void 0),children:m.map(([e,t])=>d(e,t))})]})})})},jjt=({defaultOpen:e,children:t})=>{let[n,r]=(0,H.useState)(e);return(0,U.jsxs)(fT,{open:n,onOpenChange:r,children:[(0,U.jsxs)(pT,{className:`flex items-center gap-1 text-sm font-medium text-muted-foreground transition-colors hover:text-foreground`,children:[(0,U.jsx)(md,{className:W(`size-4 transition-transform`,n&&`rotate-90`)}),n?`Hide advanced options`:`Show advanced options`]}),(0,U.jsx)(mT,{className:`flex flex-col gap-5 pt-5`,children:t})]})},Mjt=({name:e,schema:t,parentSchema:n,required:r,value:i,onChange:a,disabled:o})=>{let s=(0,H.useId)(),c=wjt(t),l=t.description?`${s}-description`:void 0,u=(0,H.useContext)(n3).find(r=>r.matches(e,t,n)),d=u?.annotate?`${s}-annotation`:void 0,f=[l,d].filter(Boolean).join(` `)||void 0,p={id:s,name:e,schema:t,required:r,value:i,onChange:a,disabled:o,descriptionId:f},m=(0,U.jsx)(Njt,{htmlFor:s,name:e,schema:t,required:r,descriptionId:l}),h=u?.annotate?(0,U.jsx)(`div`,{id:d,className:`flex flex-col gap-1`,children:u.annotate(p)}):null;if(u?.render)return(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[m,u.render(p),h]});if(c===`boolean`){let e=(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[m,(0,U.jsx)(I1,{id:s,"aria-describedby":f,checked:typeof i==`boolean`?i:t.default===!0,onCheckedChange:e=>a(e),disabled:o})]});return h?(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[e,h]}):e}return(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[m,(0,U.jsx)(Pjt,{id:s,name:e,descriptionId:f,kind:c,schema:t,required:r,value:i,onChange:a,disabled:o}),h]})},Njt=({htmlFor:e,name:t,schema:n,required:r,descriptionId:i})=>(0,U.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,U.jsxs)(yT,{htmlFor:e,className:`capitalize`,children:[t,r?(0,U.jsx)(`span`,{className:`text-destructive`,children:` *`}):(0,U.jsx)(`span`,{className:`ml-1 font-normal normal-case text-muted-foreground`,children:`(optional)`})]}),n.description&&(0,U.jsx)(`span`,{id:i,className:`text-xs text-muted-foreground`,children:n.description})]}),Pjt=({id:e,name:t,descriptionId:n,kind:r,schema:i,required:a,value:o,onChange:s,disabled:c})=>{switch(r){case`text`:return(0,U.jsx)(Ijt,{id:e,name:t,descriptionId:n,schema:i,required:a,value:o,onChange:s,disabled:c});case`multiline-text`:return(0,U.jsx)(Ljt,{id:e,descriptionId:n,value:o,onChange:s,disabled:c});case`number`:return(0,U.jsx)(gT,{id:e,type:`number`,"aria-describedby":n,step:i.type===`integer`?1:void 0,value:typeof o==`number`?o:``,placeholder:typeof i.default==`number`?String(i.default):void 0,onChange:e=>{let t=e.target.value===``?NaN:Number(e.target.value);s(Number.isNaN(t)?void 0:t)},disabled:c});case`select`:return(0,U.jsxs)(CY,{value:typeof o==`string`?o:mnt,onValueChange:e=>s(e===`__UNSET`?void 0:e),disabled:c,children:[(0,U.jsx)(TY,{id:e,"aria-describedby":n,className:`w-full`,children:(0,U.jsx)(wY,{placeholder:`Select an option`})}),(0,U.jsxs)(EY,{children:[!a&&(0,U.jsx)(DY,{value:`__UNSET`,children:(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:`Not set`})}),(i.enum??[]).filter(e=>typeof e==`string`).map(e=>(0,U.jsx)(DY,{value:e,children:e},e))]})]});case`string-array`:return(0,U.jsx)(Rjt,{value:o,onChange:s,disabled:c});case`object-array`:return(0,U.jsx)(zjt,{schema:i,value:o,onChange:s,disabled:c});case`record`:return(0,U.jsx)(Bjt,{schema:i,value:o,onChange:s,disabled:c});case`object`:return(0,U.jsx)(`div`,{className:`border rounded-md p-3 ml-1`,children:(0,U.jsx)(r3,{schema:i,value:a3(o)?o:{},onChange:e=>s(Object.keys(e).length===0?void 0:e),disabled:c})});case`json`:return(0,U.jsx)(Vjt,{id:e,value:o,onChange:s,disabled:c})}};function Fjt(e,t){if(!t&&!(typeof e.default!=`string`||e.default===``)&&!(typeof e.minLength==`number`&&e.minLength>=1)&&!e.pattern)return e.default}var Ijt=({id:e,name:t,descriptionId:n,schema:r,required:i,value:a,onChange:o,disabled:s})=>{let c=(0,H.useId)(),l=typeof r.default==`string`?r.default:void 0,u=Fjt(r,i),d=u!==void 0,f=d&&a===``,p=d&&a===void 0,m=typeof a==`string`?a:``,h=[n,d?c:void 0].filter(Boolean).join(` `)||void 0;return(0,U.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(i3,{id:e,value:m,placeholder:a===``?void 0:l,describedById:h,onValueChange:e=>o(e===``?void 0:e),disabled:s}),d&&(0,U.jsx)(`p`,{className:`flex flex-wrap items-baseline gap-x-2 text-xs text-muted-foreground`,children:f?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`span`,{id:c,children:[`Empty value set. The default (`,u,`) is not applied.`]}),!s&&(0,U.jsx)(X,{variant:`link`,size:`xs`,className:`h-auto p-0 text-xs`,"aria-label":`Use the default for ${t}`,onClick:()=>o(void 0),children:`Use the default`})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`span`,{id:c,children:[`Leave blank to use the default (`,u,`).`]}),p&&!s&&(0,U.jsx)(X,{variant:`link`,size:`xs`,className:`h-auto p-0 text-xs`,"aria-label":`Use an empty value for ${t}`,onClick:()=>o(``),children:`Use an empty value`})]})})]})},Ljt=({id:e,descriptionId:t,value:n,onChange:r,disabled:i})=>{let a=Hjt(n);return(0,U.jsx)(HC,{id:e,"aria-describedby":t,value:a,rows:6,onChange:e=>{let t=e.target.value;r(t===``?void 0:t)},disabled:i})},i3=({id:e,value:t,placeholder:n,onValueChange:r,disabled:i,describedById:a})=>{let o=(0,H.useContext)(t3),s=Ojt(),c=o&&s&&!i;return(0,U.jsx)(kjt,{isEnabled:c,onInject:(e,t)=>r(t),children:(0,U.jsx)(gT,{id:e,value:t,placeholder:n,"aria-describedby":a,onChange:e=>r(e.target.value),disabled:i,className:W(c&&`pr-10`)})})},Rjt=({value:e,onChange:t,disabled:n})=>{let r=Array.isArray(e)?e.map(e=>typeof e==`string`?e:String(e)):[],i=e=>{t(e.length===0?void 0:e)};return(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[r.map((e,t)=>(0,U.jsxs)(`div`,{className:`flex gap-2`,children:[(0,U.jsx)(i3,{value:e,onValueChange:e=>{let n=[...r];n[t]=e,i(n)},disabled:n}),(0,U.jsx)(X,{variant:`ghost`,size:`icon`,"aria-label":`Remove item`,onClick:()=>i(r.filter((e,n)=>n!==t)),disabled:n,children:(0,U.jsx)(pp,{className:`size-4`})})]},t)),(0,U.jsxs)(X,{variant:`outline`,size:`sm`,className:`self-start`,onClick:()=>i([...r,``]),disabled:n,children:[(0,U.jsx)(Mf,{className:`size-4`}),`Add item`]})]})},zjt=({schema:e,value:t,onChange:n,disabled:r})=>{let i=Array.isArray(e.items)?void 0:e.items,a=Array.isArray(t)?t:[],o=e=>{n(e.length===0?void 0:e)};return i?(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[a.map((e,t)=>(0,U.jsxs)(`div`,{className:`relative border rounded-md p-3 pr-10`,children:[(0,U.jsx)(r3,{schema:i,value:a3(e)?e:{},onChange:e=>{let n=[...a];n[t]=e,o(n)},disabled:r}),(0,U.jsx)(X,{variant:`ghost`,size:`icon`,"aria-label":`Remove item`,className:`absolute top-2 right-2`,onClick:()=>o(a.filter((e,n)=>n!==t)),disabled:r,children:(0,U.jsx)(pp,{className:`size-4`})})]},t)),(0,U.jsxs)(X,{variant:`outline`,size:`sm`,className:`self-start`,onClick:()=>o([...a,{}]),disabled:r,children:[(0,U.jsx)(Mf,{className:`size-4`}),`Add item`]})]}):null},Bjt=({schema:e,value:t,onChange:n,disabled:r})=>{let i=typeof e.additionalProperties==`object`?e.additionalProperties.type:`string`,a=i===`number`||i===`integer`,[o,s]=(0,H.useState)(()=>a3(t)?Object.entries(t).map(([e,t])=>({key:e,value:String(t)})):[]),c=e=>{s(e);let t={};for(let n of e)if(n.key!==``)if(a){if(n.value.trim()===``)continue;let e=Number(n.value);if(Number.isNaN(e))continue;t[n.key]=e}else t[n.key]=n.value;n(Object.keys(t).length===0?void 0:t)};return(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[o.map((e,t)=>(0,U.jsxs)(`div`,{className:`flex gap-2`,children:[(0,U.jsx)(gT,{value:e.key,placeholder:`Key`,onChange:n=>{let r=[...o];r[t]={...e,key:n.target.value},c(r)},disabled:r}),a?(0,U.jsx)(gT,{value:e.value,placeholder:`Value`,type:`number`,onChange:n=>{let r=[...o];r[t]={...e,value:n.target.value},c(r)},disabled:r}):(0,U.jsx)(i3,{value:e.value,placeholder:`Value`,onValueChange:n=>{let r=[...o];r[t]={...e,value:n},c(r)},disabled:r}),(0,U.jsx)(X,{variant:`ghost`,size:`icon`,"aria-label":`Remove entry`,onClick:()=>c(o.filter((e,n)=>n!==t)),disabled:r,children:(0,U.jsx)(pp,{className:`size-4`})})]},t)),(0,U.jsxs)(X,{variant:`outline`,size:`sm`,className:`self-start`,onClick:()=>c([...o,{key:``,value:``}]),disabled:r,children:[(0,U.jsx)(Mf,{className:`size-4`}),`Add entry`]})]})},Vjt=({id:e,value:t,onChange:n,disabled:r})=>{let[i,a]=(0,H.useState)(()=>t===void 0?``:JSON.stringify(t,void 0,2)),[o,s]=(0,H.useState)(!1);return(0,U.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(HC,{id:e,className:W(`font-mono text-xs`,o&&`border-destructive`),value:i,placeholder:`JSON value`,onChange:e=>{let t=e.target.value;if(a(t),t.trim()===``){s(!1),n(void 0);return}try{n(JSON.parse(t)),s(!1)}catch{s(!0)}},disabled:r}),o&&(0,U.jsx)(`span`,{className:`text-xs text-destructive`,children:`Invalid JSON — the last valid value will be saved.`})]})};function a3(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Hjt(e){return typeof e==`string`?e:Array.isArray(e)&&e.every(e=>typeof e==`string`)?e.join(`
488
488
  `):``}var Ujt=({designConfig:e,policyType:t,defaultHandler:n,isReadOnly:r,hasError:i,codeTabLabel:a,documentationSrc:o,designerContext:s,ref:c})=>{let{logEvent:l}=S(),u=xjt(e?.id),d=vjt(u?void 0:e?.optionsSchemaUrl),f=Cjt(u??d.data),p=!!f,m=!!o,h=gjt(t),g=!!h,[_,v]=(0,H.useState)(n),[y,b]=(0,H.useState)(),[x,C]=(0,H.useState)(null),w=(0,H.useRef)(void 0),T=y??(g?`designer`:p?`form`:`code`),E=()=>{let e=w.current?.getValue();if(!e)throw Error(`The policy configuration is empty`);return JSON.parse(e)};(0,H.useImperativeHandle)(c,()=>({getHandler:()=>T===`code`?E():_}));let D=t=>{if(t!==T){if(T===`code`)try{v(E())}catch(e){C(`Fix the JSON before switching: ${e instanceof Error?e.message:`Unknown error`}`);return}t===`code`&&w.current?.setValue(JSON.stringify(_,void 0,2)),C(null),b(t),l(`policy-form-editor-mode-switched`,{policy:e?.id,mode:t})}};if(d.isLoading)return(0,U.jsx)(`div`,{className:`flex items-center justify-center min-h-40`,children:(0,U.jsx)(WI,{className:`w-5 h-5 border-2`})});let O=g||p;return(0,U.jsxs)(`div`,{className:`flex flex-col min-h-0 min-w-0 h-full`,children:[(0,U.jsx)(`div`,{className:`flex items-center gap-2 border-b p-2`,children:(0,U.jsx)(GD,{variant:`outline`,type:`single`,value:T,onValueChange:e=>{e&&D(e)},children:[...g?[{value:`designer`,label:`Designer`}]:[],...p?[{value:`form`,label:`Form`}]:[],{value:`code`,label:O?`Code`:a},...m?[{value:`docs`,label:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(ed,{}),`Docs`]})}]:[]].map(({value:e,label:t})=>(0,U.jsx)(KD,{value:e,variant:`outline`,size:`xs`,className:`gap-1 px-2`,children:t},e))})}),x&&(0,U.jsx)(`p`,{className:`text-sm text-red-500 mx-3 mt-2`,children:x}),h&&(0,U.jsx)(`div`,{className:W(`flex-1 min-h-0 min-w-0 overflow-y-auto p-4`,T!==`designer`&&`hidden`),children:(0,U.jsx)(H.Suspense,{fallback:(0,U.jsx)(`div`,{className:`flex items-center justify-center min-h-40`,children:(0,U.jsx)(WI,{className:`w-5 h-5 border-2`})}),children:(0,U.jsx)(h,{options:_.options,onChange:e=>v({..._,options:e}),isReadOnly:r,operation:s?.operation,policyManager:s?.policyManager})})}),p&&T===`form`&&f&&(0,U.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-y-auto p-4`,children:(0,U.jsx)(r3,{schema:f,value:Wjt(_.options)?_.options:{},onChange:e=>v({..._,options:e}),disabled:r})}),(0,U.jsx)(`div`,{className:W(`flex-1 min-h-0 min-w-0`,T!==`code`&&`hidden`),children:(0,U.jsx)(rL,{options:{...lQ,readOnly:r,automaticLayout:!0},className:W({"border border-red-500":i}),width:`100%`,height:`100%`,language:`json`,onMount:e=>{w.current=e},defaultValue:JSON.stringify(_,void 0,2)})}),m&&T===`docs`&&o&&(0,U.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-y-auto p-4`,children:(0,U.jsx)(pjt,{documentationSrc:o})})]})};function Wjt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var o3=({designConfig:e,policyType:t,defaultHandler:n,initialName:r,policies:i,isReadOnly:a=!1,nameDisabled:o=!1,codeTabLabel:s=`Configuration`,designerContext:c,ref:l})=>{let[u,d]=(0,H.useState)(r),[f,p]=(0,H.useState)(null),m=(0,H.useRef)(null);return(0,H.useImperativeHandle)(l,()=>({getPolicyConfig:()=>{let e=byt(u,i);if(e)throw p(e),Error(e);if(!m.current)throw Error(`The policy editor is not ready`);try{let e=m.current.getHandler();return p(null),{name:u,handler:e}}catch(e){let t=e instanceof Error?e.message:`Unknown error`;throw p(t),Error(t)}}})),(0,U.jsxs)(`div`,{className:`flex flex-col w-full h-full min-h-0`,children:[(0,U.jsx)(X4,{name:u,onChangeName:d,disabled:o,policies:i}),(0,U.jsx)(`div`,{className:`border rounded overflow-hidden mt-4 flex-1 min-h-0 min-w-0`,children:(0,U.jsx)(Ujt,{ref:m,designConfig:e,policyType:t,defaultHandler:n,isReadOnly:a,hasError:!!f,codeTabLabel:s,documentationSrc:e?.exampleHtml,designerContext:c})}),f&&(0,U.jsx)(`p`,{className:`text-red-500 ml-2 mt-1`,children:f})]})},Gjt=`Invalid Rewrite URL provided`,Kjt=`Tip: Use the API Test Console to test the behavior of request properties and environment variables.`,qjt=e=>`${e} is not a valid pattern`,Jjt=e=>`Failed to parse component(s), rewrite result: ${e}`,Yjt=e=>`${e} is not a valid URL`,s3=new Proxy({},{get(e,t){return typeof t==`symbol`?()=>`superProxy.toString()`:s3}}),Xjt=e=>{if(e===``)return{errorType:`Error`,message:Gjt};let t={url:new URL(`https://www.zuplo.com`),host:``,hostname:``,origin:``,port:``,protocol:``,headers:new Headers({}),params:{},pathname:``,method:``,query:{},search:``,env:s3,request:s3,e:encodeURIComponent,context:s3},n=(e,t={})=>Function(`vars`,[`const tagged = ( ${Object.keys(t).join(`, `)} ) =>`,`\`${e}\``,`return tagged(...Object.values(vars))`].join(`
@@ -1566,7 +1566,7 @@ In some cases, you need to provide options to alter GraphQL's execution behavior
1566
1566
  `+t+`)`}function b8(e){let t=d8(e.defaultValue,e.type),n=e.name+`: `+String(e.type);return t&&(n+=` = ${wn(t)}`),n+x8(e.deprecationReason)}function qzt(e){return S8(e)+`directive @`+e.name+Kzt(e.args)+(e.isRepeatable?` repeatable`:``)+` on `+e.locations.join(` | `)}function x8(e){return e==null?``:e===`No longer supported`?` @deprecated`:` @deprecated(reason: ${wn({kind:rr.STRING,value:e})})`}function Jzt(e){return e.specifiedByURL==null?``:` @specifiedBy(url: ${wn({kind:rr.STRING,value:e.specifiedByURL})})`}function S8(e,t=``,n=!0){let{description:r}=e;if(r==null)return``;let i=wn({kind:rr.STRING,value:r,block:Pn(r)});return(t&&!n?`
1567
1567
  `+t:t)+i.replace(/\n/g,`
1568
1568
  `+t)+`
1569
- `}var C8=`/docs/schema.graphql`,Yzt=()=>JSON.stringify({query:Azt()}),Xzt=e=>{if(!e)throw Error(`The endpoint returned an empty response.`);let t;try{t=JSON.parse(e)}catch{throw Error(`The endpoint did not return a valid JSON response.`)}if(t.errors?.length)throw Error(`The introspection query returned errors: ${t.errors.map(e=>e.message).join(`; `)}`);if(!t.data?.__schema)throw Error(`The endpoint did not return an introspection result. Make sure introspection is enabled.`);try{return`${Mzt(jzt(t.data))}\n`}catch(e){throw Error(`Could not build a schema from the introspection result: ${e instanceof Error?e.message:String(e)}`)}},Zzt=({endpointUrl:e,rewriteUrl:t,ape:n,onClose:r})=>{let{logEvent:i}=S(),a=Ep(),o=eQ(),s=GR(),[c,l]=(0,H.useState)(t??e),[u,d]=(0,H.useState)([{key:``,value:``}]),[f,p]=(0,H.useState)(!1),[m,h]=(0,H.useState)(),g=(e,t,n)=>{d(r=>r.map((r,i)=>i===e?{...r,[t]:n}:r))},_=()=>d(e=>[...e,{key:``,value:``}]),v=e=>d(t=>t.filter((t,n)=>n!==e)),y=async()=>{h(void 0),p(!0);let l=c===t?`handler`:c===e?`gateway`:`custom`,d={account:n.account.name,project:n.project.name,environment:n.environment.name,endpointMode:l};i(`graphql-schema-introspection-run`,d);let f=`request`,m;try{let e;try{f=`invalid_url`,e=new URL(c)}catch{throw Error(`Enter a valid endpoint URL, including the protocol (e.g. https://).`)}let t={"content-type":`application/json`};for(let{key:e,value:n}of u){let r=e.trim();r.length>0&&(t[r]=n)}f=`request`;let l=await(await s({environmentName:n.environment.name,testRequest:{description:`GraphQL introspection`,pathname:`${e.pathname}${e.search}`,method:`POST`,headers:t,body:Yzt()},overrideUrl:e.origin})).json();if(m=l.status,l.status<200||l.status>=300)throw f=`upstream_status`,Error(`The endpoint responded with ${l.status} ${l.statusText??``}.`.trim());f=`introspection`;let p=Xzt(l.body);f=`save`,await o.mutateAsync({file:{path:C8,content:p},accountName:n.account.name,projectName:n.project.name,environmentName:n.environment.name}),i(`graphql-schema-introspection-success`,{...d,upstreamStatus:m}),a.success(`Schema saved to ${C8}`),r()}catch(e){let t=e instanceof Error?e.message:String(e);i(`graphql-schema-introspection-failed`,{...d,stage:f,upstreamStatus:m,reason:t}),h(t)}finally{p(!1)}};return(0,U.jsx)(ow,{open:!0,onOpenChange:e=>!e&&!f&&r(),children:(0,U.jsxs)(lw,{className:`sm:max-w-2xl`,children:[(0,U.jsxs)(uw,{children:[(0,U.jsx)(fw,{children:`Download GraphQL schema`}),(0,U.jsxs)(pw,{children:[`Run an introspection query against this endpoint. On success the schema is stored in `,(0,U.jsx)(`code`,{children:C8}),`.`]})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,U.jsx)(yT,{htmlFor:`graphql-introspection-endpoint`,children:`Endpoint`}),e&&e!==c&&(0,U.jsx)(X,{variant:`link`,size:`xs`,type:`button`,className:`h-auto p-0`,disabled:f,onClick:()=>l(e),children:`Use gateway URL`})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(gT,{id:`graphql-introspection-endpoint`,value:c,onChange:e=>l(e.target.value),placeholder:`https://example.com/graphql`,disabled:f,"data-op-ignore":!0}),(0,U.jsx)(GI,{textToCopy:c})]})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,U.jsx)(yT,{children:`Headers (optional)`}),(0,U.jsx)(`div`,{className:`flex flex-col gap-2`,children:u.map((e,t)=>(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(gT,{placeholder:`Header name`,value:e.key,onChange:e=>g(t,`key`,e.target.value),"data-op-ignore":!0}),(0,U.jsx)(gT,{placeholder:`Value`,value:e.value,onChange:e=>g(t,`value`,e.target.value),"data-op-ignore":!0}),(0,U.jsx)(X,{variant:`ghost`,size:`icon`,type:`button`,"aria-label":`Remove header`,onClick:()=>v(t),children:(0,U.jsx)(op,{className:`size-4`})})]},t))}),(0,U.jsx)(`div`,{children:(0,U.jsxs)(X,{variant:`outline`,size:`sm`,type:`button`,onClick:_,children:[(0,U.jsx)(Mf,{className:`size-4`}),(0,U.jsx)(`span`,{children:`Add header`})]})})]}),m&&(0,U.jsxs)(Ub,{variant:`destructive`,children:[(0,U.jsx)(vd,{}),(0,U.jsx)(Wb,{children:`Introspection failed`}),(0,U.jsx)(Gb,{className:`break-words`,children:m})]})]}),(0,U.jsxs)(dw,{children:[(0,U.jsx)(cw,{asChild:!0,children:(0,U.jsx)(X,{variant:`outline`,type:`button`,disabled:f,children:`Cancel`})}),(0,U.jsx)(X,{variant:`brand`,type:`button`,onClick:y,disabled:f||c.trim().length===0,children:f?`Running…`:`Run introspection`})]})]})})},Qzt=({path:e,rewriteUrl:t})=>{let n=Op(),r=ao(),{logEvent:i}=S(),[a,o]=(0,H.useState)(!1),s=KR(n.environment),c=s?new URL(e,s).toString():void 0;return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(uJ,{children:[(0,U.jsx)(dJ,{asChild:!0,children:(0,U.jsxs)(X,{variant:`outline`,children:[(0,U.jsx)(C1,{className:`size-4 shrink-0`}),(0,U.jsx)(`span`,{children:`Schema`}),(0,U.jsx)(pd,{className:`size-4 shrink-0`})]})}),(0,U.jsxs)(fJ,{align:`end`,children:[(0,U.jsxs)(mJ,{onSelect:()=>{i(`graphql-schema-open`,{account:n.account.name,project:n.project.name,environment:n.environment.name}),r({pathname:ri(rx.Code,{account:n.account.name,project:n.project.name,environment:encodeURIComponent(n.environment.urlParameter)}),search:`?path=${C8}`})},children:[(0,U.jsx)(Xd,{className:`size-4`}),(0,U.jsx)(`span`,{children:`Open Schema`})]}),(0,U.jsxs)(mJ,{disabled:!c,onSelect:()=>o(!0),children:[(0,U.jsx)(zd,{className:`size-4`}),(0,U.jsx)(`span`,{children:`Download Schema`})]})]})]}),a&&c&&(0,U.jsx)(Zzt,{endpointUrl:c,rewriteUrl:t,ape:n,onClose:()=>o(!1)})]})},$zt=({operationTags:e,onTagsChanged:t})=>{let{isReadOnly:n}=HZ(),r=f1(),[i,a]=(0,H.useState)(``),o=r.openApiData?.tags?.map(e=>e.name)??[],s=n=>{e.includes(n)?t(e.filter(e=>e!==n)):t([...e,n])},c=()=>{let n=i.trim();if(n){if(!o.includes(n))try{r.addTag(n)}catch{}e.includes(n)||t([...e,n]),a(``)}};return(0,U.jsxs)(Vw,{children:[(0,U.jsx)(Hw,{asChild:!0,children:(0,U.jsxs)(x6,{children:[(0,U.jsx)(ep,{size:16}),e.length===1?(0,U.jsx)(`span`,{className:`truncate max-w-[12ch]`,title:e[0],children:e[0]}):`${e.length} Tags`]})}),(0,U.jsxs)(Uw,{className:`w-64 p-0 z-100`,align:`end`,children:[(0,U.jsx)(`div`,{className:`px-3 pt-3 pb-2`,children:(0,U.jsx)(`h4`,{className:`text-sm font-medium`,children:`Operation Tags`})}),o.length>0&&(0,U.jsx)(`div`,{className:`border-t max-h-48 overflow-y-auto`,children:o.map(t=>(0,U.jsxs)(`button`,{type:`button`,disabled:n,className:`w-full flex items-center justify-between px-3 py-1.5 text-sm hover:bg-accent disabled:opacity-50 disabled:cursor-default cursor-pointer`,onClick:()=>s(t),children:[(0,U.jsx)(`span`,{className:`truncate`,children:t}),(0,U.jsx)(fd,{size:14,className:W(`shrink-0`,!e.includes(t)&&`invisible`)})]},t))}),!n&&(0,U.jsx)(`div`,{className:`border-t p-2`,children:(0,U.jsxs)(`form`,{className:`flex gap-1`,onSubmit:e=>{e.preventDefault(),c()},children:[(0,U.jsx)(gT,{value:i,onChange:e=>a(e.target.value),placeholder:`New tag...`,className:`h-7 text-xs`}),(0,U.jsx)(X,{type:`submit`,variant:`outline`,size:`icon-sm`,disabled:!i.trim(),children:(0,U.jsx)(Mf,{size:14})})]})})]})]})},eBt=r(a((e=>{var t=/~/,n=/~[01]/g;function r(e){switch(e){case`~1`:return`/`;case`~0`:return`~`}throw Error(`Invalid tilde escape: `+e)}function i(e){return t.test(e)?e.replace(n,r):e}function a(e){if(typeof e==`string`){if(e=e.split(`/`),e[0]===``)return e;throw Error(`Invalid JSON pointer.`)}else if(Array.isArray(e)){for(let t of e)if(typeof t!=`string`&&typeof t!=`number`)throw Error(`Invalid JSON pointer. Must be of type string or number.`);return e}throw Error(`Invalid JSON pointer.`)}function o(e,t){if(typeof e!=`object`)throw Error(`Invalid input object.`);t=a(t);var n=t.length;if(n===1)return e;for(var r=1;r<n;){if(e=e[i(t[r++])],n===r)return e;if(typeof e!=`object`||!e)return}}e.get=o}))());function w8(e,t){try{return e.startsWith(`#`)?eBt.get(t,e.replace(`#`,``)):eBt.get(t,e)}catch(e){console.error(`Error resolving schema reference. Reference may be invalid or referencing an external document.`,e);return}}var tBt=(e,t)=>{let n=e;return!n||`$ref`in n&&(n=w8(n.$ref,t),!n)?``:n.example?n.example:n.examples&&n.examples.length>0?n.examples[0]:n.default?n.default:``},nBt=(e,t)=>{if(e.examples&&Object.keys(e.examples).length>0){let n=Object.values(e.examples)[0];if(`$ref`in n){let e=w8(n.$ref,t);if(!e)return``;n=e}return n.value}if(e.example)return e.example;let n=e.schema;return tBt(n,t)},rBt=(e,t)=>{let n=e.requestBody;if(!n)return``;if(`$ref`in n){let e=w8(n.$ref,t);if(!e)return``;n=e}let{content:r}=n;if(!(`application/json`in r))return``;let i=r[`application/json`];if(i.examples&&Object.keys(i.examples).length>0){let e=Object.values(i.examples)[0];if(`$ref`in e){let n=w8(e.$ref,t);if(!n)return``;e=n}return e.value}let a=i.schema;return tBt(a,t)},iBt=JSON.stringify({query:`{ __schema { queryType { name } } }`},null,2),aBt=new WR,oBt=e=>e.additionalOperationContext.method.split(`,`).map(e=>e.toUpperCase()),T8=e=>{let{oasFilePath:t,method:n,path:r}=e.additionalOperationContext;return`${t}::${e.operationId??`${n} ${r}`}`},sBt=({ape:e,envUrl:t,operation:n,openApiDocument:r,showRebuildWarning:i,onClose:a,defaultEndpointsPanelOpen:o=!1,documentsByPath:s,endpointsLoading:c})=>{let l=(t,n)=>{let r=oBt(t)[0],i=t[zX]===!0,a=WX(t),o=rBt(t,n),s=aBt.getTest(e.account.name,e.project.name,e.environment.name,t.operationId),c=t.parameters?.filter(e=>!(`$ref`in e)&&e.in===`header`).reduce((e,t)=>({...e,[t.name]:nBt(t,n)}),{})??{},l=typeof o==`string`?o:JSON.stringify(o),u=a?{"content-type":`application/json`,accept:`application/json, text/event-stream`,...c}:i?{"content-type":`application/json`,...c}:c,d=l||(a?jR:i?iBt:l);return s?.test&&s.test.method===r?s.test:{description:t.summary??t.description??``,pathname:t.additionalOperationContext.path,method:r,headers:u,body:d}},[u,d]=(0,H.useState)(n),[f,p]=(0,H.useState)(()=>l(n,r)),[m,h]=(0,H.useState)(o),g=Pp(e=>e.setTestResponse),_=Rp(),v=s??_,y=(0,H.useMemo)(()=>({...v,[n.additionalOperationContext.oasFilePath]:r}),[v,n.additionalOperationContext.oasFilePath,r]),b=(0,H.useMemo)(()=>Object.entries(y).flatMap(([e,t])=>d1(e,t)),[y]),x=(0,H.useMemo)(()=>b.map(e=>({id:T8(e),method:e.additionalOperationContext.method,path:e.additionalOperationContext.path,summary:e.summary,file:e.additionalOperationContext.oasFilePath})),[b]);return(0,H.useEffect)(()=>{g(void 0)},[]),(0,U.jsx)(`div`,{className:`flex h-[650px] max-h-[70vh] flex-col`,children:(0,U.jsx)(Drt,{ape:e,apiTest:f,showRebuildWarning:i,allowedMethods:oBt(u),url:`${t}${u.additionalOperationContext.path}`,shouldAllowLocalSaving:!!u.operationId,operationId:u.operationId,path:u.additionalOperationContext.path,onRequestChange:e=>{p(e)},onClose:a,endpoints:x,selectedEndpointId:T8(u),onSelectEndpoint:e=>{if(e===T8(u))return;let t=b.find(t=>T8(t)===e);if(!t)return;let n=y[t.additionalOperationContext.oasFilePath]??r;d(t),p(l(t,n)),g(void 0)},isEndpointPanelOpen:m,onToggleEndpointPanel:()=>h(e=>!e),endpointsLoading:c},T8(u))})},cBt=({envUrl:e,ape:t,operation:n,openApiDocument:r,showRebuildWarning:i,entries:a,onClose:o,defaultEndpointsPanelOpen:s})=>(0,U.jsx)(OY.Provider,{value:{entries:a},children:(0,U.jsx)(`div`,{className:`w-full text-muted-foreground`,children:(0,U.jsx)(sBt,{openApiDocument:r,ape:t,envUrl:e,showRebuildWarning:i,operation:n,onClose:o,defaultEndpointsPanelOpen:s})})}),lBt=({open:e,onOpenChange:t,onProceed:n})=>{let{saveAndDeploy:r,isPending:i}=aft();return(0,U.jsx)(ow,{open:e,onOpenChange:t,children:(0,U.jsxs)(lw,{className:`sm:max-w-md`,children:[(0,U.jsxs)(uw,{children:[(0,U.jsx)(fw,{children:`Unsaved changes`}),(0,U.jsx)(pw,{children:`Your unsaved changes will not be reflected when you test this route until you save and deploy them. Save them now, or continue testing the currently deployed version.`})]}),(0,U.jsxs)(dw,{children:[(0,U.jsx)(X,{variant:`ghost`,onClick:n,disabled:i,children:`Continue without saving`}),(0,U.jsx)(X,{variant:`default`,onClick:async()=>{try{await r()}catch{return}n()},disabled:i,children:(0,U.jsx)(HI,{loading:i,children:`Save changes`})})]})]})})},uBt=(0,H.lazy)(()=>vn(()=>import(`./GraphiQLConsole-DMOxH2wu.js`),__vite__mapDeps([9,1,2,8,10,11,12]))),dBt=({path:e,method:t,summary:n,operationData:r,hasFileChanged:i,isGraphql:a})=>{let{logEvent:o}=S(),s=Op(),c=f1().getOpenApiDataEnforced(),{entries:l}=(0,H.useContext)(OY),u=KR(s.environment),[d,f]=(0,H.useState)(null),p=u?new URL(e,u).toString():void 0,m=jee({mutationKey:Wdt})>0,[h,g]=M$(()=>(o(`test-route-clicked`,{httpPath:e,httpMethod:t.includes(`,`)?t.split(`,`)[0]:t,account:s.account.name,project:s.project.name,environment:s.environment.name,mode:a?`playground`:`default`}),(0,U.jsx)(ow,{open:!0,onOpenChange:e=>!e&&g(),children:(0,U.jsxs)(lw,{showCloseButton:!1,className:`max-w-6xl! w-full gap-0 overflow-hidden p-0`,children:[(0,U.jsx)(fw,{className:`sr-only`,children:`Test route`}),(0,U.jsx)(cBt,{envUrl:u??``,showRebuildWarning:i,ape:s,entries:l,operation:r,openApiDocument:c,onClose:g})]})})),[e,t,n,r,l,a]),[_,v]=M$(()=>(o(`test-route-clicked`,{httpPath:e,httpMethod:`POST`,account:s.account.name,project:s.project.name,environment:s.environment.name,mode:`graphiql`}),(0,U.jsx)(ow,{open:!0,onOpenChange:e=>!e&&v(),children:(0,U.jsxs)(lw,{className:`max-w-6xl! w-full p-0 overflow-hidden`,children:[(0,U.jsx)(fw,{className:`sr-only`,children:`GraphiQL`}),(0,U.jsx)(`div`,{className:`h-[80vh] w-full`,children:(0,U.jsx)(H.Suspense,{fallback:(0,U.jsx)(`div`,{className:`flex h-full items-center justify-center text-muted-foreground`,children:`Loading GraphiQL…`}),children:(0,U.jsx)(uBt,{url:p??``,ape:s})})})]})})),[p,s]),y=e=>{e===`graphiql`?_():h()},b=e=>{if(i){f(e);return}y(e)},x=(0,U.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,U.jsx)(`span`,{children:`Saving`}),(0,U.jsx)(VI,{color:`current`})]}),C=m?`Saving`:`Test Route`;return(0,U.jsxs)(U.Fragment,{children:[a?(0,U.jsxs)(uJ,{children:[(0,U.jsx)(dJ,{asChild:!0,children:(0,U.jsx)(X,{variant:`brand`,disabled:m,"aria-label":C,children:(0,U.jsxs)(HI,{loading:m,className:`flex items-center gap-2`,alternative:x,children:[(0,U.jsx)(mp,{className:`shrink-0 fill-current`}),(0,U.jsx)(`span`,{children:`Test Route`}),(0,U.jsx)(pd,{className:`size-4 shrink-0`})]})})}),(0,U.jsxs)(fJ,{align:`end`,children:[(0,U.jsxs)(mJ,{onSelect:()=>b(`playground`),children:[(0,U.jsx)(mp,{className:`size-4`}),(0,U.jsx)(`span`,{children:`Playground`})]}),(0,U.jsxs)(mJ,{disabled:!p,onSelect:()=>b(`graphiql`),children:[(0,U.jsx)(C1,{className:`size-4`}),(0,U.jsx)(`span`,{children:`GraphiQL`})]})]})]}):(0,U.jsx)(X,{variant:`brand`,disabled:m,"aria-label":C,onClick:()=>b(`playground`),children:(0,U.jsxs)(HI,{loading:m,className:`flex items-center gap-2`,alternative:x,children:[(0,U.jsx)(mp,{className:`shrink-0 fill-current`}),(0,U.jsx)(`span`,{children:`Test Route`})]})}),(0,U.jsx)(H.Suspense,{fallback:null,children:(0,U.jsx)(lBt,{open:d!==null,onOpenChange:e=>{e||f(null)},onProceed:()=>{let e=d;f(null),e&&y(e)}})})]})},fBt=({onRequestHandlerChange:e,isReadOnly:t,routeHandler:n})=>{let r=T1(n),i=(t,i)=>{e({...n,options:{...r.options,[t]:i}})};return(0,U.jsxs)(CA,{className:`p-4 bg-surface-sunken`,children:[(0,U.jsxs)(`div`,{className:`mb-4 flex items-center justify-between gap-2`,children:[(0,U.jsx)(`span`,{className:`text-base font-medium`,children:`MCP Server Options`}),(0,U.jsx)(hT,{showIcon:!0,href:`https://docs.zuplo.com/handlers/mcp-server`,className:`text-sm text-zuplo-pink`,children:`MCP Server Docs`})]}),(0,U.jsxs)(`div`,{className:`grid grid-cols-12 gap-4 col-span-full items-center`,children:[(0,U.jsx)(`div`,{className:`col-span-8`,children:(0,U.jsx)(y6,{isReadOnly:t,label:`Server Name`,onChange:e=>i(`name`,e.target.value),className:`col-span-8`,value:typeof r.options.name==`string`?r.options.name:`My MCP Server`})}),(0,U.jsx)(`div`,{className:`col-span-4`,children:(0,U.jsx)(y6,{isReadOnly:t,label:`Server Version`,className:`col-span-4`,onChange:e=>i(`version`,e.target.value),value:typeof r.options.version==`string`?r.options.version:`v0.0.1`})}),(0,U.jsxs)(`div`,{className:`col-span-12 mt-2`,children:[(0,U.jsx)(yT,{className:`text-sm mb-2 block`,children:`Advanced Options`}),(0,U.jsx)(`div`,{className:W(`flex gap-4`,t&&`opacity-50`),children:(0,U.jsxs)(`label`,{className:`text-sm flex items-center gap-2`,children:[(0,U.jsx)(VY,{"data-test":`mcp-debug-mode`,checked:!!r.options.debugMode,onCheckedChange:e=>{i(`debugMode`,e)},disabled:t}),`Debug Mode`]})})]})]})]})},pBt=({routeHandler:e,operation:t,isReadOnly:n,onRequestHandlerChange:r})=>{let{captureRaw:i}=S(),a=Evt(),o=T1(e),s=typeof o.options.rewritePattern==`string`?o.options.rewritePattern:``,c=kIt(()=>{i(`mcp-gateway-upstream-url-edited`)});return(0,U.jsx)(CA,{className:`p-4`,children:(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,U.jsx)(`div`,{className:`text-xs uppercase tracking-wide text-muted-foreground font-medium`,children:`Upstream MCP server`}),!!(a&&t)&&(0,U.jsxs)(X,{type:`button`,variant:`default`,size:`sm`,disabled:n,onClick:()=>{!t||!a||(i(`mcp-gateway-edit-virtual-mcp-opened`),a(t))},className:`shrink-0`,children:[(0,U.jsx)(Uf,{className:`w-3.5 h-3.5`}),`Edit MCP Server Policy`]})]}),(0,U.jsx)(l3,{isReadOnly:n,url:s,onUrlChange:t=>{c(),r({...e,options:{...o.options,rewritePattern:t}})},placeholder:`https://example.com/mcp`,"aria-label":`Upstream MCP server URL`,"data-test":`mcp-upstream-url-input`})]})})};function mBt(e){if(e)switch(e.type){case`tool`:return{type:e.type,name:e.name??``,description:e.description??``,annotations:e.annotations};case`prompt`:return{type:e.type,name:e.name??``,description:e.description??``};case`resource`:return{type:e.type,name:e.name??``,description:e.description??``,uri:e.uri??``,mimeType:e.mimeType??``};case`graphql`:return{type:e.type,introspectionTool:{name:e.introspectionTool?.name??``,description:e.introspectionTool?.description??``},executeTool:{name:e.executeTool?.name??``,description:e.executeTool?.description??``}}}}function hBt({operationData:e,addRouteMenuProps:t}){return e?(0,U.jsx)(`div`,{className:`w-full h-full min-h-0 overflow-y-auto px-4 pt-2 pb-4`,children:(0,U.jsx)(_Bt,{operationData:e})}):(0,U.jsx)(j_t,{...t})}var gBt=()=>{let e=Lp(),t=Rp(),n=(0,H.useMemo)(()=>e.flatMap(e=>{let n=t[e.path];return n?d1(e.path,n).filter(e=>WX(e)).map(t=>[e,t]):[]}),[e,t]);return{getLinkedMcpServers:(e,t)=>n.filter(([,n])=>{let r=n[VX]?.handler;return HX(r)?r.options?.operations?.some(n=>S1(n.file)===e&&n.id===t):!1})}},_Bt=({operationData:e})=>{let[t]=kY(`path`);if(!t)throw Error(`Open API file path not found in URL`);let n=ift(t),r=Op(),{logEvent:i}=S(),{additionalOperationContext:a,...o}=e,{path:s,method:c}=a,l=f1(),u=Ep(),d=D1(),{isReadOnly:f}=HZ(),[p,m]=(0,H.useState)(),[h,g]=(0,H.useState)();gBt();let _=l.openApiData?.servers?.at(0)?.url,v=o[VX]??m1(_??`https://echo.zuplo.io`),y=o[RX]===!0,b=o.deprecated===!0,x=o[zX]===!0,C=l.openApiFileModel.saveState!==Qs.unmodified,w=v.handler,T=HX(w)&&c.toUpperCase()!==`POST`?`MCP Server handler must use POST method`:void 0,E=e=>{try{l.updateOperation({path:s,method:c,newMethod:e.export===`mcpServerHandler`?`post`:void 0,newOperationObject:{...o,[VX]:{...v,handler:{...e}}}})}catch(e){u.error(e instanceof Error?e.message:`Unknown error`)}},D=e=>{l.updateOperation({path:s,method:c,newOperationObject:{...o,summary:e}})},O=e=>{l.updateOperation({path:s,method:c,newOperationObject:{...o,description:e}})},k=e=>{i(`route-visibility-changed`,{excludeFromDocs:e,fileName:t,account:r.account.name,project:r.project.name,environment:r.environment.name}),l.updateOperation({path:s,method:c,newOperationObject:{...o,[RX]:e}})},A=e=>{i(`route-deprecated-changed`,{deprecated:e,fileName:t,account:r.account.name,project:r.project.name,environment:r.environment.name}),l.updateOperation({path:s,method:c,newOperationObject:{...o,deprecated:e||void 0}})},j=e=>{i(`route-graphql-changed`,{graphql:e,fileName:t,account:r.account.name,project:r.project.name,environment:r.environment.name});let n={...o};e?(n[zX]=!0,h_t(d),n[VX]=m_t(v,!0)):(delete n[zX],o[VX]&&(n[VX]=m_t(v,!1))),l.updateOperation({path:s,method:c,newOperationObject:n})},M=e=>{let{newPath:t}=e,{newMethod:n}=e;h!=null&&t==null&&(t=h);try{l.updateOperation({path:s,newPath:t,method:c,newMethod:n,newOperationObject:o}),m(void 0),g(void 0)}catch(e){e instanceof Error&&t!=null&&(g(t),m(e.message))}},N=e=>{if(e===s){m(void 0),g(void 0);return}M({newPath:e.startsWith(`/`)?e:`/${e}`})},P=e=>{let n=e;n!==c&&(i(`route-method-changed`,{httpMethod:e,fileName:t,account:r.account.name,project:r.project.name,environment:r.environment.name}),M({newMethod:n}))},F=e=>{let n={...v,corsPolicy:e};l.updateOperation({path:s,method:c,newOperationObject:{...o,[VX]:n}}),i(`route-cors-changed`,{newCors:e,fileName:t,account:r.account.name,project:r.project.name,environment:r.environment.name})},I=e=>{let t={...o};e.length>0?t.tags=e:delete t.tags,l.updateOperation({path:s,method:c,newOperationObject:t})},L=n=>{let a={...e.additionalOperationContext.pathZuploConfig,pathMode:n},o=l.getOpenApiDataEnforced().paths;if(!o)throw Error(`Property 'paths' is undefined`);let c=o[s];if(!c)throw Error(`Path Item '${s}' is undefined`);l.updatePathItem(s,{...c,[BX]:a}),i(`route-path-mode-changed`,{pathMode:n,fileName:t,account:r.account.name,project:r.project.name,environment:r.environment.name})},R=()=>{n(Qs.modified)};return(0,U.jsxs)(`div`,{className:`mb-4 flex flex-col gap-6`,children:[(0,U.jsxs)(CA,{className:`bg-neutral-50 dark:bg-transparent`,children:[(0,U.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,U.jsxs)(wA,{children:[(0,U.jsx)(TA,{children:`Request Handling`}),(0,U.jsx)(EA,{})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2 p-6`,children:[x&&(0,U.jsx)(Qzt,{path:s,rewriteUrl:typeof w.options?.rewritePattern==`string`?w.options?.rewritePattern:void 0}),(0,U.jsx)(DRt,{operationData:e}),(0,U.jsx)(dBt,{path:s,method:c,summary:o.summary??``,operationData:e,hasFileChanged:C,isGraphql:x})]})]}),(0,U.jsxs)(DA,{className:`grid grid-cols-1 xl:grid-cols-[max-content_1fr] gap-y-3 xl:gap-y-2 items-center gap-x-6`,children:[(0,U.jsx)(IRt,{isReadOnly:f,initialPath:s,method:c,onChangeMethod:P,pathMode:e.additionalOperationContext.pathZuploConfig?.pathMode,hasError:p!=null,onPathChange:N,onPathModeChange:L,onFieldModified:R,isMcpToolHandler:HX(w)||UX(w)}),p&&(0,U.jsx)(Ub,{"data-test":`path-error`,className:`col-span-full p-2`,variant:`destructive`,children:(0,U.jsx)(Gb,{children:p})}),T&&(0,U.jsx)(Ub,{className:`col-span-full p-2 py-1`,variant:`destructive`,children:(0,U.jsxs)(Gb,{"data-test":`request-handler-error`,className:`flex items-center justify-between`,children:[(0,U.jsx)(`span`,{children:T}),(0,U.jsx)(X,{onClick:()=>P(`post`),size:`xs`,variant:`outline`,className:`border-none`,children:`Switch to POST method`})]})}),(0,U.jsx)(zMt,{isReadOnly:f,initialSummary:o.summary,onSummaryChange:D,onFieldModified:R}),(0,U.jsx)(ORt,{isReadOnly:f,defaultOperationId:e.operationId,openApiManager:l,path:s,method:c,operationData:e})]}),(0,U.jsxs)(OA,{className:`flex flex-wrap gap-2 px-3 py-1.5 bg-card justify-end`,children:[(0,U.jsx)($zt,{operationTags:o.tags??[],onTagsChanged:I}),(0,U.jsx)(sLt,{isReadOnly:f,selectedCorsPolicy:v.corsPolicy,corsPolicies:d.corsPolicyList??[],onSelectionChanged:F}),!HX(v.handler)&&!UX(v.handler)&&(0,U.jsx)(NRt,{operation:e,defaultValues:mBt(v.mcp),onSubmit:e=>{let t={...v,mcp:e};l.updateOperation({path:s,method:c,newOperationObject:{...o,[VX]:t}})}}),(0,U.jsx)(nRt,{isExcludedFromDocs:y,onVisibilityChanged:k}),(0,U.jsx)(LRt,{isGraphql:x,onGraphqlChanged:j,isDeprecated:b,onDeprecatedChanged:A})]})]}),(0,U.jsx)(SIt,{inboundPolicies:v.policies?.inbound??[],outboundPolicies:v.policies?.outbound??[],operation:e,children:(0,U.jsx)(vBt,{isReadOnly:f,operationData:e,handler:v.handler,firstServerUrl:_,onRequestHandlerChange:E})}),(0,U.jsx)(tRt,{initialDescription:o.description??``,onChange:O,path:s,method:c,oasFilePath:t})]})},vBt=({operationData:e,handler:t,firstServerUrl:n,isReadOnly:r,onRequestHandlerChange:i})=>{let a=(e[VX]??m1(n??`https://echo.zuplo.io`)).handler;switch(t.export){case`mcpServerHandler`:return(0,U.jsx)(fBt,{isReadOnly:r,routeHandler:a,onRequestHandlerChange:i});case`McpProxyHandler`:case`McpVirtualServerHandler`:case`mcpVirtualServerHandler`:return(0,U.jsx)(pBt,{routeHandler:a,operation:e,isReadOnly:r,onRequestHandlerChange:i});default:return(0,U.jsx)(rLt,{isReadOnly:r,routeHandler:a,onRequestHandlerChange:i})}},yBt=De()(e=>({updateLinkedMcpServers:void 0,setUpdateLinkedMcpServers:t=>e({updateLinkedMcpServers:t})})),bBt=()=>{let e=j(yBt,e=>e.updateLinkedMcpServers),t=aQ(),n=()=>{yBt.setState({updateLinkedMcpServers:void 0})};return(0,U.jsx)(ow,{open:!!e,onOpenChange:e=>{e||n()},children:(0,U.jsxs)(lw,{children:[(0,U.jsx)(fw,{children:`MCP Server Links`}),(0,U.jsx)(pw,{children:`This operation is linked to MCP servers, if you update the operation id, you need to update the MCP server links as well.`}),(0,U.jsx)(`div`,{className:`flex gap-2 items-center justify-center`,children:e?.linkedMcpServers.map(([,e])=>(0,U.jsx)(rT,{children:e},e))}),(0,U.jsxs)(dw,{children:[(0,U.jsx)(X,{variant:`outline`,onClick:n,children:`Cancel`}),(0,U.jsx)(X,{onClick:()=>{e?.linkedMcpServers.forEach(([n,r])=>{let i=new t_t(n,t),a=i.getOperationById(r);if(!a)return;let o=a[VX];if(!o)return;let s=o.handler;if(HX(s)){if(n.path===e.file){let t=i.getOperationById(e.oldOperationId);if(!t)throw Error(`Operation not found`);i.updateOperation({path:t.additionalOperationContext.path,method:t.additionalOperationContext.method,newOperationObject:H$(t,`operationId`,e.newOperationId)})}i.updateOperation({path:a?.additionalOperationContext.path,method:a.additionalOperationContext.method,newOperationObject:H$(a,`${VX}.handler.options.operations`,s.options?.operations?.map(t=>S1(t.file)===n.path?{...t,id:t.id===e.oldOperationId?e.newOperationId:t.id}:t))})}})},children:`Update`})]})]})})},xBt=`$import(@zuplo/runtime)`,SBt=`${xBt}::urlForwardHandler`,CBt=`${xBt}::urlRewriteHandler`,wBt=(e,t)=>{let n=e.options?.[t],r=typeof n==`string`?n.trim():``;return r.length>0?r:void 0},TBt=e=>{let t=e.trim();if(t.startsWith("${")){let e=t.indexOf(`}`);if(e!==-1)return t.slice(0,e+1)}let n=/^[a-z][a-z0-9+.-]*:\/\/[^/$?#]+/i.exec(t);if(n)return n[0];let r=t.indexOf(`/`);return r===-1?t:t.slice(0,r)},EBt=e=>{if(e){let t=`${e.module}::${e.export}`,n=t===SBt?wBt(e,`baseUrl`):t===CBt?wBt(e,`rewritePattern`):void 0;if(n){let e=TBt(n);return{key:`target:${e}`,label:e,mono:!0,icon:cf,collapsible:!0}}}return{...mvt(e),collapsible:!1}};function DBt(){let e=f1(),{captureRaw:t}=S(),n=Op(),r=nQ();return i=>{e.updateInfo(i),t(`openapi-info-updated`);let{projectTreeNodes:a,filesByPath:o}=Pp.getState(),s=a.map(e=>e.path?o[e.path]:void 0).filter(e=>!!e&&e.saveState===Qs.modified);s.length!==0&&r.mutateAsync({environmentName:n.environment.name,accountName:n.account.name,projectName:n.project.name,files:s}).catch(()=>{})}}var E8=`Document Order`,OBt=[`Document Order`,`Path`,`Summary`],D8=`Untagged`,kBt=[{value:`none`,label:`None`},{value:`path`,label:`Path`},{value:`handler`,label:`Handler type`},{value:`target`,label:`Target`}],ABt=new Set([`handler`,`target`]);function jBt(e){return`${e}-${B().split(`-`).at(0)}`}function O8(e){return new Set(e.getPolicyListEnforced().map(e=>e.name))}function MBt(e){if(!e)return;let t=AMt(e.getPolicyListEnforced());if(t)return t.name;let n=g3(OMt,O8(e));return e.createPolicy(kMt(n)),n}var NBt=e=>(t,n)=>{switch(e){case`Document Order`:return 0;case`Path`:return t.additionalOperationContext.path.localeCompare(n.additionalOperationContext.path);case`Summary`:return!t.summary&&!n.summary?0:!t.summary&&n.summary?1:t.summary&&!n.summary?-1:t.summary?.localeCompare(n.summary??``)??0;default:return 0}},PBt=e=>t=>{if(e.length===0)return!0;let n=t.tags;return!n||n.length===0?e.includes(D8):n.some(t=>e.includes(t))},FBt=({onNavigateToOpenApiFileTab:e})=>{let{logEvent:t,captureRaw:n}=S(),[r,i]=Tnt(`tags`,[]),[a,o]=Gw(`open-api-designer-group-by`,`none`);(0,H.useEffect)(()=>{let e=window.localStorage.getItem(`open-api-designer-show-headers`);e!==null&&(e===`true`&&a===`none`&&o(`path`),window.localStorage.removeItem(`open-api-designer-show-headers`))},[a,o]);let[s,c]=(0,H.useState)(!1),[l,u]=(0,H.useState)(`details`),[d,f]=(0,H.useState)(!1),p=DBt(),m=(0,H.useRef)(null);(0,H.useEffect)(()=>{let e=e=>{if(e.key!==`/`||e.metaKey||e.ctrlKey||e.altKey)return;let t=e.target;t&&(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.tagName===`SELECT`||t.isContentEditable)||(e.preventDefault(),m.current?.focus())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[]);let[h,g]=(0,H.useState)(),[_,v]=(0,H.useState)(),[y,b]=(0,H.useState)(()=>new Set),x=e=>b(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),[C,w]=(0,H.useState)(()=>new Set),T=e=>w(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),{isReadOnly:E}=HZ(),[D,O]=kY(`operation`),[k,A]=Gw(`default-sort-routes`,E8),[j,M]=kY(`sort`,k);(0,H.useEffect)(()=>{j&&A(j)},[A,j]),(0,H.useEffectEvent)(()=>{if(D)try{document.querySelector(`#op-${D}`)?.scrollIntoView()}catch{}});let[N,P]=(0,H.useState)(void 0),F=f1(),I=D1(),L=JI(),R=oQ(hvt),z=sQ(),ee=()=>{if(R)return _vt(R.content??``)?`ok`:`manual`;let e=gvt,t={path:hvt,content:e,type:Zs.File,saveState:Qs.new};if(L){let n=L.Uri.file(t.path);L.editor.getModel(n)||L.editor.createModel(e,void 0,n)}return z(t),z({...t,saveState:Qs.modified}),`ok`},{results:te,setSearchTerm:V,searchTerm:ne}=Y_t(F.operationArray?.filter(PBt(r)).sort(NBt(j))??[],{keys:[e=>e.additionalOperationContext.path,e=>e.summary??``,e=>e.operationId,e=>e.additionalOperationContext.method]});(0,H.useEffect)(()=>{let e=ne?.trim()??``;if(e.length===0)return;let n=setTimeout(()=>{t(`route-search-used`,{view:`routes`,query:e,queryLength:e.length})},600);return()=>clearTimeout(n)},[ne,t]);let re=(()=>{let e=new Map;for(let t of te){let n,r,i,o,s;if(a===`handler`||a===`target`){let e=t[VX]?.handler,c=a===`target`?EBt(e):{...mvt(e),collapsible:!1};({key:n,label:r,mono:i,collapsible:o,icon:s}=c)}else n=t.additionalOperationContext.path,r=n,i=!0,o=!1,s=void 0;let c=e.get(n);c?c.operations.push(t):e.set(n,{key:n,label:r,mono:i,icon:s,collapsible:o,operations:[t]})}return[...e.values()]})(),[ie,ae]=(0,H.useState)(),[oe,se]=(0,H.useState)(),[ce,le]=(0,H.useState)(!1),ue=(0,H.useMemo)(()=>{if(!_)return[];let e=(F.operationArray?.find(e=>e.additionalOperationContext.path===_.path&&e.additionalOperationContext.method===_.method))?.[VX]?.policies?.inbound??[];if(e.length===0)return[];let t=new Set;for(let e of I.policyList??[]){if(e.policyType!==`composite-inbound`&&e.policyType!==`composite-outbound`)continue;let n=e.handler.options?.policies;if(n)for(let e of n)t.add(e)}let n=I.policiesUsageInfo??[];return e.map(e=>n.find(t=>t.name===e)).filter(e=>{if(!e||e.operations.length!==1)return!1;let n=e.operations[0];return!(n.additionalOperationContext.path!==_.path||n.additionalOperationContext.method!==_.method||t.has(e.name))})},[_,F.operationArray,I.policyList,I.policiesUsageInfo]),[de,fe]=(0,H.useState)(()=>new Set);(0,H.useEffect)(()=>{fe(_?new Set(ue.map(e=>e.name)):new Set)},[_]);let pe=(e,t)=>{fe(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r})},me=()=>{if(_==null){le(!1);return}try{for(let e of de)try{I.deletePolicy(e),t(`policy-deleted`,{policy:e})}catch{}F.deleteOperation(_.path,_.method),t(`route-deleted`,_)}catch(e){e instanceof Error&&(t(`route-deletion-failed`,_),P(e.message),he())}v(void 0),le(!1)},[he,ge]=M$(()=>{let t=()=>{P(void 0),ge()};return(0,U.jsx)(vQ,{alertType:`ERROR`,bodyText:N??``,onPrimaryButtonClick:e,onSecondaryButtonClick:t,primaryButtonText:`Edit file directly`,secondaryButtonText:`Cancel`,hideModal:t,title:`Error`})},[N]),[_e,ve]=M$(()=>(0,U.jsx)(vQ,{alertType:`CAUTION`,bodyText:`Cannot reorder in this view — view by Document Order to reorganize the order of operations.`,onPrimaryButtonClick:()=>{M(E8),ve()},onSecondaryButtonClick:ve,primaryButtonText:`Switch to Document Order`,secondaryButtonText:`Cancel`,hideModal:ve,title:`Cannot reorder`})),[ye,be]=M$(()=>(0,U.jsx)(yvt,{open:!0,onOpenChange:e=>{e||be()}})),xe=(e,t)=>{if(j!==E8){_e();return}F.movePathInDocument(e,t)};if(!F.openApiData)throw Error(`Invalid State - no OpenApiData`);let Se=F.openApiData.info,Ce=F.openApiData.tags?.map(e=>({value:e.name,label:e.name}));Ce?.push({value:D8,label:D8});let we=()=>{let e=y1.OpenAPIV3.HttpMethods.GET,n=F.openApiData?.servers?.at(0)?.url,r=f_t(n??`https://echo.zuplo.io`),i=`/path-${((F.operationArray?.filter(t=>t.additionalOperationContext.path.startsWith(`/path-`)&&t.additionalOperationContext.method===e)?.map(e=>parseInt(e.additionalOperationContext.path.replace(`/path-`,``),10))?.filter(e=>!Number.isNaN(e))?.sort((e,t)=>t-e))?.at(0)??0)+1}`;try{let t=F.addOperation(i,e,r);t&&O(t)}catch(n){n instanceof Error&&(t(`route-add-failed`,{httpPath:i,httpMethod:e}),P(n.message),he())}t(`route-added`)},Te=(e,n,r)=>{let i=F.openApiData?.servers?.at(0)?.url,a=f_t(i??`https://echo.zuplo.io`),o=r?.[VX],s=a[VX];o&&s&&(o.handler&&(s.handler=JSON.parse(JSON.stringify(o.handler))),o.policies&&(s.policies=JSON.parse(JSON.stringify(o.policies))));try{let t=F.addOperation(e,n,a);t&&O(t)}catch(r){r instanceof Error&&(t(`route-add-failed`,{httpPath:e,httpMethod:n}),P(r.message),he())}t(`route-added`)},Ee=()=>{let e=y1.OpenAPIV3.HttpMethods.POST,n=jBt(`mcp`),r=F.addOperation(`/mcp`,e,{summary:`MCP Server`,description:`Default MCP Server`,[VX]:{corsPolicy:`none`,handler:{export:`mcpServerHandler`,module:`$import(@zuplo/runtime)`,options:{operations:[]}},policies:{inbound:[]}},operationId:n},{avoidConflict:!0});r&&O(r),t(`route-added`)},De=()=>{let e=y1.OpenAPIV3.HttpMethods.POST,n=g_t(`https://rickandmortyapi.com/graphql`);try{h_t(I);let t=F.addOperation(`/graphql`,e,n,{avoidConflict:!0});t&&O(t)}catch(n){n instanceof Error&&(t(`route-add-failed`,{httpPath:`/graphql`,httpMethod:e}),P(n.message),he())}t(`route-added`)},Oe=()=>{let e=y1.OpenAPIV3.HttpMethods.GET,n=__t();try{let t=F.addOperation(`/websocket`,e,n,{avoidConflict:!0});t&&O(t)}catch(n){n instanceof Error&&(t(`route-add-failed`,{httpPath:`/websocket`,httpMethod:e}),P(n.message),he())}t(`route-added`)},[ke,Ae]=(0,H.useState)(!1),[je,Me]=(0,H.useState)(),[Ne,Pe]=(0,H.useState)(0),Fe=(0,H.useMemo)(()=>{let e=new Set(Object.keys(F.openApiData?.paths??{}));return je&&e.delete(je.path),e},[F.openApiData?.paths,je]),Ie=async e=>{let n;try{n=ee()}catch(e){if(e instanceof Error){P(e.message),he();return}throw e}let r;try{r=MMt({result:e,policyList:I.getPolicyListEnforced(),existingOperationIds:new Set(F.operationArray?.map(e=>e.operationId)??[])});for(let e of r.policiesToCreate)I.createPolicy(e)}catch(e){if(e instanceof Error){P(e.message),he();return}throw e}try{let e=F.addOperation(r.operationPath,r.method,r.operation,{avoidConflict:!0});e&&O(e)}catch(e){e instanceof Error&&(P(e.message),he())}t(`route-added`),t(`mcp-gateway-create-virtual-mcp-submitted`,NMt(e)),n===`manual`&&ye()},Le=()=>{Pe(e=>e+1),Ae(!0)},Re=e=>{let t=yMt({operationPath:e.additionalOperationContext.path,operation:e,policyList:I?.getPolicyListEnforced()??[]});t&&(Pe(e=>e+1),Me({initialResult:t,path:e.additionalOperationContext.path,method:e.additionalOperationContext.method,operationId:e.operationId}))},ze=async e=>{let t=je;if(!t)return;let{initialResult:r,path:i,method:a}=t,o=F.operationArray?.find(e=>e.additionalOperationContext.path===i&&e.additionalOperationContext.method===a);if(!o){Me(void 0);return}let s;try{s=ee()}catch(e){if(e instanceof Error){P(e.message),he();return}throw e}let c=EMt(e.step1.name),l=n0(e.step1.mcpUrl),u=l?.protectedResourceMetadataUrl??jMt(e.step1.mcpUrl),d=o[VX]?.policies?.inbound??[],f=I?.getPolicyListEnforced()??[],p=new Map(f.map(e=>[e.name,e])),m=d.map(e=>p.get(e)).filter(e=>e!=null),h=m.find(e=>e.policyType===q4),g=m.find(e=>e.policyType===J4),_=m.find(e=>e.policyType===`remove-headers-inbound`&&Y4(e.handler?.options)),v=m.find(e=>e.policyType.startsWith(`upstream-`)),y;if(e.step1.authMode===`user-oauth`){let t={id:c,displayName:e.step1.name,summary:`${e.step1.name} remote MCP server, federated via the gateway.`,...u?{protectedResourceMetadataUrl:u}:{},authMode:`user-oauth`,scopes:l?.scopes??[],clientRegistration:e.step1.clientRegistration};if(h&&I)try{I.updatePolicy(h.name,{...h,handler:{...h.handler,options:t}}),y=h.name}catch(e){if(e instanceof Error){P(e.message),he();return}}else if(I){y=g3(`mcp-upstream-${c}`,O8(I));try{I.createPolicy({name:y,policyType:q4,handler:{module:`$import(@zuplo/runtime/mcp-gateway)`,export:`McpTokenExchangeInboundPolicy`,options:t}})}catch(e){if(e instanceof Error){P(e.message),he();return}}}}let b;if(e.step1.authMode===`upstream-policy`&&I){let{policyType:t,policyName:n,handler:r}=e.step1;try{v&&v.policyType===t?I.updatePolicy(v.name,{...v,name:n,handler:r}):I.createPolicy({name:n,policyType:t,handler:r}),b=n}catch(e){if(e instanceof Error){P(e.message),he();return}}}let x;if(e.step2.catalogMode===`curated`){let t=V4(e.step2);if(g&&I)try{I.updatePolicy(g.name,{...g,handler:{...g.handler,options:t}}),x=g.name}catch(e){if(e instanceof Error){P(e.message),he();return}}else if(I){x=g3(`mcp-filter-${c}`,O8(I));try{I.createPolicy({name:x,policyType:J4,handler:{module:`$import(@zuplo/runtime/mcp-gateway)`,export:`McpCapabilityFilterInboundPolicy`,options:t}})}catch(e){if(e instanceof Error){P(e.message),he();return}}}}let S;if(e.step3.authPolicyChoice===`existing`)S=e.step3.existingPolicyName;else if((e.step3.authPolicyChoice===`new`||e.step3.authPolicyChoice===`new-other`)&&(S=e.step3.newPolicyName,I))try{I.createPolicy({name:S,policyType:e.step3.policyType,handler:e.step3.handler})}catch(e){if(e instanceof Error){P(e.message),he();return}}let C;if(e.step1.authMode===`none`&&e.step1.noAuthBehavior===`strip`)try{C=_?.name??MBt(I)}catch(e){if(e instanceof Error){P(e.message),he();return}}let w=[S,x,y,b,C].filter(e=>!!e),T=o[VX],E=T?.handler;try{F.updateOperation({path:i,method:a,newOperationObject:{...o,summary:e.step1.name,description:`MCP Virtual Server fronted by the gateway (${e.step1.mcpUrl})`,[VX]:{...T??{},handler:{...E??{export:`McpProxyHandler`,module:`$import(@zuplo/runtime/mcp-gateway)`},options:{...E?.options??{},rewritePattern:e.step1.mcpUrl}},policies:{...T?.policies??{},inbound:w}}}})}catch(e){if(e instanceof Error){P(e.message),he();return}}let D;try{D=new URL(e.step1.mcpUrl).hostname}catch{D=void 0}n(`mcp-gateway-edit-virtual-mcp-submitted`,{upstreamHost:D,upstreamAuthMode:e.step1.authMode,previousUpstreamAuthMode:r.step1.authMode,inboundAuthChoice:e.step3.authPolicyChoice,previousInboundAuthChoice:r.step3.authPolicyChoice}),Me(void 0),s===`manual`&&ye()},Be=(0,H.useMemo)(()=>D?te.find(e=>e.operationId===D)||te.find(e=>h?.path===e.additionalOperationContext.path&&h?.method===e.additionalOperationContext.method):void 0,[te,D,h]);(0,H.useEffect)(()=>{Be&&!h&&g({path:Be.additionalOperationContext.path,method:Be.additionalOperationContext.method})},[Be,h]);let Ve=(e,n,r)=>{let i=(e,t)=>{let n=e.replace(/-duplicate(-\d+)?$/,``),r=`${n}-duplicate`,i=2;for(;t(r);)r=`${n}-duplicate-${i}`,i++;return r},a=F.operationArray??[],o=i(e,e=>a.some(t=>t.additionalOperationContext.path===e&&t.additionalOperationContext.method===n)),s=i(r.operationId??`op-${B().slice(0,4)}`,e=>a.some(t=>t.operationId===e)),c=JSON.parse(JSON.stringify(r));c.operationId=s;try{let e=F.addOperation(o,n,c);e&&O(e)}catch(e){e instanceof Error&&(t(`route-add-failed`,{httpPath:o,httpMethod:n}),P(e.message),he())}t(`route-added`,{httpPath:o,httpMethod:n,duplicate:!0})},He=()=>{f(!0),u(`tags`),c(!0)},Ue=je!==void 0,We=(0,U.jsx)(bMt,{isOpen:ke||Ue,existingPaths:Fe,mode:Ue?`edit`:`create`,initialResult:je?.initialResult,onClose:()=>{Ae(!1),Me(void 0)},onFinish:Ue?ze:Ie},`mcp-wizard-${Ne}`),Ge={onAddRest:we,onAddGraphql:De,onAddWebSocket:Oe,onAddMcpVirtual:Le,onAddMcpServer:Ee,onAddTag:He};return F.operationArray?.length===0&&(!ne||ne.trim().length===0)?(0,U.jsxs)(U.Fragment,{children:[We,(0,U.jsx)(j_t,{...Ge})]}):(0,U.jsxs)(`div`,{className:`ms-2 grid grid-cols-3 h-full grow`,children:[(0,U.jsx)(k$,{open:ce,onOpenChange:e=>{le(e),e||v(void 0)},onClickDelete:me,title:`Delete`,deleteButtonText:`Confirm`,children:ue.length===0?`Are you sure you want to delete this operation?`:(0,U.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,U.jsxs)(`div`,{children:[`The following`,` `,ue.length===1?`policy is`:`policies are`,` `,`used only by this route. Would you like to delete`,` `,ue.length===1?`it`:`them`,` `,`too?`]}),(0,U.jsx)(`ul`,{className:`flex flex-col divide-y divide-border max-h-[40vh] overflow-y-auto rounded-md border bg-surface-sunken`,children:ue.map(e=>{let t=`delete-policy-${e.name}`;return(0,U.jsxs)(`li`,{className:`flex items-start gap-2 px-3 py-2`,children:[(0,U.jsx)(VY,{id:t,checked:de.has(e.name),onCheckedChange:t=>pe(e.name,t===!0),className:`mt-0.5`}),(0,U.jsxs)(`label`,{htmlFor:t,className:`flex flex-col gap-0.5 text-left cursor-pointer min-w-0`,children:[(0,U.jsx)(`span`,{className:`font-medium text-foreground truncate`,children:e.name}),(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground truncate`,children:e.policyType})]})]},e.name)})})]})}),(0,U.jsx)(bBt,{}),We,Se&&(0,U.jsx)(LMt,{open:s,onOpenChange:c,info:Se,onSave:p,defaultTab:l,tagsAutoCreate:d,onTagsAutoCreateConsumed:()=>f(!1)}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-2 justify-start h-full pt-2 min-h-0`,children:[(0,U.jsxs)(`div`,{className:`flex justify-between gap-x-2`,children:[(0,U.jsx)(`div`,{className:`flex gap-1`,children:(0,U.jsxs)(uJ,{children:[(0,U.jsx)(dJ,{className:`flex group select-none`,asChild:!0,children:(0,U.jsxs)(X,{variant:`outline`,size:`sm`,title:`Filter and sort routes`,children:[(0,U.jsx)(rf,{size:16}),`Filter`]})}),(0,U.jsxs)(fJ,{className:`min-w-[220px]`,align:`start`,children:[(0,U.jsx)(gJ,{children:`Sort by`}),(0,U.jsx)(pJ,{children:OBt.map(e=>(0,U.jsxs)(mJ,{onClick:()=>M(e),className:`justify-between`,children:[e,(0,U.jsx)(fd,{className:W(`mr-2`,e!==j&&`invisible`),size:16})]},e))}),(0,U.jsx)(_J,{}),(0,U.jsx)(gJ,{children:`Filter by tag`}),(0,U.jsx)(pJ,{className:`max-h-60 overflow-y-auto`,children:Ce?.map(e=>(0,U.jsxs)(mJ,{onClick:t=>{t.stopPropagation(),t.preventDefault(),r.includes(e.value)?i(r.filter(t=>t!==e.value)):i([...r,e.value])},className:`justify-between`,children:[e.label,(0,U.jsx)(fd,{className:W(`mr-2`,!r.includes(e.value)&&`invisible`),size:18})]},e.label))}),(0,U.jsx)(_J,{}),(0,U.jsx)(gJ,{children:(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(gee,{size:16}),`Group by`]})}),(0,U.jsx)(pJ,{children:kBt.map(e=>(0,U.jsxs)(mJ,{onClick:t=>{t.stopPropagation(),t.preventDefault(),o(e.value)},className:`justify-between`,children:[e.label,(0,U.jsx)(fd,{className:W(`mr-2`,a!==e.value&&`invisible`),size:16})]},e.value))})]})]})}),E?null:(0,U.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,U.jsx)(X,{variant:`outline`,size:`sm`,onClick:()=>{f(!1),u(`details`),c(!0)},"aria-label":`API Settings`,title:`API Settings`,children:(0,U.jsx)(Af,{size:16})}),(0,U.jsxs)(uJ,{children:[(0,U.jsx)(dJ,{asChild:!0,children:(0,U.jsxs)(X,{variant:`outline`,size:`sm`,"data-test":`add-route-btn`,className:`relative gap-0.5!`,children:[(0,U.jsx)(`div`,{className:`absolute w-1.5 h-1.5 rounded-full -top-0.5 -right-[3px] bg-zuplo-700`}),(0,U.jsx)(Mf,{"aria-hidden":`true`,className:`size-3.5`}),`Add`]})}),(0,U.jsx)(fJ,{children:(0,U.jsx)(A_t,{...Ge})})]})]})]}),(0,U.jsx)(IY,{onClearValue:()=>V(``),value:ne,showClearButton:!!ne&&ne.length>0,children:(0,U.jsx)(gT,{ref:m,value:ne,onChange:e=>V(e.target.value),placeholder:`Search Routes`,className:`px-8`})}),r.length>0&&(0,U.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:r.map(e=>(0,U.jsxs)(`div`,{className:`group flex items-center gap-1 max-w-full pl-1.5 pr-0.5 py-0.5 rounded-full border border-border bg-card text-xs text-foreground`,children:[(0,U.jsx)(ep,{size:11,className:`shrink-0 text-muted-foreground`}),(0,U.jsx)(`span`,{className:`truncate`,title:e,children:e}),(0,U.jsx)(`button`,{type:`button`,"aria-label":`Remove ${e} filter`,onClick:t=>{t.stopPropagation(),i(r.filter(t=>t!==e))},className:`shrink-0 size-4 rounded-full flex items-center justify-center text-muted-foreground hover:bg-surface-emphasis hover:text-neutral-900 dark:hover:text-foreground`,children:(0,U.jsx)(pp,{size:11})})]},e))}),(0,U.jsx)(`div`,{className:`overflow-y-auto space-y-1`,children:re.map((e,t,n)=>{let r=!e.collapsible||C.has(e.key),i=e.operations.length,o=e.icon,s=(0,U.jsx)(`span`,{className:`ml-auto shrink-0 rounded-full bg-background px-1.5 py-0.5 text-xs font-normal tabular-nums text-muted-foreground`,children:i});return(0,U.jsxs)(`div`,{children:[e.collapsible?(0,U.jsxs)(`button`,{type:`button`,onClick:()=>T(e.key),"aria-expanded":r,className:`mt-3 mb-1 flex w-full items-center gap-1.5 rounded-md bg-muted/60 px-2 py-2 text-left text-sm font-semibold text-foreground transition-colors first:mt-1 hover:bg-muted`,title:r?`Collapse ${e.label}`:`Expand ${e.label} (${i} ${i===1?`route`:`routes`})`,children:[r?(0,U.jsx)(pd,{size:15,className:`shrink-0 text-muted-foreground`}):(0,U.jsx)(md,{size:15,className:`shrink-0 text-muted-foreground`}),o&&(0,U.jsx)(o,{size:16,className:`shrink-0 text-muted-foreground`}),(0,U.jsx)(`span`,{className:`truncate font-mono`,title:e.label,children:e.label}),s]}):a!==`none`&&(0,U.jsxs)(`div`,{className:`mt-3 mb-1 flex items-center gap-1.5 rounded-md bg-muted/60 px-2 py-2 text-sm font-semibold text-foreground first:mt-1`,children:[o&&(0,U.jsx)(o,{size:16,className:`shrink-0 text-muted-foreground`}),(0,U.jsx)(`span`,{className:W(`truncate`,e.mono&&`font-mono`),title:e.label,children:e.label}),s]}),r&&e.operations.map(({additionalOperationContext:e,...r})=>{let i=Be?.operationId===r.operationId,o=r[VX]?.handler,s=HX(o),c=UX(o),l=s?o.options?.operations?.length??0:0,u=l>0,d=y.has(r.operationId);return(0,U.jsxs)(H.Fragment,{children:[(0,U.jsx)(nvt,{path:i&&ie?ie:e.path,type:c?`mcp-virtual`:s?`mcp`:`route`,method:e.method,summary:i&&oe?oe:r.summary,operationId:r.operationId,operation:r,isSelected:i,onOperationSelected:t=>{ae(``),se(``),g({path:e.path,method:e.method}),O(t)},onDelete:(e,t,n)=>{v({path:e,method:t,operationId:n}),le(!0)},onAddRoute:Te,onDuplicate:()=>Ve(e.path,e.method,r),onMoveUp:ABt.has(a)?void 0:()=>xe(e.path,`up`),onMoveDown:ABt.has(a)?void 0:()=>xe(e.path,`down`),isFirstPath:j===E8&&t===0,isLastPath:j===E8&&t===n.length-1,isToolsExpanded:u?d:void 0,onToggleTools:u?()=>x(r.operationId):void 0,toolsCount:u?l:void 0}),o&&u&&d&&(0,U.jsx)(wvt,{handler:o,operation:{...r,additionalOperationContext:e}})]},r.operationId)})]},e.key)})})]}),(0,U.jsx)(`div`,{className:`col-span-2 flex flex-col h-full overflow-y-auto`,children:(0,U.jsx)(_3.Provider,{value:{setPath:ae,setSummary:se},children:(0,U.jsx)(Tvt.Provider,{value:Re,children:(0,U.jsx)(hBt,{operationData:Be,addRouteMenuProps:Ge})})})})]})},IBt={create:{shell:`bg-emerald-500/8 shadow-emerald-950/5`,icon:`bg-emerald-500/12 text-emerald-700 dark:text-emerald-300`,count:`bg-emerald-500/12 text-emerald-700 dark:text-emerald-300`},update:{shell:`bg-brand/8 shadow-brand/5`,icon:`bg-brand/12 text-brand`,count:`bg-brand/12 text-brand`},keep:{shell:`bg-background shadow-black/5 dark:shadow-white/5`,icon:`bg-muted text-muted-foreground`,count:`bg-muted text-muted-foreground`}},k8=({icon:e,operations:t,title:n,tone:r})=>{let i=IBt[r];return(0,U.jsxs)(`section`,{className:`rounded-2xl p-4 shadow-sm ${i.shell}`,"aria-label":`${n} operations`,children:[(0,U.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2 font-semibold text-foreground`,children:[(0,U.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded-xl ${i.icon}`,children:e}),n,` operations`]}),(0,U.jsx)(`div`,{className:`rounded-full px-2.5 py-1 text-xs font-medium tabular-nums ${i.count}`,children:t.size})]}),(0,U.jsx)(`div`,{className:`space-y-1.5`,children:Array.from(t).map(e=>{let t=e.split(`>`),n=t[0],r=t.slice(1,t.length).join(`>`);return(0,U.jsxs)(`div`,{className:`flex min-h-10 items-center gap-3 rounded-xl bg-background/80 px-3 py-2 text-sm shadow-xs`,children:[(0,U.jsx)(LY,{className:`w-14`,method:n}),(0,U.jsx)(`span`,{className:`break-all text-foreground/90`,children:r})]},e)})})]})},LBt=({openApiFileModel:e,onOpenApiFileSynced:t,setIsOpen:n})=>{let[r,i]=(0,H.useState)(),a=Ep(),o=e=>{i(e)},s=async()=>{if(!r)throw Error(`No file selected`);let i=e.content?JSON.parse(e.content):null;t(i?xlt(i,r.content):r.content),n(!1),a.success(`OpenAPI file merged successfully`,{icon:(0,U.jsx)(Wfe,{className:`h-4 w-4`})})};if(r){let t=Elt(JSON.parse(e.content??`{}`),r.content);return(0,U.jsx)(g1,{isOpen:!0,setIsOpen:n,title:`Review OpenAPI import`,className:`sm:max-w-4xl max-h-[88vh] overflow-y-auto`,icon:(0,U.jsx)(gb,{className:`shrink-0 h-6 w-6 text-brand`}),iconStyle:`bg-zuplo-pink/10`,buttons:[{onButtonClick:()=>{n(!1)},variant:`outline`,buttonContent:`Cancel`,id:`Close merge open-api modal`,testID:`merge-cancel-btn`},{onButtonClick:s,variant:`brand`,buttonContent:`Import changes`,id:`Complete open-api merge`,testID:`complete-merge-btn`}],bodyComponent:(0,U.jsxs)(`div`,{className:`mt-6 text-left text-sm`,children:[(0,U.jsx)(`div`,{className:`overflow-hidden rounded-3xl bg-gradient-to-br from-brand/12 via-background to-background p-px shadow-lg shadow-brand/5`,children:(0,U.jsxs)(`div`,{className:`rounded-[calc(1.5rem-1px)] bg-background p-5`,children:[(0,U.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-[1fr_auto_1fr] md:items-center`,children:[(0,U.jsx)(`div`,{className:`rounded-2xl bg-surface-sunken p-4 shadow-[inset_0_1px_rgba(255,255,255,0.05)]`,children:(0,U.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,U.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-xl bg-brand/10 text-brand`,children:(0,U.jsx)(hpe,{className:`h-5 w-5`})}),(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-wide text-muted-foreground`,children:`Import file`}),(0,U.jsx)(`div`,{className:`mt-0.5 truncate font-medium text-foreground`,children:r.name})]})]})}),(0,U.jsx)(`div`,{className:`hidden h-10 w-10 items-center justify-center rounded-full bg-brand text-brand-foreground shadow-sm shadow-brand/24 md:flex`,children:(0,U.jsx)(gb,{className:`h-5 w-5`})}),(0,U.jsx)(`div`,{className:`rounded-2xl bg-surface-sunken p-4 shadow-[inset_0_1px_rgba(255,255,255,0.05)]`,children:(0,U.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,U.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-xl bg-emerald-500/10 text-emerald-600 dark:text-emerald-400`,children:(0,U.jsx)(Sb,{className:`h-5 w-5`})}),(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-wide text-muted-foreground`,children:`Current API`}),(0,U.jsx)(`div`,{className:`mt-0.5 truncate font-medium text-foreground`,children:e.path})]})]})})]}),(0,U.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-2 text-muted-foreground`,children:[(0,U.jsx)(`span`,{children:`Operations are matched by`}),(0,U.jsx)(rT,{variant:`outline`,children:`Path + method`}),(0,U.jsx)(`span`,{children:`so existing Zuplo extensions and policies stay in place.`})]})]})}),(0,U.jsxs)(`div`,{className:`mt-6 flex items-end justify-between gap-3`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`div`,{className:`text-base font-semibold text-foreground`,children:`Import summary`}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Review what will change before applying this file.`})]}),(0,U.jsxs)(`div`,{className:`rounded-full bg-surface-sunken px-3 py-1 text-xs font-medium text-muted-foreground tabular-nums`,children:[t.created.size+t.merged.size+t.retained.size,` `,`operations`]})]}),(0,U.jsxs)(`div`,{className:`mt-3 grid max-h-96 gap-3 overflow-y-auto rounded-3xl bg-surface-sunken p-3 shadow-[inset_0_1px_rgba(255,255,255,0.04)]`,children:[t.created.size>0?(0,U.jsx)(k8,{icon:(0,U.jsx)(Fpe,{className:`h-4 w-4`}),title:`Create`,tone:`create`,operations:t.created}):null,t.merged.size>0?(0,U.jsx)(k8,{icon:(0,U.jsx)(Mpe,{className:`h-4 w-4`}),title:`Update`,tone:`update`,operations:t.merged}):null,t.retained.size>0?(0,U.jsx)(k8,{icon:(0,U.jsx)(Gfe,{className:`h-4 w-4`}),title:`Keep`,tone:`keep`,operations:t.retained}):null]})]})})}return(0,U.jsx)(w_t,{title:`Import OpenAPI`,onValidFileSelected:o,setIsOpen:n})},RBt=()=>{let e=bt(),t=Oe({mutationFn:t=>e.fetch(ae.users.updatePreferences(t))}),{data:n}=ax(je.user.preferences());return{preferences:n,updatePreferences:t.mutate,updatePreferencesMutation:t}},zBt=!1;function A8(){let e=At(),{preferences:t,updatePreferencesMutation:n}=RBt();return{isFileTreeOpen:t.fileTreeOpen??zBt,setIsFileTreeOpen:r=>{let i=[je.user.preferences().url,!0],a=e.getQueryData(i),o={...a??t,fileTreeOpen:r};e.setQueryData(i,o),n.mutate(o,{onError:()=>{a&&e.setQueryData(i,a),e.invalidateQueries({queryKey:i})}})}}}function BBt(){let e=iQ(),{logEvent:t}=S(),[n,r]=kY(`v`,`designer`),{isFileTreeOpen:i}=A8(),a=e?.path.split(`/`).pop()??`JSON`,o=aQ(),s=E_t(),[c,l]=M$(()=>{if(!e)throw Error(`File model not found`);return t(`merge-open-api`),(0,U.jsx)(LBt,{openApiFileModel:e,onOpenApiFileSynced:n=>{let r={...e,content:JSON.stringify(n,null,2)};o(r,!0),t(`merge-open-api-complete`),s(r.path)},setIsOpen:l})},[e,s]);return(0,U.jsx)(ovt,{children:(0,U.jsx)(r_t,{children:(0,U.jsxs)(hj,{defaultValue:`designer`,value:n,onValueChange:e=>r(e),className:`flex flex-col h-full w-full max-h-screen min-w-[850px]`,children:[i&&(0,U.jsxs)(gj,{className:`rounded-none border-b w-full justify-start`,children:[(0,U.jsx)(_j,{value:`designer`,children:`Route Designer`}),(0,U.jsx)(_j,{value:`raw`,children:a??`Raw`}),(0,U.jsxs)(X,{variant:`outline`,size:`sm`,onClick:c,className:`ml-4`,children:[(0,U.jsx)(Upe,{className:`w-4 h-4`}),` Import`]})]}),(0,U.jsx)(vj,{value:`designer`,className:`grow h-full overflow-y-auto`,children:(0,U.jsx)(d_t,{onNavigateToOpenApiFileTab:()=>r(`raw`),children:(0,U.jsx)(FBt,{onNavigateToOpenApiFileTab:()=>r(`raw`)})})}),(0,U.jsx)(vj,{value:`raw`,className:`grow h-full overflow-y-auto`,forceMount:!0,children:(0,U.jsx)(_Q,{})})]})})})}function VBt({title:e,description:t,folder:n,icon:r,emptyText:i,newLabel:a,onCreate:o}){let s=Pp(e=>e.projectTreeNodes),[c,l]=Vs(),{isReadOnly:u}=HZ(),d=n.endsWith(`/`)?n:`${n}/`,f=(0,H.useMemo)(()=>s.filter(e=>e.type===Zs.File&&e.path.startsWith(d)).sort((e,t)=>e.path.localeCompare(t.path)),[s,d]),p=e=>{let t=new URLSearchParams(c);t.set(`path`,e),t.delete(`v`),t.delete(`line`),l(t)};return(0,U.jsx)(`div`,{className:`h-full w-full overflow-y-auto`,children:(0,U.jsxs)(`div`,{className:`mx-auto max-w-3xl px-6 py-8`,children:[(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`h1`,{className:`text-xl font-bold text-neutral-900 dark:text-neutral-100`,children:e}),(0,U.jsx)(`p`,{className:`text-sm text-neutral-600 dark:text-neutral-400`,children:t})]}),!u&&(0,U.jsxs)(X,{variant:`secondary`,size:`sm`,onClick:o,className:`shrink-0`,children:[(0,U.jsx)(Mf,{className:`size-4`}),a]})]}),(0,U.jsx)(`div`,{className:`mt-6 flex flex-col gap-1.5`,children:f.length===0?(0,U.jsx)(`div`,{className:`rounded-lg border border-dashed p-8 text-center text-sm text-neutral-500 dark:text-neutral-400`,children:i}):f.map(e=>{let t=e.path.slice(d.length);return(0,U.jsxs)(`button`,{type:`button`,onClick:()=>p(e.path),className:W(`group flex w-full items-center gap-3 rounded-lg border px-3 py-2.5 text-left transition-colors`,`bg-surface hover:border-brand/40 hover:bg-brand/5`,`ring-offset-background focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`),children:[(0,U.jsx)(r,{className:`size-4 shrink-0 text-neutral-500 group-hover:text-brand`}),(0,U.jsx)(`span`,{className:`truncate text-sm font-medium text-neutral-800 dark:text-neutral-200`,children:t})]},e.path)})})]})})}function HBt(){let e=Pp(e=>e.setPendingNewFile),{setIsFileTreeOpen:t}=A8();return(0,U.jsx)(VBt,{title:`Custom Modules`,description:`TypeScript modules in your project's modules/ folder — request handlers, policies, and other custom code.`,folder:`/modules`,icon:Ef,emptyText:`No custom modules yet. Create one to add request handlers or custom logic.`,newLabel:`New Module`,onCreate:()=>{t(!0),e({strategyFolder:`/modules`,template:`Request Handler`})}})}function UBt(){let e=Pp(e=>e.setPendingNewFile),{setIsFileTreeOpen:t}=A8();return(0,U.jsx)(VBt,{title:`Schemas`,description:`JSON schemas in your project's schemas/ folder, used to validate requests and responses.`,folder:`/schemas`,icon:qd,emptyText:`No schemas yet. Create one to validate request or response bodies.`,newLabel:`New Schema`,onCreate:()=>{t(!0),e({strategyFolder:`/schemas`,template:`Schema`})}})}var WBt=()=>{let[e,t]=(0,H.useState)(),{isReadOnly:n}=HZ(),r=D1(),i=r.policiesUsageInfo,{logEvent:a}=S(),o=Op([`account`,`project`,`environment`]),[s,c]=M$(()=>e?(0,U.jsx)(yIt,{isOpen:!0,setIsOpen:c,stackType:e,shouldHideExistingPolicies:!0,policyManager:r}):null,[e]),l=e=>{t(e),a(`create-policy-clicked`,{account:o.account.name,project:o.project.name,environment:o.environment.name,type:e}),s()},u=(r.policyList??[]).flatMap(e=>i?.find(t=>t.name===e.name)??[]);return(0,U.jsx)(`div`,{className:`h-full w-full overflow-y-auto`,children:(0,U.jsxs)(`div`,{className:`mx-auto max-w-3xl px-6 py-8`,children:[(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`h1`,{className:`text-xl font-bold text-neutral-900 dark:text-neutral-100`,children:`Policies`}),(0,U.jsx)(`p`,{className:`text-sm text-neutral-600 dark:text-neutral-400`,children:`Reusable policies from your project's config/policies.json — apply them to routes to inspect and control requests and responses.`})]}),!n&&(0,U.jsxs)(uJ,{modal:!1,children:[(0,U.jsx)(dJ,{asChild:!0,children:(0,U.jsxs)(X,{variant:`secondary`,size:`sm`,className:`shrink-0`,children:[(0,U.jsx)(Mf,{className:`size-4`}),`New Policy`]})}),(0,U.jsxs)(fJ,{align:`end`,children:[(0,U.jsxs)(mJ,{onClick:()=>l(`inbound`),children:[(0,U.jsx)(Ku,{className:`mr-2 size-4`}),`Inbound Policy`]}),(0,U.jsxs)(mJ,{onClick:()=>l(`outbound`),children:[(0,U.jsx)(Zu,{className:`mr-2 size-4`}),`Outbound Policy`]})]})]})]}),(0,U.jsx)(`div`,{className:`mt-6 flex flex-col gap-1.5`,children:u.length===0?(0,U.jsxs)(`div`,{className:`rounded-lg border border-dashed p-8 text-center text-sm text-neutral-500 dark:text-neutral-400`,children:[`No policies yet. Create an inbound or outbound policy to inspect and control requests and responses, or`,` `,(0,U.jsx)(hT,{href:`https://zuplo.com/docs/overview/policies`,children:`read the docs`}),`.`]}):u.map(e=>(0,U.jsx)(fIt,{policy:e},e.name))})]})})},GBt=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.DeploymentLogState=void 0;var t;(function(e){e.ERROR=`ERROR`,e.IN_PROGRESS=`IN_PROGRESS`,e.SUCCESS=`SUCCESS`})(t||(e.DeploymentLogState=t={}))})),KBt=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.SourceControlProvider=e.PlanType=e.EnvironmentType=e.EnvironmentTarget=e.DeploymentState=void 0;var t;(function(e){e[e.IS_STARTING=0]=`IS_STARTING`,e[e.STARTED=1]=`STARTED`,e[e.STOPPED=2]=`STOPPED`,e[e.ERRORED=3]=`ERRORED`})(t||(e.DeploymentState=t={}));var n;(function(e){e.CLOUDFLARE=`CLOUDFLARE`,e.KNATIVE=`KNATIVE`})(n||(e.EnvironmentTarget=n={}));var r;(function(e){e.PRODUCTION=`PRODUCTION`,e.PREVIEW=`PREVIEW`,e.WORKING_COPY=`WORKING_COPY`})(r||(e.EnvironmentType=r={}));var i;(function(e){e.FREE_V1=`FREE_V1`,e.BUILDER_V1=`BUILDER_V1`,e.BUSINESS_V1=`BUSINESS_V1`,e.CUSTOM=`CUSTOM`,e.EMPLOYEE=`EMPLOYEE`,e.CUSTOM_TRIAL_V1=`CUSTOM_TRIAL_V1`})(i||(e.PlanType=i={}));var a;(function(e){e.GITHUB=`GITHUB`,e.GITLAB=`GITLAB`,e.BITBUCKET=`BITBUCKET`})(a||(e.SourceControlProvider=a={}))})),qBt=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0})})),JBt=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.INTERNAL_ROUTE_VENDOR_TAG=e.ZUPLO_OPEN_API_ROUTE_KEY=e.ZUPLO_OPEN_API_PATH_KEY=e.ZUPLO_OPEN_API_VENDOR_PREFIX=void 0,e.ZUPLO_OPEN_API_VENDOR_PREFIX=`x-zuplo`,e.ZUPLO_OPEN_API_PATH_KEY=`${e.ZUPLO_OPEN_API_VENDOR_PREFIX}-path`,e.ZUPLO_OPEN_API_ROUTE_KEY=`${e.ZUPLO_OPEN_API_VENDOR_PREFIX}-route`,e.INTERNAL_ROUTE_VENDOR_TAG=`x-internal`})),YBt=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.processJsonErrorObject=void 0;var t={'must match pattern "^[0-9a-z-]+$"':`Value must be alphanumeric or dash '-' only`,'must match pattern "^\\$import\\([^ )]*?\\)$"':`Value must be of form '$import(./path/to/module)`},n={'must match pattern "^[0-9a-z-]+$"':`Make sure the value uses only lowercase letters, numbers and dashes ('-').`,'must match pattern "^\\$import\\([^ )]*?\\)$"':`Value must be of form '$import(./path/to/module)`},r=e=>e.replace(`/`,``).replaceAll(`/`,` → `).replaceAll(`~1`,`/`),i={paths:`paths`};function a(e,a){let o=e.message,s=e.details?.property??``,c=e.details?.index??0,l=e.details?.field,u=e.details?.fieldValue,d=e.keyword,f=e.params,p=e.propertyName,m=r(e.instancePath),h=t[o]??o,g,_;if(d===`unevaluatedProperties`)g=`Unrecognized property '${f.unevaluatedProperty}'${l?` detected in '${l}'`:``} within '${a}'. Property location: ${m}.`;else if(d===`additionalProperties`)g=`Unrecognized property '${f.additionalProperty}'${l?` detected in '${l}'`:``} within '${a}'. Property location: ${m}.`;else if(d===`enum`)g=`Unrecognized value${u?` '${u}'`:``} for '${l}' detected in '${a}'. Value ${h}. Property location: ${m}.`;else if(d===`pattern`){let e=f.pattern;g=p?`Property name '${p}' does not match pattern ${e} in '${a}'. Property location: ${m}.`:`Invalid value '${u}' for field '${l}' in '${a}'. Value does not match pattern ${e}. Property location: ${m}.`}else d===`propertyNames`?g=`Invalid property name '${f.propertyName}' for property '${s}' detected in '${a}'. Property location: ${m}.`:d===`required`?g=`Missing required property '${f.missingProperty}' in '${a}'. Property location: ${m}.`:l&&s?(g=`Property ${i[s]} entry at position ${c+1} in '${a}' has invalid ${l} with value '${e.details?.fieldValue}' (${h})`,_={field:l,fieldValue:e.details?.fieldValue??``,property:s,instancePath:m,suggestion:n[o]??``}):g=s?`The ${i[s]} entry at position ${c+1} in '${a}' is invalid (${h})`:`The '${a}' configuration is invalid (${h})`;return{property:s,entry:{message:g,index:c,field:l,details:_}}}e.processJsonErrorObject=a})),XBt=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.startsWithReservedKeyword=void 0;var t=[`settings`,`user`,`manage`,`profile`,`login`,`logout`,`admin`,`system`,`account`,`accounts`,`home`,`dashboard`];function n(e){return t.filter(t=>e.startsWith(t)).length>0}e.startsWithReservedKeyword=n})),ZBt=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.isValidProjectName=e.MAX_PRETTY_BRANCH_LENGTH=e.MAX_HASH_LENGTH=void 0;var t=XBt();e.MAX_HASH_LENGTH=7,e.MAX_PRETTY_BRANCH_LENGTH=10;var n=40;function r(e){let r={isValid:!0};return e.length===0?(r.isValid=!1,r.errorMessage=`Project name cannot be empty`,r):(0,t.startsWithReservedKeyword)(e)?(r.isValid=!1,r.errorMessage=`Project name can not start with a reserved keyword`,r):/[\s]/.test(e)?(r.isValid=!1,r.errorMessage=`Project name can't contain spaces`,r):/[A-Z]/.test(e)?(r.isValid=!1,r.errorMessage=`Project name should be in lowercase`,r):/^[^a-z]/.test(e)?(r.isValid=!1,r.errorMessage=`Project name should start with a letter`,r):/[^a-z0-9]$/.test(e)?(r.isValid=!1,r.errorMessage=`Project name should end with a letter or number`,r):/[^a-z0-9\\-]/.test(e)?(r.isValid=!1,r.errorMessage=`Project name only can contain letter, numbers and dashes`,r):(e.length>n&&(r.isValid=!1,r.errorMessage=`Project name cannot exceed ${n} characters because it needs to be part of the URL subdomain. Your chosen name is ${e.length-n} over.`),r)}e.isValidProjectName=r})),QBt=i({$defs:()=>I8,$id:()=>M8,$schema:()=>j8,additionalProperties:()=>!1,default:()=>$Bt,description:()=>``,properties:()=>L8,required:()=>F8,title:()=>N8,type:()=>P8}),j8,M8,N8,P8,F8,I8,L8,$Bt,eVt=n((()=>{j8=`https://json-schema.org/draft/2020-12/schema`,M8=`http://schemas.zuplo.com/route.json`,N8=`Route Config File`,P8=`object`,F8=[`routes`,`versions`],I8={corsPolicy:{type:`string`,pattern:`^[0-9a-z-]+$`},httpMethod:{type:`string`,enum:[`GET`,`HEAD`,`POST`,`PUT`,`DELETE`,`CONNECT`,`OPTIONS`,`TRACE`,`PATCH`]},handlerDefinition:{type:`object`,properties:{module:{type:`string`,pattern:`^\\$import\\([^ )]*?\\)$`},export:{type:`string`},options:{type:`object`,additionalProperties:!0}},additionalProperties:!1,required:[`module`,`export`]},schema:{$comment:`https://spec.openapis.org/oas/v3.1.0#schema-object`,type:[`object`,`boolean`]},parameterBaseObject:{$comment:`https://spec.openapis.org/oas/v3.1.0#schema-object`,type:`object`,properties:{description:{type:`string`},required:{default:!1,type:`boolean`},deprecated:{default:!1,type:`boolean`},schema:{$ref:`#/$defs/schema`}},required:[`schema`]},parameterDefinition:{$comment:`https://spec.openapis.org/oas/v3.1.0#parameter-object`,allOf:[{$ref:`#/$defs/parameterBaseObject`}],type:`object`,properties:{name:{type:`string`},in:{type:`string`,enum:[`query`,`header`,`path`,`cookie`]}},required:[`name`,`in`,`schema`],if:{type:`object`,properties:{in:{const:`query`}},required:[`in`]},then:{type:`object`,properties:{allowEmptyValue:{default:!1,type:`boolean`}}}},"media-type":{$comment:`https://spec.openapis.org/oas/v3.1.0#media-type-object`,type:`object`,properties:{schema:{$ref:`#/$defs/schema`}},unevaluatedProperties:!1},content:{$comment:`https://spec.openapis.org/oas/v3.1.0#fixed-fields-10`,type:`object`,additionalProperties:{$ref:`#/$defs/media-type`},propertyNames:{enum:[`application/json`,`application/problem+json`]}},header:{$comment:`https://spec.openapis.org/oas/v3.1.0#header-object`,allOf:[{$ref:`#/$defs/parameterBaseObject`}],type:`object`,required:[`schema`]},response:{$comment:`https://spec.openapis.org/oas/v3.1.0#response-object`,type:`object`,properties:{description:{type:`string`},headers:{type:`object`,additionalProperties:{$ref:`#/$defs/header`}},content:{$ref:`#/$defs/content`}},required:[`description`],unevaluatedProperties:!1},responsesDefinition:{$comment:`https://spec.openapis.org/oas/v3.1.0#responses-object`,type:`object`,properties:{default:{$ref:`#/$defs/response`}},patternProperties:{"^[1-5](?:[0-9]{2}|XX)$":{$ref:`#/$defs/response`}},minProperties:1,unevaluatedProperties:!1},tag:{$comment:`https://spec.openapis.org/oas/v3.1.0#tag-object`,type:`object`,properties:{name:{type:`string`},description:{type:`string`}},required:[`name`],unevaluatedProperties:!1},info:{type:`object`,required:[`title`,`version`],properties:{title:{type:`string`},summary:{type:`string`},description:{type:`string`},termsOfService:{type:`string`,format:`uri`},version:{type:`string`}}},versionData:{type:`object`,required:[`name`,`pathPrefix`],additionalProperties:!1,properties:{name:{type:`string`,pattern:`^[0-9a-z-]+$`},pathPrefix:{type:`string`,pattern:`(^$|^/[^\\s]*$)`},info:{$ref:`#/$defs/info`},openApiFile:{description:`The project relative path to the OpenAPI spec.`,type:`string`},tags:{type:`array`,items:{$ref:`#/$defs/tag`}},excludeFromOpenApi:{type:`boolean`,description:`If false, OpenAPI documentation will not be generated for this version. If openApiFile is set this setting is ignored.`},enforceOpenApi:{type:`boolean`,description:`If true, schema validation found in the OpenAPI spec will be enforced on requests/responses.`}}},routeConfiguration:{type:`object`,required:[`path`,`methods`,`handler`,`version`],additionalProperties:!1,properties:{operationId:{type:`string`},path:{type:`string`,pattern:`^/[^\\s]*$`},methods:{type:`array`,items:{$ref:`#/$defs/httpMethod`}},label:{type:`string`,description:`An internal user-friendly identifier of the route.`},enforceOpenApi:{type:`boolean`,description:`If true, schema validation found in the OpenAPI spec will be enforced on requests/responses.`},key:{type:`string`,deprecated:!0},handler:{$ref:`#/$defs/handlerDefinition`},corsPolicy:{$ref:`#/$defs/corsPolicy`},custom:{},version:{type:`string`,pattern:`^[0-9a-z-]+$`},policies:{type:`object`,additionalProperties:!1,properties:{inbound:{type:`array`,items:{type:`string`,pattern:`^[0-9a-z-]+$`}},outbound:{type:`array`,items:{type:`string`,pattern:`^[0-9a-z-]+$`}}}},summary:{type:`string`},description:{type:`string`},parameters:{type:`array`,items:{$ref:`#/$defs/parameterDefinition`}},excludeFromOpenApi:{type:`boolean`},responses:{$ref:`#/$defs/responsesDefinition`},tags:{type:`array`,items:{type:`string`}}}},policyConfiguration:{type:`object`,required:[`name`,`policyType`,`handler`],additionalProperties:!1,properties:{name:{type:`string`,pattern:`^[0-9a-z-]+$`},policyType:{type:`string`},handler:{$ref:`#/$defs/handlerDefinition`},options:{type:`object`,additionalProperties:!0}}},corsPolicyConfiguration:{type:`object`,required:[`name`,`allowedOrigins`],additionalProperties:!1,properties:{name:{type:`string`,pattern:`^[0-9a-z-]+$`},allowCredentials:{type:`boolean`},maxAge:{type:`number`},allowedOrigins:{oneOf:[{type:`array`,items:{type:`string`}},{type:`string`}]},allowedMethods:{oneOf:[{type:`array`,items:{$ref:`#/$defs/httpMethod`}},{type:`string`}]},allowedHeaders:{oneOf:[{type:`array`,items:{type:`string`}},{type:`string`}]},exposeHeaders:{oneOf:[{type:`array`,items:{type:`string`}},{type:`string`}]}}}},L8={$schema:{type:`string`},info:{$ref:`#/$defs/info`,deprecated:!0},versions:{type:`array`,minItems:1,items:{$ref:`#/$defs/versionData`}},routes:{type:`array`,minItems:0,items:{$ref:`#/$defs/routeConfiguration`}},policies:{type:`array`,items:{$ref:`#/$defs/policyConfiguration`}},corsPolicies:{type:`array`,items:{$ref:`#/$defs/corsPolicyConfiguration`}},requestErrorHandler:{$ref:`#/$defs/handlerDefinition`}},$Bt={$schema:j8,$id:M8,title:N8,description:``,type:P8,additionalProperties:!1,required:F8,$defs:I8,properties:L8}})),tVt=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.formatNames=e.fastFormats=e.fullFormats=void 0;function t(e,t){return{validate:e,compare:t}}e.fullFormats={date:t(a,o),time:t(c,l),"date-time":t(d,f),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:h,"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,url:/^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,ipv6:/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,regex:w,uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:_,int32:{type:`number`,validate:b},int64:{type:`number`,validate:x},float:{type:`number`,validate:S},double:{type:`number`,validate:S},password:!0,binary:!0},e.fastFormats={...e.fullFormats,date:t(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,o),time:t(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,l),"date-time":t(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,f),uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i},e.formatNames=Object.keys(e.fullFormats);function n(e){return e%4==0&&(e%100!=0||e%400==0)}var r=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,i=[0,31,28,31,30,31,30,31,31,30,31,30,31];function a(e){let t=r.exec(e);if(!t)return!1;let a=+t[1],o=+t[2],s=+t[3];return o>=1&&o<=12&&s>=1&&s<=(o===2&&n(a)?29:i[o])}function o(e,t){if(e&&t)return e>t?1:e<t?-1:0}var s=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i;function c(e,t){let n=s.exec(e);if(!n)return!1;let r=+n[1],i=+n[2],a=+n[3],o=n[5];return(r<=23&&i<=59&&a<=59||r===23&&i===59&&a===60)&&(!t||o!==``)}function l(e,t){if(!(e&&t))return;let n=s.exec(e),r=s.exec(t);if(n&&r)return e=n[1]+n[2]+n[3]+(n[4]||``),t=r[1]+r[2]+r[3]+(r[4]||``),e>t?1:e<t?-1:0}var u=/t|\s/i;function d(e){let t=e.split(u);return t.length===2&&a(t[0])&&c(t[1],!0)}function f(e,t){if(!(e&&t))return;let[n,r]=e.split(u),[i,a]=t.split(u),s=o(n,i);if(s!==void 0)return s||l(r,a)}var p=/\/|:/,m=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function h(e){return p.test(e)&&m.test(e)}var g=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function _(e){return g.lastIndex=0,g.test(e)}var v=-(2**31),y=2**31-1;function b(e){return Number.isInteger(e)&&e<=y&&e>=v}function x(e){return Number.isInteger(e)}function S(){return!0}var C=/[^\\]\\Z/;function w(e){if(C.test(e))return!1;try{return new RegExp(e),!0}catch{return!1}}})),R8=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.regexpCode=e.getEsmExportName=e.getProperty=e.safeStringify=e.stringify=e.strConcat=e.addCodeArg=e.str=e._=e.nil=e._Code=e.Name=e.IDENTIFIER=e._CodeOrName=void 0;var t=class{};e._CodeOrName=t,e.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var n=class extends t{constructor(t){if(super(),!e.IDENTIFIER.test(t))throw Error(`CodeGen: name must be a valid identifier`);this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};e.Name=n;var r=class extends t{constructor(e){super(),this._items=typeof e==`string`?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===``||e===`""`}get str(){return this._str??=this._items.reduce((e,t)=>`${e}${t}`,``)}get names(){return this._names??=this._items.reduce((e,t)=>(t instanceof n&&(e[t.str]=(e[t.str]||0)+1),e),{})}};e._Code=r,e.nil=new r(``);function i(e,...t){let n=[e[0]],i=0;for(;i<t.length;)s(n,t[i]),n.push(e[++i]);return new r(n)}e._=i;var a=new r(`+`);function o(e,...t){let n=[p(e[0])],i=0;for(;i<t.length;)n.push(a),s(n,t[i]),n.push(a,p(e[++i]));return c(n),new r(n)}e.str=o;function s(e,t){t instanceof r?e.push(...t._items):t instanceof n?e.push(t):e.push(d(t))}e.addCodeArg=s;function c(e){let t=1;for(;t<e.length-1;){if(e[t]===a){let n=l(e[t-1],e[t+1]);if(n!==void 0){e.splice(t-1,3,n);continue}e[t++]=`+`}t++}}function l(e,t){if(t===`""`)return e;if(e===`""`)return t;if(typeof e==`string`)return t instanceof n||e[e.length-1]!==`"`?void 0:typeof t==`string`?t[0]===`"`?e.slice(0,-1)+t.slice(1):void 0:`${e.slice(0,-1)}${t}"`;if(typeof t==`string`&&t[0]===`"`&&!(e instanceof n))return`"${e}${t.slice(1)}`}function u(e,t){return t.emptyStr()?e:e.emptyStr()?t:o`${e}${t}`}e.strConcat=u;function d(e){return typeof e==`number`||typeof e==`boolean`||e===null?e:p(Array.isArray(e)?e.join(`,`):e)}function f(e){return new r(p(e))}e.stringify=f;function p(e){return JSON.stringify(e).replace(/\u2028/g,`\\u2028`).replace(/\u2029/g,`\\u2029`)}e.safeStringify=p;function m(t){return typeof t==`string`&&e.IDENTIFIER.test(t)?new r(`.${t}`):i`[${t}]`}e.getProperty=m;function h(t){if(typeof t==`string`&&e.IDENTIFIER.test(t))return new r(`${t}`);throw Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}e.getEsmExportName=h;function g(e){return new r(e.toString())}e.regexpCode=g})),nVt=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;var t=R8(),n=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},r;(function(e){e[e.Started=0]=`Started`,e[e.Completed=1]=`Completed`})(r=e.UsedValueState||={}),e.varKinds={const:new t.Name(`const`),let:new t.Name(`let`),var:new t.Name(`var`)};var i=class{constructor({prefixes:e,parent:t}={}){this._names={},this._prefixes=e,this._parent=t}toName(e){return e instanceof t.Name?e:this.name(e)}name(e){return new t.Name(this._newName(e))}_newName(e){let t=this._names[e]||this._nameGroup(e);return`${e}${t.index++}`}_nameGroup(e){if((this._parent?._prefixes)?.has(e)||this._prefixes&&!this._prefixes.has(e))throw Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};e.Scope=i;var a=class extends t.Name{constructor(e,t){super(t),this.prefix=e}setValue(e,{property:n,itemIndex:r}){this.value=e,this.scopePath=(0,t._)`.${new t.Name(n)}[${r}]`}};e.ValueScopeName=a;var o=(0,t._)`\n`;e.ValueScope=class extends i{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?o:t.nil}}get(){return this._scope}name(e){return new a(e,this._newName(e))}value(e,t){if(t.ref===void 0)throw Error(`CodeGen: ref must be passed in value`);let n=this.toName(e),{prefix:r}=n,i=t.key??t.ref,a=this._values[r];if(a){let e=a.get(i);if(e)return e}else a=this._values[r]=new Map;a.set(i,n);let o=this._scope[r]||(this._scope[r]=[]),s=o.length;return o[s]=t.ref,n.setValue(t,{property:r,itemIndex:s}),n}getValue(e,t){let n=this._values[e];if(n)return n.get(t)}scopeRefs(e,n=this._values){return this._reduceValues(n,n=>{if(n.scopePath===void 0)throw Error(`CodeGen: name "${n}" has no value`);return(0,t._)`${e}${n.scopePath}`})}scopeCode(e=this._values,t,n){return this._reduceValues(e,e=>{if(e.value===void 0)throw Error(`CodeGen: name "${e}" has no value`);return e.value.code},t,n)}_reduceValues(i,a,o={},s){let c=t.nil;for(let l in i){let u=i[l];if(!u)continue;let d=o[l]=o[l]||new Map;u.forEach(i=>{if(d.has(i))return;d.set(i,r.Started);let o=a(i);if(o){let n=this.opts.es5?e.varKinds.var:e.varKinds.const;c=(0,t._)`${c}${n} ${i} = ${o};${this.opts._n}`}else if(o=s?.(i))c=(0,t._)`${c}${o}${this.opts._n}`;else throw new n(i);d.set(i,r.Completed)})}return c}}})),z8=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.or=e.and=e.not=e.CodeGen=e.operators=e.varKinds=e.ValueScopeName=e.ValueScope=e.Scope=e.Name=e.regexpCode=e.stringify=e.getProperty=e.nil=e.strConcat=e.str=e._=void 0;var t=R8(),n=nVt(),r=R8();Object.defineProperty(e,`_`,{enumerable:!0,get:function(){return r._}}),Object.defineProperty(e,`str`,{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(e,`strConcat`,{enumerable:!0,get:function(){return r.strConcat}}),Object.defineProperty(e,`nil`,{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(e,`getProperty`,{enumerable:!0,get:function(){return r.getProperty}}),Object.defineProperty(e,`stringify`,{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(e,`regexpCode`,{enumerable:!0,get:function(){return r.regexpCode}}),Object.defineProperty(e,`Name`,{enumerable:!0,get:function(){return r.Name}});var i=nVt();Object.defineProperty(e,`Scope`,{enumerable:!0,get:function(){return i.Scope}}),Object.defineProperty(e,`ValueScope`,{enumerable:!0,get:function(){return i.ValueScope}}),Object.defineProperty(e,`ValueScopeName`,{enumerable:!0,get:function(){return i.ValueScopeName}}),Object.defineProperty(e,`varKinds`,{enumerable:!0,get:function(){return i.varKinds}}),e.operators={GT:new t._Code(`>`),GTE:new t._Code(`>=`),LT:new t._Code(`<`),LTE:new t._Code(`<=`),EQ:new t._Code(`===`),NEQ:new t._Code(`!==`),NOT:new t._Code(`!`),OR:new t._Code(`||`),AND:new t._Code(`&&`),ADD:new t._Code(`+`)};var a=class{optimizeNodes(){return this}optimizeNames(e,t){return this}},o=class extends a{constructor(e,t,n){super(),this.varKind=e,this.name=t,this.rhs=n}render({es5:e,_n:t}){let r=e?n.varKinds.var:this.varKind,i=this.rhs===void 0?``:` = ${this.rhs}`;return`${r} ${this.name}${i};`+t}optimizeNames(e,t){if(e[this.name.str])return this.rhs&&=k(this.rhs,e,t),this}get names(){return this.rhs instanceof t._CodeOrName?this.rhs.names:{}}},s=class extends a{constructor(e,t,n){super(),this.lhs=e,this.rhs=t,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,n){if(!(this.lhs instanceof t.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=k(this.rhs,e,n),this}get names(){return O(this.lhs instanceof t.Name?{}:{...this.lhs.names},this.rhs)}},c=class extends s{constructor(e,t,n,r){super(e,n,r),this.op=t}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},l=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},u=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:``};`+e}},d=class extends a{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},f=class extends a{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,t){return this.code=k(this.code,e,t),this}get names(){return this.code instanceof t._CodeOrName?this.code.names:{}}},p=class extends a{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((t,n)=>t+n.render(e),``)}optimizeNodes(){let{nodes:e}=this,t=e.length;for(;t--;){let n=e[t].optimizeNodes();Array.isArray(n)?e.splice(t,1,...n):n?e[t]=n:e.splice(t,1)}return e.length>0?this:void 0}optimizeNames(e,t){let{nodes:n}=this,r=n.length;for(;r--;){let i=n[r];i.optimizeNames(e,t)||(A(e,i.names),n.splice(r,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,t)=>D(e,t.names),{})}},m=class extends p{render(e){return`{`+e._n+super.render(e)+`}`+e._n}},h=class extends p{},g=class extends m{};g.kind=`else`;var _=class e extends m{constructor(e,t){super(t),this.condition=e}render(e){let t=`if(${this.condition})`+super.render(e);return this.else&&(t+=`else `+this.else.render(e)),t}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===!0)return this.nodes;let n=this.else;if(n){let e=n.optimizeNodes();n=this.else=Array.isArray(e)?new g(e):e}if(n)return t===!1?n instanceof e?n:n.nodes:this.nodes.length?this:new e(j(t),n instanceof e?[n]:n.nodes);if(!(t===!1||!this.nodes.length))return this}optimizeNames(e,t){if(this.else=this.else?.optimizeNames(e,t),super.optimizeNames(e,t)||this.else)return this.condition=k(this.condition,e,t),this}get names(){let e=super.names;return O(e,this.condition),this.else&&D(e,this.else.names),e}};_.kind=`if`;var v=class extends m{};v.kind=`for`;var y=class extends v{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iteration=k(this.iteration,e,t),this}get names(){return D(super.names,this.iteration.names)}},b=class extends v{constructor(e,t,n,r){super(),this.varKind=e,this.name=t,this.from=n,this.to=r}render(e){let t=e.es5?n.varKinds.var:this.varKind,{name:r,from:i,to:a}=this;return`for(${t} ${r}=${i}; ${r}<${a}; ${r}++)`+super.render(e)}get names(){return O(O(super.names,this.from),this.to)}},x=class extends v{constructor(e,t,n,r){super(),this.loop=e,this.varKind=t,this.name=n,this.iterable=r}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iterable=k(this.iterable,e,t),this}get names(){return D(super.names,this.iterable.names)}},S=class extends m{constructor(e,t,n){super(),this.name=e,this.args=t,this.async=n}render(e){return`${this.async?`async `:``}function ${this.name}(${this.args})`+super.render(e)}};S.kind=`func`;var C=class extends p{render(e){return`return `+super.render(e)}};C.kind=`return`;var w=class extends m{render(e){let t=`try`+super.render(e);return this.catch&&(t+=this.catch.render(e)),this.finally&&(t+=this.finally.render(e)),t}optimizeNodes(){var e,t;return super.optimizeNodes(),(e=this.catch)==null||e.optimizeNodes(),(t=this.finally)==null||t.optimizeNodes(),this}optimizeNames(e,t){var n,r;return super.optimizeNames(e,t),(n=this.catch)==null||n.optimizeNames(e,t),(r=this.finally)==null||r.optimizeNames(e,t),this}get names(){let e=super.names;return this.catch&&D(e,this.catch.names),this.finally&&D(e,this.finally.names),e}},T=class extends m{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};T.kind=`catch`;var E=class extends m{render(e){return`finally`+super.render(e)}};E.kind=`finally`,e.CodeGen=class{constructor(e,t={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...t,_n:t.lines?`
1569
+ `}var C8=`/docs/schema.graphql`,Yzt=()=>JSON.stringify({query:Azt()}),Xzt=e=>{if(!e)throw Error(`The endpoint returned an empty response.`);let t;try{t=JSON.parse(e)}catch{throw Error(`The endpoint did not return a valid JSON response.`)}if(t.errors?.length)throw Error(`The introspection query returned errors: ${t.errors.map(e=>e.message).join(`; `)}`);if(!t.data?.__schema)throw Error(`The endpoint did not return an introspection result. Make sure introspection is enabled.`);try{return`${Mzt(jzt(t.data))}\n`}catch(e){throw Error(`Could not build a schema from the introspection result: ${e instanceof Error?e.message:String(e)}`)}},Zzt=({endpointUrl:e,rewriteUrl:t,ape:n,onClose:r})=>{let{logEvent:i}=S(),a=Ep(),o=eQ(),s=GR(),[c,l]=(0,H.useState)(t??e),[u,d]=(0,H.useState)([{key:``,value:``}]),[f,p]=(0,H.useState)(!1),[m,h]=(0,H.useState)(),g=(e,t,n)=>{d(r=>r.map((r,i)=>i===e?{...r,[t]:n}:r))},_=()=>d(e=>[...e,{key:``,value:``}]),v=e=>d(t=>t.filter((t,n)=>n!==e)),y=async()=>{h(void 0),p(!0);let l=c===t?`handler`:c===e?`gateway`:`custom`,d={account:n.account.name,project:n.project.name,environment:n.environment.name,endpointMode:l};i(`graphql-schema-introspection-run`,d);let f=`request`,m;try{let e;try{f=`invalid_url`,e=new URL(c)}catch{throw Error(`Enter a valid endpoint URL, including the protocol (e.g. https://).`)}let t={"content-type":`application/json`};for(let{key:e,value:n}of u){let r=e.trim();r.length>0&&(t[r]=n)}f=`request`;let l=await(await s({environmentName:n.environment.name,testRequest:{description:`GraphQL introspection`,pathname:`${e.pathname}${e.search}`,method:`POST`,headers:t,body:Yzt()},overrideUrl:e.origin})).json();if(m=l.status,l.status<200||l.status>=300)throw f=`upstream_status`,Error(`The endpoint responded with ${l.status} ${l.statusText??``}.`.trim());f=`introspection`;let p=Xzt(l.body);f=`save`,await o.mutateAsync({file:{path:C8,content:p},accountName:n.account.name,projectName:n.project.name,environmentName:n.environment.name}),i(`graphql-schema-introspection-success`,{...d,upstreamStatus:m}),a.success(`Schema saved to ${C8}`),r()}catch(e){let t=e instanceof Error?e.message:String(e);i(`graphql-schema-introspection-failed`,{...d,stage:f,upstreamStatus:m,reason:t}),h(t)}finally{p(!1)}};return(0,U.jsx)(ow,{open:!0,onOpenChange:e=>!e&&!f&&r(),children:(0,U.jsxs)(lw,{className:`sm:max-w-2xl`,children:[(0,U.jsxs)(uw,{children:[(0,U.jsx)(fw,{children:`Download GraphQL schema`}),(0,U.jsxs)(pw,{children:[`Run an introspection query against this endpoint. On success the schema is stored in `,(0,U.jsx)(`code`,{children:C8}),`.`]})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,U.jsx)(yT,{htmlFor:`graphql-introspection-endpoint`,children:`Endpoint`}),e&&e!==c&&(0,U.jsx)(X,{variant:`link`,size:`xs`,type:`button`,className:`h-auto p-0`,disabled:f,onClick:()=>l(e),children:`Use gateway URL`})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(gT,{id:`graphql-introspection-endpoint`,value:c,onChange:e=>l(e.target.value),placeholder:`https://example.com/graphql`,disabled:f,"data-op-ignore":!0}),(0,U.jsx)(GI,{textToCopy:c})]})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,U.jsx)(yT,{children:`Headers (optional)`}),(0,U.jsx)(`div`,{className:`flex flex-col gap-2`,children:u.map((e,t)=>(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(gT,{placeholder:`Header name`,value:e.key,onChange:e=>g(t,`key`,e.target.value),"data-op-ignore":!0}),(0,U.jsx)(gT,{placeholder:`Value`,value:e.value,onChange:e=>g(t,`value`,e.target.value),"data-op-ignore":!0}),(0,U.jsx)(X,{variant:`ghost`,size:`icon`,type:`button`,"aria-label":`Remove header`,onClick:()=>v(t),children:(0,U.jsx)(op,{className:`size-4`})})]},t))}),(0,U.jsx)(`div`,{children:(0,U.jsxs)(X,{variant:`outline`,size:`sm`,type:`button`,onClick:_,children:[(0,U.jsx)(Mf,{className:`size-4`}),(0,U.jsx)(`span`,{children:`Add header`})]})})]}),m&&(0,U.jsxs)(Ub,{variant:`destructive`,children:[(0,U.jsx)(vd,{}),(0,U.jsx)(Wb,{children:`Introspection failed`}),(0,U.jsx)(Gb,{className:`break-words`,children:m})]})]}),(0,U.jsxs)(dw,{children:[(0,U.jsx)(cw,{asChild:!0,children:(0,U.jsx)(X,{variant:`outline`,type:`button`,disabled:f,children:`Cancel`})}),(0,U.jsx)(X,{variant:`brand`,type:`button`,onClick:y,disabled:f||c.trim().length===0,children:f?`Running…`:`Run introspection`})]})]})})},Qzt=({path:e,rewriteUrl:t})=>{let n=Op(),r=ao(),{logEvent:i}=S(),[a,o]=(0,H.useState)(!1),s=KR(n.environment),c=s?new URL(e,s).toString():void 0;return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(uJ,{children:[(0,U.jsx)(dJ,{asChild:!0,children:(0,U.jsxs)(X,{variant:`outline`,children:[(0,U.jsx)(C1,{className:`size-4 shrink-0`}),(0,U.jsx)(`span`,{children:`Schema`}),(0,U.jsx)(pd,{className:`size-4 shrink-0`})]})}),(0,U.jsxs)(fJ,{align:`end`,children:[(0,U.jsxs)(mJ,{onSelect:()=>{i(`graphql-schema-open`,{account:n.account.name,project:n.project.name,environment:n.environment.name}),r({pathname:ri(rx.Code,{account:n.account.name,project:n.project.name,environment:encodeURIComponent(n.environment.urlParameter)}),search:`?path=${C8}`})},children:[(0,U.jsx)(Xd,{className:`size-4`}),(0,U.jsx)(`span`,{children:`Open Schema`})]}),(0,U.jsxs)(mJ,{disabled:!c,onSelect:()=>o(!0),children:[(0,U.jsx)(zd,{className:`size-4`}),(0,U.jsx)(`span`,{children:`Download Schema`})]})]})]}),a&&c&&(0,U.jsx)(Zzt,{endpointUrl:c,rewriteUrl:t,ape:n,onClose:()=>o(!1)})]})},$zt=({operationTags:e,onTagsChanged:t})=>{let{isReadOnly:n}=HZ(),r=f1(),[i,a]=(0,H.useState)(``),o=r.openApiData?.tags?.map(e=>e.name)??[],s=n=>{e.includes(n)?t(e.filter(e=>e!==n)):t([...e,n])},c=()=>{let n=i.trim();if(n){if(!o.includes(n))try{r.addTag(n)}catch{}e.includes(n)||t([...e,n]),a(``)}};return(0,U.jsxs)(Vw,{children:[(0,U.jsx)(Hw,{asChild:!0,children:(0,U.jsxs)(x6,{children:[(0,U.jsx)(ep,{size:16}),e.length===1?(0,U.jsx)(`span`,{className:`truncate max-w-[12ch]`,title:e[0],children:e[0]}):`${e.length} Tags`]})}),(0,U.jsxs)(Uw,{className:`w-64 p-0 z-100`,align:`end`,children:[(0,U.jsx)(`div`,{className:`px-3 pt-3 pb-2`,children:(0,U.jsx)(`h4`,{className:`text-sm font-medium`,children:`Operation Tags`})}),o.length>0&&(0,U.jsx)(`div`,{className:`border-t max-h-48 overflow-y-auto`,children:o.map(t=>(0,U.jsxs)(`button`,{type:`button`,disabled:n,className:`w-full flex items-center justify-between px-3 py-1.5 text-sm hover:bg-accent disabled:opacity-50 disabled:cursor-default cursor-pointer`,onClick:()=>s(t),children:[(0,U.jsx)(`span`,{className:`truncate`,children:t}),(0,U.jsx)(fd,{size:14,className:W(`shrink-0`,!e.includes(t)&&`invisible`)})]},t))}),!n&&(0,U.jsx)(`div`,{className:`border-t p-2`,children:(0,U.jsxs)(`form`,{className:`flex gap-1`,onSubmit:e=>{e.preventDefault(),c()},children:[(0,U.jsx)(gT,{value:i,onChange:e=>a(e.target.value),placeholder:`New tag...`,className:`h-7 text-xs`}),(0,U.jsx)(X,{type:`submit`,variant:`outline`,size:`icon-sm`,disabled:!i.trim(),children:(0,U.jsx)(Mf,{size:14})})]})})]})]})},eBt=r(a((e=>{var t=/~/,n=/~[01]/g;function r(e){switch(e){case`~1`:return`/`;case`~0`:return`~`}throw Error(`Invalid tilde escape: `+e)}function i(e){return t.test(e)?e.replace(n,r):e}function a(e){if(typeof e==`string`){if(e=e.split(`/`),e[0]===``)return e;throw Error(`Invalid JSON pointer.`)}else if(Array.isArray(e)){for(let t of e)if(typeof t!=`string`&&typeof t!=`number`)throw Error(`Invalid JSON pointer. Must be of type string or number.`);return e}throw Error(`Invalid JSON pointer.`)}function o(e,t){if(typeof e!=`object`)throw Error(`Invalid input object.`);t=a(t);var n=t.length;if(n===1)return e;for(var r=1;r<n;){if(e=e[i(t[r++])],n===r)return e;if(typeof e!=`object`||!e)return}}e.get=o}))());function w8(e,t){try{return e.startsWith(`#`)?eBt.get(t,e.replace(`#`,``)):eBt.get(t,e)}catch(e){console.error(`Error resolving schema reference. Reference may be invalid or referencing an external document.`,e);return}}var tBt=(e,t)=>{let n=e;return!n||`$ref`in n&&(n=w8(n.$ref,t),!n)?``:n.example?n.example:n.examples&&n.examples.length>0?n.examples[0]:n.default?n.default:``},nBt=(e,t)=>{if(e.examples&&Object.keys(e.examples).length>0){let n=Object.values(e.examples)[0];if(`$ref`in n){let e=w8(n.$ref,t);if(!e)return``;n=e}return n.value}if(e.example)return e.example;let n=e.schema;return tBt(n,t)},rBt=(e,t)=>{let n=e.requestBody;if(!n)return``;if(`$ref`in n){let e=w8(n.$ref,t);if(!e)return``;n=e}let{content:r}=n;if(!(`application/json`in r))return``;let i=r[`application/json`];if(i.examples&&Object.keys(i.examples).length>0){let e=Object.values(i.examples)[0];if(`$ref`in e){let n=w8(e.$ref,t);if(!n)return``;e=n}return e.value}let a=i.schema;return tBt(a,t)},iBt=JSON.stringify({query:`{ __schema { queryType { name } } }`},null,2),aBt=new WR,oBt=e=>e.additionalOperationContext.method.split(`,`).map(e=>e.toUpperCase()),T8=e=>{let{oasFilePath:t,method:n,path:r}=e.additionalOperationContext;return`${t}::${e.operationId??`${n} ${r}`}`},sBt=({ape:e,envUrl:t,operation:n,openApiDocument:r,showRebuildWarning:i,onClose:a,defaultEndpointsPanelOpen:o=!1,documentsByPath:s,endpointsLoading:c})=>{let l=(t,n)=>{let r=oBt(t)[0],i=t[zX]===!0,a=WX(t),o=rBt(t,n),s=aBt.getTest(e.account.name,e.project.name,e.environment.name,t.operationId),c=t.parameters?.filter(e=>!(`$ref`in e)&&e.in===`header`).reduce((e,t)=>({...e,[t.name]:nBt(t,n)}),{})??{},l=typeof o==`string`?o:JSON.stringify(o),u=a?{"content-type":`application/json`,accept:`application/json, text/event-stream`,...c}:i?{"content-type":`application/json`,...c}:c,d=l||(a?jR:i?iBt:l);return s?.test&&s.test.method===r?s.test:{description:t.summary??t.description??``,pathname:t.additionalOperationContext.path,method:r,headers:u,body:d}},[u,d]=(0,H.useState)(n),[f,p]=(0,H.useState)(()=>l(n,r)),[m,h]=(0,H.useState)(o),g=Pp(e=>e.setTestResponse),_=Rp(),v=s??_,y=(0,H.useMemo)(()=>({...v,[n.additionalOperationContext.oasFilePath]:r}),[v,n.additionalOperationContext.oasFilePath,r]),b=(0,H.useMemo)(()=>Object.entries(y).flatMap(([e,t])=>d1(e,t)),[y]),x=(0,H.useMemo)(()=>b.map(e=>({id:T8(e),method:e.additionalOperationContext.method,path:e.additionalOperationContext.path,summary:e.summary,file:e.additionalOperationContext.oasFilePath})),[b]);return(0,H.useEffect)(()=>{g(void 0)},[]),(0,U.jsx)(`div`,{className:`flex h-[650px] max-h-[70vh] flex-col`,children:(0,U.jsx)(Drt,{ape:e,apiTest:f,showRebuildWarning:i,allowedMethods:oBt(u),url:`${t}${u.additionalOperationContext.path}`,shouldAllowLocalSaving:!!u.operationId,operationId:u.operationId,path:u.additionalOperationContext.path,onRequestChange:e=>{p(e)},onClose:a,endpoints:x,selectedEndpointId:T8(u),onSelectEndpoint:e=>{if(e===T8(u))return;let t=b.find(t=>T8(t)===e);if(!t)return;let n=y[t.additionalOperationContext.oasFilePath]??r;d(t),p(l(t,n)),g(void 0)},isEndpointPanelOpen:m,onToggleEndpointPanel:()=>h(e=>!e),endpointsLoading:c},T8(u))})},cBt=({envUrl:e,ape:t,operation:n,openApiDocument:r,showRebuildWarning:i,entries:a,onClose:o,defaultEndpointsPanelOpen:s})=>(0,U.jsx)(OY.Provider,{value:{entries:a},children:(0,U.jsx)(`div`,{className:`w-full text-muted-foreground`,children:(0,U.jsx)(sBt,{openApiDocument:r,ape:t,envUrl:e,showRebuildWarning:i,operation:n,onClose:o,defaultEndpointsPanelOpen:s})})}),lBt=({open:e,onOpenChange:t,onProceed:n})=>{let{saveAndDeploy:r,isPending:i}=aft();return(0,U.jsx)(ow,{open:e,onOpenChange:t,children:(0,U.jsxs)(lw,{className:`sm:max-w-md`,children:[(0,U.jsxs)(uw,{children:[(0,U.jsx)(fw,{children:`Unsaved changes`}),(0,U.jsx)(pw,{children:`Your unsaved changes will not be reflected when you test this route until you save and deploy them. Save them now, or continue testing the currently deployed version.`})]}),(0,U.jsxs)(dw,{children:[(0,U.jsx)(X,{variant:`ghost`,onClick:n,disabled:i,children:`Continue without saving`}),(0,U.jsx)(X,{variant:`default`,onClick:async()=>{try{await r()}catch{return}n()},disabled:i,children:(0,U.jsx)(HI,{loading:i,children:`Save changes`})})]})]})})},uBt=(0,H.lazy)(()=>vn(()=>import(`./GraphiQLConsole-PIko1Gzn.js`),__vite__mapDeps([9,1,2,8,10,11,12]))),dBt=({path:e,method:t,summary:n,operationData:r,hasFileChanged:i,isGraphql:a})=>{let{logEvent:o}=S(),s=Op(),c=f1().getOpenApiDataEnforced(),{entries:l}=(0,H.useContext)(OY),u=KR(s.environment),[d,f]=(0,H.useState)(null),p=u?new URL(e,u).toString():void 0,m=jee({mutationKey:Wdt})>0,[h,g]=M$(()=>(o(`test-route-clicked`,{httpPath:e,httpMethod:t.includes(`,`)?t.split(`,`)[0]:t,account:s.account.name,project:s.project.name,environment:s.environment.name,mode:a?`playground`:`default`}),(0,U.jsx)(ow,{open:!0,onOpenChange:e=>!e&&g(),children:(0,U.jsxs)(lw,{showCloseButton:!1,className:`max-w-6xl! w-full gap-0 overflow-hidden p-0`,children:[(0,U.jsx)(fw,{className:`sr-only`,children:`Test route`}),(0,U.jsx)(cBt,{envUrl:u??``,showRebuildWarning:i,ape:s,entries:l,operation:r,openApiDocument:c,onClose:g})]})})),[e,t,n,r,l,a]),[_,v]=M$(()=>(o(`test-route-clicked`,{httpPath:e,httpMethod:`POST`,account:s.account.name,project:s.project.name,environment:s.environment.name,mode:`graphiql`}),(0,U.jsx)(ow,{open:!0,onOpenChange:e=>!e&&v(),children:(0,U.jsxs)(lw,{className:`max-w-6xl! w-full p-0 overflow-hidden`,children:[(0,U.jsx)(fw,{className:`sr-only`,children:`GraphiQL`}),(0,U.jsx)(`div`,{className:`h-[80vh] w-full`,children:(0,U.jsx)(H.Suspense,{fallback:(0,U.jsx)(`div`,{className:`flex h-full items-center justify-center text-muted-foreground`,children:`Loading GraphiQL…`}),children:(0,U.jsx)(uBt,{url:p??``,ape:s})})})]})})),[p,s]),y=e=>{e===`graphiql`?_():h()},b=e=>{if(i){f(e);return}y(e)},x=(0,U.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,U.jsx)(`span`,{children:`Saving`}),(0,U.jsx)(VI,{color:`current`})]}),C=m?`Saving`:`Test Route`;return(0,U.jsxs)(U.Fragment,{children:[a?(0,U.jsxs)(uJ,{children:[(0,U.jsx)(dJ,{asChild:!0,children:(0,U.jsx)(X,{variant:`brand`,disabled:m,"aria-label":C,children:(0,U.jsxs)(HI,{loading:m,className:`flex items-center gap-2`,alternative:x,children:[(0,U.jsx)(mp,{className:`shrink-0 fill-current`}),(0,U.jsx)(`span`,{children:`Test Route`}),(0,U.jsx)(pd,{className:`size-4 shrink-0`})]})})}),(0,U.jsxs)(fJ,{align:`end`,children:[(0,U.jsxs)(mJ,{onSelect:()=>b(`playground`),children:[(0,U.jsx)(mp,{className:`size-4`}),(0,U.jsx)(`span`,{children:`Playground`})]}),(0,U.jsxs)(mJ,{disabled:!p,onSelect:()=>b(`graphiql`),children:[(0,U.jsx)(C1,{className:`size-4`}),(0,U.jsx)(`span`,{children:`GraphiQL`})]})]})]}):(0,U.jsx)(X,{variant:`brand`,disabled:m,"aria-label":C,onClick:()=>b(`playground`),children:(0,U.jsxs)(HI,{loading:m,className:`flex items-center gap-2`,alternative:x,children:[(0,U.jsx)(mp,{className:`shrink-0 fill-current`}),(0,U.jsx)(`span`,{children:`Test Route`})]})}),(0,U.jsx)(H.Suspense,{fallback:null,children:(0,U.jsx)(lBt,{open:d!==null,onOpenChange:e=>{e||f(null)},onProceed:()=>{let e=d;f(null),e&&y(e)}})})]})},fBt=({onRequestHandlerChange:e,isReadOnly:t,routeHandler:n})=>{let r=T1(n),i=(t,i)=>{e({...n,options:{...r.options,[t]:i}})};return(0,U.jsxs)(CA,{className:`p-4 bg-surface-sunken`,children:[(0,U.jsxs)(`div`,{className:`mb-4 flex items-center justify-between gap-2`,children:[(0,U.jsx)(`span`,{className:`text-base font-medium`,children:`MCP Server Options`}),(0,U.jsx)(hT,{showIcon:!0,href:`https://docs.zuplo.com/handlers/mcp-server`,className:`text-sm text-zuplo-pink`,children:`MCP Server Docs`})]}),(0,U.jsxs)(`div`,{className:`grid grid-cols-12 gap-4 col-span-full items-center`,children:[(0,U.jsx)(`div`,{className:`col-span-8`,children:(0,U.jsx)(y6,{isReadOnly:t,label:`Server Name`,onChange:e=>i(`name`,e.target.value),className:`col-span-8`,value:typeof r.options.name==`string`?r.options.name:`My MCP Server`})}),(0,U.jsx)(`div`,{className:`col-span-4`,children:(0,U.jsx)(y6,{isReadOnly:t,label:`Server Version`,className:`col-span-4`,onChange:e=>i(`version`,e.target.value),value:typeof r.options.version==`string`?r.options.version:`v0.0.1`})}),(0,U.jsxs)(`div`,{className:`col-span-12 mt-2`,children:[(0,U.jsx)(yT,{className:`text-sm mb-2 block`,children:`Advanced Options`}),(0,U.jsx)(`div`,{className:W(`flex gap-4`,t&&`opacity-50`),children:(0,U.jsxs)(`label`,{className:`text-sm flex items-center gap-2`,children:[(0,U.jsx)(VY,{"data-test":`mcp-debug-mode`,checked:!!r.options.debugMode,onCheckedChange:e=>{i(`debugMode`,e)},disabled:t}),`Debug Mode`]})})]})]})]})},pBt=({routeHandler:e,operation:t,isReadOnly:n,onRequestHandlerChange:r})=>{let{captureRaw:i}=S(),a=Evt(),o=T1(e),s=typeof o.options.rewritePattern==`string`?o.options.rewritePattern:``,c=kIt(()=>{i(`mcp-gateway-upstream-url-edited`)});return(0,U.jsx)(CA,{className:`p-4`,children:(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,U.jsx)(`div`,{className:`text-xs uppercase tracking-wide text-muted-foreground font-medium`,children:`Upstream MCP server`}),!!(a&&t)&&(0,U.jsxs)(X,{type:`button`,variant:`default`,size:`sm`,disabled:n,onClick:()=>{!t||!a||(i(`mcp-gateway-edit-virtual-mcp-opened`),a(t))},className:`shrink-0`,children:[(0,U.jsx)(Uf,{className:`w-3.5 h-3.5`}),`Edit MCP Server Policy`]})]}),(0,U.jsx)(l3,{isReadOnly:n,url:s,onUrlChange:t=>{c(),r({...e,options:{...o.options,rewritePattern:t}})},placeholder:`https://example.com/mcp`,"aria-label":`Upstream MCP server URL`,"data-test":`mcp-upstream-url-input`})]})})};function mBt(e){if(e)switch(e.type){case`tool`:return{type:e.type,name:e.name??``,description:e.description??``,annotations:e.annotations};case`prompt`:return{type:e.type,name:e.name??``,description:e.description??``};case`resource`:return{type:e.type,name:e.name??``,description:e.description??``,uri:e.uri??``,mimeType:e.mimeType??``};case`graphql`:return{type:e.type,introspectionTool:{name:e.introspectionTool?.name??``,description:e.introspectionTool?.description??``},executeTool:{name:e.executeTool?.name??``,description:e.executeTool?.description??``}}}}function hBt({operationData:e,addRouteMenuProps:t}){return e?(0,U.jsx)(`div`,{className:`w-full h-full min-h-0 overflow-y-auto px-4 pt-2 pb-4`,children:(0,U.jsx)(_Bt,{operationData:e})}):(0,U.jsx)(j_t,{...t})}var gBt=()=>{let e=Lp(),t=Rp(),n=(0,H.useMemo)(()=>e.flatMap(e=>{let n=t[e.path];return n?d1(e.path,n).filter(e=>WX(e)).map(t=>[e,t]):[]}),[e,t]);return{getLinkedMcpServers:(e,t)=>n.filter(([,n])=>{let r=n[VX]?.handler;return HX(r)?r.options?.operations?.some(n=>S1(n.file)===e&&n.id===t):!1})}},_Bt=({operationData:e})=>{let[t]=kY(`path`);if(!t)throw Error(`Open API file path not found in URL`);let n=ift(t),r=Op(),{logEvent:i}=S(),{additionalOperationContext:a,...o}=e,{path:s,method:c}=a,l=f1(),u=Ep(),d=D1(),{isReadOnly:f}=HZ(),[p,m]=(0,H.useState)(),[h,g]=(0,H.useState)();gBt();let _=l.openApiData?.servers?.at(0)?.url,v=o[VX]??m1(_??`https://echo.zuplo.io`),y=o[RX]===!0,b=o.deprecated===!0,x=o[zX]===!0,C=l.openApiFileModel.saveState!==Qs.unmodified,w=v.handler,T=HX(w)&&c.toUpperCase()!==`POST`?`MCP Server handler must use POST method`:void 0,E=e=>{try{l.updateOperation({path:s,method:c,newMethod:e.export===`mcpServerHandler`?`post`:void 0,newOperationObject:{...o,[VX]:{...v,handler:{...e}}}})}catch(e){u.error(e instanceof Error?e.message:`Unknown error`)}},D=e=>{l.updateOperation({path:s,method:c,newOperationObject:{...o,summary:e}})},O=e=>{l.updateOperation({path:s,method:c,newOperationObject:{...o,description:e}})},k=e=>{i(`route-visibility-changed`,{excludeFromDocs:e,fileName:t,account:r.account.name,project:r.project.name,environment:r.environment.name}),l.updateOperation({path:s,method:c,newOperationObject:{...o,[RX]:e}})},A=e=>{i(`route-deprecated-changed`,{deprecated:e,fileName:t,account:r.account.name,project:r.project.name,environment:r.environment.name}),l.updateOperation({path:s,method:c,newOperationObject:{...o,deprecated:e||void 0}})},j=e=>{i(`route-graphql-changed`,{graphql:e,fileName:t,account:r.account.name,project:r.project.name,environment:r.environment.name});let n={...o};e?(n[zX]=!0,h_t(d),n[VX]=m_t(v,!0)):(delete n[zX],o[VX]&&(n[VX]=m_t(v,!1))),l.updateOperation({path:s,method:c,newOperationObject:n})},M=e=>{let{newPath:t}=e,{newMethod:n}=e;h!=null&&t==null&&(t=h);try{l.updateOperation({path:s,newPath:t,method:c,newMethod:n,newOperationObject:o}),m(void 0),g(void 0)}catch(e){e instanceof Error&&t!=null&&(g(t),m(e.message))}},N=e=>{if(e===s){m(void 0),g(void 0);return}M({newPath:e.startsWith(`/`)?e:`/${e}`})},P=e=>{let n=e;n!==c&&(i(`route-method-changed`,{httpMethod:e,fileName:t,account:r.account.name,project:r.project.name,environment:r.environment.name}),M({newMethod:n}))},F=e=>{let n={...v,corsPolicy:e};l.updateOperation({path:s,method:c,newOperationObject:{...o,[VX]:n}}),i(`route-cors-changed`,{newCors:e,fileName:t,account:r.account.name,project:r.project.name,environment:r.environment.name})},I=e=>{let t={...o};e.length>0?t.tags=e:delete t.tags,l.updateOperation({path:s,method:c,newOperationObject:t})},L=n=>{let a={...e.additionalOperationContext.pathZuploConfig,pathMode:n},o=l.getOpenApiDataEnforced().paths;if(!o)throw Error(`Property 'paths' is undefined`);let c=o[s];if(!c)throw Error(`Path Item '${s}' is undefined`);l.updatePathItem(s,{...c,[BX]:a}),i(`route-path-mode-changed`,{pathMode:n,fileName:t,account:r.account.name,project:r.project.name,environment:r.environment.name})},R=()=>{n(Qs.modified)};return(0,U.jsxs)(`div`,{className:`mb-4 flex flex-col gap-6`,children:[(0,U.jsxs)(CA,{className:`bg-neutral-50 dark:bg-transparent`,children:[(0,U.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,U.jsxs)(wA,{children:[(0,U.jsx)(TA,{children:`Request Handling`}),(0,U.jsx)(EA,{})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2 p-6`,children:[x&&(0,U.jsx)(Qzt,{path:s,rewriteUrl:typeof w.options?.rewritePattern==`string`?w.options?.rewritePattern:void 0}),(0,U.jsx)(DRt,{operationData:e}),(0,U.jsx)(dBt,{path:s,method:c,summary:o.summary??``,operationData:e,hasFileChanged:C,isGraphql:x})]})]}),(0,U.jsxs)(DA,{className:`grid grid-cols-1 xl:grid-cols-[max-content_1fr] gap-y-3 xl:gap-y-2 items-center gap-x-6`,children:[(0,U.jsx)(IRt,{isReadOnly:f,initialPath:s,method:c,onChangeMethod:P,pathMode:e.additionalOperationContext.pathZuploConfig?.pathMode,hasError:p!=null,onPathChange:N,onPathModeChange:L,onFieldModified:R,isMcpToolHandler:HX(w)||UX(w)}),p&&(0,U.jsx)(Ub,{"data-test":`path-error`,className:`col-span-full p-2`,variant:`destructive`,children:(0,U.jsx)(Gb,{children:p})}),T&&(0,U.jsx)(Ub,{className:`col-span-full p-2 py-1`,variant:`destructive`,children:(0,U.jsxs)(Gb,{"data-test":`request-handler-error`,className:`flex items-center justify-between`,children:[(0,U.jsx)(`span`,{children:T}),(0,U.jsx)(X,{onClick:()=>P(`post`),size:`xs`,variant:`outline`,className:`border-none`,children:`Switch to POST method`})]})}),(0,U.jsx)(zMt,{isReadOnly:f,initialSummary:o.summary,onSummaryChange:D,onFieldModified:R}),(0,U.jsx)(ORt,{isReadOnly:f,defaultOperationId:e.operationId,openApiManager:l,path:s,method:c,operationData:e})]}),(0,U.jsxs)(OA,{className:`flex flex-wrap gap-2 px-3 py-1.5 bg-card justify-end`,children:[(0,U.jsx)($zt,{operationTags:o.tags??[],onTagsChanged:I}),(0,U.jsx)(sLt,{isReadOnly:f,selectedCorsPolicy:v.corsPolicy,corsPolicies:d.corsPolicyList??[],onSelectionChanged:F}),!HX(v.handler)&&!UX(v.handler)&&(0,U.jsx)(NRt,{operation:e,defaultValues:mBt(v.mcp),onSubmit:e=>{let t={...v,mcp:e};l.updateOperation({path:s,method:c,newOperationObject:{...o,[VX]:t}})}}),(0,U.jsx)(nRt,{isExcludedFromDocs:y,onVisibilityChanged:k}),(0,U.jsx)(LRt,{isGraphql:x,onGraphqlChanged:j,isDeprecated:b,onDeprecatedChanged:A})]})]}),(0,U.jsx)(SIt,{inboundPolicies:v.policies?.inbound??[],outboundPolicies:v.policies?.outbound??[],operation:e,children:(0,U.jsx)(vBt,{isReadOnly:f,operationData:e,handler:v.handler,firstServerUrl:_,onRequestHandlerChange:E})}),(0,U.jsx)(tRt,{initialDescription:o.description??``,onChange:O,path:s,method:c,oasFilePath:t})]})},vBt=({operationData:e,handler:t,firstServerUrl:n,isReadOnly:r,onRequestHandlerChange:i})=>{let a=(e[VX]??m1(n??`https://echo.zuplo.io`)).handler;switch(t.export){case`mcpServerHandler`:return(0,U.jsx)(fBt,{isReadOnly:r,routeHandler:a,onRequestHandlerChange:i});case`McpProxyHandler`:case`McpVirtualServerHandler`:case`mcpVirtualServerHandler`:return(0,U.jsx)(pBt,{routeHandler:a,operation:e,isReadOnly:r,onRequestHandlerChange:i});default:return(0,U.jsx)(rLt,{isReadOnly:r,routeHandler:a,onRequestHandlerChange:i})}},yBt=De()(e=>({updateLinkedMcpServers:void 0,setUpdateLinkedMcpServers:t=>e({updateLinkedMcpServers:t})})),bBt=()=>{let e=j(yBt,e=>e.updateLinkedMcpServers),t=aQ(),n=()=>{yBt.setState({updateLinkedMcpServers:void 0})};return(0,U.jsx)(ow,{open:!!e,onOpenChange:e=>{e||n()},children:(0,U.jsxs)(lw,{children:[(0,U.jsx)(fw,{children:`MCP Server Links`}),(0,U.jsx)(pw,{children:`This operation is linked to MCP servers, if you update the operation id, you need to update the MCP server links as well.`}),(0,U.jsx)(`div`,{className:`flex gap-2 items-center justify-center`,children:e?.linkedMcpServers.map(([,e])=>(0,U.jsx)(rT,{children:e},e))}),(0,U.jsxs)(dw,{children:[(0,U.jsx)(X,{variant:`outline`,onClick:n,children:`Cancel`}),(0,U.jsx)(X,{onClick:()=>{e?.linkedMcpServers.forEach(([n,r])=>{let i=new t_t(n,t),a=i.getOperationById(r);if(!a)return;let o=a[VX];if(!o)return;let s=o.handler;if(HX(s)){if(n.path===e.file){let t=i.getOperationById(e.oldOperationId);if(!t)throw Error(`Operation not found`);i.updateOperation({path:t.additionalOperationContext.path,method:t.additionalOperationContext.method,newOperationObject:H$(t,`operationId`,e.newOperationId)})}i.updateOperation({path:a?.additionalOperationContext.path,method:a.additionalOperationContext.method,newOperationObject:H$(a,`${VX}.handler.options.operations`,s.options?.operations?.map(t=>S1(t.file)===n.path?{...t,id:t.id===e.oldOperationId?e.newOperationId:t.id}:t))})}})},children:`Update`})]})]})})},xBt=`$import(@zuplo/runtime)`,SBt=`${xBt}::urlForwardHandler`,CBt=`${xBt}::urlRewriteHandler`,wBt=(e,t)=>{let n=e.options?.[t],r=typeof n==`string`?n.trim():``;return r.length>0?r:void 0},TBt=e=>{let t=e.trim();if(t.startsWith("${")){let e=t.indexOf(`}`);if(e!==-1)return t.slice(0,e+1)}let n=/^[a-z][a-z0-9+.-]*:\/\/[^/$?#]+/i.exec(t);if(n)return n[0];let r=t.indexOf(`/`);return r===-1?t:t.slice(0,r)},EBt=e=>{if(e){let t=`${e.module}::${e.export}`,n=t===SBt?wBt(e,`baseUrl`):t===CBt?wBt(e,`rewritePattern`):void 0;if(n){let e=TBt(n);return{key:`target:${e}`,label:e,mono:!0,icon:cf,collapsible:!0}}}return{...mvt(e),collapsible:!1}};function DBt(){let e=f1(),{captureRaw:t}=S(),n=Op(),r=nQ();return i=>{e.updateInfo(i),t(`openapi-info-updated`);let{projectTreeNodes:a,filesByPath:o}=Pp.getState(),s=a.map(e=>e.path?o[e.path]:void 0).filter(e=>!!e&&e.saveState===Qs.modified);s.length!==0&&r.mutateAsync({environmentName:n.environment.name,accountName:n.account.name,projectName:n.project.name,files:s}).catch(()=>{})}}var E8=`Document Order`,OBt=[`Document Order`,`Path`,`Summary`],D8=`Untagged`,kBt=[{value:`none`,label:`None`},{value:`path`,label:`Path`},{value:`handler`,label:`Handler type`},{value:`target`,label:`Target`}],ABt=new Set([`handler`,`target`]);function jBt(e){return`${e}-${B().split(`-`).at(0)}`}function O8(e){return new Set(e.getPolicyListEnforced().map(e=>e.name))}function MBt(e){if(!e)return;let t=AMt(e.getPolicyListEnforced());if(t)return t.name;let n=g3(OMt,O8(e));return e.createPolicy(kMt(n)),n}var NBt=e=>(t,n)=>{switch(e){case`Document Order`:return 0;case`Path`:return t.additionalOperationContext.path.localeCompare(n.additionalOperationContext.path);case`Summary`:return!t.summary&&!n.summary?0:!t.summary&&n.summary?1:t.summary&&!n.summary?-1:t.summary?.localeCompare(n.summary??``)??0;default:return 0}},PBt=e=>t=>{if(e.length===0)return!0;let n=t.tags;return!n||n.length===0?e.includes(D8):n.some(t=>e.includes(t))},FBt=({onNavigateToOpenApiFileTab:e})=>{let{logEvent:t,captureRaw:n}=S(),[r,i]=Tnt(`tags`,[]),[a,o]=Gw(`open-api-designer-group-by`,`none`);(0,H.useEffect)(()=>{let e=window.localStorage.getItem(`open-api-designer-show-headers`);e!==null&&(e===`true`&&a===`none`&&o(`path`),window.localStorage.removeItem(`open-api-designer-show-headers`))},[a,o]);let[s,c]=(0,H.useState)(!1),[l,u]=(0,H.useState)(`details`),[d,f]=(0,H.useState)(!1),p=DBt(),m=(0,H.useRef)(null);(0,H.useEffect)(()=>{let e=e=>{if(e.key!==`/`||e.metaKey||e.ctrlKey||e.altKey)return;let t=e.target;t&&(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.tagName===`SELECT`||t.isContentEditable)||(e.preventDefault(),m.current?.focus())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[]);let[h,g]=(0,H.useState)(),[_,v]=(0,H.useState)(),[y,b]=(0,H.useState)(()=>new Set),x=e=>b(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),[C,w]=(0,H.useState)(()=>new Set),T=e=>w(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),{isReadOnly:E}=HZ(),[D,O]=kY(`operation`),[k,A]=Gw(`default-sort-routes`,E8),[j,M]=kY(`sort`,k);(0,H.useEffect)(()=>{j&&A(j)},[A,j]),(0,H.useEffectEvent)(()=>{if(D)try{document.querySelector(`#op-${D}`)?.scrollIntoView()}catch{}});let[N,P]=(0,H.useState)(void 0),F=f1(),I=D1(),L=JI(),R=oQ(hvt),z=sQ(),ee=()=>{if(R)return _vt(R.content??``)?`ok`:`manual`;let e=gvt,t={path:hvt,content:e,type:Zs.File,saveState:Qs.new};if(L){let n=L.Uri.file(t.path);L.editor.getModel(n)||L.editor.createModel(e,void 0,n)}return z(t),z({...t,saveState:Qs.modified}),`ok`},{results:te,setSearchTerm:V,searchTerm:ne}=Y_t(F.operationArray?.filter(PBt(r)).sort(NBt(j))??[],{keys:[e=>e.additionalOperationContext.path,e=>e.summary??``,e=>e.operationId,e=>e.additionalOperationContext.method]});(0,H.useEffect)(()=>{let e=ne?.trim()??``;if(e.length===0)return;let n=setTimeout(()=>{t(`route-search-used`,{view:`routes`,query:e,queryLength:e.length})},600);return()=>clearTimeout(n)},[ne,t]);let re=(()=>{let e=new Map;for(let t of te){let n,r,i,o,s;if(a===`handler`||a===`target`){let e=t[VX]?.handler,c=a===`target`?EBt(e):{...mvt(e),collapsible:!1};({key:n,label:r,mono:i,collapsible:o,icon:s}=c)}else n=t.additionalOperationContext.path,r=n,i=!0,o=!1,s=void 0;let c=e.get(n);c?c.operations.push(t):e.set(n,{key:n,label:r,mono:i,icon:s,collapsible:o,operations:[t]})}return[...e.values()]})(),[ie,ae]=(0,H.useState)(),[oe,se]=(0,H.useState)(),[ce,le]=(0,H.useState)(!1),ue=(0,H.useMemo)(()=>{if(!_)return[];let e=(F.operationArray?.find(e=>e.additionalOperationContext.path===_.path&&e.additionalOperationContext.method===_.method))?.[VX]?.policies?.inbound??[];if(e.length===0)return[];let t=new Set;for(let e of I.policyList??[]){if(e.policyType!==`composite-inbound`&&e.policyType!==`composite-outbound`)continue;let n=e.handler.options?.policies;if(n)for(let e of n)t.add(e)}let n=I.policiesUsageInfo??[];return e.map(e=>n.find(t=>t.name===e)).filter(e=>{if(!e||e.operations.length!==1)return!1;let n=e.operations[0];return!(n.additionalOperationContext.path!==_.path||n.additionalOperationContext.method!==_.method||t.has(e.name))})},[_,F.operationArray,I.policyList,I.policiesUsageInfo]),[de,fe]=(0,H.useState)(()=>new Set);(0,H.useEffect)(()=>{fe(_?new Set(ue.map(e=>e.name)):new Set)},[_]);let pe=(e,t)=>{fe(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r})},me=()=>{if(_==null){le(!1);return}try{for(let e of de)try{I.deletePolicy(e),t(`policy-deleted`,{policy:e})}catch{}F.deleteOperation(_.path,_.method),t(`route-deleted`,_)}catch(e){e instanceof Error&&(t(`route-deletion-failed`,_),P(e.message),he())}v(void 0),le(!1)},[he,ge]=M$(()=>{let t=()=>{P(void 0),ge()};return(0,U.jsx)(vQ,{alertType:`ERROR`,bodyText:N??``,onPrimaryButtonClick:e,onSecondaryButtonClick:t,primaryButtonText:`Edit file directly`,secondaryButtonText:`Cancel`,hideModal:t,title:`Error`})},[N]),[_e,ve]=M$(()=>(0,U.jsx)(vQ,{alertType:`CAUTION`,bodyText:`Cannot reorder in this view — view by Document Order to reorganize the order of operations.`,onPrimaryButtonClick:()=>{M(E8),ve()},onSecondaryButtonClick:ve,primaryButtonText:`Switch to Document Order`,secondaryButtonText:`Cancel`,hideModal:ve,title:`Cannot reorder`})),[ye,be]=M$(()=>(0,U.jsx)(yvt,{open:!0,onOpenChange:e=>{e||be()}})),xe=(e,t)=>{if(j!==E8){_e();return}F.movePathInDocument(e,t)};if(!F.openApiData)throw Error(`Invalid State - no OpenApiData`);let Se=F.openApiData.info,Ce=F.openApiData.tags?.map(e=>({value:e.name,label:e.name}));Ce?.push({value:D8,label:D8});let we=()=>{let e=y1.OpenAPIV3.HttpMethods.GET,n=F.openApiData?.servers?.at(0)?.url,r=f_t(n??`https://echo.zuplo.io`),i=`/path-${((F.operationArray?.filter(t=>t.additionalOperationContext.path.startsWith(`/path-`)&&t.additionalOperationContext.method===e)?.map(e=>parseInt(e.additionalOperationContext.path.replace(`/path-`,``),10))?.filter(e=>!Number.isNaN(e))?.sort((e,t)=>t-e))?.at(0)??0)+1}`;try{let t=F.addOperation(i,e,r);t&&O(t)}catch(n){n instanceof Error&&(t(`route-add-failed`,{httpPath:i,httpMethod:e}),P(n.message),he())}t(`route-added`)},Te=(e,n,r)=>{let i=F.openApiData?.servers?.at(0)?.url,a=f_t(i??`https://echo.zuplo.io`),o=r?.[VX],s=a[VX];o&&s&&(o.handler&&(s.handler=JSON.parse(JSON.stringify(o.handler))),o.policies&&(s.policies=JSON.parse(JSON.stringify(o.policies))));try{let t=F.addOperation(e,n,a);t&&O(t)}catch(r){r instanceof Error&&(t(`route-add-failed`,{httpPath:e,httpMethod:n}),P(r.message),he())}t(`route-added`)},Ee=()=>{let e=y1.OpenAPIV3.HttpMethods.POST,n=jBt(`mcp`),r=F.addOperation(`/mcp`,e,{summary:`MCP Server`,description:`Default MCP Server`,[VX]:{corsPolicy:`none`,handler:{export:`mcpServerHandler`,module:`$import(@zuplo/runtime)`,options:{operations:[]}},policies:{inbound:[]}},operationId:n},{avoidConflict:!0});r&&O(r),t(`route-added`)},De=()=>{let e=y1.OpenAPIV3.HttpMethods.POST,n=g_t(`https://rickandmortyapi.com/graphql`);try{h_t(I);let t=F.addOperation(`/graphql`,e,n,{avoidConflict:!0});t&&O(t)}catch(n){n instanceof Error&&(t(`route-add-failed`,{httpPath:`/graphql`,httpMethod:e}),P(n.message),he())}t(`route-added`)},Oe=()=>{let e=y1.OpenAPIV3.HttpMethods.GET,n=__t();try{let t=F.addOperation(`/websocket`,e,n,{avoidConflict:!0});t&&O(t)}catch(n){n instanceof Error&&(t(`route-add-failed`,{httpPath:`/websocket`,httpMethod:e}),P(n.message),he())}t(`route-added`)},[ke,Ae]=(0,H.useState)(!1),[je,Me]=(0,H.useState)(),[Ne,Pe]=(0,H.useState)(0),Fe=(0,H.useMemo)(()=>{let e=new Set(Object.keys(F.openApiData?.paths??{}));return je&&e.delete(je.path),e},[F.openApiData?.paths,je]),Ie=async e=>{let n;try{n=ee()}catch(e){if(e instanceof Error){P(e.message),he();return}throw e}let r;try{r=MMt({result:e,policyList:I.getPolicyListEnforced(),existingOperationIds:new Set(F.operationArray?.map(e=>e.operationId)??[])});for(let e of r.policiesToCreate)I.createPolicy(e)}catch(e){if(e instanceof Error){P(e.message),he();return}throw e}try{let e=F.addOperation(r.operationPath,r.method,r.operation,{avoidConflict:!0});e&&O(e)}catch(e){e instanceof Error&&(P(e.message),he())}t(`route-added`),t(`mcp-gateway-create-virtual-mcp-submitted`,NMt(e)),n===`manual`&&ye()},Le=()=>{Pe(e=>e+1),Ae(!0)},Re=e=>{let t=yMt({operationPath:e.additionalOperationContext.path,operation:e,policyList:I?.getPolicyListEnforced()??[]});t&&(Pe(e=>e+1),Me({initialResult:t,path:e.additionalOperationContext.path,method:e.additionalOperationContext.method,operationId:e.operationId}))},ze=async e=>{let t=je;if(!t)return;let{initialResult:r,path:i,method:a}=t,o=F.operationArray?.find(e=>e.additionalOperationContext.path===i&&e.additionalOperationContext.method===a);if(!o){Me(void 0);return}let s;try{s=ee()}catch(e){if(e instanceof Error){P(e.message),he();return}throw e}let c=EMt(e.step1.name),l=n0(e.step1.mcpUrl),u=l?.protectedResourceMetadataUrl??jMt(e.step1.mcpUrl),d=o[VX]?.policies?.inbound??[],f=I?.getPolicyListEnforced()??[],p=new Map(f.map(e=>[e.name,e])),m=d.map(e=>p.get(e)).filter(e=>e!=null),h=m.find(e=>e.policyType===q4),g=m.find(e=>e.policyType===J4),_=m.find(e=>e.policyType===`remove-headers-inbound`&&Y4(e.handler?.options)),v=m.find(e=>e.policyType.startsWith(`upstream-`)),y;if(e.step1.authMode===`user-oauth`){let t={id:c,displayName:e.step1.name,summary:`${e.step1.name} remote MCP server, federated via the gateway.`,...u?{protectedResourceMetadataUrl:u}:{},authMode:`user-oauth`,scopes:l?.scopes??[],clientRegistration:e.step1.clientRegistration};if(h&&I)try{I.updatePolicy(h.name,{...h,handler:{...h.handler,options:t}}),y=h.name}catch(e){if(e instanceof Error){P(e.message),he();return}}else if(I){y=g3(`mcp-upstream-${c}`,O8(I));try{I.createPolicy({name:y,policyType:q4,handler:{module:`$import(@zuplo/runtime/mcp-gateway)`,export:`McpTokenExchangeInboundPolicy`,options:t}})}catch(e){if(e instanceof Error){P(e.message),he();return}}}}let b;if(e.step1.authMode===`upstream-policy`&&I){let{policyType:t,policyName:n,handler:r}=e.step1;try{v&&v.policyType===t?I.updatePolicy(v.name,{...v,name:n,handler:r}):I.createPolicy({name:n,policyType:t,handler:r}),b=n}catch(e){if(e instanceof Error){P(e.message),he();return}}}let x;if(e.step2.catalogMode===`curated`){let t=V4(e.step2);if(g&&I)try{I.updatePolicy(g.name,{...g,handler:{...g.handler,options:t}}),x=g.name}catch(e){if(e instanceof Error){P(e.message),he();return}}else if(I){x=g3(`mcp-filter-${c}`,O8(I));try{I.createPolicy({name:x,policyType:J4,handler:{module:`$import(@zuplo/runtime/mcp-gateway)`,export:`McpCapabilityFilterInboundPolicy`,options:t}})}catch(e){if(e instanceof Error){P(e.message),he();return}}}}let S;if(e.step3.authPolicyChoice===`existing`)S=e.step3.existingPolicyName;else if((e.step3.authPolicyChoice===`new`||e.step3.authPolicyChoice===`new-other`)&&(S=e.step3.newPolicyName,I))try{I.createPolicy({name:S,policyType:e.step3.policyType,handler:e.step3.handler})}catch(e){if(e instanceof Error){P(e.message),he();return}}let C;if(e.step1.authMode===`none`&&e.step1.noAuthBehavior===`strip`)try{C=_?.name??MBt(I)}catch(e){if(e instanceof Error){P(e.message),he();return}}let w=[S,x,y,b,C].filter(e=>!!e),T=o[VX],E=T?.handler;try{F.updateOperation({path:i,method:a,newOperationObject:{...o,summary:e.step1.name,description:`MCP Virtual Server fronted by the gateway (${e.step1.mcpUrl})`,[VX]:{...T??{},handler:{...E??{export:`McpProxyHandler`,module:`$import(@zuplo/runtime/mcp-gateway)`},options:{...E?.options??{},rewritePattern:e.step1.mcpUrl}},policies:{...T?.policies??{},inbound:w}}}})}catch(e){if(e instanceof Error){P(e.message),he();return}}let D;try{D=new URL(e.step1.mcpUrl).hostname}catch{D=void 0}n(`mcp-gateway-edit-virtual-mcp-submitted`,{upstreamHost:D,upstreamAuthMode:e.step1.authMode,previousUpstreamAuthMode:r.step1.authMode,inboundAuthChoice:e.step3.authPolicyChoice,previousInboundAuthChoice:r.step3.authPolicyChoice}),Me(void 0),s===`manual`&&ye()},Be=(0,H.useMemo)(()=>D?te.find(e=>e.operationId===D)||te.find(e=>h?.path===e.additionalOperationContext.path&&h?.method===e.additionalOperationContext.method):void 0,[te,D,h]);(0,H.useEffect)(()=>{Be&&!h&&g({path:Be.additionalOperationContext.path,method:Be.additionalOperationContext.method})},[Be,h]);let Ve=(e,n,r)=>{let i=(e,t)=>{let n=e.replace(/-duplicate(-\d+)?$/,``),r=`${n}-duplicate`,i=2;for(;t(r);)r=`${n}-duplicate-${i}`,i++;return r},a=F.operationArray??[],o=i(e,e=>a.some(t=>t.additionalOperationContext.path===e&&t.additionalOperationContext.method===n)),s=i(r.operationId??`op-${B().slice(0,4)}`,e=>a.some(t=>t.operationId===e)),c=JSON.parse(JSON.stringify(r));c.operationId=s;try{let e=F.addOperation(o,n,c);e&&O(e)}catch(e){e instanceof Error&&(t(`route-add-failed`,{httpPath:o,httpMethod:n}),P(e.message),he())}t(`route-added`,{httpPath:o,httpMethod:n,duplicate:!0})},He=()=>{f(!0),u(`tags`),c(!0)},Ue=je!==void 0,We=(0,U.jsx)(bMt,{isOpen:ke||Ue,existingPaths:Fe,mode:Ue?`edit`:`create`,initialResult:je?.initialResult,onClose:()=>{Ae(!1),Me(void 0)},onFinish:Ue?ze:Ie},`mcp-wizard-${Ne}`),Ge={onAddRest:we,onAddGraphql:De,onAddWebSocket:Oe,onAddMcpVirtual:Le,onAddMcpServer:Ee,onAddTag:He};return F.operationArray?.length===0&&(!ne||ne.trim().length===0)?(0,U.jsxs)(U.Fragment,{children:[We,(0,U.jsx)(j_t,{...Ge})]}):(0,U.jsxs)(`div`,{className:`ms-2 grid grid-cols-3 h-full grow`,children:[(0,U.jsx)(k$,{open:ce,onOpenChange:e=>{le(e),e||v(void 0)},onClickDelete:me,title:`Delete`,deleteButtonText:`Confirm`,children:ue.length===0?`Are you sure you want to delete this operation?`:(0,U.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,U.jsxs)(`div`,{children:[`The following`,` `,ue.length===1?`policy is`:`policies are`,` `,`used only by this route. Would you like to delete`,` `,ue.length===1?`it`:`them`,` `,`too?`]}),(0,U.jsx)(`ul`,{className:`flex flex-col divide-y divide-border max-h-[40vh] overflow-y-auto rounded-md border bg-surface-sunken`,children:ue.map(e=>{let t=`delete-policy-${e.name}`;return(0,U.jsxs)(`li`,{className:`flex items-start gap-2 px-3 py-2`,children:[(0,U.jsx)(VY,{id:t,checked:de.has(e.name),onCheckedChange:t=>pe(e.name,t===!0),className:`mt-0.5`}),(0,U.jsxs)(`label`,{htmlFor:t,className:`flex flex-col gap-0.5 text-left cursor-pointer min-w-0`,children:[(0,U.jsx)(`span`,{className:`font-medium text-foreground truncate`,children:e.name}),(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground truncate`,children:e.policyType})]})]},e.name)})})]})}),(0,U.jsx)(bBt,{}),We,Se&&(0,U.jsx)(LMt,{open:s,onOpenChange:c,info:Se,onSave:p,defaultTab:l,tagsAutoCreate:d,onTagsAutoCreateConsumed:()=>f(!1)}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-2 justify-start h-full pt-2 min-h-0`,children:[(0,U.jsxs)(`div`,{className:`flex justify-between gap-x-2`,children:[(0,U.jsx)(`div`,{className:`flex gap-1`,children:(0,U.jsxs)(uJ,{children:[(0,U.jsx)(dJ,{className:`flex group select-none`,asChild:!0,children:(0,U.jsxs)(X,{variant:`outline`,size:`sm`,title:`Filter and sort routes`,children:[(0,U.jsx)(rf,{size:16}),`Filter`]})}),(0,U.jsxs)(fJ,{className:`min-w-[220px]`,align:`start`,children:[(0,U.jsx)(gJ,{children:`Sort by`}),(0,U.jsx)(pJ,{children:OBt.map(e=>(0,U.jsxs)(mJ,{onClick:()=>M(e),className:`justify-between`,children:[e,(0,U.jsx)(fd,{className:W(`mr-2`,e!==j&&`invisible`),size:16})]},e))}),(0,U.jsx)(_J,{}),(0,U.jsx)(gJ,{children:`Filter by tag`}),(0,U.jsx)(pJ,{className:`max-h-60 overflow-y-auto`,children:Ce?.map(e=>(0,U.jsxs)(mJ,{onClick:t=>{t.stopPropagation(),t.preventDefault(),r.includes(e.value)?i(r.filter(t=>t!==e.value)):i([...r,e.value])},className:`justify-between`,children:[e.label,(0,U.jsx)(fd,{className:W(`mr-2`,!r.includes(e.value)&&`invisible`),size:18})]},e.label))}),(0,U.jsx)(_J,{}),(0,U.jsx)(gJ,{children:(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(gee,{size:16}),`Group by`]})}),(0,U.jsx)(pJ,{children:kBt.map(e=>(0,U.jsxs)(mJ,{onClick:t=>{t.stopPropagation(),t.preventDefault(),o(e.value)},className:`justify-between`,children:[e.label,(0,U.jsx)(fd,{className:W(`mr-2`,a!==e.value&&`invisible`),size:16})]},e.value))})]})]})}),E?null:(0,U.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,U.jsx)(X,{variant:`outline`,size:`sm`,onClick:()=>{f(!1),u(`details`),c(!0)},"aria-label":`API Settings`,title:`API Settings`,children:(0,U.jsx)(Af,{size:16})}),(0,U.jsxs)(uJ,{children:[(0,U.jsx)(dJ,{asChild:!0,children:(0,U.jsxs)(X,{variant:`outline`,size:`sm`,"data-test":`add-route-btn`,className:`relative gap-0.5!`,children:[(0,U.jsx)(`div`,{className:`absolute w-1.5 h-1.5 rounded-full -top-0.5 -right-[3px] bg-zuplo-700`}),(0,U.jsx)(Mf,{"aria-hidden":`true`,className:`size-3.5`}),`Add`]})}),(0,U.jsx)(fJ,{children:(0,U.jsx)(A_t,{...Ge})})]})]})]}),(0,U.jsx)(IY,{onClearValue:()=>V(``),value:ne,showClearButton:!!ne&&ne.length>0,children:(0,U.jsx)(gT,{ref:m,value:ne,onChange:e=>V(e.target.value),placeholder:`Search Routes`,className:`px-8`})}),r.length>0&&(0,U.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:r.map(e=>(0,U.jsxs)(`div`,{className:`group flex items-center gap-1 max-w-full pl-1.5 pr-0.5 py-0.5 rounded-full border border-border bg-card text-xs text-foreground`,children:[(0,U.jsx)(ep,{size:11,className:`shrink-0 text-muted-foreground`}),(0,U.jsx)(`span`,{className:`truncate`,title:e,children:e}),(0,U.jsx)(`button`,{type:`button`,"aria-label":`Remove ${e} filter`,onClick:t=>{t.stopPropagation(),i(r.filter(t=>t!==e))},className:`shrink-0 size-4 rounded-full flex items-center justify-center text-muted-foreground hover:bg-surface-emphasis hover:text-neutral-900 dark:hover:text-foreground`,children:(0,U.jsx)(pp,{size:11})})]},e))}),(0,U.jsx)(`div`,{className:`overflow-y-auto space-y-1`,children:re.map((e,t,n)=>{let r=!e.collapsible||C.has(e.key),i=e.operations.length,o=e.icon,s=(0,U.jsx)(`span`,{className:`ml-auto shrink-0 rounded-full bg-background px-1.5 py-0.5 text-xs font-normal tabular-nums text-muted-foreground`,children:i});return(0,U.jsxs)(`div`,{children:[e.collapsible?(0,U.jsxs)(`button`,{type:`button`,onClick:()=>T(e.key),"aria-expanded":r,className:`mt-3 mb-1 flex w-full items-center gap-1.5 rounded-md bg-muted/60 px-2 py-2 text-left text-sm font-semibold text-foreground transition-colors first:mt-1 hover:bg-muted`,title:r?`Collapse ${e.label}`:`Expand ${e.label} (${i} ${i===1?`route`:`routes`})`,children:[r?(0,U.jsx)(pd,{size:15,className:`shrink-0 text-muted-foreground`}):(0,U.jsx)(md,{size:15,className:`shrink-0 text-muted-foreground`}),o&&(0,U.jsx)(o,{size:16,className:`shrink-0 text-muted-foreground`}),(0,U.jsx)(`span`,{className:`truncate font-mono`,title:e.label,children:e.label}),s]}):a!==`none`&&(0,U.jsxs)(`div`,{className:`mt-3 mb-1 flex items-center gap-1.5 rounded-md bg-muted/60 px-2 py-2 text-sm font-semibold text-foreground first:mt-1`,children:[o&&(0,U.jsx)(o,{size:16,className:`shrink-0 text-muted-foreground`}),(0,U.jsx)(`span`,{className:W(`truncate`,e.mono&&`font-mono`),title:e.label,children:e.label}),s]}),r&&e.operations.map(({additionalOperationContext:e,...r})=>{let i=Be?.operationId===r.operationId,o=r[VX]?.handler,s=HX(o),c=UX(o),l=s?o.options?.operations?.length??0:0,u=l>0,d=y.has(r.operationId);return(0,U.jsxs)(H.Fragment,{children:[(0,U.jsx)(nvt,{path:i&&ie?ie:e.path,type:c?`mcp-virtual`:s?`mcp`:`route`,method:e.method,summary:i&&oe?oe:r.summary,operationId:r.operationId,operation:r,isSelected:i,onOperationSelected:t=>{ae(``),se(``),g({path:e.path,method:e.method}),O(t)},onDelete:(e,t,n)=>{v({path:e,method:t,operationId:n}),le(!0)},onAddRoute:Te,onDuplicate:()=>Ve(e.path,e.method,r),onMoveUp:ABt.has(a)?void 0:()=>xe(e.path,`up`),onMoveDown:ABt.has(a)?void 0:()=>xe(e.path,`down`),isFirstPath:j===E8&&t===0,isLastPath:j===E8&&t===n.length-1,isToolsExpanded:u?d:void 0,onToggleTools:u?()=>x(r.operationId):void 0,toolsCount:u?l:void 0}),o&&u&&d&&(0,U.jsx)(wvt,{handler:o,operation:{...r,additionalOperationContext:e}})]},r.operationId)})]},e.key)})})]}),(0,U.jsx)(`div`,{className:`col-span-2 flex flex-col h-full overflow-y-auto`,children:(0,U.jsx)(_3.Provider,{value:{setPath:ae,setSummary:se},children:(0,U.jsx)(Tvt.Provider,{value:Re,children:(0,U.jsx)(hBt,{operationData:Be,addRouteMenuProps:Ge})})})})]})},IBt={create:{shell:`bg-emerald-500/8 shadow-emerald-950/5`,icon:`bg-emerald-500/12 text-emerald-700 dark:text-emerald-300`,count:`bg-emerald-500/12 text-emerald-700 dark:text-emerald-300`},update:{shell:`bg-brand/8 shadow-brand/5`,icon:`bg-brand/12 text-brand`,count:`bg-brand/12 text-brand`},keep:{shell:`bg-background shadow-black/5 dark:shadow-white/5`,icon:`bg-muted text-muted-foreground`,count:`bg-muted text-muted-foreground`}},k8=({icon:e,operations:t,title:n,tone:r})=>{let i=IBt[r];return(0,U.jsxs)(`section`,{className:`rounded-2xl p-4 shadow-sm ${i.shell}`,"aria-label":`${n} operations`,children:[(0,U.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2 font-semibold text-foreground`,children:[(0,U.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded-xl ${i.icon}`,children:e}),n,` operations`]}),(0,U.jsx)(`div`,{className:`rounded-full px-2.5 py-1 text-xs font-medium tabular-nums ${i.count}`,children:t.size})]}),(0,U.jsx)(`div`,{className:`space-y-1.5`,children:Array.from(t).map(e=>{let t=e.split(`>`),n=t[0],r=t.slice(1,t.length).join(`>`);return(0,U.jsxs)(`div`,{className:`flex min-h-10 items-center gap-3 rounded-xl bg-background/80 px-3 py-2 text-sm shadow-xs`,children:[(0,U.jsx)(LY,{className:`w-14`,method:n}),(0,U.jsx)(`span`,{className:`break-all text-foreground/90`,children:r})]},e)})})]})},LBt=({openApiFileModel:e,onOpenApiFileSynced:t,setIsOpen:n})=>{let[r,i]=(0,H.useState)(),a=Ep(),o=e=>{i(e)},s=async()=>{if(!r)throw Error(`No file selected`);let i=e.content?JSON.parse(e.content):null;t(i?xlt(i,r.content):r.content),n(!1),a.success(`OpenAPI file merged successfully`,{icon:(0,U.jsx)(Wfe,{className:`h-4 w-4`})})};if(r){let t=Elt(JSON.parse(e.content??`{}`),r.content);return(0,U.jsx)(g1,{isOpen:!0,setIsOpen:n,title:`Review OpenAPI import`,className:`sm:max-w-4xl max-h-[88vh] overflow-y-auto`,icon:(0,U.jsx)(gb,{className:`shrink-0 h-6 w-6 text-brand`}),iconStyle:`bg-zuplo-pink/10`,buttons:[{onButtonClick:()=>{n(!1)},variant:`outline`,buttonContent:`Cancel`,id:`Close merge open-api modal`,testID:`merge-cancel-btn`},{onButtonClick:s,variant:`brand`,buttonContent:`Import changes`,id:`Complete open-api merge`,testID:`complete-merge-btn`}],bodyComponent:(0,U.jsxs)(`div`,{className:`mt-6 text-left text-sm`,children:[(0,U.jsx)(`div`,{className:`overflow-hidden rounded-3xl bg-gradient-to-br from-brand/12 via-background to-background p-px shadow-lg shadow-brand/5`,children:(0,U.jsxs)(`div`,{className:`rounded-[calc(1.5rem-1px)] bg-background p-5`,children:[(0,U.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-[1fr_auto_1fr] md:items-center`,children:[(0,U.jsx)(`div`,{className:`rounded-2xl bg-surface-sunken p-4 shadow-[inset_0_1px_rgba(255,255,255,0.05)]`,children:(0,U.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,U.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-xl bg-brand/10 text-brand`,children:(0,U.jsx)(hpe,{className:`h-5 w-5`})}),(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-wide text-muted-foreground`,children:`Import file`}),(0,U.jsx)(`div`,{className:`mt-0.5 truncate font-medium text-foreground`,children:r.name})]})]})}),(0,U.jsx)(`div`,{className:`hidden h-10 w-10 items-center justify-center rounded-full bg-brand text-brand-foreground shadow-sm shadow-brand/24 md:flex`,children:(0,U.jsx)(gb,{className:`h-5 w-5`})}),(0,U.jsx)(`div`,{className:`rounded-2xl bg-surface-sunken p-4 shadow-[inset_0_1px_rgba(255,255,255,0.05)]`,children:(0,U.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,U.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-xl bg-emerald-500/10 text-emerald-600 dark:text-emerald-400`,children:(0,U.jsx)(Sb,{className:`h-5 w-5`})}),(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-wide text-muted-foreground`,children:`Current API`}),(0,U.jsx)(`div`,{className:`mt-0.5 truncate font-medium text-foreground`,children:e.path})]})]})})]}),(0,U.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-2 text-muted-foreground`,children:[(0,U.jsx)(`span`,{children:`Operations are matched by`}),(0,U.jsx)(rT,{variant:`outline`,children:`Path + method`}),(0,U.jsx)(`span`,{children:`so existing Zuplo extensions and policies stay in place.`})]})]})}),(0,U.jsxs)(`div`,{className:`mt-6 flex items-end justify-between gap-3`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`div`,{className:`text-base font-semibold text-foreground`,children:`Import summary`}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Review what will change before applying this file.`})]}),(0,U.jsxs)(`div`,{className:`rounded-full bg-surface-sunken px-3 py-1 text-xs font-medium text-muted-foreground tabular-nums`,children:[t.created.size+t.merged.size+t.retained.size,` `,`operations`]})]}),(0,U.jsxs)(`div`,{className:`mt-3 grid max-h-96 gap-3 overflow-y-auto rounded-3xl bg-surface-sunken p-3 shadow-[inset_0_1px_rgba(255,255,255,0.04)]`,children:[t.created.size>0?(0,U.jsx)(k8,{icon:(0,U.jsx)(Fpe,{className:`h-4 w-4`}),title:`Create`,tone:`create`,operations:t.created}):null,t.merged.size>0?(0,U.jsx)(k8,{icon:(0,U.jsx)(Mpe,{className:`h-4 w-4`}),title:`Update`,tone:`update`,operations:t.merged}):null,t.retained.size>0?(0,U.jsx)(k8,{icon:(0,U.jsx)(Gfe,{className:`h-4 w-4`}),title:`Keep`,tone:`keep`,operations:t.retained}):null]})]})})}return(0,U.jsx)(w_t,{title:`Import OpenAPI`,onValidFileSelected:o,setIsOpen:n})},RBt=()=>{let e=bt(),t=Oe({mutationFn:t=>e.fetch(ae.users.updatePreferences(t))}),{data:n}=ax(je.user.preferences());return{preferences:n,updatePreferences:t.mutate,updatePreferencesMutation:t}},zBt=!1;function A8(){let e=At(),{preferences:t,updatePreferencesMutation:n}=RBt();return{isFileTreeOpen:t.fileTreeOpen??zBt,setIsFileTreeOpen:r=>{let i=[je.user.preferences().url,!0],a=e.getQueryData(i),o={...a??t,fileTreeOpen:r};e.setQueryData(i,o),n.mutate(o,{onError:()=>{a&&e.setQueryData(i,a),e.invalidateQueries({queryKey:i})}})}}}function BBt(){let e=iQ(),{logEvent:t}=S(),[n,r]=kY(`v`,`designer`),{isFileTreeOpen:i}=A8(),a=e?.path.split(`/`).pop()??`JSON`,o=aQ(),s=E_t(),[c,l]=M$(()=>{if(!e)throw Error(`File model not found`);return t(`merge-open-api`),(0,U.jsx)(LBt,{openApiFileModel:e,onOpenApiFileSynced:n=>{let r={...e,content:JSON.stringify(n,null,2)};o(r,!0),t(`merge-open-api-complete`),s(r.path)},setIsOpen:l})},[e,s]);return(0,U.jsx)(ovt,{children:(0,U.jsx)(r_t,{children:(0,U.jsxs)(hj,{defaultValue:`designer`,value:n,onValueChange:e=>r(e),className:`flex flex-col h-full w-full max-h-screen min-w-[850px]`,children:[i&&(0,U.jsxs)(gj,{className:`rounded-none border-b w-full justify-start`,children:[(0,U.jsx)(_j,{value:`designer`,children:`Route Designer`}),(0,U.jsx)(_j,{value:`raw`,children:a??`Raw`}),(0,U.jsxs)(X,{variant:`outline`,size:`sm`,onClick:c,className:`ml-4`,children:[(0,U.jsx)(Upe,{className:`w-4 h-4`}),` Import`]})]}),(0,U.jsx)(vj,{value:`designer`,className:`grow h-full overflow-y-auto`,children:(0,U.jsx)(d_t,{onNavigateToOpenApiFileTab:()=>r(`raw`),children:(0,U.jsx)(FBt,{onNavigateToOpenApiFileTab:()=>r(`raw`)})})}),(0,U.jsx)(vj,{value:`raw`,className:`grow h-full overflow-y-auto`,forceMount:!0,children:(0,U.jsx)(_Q,{})})]})})})}function VBt({title:e,description:t,folder:n,icon:r,emptyText:i,newLabel:a,onCreate:o}){let s=Pp(e=>e.projectTreeNodes),[c,l]=Vs(),{isReadOnly:u}=HZ(),d=n.endsWith(`/`)?n:`${n}/`,f=(0,H.useMemo)(()=>s.filter(e=>e.type===Zs.File&&e.path.startsWith(d)).sort((e,t)=>e.path.localeCompare(t.path)),[s,d]),p=e=>{let t=new URLSearchParams(c);t.set(`path`,e),t.delete(`v`),t.delete(`line`),l(t)};return(0,U.jsx)(`div`,{className:`h-full w-full overflow-y-auto`,children:(0,U.jsxs)(`div`,{className:`mx-auto max-w-3xl px-6 py-8`,children:[(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`h1`,{className:`text-xl font-bold text-neutral-900 dark:text-neutral-100`,children:e}),(0,U.jsx)(`p`,{className:`text-sm text-neutral-600 dark:text-neutral-400`,children:t})]}),!u&&(0,U.jsxs)(X,{variant:`secondary`,size:`sm`,onClick:o,className:`shrink-0`,children:[(0,U.jsx)(Mf,{className:`size-4`}),a]})]}),(0,U.jsx)(`div`,{className:`mt-6 flex flex-col gap-1.5`,children:f.length===0?(0,U.jsx)(`div`,{className:`rounded-lg border border-dashed p-8 text-center text-sm text-neutral-500 dark:text-neutral-400`,children:i}):f.map(e=>{let t=e.path.slice(d.length);return(0,U.jsxs)(`button`,{type:`button`,onClick:()=>p(e.path),className:W(`group flex w-full items-center gap-3 rounded-lg border px-3 py-2.5 text-left transition-colors`,`bg-surface hover:border-brand/40 hover:bg-brand/5`,`ring-offset-background focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`),children:[(0,U.jsx)(r,{className:`size-4 shrink-0 text-neutral-500 group-hover:text-brand`}),(0,U.jsx)(`span`,{className:`truncate text-sm font-medium text-neutral-800 dark:text-neutral-200`,children:t})]},e.path)})})]})})}function HBt(){let e=Pp(e=>e.setPendingNewFile),{setIsFileTreeOpen:t}=A8();return(0,U.jsx)(VBt,{title:`Custom Modules`,description:`TypeScript modules in your project's modules/ folder — request handlers, policies, and other custom code.`,folder:`/modules`,icon:Ef,emptyText:`No custom modules yet. Create one to add request handlers or custom logic.`,newLabel:`New Module`,onCreate:()=>{t(!0),e({strategyFolder:`/modules`,template:`Request Handler`})}})}function UBt(){let e=Pp(e=>e.setPendingNewFile),{setIsFileTreeOpen:t}=A8();return(0,U.jsx)(VBt,{title:`Schemas`,description:`JSON schemas in your project's schemas/ folder, used to validate requests and responses.`,folder:`/schemas`,icon:qd,emptyText:`No schemas yet. Create one to validate request or response bodies.`,newLabel:`New Schema`,onCreate:()=>{t(!0),e({strategyFolder:`/schemas`,template:`Schema`})}})}var WBt=()=>{let[e,t]=(0,H.useState)(),{isReadOnly:n}=HZ(),r=D1(),i=r.policiesUsageInfo,{logEvent:a}=S(),o=Op([`account`,`project`,`environment`]),[s,c]=M$(()=>e?(0,U.jsx)(yIt,{isOpen:!0,setIsOpen:c,stackType:e,shouldHideExistingPolicies:!0,policyManager:r}):null,[e]),l=e=>{t(e),a(`create-policy-clicked`,{account:o.account.name,project:o.project.name,environment:o.environment.name,type:e}),s()},u=(r.policyList??[]).flatMap(e=>i?.find(t=>t.name===e.name)??[]);return(0,U.jsx)(`div`,{className:`h-full w-full overflow-y-auto`,children:(0,U.jsxs)(`div`,{className:`mx-auto max-w-3xl px-6 py-8`,children:[(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`h1`,{className:`text-xl font-bold text-neutral-900 dark:text-neutral-100`,children:`Policies`}),(0,U.jsx)(`p`,{className:`text-sm text-neutral-600 dark:text-neutral-400`,children:`Reusable policies from your project's config/policies.json — apply them to routes to inspect and control requests and responses.`})]}),!n&&(0,U.jsxs)(uJ,{modal:!1,children:[(0,U.jsx)(dJ,{asChild:!0,children:(0,U.jsxs)(X,{variant:`secondary`,size:`sm`,className:`shrink-0`,children:[(0,U.jsx)(Mf,{className:`size-4`}),`New Policy`]})}),(0,U.jsxs)(fJ,{align:`end`,children:[(0,U.jsxs)(mJ,{onClick:()=>l(`inbound`),children:[(0,U.jsx)(Ku,{className:`mr-2 size-4`}),`Inbound Policy`]}),(0,U.jsxs)(mJ,{onClick:()=>l(`outbound`),children:[(0,U.jsx)(Zu,{className:`mr-2 size-4`}),`Outbound Policy`]})]})]})]}),(0,U.jsx)(`div`,{className:`mt-6 flex flex-col gap-1.5`,children:u.length===0?(0,U.jsxs)(`div`,{className:`rounded-lg border border-dashed p-8 text-center text-sm text-neutral-500 dark:text-neutral-400`,children:[`No policies yet. Create an inbound or outbound policy to inspect and control requests and responses, or`,` `,(0,U.jsx)(hT,{href:`https://zuplo.com/docs/overview/policies`,children:`read the docs`}),`.`]}):u.map(e=>(0,U.jsx)(fIt,{policy:e},e.name))})]})})},GBt=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.DeploymentLogState=void 0;var t;(function(e){e.ERROR=`ERROR`,e.IN_PROGRESS=`IN_PROGRESS`,e.SUCCESS=`SUCCESS`})(t||(e.DeploymentLogState=t={}))})),KBt=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.SourceControlProvider=e.PlanType=e.EnvironmentType=e.EnvironmentTarget=e.DeploymentState=void 0;var t;(function(e){e[e.IS_STARTING=0]=`IS_STARTING`,e[e.STARTED=1]=`STARTED`,e[e.STOPPED=2]=`STOPPED`,e[e.ERRORED=3]=`ERRORED`})(t||(e.DeploymentState=t={}));var n;(function(e){e.CLOUDFLARE=`CLOUDFLARE`,e.KNATIVE=`KNATIVE`})(n||(e.EnvironmentTarget=n={}));var r;(function(e){e.PRODUCTION=`PRODUCTION`,e.PREVIEW=`PREVIEW`,e.WORKING_COPY=`WORKING_COPY`})(r||(e.EnvironmentType=r={}));var i;(function(e){e.FREE_V1=`FREE_V1`,e.BUILDER_V1=`BUILDER_V1`,e.BUSINESS_V1=`BUSINESS_V1`,e.CUSTOM=`CUSTOM`,e.EMPLOYEE=`EMPLOYEE`,e.CUSTOM_TRIAL_V1=`CUSTOM_TRIAL_V1`})(i||(e.PlanType=i={}));var a;(function(e){e.GITHUB=`GITHUB`,e.GITLAB=`GITLAB`,e.BITBUCKET=`BITBUCKET`})(a||(e.SourceControlProvider=a={}))})),qBt=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0})})),JBt=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.INTERNAL_ROUTE_VENDOR_TAG=e.ZUPLO_OPEN_API_ROUTE_KEY=e.ZUPLO_OPEN_API_PATH_KEY=e.ZUPLO_OPEN_API_VENDOR_PREFIX=void 0,e.ZUPLO_OPEN_API_VENDOR_PREFIX=`x-zuplo`,e.ZUPLO_OPEN_API_PATH_KEY=`${e.ZUPLO_OPEN_API_VENDOR_PREFIX}-path`,e.ZUPLO_OPEN_API_ROUTE_KEY=`${e.ZUPLO_OPEN_API_VENDOR_PREFIX}-route`,e.INTERNAL_ROUTE_VENDOR_TAG=`x-internal`})),YBt=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.processJsonErrorObject=void 0;var t={'must match pattern "^[0-9a-z-]+$"':`Value must be alphanumeric or dash '-' only`,'must match pattern "^\\$import\\([^ )]*?\\)$"':`Value must be of form '$import(./path/to/module)`},n={'must match pattern "^[0-9a-z-]+$"':`Make sure the value uses only lowercase letters, numbers and dashes ('-').`,'must match pattern "^\\$import\\([^ )]*?\\)$"':`Value must be of form '$import(./path/to/module)`},r=e=>e.replace(`/`,``).replaceAll(`/`,` → `).replaceAll(`~1`,`/`),i={paths:`paths`};function a(e,a){let o=e.message,s=e.details?.property??``,c=e.details?.index??0,l=e.details?.field,u=e.details?.fieldValue,d=e.keyword,f=e.params,p=e.propertyName,m=r(e.instancePath),h=t[o]??o,g,_;if(d===`unevaluatedProperties`)g=`Unrecognized property '${f.unevaluatedProperty}'${l?` detected in '${l}'`:``} within '${a}'. Property location: ${m}.`;else if(d===`additionalProperties`)g=`Unrecognized property '${f.additionalProperty}'${l?` detected in '${l}'`:``} within '${a}'. Property location: ${m}.`;else if(d===`enum`)g=`Unrecognized value${u?` '${u}'`:``} for '${l}' detected in '${a}'. Value ${h}. Property location: ${m}.`;else if(d===`pattern`){let e=f.pattern;g=p?`Property name '${p}' does not match pattern ${e} in '${a}'. Property location: ${m}.`:`Invalid value '${u}' for field '${l}' in '${a}'. Value does not match pattern ${e}. Property location: ${m}.`}else d===`propertyNames`?g=`Invalid property name '${f.propertyName}' for property '${s}' detected in '${a}'. Property location: ${m}.`:d===`required`?g=`Missing required property '${f.missingProperty}' in '${a}'. Property location: ${m}.`:l&&s?(g=`Property ${i[s]} entry at position ${c+1} in '${a}' has invalid ${l} with value '${e.details?.fieldValue}' (${h})`,_={field:l,fieldValue:e.details?.fieldValue??``,property:s,instancePath:m,suggestion:n[o]??``}):g=s?`The ${i[s]} entry at position ${c+1} in '${a}' is invalid (${h})`:`The '${a}' configuration is invalid (${h})`;return{property:s,entry:{message:g,index:c,field:l,details:_}}}e.processJsonErrorObject=a})),XBt=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.startsWithReservedKeyword=void 0;var t=[`settings`,`user`,`manage`,`profile`,`login`,`logout`,`admin`,`system`,`account`,`accounts`,`home`,`dashboard`];function n(e){return t.filter(t=>e.startsWith(t)).length>0}e.startsWithReservedKeyword=n})),ZBt=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.isValidProjectName=e.MAX_PRETTY_BRANCH_LENGTH=e.MAX_HASH_LENGTH=void 0;var t=XBt();e.MAX_HASH_LENGTH=7,e.MAX_PRETTY_BRANCH_LENGTH=10;var n=40;function r(e){let r={isValid:!0};return e.length===0?(r.isValid=!1,r.errorMessage=`Project name cannot be empty`,r):(0,t.startsWithReservedKeyword)(e)?(r.isValid=!1,r.errorMessage=`Project name can not start with a reserved keyword`,r):/[\s]/.test(e)?(r.isValid=!1,r.errorMessage=`Project name can't contain spaces`,r):/[A-Z]/.test(e)?(r.isValid=!1,r.errorMessage=`Project name should be in lowercase`,r):/^[^a-z]/.test(e)?(r.isValid=!1,r.errorMessage=`Project name should start with a letter`,r):/[^a-z0-9]$/.test(e)?(r.isValid=!1,r.errorMessage=`Project name should end with a letter or number`,r):/[^a-z0-9\\-]/.test(e)?(r.isValid=!1,r.errorMessage=`Project name only can contain letter, numbers and dashes`,r):(e.length>n&&(r.isValid=!1,r.errorMessage=`Project name cannot exceed ${n} characters because it needs to be part of the URL subdomain. Your chosen name is ${e.length-n} over.`),r)}e.isValidProjectName=r})),QBt=i({$defs:()=>I8,$id:()=>M8,$schema:()=>j8,additionalProperties:()=>!1,default:()=>$Bt,description:()=>``,properties:()=>L8,required:()=>F8,title:()=>N8,type:()=>P8}),j8,M8,N8,P8,F8,I8,L8,$Bt,eVt=n((()=>{j8=`https://json-schema.org/draft/2020-12/schema`,M8=`http://schemas.zuplo.com/route.json`,N8=`Route Config File`,P8=`object`,F8=[`routes`,`versions`],I8={corsPolicy:{type:`string`,pattern:`^[0-9a-z-]+$`},httpMethod:{type:`string`,enum:[`GET`,`HEAD`,`POST`,`PUT`,`DELETE`,`CONNECT`,`OPTIONS`,`TRACE`,`PATCH`]},handlerDefinition:{type:`object`,properties:{module:{type:`string`,pattern:`^\\$import\\([^ )]*?\\)$`},export:{type:`string`},options:{type:`object`,additionalProperties:!0}},additionalProperties:!1,required:[`module`,`export`]},schema:{$comment:`https://spec.openapis.org/oas/v3.1.0#schema-object`,type:[`object`,`boolean`]},parameterBaseObject:{$comment:`https://spec.openapis.org/oas/v3.1.0#schema-object`,type:`object`,properties:{description:{type:`string`},required:{default:!1,type:`boolean`},deprecated:{default:!1,type:`boolean`},schema:{$ref:`#/$defs/schema`}},required:[`schema`]},parameterDefinition:{$comment:`https://spec.openapis.org/oas/v3.1.0#parameter-object`,allOf:[{$ref:`#/$defs/parameterBaseObject`}],type:`object`,properties:{name:{type:`string`},in:{type:`string`,enum:[`query`,`header`,`path`,`cookie`]}},required:[`name`,`in`,`schema`],if:{type:`object`,properties:{in:{const:`query`}},required:[`in`]},then:{type:`object`,properties:{allowEmptyValue:{default:!1,type:`boolean`}}}},"media-type":{$comment:`https://spec.openapis.org/oas/v3.1.0#media-type-object`,type:`object`,properties:{schema:{$ref:`#/$defs/schema`}},unevaluatedProperties:!1},content:{$comment:`https://spec.openapis.org/oas/v3.1.0#fixed-fields-10`,type:`object`,additionalProperties:{$ref:`#/$defs/media-type`},propertyNames:{enum:[`application/json`,`application/problem+json`]}},header:{$comment:`https://spec.openapis.org/oas/v3.1.0#header-object`,allOf:[{$ref:`#/$defs/parameterBaseObject`}],type:`object`,required:[`schema`]},response:{$comment:`https://spec.openapis.org/oas/v3.1.0#response-object`,type:`object`,properties:{description:{type:`string`},headers:{type:`object`,additionalProperties:{$ref:`#/$defs/header`}},content:{$ref:`#/$defs/content`}},required:[`description`],unevaluatedProperties:!1},responsesDefinition:{$comment:`https://spec.openapis.org/oas/v3.1.0#responses-object`,type:`object`,properties:{default:{$ref:`#/$defs/response`}},patternProperties:{"^[1-5](?:[0-9]{2}|XX)$":{$ref:`#/$defs/response`}},minProperties:1,unevaluatedProperties:!1},tag:{$comment:`https://spec.openapis.org/oas/v3.1.0#tag-object`,type:`object`,properties:{name:{type:`string`},description:{type:`string`}},required:[`name`],unevaluatedProperties:!1},info:{type:`object`,required:[`title`,`version`],properties:{title:{type:`string`},summary:{type:`string`},description:{type:`string`},termsOfService:{type:`string`,format:`uri`},version:{type:`string`}}},versionData:{type:`object`,required:[`name`,`pathPrefix`],additionalProperties:!1,properties:{name:{type:`string`,pattern:`^[0-9a-z-]+$`},pathPrefix:{type:`string`,pattern:`(^$|^/[^\\s]*$)`},info:{$ref:`#/$defs/info`},openApiFile:{description:`The project relative path to the OpenAPI spec.`,type:`string`},tags:{type:`array`,items:{$ref:`#/$defs/tag`}},excludeFromOpenApi:{type:`boolean`,description:`If false, OpenAPI documentation will not be generated for this version. If openApiFile is set this setting is ignored.`},enforceOpenApi:{type:`boolean`,description:`If true, schema validation found in the OpenAPI spec will be enforced on requests/responses.`}}},routeConfiguration:{type:`object`,required:[`path`,`methods`,`handler`,`version`],additionalProperties:!1,properties:{operationId:{type:`string`},path:{type:`string`,pattern:`^/[^\\s]*$`},methods:{type:`array`,items:{$ref:`#/$defs/httpMethod`}},label:{type:`string`,description:`An internal user-friendly identifier of the route.`},enforceOpenApi:{type:`boolean`,description:`If true, schema validation found in the OpenAPI spec will be enforced on requests/responses.`},key:{type:`string`,deprecated:!0},handler:{$ref:`#/$defs/handlerDefinition`},corsPolicy:{$ref:`#/$defs/corsPolicy`},custom:{},version:{type:`string`,pattern:`^[0-9a-z-]+$`},policies:{type:`object`,additionalProperties:!1,properties:{inbound:{type:`array`,items:{type:`string`,pattern:`^[0-9a-z-]+$`}},outbound:{type:`array`,items:{type:`string`,pattern:`^[0-9a-z-]+$`}}}},summary:{type:`string`},description:{type:`string`},parameters:{type:`array`,items:{$ref:`#/$defs/parameterDefinition`}},excludeFromOpenApi:{type:`boolean`},responses:{$ref:`#/$defs/responsesDefinition`},tags:{type:`array`,items:{type:`string`}}}},policyConfiguration:{type:`object`,required:[`name`,`policyType`,`handler`],additionalProperties:!1,properties:{name:{type:`string`,pattern:`^[0-9a-z-]+$`},policyType:{type:`string`},handler:{$ref:`#/$defs/handlerDefinition`},options:{type:`object`,additionalProperties:!0}}},corsPolicyConfiguration:{type:`object`,required:[`name`,`allowedOrigins`],additionalProperties:!1,properties:{name:{type:`string`,pattern:`^[0-9a-z-]+$`},allowCredentials:{type:`boolean`},maxAge:{type:`number`},allowedOrigins:{oneOf:[{type:`array`,items:{type:`string`}},{type:`string`}]},allowedMethods:{oneOf:[{type:`array`,items:{$ref:`#/$defs/httpMethod`}},{type:`string`}]},allowedHeaders:{oneOf:[{type:`array`,items:{type:`string`}},{type:`string`}]},exposeHeaders:{oneOf:[{type:`array`,items:{type:`string`}},{type:`string`}]}}}},L8={$schema:{type:`string`},info:{$ref:`#/$defs/info`,deprecated:!0},versions:{type:`array`,minItems:1,items:{$ref:`#/$defs/versionData`}},routes:{type:`array`,minItems:0,items:{$ref:`#/$defs/routeConfiguration`}},policies:{type:`array`,items:{$ref:`#/$defs/policyConfiguration`}},corsPolicies:{type:`array`,items:{$ref:`#/$defs/corsPolicyConfiguration`}},requestErrorHandler:{$ref:`#/$defs/handlerDefinition`}},$Bt={$schema:j8,$id:M8,title:N8,description:``,type:P8,additionalProperties:!1,required:F8,$defs:I8,properties:L8}})),tVt=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.formatNames=e.fastFormats=e.fullFormats=void 0;function t(e,t){return{validate:e,compare:t}}e.fullFormats={date:t(a,o),time:t(c,l),"date-time":t(d,f),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:h,"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,url:/^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,ipv6:/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,regex:w,uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:_,int32:{type:`number`,validate:b},int64:{type:`number`,validate:x},float:{type:`number`,validate:S},double:{type:`number`,validate:S},password:!0,binary:!0},e.fastFormats={...e.fullFormats,date:t(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,o),time:t(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,l),"date-time":t(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,f),uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i},e.formatNames=Object.keys(e.fullFormats);function n(e){return e%4==0&&(e%100!=0||e%400==0)}var r=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,i=[0,31,28,31,30,31,30,31,31,30,31,30,31];function a(e){let t=r.exec(e);if(!t)return!1;let a=+t[1],o=+t[2],s=+t[3];return o>=1&&o<=12&&s>=1&&s<=(o===2&&n(a)?29:i[o])}function o(e,t){if(e&&t)return e>t?1:e<t?-1:0}var s=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i;function c(e,t){let n=s.exec(e);if(!n)return!1;let r=+n[1],i=+n[2],a=+n[3],o=n[5];return(r<=23&&i<=59&&a<=59||r===23&&i===59&&a===60)&&(!t||o!==``)}function l(e,t){if(!(e&&t))return;let n=s.exec(e),r=s.exec(t);if(n&&r)return e=n[1]+n[2]+n[3]+(n[4]||``),t=r[1]+r[2]+r[3]+(r[4]||``),e>t?1:e<t?-1:0}var u=/t|\s/i;function d(e){let t=e.split(u);return t.length===2&&a(t[0])&&c(t[1],!0)}function f(e,t){if(!(e&&t))return;let[n,r]=e.split(u),[i,a]=t.split(u),s=o(n,i);if(s!==void 0)return s||l(r,a)}var p=/\/|:/,m=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function h(e){return p.test(e)&&m.test(e)}var g=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function _(e){return g.lastIndex=0,g.test(e)}var v=-(2**31),y=2**31-1;function b(e){return Number.isInteger(e)&&e<=y&&e>=v}function x(e){return Number.isInteger(e)}function S(){return!0}var C=/[^\\]\\Z/;function w(e){if(C.test(e))return!1;try{return new RegExp(e),!0}catch{return!1}}})),R8=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.regexpCode=e.getEsmExportName=e.getProperty=e.safeStringify=e.stringify=e.strConcat=e.addCodeArg=e.str=e._=e.nil=e._Code=e.Name=e.IDENTIFIER=e._CodeOrName=void 0;var t=class{};e._CodeOrName=t,e.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var n=class extends t{constructor(t){if(super(),!e.IDENTIFIER.test(t))throw Error(`CodeGen: name must be a valid identifier`);this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};e.Name=n;var r=class extends t{constructor(e){super(),this._items=typeof e==`string`?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===``||e===`""`}get str(){return this._str??=this._items.reduce((e,t)=>`${e}${t}`,``)}get names(){return this._names??=this._items.reduce((e,t)=>(t instanceof n&&(e[t.str]=(e[t.str]||0)+1),e),{})}};e._Code=r,e.nil=new r(``);function i(e,...t){let n=[e[0]],i=0;for(;i<t.length;)s(n,t[i]),n.push(e[++i]);return new r(n)}e._=i;var a=new r(`+`);function o(e,...t){let n=[p(e[0])],i=0;for(;i<t.length;)n.push(a),s(n,t[i]),n.push(a,p(e[++i]));return c(n),new r(n)}e.str=o;function s(e,t){t instanceof r?e.push(...t._items):t instanceof n?e.push(t):e.push(d(t))}e.addCodeArg=s;function c(e){let t=1;for(;t<e.length-1;){if(e[t]===a){let n=l(e[t-1],e[t+1]);if(n!==void 0){e.splice(t-1,3,n);continue}e[t++]=`+`}t++}}function l(e,t){if(t===`""`)return e;if(e===`""`)return t;if(typeof e==`string`)return t instanceof n||e[e.length-1]!==`"`?void 0:typeof t==`string`?t[0]===`"`?e.slice(0,-1)+t.slice(1):void 0:`${e.slice(0,-1)}${t}"`;if(typeof t==`string`&&t[0]===`"`&&!(e instanceof n))return`"${e}${t.slice(1)}`}function u(e,t){return t.emptyStr()?e:e.emptyStr()?t:o`${e}${t}`}e.strConcat=u;function d(e){return typeof e==`number`||typeof e==`boolean`||e===null?e:p(Array.isArray(e)?e.join(`,`):e)}function f(e){return new r(p(e))}e.stringify=f;function p(e){return JSON.stringify(e).replace(/\u2028/g,`\\u2028`).replace(/\u2029/g,`\\u2029`)}e.safeStringify=p;function m(t){return typeof t==`string`&&e.IDENTIFIER.test(t)?new r(`.${t}`):i`[${t}]`}e.getProperty=m;function h(t){if(typeof t==`string`&&e.IDENTIFIER.test(t))return new r(`${t}`);throw Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}e.getEsmExportName=h;function g(e){return new r(e.toString())}e.regexpCode=g})),nVt=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;var t=R8(),n=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},r;(function(e){e[e.Started=0]=`Started`,e[e.Completed=1]=`Completed`})(r=e.UsedValueState||={}),e.varKinds={const:new t.Name(`const`),let:new t.Name(`let`),var:new t.Name(`var`)};var i=class{constructor({prefixes:e,parent:t}={}){this._names={},this._prefixes=e,this._parent=t}toName(e){return e instanceof t.Name?e:this.name(e)}name(e){return new t.Name(this._newName(e))}_newName(e){let t=this._names[e]||this._nameGroup(e);return`${e}${t.index++}`}_nameGroup(e){if((this._parent?._prefixes)?.has(e)||this._prefixes&&!this._prefixes.has(e))throw Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};e.Scope=i;var a=class extends t.Name{constructor(e,t){super(t),this.prefix=e}setValue(e,{property:n,itemIndex:r}){this.value=e,this.scopePath=(0,t._)`.${new t.Name(n)}[${r}]`}};e.ValueScopeName=a;var o=(0,t._)`\n`;e.ValueScope=class extends i{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?o:t.nil}}get(){return this._scope}name(e){return new a(e,this._newName(e))}value(e,t){if(t.ref===void 0)throw Error(`CodeGen: ref must be passed in value`);let n=this.toName(e),{prefix:r}=n,i=t.key??t.ref,a=this._values[r];if(a){let e=a.get(i);if(e)return e}else a=this._values[r]=new Map;a.set(i,n);let o=this._scope[r]||(this._scope[r]=[]),s=o.length;return o[s]=t.ref,n.setValue(t,{property:r,itemIndex:s}),n}getValue(e,t){let n=this._values[e];if(n)return n.get(t)}scopeRefs(e,n=this._values){return this._reduceValues(n,n=>{if(n.scopePath===void 0)throw Error(`CodeGen: name "${n}" has no value`);return(0,t._)`${e}${n.scopePath}`})}scopeCode(e=this._values,t,n){return this._reduceValues(e,e=>{if(e.value===void 0)throw Error(`CodeGen: name "${e}" has no value`);return e.value.code},t,n)}_reduceValues(i,a,o={},s){let c=t.nil;for(let l in i){let u=i[l];if(!u)continue;let d=o[l]=o[l]||new Map;u.forEach(i=>{if(d.has(i))return;d.set(i,r.Started);let o=a(i);if(o){let n=this.opts.es5?e.varKinds.var:e.varKinds.const;c=(0,t._)`${c}${n} ${i} = ${o};${this.opts._n}`}else if(o=s?.(i))c=(0,t._)`${c}${o}${this.opts._n}`;else throw new n(i);d.set(i,r.Completed)})}return c}}})),z8=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.or=e.and=e.not=e.CodeGen=e.operators=e.varKinds=e.ValueScopeName=e.ValueScope=e.Scope=e.Name=e.regexpCode=e.stringify=e.getProperty=e.nil=e.strConcat=e.str=e._=void 0;var t=R8(),n=nVt(),r=R8();Object.defineProperty(e,`_`,{enumerable:!0,get:function(){return r._}}),Object.defineProperty(e,`str`,{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(e,`strConcat`,{enumerable:!0,get:function(){return r.strConcat}}),Object.defineProperty(e,`nil`,{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(e,`getProperty`,{enumerable:!0,get:function(){return r.getProperty}}),Object.defineProperty(e,`stringify`,{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(e,`regexpCode`,{enumerable:!0,get:function(){return r.regexpCode}}),Object.defineProperty(e,`Name`,{enumerable:!0,get:function(){return r.Name}});var i=nVt();Object.defineProperty(e,`Scope`,{enumerable:!0,get:function(){return i.Scope}}),Object.defineProperty(e,`ValueScope`,{enumerable:!0,get:function(){return i.ValueScope}}),Object.defineProperty(e,`ValueScopeName`,{enumerable:!0,get:function(){return i.ValueScopeName}}),Object.defineProperty(e,`varKinds`,{enumerable:!0,get:function(){return i.varKinds}}),e.operators={GT:new t._Code(`>`),GTE:new t._Code(`>=`),LT:new t._Code(`<`),LTE:new t._Code(`<=`),EQ:new t._Code(`===`),NEQ:new t._Code(`!==`),NOT:new t._Code(`!`),OR:new t._Code(`||`),AND:new t._Code(`&&`),ADD:new t._Code(`+`)};var a=class{optimizeNodes(){return this}optimizeNames(e,t){return this}},o=class extends a{constructor(e,t,n){super(),this.varKind=e,this.name=t,this.rhs=n}render({es5:e,_n:t}){let r=e?n.varKinds.var:this.varKind,i=this.rhs===void 0?``:` = ${this.rhs}`;return`${r} ${this.name}${i};`+t}optimizeNames(e,t){if(e[this.name.str])return this.rhs&&=k(this.rhs,e,t),this}get names(){return this.rhs instanceof t._CodeOrName?this.rhs.names:{}}},s=class extends a{constructor(e,t,n){super(),this.lhs=e,this.rhs=t,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,n){if(!(this.lhs instanceof t.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=k(this.rhs,e,n),this}get names(){return O(this.lhs instanceof t.Name?{}:{...this.lhs.names},this.rhs)}},c=class extends s{constructor(e,t,n,r){super(e,n,r),this.op=t}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},l=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},u=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:``};`+e}},d=class extends a{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},f=class extends a{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,t){return this.code=k(this.code,e,t),this}get names(){return this.code instanceof t._CodeOrName?this.code.names:{}}},p=class extends a{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((t,n)=>t+n.render(e),``)}optimizeNodes(){let{nodes:e}=this,t=e.length;for(;t--;){let n=e[t].optimizeNodes();Array.isArray(n)?e.splice(t,1,...n):n?e[t]=n:e.splice(t,1)}return e.length>0?this:void 0}optimizeNames(e,t){let{nodes:n}=this,r=n.length;for(;r--;){let i=n[r];i.optimizeNames(e,t)||(A(e,i.names),n.splice(r,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,t)=>D(e,t.names),{})}},m=class extends p{render(e){return`{`+e._n+super.render(e)+`}`+e._n}},h=class extends p{},g=class extends m{};g.kind=`else`;var _=class e extends m{constructor(e,t){super(t),this.condition=e}render(e){let t=`if(${this.condition})`+super.render(e);return this.else&&(t+=`else `+this.else.render(e)),t}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===!0)return this.nodes;let n=this.else;if(n){let e=n.optimizeNodes();n=this.else=Array.isArray(e)?new g(e):e}if(n)return t===!1?n instanceof e?n:n.nodes:this.nodes.length?this:new e(j(t),n instanceof e?[n]:n.nodes);if(!(t===!1||!this.nodes.length))return this}optimizeNames(e,t){if(this.else=this.else?.optimizeNames(e,t),super.optimizeNames(e,t)||this.else)return this.condition=k(this.condition,e,t),this}get names(){let e=super.names;return O(e,this.condition),this.else&&D(e,this.else.names),e}};_.kind=`if`;var v=class extends m{};v.kind=`for`;var y=class extends v{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iteration=k(this.iteration,e,t),this}get names(){return D(super.names,this.iteration.names)}},b=class extends v{constructor(e,t,n,r){super(),this.varKind=e,this.name=t,this.from=n,this.to=r}render(e){let t=e.es5?n.varKinds.var:this.varKind,{name:r,from:i,to:a}=this;return`for(${t} ${r}=${i}; ${r}<${a}; ${r}++)`+super.render(e)}get names(){return O(O(super.names,this.from),this.to)}},x=class extends v{constructor(e,t,n,r){super(),this.loop=e,this.varKind=t,this.name=n,this.iterable=r}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iterable=k(this.iterable,e,t),this}get names(){return D(super.names,this.iterable.names)}},S=class extends m{constructor(e,t,n){super(),this.name=e,this.args=t,this.async=n}render(e){return`${this.async?`async `:``}function ${this.name}(${this.args})`+super.render(e)}};S.kind=`func`;var C=class extends p{render(e){return`return `+super.render(e)}};C.kind=`return`;var w=class extends m{render(e){let t=`try`+super.render(e);return this.catch&&(t+=this.catch.render(e)),this.finally&&(t+=this.finally.render(e)),t}optimizeNodes(){var e,t;return super.optimizeNodes(),(e=this.catch)==null||e.optimizeNodes(),(t=this.finally)==null||t.optimizeNodes(),this}optimizeNames(e,t){var n,r;return super.optimizeNames(e,t),(n=this.catch)==null||n.optimizeNames(e,t),(r=this.finally)==null||r.optimizeNames(e,t),this}get names(){let e=super.names;return this.catch&&D(e,this.catch.names),this.finally&&D(e,this.finally.names),e}},T=class extends m{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};T.kind=`catch`;var E=class extends m{render(e){return`finally`+super.render(e)}};E.kind=`finally`,e.CodeGen=class{constructor(e,t={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...t,_n:t.lines?`
1570
1570
  `:``},this._extScope=e,this._scope=new n.Scope({parent:e}),this._nodes=[new h]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,t){let n=this._extScope.value(e,t);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(e,t){return this._extScope.getValue(e,t)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,t,n,r){let i=this._scope.toName(t);return n!==void 0&&r&&(this._constants[i.str]=n),this._leafNode(new o(e,i,n)),i}const(e,t,r){return this._def(n.varKinds.const,e,t,r)}let(e,t,r){return this._def(n.varKinds.let,e,t,r)}var(e,t,r){return this._def(n.varKinds.var,e,t,r)}assign(e,t,n){return this._leafNode(new s(e,t,n))}add(t,n){return this._leafNode(new c(t,e.operators.ADD,n))}code(e){return typeof e==`function`?e():e!==t.nil&&this._leafNode(new f(e)),this}object(...e){let n=[`{`];for(let[r,i]of e)n.length>1&&n.push(`,`),n.push(r),(r!==i||this.opts.es5)&&(n.push(`:`),(0,t.addCodeArg)(n,i));return n.push(`}`),new t._Code(n)}if(e,t,n){if(this._blockNode(new _(e)),t&&n)this.code(t).else().code(n).endIf();else if(t)this.code(t).endIf();else if(n)throw Error(`CodeGen: "else" body without "then" body`);return this}elseIf(e){return this._elseNode(new _(e))}else(){return this._elseNode(new g)}endIf(){return this._endBlockNode(_,g)}_for(e,t){return this._blockNode(e),t&&this.code(t).endFor(),this}for(e,t){return this._for(new y(e),t)}forRange(e,t,r,i,a=this.opts.es5?n.varKinds.var:n.varKinds.let){let o=this._scope.toName(e);return this._for(new b(a,o,t,r),()=>i(o))}forOf(e,r,i,a=n.varKinds.const){let o=this._scope.toName(e);if(this.opts.es5){let e=r instanceof t.Name?r:this.var(`_arr`,r);return this.forRange(`_i`,0,(0,t._)`${e}.length`,n=>{this.var(o,(0,t._)`${e}[${n}]`),i(o)})}return this._for(new x(`of`,a,o,r),()=>i(o))}forIn(e,r,i,a=this.opts.es5?n.varKinds.var:n.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,t._)`Object.keys(${r})`,i);let o=this._scope.toName(e);return this._for(new x(`in`,a,o,r),()=>i(o))}endFor(){return this._endBlockNode(v)}label(e){return this._leafNode(new l(e))}break(e){return this._leafNode(new u(e))}return(e){let t=new C;if(this._blockNode(t),this.code(e),t.nodes.length!==1)throw Error(`CodeGen: "return" should have one node`);return this._endBlockNode(C)}try(e,t,n){if(!t&&!n)throw Error(`CodeGen: "try" without "catch" and "finally"`);let r=new w;if(this._blockNode(r),this.code(e),t){let e=this.name(`e`);this._currNode=r.catch=new T(e),t(e)}return n&&(this._currNode=r.finally=new E,this.code(n)),this._endBlockNode(T,E)}throw(e){return this._leafNode(new d(e))}block(e,t){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(t),this}endBlock(e){let t=this._blockStarts.pop();if(t===void 0)throw Error(`CodeGen: not in self-balancing block`);let n=this._nodes.length-t;if(n<0||e!==void 0&&n!==e)throw Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=t,this}func(e,n=t.nil,r,i){return this._blockNode(new S(e,n,r)),i&&this.code(i).endFunc(),this}endFunc(){return this._endBlockNode(S)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,t){let n=this._currNode;if(n instanceof e||t&&n instanceof t)return this._nodes.pop(),this;throw Error(`CodeGen: not in block "${t?`${e.kind}/${t.kind}`:e.kind}"`)}_elseNode(e){let t=this._currNode;if(!(t instanceof _))throw Error(`CodeGen: "else" without "if"`);return this._currNode=t.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let t=this._nodes;t[t.length-1]=e}};function D(e,t){for(let n in t)e[n]=(e[n]||0)+(t[n]||0);return e}function O(e,n){return n instanceof t._CodeOrName?D(e,n.names):e}function k(e,n,r){if(e instanceof t.Name)return i(e);if(!a(e))return e;return new t._Code(e._items.reduce((e,n)=>(n instanceof t.Name&&(n=i(n)),n instanceof t._Code?e.push(...n._items):e.push(n),e),[]));function i(e){let t=r[e.str];return t===void 0||n[e.str]!==1?e:(delete n[e.str],t)}function a(e){return e instanceof t._Code&&e._items.some(e=>e instanceof t.Name&&n[e.str]===1&&r[e.str]!==void 0)}}function A(e,t){for(let n in t)e[n]=(e[n]||0)-(t[n]||0)}function j(e){return typeof e==`boolean`||typeof e==`number`||e===null?!e:(0,t._)`!${L(e)}`}e.not=j;var M=I(e.operators.AND);function N(...e){return e.reduce(M)}e.and=N;var P=I(e.operators.OR);function F(...e){return e.reduce(P)}e.or=F;function I(e){return(n,r)=>n===t.nil?r:r===t.nil?n:(0,t._)`${L(n)} ${e} ${L(r)}`}function L(e){return e instanceof t.Name?e:(0,t._)`(${e})`}})),B8=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.checkStrictMode=e.getErrorPath=e.Type=e.useFunc=e.setEvaluated=e.evaluatedPropsToName=e.mergeEvaluated=e.eachItem=e.unescapeJsonPointer=e.escapeJsonPointer=e.escapeFragment=e.unescapeFragment=e.schemaRefOrVal=e.schemaHasRulesButRef=e.schemaHasRules=e.checkUnknownRules=e.alwaysValidSchema=e.toHash=void 0;var t=z8(),n=R8();function r(e){let t={};for(let n of e)t[n]=!0;return t}e.toHash=r;function i(e,t){return typeof t==`boolean`?t:Object.keys(t).length===0?!0:(a(e,t),!o(t,e.self.RULES.all))}e.alwaysValidSchema=i;function a(e,t=e.schema){let{opts:n,self:r}=e;if(!n.strictSchema||typeof t==`boolean`)return;let i=r.RULES.keywords;for(let n in t)i[n]||x(e,`unknown keyword: "${n}"`)}e.checkUnknownRules=a;function o(e,t){if(typeof e==`boolean`)return!e;for(let n in e)if(t[n])return!0;return!1}e.schemaHasRules=o;function s(e,t){if(typeof e==`boolean`)return!e;for(let n in e)if(n!==`$ref`&&t.all[n])return!0;return!1}e.schemaHasRulesButRef=s;function c({topSchemaRef:e,schemaPath:n},r,i,a){if(!a){if(typeof r==`number`||typeof r==`boolean`)return r;if(typeof r==`string`)return(0,t._)`${r}`}return(0,t._)`${e}${n}${(0,t.getProperty)(i)}`}e.schemaRefOrVal=c;function l(e){return f(decodeURIComponent(e))}e.unescapeFragment=l;function u(e){return encodeURIComponent(d(e))}e.escapeFragment=u;function d(e){return typeof e==`number`?`${e}`:e.replace(/~/g,`~0`).replace(/\//g,`~1`)}e.escapeJsonPointer=d;function f(e){return e.replace(/~1/g,`/`).replace(/~0/g,`~`)}e.unescapeJsonPointer=f;function p(e,t){if(Array.isArray(e))for(let n of e)t(n);else t(e)}e.eachItem=p;function m({mergeNames:e,mergeToName:n,mergeValues:r,resultToName:i}){return(a,o,s,c)=>{let l=s===void 0?o:s instanceof t.Name?(o instanceof t.Name?e(a,o,s):n(a,o,s),s):o instanceof t.Name?(n(a,s,o),o):r(o,s);return c===t.Name&&!(l instanceof t.Name)?i(a,l):l}}e.mergeEvaluated={props:m({mergeNames:(e,n,r)=>e.if((0,t._)`${r} !== true && ${n} !== undefined`,()=>{e.if((0,t._)`${n} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,t._)`${r} || {}`).code((0,t._)`Object.assign(${r}, ${n})`))}),mergeToName:(e,n,r)=>e.if((0,t._)`${r} !== true`,()=>{n===!0?e.assign(r,!0):(e.assign(r,(0,t._)`${r} || {}`),g(e,r,n))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:h}),items:m({mergeNames:(e,n,r)=>e.if((0,t._)`${r} !== true && ${n} !== undefined`,()=>e.assign(r,(0,t._)`${n} === true ? true : ${r} > ${n} ? ${r} : ${n}`)),mergeToName:(e,n,r)=>e.if((0,t._)`${r} !== true`,()=>e.assign(r,n===!0?!0:(0,t._)`${r} > ${n} ? ${r} : ${n}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var(`items`,t)})};function h(e,n){if(n===!0)return e.var(`props`,!0);let r=e.var(`props`,(0,t._)`{}`);return n!==void 0&&g(e,r,n),r}e.evaluatedPropsToName=h;function g(e,n,r){Object.keys(r).forEach(r=>e.assign((0,t._)`${n}${(0,t.getProperty)(r)}`,!0))}e.setEvaluated=g;var _={};function v(e,t){return e.scopeValue(`func`,{ref:t,code:_[t.code]||(_[t.code]=new n._Code(t.code))})}e.useFunc=v;var y;(function(e){e[e.Num=0]=`Num`,e[e.Str=1]=`Str`})(y=e.Type||={});function b(e,n,r){if(e instanceof t.Name){let i=n===y.Num;return r?i?(0,t._)`"[" + ${e} + "]"`:(0,t._)`"['" + ${e} + "']"`:i?(0,t._)`"/" + ${e}`:(0,t._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,t.getProperty)(e).toString():`/`+d(e)}e.getErrorPath=b;function x(e,t,n=e.opts.strictSchema){if(n){if(t=`strict mode: ${t}`,n===!0)throw Error(t);e.self.logger.warn(t)}}e.checkStrictMode=x})),V8=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=z8();e.default={data:new t.Name(`data`),valCxt:new t.Name(`valCxt`),instancePath:new t.Name(`instancePath`),parentData:new t.Name(`parentData`),parentDataProperty:new t.Name(`parentDataProperty`),rootData:new t.Name(`rootData`),dynamicAnchors:new t.Name(`dynamicAnchors`),vErrors:new t.Name(`vErrors`),errors:new t.Name(`errors`),this:new t.Name(`this`),self:new t.Name(`self`),scope:new t.Name(`scope`),json:new t.Name(`json`),jsonPos:new t.Name(`jsonPos`),jsonLen:new t.Name(`jsonLen`),jsonPart:new t.Name(`jsonPart`)}})),H8=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.extendErrors=e.resetErrorsCount=e.reportExtraError=e.reportError=e.keyword$DataError=e.keywordError=void 0;var t=z8(),n=B8(),r=V8();e.keywordError={message:({keyword:e})=>(0,t.str)`must pass "${e}" keyword validation`},e.keyword$DataError={message:({keyword:e,schemaType:n})=>n?(0,t.str)`"${e}" keyword must be ${n} ($data)`:(0,t.str)`"${e}" keyword is invalid ($data)`};function i(n,r=e.keywordError,i,a){let{it:o}=n,{gen:s,compositeRule:u,allErrors:f}=o,p=d(n,r,i);a??(u||f)?c(s,p):l(o,(0,t._)`[${p}]`)}e.reportError=i;function a(t,n=e.keywordError,i){let{it:a}=t,{gen:o,compositeRule:s,allErrors:u}=a;c(o,d(t,n,i)),s||u||l(a,r.default.vErrors)}e.reportExtraError=a;function o(e,n){e.assign(r.default.errors,n),e.if((0,t._)`${r.default.vErrors} !== null`,()=>e.if(n,()=>e.assign((0,t._)`${r.default.vErrors}.length`,n),()=>e.assign(r.default.vErrors,null)))}e.resetErrorsCount=o;function s({gen:e,keyword:n,schemaValue:i,data:a,errsCount:o,it:s}){if(o===void 0)throw Error(`ajv implementation error`);let c=e.name(`err`);e.forRange(`i`,o,r.default.errors,o=>{e.const(c,(0,t._)`${r.default.vErrors}[${o}]`),e.if((0,t._)`${c}.instancePath === undefined`,()=>e.assign((0,t._)`${c}.instancePath`,(0,t.strConcat)(r.default.instancePath,s.errorPath))),e.assign((0,t._)`${c}.schemaPath`,(0,t.str)`${s.errSchemaPath}/${n}`),s.opts.verbose&&(e.assign((0,t._)`${c}.schema`,i),e.assign((0,t._)`${c}.data`,a))})}e.extendErrors=s;function c(e,n){let i=e.const(`err`,n);e.if((0,t._)`${r.default.vErrors} === null`,()=>e.assign(r.default.vErrors,(0,t._)`[${i}]`),(0,t._)`${r.default.vErrors}.push(${i})`),e.code((0,t._)`${r.default.errors}++`)}function l(e,n){let{gen:r,validateName:i,schemaEnv:a}=e;a.$async?r.throw((0,t._)`new ${e.ValidationError}(${n})`):(r.assign((0,t._)`${i}.errors`,n),r.return(!1))}var u={keyword:new t.Name(`keyword`),schemaPath:new t.Name(`schemaPath`),params:new t.Name(`params`),propertyName:new t.Name(`propertyName`),message:new t.Name(`message`),schema:new t.Name(`schema`),parentSchema:new t.Name(`parentSchema`)};function d(e,n,r){let{createErrors:i}=e.it;return i===!1?(0,t._)`{}`:f(e,n,r)}function f(e,t,n={}){let{gen:r,it:i}=e,a=[p(i,n),m(e,n)];return h(e,t,a),r.object(...a)}function p({errorPath:e},{instancePath:i}){let a=i?(0,t.str)`${e}${(0,n.getErrorPath)(i,n.Type.Str)}`:e;return[r.default.instancePath,(0,t.strConcat)(r.default.instancePath,a)]}function m({keyword:e,it:{errSchemaPath:r}},{schemaPath:i,parentSchema:a}){let o=a?r:(0,t.str)`${r}/${e}`;return i&&(o=(0,t.str)`${o}${(0,n.getErrorPath)(i,n.Type.Str)}`),[u.schemaPath,o]}function h(e,{params:n,message:i},a){let{keyword:o,data:s,schemaValue:c,it:l}=e,{opts:d,propertyName:f,topSchemaRef:p,schemaPath:m}=l;a.push([u.keyword,o],[u.params,typeof n==`function`?n(e):n||(0,t._)`{}`]),d.messages&&a.push([u.message,typeof i==`function`?i(e):i]),d.verbose&&a.push([u.schema,c],[u.parentSchema,(0,t._)`${p}${m}`],[r.default.data,s]),f&&a.push([u.propertyName,f])}})),rVt=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.boolOrEmptySchema=e.topBoolOrEmptySchema=void 0;var t=H8(),n=z8(),r=V8(),i={message:`boolean schema is false`};function a(e){let{gen:t,schema:i,validateName:a}=e;i===!1?s(e,!1):typeof i==`object`&&i.$async===!0?t.return(r.default.data):(t.assign((0,n._)`${a}.errors`,null),t.return(!0))}e.topBoolOrEmptySchema=a;function o(e,t){let{gen:n,schema:r}=e;r===!1?(n.var(t,!1),s(e)):n.var(t,!0)}e.boolOrEmptySchema=o;function s(e,n){let{gen:r,data:a}=e,o={gen:r,keyword:`false schema`,data:a,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,t.reportError)(o,i,void 0,n)}})),iVt=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getRules=e.isJSONType=void 0;var t=new Set([`string`,`number`,`integer`,`boolean`,`null`,`object`,`array`]);function n(e){return typeof e==`string`&&t.has(e)}e.isJSONType=n;function r(){let e={number:{type:`number`,rules:[]},string:{type:`string`,rules:[]},array:{type:`array`,rules:[]},object:{type:`object`,rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}e.getRules=r})),aVt=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.shouldUseRule=e.shouldUseGroup=e.schemaHasRulesForType=void 0;function t({schema:e,self:t},r){let i=t.RULES.types[r];return i&&i!==!0&&n(e,i)}e.schemaHasRulesForType=t;function n(e,t){return t.rules.some(t=>r(e,t))}e.shouldUseGroup=n;function r(e,t){return e[t.keyword]!==void 0||t.definition.implements?.some(t=>e[t]!==void 0)}e.shouldUseRule=r})),U8=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.reportTypeError=e.checkDataTypes=e.checkDataType=e.coerceAndCheckDataType=e.getJSONTypes=e.getSchemaTypes=e.DataType=void 0;var t=iVt(),n=aVt(),r=H8(),i=z8(),a=B8(),o;(function(e){e[e.Correct=0]=`Correct`,e[e.Wrong=1]=`Wrong`})(o=e.DataType||={});function s(e){let t=c(e.type);if(t.includes(`null`)){if(e.nullable===!1)throw Error(`type: null contradicts nullable: false`)}else{if(!t.length&&e.nullable!==void 0)throw Error(`"nullable" cannot be used without "type"`);e.nullable===!0&&t.push(`null`)}return t}e.getSchemaTypes=s;function c(e){let n=Array.isArray(e)?e:e?[e]:[];if(n.every(t.isJSONType))return n;throw Error(`type must be JSONType or JSONType[]: `+n.join(`,`))}e.getJSONTypes=c;function l(e,t){let{gen:r,data:i,opts:a}=e,s=d(t,a.coerceTypes),c=t.length>0&&!(s.length===0&&t.length===1&&(0,n.schemaHasRulesForType)(e,t[0]));if(c){let n=h(t,i,a.strictNumbers,o.Wrong);r.if(n,()=>{s.length?f(e,t,s):_(e)})}return c}e.coerceAndCheckDataType=l;var u=new Set([`string`,`number`,`integer`,`boolean`,`null`]);function d(e,t){return t?e.filter(e=>u.has(e)||t===`array`&&e===`array`):[]}function f(e,t,n){let{gen:r,data:a,opts:o}=e,s=r.let(`dataType`,(0,i._)`typeof ${a}`),c=r.let(`coerced`,(0,i._)`undefined`);o.coerceTypes===`array`&&r.if((0,i._)`${s} == 'object' && Array.isArray(${a}) && ${a}.length == 1`,()=>r.assign(a,(0,i._)`${a}[0]`).assign(s,(0,i._)`typeof ${a}`).if(h(t,a,o.strictNumbers),()=>r.assign(c,a))),r.if((0,i._)`${c} !== undefined`);for(let e of n)(u.has(e)||e===`array`&&o.coerceTypes===`array`)&&l(e);r.else(),_(e),r.endIf(),r.if((0,i._)`${c} !== undefined`,()=>{r.assign(a,c),p(e,c)});function l(e){switch(e){case`string`:r.elseIf((0,i._)`${s} == "number" || ${s} == "boolean"`).assign(c,(0,i._)`"" + ${a}`).elseIf((0,i._)`${a} === null`).assign(c,(0,i._)`""`);return;case`number`:r.elseIf((0,i._)`${s} == "boolean" || ${a} === null
1571
1571
  || (${s} == "string" && ${a} && ${a} == +${a})`).assign(c,(0,i._)`+${a}`);return;case`integer`:r.elseIf((0,i._)`${s} === "boolean" || ${a} === null
1572
1572
  || (${s} === "string" && ${a} && ${a} == +${a} && !(${a} % 1))`).assign(c,(0,i._)`+${a}`);return;case`boolean`:r.elseIf((0,i._)`${a} === "false" || ${a} === 0 || ${a} === null`).assign(c,!1).elseIf((0,i._)`${a} === "true" || ${a} === 1`).assign(c,!0);return;case`null`:r.elseIf((0,i._)`${a} === "" || ${a} === 0 || ${a} === false`),r.assign(c,null);return;case`array`:r.elseIf((0,i._)`${s} === "string" || ${s} === "number"
@@ -1579,7 +1579,7 @@ cd ${i.sourceRepoUrl.split(`/`).pop()}
1579
1579
  npm install
1580
1580
  npm run dev`.trim()})]})]}),(0,U.jsxs)(dw,{children:[(0,U.jsx)(X,{variant:`ghost`,onClick:()=>t(!1),children:`Later`}),(0,U.jsx)(X,{ref:o,onClick:()=>{s(`working-copy-create-clicked`,{account:r.name,project:i.name}),l.mutate({accountName:r.name,projectName:i.name})},children:(0,U.jsx)(HI,{loading:l.isPending,alternative:(0,U.jsx)(WI,{className:`w-4 h-4 border-2 border-white`}),children:`Create working copy`})})]})]})})},yUt=()=>(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1.5 border-b border-amber-200 bg-amber-100 px-4 py-1.5 text-sm text-amber-800 dark:border-amber-900/60 dark:bg-amber-950/40 dark:text-amber-200`,"data-test":`read-only-banner`,children:[(0,U.jsx)(xUt,{className:`min-w-0 flex-1`}),(0,U.jsx)(bUt,{className:`ml-auto shrink-0`})]}),bUt=({switchLabel:e,className:t,onActionClick:n})=>{let{project:r}=Op([`project`]);return SO(r)?(0,U.jsx)(mUt,{className:t,onOpenClick:n}):(0,U.jsx)(SUt,{label:e,className:t,onSwitchClick:n})},xUt=({className:e})=>{let t=Op(),n=t.environment.branchName??null,r=AL(t.environment.environmentType,kL.PRODUCTION),i=SO(t.project);return(0,U.jsxs)(`span`,{className:W(`flex items-center gap-x-2 text-xs`,e),"data-test":`read-only-hint`,children:[(0,U.jsx)(Ud,{size:14,className:`shrink-0`,"aria-hidden":!0}),(0,U.jsxs)(`span`,{children:[(0,U.jsx)(`span`,{className:`font-semibold`,children:`Read-only`}),` — you are viewing`,` `,n?(0,U.jsxs)(U.Fragment,{children:[`the `,(0,U.jsx)(`span`,{className:`font-medium`,children:n}),` branch`]}):r?`the deployed Production environment`:`a deployed environment`,`.`,` `,i?`To make changes, set up local development.`:`To make changes, switch to Development.`]})]})},SUt=({label:e=`Switch to Development`,variant:t=`outline`,size:n=`sm`,className:r,onSwitchClick:i})=>{let a=Op(),o=v7(),{logEvent:s}=S(),c=_Ut(),[l,u]=(0,H.useState)(!1),[d,f]=(0,H.useState)(!1),p=wR(a.account.name,a.project.name).data?.find(e=>AL(e.environmentType,kL.WORKING_COPY)),m=a.environment.branchName??null,h=!!(a.project.sourceRepoUrl&&m&&a.project.hasCurrentUserWorkingCopy&&p),g=c||a.project.hasCurrentUserWorkingCopy,_=c||!!p;return g?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(X,{size:n,variant:t,className:r,onClick:()=>{if(i?.(),s(`read-only-banner-switch-to-development-clicked`,{account:a.account.name,project:a.project.name,environment:a.environment.name,action:c?`setup-working-copy`:h?`checkout-dialog`:`navigate`}),c){f(!0);return}if(h){u(!0);return}p&&o({environment:p})},disabled:!_,"data-test":`read-only-switch-to-development`,children:[(0,U.jsx)(Tb,{size:14}),e]}),(0,U.jsx)(vUt,{open:d,onOpenChange:f}),h&&m&&p&&(0,U.jsx)(CUt,{open:l,onOpenChange:u,branchName:m,workingCopyEnvironment:p})]}):null},CUt=({open:e,onOpenChange:t,branchName:n,workingCopyEnvironment:r})=>{let i=Op(),a=Ep(),o=v7(),{logEvent:s}=S(),c=kgt(),{data:l,isLoading:u}=qdt(r.name,{enabled:e}),d=gUt(l,i.project.defaultBranch,!1,`Checking out`),f=d?.hasLocalWork??!1,p=()=>{s(`read-only-banner-keep-working-copy-clicked`,{account:i.account.name,project:i.project.name,environment:i.environment.name,branch:n}),t(!1),o({environment:r})},m=Ogt({onSuccess:()=>{c(i.account.name,i.project.name),t(!1),a.success(`Checked out ${n} in your working copy`,{title:`Success`,icon:(0,U.jsx)(fd,{className:`h-4 w-4`})}),o({environment:r})}});return(0,U.jsx)(ow,{open:e,onOpenChange:e=>{m.isPending||t(e)},children:(0,U.jsxs)(lw,{"data-test":`checkout-branch-dialog`,children:[(0,U.jsx)(uw,{children:(0,U.jsx)(fw,{children:`Switch to Development`})}),(0,U.jsxs)(pw,{children:[`Development is your editable working copy. Keep it as it is now, or check out the `,(0,U.jsx)(rT,{variant:`outline`,children:n}),` branch to replace your working copy's files with the latest version of this branch.`]}),d?.hasLocalWork&&(0,U.jsxs)(Ub,{variant:`warning`,"data-test":`checkout-working-copy-warning`,children:[(0,U.jsx)(cp,{}),(0,U.jsx)(Wb,{children:d.title}),(0,U.jsxs)(Gb,{children:[d.detail,` Keep your working copy to switch with them intact.`]})]}),(0,U.jsx)(SA,{error:m.error}),(0,U.jsxs)(dw,{children:[(0,U.jsx)(X,{variant:`ghost`,className:`sm:mr-auto`,onClick:()=>{s(`read-only-banner-switch-cancelled`,{account:i.account.name,project:i.project.name,environment:i.environment.name,branch:n}),t(!1)},disabled:m.isPending,"data-test":`checkout-branch-cancel`,children:`Cancel`}),(0,U.jsx)(X,{variant:`outline`,onClick:p,disabled:m.isPending,"data-test":`checkout-branch-keep`,children:`Just switch`}),(0,U.jsx)(X,{variant:f?`destructive`:`default`,disabled:m.isPending||u,onClick:()=>{s(`read-only-banner-checkout-branch-confirmed`,{account:i.account.name,project:i.project.name,environment:i.environment.name,branch:n,hasLocalWork:f}),m.mutate({accountName:i.account.name,projectName:i.project.name,branchName:n})},"data-test":`checkout-branch-confirm`,children:(0,U.jsx)(HI,{loading:m.isPending,children:`Checkout & switch`})})]})]})})},wUt=({item:e,isSelected:t,onSelect:n})=>{let r=new Date(e.createdOn),i=Jje(r)?`${_O(r,`H:mm:ss`)} Today`:qje(r)?`${_O(r,`H:mm:ss ccc d, MMM`)}`:`${_O(r,`H:mm:ss ccc d`)} ${_O(r,`MMM yyy`)}`;return(0,U.jsxs)(`div`,{className:(0,zI.default)(`flex items-center gap-2 px-3 cursor-pointer h-10 border-border border-b`,{"bg-accent text-accent-foreground":t,"hover:bg-accent/50":!t}),onClick:()=>n(),children:[(0,U.jsx)(`div`,{className:`flex justify-center items-center w-5 shrink-0`,children:(0,U.jsx)(S5e,{deployment:e})}),(0,U.jsx)(`span`,{className:`w-full text-sm truncate`,children:i})]})},TUt={"in-progress":`Building`,success:`Finished`,failed:`Failed`,skipped:`Skipped`},EUt=({status:e})=>TUt[e],DUt={lint:`Lint`,build:`Build`,deploy:`Deploy`},OUt=({step:e})=>DUt[e]??e,b7=r(a(((e,t)=>{(function(n,r){typeof e==`object`&&t!==void 0?t.exports=r():typeof define==`function`&&define.amd?define(r):(n=typeof globalThis<`u`?globalThis:n||self).dayjs=r()})(e,(function(){var e=1e3,t=6e4,n=36e5,r=`millisecond`,i=`second`,a=`minute`,o=`hour`,s=`day`,c=`week`,l=`month`,u=`quarter`,d=`year`,f=`date`,p=`Invalid Date`,m=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,h=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,g={name:`en`,weekdays:`Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday`.split(`_`),months:`January_February_March_April_May_June_July_August_September_October_November_December`.split(`_`),ordinal:function(e){var t=[`th`,`st`,`nd`,`rd`],n=e%100;return`[`+e+(t[(n-20)%10]||t[n]||t[0])+`]`}},_=function(e,t,n){var r=String(e);return!r||r.length>=t?e:``+Array(t+1-r.length).join(n)+e},v={s:_,z:function(e){var t=-e.utcOffset(),n=Math.abs(t),r=Math.floor(n/60),i=n%60;return(t<=0?`+`:`-`)+_(r,2,`0`)+`:`+_(i,2,`0`)},m:function e(t,n){if(t.date()<n.date())return-e(n,t);var r=12*(n.year()-t.year())+(n.month()-t.month()),i=t.clone().add(r,l),a=n-i<0,o=t.clone().add(r+(a?-1:1),l);return+(-(r+(n-i)/(a?i-o:o-i))||0)},a:function(e){return e<0?Math.ceil(e)||0:Math.floor(e)},p:function(e){return{M:l,y:d,w:c,d:s,D:f,h:o,m:a,s:i,ms:r,Q:u}[e]||String(e||``).toLowerCase().replace(/s$/,``)},u:function(e){return e===void 0}},y=`en`,b={};b[y]=g;var x=`$isDayjsObject`,S=function(e){return e instanceof E||!(!e||!e[x])},C=function e(t,n,r){var i;if(!t)return y;if(typeof t==`string`){var a=t.toLowerCase();b[a]&&(i=a),n&&(b[a]=n,i=a);var o=t.split(`-`);if(!i&&o.length>1)return e(o[0])}else{var s=t.name;b[s]=t,i=s}return!r&&i&&(y=i),i||!r&&y},w=function(e,t){if(S(e))return e.clone();var n=typeof t==`object`?t:{};return n.date=e,n.args=arguments,new E(n)},T=v;T.l=C,T.i=S,T.w=function(e,t){return w(e,{locale:t.$L,utc:t.$u,x:t.$x,$offset:t.$offset})};var E=function(){function g(e){this.$L=C(e.locale,null,!0),this.parse(e),this.$x=this.$x||e.x||{},this[x]=!0}var _=g.prototype;return _.parse=function(e){this.$d=function(e){var t=e.date,n=e.utc;if(t===null)return new Date(NaN);if(T.u(t))return new Date;if(t instanceof Date)return new Date(t);if(typeof t==`string`&&!/Z$/i.test(t)){var r=t.match(m);if(r){var i=r[2]-1||0,a=(r[7]||`0`).substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,a)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,a)}}return new Date(t)}(e),this.init()},_.init=function(){var e=this.$d;this.$y=e.getFullYear(),this.$M=e.getMonth(),this.$D=e.getDate(),this.$W=e.getDay(),this.$H=e.getHours(),this.$m=e.getMinutes(),this.$s=e.getSeconds(),this.$ms=e.getMilliseconds()},_.$utils=function(){return T},_.isValid=function(){return this.$d.toString()!==p},_.isSame=function(e,t){var n=w(e);return this.startOf(t)<=n&&n<=this.endOf(t)},_.isAfter=function(e,t){return w(e)<this.startOf(t)},_.isBefore=function(e,t){return this.endOf(t)<w(e)},_.$g=function(e,t,n){return T.u(e)?this[t]:this.set(n,e)},_.unix=function(){return Math.floor(this.valueOf()/1e3)},_.valueOf=function(){return this.$d.getTime()},_.startOf=function(e,t){var n=this,r=!!T.u(t)||t,u=T.p(e),p=function(e,t){var i=T.w(n.$u?Date.UTC(n.$y,t,e):new Date(n.$y,t,e),n);return r?i:i.endOf(s)},m=function(e,t){return T.w(n.toDate()[e].apply(n.toDate(`s`),(r?[0,0,0,0]:[23,59,59,999]).slice(t)),n)},h=this.$W,g=this.$M,_=this.$D,v=`set`+(this.$u?`UTC`:``);switch(u){case d:return r?p(1,0):p(31,11);case l:return r?p(1,g):p(0,g+1);case c:var y=this.$locale().weekStart||0,b=(h<y?h+7:h)-y;return p(r?_-b:_+(6-b),g);case s:case f:return m(v+`Hours`,0);case o:return m(v+`Minutes`,1);case a:return m(v+`Seconds`,2);case i:return m(v+`Milliseconds`,3);default:return this.clone()}},_.endOf=function(e){return this.startOf(e,!1)},_.$set=function(e,t){var n,c=T.p(e),u=`set`+(this.$u?`UTC`:``),p=(n={},n[s]=u+`Date`,n[f]=u+`Date`,n[l]=u+`Month`,n[d]=u+`FullYear`,n[o]=u+`Hours`,n[a]=u+`Minutes`,n[i]=u+`Seconds`,n[r]=u+`Milliseconds`,n)[c],m=c===s?this.$D+(t-this.$W):t;if(c===l||c===d){var h=this.clone().set(f,1);h.$d[p](m),h.init(),this.$d=h.set(f,Math.min(this.$D,h.daysInMonth())).$d}else p&&this.$d[p](m);return this.init(),this},_.set=function(e,t){return this.clone().$set(e,t)},_.get=function(e){return this[T.p(e)]()},_.add=function(r,u){var f,p=this;r=Number(r);var m=T.p(u),h=function(e){var t=w(p);return T.w(t.date(t.date()+Math.round(e*r)),p)};if(m===l)return this.set(l,this.$M+r);if(m===d)return this.set(d,this.$y+r);if(m===s)return h(1);if(m===c)return h(7);var g=(f={},f[a]=t,f[o]=n,f[i]=e,f)[m]||1,_=this.$d.getTime()+r*g;return T.w(_,this)},_.subtract=function(e,t){return this.add(-1*e,t)},_.format=function(e){var t=this,n=this.$locale();if(!this.isValid())return n.invalidDate||p;var r=e||`YYYY-MM-DDTHH:mm:ssZ`,i=T.z(this),a=this.$H,o=this.$m,s=this.$M,c=n.weekdays,l=n.months,u=n.meridiem,d=function(e,n,i,a){return e&&(e[n]||e(t,r))||i[n].slice(0,a)},f=function(e){return T.s(a%12||12,e,`0`)},m=u||function(e,t,n){var r=e<12?`AM`:`PM`;return n?r.toLowerCase():r};return r.replace(h,(function(e,r){return r||function(e){switch(e){case`YY`:return String(t.$y).slice(-2);case`YYYY`:return T.s(t.$y,4,`0`);case`M`:return s+1;case`MM`:return T.s(s+1,2,`0`);case`MMM`:return d(n.monthsShort,s,l,3);case`MMMM`:return d(l,s);case`D`:return t.$D;case`DD`:return T.s(t.$D,2,`0`);case`d`:return String(t.$W);case`dd`:return d(n.weekdaysMin,t.$W,c,2);case`ddd`:return d(n.weekdaysShort,t.$W,c,3);case`dddd`:return c[t.$W];case`H`:return String(a);case`HH`:return T.s(a,2,`0`);case`h`:return f(1);case`hh`:return f(2);case`a`:return m(a,o,!0);case`A`:return m(a,o,!1);case`m`:return String(o);case`mm`:return T.s(o,2,`0`);case`s`:return String(t.$s);case`ss`:return T.s(t.$s,2,`0`);case`SSS`:return T.s(t.$ms,3,`0`);case`Z`:return i}return null}(e)||i.replace(`:`,``)}))},_.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},_.diff=function(r,f,p){var m,h=this,g=T.p(f),_=w(r),v=(_.utcOffset()-this.utcOffset())*t,y=this-_,b=function(){return T.m(h,_)};switch(g){case d:m=b()/12;break;case l:m=b();break;case u:m=b()/3;break;case c:m=(y-v)/6048e5;break;case s:m=(y-v)/864e5;break;case o:m=y/n;break;case a:m=y/t;break;case i:m=y/e;break;default:m=y}return p?m:T.a(m)},_.daysInMonth=function(){return this.endOf(l).$D},_.$locale=function(){return b[this.$L]},_.locale=function(e,t){if(!e)return this.$L;var n=this.clone(),r=C(e,t,!0);return r&&(n.$L=r),n},_.clone=function(){return T.w(this.$d,this)},_.toDate=function(){return new Date(this.valueOf())},_.toJSON=function(){return this.isValid()?this.toISOString():null},_.toISOString=function(){return this.$d.toISOString()},_.toString=function(){return this.$d.toUTCString()},g}(),D=E.prototype;return w.prototype=D,[[`$ms`,r],[`$s`,i],[`$m`,a],[`$H`,o],[`$W`,s],[`$M`,l],[`$y`,d],[`$D`,f]].forEach((function(e){D[e[1]]=function(t){return this.$g(t,e[0],e[1])}})),w.extend=function(e,t){return e.$i||=(e(t,E,w),!0),w},w.locale=C,w.isDayjs=S,w.unix=function(e){return w(1e3*e)},w.en=b[y],w.Ls=b,w.p={},w}))}))(),1);function kUt({onlyFirst:e=!1}={}){let t=[`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))`,`(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))`].join(`|`);return new RegExp(t,e?void 0:`g`)}var AUt=kUt();function jUt(e){if(typeof e!=`string`)throw TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.replace(AUt,``)}var MUt=({logs:e,children:t,className:n})=>(0,U.jsx)(`div`,{className:W(`grid grid-cols-[auto_1fr] auto-rows-min gap-x-5 py-4 text-xs h-full overflow-auto`,`bg-neutral-950 font-mono text-white`,n),children:t||(e.length>0?e.map(({timestamp:e,severity:t,message:n},r)=>(0,U.jsxs)(`div`,{className:W(`grid grid-cols-subgrid col-span-full px-4 py-1 hover:bg-neutral-800 text-neutral-200`,{"text-red-400":t===`error`,"text-yellow-400":t===`warn`,"text-green-500":/^\x1b\[32m/.test(n)}),children:[(0,U.jsx)(`div`,{className:`select-none`,children:(0,b7.default)(e).format(`HH:mm:ss.SSS`)}),(0,U.jsx)(`pre`,{className:`whitespace-pre-wrap`,children:(0,U.jsx)(Yje,{text:jUt(n).trim()})})]},`${e}-${r}`)):(0,U.jsx)(`div`,{className:`text-neutral-300 italic px-4`,children:`No logs available`}))}),NUt=({stage:e,buildLogs:t,isLoading:n})=>(0,U.jsx)(`div`,{className:`divide-y divide-neutral-800`,children:[...e.steps??[]].sort((e,t)=>e.ordinal-t.ordinal).map(r=>{let i=D5e(t,e.stage,r.step),a=T5e(i);return(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 text-xs font-medium bg-neutral-900 text-neutral-300`,children:[(0,U.jsx)(o1,{status:r.status}),(0,U.jsx)(OUt,{step:r.step}),a>0&&(0,U.jsxs)(rT,{variant:`warn`,children:[a,` warning`,a>1?`s`:``]})]}),(0,U.jsx)(MUt,{logs:i,children:n&&(0,U.jsxs)(`div`,{className:`flex flex-col gap-0.5 col-span-full px-4`,children:[(0,U.jsx)(bD,{className:`h-4 w-3/6 bg-white/20`}),(0,U.jsx)(bD,{className:`h-4 w-2/6 bg-white/20`})]})})]},r.id)})}),PUt=(e,t)=>e?t(e):void 0,FUt=({deployment:e,defaultOpen:t})=>{let{environment:n}=Op([`environment`]),r=Snt(n.name,e.id,{});return r.isPending?(0,U.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,U.jsx)(bD,{className:`h-10 w-full`}),(0,U.jsx)(bD,{className:`h-10 w-full`})]}):r.isError?(0,U.jsx)(Ub,{variant:`warning`,children:(0,U.jsx)(Gb,{className:`text-center`,children:(0,U.jsx)(`div`,{className:`text-neutral-600 text-lg`,children:r.error?r.error.status===401||r.error.status===403?`You don't have permission to view build logs for this deployment.`:r.error.status===404?`Deployment not found. The selected deployment may have been deleted or doesn't exist.`:r.error.status===500?`Server error occurred while loading build logs. Please try again or contact support if the problem persists.`:`Unable to load build logs. Please try again or contact support if the problem persists.`:`Could not load logs. Please try again or contact support if the problem persists.`})})}):(0,U.jsx)(CA,{className:`divide-y overflow-hidden`,children:e.stages.map((n,i)=>(0,U.jsx)(IUt,{stage:n,stageIndex:i,stageCount:e.stages.length,buildLogs:r.data,isLoading:r.isLoading,defaultOpen:t},n.id))})},IUt=({stage:e,stageIndex:t,stageCount:n,buildLogs:r,isLoading:i,defaultOpen:a})=>{let o=e.steps&&e.steps.length>0;return(0,U.jsxs)(fT,{defaultOpen:a,children:[(0,U.jsx)(pT,{asChild:!0,children:(0,U.jsxs)(`div`,{className:`flex items-center gap-2 p-2 w-full hover:bg-accent cursor-pointer group`,children:[(0,U.jsx)(o1,{status:e.status}),(0,U.jsxs)(`div`,{className:`font-medium`,children:[(0,U.jsxs)(`span`,{className:`font-mono text-xs me-2`,children:[`(`,t+1,`/`,n,`)`]}),`Building `,(0,U.jsx)(Egt,{stage:e.stage})]}),(0,U.jsx)(`div`,{className:`text-muted-foreground text-xs`,children:(0,U.jsx)(EUt,{status:e.status})}),(0,U.jsx)(`div`,{className:`text-xs text-amber-400`,children:PUt(T5e(E5e(r,e.stage)),e=>(0,U.jsxs)(rT,{variant:`warn`,children:[e,` warning`,e>1?`s`:``]}))}),(0,U.jsx)(`div`,{className:`ms-2 flex items-center justify-center`,children:(0,U.jsx)(pd,{className:`w-4 h-4 transition-transform group-data-[state=closed]:-rotate-90`})})]})}),(0,U.jsx)(mT,{children:o?(0,U.jsx)(NUt,{stage:e,buildLogs:r,isLoading:i}):(0,U.jsx)(MUt,{logs:E5e(r,e.stage),children:i&&(0,U.jsxs)(`div`,{className:`flex flex-col gap-0.5 col-span-full px-4`,children:[(0,U.jsx)(bD,{className:`h-4 w-3/6 bg-white/20`}),(0,U.jsx)(bD,{className:`h-4 w-2/6 bg-white/20`})]})})})]})},LUt=({build:e})=>(0,U.jsx)(`div`,{className:`p-4 w-full`,children:(0,U.jsx)(FUt,{deployment:e,defaultOpen:!0})}),RUt=()=>{let[e,t]=kY(`build`),{environment:n}=Op([`account`,`project`,`environment`]),{data:r}=ER(n.name),i=r?.data?.find(t=>t.id===e);return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(rY,{}),(0,U.jsxs)(nY,{className:`min-h-36 shadow-[rgb(215_215_215/15%)_0px_-4px_3px_0px] dark:shadow-[rgb(0_0_0/40%)_0px_-4px_3px_0px]`,defaultSize:30,children:[(0,U.jsxs)(`div`,{className:`flex gap-2 border-b h-8 items-center justify-between group bg-surface-muted px-3`,children:[(0,U.jsx)(`div`,{className:`divide-neutral-200`,children:(0,U.jsxs)(`div`,{className:`flex items-center gap-2 group rounded-none relative text-xs font-medium`,title:e,children:[(0,U.jsx)(Md,{size:16}),e?`Build ${e.slice(0,8)}`:`Builds`]})}),(0,U.jsx)(`div`,{className:`flex flex-row gap-2`,children:(0,U.jsx)(X,{variant:`ghost`,size:`icon-xs`,onClick:()=>t(void 0),children:(0,U.jsx)(pp,{size:18})})})]}),(0,U.jsxs)(`div`,{className:`h-[calc(100%-2rem)]`,children:[r?.data?.length===0&&(0,U.jsx)(`div`,{className:`p-3 text-sm`,children:`Start changing your local copy to see build information.`}),(0,U.jsxs)(`div`,{className:`divide-x grid grid-cols-[min-content_1fr] w-full h-full`,children:[(0,U.jsx)(`div`,{className:`overflow-y-auto`,children:r?.data?.map(n=>(0,U.jsx)(wUt,{item:n,isSelected:n.id===e,onSelect:()=>t(n.id)},`${n.id}`))}),(0,U.jsx)(`div`,{className:`overflow-y-auto`,children:e&&i?(0,U.jsx)(LUt,{build:i}):(0,U.jsx)(`div`,{className:`p-3 text-sm`,children:`Select a build to view more information.`})})]})]})]})]})},x7=`/modules`,S7=`/schemas`;function zUt({showReadOnlyBanner:e=!0}={}){let t=Op(),{editStrategies:n}=b6(),[r,i]=kY(`path`),[a]=kY(`build`),{monaco:o,reloadFiles:c}=_7(),l=XR(c.execute),u=t.environment.name,{isReadOnly:d}=HZ(),{isFileTreeOpen:f,setIsFileTreeOpen:p}=A8(),m=Pp(e=>e.projectTreeNodes),[h,g]=Vs(),_=e=>{let t=new URLSearchParams(h);t.set(`path`,e),t.delete(`v`),t.delete(`line`),g(t)},v=`${t.account.name}/${t.project.name}/${t.environment.name}`,[y,b]=(0,H.useState)(!1),[x,S]=(0,H.useState)(v);x!==v&&(S(v),b(!1)),(0,H.useEffect)(()=>{if(y)return;if(r){b(!0);return}if(m.length===0)return;let e=m.find(e=>e.path&&Ip.test(e.path));b(!0),e&&i(e.path)},[r,m,i,y]);let C=m.length===0,w=!r&&(C||!y),T=m.find(e=>e.path&&Ip.test(e.path))?.path,E=r??``,D=[{label:`Routes`,testId:`sidebar-routes`,icon:(0,U.jsx)(cft,{className:`size-[18px]`}),isActive:Ip.test(E),disabled:!T,onClick:()=>T&&_(T)},{label:`Policies`,testId:`sidebar-policies`,icon:(0,U.jsx)(Gf,{size:18}),isActive:E===`/config/policies.json`,disabled:!1,onClick:()=>_(`/config/policies.json`)},{label:`Modules`,testId:`sidebar-modules`,icon:(0,U.jsx)(Ef,{size:18}),isActive:E===x7,disabled:!1,onClick:()=>_(x7)},{label:`Schemas`,testId:`sidebar-schemas`,icon:(0,U.jsx)(qd,{size:18}),isActive:E===S7,disabled:!1,onClick:()=>_(S7)}],{isError:O,error:A}=k({queryKey:[`reloadFiles`,t.account.name,t.project.name,t.environment.name],queryFn:async({signal:e})=>(await l.current({accountName:t.account.name,projectName:t.project.name,environmentName:t.environment.name},e),!0),refetchOnWindowFocus:!1,enabled:!!o&&!!u});if(O&&A instanceof s)return(0,U.jsx)(`div`,{className:`w-full h-full flex items-center justify-center`,children:(0,U.jsxs)(Ub,{className:`max-w-md`,children:[(0,U.jsx)(Wb,{children:A.title}),(0,U.jsxs)(Gb,{className:`flex flex-col gap-2`,children:[ux(A),(0,U.jsx)(oUt,{})]})]})});let j=(0,U.jsxs)(tY,{direction:`vertical`,autoSaveId:`bottom-pane`,className:`relative`,children:[(0,U.jsx)(nY,{minSize:10,children:r?(0,U.jsx)(JY,{blastRadius:`feature-dead`,fallback:e=>(0,U.jsx)(Qgt,{...e}),children:(0,U.jsx)(BUt,{})}):w?(0,U.jsx)(VUt,{}):null}),a!==void 0&&(0,U.jsx)(RUt,{})]});return(0,U.jsxs)(`div`,{className:`flex h-full w-full flex-col`,children:[e&&d&&(0,U.jsx)(yUt,{}),(0,U.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[!f&&(0,U.jsxs)(`div`,{className:`flex flex-col items-center bg-surface-sunken border-r shrink-0 w-12 py-2 gap-1`,children:[(0,U.jsx)(HUt,{label:`Expand file tree`,onClick:()=>p(!0),testId:`expand-file-tree`,children:(0,U.jsx)(Of,{size:18})}),(0,U.jsx)(`div`,{className:`my-1 h-px w-6 bg-surface-emphasis`,"aria-hidden":!0}),D.map(e=>(0,U.jsx)(HUt,{label:e.label,onClick:e.onClick,testId:e.testId,isActive:e.isActive,disabled:e.disabled,children:e.icon},e.label)),(0,U.jsx)(`div`,{className:`flex-1`}),(0,U.jsx)(`span`,{className:`text-[10px] font-medium text-neutral-500 uppercase tracking-wider select-none pb-1`,style:{writingMode:`vertical-rl`},children:`Files`})]}),f?(0,U.jsxs)(tY,{direction:`horizontal`,autoSaveId:`file-tree`,className:`flex-1 min-w-0`,children:[(0,U.jsx)(nY,{minSize:10,defaultSize:20,className:`bg-surface-sunken min-w-[270px]`,children:(0,U.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between h-10 px-2 border-b shrink-0`,children:[(0,U.jsx)(`span`,{className:`text-xs font-medium text-neutral-600 dark:text-neutral-400 uppercase tracking-wide pl-1`,children:`Files`}),(0,U.jsx)(X,{variant:`ghost`,size:`icon-xs`,onClick:()=>p(!1),"aria-label":`Collapse file tree`,title:`Collapse file tree`,children:(0,U.jsx)(Df,{size:14})})]}),(0,U.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,U.jsx)(Xgt,{directoryStrategies:n})})]})}),(0,U.jsx)(rY,{}),(0,U.jsx)(nY,{minSize:70,children:j})]}):(0,U.jsx)(`div`,{className:`flex-1 min-w-0`,children:j})]})]})}var BUt=()=>{let[e]=kY(`path`);if(!e)throw Error(`Invalid state - FileViewer should not be displayed if no path`);let t=e.toLowerCase();if(t===x7)return(0,U.jsx)(HBt,{});if(t===S7)return(0,U.jsx)(UBt,{});if(t===`/docs/sidebar.json`)return(0,U.jsx)(pmt,{});if(t.includes(`.oas.json`))return(0,U.jsx)(BBt,{});if(t===`/config/policies.json`)return(0,U.jsx)(QHt,{});if(t.endsWith(`.md`)||t.endsWith(`.mdx`)){let e=t.split(`/`),n=e[e.length-1];return(0,U.jsx)(fmt,{fileName:n})}return t.endsWith(`.ts`)||t.endsWith(`.css`)?(0,U.jsx)(_Q,{maxHeightVh:100}):t.startsWith(`/schemas`)&&t.endsWith(`.json`)?(0,U.jsx)(_Q,{}):t===`/config/dev-portal.json`?(0,U.jsxs)(`div`,{className:`size-full`,children:[(0,U.jsx)(`div`,{className:`p-4`,children:(0,U.jsx)(nUt,{})}),(0,U.jsx)(_Q,{})]}):(0,U.jsx)(_Q,{})},VUt=()=>(0,U.jsxs)(`div`,{className:`p-6 flex flex-col gap-2`,"data-test":`editor-loading`,children:[(0,U.jsx)(bD,{className:`w-40 h-4`}),(0,U.jsx)(bD,{className:`w-56 h-4`}),(0,U.jsx)(bD,{className:`w-28 h-4`}),(0,U.jsx)(bD,{className:`w-64 h-4`}),(0,U.jsx)(bD,{className:`w-56 h-4`}),(0,U.jsx)(bD,{className:`w-56 h-4`}),(0,U.jsx)(bD,{className:`w-56 h-4`})]}),HUt=({label:e,onClick:t,testId:n,isActive:r=!1,disabled:i=!1,children:a})=>(0,U.jsx)(uR,{content:e,side:`right`,children:(0,U.jsx)(`button`,{type:`button`,onClick:t,"aria-label":e,"aria-current":r?`page`:void 0,disabled:i,"data-test":n,className:W(`group flex items-center justify-center size-9 rounded-md transition-colors ring-offset-background focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,i?`text-neutral-300 dark:text-neutral-700 cursor-not-allowed`:`cursor-pointer`,!i&&(r?`bg-brand/10 text-brand`:`text-neutral-600 dark:text-neutral-400 hover:text-neutral-900 dark:hover:text-neutral-100 hover:bg-neutral-200 dark:hover:bg-neutral-800`)),children:a})});function UUt(){return(0,U.jsxs)(Uut,{children:[(0,U.jsx)(zUt,{}),(0,U.jsx)(sft,{})]})}var WUt=`/static/img/hero-Ct8-h_EN.svg`,GUt=`/static/img/hero-dark-Z9HfvwEQ.svg`,KUt=[{label:`Monetization`,value:`monetization`,badge:`Beta`,items:[{title:`Monetization Overview`,description:`Learn more about our first-party metering and billing solution built directly into the Zuplo platform.`,icon:db,link:{href:{web:`https://zuplo.com/docs/articles/monetization/index`,local:`https://zuplo.com/docs/articles/monetization/index`},text:`Read the docs`}},{title:`Monetization Quickstart`,description:`Get up and running with API monetization in minutes using Zuplo's built-in billing and metering.`,icon:yb,link:{href:{web:`https://zuplo.com/docs/articles/monetization/quickstart`,local:`https://zuplo.com/docs/articles/monetization/quickstart`},text:`Get Started`}},{title:`Pricing Models`,description:`Explore the different pricing models available for monetizing your APIs with Zuplo.`,icon:fb,link:{href:{web:`https://zuplo.com/docs/articles/monetization/pricing-models`,local:`https://zuplo.com/docs/articles/monetization/pricing-models`},text:`Read the docs`}}]},{label:`MCP`,value:`mcp`,items:[{title:`Installing the MCP Inspector`,description:`Set up the MCP Inspector locally and start testing your MCP server with ease.`,icon:mb,link:{href:{web:`https://zuplo.com/docs/handlers/mcp-server#mcp-inspector`,local:`https://zuplo.com/docs/handlers/mcp-server#mcp-inspector`},text:`Get Started`}},{title:`MCP Quickstart`,description:`Learn how to start using Model Context Protocol to pass context into any model call.`,icon:yb,link:{href:{web:`https://zuplo.com/docs/articles/mcp-quickstart`,local:`https://zuplo.com/docs/articles/mcp-quickstart`},text:`Get Started`}},{title:`Using OAuth with MCP`,description:`Authenticate users securely by integrating OAuth flows into your Model Context Protocol setup.`,icon:vb,link:{href:{web:`https://zuplo.com/docs/articles/configuring-auth0-for-mcp-auth`,local:`https://zuplo.com/docs/articles/configuring-auth0-for-mcp-auth`},text:`Get Started`}}]},{label:`Rate Limiting`,value:`rate-limiting`,items:[{title:`Adding Rate Limiting`,description:`Control traffic and protect your APIs by setting up flexible, customizable rate limits.`,icon:fb,link:{href:{web:`https://zuplo.com/docs/articles/step-2-add-rate-limiting`,local:`https://zuplo.com/docs/articles/step-2-add-rate-limiting-local`},text:`Get Started`}},{title:`Complex Rate Limiting`,description:`Implement advanced rules to rate limit by user, IP, plan, or custom logic.`,icon:pb,link:{href:{web:`https://zuplo.com/docs/policies/complex-rate-limit-inbound`,local:`https://zuplo.com/docs/policies/complex-rate-limit-inbound`},text:`Get Started`}},{title:`Dynamic Rate Limits`,description:`Set rate limits that adapt in real-time based on headers, tokens, or user context.`,icon:xpe,link:{href:{web:`https://zuplo.com/examples/dynamic-rate-limits`,local:`https://zuplo.com/examples/dynamic-rate-limits`},text:`Get Started`}}]},{label:`Authentication`,value:`authentication`,items:[{title:`Using API Keys`,description:`Authenticate and manage access to your APIs with simple, secure API key workflows.`,icon:Epe,link:{href:{web:`https://zuplo.com/docs/policies/api-key-inbound`,local:`https://zuplo.com/docs/policies/api-key-inbound`},text:`Get Started`}},{title:`Using Auth0`,description:`Connect your APIs to Auth0 for streamlined authentication and powerful identity management.`,icon:Cb,link:{href:{web:`https://zuplo.com/docs/policies/auth0-jwt-auth-inbound`,local:`https://zuplo.com/docs/policies/auth0-jwt-auth-inbound`},text:`Get Started`}},{title:`Using Okta`,description:`Integrate Okta with your APIs to enable secure, enterprise-grade authentication and authorization.`,icon:hb,link:{href:{web:`https://zuplo.com/docs/policies/okta-jwt-auth-inbound`,local:`https://zuplo.com/docs/policies/okta-jwt-auth-inbound`},text:`Get Started`}}]},{label:`Dev Portal`,value:`dev-portal`,items:[{title:`Setup your API Reference`,description:`Instantly generate an interactive reference by importing your OpenAPI spec—no manual work needed.`,icon:Dfe,link:{href:{web:`https://zuplo.com/docs/dev-portal/zudoku/configuration/api-reference`,local:`https://zuplo.com/docs/dev-portal/zudoku/configuration/api-reference`},text:`Get Started`}},{title:`Adding Authentication`,description:`Guide users through secure API access by adding auth flows to your developer portal.`,icon:bb,link:{href:{web:`https://zuplo.com/docs/dev-portal/zudoku/configuration/authentication`,local:`https://zuplo.com/docs/dev-portal/zudoku/configuration/authentication`},text:`Get Started`}},{title:`Creating API Catalogs`,description:`Organize your APIs into searchable, user-friendly catalogs for easier discovery and onboarding.`,icon:db,link:{href:{web:`https://zuplo.com/docs/dev-portal/zudoku/guides/using-multiple-apis`,local:`https://zuplo.com/docs/dev-portal/zudoku/guides/using-multiple-apis`},text:`Get Started`}}]}],qUt=({mode:e=`web`})=>(0,U.jsxs)(dj,{defaultValue:`monetization`,className:`flex flex-col my-8`,children:[(0,U.jsx)(fj,{className:`flex gap-8 border-b border-surface-border mb-8 ml-1`,children:KUt.map(e=>(0,U.jsxs)(pj,{value:e.value,className:`relative py-2 text-sm font-medium text-gray-600 dark:text-neutral-400 hover:text-gray-900 dark:hover:text-neutral-100 data-[state=active]:text-gray-900 dark:data-[state=active]:text-neutral-100 border-b-2 border-transparent data-[state=active]:border-black dark:data-[state=active]:border-white transition-colors`,children:[e.label,`badge`in e&&e.badge&&(0,U.jsx)(rT,{variant:`invert`,className:`ml-2`,children:e.badge})]},e.value))}),KUt.map(t=>(0,U.jsx)(mj,{value:t.value,className:`grid grid-cols-3 gap-4`,children:t.items.map(t=>(0,U.jsxs)(CA,{className:`flex flex-col gap-2 text-muted-foreground`,children:[(0,U.jsxs)(wA,{className:`flex gap-2`,children:[(0,U.jsx)(t.icon,{size:24,weight:`duotone`,className:`[&_[opacity='0.2']]:fill-pink-500`}),(0,U.jsx)(TA,{className:`gap-x-2 text-lg font-semibold`,children:t.title})]}),(0,U.jsx)(DA,{children:t.description}),(0,U.jsx)(OA,{className:`flex-1 items-end! border-0 mb-4`,children:(0,U.jsx)(X,{variant:`outline`,className:`w-full`,asChild:!0,children:(0,U.jsx)(hT,{href:t.link.href[e],variant:`ghost`,children:t.link.text})})})]},t.title))},t.value))]}),JUt=({title:e,url:t,className:n})=>{let{copyToClipboard:r,state:i}=WC(t??``);return(0,U.jsxs)(CA,{className:W(`col-span-full md:col-span-5 py-2 px-4 flex items-center text-sm gap-x-2`,n),children:[(0,U.jsx)(`div`,{className:`bg-green-600 rounded-full w-4 h-4 p-0.5`,children:(0,U.jsx)(fd,{className:`text-white`,size:12})}),(0,U.jsx)(`span`,{className:`font-semibold`,children:e}),(0,U.jsx)(`div`,{className:`flex-1`,children:t?(0,U.jsx)(hT,{href:t,className:`ml-2 font-medium line-clamp-1 break-all`,children:t}):(0,U.jsx)(bD,{className:`ml-2 h-4 w-8/12`})}),(0,U.jsx)(X,{variant:`secondary`,size:`sm`,onClick:r,children:(0,U.jsxs)(HI,{loading:i===`copied`,alternative:(0,U.jsx)(fd,{size:12,className:`text-green-600`,strokeWidth:3}),className:`flex`,children:[(0,U.jsx)(Pd,{size:16,className:`mr-2`,strokeWidth:1.5}),`Copy URL`]})})]})},YUt=({size:e=24,...t})=>(0,U.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:e,height:e,fill:`none`,viewBox:`0 0 16 16`,...t,children:(0,U.jsx)(`path`,{fill:`currentColor`,d:`m7.47 12.412 3.348-.592.031-.007-1.722-2.049a291.474 291.474 0 0 1-1.723-2.058c0-.01 1.779-4.909 1.789-4.926a788.95 788.95 0 0 1 2.934 5.066l2.95 5.115.023.039-10.948-.001 3.317-.587zM.9 11.788c0-.003.811-1.412 1.803-3.131L4.507 5.53l2.102-1.764C7.765 2.797 8.714 2 8.717 2a.37.37 0 0 1-.033.085L6.4 6.981l-2.24 4.808-1.63.002c-.897.001-1.63 0-1.63-.003z`})}),XUt=({className:e,size:t=24})=>(0,U.jsx)(`svg`,{width:t,height:t,viewBox:`0 0 24 24`,fill:`currentColor`,className:e,children:(0,U.jsx)(`path`,{d:`M.778 1.211c-.424-.006-.772.334-.778.758 0 .045.002.09.01.134l3.263 19.811c.084.499.515.867 1.022.872H19.95c.382.004.708-.271.77-.646l3.27-20.03c.068-.418-.216-.813-.635-.881-.045-.008-.089-.011-.133-.01L.778 1.211zM14.52 15.528H9.522L8.17 8.464h7.561l-1.211 7.064z`})}),ZUt=({className:e,size:t=24})=>(0,U.jsx)(`svg`,{width:t,height:t,viewBox:`0 0 24 24`,fill:`currentColor`,className:e,children:(0,U.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M12 2C6.477 2 2 6.463 2 11.97c0 4.404 2.865 8.14 6.839 9.458.5.092.682-.216.682-.48 0-.236-.008-.864-.013-1.695-2.782.602-3.369-1.337-3.369-1.337-.454-1.151-1.11-1.458-1.11-1.458-.908-.618.069-.606.069-.606 1.003.07 1.531 1.027 1.531 1.027.892 1.524 2.341 1.084 2.91.828.092-.643.35-1.083.636-1.332-2.22-.251-4.555-1.107-4.555-4.927 0-1.088.39-1.979 1.029-2.675-.103-.252-.446-1.266.098-2.638 0 0 .84-.268 2.75 1.022A9.606 9.606 0 0112 6.82c.85.004 1.705.114 2.504.336 1.909-1.29 2.747-1.022 2.747-1.022.546 1.372.202 2.386.1 2.638.64.696 1.028 1.587 1.028 2.675 0 3.83-2.339 4.673-4.566 4.92.359.307.678.915.678 1.846 0 1.332-.012 2.407-.012 2.734 0 .267.18.577.688.48C19.137 20.107 22 16.373 22 11.969 22 6.463 17.522 2 12 2z`})}),QUt=({className:e,size:t=24})=>(0,U.jsx)(`svg`,{width:t,height:t,viewBox:`0 0 24 24`,fill:`currentColor`,className:e,children:(0,U.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M22.65 14.39L12 22.13 1.35 14.39a.84.84 0 0 1-.3-.94l1.22-3.78 2.44-7.51A.42.42 0 0 1 4.82 2a.43.43 0 0 1 .58 0 .42.42 0 0 1 .11.18l2.44 7.49h8.1l2.44-7.51A.42.42 0 0 1 18.6 2a.43.43 0 0 1 .58 0 .42.42 0 0 1 .11.18l2.44 7.51L23 13.45a.84.84 0 0 1-.35.94z`})});function C7({providerName:e,className:t,size:n=24}){switch(e?.toLowerCase()){case`gitlab`:return(0,U.jsx)(QUt,{className:t,size:n});case`bitbucket`:return(0,U.jsx)(XUt,{className:t,size:n});case`azure`:return(0,U.jsx)(YUt,{className:t,size:n});default:return(0,U.jsx)(ZUt,{className:t,size:n})}}var $Ut=({onSuccess:e}={})=>{let t=bt(),{logEvent:n,captureException:r}=S();return Oe({mutationFn:async e=>(await t.fetch(ae.accounts.createCustomDomain({accountName:e.accountName,isAlias:e.isAlias,projectName:e.projectName,hostname:e.hostname,deploymentName:e.deploymentName,stage:e.stage}))).json(),onSuccess:(t,r)=>{n(`account-custom-domain-creation-success`,{account:r.accountName}),e?.(t)},onError:e=>{n(`account-custom-domain-creation-failed`),r(e)}})},eWt=()=>{let e=bt();return Oe({mutationFn:async t=>{await e.fetch(ae.accounts.editCustomDomain({accountName:t.accountName,projectName:t.projectName,hostname:t.hostname,deploymentName:t.deploymentName}))}})},tWt=()=>{let e=bt();return Oe({mutationFn:async t=>{await e.fetch(ae.accounts.deleteCustomDomain({accountName:t.accountName,projectName:t.projectName,hostname:t.hostname,deploymentName:t.deploymentName}))}})},nWt=(e,t)=>ox(je.customDomains(e,t),{extractData:!0}),rWt=(0,H.forwardRef)(({icon:e,label:t,count:n,expanded:r,onToggle:i,children:a},o)=>(0,U.jsxs)(`div`,{className:`overflow-hidden rounded-xl border border-surface-border bg-surface shadow-xs`,children:[(0,U.jsxs)(`button`,{ref:o,type:`button`,onClick:i,"aria-expanded":r,className:`flex w-full items-center justify-between gap-2 px-3.5 py-2 text-sm transition hover:bg-gray-50 dark:hover:bg-neutral-800`,children:[(0,U.jsxs)(`span`,{className:`flex items-center gap-2 font-medium text-gray-800 dark:text-neutral-200`,children:[(0,U.jsx)(e,{size:14,className:`text-gray-500 dark:text-neutral-400`,strokeWidth:2}),t]}),(0,U.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,U.jsx)(rT,{variant:`secondary`,size:`sm`,className:`px-1.5 font-mono`,children:n??0}),r?(0,U.jsx)(hd,{size:14,className:`text-gray-500 dark:text-neutral-400`}):(0,U.jsx)(pd,{size:14,className:`text-gray-400 dark:text-neutral-500`})]})]}),r?(0,U.jsx)(`div`,{className:`border-t border-gray-100 dark:border-neutral-800`,children:a}):null]}));rWt.displayName=`ExpandableNode`;var iWt=({selected:e,onChange:t,options:n,listLabel:r,className:i,classNameOptions:a,testId:o,placeholder:s,disabled:c,isLoadingData:l=!1})=>{let u=(0,H.useId)(),d=n.filter(e=>String(e.value)!==``);return(0,U.jsxs)(CY,{value:e?String(e.value):``,onValueChange:e=>{let n=d.find(t=>String(t.value)===e);n&&t(n)},disabled:c,children:[r?(0,U.jsx)(`span`,{id:u,className:`mb-1 block text-sm font-medium text-foreground`,children:r}):null,(0,U.jsx)(TY,{"data-test":o,className:W(`w-full`,i),"aria-labelledby":r?u:void 0,"aria-label":r?void 0:s,children:l&&e?.icon?(0,U.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,U.jsx)(WI,{className:`h-4 w-4`,borderPositionAndSize:`border-l-2`}),(0,U.jsx)(`span`,{className:`truncate`,children:e.label})]}):(0,U.jsx)(wY,{placeholder:s})}),(0,U.jsx)(EY,{align:`start`,className:W(`max-h-72`,a),children:d.map((e,t)=>(0,U.jsx)(DY,{"data-test":`${o}-${t}`,value:String(e.value),disabled:e.disabled??!1,description:e.description,children:e.icon?(0,U.jsxs)(`span`,{className:`flex items-center gap-2`,children:[e.icon,e.label]}):e.label},`${t}-${e.value}`))})]})};function aWt(e,t=500){let[n,r]=(0,H.useState)(e);return(0,H.useEffect)(()=>{let n=setTimeout(()=>r(e),t);return()=>{clearTimeout(n)}},[e,t]),n}var oWt=({projects:e,isLoadingProjects:t,selectedProject:n,onProjectChange:r})=>(0,U.jsx)(iWt,{testId:`project-selector`,placeholder:`Select Project`,options:(e||[]).map(e=>({label:e.name,value:e.id,icon:(0,U.jsx)(nf,{className:`mr-1.5`,size:16})})),selected:n,onChange:r,className:`flex-1 items-center w-full h-9`,isLoadingData:t});function sWt({title:e,className:t}){return(0,U.jsx)(`div`,{className:W(`text-2xl font-medium`,t),children:e})}var cWt=({showHeader:e})=>(0,U.jsxs)(U.Fragment,{children:[e&&(0,U.jsx)(sWt,{title:`Source Control Settings`}),(0,U.jsxs)(`div`,{className:`w-full sm:max-w-md md:max-w-2xl lg:max-w-5xl animate-pulse`,children:[e&&(0,U.jsx)(`div`,{className:`h-2.5 bg-gray-200 rounded-full dark:bg-gray-700 mb-9 mt-7 w-[650px]`}),(0,U.jsxs)(`div`,{className:`flex flex-col md:flex-row lg:flex-row sm:gap-4`,children:[(0,U.jsx)(`div`,{className:`inline-block w-full max-w-sm md:max-w-xs mr-4 h-10 bg-gray-200 rounded-md dark:bg-gray-700`}),(0,U.jsx)(`div`,{className:`inline-block w-full max-w-sm md:max-w-xs mr-4 h-10 bg-gray-200 rounded-md dark:bg-gray-700`}),(0,U.jsx)(`div`,{className:`inline-block w-full max-w-sm md:max-w-xs right-0 h-10 bg-gray-200 rounded-md dark:bg-gray-700`})]}),(0,U.jsx)(`div`,{className:`h-5 mt-5 mb-3`,children:(0,U.jsx)(`div`,{className:`h-2.5 bg-gray-200 rounded-full dark:bg-gray-700 mb-9 mt-7 w-[650px]`})}),(0,U.jsx)(`div`,{className:`mt-5 h-96 relative bg-gray-200 rounded-md dark:bg-gray-700`})]})]}),w7=`GITLAB`,T7=`GITHUB`,E7=`BITBUCKET`,D7=`AZURE`,lWt=({installUrl:e,selectedOrg:t,projectName:n,className:r,provider:i=T7,disabled:a,repoDescription:o=`Zuplo API Gateway`,onContinue:s})=>{let{logEvent:c}=S(),[l,u]=(0,H.useState)(!1),d=e=>{c(`source-control-create-repo-continue-clicked`,{sourceControlNamespace:e??`none`,sourceControlProvider:i,project:n}),s?.();let t;switch(i){case D7:t=e?`https://dev.azure.com/${e}/_createproject`:`https://dev.azure.com/`;break;case w7:t=e?`https://gitlab.com/projects/new?namespace_id=${e}`:`https://gitlab.com/projects/new`;break;case E7:t=e?`https://bitbucket.org/repo/create?owner=${e}`:`https://bitbucket.org/repo/create`;break;default:{let r=encodeURIComponent(o);t=e===null?`https://github.com/new?name=${n}&description=${r}`:`https://github.com/organizations/${e}/repositories/new?owner=${e}&name=${n}&description=${r}`;break}}window.open(t),u(!1)};return(0,U.jsxs)(ow,{open:l,onOpenChange:u,children:[(0,U.jsx)(sw,{asChild:!0,children:(0,U.jsx)(X,{className:r,disabled:a,children:`Create new repository`})}),(0,U.jsxs)(lw,{className:`max-w-xl! w-full`,children:[(0,U.jsxs)(uw,{children:[(0,U.jsx)(fw,{children:`Create new repository`}),(0,U.jsx)(pw,{})]}),(0,U.jsxs)(`div`,{className:`space-y-4`,children:[(0,U.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`We're about to help you create a new repository in`,` `,lx(i),`.`]}),(0,U.jsxs)(`div`,{className:`rounded-md bg-muted/50 p-3 text-sm space-y-2 border`,children:[(0,U.jsx)(`p`,{className:`font-medium`,children:`What you'll need to do:`}),i===`AZURE`&&(0,U.jsxs)(`ul`,{className:`list-disc list-inside space-y-1 text-muted-foreground`,children:[(0,U.jsx)(`li`,{children:`Create a project and repository in Azure DevOps`}),(0,U.jsx)(`li`,{children:`Return to Zuplo to connect it`})]}),i===`GITHUB`&&(0,U.jsxs)(`ul`,{className:`list-disc list-inside space-y-1 text-muted-foreground`,children:[(0,U.jsx)(`li`,{children:`Create your new repository on GitHub`}),(0,U.jsxs)(`li`,{children:[`Ensure the`,` `,(0,U.jsx)(hT,{href:e,children:`Zuplo GitHub App`}),` `,`has access to your new repo`]}),(0,U.jsx)(`li`,{children:`Return to Zuplo to see and connect it`})]}),(i===`GITLAB`||i===`BITBUCKET`)&&(0,U.jsxs)(`ul`,{className:`list-disc list-inside space-y-1 text-muted-foreground`,children:[(0,U.jsxs)(`li`,{children:[`Create your repository in `,lx(i)]}),(0,U.jsx)(`li`,{children:`Return to Zuplo to connect it`})]})]}),(0,U.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Need help?`,` `,(0,U.jsx)(hT,{href:`https://zuplo.com/docs/articles/source-control`,children:`View our troubleshooting guide`})]})]}),(0,U.jsx)(dw,{children:(0,U.jsxs)(X,{"data-test":`navigate-new-${i.toLowerCase()}-repo`,onClick:()=>d(t),children:[`Continue to `,lx(i)]})})]})]})},uWt=e=>e instanceof s&&e.type===`https://zup.fail/github-integration-monorepo-detected`,O7=`The GitHub integration connects a repository with a single Zuplo project at its root, so it can't connect this repository. You can still deploy it using the Zuplo CLI in your CI/CD pipeline.`,k7={linkAnyway:{title:`Link existing Zuplo project`,description:`Looks like Zuplo was set up here before, so we'll link your project to the existing repository instead of pushing a new one. Nothing is pushed or pulled automatically; you can commit and push from the portal whenever you're ready.`,actionLabel:`Link project`},monorepo:{title:`This looks like a monorepo`,description:O7,actionLabel:`Manual setup`},nonEmpty:{title:`This repository isn't empty`,description:O7,actionLabel:`Manual setup`},pullRequestOpened:{title:`We opened a pull request`,description:`Your default branch requires changes to go through a pull request, so we pushed your project to a setup branch and opened one. Merge the pull request to finish setup and land your project on the default branch.`,actionLabel:`Open pull request`}},A7=`https://zuplo.com/docs/articles/monorepo-deployment`,dWt=new Set([`https://zup.fail/github-integration-invalid-repo`,`https://zup.fail/github-integration-package-json-missing-repo`,`https://zup.fail/create-project-invalid-git-repo`,`https://zup.fail/azure-integration-invalid-repo`]),fWt=e=>uWt(e)?`monorepo`:e instanceof s&&typeof e.type==`string`&&dWt.has(e.type)?`invalidRepo`:`other`,pWt=({accountName:e,projectName:t,orgName:n,repositoryUrl:r,provider:i,handleErrors:a})=>{let{logEvent:o,captureException:s}=S(),[c,l]=(0,H.useState)(null),[u,d]=(0,H.useState)(null),f=ROe(e,t),p={account:e,project:t,sourceControlNamespace:n},m=async(e,t,n)=>{try{if(e===null)throw Error(`Invalid ${lx(i)} account/organization selected, please try again.`);if(t===null)throw Error(`Invalid repository selected, please try again.`);let r=await(await f.mutateAsync({orgName:e,repositoryURL:t,defaultBranch:`main`,forceConnect:n})).json();r.connected?r.pullRequestUrl?(d(r.pullRequestUrl),o(`source-control-repo-connected-via-pr`,p),l(`pullRequestOpened`)):(o(`source-control-repo-connected`,p),l(null)):r.emptyRepository===!1&&(a(``),o(`source-control-existing-repo-confirm-shown`,p),l(`linkAnyway`))}catch(e){let t=ux(e);switch(fWt(e)){case`monorepo`:a(``),o(`source-control-monorepo-detected`,p),l(`monorepo`);break;case`invalidRepo`:a(``),o(`source-control-nonempty-repo-detected`,p),l(`nonEmpty`);break;default:s(e),o(`source-control-repo-connection-failed`,{...p,errorMessage:t,...Fme(e)}),a(t),l(null)}}};return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(yL,{open:c===`linkAnyway`,onOpenChange:e=>{e||(o(`source-control-existing-repo-confirm-cancelled`,p),l(null))},title:k7.linkAnyway.title,description:(0,U.jsxs)(U.Fragment,{children:[k7.linkAnyway.description,` `,(0,U.jsx)(hT,{href:`https://zuplo.com/docs/articles/source-control`,children:`Learn more about source control`})]}),actionLabel:k7.linkAnyway.actionLabel,isPending:f.isPending,onConfirm:()=>{o(`source-control-existing-repo-confirm-confirmed`,p),m(n,r,!0)}}),(0,U.jsx)(yL,{open:c===`monorepo`,onOpenChange:e=>{e||(o(`source-control-monorepo-cancelled`,p),l(null))},title:k7.monorepo.title,description:(0,U.jsxs)(U.Fragment,{children:[k7.monorepo.description,` `,(0,U.jsx)(hT,{href:A7,children:`Learn how to deploy from a monorepo`})]}),actionLabel:k7.monorepo.actionLabel,onConfirm:()=>{o(`source-control-monorepo-manual-setup-clicked`,p),l(null),window.open(A7,`_blank`,`noopener,noreferrer`)}}),(0,U.jsx)(yL,{open:c===`nonEmpty`,onOpenChange:e=>{e||(o(`source-control-nonempty-repo-cancelled`,p),l(null))},title:k7.nonEmpty.title,description:(0,U.jsxs)(U.Fragment,{children:[k7.nonEmpty.description,` `,(0,U.jsx)(hT,{href:A7,children:`Learn how to deploy from a monorepo`})]}),actionLabel:k7.nonEmpty.actionLabel,onConfirm:()=>{o(`source-control-nonempty-repo-manual-setup-clicked`,p),l(null),window.open(A7,`_blank`,`noopener,noreferrer`)}}),(0,U.jsx)(yL,{open:c===`pullRequestOpened`,onOpenChange:e=>{e||l(null)},title:k7.pullRequestOpened.title,description:k7.pullRequestOpened.description,actionLabel:k7.pullRequestOpened.actionLabel,onConfirm:()=>{o(`source-control-pr-opened-view-clicked`,p),l(null),u&&window.open(u,`_blank`,`noopener,noreferrer`)}}),(0,U.jsx)(X,{"data-test":`connect-repo-button`,variant:`outline`,size:`sm`,onClick:()=>{o(`source-control-connect-button-clicked`,{...p,sourceControlProvider:i}),m(n,r,!1)},children:(0,U.jsx)(HI,{loading:f.isPending,children:`Connect`})})]})},mWt=({repositories:e,account:t,project:n,selectedNamespace:r,provider:i,maxItems:a=5,onConnectError:o,newRepoIds:s})=>{let c=i===`azure`;return(0,U.jsx)(U.Fragment,{children:e.slice(0,a).map((e,a)=>(0,U.jsxs)(`div`,{className:(0,zI.default)(`flex flex-row items-center justify-center h-16 border-border px-5 lg:gap-5 gap-2 transition-colors duration-700`,{"border-t":a!==0},{"bg-emerald-50 dark:bg-emerald-950/30":s?.has(e.id)}),children:[(0,U.jsxs)(`div`,{className:`flex text-sm flex-1 gap-1`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col flex-1`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`span`,{className:`font-medium line-clamp-1`,children:e.name}),s?.has(e.id)&&(0,U.jsx)(`span`,{className:`rounded bg-emerald-100 px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-emerald-700 dark:bg-emerald-900/40 dark:text-emerald-300`,children:`New`})]}),c&&e.metadata?.projectName?(0,U.jsxs)(`span`,{className:`text-muted-foreground text-xs`,children:[`Project: `,e.metadata.projectName]}):(0,U.jsxs)(`span`,{className:`text-muted-foreground hidden md:inline-block lg:inline-block`,children:[`Updated on`,` `,new Date(e.updatedAt).toLocaleDateString([],{day:`numeric`,month:`short`,year:`numeric`})]})]}),e.private&&(0,U.jsxs)(`div`,{className:`flex justify-center items-center text-muted-foreground gap-1`,children:[(0,U.jsx)(yf,{className:`h-4 w-4`,"aria-hidden":`false`,"aria-label":`Private Git repository`}),(0,U.jsx)(`span`,{className:`hidden lg:block`,children:`Private Repository`})]})]}),(0,U.jsx)(pWt,{accountName:t.name,projectName:n.name,orgName:r?.label||``,repositoryUrl:e.url,provider:i,handleErrors:o})]},e.id))})},hWt={[T7]:{name:`GitHub`,icon:(e=20)=>(0,U.jsx)(ZUt,{className:`mr-1.5`,size:e}),supportsProjects:!1,placeholder:{namespace:`Select GitHub Account`,search:`Search repositories`},messages:{noRepoAtHand:`No repository at hand? We can help you create a new one.`,selectAccount:`Make sure to select a Git account or organization on the top left.`,grantAccess:`Make sure to grant Zuplo access to the Git account & its repositories you'd like to connect to.`}},[D7]:{name:`Azure DevOps`,icon:(e=20)=>(0,U.jsx)(YUt,{className:`mr-1.5`,size:e}),supportsProjects:!0,placeholder:{namespace:`Select Organization`,project:`Select Project`,search:`Search repositories`},messages:{noRepoInProject:`No repository in this project? Create a new one.`,noRepoAtHand:`No project at hand? We can help you create one.`,selectAccount:`Please select a project to view repositories.`,grantAccess:`No repositories in this project yet.`}},[w7]:{name:`GitLab`,icon:(e=20)=>(0,U.jsx)(of,{className:`mr-1.5`,size:e}),supportsProjects:!1,placeholder:{namespace:`Select GitLab Group`,search:`Search repositories`},messages:{noRepoAtHand:`No repository at hand? Create a new one.`,selectAccount:`Select a GitLab group or namespace.`,grantAccess:`Connect your GitLab account to see repositories.`}},[E7]:{name:`Bitbucket`,icon:(e=20)=>(0,U.jsx)(sd,{className:`mr-1.5`,size:e}),supportsProjects:!1,placeholder:{namespace:`Select Bitbucket Project`,search:`Search repositories`},messages:{noRepoAtHand:`No repository at hand? Create a new one.`,selectAccount:`Select a Bitbucket project.`,grantAccess:`Connect your Bitbucket account to see repositories.`}}},gWt=e=>hWt[e]||hWt.GITHUB,j7=({account:e,project:t})=>{let{logEvent:n}=S(),r=LOe(e.name),[i,a]=(0,H.useState)(t.name),[o,s]=(0,H.useState)(!1);return{newRepoName:i,setNewRepoName:a,showCreateRepoForm:o,setShowCreateRepoForm:s,createRepoMutation:r,isCreating:r.isPending,handleCreateRepo:async({namespace:o,repoName:c,otherParams:l})=>{let u=c||i||t.name;await r.mutateAsync({projectName:t.name,orgName:o,repositoryName:u,defaultBranch:`main`,otherParams:l}),n(`source-control-repo-created`,{sourceControlRepository:u,sourceControlNamespace:o,account:e.name,project:t.name}),a(``),s(!1)},reset:()=>{s(!1),a(t.name)},transformRepoToRepository:(e,t)=>({id:e.url,url:e.url,provider:t,name:e.name,slug:e.name,defaultBranch:e.defaultBranch,namespace:e.organization,owner:{id:0,name:e.organization},private:!0,updatedAt:new Date().toISOString(),ownerType:e.isUserRepo?`user`:`team`,metadata:e.metadata}),logEvent:n}},_Wt=e=>{let{account:t,project:n,sourceControlConfig:r,selectedNamespace:i,searchTerm:a}=e,o=j7(e),[s,c]=(0,H.useState)(null),l=r.provider===D7,{data:u,isLoading:d}=Mgt(t.name,i?.value||``,{enabled:l&&!!i}),{data:f,isLoading:p}=Agt(t.name),m=o.transformRepoToRepository;return{repositories:(0,H.useMemo)(()=>!f?.data||!i||!s?[]:(f.data[i.label]||[]).filter(e=>e.metadata?.projectName===s.label).filter(e=>!a||e.name.toLowerCase().includes(a.toLowerCase())).map(e=>m(e,`azure`)),[f,i,s,a,m]),isLoadingRepos:p&&!!s,projects:u?.data,selectedProject:s,isLoadingProjects:d,onProjectChange:e=>{c(e),o.logEvent(`source-control-project-selected`,{account:t.name,project:n.name,sourceControlProvider:r.provider})},reset:()=>{c(null),o.reset()}}},vWt=e=>{let{account:t,sourceControlConfig:n,selectedNamespace:r,searchTerm:i}=e,a=j7(e),o=n.provider===E7,{data:s,isLoading:c,refetch:l}=Ngt(t.name,r?r.value:``,i,{enabled:o&&r!==null});return{repositories:s?.repositories||[],isLoadingRepos:c,onCreateRepo:async()=>{if(!r)throw Error(`Please select a project`);await a.handleCreateRepo({namespace:r.value}),l()},reset:a.reset,showCreateRepoForm:a.showCreateRepoForm,setShowCreateRepoForm:a.setShowCreateRepoForm,newRepoName:a.newRepoName,setNewRepoName:a.setNewRepoName,isCreating:a.isCreating}},yWt=e=>{let{account:t,sourceControlConfig:n,selectedNamespace:r,searchTerm:i}=e,a=j7(e),o=n.provider===T7,{data:s,isLoading:c}=Ngt(t.name,r?r.value:``,i,{enabled:o&&r!==null});return{...a,repositories:s?.repositories||[],isLoadingRepos:c,reset:a.reset}},bWt=e=>{let{account:t,selectedNamespace:n,searchTerm:r}=e,i=j7(e),{data:a}=jgt(t.name),{data:o,isLoading:s,refetch:c}=Agt(t.name),l=i.transformRepoToRepository;return{repositories:(0,H.useMemo)(()=>{if(!o?.data||!n)return[];let e=a?.find(e=>e.installationId===Number(n.value))?.slug||n.label;return(o.data[e]||[]).filter(e=>!r||e.name.toLowerCase().includes(r.toLowerCase())).map(e=>l(e,`gitlab`))},[o,n,r,a,l]),isLoadingRepos:s,onCreateRepo:async()=>{if(!n)throw Error(`Please select a namespace`);await i.handleCreateRepo({namespace:n.value}),c()},reset:i.reset,showCreateRepoForm:i.showCreateRepoForm,setShowCreateRepoForm:i.setShowCreateRepoForm,newRepoName:i.newRepoName,setNewRepoName:i.setNewRepoName,isCreating:i.isCreating}},xWt=250,SWt=({account:e,project:t,sourceControlConfig:n})=>{let{logEvent:r}=S(),i=n.provider,a=gWt(i),[o,c]=(0,H.useState)(``),[l,u]=(0,H.useState)(null),[d,f]=(0,H.useState)(``),p=aWt(d,xWt),m=(0,H.useRef)(new Set),h=(0,H.useRef)(null),g=(0,H.useRef)(!1),[_,v]=(0,H.useState)(new Set),[y,b]=(0,H.useState)(!1),{data:x,isLoading:C,isFetching:w,error:T}=jgt(e.name),E=T instanceof s&&T.type===gt.type,D={account:e,project:t,sourceControlConfig:n,selectedNamespace:l,searchTerm:p},O=_Wt(D),k=bWt(D),A=vWt(D),j=yWt(D),M=(()=>{switch(i){case D7:return O;case w7:return k;case E7:return A;default:return j}})();(0,H.useEffect)(()=>{if(x&&x.length>0){let e=x[0];u({label:e.name,value:i===`AZURE`?e.slug:e.installationId.toString(),icon:a.icon(20)})}},[x,i,a]),(0,H.useEffect)(()=>{if(p!==``||M.isLoadingRepos)return;let e=l?.value?.toString()??null,t=M.repositories.map(e=>e.id);if(h.current!==e){h.current=e,m.current=new Set(t),v(new Set),b(!1);return}let n=t.filter(e=>!m.current.has(e));if(n.length>0){for(let e of n)m.current.add(e);g.current=!1,b(!1),v(new Set(n))}else g.current&&(g.current=!1,b(!0))},[M.repositories,M.isLoadingRepos,p,l]);let N=a=>{if(a.value===`add-github-account`){r(`source-control-add-account-selected`,{sourceControlNamespace:a.value,account:e.name,project:t.name,sourceControlProvider:i}),n.installUrl&&(g.current=!0,window.open(n.installUrl));return}r(`source-control-namespace-selected`,{sourceControlNamespace:a.value,sourceControlProvider:i,account:e.name,project:t.name}),c(``),u(a),M.reset()},P=[];x?.forEach(e=>{P.push({label:e.name,value:String(i===`AZURE`?e.slug:e.installationId),icon:a.icon(20)})}),i===`GITHUB`&&P.push({label:`Add GitHub Account`,value:`add-github-account`,icon:(0,U.jsx)(Mf,{className:`mr-1.5`,size:16})});let F=()=>a.supportsProjects&&M.selectedProject?M.repositories.length>0?`Showing ${M.repositories.length} repositories from project: ${M.selectedProject.label}`:a.messages.grantAccess:!a.supportsProjects&&M.repositories.length>0?`Showing ${Math.min(M.repositories.length,5)} repositories`:a.supportsProjects&&!M.selectedProject?a.messages.selectAccount:`Select an account to view repositories`,I=()=>(0,U.jsx)(lWt,{installUrl:n.installUrl??``,selectedOrg:l?.label??``,projectName:t.name,provider:i,repoDescription:xO(t)?`Zuplo AI Gateway`:void 0,className:`w-full md:w-auto`,onContinue:()=>{g.current=!0}}),L=C||M.isLoadingRepos,R=!a.supportsProjects||M.selectedProject;return(0,U.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[E?(0,U.jsxs)(Ub,{variant:`destructive`,children:[(0,U.jsx)(Wb,{children:`Reconnect GitHub`}),(0,U.jsxs)(Gb,{children:[(0,U.jsx)(`p`,{children:`Your saved GitHub credentials are no longer valid. Revoke the connection from your profile, then connect GitHub again.`}),(0,U.jsx)(X,{asChild:!0,variant:`outline`,size:`sm`,className:`mt-2`,children:(0,U.jsx)(Ns,{to:rx.Profile,children:`Go to profile`})})]})]}):(0,U.jsx)(SA,{error:T}),(0,U.jsx)(SA,{error:o}),(0,U.jsxs)(`div`,{className:`mt-2 flex flex-col gap-3 rounded-lg border p-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,U.jsxs)(`div`,{className:`text-sm`,children:[(0,U.jsx)(`p`,{className:`font-medium`,children:`Start fresh with a new repository`}),(0,U.jsx)(`p`,{className:`text-muted-foreground`,children:`We'll set up a ready-to-deploy Zuplo project so GitOps works right away.`})]}),I()]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-3 my-3`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-muted-foreground`,children:[(0,U.jsx)(`span`,{className:`h-px flex-1 bg-border`}),(0,U.jsx)(`span`,{children:`Or connect an existing repository`}),(0,U.jsx)(`span`,{className:`h-px flex-1 bg-border`})]}),(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`We'll link this project to your repo. You'll push and pull changes manually.`})]}),L&&l===null&&(0,U.jsx)(cWt,{showHeader:!1}),!C&&(0,U.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,U.jsx)(iWt,{testId:`namespace-selector`,placeholder:a.placeholder.namespace,options:P,selected:l,onChange:N,className:`flex-1 items-center h-9`,isLoadingData:w}),i===`AZURE`&&l&&(0,U.jsx)(oWt,{projects:M.projects,isLoadingProjects:M.isLoadingProjects||!1,selectedProject:M.selectedProject||null,onProjectChange:M.onProjectChange||(()=>{})}),(0,U.jsxs)(iX,{className:`flex-2 w-full`,children:[(0,U.jsx)(oX,{value:d,onChange:e=>f(e.target.value),placeholder:a.placeholder.search}),(0,U.jsx)(aX,{align:`inline-start`,children:(0,U.jsx)(zf,{className:`opacity-75`})}),d&&(0,U.jsx)(aX,{align:`inline-end`,children:(0,U.jsx)(X,{variant:`ghost`,size:`icon-sm`,onClick:()=>f(``),children:(0,U.jsx)(pp,{})})})]})]}),(0,U.jsx)(CA,{className:`flex flex-col`,children:M.isLoadingRepos&&R?(0,U.jsxs)(`div`,{className:`flex flex-row items-center p-2 justify-center align-middle h-80`,children:[(0,U.jsx)(WI,{className:`w-4 h-4 mr-2`,borderPositionAndSize:`border-l-2`}),(0,U.jsx)(`span`,{children:`Loading repositories...`})]}):R&&M.repositories.length>0?(0,U.jsx)(mWt,{repositories:M.repositories,account:e,project:t,selectedNamespace:l,provider:i,onConnectError:c,newRepoIds:_}):R?(0,U.jsxs)(`div`,{className:`flex flex-col text-sm text-center gap-2 items-center justify-center h-80`,children:[(0,U.jsx)(`h2`,{className:`text-base`,children:`No Results Found`}),(0,U.jsx)(`p`,{children:d?`Your search for "${d}" did not return any results.`:a.messages.grantAccess})]}):(0,U.jsx)(`div`,{className:`flex items-center justify-center h-80`,children:(0,U.jsx)(`p`,{children:a.messages.selectAccount})})}),i===`GITHUB`&&n.installUrl&&(y?(0,U.jsxs)(Ub,{variant:`info`,children:[(0,U.jsx)(Wb,{children:`Don't see your repository?`}),(0,U.jsxs)(Gb,{children:[`Check that you selected the right account above, and that you granted the Zuplo GitHub App access to that repository.`,` `,(0,U.jsx)(hT,{href:n.installUrl,onClick:()=>{g.current=!0},children:`Manage repository access →`})]})]}):(0,U.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-dashed p-3 text-sm sm:flex-row sm:items-center sm:justify-between`,children:[(0,U.jsxs)(`p`,{children:[(0,U.jsx)(`span`,{className:`font-medium`,children:`Missing repositories? `}),(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:`Zuplo only shows repositories you've granted the Zuplo GitHub App access to.`})]}),(0,U.jsx)(hT,{href:n.installUrl,className:`whitespace-nowrap`,onClick:()=>{g.current=!0},children:`Manage repository access →`})]})),(0,U.jsxs)(`div`,{className:`flex whitespace-pre-line text-gray-500 text-sm justify-between gap-4`,children:[(0,U.jsx)(`span`,{children:F()}),(i===`GITLAB`||i===`BITBUCKET`)&&n.installUrl&&(0,U.jsxs)(hT,{href:n.installUrl,className:`whitespace-pre`,children:[`Adjust `,a.name,` Permissions →`]})]})]})},CWt=({provider:e,url:t,org:n,name:r,children:i})=>(0,U.jsx)(CA,{className:`flex gap-2 flex-col`,offset:`md`,children:(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(C7,{providerName:e}),(0,U.jsx)(`div`,{className:`flex flex-col flex-1`,children:(0,U.jsxs)(`a`,{className:`text-sm font-semibold hover:text-zuplo-pink-hover underline flex gap-1 items-center`,href:t,target:`_blank`,rel:`noopener noreferrer`,children:[n,`/`,r,(0,U.jsx)(Vd,{className:`h-4 w-4`})]})}),i]})}),wWt=({account:e,project:t})=>{let{logEvent:n}=S(),r=Op([`account`,`project`]);if(!t.sourceRepoUrl)throw Error(`No sourceRepoUrl on project '${r.account.name}'`);let i=t.sourceRepoUrl.replace(`.git`,``),a,o,s=!1;try{s=new URL(t.sourceRepoUrl).hostname===`dev.azure.com`}catch{s=!1}if(s){let e=t.sourceRepoUrl.match(/^https:\/\/dev\.azure\.com\/([^/]+)\/([^/]+)\/_git\/([^/]+)/);if(e){a=e[1];let t=e[2],n=e[3].replace(`.git`,``);a=`${e[1]}/${t}`,o=n}else{let e=t.sourceRepoUrl.split(`/`);a=e[e.length-2],o=e[e.length-1]}}else{let e=t.sourceRepoUrl.split(`/`);a=e[e.length-2],o=e[e.length-1]}let c=zOe(e.name,t.name),l=async()=>{await c.mutateAsync(),n(`source-control-repo-disconnected`,{account:r.account.name,project:r.project.name})};return(0,U.jsx)(CWt,{org:a,name:o,url:i,provider:t.sourceControlProvider.toLowerCase(),children:(0,U.jsx)(X,{"data-test":`disconnect-repo-button`,onClick:l,variant:`secondary`,className:`self-end`,disabled:c.isPending,children:(0,U.jsx)(HI,{className:`flex items-center gap-1`,loading:c.isPending,children:`Disconnect`})})})},TWt=({provider:e,onClose:t})=>{if(!e)return null;let n=lx(e);return(0,U.jsx)(ow,{open:!!e,onOpenChange:e=>!e&&t(),children:(0,U.jsxs)(lw,{children:[(0,U.jsxs)(uw,{children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,U.jsx)(C7,{providerName:e.toLowerCase(),size:28}),(0,U.jsxs)(fw,{children:[n,` Integration`]})]}),(0,U.jsxs)(pw,{className:`pt-2`,children:[n,` source control integration is available on Enterprise plans. Contact our sales team or book a demo to learn more about connecting your `,n,` repositories to Zuplo.`]})]}),(0,U.jsxs)(dw,{className:`mt-2`,children:[(0,U.jsx)(X,{variant:`outline`,asChild:!0,children:(0,U.jsx)(hT,{href:`mailto:${nx}?subject=${encodeURIComponent(`${n} Source Control Integration`)}`,variant:`ghost`,children:`Contact Sales`})}),(0,U.jsx)(X,{asChild:!0,children:(0,U.jsx)(hT,{href:tx,variant:`ghost`,children:`Book a Demo`})})]})]})})},M7=`sourceControlConnect`,EWt=`sourceControlConnectError`,DWt=`sourceControlConnectSuccess`,OWt=3e5,kWt=1e3;function AWt(e){if(e.key!==`sourceControlConnectSuccess`&&e.key!==`sourceControlConnectError`||!e.newValue)return null;try{return JSON.parse(e.newValue)}catch{return null}}var jWt=()=>{let{logEvent:e}=S(),{error:t}=Ep(),n=At(),[r,i]=(0,H.useState)(!1),a=(0,H.useRef)(null),o=(0,H.useRef)(null);return(0,H.useEffect)(()=>()=>a.current?.(),[]),{connect:(r,s,c)=>{let{id:l,provider:u,clientId:d,scopes:f,redirectUri:p,providerUrl:m}=s;e(`source-control-provider-clicked`,{provider:u});let h=`${r}::${l}::${crypto.randomUUID()}`;localStorage.removeItem(M7),localStorage.removeItem(EWt),localStorage.removeItem(DWt),localStorage.setItem(M7,h),i(!0);let g;if(u===`GITHUB`?g=f===``?`https://github.com/login/oauth/authorize?client_id=${d}`:`https://github.com/login/oauth/authorize?client_id=${d}&scope=${f}`:u===`GITLAB`?g=`${m}/oauth/authorize?client_id=${d}&redirect_uri=${p}&response_type=code&scope=${f}`:u===`BITBUCKET`?g=`${m}/site/oauth2/authorize?client_id=${d}&response_type=code`:u===`AZURE`&&(g=`https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=${d}&redirect_uri=${encodeURIComponent(p)}&response_type=code&response_mode=query&scope=${encodeURIComponent(f)}`),!g){i(!1),localStorage.removeItem(M7);return}let _=window.open(g),v=!1,y,b,x;function S(i){let a=AWt(i);if(!(!a||a.connect!==h)){if(i.key===`sourceControlConnectSuccess`){w(()=>{e(`source-control-access-granted`,{account:r,sourceControlProvider:u}),n.invalidateQueries({queryKey:[je.accountsSourceControlConfigurations().url],exact:!1})});return}i.key===`sourceControlConnectError`&&w(()=>{t(a.message??``),c?.onFailure?.()})}}function C(){window.removeEventListener(`storage`,S),y!==void 0&&clearInterval(y),b!==void 0&&clearTimeout(b),x!==void 0&&clearTimeout(x),localStorage.removeItem(M7),localStorage.removeItem(EWt),localStorage.removeItem(DWt),a.current=null,o.current=null}function w(e){v||(v=!0,i(!1),C(),e?.())}if(window.addEventListener(`storage`,S,!1),!_){w(()=>{t(`Couldn't open the ${lx(u)} sign-in window. Your browser may be blocking pop-ups; allow them for this site and try again.`),e(`source-control-connect-popup-blocked`,{account:r,sourceControlProvider:u}),c?.onFailure?.()});return}y=setInterval(()=>{let n=!1;try{n=_.closed}catch{return}n&&(y!==void 0&&clearInterval(y),b=setTimeout(()=>{w(()=>{t(`We didn't get a response from the ${lx(u)} sign-in window. Please try again.`),e(`source-control-connect-abandoned`,{account:r,sourceControlProvider:u}),c?.onFailure?.()})},kWt))},500),x=setTimeout(()=>{w(()=>{t(`Connecting to ${lx(u)} timed out. Please try again.`),e(`source-control-connect-timeout`,{account:r,sourceControlProvider:u}),c?.onFailure?.()})},OWt),a.current=C,o.current={account:r,provider:u}},isConnecting:r,cancel:()=>{let t=o.current;t&&e(`source-control-connect-abandoned`,{account:t.account,sourceControlProvider:t.provider}),a.current?.(),i(!1)}}},MWt=({accountName:e,sourceControlConfig:t})=>{let{connect:n,isConnecting:r,cancel:i}=jWt(),{provider:a}=t;return(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(X,{variant:`outline`,className:`gap-2`,disabled:r,onClick:()=>n(e,t),children:(0,U.jsx)(HI,{loading:r,children:(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(C7,{providerName:a}),(0,U.jsx)(`span`,{children:`Connect to ${lx(a)}`})]})})}),r&&(0,U.jsx)(X,{variant:`ghost`,size:`sm`,onClick:i,children:`Cancel`})]})},NWt=[{key:w7,label:`GitLab`},{key:E7,label:`Bitbucket`}],PWt=({account:e,project:t,sourceControlConfig:n})=>{let{logEvent:r}=S(),[i,a]=(0,H.useState)(null);if(n?.userHasCredentials&&t.sourceRepoUrl)return(0,U.jsx)(wWt,{account:e,project:t});if(n&&!t.sourceRepoUrl&&n.userHasCredentials)return(0,U.jsx)(SWt,{account:e,project:t,sourceControlConfig:n});let o=n?lx(n.provider):null;return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(CA,{offset:`md`,className:`flex flex-col gap-4`,children:[(0,U.jsxs)(`div`,{className:`text-sm whitespace-pre-line text-gray-500`,children:[n&&t.sourceRepoUrl&&(0,U.jsxs)(`p`,{className:`mb-3`,children:[`This project is currently associated with a `,o,` `,`repository but you have not connected to your `,o,` `,`account.`]}),(0,U.jsx)(`p`,{children:`Connect to a source control provider to enable source control on your project.`})]}),(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[n&&(0,U.jsx)(MWt,{accountName:e.name,sourceControlConfig:n}),NWt.map(({key:e,label:t})=>(0,U.jsxs)(X,{variant:`outline`,className:`gap-2`,onClick:()=>{r(`source-control-provider-clicked`,{provider:e}),a(e)},children:[(0,U.jsx)(C7,{providerName:e.toLowerCase(),size:20}),(0,U.jsxs)(`span`,{children:[`Connect to `,t]})]},e))]})]}),(0,U.jsx)(TWt,{provider:i,onClose:()=>a(null)})]})},FWt=()=>ox(je.accountsSourceControlConfigurations()),IWt=()=>{let{account:e,project:t}=Op([`account`,`project`]),{logEvent:n}=S();return(0,U.jsxs)(`div`,{className:`flex flex-col space-y-4`,children:[(0,U.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Support`}),(0,U.jsx)(CA,{offset:`md`,className:`p-6`,children:(0,U.jsxs)(`div`,{className:`flex w-full gap-4 items-center`,children:[(0,U.jsx)(`div`,{className:`rounded-lg bg-gray-100 dark:bg-neutral-800 w-20 h-20 grid place-items-center`,children:(0,U.jsx)(jf,{size:38,strokeWidth:1.6,fill:`#FF99E5`,fillOpacity:.2})}),(0,U.jsxs)(`div`,{className:`flex-1`,children:[(0,U.jsx)(TA,{className:`text-base`,children:`Talk to an API expert`}),(0,U.jsx)(EA,{children:`Get a free technical consultation with one of our API experts.`})]}),(0,U.jsx)(X,{onClick:()=>{n(`getting-started-book-a-meeting-clicked`,{account:e.name}),window.open(tx,`_blank`)},className:`min-w-40`,variant:`secondary`,asChild:!0,children:(0,U.jsxs)(hT,{href:tx,variant:`ghost`,children:[(0,U.jsx)(ud,{}),`Book a Meeting`]})})]})}),(0,U.jsx)(CA,{offset:`md`,className:`p-6`,children:(0,U.jsxs)(`div`,{className:`flex w-full gap-4 items-center`,children:[(0,U.jsx)(`div`,{className:`rounded-lg bg-gray-100 dark:bg-neutral-800 w-20 h-20 grid place-items-center`,children:(0,U.jsx)(_f,{size:38,strokeWidth:1.6,fill:`#FF99E5`,fillOpacity:.2})}),(0,U.jsxs)(`div`,{className:`flex-1`,children:[(0,U.jsx)(TA,{className:`text-base`,children:`Feeling Stuck?`}),(0,U.jsx)(EA,{children:`Check out our various support options to get help with your API`})]}),(0,U.jsx)(X,{className:`min-w-40`,variant:`secondary`,asChild:!0,children:(0,U.jsxs)(Ns,{to:ri(rx.Support,{account:e.name}),children:[(0,U.jsx)(_f,{}),`Get Help`]})})]})}),(0,U.jsx)(CA,{offset:`md`,className:`p-6`,children:(0,U.jsxs)(`div`,{className:`flex w-full gap-4 items-center`,children:[(0,U.jsx)(`div`,{className:`rounded-lg bg-gray-100 dark:bg-neutral-800 w-20 h-20 grid place-items-center`,children:(0,U.jsx)(jf,{size:38,strokeWidth:1.6,fill:`#FF99E5`,fillOpacity:.2})}),(0,U.jsxs)(`div`,{className:`flex-1`,children:[(0,U.jsx)(TA,{className:`text-base`,children:`Join the Zuplo API Community`}),(0,U.jsx)(EA,{children:`Come chat with fellow Zuplo users and the Zuplo team in our Discord channel.`})]}),(0,U.jsx)(X,{onClick:()=>{n(`getting-started-join-discord-clicked`,{account:e.name,project:t.name}),window.open($b,`_blank`)},className:`min-w-40`,variant:`secondary`,asChild:!0,children:(0,U.jsxs)(hT,{href:$b,variant:`ghost`,children:[(0,U.jsx)(Sf,{size:16}),`Join Us`]})})]})})]})},LWt=()=>{let{account:e,project:t,environment:n}=sx([`account`,`project`,`environment`]);return(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(wA,{children:[(0,U.jsx)(TA,{className:`text-base`,children:`Welcome to your Gateway`}),(0,U.jsx)(EA,{className:`text-base`,children:`You can get started by configuring your routes and setting up policies in our visual Route Designer.`})]}),(0,U.jsxs)(OA,{className:`border-0 gap-2 py-6`,children:[(0,U.jsx)(X,{asChild:!0,size:`sm`,className:`gap-2 px-8`,variant:`brand-outline`,children:(0,U.jsxs)(Ns,{to:ri(rx.Code,{account:e,project:t,environment:n}),children:[(0,U.jsx)(Ad,{size:16}),`Start Building`]})}),(0,U.jsx)(X,{className:`px-8`,variant:`secondary`,size:`sm`,asChild:!0,children:(0,U.jsxs)(hT,{variant:`ghost`,href:`https://zuplo.com/docs/articles/step-1-setup-basic-gateway`,children:[(0,U.jsx)(Xd,{size:16}),`Quickstart`]})})]})]})},RWt=()=>{let[e,t]=(0,H.useState)(!1);return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(CA,{className:`col-span-full md:col-span-3 py-2 px-4 flex items-center text-sm gap-x-2`,children:[(0,U.jsx)(`div`,{className:`rounded-full w-4 h-4 p-0.5 bg-gray-500`,children:(0,U.jsx)(Dd,{className:`text-white`,size:12})}),(0,U.jsx)(`span`,{className:`font-semibold flex-1 line-clamp-1 break-all`,children:`Developer Portal`}),(0,U.jsxs)(X,{variant:`secondary`,size:`sm`,onClick:()=>t(!0),children:[(0,U.jsx)(Xd,{}),`Open\xA0Portal`]})]}),(0,U.jsx)(ow,{open:e,onOpenChange:t,children:(0,U.jsxs)(lw,{children:[(0,U.jsxs)(uw,{children:[(0,U.jsx)(fw,{children:`Run Developer Portal Locally`}),(0,U.jsx)(pw,{children:`To view and edit your API documentation, you need to run the developer portal locally.`})]}),(0,U.jsxs)(`div`,{className:`space-y-4 py-4`,children:[(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(`p`,{className:`text-sm font-semibold`,children:`Steps to run the portal:`}),(0,U.jsxs)(`ol`,{className:`list-decimal list-inside space-y-2 text-sm text-gray-600`,children:[(0,U.jsxs)(`li`,{children:[`Open a terminal in the`,` `,(0,U.jsx)(`code`,{className:`bg-gray-100 px-1 rounded-sm`,children:`/docs`}),` `,`folder of your Zuplo project`]}),(0,U.jsxs)(`li`,{children:[`Run`,` `,(0,U.jsx)(`code`,{className:`bg-gray-100 px-1 rounded-sm`,children:`npm run dev`})]}),(0,U.jsx)(`li`,{children:`The portal will open in your browser automatically`})]})]}),(0,U.jsx)(`div`,{className:`bg-info-muted border border-blue-200 dark:border-blue-800 rounded-md p-3`,children:(0,U.jsxs)(`p`,{className:`text-xs text-blue-800 dark:text-blue-200`,children:[(0,U.jsx)(`strong`,{children:`Tip:`}),` The developer portal will automatically reload when you make changes to your OpenAPI documentation.`]})})]}),(0,U.jsxs)(dw,{children:[(0,U.jsx)(X,{variant:`secondary`,onClick:()=>t(!1),children:`Close`}),(0,U.jsx)(X,{asChild:!0,variant:`outline`,children:(0,U.jsx)(hT,{href:`https://zuplo.com/docs/dev-portal`,children:`View Documentation`})})]})]})})]})},zWt=()=>{let{project:e,environment:t}=Op(),n=KR(t);return(0,U.jsx)(`div`,{className:`bg-neutral-50 dark:bg-neutral-950 h-full overflow-y-auto`,children:(0,U.jsxs)(`div`,{className:`pt-4 max-w-6xl pb-16 m-auto px-5 flex flex-col gap-4`,children:[(0,U.jsx)(`h1`,{className:`text-2xl font-semibold`,children:e.name}),(0,U.jsxs)(`div`,{className:`grid grid-cols-8 gap-3`,children:[(0,U.jsx)(JUt,{title:`Gateway`,url:n}),(0,U.jsx)(RWt,{})]}),(0,U.jsxs)(CA,{className:`relative grid md:grid-cols-2 overflow-hidden min-h-[220px]`,children:[(0,U.jsx)(LWt,{}),(0,U.jsxs)(`div`,{className:`hidden md:block self-end h-full w-full`,children:[(0,U.jsx)(`img`,{src:WUt,alt:e.name,className:`w-full h-full object-cover object-left dark:hidden`}),(0,U.jsx)(`img`,{src:GUt,alt:``,"aria-hidden":!0,className:`hidden w-full h-full object-cover object-left dark:block`})]})]}),(0,U.jsx)(qUt,{mode:`local`}),(0,U.jsx)(IWt,{})]})})},BWt=()=>Xe().brand,VWt=({account:e,accountLabel:t,navigateTo:n})=>{let{data:r,isLoading:i}=Kw(e),a=MTe(e),o=i||a.isLoading,s=t||e,c=FTe(r,a).sort((e,t)=>e.name.toLowerCase().localeCompare(t.name.toLowerCase()));return o?(0,U.jsx)(vw,{heading:s,forceMount:!0,children:(0,U.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-3 text-sm text-muted-foreground`,"aria-live":`polite`,children:[(0,U.jsx)(vf,{className:`h-4 w-4 animate-spin`}),(0,U.jsx)(`span`,{children:`Loading projects...`})]})}):(0,U.jsx)(vw,{heading:s,children:c.map(r=>(0,U.jsxs)(yw,{value:`${e}/${r.name}`,keywords:t?[r.name,e,t]:[r.name,e],onSelect:()=>n(ri(rx.Overview,{account:e,project:r.name})),children:[(0,U.jsx)(id,{className:`mr-3 h-4 w-4 text-neutral-600`}),(0,U.jsx)(`span`,{children:r.name})]},r.id))})},HWt=({accounts:e,navigateTo:t})=>{let n=e?.map(e=>e.name)??[],r=NOe(n),i=NTe(n),a=[...e??[]].sort((e,t)=>(e.label||e.name).toLowerCase().localeCompare((t.label||t.name).toLowerCase())),o=(e??[]).flatMap((e,t)=>i[t]?FTe(r[t]?.data,i[t]).map(t=>({account:e,project:t})):[]).sort((e,t)=>e.project.name.toLowerCase().localeCompare(t.project.name.toLowerCase()));return(0,U.jsxs)(vw,{children:[a.map(e=>(0,U.jsxs)(yw,{value:e.name,keywords:[e.label||e.name,e.name],onSelect:()=>t(ri(rx.AccountProjects,{account:e.name})),children:[(0,U.jsx)(ld,{className:`mr-3 h-4 w-4 text-neutral-600`}),(0,U.jsx)(`span`,{className:`truncate`,children:e.label||e.name}),e.label&&e.label!==e.name&&(0,U.jsx)(`span`,{className:`ml-2 truncate text-xs text-muted-foreground`,children:e.name}),(0,U.jsx)(`span`,{className:`ml-auto shrink-0 pl-3 text-xs text-muted-foreground`,children:`Account`})]},`account:${e.name}`)),o.map(({account:e,project:n})=>(0,U.jsxs)(yw,{value:`${e.name}/${n.name}`,keywords:e.label?[n.name,e.name,e.label]:[n.name,e.name],onSelect:()=>t(ri(rx.Overview,{account:e.name,project:n.name})),children:[(0,U.jsx)(id,{className:`mr-3 h-4 w-4 text-neutral-600`}),(0,U.jsx)(`span`,{className:`truncate`,children:n.name}),(0,U.jsx)(`span`,{className:`ml-auto shrink-0 pl-3 text-xs text-muted-foreground`,children:e.label||e.name})]},n.id))]})},UWt=({accounts:e,navigateTo:t,search:n})=>n.trim()?(0,U.jsx)(HWt,{accounts:e,navigateTo:t}):(0,U.jsxs)(U.Fragment,{children:[e?.map(e=>(0,U.jsx)(VWt,{navigateTo:t,account:e.name,accountLabel:e.label},`projects-${e.name}`)),(0,U.jsx)(vw,{heading:`Accounts`,children:e?.map(e=>(0,U.jsxs)(yw,{keywords:[e.label||e.name,e.name],onSelect:()=>{t(ri(rx.AccountProjects,{account:e.name}))},children:[(0,U.jsx)(ld,{className:`mr-2 h-4 w-4`}),(0,U.jsx)(`span`,{children:e.label||e.name}),e.label&&e.label!==e.name&&(0,U.jsx)(`span`,{className:`ml-2 truncate text-xs text-muted-foreground`,children:e.name})]},e.name))})]}),WWt=`__zuplo_commander_ask_ai__`,GWt=.5,KWt=(e,t,n)=>{if(e===`__zuplo_commander_ask_ai__`)return GWt;let[r=e,...i]=n??[],a=QC(r,t);if(a>0)return 2+a;let o=i.reduce((e,n)=>Math.max(e,QC(n,t)),0);return o>0?1+o:0},qWt=({query:e,onSelected:t})=>{let n=Cut(),{logEvent:r}=S();if(!n?.enabled)return null;let i=e.trim();return(0,U.jsx)(vw,{children:(0,U.jsxs)(yw,{value:WWt,onSelect:()=>{r(`agent-z-panel-opened`,{source:`command-palette`}),n.openWithPrompt(i),t()},children:[(0,U.jsx)(`div`,{className:`mr-2`,children:(0,U.jsx)(wb,{weight:`fill`,"aria-hidden":!0})}),(0,U.jsx)(`span`,{children:`Ask AI`}),i&&(0,U.jsx)(`span`,{className:`ml-2 truncate text-xs text-muted-foreground`,children:`"${i}"`})]})})},JWt=({account:e,navigateTo:t,project:n,environment:r})=>(0,U.jsx)(vw,{heading:`Files`,children:Pp(e=>e.projectTreeNodes).filter(e=>e.path&&e.type===Zs.File).map(i=>(0,U.jsxs)(yw,{onSelect:()=>t(ri(`${rx.Code}?path=${i.path}`,{account:e,project:n,environment:r})),children:[(0,U.jsx)(`div`,{className:`mr-3`,children:(0,U.jsx)(Qd,{className:`h-4 w-4 text-neutral-500`})}),(0,U.jsx)(`span`,{className:`line-clamp-1`,children:i.path.substring(1)})]},i.path))}),YWt=({children:e,className:t})=>(0,U.jsx)(`div`,{className:W(`bg-surface-sunken`,t),children:e}),XWt=({children:e,className:t})=>(0,U.jsx)(`div`,{className:W(`pt-4 max-w-6xl pb-16 m-auto px-5 w-full`,t),children:e}),ZWt=({children:e,className:t,muted:n})=>(0,U.jsx)(`div`,{className:W(`bg-background`,n&&`bg-surface-sunken`),children:(0,U.jsx)(`div`,{className:W(`py-6 max-w-6xl mx-auto px-5 min-h-20 flex items-center w-full`,t),children:e})}),QWt=({children:e,className:t})=>(0,U.jsx)(`div`,{className:W(`text-sm text-foreground`,t),children:e}),$Wt=({children:e,className:t})=>(0,U.jsx)(`h1`,{className:W(`text-2xl font-semibold tracking-tight`,t),children:e});(0,H.createContext)(void 0);var eGt=YR(`div`,`grid grid-cols-subgrid col-span-full w-full items-center border-b px-4 py-3 last:border-0`),tGt=YR(`div`,`grid grid-cols-subgrid col-span-full w-full items-center border-b px-4 py-2.5 text-xs font-medium uppercase tracking-wide text-muted-foreground`),N7=({title:e,description:t,action:n,children:r,contentClassName:i})=>(0,U.jsxs)(YWt,{className:`min-h-full`,children:[(0,U.jsx)(`div`,{className:`border-b`,children:(0,U.jsx)(ZWt,{muted:!0,children:(0,U.jsxs)(`div`,{className:`flex w-full flex-wrap items-start justify-between gap-4`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,U.jsx)($Wt,{children:e}),t&&(0,U.jsx)(QWt,{className:`text-muted-foreground`,children:t})]}),n]})})}),(0,U.jsx)(XWt,{className:W(`flex flex-col gap-5`,i),children:r})]});function nGt({assignment:e,children:t,onOpenChange:n}){let[r,i]=(0,H.useState)(!1),[a,o]=(0,H.useState)(!1),{startOpening:s,renderTrigger:c}=aot(),{project:l}=Op([`project`]),u=CO(l),d=(0,H.useCallback)(()=>{o(!1),n?.(!1),i(!1)},[n]),f=xL(a,d);return(0,U.jsxs)(ow,{open:r,onOpenChange:e=>{e?(n?.(!0),s(()=>i(!0))):f.guardedClose()},children:[(0,U.jsx)(sw,{asChild:!0,children:c(t)}),(0,U.jsxs)(lw,{className:`sm:max-w-4xl max-h-[90vh] overflow-hidden flex flex-col`,children:[(0,U.jsxs)(uw,{children:[(0,U.jsx)(fw,{children:`Edit AI Provider`}),(0,U.jsx)(pw,{children:u?(0,U.jsx)(U.Fragment,{children:`The Provider Name identifies this provider throughout the project and cannot be changed.`}):(0,U.jsxs)(U.Fragment,{children:[`The Provider Name is the routing address used in`,` `,(0,U.jsx)(`code`,{className:`font-mono`,children:`providerName/model`}),` references and cannot be changed.`]})})]}),(0,U.jsx)(rGt,{assignment:e,onDirtyChange:o,onClose:d})]}),(0,U.jsx)(bL,{open:f.showConfirm,onOpenChange:f.setShowConfirm,onDiscard:f.handleDiscard})]})}var rGt=({assignment:e,onDirtyChange:t,onClose:n})=>{let r=rX(),i=Ep(),a=bX(),o=bt(),{account:s,project:c}=sx([`account`,`project`]),{project:l}=Op([`project`]),{data:u,providers:d}=wX().data,f=e.provider===`Custom`?e.customProviderName??e.provider:e.provider,p=d[f],m=p?.isCustom===!0&&!CO(l),h=(0,H.useMemo)(()=>[...u[f]??[]].sort((e,t)=>EX(e.model,t.model)),[u,f]),g=(0,H.useMemo)(()=>{try{return JSON.parse(e.metadata)}catch{return{}}},[e.metadata]),_=vA({defaultValues:{provider:f,customProviderName:e.customProviderName,label:e.label,apiKey:``,envVarName:e.envVarName,region:eMe(e.endpointUrl)??iMe(e.endpointUrl)??fMe(e.endpointUrl)??``,awsAccessKeyId:``,awsSecretAccessKey:``,gcpProjectId:e.gcpProjectId??``,azureResourceName:LO(e.endpointUrl)?.resourceName??``,azureHostSuffix:LO(e.endpointUrl)?.hostSuffix??`openai.azure.com`,deploymentModels:yMe(e.deploymentModels),models:{completions:g.models?.completions??[],embeddings:g.models?.embeddings??[]},...m?{customModels:h.map(e=>({modelId:e.id,name:e.model,kind:e.kind,status:e.status===`deprecated`?`deprecated`:`active`,inputCostPerToken:e.inputCostPerToken,outputCostPerToken:e.outputCostPerToken,cachedInputCostPerToken:e.cachedInputCostPerToken,cacheWriteCostPerToken:e.cacheWriteCostPerToken}))}:{}},mode:`onChange`,resolver:xA(rot)}),{isDirty:v}=Ck(_);(0,H.useEffect)(()=>{t(v)},[v,t]);let y=Oe({mutationFn:async t=>{if(m&&p?.id){let e=Tat(h,t.customModels);for(let t of e.deleted)await o.fetch(ae.ai.deleteAiProviderModel(a,p.id,t));for(let t of e.repriced)await o.fetch(ae.ai.updateAiProviderModel(a,p.id,t.id,{inputCostPerToken:t.inputCostPerToken,outputCostPerToken:t.outputCostPerToken,cachedInputCostPerToken:t.cachedInputCostPerToken,cacheWriteCostPerToken:t.cacheWriteCostPerToken}));for(let t of e.created)await o.fetch(ae.ai.createAiProviderModel(a,p.id,{model:t.name,kind:t.kind,inputCostPerToken:t.inputCostPerToken,outputCostPerToken:t.outputCostPerToken,cachedInputCostPerToken:t.cachedInputCostPerToken,cacheWriteCostPerToken:t.cacheWriteCostPerToken,status:`active`}))}let n=OO(t),r=kO(t);return await o.fetch(ae.ai.updateAiProviderAssignment(s,c,e.id,{envVarName:t.envVarName,...r?{value:r}:{},...n?{endpointUrl:n}:{},...t.provider===`VertexAI`&&t.gcpProjectId?.trim()?{gcpProjectId:t.gcpProjectId.trim()}:{},...t.provider===`AzureAI`?{deploymentModels:RO(t.deploymentModels)??{}}:{},metadata:{models:Eat(t,m)}}))},onSuccess:(e,t)=>{xO(l)&&kO(t)&&i.success(`Key updated. Your gateway is redeploying — ${TO}.`,{duration:EO}),_.reset(_.getValues()),n()},onSettled:(t,n)=>r(`provider.updated`,n?`failed`:`succeeded`,{provider:e.provider})});return(0,U.jsx)(YY,{..._,children:(0,U.jsxs)(`form`,{onSubmit:_.handleSubmit(e=>y.mutate(e)),className:`flex flex-col flex-1 min-h-0`,children:[(0,U.jsx)(SA,{error:y.error,className:`mb-4 break-all`}),(0,U.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto px-1 space-y-4`,children:(0,U.jsx)(Mat,{form:_,mode:`edit`,providerDisabled:!0,allowCustomModelEditing:m})}),(0,U.jsxs)(dw,{className:`mt-4`,children:[(0,U.jsx)(X,{type:`button`,variant:`ghost`,onClick:n,disabled:y.isPending,children:`Cancel`}),(0,U.jsx)(X,{type:`submit`,disabled:!_.formState.isValid||y.isPending,children:(0,U.jsx)(HI,{loading:y.isPending,children:`Save`})})]})]})})},iGt=e=>e.label,P7=12,aGt=`Connect API keys for providers like OpenAI and Anthropic and choose which models your gateway is allowed to route to.`,oGt=()=>(0,U.jsx)(H.Suspense,{fallback:null,children:(0,U.jsx)(FX,{children:(0,U.jsxs)(X,{children:[(0,U.jsx)(Mf,{size:16}),`Add Provider`]})})}),sGt=()=>(0,U.jsx)(OX,{source:`providers-page`,children:(0,U.jsxs)(X,{variant:`outline`,children:[(0,U.jsx)(Cf,{size:16}),`Request a provider or model`]})}),cGt=()=>(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,U.jsx)(sGt,{}),(0,U.jsx)(oGt,{})]}),lGt=()=>(0,U.jsx)(U.Fragment,{children:[0,1].map(e=>(0,U.jsxs)(CA,{children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-3 p-5`,children:[(0,U.jsx)(bD,{className:`size-10 rounded-lg`}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,U.jsx)(bD,{className:`h-5 w-48`}),(0,U.jsx)(bD,{className:`h-3 w-32`})]})]}),(0,U.jsx)(`div`,{className:`border-t`}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-2 p-5`,children:[(0,U.jsx)(bD,{className:`h-3 w-24`}),(0,U.jsx)(bD,{className:`h-4 w-full max-w-2xl`})]})]},e))}),uGt=()=>{let e=rX(),{account:t,project:n}=sx([`account`,`project`]),r=ax(je.aiProviderAssignments(t,n)),i=bt(),a=Oe({mutationFn:async e=>i.fetch(ae.ai.deleteAiProviderAssignment(t,n,e)),onSettled:(t,n)=>e(`provider.deleted`,n?`failed`:`succeeded`)}),o=r.data;return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(SA,{error:a.error}),o.length>0?o.map(e=>(0,U.jsx)(fGt,{assignment:e,onDelete:()=>a.mutate(e.id)},e.id)):(0,U.jsx)(CA,{children:(0,U.jsxs)(qb,{children:[(0,U.jsxs)(Jb,{children:[(0,U.jsx)(Yb,{variant:`icon`,children:(0,U.jsx)(od,{})}),(0,U.jsx)(Xb,{children:`No AI providers yet`}),(0,U.jsx)(Zb,{children:`Connect API keys for providers like OpenAI and Anthropic so your gateway can route requests to their models.`})]}),(0,U.jsx)(Qb,{children:(0,U.jsx)(FX,{})})]})})]})},dGt=({assignment:e})=>(0,U.jsx)(`div`,{className:`flex size-10 shrink-0 items-center justify-center rounded-lg bg-zuplo-100 text-lg font-semibold text-zuplo-700 dark:bg-zuplo-950/50 dark:text-zuplo-300`,children:(e.label||e.provider||`?`).trim().charAt(0).toUpperCase()}),fGt=({assignment:e,onDelete:t})=>{let[n,r]=(0,H.useState)(!1),i=(0,H.useCallback)(()=>r(!0),[]),{completions:a,embeddings:o}=(0,H.useMemo)(()=>{try{let t=JSON.parse(e.metadata);return{completions:t.models?.completions??[],embeddings:t.models?.embeddings??[]}}catch{return{completions:[],embeddings:[]}}},[e.metadata]),s=a.length+o.length,c=iGt(e),l=e.provider===`Custom`,u=e.provider===AO,d=a.length>P7||o.length>P7;return(0,U.jsxs)(CA,{children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-4 p-5`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,U.jsx)(dGt,{assignment:e}),(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,U.jsx)(`span`,{className:`truncate text-lg font-medium`,children:e.label}),(0,U.jsx)(rT,{variant:`outline`,size:`default`,children:l?e.customProviderName===e.label?e.customProviderName:`Custom`:u?jO:e.provider})]}),u?(0,U.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-1 text-xs text-amber-700 dark:text-amber-400`,children:[(0,U.jsx)(cp,{size:12}),(0,U.jsx)(`span`,{className:`truncate`,children:`Demo provider — not for production`})]}):(0,U.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-1 text-xs text-muted-foreground`,children:[(0,U.jsx)(mf,{size:12}),(0,U.jsx)(`span`,{className:`truncate font-mono`,children:e.envVarName})]})]})]}),(0,U.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,U.jsx)(nGt,{assignment:e,children:(0,U.jsx)(X,{variant:`ghost`,size:`icon`,title:`Edit provider`,"aria-label":`Edit provider`,children:(0,U.jsx)(Af,{size:16})})}),(0,U.jsx)(mht,{onConfirm:t,description:`Are you sure you want to delete this provider? Apps using its models will stop working.`,children:(0,U.jsx)(X,{variant:`ghost`,size:`icon`,title:`Delete provider`,"aria-label":`Delete provider`,className:`text-muted-foreground hover:text-destructive-foreground`,children:(0,U.jsx)(sp,{size:16})})})]})]}),(0,U.jsx)(`div`,{className:`border-t`}),s===0?(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-4 p-5`,children:[(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No models are enabled for this provider yet.`}),(0,U.jsx)(nGt,{assignment:e,children:(0,U.jsx)(X,{variant:`outline`,size:`sm`,children:`Select models`})})]}):(0,U.jsxs)(`div`,{className:`space-y-4 p-5`,children:[(0,U.jsx)(pGt,{icon:(0,U.jsx)(wf,{size:14}),title:`Chat`,models:a,referenceKey:c,expanded:n,onReveal:i}),(0,U.jsx)(pGt,{icon:(0,U.jsx)(hf,{size:14}),title:`Embeddings`,models:o,referenceKey:c,expanded:n,onReveal:i}),d&&(0,U.jsx)(X,{variant:`link`,size:`sm`,className:`h-auto px-0`,onClick:()=>r(e=>!e),children:n?`Show fewer models`:`Show all ${s} models`})]})]})},pGt=({icon:e,title:t,models:n,referenceKey:r,expanded:i,onReveal:a})=>{if(n.length===0)return null;let o=n.slice(P7);return(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-medium text-muted-foreground`,children:[e,(0,U.jsx)(`span`,{children:t}),(0,U.jsx)(`span`,{className:`text-muted-foreground/70`,children:`·`}),(0,U.jsx)(`span`,{className:`text-muted-foreground/70`,children:n.length})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(mGt,{models:n.slice(0,P7),referenceKey:r}),o.length>0&&(0,U.jsx)(gGt,{hidden:!i,onReveal:a,children:(0,U.jsx)(mGt,{models:o,referenceKey:r,className:`mt-1`})})]})]})},mGt=({models:e,referenceKey:t,className:n})=>(0,U.jsx)(`ul`,{className:W(`grid grid-cols-1 gap-x-6 gap-y-1 font-mono text-xs sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4`,n),children:e.map(e=>(0,U.jsx)(hGt,{model:e,referenceKey:t},e))}),hGt=({model:e,referenceKey:t})=>{let n=t?`${t}/${e}`:e,{copyToClipboard:r}=WC(n);return(0,U.jsx)(`li`,{className:`min-w-0`,children:(0,U.jsxs)(oR,{delayDuration:300,children:[(0,U.jsx)(sR,{asChild:!0,children:(0,U.jsx)(`button`,{type:`button`,onClick:()=>void r(),"aria-label":`Copy ${n}`,className:`block w-full cursor-pointer truncate rounded-xs text-left outline-none hover:underline hover:decoration-dotted hover:underline-offset-4 focus-visible:ring-2 focus-visible:ring-ring`,children:e})}),(0,U.jsxs)(cR,{className:`flex flex-col gap-0.5`,children:[(0,U.jsx)(`span`,{className:`font-mono`,children:n}),(0,U.jsx)(`span`,{className:`text-background/70`,children:`Click to copy full name`})]})]})})},gGt=({hidden:e,onReveal:t,children:n})=>{let r=(0,H.useRef)(null);return(0,H.useLayoutEffect)(()=>{let t=r.current;t&&(e?t.setAttribute(`hidden`,`until-found`):t.removeAttribute(`hidden`))},[e]),(0,H.useEffect)(()=>{let e=r.current;if(e)return e.addEventListener(`beforematch`,t),()=>e.removeEventListener(`beforematch`,t)},[t]),(0,U.jsx)(`div`,{ref:r,children:n})},_Gt=()=>(0,U.jsx)(N7,{title:`AI Gateway`,description:aGt,action:(0,U.jsx)(cGt,{}),children:(0,U.jsx)(H.Suspense,{fallback:(0,U.jsx)(lGt,{}),children:(0,U.jsx)(uGt,{})})}),vGt=e=>e.plan===`FREE_V1`,yGt=({account:e,className:t,source:n})=>{let r=e.customDomainsInUse,i=e.entitlements.customDomains,a=vGt(e),o=`${ri(rx.AccountSettings,{account:e.name})}/upgrade-billing?source=${n}`;return(0,U.jsxs)(CA,{variant:`default`,className:t,children:[(0,U.jsx)(wA,{children:a?`Custom domains require a paid plan`:`Custom domain limit reached`}),(0,U.jsx)(DA,{className:`text-sm leading-relaxed`,children:a?(0,U.jsx)(`p`,{children:`Custom domains let you serve your APIs and developer portal from your own domain. Upgrade to the Builder plan to add custom domains to your account.`}):(0,U.jsxs)(`p`,{children:[`Your account is using`,` `,(0,U.jsxs)(`span`,{className:`font-medium`,children:[r,` of `,i]}),` `,`custom domains. Contact our team to increase your limit.`]})}),(0,U.jsxs)(OA,{className:`flex flex-wrap items-center gap-2`,children:[a?(0,U.jsx)(X,{asChild:!0,children:(0,U.jsx)(Kb,{variant:`ghost`,to:o,children:`Upgrade to Builder`})}):(0,U.jsx)(X,{asChild:!0,children:(0,U.jsx)(hT,{href:tx,variant:`ghost`,children:`Contact Sales`})}),(0,U.jsx)(X,{variant:`outline`,asChild:!0,children:(0,U.jsx)(Kb,{variant:`ghost`,to:o,children:`View Plans`})})]})]})},bGt=({used:e,max:t,label:n,account:r,navigationSource:i,className:a,hideAtLimit:o=!1})=>{if(t<=0)return null;let s=e>=t,c=r.plan.startsWith(`FREE`),l=`${ri(rx.AccountSettings,{account:r.name})}/upgrade-billing${i?`?source=${i}`:``}`;return s?o?null:(0,U.jsxs)(Ub,{variant:`warning`,className:a,children:[(0,U.jsx)(cp,{}),(0,U.jsx)(Gb,{children:(0,U.jsxs)(`p`,{children:[`You've reached the limit of `,t,` `,n,` on your plan (`,e,` of`,` `,t,` used).`,` `,c?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Kb,{to:l,className:`hover:text-zuplo-pink-hover text-zuplo-pink underline`,children:`Upgrade your plan`}),` `,`to add more.`]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(hT,{href:`mailto:${nx}`,className:`text-zuplo-pink hover:text-zuplo-pink-hover underline`,children:`Contact sales`}),` `,`to increase your limit.`]})]})})]}):(0,U.jsxs)(`p`,{className:W(`text-sm text-muted-foreground`,a),children:[`Using `,e,` of `,t,` `,n,`.`]})},xGt=({className:e})=>(0,U.jsxs)(CA,{variant:`info`,className:e,children:[(0,U.jsx)(wA,{children:`Managed Dedicated Project`}),(0,U.jsx)(DA,{className:`flex-1 leading-loose mt-1 text-sm`,children:(0,U.jsxs)(`p`,{className:`leading-loose`,children:[`This project uses Akamai managed dedicated hosting. Custom domains for Akamai must be configured through Akamai CDN. See`,` `,(0,U.jsx)(hT,{href:`https://zuplo.com/docs/dedicated/akamai/cdn`,children:`Akamai custom domain documentation`}),`.`]})})]}),F7=`Switch`,[SGt,CGt]=V(F7),[wGt,TGt]=SGt(F7),EGt=H.forwardRef((e,t)=>{let{__scopeSwitch:n,name:r,checked:i,defaultChecked:a,required:o,disabled:s,value:c=`on`,onCheckedChange:l,form:u,...d}=e,[f,m]=H.useState(null),h=p(t,e=>m(e)),g=H.useRef(!1),_=f?u||!!f.closest(`form`):!0,[v,y]=yt({prop:i,defaultProp:a??!1,onChange:l,caller:F7});return(0,U.jsxs)(wGt,{scope:n,checked:v,disabled:s,children:[(0,U.jsx)(hc.button,{type:`button`,role:`switch`,"aria-checked":v,"aria-required":o,"data-state":jGt(v),"data-disabled":s?``:void 0,disabled:s,value:c,...d,ref:h,onClick:oc(e.onClick,e=>{y(e=>!e),_&&(g.current=e.isPropagationStopped(),g.current||e.stopPropagation())})}),_&&(0,U.jsx)(AGt,{control:f,bubbles:!g.current,name:r,value:c,checked:v,required:o,disabled:s,form:u,style:{transform:`translateX(-100%)`}})]})});EGt.displayName=F7;var DGt=`SwitchThumb`,OGt=H.forwardRef((e,t)=>{let{__scopeSwitch:n,...r}=e,i=TGt(DGt,n);return(0,U.jsx)(hc.span,{"data-state":jGt(i.checked),"data-disabled":i.disabled?``:void 0,...r,ref:t})});OGt.displayName=DGt;var kGt=`SwitchBubbleInput`,AGt=H.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...i},a)=>{let o=H.useRef(null),s=p(o,a),c=aY(n),l=we(t);return H.useEffect(()=>{let e=o.current;if(!e)return;let t=window.HTMLInputElement.prototype,i=Object.getOwnPropertyDescriptor(t,`checked`).set;if(c!==n&&i){let t=new Event(`click`,{bubbles:r});i.call(e,n),e.dispatchEvent(t)}},[c,n,r]),(0,U.jsx)(`input`,{type:`checkbox`,"aria-hidden":!0,defaultChecked:n,...i,tabIndex:-1,ref:s,style:{...i.style,...l,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0}})});AGt.displayName=kGt;function jGt(e){return e?`checked`:`unchecked`}var MGt=EGt,NGt=OGt;function PGt({className:e,...t}){return(0,U.jsx)(MGt,{"data-slot":`switch`,className:W(`peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50`,e),...t,children:(0,U.jsx)(NGt,{"data-slot":`switch-thumb`,className:W(`bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0`)})})}var I7=({customDomain:e,cname:t,documentationUrl:n=`https://www.zuplo.com/docs/guides/custom-domain-setup`})=>(0,U.jsxs)(`div`,{className:`text-left text-sm text-foreground whitespace-pre-line w-full mb-2`,children:[(0,U.jsx)(`p`,{children:`We've set things up on our end, now you need to configure your DNS with a new entry.`}),(0,U.jsx)(`br`,{}),(0,U.jsx)(CA,{variant:`muted`,className:`font-mono p-4 text-sm`,children:(0,U.jsxs)(`ol`,{children:[(0,U.jsx)(`li`,{className:`leading-6`,children:`Type: CNAME`}),(0,U.jsxs)(`li`,{className:`leading-6`,children:[`Name: `,e,` `,(0,U.jsx)(GI,{textToCopy:e??``})]}),(0,U.jsxs)(`li`,{className:`leading-6`,children:[`Value: `,t,` `,(0,U.jsx)(GI,{textToCopy:t??``})]}),(0,U.jsx)(`li`,{className:`leading-6`,children:`TTL: 60s or auto`})]})}),(0,U.jsx)(`br`,{}),(0,U.jsx)(`p`,{children:`Note that it does sometimes take a few hours for records to propagate and for the SSL certificate to be created.`}),(0,U.jsx)(`br`,{}),(0,U.jsxs)(`p`,{children:[`For more information see our`,` `,(0,U.jsx)(hT,{href:n,children:`documentation on custom domains`}),`.`]})]});function FGt({projectType:e,defaultConfiguration:t}){return e===`managed-dedicated`&&t.some(e=>!!e.managedDedicatedConfiguration)}function IGt({stage:e,isManagedDedicatedProject:t,isAkamaiManagedDedicatedProject:n,formIsAlias:r}){return e===`dev-portal`?!1:n?!0:t?!1:r??!1}function LGt({projectType:e,defaultConfiguration:t}){return e===`managed-dedicated`&&t.some(e=>e.managedDedicatedConfiguration?.vendor===`akamai`)}function RGt({project:e,isAkamaiManagedDedicatedProject:t}){return t||!e?!1:!xO(e)}var L7=()=>(0,U.jsxs)(`div`,{className:`text-left text-sm text-foreground whitespace-pre-line w-full mb-2`,children:[(0,U.jsx)(`p`,{children:`This custom domain is setup with an advanced configuration. In order to make changes to this domain, please contact support.`}),(0,U.jsx)(`br`,{}),(0,U.jsxs)(`p`,{children:[`For more information see our`,` `,(0,U.jsx)(hT,{href:`https://www.zuplo.com/docs/guides/custom-domain-setup`,children:`documentation on custom domains`}),`.`]})]}),zGt=/^(?!https?:\/\/)[a-zA-Z0-9.-]*\.[a-zA-Z]+$/,BGt=`https://zuplo.com/docs/dedicated/custom-domains`,VGt=Ym({project:Gm().min(1),hostname:Gm().regex(zGt,`Please enter a valid domain name (e.g. api.example.com)`),environment:Gm().min(1),stage:Zm([`api`,`dev-portal`]),isAlias:qm().optional()}),HGt=({account:e,projectName:t,disabled:n=!1,isManagedDedicatedProject:r=!1,isAkamaiManagedDedicatedProject:i=!1})=>{let a=t===void 0,o=ao(),s=vA({resolver:xA(VGt),defaultValues:{project:t??``,hostname:``,environment:``,stage:`api`,isAlias:i}}),[c,l]=(0,H.useState)(!1),[u,d]=(0,H.useState)(`project`),[f,p,m]=s.watch([`isAlias`,`stage`,`project`]),{data:h,isLoading:g}=wR(e.name,m,{enabled:!!m}),{aliasDomains:_}=e.entitlements,{data:v}=Kw(e.name),y=v?.find(e=>e.name===m),b=y?Gje(new Date(Number(y.createdOn)),new Date(`2025-04-01`)):!1,x=(v??[]).filter(e=>e.type!==`self-hosted`&&e.deployedEnvironmentCount>0).sort((e,t)=>e.name.localeCompare(t.name)),{data:S,isLoading:C}=qw(e.name,m,{enabled:a&&!!m}),w=a?FGt({projectType:y?.type,defaultConfiguration:S?.defaultConfiguration??[]}):r,T=a?LGt({projectType:y?.type,defaultConfiguration:S?.defaultConfiguration??[]}):i,E=RGt({project:y,isAkamaiManagedDedicatedProject:T}),D=h?h.filter(e=>e.environmentType!==kL.WORKING_COPY):[],O=$Ut({onSuccess:()=>{IGt({stage:p,isManagedDedicatedProject:w,isAkamaiManagedDedicatedProject:T,formIsAlias:f})&&!a&&l(!1)}}),k=(0,H.useCallback)(()=>{s.reset(),O.isSuccess&&O.reset(),d(`project`),l(!1)},[s,O]),A=xL(s.formState.isDirty&&!O.isSuccess,k),j=()=>{l(!1),o(`${ri(rx.Settings,{account:e.name,project:m})}/custom-domain`)},M=a&&v!==void 0&&x.length===0,N=!a||u===`details`,P=g||C;return(0,U.jsxs)(ow,{open:c,onOpenChange:e=>{e?l(!0):A.guardedClose()},children:[(0,U.jsx)(sw,{asChild:!0,children:(0,U.jsx)(X,{"data-test":`create-custom-domain-modal-btn`,disabled:n,title:n?`You reached the limit of custom domains`:``,children:`Add Custom Domain`})}),(0,U.jsxs)(lw,{children:[(0,U.jsx)(uw,{children:(0,U.jsx)(fw,{children:`Add Custom Domain`})}),(0,U.jsx)(`div`,{className:`space-y-4`,children:O.isSuccess?(0,U.jsxs)(U.Fragment,{children:[w&&!f&&p===`api`?O.data?.cname?(0,U.jsx)(I7,{customDomain:s.getValues(`hostname`),cname:O.data.cname,documentationUrl:BGt}):(0,U.jsx)(L7,{}):!_&&O.data?.cname&&(0,U.jsx)(I7,{customDomain:s.getValues(`hostname`),cname:O.data?.cname}),!w&&!_&&!O.data?.cname&&p===`api`&&(0,U.jsx)(L7,{}),(0,U.jsxs)(`div`,{className:`mt-5 sm:mt-4 flex justify-end gap-x-4`,children:[a&&(0,U.jsx)(X,{type:`button`,variant:`secondary`,"data-test":`view-custom-domain-btn`,onClick:j,children:`View in project`}),(0,U.jsx)(cw,{asChild:!0,children:(0,U.jsx)(X,{"data-test":`ok-create-custom-domain-btn`,children:`Done`})})]})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(SA,{error:O.error}),(0,U.jsx)(`div`,{className:`text-left text-sm text-foreground whitespace-pre-line w-full mb-2`,children:(0,U.jsxs)(YY,{...s,children:[N&&T&&(0,U.jsx)(Ub,{variant:`info`,children:(0,U.jsx)(Gb,{children:`Make sure this hostname is already configured in your Akamai CDN. Registering it here records the alias domain with Zuplo so your public URLs match the client-facing domain.`})}),N&&b&&E&&(0,U.jsxs)(Ub,{variant:`warning`,children:[(0,U.jsx)(Wb,{children:`Preview Notice`}),(0,U.jsxs)(Gb,{children:[`Custom domains for the Dev Portal are currently in preview and only available after the migration to our preview version.`,` `,(0,U.jsx)(hT,{href:`https://zuplo.com/docs/articles/custom-domains`,target:`_blank`,children:`Learn more`})]})]}),(0,U.jsx)(`form`,{onSubmit:s.handleSubmit(async t=>{await O.mutateAsync({accountName:e.name,projectName:t.project,isAlias:IGt({stage:t.stage,isManagedDedicatedProject:w,isAkamaiManagedDedicatedProject:T,formIsAlias:t.isAlias}),hostname:t.hostname,deploymentName:t.environment,stage:t.stage})}),children:a&&u===`project`?(0,U.jsxs)(U.Fragment,{children:[M?(0,U.jsx)(`p`,{className:`mt-2`,children:`You don't have any projects that can use a custom domain yet. Custom domains require a project with a deployed (edge) environment.`}):(0,U.jsx)(XY,{control:s.control,name:`project`,render:({field:e})=>(0,U.jsxs)(QY,{className:`mt-2`,children:[(0,U.jsx)(yT,{className:`block`,htmlFor:`project-field`,children:`Which project is this domain for?`}),(0,U.jsxs)(CY,{value:e.value,onValueChange:t=>{e.onChange(t),s.setValue(`environment`,``),s.setValue(`stage`,`api`),s.setValue(`isAlias`,!1)},disabled:O.isPending,children:[(0,U.jsx)(TY,{id:`project-field`,"data-test":`project-field`,className:`w-full`,children:(0,U.jsx)(wY,{placeholder:`Select a project`})}),(0,U.jsx)(EY,{children:x.map(e=>(0,U.jsx)(DY,{value:e.name,children:e.name},e.id))})]}),(0,U.jsx)(nX,{})]})}),(0,U.jsxs)(`div`,{className:`mt-5 sm:mt-4 flex justify-end gap-x-4`,children:[(0,U.jsx)(cw,{asChild:!0,children:(0,U.jsx)(X,{type:`button`,variant:`secondary`,"data-test":`cancel-create-custom-domain-btn`,children:`Cancel`})}),!M&&(0,U.jsx)(X,{type:`button`,"data-test":`continue-create-custom-domain-btn`,disabled:!m||P,onClick:()=>d(`details`),children:(0,U.jsx)(HI,{loading:!!m&&P,children:`Continue`})})]})]}):(0,U.jsxs)(U.Fragment,{children:[a&&(0,U.jsxs)(`div`,{className:`mt-2 mb-1 flex items-center justify-between gap-2`,children:[(0,U.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Project:`,` `,(0,U.jsx)(`span`,{className:`font-medium text-foreground`,children:m})]}),(0,U.jsx)(X,{type:`button`,variant:`ghost`,size:`sm`,"data-test":`change-project-custom-domain-btn`,onClick:()=>d(`project`),disabled:O.isPending,children:`Change`})]}),g?(0,U.jsx)(bD,{className:`h-9 mt-4`}):D.length>0?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(XY,{control:s.control,name:`environment`,render:({field:e})=>(0,U.jsxs)(QY,{className:`mt-2`,children:[(0,U.jsx)(yT,{htmlFor:`environment-field`,children:`Which environment do you want to apply your new domain to?`}),(0,U.jsx)(fR,{id:`environment-field`,"data-test":`environment-field`,environments:D,value:e.value,onValueChange:e.onChange,disabled:O.isPending,placeholder:`Select an environment`}),(0,U.jsx)(nX,{})]})}),E&&(0,U.jsx)(XY,{control:s.control,name:`stage`,render:({field:e})=>(0,U.jsxs)(QY,{className:`mt-2`,children:[(0,U.jsx)(yT,{className:`block`,htmlFor:`stage-field`,children:`What do you want the custom domain to be assigned to?`}),(0,U.jsxs)(CY,{onValueChange:t=>{(t===`api`||t===`dev-portal`)&&e.onChange(t)},disabled:O.isPending,...e,children:[(0,U.jsx)(TY,{id:`stage-field`,className:`w-full`,children:(0,U.jsx)(wY,{placeholder:`Select a stage`})}),(0,U.jsxs)(EY,{children:[(0,U.jsx)(DY,{value:`api`,children:(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(cf,{size:16}),` Gateway`]})}),(0,U.jsx)(DY,{value:`dev-portal`,children:(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(Yf,{size:16}),` Dev Portal`,(0,U.jsx)(rT,{className:``,variant:`info`,children:`New`})]})})]})]}),(0,U.jsx)(nX,{})]})}),(0,U.jsx)(XY,{control:s.control,name:`hostname`,render:({field:e})=>(0,U.jsxs)(QY,{className:`mt-2`,children:[(0,U.jsx)(yT,{htmlFor:`hostname-field`,children:`Your custom domain (e.g. example.com or api.example.com)`}),(0,U.jsx)(gT,{type:`text`,autoComplete:`off`,placeholder:`api.example.com`,id:`hostname-field`,"data-test":`hostname-field`,...e,disabled:O.isPending}),(0,U.jsx)(nX,{})]})}),(0,U.jsx)(XY,{control:s.control,name:`isAlias`,render:({field:e})=>(0,U.jsx)(QY,{className:W((!_||p===`dev-portal`||w)&&`hidden`,`mt-2`),children:(0,U.jsxs)(CA,{className:`p-4 flex items-center gap-3`,children:[(0,U.jsxs)(yT,{className:`flex flex-col gap-2`,htmlFor:`isAlias`,children:[`Is this an alias domain?`,(0,U.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`If your API Gateway is behind a CDN or WAF, your clients may use a different domain. Use an`,` `,(0,U.jsx)(hT,{href:`https://zuplo.com/docs/articles/custom-domains#alias-domains`,target:`_blank`,rel:`noreferrer`,className:`underline`,children:`alias domain`}),` `,`so public URLs like docs and OpenAPI match the client-facing domain.`]})]}),(0,U.jsx)(PGt,{className:`mx-3`,id:`isAlias`,"data-test":`isAlias`,checked:e.value??!1,onCheckedChange:e.onChange,disabled:O.isPending}),(0,U.jsx)(nX,{})]})})}),(0,U.jsxs)(`div`,{className:`mt-5 sm:mt-4 flex justify-end gap-x-4`,children:[a?(0,U.jsx)(X,{type:`button`,variant:`secondary`,"data-test":`back-create-custom-domain-btn`,disabled:O.isPending,onClick:()=>d(`project`),children:`Back`}):(0,U.jsx)(cw,{asChild:!0,children:(0,U.jsx)(X,{type:`button`,"data-test":`cancel-create-custom-domain-btn`,disabled:O.isPending,variant:`secondary`,children:`Cancel`})}),(0,U.jsx)(X,{type:`submit`,"data-test":`create-custom-domain-btn`,disabled:O.isPending,children:(0,U.jsx)(HI,{loading:O.isPending,children:`Create`})})]})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`p`,{className:`mt-4`,children:`Custom domains can only be configured on edge deployment environments and this project only has a working-copy environment.`}),(0,U.jsx)(`br`,{}),(0,U.jsxs)(`p`,{children:[` `,`For more information on this see our`,` `,(0,U.jsx)(hT,{href:`https://zuplo.com/docs/articles/environments`,children:`documentation on environments`}),`.`]}),a&&(0,U.jsx)(`div`,{className:`mt-5 sm:mt-4 flex justify-end`,children:(0,U.jsx)(X,{type:`button`,variant:`secondary`,"data-test":`back-create-custom-domain-btn`,onClick:()=>d(`project`),children:`Back`})})]})]})})]})})]})})]}),(0,U.jsx)(bL,{open:A.showConfirm,onOpenChange:A.setShowConfirm,onDiscard:A.handleDiscard})]})},UGt=`https://zuplo.com/docs/dedicated/custom-domains`,WGt=({customDomain:e,isManagedDedicatedProject:t,isAkamaiManagedDedicatedProject:n})=>{let[r,i]=(0,H.useState)(void 0),a=()=>{s(),i(void 0)},[o,s]=M$(()=>{let i=r?.deployments.at(0)?.stage,o=r?.deployments.at(0)?.cname,s=typeof o==`string`&&o.length>0;return(0,U.jsx)(jL,{onClose:a,isOpen:!0,title:`Configure your custom domain`,children:(0,U.jsx)(`div`,{className:`space-y-4`,children:n?(0,U.jsx)(xGt,{}):t&&i===`api`?s?(0,U.jsx)(I7,{customDomain:r?.hostname,cname:o,documentationUrl:UGt}):(0,U.jsx)(L7,{}):e.provider===`custom`?(0,U.jsx)(L7,{}):e.provider===`amazon`?s?(0,U.jsx)(I7,{customDomain:r?.hostname,cname:o,documentationUrl:UGt}):(0,U.jsx)(L7,{}):s?(0,U.jsx)(I7,{customDomain:r?.hostname,cname:o}):(0,U.jsx)(L7,{})})})},[r]),c=e=>{i(e),o()};return(0,U.jsx)(X,{onClick:()=>{c(e)},"data-test":`view-domain-configuration-btn`,title:`View Configuration`,variant:`ghost`,size:`icon`,children:(0,U.jsx)(pf,{size:18})})},GGt=/held zone/i;function KGt(e){return!!e?.some(e=>GGt.test(e))}var qGt=new Set([`pending`,`pending_migration`,`pending_provisioned`,`active_redeploying`,`provisioned`]),JGt=new Set([`blocked`,`pending_blocked`,`moved`,`deleted`,`pending_deletion`,`test_blocked`,`test_failed`]),YGt=new Set([`initializing`,`pending_validation`,`pending_issuance`,`pending_deployment`,`pending_cleanup`,`staging_deployment`,`holding_deployment`]),XGt=new Set([`expired`,`deactivating`,`inactive`,`initializing_timed_out`,`validation_timed_out`,`issuance_timed_out`,`deployment_timed_out`,`deletion_timed_out`,`deleted`,`pending_deletion`,`pending_expiration`]);function ZGt(e){if(e.provider===`alias`)return null;if(e.provider===`custom`||e.provider===`amazon`)return{level:`unknown`,label:`Externally managed`,description:`This domain's status isn't reported to Zuplo — verification and certificates are handled by your dedicated infrastructure provider.`};let t=e.verificationErrors&&e.verificationErrors.length>0,n=e.status??null,r=e.sslStatus??null;if(!n&&!r&&!t)return{level:`pending`,label:`Initializing`,description:`We're waiting for the domain provider to report a status. This usually takes a few seconds after the domain is created.`};if(KGt(e.verificationErrors))return{level:`error`,label:`Zone hold`,description:`Cloudflare is blocking this hostname because the parent domain has a zone hold on another Cloudflare account. The zone owner needs to release the hold before we can finish provisioning.`,helpUrl:`https://developers.cloudflare.com/fundamentals/account/account-security/zone-holds/`,helpLabel:`How to release a zone hold`};if(t)return{level:`error`,label:`Needs attention`,description:`The domain provider reported verification errors. Review the details to resolve them.`};if(n&&JGt.has(n))return{level:`error`,label:R7(n),description:`The domain is in a state that prevents it from serving traffic. Contact support if this persists.`};if(r&&XGt.has(r))return{level:`error`,label:`SSL error`,description:`The SSL certificate is in the "${R7(r)}" state. The domain may not serve HTTPS traffic until this is resolved.`};let i=n===`active`||n===`test_active`||n===`test_active_apex`;return i&&(r===`active`||r===`staging_active`||r===`backup_issued`)?{level:`active`,label:`Active`,description:`The domain is verified and serving traffic over HTTPS.`}:i&&r&&YGt.has(r)?{level:`pending`,label:`Issuing certificate`,description:`The domain is verified. We're still provisioning the SSL certificate — this usually takes a few minutes.`}:n&&qGt.has(n)?{level:`pending`,label:`Verifying domain`,description:`We're waiting for DNS verification. Double-check the CNAME record at your DNS provider.`}:n||r?{level:`pending`,label:R7(n??r??`pending`),description:`The domain is still being set up. If this state persists, contact support.`}:{level:`unknown`,label:`Unknown`,description:`No status information is available for this domain.`}}function R7(e){return e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}var QGt={active:{dot:`bg-green-500`,pulse:!1,pill:`bg-green-50 text-green-700 border-green-200 hover:bg-green-100 dark:bg-green-950 dark:text-green-300 dark:border-green-800 dark:hover:bg-green-900`},pending:{dot:`bg-amber-500`,pulse:!0,pill:`bg-amber-50 text-amber-800 border-amber-200 hover:bg-amber-100 dark:bg-amber-950 dark:text-amber-300 dark:border-amber-800 dark:hover:bg-amber-900`},error:{dot:`bg-red-500`,pulse:!1,pill:`bg-red-50 text-red-700 border-red-200 hover:bg-red-100 dark:bg-red-950 dark:text-red-300 dark:border-red-800 dark:hover:bg-red-900`},unknown:{dot:`bg-gray-400`,pulse:!1,pill:`bg-gray-50 text-gray-700 border-gray-200 hover:bg-gray-100 dark:bg-gray-800 dark:text-gray-300 dark:border-gray-600 dark:hover:bg-gray-700`}},$Gt=({domain:e})=>{let t=ZGt(e);if(!t)return null;let n=QGt[t.level],r=e.verificationErrors??[];return(0,U.jsxs)(Vw,{children:[(0,U.jsx)(Hw,{asChild:!0,children:(0,U.jsxs)(`button`,{type:`button`,className:W(`inline-flex items-center gap-1.5 rounded-full border px-2 py-0.5 text-xs font-medium transition-colors focus:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,n.pill),"aria-label":`${e.hostname} status: ${t.label}`,children:[(0,U.jsxs)(`span`,{className:`relative flex size-2 items-center justify-center`,children:[n.pulse&&(0,U.jsx)(`span`,{className:W(`absolute inline-flex h-full w-full animate-ping rounded-full opacity-75`,n.dot)}),(0,U.jsx)(`span`,{className:W(`relative inline-flex size-2 rounded-full`,n.dot)})]}),t.label]})}),(0,U.jsx)(Uw,{align:`start`,className:`w-96`,children:(0,U.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`span`,{className:W(`inline-flex size-2 rounded-full`,n.dot)}),(0,U.jsx)(`span`,{className:`font-medium`,children:t.label})]}),(0,U.jsx)(`p`,{className:`text-muted-foreground`,children:t.description}),t.helpUrl&&(0,U.jsx)(hT,{href:t.helpUrl,className:`text-xs`,children:t.helpLabel??`Learn more`}),r.length>0&&(0,U.jsxs)(`div`,{className:`space-y-1`,children:[(0,U.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-wide text-muted-foreground`,children:`Verification errors`}),(0,U.jsx)(`ul`,{className:`list-disc pl-5 space-y-1 text-destructive-foreground`,children:r.map(e=>(0,U.jsx)(`li`,{children:e},e))})]})]})})]})},eKt=({account:e,currentDomainConfig:t})=>{let{logEvent:n,captureException:r}=S(),[i,a]=(0,H.useState)(``),[o,s]=(0,H.useState)(``),c=e=>{let t=e.target.value;a(t)},l=tWt(),u=async()=>{try{if(s(``),!t.hostname||t.hostname.trim()===``){s(`The current domain configuration does not have a hostname associated with it`);return}await l.mutateAsync({accountName:e.name,projectName:t.projectName??``,hostname:t.hostname,deploymentName:t.deployments[0]?.deploymentName}),n(`account-custom-domain-delete-success`,{account:e.name}),d()}catch(t){r(t);let i=ux(t);s(i),n(`account-custom-domain-delete-failed`,{account:e.name,errorMessage:i})}},d=()=>{p(),a(``),s(``)},[f,p]=M$(()=>(0,U.jsx)(jL,{onClose:d,isOpen:!0,title:`Delete custom domain`,className:`sm:max-w-xl`,children:(0,U.jsxs)(`div`,{className:`space-y-4`,children:[(0,U.jsx)(SA,{error:o,className:`mb-3`}),(0,U.jsxs)(`div`,{className:`text-sm text-foreground whitespace-pre-line w-full mb-2`,children:[(0,U.jsxs)(`div`,{className:`relative bg-yellow-100 dark:bg-yellow-950/40 rounded-sm p-4 text-yellow-900 dark:text-yellow-200 text-sm whitespace-pre-line w-full mb-2`,children:[(0,U.jsxs)(`div`,{className:`flex space-x-2 items-center`,children:[(0,U.jsx)(vd,{className:`h-5 w-5 text-yellow-900 dark:text-yellow-200`}),(0,U.jsx)(`span`,{className:`text-sm font-medium antialiased mt-0.5`,children:`Caution: Your project will no longer be accessible with this domain.`})]}),(0,U.jsxs)(`p`,{className:`px-2 mt-4`,children:[`You are about to delete the custom domain`,` `,(0,U.jsx)(`span`,{className:`font-medium antialiased`,children:t.hostname}),` `,`from your project. Requests using it will no longer reach your zup.`]})]}),(0,U.jsx)(`br`,{}),(0,U.jsxs)(`label`,{className:`block mb-2`,htmlFor:`hostname-field`,children:[`Please type`,` `,(0,U.jsx)(`span`,{className:`font-medium antialiased`,children:t.hostname}),` `,`to confirm.`]}),(0,U.jsx)(gT,{className:`mb-4`,type:`text`,autoComplete:`off`,value:i,onChange:c,id:`hostname-field`,"data-test":`hostname-field`}),(0,U.jsx)(`div`,{className:` text-red-500`,children:`I understand the consequences, delete this custom domain`})]}),(0,U.jsxs)(`div`,{className:`mt-5 sm:mt-4 flex justify-end gap-x-4`,children:[(0,U.jsx)(X,{onClick:d,"data-test":`cancel-delete-custom-domain-btn`,variant:`outline`,disabled:l.isPending,children:`Cancel`}),(0,U.jsx)(X,{"data-test":`delete-custom-domain-btn`,onClick:u,disabled:l.isPending||i!==t.hostname,children:(0,U.jsx)(HI,{loading:l.isPending,children:`Delete`})})]})]})}),[l.isPending,o,t,i]);return(0,U.jsx)(X,{type:`button`,title:`Delete Custom Domain`,onClick:f,"data-test-id":`delete-custom-domain-btn`,variant:`ghost`,size:`icon-sm`,children:(0,U.jsx)(HI,{loading:l.isPending,children:(0,U.jsx)(sp,{size:18})})})},tKt=/^(?!https?:\/\/)[a-zA-Z0-9.-]*\.[a-zA-Z]+$/,nKt=({account:e,projectName:t,currentDomainConfig:n})=>{let{logEvent:r,captureException:i}=S(),[a,o]=(0,H.useState)(``),[s,c]=(0,H.useState)(!1),[l,u]=(0,H.useState)(n.deployments[0]?.deploymentName),d=n.hostname,{data:f,error:p}=wR(e.name,t),m=ux(p);(0,H.useEffect)(()=>{m&&o(m)},[m]);let h=f?f.filter(e=>e.environmentType!==kL.WORKING_COPY):[],g=eWt(),_=async n=>{if(n.preventDefault(),!l||l.trim()===``){o(`Please select an environment from the options available`);return}if(!d||d.trim()===``){o(`Please provide a value on the custom domain field.`);return}if(d&&!tKt.test(d)){o(`A custom domain value should only be the domain name. It should not start with 'http(s)' and should end with an alpha character.`);return}try{o(``),await g.mutateAsync({accountName:e.name,projectName:t,hostname:d,deploymentName:l}),c(!0),r(`account-custom-domain-edit-success`,{account:e.name})}catch(t){i(t);let n=ux(t);r(`account-custom-domain-edit-failed`,{account:e.name,errorMessage:n}),o(n),c(!1)}},v=()=>{b(),u(n.deployments[0]?.deploymentName),o(``),c(!1)},[y,b]=M$(()=>(0,U.jsx)(jL,{onClose:v,isOpen:!0,title:`Edit your custom domain`,children:(0,U.jsxs)(`div`,{className:`space-y-4`,children:[(0,U.jsx)(SA,{error:a}),(0,U.jsxs)(`div`,{className:`text-left text-sm text-foreground whitespace-pre-line w-full mb-2`,children:[s===!1&&(0,U.jsxs)(`form`,{onSubmit:_,children:[(0,U.jsx)(`label`,{className:`block mb-2`,htmlFor:`environment-field`,children:`Which environment do you want to apply your custom domain to ?`}),(0,U.jsx)(`div`,{className:`mb-9`,children:(0,U.jsx)(fR,{id:`environment-field`,"data-test":`environment-field`,environments:h,value:l??``,onValueChange:e=>u(e),disabled:g.isPending,placeholder:`Select an environment`})}),(0,U.jsx)(`label`,{className:`block mb-2`,htmlFor:`hostname-field`,children:`Your custom domain`}),(0,U.jsx)(gT,{className:`mb-9`,type:`text`,autoComplete:`off`,placeholder:`api.example.com`,id:`hostname-field`,value:d,disabled:!0,"data-test":`hostname-field`}),(0,U.jsxs)(`div`,{className:`mt-5 sm:mt-4 flex justify-end gap-x-4`,children:[(0,U.jsx)(X,{variant:`outline`,type:`button`,onClick:v,"data-test":`cancel-edit-custom-domain-btn`,disabled:g.isPending,children:`Cancel`}),(0,U.jsx)(X,{"data-test":`save-edit-custom-domain-btn`,type:`submit`,disabled:g.isPending||l===n.deployments[0]?.deploymentName,children:(0,U.jsx)(HI,{loading:g.isPending,children:`Save`})})]})]}),s===!0&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`div`,{className:`text-left text-sm text-foreground whitespace-pre-line w-full mb-2`,children:(0,U.jsxs)(`p`,{children:[`Successfully edited custom domain`,` `,(0,U.jsx)(hT,{href:`https://${d}`,children:d}),` `,`to map to deployment `,l]})}),(0,U.jsx)(`div`,{className:`mt-5 sm:mt-4 flex justify-end gap-x-4`,children:(0,U.jsx)(X,{variant:`outline`,className:`w-24 justify-center`,type:`button`,onClick:v,"data-test":`ok-edit-custom-domain-btn`,disabled:!s,children:`OK`})})]})]})]})}),[h,a]),x=()=>{y()};return(0,U.jsx)(X,{onClick:()=>x(),title:`Edit Custom Domain`,"data-test-id":`edit-custom-domain-btn`,variant:`ghost`,size:`icon-sm`,children:(0,U.jsx)(HI,{loading:g.isPending,children:(0,U.jsx)(Yd,{size:18})})})},rKt=({classNames:e,projectType:t,feature:n,helpUrl:r})=>(0,U.jsxs)(CA,{variant:`danger`,className:e,children:[(0,U.jsx)(wA,{children:t===`managed-dedicated`?`Managed Dedicated Project`:t===`self-hosted`?`Self Hosted Project`:`Managed Edge Project`}),(0,U.jsx)(DA,{className:`flex-1 leading-loose mt-1 text-sm`,children:(0,U.jsxs)(`p`,{className:`leading-loose`,children:[`Your project is running on a `,t===`managed-dedicated`?`managed dedicated`:t===`self-hosted`?`self hosted`:`managed edge hosted`,` environment. For information on how to setup up `,n,`, please refer to`,` `,(0,U.jsx)(hT,{href:r,children:`the documentation`}),`.`]})})]});function iKt(){return(0,U.jsx)(`button`,{type:`button`,disabled:!0,title:`Locked custom domain`,className:`items-center justify-center p-2 hover:bg-gray-100 rounded-sm cursor-pointer`,children:(0,U.jsx)(yf,{className:`h-5 w-5 mx-auto`,"aria-hidden":`true`})})}var aKt=`Custom Domains`,oKt=(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(hT,{href:`https://zuplo.com/docs/articles/custom-domains`,children:`Custom domains`}),` `,`allow you to use your own domain name for your API and developer portal. For complex custom domain configurations, please contact us at`,` `,(0,U.jsx)(hT,{href:`mailto:${ex}`,children:ex}),` `,`or use the chat widget at the bottom right.`]}),sKt=()=>{let e=Op([`account`,`project`]),t=nWt(e.account.name,e.project.name),n=qw(e.account.name,e.project.name);if(!t.data||!n.data)return(0,U.jsx)(N7,{title:aKt,description:oKt,children:(0,U.jsx)(l1,{})});let r=t.data?.filter(t=>t.projectName&&t.projectName===e.project.name&&t.deployments[0]).sort((e,t)=>e.deployments[0].deploymentName.localeCompare(t.deployments[0].deploymentName)),i=e.account.customDomainsInUse>=e.account.entitlements.customDomains,a=LGt({projectType:e.project.type,defaultConfiguration:n.data.defaultConfiguration}),o=FGt({projectType:e.project.type,defaultConfiguration:n.data.defaultConfiguration}),s=e.project.type!==`self-hosted`&&(a?!!e.account.entitlements.aliasDomains:e.account.entitlements.customDomains>0);return(0,U.jsxs)(N7,{title:aKt,description:oKt,action:s?(0,U.jsx)(HGt,{disabled:!a&&i,account:e.account,projectName:e.project.name,isManagedDedicatedProject:o,isAkamaiManagedDedicatedProject:a}):void 0,children:[i&&e.account.entitlements.customDomains>0&&e.project.type!==`self-hosted`&&!a&&(0,U.jsx)(yGt,{account:e.account,source:`custom-domain-limit`}),!i&&e.project.type!==`self-hosted`&&!a&&(0,U.jsx)(bGt,{used:e.account.customDomainsInUse,max:e.account.entitlements.customDomains,label:`custom domains`,account:e.account,hideAtLimit:!0}),a&&!!e.account.entitlements.aliasDomains&&(0,U.jsx)(Ub,{variant:`info`,className:`text-sm`,children:(0,U.jsx)(Gb,{children:(0,U.jsxs)(`p`,{children:[`This project uses Akamai managed dedicated hosting. Configure the hostname in your Akamai CDN first — see the`,` `,(0,U.jsx)(hT,{href:`https://zuplo.com/docs/dedicated/akamai/cdn`,children:`Akamai custom domain documentation`}),`. Once it's set up there, add the domain using the button above to register it with Zuplo.`]})})}),r.length>0?(0,U.jsx)(CA,{className:`overflow-hidden`,children:r.map(t=>{let n=t.deployments[0],r=o&&n?.stage===`api`,i=t.provider===`custom`&&!r,s=t.provider===`alias`,c=n.stage===`dev-portal`,l=a&&!s||i;return(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-4 border-b px-4 py-3 last:border-0`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0 flex-1`,children:[(0,U.jsx)(`div`,{className:`shrink-0 flex size-9 items-center justify-center rounded-md bg-muted text-muted-foreground`,children:c?(0,U.jsx)(Yf,{className:`size-4`}):(0,U.jsx)(cf,{className:`size-4`})}),(0,U.jsxs)(`div`,{className:`flex flex-col min-w-0 gap-1`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,U.jsxs)(`a`,{href:`https://${t.hostname}`,target:`_blank`,rel:`noreferrer`,className:`font-medium text-sm text-foreground hover:underline inline-flex items-center gap-1 truncate`,children:[(0,U.jsx)(`span`,{className:`truncate`,children:t.hostname}),(0,U.jsx)(Vd,{className:`size-3 shrink-0 opacity-60`})]}),(0,U.jsx)($Gt,{domain:t}),n.isDefault&&(0,U.jsx)(rT,{variant:`outline`,className:`text-xs`,children:`Default`}),s&&(0,U.jsx)(rT,{variant:`outline`,className:`text-xs`,children:`Alias`})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-muted-foreground flex-wrap`,children:[(0,U.jsx)(`span`,{className:`inline-flex items-center gap-1`,children:c?`Dev Portal`:`API`}),(0,U.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,U.jsxs)(`span`,{children:[(0,U.jsx)(Jze,{env:n.environmentType??null}),` `,`(`,n.deploymentName,`)`]}),n.branch&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1 font-mono`,children:[(0,U.jsx)(of,{className:`size-3`}),n.branch]})]})]})]})]}),(0,U.jsxs)(`div`,{className:`shrink-0 flex items-center gap-1`,children:[!s&&(0,U.jsx)(WGt,{customDomain:t,isManagedDedicatedProject:o,isAkamaiManagedDedicatedProject:a}),l?(0,U.jsx)(iKt,{}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(nKt,{account:e.account,projectName:e.project.name,currentDomainConfig:t}),(0,U.jsx)(eKt,{account:e.account,currentDomainConfig:t})]})]})]},t.id)})}):s?(0,U.jsx)(CA,{children:(0,U.jsxs)(qb,{children:[(0,U.jsxs)(Jb,{children:[(0,U.jsx)(Yb,{variant:`icon`,children:(0,U.jsx)(cf,{})}),(0,U.jsx)(Xb,{children:`No custom domains yet`}),(0,U.jsx)(Zb,{children:`Serve your API and developer portal from your own domain name.`})]}),(0,U.jsx)(Qb,{children:(0,U.jsx)(HGt,{disabled:!a&&i,account:e.account,projectName:e.project.name,isManagedDedicatedProject:o,isAkamaiManagedDedicatedProject:a})})]})}):null,e.project.type===`self-hosted`?(0,U.jsx)(rKt,{classNames:``,feature:`custom domains`,helpUrl:`https://zuplo.com/docs/dedicated/custom-domains`,projectType:e.project.type}):a&&!e.account.entitlements.aliasDomains?(0,U.jsx)(xGt,{}):!a&&e.account.entitlements.customDomains<=0?(0,U.jsx)(yGt,{account:e.account,source:`custom-domain`}):null]})},cKt=e=>{let t=document.createRange();return t.selectNodeContents(e),t.getBoundingClientRect().width>e.getBoundingClientRect().width},lKt=()=>{let[e,t]=(0,H.useState)(!1);return{tooltipProps:(0,H.useMemo)(()=>{if(!e)return{open:!1}},[e]),triggerProps:(0,H.useMemo)(()=>({ref:e=>{e&&t(cKt(e))}}),[])}};function uKt({isSecret:e}){return e?(0,U.jsx)(yf,{className:`h-4 w-auto`}):(0,U.jsx)(Ad,{className:`h-4 w-auto`})}var dKt=({variable:e,asIcon:t=!1})=>(0,U.jsxs)(AIt,{children:[(0,U.jsx)(jIt,{asChild:!0,children:t?(0,U.jsx)(X,{variant:`ghost`,size:`icon`,className:`flex items-center`,children:(0,U.jsx)(Ad,{className:`w-4 h-4`})}):(0,U.jsxs)(X,{variant:`secondary`,size:`default`,className:`flex items-center gap-2`,children:[(0,U.jsx)(Ad,{className:`w-4 h-4`}),`Get Code Snippet`]})}),(0,U.jsxs)(v6,{side:`right`,className:`sm:max-w-none w-1/3 min-w-[500px]`,children:[(0,U.jsx)(`div`,{className:`text-lg font-semibold border-b`,children:`Code Snippets`}),(0,U.jsx)(`p`,{className:`my-2 text-sm`,children:`Use this Code Snippet anywhere in your modules to access your environment variable.`}),(0,U.jsx)(CA,{offset:`md`,className:`bg-gray-200 text-xs `,children:(0,U.jsxs)(`pre`,{id:`codePre`,"data-lang":`typescript`,className:`font-mono text-gray-900 overflow-x-auto`,children:[`import `,`{`,` environment `,`}`,` from "@zuplo/runtime";`,`\r
1581
1581
  \r
1582
- `,`const ${e.name} = environment.${e.name};\r\n`]})})]})]}),fKt=e=>{let t=[];return e.targets.includes(`production`)&&t.push(`production`),e.targets.includes(`preview`)&&t.push(e.targetBranch??`preview`),e.targets.includes(`working-copy`)&&t.push(`development`),t.join(`, `)};function pKt({variable:e,account:t,project:n,previewEnvironments:r}){let i=iBe(),{logEvent:a}=S(),[o,c]=(0,H.useState)(),[l,u]=(0,H.useState)(!1),{tooltipProps:d,triggerProps:f}=lKt(),{tooltipProps:p,triggerProps:m}=lKt(),[h,g]=M$(()=>{let r=async()=>{g(),await i.mutateAsync({accountName:t,projectName:n.name,id:e.id}),a(`env-var-deleted`,{account:t,project:n.name,id:e.id})},c=`Error deleting Environment Variable`,l=`We found an error trying to remove the variable.`;return o instanceof s&&(c=o.title??c,l=o.detail??l),(0,U.jsx)(vQ,{alertType:`ERROR`,bodyText:l,onPrimaryButtonClick:r,onSecondaryButtonClick:g,primaryButtonText:`Try again`,secondaryButtonText:`Cancel`,hideModal:g,title:c})},[e,r,o]),_=async()=>{try{await i.mutateAsync({accountName:t,projectName:n.name,id:e.id}),a(`env-var-deleted`,{account:t,project:n.name,id:e.id}),u(!1)}catch(r){a(`env-var-deletion-failed`,{account:t,project:n.name,id:e.id}),u(!1),c(r instanceof Error?r:Error(r)),h()}},[v,y]=M$(()=>(0,U.jsx)(bR,{project:n,variable:e,previewEnvironments:r,onClose:y,account:t}),[e,r]),b=e.personalValue??e.value;return(0,U.jsxs)(`div`,{className:`grid grid-cols-subgrid col-span-full gap-4 items-center border-b px-4 py-3 last:border-0`,children:[(0,U.jsxs)(k$,{open:l,onOpenChange:u,onClickDelete:_,isPending:i.isPending,deleteButtonText:`Confirm`,children:[`Are you sure you want to delete the variable '`,e.name,`'`]}),(0,U.jsx)(`div`,{className:`rounded-full border w-10 h-10 flex items-center justify-center`,children:(0,U.jsx)(uKt,{isSecret:e.type===`secret`})}),(0,U.jsxs)(`div`,{className:`flex flex-row justify-between items-center truncate`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col truncate`,children:[(0,U.jsxs)(oR,{...p,delayDuration:0,children:[(0,U.jsx)(sR,{...m,asChild:!0,children:(0,U.jsx)(`span`,{className:`font-mono text-sm truncate`,"data-test":`env-variable-name`,children:e.name})}),(0,U.jsxs)(cR,{className:`font-mono`,children:[(0,U.jsx)(lR,{}),e.name]})]}),(0,U.jsx)(`div`,{className:`text-sm text-neutral-500 line-clamp-2`,children:fKt(e)})]}),e.personalValue&&(0,U.jsx)(`div`,{className:`bg-zuplo-highlight rounded-full text-2xs text-white px-2 py-1 mx-2 flex-none`,children:`PERSONAL`})]}),(0,U.jsx)(`div`,{"data-test":`env-variable-value`,className:`truncate flex text-xs font-mono`,children:b?(0,U.jsxs)(oR,{...d,children:[(0,U.jsx)(sR,{asChild:!0,...f,children:(0,U.jsx)(`div`,{className:`bg-muted p-1 px-2 rounded-sm max-w-96 truncate`,children:e.type===`config`?b:`************`})}),(0,U.jsxs)(cR,{className:`text-xs`,children:[(0,U.jsx)(lR,{}),b]})]}):(0,U.jsx)(rT,{variant:`outline`,children:`No value`})}),(0,U.jsxs)(`div`,{className:`flex gap-2 justify-end`,children:[(0,U.jsx)(dKt,{variable:e,asIcon:!0}),(0,U.jsx)(X,{size:`icon`,variant:`ghost`,type:`button`,"data-test":`env-variable-edit`,onClick:()=>{v()},children:(0,U.jsx)(Uf,{size:18})}),(0,U.jsx)(X,{size:`icon`,variant:`ghost`,"data-test":`env-variable-delete`,onClick:()=>{u(!0)},children:i.isPending?(0,U.jsx)(WI,{className:`w-4 h-4`,borderPositionAndSize:`border-2`}):(0,U.jsx)(sp,{size:18})})]})]},e.name)}var z7=`___EMPTY___`,B7=`Environment Variables`,V7=`Configuration and secrets available to your environments at build and runtime. Changes take effect on the next deployment.`;function mKt(){let e=Op([`account`,`project`]),{logEvent:t}=S(),n=vR(e.account.name,e.project.name),r=!!e.project.sourceRepoUrl,i=wR(e.account.name,e.project.name),a=[{label:`All`,value:z7},{label:`Production`,value:`production`},{label:`Preview (other branches)`,value:`preview`},{label:`Development`,value:`working-copy`}],[o,s]=(0,H.useState)(z7),[c,l]=(0,H.useState)(z7),[u,d]=(0,H.useState)(``),f=i.data?.filter(e=>!AL(e.environmentType,kL.PRODUCTION,kL.WORKING_COPY))??[],p=f.map(e=>e.branchName),m=(0,H.useMemo)(()=>[z7,...p],[p]),h=(0,H.useMemo)(()=>n.data??[],[n.data]),g=(0,H.useMemo)(()=>h.filter(e=>o===z7||e.targets.includes(o)),[h,o]),_=vX(u,(0,H.useMemo)(()=>o!==`preview`||c===z7?g:g.filter(e=>e.targets.includes(`preview`)&&e.targetBranch===c),[g,o,c]),{key:`id`,getText:e=>[e.name,e.type,e.value,...e.targets,e.targetBranch].filter(Boolean)}),[v,y]=M$(()=>(0,U.jsx)(CR,{account:e.account.name,project:e.project,previewEnvironments:f,onClose:y}),[f]);if(n.isError)return(0,U.jsx)(N7,{title:B7,description:V7,children:(0,U.jsx)(gze,{error:n.error})});if(!n.data||r&&!i.data)return(0,U.jsx)(N7,{title:B7,description:V7,children:(0,U.jsx)(l1,{})});let b=o!==z7||c!==z7&&c!==``||u!==``;return(0,U.jsxs)(N7,{title:B7,description:V7,action:(0,U.jsxs)(X,{onClick:v,children:[(0,U.jsx)(Mf,{size:16}),`Add variable`]}),children:[(0,U.jsxs)(`div`,{className:`flex flex-row items-center gap-3`,children:[(0,U.jsx)(gT,{type:`search`,placeholder:`Search variables`,className:`max-w-xs`,value:u,onChange:n=>{d(n.currentTarget.value),t(`env-var-filter-changed`,{account:e.account.name,project:e.project.name,query:n.currentTarget.value})}}),(0,U.jsxs)(CY,{value:o,onValueChange:e=>{s(e),e!==`preview`&&l(``)},children:[(0,U.jsx)(TY,{className:`w-52`,"data-test":`env-variable-filter`,children:(0,U.jsx)(wY,{})}),(0,U.jsx)(EY,{className:`w-52`,children:a.map((e,t)=>(0,U.jsx)(DY,{value:e.value,"data-test":`env-variable-filter-${t}`,children:e.label},e.value))})]}),o===`preview`?(0,U.jsxs)(CY,{value:c,onValueChange:e=>{l(e)},children:[(0,U.jsx)(TY,{className:`w-52`,"data-test":`env-variable-branch-filter`,children:(0,U.jsx)(wY,{})}),(0,U.jsx)(EY,{className:`w-52`,children:m.map(e=>(0,U.jsx)(DY,{value:e,children:e===z7?`All branches`:e},e))})]}):null]}),_.length>0?(0,U.jsx)(CA,{className:`grid grid-cols-[min-content_minmax(auto,250px)_1fr_auto] overflow-hidden`,children:_.map(t=>(0,U.jsx)(pKt,{account:e.account.name,project:e.project,previewEnvironments:f,variable:t},t.id))}):(0,U.jsx)(CA,{children:b?(0,U.jsxs)(qb,{children:[(0,U.jsxs)(Jb,{children:[(0,U.jsx)(Yb,{variant:`icon`,children:(0,U.jsx)(Bf,{})}),(0,U.jsx)(Xb,{children:`No matching variables`}),(0,U.jsx)(Zb,{children:`No environment variables match the current search or filter.`})]}),(0,U.jsx)(Qb,{children:(0,U.jsx)(X,{variant:`outline`,onClick:()=>{d(``),s(z7),l(z7)},children:`Clear filters`})})]}):(0,U.jsxs)(qb,{children:[(0,U.jsxs)(Jb,{children:[(0,U.jsx)(Yb,{variant:`icon`,children:(0,U.jsx)(Xf,{})}),(0,U.jsx)(Xb,{children:`No environment variables yet`}),(0,U.jsxs)(Zb,{className:`max-w-md`,children:[`Variables you add here are provided to your environments during build and at runtime.`,` `,(0,U.jsx)(hT,{href:`https://zuplo.com/docs/deployments/environment-variables`,children:`Read the docs`}),`.`]})]}),(0,U.jsx)(Qb,{children:(0,U.jsxs)(X,{onClick:v,children:[(0,U.jsx)(Mf,{size:16}),`Add your first variable`]})})]})})]})}var hKt=({projectName:e,closeModalAction:t,accountName:n,onFinishDeletion:r})=>{let{logEvent:i,captureException:a}=S(),[o,s]=(0,H.useState)(!1),[c,l]=(0,H.useState)(null),u=t=>{s(t.target.value===e)},d=FOe(n,e);return(0,U.jsx)(hmt,{alertType:`DELETE`,isOpen:!0,title:`Delete Project`,setIsOpen:t,secondaryButtonContent:`Cancel`,secondaryButtonTestID:`project-list-close-delete-project-modal`,onSecondaryButtonClick:t,primaryButtonTestID:`project-list-delete-project-button`,secondaryButtonDisabled:d.isPending,primaryButtonDisabled:!o||d.isPending,primaryButtonContent:`Delete`,onPrimaryButtonClick:async()=>{try{l(null),await d.mutateAsync(),i(`project-deleted`,{account:n,project:e}),r?.(),t()}catch(t){i(`project-deletion-failed`,{account:n,project:e}),a(t),l(ux(t))}},bodyElement:(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(SA,{error:c}),(0,U.jsx)(`p`,{className:`text-sm`,children:`This cannot be undone! Your GitHub repository will be untouched.`}),(0,U.jsxs)(`p`,{className:`text-sm`,children:[`Please type `,(0,U.jsx)(`strong`,{onDoubleClick:e=>{let t=e.currentTarget,n=new Range;n.setStart(t,0),n.setEnd(t,1),document.getSelection()?.removeAllRanges(),document.getSelection()?.addRange(n)},children:e}),` `,`to confirm.`]}),(0,U.jsx)(gT,{disabled:d.isPending,type:`text`,className:`mt-2`,autoFocus:!0,autoComplete:`off`,onChange:u})]})})};function gKt(){let e=sx([`account`,`project`]),t=ao(),[n,r]=M$(()=>(0,U.jsx)(hKt,{projectName:e.project,accountName:e.account,closeModalAction:r,onFinishDeletion:()=>t(`/`)}),[]);return(0,U.jsxs)(CA,{variant:`danger`,children:[(0,U.jsxs)(wA,{children:[(0,U.jsx)(TA,{children:`Delete Project`}),(0,U.jsx)(EA,{children:`Permanently delete this project and all associated data. This cannot be undone, there is no going back.`})]}),(0,U.jsx)(DA,{className:`leading-loose text-sm`,children:`Your GitHub repository will remain untouched.`}),(0,U.jsx)(OA,{variant:`danger`,className:`justify-end`,children:(0,U.jsxs)(X,{"data-test":`delete-button`,variant:`destructive`,onClick:n,children:[(0,U.jsx)(sp,{size:16}),`Delete Project`]})})]})}var _Kt=({children:e,copyValue:t})=>{let{logEvent:n}=S();return(0,U.jsxs)(`div`,{className:`mb-2 md:mb-0`,children:[e,t&&(0,U.jsx)(GI,{className:`relative top-1`,onClick:()=>{n(`project-information-property-copied`)},textToCopy:t})]})},vKt=()=>{let{logEvent:e}=S(),t=Op([`account`,`project`]);if(!wR(t.account.name,t.project.name).data)return(0,U.jsx)(`div`,{className:`p-6`,children:(0,U.jsx)(l1,{})});let n=[];return n.push({label:`Project Name`,value:t.project.name}),n.push({label:`Account Name`,value:t.account.name}),(0,U.jsxs)(CA,{children:[(0,U.jsxs)(wA,{children:[(0,U.jsx)(TA,{children:`Project Information`}),(0,U.jsx)(EA,{})]}),(0,U.jsx)(DA,{children:(0,U.jsx)(`div`,{className:`grid gap-2 grid-cols-1 md:grid-cols-[150px_1fr] text-sm mt-2`,children:n.map(t=>(0,U.jsxs)(H.Fragment,{children:[(0,U.jsx)(`div`,{className:`font-medium`,children:t.label}),(0,U.jsx)(_Kt,{copyValue:t.value,children:t.isLink?(0,U.jsx)(hT,{href:t.value,onClick:()=>{e(`project-information-link-clicked`,{label:t.label,value:t.value})},className:`break-all`,children:t.value}):t.value})]},t.value))})})]})},yKt=()=>(0,U.jsxs)(N7,{title:`General`,description:`Project name, identifiers, and lifecycle.`,children:[(0,U.jsx)(vKt,{}),(0,U.jsx)(gKt,{})]}),bKt={admin:`Admin`,developer:`Developer`,member:`Member`,"ai-user":`AI User`,"no-access":`No Access`},H7=(e,t)=>e!==`no-access`&&(t||e===`admin`),xKt=({value:e,hiddenRoles:t=[],aiProject:n=!1,...r})=>{let i=Ep(),a=Op([`account`]).account.entitlements.rbacEnabled,o=UC.filter(r=>!t.concat([`no-access`]).includes(r)&&(r!==`ai-user`||n&&(a||e===`ai-user`)));return(0,U.jsxs)(CY,{...r,value:e,onValueChange:e=>{H7(e,a)?r.onValueChange?.(e):i.toast((0,U.jsxs)(U.Fragment,{children:[`This role is not available for your account. Please upgrade to the Enterprise plan.`,` `,(0,U.jsx)(hT,{href:`https://zuplo.com/docs/articles/accounts/roles-and-permissions`,target:`_blank`,children:`Learn more about roles and permissions.`})]}))},children:[(0,U.jsx)(TY,{className:`min-w-40`,children:(0,U.jsx)(wY,{placeholder:`Select a role`})}),(0,U.jsx)(EY,{className:`min-w-40`,children:o.map(e=>(0,U.jsx)(DY,{value:e,onClick:t=>{H7(e,a)||(t.preventDefault(),t.stopPropagation(),window.open(`https://zuplo.com/docs/articles/accounts/roles-and-permissions`,`_blank`))},children:(0,U.jsxs)(`div`,{className:`grid grid-cols-2`,children:[bKt[e],!H7(e,a)&&(0,U.jsx)(rT,{variant:`outline`,className:``,children:`Enterprise`})]})},e))})]})},SKt={zuplo:{viewBox:[0,0,308,308],ink:[41.36,259.74],Glyph:()=>(0,U.jsxs)(`g`,{fillRule:`nonzero`,fill:`none`,children:[(0,U.jsx)(`path`,{d:`M0 0h308v308H0z`}),(0,U.jsx)(`path`,{d:`M214.523 182.007h-74.088l78.939-79.076a5.34 5.34 0 0 0-.807-8.204 5.314 5.314 0 0 0-2.957-.899H90.239V41.364h137.515a53.31 53.31 0 0 1 28.617 7.922 53.444 53.444 0 0 1 19.967 22.011 52.117 52.117 0 0 1 4.221 31.194 52.062 52.062 0 0 1-14.508 27.924l-51.528 51.592Z`,fill:`currentColor`}),(0,U.jsx)(`path`,{d:`M90.24 119.097h74.092l-78.781 78.917a5.431 5.431 0 0 0-1.172 5.912 5.423 5.423 0 0 0 5.001 3.351h125.017v52.464H77.016a53.322 53.322 0 0 1-28.616-7.923 53.453 53.453 0 0 1-19.968-22.011 52.109 52.109 0 0 1-4.219-31.194 52.059 52.059 0 0 1 14.51-27.924l51.517-51.592Z`,fill:`currentColor`})]})},akamai:{viewBox:[344.42,285.18,451,489.75],ink:[285.18,774.93],Glyph:()=>(0,U.jsxs)(`g`,{fill:`currentColor`,children:[(0,U.jsx)(`path`,{d:`M592.85,764.11c-100.8-30.77-174.12-123.92-174.12-234.05s74.88-205.29,177.4-235.02c10.48-3.06,7.73-9.86-4.91-9.86-136.28,0-246.8,109.69-246.8,244.89s110.51,244.86,246.8,244.86c12.63,0,13.14-7.3,1.63-10.81Z`}),(0,U.jsx)(`path`,{d:`M465.48,587.42c-.68-6.58-1.01-13.23-1.01-19.94,0-107.36,87.05-194.39,194.43-194.39,101.52,0,132,45.31,135.78,42.35,4.12-3.26-36.84-93.07-156.05-93.07-107.39,0-194.44,87.03-194.44,194.39,0,24.84,4.65,48.52,13.13,70.31,3.58,9.14,9.08,9.22,8.17.35Z`}),(0,U.jsx)(`path`,{d:`M546.92,447.31c50.53-22.03,114.01-22.7,176.42-.89,41.91,14.62,66.2,35.5,68.19,34.64,3.31-1.43-24.38-45.28-74.36-64.24-60.51-22.93-125.69-10.93-173.18,26.32-5.22,4.11-3.25,6.87,2.93,4.17Z`})]})}},CKt=({mark:e,...t})=>(0,U.jsx)(`svg`,{viewBox:e.viewBox.join(` `),xmlns:`http://www.w3.org/2000/svg`,...t,children:(0,U.jsx)(e.Glyph,{})}),wKt=({viewBox:[e,t,n,r],ink:[i,a]})=>{let o=n/2,s=(a-i)*.07,c=o/2,l=e-o,u=e+n+o,d=t+r+s;return{surface:`M${l} ${t}${Array.from({length:Math.round((u-l)/c)},(e,t)=>`q${c/2} ${t%2==0?-2*s:2*s} ${c} 0`).join(``)}L${u} ${d}L${l} ${d}Z`,period:o,empty:a-t+s,full:i-t-s}},TKt=({mark:e})=>{let t=(0,H.useId)(),[n,r,i,a]=e.viewBox,{surface:o,period:s,empty:c,full:l}=wKt(e);return(0,U.jsxs)(`svg`,{viewBox:e.viewBox.join(` `),xmlns:`http://www.w3.org/2000/svg`,"aria-hidden":`true`,className:`absolute inset-0 size-full text-zuplo-pink`,style:{"--logo-fill-empty":`${c}px`,"--logo-fill-full":`${l}px`,"--logo-fill-period":`${s}px`},children:[(0,U.jsx)(`mask`,{id:t,maskUnits:`userSpaceOnUse`,x:n,y:r,width:i,height:a,children:(0,U.jsxs)(`g`,{className:`logo-fill-level`,children:[(0,U.jsx)(`path`,{className:`logo-fill-wave`,d:o,fill:`#fff`}),(0,U.jsx)(`path`,{className:`logo-fill-wave`,d:o,fill:`#fff`})]})}),(0,U.jsx)(`g`,{mask:`url(#${t})`,children:(0,U.jsx)(e.Glyph,{})})]})},EKt=({variant:e=`full`,className:t,width:n,height:r,fillOnHover:i=!1})=>{let a=BWt();if(e===`mark`){let e=SKt[a.id],o=(0,U.jsx)(CKt,{mark:e,className:t,width:n,height:r,role:`img`,"aria-label":a.logoAlt});return i?(0,U.jsxs)(`span`,{className:`group relative flex`,children:[o,(0,U.jsx)(TKt,{mark:e})]}):o}return e===`full`&&a.logoDark?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`img`,{src:a.logo,alt:a.logoAlt,className:W(t,`dark:hidden`),width:n,height:r}),(0,U.jsx)(`img`,{src:a.logoDark,alt:a.logoAlt,className:W(t,`hidden dark:inline`),width:n,height:r})]}):(0,U.jsx)(`img`,{src:e===`white`?a.logoWhite:a.logo,alt:a.logoAlt,className:W(t),width:n,height:r})},DKt=()=>(0,U.jsx)(`div`,{className:`h-0 flex flex-col items-center -translate-y-14 mb-2`,children:(0,U.jsx)(EKt,{variant:`white`,className:`h-17 w-auto rounded-full bg-zuplo-pink p-4 shadow-xs`})}),OKt=(e,t,n)=>{let[r,i]=(0,H.useState)(t),a=XR(n);return[e===void 0?r:e,(0,H.useCallback)(t=>{e===void 0?i(t):a.current?.(t)},[e,a])]},kKt=Ym({email:Gm().email(`Invalid email address`),role:Zm([`admin`,`developer`,`member`,`ai-user`])}),AKt=({inviteOnly:e=!1,account:t,project:n,pool:r,description:i,hiddenRoles:a,children:o,open:s,onOpenChange:c,excludeUserIds:l,changeRoleForUserIds:u})=>{let d=Op([`account`]),{logEvent:f}=S(),[p,m]=OKt(s,!1,c),[h,g]=(0,H.useState)(!1),[_,v]=(0,H.useState)(!1),y=bt(),{onError:b,onSuccess:x}=CL(),C=d.account.entitlements.rbacEnabled,w=vA({resolver:xA(kKt),defaultValues:{email:``,role:C?`member`:`admin`}}),T=C?`member`:`admin`,E=ox(je.authAccountUsersRoles(t),{extractData:!0}),D=w.watch(`email`),O=XR(()=>{w.reset(),g(!1)});(0,H.useEffect)(()=>{p||O.current()},[p,O]);let k=Oe({mutationFn:({email:e,role:i})=>{let a=r&&n?{account:{role:T},project:{name:n,role:T},team:{...r,role:i}}:n?{account:{role:T},project:{name:n,role:i}}:{account:{role:i}},o=E?.data?.find(t=>t.email===e)?.id;return!h&&o&&u?.includes(o)?y.fetch(ae.auth.updateUsersRole({accountName:t,projectName:n,userId:o,role:i})):y.fetch(ae.accountInvite.createAccountInvite(t,e,a))},onError:b,onSuccess:()=>{x(h?`Invitation sent to ${w.getValues(`email`)}`:`Member added to ${d.account.label??d.account.name}`),m(!1)}}),A=vX(D,(E?.data??[]).filter(e=>!l||!l.includes(e.id)&&!l.includes(e.sub)),{getText:e=>[e.name,e.email],key:`email`}),j=e=>{f(`account-invite-submitted`,{role:e.role,teamId:r?.id??``,project:n,account:t}),k.mutate({email:e.email,role:e.role})};return(0,U.jsxs)(ow,{open:p,onOpenChange:e=>{e||w.reset(),m(e)},children:[o&&(0,U.jsx)(sw,{asChild:!0,children:o}),(0,U.jsxs)(lw,{className:`max-w-md`,children:[(0,U.jsx)(vOe,{}),(0,U.jsx)(DKt,{}),(0,U.jsxs)(uw,{className:`mt-2`,children:[(0,U.jsxs)(fw,{children:[`Invite to `,d.account.label??d.account.name]}),(0,U.jsx)(pw,{className:`opacity-75`,children:i??`Once you invite someone to your account, they can be granted access to account projects.`})]}),(0,U.jsx)(YY,{...w,children:(0,U.jsxs)(`form`,{onSubmit:w.handleSubmit(j),className:`mt-2 space-y-4`,children:[(0,U.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,U.jsx)(XY,{control:w.control,name:`email`,render:({field:t})=>(0,U.jsxs)(QY,{className:`w-full`,children:[(0,U.jsx)($Y,{children:`Member`}),(0,U.jsx)(eX,{children:(0,U.jsx)(`div`,{className:`relative`,children:(0,U.jsx)(Vw,{open:_&&D.length>0,onOpenChange:v,modal:!1,children:(0,U.jsxs)(mw,{shouldFilter:!1,loop:!0,children:[(0,U.jsx)(Rw,{asChild:!0,children:(0,U.jsx)(tw.Input,{asChild:!0,value:D,onValueChange:t.onChange,onKeyDown:e=>{if(e.key===`Enter`&&_===!1){e.currentTarget.form?.requestSubmit(),e.preventDefault();return}v(e.key!==`Escape`)},onMouseDown:()=>v(e=>!!D||!e),onFocus:()=>v(!0),onBlur:()=>v(!1),children:(0,U.jsx)(gT,{placeholder:`Email address or member name`})})}),!open&&(0,U.jsx)(gw,{"aria-hidden":`true`,className:`hidden`}),(0,U.jsx)(Uw,{asChild:!0,align:`start`,onOpenAutoFocus:e=>e.preventDefault(),onInteractOutside:e=>{e.target instanceof Element&&e.target.hasAttribute(`cmdk-input`)&&e.preventDefault()},className:`w-(--radix-popover-trigger-width) p-0`,children:(0,U.jsxs)(gw,{className:`max-h-[200px] overflow-y-auto`,children:[(0,U.jsx)(_w,{children:`No members found.`}),(0,U.jsxs)(vw,{children:[!e&&A.map((e,n)=>(0,U.jsx)(yw,{value:n.toString(),onSelect:()=>{t.onChange(e.email),g(!1),v(!1)},children:(0,U.jsx)(`span`,{children:e.name})},e.id)),D.length>0&&(0,U.jsxs)(yw,{value:A.length.toString(),onSelect:()=>{g(!0),v(!1)},children:[(0,U.jsx)(Fd,{size:16,className:`mr-2`}),` `,`Invite "`,D.includes(`@`)?D:`${D}@example.com`,`" to Account`]})]})]})})]})})})}),(0,U.jsx)(nX,{})]})}),(0,U.jsx)(XY,{control:w.control,name:`role`,render:({field:e})=>(0,U.jsxs)(QY,{children:[(0,U.jsx)($Y,{children:`Role`}),(0,U.jsx)(eX,{children:(0,U.jsxs)(oR,{children:[(0,U.jsx)(sR,{asChild:!0,children:(0,U.jsx)(xKt,{aiProject:!!(n&&!r&&d.project&&xO(d.project)),value:e.value,onValueChange:e.onChange,hiddenRoles:a})}),(0,U.jsx)(cR,{children:C?(0,U.jsx)(`p`,{children:`New users will be assigned the member role. You can change their role later.`}):(0,U.jsx)(`p`,{children:`New users will be assigned the admin role. You can change their role later.`})})]})}),(0,U.jsx)(nX,{})]})})]}),(0,U.jsx)(dw,{children:(0,U.jsx)(X,{type:`submit`,className:`justify-end`,children:(0,U.jsxs)(HI,{loading:k.isPending,children:[h?`Send Invite`:`Add member`,(0,U.jsx)(tz,{className:`bg-white/20`,children:(0,U.jsx)(ez,{onPress:w.handleSubmit(j),hotkey:`meta+Enter`})})]})})})]})})]})]})},jKt=()=>{let{account:e}=Op([`account`]);return e.entitlements.rbacEnabled?null:(0,U.jsxs)(Ub,{variant:`info`,className:`text-sm`,children:[(0,U.jsx)(yd,{size:22}),(0,U.jsx)(Gb,{children:(0,U.jsxs)(`p`,{children:[`Role-based access control (RBAC) is not enabled for this account.`,` `,(0,U.jsx)(Kb,{to:`mailto:${nx}?subject=Fine-grain%20access%20control`,children:`Contact sales`}),` `,`for more information.`]})})]})},MKt=({name:e,sub:t,email:n})=>{let{copyToClipboard:r}=WC(t??n??``);return(0,U.jsxs)(oR,{children:[(0,U.jsx)(sR,{onDoubleClick:()=>{r()},className:`text-left`,children:e}),(0,U.jsxs)(cR,{className:`flex items-center gap-2`,children:[t&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)($d,{size:16}),` Sub `,t]}),n&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(xf,{size:16}),` Email `,n]})]})]})},NKt=r(a(((e,t)=>{(function(n,r){typeof e==`object`&&t!==void 0?t.exports=r():typeof define==`function`&&define.amd?define(r):(n=typeof globalThis<`u`?globalThis:n||self).dayjs_plugin_relativeTime=r()})(e,(function(){return function(e,t,n){e||={};var r=t.prototype,i={future:`in %s`,past:`%s ago`,s:`a few seconds`,m:`a minute`,mm:`%d minutes`,h:`an hour`,hh:`%d hours`,d:`a day`,dd:`%d days`,M:`a month`,MM:`%d months`,y:`a year`,yy:`%d years`};function a(e,t,n,i){return r.fromToBase(e,t,n,i)}n.en.relativeTime=i,r.fromToBase=function(t,r,a,o,s){for(var c,l,u,d=a.$locale().relativeTime||i,f=e.thresholds||[{l:`s`,r:44,d:`second`},{l:`m`,r:89},{l:`mm`,r:44,d:`minute`},{l:`h`,r:89},{l:`hh`,r:21,d:`hour`},{l:`d`,r:35},{l:`dd`,r:25,d:`day`},{l:`M`,r:45},{l:`MM`,r:10,d:`month`},{l:`y`,r:17},{l:`yy`,d:`year`}],p=f.length,m=0;m<p;m+=1){var h=f[m];h.d&&(c=o?n(t).diff(a,h.d,!0):a.diff(t,h.d,!0));var g=(e.rounding||Math.round)(Math.abs(c));if(u=c>0,g<=h.r||!h.r){g<=1&&m>0&&(h=f[m-1]);var _=d[h.l];s&&(g=s(``+g)),l=typeof _==`string`?_.replace(`%d`,g):_(g,r,h.l,u);break}}if(r)return l;var v=u?d.future:d.past;return typeof v==`function`?v(l):v.replace(`%s`,l)},r.to=function(e,t){return a(e,t,this,!0)},r.from=function(e,t){return a(e,t,this)};var o=function(e){return e.$u?n.utc():n()};r.toNow=function(e){return this.to(o(this),e)},r.fromNow=function(e){return this.from(o(this),e)}}}))}))());function PKt({accountName:e,invite:t}){let n=Ep(),[r,i]=(0,H.useState)(!1),a=Lme();return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(X,{size:`icon`,variant:`ghost`,title:`Remove invitation`,disabled:a.isPending,onClick:()=>i(!0),children:(0,U.jsx)(sp,{size:18})}),(0,U.jsxs)(k$,{open:r,onOpenChange:i,title:`Delete account invite`,deleteButtonText:`Delete invitation`,isPending:a.isPending,onClickDelete:async()=>{try{await a.mutateAsync({accountName:e,inviteId:t.id}),n.success(`Invitation was removed`),i(!1)}catch(e){n.error(ux(e))}},children:[`You are about to delete the account invite sent to `,t.email,`. The invitation can no longer be used to join your account.`]})]})}function FKt({accountName:e,invite:t}){let n=Ep(),r=Rme(),[i,a]=(0,H.useState)(!1);return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(oR,{children:[(0,U.jsx)(sR,{asChild:!0,children:(0,U.jsx)(X,{size:`icon`,variant:`ghost`,disabled:r.isPending,onClick:()=>a(!0),children:(0,U.jsx)(fee,{size:18})})}),(0,U.jsx)(cR,{children:`Resend invitation`})]}),(0,U.jsx)(yL,{open:i,onOpenChange:a,title:`Do you want to resend the invitation?`,description:`You are about to resend the account membership invite for "${t.email}" to join "${e}".`,actionLabel:`Resend invitation`,isPending:r.isPending,onConfirm:async()=>{try{await r.mutateAsync({accountName:e,inviteId:t.id}),n.success(`Invitation has been resent`),a(!1)}catch(e){n.error(ux(e)),a(!1)}}})]})}var IKt=({date:e,withTime:t})=>(0,U.jsxs)(`span`,{children:[e.toLocaleDateString(),t&&` ${e.toLocaleTimeString()}`]}),LKt=({email:e,className:t})=>{let{copyToClipboard:n}=WC(e);return(0,U.jsxs)(oR,{children:[(0,U.jsx)(sR,{onDoubleClick:n,className:W(`cursor-pointer`,t),children:e}),(0,U.jsxs)(cR,{children:[`Copy `,(0,U.jsxs)(`span`,{className:`font-mono`,children:[`"`,e,`"`]}),` to clipboard`]})]})};b7.default.extend(NKt.default);function RKt(){let{account:e}=sx([`account`]),t=Ime(e).data??[];return t.length===0?null:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`div`,{className:`text-lg font-medium`,children:`Pending account invitations`}),(0,U.jsx)(`div`,{className:`grid grid-cols-4 gap-2`,children:t.map(t=>(0,U.jsxs)(N$,{variant:`outline`,size:`sm`,className:W(`col-span-full grid grid-cols-subgrid justify-between py-1`,(0,b7.default)().diff((0,b7.default)(t.createdOn),`minutes`)<5&&`bg-zuplo-50/50`),children:[(0,U.jsx)(`div`,{className:`text-ellipsis overflow-hidden truncate`,children:(0,U.jsxs)(oR,{children:[(0,U.jsx)(sR,{children:(0,U.jsxs)(rT,{variant:`outline`,children:[`Invited `,(0,b7.default)(t.createdOn).fromNow()]})}),(0,U.jsx)(cR,{children:(0,U.jsx)(IKt,{date:new Date(t.createdOn),withTime:!0})})]})}),(0,U.jsx)(LKt,{email:t.email,className:`text-left text-ellipsis overflow-hidden truncate`}),(0,U.jsxs)(`div`,{className:`flex justify-end col-span-2`,children:[(0,U.jsx)(FKt,{accountName:e,invite:t}),(0,U.jsx)(PKt,{accountName:e,invite:t})]})]},t.id))})]})}var zKt=5,BKt=`Members & Access`,VKt=(0,U.jsxs)(U.Fragment,{children:[`Manage who can access this project. Account members can create or be added to projects.`,` `,(0,U.jsx)(hT,{href:`https://zuplo.com/docs/articles/add-project-collaborators`,children:`Learn more`}),`.`]});function HKt(){let e=Op([`account`,`project`]),{canViewMembers:t,role:n,error:r}=ATe(e.account.name,e.project.name);return n?t?(0,U.jsx)(UKt,{}):(0,U.jsx)(`p`,{className:`p-6`,children:`You do not have access to project membership.`}):r?(0,U.jsxs)(`div`,{role:`alert`,className:`p-6 flex items-center gap-3`,children:[(0,U.jsx)(`p`,{children:`We couldn’t check your project access.`}),(0,U.jsx)(X,{variant:`outline`,onClick:()=>window.location.reload(),children:`Reload to retry`})]}):(0,U.jsx)(`output`,{"aria-label":`Loading project access`,className:`p-6 flex justify-center items-center`,children:(0,U.jsx)(VI,{color:`primary`})})}function UKt(){let e=Op([`account`,`project`]),t=Ep(),{user:n}=u(),r=bt(),i=Oe({mutationFn:({userId:t,role:n})=>r.fetch(ae.auth.updateUsersRole({accountName:e.account.name,projectName:e.project.name,userId:t,role:n})),onError:e=>t.error(ux(e))}),[a,o]=(0,H.useState)(!1),[s,c]=(0,H.useState)(!1),l=ax(je.accountMemberInvites(e.account.name)),d=ax(je.authProjectUsersRoles(e.account.name,e.project.name,{includeInheritedRoles:!1}),{extractData:!0}),f=d.data?.map(e=>e.id),p=ax(je.authProjectUsersRoles(e.account.name,e.project.name,{includeInheritedRoles:!0}),{extractData:!0}),m=p.data?.filter(e=>!f?.includes(e.id)),h=d.data?.filter(e=>e.project.role!==`no-access`),g=e.account.entitlements.rbacEnabled,_=(h?.map(({id:e})=>e)??[]).concat(g?[]:m?.map(({id:e})=>e)??[]);return(0,U.jsxs)(N7,{title:BKt,description:VKt,action:(0,U.jsx)(AKt,{account:e.account.name,project:e.project.name,changeRoleForUserIds:p.data?.map(({id:e})=>e)??[],excludeUserIds:_,open:s,onOpenChange:c,description:`Inviting a user to a project will grant them access to the project and add them to the account as a member.`,children:(0,U.jsxs)(X,{children:[(0,U.jsx)(Mf,{size:16}),`Add to project`]})}),children:[(0,U.jsxs)(`section`,{className:`flex flex-col gap-3 text-sm`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Members with inherited access`}),(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Account Admins and developers automatically have access to all projects.`})]}),(m?.length??0)>0&&(0,U.jsx)(CA,{className:`overflow-hidden`,children:m?.slice(0,a?void 0:zKt).map(e=>(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-4 border-b px-4 py-3 last:border-0`,children:[(0,U.jsx)(MKt,{name:e.name,email:e.email}),(0,U.jsxs)(oR,{children:[(0,U.jsx)(sR,{children:(0,U.jsx)(rT,{variant:`outline`,children:e.project.role===`admin`?`Full access`:`Read only`})}),(0,U.jsx)(cR,{children:bKt[e.project.role]})]})]},e.id))}),(m?.length??0)>zKt&&(0,U.jsx)(X,{variant:`ghost`,size:`sm`,onClick:()=>{o(!a)},children:a?`Show less`:`Show more`})]}),l.data?.length>0&&(0,U.jsx)(RKt,{}),(0,U.jsxs)(`section`,{className:`flex flex-col gap-3 text-sm`,children:[(0,U.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Members with project access`}),(0,U.jsx)(SA,{error:d.error}),i.isError&&(0,U.jsx)(jKt,{}),h?.length===0&&(0,U.jsx)(CA,{children:(0,U.jsxs)(qb,{children:[(0,U.jsxs)(Jb,{children:[(0,U.jsx)(Yb,{variant:`icon`,children:(0,U.jsx)(up,{})}),(0,U.jsx)(Xb,{children:`No project members yet`}),(0,U.jsx)(Zb,{children:`No members have been added directly to this project yet.`})]}),(0,U.jsx)(Qb,{children:(0,U.jsxs)(X,{onClick:()=>c(!0),children:[(0,U.jsx)(Mf,{size:16}),`Add to project`]})})]})}),(h?.length??0)>0&&(0,U.jsxs)(CA,{className:`grid grid-cols-[1fr_auto_auto] gap-x-4 overflow-hidden text-sm`,children:[(0,U.jsxs)(tGt,{children:[(0,U.jsx)(`div`,{children:`Member`}),(0,U.jsx)(`div`,{children:`Role`}),(0,U.jsx)(`div`,{})]}),!d.isError&&h?.map(t=>(0,U.jsxs)(eGt,{children:[(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(MKt,{name:t.name,sub:t.sub}),t.sub===n?.sub&&(0,U.jsx)(rT,{variant:`outline`,className:`ml-4`,children:`You`})]}),(0,U.jsx)(`div`,{className:W(`text-ellipsis overflow-hidden truncate`,t.email===t.name&&`hidden`),title:t.email,children:t.email})]}),(0,U.jsx)(`div`,{className:`max-w-60 w-full`,children:(0,U.jsx)(xKt,{aiProject:xO(e.project),hiddenRoles:e.account.entitlements.rbacEnabled?[]:[`member`,`developer`],value:t.project.role,disabled:!!(t.sub===n?.sub||i.isPending),onValueChange:e=>{if(!UC.includes(e))throw Error(`Invalid role`);i.mutate({userId:t.id,role:e})}})}),(0,U.jsx)(`div`,{className:`flex justify-end`,children:(0,U.jsx)(X,{variant:`ghost`,size:`icon-lg`,onClick:()=>{i.mutate({role:`no-access`,userId:t.id})},children:(0,U.jsx)(sp,{size:16})})})]},t.sub))]})]})]})}YR(`div`,`grid grid-cols-subgrid col-span-full w-full border-b px-4 py-3 items-center`);var WKt=({accountName:e,projectName:t,sourceRepoUrl:n,defaultBranch:r})=>{let{logEvent:i,captureException:a}=S(),[o,s]=(0,H.useState)(``),[c,l]=(0,H.useState)(r),[u,d]=(0,H.useState)(!1),f=BOe(e,t);(0,H.useEffect)(()=>{u||(s(``),l(r))},[u,r]);let p=n.split(`/`),m=p[p.length-2],h=p[p.length-1],g=async()=>{try{if(s(``),!c||c===r){s(`Select a new default branch.`);return}await f.mutateAsync({defaultBranch:c,sourceRepoUrl:n}),i(`project-update-default-branch-success`,{account:e}),d(!1)}catch(t){a(t);let n=ux(t);s(n),i(`project-update-default-branch-failed`,{account:e,errorMessage:n})}};return(0,U.jsxs)(CA,{children:[(0,U.jsx)(wA,{children:`Default Branch`}),(0,U.jsxs)(DA,{className:`mt-1 text-sm`,children:[(0,U.jsx)(EA,{children:`The default branch is considered the “base” branch in your repository, against which all pull requests and code commits are automatically made. This is the branch used for your project's production deployments.`}),(0,U.jsxs)(`div`,{className:`flex gap-2`,children:[(0,U.jsx)(gT,{type:`text`,autoComplete:`off`,id:`default-branch-field`,value:r??`main`,disabled:!0,className:`max-w-52`,"data-test":`default-branch-field`}),(0,U.jsxs)(ow,{onOpenChange:e=>d(e),open:u,children:[(0,U.jsx)(sw,{children:(0,U.jsx)(X,{type:`button`,"data-test":`update-default-branch`,variant:`outline`,children:`Update`})}),(0,U.jsxs)(lw,{children:[(0,U.jsx)(uw,{children:(0,U.jsx)(fw,{children:`Switch default branch to another branch`})}),(0,U.jsxs)(`div`,{className:`space-y-4`,children:[(0,U.jsx)(SA,{error:o}),(0,U.jsxs)(pw,{className:`text-foreground`,children:[`Choose another branch in`,` `,(0,U.jsxs)(hT,{href:n,children:[m,`/`,h]}),` `,`to use as the default branch of the project instead of`,` `,r,`.`,(0,U.jsx)(gT,{type:`text`,autoComplete:`off`,placeholder:`Type a branch name`,id:`default-branch-field`,className:`mt-4`,"data-test":`default-branch-field`,value:c,onChange:e=>l(e.target.value)})]})]}),(0,U.jsxs)(dw,{children:[(0,U.jsx)(cw,{children:(0,U.jsx)(X,{"data-test":`cancel-update-default-branch-btn`,disabled:f.isPending,variant:`ghost`,children:`Cancel`})}),(0,U.jsx)(X,{"data-test":`update-default-branch-btn`,type:`button`,onClick:g,disabled:f.isPending,variant:`outline`,children:(0,U.jsx)(HI,{loading:f.isPending,alternative:`Updating...`,children:`Switch branch`})})]})]})]})]})]})]})},GKt=`Source Control`,KKt=(0,U.jsxs)(U.Fragment,{children:[`Connect a Git repository to deploy your project. Learn more about deploying with source control in our`,` `,(0,U.jsx)(hT,{href:`https://zuplo.com/docs/articles/step-4-deploying-to-the-edge`,showIcon:!0,children:`documentation`}),`.`]}),qKt=()=>{let e=Op([`account`,`project`]),{logEvent:t}=S(),n=FWt();if((0,H.useEffect)(()=>{t(`source-control-settings-viewed`,{account:e.account.name,project:e.project.name})},[e.account.name,e.project.name,t]),!n.data)return(0,U.jsx)(N7,{title:GKt,description:KKt,children:(0,U.jsx)(cWt,{showHeader:!1})});let r=Pme(e.account.name,n.data);return(0,U.jsxs)(N7,{title:GKt,description:KKt,children:[e.project.sourceRepoUrl!==null&&(0,U.jsx)(WKt,{accountName:e.account.name,projectName:e.project.name,sourceRepoUrl:e.project.sourceRepoUrl,defaultBranch:e.project.defaultBranch??void 0}),(0,U.jsxs)(CA,{children:[(0,U.jsxs)(wA,{children:[(0,U.jsx)(TA,{children:`Connected Git Repository`}),(0,U.jsx)(EA,{children:`Seamlessly create Environments for every branch and deployments for any commits pushed to your Git repository.`})]}),(0,U.jsx)(DA,{children:(0,U.jsx)(PWt,{account:e.account,project:e.project,sourceControlConfig:r})})]})]})},JKt=()=>{let{account:e,project:t}=sx([`account`,`project`]);return(0,U.jsx)(Bo,{to:ri(rx.Environments,{account:e,project:t})})},YKt=({to:e})=>(0,U.jsx)(Bo,{to:`/accounts/${Op([`account`]).account.name}/settings/${e}`,replace:!0}),XKt=[{key:`general`,group:`project`,icon:(0,U.jsx)($f,{className:`w-4 h-4`}),name:`General`,view:(0,U.jsx)(yKt,{}),testID:`settings-general`},{key:`share-project`,group:`project`,icon:(0,U.jsx)(up,{className:`w-4 h-4`}),name:`Members & Access`,view:(0,U.jsx)(HKt,{}),testID:`settings-share-project`},{key:`source-control-settings`,group:`project`,icon:(0,U.jsx)(sf,{className:`w-4 h-4`}),name:`Source Control`,view:(0,U.jsx)(qKt,{}),testID:`settings-source-control-settings`},{key:`environment-variables`,group:`configuration`,icon:(0,U.jsx)(Xf,{className:`w-4 h-4`}),name:`Environment Variables`,view:(0,U.jsx)(mKt,{}),testID:`settings-environment-variables`},{key:`custom-domain`,group:`configuration`,icon:(0,U.jsx)(pee,{className:`w-4 h-4`}),name:`Custom Domains`,view:(0,U.jsx)(sKt,{}),testID:`settings-custom-domain`},{key:`ai-providers`,group:`configuration`,icon:(0,U.jsx)(od,{className:`w-4 h-4`}),name:`AI Gateway`,view:(0,U.jsx)(_Gt,{}),testID:`settings-ai-providers`},{key:`upgrade-billing`,group:`account`,icon:(0,U.jsx)(yd,{className:`w-4 h-4`}),name:`Billing`,view:(0,U.jsx)(YKt,{to:`upgrade-billing`}),outbound:!0,testID:`settings-upgrade-billing`},{key:`zuplo-api-keys`,group:`account`,icon:(0,U.jsx)(mf,{className:`w-4 h-4`}),name:`Zuplo API Keys`,view:(0,U.jsx)(YKt,{to:`api-keys`}),outbound:!0,testID:`settings-zuplo-api-keys`},{key:`api-key-consumers`,group:`configuration`,icon:(0,U.jsx)(mf,{className:`w-4 h-4`}),name:`API Key Consumers`,view:(0,U.jsx)(()=>{let e=Op([`account`,`project`]);return(0,U.jsx)(Bo,{to:ri(rx.ProjectServices,{account:e.account.name,project:e.project.name}),replace:!0})},{}),hidden:!0},{key:`environments`,group:`account`,icon:(0,U.jsx)($f,{className:`w-4 h-4`}),name:`Environments`,view:(0,U.jsx)(JKt,{}),hidden:!0}];function ZKt({project:e,hideEnvironmentVariables:t}){return XKt.filter(n=>n.hidden?!1:n.key===`ai-providers`?xO(e):n.key===`environment-variables`?!t:!0)}var QKt=({account:e,project:t,environment:n,navigateTo:r})=>{let{data:i}=POe(e??``,t);return!e||!t||!n?null:(0,U.jsx)(vw,{heading:`Settings`,children:ZKt({project:i??{productType:`standard`},hideEnvironmentVariables:!1}).map(n=>(0,U.jsxs)(yw,{onSelect:()=>r(ri(`${rx.Settings}/${n.key}`,{account:e,project:t})),children:[n.icon,(0,U.jsx)(`span`,{className:`ml-3`,children:n.name})]},n.key))})},$Kt={GET:`bg-emerald-50 text-emerald-700 border-emerald-200 dark:bg-emerald-950 dark:text-emerald-300 dark:border-emerald-800`,POST:`bg-sky-50 text-sky-700 border-sky-200 dark:bg-sky-950 dark:text-sky-300 dark:border-sky-800`,PUT:`bg-amber-50 text-amber-700 border-amber-200 dark:bg-amber-950 dark:text-amber-300 dark:border-amber-800`,PATCH:`bg-orange-50 text-orange-700 border-orange-200 dark:bg-orange-950 dark:text-orange-300 dark:border-orange-800`,DELETE:`bg-red-50 text-red-700 border-red-200 dark:bg-red-950 dark:text-red-300 dark:border-red-800`},eqt=({account:e,project:t,environment:n,navigateTo:r})=>{let i=wR(e,t).data?.find(e=>e.urlParameter===n)?.name,a=Llt(i??``,{enabled:i!==void 0}).data?.model;if(!a||a.routes.length===0)return null;let o=new Map(a.handlers.map(e=>[e.key,e])),s=ri(rx.Code,{account:e,project:t,environment:n}),c=e=>`${s}?path=${encodeURIComponent(e.filePath)}${e.operationId?`&operation=${encodeURIComponent(e.operationId)}`:``}`;return(0,U.jsx)(vw,{heading:`Routes`,children:a.routes.map(e=>{let t=e.handlerKey?o.get(e.handlerKey):void 0;return(0,U.jsxs)(yw,{value:e.id,keywords:[`${e.method} ${e.path}`,...[e.operationId,e.summary,t?.name].filter(e=>!!e),...e.inboundPolicies,...e.outboundPolicies],onSelect:()=>r(c(e)),className:`gap-2`,children:[(0,U.jsx)(`span`,{className:W(`w-14 shrink-0 rounded-sm border px-1 py-0.5 text-center font-mono text-[10px] font-semibold uppercase leading-4`,$Kt[e.method]??`bg-neutral-50 text-neutral-600 border-neutral-200 dark:bg-neutral-900 dark:text-neutral-300 dark:border-neutral-700`),children:e.method}),(0,U.jsx)(`span`,{className:`truncate font-mono`,children:e.path}),e.summary&&(0,U.jsx)(`span`,{className:`ml-auto truncate pl-3 text-xs text-muted-foreground`,children:e.summary})]},e.id)})})},U7=({path:e,children:t,navigateTo:n,...r})=>(0,U.jsxs)(yw,{onSelect:()=>n(ri(e,r)),children:[(0,U.jsx)(`div`,{className:`mr-2`,children:t??(0,U.jsx)(Yu,{className:` h-4 w-4`})}),(0,U.jsx)(`span`,{children:Object.entries(rx).find(([,t])=>t===e)?.at(0)})]}),tqt=({account:e,navigateTo:t})=>{let{isAiUser:n,isLoading:r}=MTe(e);return n||r?null:(0,U.jsx)(U7,{path:rx.AccountSettings,navigateTo:t,account:e,children:(0,U.jsx)(Wf,{})})};function nqt(){let{isAuthenticated:e}=u(),t=BWt(),{account:n,project:r,environment:i}=lo(),a=ao(),o=n&&r&&i,s={account:n,project:r,environment:i},[c,l]=(0,H.useState)(``),d=(0,H.useRef)(null),f=e=>{l(e),d.current?.scrollTo({top:0})},p=dx({enabled:e});NOe(e?p.data?.map(e=>e.name)??[]:[]);let[m,h]=(0,H.useState)(!1);$R(`meta+k`,()=>{h(!0)});let g=e=>{h(e),e||l(``)},_=e=>{a(e),g(!1)};return(0,U.jsxs)(xEe,{open:m,onOpenChange:g,filter:KWt,children:[(0,U.jsx)(hw,{placeholder:`What do you want to do?`,onValueChange:f}),(0,U.jsxs)(gw,{ref:d,children:[(0,U.jsx)(_w,{children:(0,U.jsxs)(`div`,{className:`text-muted-foreground my-3`,children:[`No results found "`,c,`".`]})}),o&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(eqt,{navigateTo:_,account:n,project:r,environment:i}),(0,U.jsx)(JWt,{navigateTo:_,account:n,project:r,environment:i})]}),n&&r&&i&&(0,U.jsx)(QKt,{navigateTo:_,...s}),e&&(0,U.jsx)(UWt,{navigateTo:_,accounts:p.data,search:c}),(0,U.jsxs)(vw,{title:t.shortName,children:[(0,U.jsx)(U7,{path:rx.Profile,navigateTo:_,children:(0,U.jsx)(lp,{})}),(0,U.jsx)(U7,{path:rx.Logout,navigateTo:_,children:(0,U.jsx)(bf,{})}),n&&r&&(0,U.jsx)(U7,{path:rx.Settings,navigateTo:_,account:n,project:r,children:(0,U.jsx)(Wf,{})}),n&&e&&(0,U.jsx)(tqt,{account:n,navigateTo:_})]}),(0,U.jsx)(qWt,{query:c,onSelected:()=>g(!1)})]})]})}var rqt=Date.now(),iqt=300*1e3,aqt=14400*1e3,oqt=1440*60*1e3,sqt=async e=>{try{let t=await fetch(e,{method:`HEAD`,cache:`no-cache`});if(!t.ok)return!1;let n=t.headers.get(`date`),r=t.headers.get(`last-modified`);if(!n||!r)return!1;let i=new Date(n).getTime(),a=new Date(r).getTime();if(Number.isNaN(i)||Number.isNaN(a))return!1;let o=i-a>=oqt;return a>rqt&&i>rqt&&o}catch{return!1}},cqt=({enabled:e})=>{let t=(0,H.useRef)(0),n=y(),{data:r}=k({enabled:e,refetchInterval:iqt,refetchIntervalInBackground:!1,networkMode:`online`,retry:!1,queryFn:async()=>{let e=await sqt(window.location.href),r=Date.now();return e&&r-t.current>=aqt?(t.current=r,n.capture(`show-update-toast`),!0):!1},queryKey:[`update-check`]});return(0,U.jsxs)(yp,{open:r??!1,duration:1/0,children:[(0,U.jsxs)(_p,{children:[(0,U.jsx)(Sp,{children:`Update available`}),(0,U.jsx)(Cp,{children:`A new version of the Zuplo Portal is available. Click to reload.`})]}),(0,U.jsx)(bp,{altText:`Reload`,children:(0,U.jsx)(`button`,{type:`button`,onClick:()=>window.location.reload(),children:`Reload`})}),(0,U.jsx)(xp,{})]})},lqt=e=>e.handle?.preserveScroll===!0,uqt=(e,t)=>{for(let t=e.length-1;t>=0;t--)if(!lqt(e[t]))return e[t].pathname;return t},dqt=`[data-scroll-reset]`,W7=()=>Array.from(document.querySelectorAll(dqt)),fqt=e=>{if(!e)return!1;try{let t=document.getElementById(decodeURIComponent(e.slice(1)));return t?.scrollIntoView(),t!==null}catch{return!1}},pqt=e=>{let t=W7(),n=0,r=()=>{let i=!0;t.forEach((t,n)=>{let r=e[n]??0;t.scrollTop=r,Math.abs(t.scrollTop-r)>1&&(i=!1)}),!i&&++n<30&&requestAnimationFrame(r)};r()};function mqt(){let{key:e,pathname:t,hash:n}=to(),r=no(),i=uqt(To(),t),a=(0,H.useRef)(i),o=(0,H.useRef)(e),s=(0,H.useRef)(new Map);return(0,H.useEffect)(()=>{let e=e=>{e.target instanceof Element&&e.target.matches(dqt)&&s.current.set(o.current,W7().map(e=>e.scrollTop))};return document.addEventListener(`scroll`,e,{capture:!0,passive:!0}),()=>document.removeEventListener(`scroll`,e,{capture:!0})},[]),(0,H.useLayoutEffect)(()=>{let t=a.current!==i;if(a.current=i,o.current=e,t&&r===`POP`)pqt(s.current.get(e)??[]);else if(t&&!fqt(n)){window.scrollTo(0,0);for(let e of W7())e.scrollTop=0}s.current.has(e)||s.current.set(e,W7().map(e=>e.scrollTop))},[e,i,n,r]),null}var hqt=({enableUpdateNotifications:e})=>(0,U.jsx)(xht,{children:(0,U.jsxs)(hp,{children:[(0,U.jsx)(mqt,{}),(0,U.jsx)(cqt,{enabled:e}),(0,U.jsx)(nqt,{}),(0,U.jsx)(wp,{}),(0,U.jsx)(Vo,{}),(0,U.jsx)(gp,{})]})});function gqt(){return(0,U.jsx)(`div`,{className:`m-auto`,children:(0,U.jsxs)(`div`,{className:`flex flex-col gap-2 my-5`,children:[(0,U.jsx)(`div`,{children:(0,U.jsx)(rT,{variant:`outline`,children:`404`})}),(0,U.jsx)(`span`,{className:`text-2xl font-medium`,children:`Oops! Page not found.`}),(0,U.jsx)(`span`,{children:`Sorry, we could not find the page you were looking for.`}),(0,U.jsx)(`div`,{className:`h-2`}),(0,U.jsx)(Dut,{hasGoHome:!0})]})})}var _qt=()=>{let{environment:e}=sx([`environment`]),[t,n]=(0,H.useState)(null),r=Pp(e=>e.updateFile),i=Pp(e=>e.filesByPath);return{conflict:t,checkForConflictsBeforeSave:(0,H.useCallback)(async(t,r)=>{let a=i[t];try{let i=await nc(e,t);return a.lastModified&&i.lastModified&&i.lastModified>a.lastModified?(jt.warn(`File ${t} was modified on disk. Showing conflict dialog before save.`),new Promise(e=>{n({filePath:t,localContent:a.content??``,remoteContent:i.content??``,remoteLastModified:i.lastModified,onProceed:async()=>{await r(),e(!0)}})})):(await r(),!0)}catch(e){return jt.error(`Error checking for conflicts`,{error:e}),await r(),!0}},[e,i]),showConflict:(0,H.useCallback)(e=>{jt.info(`Showing conflict dialog for ${e.filePath}`),n(e)},[]),resolveConflict:(0,H.useCallback)(async a=>{if(!t)return;let o=i[t.filePath];if(!o){n(null);return}if(a===`remote`)r({...o,content:t.remoteContent,lastModified:t.remoteLastModified,saveState:Qs.unmodified}),jt.info(`Using disk version for ${t.filePath}, canceling save`),n(null);else if(jt.info(`User chose local version for ${t.filePath}${t.onProceed?`, proceeding with save`:`, saving to disk`}`),t.onProceed)await t.onProceed(),n(null);else try{await ic(e,{path:o.path,content:o.content},{forceSave:!0});let i=await nc(e,t.filePath);r({...o,lastModified:i.lastModified,saveState:Qs.unmodified}),jt.info(`Successfully saved local version for ${t.filePath}`),n(null)}catch(e){jt.error(`Error saving local version for ${t.filePath}`,{error:e}),r({...o,saveState:Qs.modified})}},[t,i,r,e]),cancelConflict:(0,H.useCallback)(async()=>{if(!t)return;let a=i[t.filePath];if(a){let n=await nc(e,t.filePath);r({...a,lastModified:n.lastModified,saveState:Qs.modified}),jt.info(`Conflict dialog canceled for ${t.filePath}, file marked as modified`)}n(null)},[t,i,r,e])}};function vqt({open:e,filePath:t,localContent:n,remoteContent:r,onResolve:i,onCancel:a}){let[o,s]=(0,H.useState)(`local`),c=Gdt(t);return(0,U.jsx)(ow,{open:e,onOpenChange:e=>!e&&a(),children:(0,U.jsxs)(lw,{className:`max-w-7xl max-h-[90vh] p-0`,showCloseButton:!1,children:[(0,U.jsx)(`div`,{className:`p-6 pb-0`,children:(0,U.jsxs)(uw,{children:[(0,U.jsx)(fw,{className:`text-lg font-semibold text-left mb-1`,children:`File Conflict Detected`}),(0,U.jsxs)(`p`,{className:`text-sm text-muted-foreground text-left`,children:[(0,U.jsx)(`span`,{className:`font-mono font-semibold`,children:t}),` has been modified both locally and on disk`]})]})}),(0,U.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-col px-6`,children:[(0,U.jsxs)(`div`,{className:`grid grid-cols-2`,children:[(0,U.jsxs)(`button`,{type:`button`,className:`flex flex-col py-3 cursor-pointer transition-all border-t-4 border-x ${o===`local`?`border-t-pink-500 border-x-pink-200 bg-pink-50`:`border-t-border border-x-border bg-gray-50 dark:bg-neutral-900 hover:bg-gray-100 dark:hover:bg-neutral-800`}`,style:{paddingLeft:`26px`,paddingRight:`24px`},onClick:()=>s(`local`),"aria-pressed":o===`local`,children:[(0,U.jsx)(`div`,{className:`font-semibold text-sm`,children:`Browser Version`}),(0,U.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Current editor content`})]}),(0,U.jsxs)(`button`,{type:`button`,className:`flex flex-col px-6 py-3 cursor-pointer transition-all border-t-4 border-x ${o===`remote`?`border-t-pink-500 border-x-pink-200 bg-pink-50`:`border-t-border border-x-border bg-gray-50 dark:bg-neutral-900 hover:bg-gray-100 dark:hover:bg-neutral-800`}`,onClick:()=>s(`remote`),"aria-pressed":o===`remote`,children:[(0,U.jsx)(`div`,{className:`font-semibold text-sm`,children:`Disk Version`}),(0,U.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`File on disk`})]})]}),(0,U.jsx)(`div`,{className:`border border-t-0 overflow-hidden shadow-xs flex-1 min-h-[55vh]`,children:(0,U.jsx)(iL,{original:n,modified:r,language:c,options:{readOnly:!0,renderSideBySide:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:13,wordWrap:`off`}})})]}),(0,U.jsxs)(dw,{className:`px-6 pb-6 flex-row justify-between items-center`,children:[(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:o===`local`?(0,U.jsx)(U.Fragment,{children:`Browser version will be saved to disk`}):(0,U.jsx)(U.Fragment,{children:`Disk version will replace browser content`})}),(0,U.jsxs)(`div`,{className:`flex gap-2`,children:[(0,U.jsx)(X,{variant:`ghost`,onClick:a,children:`Cancel`}),(0,U.jsxs)(X,{variant:`default`,onClick:()=>i(o),children:[`Apply `,o===`local`?`Browser`:`Disk`,` Version`]})]})]})]})})}function yqt(){let{environment:e}=sx([`environment`]),{conflict:t,showConflict:n,resolveConflict:r,cancelConflict:i}=_qt(),a=Pp(e=>e.filesByPath),o=Pp(e=>e.saveConflictPath),s=Pp(e=>e.clearSaveConflict);return(0,H.useEffect)(()=>{if(o){jt.info(`Save conflict detected for ${o}`);let t=a[o];t?nc(e,o).then(e=>{n({filePath:o,localContent:t.content??``,remoteContent:e.content??``,remoteLastModified:e.lastModified})}).catch(e=>{jt.error(`Error fetching file for conflict dialog`,{error:e})}):jt.warn(`No file model found for ${o}`),s()}},[o,a,s,n,e]),t?(0,U.jsx)(vqt,{open:!0,filePath:t.filePath,localContent:t.localContent,remoteContent:t.remoteContent,onResolve:r,onCancel:i}):null}var bqt=()=>{let e=Op(),{monaco:t,reloadFiles:n}=_7(),r=XR(n.execute),i=e.environment.name,{error:a}=k({queryKey:[`reloadFiles`,e.account.name,e.project.name,i],queryFn:async()=>{try{return await r.current({accountName:e.account.name,projectName:e.project.name,environmentName:e.environment.name}),!0}catch(e){throw jt.error(`Failed to reload files`,{error:e}),e}},refetchOnWindowFocus:!1,enabled:!!t&&!!i,retry:3,retryDelay:e=>Math.min(1e3*2**e,3e4)});return a?(0,U.jsx)(`div`,{className:`flex items-center justify-center h-full bg-gray-50`,children:(0,U.jsxs)(`div`,{className:`text-center p-8 max-w-lg`,children:[(0,U.jsx)(`h2`,{className:`text-xl font-semibold text-gray-900 mb-2`,children:`Failed to Load Files`}),(0,U.jsx)(`p`,{className:`text-gray-600 mb-4`,children:`Unable to load project files from the local server. Please check that the dev server is running and try again.`}),(0,U.jsx)(`button`,{type:`button`,onClick:()=>window.location.reload(),className:`px-4 py-2 bg-blue-600 text-white rounded-sm hover:bg-blue-700`,children:`Retry`})]})}):null},xqt=()=>{let{account:e,project:t}=sx([`account`,`project`]),n=Pp(e=>e.resetStore);return(0,H.useEffect)(()=>{n()},[t,e,n]),(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(bqt,{}),(0,U.jsx)(yqt,{}),(0,U.jsx)(eUt,{}),(0,U.jsx)(Vo,{})]})};H.createContext({en:{translations:{archiveNotification:`Archive this notification`,archiveRead:`Archive Read`,markAllAsRead:`Mark all as read`,notifications:`Notifications`,emptyFeedTitle:`No notifications yet`,emptyFeedBody:`We'll let you know when we've got something new for you.`,all:`All`,unread:`Unread`,read:`Read`,unseen:`Unseen`,msTeamsChannelSetError:`Error setting channel.`,msTeamsConnect:`Connect to Microsoft Teams`,msTeamsConnected:`Connected`,msTeamsConnecting:`Connecting to Microsoft Teams…`,msTeamsConnectionErrorExists:`Try reconnecting to Microsoft Teams to find and select channels from your teams.`,msTeamsConnectionErrorOccurred:`There was an error connecting to Microsoft Teams. Try reconnecting to find and select channels from your teams.`,msTeamsConnectContainerDescription:`Connect to get notifications in Microsoft Teams`,msTeamsDisconnect:`Disconnect`,msTeamsDisconnecting:`Disconnecting from Microsoft Teams…`,msTeamsError:`Error`,msTeamsReconnect:`Reconnect`,msTeamsTenantIdNotSet:`Microsoft Teams tenant ID not set.`,slackConnectChannel:`Connect channel`,slackChannelId:`Slack channel ID`,slackConnecting:`Connecting to Slack...`,slackDisconnecting:`Disconnecting...`,slackConnect:`Connect to Slack`,slackConnected:`Connected`,slackConnectContainerDescription:`Connect to get notifications in your Slack workspace.`,slackSearchbarDisconnected:`Slack is not connected.`,slackSearchbarNoChannelsConnected:`Search channels`,slackSearchbarNoChannelsFound:`No slack channels.`,slackSearchbarChannelsError:`Error fetching channels.`,slackSearchChannels:`Search channels`,slackConnectionErrorExists:`Try reconnecting to Slack to find and select channels from your workspace.`,slackConnectionErrorOccurred:`There was an error connecting to Slack. Try reconnecting to find and select channels from your workspace.`,slackChannelAlreadyConnected:`Error: already connected`,slackError:`Error`,slackDisconnect:`Disconnect`,slackChannelSetError:`Error setting channel.`,slackAccessTokenNotSet:`Access token not set.`,slackReconnect:`Reconnect`},locale:`en`},de:{translations:{archiveNotification:`Benachrichtigung archivieren`,archiveRead:`Gelesenes Archivieren`,markAllAsRead:`Alle als gelesen markieren`,notifications:`Benachrichtigungen`,emptyFeedTitle:`Noch keine Benachrichtigungen`,emptyFeedBody:`Wir werden dich benachrichtigen, sobald wir etwas Neues für dich haben.`,all:`Alle`,unread:`Ungelesen`,read:`Gelesen`,unseen:`Ungesehen`,slackConnectChannel:`Kanal verbinden`,slackChannelId:`Slack Kanal ID`,slackConnecting:`Verbinden mit Slack...`,slackDisconnecting:`Trennen der Verbindung...`,slackConnect:`Mit Slack verbinden`,slackConnected:`Verbunden`,slackConnectContainerDescription:`Verbinden, um Benachrichtigungen in Ihrem Slack-Arbeitsbereich zu erhalten.`,slackSearchbarDisconnected:`Slack ist nicht verbunden.`,slackSearchbarNoChannelsConnected:`Suchkanäle`,slackSearchbarNoChannelsFound:`Keine schlaffen Kanäle.`,slackSearchbarChannelsError:`Fehler beim Abrufen von Kanälen.`,slackSearchChannels:`Suchkanäle`,slackConnectionErrorExists:`Versuchen Sie, sich erneut mit Slack zu verbinden, um Kanäle in Ihrem Arbeitsbereich zu finden und auszuwählen.`,slackConnectionErrorOccurred:`Es ist ein Fehler beim Verbinden mit Slack aufgetreten. Versuchen Sie, sich erneut zu verbinden, um Kanäle in Ihrem Arbeitsbereich zu finden und auszuwählen.`,slackChannelAlreadyConnected:`Fehler: bereits verbunden`,slackError:`Fehler`,slackDisconnect:`Trennen Sie die Verbindung.`,slackChannelSetError:`Fehlereinstellung Kanal.`,slackAccessTokenNotSet:`Zugriffstoken nicht gesetzt.`,slackReconnect:`Neu verbinden`},locale:`de`}}.en),a(((e,t)=>{(function(n){var r=Object.hasOwnProperty,i=Array.isArray?Array.isArray:function(e){return Object.prototype.toString.call(e)===`[object Array]`},a=10,o=typeof process==`object`&&typeof process.nextTick==`function`,s=typeof Symbol==`function`,c=typeof Reflect==`object`,l=typeof setImmediate==`function`?setImmediate:setTimeout,u=s?c&&typeof Reflect.ownKeys==`function`?Reflect.ownKeys:function(e){var t=Object.getOwnPropertyNames(e);return t.push.apply(t,Object.getOwnPropertySymbols(e)),t}:Object.keys;function d(){this._events={},this._conf&&f.call(this,this._conf)}function f(e){e&&(this._conf=e,e.delimiter&&(this.delimiter=e.delimiter),e.maxListeners!==n&&(this._maxListeners=e.maxListeners),e.wildcard&&(this.wildcard=e.wildcard),e.newListener&&(this._newListener=e.newListener),e.removeListener&&(this._removeListener=e.removeListener),e.verboseMemoryLeak&&(this.verboseMemoryLeak=e.verboseMemoryLeak),e.ignoreErrors&&(this.ignoreErrors=e.ignoreErrors),this.wildcard&&(this.listenerTree={}))}function p(e,t){var n=`(node) warning: possible EventEmitter memory leak detected. `+e+` listeners added. Use emitter.setMaxListeners() to increase limit.`;if(this.verboseMemoryLeak&&(n+=` Event name: `+t+`.`),typeof process<`u`&&process.emitWarning){var r=Error(n);r.name=`MaxListenersExceededWarning`,r.emitter=this,r.count=e,process.emitWarning(r)}else console.error(n),console.trace&&console.trace()}var m=function(e,t,n){var r=arguments.length;switch(r){case 0:return[];case 1:return[e];case 2:return[e,t];case 3:return[e,t,n];default:for(var i=Array(r);r--;)i[r]=arguments[r];return i}};function h(e,t){for(var r={},i,a=e.length,o=t?t.length:0,s=0;s<a;s++)i=e[s],r[i]=s<o?t[s]:n;return r}function g(e,t,n){this._emitter=e,this._target=t,this._listeners={},this._listenersCount=0;var r,i;if((n.on||n.off)&&(r=n.on,i=n.off),t.addEventListener?(r=t.addEventListener,i=t.removeEventListener):t.addListener?(r=t.addListener,i=t.removeListener):t.on&&(r=t.on,i=t.off),!r&&!i)throw Error(`target does not implement any known event API`);if(typeof r!=`function`)throw TypeError(`on method must be a function`);if(typeof i!=`function`)throw TypeError(`off method must be a function`);this._on=r,this._off=i;var a=e._observers;a?a.push(this):e._observers=[this]}Object.assign(g.prototype,{subscribe:function(e,t,n){var r=this,i=this._target,a=this._emitter,o=this._listeners,s=function(){var r=m.apply(null,arguments),o={data:r,name:t,original:e};if(n){n.call(i,o)!==!1&&a.emit.apply(a,[o.name].concat(r));return}a.emit.apply(a,[t].concat(r))};if(o[e])throw Error(`Event '`+e+`' is already listening`);this._listenersCount++,a._newListener&&a._removeListener&&!r._onNewListener?(this._onNewListener=function(n){n===t&&o[e]===null&&(o[e]=s,r._on.call(i,e,s))},a.on(`newListener`,this._onNewListener),this._onRemoveListener=function(n){n===t&&!a.hasListeners(n)&&o[e]&&(o[e]=null,r._off.call(i,e,s))},o[e]=null,a.on(`removeListener`,this._onRemoveListener)):(o[e]=s,r._on.call(i,e,s))},unsubscribe:function(e){var t=this,n=this._listeners,r=this._emitter,i,a,o=this._off,s=this._target,c;if(e&&typeof e!=`string`)throw TypeError(`event must be a string`);function l(){t._onNewListener&&(r.off(`newListener`,t._onNewListener),r.off(`removeListener`,t._onRemoveListener),t._onNewListener=null,t._onRemoveListener=null);var e=C.call(r,t);r._observers.splice(e,1)}if(e){if(i=n[e],!i)return;o.call(s,e,i),delete n[e],--this._listenersCount||l()}else{for(a=u(n),c=a.length;c-- >0;)e=a[c],o.call(s,e,n[e]);this._listeners={},this._listenersCount=0,l()}}});function _(e,t,i,a){var o=Object.assign({},t);if(!e)return o;if(typeof e!=`object`)throw TypeError(`options must be an object`);var s=Object.keys(e),c=s.length,l,u,d;function f(e){throw Error(`Invalid "`+l+`" option value`+(e?`. Reason: `+e:``))}for(var p=0;p<c;p++){if(l=s[p],!a&&!r.call(t,l))throw Error(`Unknown "`+l+`" option`);u=e[l],u!==n&&(d=i[l],o[l]=d?d(u,f):u)}return o}function v(e,t){return(typeof e!=`function`||!e.hasOwnProperty(`prototype`))&&t(`value must be a constructor`),e}function y(e){var t=`value must be type of `+e.join(`|`),n=e.length,r=e[0],i=e[1];return n===1?function(e,n){if(typeof e===r)return e;n(t)}:n===2?function(e,n){var a=typeof e;if(a===r||a===i)return e;n(t)}:function(r,i){for(var a=typeof r,o=n;o-- >0;)if(a===e[o])return r;i(t)}}var b=y([`function`]),x=y([`object`,`function`]);function S(e,t,n){var r,i,a=0,o,s=new e(function(c,l,u){n=_(n,{timeout:0,overload:!1},{timeout:function(e,t){return e*=1,(typeof e!=`number`||e<0||!Number.isFinite(e))&&t(`timeout must be a positive number`),e}}),r=!n.overload&&typeof e.prototype.cancel==`function`&&typeof u==`function`;function d(){i&&=null,a&&=(clearTimeout(a),0)}var f=function(e){d(),c(e)},p=function(e){d(),l(e)};r?t(f,p,u):(i=[function(e){p(e||Error(`canceled`))}],t(f,p,function(e){if(o)throw Error(`Unable to subscribe on cancel event asynchronously`);if(typeof e!=`function`)throw TypeError(`onCancel callback must be a function`);i.push(e)}),o=!0),n.timeout>0&&(a=setTimeout(function(){var e=Error(`timeout`);e.code=`ETIMEDOUT`,a=0,s.cancel(e),l(e)},n.timeout))});return r||(s.cancel=function(e){if(i){for(var t=i.length,n=1;n<t;n++)i[n](e);i[0](e),i=null}}),s}function C(e){var t=this._observers;if(!t)return-1;for(var n=t.length,r=0;r<n;r++)if(t[r]._target===e)return r;return-1}function w(e,t,n,r,i){if(!n)return null;if(r===0){var a=typeof t;if(a===`string`){var o,s,c=0,l=0,d=this.delimiter,f=d.length;if((s=t.indexOf(d))!==-1){o=[,,,,,];do o[c++]=t.slice(l,s),l=s+f;while((s=t.indexOf(d,l))!==-1);o[c++]=t.slice(l),t=o,i=c}else t=[t],i=1}else a===`object`?i=t.length:(t=[t],i=1)}var p=null,m,h,g,_,v,y=t[r],b=t[r+1],x,S;if(r===i)n._listeners&&(typeof n._listeners==`function`?(e&&e.push(n._listeners),p=[n]):(e&&e.push.apply(e,n._listeners),p=[n]));else if(y===`*`){for(x=u(n),s=x.length;s-- >0;)m=x[s],m!==`_listeners`&&(S=w(e,t,n[m],r+1,i),S&&(p?p.push.apply(p,S):p=S));return p}else if(y===`**`){for(v=r+1===i||r+2===i&&b===`*`,v&&n._listeners&&(p=w(e,t,n,i,i)),x=u(n),s=x.length;s-- >0;)m=x[s],m!==`_listeners`&&(m===`*`||m===`**`?(n[m]._listeners&&!v&&(S=w(e,t,n[m],i,i),S&&(p?p.push.apply(p,S):p=S)),S=w(e,t,n[m],r,i)):S=m===b?w(e,t,n[m],r+2,i):w(e,t,n[m],r,i),S&&(p?p.push.apply(p,S):p=S));return p}else n[y]&&(p=w(e,t,n[y],r+1,i));if(h=n[`*`],h&&w(e,t,h,r+1,i),g=n[`**`],g)if(r<i)for(g._listeners&&w(e,t,g,i,i),x=u(g),s=x.length;s-- >0;)m=x[s],m!==`_listeners`&&(m===b?w(e,t,g[m],r+2,i):m===y?w(e,t,g[m],r+1,i):(_={},_[m]=g[m],w(e,t,{"**":_},r+1,i)));else g._listeners?w(e,t,g,i,i):g[`*`]&&g[`*`]._listeners&&w(e,t,g[`*`],i,i);return p}function T(e,t,n){var r=0,i=0,a,o=this.delimiter,s=o.length,c;if(typeof e==`string`)if((a=e.indexOf(o))!==-1){c=[,,,,,];do c[r++]=e.slice(i,a),i=a+s;while((a=e.indexOf(o,i))!==-1);c[r++]=e.slice(i)}else c=[e],r=1;else c=e,r=e.length;if(r>1){for(a=0;a+1<r;a++)if(c[a]===`**`&&c[a+1]===`**`)return}var l=this.listenerTree,u;for(a=0;a<r;a++)if(u=c[a],l=l[u]||(l[u]={}),a===r-1)return l._listeners?(typeof l._listeners==`function`&&(l._listeners=[l._listeners]),n?l._listeners.unshift(t):l._listeners.push(t),!l._listeners.warned&&this._maxListeners>0&&l._listeners.length>this._maxListeners&&(l._listeners.warned=!0,p.call(this,l._listeners.length,u))):l._listeners=t,!0;return!0}function E(e,t,n,r){for(var i=u(e),a=i.length,o,s,c,l=e._listeners,d;a-- >0;)s=i[a],o=e[s],c=s===`_listeners`?n:n?n.concat(s):[s],d=r||typeof s==`symbol`,l&&t.push(d?c:c.join(this.delimiter)),typeof o==`object`&&E.call(this,o,t,c,d);return t}function D(e){for(var t=u(e),n=t.length,r,i,a;n-- >0;)i=t[n],r=e[i],r&&(a=!0,i!==`_listeners`&&!D(r)&&delete e[i]);return a}function O(e,t,n){this.emitter=e,this.event=t,this.listener=n}O.prototype.off=function(){return this.emitter.off(this.event,this.listener),this};function k(e,t,r){if(r===!0)a=!0;else if(r===!1)i=!0;else{if(!r||typeof r!=`object`)throw TypeError(`options should be an object or true`);var i=r.async,a=r.promisify,s=r.nextTick,c=r.objectify}if(i||s||a){var u=t,d=t._origin||t;if(s&&!o)throw Error(`process.nextTick is not supported`);a===n&&(a=t.constructor.name===`AsyncFunction`),t=function(){var e=arguments,t=this,n=this.event;return a?s?Promise.resolve():new Promise(function(e){l(e)}).then(function(){return t.event=n,u.apply(t,e)}):(s?process.nextTick:l)(function(){t.event=n,u.apply(t,e)})},t._async=!0,t._origin=d}return[t,c?new O(this,e,t):this]}function A(e){this._events={},this._newListener=!1,this._removeListener=!1,this.verboseMemoryLeak=!1,f.call(this,e)}A.EventEmitter2=A,A.prototype.listenTo=function(e,t,r){if(typeof e!=`object`)throw TypeError(`target musts be an object`);var a=this;r=_(r,{on:n,off:n,reducers:n},{on:b,off:b,reducers:x});function o(t){if(typeof t!=`object`)throw TypeError(`events must be an object`);for(var n=r.reducers,i=C.call(a,e),o=i===-1?new g(a,e,r):a._observers[i],s=u(t),c=s.length,l,d=typeof n==`function`,f=0;f<c;f++)l=s[f],o.subscribe(l,t[l]||l,d?n:n&&n[l])}return i(t)?o(h(t)):o(typeof t==`string`?h(t.split(/\s+/)):t),this},A.prototype.stopListeningTo=function(e,t){var n=this._observers;if(!n)return!1;var r=n.length,i,a=!1;if(e&&typeof e!=`object`)throw TypeError(`target should be an object`);for(;r-- >0;)i=n[r],(!e||i._target===e)&&(i.unsubscribe(t),a=!0);return a},A.prototype.delimiter=`.`,A.prototype.setMaxListeners=function(e){e!==n&&(this._maxListeners=e,this._conf||={},this._conf.maxListeners=e)},A.prototype.getMaxListeners=function(){return this._maxListeners},A.prototype.event=``,A.prototype.once=function(e,t,n){return this._once(e,t,!1,n)},A.prototype.prependOnceListener=function(e,t,n){return this._once(e,t,!0,n)},A.prototype._once=function(e,t,n,r){return this._many(e,1,t,n,r)},A.prototype.many=function(e,t,n,r){return this._many(e,t,n,!1,r)},A.prototype.prependMany=function(e,t,n,r){return this._many(e,t,n,!0,r)},A.prototype._many=function(e,t,n,r,i){var a=this;if(typeof n!=`function`)throw Error(`many only accepts instances of Function`);function o(){return--t===0&&a.off(e,o),n.apply(this,arguments)}return o._origin=n,this._on(e,o,r,i)},A.prototype.emit=function(){if(!this._events&&!this._all)return!1;this._events||d.call(this);var e=arguments[0],t,n=this.wildcard,r,i,a,o,c;if(e===`newListener`&&!this._newListener&&!this._events.newListener)return!1;if(n&&(t=e,e!==`newListener`&&e!==`removeListener`&&typeof e==`object`)){if(i=e.length,s){for(a=0;a<i;a++)if(typeof e[a]==`symbol`){c=!0;break}}c||(e=e.join(this.delimiter))}var l=arguments.length,u;if(this._all&&this._all.length)for(u=this._all.slice(),a=0,i=u.length;a<i;a++)switch(this.event=e,l){case 1:u[a].call(this,e);break;case 2:u[a].call(this,e,arguments[1]);break;case 3:u[a].call(this,e,arguments[1],arguments[2]);break;default:u[a].apply(this,arguments)}if(n)u=[],w.call(this,u,t,this.listenerTree,0,i);else if(u=this._events[e],typeof u==`function`){switch(this.event=e,l){case 1:u.call(this);break;case 2:u.call(this,arguments[1]);break;case 3:u.call(this,arguments[1],arguments[2]);break;default:for(r=Array(l-1),o=1;o<l;o++)r[o-1]=arguments[o];u.apply(this,r)}return!0}else u&&=u.slice();if(u&&u.length){if(l>3)for(r=Array(l-1),o=1;o<l;o++)r[o-1]=arguments[o];for(a=0,i=u.length;a<i;a++)switch(this.event=e,l){case 1:u[a].call(this);break;case 2:u[a].call(this,arguments[1]);break;case 3:u[a].call(this,arguments[1],arguments[2]);break;default:u[a].apply(this,r)}return!0}else if(!this.ignoreErrors&&!this._all&&e===`error`)throw arguments[1]instanceof Error?arguments[1]:Error(`Uncaught, unspecified 'error' event.`);return!!this._all},A.prototype.emitAsync=function(){if(!this._events&&!this._all)return!1;this._events||d.call(this);var e=arguments[0],t=this.wildcard,n,r,i,a,o,c;if(e===`newListener`&&!this._newListener&&!this._events.newListener)return Promise.resolve([!1]);if(t&&(n=e,e!==`newListener`&&e!==`removeListener`&&typeof e==`object`)){if(a=e.length,s){for(o=0;o<a;o++)if(typeof e[o]==`symbol`){r=!0;break}}r||(e=e.join(this.delimiter))}var l=[],u=arguments.length,f;if(this._all)for(o=0,a=this._all.length;o<a;o++)switch(this.event=e,u){case 1:l.push(this._all[o].call(this,e));break;case 2:l.push(this._all[o].call(this,e,arguments[1]));break;case 3:l.push(this._all[o].call(this,e,arguments[1],arguments[2]));break;default:l.push(this._all[o].apply(this,arguments))}if(t?(f=[],w.call(this,f,n,this.listenerTree,0)):f=this._events[e],typeof f==`function`)switch(this.event=e,u){case 1:l.push(f.call(this));break;case 2:l.push(f.call(this,arguments[1]));break;case 3:l.push(f.call(this,arguments[1],arguments[2]));break;default:for(i=Array(u-1),c=1;c<u;c++)i[c-1]=arguments[c];l.push(f.apply(this,i))}else if(f&&f.length){if(f=f.slice(),u>3)for(i=Array(u-1),c=1;c<u;c++)i[c-1]=arguments[c];for(o=0,a=f.length;o<a;o++)switch(this.event=e,u){case 1:l.push(f[o].call(this));break;case 2:l.push(f[o].call(this,arguments[1]));break;case 3:l.push(f[o].call(this,arguments[1],arguments[2]));break;default:l.push(f[o].apply(this,i))}}else if(!this.ignoreErrors&&!this._all&&e===`error`)return arguments[1]instanceof Error?Promise.reject(arguments[1]):Promise.reject(`Uncaught, unspecified 'error' event.`);return Promise.all(l)},A.prototype.on=function(e,t,n){return this._on(e,t,!1,n)},A.prototype.prependListener=function(e,t,n){return this._on(e,t,!0,n)},A.prototype.onAny=function(e){return this._onAny(e,!1)},A.prototype.prependAny=function(e){return this._onAny(e,!0)},A.prototype.addListener=A.prototype.on,A.prototype._onAny=function(e,t){if(typeof e!=`function`)throw Error(`onAny only accepts instances of Function`);return this._all||=[],t?this._all.unshift(e):this._all.push(e),this},A.prototype._on=function(e,t,r,i){if(typeof e==`function`)return this._onAny(e,t),this;if(typeof t!=`function`)throw Error(`on only accepts instances of Function`);this._events||d.call(this);var a=this,o;return i!==n&&(o=k.call(this,e,t,i),t=o[0],a=o[1]),this._newListener&&this.emit(`newListener`,e,t),this.wildcard?(T.call(this,e,t,r),a):(this._events[e]?(typeof this._events[e]==`function`&&(this._events[e]=[this._events[e]]),r?this._events[e].unshift(t):this._events[e].push(t),!this._events[e].warned&&this._maxListeners>0&&this._events[e].length>this._maxListeners&&(this._events[e].warned=!0,p.call(this,this._events[e].length,e))):this._events[e]=t,a)},A.prototype.off=function(e,t){if(typeof t!=`function`)throw Error(`removeListener only takes instances of Function`);var n,r=[];if(this.wildcard){var a=typeof e==`string`?e.split(this.delimiter):e.slice();if(r=w.call(this,null,a,this.listenerTree,0),!r)return this}else{if(!this._events[e])return this;n=this._events[e],r.push({_listeners:n})}for(var o=0;o<r.length;o++){var s=r[o];if(n=s._listeners,i(n)){for(var c=-1,l=0,u=n.length;l<u;l++)if(n[l]===t||n[l].listener&&n[l].listener===t||n[l]._origin&&n[l]._origin===t){c=l;break}if(c<0)continue;return this.wildcard?s._listeners.splice(c,1):this._events[e].splice(c,1),n.length===0&&(this.wildcard?delete s._listeners:delete this._events[e]),this._removeListener&&this.emit(`removeListener`,e,t),this}else (n===t||n.listener&&n.listener===t||n._origin&&n._origin===t)&&(this.wildcard?delete s._listeners:delete this._events[e],this._removeListener&&this.emit(`removeListener`,e,t))}return this.listenerTree&&D(this.listenerTree),this},A.prototype.offAny=function(e){var t=0,n=0,r;if(e&&this._all&&this._all.length>0){for(r=this._all,t=0,n=r.length;t<n;t++)if(e===r[t])return r.splice(t,1),this._removeListener&&this.emit(`removeListenerAny`,e),this}else{if(r=this._all,this._removeListener)for(t=0,n=r.length;t<n;t++)this.emit(`removeListenerAny`,r[t]);this._all=[]}return this},A.prototype.removeListener=A.prototype.off,A.prototype.removeAllListeners=function(e){if(e===n)return!this._events||d.call(this),this;if(this.wildcard){var t=w.call(this,null,e,this.listenerTree,0),r,i;if(!t)return this;for(i=0;i<t.length;i++)r=t[i],r._listeners=null;this.listenerTree&&D(this.listenerTree)}else this._events&&(this._events[e]=null);return this},A.prototype.listeners=function(e){var t=this._events,r,i,a,o,s;if(e===n){if(this.wildcard)throw Error(`event name required for wildcard emitter`);if(!t)return[];for(r=u(t),o=r.length,a=[];o-- >0;)i=t[r[o]],typeof i==`function`?a.push(i):a.push.apply(a,i);return a}else{if(this.wildcard){if(s=this.listenerTree,!s)return[];var c=[],l=typeof e==`string`?e.split(this.delimiter):e.slice();return w.call(this,c,l,s,0),c}return!t||(i=t[e],!i)?[]:typeof i==`function`?[i]:i}},A.prototype.eventNames=function(e){var t=this._events;return this.wildcard?E.call(this,this.listenerTree,[],null,e):t?u(t):[]},A.prototype.listenerCount=function(e){return this.listeners(e).length},A.prototype.hasListeners=function(e){if(this.wildcard){var t=[],r=typeof e==`string`?e.split(this.delimiter):e.slice();return w.call(this,t,r,this.listenerTree,0),t.length>0}var i=this._events,a=this._all;return!!(a&&a.length||i&&(e===n?u(i).length:i[e]))},A.prototype.listenersAny=function(){return this._all?this._all:[]},A.prototype.waitFor=function(e,t){var r=this,i=typeof t;return i===`number`?t={timeout:t}:i===`function`&&(t={filter:t}),t=_(t,{timeout:0,filter:n,handleError:!1,Promise,overload:!1},{filter:b,Promise:v}),S(t.Promise,function(n,i,a){function o(){var a=t.filter;if(!(a&&!a.apply(r,arguments)))if(r.off(e,o),t.handleError){var s=arguments[0];s?i(s):n(m.apply(null,arguments).slice(1))}else n(m.apply(null,arguments))}a(function(){r.off(e,o)}),r._on(e,o,!1)},{timeout:t.timeout,overload:t.overload})};function j(e,t,n){n=_(n,{Promise,timeout:0,overload:!1},{Promise:v});var r=n.Promise;return S(r,function(n,r,i){var a;if(typeof e.addEventListener==`function`){a=function(){n(m.apply(null,arguments))},i(function(){e.removeEventListener(t,a)}),e.addEventListener(t,a,{once:!0});return}var o=function(){s&&e.removeListener(`error`,s),n(m.apply(null,arguments))},s;t!==`error`&&(s=function(n){e.removeListener(t,o),r(n)},e.once(`error`,s)),i(function(){s&&e.removeListener(`error`,s),e.removeListener(t,o)}),e.once(t,o)},{timeout:n.timeout,overload:n.overload})}var M=A.prototype;if(Object.defineProperties(A,{defaultMaxListeners:{get:function(){return M._maxListeners},set:function(e){if(typeof e!=`number`||e<0||Number.isNaN(e))throw TypeError(`n must be a non-negative number`);M._maxListeners=e},enumerable:!0},once:{value:j,writable:!0,configurable:!0}}),Object.defineProperties(M,{_maxListeners:{value:a,writable:!0,configurable:!0},_observers:{value:null,writable:!0,configurable:!0}}),typeof define==`function`&&define.amd)define(function(){return A});else if(typeof e==`object`)t.exports=A;else{var N=Function(``,`return this`)();N.EventEmitter2=A}})()}))();var Sqt=(e=>(e.loading=`loading`,e.fetchMore=`fetchMore`,e.ready=`ready`,e.error=`error`,e))(Sqt||{}),G7=new WeakMap,K7=new WeakMap,q7={current:[]},J7=!1,Cqt=0,Y7=new Set,X7=new Map;function wqt(e){let t=Array.from(e).sort((e,t)=>e instanceof Aqt&&e.options.deps.includes(t)?1:t instanceof Aqt&&t.options.deps.includes(e)?-1:0);for(let e of t){if(q7.current.includes(e))continue;q7.current.push(e),e.recompute();let t=K7.get(e);if(t)for(let e of t){let t=G7.get(e);t&&wqt(t)}}}function Tqt(e){let t={prevVal:e.prevState,currentVal:e.state};for(let n of e.listeners)n(t)}function Eqt(e){let t={prevVal:e.prevState,currentVal:e.state};for(let n of e.listeners)n(t)}function Dqt(e){if(Cqt>0&&!X7.has(e)&&X7.set(e,e.prevState),Y7.add(e),!(Cqt>0)&&!J7)try{for(J7=!0;Y7.size>0;){let e=Array.from(Y7);Y7.clear();for(let t of e)t.prevState=X7.get(t)??t.prevState,Tqt(t);for(let t of e){let e=G7.get(t);e&&(q7.current.push(t),wqt(e))}for(let t of e){let e=G7.get(t);if(e)for(let t of e)Eqt(t)}}}finally{J7=!1,q7.current=[],X7.clear()}}function Oqt(e){return typeof e==`function`}var kqt=class{constructor(e,t){this.listeners=new Set,this.subscribe=e=>{var t;this.listeners.add(e);let n=((t=this.options)?.onSubscribe)?.call(t,e,this);return()=>{this.listeners.delete(e),n?.()}},this.prevState=e,this.state=e,this.options=t}setState(e){var t,n;this.prevState=this.state,this.options?.updateFn?this.state=this.options.updateFn(this.prevState)(e):Oqt(e)?this.state=e(this.prevState):this.state=e,(n=(t=this.options)?.onUpdate)==null||n.call(t),Dqt(this)}},Aqt=class e{constructor(t){this.listeners=new Set,this._subscriptions=[],this.lastSeenDepValues=[],this.getDepVals=()=>{let e=this.options.deps.length,t=Array(e),n=Array(e);for(let r=0;r<e;r++){let e=this.options.deps[r];t[r]=e.prevState,n[r]=e.state}return this.lastSeenDepValues=n,{prevDepVals:t,currDepVals:n,prevVal:this.prevState??void 0}},this.recompute=()=>{var e,t;this.prevState=this.state;let n=this.getDepVals();this.state=this.options.fn(n),(t=(e=this.options).onUpdate)==null||t.call(e)},this.checkIfRecalculationNeededDeeply=()=>{for(let t of this.options.deps)t instanceof e&&t.checkIfRecalculationNeededDeeply();let t=!1,n=this.lastSeenDepValues,{currDepVals:r}=this.getDepVals();for(let e=0;e<r.length;e++)if(r[e]!==n[e]){t=!0;break}t&&this.recompute()},this.mount=()=>(this.registerOnGraph(),this.checkIfRecalculationNeededDeeply(),()=>{this.unregisterFromGraph();for(let e of this._subscriptions)e()}),this.subscribe=e=>{var t;this.listeners.add(e);let n=(t=this.options).onSubscribe?.call(t,e,this);return()=>{this.listeners.delete(e),n?.()}},this.options=t,this.state=t.fn({prevDepVals:void 0,prevVal:void 0,currDepVals:this.getDepVals().currDepVals})}registerOnGraph(t=this.options.deps){for(let n of t)if(n instanceof e)n.registerOnGraph(),this.registerOnGraph(n.options.deps);else if(n instanceof kqt){let e=G7.get(n);e||(e=new Set,G7.set(n,e)),e.add(this);let t=K7.get(this);t||(t=new Set,K7.set(this,t)),t.add(n)}}unregisterFromGraph(t=this.options.deps){for(let n of t)if(n instanceof e)this.unregisterFromGraph(n.options.deps);else if(n instanceof kqt){let e=G7.get(n);e&&e.delete(this);let t=K7.get(this);t&&t.delete(n)}}};({NewMessage:`new-message`}).NewMessage,Sqt.ready;var jqt=class extends Error{};jqt.prototype.name=`InvalidTokenError`;function Mqt(e,t){return function(){return e.apply(t,arguments)}}var{toString:Nqt}=Object.prototype,{getPrototypeOf:Z7}=Object,{iterator:Q7,toStringTag:Pqt}=Symbol,$7=(e=>t=>{let n=Nqt.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),e9=e=>(e=e.toLowerCase(),t=>$7(t)===e),t9=e=>t=>typeof t===e,{isArray:n9}=Array,r9=t9(`undefined`);function i9(e){return e!==null&&!r9(e)&&e.constructor!==null&&!r9(e.constructor)&&a9(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var Fqt=e9(`ArrayBuffer`);function Iqt(e){let t;return t=typeof ArrayBuffer<`u`&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&Fqt(e.buffer),t}var Lqt=t9(`string`),a9=t9(`function`),Rqt=t9(`number`),o9=e=>typeof e==`object`&&!!e,zqt=e=>e===!0||e===!1,s9=e=>{if($7(e)!==`object`)return!1;let t=Z7(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Pqt in e)&&!(Q7 in e)},Bqt=e=>{if(!o9(e)||i9(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Vqt=e9(`Date`),Hqt=e9(`File`),Uqt=e9(`Blob`),Wqt=e9(`FileList`),Gqt=e=>o9(e)&&a9(e.pipe),Kqt=e=>{let t;return e&&(typeof FormData==`function`&&e instanceof FormData||a9(e.append)&&((t=$7(e))===`formdata`||t===`object`&&a9(e.toString)&&e.toString()===`[object FormData]`))},qqt=e9(`URLSearchParams`),[Jqt,Yqt,Xqt,Zqt]=[`ReadableStream`,`Request`,`Response`,`Headers`].map(e9),Qqt=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,``);function c9(e,t,{allOwnKeys:n=!1}={}){if(e==null)return;let r,i;if(typeof e!=`object`&&(e=[e]),n9(e))for(r=0,i=e.length;r<i;r++)t.call(null,e[r],r,e);else{if(i9(e))return;let i=n?Object.getOwnPropertyNames(e):Object.keys(e),a=i.length,o;for(r=0;r<a;r++)o=i[r],t.call(null,e[o],o,e)}}function $qt(e,t){if(i9(e))return null;t=t.toLowerCase();let n=Object.keys(e),r=n.length,i;for(;r-- >0;)if(i=n[r],t===i.toLowerCase())return i;return null}var l9=typeof globalThis<`u`?globalThis:typeof self<`u`?self:typeof window<`u`?window:global,eJt=e=>!r9(e)&&e!==l9;function u9(){let{caseless:e,skipUndefined:t}=eJt(this)&&this||{},n={},r=(r,i)=>{if(i===`__proto__`||i===`constructor`||i===`prototype`)return;let a=e&&$qt(n,i)||i;s9(n[a])&&s9(r)?n[a]=u9(n[a],r):s9(r)?n[a]=u9({},r):n9(r)?n[a]=r.slice():(!t||!r9(r))&&(n[a]=r)};for(let e=0,t=arguments.length;e<t;e++)arguments[e]&&c9(arguments[e],r);return n}var tJt=(e,t,n,{allOwnKeys:r}={})=>(c9(t,(t,r)=>{n&&a9(t)?Object.defineProperty(e,r,{value:Mqt(t,n),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(e,r,{value:t,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:r}),e),nJt=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),rJt=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),Object.defineProperty(e.prototype,`constructor`,{value:e,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(e,`super`,{value:t.prototype}),n&&Object.assign(e.prototype,n)},iJt=(e,t,n,r)=>{let i,a,o,s={};if(t||={},e==null)return t;do{for(i=Object.getOwnPropertyNames(e),a=i.length;a-- >0;)o=i[a],(!r||r(o,e,t))&&!s[o]&&(t[o]=e[o],s[o]=!0);e=n!==!1&&Z7(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},aJt=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;let r=e.indexOf(t,n);return r!==-1&&r===n},oJt=e=>{if(!e)return null;if(n9(e))return e;let t=e.length;if(!Rqt(t))return null;let n=Array(t);for(;t-- >0;)n[t]=e[t];return n},sJt=(e=>t=>e&&t instanceof e)(typeof Uint8Array<`u`&&Z7(Uint8Array)),cJt=(e,t)=>{let n=(e&&e[Q7]).call(e),r;for(;(r=n.next())&&!r.done;){let n=r.value;t.call(e,n[0],n[1])}},lJt=(e,t)=>{let n,r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},uJt=e9(`HTMLFormElement`),dJt=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(e,t,n){return t.toUpperCase()+n}),fJt=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),pJt=e9(`RegExp`),mJt=(e,t)=>{let n=Object.getOwnPropertyDescriptors(e),r={};c9(n,(n,i)=>{let a;(a=t(n,i,e))!==!1&&(r[i]=a||n)}),Object.defineProperties(e,r)},hJt=e=>{mJt(e,(t,n)=>{if(a9(e)&&[`arguments`,`caller`,`callee`].indexOf(n)!==-1)return!1;let r=e[n];if(a9(r)){if(t.enumerable=!1,`writable`in t){t.writable=!1;return}t.set||=()=>{throw Error(`Can not rewrite read-only method '`+n+`'`)}}})},gJt=(e,t)=>{let n={},r=e=>{e.forEach(e=>{n[e]=!0})};return n9(e)?r(e):r(String(e).split(t)),n},_Jt=()=>{},vJt=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function yJt(e){return!!(e&&a9(e.append)&&e[Pqt]===`FormData`&&e[Q7])}var bJt=e=>{let t=Array(10),n=(e,r)=>{if(o9(e)){if(t.indexOf(e)>=0)return;if(i9(e))return e;if(!(`toJSON`in e)){t[r]=e;let i=n9(e)?[]:{};return c9(e,(e,t)=>{let a=n(e,r+1);!r9(a)&&(i[t]=a)}),t[r]=void 0,i}}return e};return n(e,0)},xJt=e9(`AsyncFunction`),SJt=e=>e&&(o9(e)||a9(e))&&a9(e.then)&&a9(e.catch),CJt=((e,t)=>e?setImmediate:t?((e,t)=>(l9.addEventListener(`message`,({source:n,data:r})=>{n===l9&&r===e&&t.length&&t.shift()()},!1),n=>{t.push(n),l9.postMessage(e,`*`)}))(`axios@${Math.random()}`,[]):e=>setTimeout(e))(typeof setImmediate==`function`,a9(l9.postMessage)),$={isArray:n9,isArrayBuffer:Fqt,isBuffer:i9,isFormData:Kqt,isArrayBufferView:Iqt,isString:Lqt,isNumber:Rqt,isBoolean:zqt,isObject:o9,isPlainObject:s9,isEmptyObject:Bqt,isReadableStream:Jqt,isRequest:Yqt,isResponse:Xqt,isHeaders:Zqt,isUndefined:r9,isDate:Vqt,isFile:Hqt,isBlob:Uqt,isRegExp:pJt,isFunction:a9,isStream:Gqt,isURLSearchParams:qqt,isTypedArray:sJt,isFileList:Wqt,forEach:c9,merge:u9,extend:tJt,trim:Qqt,stripBOM:nJt,inherits:rJt,toFlatObject:iJt,kindOf:$7,kindOfTest:e9,endsWith:aJt,toArray:oJt,forEachEntry:cJt,matchAll:lJt,isHTMLForm:uJt,hasOwnProperty:fJt,hasOwnProp:fJt,reduceDescriptors:mJt,freezeMethods:hJt,toObjectSet:gJt,toCamelCase:dJt,noop:_Jt,toFiniteNumber:vJt,findKey:$qt,global:l9,isContextDefined:eJt,isSpecCompliantForm:yJt,toJSONObject:bJt,isAsyncFn:xJt,isThenable:SJt,setImmediate:CJt,asap:typeof queueMicrotask<`u`?queueMicrotask.bind(l9):typeof process<`u`&&process.nextTick||CJt,isIterable:e=>e!=null&&a9(e[Q7])},d9=class e extends Error{static from(t,n,r,i,a,o){let s=new e(t.message,n||t.code,r,i,a);return s.cause=t,s.name=t.name,o&&Object.assign(s,o),s}constructor(e,t,n,r,i){super(e),this.name=`AxiosError`,this.isAxiosError=!0,t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),i&&(this.response=i,this.status=i.status)}toJSON(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:$.toJSONObject(this.config),code:this.code,status:this.status}}};d9.ERR_BAD_OPTION_VALUE=`ERR_BAD_OPTION_VALUE`,d9.ERR_BAD_OPTION=`ERR_BAD_OPTION`,d9.ECONNABORTED=`ECONNABORTED`,d9.ETIMEDOUT=`ETIMEDOUT`,d9.ERR_NETWORK=`ERR_NETWORK`,d9.ERR_FR_TOO_MANY_REDIRECTS=`ERR_FR_TOO_MANY_REDIRECTS`,d9.ERR_DEPRECATED=`ERR_DEPRECATED`,d9.ERR_BAD_RESPONSE=`ERR_BAD_RESPONSE`,d9.ERR_BAD_REQUEST=`ERR_BAD_REQUEST`,d9.ERR_CANCELED=`ERR_CANCELED`,d9.ERR_NOT_SUPPORT=`ERR_NOT_SUPPORT`,d9.ERR_INVALID_URL=`ERR_INVALID_URL`;function f9(e){return $.isPlainObject(e)||$.isArray(e)}function wJt(e){return $.endsWith(e,`[]`)?e.slice(0,-2):e}function TJt(e,t,n){return e?e.concat(t).map(function(e,t){return e=wJt(e),!n&&t?`[`+e+`]`:e}).join(n?`.`:``):t}function EJt(e){return $.isArray(e)&&!e.some(f9)}var DJt=$.toFlatObject($,{},null,function(e){return/^is[A-Z]/.test(e)});function p9(e,t,n){if(!$.isObject(e))throw TypeError(`target must be an object`);t||=new FormData,n=$.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(e,t){return!$.isUndefined(t[e])});let r=n.metaTokens,i=n.visitor||l,a=n.dots,o=n.indexes,s=(n.Blob||typeof Blob<`u`&&Blob)&&$.isSpecCompliantForm(t);if(!$.isFunction(i))throw TypeError(`visitor must be a function`);function c(e){if(e===null)return``;if($.isDate(e))return e.toISOString();if($.isBoolean(e))return e.toString();if(!s&&$.isBlob(e))throw new d9(`Blob is not supported. Use a Buffer instead.`);return $.isArrayBuffer(e)||$.isTypedArray(e)?s&&typeof Blob==`function`?new Blob([e]):Buffer.from(e):e}function l(e,n,i){let s=e;if(e&&!i&&typeof e==`object`){if($.endsWith(n,`{}`))n=r?n:n.slice(0,-2),e=JSON.stringify(e);else if($.isArray(e)&&EJt(e)||($.isFileList(e)||$.endsWith(n,`[]`))&&(s=$.toArray(e)))return n=wJt(n),s.forEach(function(e,r){!($.isUndefined(e)||e===null)&&t.append(o===!0?TJt([n],r,a):o===null?n:n+`[]`,c(e))}),!1}return f9(e)?!0:(t.append(TJt(i,n,a),c(e)),!1)}let u=[],d=Object.assign(DJt,{defaultVisitor:l,convertValue:c,isVisitable:f9});function f(e,n){if(!$.isUndefined(e)){if(u.indexOf(e)!==-1)throw Error(`Circular reference detected in `+n.join(`.`));u.push(e),$.forEach(e,function(e,r){(!($.isUndefined(e)||e===null)&&i.call(t,e,$.isString(r)?r.trim():r,n,d))===!0&&f(e,n?n.concat(r):[r])}),u.pop()}}if(!$.isObject(e))throw TypeError(`data must be an object`);return f(e),t}function OJt(e){let t={"!":`%21`,"'":`%27`,"(":`%28`,")":`%29`,"~":`%7E`,"%20":`+`,"%00":`\0`};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(e){return t[e]})}function m9(e,t){this._pairs=[],e&&p9(e,this,t)}var kJt=m9.prototype;kJt.append=function(e,t){this._pairs.push([e,t])},kJt.toString=function(e){let t=e?function(t){return e.call(this,t,OJt)}:OJt;return this._pairs.map(function(e){return t(e[0])+`=`+t(e[1])},``).join(`&`)};function AJt(e){return encodeURIComponent(e).replace(/%3A/gi,`:`).replace(/%24/g,`$`).replace(/%2C/gi,`,`).replace(/%20/g,`+`)}function jJt(e,t,n){if(!t)return e;let r=n&&n.encode||AJt,i=$.isFunction(n)?{serialize:n}:n,a=i&&i.serialize,o;if(o=a?a(t,i):$.isURLSearchParams(t)?t.toString():new m9(t,i).toString(r),o){let t=e.indexOf(`#`);t!==-1&&(e=e.slice(0,t)),e+=(e.indexOf(`?`)===-1?`?`:`&`)+o}return e}var MJt=class{constructor(){this.handlers=[]}use(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&=[]}forEach(e){$.forEach(this.handlers,function(t){t!==null&&e(t)})}},h9={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},NJt={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<`u`?URLSearchParams:m9,FormData:typeof FormData<`u`?FormData:null,Blob:typeof Blob<`u`?Blob:null},protocols:[`http`,`https`,`file`,`blob`,`url`,`data`]},PJt=i({hasBrowserEnv:()=>g9,hasStandardBrowserEnv:()=>FJt,hasStandardBrowserWebWorkerEnv:()=>IJt,navigator:()=>_9,origin:()=>LJt}),g9=typeof window<`u`&&typeof document<`u`,_9=typeof navigator==`object`&&navigator||void 0,FJt=g9&&(!_9||[`ReactNative`,`NativeScript`,`NS`].indexOf(_9.product)<0),IJt=typeof WorkerGlobalScope<`u`&&self instanceof WorkerGlobalScope&&typeof self.importScripts==`function`,LJt=g9&&window.location.href||`http://localhost`,v9={...PJt,...NJt};function RJt(e,t){return p9(e,new v9.classes.URLSearchParams,{visitor:function(e,t,n,r){return v9.isNode&&$.isBuffer(e)?(this.append(t,e.toString(`base64`)),!1):r.defaultVisitor.apply(this,arguments)},...t})}function zJt(e){return $.matchAll(/\w+|\[(\w*)]/g,e).map(e=>e[0]===`[]`?``:e[1]||e[0])}function BJt(e){let t={},n=Object.keys(e),r,i=n.length,a;for(r=0;r<i;r++)a=n[r],t[a]=e[a];return t}function VJt(e){function t(e,n,r,i){let a=e[i++];if(a===`__proto__`)return!0;let o=Number.isFinite(+a),s=i>=e.length;return a=!a&&$.isArray(r)?r.length:a,s?($.hasOwnProp(r,a)?r[a]=[r[a],n]:r[a]=n,!o):((!r[a]||!$.isObject(r[a]))&&(r[a]=[]),t(e,n,r[a],i)&&$.isArray(r[a])&&(r[a]=BJt(r[a])),!o)}if($.isFormData(e)&&$.isFunction(e.entries)){let n={};return $.forEachEntry(e,(e,r)=>{t(zJt(e),r,n,0)}),n}return null}function HJt(e,t,n){if($.isString(e))try{return(t||JSON.parse)(e),$.trim(e)}catch(e){if(e.name!==`SyntaxError`)throw e}return(n||JSON.stringify)(e)}var y9={transitional:h9,adapter:[`xhr`,`http`,`fetch`],transformRequest:[function(e,t){let n=t.getContentType()||``,r=n.indexOf(`application/json`)>-1,i=$.isObject(e);if(i&&$.isHTMLForm(e)&&(e=new FormData(e)),$.isFormData(e))return r?JSON.stringify(VJt(e)):e;if($.isArrayBuffer(e)||$.isBuffer(e)||$.isStream(e)||$.isFile(e)||$.isBlob(e)||$.isReadableStream(e))return e;if($.isArrayBufferView(e))return e.buffer;if($.isURLSearchParams(e))return t.setContentType(`application/x-www-form-urlencoded;charset=utf-8`,!1),e.toString();let a;if(i){if(n.indexOf(`application/x-www-form-urlencoded`)>-1)return RJt(e,this.formSerializer).toString();if((a=$.isFileList(e))||n.indexOf(`multipart/form-data`)>-1){let t=this.env&&this.env.FormData;return p9(a?{"files[]":e}:e,t&&new t,this.formSerializer)}}return i||r?(t.setContentType(`application/json`,!1),HJt(e)):e}],transformResponse:[function(e){let t=this.transitional||y9.transitional,n=t&&t.forcedJSONParsing,r=this.responseType===`json`;if($.isResponse(e)||$.isReadableStream(e))return e;if(e&&$.isString(e)&&(n&&!this.responseType||r)){let n=!(t&&t.silentJSONParsing)&&r;try{return JSON.parse(e,this.parseReviver)}catch(e){if(n)throw e.name===`SyntaxError`?d9.from(e,d9.ERR_BAD_RESPONSE,this,null,this.response):e}}return e}],timeout:0,xsrfCookieName:`XSRF-TOKEN`,xsrfHeaderName:`X-XSRF-TOKEN`,maxContentLength:-1,maxBodyLength:-1,env:{FormData:v9.classes.FormData,Blob:v9.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:`application/json, text/plain, */*`,"Content-Type":void 0}}};$.forEach([`delete`,`get`,`head`,`post`,`put`,`patch`],e=>{y9.headers[e]={}});var UJt=$.toObjectSet([`age`,`authorization`,`content-length`,`content-type`,`etag`,`expires`,`from`,`host`,`if-modified-since`,`if-unmodified-since`,`last-modified`,`location`,`max-forwards`,`proxy-authorization`,`referer`,`retry-after`,`user-agent`]),WJt=e=>{let t={},n,r,i;return e&&e.split(`
1582
+ `,`const ${e.name} = environment.${e.name};\r\n`]})})]})]}),fKt=e=>{let t=[];return e.targets.includes(`production`)&&t.push(`production`),e.targets.includes(`preview`)&&t.push(e.targetBranch??`preview`),e.targets.includes(`working-copy`)&&t.push(`development`),t.join(`, `)};function pKt({variable:e,account:t,project:n,previewEnvironments:r,environmentsLoaded:i}){let a=iBe(),{logEvent:o}=S(),[c,l]=(0,H.useState)(),[u,d]=(0,H.useState)(!1),{tooltipProps:f,triggerProps:p}=lKt(),{tooltipProps:m,triggerProps:h}=lKt(),[g,_]=M$(()=>{let r=async()=>{_(),await a.mutateAsync({accountName:t,projectName:n.name,id:e.id}),o(`env-var-deleted`,{account:t,project:n.name,id:e.id})},i=`Error deleting Environment Variable`,l=`We found an error trying to remove the variable.`;return c instanceof s&&(i=c.title??i,l=c.detail??l),(0,U.jsx)(vQ,{alertType:`ERROR`,bodyText:l,onPrimaryButtonClick:r,onSecondaryButtonClick:_,primaryButtonText:`Try again`,secondaryButtonText:`Cancel`,hideModal:_,title:i})},[e,r,c]),v=async()=>{try{await a.mutateAsync({accountName:t,projectName:n.name,id:e.id}),o(`env-var-deleted`,{account:t,project:n.name,id:e.id}),d(!1)}catch(r){o(`env-var-deletion-failed`,{account:t,project:n.name,id:e.id}),d(!1),l(r instanceof Error?r:Error(r)),g()}},[y,b]=M$(()=>(0,U.jsx)(bR,{project:n,variable:e,previewEnvironments:r,environmentsLoaded:i,onClose:b,account:t}),[e,r,i]),x=e.personalValue??e.value;return(0,U.jsxs)(`div`,{className:`grid grid-cols-subgrid col-span-full gap-4 items-center border-b px-4 py-3 last:border-0`,children:[(0,U.jsxs)(k$,{open:u,onOpenChange:d,onClickDelete:v,isPending:a.isPending,deleteButtonText:`Confirm`,children:[`Are you sure you want to delete the variable '`,e.name,`'`]}),(0,U.jsx)(`div`,{className:`rounded-full border w-10 h-10 flex items-center justify-center`,children:(0,U.jsx)(uKt,{isSecret:e.type===`secret`})}),(0,U.jsxs)(`div`,{className:`flex flex-row justify-between items-center truncate`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col truncate`,children:[(0,U.jsxs)(oR,{...m,delayDuration:0,children:[(0,U.jsx)(sR,{...h,asChild:!0,children:(0,U.jsx)(`span`,{className:`font-mono text-sm truncate`,"data-test":`env-variable-name`,children:e.name})}),(0,U.jsxs)(cR,{className:`font-mono`,children:[(0,U.jsx)(lR,{}),e.name]})]}),(0,U.jsx)(`div`,{className:`text-sm text-neutral-500 line-clamp-2`,children:fKt(e)})]}),e.personalValue&&(0,U.jsx)(`div`,{className:`bg-zuplo-highlight rounded-full text-2xs text-white px-2 py-1 mx-2 flex-none`,children:`PERSONAL`})]}),(0,U.jsx)(`div`,{"data-test":`env-variable-value`,className:`truncate flex text-xs font-mono`,children:x?(0,U.jsxs)(oR,{...f,children:[(0,U.jsx)(sR,{asChild:!0,...p,children:(0,U.jsx)(`div`,{className:`bg-muted p-1 px-2 rounded-sm max-w-96 truncate`,children:e.type===`config`?x:`************`})}),(0,U.jsxs)(cR,{className:`text-xs`,children:[(0,U.jsx)(lR,{}),x]})]}):(0,U.jsx)(rT,{variant:`outline`,children:`No value`})}),(0,U.jsxs)(`div`,{className:`flex gap-2 justify-end`,children:[(0,U.jsx)(dKt,{variable:e,asIcon:!0}),(0,U.jsx)(X,{size:`icon`,variant:`ghost`,type:`button`,"data-test":`env-variable-edit`,onClick:()=>{y()},children:(0,U.jsx)(Uf,{size:18})}),(0,U.jsx)(X,{size:`icon`,variant:`ghost`,"data-test":`env-variable-delete`,onClick:()=>{d(!0)},children:a.isPending?(0,U.jsx)(WI,{className:`w-4 h-4`,borderPositionAndSize:`border-2`}):(0,U.jsx)(sp,{size:18})})]})]},e.name)}var z7=`___EMPTY___`,B7=`Environment Variables`,V7=`Configuration and secrets available to your environments at build and runtime. Changes take effect on the next deployment.`;function mKt(){let e=Op([`account`,`project`]),{logEvent:t}=S(),n=vR(e.account.name,e.project.name),r=!!e.project.sourceRepoUrl,i=wR(e.account.name,e.project.name),a=[{label:`All`,value:z7},{label:`Production`,value:`production`},{label:`Preview (other branches)`,value:`preview`},{label:`Development`,value:`working-copy`}],[o,s]=(0,H.useState)(z7),[c,l]=(0,H.useState)(z7),[u,d]=(0,H.useState)(``),f=i.data?.filter(e=>!AL(e.environmentType,kL.PRODUCTION,kL.WORKING_COPY))??[],p=i.data!==void 0,m=f.map(e=>e.branchName),h=(0,H.useMemo)(()=>[z7,...m],[m]),g=(0,H.useMemo)(()=>n.data??[],[n.data]),_=(0,H.useMemo)(()=>g.filter(e=>o===z7||e.targets.includes(o)),[g,o]),v=vX(u,(0,H.useMemo)(()=>o!==`preview`||c===z7?_:_.filter(e=>e.targets.includes(`preview`)&&e.targetBranch===c),[_,o,c]),{key:`id`,getText:e=>[e.name,e.type,e.value,...e.targets,e.targetBranch].filter(Boolean)}),[y,b]=M$(()=>(0,U.jsx)(CR,{account:e.account.name,project:e.project,previewEnvironments:f,onClose:b}),[f]);if(n.isError)return(0,U.jsx)(N7,{title:B7,description:V7,children:(0,U.jsx)(gze,{error:n.error})});if(!n.data||r&&!i.data)return(0,U.jsx)(N7,{title:B7,description:V7,children:(0,U.jsx)(l1,{})});let x=o!==z7||c!==z7&&c!==``||u!==``;return(0,U.jsxs)(N7,{title:B7,description:V7,action:(0,U.jsxs)(X,{onClick:y,children:[(0,U.jsx)(Mf,{size:16}),`Add variable`]}),children:[(0,U.jsxs)(`div`,{className:`flex flex-row items-center gap-3`,children:[(0,U.jsx)(gT,{type:`search`,placeholder:`Search variables`,className:`max-w-xs`,value:u,onChange:n=>{d(n.currentTarget.value),t(`env-var-filter-changed`,{account:e.account.name,project:e.project.name,query:n.currentTarget.value})}}),(0,U.jsxs)(CY,{value:o,onValueChange:e=>{s(e),e!==`preview`&&l(``)},children:[(0,U.jsx)(TY,{className:`w-52`,"data-test":`env-variable-filter`,children:(0,U.jsx)(wY,{})}),(0,U.jsx)(EY,{className:`w-52`,children:a.map((e,t)=>(0,U.jsx)(DY,{value:e.value,"data-test":`env-variable-filter-${t}`,children:e.label},e.value))})]}),o===`preview`?(0,U.jsxs)(CY,{value:c,onValueChange:e=>{l(e)},children:[(0,U.jsx)(TY,{className:`w-52`,"data-test":`env-variable-branch-filter`,children:(0,U.jsx)(wY,{})}),(0,U.jsx)(EY,{className:`w-52`,children:h.map(e=>(0,U.jsx)(DY,{value:e,children:e===z7?`All branches`:e},e))})]}):null]}),v.length>0?(0,U.jsx)(CA,{className:`grid grid-cols-[min-content_minmax(auto,250px)_1fr_auto] overflow-hidden`,children:v.map(t=>(0,U.jsx)(pKt,{account:e.account.name,project:e.project,previewEnvironments:f,environmentsLoaded:p,variable:t},t.id))}):(0,U.jsx)(CA,{children:x?(0,U.jsxs)(qb,{children:[(0,U.jsxs)(Jb,{children:[(0,U.jsx)(Yb,{variant:`icon`,children:(0,U.jsx)(Bf,{})}),(0,U.jsx)(Xb,{children:`No matching variables`}),(0,U.jsx)(Zb,{children:`No environment variables match the current search or filter.`})]}),(0,U.jsx)(Qb,{children:(0,U.jsx)(X,{variant:`outline`,onClick:()=>{d(``),s(z7),l(z7)},children:`Clear filters`})})]}):(0,U.jsxs)(qb,{children:[(0,U.jsxs)(Jb,{children:[(0,U.jsx)(Yb,{variant:`icon`,children:(0,U.jsx)(Xf,{})}),(0,U.jsx)(Xb,{children:`No environment variables yet`}),(0,U.jsxs)(Zb,{className:`max-w-md`,children:[`Variables you add here are provided to your environments during build and at runtime.`,` `,(0,U.jsx)(hT,{href:`https://zuplo.com/docs/deployments/environment-variables`,children:`Read the docs`}),`.`]})]}),(0,U.jsx)(Qb,{children:(0,U.jsxs)(X,{onClick:y,children:[(0,U.jsx)(Mf,{size:16}),`Add your first variable`]})})]})})]})}var hKt=({projectName:e,closeModalAction:t,accountName:n,onFinishDeletion:r})=>{let{logEvent:i,captureException:a}=S(),[o,s]=(0,H.useState)(!1),[c,l]=(0,H.useState)(null),u=t=>{s(t.target.value===e)},d=FOe(n,e);return(0,U.jsx)(hmt,{alertType:`DELETE`,isOpen:!0,title:`Delete Project`,setIsOpen:t,secondaryButtonContent:`Cancel`,secondaryButtonTestID:`project-list-close-delete-project-modal`,onSecondaryButtonClick:t,primaryButtonTestID:`project-list-delete-project-button`,secondaryButtonDisabled:d.isPending,primaryButtonDisabled:!o||d.isPending,primaryButtonContent:`Delete`,onPrimaryButtonClick:async()=>{try{l(null),await d.mutateAsync(),i(`project-deleted`,{account:n,project:e}),r?.(),t()}catch(t){i(`project-deletion-failed`,{account:n,project:e}),a(t),l(ux(t))}},bodyElement:(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(SA,{error:c}),(0,U.jsx)(`p`,{className:`text-sm`,children:`This cannot be undone! Your GitHub repository will be untouched.`}),(0,U.jsxs)(`p`,{className:`text-sm`,children:[`Please type `,(0,U.jsx)(`strong`,{onDoubleClick:e=>{let t=e.currentTarget,n=new Range;n.setStart(t,0),n.setEnd(t,1),document.getSelection()?.removeAllRanges(),document.getSelection()?.addRange(n)},children:e}),` `,`to confirm.`]}),(0,U.jsx)(gT,{disabled:d.isPending,type:`text`,className:`mt-2`,autoFocus:!0,autoComplete:`off`,onChange:u})]})})};function gKt(){let e=sx([`account`,`project`]),t=ao(),[n,r]=M$(()=>(0,U.jsx)(hKt,{projectName:e.project,accountName:e.account,closeModalAction:r,onFinishDeletion:()=>t(`/`)}),[]);return(0,U.jsxs)(CA,{variant:`danger`,children:[(0,U.jsxs)(wA,{children:[(0,U.jsx)(TA,{children:`Delete Project`}),(0,U.jsx)(EA,{children:`Permanently delete this project and all associated data. This cannot be undone, there is no going back.`})]}),(0,U.jsx)(DA,{className:`leading-loose text-sm`,children:`Your GitHub repository will remain untouched.`}),(0,U.jsx)(OA,{variant:`danger`,className:`justify-end`,children:(0,U.jsxs)(X,{"data-test":`delete-button`,variant:`destructive`,onClick:n,children:[(0,U.jsx)(sp,{size:16}),`Delete Project`]})})]})}var _Kt=({children:e,copyValue:t})=>{let{logEvent:n}=S();return(0,U.jsxs)(`div`,{className:`mb-2 md:mb-0`,children:[e,t&&(0,U.jsx)(GI,{className:`relative top-1`,onClick:()=>{n(`project-information-property-copied`)},textToCopy:t})]})},vKt=()=>{let{logEvent:e}=S(),t=Op([`account`,`project`]);if(!wR(t.account.name,t.project.name).data)return(0,U.jsx)(`div`,{className:`p-6`,children:(0,U.jsx)(l1,{})});let n=[];return n.push({label:`Project Name`,value:t.project.name}),n.push({label:`Account Name`,value:t.account.name}),(0,U.jsxs)(CA,{children:[(0,U.jsxs)(wA,{children:[(0,U.jsx)(TA,{children:`Project Information`}),(0,U.jsx)(EA,{})]}),(0,U.jsx)(DA,{children:(0,U.jsx)(`div`,{className:`grid gap-2 grid-cols-1 md:grid-cols-[150px_1fr] text-sm mt-2`,children:n.map(t=>(0,U.jsxs)(H.Fragment,{children:[(0,U.jsx)(`div`,{className:`font-medium`,children:t.label}),(0,U.jsx)(_Kt,{copyValue:t.value,children:t.isLink?(0,U.jsx)(hT,{href:t.value,onClick:()=>{e(`project-information-link-clicked`,{label:t.label,value:t.value})},className:`break-all`,children:t.value}):t.value})]},t.value))})})]})},yKt=()=>(0,U.jsxs)(N7,{title:`General`,description:`Project name, identifiers, and lifecycle.`,children:[(0,U.jsx)(vKt,{}),(0,U.jsx)(gKt,{})]}),bKt={admin:`Admin`,developer:`Developer`,member:`Member`,"ai-user":`AI User`,"no-access":`No Access`},H7=(e,t)=>e!==`no-access`&&(t||e===`admin`),xKt=({value:e,hiddenRoles:t=[],aiProject:n=!1,...r})=>{let i=Ep(),a=Op([`account`]).account.entitlements.rbacEnabled,o=UC.filter(r=>!t.concat([`no-access`]).includes(r)&&(r!==`ai-user`||n&&(a||e===`ai-user`)));return(0,U.jsxs)(CY,{...r,value:e,onValueChange:e=>{H7(e,a)?r.onValueChange?.(e):i.toast((0,U.jsxs)(U.Fragment,{children:[`This role is not available for your account. Please upgrade to the Enterprise plan.`,` `,(0,U.jsx)(hT,{href:`https://zuplo.com/docs/articles/accounts/roles-and-permissions`,target:`_blank`,children:`Learn more about roles and permissions.`})]}))},children:[(0,U.jsx)(TY,{className:`min-w-40`,children:(0,U.jsx)(wY,{placeholder:`Select a role`})}),(0,U.jsx)(EY,{className:`min-w-40`,children:o.map(e=>(0,U.jsx)(DY,{value:e,onClick:t=>{H7(e,a)||(t.preventDefault(),t.stopPropagation(),window.open(`https://zuplo.com/docs/articles/accounts/roles-and-permissions`,`_blank`))},children:(0,U.jsxs)(`div`,{className:`grid grid-cols-2`,children:[bKt[e],!H7(e,a)&&(0,U.jsx)(rT,{variant:`outline`,className:``,children:`Enterprise`})]})},e))})]})},SKt={zuplo:{viewBox:[0,0,308,308],ink:[41.36,259.74],Glyph:()=>(0,U.jsxs)(`g`,{fillRule:`nonzero`,fill:`none`,children:[(0,U.jsx)(`path`,{d:`M0 0h308v308H0z`}),(0,U.jsx)(`path`,{d:`M214.523 182.007h-74.088l78.939-79.076a5.34 5.34 0 0 0-.807-8.204 5.314 5.314 0 0 0-2.957-.899H90.239V41.364h137.515a53.31 53.31 0 0 1 28.617 7.922 53.444 53.444 0 0 1 19.967 22.011 52.117 52.117 0 0 1 4.221 31.194 52.062 52.062 0 0 1-14.508 27.924l-51.528 51.592Z`,fill:`currentColor`}),(0,U.jsx)(`path`,{d:`M90.24 119.097h74.092l-78.781 78.917a5.431 5.431 0 0 0-1.172 5.912 5.423 5.423 0 0 0 5.001 3.351h125.017v52.464H77.016a53.322 53.322 0 0 1-28.616-7.923 53.453 53.453 0 0 1-19.968-22.011 52.109 52.109 0 0 1-4.219-31.194 52.059 52.059 0 0 1 14.51-27.924l51.517-51.592Z`,fill:`currentColor`})]})},akamai:{viewBox:[344.42,285.18,451,489.75],ink:[285.18,774.93],Glyph:()=>(0,U.jsxs)(`g`,{fill:`currentColor`,children:[(0,U.jsx)(`path`,{d:`M592.85,764.11c-100.8-30.77-174.12-123.92-174.12-234.05s74.88-205.29,177.4-235.02c10.48-3.06,7.73-9.86-4.91-9.86-136.28,0-246.8,109.69-246.8,244.89s110.51,244.86,246.8,244.86c12.63,0,13.14-7.3,1.63-10.81Z`}),(0,U.jsx)(`path`,{d:`M465.48,587.42c-.68-6.58-1.01-13.23-1.01-19.94,0-107.36,87.05-194.39,194.43-194.39,101.52,0,132,45.31,135.78,42.35,4.12-3.26-36.84-93.07-156.05-93.07-107.39,0-194.44,87.03-194.44,194.39,0,24.84,4.65,48.52,13.13,70.31,3.58,9.14,9.08,9.22,8.17.35Z`}),(0,U.jsx)(`path`,{d:`M546.92,447.31c50.53-22.03,114.01-22.7,176.42-.89,41.91,14.62,66.2,35.5,68.19,34.64,3.31-1.43-24.38-45.28-74.36-64.24-60.51-22.93-125.69-10.93-173.18,26.32-5.22,4.11-3.25,6.87,2.93,4.17Z`})]})}},CKt=({mark:e,...t})=>(0,U.jsx)(`svg`,{viewBox:e.viewBox.join(` `),xmlns:`http://www.w3.org/2000/svg`,...t,children:(0,U.jsx)(e.Glyph,{})}),wKt=({viewBox:[e,t,n,r],ink:[i,a]})=>{let o=n/2,s=(a-i)*.07,c=o/2,l=e-o,u=e+n+o,d=t+r+s;return{surface:`M${l} ${t}${Array.from({length:Math.round((u-l)/c)},(e,t)=>`q${c/2} ${t%2==0?-2*s:2*s} ${c} 0`).join(``)}L${u} ${d}L${l} ${d}Z`,period:o,empty:a-t+s,full:i-t-s}},TKt=({mark:e})=>{let t=(0,H.useId)(),[n,r,i,a]=e.viewBox,{surface:o,period:s,empty:c,full:l}=wKt(e);return(0,U.jsxs)(`svg`,{viewBox:e.viewBox.join(` `),xmlns:`http://www.w3.org/2000/svg`,"aria-hidden":`true`,className:`absolute inset-0 size-full text-zuplo-pink`,style:{"--logo-fill-empty":`${c}px`,"--logo-fill-full":`${l}px`,"--logo-fill-period":`${s}px`},children:[(0,U.jsx)(`mask`,{id:t,maskUnits:`userSpaceOnUse`,x:n,y:r,width:i,height:a,children:(0,U.jsxs)(`g`,{className:`logo-fill-level`,children:[(0,U.jsx)(`path`,{className:`logo-fill-wave`,d:o,fill:`#fff`}),(0,U.jsx)(`path`,{className:`logo-fill-wave`,d:o,fill:`#fff`})]})}),(0,U.jsx)(`g`,{mask:`url(#${t})`,children:(0,U.jsx)(e.Glyph,{})})]})},EKt=({variant:e=`full`,className:t,width:n,height:r,fillOnHover:i=!1})=>{let a=BWt();if(e===`mark`){let e=SKt[a.id],o=(0,U.jsx)(CKt,{mark:e,className:t,width:n,height:r,role:`img`,"aria-label":a.logoAlt});return i?(0,U.jsxs)(`span`,{className:`group relative flex`,children:[o,(0,U.jsx)(TKt,{mark:e})]}):o}return e===`full`&&a.logoDark?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`img`,{src:a.logo,alt:a.logoAlt,className:W(t,`dark:hidden`),width:n,height:r}),(0,U.jsx)(`img`,{src:a.logoDark,alt:a.logoAlt,className:W(t,`hidden dark:inline`),width:n,height:r})]}):(0,U.jsx)(`img`,{src:e===`white`?a.logoWhite:a.logo,alt:a.logoAlt,className:W(t),width:n,height:r})},DKt=()=>(0,U.jsx)(`div`,{className:`h-0 flex flex-col items-center -translate-y-14 mb-2`,children:(0,U.jsx)(EKt,{variant:`white`,className:`h-17 w-auto rounded-full bg-zuplo-pink p-4 shadow-xs`})}),OKt=(e,t,n)=>{let[r,i]=(0,H.useState)(t),a=XR(n);return[e===void 0?r:e,(0,H.useCallback)(t=>{e===void 0?i(t):a.current?.(t)},[e,a])]},kKt=Ym({email:Gm().email(`Invalid email address`),role:Zm([`admin`,`developer`,`member`,`ai-user`])}),AKt=({inviteOnly:e=!1,account:t,project:n,pool:r,description:i,hiddenRoles:a,children:o,open:s,onOpenChange:c,excludeUserIds:l,changeRoleForUserIds:u})=>{let d=Op([`account`]),{logEvent:f}=S(),[p,m]=OKt(s,!1,c),[h,g]=(0,H.useState)(!1),[_,v]=(0,H.useState)(!1),y=bt(),{onError:b,onSuccess:x}=CL(),C=d.account.entitlements.rbacEnabled,w=vA({resolver:xA(kKt),defaultValues:{email:``,role:C?`member`:`admin`}}),T=C?`member`:`admin`,E=ox(je.authAccountUsersRoles(t),{extractData:!0}),D=w.watch(`email`),O=XR(()=>{w.reset(),g(!1)});(0,H.useEffect)(()=>{p||O.current()},[p,O]);let k=Oe({mutationFn:({email:e,role:i})=>{let a=r&&n?{account:{role:T},project:{name:n,role:T},team:{...r,role:i}}:n?{account:{role:T},project:{name:n,role:i}}:{account:{role:i}},o=E?.data?.find(t=>t.email===e)?.id;return!h&&o&&u?.includes(o)?y.fetch(ae.auth.updateUsersRole({accountName:t,projectName:n,userId:o,role:i})):y.fetch(ae.accountInvite.createAccountInvite(t,e,a))},onError:b,onSuccess:()=>{x(h?`Invitation sent to ${w.getValues(`email`)}`:`Member added to ${d.account.label??d.account.name}`),m(!1)}}),A=vX(D,(E?.data??[]).filter(e=>!l||!l.includes(e.id)&&!l.includes(e.sub)),{getText:e=>[e.name,e.email],key:`email`}),j=e=>{f(`account-invite-submitted`,{role:e.role,teamId:r?.id??``,project:n,account:t}),k.mutate({email:e.email,role:e.role})};return(0,U.jsxs)(ow,{open:p,onOpenChange:e=>{e||w.reset(),m(e)},children:[o&&(0,U.jsx)(sw,{asChild:!0,children:o}),(0,U.jsxs)(lw,{className:`max-w-md`,children:[(0,U.jsx)(vOe,{}),(0,U.jsx)(DKt,{}),(0,U.jsxs)(uw,{className:`mt-2`,children:[(0,U.jsxs)(fw,{children:[`Invite to `,d.account.label??d.account.name]}),(0,U.jsx)(pw,{className:`opacity-75`,children:i??`Once you invite someone to your account, they can be granted access to account projects.`})]}),(0,U.jsx)(YY,{...w,children:(0,U.jsxs)(`form`,{onSubmit:w.handleSubmit(j),className:`mt-2 space-y-4`,children:[(0,U.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,U.jsx)(XY,{control:w.control,name:`email`,render:({field:t})=>(0,U.jsxs)(QY,{className:`w-full`,children:[(0,U.jsx)($Y,{children:`Member`}),(0,U.jsx)(eX,{children:(0,U.jsx)(`div`,{className:`relative`,children:(0,U.jsx)(Vw,{open:_&&D.length>0,onOpenChange:v,modal:!1,children:(0,U.jsxs)(mw,{shouldFilter:!1,loop:!0,children:[(0,U.jsx)(Rw,{asChild:!0,children:(0,U.jsx)(tw.Input,{asChild:!0,value:D,onValueChange:t.onChange,onKeyDown:e=>{if(e.key===`Enter`&&_===!1){e.currentTarget.form?.requestSubmit(),e.preventDefault();return}v(e.key!==`Escape`)},onMouseDown:()=>v(e=>!!D||!e),onFocus:()=>v(!0),onBlur:()=>v(!1),children:(0,U.jsx)(gT,{placeholder:`Email address or member name`})})}),!open&&(0,U.jsx)(gw,{"aria-hidden":`true`,className:`hidden`}),(0,U.jsx)(Uw,{asChild:!0,align:`start`,onOpenAutoFocus:e=>e.preventDefault(),onInteractOutside:e=>{e.target instanceof Element&&e.target.hasAttribute(`cmdk-input`)&&e.preventDefault()},className:`w-(--radix-popover-trigger-width) p-0`,children:(0,U.jsxs)(gw,{className:`max-h-[200px] overflow-y-auto`,children:[(0,U.jsx)(_w,{children:`No members found.`}),(0,U.jsxs)(vw,{children:[!e&&A.map((e,n)=>(0,U.jsx)(yw,{value:n.toString(),onSelect:()=>{t.onChange(e.email),g(!1),v(!1)},children:(0,U.jsx)(`span`,{children:e.name})},e.id)),D.length>0&&(0,U.jsxs)(yw,{value:A.length.toString(),onSelect:()=>{g(!0),v(!1)},children:[(0,U.jsx)(Fd,{size:16,className:`mr-2`}),` `,`Invite "`,D.includes(`@`)?D:`${D}@example.com`,`" to Account`]})]})]})})]})})})}),(0,U.jsx)(nX,{})]})}),(0,U.jsx)(XY,{control:w.control,name:`role`,render:({field:e})=>(0,U.jsxs)(QY,{children:[(0,U.jsx)($Y,{children:`Role`}),(0,U.jsx)(eX,{children:(0,U.jsxs)(oR,{children:[(0,U.jsx)(sR,{asChild:!0,children:(0,U.jsx)(xKt,{aiProject:!!(n&&!r&&d.project&&xO(d.project)),value:e.value,onValueChange:e.onChange,hiddenRoles:a})}),(0,U.jsx)(cR,{children:C?(0,U.jsx)(`p`,{children:`New users will be assigned the member role. You can change their role later.`}):(0,U.jsx)(`p`,{children:`New users will be assigned the admin role. You can change their role later.`})})]})}),(0,U.jsx)(nX,{})]})})]}),(0,U.jsx)(dw,{children:(0,U.jsx)(X,{type:`submit`,className:`justify-end`,children:(0,U.jsxs)(HI,{loading:k.isPending,children:[h?`Send Invite`:`Add member`,(0,U.jsx)(tz,{className:`bg-white/20`,children:(0,U.jsx)(ez,{onPress:w.handleSubmit(j),hotkey:`meta+Enter`})})]})})})]})})]})]})},jKt=()=>{let{account:e}=Op([`account`]);return e.entitlements.rbacEnabled?null:(0,U.jsxs)(Ub,{variant:`info`,className:`text-sm`,children:[(0,U.jsx)(yd,{size:22}),(0,U.jsx)(Gb,{children:(0,U.jsxs)(`p`,{children:[`Role-based access control (RBAC) is not enabled for this account.`,` `,(0,U.jsx)(Kb,{to:`mailto:${nx}?subject=Fine-grain%20access%20control`,children:`Contact sales`}),` `,`for more information.`]})})]})},MKt=({name:e,sub:t,email:n})=>{let{copyToClipboard:r}=WC(t??n??``);return(0,U.jsxs)(oR,{children:[(0,U.jsx)(sR,{onDoubleClick:()=>{r()},className:`text-left`,children:e}),(0,U.jsxs)(cR,{className:`flex items-center gap-2`,children:[t&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)($d,{size:16}),` Sub `,t]}),n&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(xf,{size:16}),` Email `,n]})]})]})},NKt=r(a(((e,t)=>{(function(n,r){typeof e==`object`&&t!==void 0?t.exports=r():typeof define==`function`&&define.amd?define(r):(n=typeof globalThis<`u`?globalThis:n||self).dayjs_plugin_relativeTime=r()})(e,(function(){return function(e,t,n){e||={};var r=t.prototype,i={future:`in %s`,past:`%s ago`,s:`a few seconds`,m:`a minute`,mm:`%d minutes`,h:`an hour`,hh:`%d hours`,d:`a day`,dd:`%d days`,M:`a month`,MM:`%d months`,y:`a year`,yy:`%d years`};function a(e,t,n,i){return r.fromToBase(e,t,n,i)}n.en.relativeTime=i,r.fromToBase=function(t,r,a,o,s){for(var c,l,u,d=a.$locale().relativeTime||i,f=e.thresholds||[{l:`s`,r:44,d:`second`},{l:`m`,r:89},{l:`mm`,r:44,d:`minute`},{l:`h`,r:89},{l:`hh`,r:21,d:`hour`},{l:`d`,r:35},{l:`dd`,r:25,d:`day`},{l:`M`,r:45},{l:`MM`,r:10,d:`month`},{l:`y`,r:17},{l:`yy`,d:`year`}],p=f.length,m=0;m<p;m+=1){var h=f[m];h.d&&(c=o?n(t).diff(a,h.d,!0):a.diff(t,h.d,!0));var g=(e.rounding||Math.round)(Math.abs(c));if(u=c>0,g<=h.r||!h.r){g<=1&&m>0&&(h=f[m-1]);var _=d[h.l];s&&(g=s(``+g)),l=typeof _==`string`?_.replace(`%d`,g):_(g,r,h.l,u);break}}if(r)return l;var v=u?d.future:d.past;return typeof v==`function`?v(l):v.replace(`%s`,l)},r.to=function(e,t){return a(e,t,this,!0)},r.from=function(e,t){return a(e,t,this)};var o=function(e){return e.$u?n.utc():n()};r.toNow=function(e){return this.to(o(this),e)},r.fromNow=function(e){return this.from(o(this),e)}}}))}))());function PKt({accountName:e,invite:t}){let n=Ep(),[r,i]=(0,H.useState)(!1),a=Lme();return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(X,{size:`icon`,variant:`ghost`,title:`Remove invitation`,disabled:a.isPending,onClick:()=>i(!0),children:(0,U.jsx)(sp,{size:18})}),(0,U.jsxs)(k$,{open:r,onOpenChange:i,title:`Delete account invite`,deleteButtonText:`Delete invitation`,isPending:a.isPending,onClickDelete:async()=>{try{await a.mutateAsync({accountName:e,inviteId:t.id}),n.success(`Invitation was removed`),i(!1)}catch(e){n.error(ux(e))}},children:[`You are about to delete the account invite sent to `,t.email,`. The invitation can no longer be used to join your account.`]})]})}function FKt({accountName:e,invite:t}){let n=Ep(),r=Rme(),[i,a]=(0,H.useState)(!1);return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(oR,{children:[(0,U.jsx)(sR,{asChild:!0,children:(0,U.jsx)(X,{size:`icon`,variant:`ghost`,disabled:r.isPending,onClick:()=>a(!0),children:(0,U.jsx)(fee,{size:18})})}),(0,U.jsx)(cR,{children:`Resend invitation`})]}),(0,U.jsx)(yL,{open:i,onOpenChange:a,title:`Do you want to resend the invitation?`,description:`You are about to resend the account membership invite for "${t.email}" to join "${e}".`,actionLabel:`Resend invitation`,isPending:r.isPending,onConfirm:async()=>{try{await r.mutateAsync({accountName:e,inviteId:t.id}),n.success(`Invitation has been resent`),a(!1)}catch(e){n.error(ux(e)),a(!1)}}})]})}var IKt=({date:e,withTime:t})=>(0,U.jsxs)(`span`,{children:[e.toLocaleDateString(),t&&` ${e.toLocaleTimeString()}`]}),LKt=({email:e,className:t})=>{let{copyToClipboard:n}=WC(e);return(0,U.jsxs)(oR,{children:[(0,U.jsx)(sR,{onDoubleClick:n,className:W(`cursor-pointer`,t),children:e}),(0,U.jsxs)(cR,{children:[`Copy `,(0,U.jsxs)(`span`,{className:`font-mono`,children:[`"`,e,`"`]}),` to clipboard`]})]})};b7.default.extend(NKt.default);function RKt(){let{account:e}=sx([`account`]),t=Ime(e).data??[];return t.length===0?null:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`div`,{className:`text-lg font-medium`,children:`Pending account invitations`}),(0,U.jsx)(`div`,{className:`grid grid-cols-4 gap-2`,children:t.map(t=>(0,U.jsxs)(N$,{variant:`outline`,size:`sm`,className:W(`col-span-full grid grid-cols-subgrid justify-between py-1`,(0,b7.default)().diff((0,b7.default)(t.createdOn),`minutes`)<5&&`bg-zuplo-50/50`),children:[(0,U.jsx)(`div`,{className:`text-ellipsis overflow-hidden truncate`,children:(0,U.jsxs)(oR,{children:[(0,U.jsx)(sR,{children:(0,U.jsxs)(rT,{variant:`outline`,children:[`Invited `,(0,b7.default)(t.createdOn).fromNow()]})}),(0,U.jsx)(cR,{children:(0,U.jsx)(IKt,{date:new Date(t.createdOn),withTime:!0})})]})}),(0,U.jsx)(LKt,{email:t.email,className:`text-left text-ellipsis overflow-hidden truncate`}),(0,U.jsxs)(`div`,{className:`flex justify-end col-span-2`,children:[(0,U.jsx)(FKt,{accountName:e,invite:t}),(0,U.jsx)(PKt,{accountName:e,invite:t})]})]},t.id))})]})}var zKt=5,BKt=`Members & Access`,VKt=(0,U.jsxs)(U.Fragment,{children:[`Manage who can access this project. Account members can create or be added to projects.`,` `,(0,U.jsx)(hT,{href:`https://zuplo.com/docs/articles/add-project-collaborators`,children:`Learn more`}),`.`]});function HKt(){let e=Op([`account`,`project`]),{canViewMembers:t,role:n,error:r}=ATe(e.account.name,e.project.name);return n?t?(0,U.jsx)(UKt,{}):(0,U.jsx)(`p`,{className:`p-6`,children:`You do not have access to project membership.`}):r?(0,U.jsxs)(`div`,{role:`alert`,className:`p-6 flex items-center gap-3`,children:[(0,U.jsx)(`p`,{children:`We couldn’t check your project access.`}),(0,U.jsx)(X,{variant:`outline`,onClick:()=>window.location.reload(),children:`Reload to retry`})]}):(0,U.jsx)(`output`,{"aria-label":`Loading project access`,className:`p-6 flex justify-center items-center`,children:(0,U.jsx)(VI,{color:`primary`})})}function UKt(){let e=Op([`account`,`project`]),t=Ep(),{user:n}=u(),r=bt(),i=Oe({mutationFn:({userId:t,role:n})=>r.fetch(ae.auth.updateUsersRole({accountName:e.account.name,projectName:e.project.name,userId:t,role:n})),onError:e=>t.error(ux(e))}),[a,o]=(0,H.useState)(!1),[s,c]=(0,H.useState)(!1),l=ax(je.accountMemberInvites(e.account.name)),d=ax(je.authProjectUsersRoles(e.account.name,e.project.name,{includeInheritedRoles:!1}),{extractData:!0}),f=d.data?.map(e=>e.id),p=ax(je.authProjectUsersRoles(e.account.name,e.project.name,{includeInheritedRoles:!0}),{extractData:!0}),m=p.data?.filter(e=>!f?.includes(e.id)),h=d.data?.filter(e=>e.project.role!==`no-access`),g=e.account.entitlements.rbacEnabled,_=(h?.map(({id:e})=>e)??[]).concat(g?[]:m?.map(({id:e})=>e)??[]);return(0,U.jsxs)(N7,{title:BKt,description:VKt,action:(0,U.jsx)(AKt,{account:e.account.name,project:e.project.name,changeRoleForUserIds:p.data?.map(({id:e})=>e)??[],excludeUserIds:_,open:s,onOpenChange:c,description:`Inviting a user to a project will grant them access to the project and add them to the account as a member.`,children:(0,U.jsxs)(X,{children:[(0,U.jsx)(Mf,{size:16}),`Add to project`]})}),children:[(0,U.jsxs)(`section`,{className:`flex flex-col gap-3 text-sm`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Members with inherited access`}),(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Account Admins and developers automatically have access to all projects.`})]}),(m?.length??0)>0&&(0,U.jsx)(CA,{className:`overflow-hidden`,children:m?.slice(0,a?void 0:zKt).map(e=>(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-4 border-b px-4 py-3 last:border-0`,children:[(0,U.jsx)(MKt,{name:e.name,email:e.email}),(0,U.jsxs)(oR,{children:[(0,U.jsx)(sR,{children:(0,U.jsx)(rT,{variant:`outline`,children:e.project.role===`admin`?`Full access`:`Read only`})}),(0,U.jsx)(cR,{children:bKt[e.project.role]})]})]},e.id))}),(m?.length??0)>zKt&&(0,U.jsx)(X,{variant:`ghost`,size:`sm`,onClick:()=>{o(!a)},children:a?`Show less`:`Show more`})]}),l.data?.length>0&&(0,U.jsx)(RKt,{}),(0,U.jsxs)(`section`,{className:`flex flex-col gap-3 text-sm`,children:[(0,U.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Members with project access`}),(0,U.jsx)(SA,{error:d.error}),i.isError&&(0,U.jsx)(jKt,{}),h?.length===0&&(0,U.jsx)(CA,{children:(0,U.jsxs)(qb,{children:[(0,U.jsxs)(Jb,{children:[(0,U.jsx)(Yb,{variant:`icon`,children:(0,U.jsx)(up,{})}),(0,U.jsx)(Xb,{children:`No project members yet`}),(0,U.jsx)(Zb,{children:`No members have been added directly to this project yet.`})]}),(0,U.jsx)(Qb,{children:(0,U.jsxs)(X,{onClick:()=>c(!0),children:[(0,U.jsx)(Mf,{size:16}),`Add to project`]})})]})}),(h?.length??0)>0&&(0,U.jsxs)(CA,{className:`grid grid-cols-[1fr_auto_auto] gap-x-4 overflow-hidden text-sm`,children:[(0,U.jsxs)(tGt,{children:[(0,U.jsx)(`div`,{children:`Member`}),(0,U.jsx)(`div`,{children:`Role`}),(0,U.jsx)(`div`,{})]}),!d.isError&&h?.map(t=>(0,U.jsxs)(eGt,{children:[(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(MKt,{name:t.name,sub:t.sub}),t.sub===n?.sub&&(0,U.jsx)(rT,{variant:`outline`,className:`ml-4`,children:`You`})]}),(0,U.jsx)(`div`,{className:W(`text-ellipsis overflow-hidden truncate`,t.email===t.name&&`hidden`),title:t.email,children:t.email})]}),(0,U.jsx)(`div`,{className:`max-w-60 w-full`,children:(0,U.jsx)(xKt,{aiProject:xO(e.project),hiddenRoles:e.account.entitlements.rbacEnabled?[]:[`member`,`developer`],value:t.project.role,disabled:!!(t.sub===n?.sub||i.isPending),onValueChange:e=>{if(!UC.includes(e))throw Error(`Invalid role`);i.mutate({userId:t.id,role:e})}})}),(0,U.jsx)(`div`,{className:`flex justify-end`,children:(0,U.jsx)(X,{variant:`ghost`,size:`icon-lg`,onClick:()=>{i.mutate({role:`no-access`,userId:t.id})},children:(0,U.jsx)(sp,{size:16})})})]},t.sub))]})]})]})}YR(`div`,`grid grid-cols-subgrid col-span-full w-full border-b px-4 py-3 items-center`);var WKt=({accountName:e,projectName:t,sourceRepoUrl:n,defaultBranch:r})=>{let{logEvent:i,captureException:a}=S(),[o,s]=(0,H.useState)(``),[c,l]=(0,H.useState)(r),[u,d]=(0,H.useState)(!1),f=BOe(e,t);(0,H.useEffect)(()=>{u||(s(``),l(r))},[u,r]);let p=n.split(`/`),m=p[p.length-2],h=p[p.length-1],g=async()=>{try{if(s(``),!c||c===r){s(`Select a new default branch.`);return}await f.mutateAsync({defaultBranch:c,sourceRepoUrl:n}),i(`project-update-default-branch-success`,{account:e}),d(!1)}catch(t){a(t);let n=ux(t);s(n),i(`project-update-default-branch-failed`,{account:e,errorMessage:n})}};return(0,U.jsxs)(CA,{children:[(0,U.jsx)(wA,{children:`Default Branch`}),(0,U.jsxs)(DA,{className:`mt-1 text-sm`,children:[(0,U.jsx)(EA,{children:`The default branch is considered the “base” branch in your repository, against which all pull requests and code commits are automatically made. This is the branch used for your project's production deployments.`}),(0,U.jsxs)(`div`,{className:`flex gap-2`,children:[(0,U.jsx)(gT,{type:`text`,autoComplete:`off`,id:`default-branch-field`,value:r??`main`,disabled:!0,className:`max-w-52`,"data-test":`default-branch-field`}),(0,U.jsxs)(ow,{onOpenChange:e=>d(e),open:u,children:[(0,U.jsx)(sw,{children:(0,U.jsx)(X,{type:`button`,"data-test":`update-default-branch`,variant:`outline`,children:`Update`})}),(0,U.jsxs)(lw,{children:[(0,U.jsx)(uw,{children:(0,U.jsx)(fw,{children:`Switch default branch to another branch`})}),(0,U.jsxs)(`div`,{className:`space-y-4`,children:[(0,U.jsx)(SA,{error:o}),(0,U.jsxs)(pw,{className:`text-foreground`,children:[`Choose another branch in`,` `,(0,U.jsxs)(hT,{href:n,children:[m,`/`,h]}),` `,`to use as the default branch of the project instead of`,` `,r,`.`,(0,U.jsx)(gT,{type:`text`,autoComplete:`off`,placeholder:`Type a branch name`,id:`default-branch-field`,className:`mt-4`,"data-test":`default-branch-field`,value:c,onChange:e=>l(e.target.value)})]})]}),(0,U.jsxs)(dw,{children:[(0,U.jsx)(cw,{children:(0,U.jsx)(X,{"data-test":`cancel-update-default-branch-btn`,disabled:f.isPending,variant:`ghost`,children:`Cancel`})}),(0,U.jsx)(X,{"data-test":`update-default-branch-btn`,type:`button`,onClick:g,disabled:f.isPending,variant:`outline`,children:(0,U.jsx)(HI,{loading:f.isPending,alternative:`Updating...`,children:`Switch branch`})})]})]})]})]})]})]})},GKt=`Source Control`,KKt=(0,U.jsxs)(U.Fragment,{children:[`Connect a Git repository to deploy your project. Learn more about deploying with source control in our`,` `,(0,U.jsx)(hT,{href:`https://zuplo.com/docs/articles/step-4-deploying-to-the-edge`,showIcon:!0,children:`documentation`}),`.`]}),qKt=()=>{let e=Op([`account`,`project`]),{logEvent:t}=S(),n=FWt();if((0,H.useEffect)(()=>{t(`source-control-settings-viewed`,{account:e.account.name,project:e.project.name})},[e.account.name,e.project.name,t]),!n.data)return(0,U.jsx)(N7,{title:GKt,description:KKt,children:(0,U.jsx)(cWt,{showHeader:!1})});let r=Pme(e.account.name,n.data);return(0,U.jsxs)(N7,{title:GKt,description:KKt,children:[e.project.sourceRepoUrl!==null&&(0,U.jsx)(WKt,{accountName:e.account.name,projectName:e.project.name,sourceRepoUrl:e.project.sourceRepoUrl,defaultBranch:e.project.defaultBranch??void 0}),(0,U.jsxs)(CA,{children:[(0,U.jsxs)(wA,{children:[(0,U.jsx)(TA,{children:`Connected Git Repository`}),(0,U.jsx)(EA,{children:`Seamlessly create Environments for every branch and deployments for any commits pushed to your Git repository.`})]}),(0,U.jsx)(DA,{children:(0,U.jsx)(PWt,{account:e.account,project:e.project,sourceControlConfig:r})})]})]})},JKt=()=>{let{account:e,project:t}=sx([`account`,`project`]);return(0,U.jsx)(Bo,{to:ri(rx.Environments,{account:e,project:t})})},YKt=({to:e})=>(0,U.jsx)(Bo,{to:`/accounts/${Op([`account`]).account.name}/settings/${e}`,replace:!0}),XKt=[{key:`general`,group:`project`,icon:(0,U.jsx)($f,{className:`w-4 h-4`}),name:`General`,view:(0,U.jsx)(yKt,{}),testID:`settings-general`},{key:`share-project`,group:`project`,icon:(0,U.jsx)(up,{className:`w-4 h-4`}),name:`Members & Access`,view:(0,U.jsx)(HKt,{}),testID:`settings-share-project`},{key:`source-control-settings`,group:`project`,icon:(0,U.jsx)(sf,{className:`w-4 h-4`}),name:`Source Control`,view:(0,U.jsx)(qKt,{}),testID:`settings-source-control-settings`},{key:`environment-variables`,group:`configuration`,icon:(0,U.jsx)(Xf,{className:`w-4 h-4`}),name:`Environment Variables`,view:(0,U.jsx)(mKt,{}),testID:`settings-environment-variables`},{key:`custom-domain`,group:`configuration`,icon:(0,U.jsx)(pee,{className:`w-4 h-4`}),name:`Custom Domains`,view:(0,U.jsx)(sKt,{}),testID:`settings-custom-domain`},{key:`ai-providers`,group:`configuration`,icon:(0,U.jsx)(od,{className:`w-4 h-4`}),name:`AI Gateway`,view:(0,U.jsx)(_Gt,{}),testID:`settings-ai-providers`},{key:`upgrade-billing`,group:`account`,icon:(0,U.jsx)(yd,{className:`w-4 h-4`}),name:`Billing`,view:(0,U.jsx)(YKt,{to:`upgrade-billing`}),outbound:!0,testID:`settings-upgrade-billing`},{key:`zuplo-api-keys`,group:`account`,icon:(0,U.jsx)(mf,{className:`w-4 h-4`}),name:`Zuplo API Keys`,view:(0,U.jsx)(YKt,{to:`api-keys`}),outbound:!0,testID:`settings-zuplo-api-keys`},{key:`api-key-consumers`,group:`configuration`,icon:(0,U.jsx)(mf,{className:`w-4 h-4`}),name:`API Key Consumers`,view:(0,U.jsx)(()=>{let e=Op([`account`,`project`]);return(0,U.jsx)(Bo,{to:ri(rx.ProjectServices,{account:e.account.name,project:e.project.name}),replace:!0})},{}),hidden:!0},{key:`environments`,group:`account`,icon:(0,U.jsx)($f,{className:`w-4 h-4`}),name:`Environments`,view:(0,U.jsx)(JKt,{}),hidden:!0}];function ZKt({project:e,hideEnvironmentVariables:t}){return XKt.filter(n=>n.hidden?!1:n.key===`ai-providers`?xO(e):n.key===`environment-variables`?!t:!0)}var QKt=({account:e,project:t,environment:n,navigateTo:r})=>{let{data:i}=POe(e??``,t);return!e||!t||!n?null:(0,U.jsx)(vw,{heading:`Settings`,children:ZKt({project:i??{productType:`standard`},hideEnvironmentVariables:!1}).map(n=>(0,U.jsxs)(yw,{onSelect:()=>r(ri(`${rx.Settings}/${n.key}`,{account:e,project:t})),children:[n.icon,(0,U.jsx)(`span`,{className:`ml-3`,children:n.name})]},n.key))})},$Kt={GET:`bg-emerald-50 text-emerald-700 border-emerald-200 dark:bg-emerald-950 dark:text-emerald-300 dark:border-emerald-800`,POST:`bg-sky-50 text-sky-700 border-sky-200 dark:bg-sky-950 dark:text-sky-300 dark:border-sky-800`,PUT:`bg-amber-50 text-amber-700 border-amber-200 dark:bg-amber-950 dark:text-amber-300 dark:border-amber-800`,PATCH:`bg-orange-50 text-orange-700 border-orange-200 dark:bg-orange-950 dark:text-orange-300 dark:border-orange-800`,DELETE:`bg-red-50 text-red-700 border-red-200 dark:bg-red-950 dark:text-red-300 dark:border-red-800`},eqt=({account:e,project:t,environment:n,navigateTo:r})=>{let i=wR(e,t).data?.find(e=>e.urlParameter===n)?.name,a=Llt(i??``,{enabled:i!==void 0}).data?.model;if(!a||a.routes.length===0)return null;let o=new Map(a.handlers.map(e=>[e.key,e])),s=ri(rx.Code,{account:e,project:t,environment:n}),c=e=>`${s}?path=${encodeURIComponent(e.filePath)}${e.operationId?`&operation=${encodeURIComponent(e.operationId)}`:``}`;return(0,U.jsx)(vw,{heading:`Routes`,children:a.routes.map(e=>{let t=e.handlerKey?o.get(e.handlerKey):void 0;return(0,U.jsxs)(yw,{value:e.id,keywords:[`${e.method} ${e.path}`,...[e.operationId,e.summary,t?.name].filter(e=>!!e),...e.inboundPolicies,...e.outboundPolicies],onSelect:()=>r(c(e)),className:`gap-2`,children:[(0,U.jsx)(`span`,{className:W(`w-14 shrink-0 rounded-sm border px-1 py-0.5 text-center font-mono text-[10px] font-semibold uppercase leading-4`,$Kt[e.method]??`bg-neutral-50 text-neutral-600 border-neutral-200 dark:bg-neutral-900 dark:text-neutral-300 dark:border-neutral-700`),children:e.method}),(0,U.jsx)(`span`,{className:`truncate font-mono`,children:e.path}),e.summary&&(0,U.jsx)(`span`,{className:`ml-auto truncate pl-3 text-xs text-muted-foreground`,children:e.summary})]},e.id)})})},U7=({path:e,children:t,navigateTo:n,...r})=>(0,U.jsxs)(yw,{onSelect:()=>n(ri(e,r)),children:[(0,U.jsx)(`div`,{className:`mr-2`,children:t??(0,U.jsx)(Yu,{className:` h-4 w-4`})}),(0,U.jsx)(`span`,{children:Object.entries(rx).find(([,t])=>t===e)?.at(0)})]}),tqt=({account:e,navigateTo:t})=>{let{isAiUser:n,isLoading:r}=MTe(e);return n||r?null:(0,U.jsx)(U7,{path:rx.AccountSettings,navigateTo:t,account:e,children:(0,U.jsx)(Wf,{})})};function nqt(){let{isAuthenticated:e}=u(),t=BWt(),{account:n,project:r,environment:i}=lo(),a=ao(),o=n&&r&&i,s={account:n,project:r,environment:i},[c,l]=(0,H.useState)(``),d=(0,H.useRef)(null),f=e=>{l(e),d.current?.scrollTo({top:0})},p=dx({enabled:e});NOe(e?p.data?.map(e=>e.name)??[]:[]);let[m,h]=(0,H.useState)(!1);$R(`meta+k`,()=>{h(!0)});let g=e=>{h(e),e||l(``)},_=e=>{a(e),g(!1)};return(0,U.jsxs)(xEe,{open:m,onOpenChange:g,filter:KWt,children:[(0,U.jsx)(hw,{placeholder:`What do you want to do?`,onValueChange:f}),(0,U.jsxs)(gw,{ref:d,children:[(0,U.jsx)(_w,{children:(0,U.jsxs)(`div`,{className:`text-muted-foreground my-3`,children:[`No results found "`,c,`".`]})}),o&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(eqt,{navigateTo:_,account:n,project:r,environment:i}),(0,U.jsx)(JWt,{navigateTo:_,account:n,project:r,environment:i})]}),n&&r&&i&&(0,U.jsx)(QKt,{navigateTo:_,...s}),e&&(0,U.jsx)(UWt,{navigateTo:_,accounts:p.data,search:c}),(0,U.jsxs)(vw,{title:t.shortName,children:[(0,U.jsx)(U7,{path:rx.Profile,navigateTo:_,children:(0,U.jsx)(lp,{})}),(0,U.jsx)(U7,{path:rx.Logout,navigateTo:_,children:(0,U.jsx)(bf,{})}),n&&r&&(0,U.jsx)(U7,{path:rx.Settings,navigateTo:_,account:n,project:r,children:(0,U.jsx)(Wf,{})}),n&&e&&(0,U.jsx)(tqt,{account:n,navigateTo:_})]}),(0,U.jsx)(qWt,{query:c,onSelected:()=>g(!1)})]})]})}var rqt=Date.now(),iqt=300*1e3,aqt=14400*1e3,oqt=1440*60*1e3,sqt=async e=>{try{let t=await fetch(e,{method:`HEAD`,cache:`no-cache`});if(!t.ok)return!1;let n=t.headers.get(`date`),r=t.headers.get(`last-modified`);if(!n||!r)return!1;let i=new Date(n).getTime(),a=new Date(r).getTime();if(Number.isNaN(i)||Number.isNaN(a))return!1;let o=i-a>=oqt;return a>rqt&&i>rqt&&o}catch{return!1}},cqt=({enabled:e})=>{let t=(0,H.useRef)(0),n=y(),{data:r}=k({enabled:e,refetchInterval:iqt,refetchIntervalInBackground:!1,networkMode:`online`,retry:!1,queryFn:async()=>{let e=await sqt(window.location.href),r=Date.now();return e&&r-t.current>=aqt?(t.current=r,n.capture(`show-update-toast`),!0):!1},queryKey:[`update-check`]});return(0,U.jsxs)(yp,{open:r??!1,duration:1/0,children:[(0,U.jsxs)(_p,{children:[(0,U.jsx)(Sp,{children:`Update available`}),(0,U.jsx)(Cp,{children:`A new version of the Zuplo Portal is available. Click to reload.`})]}),(0,U.jsx)(bp,{altText:`Reload`,children:(0,U.jsx)(`button`,{type:`button`,onClick:()=>window.location.reload(),children:`Reload`})}),(0,U.jsx)(xp,{})]})},lqt=e=>e.handle?.preserveScroll===!0,uqt=(e,t)=>{for(let t=e.length-1;t>=0;t--)if(!lqt(e[t]))return e[t].pathname;return t},dqt=`[data-scroll-reset]`,W7=()=>Array.from(document.querySelectorAll(dqt)),fqt=e=>{if(!e)return!1;try{let t=document.getElementById(decodeURIComponent(e.slice(1)));return t?.scrollIntoView(),t!==null}catch{return!1}},pqt=e=>{let t=W7(),n=0,r=()=>{let i=!0;t.forEach((t,n)=>{let r=e[n]??0;t.scrollTop=r,Math.abs(t.scrollTop-r)>1&&(i=!1)}),!i&&++n<30&&requestAnimationFrame(r)};r()};function mqt(){let{key:e,pathname:t,hash:n}=to(),r=no(),i=uqt(To(),t),a=(0,H.useRef)(i),o=(0,H.useRef)(e),s=(0,H.useRef)(new Map);return(0,H.useEffect)(()=>{let e=e=>{e.target instanceof Element&&e.target.matches(dqt)&&s.current.set(o.current,W7().map(e=>e.scrollTop))};return document.addEventListener(`scroll`,e,{capture:!0,passive:!0}),()=>document.removeEventListener(`scroll`,e,{capture:!0})},[]),(0,H.useLayoutEffect)(()=>{let t=a.current!==i;if(a.current=i,o.current=e,t&&r===`POP`)pqt(s.current.get(e)??[]);else if(t&&!fqt(n)){window.scrollTo(0,0);for(let e of W7())e.scrollTop=0}s.current.has(e)||s.current.set(e,W7().map(e=>e.scrollTop))},[e,i,n,r]),null}var hqt=({enableUpdateNotifications:e})=>(0,U.jsx)(xht,{children:(0,U.jsxs)(hp,{children:[(0,U.jsx)(mqt,{}),(0,U.jsx)(cqt,{enabled:e}),(0,U.jsx)(nqt,{}),(0,U.jsx)(wp,{}),(0,U.jsx)(Vo,{}),(0,U.jsx)(gp,{})]})});function gqt(){return(0,U.jsx)(`div`,{className:`m-auto`,children:(0,U.jsxs)(`div`,{className:`flex flex-col gap-2 my-5`,children:[(0,U.jsx)(`div`,{children:(0,U.jsx)(rT,{variant:`outline`,children:`404`})}),(0,U.jsx)(`span`,{className:`text-2xl font-medium`,children:`Oops! Page not found.`}),(0,U.jsx)(`span`,{children:`Sorry, we could not find the page you were looking for.`}),(0,U.jsx)(`div`,{className:`h-2`}),(0,U.jsx)(Dut,{hasGoHome:!0})]})})}var _qt=()=>{let{environment:e}=sx([`environment`]),[t,n]=(0,H.useState)(null),r=Pp(e=>e.updateFile),i=Pp(e=>e.filesByPath);return{conflict:t,checkForConflictsBeforeSave:(0,H.useCallback)(async(t,r)=>{let a=i[t];try{let i=await nc(e,t);return a.lastModified&&i.lastModified&&i.lastModified>a.lastModified?(jt.warn(`File ${t} was modified on disk. Showing conflict dialog before save.`),new Promise(e=>{n({filePath:t,localContent:a.content??``,remoteContent:i.content??``,remoteLastModified:i.lastModified,onProceed:async()=>{await r(),e(!0)}})})):(await r(),!0)}catch(e){return jt.error(`Error checking for conflicts`,{error:e}),await r(),!0}},[e,i]),showConflict:(0,H.useCallback)(e=>{jt.info(`Showing conflict dialog for ${e.filePath}`),n(e)},[]),resolveConflict:(0,H.useCallback)(async a=>{if(!t)return;let o=i[t.filePath];if(!o){n(null);return}if(a===`remote`)r({...o,content:t.remoteContent,lastModified:t.remoteLastModified,saveState:Qs.unmodified}),jt.info(`Using disk version for ${t.filePath}, canceling save`),n(null);else if(jt.info(`User chose local version for ${t.filePath}${t.onProceed?`, proceeding with save`:`, saving to disk`}`),t.onProceed)await t.onProceed(),n(null);else try{await ic(e,{path:o.path,content:o.content},{forceSave:!0});let i=await nc(e,t.filePath);r({...o,lastModified:i.lastModified,saveState:Qs.unmodified}),jt.info(`Successfully saved local version for ${t.filePath}`),n(null)}catch(e){jt.error(`Error saving local version for ${t.filePath}`,{error:e}),r({...o,saveState:Qs.modified})}},[t,i,r,e]),cancelConflict:(0,H.useCallback)(async()=>{if(!t)return;let a=i[t.filePath];if(a){let n=await nc(e,t.filePath);r({...a,lastModified:n.lastModified,saveState:Qs.modified}),jt.info(`Conflict dialog canceled for ${t.filePath}, file marked as modified`)}n(null)},[t,i,r,e])}};function vqt({open:e,filePath:t,localContent:n,remoteContent:r,onResolve:i,onCancel:a}){let[o,s]=(0,H.useState)(`local`),c=Gdt(t);return(0,U.jsx)(ow,{open:e,onOpenChange:e=>!e&&a(),children:(0,U.jsxs)(lw,{className:`max-w-7xl max-h-[90vh] p-0`,showCloseButton:!1,children:[(0,U.jsx)(`div`,{className:`p-6 pb-0`,children:(0,U.jsxs)(uw,{children:[(0,U.jsx)(fw,{className:`text-lg font-semibold text-left mb-1`,children:`File Conflict Detected`}),(0,U.jsxs)(`p`,{className:`text-sm text-muted-foreground text-left`,children:[(0,U.jsx)(`span`,{className:`font-mono font-semibold`,children:t}),` has been modified both locally and on disk`]})]})}),(0,U.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-col px-6`,children:[(0,U.jsxs)(`div`,{className:`grid grid-cols-2`,children:[(0,U.jsxs)(`button`,{type:`button`,className:`flex flex-col py-3 cursor-pointer transition-all border-t-4 border-x ${o===`local`?`border-t-pink-500 border-x-pink-200 bg-pink-50`:`border-t-border border-x-border bg-gray-50 dark:bg-neutral-900 hover:bg-gray-100 dark:hover:bg-neutral-800`}`,style:{paddingLeft:`26px`,paddingRight:`24px`},onClick:()=>s(`local`),"aria-pressed":o===`local`,children:[(0,U.jsx)(`div`,{className:`font-semibold text-sm`,children:`Browser Version`}),(0,U.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Current editor content`})]}),(0,U.jsxs)(`button`,{type:`button`,className:`flex flex-col px-6 py-3 cursor-pointer transition-all border-t-4 border-x ${o===`remote`?`border-t-pink-500 border-x-pink-200 bg-pink-50`:`border-t-border border-x-border bg-gray-50 dark:bg-neutral-900 hover:bg-gray-100 dark:hover:bg-neutral-800`}`,onClick:()=>s(`remote`),"aria-pressed":o===`remote`,children:[(0,U.jsx)(`div`,{className:`font-semibold text-sm`,children:`Disk Version`}),(0,U.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`File on disk`})]})]}),(0,U.jsx)(`div`,{className:`border border-t-0 overflow-hidden shadow-xs flex-1 min-h-[55vh]`,children:(0,U.jsx)(iL,{original:n,modified:r,language:c,options:{readOnly:!0,renderSideBySide:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:13,wordWrap:`off`}})})]}),(0,U.jsxs)(dw,{className:`px-6 pb-6 flex-row justify-between items-center`,children:[(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:o===`local`?(0,U.jsx)(U.Fragment,{children:`Browser version will be saved to disk`}):(0,U.jsx)(U.Fragment,{children:`Disk version will replace browser content`})}),(0,U.jsxs)(`div`,{className:`flex gap-2`,children:[(0,U.jsx)(X,{variant:`ghost`,onClick:a,children:`Cancel`}),(0,U.jsxs)(X,{variant:`default`,onClick:()=>i(o),children:[`Apply `,o===`local`?`Browser`:`Disk`,` Version`]})]})]})]})})}function yqt(){let{environment:e}=sx([`environment`]),{conflict:t,showConflict:n,resolveConflict:r,cancelConflict:i}=_qt(),a=Pp(e=>e.filesByPath),o=Pp(e=>e.saveConflictPath),s=Pp(e=>e.clearSaveConflict);return(0,H.useEffect)(()=>{if(o){jt.info(`Save conflict detected for ${o}`);let t=a[o];t?nc(e,o).then(e=>{n({filePath:o,localContent:t.content??``,remoteContent:e.content??``,remoteLastModified:e.lastModified})}).catch(e=>{jt.error(`Error fetching file for conflict dialog`,{error:e})}):jt.warn(`No file model found for ${o}`),s()}},[o,a,s,n,e]),t?(0,U.jsx)(vqt,{open:!0,filePath:t.filePath,localContent:t.localContent,remoteContent:t.remoteContent,onResolve:r,onCancel:i}):null}var bqt=()=>{let e=Op(),{monaco:t,reloadFiles:n}=_7(),r=XR(n.execute),i=e.environment.name,{error:a}=k({queryKey:[`reloadFiles`,e.account.name,e.project.name,i],queryFn:async()=>{try{return await r.current({accountName:e.account.name,projectName:e.project.name,environmentName:e.environment.name}),!0}catch(e){throw jt.error(`Failed to reload files`,{error:e}),e}},refetchOnWindowFocus:!1,enabled:!!t&&!!i,retry:3,retryDelay:e=>Math.min(1e3*2**e,3e4)});return a?(0,U.jsx)(`div`,{className:`flex items-center justify-center h-full bg-gray-50`,children:(0,U.jsxs)(`div`,{className:`text-center p-8 max-w-lg`,children:[(0,U.jsx)(`h2`,{className:`text-xl font-semibold text-gray-900 mb-2`,children:`Failed to Load Files`}),(0,U.jsx)(`p`,{className:`text-gray-600 mb-4`,children:`Unable to load project files from the local server. Please check that the dev server is running and try again.`}),(0,U.jsx)(`button`,{type:`button`,onClick:()=>window.location.reload(),className:`px-4 py-2 bg-blue-600 text-white rounded-sm hover:bg-blue-700`,children:`Retry`})]})}):null},xqt=()=>{let{account:e,project:t}=sx([`account`,`project`]),n=Pp(e=>e.resetStore);return(0,H.useEffect)(()=>{n()},[t,e,n]),(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(bqt,{}),(0,U.jsx)(yqt,{}),(0,U.jsx)(eUt,{}),(0,U.jsx)(Vo,{})]})};H.createContext({en:{translations:{archiveNotification:`Archive this notification`,archiveRead:`Archive Read`,markAllAsRead:`Mark all as read`,notifications:`Notifications`,emptyFeedTitle:`No notifications yet`,emptyFeedBody:`We'll let you know when we've got something new for you.`,all:`All`,unread:`Unread`,read:`Read`,unseen:`Unseen`,msTeamsChannelSetError:`Error setting channel.`,msTeamsConnect:`Connect to Microsoft Teams`,msTeamsConnected:`Connected`,msTeamsConnecting:`Connecting to Microsoft Teams…`,msTeamsConnectionErrorExists:`Try reconnecting to Microsoft Teams to find and select channels from your teams.`,msTeamsConnectionErrorOccurred:`There was an error connecting to Microsoft Teams. Try reconnecting to find and select channels from your teams.`,msTeamsConnectContainerDescription:`Connect to get notifications in Microsoft Teams`,msTeamsDisconnect:`Disconnect`,msTeamsDisconnecting:`Disconnecting from Microsoft Teams…`,msTeamsError:`Error`,msTeamsReconnect:`Reconnect`,msTeamsTenantIdNotSet:`Microsoft Teams tenant ID not set.`,slackConnectChannel:`Connect channel`,slackChannelId:`Slack channel ID`,slackConnecting:`Connecting to Slack...`,slackDisconnecting:`Disconnecting...`,slackConnect:`Connect to Slack`,slackConnected:`Connected`,slackConnectContainerDescription:`Connect to get notifications in your Slack workspace.`,slackSearchbarDisconnected:`Slack is not connected.`,slackSearchbarNoChannelsConnected:`Search channels`,slackSearchbarNoChannelsFound:`No slack channels.`,slackSearchbarChannelsError:`Error fetching channels.`,slackSearchChannels:`Search channels`,slackConnectionErrorExists:`Try reconnecting to Slack to find and select channels from your workspace.`,slackConnectionErrorOccurred:`There was an error connecting to Slack. Try reconnecting to find and select channels from your workspace.`,slackChannelAlreadyConnected:`Error: already connected`,slackError:`Error`,slackDisconnect:`Disconnect`,slackChannelSetError:`Error setting channel.`,slackAccessTokenNotSet:`Access token not set.`,slackReconnect:`Reconnect`},locale:`en`},de:{translations:{archiveNotification:`Benachrichtigung archivieren`,archiveRead:`Gelesenes Archivieren`,markAllAsRead:`Alle als gelesen markieren`,notifications:`Benachrichtigungen`,emptyFeedTitle:`Noch keine Benachrichtigungen`,emptyFeedBody:`Wir werden dich benachrichtigen, sobald wir etwas Neues für dich haben.`,all:`Alle`,unread:`Ungelesen`,read:`Gelesen`,unseen:`Ungesehen`,slackConnectChannel:`Kanal verbinden`,slackChannelId:`Slack Kanal ID`,slackConnecting:`Verbinden mit Slack...`,slackDisconnecting:`Trennen der Verbindung...`,slackConnect:`Mit Slack verbinden`,slackConnected:`Verbunden`,slackConnectContainerDescription:`Verbinden, um Benachrichtigungen in Ihrem Slack-Arbeitsbereich zu erhalten.`,slackSearchbarDisconnected:`Slack ist nicht verbunden.`,slackSearchbarNoChannelsConnected:`Suchkanäle`,slackSearchbarNoChannelsFound:`Keine schlaffen Kanäle.`,slackSearchbarChannelsError:`Fehler beim Abrufen von Kanälen.`,slackSearchChannels:`Suchkanäle`,slackConnectionErrorExists:`Versuchen Sie, sich erneut mit Slack zu verbinden, um Kanäle in Ihrem Arbeitsbereich zu finden und auszuwählen.`,slackConnectionErrorOccurred:`Es ist ein Fehler beim Verbinden mit Slack aufgetreten. Versuchen Sie, sich erneut zu verbinden, um Kanäle in Ihrem Arbeitsbereich zu finden und auszuwählen.`,slackChannelAlreadyConnected:`Fehler: bereits verbunden`,slackError:`Fehler`,slackDisconnect:`Trennen Sie die Verbindung.`,slackChannelSetError:`Fehlereinstellung Kanal.`,slackAccessTokenNotSet:`Zugriffstoken nicht gesetzt.`,slackReconnect:`Neu verbinden`},locale:`de`}}.en),a(((e,t)=>{(function(n){var r=Object.hasOwnProperty,i=Array.isArray?Array.isArray:function(e){return Object.prototype.toString.call(e)===`[object Array]`},a=10,o=typeof process==`object`&&typeof process.nextTick==`function`,s=typeof Symbol==`function`,c=typeof Reflect==`object`,l=typeof setImmediate==`function`?setImmediate:setTimeout,u=s?c&&typeof Reflect.ownKeys==`function`?Reflect.ownKeys:function(e){var t=Object.getOwnPropertyNames(e);return t.push.apply(t,Object.getOwnPropertySymbols(e)),t}:Object.keys;function d(){this._events={},this._conf&&f.call(this,this._conf)}function f(e){e&&(this._conf=e,e.delimiter&&(this.delimiter=e.delimiter),e.maxListeners!==n&&(this._maxListeners=e.maxListeners),e.wildcard&&(this.wildcard=e.wildcard),e.newListener&&(this._newListener=e.newListener),e.removeListener&&(this._removeListener=e.removeListener),e.verboseMemoryLeak&&(this.verboseMemoryLeak=e.verboseMemoryLeak),e.ignoreErrors&&(this.ignoreErrors=e.ignoreErrors),this.wildcard&&(this.listenerTree={}))}function p(e,t){var n=`(node) warning: possible EventEmitter memory leak detected. `+e+` listeners added. Use emitter.setMaxListeners() to increase limit.`;if(this.verboseMemoryLeak&&(n+=` Event name: `+t+`.`),typeof process<`u`&&process.emitWarning){var r=Error(n);r.name=`MaxListenersExceededWarning`,r.emitter=this,r.count=e,process.emitWarning(r)}else console.error(n),console.trace&&console.trace()}var m=function(e,t,n){var r=arguments.length;switch(r){case 0:return[];case 1:return[e];case 2:return[e,t];case 3:return[e,t,n];default:for(var i=Array(r);r--;)i[r]=arguments[r];return i}};function h(e,t){for(var r={},i,a=e.length,o=t?t.length:0,s=0;s<a;s++)i=e[s],r[i]=s<o?t[s]:n;return r}function g(e,t,n){this._emitter=e,this._target=t,this._listeners={},this._listenersCount=0;var r,i;if((n.on||n.off)&&(r=n.on,i=n.off),t.addEventListener?(r=t.addEventListener,i=t.removeEventListener):t.addListener?(r=t.addListener,i=t.removeListener):t.on&&(r=t.on,i=t.off),!r&&!i)throw Error(`target does not implement any known event API`);if(typeof r!=`function`)throw TypeError(`on method must be a function`);if(typeof i!=`function`)throw TypeError(`off method must be a function`);this._on=r,this._off=i;var a=e._observers;a?a.push(this):e._observers=[this]}Object.assign(g.prototype,{subscribe:function(e,t,n){var r=this,i=this._target,a=this._emitter,o=this._listeners,s=function(){var r=m.apply(null,arguments),o={data:r,name:t,original:e};if(n){n.call(i,o)!==!1&&a.emit.apply(a,[o.name].concat(r));return}a.emit.apply(a,[t].concat(r))};if(o[e])throw Error(`Event '`+e+`' is already listening`);this._listenersCount++,a._newListener&&a._removeListener&&!r._onNewListener?(this._onNewListener=function(n){n===t&&o[e]===null&&(o[e]=s,r._on.call(i,e,s))},a.on(`newListener`,this._onNewListener),this._onRemoveListener=function(n){n===t&&!a.hasListeners(n)&&o[e]&&(o[e]=null,r._off.call(i,e,s))},o[e]=null,a.on(`removeListener`,this._onRemoveListener)):(o[e]=s,r._on.call(i,e,s))},unsubscribe:function(e){var t=this,n=this._listeners,r=this._emitter,i,a,o=this._off,s=this._target,c;if(e&&typeof e!=`string`)throw TypeError(`event must be a string`);function l(){t._onNewListener&&(r.off(`newListener`,t._onNewListener),r.off(`removeListener`,t._onRemoveListener),t._onNewListener=null,t._onRemoveListener=null);var e=C.call(r,t);r._observers.splice(e,1)}if(e){if(i=n[e],!i)return;o.call(s,e,i),delete n[e],--this._listenersCount||l()}else{for(a=u(n),c=a.length;c-- >0;)e=a[c],o.call(s,e,n[e]);this._listeners={},this._listenersCount=0,l()}}});function _(e,t,i,a){var o=Object.assign({},t);if(!e)return o;if(typeof e!=`object`)throw TypeError(`options must be an object`);var s=Object.keys(e),c=s.length,l,u,d;function f(e){throw Error(`Invalid "`+l+`" option value`+(e?`. Reason: `+e:``))}for(var p=0;p<c;p++){if(l=s[p],!a&&!r.call(t,l))throw Error(`Unknown "`+l+`" option`);u=e[l],u!==n&&(d=i[l],o[l]=d?d(u,f):u)}return o}function v(e,t){return(typeof e!=`function`||!e.hasOwnProperty(`prototype`))&&t(`value must be a constructor`),e}function y(e){var t=`value must be type of `+e.join(`|`),n=e.length,r=e[0],i=e[1];return n===1?function(e,n){if(typeof e===r)return e;n(t)}:n===2?function(e,n){var a=typeof e;if(a===r||a===i)return e;n(t)}:function(r,i){for(var a=typeof r,o=n;o-- >0;)if(a===e[o])return r;i(t)}}var b=y([`function`]),x=y([`object`,`function`]);function S(e,t,n){var r,i,a=0,o,s=new e(function(c,l,u){n=_(n,{timeout:0,overload:!1},{timeout:function(e,t){return e*=1,(typeof e!=`number`||e<0||!Number.isFinite(e))&&t(`timeout must be a positive number`),e}}),r=!n.overload&&typeof e.prototype.cancel==`function`&&typeof u==`function`;function d(){i&&=null,a&&=(clearTimeout(a),0)}var f=function(e){d(),c(e)},p=function(e){d(),l(e)};r?t(f,p,u):(i=[function(e){p(e||Error(`canceled`))}],t(f,p,function(e){if(o)throw Error(`Unable to subscribe on cancel event asynchronously`);if(typeof e!=`function`)throw TypeError(`onCancel callback must be a function`);i.push(e)}),o=!0),n.timeout>0&&(a=setTimeout(function(){var e=Error(`timeout`);e.code=`ETIMEDOUT`,a=0,s.cancel(e),l(e)},n.timeout))});return r||(s.cancel=function(e){if(i){for(var t=i.length,n=1;n<t;n++)i[n](e);i[0](e),i=null}}),s}function C(e){var t=this._observers;if(!t)return-1;for(var n=t.length,r=0;r<n;r++)if(t[r]._target===e)return r;return-1}function w(e,t,n,r,i){if(!n)return null;if(r===0){var a=typeof t;if(a===`string`){var o,s,c=0,l=0,d=this.delimiter,f=d.length;if((s=t.indexOf(d))!==-1){o=[,,,,,];do o[c++]=t.slice(l,s),l=s+f;while((s=t.indexOf(d,l))!==-1);o[c++]=t.slice(l),t=o,i=c}else t=[t],i=1}else a===`object`?i=t.length:(t=[t],i=1)}var p=null,m,h,g,_,v,y=t[r],b=t[r+1],x,S;if(r===i)n._listeners&&(typeof n._listeners==`function`?(e&&e.push(n._listeners),p=[n]):(e&&e.push.apply(e,n._listeners),p=[n]));else if(y===`*`){for(x=u(n),s=x.length;s-- >0;)m=x[s],m!==`_listeners`&&(S=w(e,t,n[m],r+1,i),S&&(p?p.push.apply(p,S):p=S));return p}else if(y===`**`){for(v=r+1===i||r+2===i&&b===`*`,v&&n._listeners&&(p=w(e,t,n,i,i)),x=u(n),s=x.length;s-- >0;)m=x[s],m!==`_listeners`&&(m===`*`||m===`**`?(n[m]._listeners&&!v&&(S=w(e,t,n[m],i,i),S&&(p?p.push.apply(p,S):p=S)),S=w(e,t,n[m],r,i)):S=m===b?w(e,t,n[m],r+2,i):w(e,t,n[m],r,i),S&&(p?p.push.apply(p,S):p=S));return p}else n[y]&&(p=w(e,t,n[y],r+1,i));if(h=n[`*`],h&&w(e,t,h,r+1,i),g=n[`**`],g)if(r<i)for(g._listeners&&w(e,t,g,i,i),x=u(g),s=x.length;s-- >0;)m=x[s],m!==`_listeners`&&(m===b?w(e,t,g[m],r+2,i):m===y?w(e,t,g[m],r+1,i):(_={},_[m]=g[m],w(e,t,{"**":_},r+1,i)));else g._listeners?w(e,t,g,i,i):g[`*`]&&g[`*`]._listeners&&w(e,t,g[`*`],i,i);return p}function T(e,t,n){var r=0,i=0,a,o=this.delimiter,s=o.length,c;if(typeof e==`string`)if((a=e.indexOf(o))!==-1){c=[,,,,,];do c[r++]=e.slice(i,a),i=a+s;while((a=e.indexOf(o,i))!==-1);c[r++]=e.slice(i)}else c=[e],r=1;else c=e,r=e.length;if(r>1){for(a=0;a+1<r;a++)if(c[a]===`**`&&c[a+1]===`**`)return}var l=this.listenerTree,u;for(a=0;a<r;a++)if(u=c[a],l=l[u]||(l[u]={}),a===r-1)return l._listeners?(typeof l._listeners==`function`&&(l._listeners=[l._listeners]),n?l._listeners.unshift(t):l._listeners.push(t),!l._listeners.warned&&this._maxListeners>0&&l._listeners.length>this._maxListeners&&(l._listeners.warned=!0,p.call(this,l._listeners.length,u))):l._listeners=t,!0;return!0}function E(e,t,n,r){for(var i=u(e),a=i.length,o,s,c,l=e._listeners,d;a-- >0;)s=i[a],o=e[s],c=s===`_listeners`?n:n?n.concat(s):[s],d=r||typeof s==`symbol`,l&&t.push(d?c:c.join(this.delimiter)),typeof o==`object`&&E.call(this,o,t,c,d);return t}function D(e){for(var t=u(e),n=t.length,r,i,a;n-- >0;)i=t[n],r=e[i],r&&(a=!0,i!==`_listeners`&&!D(r)&&delete e[i]);return a}function O(e,t,n){this.emitter=e,this.event=t,this.listener=n}O.prototype.off=function(){return this.emitter.off(this.event,this.listener),this};function k(e,t,r){if(r===!0)a=!0;else if(r===!1)i=!0;else{if(!r||typeof r!=`object`)throw TypeError(`options should be an object or true`);var i=r.async,a=r.promisify,s=r.nextTick,c=r.objectify}if(i||s||a){var u=t,d=t._origin||t;if(s&&!o)throw Error(`process.nextTick is not supported`);a===n&&(a=t.constructor.name===`AsyncFunction`),t=function(){var e=arguments,t=this,n=this.event;return a?s?Promise.resolve():new Promise(function(e){l(e)}).then(function(){return t.event=n,u.apply(t,e)}):(s?process.nextTick:l)(function(){t.event=n,u.apply(t,e)})},t._async=!0,t._origin=d}return[t,c?new O(this,e,t):this]}function A(e){this._events={},this._newListener=!1,this._removeListener=!1,this.verboseMemoryLeak=!1,f.call(this,e)}A.EventEmitter2=A,A.prototype.listenTo=function(e,t,r){if(typeof e!=`object`)throw TypeError(`target musts be an object`);var a=this;r=_(r,{on:n,off:n,reducers:n},{on:b,off:b,reducers:x});function o(t){if(typeof t!=`object`)throw TypeError(`events must be an object`);for(var n=r.reducers,i=C.call(a,e),o=i===-1?new g(a,e,r):a._observers[i],s=u(t),c=s.length,l,d=typeof n==`function`,f=0;f<c;f++)l=s[f],o.subscribe(l,t[l]||l,d?n:n&&n[l])}return i(t)?o(h(t)):o(typeof t==`string`?h(t.split(/\s+/)):t),this},A.prototype.stopListeningTo=function(e,t){var n=this._observers;if(!n)return!1;var r=n.length,i,a=!1;if(e&&typeof e!=`object`)throw TypeError(`target should be an object`);for(;r-- >0;)i=n[r],(!e||i._target===e)&&(i.unsubscribe(t),a=!0);return a},A.prototype.delimiter=`.`,A.prototype.setMaxListeners=function(e){e!==n&&(this._maxListeners=e,this._conf||={},this._conf.maxListeners=e)},A.prototype.getMaxListeners=function(){return this._maxListeners},A.prototype.event=``,A.prototype.once=function(e,t,n){return this._once(e,t,!1,n)},A.prototype.prependOnceListener=function(e,t,n){return this._once(e,t,!0,n)},A.prototype._once=function(e,t,n,r){return this._many(e,1,t,n,r)},A.prototype.many=function(e,t,n,r){return this._many(e,t,n,!1,r)},A.prototype.prependMany=function(e,t,n,r){return this._many(e,t,n,!0,r)},A.prototype._many=function(e,t,n,r,i){var a=this;if(typeof n!=`function`)throw Error(`many only accepts instances of Function`);function o(){return--t===0&&a.off(e,o),n.apply(this,arguments)}return o._origin=n,this._on(e,o,r,i)},A.prototype.emit=function(){if(!this._events&&!this._all)return!1;this._events||d.call(this);var e=arguments[0],t,n=this.wildcard,r,i,a,o,c;if(e===`newListener`&&!this._newListener&&!this._events.newListener)return!1;if(n&&(t=e,e!==`newListener`&&e!==`removeListener`&&typeof e==`object`)){if(i=e.length,s){for(a=0;a<i;a++)if(typeof e[a]==`symbol`){c=!0;break}}c||(e=e.join(this.delimiter))}var l=arguments.length,u;if(this._all&&this._all.length)for(u=this._all.slice(),a=0,i=u.length;a<i;a++)switch(this.event=e,l){case 1:u[a].call(this,e);break;case 2:u[a].call(this,e,arguments[1]);break;case 3:u[a].call(this,e,arguments[1],arguments[2]);break;default:u[a].apply(this,arguments)}if(n)u=[],w.call(this,u,t,this.listenerTree,0,i);else if(u=this._events[e],typeof u==`function`){switch(this.event=e,l){case 1:u.call(this);break;case 2:u.call(this,arguments[1]);break;case 3:u.call(this,arguments[1],arguments[2]);break;default:for(r=Array(l-1),o=1;o<l;o++)r[o-1]=arguments[o];u.apply(this,r)}return!0}else u&&=u.slice();if(u&&u.length){if(l>3)for(r=Array(l-1),o=1;o<l;o++)r[o-1]=arguments[o];for(a=0,i=u.length;a<i;a++)switch(this.event=e,l){case 1:u[a].call(this);break;case 2:u[a].call(this,arguments[1]);break;case 3:u[a].call(this,arguments[1],arguments[2]);break;default:u[a].apply(this,r)}return!0}else if(!this.ignoreErrors&&!this._all&&e===`error`)throw arguments[1]instanceof Error?arguments[1]:Error(`Uncaught, unspecified 'error' event.`);return!!this._all},A.prototype.emitAsync=function(){if(!this._events&&!this._all)return!1;this._events||d.call(this);var e=arguments[0],t=this.wildcard,n,r,i,a,o,c;if(e===`newListener`&&!this._newListener&&!this._events.newListener)return Promise.resolve([!1]);if(t&&(n=e,e!==`newListener`&&e!==`removeListener`&&typeof e==`object`)){if(a=e.length,s){for(o=0;o<a;o++)if(typeof e[o]==`symbol`){r=!0;break}}r||(e=e.join(this.delimiter))}var l=[],u=arguments.length,f;if(this._all)for(o=0,a=this._all.length;o<a;o++)switch(this.event=e,u){case 1:l.push(this._all[o].call(this,e));break;case 2:l.push(this._all[o].call(this,e,arguments[1]));break;case 3:l.push(this._all[o].call(this,e,arguments[1],arguments[2]));break;default:l.push(this._all[o].apply(this,arguments))}if(t?(f=[],w.call(this,f,n,this.listenerTree,0)):f=this._events[e],typeof f==`function`)switch(this.event=e,u){case 1:l.push(f.call(this));break;case 2:l.push(f.call(this,arguments[1]));break;case 3:l.push(f.call(this,arguments[1],arguments[2]));break;default:for(i=Array(u-1),c=1;c<u;c++)i[c-1]=arguments[c];l.push(f.apply(this,i))}else if(f&&f.length){if(f=f.slice(),u>3)for(i=Array(u-1),c=1;c<u;c++)i[c-1]=arguments[c];for(o=0,a=f.length;o<a;o++)switch(this.event=e,u){case 1:l.push(f[o].call(this));break;case 2:l.push(f[o].call(this,arguments[1]));break;case 3:l.push(f[o].call(this,arguments[1],arguments[2]));break;default:l.push(f[o].apply(this,i))}}else if(!this.ignoreErrors&&!this._all&&e===`error`)return arguments[1]instanceof Error?Promise.reject(arguments[1]):Promise.reject(`Uncaught, unspecified 'error' event.`);return Promise.all(l)},A.prototype.on=function(e,t,n){return this._on(e,t,!1,n)},A.prototype.prependListener=function(e,t,n){return this._on(e,t,!0,n)},A.prototype.onAny=function(e){return this._onAny(e,!1)},A.prototype.prependAny=function(e){return this._onAny(e,!0)},A.prototype.addListener=A.prototype.on,A.prototype._onAny=function(e,t){if(typeof e!=`function`)throw Error(`onAny only accepts instances of Function`);return this._all||=[],t?this._all.unshift(e):this._all.push(e),this},A.prototype._on=function(e,t,r,i){if(typeof e==`function`)return this._onAny(e,t),this;if(typeof t!=`function`)throw Error(`on only accepts instances of Function`);this._events||d.call(this);var a=this,o;return i!==n&&(o=k.call(this,e,t,i),t=o[0],a=o[1]),this._newListener&&this.emit(`newListener`,e,t),this.wildcard?(T.call(this,e,t,r),a):(this._events[e]?(typeof this._events[e]==`function`&&(this._events[e]=[this._events[e]]),r?this._events[e].unshift(t):this._events[e].push(t),!this._events[e].warned&&this._maxListeners>0&&this._events[e].length>this._maxListeners&&(this._events[e].warned=!0,p.call(this,this._events[e].length,e))):this._events[e]=t,a)},A.prototype.off=function(e,t){if(typeof t!=`function`)throw Error(`removeListener only takes instances of Function`);var n,r=[];if(this.wildcard){var a=typeof e==`string`?e.split(this.delimiter):e.slice();if(r=w.call(this,null,a,this.listenerTree,0),!r)return this}else{if(!this._events[e])return this;n=this._events[e],r.push({_listeners:n})}for(var o=0;o<r.length;o++){var s=r[o];if(n=s._listeners,i(n)){for(var c=-1,l=0,u=n.length;l<u;l++)if(n[l]===t||n[l].listener&&n[l].listener===t||n[l]._origin&&n[l]._origin===t){c=l;break}if(c<0)continue;return this.wildcard?s._listeners.splice(c,1):this._events[e].splice(c,1),n.length===0&&(this.wildcard?delete s._listeners:delete this._events[e]),this._removeListener&&this.emit(`removeListener`,e,t),this}else (n===t||n.listener&&n.listener===t||n._origin&&n._origin===t)&&(this.wildcard?delete s._listeners:delete this._events[e],this._removeListener&&this.emit(`removeListener`,e,t))}return this.listenerTree&&D(this.listenerTree),this},A.prototype.offAny=function(e){var t=0,n=0,r;if(e&&this._all&&this._all.length>0){for(r=this._all,t=0,n=r.length;t<n;t++)if(e===r[t])return r.splice(t,1),this._removeListener&&this.emit(`removeListenerAny`,e),this}else{if(r=this._all,this._removeListener)for(t=0,n=r.length;t<n;t++)this.emit(`removeListenerAny`,r[t]);this._all=[]}return this},A.prototype.removeListener=A.prototype.off,A.prototype.removeAllListeners=function(e){if(e===n)return!this._events||d.call(this),this;if(this.wildcard){var t=w.call(this,null,e,this.listenerTree,0),r,i;if(!t)return this;for(i=0;i<t.length;i++)r=t[i],r._listeners=null;this.listenerTree&&D(this.listenerTree)}else this._events&&(this._events[e]=null);return this},A.prototype.listeners=function(e){var t=this._events,r,i,a,o,s;if(e===n){if(this.wildcard)throw Error(`event name required for wildcard emitter`);if(!t)return[];for(r=u(t),o=r.length,a=[];o-- >0;)i=t[r[o]],typeof i==`function`?a.push(i):a.push.apply(a,i);return a}else{if(this.wildcard){if(s=this.listenerTree,!s)return[];var c=[],l=typeof e==`string`?e.split(this.delimiter):e.slice();return w.call(this,c,l,s,0),c}return!t||(i=t[e],!i)?[]:typeof i==`function`?[i]:i}},A.prototype.eventNames=function(e){var t=this._events;return this.wildcard?E.call(this,this.listenerTree,[],null,e):t?u(t):[]},A.prototype.listenerCount=function(e){return this.listeners(e).length},A.prototype.hasListeners=function(e){if(this.wildcard){var t=[],r=typeof e==`string`?e.split(this.delimiter):e.slice();return w.call(this,t,r,this.listenerTree,0),t.length>0}var i=this._events,a=this._all;return!!(a&&a.length||i&&(e===n?u(i).length:i[e]))},A.prototype.listenersAny=function(){return this._all?this._all:[]},A.prototype.waitFor=function(e,t){var r=this,i=typeof t;return i===`number`?t={timeout:t}:i===`function`&&(t={filter:t}),t=_(t,{timeout:0,filter:n,handleError:!1,Promise,overload:!1},{filter:b,Promise:v}),S(t.Promise,function(n,i,a){function o(){var a=t.filter;if(!(a&&!a.apply(r,arguments)))if(r.off(e,o),t.handleError){var s=arguments[0];s?i(s):n(m.apply(null,arguments).slice(1))}else n(m.apply(null,arguments))}a(function(){r.off(e,o)}),r._on(e,o,!1)},{timeout:t.timeout,overload:t.overload})};function j(e,t,n){n=_(n,{Promise,timeout:0,overload:!1},{Promise:v});var r=n.Promise;return S(r,function(n,r,i){var a;if(typeof e.addEventListener==`function`){a=function(){n(m.apply(null,arguments))},i(function(){e.removeEventListener(t,a)}),e.addEventListener(t,a,{once:!0});return}var o=function(){s&&e.removeListener(`error`,s),n(m.apply(null,arguments))},s;t!==`error`&&(s=function(n){e.removeListener(t,o),r(n)},e.once(`error`,s)),i(function(){s&&e.removeListener(`error`,s),e.removeListener(t,o)}),e.once(t,o)},{timeout:n.timeout,overload:n.overload})}var M=A.prototype;if(Object.defineProperties(A,{defaultMaxListeners:{get:function(){return M._maxListeners},set:function(e){if(typeof e!=`number`||e<0||Number.isNaN(e))throw TypeError(`n must be a non-negative number`);M._maxListeners=e},enumerable:!0},once:{value:j,writable:!0,configurable:!0}}),Object.defineProperties(M,{_maxListeners:{value:a,writable:!0,configurable:!0},_observers:{value:null,writable:!0,configurable:!0}}),typeof define==`function`&&define.amd)define(function(){return A});else if(typeof e==`object`)t.exports=A;else{var N=Function(``,`return this`)();N.EventEmitter2=A}})()}))();var Sqt=(e=>(e.loading=`loading`,e.fetchMore=`fetchMore`,e.ready=`ready`,e.error=`error`,e))(Sqt||{}),G7=new WeakMap,K7=new WeakMap,q7={current:[]},J7=!1,Cqt=0,Y7=new Set,X7=new Map;function wqt(e){let t=Array.from(e).sort((e,t)=>e instanceof Aqt&&e.options.deps.includes(t)?1:t instanceof Aqt&&t.options.deps.includes(e)?-1:0);for(let e of t){if(q7.current.includes(e))continue;q7.current.push(e),e.recompute();let t=K7.get(e);if(t)for(let e of t){let t=G7.get(e);t&&wqt(t)}}}function Tqt(e){let t={prevVal:e.prevState,currentVal:e.state};for(let n of e.listeners)n(t)}function Eqt(e){let t={prevVal:e.prevState,currentVal:e.state};for(let n of e.listeners)n(t)}function Dqt(e){if(Cqt>0&&!X7.has(e)&&X7.set(e,e.prevState),Y7.add(e),!(Cqt>0)&&!J7)try{for(J7=!0;Y7.size>0;){let e=Array.from(Y7);Y7.clear();for(let t of e)t.prevState=X7.get(t)??t.prevState,Tqt(t);for(let t of e){let e=G7.get(t);e&&(q7.current.push(t),wqt(e))}for(let t of e){let e=G7.get(t);if(e)for(let t of e)Eqt(t)}}}finally{J7=!1,q7.current=[],X7.clear()}}function Oqt(e){return typeof e==`function`}var kqt=class{constructor(e,t){this.listeners=new Set,this.subscribe=e=>{var t;this.listeners.add(e);let n=((t=this.options)?.onSubscribe)?.call(t,e,this);return()=>{this.listeners.delete(e),n?.()}},this.prevState=e,this.state=e,this.options=t}setState(e){var t,n;this.prevState=this.state,this.options?.updateFn?this.state=this.options.updateFn(this.prevState)(e):Oqt(e)?this.state=e(this.prevState):this.state=e,(n=(t=this.options)?.onUpdate)==null||n.call(t),Dqt(this)}},Aqt=class e{constructor(t){this.listeners=new Set,this._subscriptions=[],this.lastSeenDepValues=[],this.getDepVals=()=>{let e=this.options.deps.length,t=Array(e),n=Array(e);for(let r=0;r<e;r++){let e=this.options.deps[r];t[r]=e.prevState,n[r]=e.state}return this.lastSeenDepValues=n,{prevDepVals:t,currDepVals:n,prevVal:this.prevState??void 0}},this.recompute=()=>{var e,t;this.prevState=this.state;let n=this.getDepVals();this.state=this.options.fn(n),(t=(e=this.options).onUpdate)==null||t.call(e)},this.checkIfRecalculationNeededDeeply=()=>{for(let t of this.options.deps)t instanceof e&&t.checkIfRecalculationNeededDeeply();let t=!1,n=this.lastSeenDepValues,{currDepVals:r}=this.getDepVals();for(let e=0;e<r.length;e++)if(r[e]!==n[e]){t=!0;break}t&&this.recompute()},this.mount=()=>(this.registerOnGraph(),this.checkIfRecalculationNeededDeeply(),()=>{this.unregisterFromGraph();for(let e of this._subscriptions)e()}),this.subscribe=e=>{var t;this.listeners.add(e);let n=(t=this.options).onSubscribe?.call(t,e,this);return()=>{this.listeners.delete(e),n?.()}},this.options=t,this.state=t.fn({prevDepVals:void 0,prevVal:void 0,currDepVals:this.getDepVals().currDepVals})}registerOnGraph(t=this.options.deps){for(let n of t)if(n instanceof e)n.registerOnGraph(),this.registerOnGraph(n.options.deps);else if(n instanceof kqt){let e=G7.get(n);e||(e=new Set,G7.set(n,e)),e.add(this);let t=K7.get(this);t||(t=new Set,K7.set(this,t)),t.add(n)}}unregisterFromGraph(t=this.options.deps){for(let n of t)if(n instanceof e)this.unregisterFromGraph(n.options.deps);else if(n instanceof kqt){let e=G7.get(n);e&&e.delete(this);let t=K7.get(this);t&&t.delete(n)}}};({NewMessage:`new-message`}).NewMessage,Sqt.ready;var jqt=class extends Error{};jqt.prototype.name=`InvalidTokenError`;function Mqt(e,t){return function(){return e.apply(t,arguments)}}var{toString:Nqt}=Object.prototype,{getPrototypeOf:Z7}=Object,{iterator:Q7,toStringTag:Pqt}=Symbol,$7=(e=>t=>{let n=Nqt.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),e9=e=>(e=e.toLowerCase(),t=>$7(t)===e),t9=e=>t=>typeof t===e,{isArray:n9}=Array,r9=t9(`undefined`);function i9(e){return e!==null&&!r9(e)&&e.constructor!==null&&!r9(e.constructor)&&a9(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var Fqt=e9(`ArrayBuffer`);function Iqt(e){let t;return t=typeof ArrayBuffer<`u`&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&Fqt(e.buffer),t}var Lqt=t9(`string`),a9=t9(`function`),Rqt=t9(`number`),o9=e=>typeof e==`object`&&!!e,zqt=e=>e===!0||e===!1,s9=e=>{if($7(e)!==`object`)return!1;let t=Z7(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Pqt in e)&&!(Q7 in e)},Bqt=e=>{if(!o9(e)||i9(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Vqt=e9(`Date`),Hqt=e9(`File`),Uqt=e9(`Blob`),Wqt=e9(`FileList`),Gqt=e=>o9(e)&&a9(e.pipe),Kqt=e=>{let t;return e&&(typeof FormData==`function`&&e instanceof FormData||a9(e.append)&&((t=$7(e))===`formdata`||t===`object`&&a9(e.toString)&&e.toString()===`[object FormData]`))},qqt=e9(`URLSearchParams`),[Jqt,Yqt,Xqt,Zqt]=[`ReadableStream`,`Request`,`Response`,`Headers`].map(e9),Qqt=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,``);function c9(e,t,{allOwnKeys:n=!1}={}){if(e==null)return;let r,i;if(typeof e!=`object`&&(e=[e]),n9(e))for(r=0,i=e.length;r<i;r++)t.call(null,e[r],r,e);else{if(i9(e))return;let i=n?Object.getOwnPropertyNames(e):Object.keys(e),a=i.length,o;for(r=0;r<a;r++)o=i[r],t.call(null,e[o],o,e)}}function $qt(e,t){if(i9(e))return null;t=t.toLowerCase();let n=Object.keys(e),r=n.length,i;for(;r-- >0;)if(i=n[r],t===i.toLowerCase())return i;return null}var l9=typeof globalThis<`u`?globalThis:typeof self<`u`?self:typeof window<`u`?window:global,eJt=e=>!r9(e)&&e!==l9;function u9(){let{caseless:e,skipUndefined:t}=eJt(this)&&this||{},n={},r=(r,i)=>{if(i===`__proto__`||i===`constructor`||i===`prototype`)return;let a=e&&$qt(n,i)||i;s9(n[a])&&s9(r)?n[a]=u9(n[a],r):s9(r)?n[a]=u9({},r):n9(r)?n[a]=r.slice():(!t||!r9(r))&&(n[a]=r)};for(let e=0,t=arguments.length;e<t;e++)arguments[e]&&c9(arguments[e],r);return n}var tJt=(e,t,n,{allOwnKeys:r}={})=>(c9(t,(t,r)=>{n&&a9(t)?Object.defineProperty(e,r,{value:Mqt(t,n),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(e,r,{value:t,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:r}),e),nJt=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),rJt=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),Object.defineProperty(e.prototype,`constructor`,{value:e,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(e,`super`,{value:t.prototype}),n&&Object.assign(e.prototype,n)},iJt=(e,t,n,r)=>{let i,a,o,s={};if(t||={},e==null)return t;do{for(i=Object.getOwnPropertyNames(e),a=i.length;a-- >0;)o=i[a],(!r||r(o,e,t))&&!s[o]&&(t[o]=e[o],s[o]=!0);e=n!==!1&&Z7(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},aJt=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;let r=e.indexOf(t,n);return r!==-1&&r===n},oJt=e=>{if(!e)return null;if(n9(e))return e;let t=e.length;if(!Rqt(t))return null;let n=Array(t);for(;t-- >0;)n[t]=e[t];return n},sJt=(e=>t=>e&&t instanceof e)(typeof Uint8Array<`u`&&Z7(Uint8Array)),cJt=(e,t)=>{let n=(e&&e[Q7]).call(e),r;for(;(r=n.next())&&!r.done;){let n=r.value;t.call(e,n[0],n[1])}},lJt=(e,t)=>{let n,r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},uJt=e9(`HTMLFormElement`),dJt=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(e,t,n){return t.toUpperCase()+n}),fJt=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),pJt=e9(`RegExp`),mJt=(e,t)=>{let n=Object.getOwnPropertyDescriptors(e),r={};c9(n,(n,i)=>{let a;(a=t(n,i,e))!==!1&&(r[i]=a||n)}),Object.defineProperties(e,r)},hJt=e=>{mJt(e,(t,n)=>{if(a9(e)&&[`arguments`,`caller`,`callee`].indexOf(n)!==-1)return!1;let r=e[n];if(a9(r)){if(t.enumerable=!1,`writable`in t){t.writable=!1;return}t.set||=()=>{throw Error(`Can not rewrite read-only method '`+n+`'`)}}})},gJt=(e,t)=>{let n={},r=e=>{e.forEach(e=>{n[e]=!0})};return n9(e)?r(e):r(String(e).split(t)),n},_Jt=()=>{},vJt=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function yJt(e){return!!(e&&a9(e.append)&&e[Pqt]===`FormData`&&e[Q7])}var bJt=e=>{let t=Array(10),n=(e,r)=>{if(o9(e)){if(t.indexOf(e)>=0)return;if(i9(e))return e;if(!(`toJSON`in e)){t[r]=e;let i=n9(e)?[]:{};return c9(e,(e,t)=>{let a=n(e,r+1);!r9(a)&&(i[t]=a)}),t[r]=void 0,i}}return e};return n(e,0)},xJt=e9(`AsyncFunction`),SJt=e=>e&&(o9(e)||a9(e))&&a9(e.then)&&a9(e.catch),CJt=((e,t)=>e?setImmediate:t?((e,t)=>(l9.addEventListener(`message`,({source:n,data:r})=>{n===l9&&r===e&&t.length&&t.shift()()},!1),n=>{t.push(n),l9.postMessage(e,`*`)}))(`axios@${Math.random()}`,[]):e=>setTimeout(e))(typeof setImmediate==`function`,a9(l9.postMessage)),$={isArray:n9,isArrayBuffer:Fqt,isBuffer:i9,isFormData:Kqt,isArrayBufferView:Iqt,isString:Lqt,isNumber:Rqt,isBoolean:zqt,isObject:o9,isPlainObject:s9,isEmptyObject:Bqt,isReadableStream:Jqt,isRequest:Yqt,isResponse:Xqt,isHeaders:Zqt,isUndefined:r9,isDate:Vqt,isFile:Hqt,isBlob:Uqt,isRegExp:pJt,isFunction:a9,isStream:Gqt,isURLSearchParams:qqt,isTypedArray:sJt,isFileList:Wqt,forEach:c9,merge:u9,extend:tJt,trim:Qqt,stripBOM:nJt,inherits:rJt,toFlatObject:iJt,kindOf:$7,kindOfTest:e9,endsWith:aJt,toArray:oJt,forEachEntry:cJt,matchAll:lJt,isHTMLForm:uJt,hasOwnProperty:fJt,hasOwnProp:fJt,reduceDescriptors:mJt,freezeMethods:hJt,toObjectSet:gJt,toCamelCase:dJt,noop:_Jt,toFiniteNumber:vJt,findKey:$qt,global:l9,isContextDefined:eJt,isSpecCompliantForm:yJt,toJSONObject:bJt,isAsyncFn:xJt,isThenable:SJt,setImmediate:CJt,asap:typeof queueMicrotask<`u`?queueMicrotask.bind(l9):typeof process<`u`&&process.nextTick||CJt,isIterable:e=>e!=null&&a9(e[Q7])},d9=class e extends Error{static from(t,n,r,i,a,o){let s=new e(t.message,n||t.code,r,i,a);return s.cause=t,s.name=t.name,o&&Object.assign(s,o),s}constructor(e,t,n,r,i){super(e),this.name=`AxiosError`,this.isAxiosError=!0,t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),i&&(this.response=i,this.status=i.status)}toJSON(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:$.toJSONObject(this.config),code:this.code,status:this.status}}};d9.ERR_BAD_OPTION_VALUE=`ERR_BAD_OPTION_VALUE`,d9.ERR_BAD_OPTION=`ERR_BAD_OPTION`,d9.ECONNABORTED=`ECONNABORTED`,d9.ETIMEDOUT=`ETIMEDOUT`,d9.ERR_NETWORK=`ERR_NETWORK`,d9.ERR_FR_TOO_MANY_REDIRECTS=`ERR_FR_TOO_MANY_REDIRECTS`,d9.ERR_DEPRECATED=`ERR_DEPRECATED`,d9.ERR_BAD_RESPONSE=`ERR_BAD_RESPONSE`,d9.ERR_BAD_REQUEST=`ERR_BAD_REQUEST`,d9.ERR_CANCELED=`ERR_CANCELED`,d9.ERR_NOT_SUPPORT=`ERR_NOT_SUPPORT`,d9.ERR_INVALID_URL=`ERR_INVALID_URL`;function f9(e){return $.isPlainObject(e)||$.isArray(e)}function wJt(e){return $.endsWith(e,`[]`)?e.slice(0,-2):e}function TJt(e,t,n){return e?e.concat(t).map(function(e,t){return e=wJt(e),!n&&t?`[`+e+`]`:e}).join(n?`.`:``):t}function EJt(e){return $.isArray(e)&&!e.some(f9)}var DJt=$.toFlatObject($,{},null,function(e){return/^is[A-Z]/.test(e)});function p9(e,t,n){if(!$.isObject(e))throw TypeError(`target must be an object`);t||=new FormData,n=$.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(e,t){return!$.isUndefined(t[e])});let r=n.metaTokens,i=n.visitor||l,a=n.dots,o=n.indexes,s=(n.Blob||typeof Blob<`u`&&Blob)&&$.isSpecCompliantForm(t);if(!$.isFunction(i))throw TypeError(`visitor must be a function`);function c(e){if(e===null)return``;if($.isDate(e))return e.toISOString();if($.isBoolean(e))return e.toString();if(!s&&$.isBlob(e))throw new d9(`Blob is not supported. Use a Buffer instead.`);return $.isArrayBuffer(e)||$.isTypedArray(e)?s&&typeof Blob==`function`?new Blob([e]):Buffer.from(e):e}function l(e,n,i){let s=e;if(e&&!i&&typeof e==`object`){if($.endsWith(n,`{}`))n=r?n:n.slice(0,-2),e=JSON.stringify(e);else if($.isArray(e)&&EJt(e)||($.isFileList(e)||$.endsWith(n,`[]`))&&(s=$.toArray(e)))return n=wJt(n),s.forEach(function(e,r){!($.isUndefined(e)||e===null)&&t.append(o===!0?TJt([n],r,a):o===null?n:n+`[]`,c(e))}),!1}return f9(e)?!0:(t.append(TJt(i,n,a),c(e)),!1)}let u=[],d=Object.assign(DJt,{defaultVisitor:l,convertValue:c,isVisitable:f9});function f(e,n){if(!$.isUndefined(e)){if(u.indexOf(e)!==-1)throw Error(`Circular reference detected in `+n.join(`.`));u.push(e),$.forEach(e,function(e,r){(!($.isUndefined(e)||e===null)&&i.call(t,e,$.isString(r)?r.trim():r,n,d))===!0&&f(e,n?n.concat(r):[r])}),u.pop()}}if(!$.isObject(e))throw TypeError(`data must be an object`);return f(e),t}function OJt(e){let t={"!":`%21`,"'":`%27`,"(":`%28`,")":`%29`,"~":`%7E`,"%20":`+`,"%00":`\0`};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(e){return t[e]})}function m9(e,t){this._pairs=[],e&&p9(e,this,t)}var kJt=m9.prototype;kJt.append=function(e,t){this._pairs.push([e,t])},kJt.toString=function(e){let t=e?function(t){return e.call(this,t,OJt)}:OJt;return this._pairs.map(function(e){return t(e[0])+`=`+t(e[1])},``).join(`&`)};function AJt(e){return encodeURIComponent(e).replace(/%3A/gi,`:`).replace(/%24/g,`$`).replace(/%2C/gi,`,`).replace(/%20/g,`+`)}function jJt(e,t,n){if(!t)return e;let r=n&&n.encode||AJt,i=$.isFunction(n)?{serialize:n}:n,a=i&&i.serialize,o;if(o=a?a(t,i):$.isURLSearchParams(t)?t.toString():new m9(t,i).toString(r),o){let t=e.indexOf(`#`);t!==-1&&(e=e.slice(0,t)),e+=(e.indexOf(`?`)===-1?`?`:`&`)+o}return e}var MJt=class{constructor(){this.handlers=[]}use(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&=[]}forEach(e){$.forEach(this.handlers,function(t){t!==null&&e(t)})}},h9={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},NJt={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<`u`?URLSearchParams:m9,FormData:typeof FormData<`u`?FormData:null,Blob:typeof Blob<`u`?Blob:null},protocols:[`http`,`https`,`file`,`blob`,`url`,`data`]},PJt=i({hasBrowserEnv:()=>g9,hasStandardBrowserEnv:()=>FJt,hasStandardBrowserWebWorkerEnv:()=>IJt,navigator:()=>_9,origin:()=>LJt}),g9=typeof window<`u`&&typeof document<`u`,_9=typeof navigator==`object`&&navigator||void 0,FJt=g9&&(!_9||[`ReactNative`,`NativeScript`,`NS`].indexOf(_9.product)<0),IJt=typeof WorkerGlobalScope<`u`&&self instanceof WorkerGlobalScope&&typeof self.importScripts==`function`,LJt=g9&&window.location.href||`http://localhost`,v9={...PJt,...NJt};function RJt(e,t){return p9(e,new v9.classes.URLSearchParams,{visitor:function(e,t,n,r){return v9.isNode&&$.isBuffer(e)?(this.append(t,e.toString(`base64`)),!1):r.defaultVisitor.apply(this,arguments)},...t})}function zJt(e){return $.matchAll(/\w+|\[(\w*)]/g,e).map(e=>e[0]===`[]`?``:e[1]||e[0])}function BJt(e){let t={},n=Object.keys(e),r,i=n.length,a;for(r=0;r<i;r++)a=n[r],t[a]=e[a];return t}function VJt(e){function t(e,n,r,i){let a=e[i++];if(a===`__proto__`)return!0;let o=Number.isFinite(+a),s=i>=e.length;return a=!a&&$.isArray(r)?r.length:a,s?($.hasOwnProp(r,a)?r[a]=[r[a],n]:r[a]=n,!o):((!r[a]||!$.isObject(r[a]))&&(r[a]=[]),t(e,n,r[a],i)&&$.isArray(r[a])&&(r[a]=BJt(r[a])),!o)}if($.isFormData(e)&&$.isFunction(e.entries)){let n={};return $.forEachEntry(e,(e,r)=>{t(zJt(e),r,n,0)}),n}return null}function HJt(e,t,n){if($.isString(e))try{return(t||JSON.parse)(e),$.trim(e)}catch(e){if(e.name!==`SyntaxError`)throw e}return(n||JSON.stringify)(e)}var y9={transitional:h9,adapter:[`xhr`,`http`,`fetch`],transformRequest:[function(e,t){let n=t.getContentType()||``,r=n.indexOf(`application/json`)>-1,i=$.isObject(e);if(i&&$.isHTMLForm(e)&&(e=new FormData(e)),$.isFormData(e))return r?JSON.stringify(VJt(e)):e;if($.isArrayBuffer(e)||$.isBuffer(e)||$.isStream(e)||$.isFile(e)||$.isBlob(e)||$.isReadableStream(e))return e;if($.isArrayBufferView(e))return e.buffer;if($.isURLSearchParams(e))return t.setContentType(`application/x-www-form-urlencoded;charset=utf-8`,!1),e.toString();let a;if(i){if(n.indexOf(`application/x-www-form-urlencoded`)>-1)return RJt(e,this.formSerializer).toString();if((a=$.isFileList(e))||n.indexOf(`multipart/form-data`)>-1){let t=this.env&&this.env.FormData;return p9(a?{"files[]":e}:e,t&&new t,this.formSerializer)}}return i||r?(t.setContentType(`application/json`,!1),HJt(e)):e}],transformResponse:[function(e){let t=this.transitional||y9.transitional,n=t&&t.forcedJSONParsing,r=this.responseType===`json`;if($.isResponse(e)||$.isReadableStream(e))return e;if(e&&$.isString(e)&&(n&&!this.responseType||r)){let n=!(t&&t.silentJSONParsing)&&r;try{return JSON.parse(e,this.parseReviver)}catch(e){if(n)throw e.name===`SyntaxError`?d9.from(e,d9.ERR_BAD_RESPONSE,this,null,this.response):e}}return e}],timeout:0,xsrfCookieName:`XSRF-TOKEN`,xsrfHeaderName:`X-XSRF-TOKEN`,maxContentLength:-1,maxBodyLength:-1,env:{FormData:v9.classes.FormData,Blob:v9.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:`application/json, text/plain, */*`,"Content-Type":void 0}}};$.forEach([`delete`,`get`,`head`,`post`,`put`,`patch`],e=>{y9.headers[e]={}});var UJt=$.toObjectSet([`age`,`authorization`,`content-length`,`content-type`,`etag`,`expires`,`from`,`host`,`if-modified-since`,`if-unmodified-since`,`last-modified`,`location`,`max-forwards`,`proxy-authorization`,`referer`,`retry-after`,`user-agent`]),WJt=e=>{let t={},n,r,i;return e&&e.split(`
1583
1583
  `).forEach(function(e){i=e.indexOf(`:`),n=e.substring(0,i).trim().toLowerCase(),r=e.substring(i+1).trim(),!(!n||t[n]&&UJt[n])&&(n===`set-cookie`?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+`, `+r:r)}),t},GJt=Symbol(`internals`);function b9(e){return e&&String(e).trim().toLowerCase()}function x9(e){return e===!1||e==null?e:$.isArray(e)?e.map(x9):String(e)}function KJt(e){let t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g,r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}var qJt=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function S9(e,t,n,r,i){if($.isFunction(r))return r.call(this,t,n);if(i&&(t=n),$.isString(t)){if($.isString(r))return t.indexOf(r)!==-1;if($.isRegExp(r))return r.test(t)}}function JJt(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,n)=>t.toUpperCase()+n)}function YJt(e,t){let n=$.toCamelCase(` `+t);[`get`,`set`,`has`].forEach(r=>{Object.defineProperty(e,r+n,{value:function(e,n,i){return this[r].call(this,t,e,n,i)},configurable:!0})})}var C9=class{constructor(e){e&&this.set(e)}set(e,t,n){let r=this;function i(e,t,n){let i=b9(t);if(!i)throw Error(`header name must be a non-empty string`);let a=$.findKey(r,i);(!a||r[a]===void 0||n===!0||n===void 0&&r[a]!==!1)&&(r[a||t]=x9(e))}let a=(e,t)=>$.forEach(e,(e,n)=>i(e,n,t));if($.isPlainObject(e)||e instanceof this.constructor)a(e,t);else if($.isString(e)&&(e=e.trim())&&!qJt(e))a(WJt(e),t);else if($.isObject(e)&&$.isIterable(e)){let n={},r,i;for(let t of e){if(!$.isArray(t))throw TypeError(`Object iterator must return a key-value pair`);n[i=t[0]]=(r=n[i])?$.isArray(r)?[...r,t[1]]:[r,t[1]]:t[1]}a(n,t)}else e!=null&&i(t,e,n);return this}get(e,t){if(e=b9(e),e){let n=$.findKey(this,e);if(n){let e=this[n];if(!t)return e;if(t===!0)return KJt(e);if($.isFunction(t))return t.call(this,e,n);if($.isRegExp(t))return t.exec(e);throw TypeError(`parser must be boolean|regexp|function`)}}}has(e,t){if(e=b9(e),e){let n=$.findKey(this,e);return!!(n&&this[n]!==void 0&&(!t||S9(this,this[n],n,t)))}return!1}delete(e,t){let n=this,r=!1;function i(e){if(e=b9(e),e){let i=$.findKey(n,e);i&&(!t||S9(n,n[i],i,t))&&(delete n[i],r=!0)}}return $.isArray(e)?e.forEach(i):i(e),r}clear(e){let t=Object.keys(this),n=t.length,r=!1;for(;n--;){let i=t[n];(!e||S9(this,this[i],i,e,!0))&&(delete this[i],r=!0)}return r}normalize(e){let t=this,n={};return $.forEach(this,(r,i)=>{let a=$.findKey(n,i);if(a){t[a]=x9(r),delete t[i];return}let o=e?JJt(i):String(i).trim();o!==i&&delete t[i],t[o]=x9(r),n[o]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){let t=Object.create(null);return $.forEach(this,(n,r)=>{n!=null&&n!==!1&&(t[r]=e&&$.isArray(n)?n.join(`, `):n)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+`: `+t).join(`
1584
1584
  `)}getSetCookie(){return this.get(`set-cookie`)||[]}get[Symbol.toStringTag](){return`AxiosHeaders`}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){let n=new this(e);return t.forEach(e=>n.set(e)),n}static accessor(e){let t=(this[GJt]=this[GJt]={accessors:{}}).accessors,n=this.prototype;function r(e){let r=b9(e);t[r]||(YJt(n,e),t[r]=!0)}return $.isArray(e)?e.forEach(r):r(e),this}};C9.accessor([`Content-Type`,`Content-Length`,`Accept`,`Accept-Encoding`,`User-Agent`,`Authorization`]),$.reduceDescriptors(C9.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[n]=e}}}),$.freezeMethods(C9);function w9(e,t){let n=this||y9,r=t||n,i=C9.from(r.headers),a=r.data;return $.forEach(e,function(e){a=e.call(n,a,i.normalize(),t?t.status:void 0)}),i.normalize(),a}function XJt(e){return!!(e&&e.__CANCEL__)}var T9=class extends d9{constructor(e,t,n){super(e??`canceled`,d9.ERR_CANCELED,t,n),this.name=`CanceledError`,this.__CANCEL__=!0}};function ZJt(e,t,n){let r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new d9(`Request failed with status code `+n.status,[d9.ERR_BAD_REQUEST,d9.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function QJt(e){let t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||``}function $Jt(e,t){e||=10;let n=Array(e),r=Array(e),i=0,a=0,o;return t=t===void 0?1e3:t,function(s){let c=Date.now(),l=r[a];o||=c,n[i]=s,r[i]=c;let u=a,d=0;for(;u!==i;)d+=n[u++],u%=e;if(i=(i+1)%e,i===a&&(a=(a+1)%e),c-o<t)return;let f=l&&c-l;return f?Math.round(d*1e3/f):void 0}}function eYt(e,t){let n=0,r=1e3/t,i,a,o=(t,r=Date.now())=>{n=r,i=null,a&&=(clearTimeout(a),null),e(...t)};return[(...e)=>{let t=Date.now(),s=t-n;s>=r?o(e,t):(i=e,a||=setTimeout(()=>{a=null,o(i)},r-s))},()=>i&&o(i)]}var E9=(e,t,n=3)=>{let r=0,i=$Jt(50,250);return eYt(n=>{let a=n.loaded,o=n.lengthComputable?n.total:void 0,s=a-r,c=i(s),l=a<=o;r=a,e({loaded:a,total:o,progress:o?a/o:void 0,bytes:s,rate:c||void 0,estimated:c&&o&&l?(o-a)/c:void 0,event:n,lengthComputable:o!=null,[t?`download`:`upload`]:!0})},n)},tYt=(e,t)=>{let n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},nYt=e=>(...t)=>$.asap(()=>e(...t)),rYt=v9.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,v9.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(v9.origin),v9.navigator&&/(msie|trident)/i.test(v9.navigator.userAgent)):()=>!0,iYt=v9.hasStandardBrowserEnv?{write(e,t,n,r,i,a,o){if(typeof document>`u`)return;let s=[`${e}=${encodeURIComponent(t)}`];$.isNumber(n)&&s.push(`expires=${new Date(n).toUTCString()}`),$.isString(r)&&s.push(`path=${r}`),$.isString(i)&&s.push(`domain=${i}`),a===!0&&s.push(`secure`),$.isString(o)&&s.push(`SameSite=${o}`),document.cookie=s.join(`; `)},read(e){if(typeof document>`u`)return null;let t=document.cookie.match(RegExp(`(?:^|; )`+e+`=([^;]*)`));return t?decodeURIComponent(t[1]):null},remove(e){this.write(e,``,Date.now()-864e5,`/`)}}:{write(){},read(){return null},remove(){}};function aYt(e){return typeof e==`string`?/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e):!1}function oYt(e,t){return t?e.replace(/\/?\/$/,``)+`/`+t.replace(/^\/+/,``):e}function sYt(e,t,n){let r=!aYt(t);return e&&(r||n==0)?oYt(e,t):t}var cYt=e=>e instanceof C9?{...e}:e;function D9(e,t){t||={};let n={};function r(e,t,n,r){return $.isPlainObject(e)&&$.isPlainObject(t)?$.merge.call({caseless:r},e,t):$.isPlainObject(t)?$.merge({},t):$.isArray(t)?t.slice():t}function i(e,t,n,i){if(!$.isUndefined(t))return r(e,t,n,i);if(!$.isUndefined(e))return r(void 0,e,n,i)}function a(e,t){if(!$.isUndefined(t))return r(void 0,t)}function o(e,t){if(!$.isUndefined(t))return r(void 0,t);if(!$.isUndefined(e))return r(void 0,e)}function s(n,i,a){if(a in t)return r(n,i);if(a in e)return r(void 0,n)}let c={url:a,method:a,data:a,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:s,headers:(e,t,n)=>i(cYt(e),cYt(t),n,!0)};return $.forEach(Object.keys({...e,...t}),function(r){if(r===`__proto__`||r===`constructor`||r===`prototype`)return;let a=$.hasOwnProp(c,r)?c[r]:i,o=a(e[r],t[r],r);$.isUndefined(o)&&a!==s||(n[r]=o)}),n}var lYt=e=>{let t=D9({},e),{data:n,withXSRFToken:r,xsrfHeaderName:i,xsrfCookieName:a,headers:o,auth:s}=t;if(t.headers=o=C9.from(o),t.url=jJt(sYt(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),s&&o.set(`Authorization`,`Basic `+btoa((s.username||``)+`:`+(s.password?unescape(encodeURIComponent(s.password)):``))),$.isFormData(n)){if(v9.hasStandardBrowserEnv||v9.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if($.isFunction(n.getHeaders)){let e=n.getHeaders(),t=[`content-type`,`content-length`];Object.entries(e).forEach(([e,n])=>{t.includes(e.toLowerCase())&&o.set(e,n)})}}if(v9.hasStandardBrowserEnv&&(r&&$.isFunction(r)&&(r=r(t)),r||r!==!1&&rYt(t.url))){let e=i&&a&&iYt.read(a);e&&o.set(i,e)}return t},uYt=typeof XMLHttpRequest<`u`&&function(e){return new Promise(function(t,n){let r=lYt(e),i=r.data,a=C9.from(r.headers).normalize(),{responseType:o,onUploadProgress:s,onDownloadProgress:c}=r,l,u,d,f,p;function m(){f&&f(),p&&p(),r.cancelToken&&r.cancelToken.unsubscribe(l),r.signal&&r.signal.removeEventListener(`abort`,l)}let h=new XMLHttpRequest;h.open(r.method.toUpperCase(),r.url,!0),h.timeout=r.timeout;function g(){if(!h)return;let r=C9.from(`getAllResponseHeaders`in h&&h.getAllResponseHeaders());ZJt(function(e){t(e),m()},function(e){n(e),m()},{data:!o||o===`text`||o===`json`?h.responseText:h.response,status:h.status,statusText:h.statusText,headers:r,config:e,request:h}),h=null}`onloadend`in h?h.onloadend=g:h.onreadystatechange=function(){!h||h.readyState!==4||h.status===0&&!(h.responseURL&&h.responseURL.indexOf(`file:`)===0)||setTimeout(g)},h.onabort=function(){h&&=(n(new d9(`Request aborted`,d9.ECONNABORTED,e,h)),null)},h.onerror=function(t){let r=new d9(t&&t.message?t.message:`Network Error`,d9.ERR_NETWORK,e,h);r.event=t||null,n(r),h=null},h.ontimeout=function(){let t=r.timeout?`timeout of `+r.timeout+`ms exceeded`:`timeout exceeded`,i=r.transitional||h9;r.timeoutErrorMessage&&(t=r.timeoutErrorMessage),n(new d9(t,i.clarifyTimeoutError?d9.ETIMEDOUT:d9.ECONNABORTED,e,h)),h=null},i===void 0&&a.setContentType(null),`setRequestHeader`in h&&$.forEach(a.toJSON(),function(e,t){h.setRequestHeader(t,e)}),$.isUndefined(r.withCredentials)||(h.withCredentials=!!r.withCredentials),o&&o!==`json`&&(h.responseType=r.responseType),c&&([d,p]=E9(c,!0),h.addEventListener(`progress`,d)),s&&h.upload&&([u,f]=E9(s),h.upload.addEventListener(`progress`,u),h.upload.addEventListener(`loadend`,f)),(r.cancelToken||r.signal)&&(l=t=>{h&&=(n(!t||t.type?new T9(null,e,h):t),h.abort(),null)},r.cancelToken&&r.cancelToken.subscribe(l),r.signal&&(r.signal.aborted?l():r.signal.addEventListener(`abort`,l)));let _=QJt(r.url);if(_&&v9.protocols.indexOf(_)===-1){n(new d9(`Unsupported protocol `+_+`:`,d9.ERR_BAD_REQUEST,e));return}h.send(i||null)})},dYt=(e,t)=>{let{length:n}=e=e?e.filter(Boolean):[];if(t||n){let n=new AbortController,r,i=function(e){if(!r){r=!0,o();let t=e instanceof Error?e:this.reason;n.abort(t instanceof d9?t:new T9(t instanceof Error?t.message:t))}},a=t&&setTimeout(()=>{a=null,i(new d9(`timeout of ${t}ms exceeded`,d9.ETIMEDOUT))},t),o=()=>{e&&=(a&&clearTimeout(a),a=null,e.forEach(e=>{e.unsubscribe?e.unsubscribe(i):e.removeEventListener(`abort`,i)}),null)};e.forEach(e=>e.addEventListener(`abort`,i));let{signal:s}=n;return s.unsubscribe=()=>$.asap(o),s}},fYt=function*(e,t){let n=e.byteLength;if(!t||n<t){yield e;return}let r=0,i;for(;r<n;)i=r+t,yield e.slice(r,i),r=i},pYt=async function*(e,t){for await(let n of mYt(e))yield*fYt(n,t)},mYt=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}let t=e.getReader();try{for(;;){let{done:e,value:n}=await t.read();if(e)break;yield n}}finally{await t.cancel()}},hYt=(e,t,n,r)=>{let i=pYt(e,t),a=0,o,s=e=>{o||(o=!0,r&&r(e))};return new ReadableStream({async pull(e){try{let{done:t,value:r}=await i.next();if(t){s(),e.close();return}let o=r.byteLength;n&&n(a+=o),e.enqueue(new Uint8Array(r))}catch(e){throw s(e),e}},cancel(e){return s(e),i.return()}},{highWaterMark:2})},gYt=64*1024,{isFunction:O9}=$,_Yt=(({Request:e,Response:t})=>({Request:e,Response:t}))($.global),{ReadableStream:vYt,TextEncoder:yYt}=$.global,bYt=(e,...t)=>{try{return!!e(...t)}catch{return!1}},xYt=e=>{e=$.merge.call({skipUndefined:!0},_Yt,e);let{fetch:t,Request:n,Response:r}=e,i=t?O9(t):typeof fetch==`function`,a=O9(n),o=O9(r);if(!i)return!1;let s=i&&O9(vYt),c=i&&(typeof yYt==`function`?(e=>t=>e.encode(t))(new yYt):async e=>new Uint8Array(await new n(e).arrayBuffer())),l=a&&s&&bYt(()=>{let e=!1,t=new n(v9.origin,{body:new vYt,method:`POST`,get duplex(){return e=!0,`half`}}).headers.has(`Content-Type`);return e&&!t}),u=o&&s&&bYt(()=>$.isReadableStream(new r(``).body)),d={stream:u&&(e=>e.body)};i&&[`text`,`arrayBuffer`,`blob`,`formData`,`stream`].forEach(e=>{!d[e]&&(d[e]=(t,n)=>{let r=t&&t[e];if(r)return r.call(t);throw new d9(`Response type '${e}' is not supported`,d9.ERR_NOT_SUPPORT,n)})});let f=async e=>{if(e==null)return 0;if($.isBlob(e))return e.size;if($.isSpecCompliantForm(e))return(await new n(v9.origin,{method:`POST`,body:e}).arrayBuffer()).byteLength;if($.isArrayBufferView(e)||$.isArrayBuffer(e))return e.byteLength;if($.isURLSearchParams(e)&&(e+=``),$.isString(e))return(await c(e)).byteLength},p=async(e,t)=>$.toFiniteNumber(e.getContentLength())??f(t);return async e=>{let{url:i,method:o,data:s,signal:c,cancelToken:f,timeout:m,onDownloadProgress:h,onUploadProgress:g,responseType:_,headers:v,withCredentials:y=`same-origin`,fetchOptions:b}=lYt(e),x=t||fetch;_=_?(_+``).toLowerCase():`text`;let S=dYt([c,f&&f.toAbortSignal()],m),C=null,w=S&&S.unsubscribe&&(()=>{S.unsubscribe()}),T;try{if(g&&l&&o!==`get`&&o!==`head`&&(T=await p(v,s))!==0){let e=new n(i,{method:`POST`,body:s,duplex:`half`}),t;if($.isFormData(s)&&(t=e.headers.get(`content-type`))&&v.setContentType(t),e.body){let[t,n]=tYt(T,E9(nYt(g)));s=hYt(e.body,gYt,t,n)}}$.isString(y)||(y=y?`include`:`omit`);let t=a&&`credentials`in n.prototype,c={...b,signal:S,method:o.toUpperCase(),headers:v.normalize().toJSON(),body:s,duplex:`half`,credentials:t?y:void 0};C=a&&new n(i,c);let f=await(a?x(C,b):x(i,c)),m=u&&(_===`stream`||_===`response`);if(u&&(h||m&&w)){let e={};[`status`,`statusText`,`headers`].forEach(t=>{e[t]=f[t]});let t=$.toFiniteNumber(f.headers.get(`content-length`)),[n,i]=h&&tYt(t,E9(nYt(h),!0))||[];f=new r(hYt(f.body,gYt,n,()=>{i&&i(),w&&w()}),e)}_||=`text`;let E=await d[$.findKey(d,_)||`text`](f,e);return!m&&w&&w(),await new Promise((t,n)=>{ZJt(t,n,{data:E,headers:C9.from(f.headers),status:f.status,statusText:f.statusText,config:e,request:C})})}catch(t){throw w&&w(),t&&t.name===`TypeError`&&/Load failed|fetch/i.test(t.message)?Object.assign(new d9(`Network Error`,d9.ERR_NETWORK,e,C,t&&t.response),{cause:t.cause||t}):d9.from(t,t&&t.code,e,C,t&&t.response)}}},SYt=new Map,CYt=e=>{let t=e&&e.env||{},{fetch:n,Request:r,Response:i}=t,a=[r,i,n],o=a.length,s,c,l=SYt;for(;o--;)s=a[o],c=l.get(s),c===void 0&&l.set(s,c=o?new Map:xYt(t)),l=c;return c};CYt();var k9={http:null,xhr:uYt,fetch:{get:CYt}};$.forEach(k9,(e,t)=>{if(e){try{Object.defineProperty(e,`name`,{value:t})}catch{}Object.defineProperty(e,`adapterName`,{value:t})}});var wYt=e=>`- ${e}`,TYt=e=>$.isFunction(e)||e===null||e===!1;function EYt(e,t){e=$.isArray(e)?e:[e];let{length:n}=e,r,i,a={};for(let o=0;o<n;o++){r=e[o];let n;if(i=r,!TYt(r)&&(i=k9[(n=String(r)).toLowerCase()],i===void 0))throw new d9(`Unknown adapter '${n}'`);if(i&&($.isFunction(i)||(i=i.get(t))))break;a[n||`#`+o]=i}if(!i){let e=Object.entries(a).map(([e,t])=>`adapter ${e} `+(t===!1?`is not supported by the environment`:`is not available in the build`));throw new d9(`There is no suitable adapter to dispatch the request `+(n?e.length>1?`since :
1585
1585
  `+e.map(wYt).join(`