diff --git a/jhub_apps/static/js/index.js b/jhub_apps/static/js/index.js index e676be23..3c415ad7 100644 --- a/jhub_apps/static/js/index.js +++ b/jhub_apps/static/js/index.js @@ -188,8 +188,8 @@ Error generating stack: `+s.message+` `)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(o=>r.set(o)),r}static accessor(t){const r=(this[c1]=this[c1]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=Nl(i);r[a]||(AQ(o,i),r[a]=!0)}return $.isArray(t)?t.forEach(s):s(t),this}}kv.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);$.reduceDescriptors(kv.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}});$.freezeMethods(kv);const _r=kv;function Eh(e,t){const n=this||_g,r=t||n,o=_r.from(r.headers);let s=r.data;return $.forEach(e,function(a){s=a.call(n,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function _5(e){return!!(e&&e.__CANCEL__)}function vl(e,t,n){Ke.call(this,e??"canceled",Ke.ERR_CANCELED,t,n),this.name="CanceledError"}$.inherits(vl,Ke,{__CANCEL__:!0});function $5(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new Ke("Request failed with status code "+n.status,[Ke.ERR_BAD_REQUEST,Ke.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function PQ(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function gQ(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o=0,s=0,i;return t=t!==void 0?t:1e3,function(l){const c=Date.now(),u=r[s];i||(i=c),n[o]=l,r[o]=c;let d=s,p=0;for(;d!==o;)p+=n[d++],d=d%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),c-ir)return o&&(clearTimeout(o),o=null),n=a,e.apply(null,arguments);o||(o=setTimeout(()=>(o=null,n=Date.now(),e.apply(null,arguments)),r-(a-n)))}}const Cd=(e,t,n=3)=>{let r=0;const o=gQ(50,250);return yQ(s=>{const i=s.loaded,a=s.lengthComputable?s.total:void 0,l=i-r,c=o(l),u=i<=a;r=i;const d={loaded:i,total:a,progress:a?i/a:void 0,bytes:l,rate:c||void 0,estimated:c&&a&&u?(a-i)/c:void 0,event:s,lengthComputable:a!=null};d[t?"download":"upload"]=!0,e(d)},n)},bQ=Kr.hasStandardBrowserEnv?function(){const t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");let r;function o(s){let i=s;return t&&(n.setAttribute("href",i),i=n.href),n.setAttribute("href",i),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:n.pathname.charAt(0)==="/"?n.pathname:"/"+n.pathname}}return r=o(window.location.href),function(i){const a=$.isString(i)?o(i):i;return a.protocol===r.protocol&&a.host===r.host}}():function(){return function(){return!0}}(),xQ=Kr.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];$.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),$.isString(r)&&i.push("path="+r),$.isString(o)&&i.push("domain="+o),s===!0&&i.push("secure"),document.cookie=i.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function wQ(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function HQ(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function e3(e,t){return e&&!wQ(t)?HQ(e,t):t}const u1=e=>e instanceof _r?{...e}:e;function Si(e,t){t=t||{};const n={};function r(c,u,d){return $.isPlainObject(c)&&$.isPlainObject(u)?$.merge.call({caseless:d},c,u):$.isPlainObject(u)?$.merge({},u):$.isArray(u)?u.slice():u}function o(c,u,d){if($.isUndefined(u)){if(!$.isUndefined(c))return r(void 0,c,d)}else return r(c,u,d)}function s(c,u){if(!$.isUndefined(u))return r(void 0,u)}function i(c,u){if($.isUndefined(u)){if(!$.isUndefined(c))return r(void 0,c)}else return r(void 0,u)}function a(c,u,d){if(d in t)return r(c,u);if(d in e)return r(void 0,c)}const l={url:s,method:s,data:s,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:a,headers:(c,u)=>o(u1(c),u1(u),!0)};return $.forEach(Object.keys(Object.assign({},e,t)),function(u){const d=l[u]||o,p=d(e[u],t[u],u);$.isUndefined(p)&&d!==a||(n[u]=p)}),n}const t3=e=>{const t=Si({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;t.headers=i=_r.from(i),t.url=U5(e3(t.baseURL,t.url),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):"")));let l;if($.isFormData(n)){if(Kr.hasStandardBrowserEnv||Kr.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if((l=i.getContentType())!==!1){const[c,...u]=l?l.split(";").map(d=>d.trim()).filter(Boolean):[];i.setContentType([c||"multipart/form-data",...u].join("; "))}}if(Kr.hasStandardBrowserEnv&&(r&&$.isFunction(r)&&(r=r(t)),r||r!==!1&&bQ(t.url))){const c=o&&s&&xQ.read(s);c&&i.set(o,c)}return t},jQ=typeof XMLHttpRequest<"u",zQ=jQ&&function(e){return new Promise(function(n,r){const o=t3(e);let s=o.data;const i=_r.from(o.headers).normalize();let{responseType:a}=o,l;function c(){o.cancelToken&&o.cancelToken.unsubscribe(l),o.signal&&o.signal.removeEventListener("abort",l)}let u=new XMLHttpRequest;u.open(o.method.toUpperCase(),o.url,!0),u.timeout=o.timeout;function d(){if(!u)return;const y=_r.from("getAllResponseHeaders"in u&&u.getAllResponseHeaders()),A={data:!a||a==="text"||a==="json"?u.responseText:u.response,status:u.status,statusText:u.statusText,headers:y,config:e,request:u};$5(function(m){n(m),c()},function(m){r(m),c()},A),u=null}"onloadend"in u?u.onloadend=d:u.onreadystatechange=function(){!u||u.readyState!==4||u.status===0&&!(u.responseURL&&u.responseURL.indexOf("file:")===0)||setTimeout(d)},u.onabort=function(){u&&(r(new Ke("Request aborted",Ke.ECONNABORTED,o,u)),u=null)},u.onerror=function(){r(new Ke("Network Error",Ke.ERR_NETWORK,o,u)),u=null},u.ontimeout=function(){let h=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const A=o.transitional||Q5;o.timeoutErrorMessage&&(h=o.timeoutErrorMessage),r(new Ke(h,A.clarifyTimeoutError?Ke.ETIMEDOUT:Ke.ECONNABORTED,o,u)),u=null},s===void 0&&i.setContentType(null),"setRequestHeader"in u&&$.forEach(i.toJSON(),function(h,A){u.setRequestHeader(A,h)}),$.isUndefined(o.withCredentials)||(u.withCredentials=!!o.withCredentials),a&&a!=="json"&&(u.responseType=o.responseType),typeof o.onDownloadProgress=="function"&&u.addEventListener("progress",Cd(o.onDownloadProgress,!0)),typeof o.onUploadProgress=="function"&&u.upload&&u.upload.addEventListener("progress",Cd(o.onUploadProgress)),(o.cancelToken||o.signal)&&(l=y=>{u&&(r(!y||y.type?new vl(null,e,u):y),u.abort(),u=null)},o.cancelToken&&o.cancelToken.subscribe(l),o.signal&&(o.signal.aborted?l():o.signal.addEventListener("abort",l)));const p=PQ(o.url);if(p&&Kr.protocols.indexOf(p)===-1){r(new Ke("Unsupported protocol "+p+":",Ke.ERR_BAD_REQUEST,e));return}u.send(s||null)})},OQ=(e,t)=>{let n=new AbortController,r;const o=function(l){if(!r){r=!0,i();const c=l instanceof Error?l:this.reason;n.abort(c instanceof Ke?c:new vl(c instanceof Error?c.message:c))}};let s=t&&setTimeout(()=>{o(new Ke(`timeout ${t} of ms exceeded`,Ke.ETIMEDOUT))},t);const i=()=>{e&&(s&&clearTimeout(s),s=null,e.forEach(l=>{l&&(l.removeEventListener?l.removeEventListener("abort",o):l.unsubscribe(o))}),e=null)};e.forEach(l=>l&&l.addEventListener&&l.addEventListener("abort",o));const{signal:a}=n;return a.unsubscribe=i,[a,()=>{s&&clearTimeout(s),s=null}]},CQ=function*(e,t){let n=e.byteLength;if(!t||n{const s=DQ(e,t,o);let i=0;return new ReadableStream({type:"bytes",async pull(a){const{done:l,value:c}=await s.next();if(l){a.close(),r();return}let u=c.byteLength;n&&n(i+=u),a.enqueue(new Uint8Array(c))},cancel(a){return r(a),s.return()}},{highWaterMark:2})},d1=(e,t)=>{const n=e!=null;return r=>setTimeout(()=>t({lengthComputable:n,total:e,loaded:r}))},Ev=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",n3=Ev&&typeof ReadableStream=="function",jA=Ev&&(typeof TextEncoder=="function"?(e=>t=>e.encode(t))(new TextEncoder):async e=>new Uint8Array(await new Response(e).arrayBuffer())),SQ=n3&&(()=>{let e=!1;const t=new Request(Kr.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t})(),p1=64*1024,zA=n3&&!!(()=>{try{return $.isReadableStream(new Response("").body)}catch{}})(),Dd={stream:zA&&(e=>e.body)};Ev&&(e=>{["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!Dd[t]&&(Dd[t]=$.isFunction(e[t])?n=>n[t]():(n,r)=>{throw new Ke(`Response type '${t}' is not supported`,Ke.ERR_NOT_SUPPORT,r)})})})(new Response);const TQ=async e=>{if(e==null)return 0;if($.isBlob(e))return e.size;if($.isSpecCompliantForm(e))return(await new Request(e).arrayBuffer()).byteLength;if($.isArrayBufferView(e))return e.byteLength;if($.isURLSearchParams(e)&&(e=e+""),$.isString(e))return(await jA(e)).byteLength},RQ=async(e,t)=>{const n=$.toFiniteNumber(e.getContentLength());return n??TQ(t)},kQ=Ev&&(async e=>{let{url:t,method:n,data:r,signal:o,cancelToken:s,timeout:i,onDownloadProgress:a,onUploadProgress:l,responseType:c,headers:u,withCredentials:d="same-origin",fetchOptions:p}=t3(e);c=c?(c+"").toLowerCase():"text";let[y,h]=o||s||i?OQ([o,s],i):[],A,w;const m=()=>{!A&&setTimeout(()=>{y&&y.unsubscribe()}),A=!0};let v;try{if(l&&SQ&&n!=="get"&&n!=="head"&&(v=await RQ(u,r))!==0){let z=new Request(t,{method:"POST",body:r,duplex:"half"}),H;$.isFormData(r)&&(H=z.headers.get("content-type"))&&u.setContentType(H),z.body&&(r=f1(z.body,p1,d1(v,Cd(l)),null,jA))}$.isString(d)||(d=d?"cors":"omit"),w=new Request(t,{...p,signal:y,method:n.toUpperCase(),headers:u.normalize().toJSON(),body:r,duplex:"half",withCredentials:d});let P=await fetch(w);const x=zA&&(c==="stream"||c==="response");if(zA&&(a||x)){const z={};["status","statusText","headers"].forEach(O=>{z[O]=P[O]});const H=$.toFiniteNumber(P.headers.get("content-length"));P=new Response(f1(P.body,p1,a&&d1(H,Cd(a,!0)),x&&m,jA),z)}c=c||"text";let j=await Dd[$.findKey(Dd,c)||"text"](P,e);return!x&&m(),h&&h(),await new Promise((z,H)=>{$5(z,H,{data:j,headers:_r.from(P.headers),status:P.status,statusText:P.statusText,config:e,request:w})})}catch(P){throw m(),P&&P.name==="TypeError"&&/fetch/i.test(P.message)?Object.assign(new Ke("Network Error",Ke.ERR_NETWORK,e,w),{cause:P.cause||P}):Ke.from(P,P&&P.code,e,w)}}),OA={http:QU,xhr:zQ,fetch:kQ};$.forEach(OA,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const v1=e=>`- ${e}`,EQ=e=>$.isFunction(e)||e===null||e===!1,r3={getAdapter:e=>{e=$.isArray(e)?e:[e];const{length:t}=e;let n,r;const o={};for(let s=0;s`adapter ${a} `+(l===!1?"is not supported by the environment":"is not available in the build"));let i=t?s.length>1?`since : `+s.map(v1).join(` `):" "+v1(s[0]):"as no adapter specified";throw new Ke("There is no suitable adapter to dispatch the request "+i,"ERR_NOT_SUPPORT")}return r},adapters:OA};function Mh(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new vl(null,e)}function h1(e){return Mh(e),e.headers=_r.from(e.headers),e.data=Eh.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),r3.getAdapter(e.adapter||_g.adapter)(e).then(function(r){return Mh(e),r.data=Eh.call(e,e.transformResponse,r),r.headers=_r.from(r.headers),r},function(r){return _5(r)||(Mh(e),r&&r.response&&(r.response.data=Eh.call(e,e.transformResponse,r.response),r.response.headers=_r.from(r.response.headers))),Promise.reject(r)})}const o3="1.7.2",$g={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{$g[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const m1={};$g.transitional=function(t,n,r){function o(s,i){return"[Axios v"+o3+"] Transitional option '"+s+"'"+i+(r?". "+r:"")}return(s,i,a)=>{if(t===!1)throw new Ke(o(i," has been removed"+(n?" in "+n:"")),Ke.ERR_DEPRECATED);return n&&!m1[i]&&(m1[i]=!0,console.warn(o(i," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(s,i,a):!0}};function MQ(e,t,n){if(typeof e!="object")throw new Ke("options must be an object",Ke.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let o=r.length;for(;o-- >0;){const s=r[o],i=t[s];if(i){const a=e[s],l=a===void 0||i(a,s,e);if(l!==!0)throw new Ke("option "+s+" must be "+l,Ke.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new Ke("Unknown option "+s,Ke.ERR_BAD_OPTION)}}const CA={assertOptions:MQ,validators:$g},es=CA.validators;class Sd{constructor(t){this.defaults=t,this.interceptors={request:new l1,response:new l1}}async request(t,n){try{return await this._request(t,n)}catch(r){if(r instanceof Error){let o;Error.captureStackTrace?Error.captureStackTrace(o={}):o=new Error;const s=o.stack?o.stack.replace(/^.+\n/,""):"";try{r.stack?s&&!String(r.stack).endsWith(s.replace(/^.+\n.+\n/,""))&&(r.stack+=` -`+s):r.stack=s}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=Si(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&CA.assertOptions(r,{silentJSONParsing:es.transitional(es.boolean),forcedJSONParsing:es.transitional(es.boolean),clarifyTimeoutError:es.transitional(es.boolean)},!1),o!=null&&($.isFunction(o)?n.paramsSerializer={serialize:o}:CA.assertOptions(o,{encode:es.function,serialize:es.function},!0)),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&$.merge(s.common,s[n.method]);s&&$.forEach(["delete","get","head","post","put","patch","common"],h=>{delete s[h]}),n.headers=_r.concat(i,s);const a=[];let l=!0;this.interceptors.request.forEach(function(A){typeof A.runWhen=="function"&&A.runWhen(n)===!1||(l=l&&A.synchronous,a.unshift(A.fulfilled,A.rejected))});const c=[];this.interceptors.response.forEach(function(A){c.push(A.fulfilled,A.rejected)});let u,d=0,p;if(!l){const h=[h1.bind(this),void 0];for(h.unshift.apply(h,a),h.push.apply(h,c),p=h.length,u=Promise.resolve(n);d{if(!r._listeners)return;let s=r._listeners.length;for(;s-- >0;)r._listeners[s](o);r._listeners=null}),this.promise.then=o=>{let s;const i=new Promise(a=>{r.subscribe(a),s=a}).then(o);return i.cancel=function(){r.unsubscribe(s)},i},t(function(s,i,a){r.reason||(r.reason=new vl(s,i,a),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}static source(){let t;return{token:new ey(function(o){t=o}),cancel:t}}}const LQ=ey;function XQ(e){return function(n){return e.apply(null,n)}}function NQ(e){return $.isObject(e)&&e.isAxiosError===!0}const DA={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(DA).forEach(([e,t])=>{DA[t]=e});const BQ=DA;function s3(e){const t=new Lf(e),n=X5(Lf.prototype.request,t);return $.extend(n,Lf.prototype,t,{allOwnKeys:!0}),$.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return s3(Si(e,o))},n}const en=s3(_g);en.Axios=Lf;en.CanceledError=vl;en.CancelToken=LQ;en.isCancel=_5;en.VERSION=o3;en.toFormData=Rv;en.AxiosError=Ke;en.Cancel=en.CanceledError;en.all=function(t){return Promise.all(t)};en.spread=XQ;en.isAxiosError=NQ;en.mergeConfig=Si;en.AxiosHeaders=_r;en.formToJSON=e=>K5($.isHTMLForm(e)?new FormData(e):e);en.getAdapter=r3.getAdapter;en.HttpStatusCode=BQ;en.default=en;const Yt=en.create({baseURL:"/services/japps",headers:{"Content-Type":"application/json"}});Yt.interceptors.response.use(e=>e,e=>{const t=e.response.status;(e.response.status===401||t===403)&&(window.location.href="/services/japps/jhub-login")});var zu=e=>e.type==="checkbox",ua=e=>e instanceof Date,Mn=e=>e==null;const i3=e=>typeof e=="object";var cn=e=>!Mn(e)&&!Array.isArray(e)&&i3(e)&&!ua(e),a3=e=>cn(e)&&e.target?zu(e.target)?e.target.checked:e.target.value:e,VQ=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,l3=(e,t)=>e.has(VQ(t)),IQ=e=>{const t=e.constructor&&e.constructor.prototype;return cn(t)&&t.hasOwnProperty("isPrototypeOf")},ty=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function In(e){let t;const n=Array.isArray(e);if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set(e);else if(!(ty&&(e instanceof Blob||e instanceof FileList))&&(n||cn(e)))if(t=n?[]:{},!n&&!IQ(e))t=e;else for(const r in e)e.hasOwnProperty(r)&&(t[r]=In(e[r]));else return e;return t}var Mv=e=>Array.isArray(e)?e.filter(Boolean):[],Ft=e=>e===void 0,ye=(e,t,n)=>{if(!t||!cn(e))return n;const r=Mv(t.split(/[,[\].]+?/)).reduce((o,s)=>Mn(o)?o:o[s],e);return Ft(r)||r===e?Ft(e[t])?n:e[t]:r},po=e=>typeof e=="boolean",ny=e=>/^\w*$/.test(e),c3=e=>Mv(e.replace(/["|']|\]/g,"").split(/\.|\[/)),xt=(e,t,n)=>{let r=-1;const o=ny(t)?[t]:c3(t),s=o.length,i=s-1;for(;++rCe.useContext(WQ);var u3=(e,t,n,r=!0)=>{const o={defaultValues:t._defaultValues};for(const s in e)Object.defineProperty(o,s,{get:()=>{const i=s;return t._proxyFormState[i]!==Zr.all&&(t._proxyFormState[i]=!r||Zr.all),n&&(n[i]=!0),e[i]}});return o},sr=e=>cn(e)&&!Object.keys(e).length,f3=(e,t,n,r)=>{n(e);const{name:o,...s}=e;return sr(s)||Object.keys(s).length>=Object.keys(t).length||Object.keys(s).find(i=>t[i]===(!r||Zr.all))},bc=e=>Array.isArray(e)?e:[e],d3=(e,t,n)=>!e||!t||e===t||bc(e).some(r=>r&&(n?r===t:r.startsWith(t)||t.startsWith(r)));function oy(e){const t=Ce.useRef(e);t.current=e,Ce.useEffect(()=>{const n=!e.disabled&&t.current.subject&&t.current.subject.subscribe({next:t.current.next});return()=>{n&&n.unsubscribe()}},[e.disabled])}function JQ(e){const t=ry(),{control:n=t.control,disabled:r,name:o,exact:s}=e||{},[i,a]=Ce.useState(n._formState),l=Ce.useRef(!0),c=Ce.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1}),u=Ce.useRef(o);return u.current=o,oy({disabled:r,next:d=>l.current&&d3(u.current,d.name,s)&&f3(d,c.current,n._updateFormState)&&a({...n._formState,...d}),subject:n._subjects.state}),Ce.useEffect(()=>(l.current=!0,c.current.isValid&&n._updateValid(!0),()=>{l.current=!1}),[n]),u3(i,n,c.current,!1)}var ho=e=>typeof e=="string",p3=(e,t,n,r,o)=>ho(e)?(r&&t.watch.add(e),ye(n,e,o)):Array.isArray(e)?e.map(s=>(r&&t.watch.add(s),ye(n,s))):(r&&(t.watchAll=!0),n);function FQ(e){const t=ry(),{control:n=t.control,name:r,defaultValue:o,disabled:s,exact:i}=e||{},a=Ce.useRef(r);a.current=r,oy({disabled:s,subject:n._subjects.values,next:u=>{d3(a.current,u.name,i)&&c(In(p3(a.current,n._names,u.values||n._formValues,!1,o)))}});const[l,c]=Ce.useState(n._getWatch(r,o));return Ce.useEffect(()=>n._removeUnmounted()),l}function YQ(e){const t=ry(),{name:n,disabled:r,control:o=t.control,shouldUnregister:s}=e,i=l3(o._names.array,n),a=FQ({control:o,name:n,defaultValue:ye(o._formValues,n,ye(o._defaultValues,n,e.defaultValue)),exact:!0}),l=JQ({control:o,name:n}),c=Ce.useRef(o.register(n,{...e.rules,value:a,...po(e.disabled)?{disabled:e.disabled}:{}}));return Ce.useEffect(()=>{const u=o._options.shouldUnregister||s,d=(p,y)=>{const h=ye(o._fields,p);h&&h._f&&(h._f.mount=y)};if(d(n,!0),u){const p=In(ye(o._options.defaultValues,n));xt(o._defaultValues,n,p),Ft(ye(o._formValues,n))&&xt(o._formValues,n,p)}return()=>{(i?u&&!o._state.action:u)?o.unregister(n):d(n,!1)}},[n,o,i,s]),Ce.useEffect(()=>{ye(o._fields,n)&&o._updateDisabledField({disabled:r,fields:o._fields,name:n,value:ye(o._fields,n)._f.value})},[r,n,o]),{field:{name:n,value:a,...po(r)||l.disabled?{disabled:l.disabled||r}:{},onChange:Ce.useCallback(u=>c.current.onChange({target:{value:a3(u),name:n},type:Td.CHANGE}),[n]),onBlur:Ce.useCallback(()=>c.current.onBlur({target:{value:ye(o._formValues,n),name:n},type:Td.BLUR}),[n,o]),ref:u=>{const d=ye(o._fields,n);d&&u&&(d._f.ref={focus:()=>u.focus(),select:()=>u.select(),setCustomValidity:p=>u.setCustomValidity(p),reportValidity:()=>u.reportValidity()})}},formState:l,fieldState:Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!ye(l.errors,n)},isDirty:{enumerable:!0,get:()=>!!ye(l.dirtyFields,n)},isTouched:{enumerable:!0,get:()=>!!ye(l.touchedFields,n)},isValidating:{enumerable:!0,get:()=>!!ye(l.validatingFields,n)},error:{enumerable:!0,get:()=>ye(l.errors,n)}})}}const ts=e=>e.render(YQ(e));var qQ=(e,t,n,r,o)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:o||!0}}:{},A1=e=>({isOnSubmit:!e||e===Zr.onSubmit,isOnBlur:e===Zr.onBlur,isOnChange:e===Zr.onChange,isOnAll:e===Zr.all,isOnTouch:e===Zr.onTouched}),P1=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some(r=>e.startsWith(r)&&/^\.\w+/.test(e.slice(r.length))));const xc=(e,t,n,r)=>{for(const o of n||Object.keys(e)){const s=ye(e,o);if(s){const{_f:i,...a}=s;if(i){if(i.refs&&i.refs[0]&&t(i.refs[0],o)&&!r)break;if(i.ref&&t(i.ref,i.name)&&!r)break;xc(a,t)}else cn(a)&&xc(a,t)}}};var ZQ=(e,t,n)=>{const r=bc(ye(e,n));return xt(r,"root",t[n]),xt(e,n,r),e},sy=e=>e.type==="file",ws=e=>typeof e=="function",Rd=e=>{if(!ty)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},Xf=e=>ho(e),iy=e=>e.type==="radio",kd=e=>e instanceof RegExp;const g1={value:!1,isValid:!1},y1={value:!0,isValid:!0};var v3=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter(n=>n&&n.checked&&!n.disabled).map(n=>n.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!Ft(e[0].attributes.value)?Ft(e[0].value)||e[0].value===""?y1:{value:e[0].value,isValid:!0}:y1:g1}return g1};const b1={isValid:!1,value:null};var h3=e=>Array.isArray(e)?e.reduce((t,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:t,b1):b1;function x1(e,t,n="validate"){if(Xf(e)||Array.isArray(e)&&e.every(Xf)||po(e)&&!e)return{type:n,message:Xf(e)?e:"",ref:t}}var Yi=e=>cn(e)&&!kd(e)?e:{value:e,message:""},w1=async(e,t,n,r,o)=>{const{ref:s,refs:i,required:a,maxLength:l,minLength:c,min:u,max:d,pattern:p,validate:y,name:h,valueAsNumber:A,mount:w,disabled:m}=e._f,v=ye(t,h);if(!w||m)return{};const P=i?i[0]:s,x=R=>{r&&P.reportValidity&&(P.setCustomValidity(po(R)?"":R||""),P.reportValidity())},j={},z=iy(s),H=zu(s),O=z||H,D=(A||sy(s))&&Ft(s.value)&&Ft(v)||Rd(s)&&s.value===""||v===""||Array.isArray(v)&&!v.length,S=qQ.bind(null,h,n,j),I=(R,M,W,N=So.maxLength,Z=So.minLength)=>{const J=R?M:W;j[h]={type:R?N:Z,message:J,ref:s,...S(R?N:Z,J)}};if(o?!Array.isArray(v)||!v.length:a&&(!O&&(D||Mn(v))||po(v)&&!v||H&&!v3(i).isValid||z&&!h3(i).isValid)){const{value:R,message:M}=Xf(a)?{value:!!a,message:a}:Yi(a);if(R&&(j[h]={type:So.required,message:M,ref:P,...S(So.required,M)},!n))return x(M),j}if(!D&&(!Mn(u)||!Mn(d))){let R,M;const W=Yi(d),N=Yi(u);if(!Mn(v)&&!isNaN(v)){const Z=s.valueAsNumber||v&&+v;Mn(W.value)||(R=Z>W.value),Mn(N.value)||(M=Znew Date(new Date().toDateString()+" "+K),T=s.type=="time",B=s.type=="week";ho(W.value)&&v&&(R=T?J(v)>J(W.value):B?v>W.value:Z>new Date(W.value)),ho(N.value)&&v&&(M=T?J(v)+R.value,N=!Mn(M.value)&&v.length<+M.value;if((W||N)&&(I(W,R.message,M.message),!n))return x(j[h].message),j}if(p&&!D&&ho(v)){const{value:R,message:M}=Yi(p);if(kd(R)&&!v.match(R)&&(j[h]={type:So.pattern,message:M,ref:s,...S(So.pattern,M)},!n))return x(M),j}if(y){if(ws(y)){const R=await y(v,t),M=x1(R,P);if(M&&(j[h]={...M,...S(So.validate,M.message)},!n))return x(M.message),j}else if(cn(y)){let R={};for(const M in y){if(!sr(R)&&!n)break;const W=x1(await y[M](v,t),P,M);W&&(R={...W,...S(M,W.message)},x(W.message),n&&(j[h]=R))}if(!sr(R)&&(j[h]={ref:P,...R},!n))return j}}return x(!0),j};function GQ(e,t){const n=t.slice(0,-1).length;let r=0;for(;r{let e=[];return{get observers(){return e},next:o=>{for(const s of e)s.next&&s.next(o)},subscribe:o=>(e.push(o),{unsubscribe:()=>{e=e.filter(s=>s!==o)}}),unsubscribe:()=>{e=[]}}},Ed=e=>Mn(e)||!i3(e);function oi(e,t){if(Ed(e)||Ed(t))return e===t;if(ua(e)&&ua(t))return e.getTime()===t.getTime();const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const o of n){const s=e[o];if(!r.includes(o))return!1;if(o!=="ref"){const i=t[o];if(ua(s)&&ua(i)||cn(s)&&cn(i)||Array.isArray(s)&&Array.isArray(i)?!oi(s,i):s!==i)return!1}}return!0}var m3=e=>e.type==="select-multiple",QQ=e=>iy(e)||zu(e),Xh=e=>Rd(e)&&e.isConnected,A3=e=>{for(const t in e)if(ws(e[t]))return!0;return!1};function Md(e,t={}){const n=Array.isArray(e);if(cn(e)||n)for(const r in e)Array.isArray(e[r])||cn(e[r])&&!A3(e[r])?(t[r]=Array.isArray(e[r])?[]:{},Md(e[r],t[r])):Mn(e[r])||(t[r]=!0);return t}function P3(e,t,n){const r=Array.isArray(e);if(cn(e)||r)for(const o in e)Array.isArray(e[o])||cn(e[o])&&!A3(e[o])?Ft(t)||Ed(n[o])?n[o]=Array.isArray(e[o])?Md(e[o],[]):{...Md(e[o])}:P3(e[o],Mn(t)?{}:t[o],n[o]):n[o]=!oi(e[o],t[o]);return n}var cf=(e,t)=>P3(e,t,Md(t)),g3=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>Ft(e)?e:t?e===""?NaN:e&&+e:n&&ho(e)?new Date(e):r?r(e):e;function Nh(e){const t=e.ref;if(!(e.refs?e.refs.every(n=>n.disabled):t.disabled))return sy(t)?t.files:iy(t)?h3(e.refs).value:m3(t)?[...t.selectedOptions].map(({value:n})=>n):zu(t)?v3(e.refs).value:g3(Ft(t.value)?e.ref.value:t.value,e)}var KQ=(e,t,n,r)=>{const o={};for(const s of e){const i=ye(t,s);i&&xt(o,s,i._f)}return{criteriaMode:n,names:[...e],fields:o,shouldUseNativeValidation:r}},Bl=e=>Ft(e)?e:kd(e)?e.source:cn(e)?kd(e.value)?e.value.source:e.value:e,_Q=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function H1(e,t,n){const r=ye(e,n);if(r||ny(n))return{error:r,name:n};const o=n.split(".");for(;o.length;){const s=o.join("."),i=ye(t,s),a=ye(e,s);if(i&&!Array.isArray(i)&&n!==s)return{name:n};if(a&&a.type)return{name:s,error:a};o.pop()}return{name:n}}var $Q=(e,t,n,r,o)=>o.isOnAll?!1:!n&&o.isOnTouch?!(t||e):(n?r.isOnBlur:o.isOnBlur)?!e:(n?r.isOnChange:o.isOnChange)?e:!0,eK=(e,t)=>!Mv(ye(e,t)).length&&nn(e,t);const tK={mode:Zr.onSubmit,reValidateMode:Zr.onChange,shouldFocusError:!0};function nK(e={}){let t={...tK,...e},n={submitCount:0,isDirty:!1,isLoading:ws(t.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1},r={},o=cn(t.defaultValues)||cn(t.values)?In(t.defaultValues||t.values)||{}:{},s=t.shouldUnregister?{}:In(o),i={action:!1,mount:!1,watch:!1},a={mount:new Set,unMount:new Set,array:new Set,watch:new Set},l,c=0;const u={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},d={values:Lh(),array:Lh(),state:Lh()},p=A1(t.mode),y=A1(t.reValidateMode),h=t.criteriaMode===Zr.all,A=C=>V=>{clearTimeout(c),c=setTimeout(C,V)},w=async C=>{if(u.isValid||C){const V=t.resolver?sr((await O()).errors):await S(r,!0);V!==n.isValid&&d.state.next({isValid:V})}},m=(C,V)=>{(u.isValidating||u.validatingFields)&&((C||Array.from(a.mount)).forEach(Y=>{Y&&(V?xt(n.validatingFields,Y,V):nn(n.validatingFields,Y))}),d.state.next({validatingFields:n.validatingFields,isValidating:!sr(n.validatingFields)}))},v=(C,V=[],Y,F,Q=!0,U=!0)=>{if(F&&Y){if(i.action=!0,U&&Array.isArray(ye(r,C))){const oe=Y(ye(r,C),F.argA,F.argB);Q&&xt(r,C,oe)}if(U&&Array.isArray(ye(n.errors,C))){const oe=Y(ye(n.errors,C),F.argA,F.argB);Q&&xt(n.errors,C,oe),eK(n.errors,C)}if(u.touchedFields&&U&&Array.isArray(ye(n.touchedFields,C))){const oe=Y(ye(n.touchedFields,C),F.argA,F.argB);Q&&xt(n.touchedFields,C,oe)}u.dirtyFields&&(n.dirtyFields=cf(o,s)),d.state.next({name:C,isDirty:R(C,V),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else xt(s,C,V)},P=(C,V)=>{xt(n.errors,C,V),d.state.next({errors:n.errors})},x=C=>{n.errors=C,d.state.next({errors:n.errors,isValid:!1})},j=(C,V,Y,F)=>{const Q=ye(r,C);if(Q){const U=ye(s,C,Ft(Y)?ye(o,C):Y);Ft(U)||F&&F.defaultChecked||V?xt(s,C,V?U:Nh(Q._f)):N(C,U),i.mount&&w()}},z=(C,V,Y,F,Q)=>{let U=!1,oe=!1;const ke={name:C},Je=!!(ye(r,C)&&ye(r,C)._f&&ye(r,C)._f.disabled);if(!Y||F){u.isDirty&&(oe=n.isDirty,n.isDirty=ke.isDirty=R(),U=oe!==ke.isDirty);const tt=Je||oi(ye(o,C),V);oe=!!(!Je&&ye(n.dirtyFields,C)),tt||Je?nn(n.dirtyFields,C):xt(n.dirtyFields,C,!0),ke.dirtyFields=n.dirtyFields,U=U||u.dirtyFields&&oe!==!tt}if(Y){const tt=ye(n.touchedFields,C);tt||(xt(n.touchedFields,C,Y),ke.touchedFields=n.touchedFields,U=U||u.touchedFields&&tt!==Y)}return U&&Q&&d.state.next(ke),U?ke:{}},H=(C,V,Y,F)=>{const Q=ye(n.errors,C),U=u.isValid&&po(V)&&n.isValid!==V;if(e.delayError&&Y?(l=A(()=>P(C,Y)),l(e.delayError)):(clearTimeout(c),l=null,Y?xt(n.errors,C,Y):nn(n.errors,C)),(Y?!oi(Q,Y):Q)||!sr(F)||U){const oe={...F,...U&&po(V)?{isValid:V}:{},errors:n.errors,name:C};n={...n,...oe},d.state.next(oe)}},O=async C=>{m(C,!0);const V=await t.resolver(s,t.context,KQ(C||a.mount,r,t.criteriaMode,t.shouldUseNativeValidation));return m(C),V},D=async C=>{const{errors:V}=await O(C);if(C)for(const Y of C){const F=ye(V,Y);F?xt(n.errors,Y,F):nn(n.errors,Y)}else n.errors=V;return V},S=async(C,V,Y={valid:!0})=>{for(const F in C){const Q=C[F];if(Q){const{_f:U,...oe}=Q;if(U){const ke=a.array.has(U.name);m([F],!0);const Je=await w1(Q,s,h,t.shouldUseNativeValidation&&!V,ke);if(m([F]),Je[U.name]&&(Y.valid=!1,V))break;!V&&(ye(Je,U.name)?ke?ZQ(n.errors,Je,U.name):xt(n.errors,U.name,Je[U.name]):nn(n.errors,U.name))}oe&&await S(oe,V,Y)}}return Y.valid},I=()=>{for(const C of a.unMount){const V=ye(r,C);V&&(V._f.refs?V._f.refs.every(Y=>!Xh(Y)):!Xh(V._f.ref))&&re(C)}a.unMount=new Set},R=(C,V)=>(C&&V&&xt(s,C,V),!oi(fe(),o)),M=(C,V,Y)=>p3(C,a,{...i.mount?s:Ft(V)?o:ho(C)?{[C]:V}:V},Y,V),W=C=>Mv(ye(i.mount?s:o,C,e.shouldUnregister?ye(o,C,[]):[])),N=(C,V,Y={})=>{const F=ye(r,C);let Q=V;if(F){const U=F._f;U&&(!U.disabled&&xt(s,C,g3(V,U)),Q=Rd(U.ref)&&Mn(V)?"":V,m3(U.ref)?[...U.ref.options].forEach(oe=>oe.selected=Q.includes(oe.value)):U.refs?zu(U.ref)?U.refs.length>1?U.refs.forEach(oe=>(!oe.defaultChecked||!oe.disabled)&&(oe.checked=Array.isArray(Q)?!!Q.find(ke=>ke===oe.value):Q===oe.value)):U.refs[0]&&(U.refs[0].checked=!!Q):U.refs.forEach(oe=>oe.checked=oe.value===Q):sy(U.ref)?U.ref.value="":(U.ref.value=Q,U.ref.type||d.values.next({name:C,values:{...s}})))}(Y.shouldDirty||Y.shouldTouch)&&z(C,Q,Y.shouldTouch,Y.shouldDirty,!0),Y.shouldValidate&&K(C)},Z=(C,V,Y)=>{for(const F in V){const Q=V[F],U=`${C}.${F}`,oe=ye(r,U);(a.array.has(C)||!Ed(Q)||oe&&!oe._f)&&!ua(Q)?Z(U,Q,Y):N(U,Q,Y)}},J=(C,V,Y={})=>{const F=ye(r,C),Q=a.array.has(C),U=In(V);xt(s,C,U),Q?(d.array.next({name:C,values:{...s}}),(u.isDirty||u.dirtyFields)&&Y.shouldDirty&&d.state.next({name:C,dirtyFields:cf(o,s),isDirty:R(C,U)})):F&&!F._f&&!Mn(U)?Z(C,U,Y):N(C,U,Y),P1(C,a)&&d.state.next({...n}),d.values.next({name:i.mount?C:void 0,values:{...s}})},T=async C=>{i.mount=!0;const V=C.target;let Y=V.name,F=!0;const Q=ye(r,Y),U=()=>V.type?Nh(Q._f):a3(C),oe=ke=>{F=Number.isNaN(ke)||ke===ye(s,Y,ke)};if(Q){let ke,Je;const tt=U(),Xe=C.type===Td.BLUR||C.type===Td.FOCUS_OUT,he=!_Q(Q._f)&&!t.resolver&&!ye(n.errors,Y)&&!Q._f.deps||$Q(Xe,ye(n.touchedFields,Y),n.isSubmitted,y,p),Qe=P1(Y,a,Xe);xt(s,Y,tt),Xe?(Q._f.onBlur&&Q._f.onBlur(C),l&&l(0)):Q._f.onChange&&Q._f.onChange(C);const mt=z(Y,tt,Xe,!1),jt=!sr(mt)||Qe;if(!Xe&&d.values.next({name:Y,type:C.type,values:{...s}}),he)return u.isValid&&w(),jt&&d.state.next({name:Y,...Qe?{}:mt});if(!Xe&&Qe&&d.state.next({...n}),t.resolver){const{errors:je}=await O([Y]);if(oe(tt),F){const Ge=H1(n.errors,r,Y),X=H1(je,r,Ge.name||Y);ke=X.error,Y=X.name,Je=sr(je)}}else m([Y],!0),ke=(await w1(Q,s,h,t.shouldUseNativeValidation))[Y],m([Y]),oe(tt),F&&(ke?Je=!1:u.isValid&&(Je=await S(r,!0)));F&&(Q._f.deps&&K(Q._f.deps),H(Y,Je,ke,mt))}},B=(C,V)=>{if(ye(n.errors,V)&&C.focus)return C.focus(),1},K=async(C,V={})=>{let Y,F;const Q=bc(C);if(t.resolver){const U=await D(Ft(C)?C:Q);Y=sr(U),F=C?!Q.some(oe=>ye(U,oe)):Y}else C?(F=(await Promise.all(Q.map(async U=>{const oe=ye(r,U);return await S(oe&&oe._f?{[U]:oe}:oe)}))).every(Boolean),!(!F&&!n.isValid)&&w()):F=Y=await S(r);return d.state.next({...!ho(C)||u.isValid&&Y!==n.isValid?{}:{name:C},...t.resolver||!C?{isValid:Y}:{},errors:n.errors}),V.shouldFocus&&!F&&xc(r,B,C?Q:a.mount),F},fe=C=>{const V={...i.mount?s:o};return Ft(C)?V:ho(C)?ye(V,C):C.map(Y=>ye(V,Y))},E=(C,V)=>({invalid:!!ye((V||n).errors,C),isDirty:!!ye((V||n).dirtyFields,C),error:ye((V||n).errors,C),isValidating:!!ye(n.validatingFields,C),isTouched:!!ye((V||n).touchedFields,C)}),ee=C=>{C&&bc(C).forEach(V=>nn(n.errors,V)),d.state.next({errors:C?n.errors:{}})},G=(C,V,Y)=>{const F=(ye(r,C,{_f:{}})._f||{}).ref,Q=ye(n.errors,C)||{},{ref:U,message:oe,type:ke,...Je}=Q;xt(n.errors,C,{...Je,...V,ref:F}),d.state.next({name:C,errors:n.errors,isValid:!1}),Y&&Y.shouldFocus&&F&&F.focus&&F.focus()},ie=(C,V)=>ws(C)?d.values.subscribe({next:Y=>C(M(void 0,V),Y)}):M(C,V,!0),re=(C,V={})=>{for(const Y of C?bc(C):a.mount)a.mount.delete(Y),a.array.delete(Y),V.keepValue||(nn(r,Y),nn(s,Y)),!V.keepError&&nn(n.errors,Y),!V.keepDirty&&nn(n.dirtyFields,Y),!V.keepTouched&&nn(n.touchedFields,Y),!V.keepIsValidating&&nn(n.validatingFields,Y),!t.shouldUnregister&&!V.keepDefaultValue&&nn(o,Y);d.values.next({values:{...s}}),d.state.next({...n,...V.keepDirty?{isDirty:R()}:{}}),!V.keepIsValid&&w()},me=({disabled:C,name:V,field:Y,fields:F,value:Q})=>{if(po(C)&&i.mount||C){const U=C?void 0:Ft(Q)?Nh(Y?Y._f:ye(F,V)._f):Q;xt(s,V,U),z(V,U,!1,!1,!0)}},ue=(C,V={})=>{let Y=ye(r,C);const F=po(V.disabled);return xt(r,C,{...Y||{},_f:{...Y&&Y._f?Y._f:{ref:{name:C}},name:C,mount:!0,...V}}),a.mount.add(C),Y?me({field:Y,disabled:V.disabled,name:C,value:V.value}):j(C,!0,V.value),{...F?{disabled:V.disabled}:{},...t.progressive?{required:!!V.required,min:Bl(V.min),max:Bl(V.max),minLength:Bl(V.minLength),maxLength:Bl(V.maxLength),pattern:Bl(V.pattern)}:{},name:C,onChange:T,onBlur:T,ref:Q=>{if(Q){ue(C,V),Y=ye(r,C);const U=Ft(Q.value)&&Q.querySelectorAll&&Q.querySelectorAll("input,select,textarea")[0]||Q,oe=QQ(U),ke=Y._f.refs||[];if(oe?ke.find(Je=>Je===U):U===Y._f.ref)return;xt(r,C,{_f:{...Y._f,...oe?{refs:[...ke.filter(Xh),U,...Array.isArray(ye(o,C))?[{}]:[]],ref:{type:U.type,name:C}}:{ref:U}}}),j(C,!1,void 0,U)}else Y=ye(r,C,{}),Y._f&&(Y._f.mount=!1),(t.shouldUnregister||V.shouldUnregister)&&!(l3(a.array,C)&&i.action)&&a.unMount.add(C)}}},se=()=>t.shouldFocusError&&xc(r,B,a.mount),de=C=>{po(C)&&(d.state.next({disabled:C}),xc(r,(V,Y)=>{const F=ye(r,Y);F&&(V.disabled=F._f.disabled||C,Array.isArray(F._f.refs)&&F._f.refs.forEach(Q=>{Q.disabled=F._f.disabled||C}))},0,!1))},He=(C,V)=>async Y=>{let F;Y&&(Y.preventDefault&&Y.preventDefault(),Y.persist&&Y.persist());let Q=In(s);if(d.state.next({isSubmitting:!0}),t.resolver){const{errors:U,values:oe}=await O();n.errors=U,Q=oe}else await S(r);if(nn(n.errors,"root"),sr(n.errors)){d.state.next({errors:{}});try{await C(Q,Y)}catch(U){F=U}}else V&&await V({...n.errors},Y),se(),setTimeout(se);if(d.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:sr(n.errors)&&!F,submitCount:n.submitCount+1,errors:n.errors}),F)throw F},we=(C,V={})=>{ye(r,C)&&(Ft(V.defaultValue)?J(C,In(ye(o,C))):(J(C,V.defaultValue),xt(o,C,In(V.defaultValue))),V.keepTouched||nn(n.touchedFields,C),V.keepDirty||(nn(n.dirtyFields,C),n.isDirty=V.defaultValue?R(C,In(ye(o,C))):R()),V.keepError||(nn(n.errors,C),u.isValid&&w()),d.state.next({...n}))},be=(C,V={})=>{const Y=C?In(C):o,F=In(Y),Q=sr(C),U=Q?o:F;if(V.keepDefaultValues||(o=Y),!V.keepValues){if(V.keepDirtyValues)for(const oe of a.mount)ye(n.dirtyFields,oe)?xt(U,oe,ye(s,oe)):J(oe,ye(U,oe));else{if(ty&&Ft(C))for(const oe of a.mount){const ke=ye(r,oe);if(ke&&ke._f){const Je=Array.isArray(ke._f.refs)?ke._f.refs[0]:ke._f.ref;if(Rd(Je)){const tt=Je.closest("form");if(tt){tt.reset();break}}}}r={}}s=e.shouldUnregister?V.keepDefaultValues?In(o):{}:In(U),d.array.next({values:{...U}}),d.values.next({values:{...U}})}a={mount:V.keepDirtyValues?a.mount:new Set,unMount:new Set,array:new Set,watch:new Set,watchAll:!1,focus:""},i.mount=!u.isValid||!!V.keepIsValid||!!V.keepDirtyValues,i.watch=!!e.shouldUnregister,d.state.next({submitCount:V.keepSubmitCount?n.submitCount:0,isDirty:Q?!1:V.keepDirty?n.isDirty:!!(V.keepDefaultValues&&!oi(C,o)),isSubmitted:V.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:Q?{}:V.keepDirtyValues?V.keepDefaultValues&&s?cf(o,s):n.dirtyFields:V.keepDefaultValues&&C?cf(o,C):V.keepDirty?n.dirtyFields:{},touchedFields:V.keepTouched?n.touchedFields:{},errors:V.keepErrors?n.errors:{},isSubmitSuccessful:V.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1})},Ie=(C,V)=>be(ws(C)?C(s):C,V);return{control:{register:ue,unregister:re,getFieldState:E,handleSubmit:He,setError:G,_executeSchema:O,_getWatch:M,_getDirty:R,_updateValid:w,_removeUnmounted:I,_updateFieldArray:v,_updateDisabledField:me,_getFieldArray:W,_reset:be,_resetDefaultValues:()=>ws(t.defaultValues)&&t.defaultValues().then(C=>{Ie(C,t.resetOptions),d.state.next({isLoading:!1})}),_updateFormState:C=>{n={...n,...C}},_disableForm:de,_subjects:d,_proxyFormState:u,_setErrors:x,get _fields(){return r},get _formValues(){return s},get _state(){return i},set _state(C){i=C},get _defaultValues(){return o},get _names(){return a},set _names(C){a=C},get _formState(){return n},set _formState(C){n=C},get _options(){return t},set _options(C){t={...t,...C}}},trigger:K,register:ue,handleSubmit:He,watch:ie,setValue:J,getValues:fe,reset:Ie,resetField:we,clearErrors:ee,unregister:re,setError:G,setFocus:(C,V={})=>{const Y=ye(r,C),F=Y&&Y._f;if(F){const Q=F.refs?F.refs[0]:F.ref;Q.focus&&(Q.focus(),V.shouldSelect&&Q.select())}},getFieldState:E}}function rK(e={}){const t=Ce.useRef(),n=Ce.useRef(),[r,o]=Ce.useState({isDirty:!1,isValidating:!1,isLoading:ws(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,defaultValues:ws(e.defaultValues)?void 0:e.defaultValues});t.current||(t.current={...nK(e),formState:r});const s=t.current.control;return s._options=e,oy({subject:s._subjects.state,next:i=>{f3(i,s._proxyFormState,s._updateFormState,!0)&&o({...s._formState})}}),Ce.useEffect(()=>s._disableForm(e.disabled),[s,e.disabled]),Ce.useEffect(()=>{if(s._proxyFormState.isDirty){const i=s._getDirty();i!==r.isDirty&&s._subjects.state.next({isDirty:i})}},[s,r.isDirty]),Ce.useEffect(()=>{e.values&&!oi(e.values,n.current)?(s._reset(e.values,s._options.resetOptions),n.current=e.values,o(i=>({...i}))):s._resetDefaultValues()},[e.values,s]),Ce.useEffect(()=>{e.errors&&s._setErrors(e.errors)},[e.errors,s]),Ce.useEffect(()=>{s._state.mount||(s._updateValid(),s._state.mount=!0),s._state.watch&&(s._state.watch=!1,s._subjects.state.next({...s._formState})),s._removeUnmounted()}),Ce.useEffect(()=>{e.shouldUnregister&&s._subjects.values.next({values:s._getWatch()})},[e.shouldUnregister,s]),t.current.formState=u3(r,s),t.current}const Qi=_("div")(()=>({paddingBottom:"30px"})),oK=({label:e,required:t,style:n})=>f.jsxs("span",{style:{backgroundColor:"#fafafa",padding:"0 2px",...n},children:[t&&f.jsx("span",{style:{color:(n==null?void 0:n.requiredColor)||"inherit"},children:"*"}),e]}),y3=({id:e})=>{var Y;const t=vg(),[n,r]=g.useState(!1),[o]=Ve(Ko),[s,i]=g.useState(""),a=g.useRef(null),l=g.useRef(null),[c,u]=g.useState(!1),d=g.useRef(null),p=g.useRef(null),y=F=>{F&&(F.style.height="auto",F.style.height=F.scrollHeight+"px")},[,h]=Ve(eo),[A,w]=Ve(y5),[m,v]=Ve(g5),[P,x]=Ve(x5),[j,z]=Ve(b5),[H,O]=g.useState(!1),[D,S]=g.useState([]),[I,R]=g.useState([]),[M,W]=g.useState(!1),[N,Z]=g.useState(null),{data:J,error:T}=Ln({queryKey:["app-form",e],queryFn:()=>Yt.get(`/server/${e}`).then(F=>F.data),enabled:!!e}),{data:B,isLoading:K}=Ln({queryKey:["app-frameworks"],queryFn:()=>Yt.get("/frameworks/").then(F=>F.data)}),{data:fe,isLoading:E}=Ln({queryKey:["app-environments"],queryFn:()=>Yt.get("/conda-environments/").then(F=>F.data)}),{data:ee,isLoading:G}=Ln({queryKey:["app-profiles"],queryFn:()=>Yt.get("/spawner-profiles/").then(F=>F.data)}),{control:ie,handleSubmit:re,setFocus:me,reset:ue,watch:se,formState:{errors:de}}=rK({defaultValues:{display_name:"",description:"",framework:"",thumbnail:"",filepath:"",conda_env:"",custom_command:"",profile:"",is_public:!1,keep_alive:!1}}),He=se("framework");g.useEffect(()=>{const F=a.current,Q=()=>{l.current&&a.current&&(l.current.scrollTop=a.current.scrollTop)};return F==null||F.addEventListener("scroll",Q),()=>F==null?void 0:F.removeEventListener("scroll",Q)},[]);const we=()=>{const F=s.slice(0,200),Q=s.slice(200);return f.jsxs(f.Fragment,{children:[F,f.jsx("span",{style:{color:"red"},children:Q})]})};function be(F){u(F)}const Ie=({display_name:F,description:Q,framework:U,thumbnail:oe,filepath:ke,conda_env:Je,custom_command:tt,profile:Xe})=>{const he=UG(F);if(ee&&ee.length>0){const Qe={jhub_app:!0,display_name:he,description:Q,framework:U,thumbnail:oe,filepath:ke,conda_env:Je,env:bA(N),custom_command:tt,profile:Xe,is_public:H,share_with:{users:D,groups:I},keep_alive:M};w(Qe),t(`/server-types${e?`?id=${e}`:""}`)}else{const Qe={servername:m||he,user_options:{jhub_app:!0,name:m||he,display_name:he,description:Q||"",framework:U,thumbnail:oe||"",filepath:ke||"",conda_env:Je||"",env:bA(N),custom_command:tt||"",profile:Xe||"",public:H,share_with:{users:D,groups:I},keep_alive:M}};r(!0),e?C(Qe,{onSuccess:async()=>{window.location.assign($t)},onError:async mt=>{r(!1),h(mt.message)}}):nt(Qe,{onSuccess:async mt=>{const jt=o==null?void 0:o.name;if(jt&&(mt==null?void 0:mt.length)>1){const je=mt[1];window.location.assign(`${$t}/spawn-pending/${jt}/${je}`)}},onError:async mt=>{r(!1),h(mt.message)}})}},Ee=async({servername:F,user_options:Q})=>{const U={accept:"application/json","Content-Type":"multipart/form-data"},oe=new FormData;return oe.append("data",JSON.stringify({servername:F,user_options:Q})),P&&oe.append("thumbnail",P),(await Yt.post("/server",oe,{headers:U})).data},ge=async({servername:F,user_options:Q})=>{const U={accept:"application/json","Content-Type":"multipart/form-data"},oe=new FormData;return oe.append("data",JSON.stringify({servername:F,user_options:Q})),P?oe.append("thumbnail",P):j&&oe.append("thumbnail_data_url",j),(await Yt.put(`/server/${F}`,oe,{headers:U})).data},{mutate:nt}=_a({mutationFn:Ee,retry:1}),{mutate:C}=_a({mutationFn:ge,retry:1});g.useEffect(()=>{var F,Q;J!=null&&J.name&&(J!=null&&J.user_options)&&(v(J.name),i(J.user_options.description),ue({...J.user_options}),O(J.user_options.public),W(J.user_options.keep_alive),Z(J.user_options.env||null),z(J.user_options.thumbnail),S((F=J.user_options.share_with)==null?void 0:F.users),R((Q=J.user_options.share_with)==null?void 0:Q.groups))},[J,J==null?void 0:J.name,J==null?void 0:J.user_options,ue,z,v]),g.useEffect(()=>{var F,Q;A&&(ue({display_name:A.display_name||"",description:A.description||"",framework:A.framework||"",filepath:A.filepath||"",conda_env:A.conda_env||"",custom_command:A.custom_command||"",profile:A.profile||""}),O(A.is_public),W(A.keep_alive),Z(A.env||null),z(A.thumbnail),S((F=A.share_with)==null?void 0:F.users),R((Q=A.share_with)==null?void 0:Q.groups))},[A,ue,z,v]),g.useEffect(()=>{T&&h(T.message)},[T,h]);const V=g.useCallback(()=>{const F=Q=>{if(Q){const oe=Q.getBoundingClientRect(),ke=window.scrollY||window.scrollY,Je=oe.top+ke-120;window.scrollTo({top:Je,behavior:"smooth"}),setTimeout(()=>{},500)}};setTimeout(()=>{requestAnimationFrame(()=>{de.display_name?(F(document.getElementById("display_name")),me("display_name")):de.framework?(F(document.getElementById("framework")),me("framework")):de.custom_command?(F(document.getElementById("custom_command")),me("custom_command")):de.conda_env&&(F(document.getElementById("conda_env")),me("conda_env"))})},0)},[de,me]);return g.useEffect(()=>{Object.keys(de).length>0&&V()},[de,V]),f.jsxs("form",{id:"app-form",onSubmit:re(Ie,V),className:"form",noValidate:!0,children:[f.jsxs(Qi,{ref:p,children:[f.jsx(Ue,{component:"h2",variant:"subtitle1",children:"App Info"}),f.jsx(ts,{name:"display_name",control:ie,rules:{required:!0},render:({field:{ref:F,...Q}})=>f.jsxs(Ro,{error:!!de.display_name,children:[de.display_name&&f.jsxs(Fe,{display:"flex",alignItems:"center",color:"error.main",mb:2,children:[f.jsx($l,{fontSize:"small"}),f.jsx(Ue,{variant:"body2",color:"error",ml:1,children:"Enter an app name"})]}),f.jsx(Rs,{...Q,id:"display_name",label:f.jsx(oK,{label:"Name",required:!0}),placeholder:"Add app name",inputRef:U=>{F(U),de.display_name&&(d.current=U)},autoFocus:!0,error:!!de.display_name,inputProps:{maxLength:255},helperText:f.jsx("span",{style:{fontSize:"12px",color:de.display_name?"error":"textSecondary"},children:"*Required"}),InputLabelProps:{shrink:!0},InputProps:{startAdornment:f.jsx(rg,{position:"start"})}})]})}),f.jsx(ts,{name:"description",control:ie,render:({field:F})=>f.jsxs(Ro,{fullWidth:!0,className:"form-control outer-div",variant:"outlined",style:{position:"relative"},children:[f.jsx("label",{htmlFor:"description",className:"description-label",style:{position:"absolute",top:"0",left:"10px",transform:"translate(0, -50%)",color:c?"#ba18da":"#646464",backgroundColor:"#fafafa",padding:"0 4px",zIndex:1},children:"Description"}),f.jsx("textarea",{...F,ref:a,id:"description",value:s,onChange:Q=>{i(Q.target.value),F.onChange(Q.target.value),y(Q.target)},onFocus:()=>be(!0),onBlur:()=>{F.onBlur(),be(!1)},className:"description_text-field",placeholder:"Add app description (max. 200 characters)",style:{paddingBottom:"8px",borderColor:c?"#ba18da":"#ccc",letterSpacing:".15px",backgroundColor:"#FAFAFA"}}),f.jsx("div",{ref:l,className:"overlay-text",children:we()}),f.jsxs(Df,{className:"form-helper-text",style:{textAlign:"right",marginRight:"0",fontSize:"1rem",color:s.length>200?"red":"inherit"},children:[s.length,"/200"]})]})})]}),f.jsxs(Qi,{children:[f.jsx(Ue,{component:"h2",variant:"subtitle1",children:"Configuration"}),f.jsx(ts,{name:"framework",control:ie,rules:{required:!0},render:({field:{ref:F,...Q}})=>f.jsxs(Ro,{error:!!de.framework,fullWidth:!0,variant:"outlined",children:[de.framework&&f.jsxs(Fe,{display:"flex",alignItems:"center",color:"error.main",mb:2,children:[f.jsx($l,{fontSize:"small"}),f.jsx(Ue,{variant:"body2",color:"error",ml:1,children:"Select a framework"})]}),f.jsx(Ym,{id:"framework-label",shrink:!0,sx:{fontSize:"1rem",transform:"translate(14px, -6px) scale(0.75)",color:de.framework?"#f44336":"rgba(0, 0, 0, 0.54)",top:de.framework?"33px":"0",left:"-4px",padding:"0 4px",zIndex:1,position:"absolute",pointerEvents:"none",transition:"color 0.3s ease"},children:"*Framework"}),f.jsxs(gd,{...Q,id:"framework",error:!!de.framework,displayEmpty:!0,labelId:"framework-label",label:"Framework",sx:{"& .MuiOutlinedInput-notchedOutline":{borderColor:de.framework?"#f44336":"rgba(0, 0, 0, 0.23)"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:de.framework?"#f44336":"rgba(0, 0, 0, 0.87)"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:de.framework?"#f44336":"#BA18DA"}},inputProps:{"aria-label":"Select framework"},children:[f.jsx(vo,{value:"",disabled:!0,children:"Select framework"}),B==null?void 0:B.map(U=>f.jsx(vo,{value:U.name,children:U.display_name},U.name))]}),f.jsx(Df,{children:"*Required"})]})}),He==="custom"?f.jsx(ts,{name:"custom_command",control:ie,rules:{required:!0},render:({field:{ref:F,...Q}})=>f.jsxs(Ro,{error:!!de.custom_command,fullWidth:!0,variant:"outlined",sx:{mb:3},children:[de.custom_command&&f.jsxs(Fe,{display:"flex",alignItems:"center",color:"error.main",mb:2,children:[f.jsx($l,{fontSize:"small"}),f.jsx(Ue,{variant:"body2",color:"error",ml:1,children:"Enter a custom command"})]}),f.jsx(Rs,{...Q,id:"custom_command",label:"*Custom Command",placeholder:"Enter custom command",inputRef:U=>{F(U),de.custom_command&&(d.current=U)},autoFocus:!!de.custom_command,error:!!de.custom_command,inputProps:{maxLength:255},helperText:f.jsx("span",{style:{fontSize:"12px",color:de.custom_command?"error":"textSecondary"},children:"*Required"}),InputProps:{style:de.custom_command?{borderColor:"#d32f2f"}:{}},InputLabelProps:{style:{fontSize:"1rem",transform:"translate(14px, -6px) scale(0.75)",color:de.custom_command?"#d32f2f":"rgba(0, 0, 0, 0.54)",top:"-3px",position:"absolute",pointerEvents:"none",transition:"color 0.3s ease"},shrink:!0},onFocus:()=>u(!0),onBlur:()=>u(!1)})]})}):f.jsx(f.Fragment,{}),fe&&fe.length>0?f.jsx(ts,{name:"conda_env",control:ie,rules:{required:!0},render:({field:{ref:F,...Q}})=>f.jsxs(Ro,{error:!!de.conda_env,fullWidth:!0,variant:"outlined",children:[de.conda_env&&f.jsxs(Fe,{display:"flex",alignItems:"center",color:"error.main",mb:2,children:[f.jsx($l,{fontSize:"small"}),f.jsx(Ue,{variant:"body2",color:"error",ml:1,children:"Select a software environment"})]}),f.jsx(Ym,{id:"conda_env-label",shrink:!0,sx:{fontSize:"1rem",transform:"translate(14px, -6px) scale(0.75)",color:de.conda_env?"#f44336":"rgba(0, 0, 0, 0.54)",top:de.conda_env?"33px":"-2px",left:"-5px",padding:"0 4px",zIndex:1},children:"*Software Environment"}),f.jsxs(gd,{...Q,id:"conda_env",error:!!de.conda_env,displayEmpty:!0,labelId:"conda_env-label",label:"Software Environment",sx:{"& .MuiOutlinedInput-notchedOutline":{borderColor:de.conda_env?"#f44336":"rgba(0, 0, 0, 0.23)"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:de.conda_env?"#f44336":"rgba(0, 0, 0, 0.87)"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:de.conda_env?"#f44336":"#BA18DA"}},inputProps:{"aria-label":"Select software environment"},children:[f.jsx(vo,{value:"",disabled:!0,children:"Select software environment"}),fe.map(U=>f.jsx(vo,{value:U,children:U},U))]}),f.jsx(Df,{children:"*Required"})]})}):f.jsx(f.Fragment,{}),f.jsx(ts,{name:"filepath",control:ie,render:({field:{ref:F,...Q}})=>f.jsx(Ro,{children:f.jsx(Rs,{...Q,id:"filepath",label:"File path",placeholder:'Enter the path to the file, e.g. "/shared/users/panel_basic.py"',error:!!de.filepath})})}),f.jsxs(Fe,{sx:{display:"flex",flexDirection:"row"},children:[f.jsx(ig,{placement:"bottom-start",title:f.jsx("span",{style:{fontSize:"10px",fontWeight:600},children:"Keep alive prevents the app from being suspended even when not in active use. Your app will be instantly available, but it will consume resources until manually stopped."}),children:f.jsx(L5,{fontSize:"small",sx:{position:"relative",top:"9px",left:"2px",color:"#0F10158F"}})}),f.jsx(ts,{name:"keep_alive",control:ie,render:({field:{ref:F,value:Q,onChange:U,...oe}})=>f.jsx(Ro,{sx:{flexDirection:"row"},children:f.jsx(ri,{control:f.jsx(b9,{...oe,id:"keep_alive",checked:M,onChange:()=>{W(!M)}}),label:"Keep app alive",labelPlacement:"start"})})})]})]}),f.jsxs(Qi,{children:[f.jsx(Ue,{component:"h2",variant:"subtitle1",children:"Environment Variables"}),f.jsx(OK,{variables:N,setVariables:Z})]}),f.jsxs(Qi,{children:[f.jsx(Ue,{component:"h2",variant:"subtitle1",children:"Sharing"}),f.jsx(PK,{url:J==null?void 0:J.url,permissions:(Y=J==null?void 0:J.user_options)==null?void 0:Y.share_with,isPublic:H,setCurrentUserPermissions:S,setCurrentGroupPermissions:R,setIsPublic:O})]}),f.jsxs(Qi,{sx:{pb:"36px"},children:[f.jsx(Ue,{component:"h2",variant:"subtitle1",children:"Custom Thumbnail"}),f.jsx(ts,{name:"thumbnail",control:ie,render:({field:{ref:F,value:Q,onChange:U,...oe}})=>f.jsx(Ro,{sx:{pb:0},children:f.jsx(n_,{...oe,id:"thumbnail",currentImage:j,setCurrentImage:z,currentFile:P,setCurrentFile:x})})})]}),f.jsx("hr",{}),f.jsxs("div",{className:"button-section",children:[f.jsx("div",{className:"prev",children:f.jsx(at,{id:"cancel-btn",type:"button",variant:"text",color:"primary",onClick:()=>Bo(`${$t}`),children:"Cancel"})}),f.jsx("div",{className:"next",children:f.jsx(at,{id:"submit-btn",type:"submit",variant:"contained",color:"primary",disabled:K||E||G||n||s.length>200,children:ee&&ee.length>0?f.jsx(f.Fragment,{children:"Next"}):e?f.jsx(f.Fragment,{children:"Save"}):f.jsx(f.Fragment,{children:"Create App"})})})]})]})};var ay={},sK=ct;Object.defineProperty(ay,"__esModule",{value:!0});var b3=ay.default=void 0,iK=sK(ut()),aK=f;b3=ay.default=(0,iK.default)((0,aK.jsx)("path",{d:"M15 20H5V7c0-.55-.45-1-1-1s-1 .45-1 1v13c0 1.1.9 2 2 2h10c.55 0 1-.45 1-1s-.45-1-1-1m5-4V4c0-1.1-.9-2-2-2H9c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h9c1.1 0 2-.9 2-2m-2 0H9V4h9z"}),"ContentCopyRounded");var ly={},lK=ct;Object.defineProperty(ly,"__esModule",{value:!0});var x3=ly.default=void 0,cK=lK(ut()),uK=f;x3=ly.default=(0,cK.default)((0,uK.jsx)("path",{d:"M15.41 16.59 10.83 12l4.58-4.59L14 6l-6 6 6 6z"}),"KeyboardArrowLeft");var cy={},fK=ct;Object.defineProperty(cy,"__esModule",{value:!0});var w3=cy.default=void 0,dK=fK(ut()),pK=f;w3=cy.default=(0,dK.default)((0,pK.jsx)("path",{d:"M8.59 16.59 13.17 12 8.59 7.41 10 6l6 6-6 6z"}),"KeyboardArrowRight");var uy={},vK=ct;Object.defineProperty(uy,"__esModule",{value:!0});var H3=uy.default=void 0,hK=vK(ut()),mK=f;H3=uy.default=(0,hK.default)((0,mK.jsx)("path",{d:"M4.47 21h15.06c1.54 0 2.5-1.67 1.73-3L13.73 4.99c-.77-1.33-2.69-1.33-3.46 0L2.74 18c-.77 1.33.19 3 1.73 3M12 14c-.55 0-1-.45-1-1v-2c0-.55.45-1 1-1s1 .45 1 1v2c0 .55-.45 1-1 1m1 4h-2v-2h2z"}),"WarningRounded");const ot=_("div")(({theme:e})=>({padding:e.spacing(0)}));function AK(e){const{count:t,page:n,rowsPerPage:r,onPageChange:o}=e,s=a=>{o(a,n-1)},i=a=>{o(a,n+1)};return f.jsxs(Fe,{sx:{flexShrink:0,ml:2.5},children:[f.jsx(qn,{onClick:s,disabled:n===0,"aria-label":"previous page","data-testid":"previous-page",children:f.jsx(x3,{})}),f.jsx(qn,{onClick:i,disabled:n>=Math.ceil(t/r)-1,"aria-label":"next page","data-testid":"next-page",children:f.jsx(w3,{})})]})}const PK=({url:e,permissions:t,isPublic:n,setCurrentUserPermissions:r,setCurrentGroupPermissions:o,setIsPublic:s})=>{const[i]=Ve(Ko),[a]=g.useState("Adding individuals or groups will allow others to access this app."),[l,c]=g.useState(!1),[u,d]=g.useState([]),[p,y]=g.useState([]),[h,A]=g.useState([]),[w,m]=g.useState(0),[v]=g.useState(5),[P,x]=g.useState([]),j=()=>{if(p.length>0){const H=[...new Set([...h,...p])];A(H),o(()=>H.filter(O=>O.type==="group").map(O=>O.name)),r(()=>H.filter(O=>O.type==="user").map(O=>O.name))}x([])},z=(H,O)=>{H&&m(O)};return g.useEffect(()=>{if(i&&i.share_permissions){const H=[];H.push(...i.share_permissions.users.map(O=>({name:O,type:"user"}))),H.push(...i.share_permissions.groups.map(O=>({name:O,type:"group"}))),d(H)}},[i]),g.useEffect(()=>{if(t){const H=[];H.push(...t.users.map(O=>({name:O,type:"user"}))),H.push(...t.groups.map(O=>({name:O,type:"group"}))),A(H)}},[t]),f.jsx(Fe,{id:"app-sharing",children:f.jsxs(Ho,{direction:"column",children:[i!=null&&i.share_permissions?f.jsxs(f.Fragment,{children:[f.jsx(ot,{children:f.jsx(qP,{id:"sharing-notification",severity:"warning",icon:f.jsx(H3,{sx:{color:"#EAB54E",top:"-2px",position:"relative"}}),sx:{mb:"16px",position:"relative"},children:a})}),f.jsxs(ot,{sx:{pb:"8px"},children:[f.jsx(Ue,{variant:"subtitle1",sx:{fontWeight:400,pb:0},children:"Individuals and group access"}),f.jsxs(Fe,{sx:{display:"flex",flexDirection:"row",width:"100%",gap:"8px",py:"16px"},children:[f.jsx(Fe,{sx:{display:"flex",flexDirection:"row",justifyContent:"flex-start"},children:f.jsx($R,{disablePortal:!0,id:"share-permissions-autocomplete",options:u,getOptionLabel:H=>H.type==="user"?H.name:`${H.name} (Group)`,multiple:!0,disableCloseOnSelect:!0,clearOnBlur:!0,limitTags:2,sx:{width:510},renderInput:H=>f.jsx(Rs,{...H,placeholder:P.length>0?void 0:"Search one or more usernames or group names"}),value:P,onChange:(H,O)=>{H&&O&&(y(O),x(O))}})}),f.jsx(Fe,{sx:{display:"flex",flexDirection:"row",justifyContent:"flex-end",margin:"auto auto"},children:f.jsx(at,{variant:"contained",color:"primary",onClick:j,disabled:p.length===0,sx:{height:"42px",px:"22px",py:"8px"},children:"Share"})})]})]}),h.length>0?f.jsx(ot,{sx:{pb:"20px"},children:f.jsx(vr,{elevation:0,children:f.jsx(j9,{children:f.jsxs(w9,{"aria-label":"Individuals and Groups",size:"small",children:[f.jsx(H9,{children:h.slice(w*v,w*v+v).map(H=>f.jsxs(yd,{sx:{"&:last-child td, &:last-child th":{border:0}},children:[f.jsxs(kn,{component:"td",scope:"row",sx:{fontSize:"16px"},children:[H.name," ",H.type==="group"?f.jsxs("span",{style:{fontWeight:600},children:[" ","(Group)"]}):f.jsx(f.Fragment,{})]}),f.jsx(kn,{align:"right",children:f.jsx(at,{variant:"text",color:"error",size:"small",sx:{fontWeight:"600",fontSize:"14px"},onClick:()=>{A(O=>O.filter(D=>D.name!==H.name)),H.type==="group"?o(O=>O.filter(D=>D!==H.name)):r(O=>O.filter(D=>D!==H.name))},children:"Remove"})})]},H.name))}),f.jsx(oB,{children:f.jsx(yd,{children:f.jsx(LB,{colSpan:2,count:h.length,rowsPerPage:v,rowsPerPageOptions:[5,10,25,{label:"All",value:-1}],page:w,showFirstButton:!1,showLastButton:!1,width:"500px",slotProps:{select:{inputProps:{"aria-label":"rows per page",width:"500px"},native:!1}},onPageChange:z,ActionsComponent:AK})})})]})})})}):f.jsx(f.Fragment,{})]}):f.jsx(f.Fragment,{}),f.jsx(ot,{children:f.jsx(Fe,{children:f.jsx(vr,{elevation:0,children:f.jsxs(Ho,{direction:"column",children:[f.jsx(ot,{sx:{pt:"8px"},children:f.jsx(ri,{control:f.jsx(b9,{id:"is-public",checked:n,onChange:()=>s(!n)}),label:"Public access",labelPlacement:"start"})}),f.jsx(ot,{sx:{px:"16px",pt:"16px",pb:"4px"},children:f.jsx(Fe,{sx:{display:"flex",flexDirection:"row",gap:"8px",pb:"8px"},children:n?f.jsxs(f.Fragment,{children:[f.jsx(Hv,{sx:{fontSize:"24px"}}),f.jsx(Ue,{variant:"body1",children:"Link sharing public"})]}):f.jsxs(f.Fragment,{children:[f.jsx(wv,{sx:{fontSize:"24px"}}),f.jsx(Ue,{variant:"body1",children:"Link sharing restricted"})]})})}),f.jsx(ot,{sx:{pl:"16px",pb:"16px"},children:n?f.jsxs(Ue,{variant:"body2",children:["This app is accessible to"," ",f.jsx(Ue,{component:"span",variant:"body2",color:"error",children:"anyone via its link and sign in is not required."})]}):f.jsx(Ue,{variant:"body2",children:"This app is accessible to you and the people added above via its link."})}),e?f.jsx(ot,{sx:{p:"16px",pt:0},children:f.jsx(Rs,{id:"sharing-link",placeholder:"http://","aria-label":"Sharing link",fullWidth:!0,InputProps:{endAdornment:f.jsx(rg,{position:"end",children:f.jsx(R2,{onClickAway:()=>c(!1),children:f.jsx(ig,{PopperProps:{disablePortal:!0},onClose:()=>c(!1),open:l,disableFocusListener:!0,disableHoverListener:!0,disableTouchListener:!0,title:"Copied to clipboard!",placement:"top",children:f.jsx(qn,{id:"copy-to-clipboard",onClick:()=>{e&&window.isSecureContext&&(navigator.clipboard.writeText(n1(e)),c(!0))},children:f.jsx(b3,{})})})})})},value:n1(e)})}):f.jsx(f.Fragment,{})]})})})})]})})};var j3={exports:{}};/*! +`+s):r.stack=s}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=Si(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&CA.assertOptions(r,{silentJSONParsing:es.transitional(es.boolean),forcedJSONParsing:es.transitional(es.boolean),clarifyTimeoutError:es.transitional(es.boolean)},!1),o!=null&&($.isFunction(o)?n.paramsSerializer={serialize:o}:CA.assertOptions(o,{encode:es.function,serialize:es.function},!0)),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&$.merge(s.common,s[n.method]);s&&$.forEach(["delete","get","head","post","put","patch","common"],h=>{delete s[h]}),n.headers=_r.concat(i,s);const a=[];let l=!0;this.interceptors.request.forEach(function(A){typeof A.runWhen=="function"&&A.runWhen(n)===!1||(l=l&&A.synchronous,a.unshift(A.fulfilled,A.rejected))});const c=[];this.interceptors.response.forEach(function(A){c.push(A.fulfilled,A.rejected)});let u,d=0,p;if(!l){const h=[h1.bind(this),void 0];for(h.unshift.apply(h,a),h.push.apply(h,c),p=h.length,u=Promise.resolve(n);d{if(!r._listeners)return;let s=r._listeners.length;for(;s-- >0;)r._listeners[s](o);r._listeners=null}),this.promise.then=o=>{let s;const i=new Promise(a=>{r.subscribe(a),s=a}).then(o);return i.cancel=function(){r.unsubscribe(s)},i},t(function(s,i,a){r.reason||(r.reason=new vl(s,i,a),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}static source(){let t;return{token:new ey(function(o){t=o}),cancel:t}}}const LQ=ey;function XQ(e){return function(n){return e.apply(null,n)}}function NQ(e){return $.isObject(e)&&e.isAxiosError===!0}const DA={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(DA).forEach(([e,t])=>{DA[t]=e});const BQ=DA;function s3(e){const t=new Lf(e),n=X5(Lf.prototype.request,t);return $.extend(n,Lf.prototype,t,{allOwnKeys:!0}),$.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return s3(Si(e,o))},n}const en=s3(_g);en.Axios=Lf;en.CanceledError=vl;en.CancelToken=LQ;en.isCancel=_5;en.VERSION=o3;en.toFormData=Rv;en.AxiosError=Ke;en.Cancel=en.CanceledError;en.all=function(t){return Promise.all(t)};en.spread=XQ;en.isAxiosError=NQ;en.mergeConfig=Si;en.AxiosHeaders=_r;en.formToJSON=e=>K5($.isHTMLForm(e)?new FormData(e):e);en.getAdapter=r3.getAdapter;en.HttpStatusCode=BQ;en.default=en;const Yt=en.create({baseURL:"/services/japps",headers:{"Content-Type":"application/json"}});Yt.interceptors.response.use(e=>e,e=>{const t=e.response.status;(e.response.status===401||t===403)&&(window.location.href="/services/japps/jhub-login")});var zu=e=>e.type==="checkbox",ua=e=>e instanceof Date,Mn=e=>e==null;const i3=e=>typeof e=="object";var cn=e=>!Mn(e)&&!Array.isArray(e)&&i3(e)&&!ua(e),a3=e=>cn(e)&&e.target?zu(e.target)?e.target.checked:e.target.value:e,VQ=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,l3=(e,t)=>e.has(VQ(t)),IQ=e=>{const t=e.constructor&&e.constructor.prototype;return cn(t)&&t.hasOwnProperty("isPrototypeOf")},ty=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function In(e){let t;const n=Array.isArray(e);if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set(e);else if(!(ty&&(e instanceof Blob||e instanceof FileList))&&(n||cn(e)))if(t=n?[]:{},!n&&!IQ(e))t=e;else for(const r in e)e.hasOwnProperty(r)&&(t[r]=In(e[r]));else return e;return t}var Mv=e=>Array.isArray(e)?e.filter(Boolean):[],Ft=e=>e===void 0,ye=(e,t,n)=>{if(!t||!cn(e))return n;const r=Mv(t.split(/[,[\].]+?/)).reduce((o,s)=>Mn(o)?o:o[s],e);return Ft(r)||r===e?Ft(e[t])?n:e[t]:r},po=e=>typeof e=="boolean",ny=e=>/^\w*$/.test(e),c3=e=>Mv(e.replace(/["|']|\]/g,"").split(/\.|\[/)),xt=(e,t,n)=>{let r=-1;const o=ny(t)?[t]:c3(t),s=o.length,i=s-1;for(;++rCe.useContext(WQ);var u3=(e,t,n,r=!0)=>{const o={defaultValues:t._defaultValues};for(const s in e)Object.defineProperty(o,s,{get:()=>{const i=s;return t._proxyFormState[i]!==Zr.all&&(t._proxyFormState[i]=!r||Zr.all),n&&(n[i]=!0),e[i]}});return o},sr=e=>cn(e)&&!Object.keys(e).length,f3=(e,t,n,r)=>{n(e);const{name:o,...s}=e;return sr(s)||Object.keys(s).length>=Object.keys(t).length||Object.keys(s).find(i=>t[i]===(!r||Zr.all))},bc=e=>Array.isArray(e)?e:[e],d3=(e,t,n)=>!e||!t||e===t||bc(e).some(r=>r&&(n?r===t:r.startsWith(t)||t.startsWith(r)));function oy(e){const t=Ce.useRef(e);t.current=e,Ce.useEffect(()=>{const n=!e.disabled&&t.current.subject&&t.current.subject.subscribe({next:t.current.next});return()=>{n&&n.unsubscribe()}},[e.disabled])}function JQ(e){const t=ry(),{control:n=t.control,disabled:r,name:o,exact:s}=e||{},[i,a]=Ce.useState(n._formState),l=Ce.useRef(!0),c=Ce.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1}),u=Ce.useRef(o);return u.current=o,oy({disabled:r,next:d=>l.current&&d3(u.current,d.name,s)&&f3(d,c.current,n._updateFormState)&&a({...n._formState,...d}),subject:n._subjects.state}),Ce.useEffect(()=>(l.current=!0,c.current.isValid&&n._updateValid(!0),()=>{l.current=!1}),[n]),u3(i,n,c.current,!1)}var ho=e=>typeof e=="string",p3=(e,t,n,r,o)=>ho(e)?(r&&t.watch.add(e),ye(n,e,o)):Array.isArray(e)?e.map(s=>(r&&t.watch.add(s),ye(n,s))):(r&&(t.watchAll=!0),n);function FQ(e){const t=ry(),{control:n=t.control,name:r,defaultValue:o,disabled:s,exact:i}=e||{},a=Ce.useRef(r);a.current=r,oy({disabled:s,subject:n._subjects.values,next:u=>{d3(a.current,u.name,i)&&c(In(p3(a.current,n._names,u.values||n._formValues,!1,o)))}});const[l,c]=Ce.useState(n._getWatch(r,o));return Ce.useEffect(()=>n._removeUnmounted()),l}function YQ(e){const t=ry(),{name:n,disabled:r,control:o=t.control,shouldUnregister:s}=e,i=l3(o._names.array,n),a=FQ({control:o,name:n,defaultValue:ye(o._formValues,n,ye(o._defaultValues,n,e.defaultValue)),exact:!0}),l=JQ({control:o,name:n}),c=Ce.useRef(o.register(n,{...e.rules,value:a,...po(e.disabled)?{disabled:e.disabled}:{}}));return Ce.useEffect(()=>{const u=o._options.shouldUnregister||s,d=(p,y)=>{const h=ye(o._fields,p);h&&h._f&&(h._f.mount=y)};if(d(n,!0),u){const p=In(ye(o._options.defaultValues,n));xt(o._defaultValues,n,p),Ft(ye(o._formValues,n))&&xt(o._formValues,n,p)}return()=>{(i?u&&!o._state.action:u)?o.unregister(n):d(n,!1)}},[n,o,i,s]),Ce.useEffect(()=>{ye(o._fields,n)&&o._updateDisabledField({disabled:r,fields:o._fields,name:n,value:ye(o._fields,n)._f.value})},[r,n,o]),{field:{name:n,value:a,...po(r)||l.disabled?{disabled:l.disabled||r}:{},onChange:Ce.useCallback(u=>c.current.onChange({target:{value:a3(u),name:n},type:Td.CHANGE}),[n]),onBlur:Ce.useCallback(()=>c.current.onBlur({target:{value:ye(o._formValues,n),name:n},type:Td.BLUR}),[n,o]),ref:u=>{const d=ye(o._fields,n);d&&u&&(d._f.ref={focus:()=>u.focus(),select:()=>u.select(),setCustomValidity:p=>u.setCustomValidity(p),reportValidity:()=>u.reportValidity()})}},formState:l,fieldState:Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!ye(l.errors,n)},isDirty:{enumerable:!0,get:()=>!!ye(l.dirtyFields,n)},isTouched:{enumerable:!0,get:()=>!!ye(l.touchedFields,n)},isValidating:{enumerable:!0,get:()=>!!ye(l.validatingFields,n)},error:{enumerable:!0,get:()=>ye(l.errors,n)}})}}const ts=e=>e.render(YQ(e));var qQ=(e,t,n,r,o)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:o||!0}}:{},A1=e=>({isOnSubmit:!e||e===Zr.onSubmit,isOnBlur:e===Zr.onBlur,isOnChange:e===Zr.onChange,isOnAll:e===Zr.all,isOnTouch:e===Zr.onTouched}),P1=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some(r=>e.startsWith(r)&&/^\.\w+/.test(e.slice(r.length))));const xc=(e,t,n,r)=>{for(const o of n||Object.keys(e)){const s=ye(e,o);if(s){const{_f:i,...a}=s;if(i){if(i.refs&&i.refs[0]&&t(i.refs[0],o)&&!r)break;if(i.ref&&t(i.ref,i.name)&&!r)break;xc(a,t)}else cn(a)&&xc(a,t)}}};var ZQ=(e,t,n)=>{const r=bc(ye(e,n));return xt(r,"root",t[n]),xt(e,n,r),e},sy=e=>e.type==="file",ws=e=>typeof e=="function",Rd=e=>{if(!ty)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},Xf=e=>ho(e),iy=e=>e.type==="radio",kd=e=>e instanceof RegExp;const g1={value:!1,isValid:!1},y1={value:!0,isValid:!0};var v3=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter(n=>n&&n.checked&&!n.disabled).map(n=>n.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!Ft(e[0].attributes.value)?Ft(e[0].value)||e[0].value===""?y1:{value:e[0].value,isValid:!0}:y1:g1}return g1};const b1={isValid:!1,value:null};var h3=e=>Array.isArray(e)?e.reduce((t,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:t,b1):b1;function x1(e,t,n="validate"){if(Xf(e)||Array.isArray(e)&&e.every(Xf)||po(e)&&!e)return{type:n,message:Xf(e)?e:"",ref:t}}var Yi=e=>cn(e)&&!kd(e)?e:{value:e,message:""},w1=async(e,t,n,r,o)=>{const{ref:s,refs:i,required:a,maxLength:l,minLength:c,min:u,max:d,pattern:p,validate:y,name:h,valueAsNumber:A,mount:w,disabled:m}=e._f,v=ye(t,h);if(!w||m)return{};const P=i?i[0]:s,x=R=>{r&&P.reportValidity&&(P.setCustomValidity(po(R)?"":R||""),P.reportValidity())},j={},z=iy(s),H=zu(s),O=z||H,D=(A||sy(s))&&Ft(s.value)&&Ft(v)||Rd(s)&&s.value===""||v===""||Array.isArray(v)&&!v.length,S=qQ.bind(null,h,n,j),I=(R,M,W,N=So.maxLength,Z=So.minLength)=>{const J=R?M:W;j[h]={type:R?N:Z,message:J,ref:s,...S(R?N:Z,J)}};if(o?!Array.isArray(v)||!v.length:a&&(!O&&(D||Mn(v))||po(v)&&!v||H&&!v3(i).isValid||z&&!h3(i).isValid)){const{value:R,message:M}=Xf(a)?{value:!!a,message:a}:Yi(a);if(R&&(j[h]={type:So.required,message:M,ref:P,...S(So.required,M)},!n))return x(M),j}if(!D&&(!Mn(u)||!Mn(d))){let R,M;const W=Yi(d),N=Yi(u);if(!Mn(v)&&!isNaN(v)){const Z=s.valueAsNumber||v&&+v;Mn(W.value)||(R=Z>W.value),Mn(N.value)||(M=Znew Date(new Date().toDateString()+" "+K),T=s.type=="time",B=s.type=="week";ho(W.value)&&v&&(R=T?J(v)>J(W.value):B?v>W.value:Z>new Date(W.value)),ho(N.value)&&v&&(M=T?J(v)+R.value,N=!Mn(M.value)&&v.length<+M.value;if((W||N)&&(I(W,R.message,M.message),!n))return x(j[h].message),j}if(p&&!D&&ho(v)){const{value:R,message:M}=Yi(p);if(kd(R)&&!v.match(R)&&(j[h]={type:So.pattern,message:M,ref:s,...S(So.pattern,M)},!n))return x(M),j}if(y){if(ws(y)){const R=await y(v,t),M=x1(R,P);if(M&&(j[h]={...M,...S(So.validate,M.message)},!n))return x(M.message),j}else if(cn(y)){let R={};for(const M in y){if(!sr(R)&&!n)break;const W=x1(await y[M](v,t),P,M);W&&(R={...W,...S(M,W.message)},x(W.message),n&&(j[h]=R))}if(!sr(R)&&(j[h]={ref:P,...R},!n))return j}}return x(!0),j};function GQ(e,t){const n=t.slice(0,-1).length;let r=0;for(;r{let e=[];return{get observers(){return e},next:o=>{for(const s of e)s.next&&s.next(o)},subscribe:o=>(e.push(o),{unsubscribe:()=>{e=e.filter(s=>s!==o)}}),unsubscribe:()=>{e=[]}}},Ed=e=>Mn(e)||!i3(e);function oi(e,t){if(Ed(e)||Ed(t))return e===t;if(ua(e)&&ua(t))return e.getTime()===t.getTime();const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const o of n){const s=e[o];if(!r.includes(o))return!1;if(o!=="ref"){const i=t[o];if(ua(s)&&ua(i)||cn(s)&&cn(i)||Array.isArray(s)&&Array.isArray(i)?!oi(s,i):s!==i)return!1}}return!0}var m3=e=>e.type==="select-multiple",QQ=e=>iy(e)||zu(e),Xh=e=>Rd(e)&&e.isConnected,A3=e=>{for(const t in e)if(ws(e[t]))return!0;return!1};function Md(e,t={}){const n=Array.isArray(e);if(cn(e)||n)for(const r in e)Array.isArray(e[r])||cn(e[r])&&!A3(e[r])?(t[r]=Array.isArray(e[r])?[]:{},Md(e[r],t[r])):Mn(e[r])||(t[r]=!0);return t}function P3(e,t,n){const r=Array.isArray(e);if(cn(e)||r)for(const o in e)Array.isArray(e[o])||cn(e[o])&&!A3(e[o])?Ft(t)||Ed(n[o])?n[o]=Array.isArray(e[o])?Md(e[o],[]):{...Md(e[o])}:P3(e[o],Mn(t)?{}:t[o],n[o]):n[o]=!oi(e[o],t[o]);return n}var cf=(e,t)=>P3(e,t,Md(t)),g3=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>Ft(e)?e:t?e===""?NaN:e&&+e:n&&ho(e)?new Date(e):r?r(e):e;function Nh(e){const t=e.ref;if(!(e.refs?e.refs.every(n=>n.disabled):t.disabled))return sy(t)?t.files:iy(t)?h3(e.refs).value:m3(t)?[...t.selectedOptions].map(({value:n})=>n):zu(t)?v3(e.refs).value:g3(Ft(t.value)?e.ref.value:t.value,e)}var KQ=(e,t,n,r)=>{const o={};for(const s of e){const i=ye(t,s);i&&xt(o,s,i._f)}return{criteriaMode:n,names:[...e],fields:o,shouldUseNativeValidation:r}},Bl=e=>Ft(e)?e:kd(e)?e.source:cn(e)?kd(e.value)?e.value.source:e.value:e,_Q=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function H1(e,t,n){const r=ye(e,n);if(r||ny(n))return{error:r,name:n};const o=n.split(".");for(;o.length;){const s=o.join("."),i=ye(t,s),a=ye(e,s);if(i&&!Array.isArray(i)&&n!==s)return{name:n};if(a&&a.type)return{name:s,error:a};o.pop()}return{name:n}}var $Q=(e,t,n,r,o)=>o.isOnAll?!1:!n&&o.isOnTouch?!(t||e):(n?r.isOnBlur:o.isOnBlur)?!e:(n?r.isOnChange:o.isOnChange)?e:!0,eK=(e,t)=>!Mv(ye(e,t)).length&&nn(e,t);const tK={mode:Zr.onSubmit,reValidateMode:Zr.onChange,shouldFocusError:!0};function nK(e={}){let t={...tK,...e},n={submitCount:0,isDirty:!1,isLoading:ws(t.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1},r={},o=cn(t.defaultValues)||cn(t.values)?In(t.defaultValues||t.values)||{}:{},s=t.shouldUnregister?{}:In(o),i={action:!1,mount:!1,watch:!1},a={mount:new Set,unMount:new Set,array:new Set,watch:new Set},l,c=0;const u={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},d={values:Lh(),array:Lh(),state:Lh()},p=A1(t.mode),y=A1(t.reValidateMode),h=t.criteriaMode===Zr.all,A=C=>V=>{clearTimeout(c),c=setTimeout(C,V)},w=async C=>{if(u.isValid||C){const V=t.resolver?sr((await O()).errors):await S(r,!0);V!==n.isValid&&d.state.next({isValid:V})}},m=(C,V)=>{(u.isValidating||u.validatingFields)&&((C||Array.from(a.mount)).forEach(Y=>{Y&&(V?xt(n.validatingFields,Y,V):nn(n.validatingFields,Y))}),d.state.next({validatingFields:n.validatingFields,isValidating:!sr(n.validatingFields)}))},v=(C,V=[],Y,F,Q=!0,U=!0)=>{if(F&&Y){if(i.action=!0,U&&Array.isArray(ye(r,C))){const oe=Y(ye(r,C),F.argA,F.argB);Q&&xt(r,C,oe)}if(U&&Array.isArray(ye(n.errors,C))){const oe=Y(ye(n.errors,C),F.argA,F.argB);Q&&xt(n.errors,C,oe),eK(n.errors,C)}if(u.touchedFields&&U&&Array.isArray(ye(n.touchedFields,C))){const oe=Y(ye(n.touchedFields,C),F.argA,F.argB);Q&&xt(n.touchedFields,C,oe)}u.dirtyFields&&(n.dirtyFields=cf(o,s)),d.state.next({name:C,isDirty:R(C,V),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else xt(s,C,V)},P=(C,V)=>{xt(n.errors,C,V),d.state.next({errors:n.errors})},x=C=>{n.errors=C,d.state.next({errors:n.errors,isValid:!1})},j=(C,V,Y,F)=>{const Q=ye(r,C);if(Q){const U=ye(s,C,Ft(Y)?ye(o,C):Y);Ft(U)||F&&F.defaultChecked||V?xt(s,C,V?U:Nh(Q._f)):N(C,U),i.mount&&w()}},z=(C,V,Y,F,Q)=>{let U=!1,oe=!1;const ke={name:C},Je=!!(ye(r,C)&&ye(r,C)._f&&ye(r,C)._f.disabled);if(!Y||F){u.isDirty&&(oe=n.isDirty,n.isDirty=ke.isDirty=R(),U=oe!==ke.isDirty);const tt=Je||oi(ye(o,C),V);oe=!!(!Je&&ye(n.dirtyFields,C)),tt||Je?nn(n.dirtyFields,C):xt(n.dirtyFields,C,!0),ke.dirtyFields=n.dirtyFields,U=U||u.dirtyFields&&oe!==!tt}if(Y){const tt=ye(n.touchedFields,C);tt||(xt(n.touchedFields,C,Y),ke.touchedFields=n.touchedFields,U=U||u.touchedFields&&tt!==Y)}return U&&Q&&d.state.next(ke),U?ke:{}},H=(C,V,Y,F)=>{const Q=ye(n.errors,C),U=u.isValid&&po(V)&&n.isValid!==V;if(e.delayError&&Y?(l=A(()=>P(C,Y)),l(e.delayError)):(clearTimeout(c),l=null,Y?xt(n.errors,C,Y):nn(n.errors,C)),(Y?!oi(Q,Y):Q)||!sr(F)||U){const oe={...F,...U&&po(V)?{isValid:V}:{},errors:n.errors,name:C};n={...n,...oe},d.state.next(oe)}},O=async C=>{m(C,!0);const V=await t.resolver(s,t.context,KQ(C||a.mount,r,t.criteriaMode,t.shouldUseNativeValidation));return m(C),V},D=async C=>{const{errors:V}=await O(C);if(C)for(const Y of C){const F=ye(V,Y);F?xt(n.errors,Y,F):nn(n.errors,Y)}else n.errors=V;return V},S=async(C,V,Y={valid:!0})=>{for(const F in C){const Q=C[F];if(Q){const{_f:U,...oe}=Q;if(U){const ke=a.array.has(U.name);m([F],!0);const Je=await w1(Q,s,h,t.shouldUseNativeValidation&&!V,ke);if(m([F]),Je[U.name]&&(Y.valid=!1,V))break;!V&&(ye(Je,U.name)?ke?ZQ(n.errors,Je,U.name):xt(n.errors,U.name,Je[U.name]):nn(n.errors,U.name))}oe&&await S(oe,V,Y)}}return Y.valid},I=()=>{for(const C of a.unMount){const V=ye(r,C);V&&(V._f.refs?V._f.refs.every(Y=>!Xh(Y)):!Xh(V._f.ref))&&re(C)}a.unMount=new Set},R=(C,V)=>(C&&V&&xt(s,C,V),!oi(fe(),o)),M=(C,V,Y)=>p3(C,a,{...i.mount?s:Ft(V)?o:ho(C)?{[C]:V}:V},Y,V),W=C=>Mv(ye(i.mount?s:o,C,e.shouldUnregister?ye(o,C,[]):[])),N=(C,V,Y={})=>{const F=ye(r,C);let Q=V;if(F){const U=F._f;U&&(!U.disabled&&xt(s,C,g3(V,U)),Q=Rd(U.ref)&&Mn(V)?"":V,m3(U.ref)?[...U.ref.options].forEach(oe=>oe.selected=Q.includes(oe.value)):U.refs?zu(U.ref)?U.refs.length>1?U.refs.forEach(oe=>(!oe.defaultChecked||!oe.disabled)&&(oe.checked=Array.isArray(Q)?!!Q.find(ke=>ke===oe.value):Q===oe.value)):U.refs[0]&&(U.refs[0].checked=!!Q):U.refs.forEach(oe=>oe.checked=oe.value===Q):sy(U.ref)?U.ref.value="":(U.ref.value=Q,U.ref.type||d.values.next({name:C,values:{...s}})))}(Y.shouldDirty||Y.shouldTouch)&&z(C,Q,Y.shouldTouch,Y.shouldDirty,!0),Y.shouldValidate&&K(C)},Z=(C,V,Y)=>{for(const F in V){const Q=V[F],U=`${C}.${F}`,oe=ye(r,U);(a.array.has(C)||!Ed(Q)||oe&&!oe._f)&&!ua(Q)?Z(U,Q,Y):N(U,Q,Y)}},J=(C,V,Y={})=>{const F=ye(r,C),Q=a.array.has(C),U=In(V);xt(s,C,U),Q?(d.array.next({name:C,values:{...s}}),(u.isDirty||u.dirtyFields)&&Y.shouldDirty&&d.state.next({name:C,dirtyFields:cf(o,s),isDirty:R(C,U)})):F&&!F._f&&!Mn(U)?Z(C,U,Y):N(C,U,Y),P1(C,a)&&d.state.next({...n}),d.values.next({name:i.mount?C:void 0,values:{...s}})},T=async C=>{i.mount=!0;const V=C.target;let Y=V.name,F=!0;const Q=ye(r,Y),U=()=>V.type?Nh(Q._f):a3(C),oe=ke=>{F=Number.isNaN(ke)||ke===ye(s,Y,ke)};if(Q){let ke,Je;const tt=U(),Xe=C.type===Td.BLUR||C.type===Td.FOCUS_OUT,he=!_Q(Q._f)&&!t.resolver&&!ye(n.errors,Y)&&!Q._f.deps||$Q(Xe,ye(n.touchedFields,Y),n.isSubmitted,y,p),Qe=P1(Y,a,Xe);xt(s,Y,tt),Xe?(Q._f.onBlur&&Q._f.onBlur(C),l&&l(0)):Q._f.onChange&&Q._f.onChange(C);const mt=z(Y,tt,Xe,!1),jt=!sr(mt)||Qe;if(!Xe&&d.values.next({name:Y,type:C.type,values:{...s}}),he)return u.isValid&&w(),jt&&d.state.next({name:Y,...Qe?{}:mt});if(!Xe&&Qe&&d.state.next({...n}),t.resolver){const{errors:je}=await O([Y]);if(oe(tt),F){const Ge=H1(n.errors,r,Y),X=H1(je,r,Ge.name||Y);ke=X.error,Y=X.name,Je=sr(je)}}else m([Y],!0),ke=(await w1(Q,s,h,t.shouldUseNativeValidation))[Y],m([Y]),oe(tt),F&&(ke?Je=!1:u.isValid&&(Je=await S(r,!0)));F&&(Q._f.deps&&K(Q._f.deps),H(Y,Je,ke,mt))}},B=(C,V)=>{if(ye(n.errors,V)&&C.focus)return C.focus(),1},K=async(C,V={})=>{let Y,F;const Q=bc(C);if(t.resolver){const U=await D(Ft(C)?C:Q);Y=sr(U),F=C?!Q.some(oe=>ye(U,oe)):Y}else C?(F=(await Promise.all(Q.map(async U=>{const oe=ye(r,U);return await S(oe&&oe._f?{[U]:oe}:oe)}))).every(Boolean),!(!F&&!n.isValid)&&w()):F=Y=await S(r);return d.state.next({...!ho(C)||u.isValid&&Y!==n.isValid?{}:{name:C},...t.resolver||!C?{isValid:Y}:{},errors:n.errors}),V.shouldFocus&&!F&&xc(r,B,C?Q:a.mount),F},fe=C=>{const V={...i.mount?s:o};return Ft(C)?V:ho(C)?ye(V,C):C.map(Y=>ye(V,Y))},E=(C,V)=>({invalid:!!ye((V||n).errors,C),isDirty:!!ye((V||n).dirtyFields,C),error:ye((V||n).errors,C),isValidating:!!ye(n.validatingFields,C),isTouched:!!ye((V||n).touchedFields,C)}),ee=C=>{C&&bc(C).forEach(V=>nn(n.errors,V)),d.state.next({errors:C?n.errors:{}})},G=(C,V,Y)=>{const F=(ye(r,C,{_f:{}})._f||{}).ref,Q=ye(n.errors,C)||{},{ref:U,message:oe,type:ke,...Je}=Q;xt(n.errors,C,{...Je,...V,ref:F}),d.state.next({name:C,errors:n.errors,isValid:!1}),Y&&Y.shouldFocus&&F&&F.focus&&F.focus()},ie=(C,V)=>ws(C)?d.values.subscribe({next:Y=>C(M(void 0,V),Y)}):M(C,V,!0),re=(C,V={})=>{for(const Y of C?bc(C):a.mount)a.mount.delete(Y),a.array.delete(Y),V.keepValue||(nn(r,Y),nn(s,Y)),!V.keepError&&nn(n.errors,Y),!V.keepDirty&&nn(n.dirtyFields,Y),!V.keepTouched&&nn(n.touchedFields,Y),!V.keepIsValidating&&nn(n.validatingFields,Y),!t.shouldUnregister&&!V.keepDefaultValue&&nn(o,Y);d.values.next({values:{...s}}),d.state.next({...n,...V.keepDirty?{isDirty:R()}:{}}),!V.keepIsValid&&w()},me=({disabled:C,name:V,field:Y,fields:F,value:Q})=>{if(po(C)&&i.mount||C){const U=C?void 0:Ft(Q)?Nh(Y?Y._f:ye(F,V)._f):Q;xt(s,V,U),z(V,U,!1,!1,!0)}},ue=(C,V={})=>{let Y=ye(r,C);const F=po(V.disabled);return xt(r,C,{...Y||{},_f:{...Y&&Y._f?Y._f:{ref:{name:C}},name:C,mount:!0,...V}}),a.mount.add(C),Y?me({field:Y,disabled:V.disabled,name:C,value:V.value}):j(C,!0,V.value),{...F?{disabled:V.disabled}:{},...t.progressive?{required:!!V.required,min:Bl(V.min),max:Bl(V.max),minLength:Bl(V.minLength),maxLength:Bl(V.maxLength),pattern:Bl(V.pattern)}:{},name:C,onChange:T,onBlur:T,ref:Q=>{if(Q){ue(C,V),Y=ye(r,C);const U=Ft(Q.value)&&Q.querySelectorAll&&Q.querySelectorAll("input,select,textarea")[0]||Q,oe=QQ(U),ke=Y._f.refs||[];if(oe?ke.find(Je=>Je===U):U===Y._f.ref)return;xt(r,C,{_f:{...Y._f,...oe?{refs:[...ke.filter(Xh),U,...Array.isArray(ye(o,C))?[{}]:[]],ref:{type:U.type,name:C}}:{ref:U}}}),j(C,!1,void 0,U)}else Y=ye(r,C,{}),Y._f&&(Y._f.mount=!1),(t.shouldUnregister||V.shouldUnregister)&&!(l3(a.array,C)&&i.action)&&a.unMount.add(C)}}},se=()=>t.shouldFocusError&&xc(r,B,a.mount),de=C=>{po(C)&&(d.state.next({disabled:C}),xc(r,(V,Y)=>{const F=ye(r,Y);F&&(V.disabled=F._f.disabled||C,Array.isArray(F._f.refs)&&F._f.refs.forEach(Q=>{Q.disabled=F._f.disabled||C}))},0,!1))},He=(C,V)=>async Y=>{let F;Y&&(Y.preventDefault&&Y.preventDefault(),Y.persist&&Y.persist());let Q=In(s);if(d.state.next({isSubmitting:!0}),t.resolver){const{errors:U,values:oe}=await O();n.errors=U,Q=oe}else await S(r);if(nn(n.errors,"root"),sr(n.errors)){d.state.next({errors:{}});try{await C(Q,Y)}catch(U){F=U}}else V&&await V({...n.errors},Y),se(),setTimeout(se);if(d.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:sr(n.errors)&&!F,submitCount:n.submitCount+1,errors:n.errors}),F)throw F},we=(C,V={})=>{ye(r,C)&&(Ft(V.defaultValue)?J(C,In(ye(o,C))):(J(C,V.defaultValue),xt(o,C,In(V.defaultValue))),V.keepTouched||nn(n.touchedFields,C),V.keepDirty||(nn(n.dirtyFields,C),n.isDirty=V.defaultValue?R(C,In(ye(o,C))):R()),V.keepError||(nn(n.errors,C),u.isValid&&w()),d.state.next({...n}))},be=(C,V={})=>{const Y=C?In(C):o,F=In(Y),Q=sr(C),U=Q?o:F;if(V.keepDefaultValues||(o=Y),!V.keepValues){if(V.keepDirtyValues)for(const oe of a.mount)ye(n.dirtyFields,oe)?xt(U,oe,ye(s,oe)):J(oe,ye(U,oe));else{if(ty&&Ft(C))for(const oe of a.mount){const ke=ye(r,oe);if(ke&&ke._f){const Je=Array.isArray(ke._f.refs)?ke._f.refs[0]:ke._f.ref;if(Rd(Je)){const tt=Je.closest("form");if(tt){tt.reset();break}}}}r={}}s=e.shouldUnregister?V.keepDefaultValues?In(o):{}:In(U),d.array.next({values:{...U}}),d.values.next({values:{...U}})}a={mount:V.keepDirtyValues?a.mount:new Set,unMount:new Set,array:new Set,watch:new Set,watchAll:!1,focus:""},i.mount=!u.isValid||!!V.keepIsValid||!!V.keepDirtyValues,i.watch=!!e.shouldUnregister,d.state.next({submitCount:V.keepSubmitCount?n.submitCount:0,isDirty:Q?!1:V.keepDirty?n.isDirty:!!(V.keepDefaultValues&&!oi(C,o)),isSubmitted:V.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:Q?{}:V.keepDirtyValues?V.keepDefaultValues&&s?cf(o,s):n.dirtyFields:V.keepDefaultValues&&C?cf(o,C):V.keepDirty?n.dirtyFields:{},touchedFields:V.keepTouched?n.touchedFields:{},errors:V.keepErrors?n.errors:{},isSubmitSuccessful:V.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1})},Ie=(C,V)=>be(ws(C)?C(s):C,V);return{control:{register:ue,unregister:re,getFieldState:E,handleSubmit:He,setError:G,_executeSchema:O,_getWatch:M,_getDirty:R,_updateValid:w,_removeUnmounted:I,_updateFieldArray:v,_updateDisabledField:me,_getFieldArray:W,_reset:be,_resetDefaultValues:()=>ws(t.defaultValues)&&t.defaultValues().then(C=>{Ie(C,t.resetOptions),d.state.next({isLoading:!1})}),_updateFormState:C=>{n={...n,...C}},_disableForm:de,_subjects:d,_proxyFormState:u,_setErrors:x,get _fields(){return r},get _formValues(){return s},get _state(){return i},set _state(C){i=C},get _defaultValues(){return o},get _names(){return a},set _names(C){a=C},get _formState(){return n},set _formState(C){n=C},get _options(){return t},set _options(C){t={...t,...C}}},trigger:K,register:ue,handleSubmit:He,watch:ie,setValue:J,getValues:fe,reset:Ie,resetField:we,clearErrors:ee,unregister:re,setError:G,setFocus:(C,V={})=>{const Y=ye(r,C),F=Y&&Y._f;if(F){const Q=F.refs?F.refs[0]:F.ref;Q.focus&&(Q.focus(),V.shouldSelect&&Q.select())}},getFieldState:E}}function rK(e={}){const t=Ce.useRef(),n=Ce.useRef(),[r,o]=Ce.useState({isDirty:!1,isValidating:!1,isLoading:ws(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,defaultValues:ws(e.defaultValues)?void 0:e.defaultValues});t.current||(t.current={...nK(e),formState:r});const s=t.current.control;return s._options=e,oy({subject:s._subjects.state,next:i=>{f3(i,s._proxyFormState,s._updateFormState,!0)&&o({...s._formState})}}),Ce.useEffect(()=>s._disableForm(e.disabled),[s,e.disabled]),Ce.useEffect(()=>{if(s._proxyFormState.isDirty){const i=s._getDirty();i!==r.isDirty&&s._subjects.state.next({isDirty:i})}},[s,r.isDirty]),Ce.useEffect(()=>{e.values&&!oi(e.values,n.current)?(s._reset(e.values,s._options.resetOptions),n.current=e.values,o(i=>({...i}))):s._resetDefaultValues()},[e.values,s]),Ce.useEffect(()=>{e.errors&&s._setErrors(e.errors)},[e.errors,s]),Ce.useEffect(()=>{s._state.mount||(s._updateValid(),s._state.mount=!0),s._state.watch&&(s._state.watch=!1,s._subjects.state.next({...s._formState})),s._removeUnmounted()}),Ce.useEffect(()=>{e.shouldUnregister&&s._subjects.values.next({values:s._getWatch()})},[e.shouldUnregister,s]),t.current.formState=u3(r,s),t.current}const Qi=_("div")(()=>({paddingBottom:"30px"})),oK=({label:e,required:t,style:n})=>f.jsxs("span",{style:{backgroundColor:"#fafafa",padding:"0 2px",...n},children:[t&&f.jsx("span",{style:{color:(n==null?void 0:n.requiredColor)||"inherit"},children:"*"}),e]}),y3=({id:e})=>{var Y;const t=vg(),[n,r]=g.useState(!1),[o]=Ve(Ko),[s,i]=g.useState(""),a=g.useRef(null),l=g.useRef(null),[c,u]=g.useState(!1),d=g.useRef(null),p=g.useRef(null),y=F=>{F&&(F.style.height="auto",F.style.height=F.scrollHeight+"px")},[,h]=Ve(eo),[A,w]=Ve(y5),[m,v]=Ve(g5),[P,x]=Ve(x5),[j,z]=Ve(b5),[H,O]=g.useState(!1),[D,S]=g.useState([]),[I,R]=g.useState([]),[M,W]=g.useState(!1),[N,Z]=g.useState(null),{data:J,error:T}=Ln({queryKey:["app-form",e],queryFn:()=>Yt.get(`/server/${e}`).then(F=>F.data),enabled:!!e}),{data:B,isLoading:K}=Ln({queryKey:["app-frameworks"],queryFn:()=>Yt.get("/frameworks/").then(F=>F.data)}),{data:fe,isLoading:E}=Ln({queryKey:["app-environments"],queryFn:()=>Yt.get("/conda-environments/").then(F=>F.data)}),{data:ee,isLoading:G}=Ln({queryKey:["app-profiles"],queryFn:()=>Yt.get("/spawner-profiles/").then(F=>F.data)}),{control:ie,handleSubmit:re,setFocus:me,reset:ue,watch:se,formState:{errors:de}}=rK({defaultValues:{display_name:"",description:"",framework:"",thumbnail:"",filepath:"",conda_env:"",custom_command:"",profile:"",is_public:!1,keep_alive:!1}}),He=se("framework");g.useEffect(()=>{const F=a.current,Q=()=>{l.current&&a.current&&(l.current.scrollTop=a.current.scrollTop)};return F==null||F.addEventListener("scroll",Q),()=>F==null?void 0:F.removeEventListener("scroll",Q)},[]);const we=()=>{const F=s.slice(0,200),Q=s.slice(200);return f.jsxs(f.Fragment,{children:[F,f.jsx("span",{style:{color:"red"},children:Q})]})};function be(F){u(F)}const Ie=({display_name:F,description:Q,framework:U,thumbnail:oe,filepath:ke,conda_env:Je,custom_command:tt,profile:Xe})=>{const he=UG(F);if(ee&&ee.length>0){const Qe={jhub_app:!0,display_name:he,description:Q,framework:U,thumbnail:oe,filepath:ke,conda_env:Je,env:bA(N),custom_command:tt,profile:Xe,is_public:H,share_with:{users:D,groups:I},keep_alive:M};w(Qe),t(`/server-types${e?`?id=${e}`:""}`)}else{const Qe={servername:m||he,user_options:{jhub_app:!0,name:m||he,display_name:he,description:Q||"",framework:U,thumbnail:oe||"",filepath:ke||"",conda_env:Je||"",env:bA(N),custom_command:tt||"",profile:Xe||"",public:H,share_with:{users:D,groups:I},keep_alive:M}};r(!0),e?C(Qe,{onSuccess:async()=>{window.location.assign($t)},onError:async mt=>{r(!1),h(mt.message)}}):nt(Qe,{onSuccess:async mt=>{const jt=o==null?void 0:o.name;if(jt&&(mt==null?void 0:mt.length)>1){const je=mt[1];window.location.assign(`${$t}/spawn-pending/${jt}/${je}`)}},onError:async mt=>{r(!1),h(mt.message)}})}},Ee=async({servername:F,user_options:Q})=>{const U={accept:"application/json","Content-Type":"multipart/form-data"},oe=new FormData;return oe.append("data",JSON.stringify({servername:F,user_options:Q})),P&&oe.append("thumbnail",P),(await Yt.post("/server",oe,{headers:U})).data},ge=async({servername:F,user_options:Q})=>{const U={accept:"application/json","Content-Type":"multipart/form-data"},oe=new FormData;return oe.append("data",JSON.stringify({servername:F,user_options:Q})),P?oe.append("thumbnail",P):j&&oe.append("thumbnail_data_url",j),(await Yt.put(`/server/${F}`,oe,{headers:U})).data},{mutate:nt}=_a({mutationFn:Ee,retry:1}),{mutate:C}=_a({mutationFn:ge,retry:1});g.useEffect(()=>{var F,Q;J!=null&&J.name&&(J!=null&&J.user_options)&&(v(J.name),i(J.user_options.description),ue({...J.user_options}),O(J.user_options.public),W(J.user_options.keep_alive),Z(J.user_options.env||null),z(J.user_options.thumbnail),S((F=J.user_options.share_with)==null?void 0:F.users),R((Q=J.user_options.share_with)==null?void 0:Q.groups))},[J,J==null?void 0:J.name,J==null?void 0:J.user_options,ue,z,v]),g.useEffect(()=>{var F,Q;A&&(ue({display_name:A.display_name||"",description:A.description||"",framework:A.framework||"",filepath:A.filepath||"",conda_env:A.conda_env||"",custom_command:A.custom_command||"",profile:A.profile||""}),O(A.is_public),W(A.keep_alive),Z(A.env||null),z(A.thumbnail),S((F=A.share_with)==null?void 0:F.users),R((Q=A.share_with)==null?void 0:Q.groups))},[A,ue,z,v]),g.useEffect(()=>{T&&h(T.message)},[T,h]);const V=g.useCallback(()=>{const F=Q=>{if(Q){const oe=Q.getBoundingClientRect(),ke=window.scrollY||window.scrollY,Je=oe.top+ke-120;window.scrollTo({top:Je,behavior:"smooth"}),setTimeout(()=>{},500)}};setTimeout(()=>{requestAnimationFrame(()=>{de.display_name?(F(document.getElementById("display_name")),me("display_name")):de.framework?(F(document.getElementById("framework")),me("framework")):de.custom_command?(F(document.getElementById("custom_command")),me("custom_command")):de.conda_env&&(F(document.getElementById("conda_env")),me("conda_env"))})},0)},[de,me]);return g.useEffect(()=>{Object.keys(de).length>0&&V()},[de,V]),f.jsxs("form",{id:"app-form",onSubmit:re(Ie,V),className:"form",noValidate:!0,children:[f.jsxs(Qi,{ref:p,children:[f.jsx(Ue,{component:"h2",variant:"subtitle1",children:"App Info"}),f.jsx(ts,{name:"display_name",control:ie,rules:{required:!0},render:({field:{ref:F,...Q}})=>f.jsxs(Ro,{error:!!de.display_name,children:[de.display_name&&f.jsxs(Fe,{display:"flex",alignItems:"center",color:"error.main",mb:2,children:[f.jsx($l,{fontSize:"small"}),f.jsx(Ue,{variant:"body2",color:"error",ml:1,children:"Enter an app name"})]}),f.jsx(Rs,{...Q,id:"display_name",label:f.jsx(oK,{label:"Name",required:!0}),placeholder:"Add app name",inputRef:U=>{F(U),de.display_name&&(d.current=U)},autoFocus:!0,error:!!de.display_name,inputProps:{maxLength:255},helperText:f.jsx("span",{style:{fontSize:"12px",color:de.display_name?"error":"textSecondary"},children:"*Required"}),InputLabelProps:{shrink:!0},InputProps:{startAdornment:f.jsx(rg,{position:"start"})}})]})}),f.jsx(ts,{name:"description",control:ie,render:({field:F})=>f.jsxs(Ro,{fullWidth:!0,className:"form-control outer-div",variant:"outlined",style:{position:"relative"},children:[f.jsx("label",{htmlFor:"description",className:"description-label",style:{position:"absolute",top:"0",left:"10px",transform:"translate(0, -50%)",color:c?"#ba18da":"#646464",backgroundColor:"#fafafa",padding:"0 4px",zIndex:1},children:"Description"}),f.jsx("textarea",{...F,ref:a,id:"description",value:s,onChange:Q=>{i(Q.target.value),F.onChange(Q.target.value),y(Q.target)},onFocus:()=>be(!0),onBlur:()=>{F.onBlur(),be(!1)},className:"description_text-field",placeholder:"Add app description (max. 200 characters)",style:{paddingBottom:"8px",borderColor:c?"#ba18da":"#ccc",letterSpacing:".15px",backgroundColor:"#FAFAFA"}}),f.jsx("div",{ref:l,className:"overlay-text",children:we()}),f.jsxs(Df,{className:"form-helper-text",style:{textAlign:"right",marginRight:"0",fontSize:"1rem",color:s.length>200?"red":"inherit"},children:[s.length,"/200"]})]})})]}),f.jsxs(Qi,{children:[f.jsx(Ue,{component:"h2",variant:"subtitle1",children:"Configuration"}),f.jsx(ts,{name:"framework",control:ie,rules:{required:!0},render:({field:{ref:F,...Q}})=>f.jsxs(Ro,{error:!!de.framework,fullWidth:!0,variant:"outlined",children:[de.framework&&f.jsxs(Fe,{display:"flex",alignItems:"center",color:"error.main",mb:2,children:[f.jsx($l,{fontSize:"small"}),f.jsx(Ue,{variant:"body2",color:"error",ml:1,children:"Select a framework"})]}),f.jsx(Ym,{id:"framework-label",shrink:!0,sx:{fontSize:"1rem",transform:"translate(14px, -6px) scale(0.75)",color:de.framework?"#f44336":"rgba(0, 0, 0, 0.54)",top:de.framework?"33px":"0",left:"-4px",padding:"0 4px",zIndex:1,position:"absolute",pointerEvents:"none",transition:"color 0.3s ease"},children:"*Framework"}),f.jsxs(gd,{...Q,id:"framework",error:!!de.framework,displayEmpty:!0,labelId:"framework-label",label:"Framework",sx:{"& .MuiOutlinedInput-notchedOutline":{borderColor:de.framework?"#f44336":"rgba(0, 0, 0, 0.23)"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:de.framework?"#f44336":"rgba(0, 0, 0, 0.87)"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:de.framework?"#f44336":"#BA18DA"}},inputProps:{"aria-label":"Select framework"},children:[f.jsx(vo,{value:"",disabled:!0,children:"Select framework"}),B==null?void 0:B.map(U=>f.jsx(vo,{value:U.name,children:U.display_name},U.name))]}),f.jsx(Df,{children:"*Required"})]})}),He==="custom"?f.jsx(ts,{name:"custom_command",control:ie,rules:{required:!0},render:({field:{ref:F,...Q}})=>f.jsxs(Ro,{error:!!de.custom_command,fullWidth:!0,variant:"outlined",sx:{mb:3},children:[de.custom_command&&f.jsxs(Fe,{display:"flex",alignItems:"center",color:"error.main",mb:2,children:[f.jsx($l,{fontSize:"small"}),f.jsx(Ue,{variant:"body2",color:"error",ml:1,children:"Enter a custom command"})]}),f.jsx(Rs,{...Q,id:"custom_command",label:"*Custom Command",placeholder:"Enter custom command",inputRef:U=>{F(U),de.custom_command&&(d.current=U)},autoFocus:!!de.custom_command,error:!!de.custom_command,inputProps:{maxLength:255},helperText:f.jsx("span",{style:{fontSize:"12px",color:de.custom_command?"error":"textSecondary"},children:"*Required"}),InputProps:{style:de.custom_command?{borderColor:"#d32f2f"}:{}},InputLabelProps:{style:{fontSize:"1rem",transform:"translate(14px, -6px) scale(0.75)",color:de.custom_command?"#d32f2f":"rgba(0, 0, 0, 0.54)",top:"-3px",position:"absolute",pointerEvents:"none",transition:"color 0.3s ease"},shrink:!0},onFocus:()=>u(!0),onBlur:()=>u(!1)})]})}):f.jsx(f.Fragment,{}),fe&&fe.length>0?f.jsx(ts,{name:"conda_env",control:ie,rules:{required:!0},render:({field:{ref:F,...Q}})=>f.jsxs(Ro,{error:!!de.conda_env,fullWidth:!0,variant:"outlined",children:[de.conda_env&&f.jsxs(Fe,{display:"flex",alignItems:"center",color:"error.main",mb:2,children:[f.jsx($l,{fontSize:"small"}),f.jsx(Ue,{variant:"body2",color:"error",ml:1,children:"Select a software environment"})]}),f.jsx(Ym,{id:"conda_env-label",shrink:!0,sx:{fontSize:"1rem",transform:"translate(14px, -6px) scale(0.75)",color:de.conda_env?"#f44336":"rgba(0, 0, 0, 0.54)",top:de.conda_env?"33px":"-2px",left:"-5px",padding:"0 4px",zIndex:1},children:"*Software Environment"}),f.jsxs(gd,{...Q,id:"conda_env",error:!!de.conda_env,displayEmpty:!0,labelId:"conda_env-label",label:"Software Environment",sx:{"& .MuiOutlinedInput-notchedOutline":{borderColor:de.conda_env?"#f44336":"rgba(0, 0, 0, 0.23)"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:de.conda_env?"#f44336":"rgba(0, 0, 0, 0.87)"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:de.conda_env?"#f44336":"#BA18DA"}},inputProps:{"aria-label":"Select software environment"},children:[f.jsx(vo,{value:"",disabled:!0,children:"Select software environment"}),fe.map(U=>f.jsx(vo,{value:U,children:U},U))]}),f.jsx(Df,{children:"*Required"})]})}):f.jsx(f.Fragment,{}),f.jsx(ts,{name:"filepath",control:ie,render:({field:{ref:F,...Q}})=>f.jsx(Ro,{children:f.jsx(Rs,{...Q,id:"filepath",label:"File path",placeholder:'Enter the path to the file, e.g. "/shared/users/panel_basic.py"',error:!!de.filepath})})}),f.jsxs(Fe,{sx:{display:"flex",flexDirection:"row"},children:[f.jsx(ig,{placement:"bottom-start",title:f.jsx("span",{style:{fontSize:"10px",fontWeight:600},children:"Keep alive prevents the app from being suspended even when not in active use. Your app will be instantly available, but it will consume resources until manually stopped."}),children:f.jsx(L5,{fontSize:"small",sx:{position:"relative",top:"9px",left:"2px",color:"#0F10158F"}})}),f.jsx(ts,{name:"keep_alive",control:ie,render:({field:{ref:F,value:Q,onChange:U,...oe}})=>f.jsx(Ro,{sx:{flexDirection:"row"},children:f.jsx(ri,{control:f.jsx(b9,{...oe,id:"keep_alive",checked:M,onChange:()=>{W(!M)}}),label:"Keep app alive",labelPlacement:"start"})})})]})]}),f.jsxs(Qi,{children:[f.jsx(Ue,{component:"h2",variant:"subtitle1",children:"Environment Variables"}),f.jsx(OK,{variables:N,setVariables:Z})]}),f.jsxs(Qi,{children:[f.jsx(Ue,{component:"h2",variant:"subtitle1",children:"Sharing"}),f.jsx(PK,{url:J==null?void 0:J.url,permissions:(Y=J==null?void 0:J.user_options)==null?void 0:Y.share_with,isPublic:H,setCurrentUserPermissions:S,setCurrentGroupPermissions:R,setIsPublic:O})]}),f.jsxs(Qi,{sx:{pb:"36px"},children:[f.jsx(Ue,{component:"h2",variant:"subtitle1",children:"Custom Thumbnail"}),f.jsx(ts,{name:"thumbnail",control:ie,render:({field:{ref:F,value:Q,onChange:U,...oe}})=>f.jsx(Ro,{sx:{pb:0},children:f.jsx(n_,{...oe,id:"thumbnail",currentImage:j,setCurrentImage:z,currentFile:P,setCurrentFile:x})})})]}),f.jsx("hr",{}),f.jsxs("div",{className:"button-section",children:[f.jsx("div",{className:"prev",children:f.jsx(at,{id:"cancel-btn",type:"button",variant:"text",color:"primary",onClick:()=>Bo(`${$t}`),children:"Cancel"})}),f.jsx("div",{className:"next",children:f.jsx(at,{id:"submit-btn",type:"submit",variant:"contained",color:"primary",disabled:K||E||G||n||s.length>200,children:ee&&ee.length>0?f.jsx(f.Fragment,{children:"Next"}):e?f.jsx(f.Fragment,{children:"Save"}):f.jsx(f.Fragment,{children:"Deploy App"})})})]})]})};var ay={},sK=ct;Object.defineProperty(ay,"__esModule",{value:!0});var b3=ay.default=void 0,iK=sK(ut()),aK=f;b3=ay.default=(0,iK.default)((0,aK.jsx)("path",{d:"M15 20H5V7c0-.55-.45-1-1-1s-1 .45-1 1v13c0 1.1.9 2 2 2h10c.55 0 1-.45 1-1s-.45-1-1-1m5-4V4c0-1.1-.9-2-2-2H9c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h9c1.1 0 2-.9 2-2m-2 0H9V4h9z"}),"ContentCopyRounded");var ly={},lK=ct;Object.defineProperty(ly,"__esModule",{value:!0});var x3=ly.default=void 0,cK=lK(ut()),uK=f;x3=ly.default=(0,cK.default)((0,uK.jsx)("path",{d:"M15.41 16.59 10.83 12l4.58-4.59L14 6l-6 6 6 6z"}),"KeyboardArrowLeft");var cy={},fK=ct;Object.defineProperty(cy,"__esModule",{value:!0});var w3=cy.default=void 0,dK=fK(ut()),pK=f;w3=cy.default=(0,dK.default)((0,pK.jsx)("path",{d:"M8.59 16.59 13.17 12 8.59 7.41 10 6l6 6-6 6z"}),"KeyboardArrowRight");var uy={},vK=ct;Object.defineProperty(uy,"__esModule",{value:!0});var H3=uy.default=void 0,hK=vK(ut()),mK=f;H3=uy.default=(0,hK.default)((0,mK.jsx)("path",{d:"M4.47 21h15.06c1.54 0 2.5-1.67 1.73-3L13.73 4.99c-.77-1.33-2.69-1.33-3.46 0L2.74 18c-.77 1.33.19 3 1.73 3M12 14c-.55 0-1-.45-1-1v-2c0-.55.45-1 1-1s1 .45 1 1v2c0 .55-.45 1-1 1m1 4h-2v-2h2z"}),"WarningRounded");const ot=_("div")(({theme:e})=>({padding:e.spacing(0)}));function AK(e){const{count:t,page:n,rowsPerPage:r,onPageChange:o}=e,s=a=>{o(a,n-1)},i=a=>{o(a,n+1)};return f.jsxs(Fe,{sx:{flexShrink:0,ml:2.5},children:[f.jsx(qn,{onClick:s,disabled:n===0,"aria-label":"previous page","data-testid":"previous-page",children:f.jsx(x3,{})}),f.jsx(qn,{onClick:i,disabled:n>=Math.ceil(t/r)-1,"aria-label":"next page","data-testid":"next-page",children:f.jsx(w3,{})})]})}const PK=({url:e,permissions:t,isPublic:n,setCurrentUserPermissions:r,setCurrentGroupPermissions:o,setIsPublic:s})=>{const[i]=Ve(Ko),[a]=g.useState("Adding individuals or groups will allow others to access this app."),[l,c]=g.useState(!1),[u,d]=g.useState([]),[p,y]=g.useState([]),[h,A]=g.useState([]),[w,m]=g.useState(0),[v]=g.useState(5),[P,x]=g.useState([]),j=()=>{if(p.length>0){const H=[...new Set([...h,...p])];A(H),o(()=>H.filter(O=>O.type==="group").map(O=>O.name)),r(()=>H.filter(O=>O.type==="user").map(O=>O.name))}x([])},z=(H,O)=>{H&&m(O)};return g.useEffect(()=>{if(i&&i.share_permissions){const H=[];H.push(...i.share_permissions.users.map(O=>({name:O,type:"user"}))),H.push(...i.share_permissions.groups.map(O=>({name:O,type:"group"}))),d(H)}},[i]),g.useEffect(()=>{if(t){const H=[];H.push(...t.users.map(O=>({name:O,type:"user"}))),H.push(...t.groups.map(O=>({name:O,type:"group"}))),A(H)}},[t]),f.jsx(Fe,{id:"app-sharing",children:f.jsxs(Ho,{direction:"column",children:[i!=null&&i.share_permissions?f.jsxs(f.Fragment,{children:[f.jsx(ot,{children:f.jsx(qP,{id:"sharing-notification",severity:"warning",icon:f.jsx(H3,{sx:{color:"#EAB54E",top:"-2px",position:"relative"}}),sx:{mb:"16px",position:"relative"},children:a})}),f.jsxs(ot,{sx:{pb:"8px"},children:[f.jsx(Ue,{variant:"subtitle1",sx:{fontWeight:400,pb:0},children:"Individuals and group access"}),f.jsxs(Fe,{sx:{display:"flex",flexDirection:"row",width:"100%",gap:"8px",py:"16px"},children:[f.jsx(Fe,{sx:{display:"flex",flexDirection:"row",justifyContent:"flex-start"},children:f.jsx($R,{disablePortal:!0,id:"share-permissions-autocomplete",options:u,getOptionLabel:H=>H.type==="user"?H.name:`${H.name} (Group)`,multiple:!0,disableCloseOnSelect:!0,clearOnBlur:!0,limitTags:2,sx:{width:510},renderInput:H=>f.jsx(Rs,{...H,placeholder:P.length>0?void 0:"Search one or more usernames or group names"}),value:P,onChange:(H,O)=>{H&&O&&(y(O),x(O))}})}),f.jsx(Fe,{sx:{display:"flex",flexDirection:"row",justifyContent:"flex-end",margin:"auto auto"},children:f.jsx(at,{variant:"contained",color:"primary",onClick:j,disabled:p.length===0,sx:{height:"42px",px:"22px",py:"8px"},children:"Share"})})]})]}),h.length>0?f.jsx(ot,{sx:{pb:"20px"},children:f.jsx(vr,{elevation:0,children:f.jsx(j9,{children:f.jsxs(w9,{"aria-label":"Individuals and Groups",size:"small",children:[f.jsx(H9,{children:h.slice(w*v,w*v+v).map(H=>f.jsxs(yd,{sx:{"&:last-child td, &:last-child th":{border:0}},children:[f.jsxs(kn,{component:"td",scope:"row",sx:{fontSize:"16px"},children:[H.name," ",H.type==="group"?f.jsxs("span",{style:{fontWeight:600},children:[" ","(Group)"]}):f.jsx(f.Fragment,{})]}),f.jsx(kn,{align:"right",children:f.jsx(at,{variant:"text",color:"error",size:"small",sx:{fontWeight:"600",fontSize:"14px"},onClick:()=>{A(O=>O.filter(D=>D.name!==H.name)),H.type==="group"?o(O=>O.filter(D=>D!==H.name)):r(O=>O.filter(D=>D!==H.name))},children:"Remove"})})]},H.name))}),f.jsx(oB,{children:f.jsx(yd,{children:f.jsx(LB,{colSpan:2,count:h.length,rowsPerPage:v,rowsPerPageOptions:[5,10,25,{label:"All",value:-1}],page:w,showFirstButton:!1,showLastButton:!1,width:"500px",slotProps:{select:{inputProps:{"aria-label":"rows per page",width:"500px"},native:!1}},onPageChange:z,ActionsComponent:AK})})})]})})})}):f.jsx(f.Fragment,{})]}):f.jsx(f.Fragment,{}),f.jsx(ot,{children:f.jsx(Fe,{children:f.jsx(vr,{elevation:0,children:f.jsxs(Ho,{direction:"column",children:[f.jsx(ot,{sx:{pt:"8px"},children:f.jsx(ri,{control:f.jsx(b9,{id:"is-public",checked:n,onChange:()=>s(!n)}),label:"Public access",labelPlacement:"start"})}),f.jsx(ot,{sx:{px:"16px",pt:"16px",pb:"4px"},children:f.jsx(Fe,{sx:{display:"flex",flexDirection:"row",gap:"8px",pb:"8px"},children:n?f.jsxs(f.Fragment,{children:[f.jsx(Hv,{sx:{fontSize:"24px"}}),f.jsx(Ue,{variant:"body1",children:"Link sharing public"})]}):f.jsxs(f.Fragment,{children:[f.jsx(wv,{sx:{fontSize:"24px"}}),f.jsx(Ue,{variant:"body1",children:"Link sharing restricted"})]})})}),f.jsx(ot,{sx:{pl:"16px",pb:"16px"},children:n?f.jsxs(Ue,{variant:"body2",children:["This app is accessible to"," ",f.jsx(Ue,{component:"span",variant:"body2",color:"error",children:"anyone via its link and sign in is not required."})]}):f.jsx(Ue,{variant:"body2",children:"This app is accessible to you and the people added above via its link."})}),e?f.jsx(ot,{sx:{p:"16px",pt:0},children:f.jsx(Rs,{id:"sharing-link",placeholder:"http://","aria-label":"Sharing link",fullWidth:!0,InputProps:{endAdornment:f.jsx(rg,{position:"end",children:f.jsx(R2,{onClickAway:()=>c(!1),children:f.jsx(ig,{PopperProps:{disablePortal:!0},onClose:()=>c(!1),open:l,disableFocusListener:!0,disableHoverListener:!0,disableTouchListener:!0,title:"Copied to clipboard!",placement:"top",children:f.jsx(qn,{id:"copy-to-clipboard",onClick:()=>{e&&window.isSecureContext&&(navigator.clipboard.writeText(n1(e)),c(!0))},children:f.jsx(b3,{})})})})})},value:n1(e)})}):f.jsx(f.Fragment,{})]})})})})]})})};var j3={exports:{}};/*! Copyright (c) 2018 Jed Watson. Licensed under the MIT License (MIT), see http://jedwatson.github.io/classnames -*/(function(e){(function(){var t={}.hasOwnProperty;function n(){for(var s="",i=0;i{const r=yK("button-group",t);return f.jsx("ul",{id:e,className:r,children:g.Children.map(n,(o,s)=>f.jsx("li",{className:"button-group-item",children:o},s))})};var fy={},bK=ct;Object.defineProperty(fy,"__esModule",{value:!0});var dy=fy.default=void 0,xK=bK(ut()),wK=f;dy=fy.default=(0,xK.default)((0,wK.jsx)("path",{d:"M18 13h-5v5c0 .55-.45 1-1 1s-1-.45-1-1v-5H6c-.55 0-1-.45-1-1s.45-1 1-1h5V6c0-.55.45-1 1-1s1 .45 1 1v5h5c.55 0 1 .45 1 1s-.45 1-1 1"}),"AddRounded");var py={},HK=ct;Object.defineProperty(py,"__esModule",{value:!0});var z3=py.default=void 0,jK=HK(ut()),zK=f;z3=py.default=(0,jK.default)((0,zK.jsx)("path",{d:"M18.3 5.71a.9959.9959 0 0 0-1.41 0L12 10.59 7.11 5.7a.9959.9959 0 0 0-1.41 0c-.39.39-.39 1.02 0 1.41L10.59 12 5.7 16.89c-.39.39-.39 1.02 0 1.41.39.39 1.02.39 1.41 0L12 13.41l4.89 4.89c.39.39 1.02.39 1.41 0 .39-.39.39-1.02 0-1.41L13.41 12l4.89-4.89c.38-.38.38-1.02 0-1.4"}),"CloseRounded");const OK=({variables:e,setVariables:t})=>{const[n,r]=g.useState([]),o=l=>{if(!l||l.length===0)return null;const c={};return l.forEach(u=>{u.key&&(c[u.key]=u.value)}),c},s=(l,c)=>{const u=[...n];c.target.name==="key"?u[l].key=c.target.value:u[l].value=c.target.value,r(u),t(o(u))},i=()=>{r([...n,{key:"",value:""}])},a=l=>{const c=[...n];c.splice(l,1),r(c),t(o(c))};return g.useEffect(()=>{e&&n.length===0&&r(()=>{const l=[];for(const[c,u]of Object.entries(e))l.push({key:c,value:u});return l})},[e,n.length]),f.jsx(Fe,{id:"environment-variables",children:f.jsxs(Ho,{children:[n.length>0?f.jsx(ot,{sx:{pb:"16px"},children:n.map((l,c)=>f.jsxs(Ho,{direction:"row",gap:1,sx:{pb:"16px"},children:[f.jsx(ot,{sx:{width:"100%"},children:f.jsx(Rs,{id:`environment-variable-key-${c}`,name:"key",label:"Key",placeholder:"Key",value:l.key,onChange:u=>s(c,u)})}),f.jsx(ot,{sx:{width:"100%"},children:f.jsx(Rs,{id:`environment-variable-value-${c}`,name:"value",label:"Value",placeholder:"Value",value:l.value,onChange:u=>s(c,u)})}),f.jsx(ot,{children:f.jsx(qn,{sx:{mt:"7px"},onClick:()=>a(c),"aria-label":"Remove",children:f.jsx(z3,{})})})]},`environment-variable-row-${c}`))}):f.jsx(f.Fragment,{}),f.jsx(ot,{children:f.jsx(at,{variant:"contained",color:"secondary",startIcon:f.jsx(dy,{}),onClick:i,sx:{},children:"Add Variable"})})]})})};var vy={},CK=ct;Object.defineProperty(vy,"__esModule",{value:!0});var O3=vy.default=void 0,DK=CK(ut()),SK=f;O3=vy.default=(0,DK.default)((0,SK.jsx)("path",{d:"M10 19v-5h4v5c0 .55.45 1 1 1h3c.55 0 1-.45 1-1v-7h1.7c.46 0 .68-.57.33-.87L12.67 3.6c-.38-.34-.96-.34-1.34 0l-8.36 7.53c-.34.3-.13.87.33.87H5v7c0 .55.45 1 1 1h3c.55 0 1-.45 1-1"}),"HomeRounded");var hy={},TK=ct;Object.defineProperty(hy,"__esModule",{value:!0});var Ld=hy.default=void 0,RK=TK(ut()),kK=f;Ld=hy.default=(0,RK.default)((0,kK.jsx)("path",{d:"M8.12 9.29 12 13.17l3.88-3.88c.39-.39 1.02-.39 1.41 0 .39.39.39 1.02 0 1.41l-4.59 4.59c-.39.39-1.02.39-1.41 0L6.7 10.7a.9959.9959 0 0 1 0-1.41c.39-.38 1.03-.39 1.42 0"}),"KeyboardArrowDownRounded");var my={},EK=ct;Object.defineProperty(my,"__esModule",{value:!0});var Xd=my.default=void 0,MK=EK(ut()),LK=f;Xd=my.default=(0,MK.default)((0,LK.jsx)("path",{d:"M8.12 14.71 12 10.83l3.88 3.88c.39.39 1.02.39 1.41 0 .39-.39.39-1.02 0-1.41L12.7 8.71a.9959.9959 0 0 0-1.41 0L6.7 13.3c-.39.39-.39 1.02 0 1.41.39.38 1.03.39 1.42 0"}),"KeyboardArrowUpRounded");var Ay={},XK=ct;Object.defineProperty(Ay,"__esModule",{value:!0});var C3=Ay.default=void 0,NK=XK(ut()),BK=f;C3=Ay.default=(0,NK.default)((0,BK.jsx)("path",{d:"M3 18h18v-2H3zm0-5h18v-2H3zm0-7v2h18V6z"}),"Menu");_(ca)(({theme:e})=>({fontWeight:400,fontSize:"16px",paddingLeft:e.spacing(4),paddingTop:e.spacing(1),paddingBottom:e.spacing(1)}));const VK=_(ca)(({theme:e})=>({fontWeight:400,fontSize:"16px",paddingTop:e.spacing(1),paddingBottom:e.spacing(1)}));_(u9)(({theme:e})=>({paddingLeft:e.spacing(4)}));const IK=({...e})=>{const t=Ar(),[n,r]=Ce.useState(null),o=!!n,s=vM(t.breakpoints.down("sm")),{window:i}=e,[a,l]=g.useState(!s),[c]=Ve(Ko),[,u]=Ve(eo),[d,p]=g.useState([]),[y,h]=g.useState([]),[A,w]=g.useState([]),{isLoading:m,error:v,data:P}=Ln({queryKey:["app-state"],queryFn:()=>Yt.get("/server/").then(D=>D.data).then(D=>D),enabled:!!c}),{isLoading:x,error:j,data:z}=Ln({queryKey:["service-data"],queryFn:()=>Yt.get("/services/").then(D=>D.data).then(D=>D),enabled:!!c}),H=()=>{l(D=>!D)};g.useEffect(()=>{!m&&P&&c&&h(()=>M5(P,c.name))},[m,P,c]),g.useEffect(()=>{!x&&z&&c&&(p(()=>R5(z,c.name).filter(D=>!ag.includes(D.name))),w(()=>k5(z,c.name)))},[x,z,c]),g.useEffect(()=>{u(j?j.message:v?v.message:void 0)},[j,v,u]),g.useEffect(()=>{l(!s)},[s]);const O=f.jsxs(Fe,{children:[f.jsx(qm,{children:f.jsx(Ol,{disablePadding:!0,sx:{mt:10},children:f.jsxs(u9,{sx:{px:"1.5rem",mx:".5rem",backgroundColor:t.palette.primary.light,borderRadius:"8px",position:"relative",display:"flex",alignItems:"center","&::before":{content:'""',position:"absolute",left:0,top:0,bottom:0,width:"8px",backgroundColor:t.palette.primary.main,borderTopLeftRadius:"8px",borderBottomLeftRadius:"8px"},"&:hover":{backgroundColor:t.palette.gray[50],"&::before":{backgroundColor:t.palette.primary.main}}},onClick:()=>Bo(`${$t}`),children:[f.jsx(gL,{sx:{minWidth:"auto",mr:"8px",display:"flex",alignItems:"center"},children:f.jsx(O3,{sx:{color:t.palette.common.black,width:"28px",height:"28px"}})}),f.jsx(ca,{primary:f.jsx(Ue,{variant:"body1",sx:{fontSize:"16px",fontWeight:600,lineHeight:"1.2",position:"relative",top:"2px"},children:"Home"})})]})})}),f.jsxs(qm,{sx:{px:1},children:[f.jsx(Ol,{disablePadding:!0,children:f.jsx(VK,{primary:"Services",disableTypography:!0,sx:{px:"24px",py:"4px",fontSize:"14px",textTransform:"uppercase",fontWeight:600,color:"rgba(15 16 21 / 60%)"}})}),y.map((D,S)=>f.jsx(Ol,{disablePadding:!0,children:f.jsx(Ql,{href:D.url,sx:{borderRadius:"4px",textDecoration:"none",display:"block",width:"100%",px:"24px",py:"4px",color:"rgb(15 16 21 / 87%)","&:hover":{backgroundColor:"rgba(0, 0, 0, 0.04)",textDecoration:"none"}},children:f.jsx(ca,{primary:f.jsx(Ue,{variant:"body2",sx:{fontSize:"1rem",color:"rgb(15 16 21 / 87%)"},children:D.name})})})},S)),A.map((D,S)=>f.jsx(Ol,{disablePadding:!0,children:f.jsx(Ql,{href:D.url,sx:{borderRadius:"4px",textDecoration:"none",display:"block",width:"100%",px:"24px",py:"4px",color:"rgb(15 16 21 / 87%)","&:hover":{backgroundColor:"rgba(0, 0, 0, 0.04)",textDecoration:"none"}},children:f.jsx(ca,{primary:f.jsx(Ue,{variant:"body2",sx:{fontSize:"1rem",color:"rgb(15 16 21 / 87%)"},children:D.name})})})},S)),d.map((D,S)=>f.jsx(Ol,{disablePadding:!0,children:f.jsx(Ql,{href:D.url,sx:{borderRadius:"4px",textDecoration:"none",display:"block",width:"100%",px:"24px",py:"4px",color:"rgb(15 16 21 / 87%)","&:hover":{backgroundColor:"rgba(0, 0, 0, 0.04)",textDecoration:"none"}},children:f.jsx(ca,{primary:f.jsx(Ue,{variant:"body2",sx:{fontSize:"1rem",color:"rgb(15 16 21 / 87%)"},children:D.name})})})},S))]})]});return f.jsxs(Fe,{sx:{flexGrow:1},children:[f.jsx(hS,{id:"app-bar",position:"fixed",sx:{zIndex:D=>D.zIndex.drawer+1,backgroundColor:D=>D.palette.common.white},children:f.jsxs(z9,{id:"toolbar",children:[f.jsx(qn,{color:"inherit","aria-label":"open drawer",edge:"start",onClick:H,sx:{mr:2,display:{sm:"none"}},children:f.jsx(C3,{})}),f.jsx(Fe,{component:"div",sx:{flexGrow:1,display:{xs:"none",sm:"block"}},children:f.jsx(Ql,{href:$t,children:f.jsx("img",{src:_G(),alt:"logo",height:"28"})})}),f.jsxs(Fe,{sx:{display:{xs:"none",sm:"block"}},children:[f.jsxs(at,{id:"profile-menu-btn",className:"button-menu","aria-controls":o?"profile-menu-list":void 0,"aria-haspopup":"true","aria-expanded":o?"true":void 0,onClick:D=>r(D.currentTarget),endIcon:o?f.jsx(Xd,{}):f.jsx(Ld,{}),sx:{"&:hover":{backgroundColor:t.palette.gray[50]}},children:[c==null?void 0:c.name," ",(c==null?void 0:c.admin)&&f.jsx(mu,{label:"admin",size:"small",className:"chip",sx:{marginLeft:t.spacing(1)}})]}),f.jsxs(Uc,{id:"profile-menu-list",anchorEl:n,open:o,onClose:()=>r(null),MenuListProps:{"aria-labelledby":"profile-menu-btn"},sx:{marginTop:"20px"},children:[f.jsx(vo,{onClick:()=>Bo(`${$t}/token`),sx:{width:"180px"},children:"Tokens"}),(c==null?void 0:c.admin)&&f.jsx(vo,{onClick:()=>Bo(`${$t}/admin`),children:"Admin"}),f.jsx(vo,{onClick:()=>Bo(`${$t}/logout`),children:"Logout"})]})]})]})}),f.jsx("nav",{children:f.jsx(d6,{container:i!==void 0?()=>i().document.body:void 0,variant:"persistent",open:a,onClose:H,ModalProps:{keepMounted:!0},sx:{"& .MuiDrawer-paper":{boxSizing:"border-box",width:224,boxShadow:1}},children:O})})]})},WK=({severity:e="error",message:t,onClose:n})=>f.jsx("div",{className:"alert-wrapper",children:f.jsx(qP,{id:"alert-notification",severity:e,onClose:n,children:t})}),JK=e=>{let t;switch(e){case"Ready":t={bgcolor:"rgb(255, 255, 255)",border:"1px solid rgb(46, 125, 50)",color:"rgb(46, 125, 50)"};break;case"Pending":t={bgcolor:"rgb(234, 181, 78)",color:"black"};break;case"Running":t={bgcolor:"rgb(46, 125, 50)",color:"white"};break;case"Unknown":default:t={bgcolor:"rgb(121, 121, 124)",color:"white"};break}return t},D3=({status:e,additionalInfo:t,app:n,size:r="small"})=>{const[,o]=Ve(jv),[,s]=Ve(zv),i=()=>e==="Running"&&t?f.jsx(f.Fragment,{children:n&&!n.shared?f.jsxs(f.Fragment,{children:[f.jsxs("span",{className:"chip-label-info",style:{position:"relative",top:"1px"},children:[e," on ",t]}),f.jsx(qn,{onClick:a=>{a.preventDefault(),a.stopPropagation(),o(n),s(!0)},"aria-label":"Stop",sx:{pl:0,position:"relative",top:0,left:"6px"},color:"inherit",disabled:n.shared,children:f.jsx(Cv,{sx:{fontSize:"16px"}})})]}):f.jsx("span",{children:e})}):e||"Default";return f.jsx(mu,{label:i(),className:e!=="Running"||!t||n!=null&&n.shared?"chip-base":"",size:r,sx:{fontWeight:600,fontSize:"12px",...JK(e)}})};var Py={},FK=ct;Object.defineProperty(Py,"__esModule",{value:!0});var S3=Py.default=void 0,YK=FK(ut()),qK=f;S3=Py.default=(0,YK.default)((0,qK.jsx)("path",{d:"M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"}),"Close");var gy={},ZK=ct;Object.defineProperty(gy,"__esModule",{value:!0});var T3=gy.default=void 0,GK=ZK(ut()),UK=f;T3=gy.default=(0,GK.default)((0,UK.jsx)("path",{d:"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2m-1 16H6c-.55 0-1-.45-1-1V6c0-.55.45-1 1-1h12c.55 0 1 .45 1 1v12c0 .55-.45 1-1 1m-4.44-6.19-2.35 3.02-1.56-1.88c-.2-.25-.58-.24-.78.01l-1.74 2.23c-.26.33-.02.81.39.81h8.98c.41 0 .65-.47.4-.8l-2.55-3.39c-.19-.26-.59-.26-.79 0"}),"CropOriginalRounded");var yy={},QK=ct;Object.defineProperty(yy,"__esModule",{value:!0});var R3=yy.default=void 0,KK=QK(ut()),_K=f;R3=yy.default=(0,KK.default)((0,_K.jsx)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m1 15h-2v-2h2zm0-4h-2V7h2z"}),"Error");var by={},$K=ct;Object.defineProperty(by,"__esModule",{value:!0});var k3=by.default=void 0,e_=$K(ut()),t_=f;k3=by.default=(0,e_.default)((0,t_.jsx)("path",{d:"M10 16h4c.55 0 1-.45 1-1v-5h1.59c.89 0 1.34-1.08.71-1.71L12.71 3.7a.9959.9959 0 0 0-1.41 0L6.71 8.29c-.63.63-.19 1.71.7 1.71H9v5c0 .55.45 1 1 1m-4 2h12c.55 0 1 .45 1 1s-.45 1-1 1H6c-.55 0-1-.45-1-1s.45-1 1-1"}),"UploadRounded");const n_=({id:e,name:t,currentImage:n,setCurrentImage:r,currentFile:o,setCurrentFile:s,...i})=>{const a=Ar(),[l,c]=g.useState(!1),[u,d]=g.useState(!1),[p,y]=g.useState(void 0),h=g.useRef(null),A=H=>{H.preventDefault(),c(!0)},w=H=>{H.preventDefault(),c(!0)},m=H=>{H.preventDefault(),c(!1)},v=H=>{H.preventDefault(),c(!1);const O=H.dataTransfer.files[0];s(O)},P=H=>{if(!H.target.files)return;const O=5*1024*1024;if(H.target.files[0].size>O){y("File size exceeds 5MB.");return}const D=H.target.files[0];s(D),y(void 0)},x=H=>{H.preventDefault(),d(!0)},j=H=>{H.preventDefault();const O=h.current;O&&O.click()},z=H=>{H.preventDefault();const O=h.current;O&&(O.value="",s(void 0),r(void 0))};return g.useEffect(()=>{const H=h.current;if(H&&H.files&&H.files.length>0){const O=H.files[0];s(O)}},[h,s]),f.jsxs(Fe,{id:`thumbnail-${e}`,className:"thumbnail",sx:{display:"flex",flexDirection:"column",columnGap:"24px",width:"100%",border:"none"},children:[p?f.jsxs(Fe,{sx:{display:"flex",alignItems:"center",backgroundColor:"#FDEDED",color:a.palette.error.main,padding:"8px",borderRadius:"4px",marginBottom:"16px"},children:[f.jsx(R3,{sx:{marginRight:"8px"}}),f.jsx(Ue,{variant:"body2",sx:{flexGrow:1,width:"100%",color:a.palette.gray.main},children:f.jsxs("span",{className:"error-msg",children:[f.jsx("span",{className:"weight600",children:"File is too large."})," Maximum file size is 5MB."]})}),f.jsx(qn,{size:"small",onClick:()=>y(void 0),sx:{color:a.palette.gray.main},children:f.jsx(S3,{})})]}):null,f.jsxs(Fe,{id:`thumbnail-body-${e}`,className:`thumbnail-body ${l?"dragging":""} ${o||n?"selected":""}`,onDragOver:A,onDragEnter:w,onDragLeave:m,onDrop:v,sx:{display:"flex",flexDirection:"row",columnGap:"24px",height:"180px"},children:[f.jsxs(Fe,{className:"thumbnail-dropzone",sx:{height:"130px",backgroundColor:"#90969c",borderRadius:"4px"},children:[o||n?f.jsx(Fe,{sx:{margin:"auto auto"},children:f.jsx("img",{src:o?URL.createObjectURL(o):n,alt:"App thumbnail",title:"Click to view image",className:"thumbnail-img",style:{maxWidth:"225px",maxHeight:"130px",borderRadius:"4px",cursor:"pointer"},onClick:x})}):f.jsx(Fe,{tabIndex:0,title:"Select an image",className:"thumbnail-icon-container",sx:{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",width:"225px",height:"130px",cursor:"pointer","&:focus":{outlineColor:a.palette.primary.main}},onClick:j,children:f.jsx(T3,{sx:{width:"64px",height:"64px",color:a.palette.common.white}})}),f.jsx("input",{ref:h,id:e,name:t,type:"file",accept:"image/*",onChange:P,style:{display:"none"},...i})]}),f.jsxs(Fe,{sx:{display:"flex",flexDirection:"column",rowGap:"16px"},children:[f.jsxs(Fe,{sx:{display:"flex",flexDirection:{xs:"column",sm:"row"},columnGap:"16px",rowGap:"12px",height:"40px"},children:[f.jsx(at,{id:"upload-thumbnail-btn",variant:"contained",color:"secondary",startIcon:f.jsx(k3,{}),onClick:j,sx:{width:"100%",maxWidth:"170px"},children:"Select an image"}),o||n?f.jsx(at,{id:"remove-thumbnail-btn",variant:"contained",color:"secondary",startIcon:f.jsx(Ov,{}),onClick:z,hidden:!o&&!n,sx:{width:"100%",maxWidth:"170px"},children:"Remove image"}):f.jsx(f.Fragment,{})]}),f.jsx(Ue,{variant:"body1",sx:{color:"#0F101599",width:"340px",display:{xs:"none",md:"block"}},children:"Recommended size: 225x130 | JPG, PNG, Max size: 5MB"})]})]}),f.jsx(Gl,{onClose:()=>d(!1),open:u,children:f.jsx("img",{src:o?URL.createObjectURL(o):n,alt:"App thumbnail"})})]})};var xy={},r_=ct;Object.defineProperty(xy,"__esModule",{value:!0});var Lv=xy.default=void 0,o_=r_(ut()),s_=f;Lv=xy.default=(0,o_.default)((0,s_.jsx)("path",{d:"M19 11H7.83l4.88-4.88c.39-.39.39-1.03 0-1.42a.9959.9959 0 0 0-1.41 0l-6.59 6.59c-.39.39-.39 1.02 0 1.41l6.59 6.59c.39.39 1.02.39 1.41 0 .39-.39.39-1.02 0-1.41L7.83 13H19c.55 0 1-.45 1-1s-.45-1-1-1"}),"ArrowBackRounded");const wy=_("p")(()=>({maxWidth:600,paddingBottom:"30px"})),i_=()=>f.jsx(Fe,{className:"container",children:f.jsxs(Ho,{children:[f.jsx(ot,{children:f.jsx("div",{className:"form-breadcrumb",children:f.jsx(at,{id:"back-btn",type:"button",variant:"text",color:"primary",startIcon:f.jsx(Lv,{}),onClick:()=>Bo($t),children:"Back To Home"})})}),f.jsxs(ot,{children:[f.jsx(Ue,{component:"h1",variant:"h5",children:"Create a new app"}),f.jsxs(wy,{children:["Begin your project by entering the details below. For more information about creating an app,"," ",f.jsx("a",{href:"https://jhub-apps.nebari.dev/docs/reference/create-app-form",target:"_blank",rel:"noopener noreferrer",className:"form-paragraph-link",children:"visit our docs"}),"."]})]}),f.jsx(ot,{children:f.jsx(y3,{})})]})}),a_=()=>{const[e]=K9(),t=e.get("id");return f.jsx(Fe,{className:"container",children:f.jsxs(Ho,{children:[f.jsx(ot,{children:f.jsx("div",{className:"form-breadcrumb",children:f.jsx(at,{id:"back-btn",type:"button",variant:"text",color:"primary",startIcon:f.jsx(Lv,{}),onClick:()=>Bo($t),children:"Back To Home"})})}),f.jsxs(ot,{children:[f.jsx(Ue,{component:"h1",variant:"h5",children:"Edit app"}),f.jsxs(wy,{children:["Edit your app details here. For more information on editing your app,"," ",f.jsx("a",{href:"https://jhub-apps.nebari.dev/docs/reference/create-app-form",target:"_blank",rel:"noopener noreferrer",className:"form-paragraph-link",children:"visit our docs"}),"."]})]}),f.jsx(ot,{children:f.jsx(f.Fragment,{children:t?f.jsx(y3,{id:t}):f.jsx(f.Fragment,{children:"No app found."})})})]})})};var Hy={},l_=ct;Object.defineProperty(Hy,"__esModule",{value:!0});var E3=Hy.default=void 0,c_=l_(ut()),u_=f;E3=Hy.default=(0,c_.default)((0,u_.jsx)("path",{d:"M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"}),"Check");var jy={},f_=ct;Object.defineProperty(jy,"__esModule",{value:!0});var M3=jy.default=void 0,d_=f_(ut()),p_=f;M3=jy.default=(0,d_.default)((0,p_.jsx)("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14"}),"Search");var zy={},v_=ct;Object.defineProperty(zy,"__esModule",{value:!0});var L3=zy.default=void 0,h_=v_(ut()),m_=f;L3=zy.default=(0,h_.default)((0,m_.jsx)("path",{d:"M4.25 5.61C6.57 8.59 10 13 10 13v5c0 1.1.9 2 2 2s2-.9 2-2v-5s3.43-4.41 5.75-7.39c.51-.66.04-1.61-.8-1.61H5.04c-.83 0-1.3.95-.79 1.61"}),"FilterAltRounded");var Oy={},A_=ct;Object.defineProperty(Oy,"__esModule",{value:!0});var X3=Oy.default=void 0,P_=A_(ut()),g_=f;X3=Oy.default=(0,P_.default)((0,g_.jsx)("path",{d:"M4 18h4c.55 0 1-.45 1-1s-.45-1-1-1H4c-.55 0-1 .45-1 1s.45 1 1 1M3 7c0 .55.45 1 1 1h16c.55 0 1-.45 1-1s-.45-1-1-1H4c-.55 0-1 .45-1 1m1 6h10c.55 0 1-.45 1-1s-.45-1-1-1H4c-.55 0-1 .45-1 1s.45 1 1 1"}),"SortRounded");var Cy={},y_=ct;Object.defineProperty(Cy,"__esModule",{value:!0});var N3=Cy.default=void 0,b_=y_(ut()),x_=f;N3=Cy.default=(0,b_.default)((0,x_.jsx)("path",{d:"M11 21H5c-1.1 0-2-.9-2-2V5c0-1.1.9-2 2-2h6zm2 0h6c1.1 0 2-.9 2-2v-7h-8zm8-11V5c0-1.1-.9-2-2-2h-6v7z"}),"SpaceDashboard");var Dy={},w_=ct;Object.defineProperty(Dy,"__esModule",{value:!0});var B3=Dy.default=void 0,H_=w_(ut()),j_=f;B3=Dy.default=(0,H_.default)((0,j_.jsx)("path",{d:"M21 8H3V4h18zm0 2H3v4h18zm0 6H3v4h18z"}),"TableRows");const z_=_(at)(({theme:e})=>({color:e.palette.common.black,borderColor:e.palette.common.black,"&:hover":{color:e.palette.common.black,borderColor:e.palette.common.black},marginRight:"16px"})),O_=({data:e,currentUser:t,isGridViewActive:n,toggleView:r,setApps:o})=>{const[s]=Ve(w5),[i,a]=Ce.useState(null),[l,c]=Ce.useState(null),u=!!i,d=!!l,[p,y]=Ve(H5),[h,A]=Ve(z5),[w,m]=Ve(O5),[v,P]=Ve(C5),[x,j]=g.useState(0),{data:z,isLoading:H}=Ln({queryKey:["app-frameworks"],queryFn:()=>Yt.get("/frameworks/").then(N=>N.data)}),O=N=>{const J=N.target.value;p.includes(J)?y(T=>T.filter(B=>B!==J)):y(T=>[...T,J])},D=N=>{A(N)},S=N=>{m(N),o(kf(e,t,s,h,p,N,v)),c(null)},I=N=>{const J=N.target.value;v.includes(J)?P(T=>T.filter(B=>B!==J)):P(T=>[...T,J])},R=()=>{a(null),o(kf(e,t,s,h,p,w,v))},M=()=>{y([]),A("Any"),P([])},W=g.useCallback(()=>kf(e,t,s,h,p,w,v).length,[e,t,s,h,p,w,v]);return g.useEffect(()=>{j(W())},[W]),f.jsxs(yo,{container:!0,spacing:2,paddingBottom:"32px",children:[f.jsx(yo,{item:!0,xs:12,md:4,children:f.jsxs(ot,{sx:{pb:0},children:[f.jsx(z_,{id:"filters-btn",variant:"text",color:"secondary",onClick:N=>a(N.currentTarget),startIcon:f.jsx(L3,{}),sx:{fontSize:"16px",fontWeight:600,top:"-8px",background:"none"},endIcon:u?f.jsx(Xd,{}):f.jsx(Ld,{}),disabled:H||!1,children:"Filters"}),f.jsx(Uc,{id:"filters-list",anchorEl:i,open:u,onClose:()=>a(null),MenuListProps:{"aria-labelledby":"filters-btn",style:{paddingTop:0,paddingBottom:0},sx:{".MuiFormLabel-root":{fontSize:"14px"},".MuiFormControlLabel-label":{fontSize:"14px"}}},children:f.jsxs(Fe,{component:"form",name:"filters-form",id:"filters-form",sx:{width:"450px",px:"16px",pb:0,mt:3},children:[f.jsx(Sf,{id:"frameworks-label",sx:{py:"16px",fontWeight:600},children:"Frameworks"}),f.jsx(Fe,{children:z==null?void 0:z.map(N=>f.jsx(ri,{control:f.jsx(Nb,{value:N.display_name}),label:N.display_name,sx:{width:"120px","& > :last-child":{minWidth:"100%"}},onClick:O,checked:p.includes(N.display_name)},N.name))}),f.jsx(Zc,{sx:{mt:"24px",mb:"16px"}}),f.jsx(Sf,{id:"server-statuses-label",sx:{pb:"16px",fontSize:"14px",fontWeight:600},children:"Server Status"}),f.jsx(Fe,{children:KB.map(N=>f.jsx(ri,{control:f.jsx(Nb,{value:N}),label:N,onClick:I,checked:v.includes(N)},N))}),f.jsx(Zc,{sx:{mt:"24px",mb:"16px"}}),f.jsx(Sf,{id:"ownership-label",sx:{pb:"16px",fontSize:"14px",fontWeight:600},children:"Ownership"}),f.jsx(Fe,{children:f.jsx(Gm,{"aria-labelledby":"ownership-label",defaultValue:"any",name:"ownership-group",sx:{"& .MuiFormControlLabel-root":{pb:"3px"}},row:!0,children:UB.map(N=>f.jsx(ri,{control:f.jsx(Zm,{value:N}),label:N,onClick:()=>D(N),checked:h===N},N))})}),f.jsx(Fe,{sx:{backgroundColor:"#EEE",p:1,pt:.75,mx:-2,width:"auto",fontSize:"14px"},children:f.jsxs(ec,{children:[f.jsx(at,{id:"clear-filters-btn","data-testid":"clear-filters-btn",variant:"text",sx:{color:"#0F1015",display:"flex",alignItems:"center"},size:"small",onClick:M,children:"Clear"}),f.jsxs(at,{id:"apply-filters-btn",variant:"contained",size:"small",onClick:R,sx:{px:"none !important",minWidth:"20px"},children:["Show ",x," results"]})]})})]})})]})}),f.jsxs(yo,{container:!0,item:!0,xs:8,md:8,direction:"row",sx:{display:"flex",justifyContent:"flex-end",flexWrap:"nowrap"},children:[f.jsx(ot,{children:f.jsxs(Fe,{sx:{display:"flex",flexDirection:"row"},children:[f.jsxs(at,{id:"sort-by-btn",variant:"text",color:"secondary",onClick:N=>c(N.currentTarget),sx:{position:"relative",bottom:"8px",fontSize:"16px",fontWeight:600,color:"common.black",mr:"24px"},endIcon:d?f.jsx(Xd,{}):f.jsx(Ld,{}),children:[f.jsx(X3,{sx:{position:"relative",marginRight:"8px"}}),w]}),f.jsx(Uc,{id:"sort-by-list",anchorEl:l,open:d,onClose:()=>c(null),MenuListProps:{"aria-labelledby":"sort-by-btn"},anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},sx:{transform:"translateX(-85px)",".MuiFormControlLabel-label":{fontSize:"14px"}},children:f.jsx(Fe,{component:"form",name:"sort-by-form",sx:{px:"16px",width:"220px"},children:f.jsx(Gm,{defaultValue:"any",name:"sort-by-group","aria-describedby":"sort-by-label",children:QB.map(N=>f.jsx(ri,{control:f.jsx(Zm,{value:N}),label:N,onClick:()=>S(N),checked:w===N},N))})})})]})}),f.jsx(ot,{children:f.jsxs(Fe,{sx:{display:"flex",alignItems:"center",justifyContent:"space-around",border:"1px solid #DFDFE0",borderRadius:"4px",position:"relative",top:"-6px"},children:[f.jsx(at,{onClick:r,disabled:n,"aria-label":"Grid View",sx:{color:"inherit",backgroundColor:n?"#E8E8EA":"transparent",boxShadow:"none",padding:"5px",minWidth:"auto",borderRadius:"4px 0px 0px 4px",borderRight:"1px solid #DFDFE0","&:hover":{backgroundColor:n?"#E8E8EA":"transparent",boxShadow:"none"}},children:f.jsx(N3,{sx:{color:n?"#2E2F33":"#76777B"}})}),f.jsx(at,{onClick:r,disabled:!n,"aria-label":"Table View",sx:{color:"inherit",backgroundColor:n?"transparent":"#E8E8EA",boxShadow:"none",borderRadius:"0px 4px 4px 0px",padding:"5px",minWidth:"auto","&:hover":{backgroundColor:n?"transparent":"#E8E8EA",boxShadow:"none"}},children:f.jsx(B3,{sx:{color:n?"#76777B":"#2E2F33"}})})]})})]})]})},C_=({apps:e})=>f.jsx(f.Fragment,{children:e.map((t,n)=>g.createElement(xA,{...t,key:`app-${t.id}-${n}`,title:t.name,serverStatus:t.status,lastModified:t.last_activity,isPublic:t.public,isShared:t.shared,app:t}))});var Sy={},D_=ct;Object.defineProperty(Sy,"__esModule",{value:!0});var V3=Sy.default=void 0,S_=D_(ut()),T_=f;V3=Sy.default=(0,S_.default)((0,T_.jsx)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2M9.5 14.67V9.33c0-.79.88-1.27 1.54-.84l4.15 2.67c.61.39.61 1.29 0 1.68l-4.15 2.67c-.66.43-1.54-.05-1.54-.84"}),"PlayCircleRounded");const R_=({apps:e})=>{const[,t]=g.useState(""),[n,r]=g.useState(e),[,o]=Ve(eo),[,s]=Ve(jv),[,i]=Ve(Xg),[,a]=Ve(zv),[,l]=Ve(Ng),c=e.map(d=>d.status);g.useEffect(()=>{c&&t(c.join(", "))},[c,o]),g.useEffect(()=>{r(e)},[e]);const u=(d,p)=>d?f.jsx(Hv,{"data-testid":"PublicRoundedIcon",fontSize:"small",className:"align-vertical-center"}):p?f.jsx(wv,{"data-testid":"GroupRoundedIcon",fontSize:"small",className:"align-vertical-center"}):f.jsx(Eg,{"data-testid":"LockRoundedIcon",fontSize:"small",className:"align-vertical-center"});return f.jsx(f.Fragment,{children:f.jsx(Fe,{sx:{height:"100%",width:"100%"},children:f.jsx(j9,{component:vr,children:f.jsxs(w9,{sx:{minWidth:650},"aria-label":"App table",children:[f.jsx(fB,{children:f.jsxs(yd,{className:"app-header",children:[f.jsx(kn,{children:"Name"}),f.jsx(kn,{children:"Status"}),f.jsx(kn,{children:"Created by"}),f.jsx(kn,{children:"Tags"}),f.jsx(kn,{children:"Actions"})]})}),f.jsx(H9,{children:n.map(d=>f.jsxs(yd,{sx:{"&:last-child td, &:last-child th":{border:0}},children:[f.jsxs(kn,{component:"th",scope:"row",children:[u(d.public,d.shared),f.jsx("span",{className:"inline relative icon-text",children:d.name})]}),f.jsx(kn,{children:f.jsx(D3,{status:d.status,size:"medium"})}),f.jsx(kn,{children:d.username}),f.jsx(kn,{children:f.jsx(mu,{label:d.framework,variant:"outlined",size:"medium"})}),f.jsxs(kn,{children:[d.status==="Running"?f.jsx(at,{onClick:()=>{a(!0),s(d)},"aria-label":"Stop",color:"inherit",size:"small",className:"action-button","data-testid":"StopCircleRoundedIcon",disabled:d.shared,children:f.jsx(Cv,{})}):f.jsx(at,{onClick:()=>{i(!0),s(d)},"aria-label":"Start",color:"inherit",size:"small",className:"action-button","data-testid":"PlayCircleRoundedIcon",disabled:d.status==="Pending"||d.status==="Unknown",style:{borderRadius:"50%",minWidth:"none"},children:f.jsx(V3,{})}),f.jsx(at,{onClick:()=>window.location.href=`${_p}/edit-app?id=${d.id}`,"aria-label":"Edit",color:"inherit",size:"small",className:"action-button","data-testid":"EditRoundedIcon",disabled:d.shared,style:{borderRadius:"50%",minWidth:"none"},children:f.jsx(Ig,{})}),f.jsx(at,{onClick:()=>{l(!0),s(d)},"aria-label":"Delete",color:"inherit",size:"small",className:"action-button","data-testid":"DeleteRoundedIcon",disabled:d.shared,style:{borderRadius:"50%",minWidth:"none"},children:f.jsx(Ov,{})})]})]},d.id))})]})})})})},k_=()=>{const[e,t]=g.useState([]),[,n]=g.useState(""),[r]=Ve(Ko),[o,s]=g.useState(!1),[,i]=Ve(eo),[a,l]=g.useState(!0),[,c]=Ve(w5),[u]=Ve(H5),[d]=Ve(z5),[,p]=Ve(eo),[y]=Ve(O5),[h]=Ve(C5),A=()=>l(x=>!x),{isLoading:w,error:m,data:v}=Ln({queryKey:["app-state"],queryFn:()=>Yt.get("/server/").then(x=>x.data).then(x=>x),enabled:!!r}),P=x=>{const j=x.target;c(j.value),v&&r&&t(kf(v,r,j.value,d,u,y,h))};return g.useEffect(()=>{const x=e.map(j=>j.status);x&&n(x.join(", "))},[e,p,n]),g.useEffect(()=>{if(!w&&v){const x=E5(v,"all",(r==null?void 0:r.name)??"").map(j=>({...j,status:Yg(j)})).sort((j,z)=>j.last_activity>z.last_activity?-1:1);t(x)}},[w,v,r]),g.useEffect(()=>{i(m?m.message:void 0)},[m,i]),f.jsx(f.Fragment,{children:f.jsx(Fe,{children:f.jsxs(Ho,{children:[f.jsx(ot,{children:f.jsxs(yo,{container:!0,spacing:2,alignItems:"center",children:[f.jsx(yo,{item:!0,xs:12,md:4,sx:{padding:"0"},children:f.jsx(ot,{children:f.jsx(Ue,{component:"h2",variant:"h6",children:"App Library"})})}),f.jsxs(yo,{alignItems:"center",container:!0,item:!0,xs:12,md:8,direction:"row",sx:{display:"flex",flexWrap:"nowrap",justifyContent:{xs:"flex-start",md:"flex-end"}},children:[f.jsx(ot,{children:f.jsx(Rs,{id:"search",size:"small",placeholder:"Search Apps...","aria-label":"Search for an app",onChange:P,onFocus:()=>s(!0),onBlur:()=>s(!1),sx:{my:"0",width:{sm:"200px",md:"300px",lg:"600px"},mr:"16px",color:"rgba(15, 16, 21, 0.56)",backgroundColor:"#fff","& .MuiOutlinedInput-root":{"& fieldset":{borderColor:"rgba(15, 16, 21, 0.12)"},"&:hover fieldset":{borderColor:"rgba(15, 16, 21, 0.56)"},"&.Mui-focused fieldset":{borderColor:"#ba18da"}}},InputProps:{startAdornment:f.jsx(rg,{position:"start",children:!o&&f.jsx(M3,{style:{fill:"rgba(15, 16, 21, 0.56)"}})})}})}),f.jsx(ot,{children:f.jsx(at,{id:"create-app",variant:"contained",color:"primary",size:"large",startIcon:f.jsx(dy,{}),onClick:()=>{window.location.href=`${_p}/create-app`},children:"Create App"})})]})]})}),f.jsx(ot,{sx:{pt:"16px",pb:"24px"},children:f.jsx(Zc,{})}),f.jsx(ot,{children:v&&r?f.jsx(O_,{data:v,currentUser:r,setApps:t,isGridViewActive:a,toggleView:A}):f.jsx(f.Fragment,{})}),f.jsx(ot,{children:f.jsx(Fe,{sx:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:2,rowGap:2,justifyContent:"flex-start",paddingBottom:"48px"},children:w?f.jsx("div",{className:"font-bold",children:"Loading..."}):e.length>0?a?f.jsx(C_,{apps:e}):f.jsx(R_,{apps:e}):f.jsx("div",{children:"No apps available"})})})]})})})},E_=({services:e,apps:t})=>f.jsxs(f.Fragment,{children:[t.map((n,r)=>g.createElement(xA,{...n,key:`app-${n.id}-${r}`,title:n.name,serverStatus:n.status,isAppCard:!1,app:n})),e.map((n,r)=>g.createElement(xA,{...n,key:`app-${n.id}-${r}`,title:n.name,serverStatus:n.status,isAppCard:!1}))]}),M_=()=>{const[e]=Ve(Ko),[,t]=Ve(eo),[n,r]=g.useState([]),[o,s]=g.useState([]),{isLoading:i,error:a,data:l}=Ln({queryKey:["service-data"],queryFn:()=>Yt.get("/services/").then(p=>p.data).then(p=>p),enabled:!!e}),{isLoading:c,error:u,data:d}=Ln({queryKey:["app-state"],queryFn:()=>Yt.get("/server/").then(p=>p.data).then(p=>p),enabled:!!e});return g.useEffect(()=>{!i&&l&&e&&r(()=>k5(l,e.name))},[i,l,e]),g.useEffect(()=>{!c&&d&&e&&s(()=>M5(d,e.name))},[c,d,e]),g.useEffect(()=>{t(a?a.message:u?u.message:void 0)},[a,u,t]),f.jsx(Fe,{children:f.jsxs(Ho,{children:[f.jsx(ot,{children:f.jsx(yo,{container:!0,spacing:2,children:f.jsx(yo,{item:!0,xs:12,md:4,children:f.jsx(ot,{children:f.jsx(Ue,{component:"h2",variant:"h6",children:"Quick Access"})})})})}),f.jsx(ot,{sx:{pt:"16px",pb:"24px"},children:f.jsx(Zc,{})}),f.jsx(ot,{children:f.jsx(Fe,{sx:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:"16px",justifyContent:"flex-start",paddingBottom:"48px"},children:i||c?f.jsx("div",{className:"font-bold",children:"Loading..."}):n.length>0||o.length>0?f.jsx(E_,{services:n,apps:o}):f.jsx("div",{children:"No services available"})})})]})})},L_=()=>f.jsx(Wf,{sx:{backgroundColor:"green",color:"white",borderRadius:"50%",padding:"2px"},children:f.jsx(E3,{})}),j1=()=>{const[,e]=Ve(eo),[t,n]=Ve(jv),[r]=Ve(Ko),[o,s]=g.useState(null),[i,a]=Ve(Xg),[l,c]=Ve(zv),[u,d]=Ve(Ng),[p,y]=Ve(D5),[h,A]=g.useState(!1),w=$p(),[m,v]=g.useState(!1),[P,x]=g.useState(""),j=async({id:T})=>await Yt.post(`/server/${T}`),z=async({id:T,remove:B})=>await Yt.delete(`/server/${T}`,{params:{remove:B}}),{data:H}=Ln({queryKey:["app-form",o],queryFn:()=>Yt.get(`/server/${o}`).then(T=>T.data),enabled:!!o}),{mutate:O}=_a({mutationFn:j,retry:1}),{mutate:D}=_a({mutationFn:z,retry:1}),S=()=>{const T=(t==null?void 0:t.id)||"";A(!0),D({id:T,remove:!0},{onSuccess:async()=>{A(!1),d(!1),w.invalidateQueries({queryKey:["app-state"]}),x("App deleted successfully"),v(!0)},onError:async B=>{A(!1),e(B.message)}})},I=async()=>{const T=(t==null?void 0:t.id)||"";A(!0),O({id:T},{onSuccess:async()=>{A(!1),a(!1),y(!1),w.invalidateQueries({queryKey:["app-state"]})},onError:B=>{A(!1),e(B.message)}})},R=async()=>{const T=(t==null?void 0:t.id)||"";A(!0),D({id:T,remove:!1},{onSuccess:()=>{A(!1),c(!1),w.invalidateQueries({queryKey:["app-state"]}),x("Server stopped successfully"),v(!0)},onError:B=>{A(!1),e(B.message)}})},M=async()=>{if(!r||!t){A(!1);return}window.location.assign($G(r,t))},W=f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"card-dialog-body-wrapper",children:[f.jsxs("p",{className:"card-dialog-body",children:["Are you sure you want to start ",f.jsx("b",{children:t==null?void 0:t.name}),"?"]}),f.jsx("p",{className:"card-dialog-note",children:"This action starts a new server that consumes resources."})]}),f.jsxs(ec,{className:"card-dialog-button-group",children:[f.jsx(at,{id:"cancel-btn","data-testid":"cancel-btn",variant:"text",color:"primary",onClick:()=>a(!1),sx:{fontWeight:700},children:"Cancel"}),f.jsx(at,{id:"start-btn","data-testid":"start-btn",variant:"contained",color:"primary",onClick:I,disabled:h,children:"Start"})]})]}),N=f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"card-dialog-body-wrapper",children:f.jsxs("p",{className:"card-dialog-body",children:["Are you sure you want to stop ",f.jsx("b",{children:t==null?void 0:t.name}),"?"]})}),f.jsxs(ec,{className:"card-dialog-button-group",children:[f.jsx(at,{id:"cancel-btn",variant:"text",color:"primary",onClick:()=>c(!1),sx:{fontWeight:700},children:"Cancel"}),f.jsx(at,{id:"stop-btn",variant:"contained",color:"primary",onClick:R,disabled:h,children:"Stop"})]})]}),Z=f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"card-dialog-body-wrapper",children:[f.jsxs("p",{className:"card-dialog-body",children:["Are you sure you want to delete ",f.jsx("b",{children:t==null?void 0:t.name}),"?"]}),f.jsx("p",{className:"card-dialog-note",children:"This action is permanent and cannot be reversed."})]}),f.jsxs(ec,{className:"card-dialog-button-group",children:[f.jsx(at,{id:"cancel-btn","data-testid":"cancel-btn",variant:"text",color:"primary",onClick:()=>d(!1),sx:{fontWeight:700},children:"Cancel"}),f.jsx(at,{id:"delete-btn","data-testid":"delete-btn",variant:"contained",color:"error",onClick:S,disabled:h,children:"Delete"})]})]}),J=f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"card-dialog-body-wrapper",children:[f.jsxs("p",{className:"card-dialog-body",children:["Would you like to start ",f.jsx("b",{children:t==null?void 0:t.name}),"?"]}),f.jsx("p",{className:"card-dialog-note",children:"This action starts a new server that consumes resources."})]}),f.jsxs(ec,{className:"card-dialog-button-group",children:[f.jsx(at,{id:"cancel-btn","data-testid":"cancel-btn",variant:"text",color:"primary",onClick:()=>{Th(),y(!1)},sx:{fontWeight:700},children:"Cancel"}),f.jsx(at,{id:"start-btn","data-testid":"start-btn",variant:"contained",color:"primary",onClick:()=>{Th(),tU((t==null?void 0:t.name)||"")?M():I()},disabled:h,children:"Start"})]})]});return g.useEffect(()=>{if(H&&!H.started&&o){let T=H.user_options.display_name;!T&&o==="lab"?T="JupyterLab":!T&&o==="vscode"&&(T="VSCode"),n({id:o,name:T,framework:H.user_options.framework,url:H.url,ready:H.ready,public:H.user_options.public,shared:!1,last_activity:new Date(H.last_activity),status:"Ready"}),y(!0),Th()}},[H,o,y,n]),g.useEffect(()=>{const T=nU();T&&s(T)},[s]),f.jsxs(Fe,{sx:{flexGrow:1},className:"container",children:[f.jsx(yo,{container:!0,spacing:2,paddingBottom:"24px",children:f.jsx(yo,{item:!0,xs:12,md:2,children:f.jsx(ot,{children:f.jsx(Ue,{component:"h1",variant:"h5",children:"Home"})})})}),f.jsx(M_,{}),f.jsx(k_,{}),i&&f.jsxs(Gl,{open:i,onClose:()=>a(!1),"data-testid":"StartModal",sx:{".MuiPaper-root":{width:"444px"}},children:[f.jsx(_u,{sx:{fontWeight:700},children:"Start App"}),f.jsx(Ku,{sx:{padding:"0px"},children:W})]}),l&&f.jsxs(Gl,{open:l,onClose:()=>c(!1),"data-testid":"StopModal",sx:{".MuiPaper-root":{width:"444px"}},children:[f.jsx(_u,{sx:{fontWeight:700,pb:1},children:"Stop App"}),f.jsx(Ku,{sx:{padding:"0px"},children:N})]}),u&&f.jsxs(Gl,{open:u,onClose:()=>d(!1),"data-testid":"DeleteModal",sx:{".MuiPaper-root":{width:"444px"}},children:[f.jsx(_u,{sx:{fontWeight:700},children:"Delete App"}),f.jsx(Ku,{sx:{padding:"0px"},children:Z})]}),p&&f.jsxs(Gl,{open:p,onClose:()=>y(!1),"data-testid":"StartNotRunningModal",sx:{".MuiPaper-root":{width:"444px"}},children:[f.jsx(_u,{sx:{fontWeight:700},children:"Server Not Running"}),f.jsx(Ku,{sx:{padding:"0px"},children:J})]}),f.jsx(lN,{open:m,autoHideDuration:6e3,onClose:()=>v(!1),anchorOrigin:{vertical:"top",horizontal:"center"},sx:{top:"90px !important"},children:f.jsx(qP,{onClose:()=>v(!1),severity:"success",icon:f.jsx(L_,{}),sx:{width:"100%",backgroundColor:"success.main",color:"rgba(30, 70, 32, 1)",fontFamily:"Inter, sans-serif",fontWeight:600},children:P})})]})},X_=()=>{const[e,t]=Ce.useState(null),[n]=Ve(Ko),{data:r}=Ln({queryKey:["app-form",e],queryFn:()=>Yt.get(`/server/${e}`).then(o=>o.data),enabled:!!e});return g.useEffect(()=>{if(n){const o=window.location.pathname.replace(/\/$/,"").split("/").pop();o&&t(o)}},[n]),g.useEffect(()=>{r&&(r!=null&&r.started?window.location.assign(window.location.href.replace("/hub","")):r!=null&&r.pending&&n&&e?window.location.assign(eU(n,e)):(r!=null&&r.stopped&&e&&rU(e),window.location.assign($t)))},[r,e,n]),f.jsx(Fe,{sx:{margin:"auto auto"},children:f.jsx(tg,{})})};function N_(e){return De("MuiLoadingButton",e)}const B_=Se("MuiLoadingButton",["root","loading","loadingIndicator","loadingIndicatorCenter","loadingIndicatorStart","loadingIndicatorEnd","endIconLoadingEnd","startIconLoadingStart"]),To=B_,V_=["children","disabled","id","loading","loadingIndicator","loadingPosition","variant"],I_=e=>{const{loading:t,loadingPosition:n,classes:r}=e,o={root:["root",t&&"loading"],startIcon:[t&&`startIconLoading${te(n)}`],endIcon:[t&&`endIconLoading${te(n)}`],loadingIndicator:["loadingIndicator",t&&`loadingIndicator${te(n)}`]},s=Te(o,N_,r);return b({},r,s)},W_=e=>e!=="ownerState"&&e!=="theme"&&e!=="sx"&&e!=="as"&&e!=="classes",J_=_(at,{shouldForwardProp:e=>W_(e)||e==="classes",name:"MuiLoadingButton",slot:"Root",overridesResolver:(e,t)=>[t.root,t.startIconLoadingStart&&{[`& .${To.startIconLoadingStart}`]:t.startIconLoadingStart},t.endIconLoadingEnd&&{[`& .${To.endIconLoadingEnd}`]:t.endIconLoadingEnd}]})(({ownerState:e,theme:t})=>b({[`& .${To.startIconLoadingStart}, & .${To.endIconLoadingEnd}`]:{transition:t.transitions.create(["opacity"],{duration:t.transitions.duration.short}),opacity:0}},e.loadingPosition==="center"&&{transition:t.transitions.create(["background-color","box-shadow","border-color"],{duration:t.transitions.duration.short}),[`&.${To.loading}`]:{color:"transparent"}},e.loadingPosition==="start"&&e.fullWidth&&{[`& .${To.startIconLoadingStart}, & .${To.endIconLoadingEnd}`]:{transition:t.transitions.create(["opacity"],{duration:t.transitions.duration.short}),opacity:0,marginRight:-8}},e.loadingPosition==="end"&&e.fullWidth&&{[`& .${To.startIconLoadingStart}, & .${To.endIconLoadingEnd}`]:{transition:t.transitions.create(["opacity"],{duration:t.transitions.duration.short}),opacity:0,marginLeft:-8}})),F_=_("span",{name:"MuiLoadingButton",slot:"LoadingIndicator",overridesResolver:(e,t)=>{const{ownerState:n}=e;return[t.loadingIndicator,t[`loadingIndicator${te(n.loadingPosition)}`]]}})(({theme:e,ownerState:t})=>b({position:"absolute",visibility:"visible",display:"flex"},t.loadingPosition==="start"&&(t.variant==="outlined"||t.variant==="contained")&&{left:t.size==="small"?10:14},t.loadingPosition==="start"&&t.variant==="text"&&{left:6},t.loadingPosition==="center"&&{left:"50%",transform:"translate(-50%)",color:(e.vars||e).palette.action.disabled},t.loadingPosition==="end"&&(t.variant==="outlined"||t.variant==="contained")&&{right:t.size==="small"?10:14},t.loadingPosition==="end"&&t.variant==="text"&&{right:6},t.loadingPosition==="start"&&t.fullWidth&&{position:"relative",left:-10},t.loadingPosition==="end"&&t.fullWidth&&{position:"relative",right:-10})),Y_=g.forwardRef(function(t,n){const r=g.useContext(U2),o=cp(r,t),s=Re({props:o,name:"MuiLoadingButton"}),{children:i,disabled:a=!1,id:l,loading:c=!1,loadingIndicator:u,loadingPosition:d="center",variant:p="text"}=s,y=ce(s,V_),h=xo(l),A=u??f.jsx(tg,{"aria-labelledby":h,color:"inherit",size:16}),w=b({},s,{disabled:a,loading:c,loadingIndicator:A,loadingPosition:d,variant:p}),m=I_(w),v=c?f.jsx(F_,{className:m.loadingIndicator,ownerState:w,children:A}):null;return f.jsxs(J_,b({disabled:a||c,id:h,ref:n},y,{variant:p,classes:m,ownerState:w,children:[w.loadingPosition==="end"?i:v,w.loadingPosition==="end"?v:i]}))}),q_=Y_,Z_=()=>{const[e]=K9(),t=vg(),n=$p(),[r,o]=g.useState(!1),[s]=Ve(Ko),[,i]=Ve(eo),[a,l]=Ve(y5),[c]=Ve(g5),[u]=Ve(x5),[d]=Ve(b5),[,p]=Ve(eo),[y,h]=Ce.useState((a==null?void 0:a.profile)||""),A=e.get("id"),{data:w,isLoading:m,error:v}=Ln({queryKey:["server-types"],queryFn:()=>Yt.get("/spawner-profiles/").then(D=>D.data).then(D=>D),enabled:!!s}),P=D=>{h(D),a&&l({...a,profile:D})},x=D=>{var R,M;D.preventDefault();const S=(a==null?void 0:a.display_name)||"",I={servername:c||S,user_options:{jhub_app:!0,display_name:(a==null?void 0:a.display_name)||"",description:(a==null?void 0:a.description)||"",framework:(a==null?void 0:a.framework)||"",thumbnail:(a==null?void 0:a.thumbnail)||"",filepath:(a==null?void 0:a.filepath)||"",conda_env:(a==null?void 0:a.conda_env)||"",env:bA(a==null?void 0:a.env),custom_command:(a==null?void 0:a.custom_command)||"",profile:(a==null?void 0:a.profile)||"",public:(a==null?void 0:a.is_public)||!1,share_with:{users:((R=a==null?void 0:a.share_with)==null?void 0:R.users)||[],groups:((M=a==null?void 0:a.share_with)==null?void 0:M.groups)||[]},keep_alive:(a==null?void 0:a.keep_alive)||!1}};o(!0),A?O(I,{onSuccess:async()=>{n.invalidateQueries({queryKey:["app-state"]}),window.location.assign($t)},onError:async W=>{o(!1),p(W.message)}}):H(I,{onSuccess:async W=>{const N=s==null?void 0:s.name;if(N&&(W==null?void 0:W.length)>1){const Z=W[1];window.location.assign(`/hub/spawn-pending/${N}/${Z}`)}},onError:async W=>{o(!1),p(W.message)}})},j=async({servername:D,user_options:S})=>{const I={accept:"application/json","Content-Type":"multipart/form-data"},R=new FormData;return R.append("data",JSON.stringify({servername:D,user_options:S})),u&&R.append("thumbnail",u),(await Yt.post("/server",R,{headers:I})).data},z=async({servername:D,user_options:S})=>{const I={accept:"application/json","Content-Type":"multipart/form-data"},R=new FormData;return R.append("data",JSON.stringify({servername:D,user_options:S})),u?R.append("thumbnail",u):d&&R.append("thumbnail_data_url",d),(await Yt.put(`/server/${D}`,R,{headers:I})).data},{mutate:H}=_a({mutationFn:j,retry:1}),{mutate:O}=_a({mutationFn:z,retry:1});return g.useEffect(()=>{i(v?v.message:void 0)},[v,i]),f.jsx(Fe,{className:"container",children:f.jsxs(Ho,{children:[f.jsx(ot,{children:f.jsx("div",{className:"form-breadcrumb",children:f.jsx(at,{id:"back-btn",type:"button",variant:"text",color:"primary",startIcon:f.jsx(Lv,{}),onClick:()=>Bo($t),children:"Back To Home"})})}),f.jsxs(ot,{children:[f.jsx(Ue,{component:"h1",variant:"h5",children:"Server Type"}),f.jsxs(wy,{children:["Please select the appropriate server for your app. For more information on server types,"," ",f.jsx("span",{children:f.jsx("a",{href:"https://www.nebari.dev/docs/welcome",target:"_blank",rel:"noopener noreferrer",className:"form-paragraph-link",children:"visit our docs"})}),"."]})]}),f.jsx(ot,{children:m?f.jsx("div",{className:"font-bold center",children:"Loading..."}):w&&w.length>0?f.jsxs("form",{className:"form",onSubmit:x,children:[f.jsx(Qi,{sx:{pb:"36px"},children:f.jsx(Gm,{children:w==null?void 0:w.map((D,S)=>f.jsx(K2,{className:"server-type-card",onClick:()=>P(D.slug),tabIndex:0,children:f.jsxs(Jm,{children:[f.jsx(ri,{value:D.slug,id:D.slug,control:f.jsx(Zm,{checked:y?y===D.slug:S===0}),label:D.display_name},D.slug),f.jsx("p",{children:D.description})]})},`server-type-card-${D.slug}`))})}),f.jsx("hr",{}),f.jsxs("div",{className:"button-section",children:[f.jsx("div",{className:"prev",children:f.jsx(at,{id:"cancel-btn",type:"button",variant:"text",color:"primary",onClick:()=>t(A?`/edit-app?id=${A}`:"/create-app"),children:"Back"})}),f.jsx("div",{className:"next",children:f.jsx(q_,{id:"submit-btn",type:"submit",variant:"contained",color:"primary",loading:r,children:A?"Save":"Create App"})})]})]}):f.jsx("div",{children:"No servers available"})})]})})},G_=()=>f.jsxs(Fe,{id:"stop-pending",className:"container",display:"flex",flexDirection:"column",alignItems:"center",textAlign:"center",padding:"20px",children:[f.jsxs(Fe,{display:"flex",flexDirection:"column",alignItems:"center",textAlign:"center",children:[f.jsxs(Ue,{variant:"h5",component:"h1",gutterBottom:!0,sx:{paddingBottom:"0 !important"},children:["Thank you for your patience",f.jsx("br",{}),"We are stopping your application, you may start it again when we have finished"]}),f.jsx(tg,{style:{color:"#a020f0",margin:"20px 0"}})]}),f.jsxs(Fe,{sx:{marginTop:"4rem"},children:[f.jsx(Ue,{variant:"body1",gutterBottom:!0,children:"You may return to the Application Screen at any time"}),f.jsx(at,{id:"back-btn",variant:"contained",color:"primary",style:{backgroundColor:"#a020f0"},onClick:()=>Bo(`${$t}`),children:"Back To Home"})]})]}),U_=()=>{const[,e]=Ve(DG),[,t]=Ve(Ko),[,n]=Ve(j5),[r,o]=Ve(eo),{error:s,data:i}=Ln({queryKey:["user-state"],queryFn:()=>Yt.get("/user").then(c=>c.data).then(c=>c)}),{error:a,data:l}=Ln({queryKey:["server-types"],queryFn:()=>Yt.get("/spawner-profiles/").then(c=>c.data).then(c=>c)});return g.useEffect(()=>{s?o(s.message):a&&o(a.message)},[s,a,o]),g.useEffect(()=>{e(GG())},[e]),g.useEffect(()=>{i&&t({...i})},[i,t]),g.useEffect(()=>{l&&n([...l])},[l,n]),f.jsxs("div",{children:[f.jsx(IK,{}),f.jsxs(Fe,{component:"main",sx:{flexGrow:1,pt:9,pl:{xs:1,sm:33},pr:1,backgroundColor:"#fafbfc"},children:[r?f.jsx(WK,{message:r,onClose:()=>o(void 0)}):f.jsx(f.Fragment,{}),f.jsxs(yI,{children:[f.jsx(rs,{path:"/home",element:f.jsx(j1,{})}),f.jsx(rs,{path:"/user/:id/*",element:f.jsx(X_,{})}),f.jsx(rs,{path:"/create-app",element:f.jsx(i_,{})}),f.jsx(rs,{path:"/edit-app",element:f.jsx(a_,{})}),f.jsx(rs,{path:"/server-types",element:f.jsx(Z_,{})}),f.jsx(rs,{path:"/stop-pending",element:f.jsx(G_,{})}),f.jsx(rs,{path:"/",element:f.jsx(j1,{})})]})]})]})},Br={50:"#FAFBFC",100:"#2491FF",200:"#2491FF",300:"#2491FF",400:"#2491FF",500:"#005EA2",600:"#1A4480",700:"#1A4480",800:"#1A4480",900:"#162E51"},Qt={50:"rgba(0, 0, 0, .08)",100:"#E1E3E4",200:"#EEEEEE",300:"#E0E0E0",400:"#90969C",500:"#5B5F63",600:"#44474A",700:"#3C3C3B",800:"#242628",900:"#1A1C1D"},qs="#BA18DA",Bh="#BA18DA10",z1="#9B00CE",qi="#18817A",Q_="#18817A10",K_="#12635E",__="#D72D47",$_="#F66A0A",Vr="#FFFFFF",uf="#0F1015",ff="#0F101561",e$=Qt[100],Vl=vp({typography:{fontFamily:'"Inter", sans-serif',h1:{letterSpacing:"-1.5px",fontSize:"96px"},h2:{letterSpacing:"0.5px",fontSize:"60px"},h3:{letterSpacing:"0px",fontSize:"48px"},h4:{letterSpacing:"0.25px",fontSize:"34px"},h5:{letterSpacing:"0px",fontSize:"24px",fontWeight:600,paddingBottom:"16px"},h6:{letterSpacing:"0.15px",fontSize:"20px",fontWeight:700,paddingBottom:"16px"},subtitle1:{letterSpacing:"0.15px",fontSize:"16px",fontWeight:600,paddingBottom:"24px"},subtitle2:{letterSpacing:"0.1px",fontSize:"14px",fontWeight:500,paddingBottom:"24px"},body1:{letterSpacing:"0.15px",fontSize:"16px"},body2:{letterSpacing:"0.17px",fontSize:"14px"},caption:{letterSpacing:"0.4px"},overline:{letterSpacing:"1px",fontSize:"12px"}},components:{MuiButtonBase:{defaultProps:{disableRipple:!0,style:{textTransform:"none",textWrap:"nowrap"}}},MuiFormControl:{defaultProps:{fullWidth:!0,sx:{marginBottom:"24px"}}},MuiTextField:{defaultProps:{autoComplete:"off",fullWidth:!0,sx:{marginBottom:"0"}}},MuiSelect:{defaultProps:{fullWidth:!0}}}}),t$=vp(Vl,{palette:{primary:Vl.palette.augmentColor({color:{light:Bh,main:qs,dark:z1,contrastText:Vr},name:"primary"}),secondary:Vl.palette.augmentColor({color:{light:Q_,main:qi,dark:K_,contrastText:Vr},name:"secondary"}),blue:Vl.palette.augmentColor({color:{50:Br[50],100:Br[100],200:Br[200],300:Br[300],400:Br[400],500:Br[500],600:Br[600],700:Br[700],800:Br[800],900:Br[900]},name:"blue"}),gray:Vl.palette.augmentColor({color:{light:Qt[300],lighter:e$,main:Qt[500],dark:Qt[700],contrastText:uf,50:Qt[50],100:Qt[100],200:Qt[200],300:Qt[300],400:Qt[400],500:Qt[500],600:Qt[600],700:Qt[700],800:Qt[800],900:Qt[900]},name:"gray"}),warning:{main:$_,contrastText:Vr},error:{main:__,contrastText:Vr},info:{main:Br,contrastText:Vr},success:{main:qi[500],contrastText:Vr},common:{black:uf,white:Vr}},components:{MuiButton:{variants:[{props:{variant:"contained",color:"primary"},style:{backgroundColor:`${qs}`,fontWeight:700,"&:hover":{backgroundColor:`${z1}`},"&:disabled":{color:ff}}},{props:{variant:"contained",color:"secondary"},style:{backgroundColor:Qt[200],border:`1px solid ${Qt[200]}`,color:uf,fontWeight:600,"&:hover":{backgroundColor:Qt[300],border:`1px solid ${Qt[300]}`},"&:disabled":{color:ff,borderColor:"transparent"}}},{props:{variant:"contained",color:"error"},style:{fontWeight:600}},{props:{variant:"outlined",color:"primary"},style:{backgroundColor:Vr,border:`2px solid ${qs}`,color:`${qs}`,fontWeight:700,textTransform:"none","&:hover":{backgroundColor:Vr,borderWidth:2,border:`2px solid ${qs}`,color:`${qs}`}}},{props:{variant:"outlined",color:"secondary"},style:{backgroundColor:Vr,border:`2px solid ${qi}`,color:`${qi}`,fontWeight:700,textTransform:"none","&:hover":{backgroundColor:Vr,borderWidth:2,border:`2px solid ${qi}`,color:`${qi}`}}},{props:{variant:"text",color:"primary"},style:{color:`${qs}`,"&:hover":{backgroundColor:`${Bh}`},"&:focus":{backgroundColor:`${Bh}`},"&:disabled":{color:ff}}},{props:{variant:"text",color:"secondary"},style:{color:uf,"&:hover":{backgroundColor:`${Qt[50]}`},"&:focus":{backgroundColor:`${Qt[50]}`},"&:disabled":{color:ff}}}]}}}),n$=new URL(window.location.href),r$=new pV;aA.createRoot(document.getElementById("root")).render(f.jsx(Ce.StrictMode,{children:f.jsx(HI,{basename:n$.pathname.indexOf("hub")===-1?_p:$t,children:f.jsx(hG,{children:f.jsxs(qz,{theme:t$,children:[f.jsx(AE,{}),f.jsx(PV,{client:r$,children:f.jsx(U_,{})})]})})})})); +*/(function(e){(function(){var t={}.hasOwnProperty;function n(){for(var s="",i=0;i{const r=yK("button-group",t);return f.jsx("ul",{id:e,className:r,children:g.Children.map(n,(o,s)=>f.jsx("li",{className:"button-group-item",children:o},s))})};var fy={},bK=ct;Object.defineProperty(fy,"__esModule",{value:!0});var dy=fy.default=void 0,xK=bK(ut()),wK=f;dy=fy.default=(0,xK.default)((0,wK.jsx)("path",{d:"M18 13h-5v5c0 .55-.45 1-1 1s-1-.45-1-1v-5H6c-.55 0-1-.45-1-1s.45-1 1-1h5V6c0-.55.45-1 1-1s1 .45 1 1v5h5c.55 0 1 .45 1 1s-.45 1-1 1"}),"AddRounded");var py={},HK=ct;Object.defineProperty(py,"__esModule",{value:!0});var z3=py.default=void 0,jK=HK(ut()),zK=f;z3=py.default=(0,jK.default)((0,zK.jsx)("path",{d:"M18.3 5.71a.9959.9959 0 0 0-1.41 0L12 10.59 7.11 5.7a.9959.9959 0 0 0-1.41 0c-.39.39-.39 1.02 0 1.41L10.59 12 5.7 16.89c-.39.39-.39 1.02 0 1.41.39.39 1.02.39 1.41 0L12 13.41l4.89 4.89c.39.39 1.02.39 1.41 0 .39-.39.39-1.02 0-1.41L13.41 12l4.89-4.89c.38-.38.38-1.02 0-1.4"}),"CloseRounded");const OK=({variables:e,setVariables:t})=>{const[n,r]=g.useState([]),o=l=>{if(!l||l.length===0)return null;const c={};return l.forEach(u=>{u.key&&(c[u.key]=u.value)}),c},s=(l,c)=>{const u=[...n];c.target.name==="key"?u[l].key=c.target.value:u[l].value=c.target.value,r(u),t(o(u))},i=()=>{r([...n,{key:"",value:""}])},a=l=>{const c=[...n];c.splice(l,1),r(c),t(o(c))};return g.useEffect(()=>{e&&n.length===0&&r(()=>{const l=[];for(const[c,u]of Object.entries(e))l.push({key:c,value:u});return l})},[e,n.length]),f.jsx(Fe,{id:"environment-variables",children:f.jsxs(Ho,{children:[n.length>0?f.jsx(ot,{sx:{pb:"16px"},children:n.map((l,c)=>f.jsxs(Ho,{direction:"row",gap:1,sx:{pb:"16px"},children:[f.jsx(ot,{sx:{width:"100%"},children:f.jsx(Rs,{id:`environment-variable-key-${c}`,name:"key",label:"Key",placeholder:"Key",value:l.key,onChange:u=>s(c,u)})}),f.jsx(ot,{sx:{width:"100%"},children:f.jsx(Rs,{id:`environment-variable-value-${c}`,name:"value",label:"Value",placeholder:"Value",value:l.value,onChange:u=>s(c,u)})}),f.jsx(ot,{children:f.jsx(qn,{sx:{mt:"7px"},onClick:()=>a(c),"aria-label":"Remove",children:f.jsx(z3,{})})})]},`environment-variable-row-${c}`))}):f.jsx(f.Fragment,{}),f.jsx(ot,{children:f.jsx(at,{variant:"contained",color:"secondary",startIcon:f.jsx(dy,{}),onClick:i,sx:{},children:"Add Variable"})})]})})};var vy={},CK=ct;Object.defineProperty(vy,"__esModule",{value:!0});var O3=vy.default=void 0,DK=CK(ut()),SK=f;O3=vy.default=(0,DK.default)((0,SK.jsx)("path",{d:"M10 19v-5h4v5c0 .55.45 1 1 1h3c.55 0 1-.45 1-1v-7h1.7c.46 0 .68-.57.33-.87L12.67 3.6c-.38-.34-.96-.34-1.34 0l-8.36 7.53c-.34.3-.13.87.33.87H5v7c0 .55.45 1 1 1h3c.55 0 1-.45 1-1"}),"HomeRounded");var hy={},TK=ct;Object.defineProperty(hy,"__esModule",{value:!0});var Ld=hy.default=void 0,RK=TK(ut()),kK=f;Ld=hy.default=(0,RK.default)((0,kK.jsx)("path",{d:"M8.12 9.29 12 13.17l3.88-3.88c.39-.39 1.02-.39 1.41 0 .39.39.39 1.02 0 1.41l-4.59 4.59c-.39.39-1.02.39-1.41 0L6.7 10.7a.9959.9959 0 0 1 0-1.41c.39-.38 1.03-.39 1.42 0"}),"KeyboardArrowDownRounded");var my={},EK=ct;Object.defineProperty(my,"__esModule",{value:!0});var Xd=my.default=void 0,MK=EK(ut()),LK=f;Xd=my.default=(0,MK.default)((0,LK.jsx)("path",{d:"M8.12 14.71 12 10.83l3.88 3.88c.39.39 1.02.39 1.41 0 .39-.39.39-1.02 0-1.41L12.7 8.71a.9959.9959 0 0 0-1.41 0L6.7 13.3c-.39.39-.39 1.02 0 1.41.39.38 1.03.39 1.42 0"}),"KeyboardArrowUpRounded");var Ay={},XK=ct;Object.defineProperty(Ay,"__esModule",{value:!0});var C3=Ay.default=void 0,NK=XK(ut()),BK=f;C3=Ay.default=(0,NK.default)((0,BK.jsx)("path",{d:"M3 18h18v-2H3zm0-5h18v-2H3zm0-7v2h18V6z"}),"Menu");_(ca)(({theme:e})=>({fontWeight:400,fontSize:"16px",paddingLeft:e.spacing(4),paddingTop:e.spacing(1),paddingBottom:e.spacing(1)}));const VK=_(ca)(({theme:e})=>({fontWeight:400,fontSize:"16px",paddingTop:e.spacing(1),paddingBottom:e.spacing(1)}));_(u9)(({theme:e})=>({paddingLeft:e.spacing(4)}));const IK=({...e})=>{const t=Ar(),[n,r]=Ce.useState(null),o=!!n,s=vM(t.breakpoints.down("sm")),{window:i}=e,[a,l]=g.useState(!s),[c]=Ve(Ko),[,u]=Ve(eo),[d,p]=g.useState([]),[y,h]=g.useState([]),[A,w]=g.useState([]),{isLoading:m,error:v,data:P}=Ln({queryKey:["app-state"],queryFn:()=>Yt.get("/server/").then(D=>D.data).then(D=>D),enabled:!!c}),{isLoading:x,error:j,data:z}=Ln({queryKey:["service-data"],queryFn:()=>Yt.get("/services/").then(D=>D.data).then(D=>D),enabled:!!c}),H=()=>{l(D=>!D)};g.useEffect(()=>{!m&&P&&c&&h(()=>M5(P,c.name))},[m,P,c]),g.useEffect(()=>{!x&&z&&c&&(p(()=>R5(z,c.name).filter(D=>!ag.includes(D.name))),w(()=>k5(z,c.name)))},[x,z,c]),g.useEffect(()=>{u(j?j.message:v?v.message:void 0)},[j,v,u]),g.useEffect(()=>{l(!s)},[s]);const O=f.jsxs(Fe,{children:[f.jsx(qm,{children:f.jsx(Ol,{disablePadding:!0,sx:{mt:10},children:f.jsxs(u9,{sx:{px:"1.5rem",mx:".5rem",backgroundColor:t.palette.primary.light,borderRadius:"8px",position:"relative",display:"flex",alignItems:"center","&::before":{content:'""',position:"absolute",left:0,top:0,bottom:0,width:"8px",backgroundColor:t.palette.primary.main,borderTopLeftRadius:"8px",borderBottomLeftRadius:"8px"},"&:hover":{backgroundColor:t.palette.gray[50],"&::before":{backgroundColor:t.palette.primary.main}}},onClick:()=>Bo(`${$t}`),children:[f.jsx(gL,{sx:{minWidth:"auto",mr:"8px",display:"flex",alignItems:"center"},children:f.jsx(O3,{sx:{color:t.palette.common.black,width:"28px",height:"28px"}})}),f.jsx(ca,{primary:f.jsx(Ue,{variant:"body1",sx:{fontSize:"16px",fontWeight:600,lineHeight:"1.2",position:"relative",top:"2px"},children:"Home"})})]})})}),f.jsxs(qm,{sx:{px:1},children:[f.jsx(Ol,{disablePadding:!0,children:f.jsx(VK,{primary:"Services",disableTypography:!0,sx:{px:"24px",py:"4px",fontSize:"14px",textTransform:"uppercase",fontWeight:600,color:"rgba(15 16 21 / 60%)"}})}),y.map((D,S)=>f.jsx(Ol,{disablePadding:!0,children:f.jsx(Ql,{href:D.url,sx:{borderRadius:"4px",textDecoration:"none",display:"block",width:"100%",px:"24px",py:"4px",color:"rgb(15 16 21 / 87%)","&:hover":{backgroundColor:"rgba(0, 0, 0, 0.04)",textDecoration:"none"}},children:f.jsx(ca,{primary:f.jsx(Ue,{variant:"body2",sx:{fontSize:"1rem",color:"rgb(15 16 21 / 87%)"},children:D.name})})})},S)),A.map((D,S)=>f.jsx(Ol,{disablePadding:!0,children:f.jsx(Ql,{href:D.url,sx:{borderRadius:"4px",textDecoration:"none",display:"block",width:"100%",px:"24px",py:"4px",color:"rgb(15 16 21 / 87%)","&:hover":{backgroundColor:"rgba(0, 0, 0, 0.04)",textDecoration:"none"}},children:f.jsx(ca,{primary:f.jsx(Ue,{variant:"body2",sx:{fontSize:"1rem",color:"rgb(15 16 21 / 87%)"},children:D.name})})})},S)),d.map((D,S)=>f.jsx(Ol,{disablePadding:!0,children:f.jsx(Ql,{href:D.url,sx:{borderRadius:"4px",textDecoration:"none",display:"block",width:"100%",px:"24px",py:"4px",color:"rgb(15 16 21 / 87%)","&:hover":{backgroundColor:"rgba(0, 0, 0, 0.04)",textDecoration:"none"}},children:f.jsx(ca,{primary:f.jsx(Ue,{variant:"body2",sx:{fontSize:"1rem",color:"rgb(15 16 21 / 87%)"},children:D.name})})})},S))]})]});return f.jsxs(Fe,{sx:{flexGrow:1},children:[f.jsx(hS,{id:"app-bar",position:"fixed",sx:{zIndex:D=>D.zIndex.drawer+1,backgroundColor:D=>D.palette.common.white},children:f.jsxs(z9,{id:"toolbar",children:[f.jsx(qn,{color:"inherit","aria-label":"open drawer",edge:"start",onClick:H,sx:{mr:2,display:{sm:"none"}},children:f.jsx(C3,{})}),f.jsx(Fe,{component:"div",sx:{flexGrow:1,display:{xs:"none",sm:"block"}},children:f.jsx(Ql,{href:$t,children:f.jsx("img",{src:_G(),alt:"logo",height:"28"})})}),f.jsxs(Fe,{sx:{display:{xs:"none",sm:"block"}},children:[f.jsxs(at,{id:"profile-menu-btn",className:"button-menu","aria-controls":o?"profile-menu-list":void 0,"aria-haspopup":"true","aria-expanded":o?"true":void 0,onClick:D=>r(D.currentTarget),endIcon:o?f.jsx(Xd,{}):f.jsx(Ld,{}),sx:{"&:hover":{backgroundColor:t.palette.gray[50]}},children:[c==null?void 0:c.name," ",(c==null?void 0:c.admin)&&f.jsx(mu,{label:"admin",size:"small",className:"chip",sx:{marginLeft:t.spacing(1)}})]}),f.jsxs(Uc,{id:"profile-menu-list",anchorEl:n,open:o,onClose:()=>r(null),MenuListProps:{"aria-labelledby":"profile-menu-btn"},sx:{marginTop:"20px"},children:[f.jsx(vo,{onClick:()=>Bo(`${$t}/token`),sx:{width:"180px"},children:"Tokens"}),(c==null?void 0:c.admin)&&f.jsx(vo,{onClick:()=>Bo(`${$t}/admin`),children:"Admin"}),f.jsx(vo,{onClick:()=>Bo(`${$t}/logout`),children:"Logout"})]})]})]})}),f.jsx("nav",{children:f.jsx(d6,{container:i!==void 0?()=>i().document.body:void 0,variant:"persistent",open:a,onClose:H,ModalProps:{keepMounted:!0},sx:{"& .MuiDrawer-paper":{boxSizing:"border-box",width:224,boxShadow:1}},children:O})})]})},WK=({severity:e="error",message:t,onClose:n})=>f.jsx("div",{className:"alert-wrapper",children:f.jsx(qP,{id:"alert-notification",severity:e,onClose:n,children:t})}),JK=e=>{let t;switch(e){case"Ready":t={bgcolor:"rgb(255, 255, 255)",border:"1px solid rgb(46, 125, 50)",color:"rgb(46, 125, 50)"};break;case"Pending":t={bgcolor:"rgb(234, 181, 78)",color:"black"};break;case"Running":t={bgcolor:"rgb(46, 125, 50)",color:"white"};break;case"Unknown":default:t={bgcolor:"rgb(121, 121, 124)",color:"white"};break}return t},D3=({status:e,additionalInfo:t,app:n,size:r="small"})=>{const[,o]=Ve(jv),[,s]=Ve(zv),i=()=>e==="Running"&&t?f.jsx(f.Fragment,{children:n&&!n.shared?f.jsxs(f.Fragment,{children:[f.jsxs("span",{className:"chip-label-info",style:{position:"relative",top:"1px"},children:[e," on ",t]}),f.jsx(qn,{onClick:a=>{a.preventDefault(),a.stopPropagation(),o(n),s(!0)},"aria-label":"Stop",sx:{pl:0,position:"relative",top:0,left:"6px"},color:"inherit",disabled:n.shared,children:f.jsx(Cv,{sx:{fontSize:"16px"}})})]}):f.jsx("span",{children:e})}):e||"Default";return f.jsx(mu,{label:i(),className:e!=="Running"||!t||n!=null&&n.shared?"chip-base":"",size:r,sx:{fontWeight:600,fontSize:"12px",...JK(e)}})};var Py={},FK=ct;Object.defineProperty(Py,"__esModule",{value:!0});var S3=Py.default=void 0,YK=FK(ut()),qK=f;S3=Py.default=(0,YK.default)((0,qK.jsx)("path",{d:"M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"}),"Close");var gy={},ZK=ct;Object.defineProperty(gy,"__esModule",{value:!0});var T3=gy.default=void 0,GK=ZK(ut()),UK=f;T3=gy.default=(0,GK.default)((0,UK.jsx)("path",{d:"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2m-1 16H6c-.55 0-1-.45-1-1V6c0-.55.45-1 1-1h12c.55 0 1 .45 1 1v12c0 .55-.45 1-1 1m-4.44-6.19-2.35 3.02-1.56-1.88c-.2-.25-.58-.24-.78.01l-1.74 2.23c-.26.33-.02.81.39.81h8.98c.41 0 .65-.47.4-.8l-2.55-3.39c-.19-.26-.59-.26-.79 0"}),"CropOriginalRounded");var yy={},QK=ct;Object.defineProperty(yy,"__esModule",{value:!0});var R3=yy.default=void 0,KK=QK(ut()),_K=f;R3=yy.default=(0,KK.default)((0,_K.jsx)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m1 15h-2v-2h2zm0-4h-2V7h2z"}),"Error");var by={},$K=ct;Object.defineProperty(by,"__esModule",{value:!0});var k3=by.default=void 0,e_=$K(ut()),t_=f;k3=by.default=(0,e_.default)((0,t_.jsx)("path",{d:"M10 16h4c.55 0 1-.45 1-1v-5h1.59c.89 0 1.34-1.08.71-1.71L12.71 3.7a.9959.9959 0 0 0-1.41 0L6.71 8.29c-.63.63-.19 1.71.7 1.71H9v5c0 .55.45 1 1 1m-4 2h12c.55 0 1 .45 1 1s-.45 1-1 1H6c-.55 0-1-.45-1-1s.45-1 1-1"}),"UploadRounded");const n_=({id:e,name:t,currentImage:n,setCurrentImage:r,currentFile:o,setCurrentFile:s,...i})=>{const a=Ar(),[l,c]=g.useState(!1),[u,d]=g.useState(!1),[p,y]=g.useState(void 0),h=g.useRef(null),A=H=>{H.preventDefault(),c(!0)},w=H=>{H.preventDefault(),c(!0)},m=H=>{H.preventDefault(),c(!1)},v=H=>{H.preventDefault(),c(!1);const O=H.dataTransfer.files[0];s(O)},P=H=>{if(!H.target.files)return;const O=5*1024*1024;if(H.target.files[0].size>O){y("File size exceeds 5MB.");return}const D=H.target.files[0];s(D),y(void 0)},x=H=>{H.preventDefault(),d(!0)},j=H=>{H.preventDefault();const O=h.current;O&&O.click()},z=H=>{H.preventDefault();const O=h.current;O&&(O.value="",s(void 0),r(void 0))};return g.useEffect(()=>{const H=h.current;if(H&&H.files&&H.files.length>0){const O=H.files[0];s(O)}},[h,s]),f.jsxs(Fe,{id:`thumbnail-${e}`,className:"thumbnail",sx:{display:"flex",flexDirection:"column",columnGap:"24px",width:"100%",border:"none"},children:[p?f.jsxs(Fe,{sx:{display:"flex",alignItems:"center",backgroundColor:"#FDEDED",color:a.palette.error.main,padding:"8px",borderRadius:"4px",marginBottom:"16px"},children:[f.jsx(R3,{sx:{marginRight:"8px"}}),f.jsx(Ue,{variant:"body2",sx:{flexGrow:1,width:"100%",color:a.palette.gray.main},children:f.jsxs("span",{className:"error-msg",children:[f.jsx("span",{className:"weight600",children:"File is too large."})," Maximum file size is 5MB."]})}),f.jsx(qn,{size:"small",onClick:()=>y(void 0),sx:{color:a.palette.gray.main},children:f.jsx(S3,{})})]}):null,f.jsxs(Fe,{id:`thumbnail-body-${e}`,className:`thumbnail-body ${l?"dragging":""} ${o||n?"selected":""}`,onDragOver:A,onDragEnter:w,onDragLeave:m,onDrop:v,sx:{display:"flex",flexDirection:"row",columnGap:"24px",height:"180px"},children:[f.jsxs(Fe,{className:"thumbnail-dropzone",sx:{height:"130px",backgroundColor:"#90969c",borderRadius:"4px"},children:[o||n?f.jsx(Fe,{sx:{margin:"auto auto"},children:f.jsx("img",{src:o?URL.createObjectURL(o):n,alt:"App thumbnail",title:"Click to view image",className:"thumbnail-img",style:{maxWidth:"225px",maxHeight:"130px",borderRadius:"4px",cursor:"pointer"},onClick:x})}):f.jsx(Fe,{tabIndex:0,title:"Select an image",className:"thumbnail-icon-container",sx:{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",width:"225px",height:"130px",cursor:"pointer","&:focus":{outlineColor:a.palette.primary.main}},onClick:j,children:f.jsx(T3,{sx:{width:"64px",height:"64px",color:a.palette.common.white}})}),f.jsx("input",{ref:h,id:e,name:t,type:"file",accept:"image/*",onChange:P,style:{display:"none"},...i})]}),f.jsxs(Fe,{sx:{display:"flex",flexDirection:"column",rowGap:"16px"},children:[f.jsxs(Fe,{sx:{display:"flex",flexDirection:{xs:"column",sm:"row"},columnGap:"16px",rowGap:"12px",height:"40px"},children:[f.jsx(at,{id:"upload-thumbnail-btn",variant:"contained",color:"secondary",startIcon:f.jsx(k3,{}),onClick:j,sx:{width:"100%",maxWidth:"170px"},children:"Select an image"}),o||n?f.jsx(at,{id:"remove-thumbnail-btn",variant:"contained",color:"secondary",startIcon:f.jsx(Ov,{}),onClick:z,hidden:!o&&!n,sx:{width:"100%",maxWidth:"170px"},children:"Remove image"}):f.jsx(f.Fragment,{})]}),f.jsx(Ue,{variant:"body1",sx:{color:"#0F101599",width:"340px",display:{xs:"none",md:"block"}},children:"Recommended size: 225x130 | JPG, PNG, Max size: 5MB"})]})]}),f.jsx(Gl,{onClose:()=>d(!1),open:u,children:f.jsx("img",{src:o?URL.createObjectURL(o):n,alt:"App thumbnail"})})]})};var xy={},r_=ct;Object.defineProperty(xy,"__esModule",{value:!0});var Lv=xy.default=void 0,o_=r_(ut()),s_=f;Lv=xy.default=(0,o_.default)((0,s_.jsx)("path",{d:"M19 11H7.83l4.88-4.88c.39-.39.39-1.03 0-1.42a.9959.9959 0 0 0-1.41 0l-6.59 6.59c-.39.39-.39 1.02 0 1.41l6.59 6.59c.39.39 1.02.39 1.41 0 .39-.39.39-1.02 0-1.41L7.83 13H19c.55 0 1-.45 1-1s-.45-1-1-1"}),"ArrowBackRounded");const wy=_("p")(()=>({maxWidth:600,paddingBottom:"30px"})),i_=()=>f.jsx(Fe,{className:"container",children:f.jsxs(Ho,{children:[f.jsx(ot,{children:f.jsx("div",{className:"form-breadcrumb",children:f.jsx(at,{id:"back-btn",type:"button",variant:"text",color:"primary",startIcon:f.jsx(Lv,{}),onClick:()=>Bo($t),children:"Back To Home"})})}),f.jsxs(ot,{children:[f.jsx(Ue,{component:"h1",variant:"h5",children:"Create a new app"}),f.jsxs(wy,{children:["Begin your project by entering the details below. For more information about creating an app,"," ",f.jsx("a",{href:"https://jhub-apps.nebari.dev/docs/reference/create-app-form",target:"_blank",rel:"noopener noreferrer",className:"form-paragraph-link",children:"visit our docs"}),"."]})]}),f.jsx(ot,{children:f.jsx(y3,{})})]})}),a_=()=>{const[e]=K9(),t=e.get("id");return f.jsx(Fe,{className:"container",children:f.jsxs(Ho,{children:[f.jsx(ot,{children:f.jsx("div",{className:"form-breadcrumb",children:f.jsx(at,{id:"back-btn",type:"button",variant:"text",color:"primary",startIcon:f.jsx(Lv,{}),onClick:()=>Bo($t),children:"Back To Home"})})}),f.jsxs(ot,{children:[f.jsx(Ue,{component:"h1",variant:"h5",children:"Edit app"}),f.jsxs(wy,{children:["Edit your app details here. For more information on editing your app,"," ",f.jsx("a",{href:"https://jhub-apps.nebari.dev/docs/reference/create-app-form",target:"_blank",rel:"noopener noreferrer",className:"form-paragraph-link",children:"visit our docs"}),"."]})]}),f.jsx(ot,{children:f.jsx(f.Fragment,{children:t?f.jsx(y3,{id:t}):f.jsx(f.Fragment,{children:"No app found."})})})]})})};var Hy={},l_=ct;Object.defineProperty(Hy,"__esModule",{value:!0});var E3=Hy.default=void 0,c_=l_(ut()),u_=f;E3=Hy.default=(0,c_.default)((0,u_.jsx)("path",{d:"M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"}),"Check");var jy={},f_=ct;Object.defineProperty(jy,"__esModule",{value:!0});var M3=jy.default=void 0,d_=f_(ut()),p_=f;M3=jy.default=(0,d_.default)((0,p_.jsx)("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14"}),"Search");var zy={},v_=ct;Object.defineProperty(zy,"__esModule",{value:!0});var L3=zy.default=void 0,h_=v_(ut()),m_=f;L3=zy.default=(0,h_.default)((0,m_.jsx)("path",{d:"M4.25 5.61C6.57 8.59 10 13 10 13v5c0 1.1.9 2 2 2s2-.9 2-2v-5s3.43-4.41 5.75-7.39c.51-.66.04-1.61-.8-1.61H5.04c-.83 0-1.3.95-.79 1.61"}),"FilterAltRounded");var Oy={},A_=ct;Object.defineProperty(Oy,"__esModule",{value:!0});var X3=Oy.default=void 0,P_=A_(ut()),g_=f;X3=Oy.default=(0,P_.default)((0,g_.jsx)("path",{d:"M4 18h4c.55 0 1-.45 1-1s-.45-1-1-1H4c-.55 0-1 .45-1 1s.45 1 1 1M3 7c0 .55.45 1 1 1h16c.55 0 1-.45 1-1s-.45-1-1-1H4c-.55 0-1 .45-1 1m1 6h10c.55 0 1-.45 1-1s-.45-1-1-1H4c-.55 0-1 .45-1 1s.45 1 1 1"}),"SortRounded");var Cy={},y_=ct;Object.defineProperty(Cy,"__esModule",{value:!0});var N3=Cy.default=void 0,b_=y_(ut()),x_=f;N3=Cy.default=(0,b_.default)((0,x_.jsx)("path",{d:"M11 21H5c-1.1 0-2-.9-2-2V5c0-1.1.9-2 2-2h6zm2 0h6c1.1 0 2-.9 2-2v-7h-8zm8-11V5c0-1.1-.9-2-2-2h-6v7z"}),"SpaceDashboard");var Dy={},w_=ct;Object.defineProperty(Dy,"__esModule",{value:!0});var B3=Dy.default=void 0,H_=w_(ut()),j_=f;B3=Dy.default=(0,H_.default)((0,j_.jsx)("path",{d:"M21 8H3V4h18zm0 2H3v4h18zm0 6H3v4h18z"}),"TableRows");const z_=_(at)(({theme:e})=>({color:e.palette.common.black,borderColor:e.palette.common.black,"&:hover":{color:e.palette.common.black,borderColor:e.palette.common.black},marginRight:"16px"})),O_=({data:e,currentUser:t,isGridViewActive:n,toggleView:r,setApps:o})=>{const[s]=Ve(w5),[i,a]=Ce.useState(null),[l,c]=Ce.useState(null),u=!!i,d=!!l,[p,y]=Ve(H5),[h,A]=Ve(z5),[w,m]=Ve(O5),[v,P]=Ve(C5),[x,j]=g.useState(0),{data:z,isLoading:H}=Ln({queryKey:["app-frameworks"],queryFn:()=>Yt.get("/frameworks/").then(N=>N.data)}),O=N=>{const J=N.target.value;p.includes(J)?y(T=>T.filter(B=>B!==J)):y(T=>[...T,J])},D=N=>{A(N)},S=N=>{m(N),o(kf(e,t,s,h,p,N,v)),c(null)},I=N=>{const J=N.target.value;v.includes(J)?P(T=>T.filter(B=>B!==J)):P(T=>[...T,J])},R=()=>{a(null),o(kf(e,t,s,h,p,w,v))},M=()=>{y([]),A("Any"),P([])},W=g.useCallback(()=>kf(e,t,s,h,p,w,v).length,[e,t,s,h,p,w,v]);return g.useEffect(()=>{j(W())},[W]),f.jsxs(yo,{container:!0,spacing:2,paddingBottom:"32px",children:[f.jsx(yo,{item:!0,xs:12,md:4,children:f.jsxs(ot,{sx:{pb:0},children:[f.jsx(z_,{id:"filters-btn",variant:"text",color:"secondary",onClick:N=>a(N.currentTarget),startIcon:f.jsx(L3,{}),sx:{fontSize:"16px",fontWeight:600,top:"-8px",background:"none"},endIcon:u?f.jsx(Xd,{}):f.jsx(Ld,{}),disabled:H||!1,children:"Filters"}),f.jsx(Uc,{id:"filters-list",anchorEl:i,open:u,onClose:()=>a(null),MenuListProps:{"aria-labelledby":"filters-btn",style:{paddingTop:0,paddingBottom:0},sx:{".MuiFormLabel-root":{fontSize:"14px"},".MuiFormControlLabel-label":{fontSize:"14px"}}},children:f.jsxs(Fe,{component:"form",name:"filters-form",id:"filters-form",sx:{width:"450px",px:"16px",pb:0,mt:3},children:[f.jsx(Sf,{id:"frameworks-label",sx:{py:"16px",fontWeight:600},children:"Frameworks"}),f.jsx(Fe,{children:z==null?void 0:z.map(N=>f.jsx(ri,{control:f.jsx(Nb,{value:N.display_name}),label:N.display_name,sx:{width:"120px","& > :last-child":{minWidth:"100%"}},onClick:O,checked:p.includes(N.display_name)},N.name))}),f.jsx(Zc,{sx:{mt:"24px",mb:"16px"}}),f.jsx(Sf,{id:"server-statuses-label",sx:{pb:"16px",fontSize:"14px",fontWeight:600},children:"Server Status"}),f.jsx(Fe,{children:KB.map(N=>f.jsx(ri,{control:f.jsx(Nb,{value:N}),label:N,onClick:I,checked:v.includes(N)},N))}),f.jsx(Zc,{sx:{mt:"24px",mb:"16px"}}),f.jsx(Sf,{id:"ownership-label",sx:{pb:"16px",fontSize:"14px",fontWeight:600},children:"Ownership"}),f.jsx(Fe,{children:f.jsx(Gm,{"aria-labelledby":"ownership-label",defaultValue:"any",name:"ownership-group",sx:{"& .MuiFormControlLabel-root":{pb:"3px"}},row:!0,children:UB.map(N=>f.jsx(ri,{control:f.jsx(Zm,{value:N}),label:N,onClick:()=>D(N),checked:h===N},N))})}),f.jsx(Fe,{sx:{backgroundColor:"#EEE",p:1,pt:.75,mx:-2,width:"auto",fontSize:"14px"},children:f.jsxs(ec,{children:[f.jsx(at,{id:"clear-filters-btn","data-testid":"clear-filters-btn",variant:"text",sx:{color:"#0F1015",display:"flex",alignItems:"center"},size:"small",onClick:M,children:"Clear"}),f.jsxs(at,{id:"apply-filters-btn",variant:"contained",size:"small",onClick:R,sx:{px:"none !important",minWidth:"20px"},children:["Show ",x," results"]})]})})]})})]})}),f.jsxs(yo,{container:!0,item:!0,xs:8,md:8,direction:"row",sx:{display:"flex",justifyContent:"flex-end",flexWrap:"nowrap"},children:[f.jsx(ot,{children:f.jsxs(Fe,{sx:{display:"flex",flexDirection:"row"},children:[f.jsxs(at,{id:"sort-by-btn",variant:"text",color:"secondary",onClick:N=>c(N.currentTarget),sx:{position:"relative",bottom:"8px",fontSize:"16px",fontWeight:600,color:"common.black",mr:"24px"},endIcon:d?f.jsx(Xd,{}):f.jsx(Ld,{}),children:[f.jsx(X3,{sx:{position:"relative",marginRight:"8px"}}),w]}),f.jsx(Uc,{id:"sort-by-list",anchorEl:l,open:d,onClose:()=>c(null),MenuListProps:{"aria-labelledby":"sort-by-btn"},anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},sx:{transform:"translateX(-85px)",".MuiFormControlLabel-label":{fontSize:"14px"}},children:f.jsx(Fe,{component:"form",name:"sort-by-form",sx:{px:"16px",width:"220px"},children:f.jsx(Gm,{defaultValue:"any",name:"sort-by-group","aria-describedby":"sort-by-label",children:QB.map(N=>f.jsx(ri,{control:f.jsx(Zm,{value:N}),label:N,onClick:()=>S(N),checked:w===N},N))})})})]})}),f.jsx(ot,{children:f.jsxs(Fe,{sx:{display:"flex",alignItems:"center",justifyContent:"space-around",border:"1px solid #DFDFE0",borderRadius:"4px",position:"relative",top:"-6px"},children:[f.jsx(at,{onClick:r,disabled:n,"aria-label":"Grid View",sx:{color:"inherit",backgroundColor:n?"#E8E8EA":"transparent",boxShadow:"none",padding:"5px",minWidth:"auto",borderRadius:"4px 0px 0px 4px",borderRight:"1px solid #DFDFE0","&:hover":{backgroundColor:n?"#E8E8EA":"transparent",boxShadow:"none"}},children:f.jsx(N3,{sx:{color:n?"#2E2F33":"#76777B"}})}),f.jsx(at,{onClick:r,disabled:!n,"aria-label":"Table View",sx:{color:"inherit",backgroundColor:n?"transparent":"#E8E8EA",boxShadow:"none",borderRadius:"0px 4px 4px 0px",padding:"5px",minWidth:"auto","&:hover":{backgroundColor:n?"transparent":"#E8E8EA",boxShadow:"none"}},children:f.jsx(B3,{sx:{color:n?"#76777B":"#2E2F33"}})})]})})]})]})},C_=({apps:e})=>f.jsx(f.Fragment,{children:e.map((t,n)=>g.createElement(xA,{...t,key:`app-${t.id}-${n}`,title:t.name,serverStatus:t.status,lastModified:t.last_activity,isPublic:t.public,isShared:t.shared,app:t}))});var Sy={},D_=ct;Object.defineProperty(Sy,"__esModule",{value:!0});var V3=Sy.default=void 0,S_=D_(ut()),T_=f;V3=Sy.default=(0,S_.default)((0,T_.jsx)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2M9.5 14.67V9.33c0-.79.88-1.27 1.54-.84l4.15 2.67c.61.39.61 1.29 0 1.68l-4.15 2.67c-.66.43-1.54-.05-1.54-.84"}),"PlayCircleRounded");const R_=({apps:e})=>{const[,t]=g.useState(""),[n,r]=g.useState(e),[,o]=Ve(eo),[,s]=Ve(jv),[,i]=Ve(Xg),[,a]=Ve(zv),[,l]=Ve(Ng),c=e.map(d=>d.status);g.useEffect(()=>{c&&t(c.join(", "))},[c,o]),g.useEffect(()=>{r(e)},[e]);const u=(d,p)=>d?f.jsx(Hv,{"data-testid":"PublicRoundedIcon",fontSize:"small",className:"align-vertical-center"}):p?f.jsx(wv,{"data-testid":"GroupRoundedIcon",fontSize:"small",className:"align-vertical-center"}):f.jsx(Eg,{"data-testid":"LockRoundedIcon",fontSize:"small",className:"align-vertical-center"});return f.jsx(f.Fragment,{children:f.jsx(Fe,{sx:{height:"100%",width:"100%"},children:f.jsx(j9,{component:vr,children:f.jsxs(w9,{sx:{minWidth:650},"aria-label":"App table",children:[f.jsx(fB,{children:f.jsxs(yd,{className:"app-header",children:[f.jsx(kn,{children:"Name"}),f.jsx(kn,{children:"Status"}),f.jsx(kn,{children:"Created by"}),f.jsx(kn,{children:"Tags"}),f.jsx(kn,{children:"Actions"})]})}),f.jsx(H9,{children:n.map(d=>f.jsxs(yd,{sx:{"&:last-child td, &:last-child th":{border:0}},children:[f.jsxs(kn,{component:"th",scope:"row",children:[u(d.public,d.shared),f.jsx("span",{className:"inline relative icon-text",children:d.name})]}),f.jsx(kn,{children:f.jsx(D3,{status:d.status,size:"medium"})}),f.jsx(kn,{children:d.username}),f.jsx(kn,{children:f.jsx(mu,{label:d.framework,variant:"outlined",size:"medium"})}),f.jsxs(kn,{children:[d.status==="Running"?f.jsx(at,{onClick:()=>{a(!0),s(d)},"aria-label":"Stop",color:"inherit",size:"small",className:"action-button","data-testid":"StopCircleRoundedIcon",disabled:d.shared,children:f.jsx(Cv,{})}):f.jsx(at,{onClick:()=>{i(!0),s(d)},"aria-label":"Start",color:"inherit",size:"small",className:"action-button","data-testid":"PlayCircleRoundedIcon",disabled:d.status==="Pending"||d.status==="Unknown",style:{borderRadius:"50%",minWidth:"none"},children:f.jsx(V3,{})}),f.jsx(at,{onClick:()=>window.location.href=`${_p}/edit-app?id=${d.id}`,"aria-label":"Edit",color:"inherit",size:"small",className:"action-button","data-testid":"EditRoundedIcon",disabled:d.shared,style:{borderRadius:"50%",minWidth:"none"},children:f.jsx(Ig,{})}),f.jsx(at,{onClick:()=>{l(!0),s(d)},"aria-label":"Delete",color:"inherit",size:"small",className:"action-button","data-testid":"DeleteRoundedIcon",disabled:d.shared,style:{borderRadius:"50%",minWidth:"none"},children:f.jsx(Ov,{})})]})]},d.id))})]})})})})},k_=()=>{const[e,t]=g.useState([]),[,n]=g.useState(""),[r]=Ve(Ko),[o,s]=g.useState(!1),[,i]=Ve(eo),[a,l]=g.useState(!0),[,c]=Ve(w5),[u]=Ve(H5),[d]=Ve(z5),[,p]=Ve(eo),[y]=Ve(O5),[h]=Ve(C5),A=()=>l(x=>!x),{isLoading:w,error:m,data:v}=Ln({queryKey:["app-state"],queryFn:()=>Yt.get("/server/").then(x=>x.data).then(x=>x),enabled:!!r}),P=x=>{const j=x.target;c(j.value),v&&r&&t(kf(v,r,j.value,d,u,y,h))};return g.useEffect(()=>{const x=e.map(j=>j.status);x&&n(x.join(", "))},[e,p,n]),g.useEffect(()=>{if(!w&&v){const x=E5(v,"all",(r==null?void 0:r.name)??"").map(j=>({...j,status:Yg(j)})).sort((j,z)=>j.last_activity>z.last_activity?-1:1);t(x)}},[w,v,r]),g.useEffect(()=>{i(m?m.message:void 0)},[m,i]),f.jsx(f.Fragment,{children:f.jsx(Fe,{children:f.jsxs(Ho,{children:[f.jsx(ot,{children:f.jsxs(yo,{container:!0,spacing:2,alignItems:"center",children:[f.jsx(yo,{item:!0,xs:12,md:4,sx:{padding:"0"},children:f.jsx(ot,{children:f.jsx(Ue,{component:"h2",variant:"h6",children:"App Library"})})}),f.jsxs(yo,{alignItems:"center",container:!0,item:!0,xs:12,md:8,direction:"row",sx:{display:"flex",flexWrap:"nowrap",justifyContent:{xs:"flex-start",md:"flex-end"}},children:[f.jsx(ot,{children:f.jsx(Rs,{id:"search",size:"small",placeholder:"Search Apps...","aria-label":"Search for an app",onChange:P,onFocus:()=>s(!0),onBlur:()=>s(!1),sx:{my:"0",width:{sm:"200px",md:"300px",lg:"600px"},mr:"16px",color:"rgba(15, 16, 21, 0.56)",backgroundColor:"#fff","& .MuiOutlinedInput-root":{"& fieldset":{borderColor:"rgba(15, 16, 21, 0.12)"},"&:hover fieldset":{borderColor:"rgba(15, 16, 21, 0.56)"},"&.Mui-focused fieldset":{borderColor:"#ba18da"}}},InputProps:{startAdornment:f.jsx(rg,{position:"start",children:!o&&f.jsx(M3,{style:{fill:"rgba(15, 16, 21, 0.56)"}})})}})}),f.jsx(ot,{children:f.jsx(at,{id:"create-app",variant:"contained",color:"primary",size:"large",startIcon:f.jsx(dy,{}),onClick:()=>{window.location.href=`${_p}/create-app`},children:"Deploy App"})})]})]})}),f.jsx(ot,{sx:{pt:"16px",pb:"24px"},children:f.jsx(Zc,{})}),f.jsx(ot,{children:v&&r?f.jsx(O_,{data:v,currentUser:r,setApps:t,isGridViewActive:a,toggleView:A}):f.jsx(f.Fragment,{})}),f.jsx(ot,{children:f.jsx(Fe,{sx:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:2,rowGap:2,justifyContent:"flex-start",paddingBottom:"48px"},children:w?f.jsx("div",{className:"font-bold",children:"Loading..."}):e.length>0?a?f.jsx(C_,{apps:e}):f.jsx(R_,{apps:e}):f.jsx("div",{children:"No apps available"})})})]})})})},E_=({services:e,apps:t})=>f.jsxs(f.Fragment,{children:[t.map((n,r)=>g.createElement(xA,{...n,key:`app-${n.id}-${r}`,title:n.name,serverStatus:n.status,isAppCard:!1,app:n})),e.map((n,r)=>g.createElement(xA,{...n,key:`app-${n.id}-${r}`,title:n.name,serverStatus:n.status,isAppCard:!1}))]}),M_=()=>{const[e]=Ve(Ko),[,t]=Ve(eo),[n,r]=g.useState([]),[o,s]=g.useState([]),{isLoading:i,error:a,data:l}=Ln({queryKey:["service-data"],queryFn:()=>Yt.get("/services/").then(p=>p.data).then(p=>p),enabled:!!e}),{isLoading:c,error:u,data:d}=Ln({queryKey:["app-state"],queryFn:()=>Yt.get("/server/").then(p=>p.data).then(p=>p),enabled:!!e});return g.useEffect(()=>{!i&&l&&e&&r(()=>k5(l,e.name))},[i,l,e]),g.useEffect(()=>{!c&&d&&e&&s(()=>M5(d,e.name))},[c,d,e]),g.useEffect(()=>{t(a?a.message:u?u.message:void 0)},[a,u,t]),f.jsx(Fe,{children:f.jsxs(Ho,{children:[f.jsx(ot,{children:f.jsx(yo,{container:!0,spacing:2,children:f.jsx(yo,{item:!0,xs:12,md:4,children:f.jsx(ot,{children:f.jsx(Ue,{component:"h2",variant:"h6",children:"Quick Access"})})})})}),f.jsx(ot,{sx:{pt:"16px",pb:"24px"},children:f.jsx(Zc,{})}),f.jsx(ot,{children:f.jsx(Fe,{sx:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:"16px",justifyContent:"flex-start",paddingBottom:"48px"},children:i||c?f.jsx("div",{className:"font-bold",children:"Loading..."}):n.length>0||o.length>0?f.jsx(E_,{services:n,apps:o}):f.jsx("div",{children:"No services available"})})})]})})},L_=()=>f.jsx(Wf,{sx:{backgroundColor:"green",color:"white",borderRadius:"50%",padding:"2px"},children:f.jsx(E3,{})}),j1=()=>{const[,e]=Ve(eo),[t,n]=Ve(jv),[r]=Ve(Ko),[o,s]=g.useState(null),[i,a]=Ve(Xg),[l,c]=Ve(zv),[u,d]=Ve(Ng),[p,y]=Ve(D5),[h,A]=g.useState(!1),w=$p(),[m,v]=g.useState(!1),[P,x]=g.useState(""),j=async({id:T})=>await Yt.post(`/server/${T}`),z=async({id:T,remove:B})=>await Yt.delete(`/server/${T}`,{params:{remove:B}}),{data:H}=Ln({queryKey:["app-form",o],queryFn:()=>Yt.get(`/server/${o}`).then(T=>T.data),enabled:!!o}),{mutate:O}=_a({mutationFn:j,retry:1}),{mutate:D}=_a({mutationFn:z,retry:1}),S=()=>{const T=(t==null?void 0:t.id)||"";A(!0),D({id:T,remove:!0},{onSuccess:async()=>{A(!1),d(!1),w.invalidateQueries({queryKey:["app-state"]}),x("App deleted successfully"),v(!0)},onError:async B=>{A(!1),e(B.message)}})},I=async()=>{const T=(t==null?void 0:t.id)||"";A(!0),O({id:T},{onSuccess:async()=>{A(!1),a(!1),y(!1),w.invalidateQueries({queryKey:["app-state"]})},onError:B=>{A(!1),e(B.message)}})},R=async()=>{const T=(t==null?void 0:t.id)||"";A(!0),D({id:T,remove:!1},{onSuccess:()=>{A(!1),c(!1),w.invalidateQueries({queryKey:["app-state"]}),x("Server stopped successfully"),v(!0)},onError:B=>{A(!1),e(B.message)}})},M=async()=>{if(!r||!t){A(!1);return}window.location.assign($G(r,t))},W=f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"card-dialog-body-wrapper",children:[f.jsxs("p",{className:"card-dialog-body",children:["Are you sure you want to start ",f.jsx("b",{children:t==null?void 0:t.name}),"?"]}),f.jsx("p",{className:"card-dialog-note",children:"This action starts a new server that consumes resources."})]}),f.jsxs(ec,{className:"card-dialog-button-group",children:[f.jsx(at,{id:"cancel-btn","data-testid":"cancel-btn",variant:"text",color:"primary",onClick:()=>a(!1),sx:{fontWeight:700},children:"Cancel"}),f.jsx(at,{id:"start-btn","data-testid":"start-btn",variant:"contained",color:"primary",onClick:I,disabled:h,children:"Start"})]})]}),N=f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"card-dialog-body-wrapper",children:f.jsxs("p",{className:"card-dialog-body",children:["Are you sure you want to stop ",f.jsx("b",{children:t==null?void 0:t.name}),"?"]})}),f.jsxs(ec,{className:"card-dialog-button-group",children:[f.jsx(at,{id:"cancel-btn",variant:"text",color:"primary",onClick:()=>c(!1),sx:{fontWeight:700},children:"Cancel"}),f.jsx(at,{id:"stop-btn",variant:"contained",color:"primary",onClick:R,disabled:h,children:"Stop"})]})]}),Z=f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"card-dialog-body-wrapper",children:[f.jsxs("p",{className:"card-dialog-body",children:["Are you sure you want to delete ",f.jsx("b",{children:t==null?void 0:t.name}),"?"]}),f.jsx("p",{className:"card-dialog-note",children:"This action is permanent and cannot be reversed."})]}),f.jsxs(ec,{className:"card-dialog-button-group",children:[f.jsx(at,{id:"cancel-btn","data-testid":"cancel-btn",variant:"text",color:"primary",onClick:()=>d(!1),sx:{fontWeight:700},children:"Cancel"}),f.jsx(at,{id:"delete-btn","data-testid":"delete-btn",variant:"contained",color:"error",onClick:S,disabled:h,children:"Delete"})]})]}),J=f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"card-dialog-body-wrapper",children:[f.jsxs("p",{className:"card-dialog-body",children:["Would you like to start ",f.jsx("b",{children:t==null?void 0:t.name}),"?"]}),f.jsx("p",{className:"card-dialog-note",children:"This action starts a new server that consumes resources."})]}),f.jsxs(ec,{className:"card-dialog-button-group",children:[f.jsx(at,{id:"cancel-btn","data-testid":"cancel-btn",variant:"text",color:"primary",onClick:()=>{Th(),y(!1)},sx:{fontWeight:700},children:"Cancel"}),f.jsx(at,{id:"start-btn","data-testid":"start-btn",variant:"contained",color:"primary",onClick:()=>{Th(),tU((t==null?void 0:t.name)||"")?M():I()},disabled:h,children:"Start"})]})]});return g.useEffect(()=>{if(H&&!H.started&&o){let T=H.user_options.display_name;!T&&o==="lab"?T="JupyterLab":!T&&o==="vscode"&&(T="VSCode"),n({id:o,name:T,framework:H.user_options.framework,url:H.url,ready:H.ready,public:H.user_options.public,shared:!1,last_activity:new Date(H.last_activity),status:"Ready"}),y(!0),Th()}},[H,o,y,n]),g.useEffect(()=>{const T=nU();T&&s(T)},[s]),f.jsxs(Fe,{sx:{flexGrow:1},className:"container",children:[f.jsx(yo,{container:!0,spacing:2,paddingBottom:"24px",children:f.jsx(yo,{item:!0,xs:12,md:2,children:f.jsx(ot,{children:f.jsx(Ue,{component:"h1",variant:"h5",children:"Home"})})})}),f.jsx(M_,{}),f.jsx(k_,{}),i&&f.jsxs(Gl,{open:i,onClose:()=>a(!1),"data-testid":"StartModal",sx:{".MuiPaper-root":{width:"444px"}},children:[f.jsx(_u,{sx:{fontWeight:700},children:"Start App"}),f.jsx(Ku,{sx:{padding:"0px"},children:W})]}),l&&f.jsxs(Gl,{open:l,onClose:()=>c(!1),"data-testid":"StopModal",sx:{".MuiPaper-root":{width:"444px"}},children:[f.jsx(_u,{sx:{fontWeight:700,pb:1},children:"Stop App"}),f.jsx(Ku,{sx:{padding:"0px"},children:N})]}),u&&f.jsxs(Gl,{open:u,onClose:()=>d(!1),"data-testid":"DeleteModal",sx:{".MuiPaper-root":{width:"444px"}},children:[f.jsx(_u,{sx:{fontWeight:700},children:"Delete App"}),f.jsx(Ku,{sx:{padding:"0px"},children:Z})]}),p&&f.jsxs(Gl,{open:p,onClose:()=>y(!1),"data-testid":"StartNotRunningModal",sx:{".MuiPaper-root":{width:"444px"}},children:[f.jsx(_u,{sx:{fontWeight:700},children:"Server Not Running"}),f.jsx(Ku,{sx:{padding:"0px"},children:J})]}),f.jsx(lN,{open:m,autoHideDuration:6e3,onClose:()=>v(!1),anchorOrigin:{vertical:"top",horizontal:"center"},sx:{top:"90px !important"},children:f.jsx(qP,{onClose:()=>v(!1),severity:"success",icon:f.jsx(L_,{}),sx:{width:"100%",backgroundColor:"success.main",color:"rgba(30, 70, 32, 1)",fontFamily:"Inter, sans-serif",fontWeight:600},children:P})})]})},X_=()=>{const[e,t]=Ce.useState(null),[n]=Ve(Ko),{data:r}=Ln({queryKey:["app-form",e],queryFn:()=>Yt.get(`/server/${e}`).then(o=>o.data),enabled:!!e});return g.useEffect(()=>{if(n){const o=window.location.pathname.replace(/\/$/,"").split("/").pop();o&&t(o)}},[n]),g.useEffect(()=>{r&&(r!=null&&r.started?window.location.assign(window.location.href.replace("/hub","")):r!=null&&r.pending&&n&&e?window.location.assign(eU(n,e)):(r!=null&&r.stopped&&e&&rU(e),window.location.assign($t)))},[r,e,n]),f.jsx(Fe,{sx:{margin:"auto auto"},children:f.jsx(tg,{})})};function N_(e){return De("MuiLoadingButton",e)}const B_=Se("MuiLoadingButton",["root","loading","loadingIndicator","loadingIndicatorCenter","loadingIndicatorStart","loadingIndicatorEnd","endIconLoadingEnd","startIconLoadingStart"]),To=B_,V_=["children","disabled","id","loading","loadingIndicator","loadingPosition","variant"],I_=e=>{const{loading:t,loadingPosition:n,classes:r}=e,o={root:["root",t&&"loading"],startIcon:[t&&`startIconLoading${te(n)}`],endIcon:[t&&`endIconLoading${te(n)}`],loadingIndicator:["loadingIndicator",t&&`loadingIndicator${te(n)}`]},s=Te(o,N_,r);return b({},r,s)},W_=e=>e!=="ownerState"&&e!=="theme"&&e!=="sx"&&e!=="as"&&e!=="classes",J_=_(at,{shouldForwardProp:e=>W_(e)||e==="classes",name:"MuiLoadingButton",slot:"Root",overridesResolver:(e,t)=>[t.root,t.startIconLoadingStart&&{[`& .${To.startIconLoadingStart}`]:t.startIconLoadingStart},t.endIconLoadingEnd&&{[`& .${To.endIconLoadingEnd}`]:t.endIconLoadingEnd}]})(({ownerState:e,theme:t})=>b({[`& .${To.startIconLoadingStart}, & .${To.endIconLoadingEnd}`]:{transition:t.transitions.create(["opacity"],{duration:t.transitions.duration.short}),opacity:0}},e.loadingPosition==="center"&&{transition:t.transitions.create(["background-color","box-shadow","border-color"],{duration:t.transitions.duration.short}),[`&.${To.loading}`]:{color:"transparent"}},e.loadingPosition==="start"&&e.fullWidth&&{[`& .${To.startIconLoadingStart}, & .${To.endIconLoadingEnd}`]:{transition:t.transitions.create(["opacity"],{duration:t.transitions.duration.short}),opacity:0,marginRight:-8}},e.loadingPosition==="end"&&e.fullWidth&&{[`& .${To.startIconLoadingStart}, & .${To.endIconLoadingEnd}`]:{transition:t.transitions.create(["opacity"],{duration:t.transitions.duration.short}),opacity:0,marginLeft:-8}})),F_=_("span",{name:"MuiLoadingButton",slot:"LoadingIndicator",overridesResolver:(e,t)=>{const{ownerState:n}=e;return[t.loadingIndicator,t[`loadingIndicator${te(n.loadingPosition)}`]]}})(({theme:e,ownerState:t})=>b({position:"absolute",visibility:"visible",display:"flex"},t.loadingPosition==="start"&&(t.variant==="outlined"||t.variant==="contained")&&{left:t.size==="small"?10:14},t.loadingPosition==="start"&&t.variant==="text"&&{left:6},t.loadingPosition==="center"&&{left:"50%",transform:"translate(-50%)",color:(e.vars||e).palette.action.disabled},t.loadingPosition==="end"&&(t.variant==="outlined"||t.variant==="contained")&&{right:t.size==="small"?10:14},t.loadingPosition==="end"&&t.variant==="text"&&{right:6},t.loadingPosition==="start"&&t.fullWidth&&{position:"relative",left:-10},t.loadingPosition==="end"&&t.fullWidth&&{position:"relative",right:-10})),Y_=g.forwardRef(function(t,n){const r=g.useContext(U2),o=cp(r,t),s=Re({props:o,name:"MuiLoadingButton"}),{children:i,disabled:a=!1,id:l,loading:c=!1,loadingIndicator:u,loadingPosition:d="center",variant:p="text"}=s,y=ce(s,V_),h=xo(l),A=u??f.jsx(tg,{"aria-labelledby":h,color:"inherit",size:16}),w=b({},s,{disabled:a,loading:c,loadingIndicator:A,loadingPosition:d,variant:p}),m=I_(w),v=c?f.jsx(F_,{className:m.loadingIndicator,ownerState:w,children:A}):null;return f.jsxs(J_,b({disabled:a||c,id:h,ref:n},y,{variant:p,classes:m,ownerState:w,children:[w.loadingPosition==="end"?i:v,w.loadingPosition==="end"?v:i]}))}),q_=Y_,Z_=()=>{const[e]=K9(),t=vg(),n=$p(),[r,o]=g.useState(!1),[s]=Ve(Ko),[,i]=Ve(eo),[a,l]=Ve(y5),[c]=Ve(g5),[u]=Ve(x5),[d]=Ve(b5),[,p]=Ve(eo),[y,h]=Ce.useState((a==null?void 0:a.profile)||""),A=e.get("id"),{data:w,isLoading:m,error:v}=Ln({queryKey:["server-types"],queryFn:()=>Yt.get("/spawner-profiles/").then(D=>D.data).then(D=>D),enabled:!!s}),P=D=>{h(D),a&&l({...a,profile:D})},x=D=>{var R,M;D.preventDefault();const S=(a==null?void 0:a.display_name)||"",I={servername:c||S,user_options:{jhub_app:!0,display_name:(a==null?void 0:a.display_name)||"",description:(a==null?void 0:a.description)||"",framework:(a==null?void 0:a.framework)||"",thumbnail:(a==null?void 0:a.thumbnail)||"",filepath:(a==null?void 0:a.filepath)||"",conda_env:(a==null?void 0:a.conda_env)||"",env:bA(a==null?void 0:a.env),custom_command:(a==null?void 0:a.custom_command)||"",profile:(a==null?void 0:a.profile)||"",public:(a==null?void 0:a.is_public)||!1,share_with:{users:((R=a==null?void 0:a.share_with)==null?void 0:R.users)||[],groups:((M=a==null?void 0:a.share_with)==null?void 0:M.groups)||[]},keep_alive:(a==null?void 0:a.keep_alive)||!1}};o(!0),A?O(I,{onSuccess:async()=>{n.invalidateQueries({queryKey:["app-state"]}),window.location.assign($t)},onError:async W=>{o(!1),p(W.message)}}):H(I,{onSuccess:async W=>{const N=s==null?void 0:s.name;if(N&&(W==null?void 0:W.length)>1){const Z=W[1];window.location.assign(`/hub/spawn-pending/${N}/${Z}`)}},onError:async W=>{o(!1),p(W.message)}})},j=async({servername:D,user_options:S})=>{const I={accept:"application/json","Content-Type":"multipart/form-data"},R=new FormData;return R.append("data",JSON.stringify({servername:D,user_options:S})),u&&R.append("thumbnail",u),(await Yt.post("/server",R,{headers:I})).data},z=async({servername:D,user_options:S})=>{const I={accept:"application/json","Content-Type":"multipart/form-data"},R=new FormData;return R.append("data",JSON.stringify({servername:D,user_options:S})),u?R.append("thumbnail",u):d&&R.append("thumbnail_data_url",d),(await Yt.put(`/server/${D}`,R,{headers:I})).data},{mutate:H}=_a({mutationFn:j,retry:1}),{mutate:O}=_a({mutationFn:z,retry:1});return g.useEffect(()=>{i(v?v.message:void 0)},[v,i]),f.jsx(Fe,{className:"container",children:f.jsxs(Ho,{children:[f.jsx(ot,{children:f.jsx("div",{className:"form-breadcrumb",children:f.jsx(at,{id:"back-btn",type:"button",variant:"text",color:"primary",startIcon:f.jsx(Lv,{}),onClick:()=>Bo($t),children:"Back To Home"})})}),f.jsxs(ot,{children:[f.jsx(Ue,{component:"h1",variant:"h5",children:"Server Type"}),f.jsxs(wy,{children:["Please select the appropriate server for your app. For more information on server types,"," ",f.jsx("span",{children:f.jsx("a",{href:"https://www.nebari.dev/docs/welcome",target:"_blank",rel:"noopener noreferrer",className:"form-paragraph-link",children:"visit our docs"})}),"."]})]}),f.jsx(ot,{children:m?f.jsx("div",{className:"font-bold center",children:"Loading..."}):w&&w.length>0?f.jsxs("form",{className:"form",onSubmit:x,children:[f.jsx(Qi,{sx:{pb:"36px"},children:f.jsx(Gm,{children:w==null?void 0:w.map((D,S)=>f.jsx(K2,{className:"server-type-card",onClick:()=>P(D.slug),tabIndex:0,children:f.jsxs(Jm,{children:[f.jsx(ri,{value:D.slug,id:D.slug,control:f.jsx(Zm,{checked:y?y===D.slug:S===0}),label:D.display_name},D.slug),f.jsx("p",{children:D.description})]})},`server-type-card-${D.slug}`))})}),f.jsx("hr",{}),f.jsxs("div",{className:"button-section",children:[f.jsx("div",{className:"prev",children:f.jsx(at,{id:"cancel-btn",type:"button",variant:"text",color:"primary",onClick:()=>t(A?`/edit-app?id=${A}`:"/create-app"),children:"Back"})}),f.jsx("div",{className:"next",children:f.jsx(q_,{id:"submit-btn",type:"submit",variant:"contained",color:"primary",loading:r,children:A?"Save":"Deploy App"})})]})]}):f.jsx("div",{children:"No servers available"})})]})})},G_=()=>f.jsxs(Fe,{id:"stop-pending",className:"container",display:"flex",flexDirection:"column",alignItems:"center",textAlign:"center",padding:"20px",children:[f.jsxs(Fe,{display:"flex",flexDirection:"column",alignItems:"center",textAlign:"center",children:[f.jsxs(Ue,{variant:"h5",component:"h1",gutterBottom:!0,sx:{paddingBottom:"0 !important"},children:["Thank you for your patience",f.jsx("br",{}),"We are stopping your application, you may start it again when we have finished"]}),f.jsx(tg,{style:{color:"#a020f0",margin:"20px 0"}})]}),f.jsxs(Fe,{sx:{marginTop:"4rem"},children:[f.jsx(Ue,{variant:"body1",gutterBottom:!0,children:"You may return to the Application Screen at any time"}),f.jsx(at,{id:"back-btn",variant:"contained",color:"primary",style:{backgroundColor:"#a020f0"},onClick:()=>Bo(`${$t}`),children:"Back To Home"})]})]}),U_=()=>{const[,e]=Ve(DG),[,t]=Ve(Ko),[,n]=Ve(j5),[r,o]=Ve(eo),{error:s,data:i}=Ln({queryKey:["user-state"],queryFn:()=>Yt.get("/user").then(c=>c.data).then(c=>c)}),{error:a,data:l}=Ln({queryKey:["server-types"],queryFn:()=>Yt.get("/spawner-profiles/").then(c=>c.data).then(c=>c)});return g.useEffect(()=>{s?o(s.message):a&&o(a.message)},[s,a,o]),g.useEffect(()=>{e(GG())},[e]),g.useEffect(()=>{i&&t({...i})},[i,t]),g.useEffect(()=>{l&&n([...l])},[l,n]),f.jsxs("div",{children:[f.jsx(IK,{}),f.jsxs(Fe,{component:"main",sx:{flexGrow:1,pt:9,pl:{xs:1,sm:33},pr:1,backgroundColor:"#fafbfc"},children:[r?f.jsx(WK,{message:r,onClose:()=>o(void 0)}):f.jsx(f.Fragment,{}),f.jsxs(yI,{children:[f.jsx(rs,{path:"/home",element:f.jsx(j1,{})}),f.jsx(rs,{path:"/user/:id/*",element:f.jsx(X_,{})}),f.jsx(rs,{path:"/create-app",element:f.jsx(i_,{})}),f.jsx(rs,{path:"/edit-app",element:f.jsx(a_,{})}),f.jsx(rs,{path:"/server-types",element:f.jsx(Z_,{})}),f.jsx(rs,{path:"/stop-pending",element:f.jsx(G_,{})}),f.jsx(rs,{path:"/",element:f.jsx(j1,{})})]})]})]})},Br={50:"#FAFBFC",100:"#2491FF",200:"#2491FF",300:"#2491FF",400:"#2491FF",500:"#005EA2",600:"#1A4480",700:"#1A4480",800:"#1A4480",900:"#162E51"},Qt={50:"rgba(0, 0, 0, .08)",100:"#E1E3E4",200:"#EEEEEE",300:"#E0E0E0",400:"#90969C",500:"#5B5F63",600:"#44474A",700:"#3C3C3B",800:"#242628",900:"#1A1C1D"},qs="#BA18DA",Bh="#BA18DA10",z1="#9B00CE",qi="#18817A",Q_="#18817A10",K_="#12635E",__="#D72D47",$_="#F66A0A",Vr="#FFFFFF",uf="#0F1015",ff="#0F101561",e$=Qt[100],Vl=vp({typography:{fontFamily:'"Inter", sans-serif',h1:{letterSpacing:"-1.5px",fontSize:"96px"},h2:{letterSpacing:"0.5px",fontSize:"60px"},h3:{letterSpacing:"0px",fontSize:"48px"},h4:{letterSpacing:"0.25px",fontSize:"34px"},h5:{letterSpacing:"0px",fontSize:"24px",fontWeight:600,paddingBottom:"16px"},h6:{letterSpacing:"0.15px",fontSize:"20px",fontWeight:700,paddingBottom:"16px"},subtitle1:{letterSpacing:"0.15px",fontSize:"16px",fontWeight:600,paddingBottom:"24px"},subtitle2:{letterSpacing:"0.1px",fontSize:"14px",fontWeight:500,paddingBottom:"24px"},body1:{letterSpacing:"0.15px",fontSize:"16px"},body2:{letterSpacing:"0.17px",fontSize:"14px"},caption:{letterSpacing:"0.4px"},overline:{letterSpacing:"1px",fontSize:"12px"}},components:{MuiButtonBase:{defaultProps:{disableRipple:!0,style:{textTransform:"none",textWrap:"nowrap"}}},MuiFormControl:{defaultProps:{fullWidth:!0,sx:{marginBottom:"24px"}}},MuiTextField:{defaultProps:{autoComplete:"off",fullWidth:!0,sx:{marginBottom:"0"}}},MuiSelect:{defaultProps:{fullWidth:!0}}}}),t$=vp(Vl,{palette:{primary:Vl.palette.augmentColor({color:{light:Bh,main:qs,dark:z1,contrastText:Vr},name:"primary"}),secondary:Vl.palette.augmentColor({color:{light:Q_,main:qi,dark:K_,contrastText:Vr},name:"secondary"}),blue:Vl.palette.augmentColor({color:{50:Br[50],100:Br[100],200:Br[200],300:Br[300],400:Br[400],500:Br[500],600:Br[600],700:Br[700],800:Br[800],900:Br[900]},name:"blue"}),gray:Vl.palette.augmentColor({color:{light:Qt[300],lighter:e$,main:Qt[500],dark:Qt[700],contrastText:uf,50:Qt[50],100:Qt[100],200:Qt[200],300:Qt[300],400:Qt[400],500:Qt[500],600:Qt[600],700:Qt[700],800:Qt[800],900:Qt[900]},name:"gray"}),warning:{main:$_,contrastText:Vr},error:{main:__,contrastText:Vr},info:{main:Br,contrastText:Vr},success:{main:qi[500],contrastText:Vr},common:{black:uf,white:Vr}},components:{MuiButton:{variants:[{props:{variant:"contained",color:"primary"},style:{backgroundColor:`${qs}`,fontWeight:700,"&:hover":{backgroundColor:`${z1}`},"&:disabled":{color:ff}}},{props:{variant:"contained",color:"secondary"},style:{backgroundColor:Qt[200],border:`1px solid ${Qt[200]}`,color:uf,fontWeight:600,"&:hover":{backgroundColor:Qt[300],border:`1px solid ${Qt[300]}`},"&:disabled":{color:ff,borderColor:"transparent"}}},{props:{variant:"contained",color:"error"},style:{fontWeight:600}},{props:{variant:"outlined",color:"primary"},style:{backgroundColor:Vr,border:`2px solid ${qs}`,color:`${qs}`,fontWeight:700,textTransform:"none","&:hover":{backgroundColor:Vr,borderWidth:2,border:`2px solid ${qs}`,color:`${qs}`}}},{props:{variant:"outlined",color:"secondary"},style:{backgroundColor:Vr,border:`2px solid ${qi}`,color:`${qi}`,fontWeight:700,textTransform:"none","&:hover":{backgroundColor:Vr,borderWidth:2,border:`2px solid ${qi}`,color:`${qi}`}}},{props:{variant:"text",color:"primary"},style:{color:`${qs}`,"&:hover":{backgroundColor:`${Bh}`},"&:focus":{backgroundColor:`${Bh}`},"&:disabled":{color:ff}}},{props:{variant:"text",color:"secondary"},style:{color:uf,"&:hover":{backgroundColor:`${Qt[50]}`},"&:focus":{backgroundColor:`${Qt[50]}`},"&:disabled":{color:ff}}}]}}}),n$=new URL(window.location.href),r$=new pV;aA.createRoot(document.getElementById("root")).render(f.jsx(Ce.StrictMode,{children:f.jsx(HI,{basename:n$.pathname.indexOf("hub")===-1?_p:$t,children:f.jsx(hG,{children:f.jsxs(qz,{theme:t$,children:[f.jsx(AE,{}),f.jsx(PV,{client:r$,children:f.jsx(U_,{})})]})})})})); diff --git a/jhub_apps/tests/tests_e2e/test_integration.py b/jhub_apps/tests/tests_e2e/test_integration.py index acc38b99..0a11b047 100644 --- a/jhub_apps/tests/tests_e2e/test_integration.py +++ b/jhub_apps/tests/tests_e2e/test_integration.py @@ -87,7 +87,7 @@ def create_app( share_with_groups=None, ): logger.info("Creating App") - page.get_by_role("button", name="Create App").click() + page.get_by_role("button", name="Deploy App").click() logger.info("Fill App display Name") page.get_by_label("*Name").click() page.get_by_label("*Name").fill(app_name) @@ -106,10 +106,10 @@ def create_app( logger.info("Expect Small Instance to be visible") expect(small_instance_radio_button).to_be_visible() small_instance_radio_button.check() - create_app_locator = page.get_by_role("button", name="Create App") - logger.info("Expect Create App button to be visible") + create_app_locator = page.get_by_role("button", name="Deploy App") + logger.info("Expect Deploy App button to be visible") expect(create_app_locator).to_be_visible() - logger.info("Click Create App") + logger.info("Click Deploy App") create_app_locator.click() diff --git a/ui/src/components/app-form/app-form.test.tsx b/ui/src/components/app-form/app-form.test.tsx index 2f278dcb..2c3daabe 100644 --- a/ui/src/components/app-form/app-form.test.tsx +++ b/ui/src/components/app-form/app-form.test.tsx @@ -147,7 +147,7 @@ describe('AppForm', () => { // Attempt submitting without filling in required fields const btn = baseElement.querySelector('#submit-btn') as HTMLButtonElement; expect(btn).toBeInTheDocument(); - expect(btn).toHaveTextContent('Create App'); + expect(btn).toHaveTextContent('Deploy App'); expect(btn).not.toHaveAttribute('disabled', 'disabled'); await act(async () => { btn.click(); @@ -283,7 +283,7 @@ describe('AppForm', () => { // Attempt submitting without filling in required fields const btn = baseElement.querySelector('#submit-btn') as HTMLButtonElement; expect(btn).toBeInTheDocument(); - expect(btn).toHaveTextContent('Create App'); + expect(btn).toHaveTextContent('Deploy App'); expect(btn).not.toHaveAttribute('disabled', 'disabled'); await act(async () => { btn.click(); @@ -353,7 +353,7 @@ describe('AppForm', () => { // Attempt submitting without filling in required fields const btn = baseElement.querySelector('#submit-btn') as HTMLButtonElement; expect(btn).toBeInTheDocument(); - expect(btn).toHaveTextContent('Create App'); + expect(btn).toHaveTextContent('Deploy App'); expect(btn).not.toHaveAttribute('disabled', 'disabled'); await act(async () => { btn.click(); @@ -410,7 +410,7 @@ describe('AppForm', () => { const btn = baseElement.querySelector('#submit-btn') as HTMLButtonElement; expect(btn).toBeInTheDocument(); - expect(btn).toHaveTextContent('Create App'); + expect(btn).toHaveTextContent('Deploy App'); expect(btn).not.toHaveAttribute('disabled', 'disabled'); await act(async () => { btn.click(); @@ -556,7 +556,7 @@ describe('AppForm', () => { const btn = baseElement.querySelector('#submit-btn') as HTMLButtonElement; expect(btn).toBeInTheDocument(); - expect(btn).toHaveTextContent('Create App'); + expect(btn).toHaveTextContent('Deploy App'); expect(btn).not.toHaveAttribute('disabled', 'disabled'); await act(async () => { btn.click(); @@ -726,7 +726,7 @@ describe('AppForm', () => { const btn = baseElement.querySelector('#submit-btn') as HTMLButtonElement; expect(btn).toBeInTheDocument(); - expect(btn).toHaveTextContent('Create App'); + expect(btn).toHaveTextContent('Deploy App'); expect(btn).not.toHaveAttribute('disabled', 'disabled'); await act(async () => { btn.click(); diff --git a/ui/src/components/app-form/app-form.tsx b/ui/src/components/app-form/app-form.tsx index ea6d4ced..a980664f 100644 --- a/ui/src/components/app-form/app-form.tsx +++ b/ui/src/components/app-form/app-form.tsx @@ -948,7 +948,7 @@ export const AppForm = ({ id }: AppFormProps): React.ReactElement => { ) : id ? ( <>Save ) : ( - <>Create App + <>Deploy App )} diff --git a/ui/src/pages/home/apps-section/apps-section.tsx b/ui/src/pages/home/apps-section/apps-section.tsx index 115e1c84..21711a82 100644 --- a/ui/src/pages/home/apps-section/apps-section.tsx +++ b/ui/src/pages/home/apps-section/apps-section.tsx @@ -201,7 +201,7 @@ export const AppsSection = (): React.ReactElement => { window.location.href = `${API_BASE_URL}/create-app`; }} > - Create App + Deploy App diff --git a/ui/src/pages/home/home.test.tsx b/ui/src/pages/home/home.test.tsx index ef1dc0c2..bb5f8a86 100644 --- a/ui/src/pages/home/home.test.tsx +++ b/ui/src/pages/home/home.test.tsx @@ -67,10 +67,10 @@ describe('Home', () => { }); }); - test('should render create app button and respond to click events', async () => { + test('should render Deploy app button and respond to click events', async () => { const { getByText } = render(componentWrapper); await act(async () => { - const button = getByText('Create App'); + const button = getByText('Deploy App'); expect(button).toBeTruthy(); fireEvent.click(button); }); diff --git a/ui/src/pages/server-types/server-types.test.tsx b/ui/src/pages/server-types/server-types.test.tsx index 7038e8b6..239621fd 100644 --- a/ui/src/pages/server-types/server-types.test.tsx +++ b/ui/src/pages/server-types/server-types.test.tsx @@ -214,7 +214,7 @@ describe('ServerTypes', () => { mockSearchParamsGet.mockRestore(); }); - test('clicks back to create app', async () => { + test('clicks back to deploy app', async () => { jest.mock('react-router-dom', () => ({ ...jest.requireActual('react-router-dom'), useLocation: () => ({ diff --git a/ui/src/pages/server-types/server-types.tsx b/ui/src/pages/server-types/server-types.tsx index 908b32dd..af723561 100644 --- a/ui/src/pages/server-types/server-types.tsx +++ b/ui/src/pages/server-types/server-types.tsx @@ -299,7 +299,7 @@ export const ServerTypes = (): React.ReactElement => { color="primary" loading={submitting} > - {id ? 'Save' : 'Create App'} + {id ? 'Save' : 'Deploy App'}