const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["chunks/HeroSection.tsx-BASRe4I0.js","chunks/chunk-BcMzut3W.js","chunks/chunk-CLN-lmR0.js","chunks/chunk-CU-y1Q6f.js","chunks/chunk-BD9OJLJ5.js","chunks/chunk-5rBBrdbz.js","assets/monaco-editor-CpN8rtOO.css","chunks/chunk-DreM7Bcy.js","chunks/chunk-BIyfHqPs.js","chunks/FeaturesSection.tsx-DXN50HNp.js","chunks/PricingSection.tsx-BETvc893.js","chunks/FAQSection.tsx-paWsguTI.js","chunks/FillerSection.tsx-BDdijBdk.js","chunks/FooterSection.tsx-B7zf8w06.js","chunks/VideoSection.tsx-K9pTgmnZ.js"])))=>i.map(i=>d[i]); var e,t,n,s=Object.defineProperty,i=(e,t,n)=>((e,t,n)=>t in e?s(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);import{j as a,S as r,T as o,I as l,a as c,b as d,P as u,C as p,V as m,L as h,c as x,d as f,e as g,f as v,R as b,g as y,h as w,i as j,k as C,l as N,m as F,n as _,o as k,p as S,q as E,r as I,s as A,t as T,u as M,v as D,w as L,x as P,y as R,z as O,A as z,B,O as H,D as $,E as V,F as U,G as W,H as q,J as G,K as Z,M as Y,N as K,Q as J,U as Q,W as X,X as ee,Y as te,Z as ne,_ as se,$ as ie,a0 as ae,a1 as re,a2 as oe,a3 as le,a4 as ce,a5 as de,a6 as ue,a7 as pe,a8 as me,a9 as he,aa as xe,ab as fe,ac as ge,ad as ve,ae as be,af as ye,ag as we,ah as je,ai as Ce,aj as Ne,ak as Fe,al as _e,am as ke,an as Se,ao as Ee,ap as Ie,aq as Ae,ar as Te,as as Me}from"./chunks/chunk-BcMzut3W.js";import{h as De,e as Le,a as Pe,u as Re,i as Oe,R as ze,b as Be,L as He,j as $e,d as Ve,c as Ue,k as We,l as qe,N as Ge,B as Ze}from"./chunks/chunk-CLN-lmR0.js";import{c as Ye}from"./chunks/chunk-BD9OJLJ5.js";import{c as Ke,a as Je,i as Qe,w as Xe,n as et,f as tt,e as nt,b as st,d as it,p as at,g as rt,h as ot,j as lt,k as ct,l as dt,m as ut,S as pt,o as mt,q as ht,r as xt,s as ft,t as gt,u as vt,v as bt,x as yt,y as wt,z as jt,A as Ct,B as Nt,C as Ft,D as _t,E as kt,F as St,G as Et,R as It,P as At,H as Tt,I as Mt,J as Dt,K as Lt,L as Pt}from"./chunks/chunk-DreM7Bcy.js";import{a as Rt,r as Ot}from"./chunks/chunk-BIyfHqPs.js";import{m as zt,A as Bt,u as Ht}from"./chunks/chunk-CU-y1Q6f.js";import{w as $t,F as Vt,_ as Ut}from"./chunks/chunk-5rBBrdbz.js";!function(){const e=document.createElement("link").relList;if(!(e&&e.supports&&e.supports("modulepreload"))){for(const e of document.querySelectorAll('link[rel="modulepreload"]'))t(e);new MutationObserver(e=>{for(const n of e)if("childList"===n.type)for(const e of n.addedNodes)"LINK"===e.tagName&&"modulepreload"===e.rel&&t(e)}).observe(document,{childList:!0,subtree:!0})}function t(e){if(e.ep)return;e.ep=!0;const t=function(e){const t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),"use-credentials"===e.crossOrigin?t.credentials="include":"anonymous"===e.crossOrigin?t.credentials="omit":t.credentials="same-origin",t}(e);fetch(e.href,t)}}();var Wt,qt={};const Gt=Le(function(){if(Wt)return qt;Wt=1;var e=De();return qt.createRoot=e.createRoot,qt.hydrateRoot=e.hydrateRoot,qt}()),Zt={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1,VITE_API_BASE_URL:"https://api.emergent.sh",VITE_API_BASE_URL_APP_PUBLIC_POSTHOG_KEY:"phc_xAvL2Iq4tFmANRE7kzbKwaSqp1HJjN7x48s3vr0CMjs",VITE_APP_BLITZ_API_KEY:"key_BW17ja9hEvA2Mym",VITE_APP_CDN_URL:"preview.static.emergentagent.com",VITE_APP_PUBLIC_POSTHOG_HOST:"https://us.i.posthog.com",VITE_APP_PUSHER_CLUSTER:"us2",VITE_APP_PUSHER_KEY:"6c79f46bf9937b9d82df",VITE_APP_UPLOAD_URL:"https://files.emergent.sh",VITE_APP_VERSION:"1.0.32",VITE_CLOUDINARY_CLOUD_NAME:"dedwy4r6x",VITE_GITHUB_APP_URL:"https://github.com/apps/emergent-sh/installations/new",VITE_GITHUB_CLIENT_ID:"Iv23liv4X4UqMyubvvul",VITE_GOOGLE_CLIENT_ID:"201274743812-rbtii4pvbnhsfh5f0tg26qo31hcrfmg5.apps.googleusercontent.com",VITE_NEWRELIC_ACCOUNT_ID:"7256303",VITE_NEWRELIC_AGENT_ID:"1589150949",VITE_NEWRELIC_APPLICATION_ID:"1589150949",VITE_NEWRELIC_LICENSE_KEY:"NRBR-5532f07fcd7ef7d45ce",VITE_NEWRELIC_TRUST_KEY:"7256303",VITE_PREVIEW_QR_API_URL:"https://qr.emergent.host",VITE_SUPABASE_ANON_KEY:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InNua3N4d2t5dW1oZHlreXJoaGNoIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MjQ3NzI2NDYsImV4cCI6MjA0MDM0ODY0Nn0.3unO6zdz2NilPL2xdxt7OjvZA19copj3Q7ulIjPVDLQ",VITE_SUPABASE_URL:"https://snksxwkyumhdykyrhhch.supabase.co"};!function(){const e=["VITE_SUPABASE_URL","VITE_SUPABASE_ANON_KEY","VITE_API_BASE_URL","VITE_GITHUB_APP_URL","VITE_GITHUB_CLIENT_ID","VITE_API_BASE_URL_APP_PUBLIC_POSTHOG_KEY","VITE_APP_PUBLIC_POSTHOG_HOST","VITE_APP_UPLOAD_URL","VITE_CLOUDINARY_CLOUD_NAME"].filter(e=>!Zt[e]);if(e.length>0)throw new Error(`Missing required environment variables: ${e.join(", ")}`)}();const Yt={supabaseUrl:"https://snksxwkyumhdykyrhhch.supabase.co",supabaseAnonKey:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InNua3N4d2t5dW1oZHlreXJoaGNoIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MjQ3NzI2NDYsImV4cCI6MjA0MDM0ODY0Nn0.3unO6zdz2NilPL2xdxt7OjvZA19copj3Q7ulIjPVDLQ",googleClientId:"201274743812-rbtii4pvbnhsfh5f0tg26qo31hcrfmg5.apps.googleusercontent.com",githubToken:void 0,_pluginLibraryVersion:"1.0.6-beta",_apiBaseUrl:"https://api.emergent.sh",_blitzApiKey:"key_BW17ja9hEvA2Mym",_file_upload_url:"https://files.emergent.sh",_cdn_url:"preview.static.emergentagent.com",get apiBaseUrl(){return this._apiBaseUrl},set apiBaseUrl(e){this._apiBaseUrl=e,localStorage.setItem("apiBaseUrl",e)},get blitzApiKey(){return this._blitzApiKey},get cdnUrl(){return this._cdn_url}},Kt="https://github.com/apps/emergent-sh/installations/new",Jt="phc_xAvL2Iq4tFmANRE7kzbKwaSqp1HJjN7x48s3vr0CMjs",Qt="https://us.i.posthog.com",Xt=!1,en=Ye(Yt.supabaseUrl,Yt.supabaseAnonKey),tn=Object.freeze(Object.defineProperty({__proto__:null,supabase:en},Symbol.toStringTag,{value:"Module"}));let nn=0;const sn=new Map,an=e=>{if(sn.has(e))return;const t=setTimeout(()=>{sn.delete(e),cn({type:"REMOVE_TOAST",toastId:e})},5e3);sn.set(e,t)},rn=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,5)};case"UPDATE_TOAST":return{...e,toasts:e.toasts.map(e=>e.id===t.toast.id?{...e,...t.toast}:e)};case"DISMISS_TOAST":{const{toastId:n}=t;return n?an(n):e.toasts.forEach(e=>{an(e.id)}),{...e,toasts:e.toasts.map(e=>e.id===n||void 0===n?{...e,open:!1}:e)}}case"REMOVE_TOAST":return void 0===t.toastId?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(e=>e.id!==t.toastId)}}},on=[];let ln={toasts:[]};function cn(e){ln=rn(ln,e),on.forEach(e=>{e(ln)})}function dn({...e}){const t=(nn=(nn+1)%Number.MAX_SAFE_INTEGER,nn.toString()),n=e.duration||5e3,s=()=>cn({type:"DISMISS_TOAST",toastId:t});return cn({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:e=>{e||s()}}}),n!==1/0&&setTimeout(s,n),{id:t,dismiss:s,update:e=>cn({type:"UPDATE_TOAST",toast:{...e,id:t}})}}function un(){const[e,t]=Pe.useState(ln);return Pe.useEffect(()=>(on.push(t),()=>{const e=on.indexOf(t);e>-1&&on.splice(e,1)}),[e]),{...e,toast:dn,dismiss:e=>cn({type:"DISMISS_TOAST",toastId:e})}}var pn="undefined"!=typeof window?window:void 0,mn="undefined"!=typeof globalThis?globalThis:pn,hn=Array.prototype,xn=hn.forEach,fn=hn.indexOf,gn=null==mn?void 0:mn.navigator,vn=null==mn?void 0:mn.document,bn=null==mn?void 0:mn.location,yn=null==mn?void 0:mn.fetch,wn=null!=mn&&mn.XMLHttpRequest&&"withCredentials"in new mn.XMLHttpRequest?mn.XMLHttpRequest:void 0,jn=null==mn?void 0:mn.AbortController,Cn=null==gn?void 0:gn.userAgent,Nn=null!=pn?pn:{},Fn={DEBUG:!1,LIB_VERSION:"1.270.1"};function _n(e,t,n,s,i,a,r){try{var o=e[a](r),l=o.value}catch(c){return void n(c)}o.done?t(l):Promise.resolve(l).then(s,i)}function kn(e){return function(){var t=this,n=arguments;return new Promise(function(s,i){var a=e.apply(t,n);function r(e){_n(a,s,i,r,o,"next",e)}function o(e){_n(a,s,i,r,o,"throw",e)}r(void 0)})}}function Sn(){return Sn=Object.assign?Object.assign.bind():function(e){for(var t=1;t"function"==typeof e,Bn=e=>e===Object(e)&&!On(e),Hn=e=>{if(Bn(e)){for(var t in e)if(Pn.call(e,t))return!1;return!0}return!1},$n=e=>void 0===e,Vn=e=>"[object String]"==Rn.call(e),Un=e=>Vn(e)&&0===e.trim().length,Wn=e=>null===e,qn=e=>$n(e)||Wn(e),Gn=e=>"[object Number]"==Rn.call(e),Zn=e=>"[object Boolean]"===Rn.call(e),Yn=e=>An(In,e);function Kn(e){return null===e||"object"!=typeof e}function Jn(e,t){return Object.prototype.toString.call(e)==="[object "+t+"]"}function Qn(e){return!$n(Event)&&function(e,t){try{return e instanceof t}catch(n){return!1}}(e,Event)}var Xn=[!0,"true",1,"1","yes"],es=e=>An(Xn,e),ts=[!1,"false",0,"0","no"];function ns(e,t,n,s,i){return t>n&&(s.warn("min cannot be greater than max."),t=n),Gn(e)?e>n?(s.warn(" cannot be greater than max: "+n+". Using max value instead."),n):e{Object.keys(this.i).forEach(e=>{var t=this.h(e)+this.m;t>=this.S?delete this.i[e]:this.k(e,t)})},this.h=e=>this.i[String(e)],this.k=(e,t)=>{this.i[String(e)]=t},this.consumeRateLimit=e=>{var t,n,s=null!==(t=this.h(e))&&void 0!==t?t:this.S;if(0===(s=Math.max(s-1,0)))return!0;this.k(e,s);var i=0===s;return i&&(null==(n=this.$)||n.call(this,e)),i},this.$=this.t.$,this.S=ns(this.t.bucketSize,0,100,this.t.R),this.m=ns(this.t.refillRate,0,this.S,this.t.R),this.I=ns(this.t.refillInterval,0,864e5,this.t.R),this.P=setInterval(()=>{this.o()},this.I)}stop(){this.P&&(clearInterval(this.P),this.P=void 0)}};var is,as,rs,os=e=>e instanceof Error;function ls(e){var t=globalThis._posthogChunkIds;if(t){var n=Object.keys(t);return rs&&n.length===as||(as=n.length,rs=n.reduce((n,s)=>{is||(is={});var i=is[s];if(i)n[i[0]]=i[1];else for(var a=e(s),r=a.length-1;r>=0;r--){var o=a[r],l=null==o?void 0:o.filename,c=t[s];if(l&&c){n[l]=c,is[s]=[l,c];break}}return n},{})),rs}}var cs="?";function ds(e,t,n,s){var i={platform:"web:javascript",filename:e,function:""===t?cs:t,in_app:!0};return $n(n)||(i.lineno=n),$n(s)||(i.colno=s),i}var us=(e,t)=>{var n=-1!==e.indexOf("safari-extension"),s=-1!==e.indexOf("safari-web-extension");return n||s?[-1!==e.indexOf("@")?e.split("@")[0]:cs,n?"safari-extension:"+t:"safari-web-extension:"+t]:[e,t]},ps=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,ms=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,hs=/\((\S*)(?::(\d+))(?::(\d+))\)/,xs=e=>{var t=ps.exec(e);if(t){var[,n,s,i]=t;return ds(n,cs,+s,+i)}var a=ms.exec(e);if(a){if(a[2]&&0===a[2].indexOf("eval")){var r=hs.exec(a[2]);r&&(a[2]=r[1],a[3]=r[2],a[4]=r[3])}var[o,l]=us(a[1]||cs,a[2]);return ds(l,o,a[3]?+a[3]:void 0,a[4]?+a[4]:void 0)}},fs=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,gs=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,vs=e=>{var t=fs.exec(e);if(t){if(t[3]&&t[3].indexOf(" > eval")>-1){var n=gs.exec(t[3]);n&&(t[1]=t[1]||"eval",t[3]=n[1],t[4]=n[2],t[5]="")}var s=t[3],i=t[1]||cs;return[i,s]=us(i,s),ds(s,i,t[4]?+t[4]:void 0,t[5]?+t[5]:void 0)}},bs=/\(error: (.*)\)/;let ys=class{constructor(e,t,n){void 0===e&&(e=[]),void 0===t&&(t=[]),void 0===n&&(n=[]),this.coercers=e,this.modifiers=n,this.stackParser=function(){for(var e=arguments.length,t=new Array(e),n=0;n1024)){var o=bs.test(r)?r.replace(bs,"$1"):r;if(!o.match(/\S*Error: /)){for(var l of t){var c=l(o);if(c){s.push(c);break}}if(s.length>=50)break}}}return function(e){if(!e.length)return[];var t=Array.from(e);return t.reverse(),t.slice(0,50).map(e=>{return Sn({},e,{filename:e.filename||(n=t,n[n.length-1]||{}).filename,function:e.function||cs});var n})}(s)}}(...t)}buildFromUnknown(e,t){void 0===t&&(t={});var n=t&&t.mechanism||{handled:!0,type:"generic"},s=this.buildCoercingContext(n,t,0).apply(e),i=this.buildParsingContext(),a=this.parseStacktrace(s,i);return{$exception_list:this.convertToExceptionList(a,n),$exception_level:"error"}}modifyFrames(e){var t=this;return kn(function*(){for(var n of e)n.stacktrace&&n.stacktrace.frames&&On(n.stacktrace.frames)&&(n.stacktrace.frames=yield t.applyModifiers(n.stacktrace.frames));return e})()}coerceFallback(e){var t;return{type:"Error",value:"Unknown error",stack:null==(t=e.syntheticException)?void 0:t.stack,synthetic:!0}}parseStacktrace(e,t){var n,s;return null!=e.cause&&(n=this.parseStacktrace(e.cause,t)),""!=e.stack&&null!=e.stack&&(s=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?1:0),t.chunkIdMap)),Sn({},e,{cause:n,stack:s})}applyChunkIds(e,t){return e.map(e=>(e.filename&&t&&(e.chunk_id=t[e.filename]),e))}applyCoercers(e,t){for(var n of this.coercers)if(n.match(e))return n.coerce(e,t);return this.coerceFallback(t)}applyModifiers(e){var t=this;return kn(function*(){var n=e;for(var s of t.modifiers)n=yield s(n);return n})()}convertToExceptionList(e,t){var n,s,i,a={type:e.type,value:e.value,mechanism:{type:null!==(n=t.type)&&void 0!==n?n:"generic",handled:null===(s=t.handled)||void 0===s||s,synthetic:null!==(i=e.synthetic)&&void 0!==i&&i}};e.stack&&(a.stacktrace={type:"raw",frames:e.stack});var r=[a];return null!=e.cause&&r.push(...this.convertToExceptionList(e.cause,Sn({},t,{handled:!0}))),r}buildParsingContext(){return{chunkIdMap:ls(this.stackParser)}}buildCoercingContext(e,t,n){void 0===n&&(n=0);var s=(n,s)=>{if(s<=4){var i=this.buildCoercingContext(e,t,s);return this.applyCoercers(n,i)}};return Sn({},t,{syntheticException:0==n?t.syntheticException:void 0,mechanism:e,apply:e=>s(e,n),next:e=>s(e,n+1)})}},ws=class{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){var n=Vn(e.stack);return{type:this.getType(e),value:this.getValue(e),stack:n?e.stack:void 0,cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return this.isDOMError(e)?"DOMError":"DOMException"}getValue(e){var t=e.name||(this.isDOMError(e)?"DOMError":"DOMException");return e.message?t+": "+e.message:t}isDOMException(e){return Jn(e,"DOMException")}isDOMError(e){return Jn(e,"DOMError")}};class js{match(e){return e instanceof Error}coerce(e,t){return{type:this.getType(e),value:this.getMessage(e,t),stack:this.getStack(e),cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return e.name||e.constructor.name}getMessage(e,t){var n=e.message;return n.error&&"string"==typeof n.error.message?String(n.error.message):String(n)}getStack(e){return e.stacktrace||e.stack||void 0}}let Cs=class{constructor(){}match(e){return Jn(e,"ErrorEvent")&&null!=e.error}coerce(e,t){var n;return t.apply(e.error)||{type:"ErrorEvent",value:e.message,stack:null==(n=t.syntheticException)?void 0:n.stack,synthetic:!0}}};var Ns=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;class Fs{match(e){return"string"==typeof e}coerce(e,t){var n,[s,i]=this.getInfos(e);return{type:null!=s?s:"Error",value:null!=i?i:e,stack:null==(n=t.syntheticException)?void 0:n.stack,synthetic:!0}}getInfos(e){var t="Error",n=e,s=e.match(Ns);return s&&(t=s[1],n=s[2]),[t,n]}}var _s=["fatal","error","warning","log","info","debug"];function ks(e,t){void 0===t&&(t=40);var n=Object.keys(e);if(n.sort(),!n.length)return"[object has no keys]";for(var s=n.length;s>0;s--){var i=n.slice(0,s).join(", ");if(!(i.length>t))return s===n.length||i.length<=t?i:i.slice(0,t)+"..."}return""}let Ss=class{match(e){return"object"==typeof e&&null!==e}coerce(e,t){var n,s=this.getErrorPropertyFromObject(e);return s?t.apply(s):{type:this.getType(e),value:this.getValue(e),stack:null==(n=t.syntheticException)?void 0:n.stack,level:this.isSeverityLevel(e.level)?e.level:"error",synthetic:!0}}getType(e){return Qn(e)?e.constructor.name:"Error"}getValue(e){if("name"in e&&"string"==typeof e.name){var t="'"+e.name+"' captured as exception";return"message"in e&&"string"==typeof e.message&&(t+=" with message: '"+e.message+"'"),t}if("message"in e&&"string"==typeof e.message)return e.message;var n=this.getObjectClassName(e);return(n&&"Object"!==n?"'"+n+"'":"Object")+" captured as exception with keys: "+ks(e)}isSeverityLevel(e){return Vn(e)&&!Un(e)&&_s.indexOf(e)>=0}getErrorPropertyFromObject(e){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t)){var n=e[t];if(os(n))return n}}getObjectClassName(e){try{var t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch(n){return}}},Es=class{match(e){return Qn(e)}coerce(e,t){var n,s=e.constructor.name;return{type:s,value:s+" captured as exception with keys: "+ks(e),stack:null==(n=t.syntheticException)?void 0:n.stack,synthetic:!0}}};class Is{match(e){return Kn(e)}coerce(e,t){var n;return{type:"Error",value:"Primitive value captured as exception: "+String(e),stack:null==(n=t.syntheticException)?void 0:n.stack,synthetic:!0}}}let As=class{match(e){return Jn(e,"PromiseRejectionEvent")}coerce(e,t){var n,s=this.getUnhandledRejectionReason(e);return Kn(s)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(s),stack:null==(n=t.syntheticException)?void 0:n.stack,synthetic:!0}:t.apply(s)}getUnhandledRejectionReason(e){if(Kn(e))return e;try{if("reason"in e)return e.reason;if("detail"in e&&"reason"in e.detail)return e.detail.reason}catch(t){}return e}};var Ts=e=>{var t={T:function(t){if(pn&&(Fn.DEBUG||Nn.POSTHOG_DEBUG)&&!$n(pn.console)&&pn.console){for(var n=("__rrweb_original__"in pn.console[t]?pn.console[t].__rrweb_original__:pn.console[t]),s=arguments.length,i=new Array(s>1?s-1:0),a=1;a{t.error("You must initialize PostHog before calling "+e)},createLogger:t=>Ts(e+" "+t)};return t},Ms=Ts("[PostHog.js]"),Ds=Ms.createLogger,Ls=Ds("[ExternalScriptsLoader]"),Ps=(e,t,n)=>{if(e.config.disable_external_dependency_loading)return Ls.warn(t+" was requested but loading of external scripts is disabled."),n("Loading of external scripts is disabled");var s=null==vn?void 0:vn.querySelectorAll("script");if(s)for(var i,a=function(){if(s[r].src===t){var e=s[r];return e.__posthog_loading_callback_fired?{v:n()}:(e.addEventListener("load",t=>{e.__posthog_loading_callback_fired=!0,n(void 0,t)}),e.onerror=e=>n(e),{v:void 0})}},r=0;r{if(!vn)return n("document not found");var s=vn.createElement("script");if(s.type="text/javascript",s.crossOrigin="anonymous",s.src=t,s.onload=e=>{s.__posthog_loading_callback_fired=!0,n(void 0,e)},s.onerror=e=>n(e),e.config.prepare_external_dependency_script&&(s=e.config.prepare_external_dependency_script(s)),!s)return n("prepare_external_dependency_script returned null");var i,a=vn.querySelectorAll("body > script");a.length>0?null==(i=a[0].parentNode)||i.insertBefore(s,a[0]):vn.body.appendChild(s)};null!=vn&&vn.body?o():null==vn||vn.addEventListener("DOMContentLoaded",o)};Nn.__PosthogExtensions__=Nn.__PosthogExtensions__||{},Nn.__PosthogExtensions__.loadExternalDependency=(e,t,n)=>{var s="/static/"+t+".js?v="+e.version;if("remote-config"===t&&(s="/array/"+e.config.token+"/config.js"),"toolbar"===t){var i=3e5;s=s+"&t="+Math.floor(Date.now()/i)*i}var a=e.requestRouter.endpointFor("assets",s);Ps(e,a,n)},Nn.__PosthogExtensions__.loadSiteApp=(e,t,n)=>{var s=e.requestRouter.endpointFor("api",t);Ps(e,s,n)};var Rs={};function Os(e,t,n){if(On(e))if(xn&&e.forEach===xn)e.forEach(t,n);else if("length"in e&&e.length===+e.length)for(var s=0,i=e.length;se instanceof FormData)(e)){for(var s of e.entries())if(t.call(n,s[1],s[0])===Rs)return}else for(var i in e)if(Pn.call(e,i)&&t.call(n,e[i],i)===Rs)return}}var Bs=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),s=1;s1?t-1:0),s=1;s0||Gn(e))&&(t[n]=e)}),t};var qs=["herokuapp.com","vercel.app","netlify.app"];function Gs(e){var t=null==e?void 0:e.hostname;if(!Vn(t))return!1;var n=t.split(".").slice(-2).join(".");for(var s of qs)if(n===s)return!1;return!0}function Zs(e,t){for(var n=0;nt.match(e)))}function Wi(e){var t="";switch(typeof e.className){case"string":t=e.className;break;case"object":t=(e.className&&"baseVal"in e.className?e.className.baseVal:null)||e.getAttribute("class")||"";break;default:t=""}return Vi(t)}function qi(e){return qn(e)?null:Tn(e).split(/(\s+)/).filter(e=>ca(e)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Gi(e){var t="";return ta(e)&&!na(e)&&e.childNodes&&e.childNodes.length&&zs(e.childNodes,function(e){var n;Hi(e)&&e.textContent&&(t+=null!==(n=qi(e.textContent))&&void 0!==n?n:"")}),Tn(t)}function Zi(e){return $n(e.target)?e.srcElement||null:null!=(t=e.target)&&t.shadowRoot?e.composedPath()[0]||null:e.target||null;var t}var Yi=["a","button","form","input","select","textarea","label"];function Ki(e,t){if($n(t))return!0;var n,s=function(e){if(t.some(t=>e.matches(t)))return{v:!0}};for(var i of e)if(n=s(i))return n.v;return!1}function Ji(e){var t=e.parentNode;return!(!t||!zi(t))&&t}var Qi=[".ph-no-rageclick",".ph-no-capture"],Xi=e=>!e||Bi(e,"html")||!zi(e),ea=(e,t)=>{if(!pn||Xi(e))return{parentIsUsefulElement:!1,targetElementList:[]};for(var n=!1,s=[e],i=e;i.parentNode&&!Bi(i,"body");)if($i(i.parentNode))s.push(i.parentNode.host),i=i.parentNode.host;else{var a=Ji(i);if(!a)break;if(t||Yi.indexOf(a.tagName.toLowerCase())>-1)n=!0;else{var r=pn.getComputedStyle(a);r&&"pointer"===r.getPropertyValue("cursor")&&(n=!0)}s.push(a),i=a}return{parentIsUsefulElement:n,targetElementList:s}};function ta(e){for(var t=e;t.parentNode&&!Bi(t,"body");t=t.parentNode){var n=Wi(t);if(An(n,"ph-sensitive")||An(n,"ph-no-capture"))return!1}if(An(Wi(e),"ph-include"))return!0;var s=e.type||"";if(Vn(s))switch(s.toLowerCase()){case"hidden":case"password":return!1}var i=e.name||e.id||"";return!Vn(i)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(i.replace(/[^a-zA-Z0-9]/g,""))}function na(e){return!!(Bi(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||Bi(e,"select")||Bi(e,"textarea")||"true"===e.getAttribute("contenteditable"))}var sa="(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11})",ia=new RegExp("^(?:"+sa+")$"),aa=new RegExp(sa),ra="\\d{3}-?\\d{2}-?\\d{4}",oa=new RegExp("^("+ra+")$"),la=new RegExp("("+ra+")");function ca(e,t){if(void 0===t&&(t=!0),qn(e))return!1;if(Vn(e)){if(e=Tn(e),(t?ia:aa).test((e||"").replace(/[- ]/g,"")))return!1;if((t?oa:la).test(e))return!1}return!0}function da(e){var t=Gi(e);return ca(t=(t+" "+ua(e)).trim())?t:""}function ua(e){var t="";return e&&e.childNodes&&e.childNodes.length&&zs(e.childNodes,function(e){var n;if(e&&"span"===(null==(n=e.tagName)?void 0:n.toLowerCase()))try{var s=Gi(e);t=(t+" "+s).trim(),e.childNodes&&e.childNodes.length&&(t=(t+" "+ua(e)).trim())}catch(i){Ms.error("[AutoCapture]",i)}}),t}function pa(e){return function(e){return e.map(e=>{var t,n,s="";if(e.tag_name&&(s+=e.tag_name),e.attr_class)for(var i of(e.attr_class.sort(),e.attr_class))s+="."+i.replace(/"/g,"");var a=Sn({},e.text?{text:e.text}:{},{"nth-child":null!==(t=e.nth_child)&&void 0!==t?t:0,"nth-of-type":null!==(n=e.nth_of_type)&&void 0!==n?n:0},e.href?{href:e.href}:{},e.attr_id?{attr_id:e.attr_id}:{},e.attributes),r={};return $s(a).sort((e,t)=>{var[n]=e,[s]=t;return n.localeCompare(s)}).forEach(e=>{var[t,n]=e;return r[ma(t.toString())]=ma(n.toString())}),(s+=":")+$s(r).map(e=>{var[t,n]=e;return t+'="'+n+'"'}).join("")}).join(";")}(e.map(e=>{var t,n,s={text:null==(t=e.$el_text)?void 0:t.slice(0,400),tag_name:e.tag_name,href:null==(n=e.attr__href)?void 0:n.slice(0,2048),attr_class:ha(e),attr_id:e.attr__id,nth_child:e.nth_child,nth_of_type:e.nth_of_type,attributes:{}};return $s(e).filter(e=>{var[t]=e;return 0===t.indexOf("attr__")}).forEach(e=>{var[t,n]=e;return s.attributes[t]=n}),s}))}function ma(e){return e.replace(/"|\\"/g,'\\"')}function ha(e){var t=e.attr__class;return t?On(t)?t:Vi(t):void 0}let xa=class{constructor(){this.clicks=[]}isRageClick(e,t,n){var s=this.clicks[this.clicks.length-1];if(s&&Math.abs(e-s.x)+Math.abs(t-s.y)<30&&n-s.timestamp<1e3){if(this.clicks.push({x:e,y:t,timestamp:n}),3===this.clicks.length)return!0}else this.clicks=[{x:e,y:t,timestamp:n}];return!1}};var fa,ga="$copy_autocapture",va=((fa={}).GZipJS="gzip-js",fa.Base64="base64",fa),ba=["localhost","127.0.0.1"],ya=e=>{var t=null==vn?void 0:vn.createElement("a");return $n(t)?null:(t.href=e,t)},wa=function(e,t){for(var n,s=((e.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),i=0;ie?t.slice(0,e)+"...":t}function _a(e){if(e.previousElementSibling)return e.previousElementSibling;var t=e;do{t=t.previousSibling}while(t&&!zi(t));return t}function ka(e,t){for(var n,s,{e:i,maskAllElementAttributes:a,maskAllText:r,elementAttributeIgnoreList:o,elementsChainAsString:l}=t,c=[e],d=e;d.parentNode&&!Bi(d,"body");)$i(d.parentNode)?(c.push(d.parentNode.host),d=d.parentNode.host):(c.push(d.parentNode),d=d.parentNode);var u,p=[],m={},h=!1,x=!1;if(zs(c,e=>{var t=ta(e);"a"===e.tagName.toLowerCase()&&(h=e.getAttribute("href"),h=t&&h&&ca(h)&&h),An(Wi(e),"ph-no-capture")&&(x=!0),p.push(function(e,t,n,s){var i=e.tagName.toLowerCase(),a={tag_name:i};Yi.indexOf(i)>-1&&!n&&("a"===i.toLowerCase()||"button"===i.toLowerCase()?a.$el_text=Fa(1024,da(e)):a.$el_text=Fa(1024,Gi(e)));var r=Wi(e);r.length>0&&(a.classes=r.filter(function(e){return""!==e})),zs(e.attributes,function(n){var i;if((!na(e)||-1!==["name","id","class","aria-label"].indexOf(n.name))&&(null==s||!s.includes(n.name))&&!t&&ca(n.value)&&(i=n.name,!Vn(i)||"_ngcontent"!==i.substring(0,10)&&"_nghost"!==i.substring(0,7))){var r=n.value;"class"===n.name&&(r=Vi(r).join(" ")),a["attr__"+n.name]=Fa(1024,r)}});for(var o=1,l=1,c=e;c=_a(c);)o++,c.tagName===e.tagName&&l++;return a.nth_child=o,a.nth_of_type=l,a}(e,a,r,o));var n=function(e){if(!ta(e))return{};var t={};return zs(e.attributes,function(e){if(e.name&&0===e.name.indexOf("data-ph-capture-attribute")){var n=e.name.replace("data-ph-capture-attribute-",""),s=e.value;n&&s&&ca(s)&&(t[n]=s)}}),t}(e);Bs(m,n)}),x)return{props:{},explicitNoCapture:x};if(r||("a"===e.tagName.toLowerCase()||"button"===e.tagName.toLowerCase()?p[0].$el_text=da(e):p[0].$el_text=Gi(e)),h){var f,g;p[0].attr__href=h;var v=null==(f=ya(h))?void 0:f.host,b=null==pn||null==(g=pn.location)?void 0:g.host;v&&b&&v!==b&&(u=h)}return{props:Bs({$event_type:i.type,$ce_version:1},l?{}:{$elements:p},{$elements_chain:pa(p)},null!=(n=p[0])&&n.$el_text?{$el_text:null==(s=p[0])?void 0:s.$el_text}:{},u&&"click"===i.type?{$external_click_url:u}:{},m)}}let Sa=class{constructor(e){this.C=!1,this.M=null,this.rageclicks=new xa,this.O=!1,this.instance=e,this.F=null}get A(){var e,t,n=Bn(this.instance.config.autocapture)?this.instance.config.autocapture:{};return n.url_allowlist=null==(e=n.url_allowlist)?void 0:e.map(e=>new RegExp(e)),n.url_ignorelist=null==(t=n.url_ignorelist)?void 0:t.map(e=>new RegExp(e)),n}D(){if(this.isBrowserSupported()){if(pn&&vn){var e=e=>{e=e||(null==pn?void 0:pn.event);try{this.j(e)}catch(fa){Na.error("Failed to capture event",fa)}};if(Ys(vn,"submit",e,{capture:!0}),Ys(vn,"change",e,{capture:!0}),Ys(vn,"click",e,{capture:!0}),this.A.capture_copied_text){var t=e=>{e=e||(null==pn?void 0:pn.event),this.j(e,ga)};Ys(vn,"copy",t,{capture:!0}),Ys(vn,"cut",t,{capture:!0})}}}else Na.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this.C&&(this.D(),this.C=!0)}onRemoteConfig(e){e.elementsChainAsString&&(this.O=e.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[Xs]:!!e.autocapture_opt_out}),this.M=!!e.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(e){this.F=e}getElementSelectors(e){var t,n=[];return null==(t=this.F)||t.forEach(t=>{var s=null==vn?void 0:vn.querySelectorAll(t);null==s||s.forEach(s=>{e===s&&n.push(t)})}),n}get isEnabled(){var e,t,n=null==(e=this.instance.persistence)?void 0:e.props[Xs],s=this.M;if(Wn(s)&&!Zn(n)&&!this.instance.L())return!1;var i=null!==(t=this.M)&&void 0!==t?t:!!n;return!!this.instance.config.autocapture&&!i}j(e,t){if(void 0===t&&(t="$autocapture"),this.isEnabled){var n,s=Zi(e);Hi(s)&&(s=s.parentNode||null),"$autocapture"===t&&"click"===e.type&&e instanceof MouseEvent&&this.instance.config.rageclick&&null!=(n=this.rageclicks)&&n.isRageClick(e.clientX,e.clientY,(new Date).getTime())&&function(e,t){if(!pn||Xi(e))return!1;var n,s;if(!1===(n=Zn(t)?!!t&&Qi:null!==(s=null==t?void 0:t.css_selector_ignorelist)&&void 0!==s?s:Qi))return!1;var{targetElementList:i}=ea(e,!1);return!Ki(i,n)}(s,this.instance.config.rageclick)&&this.j(e,"$rageclick");var i=t===ga;if(s&&function(e,t,n,s,i){var a,r,o,l;if(void 0===n&&(n=void 0),!pn||Xi(e))return!1;if(null!=(a=n)&&a.url_allowlist&&!Ui(n.url_allowlist))return!1;if(null!=(r=n)&&r.url_ignorelist&&Ui(n.url_ignorelist))return!1;if(null!=(o=n)&&o.dom_event_allowlist){var c=n.dom_event_allowlist;if(c&&!c.some(e=>t.type===e))return!1}var{parentIsUsefulElement:d,targetElementList:u}=ea(e,s);if(!function(e,t){var n=null==t?void 0:t.element_allowlist;if($n(n))return!0;var s,i=function(e){if(n.some(t=>e.tagName.toLowerCase()===t))return{v:!0}};for(var a of e)if(s=i(a))return s.v;return!1}(u,n))return!1;if(!Ki(u,null==(l=n)?void 0:l.css_selector_allowlist))return!1;var p=pn.getComputedStyle(e);if(p&&"pointer"===p.getPropertyValue("cursor")&&"click"===t.type)return!0;var m=e.tagName.toLowerCase();switch(m){case"html":return!1;case"form":return(i||["submit"]).indexOf(t.type)>=0;case"input":case"select":case"textarea":return(i||["change","click"]).indexOf(t.type)>=0;default:return d?(i||["click"]).indexOf(t.type)>=0:(i||["click"]).indexOf(t.type)>=0&&(Yi.indexOf(m)>-1||"true"===e.getAttribute("contenteditable"))}}(s,e,this.A,i,i?["copy","cut"]:void 0)){var{props:a,explicitNoCapture:r}=ka(s,{e:e,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.A.element_attribute_ignorelist,elementsChainAsString:this.O});if(r)return!1;var o=this.getElementSelectors(s);if(o&&o.length>0&&(a.$element_selectors=o),t===ga){var l,c=qi(null==pn||null==(l=pn.getSelection())?void 0:l.toString()),d=e.type||"clipboard";if(!c)return!1;a.$selected_content=c,a.$copy_type=d}return this.instance.capture(t,a),!0}}}isBrowserSupported(){return zn(null==vn?void 0:vn.querySelectorAll)}};Math.trunc||(Math.trunc=function(e){return e<0?Math.ceil(e):Math.floor(e)}),Number.isInteger||(Number.isInteger=function(e){return Gn(e)&&isFinite(e)&&Math.floor(e)===e});var Ea="0123456789abcdef";let Ia=class e{constructor(e){if(this.bytes=e,16!==e.length)throw new TypeError("not 128-bit length")}static fromFieldsV7(t,n,s,i){if(!Number.isInteger(t)||!Number.isInteger(n)||!Number.isInteger(s)||!Number.isInteger(i)||t<0||n<0||s<0||i<0||t>0xffffffffffff||n>4095||s>1073741823||i>4294967295)throw new RangeError("invalid field value");var a=new Uint8Array(16);return a[0]=t/Math.pow(2,40),a[1]=t/Math.pow(2,32),a[2]=t/Math.pow(2,24),a[3]=t/Math.pow(2,16),a[4]=t/Math.pow(2,8),a[5]=t,a[6]=112|n>>>8,a[7]=n,a[8]=128|s>>>24,a[9]=s>>>16,a[10]=s>>>8,a[11]=s,a[12]=i>>>24,a[13]=i>>>16,a[14]=i>>>8,a[15]=i,new e(a)}toString(){for(var e="",t=0;t>>4)+Ea.charAt(15&this.bytes[t]),3!==t&&5!==t&&7!==t&&9!==t||(e+="-");if(36!==e.length)throw new Error("Invalid UUIDv7 was generated");return e}clone(){return new e(this.bytes.slice(0))}equals(e){return 0===this.compareTo(e)}compareTo(e){for(var t=0;t<16;t++){var n=this.bytes[t]-e.bytes[t];if(0!==n)return Math.sign(n)}return 0}},Aa=class{constructor(){this.N=0,this.U=0,this.B=new Da}generate(){var e=this.generateOrAbort();if($n(e)){this.N=0;var t=this.generateOrAbort();if($n(t))throw new Error("Could not generate UUID after timestamp reset");return t}return e}generateOrAbort(){var e=Date.now();if(e>this.N)this.N=e,this.q();else{if(!(e+1e4>this.N))return;this.U++,this.U>4398046511103&&(this.N++,this.q())}return Ia.fromFieldsV7(this.N,Math.trunc(this.U/Math.pow(2,30)),this.U&Math.pow(2,30)-1,this.B.nextUint32())}q(){this.U=1024*this.B.nextUint32()+(1023&this.B.nextUint32())}};var Ta,Ma=e=>{if("undefined"!=typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var t=0;tcrypto.getRandomValues(e));let Da=class{constructor(){this.H=new Uint32Array(8),this.W=1/0}nextUint32(){return this.W>=this.H.length&&(Ma(this.H),this.W=0),this.H[this.W++]}};var La=()=>Pa().toString(),Pa=()=>(Ta||(Ta=new Aa)).generate(),Ra="",Oa=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;var za={G:()=>!!vn,V:function(e){Ms.error("cookieStore error: "+e)},J:function(e){if(vn){try{for(var t=e+"=",n=vn.cookie.split(";").filter(e=>e.length),s=0;s3686.4&&Ms.warn("cookieStore warning: large cookie, len="+c.length),vn.cookie=c,c}catch(d){return}},X:function(e,t){if(null!=vn&&vn.cookie)try{za.Y(e,"",-1,t)}catch(n){return}}},Ba=null,Ha={G:function(){if(!Wn(Ba))return Ba;var e=!0;if($n(pn))e=!1;else try{var t="__mplssupport__";Ha.Y(t,"xyz"),'"xyz"'!==Ha.J(t)&&(e=!1),Ha.X(t)}catch(fa){e=!1}return e||Ms.error("localStorage unsupported; falling back to cookie store"),Ba=e,e},V:function(e){Ms.error("localStorage error: "+e)},J:function(e){try{return null==pn?void 0:pn.localStorage.getItem(e)}catch(fa){Ha.V(fa)}return null},K:function(e){try{return JSON.parse(Ha.J(e))||{}}catch(t){}return null},Y:function(e,t){try{null==pn||pn.localStorage.setItem(e,JSON.stringify(t))}catch(fa){Ha.V(fa)}},X:function(e){try{null==pn||pn.localStorage.removeItem(e)}catch(fa){Ha.V(fa)}}},$a=["distinct_id",fi,gi,Di,Mi],Va=Sn({},Ha,{K:function(e){try{var t={};try{t=za.K(e)||{}}catch(s){}var n=Bs(t,JSON.parse(Ha.J(e)||"{}"));return Ha.Y(e,n),n}catch(s){}return null},Y:function(e,t,n,s,i,a){try{Ha.Y(e,t,void 0,void 0,a);var r={};$a.forEach(e=>{t[e]&&(r[e]=t[e])}),Object.keys(r).length&&za.Y(e,r,n,s,i,a)}catch(o){Ha.V(o)}},X:function(e,t){try{null==pn||pn.localStorage.removeItem(e),za.X(e,t)}catch(fa){Ha.V(fa)}}}),Ua={},Wa={G:function(){return!0},V:function(e){Ms.error("memoryStorage error: "+e)},J:function(e){return Ua[e]||null},K:function(e){return Ua[e]||null},Y:function(e,t){Ua[e]=t},X:function(e){delete Ua[e]}},qa=null,Ga={G:function(){if(!Wn(qa))return qa;if(qa=!0,$n(pn))qa=!1;else try{var e="__support__";Ga.Y(e,"xyz"),'"xyz"'!==Ga.J(e)&&(qa=!1),Ga.X(e)}catch(fa){qa=!1}return qa},V:function(e){Ms.error("sessionStorage error: ",e)},J:function(e){try{return null==pn?void 0:pn.sessionStorage.getItem(e)}catch(fa){Ga.V(fa)}return null},K:function(e){try{return JSON.parse(Ga.J(e))||null}catch(t){}return null},Y:function(e,t){try{null==pn||pn.sessionStorage.setItem(e,JSON.stringify(t))}catch(fa){Ga.V(fa)}},X:function(e){try{null==pn||pn.sessionStorage.removeItem(e)}catch(fa){Ga.V(fa)}}},Za=function(e){return e[e.PENDING=-1]="PENDING",e[e.DENIED=0]="DENIED",e[e.GRANTED=1]="GRANTED",e}({});let Ya=class{constructor(e){this._instance=e}get A(){return this._instance.config}get consent(){return this.Z()?Za.DENIED:this.tt}isOptedOut(){return"always"===this.A.cookieless_mode||this.consent===Za.DENIED||this.consent===Za.PENDING&&(this.A.opt_out_capturing_by_default||"on_reject"===this.A.cookieless_mode)}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===Za.DENIED}optInOut(e){this.it.Y(this.et,e?1:0,this.A.cookie_expiration,this.A.cross_subdomain_cookie,this.A.secure_cookie)}reset(){this.it.X(this.et,this.A.cross_subdomain_cookie)}get et(){var{token:e,opt_out_capturing_cookie_prefix:t,consent_persistence_name:n}=this._instance.config;return n||(t?t+e:"__ph_opt_in_out_"+e)}get tt(){var e=this.it.J(this.et);return es(e)?Za.GRANTED:An(ts,e)?Za.DENIED:Za.PENDING}get it(){if(!this.rt){var e=this.A.opt_out_capturing_persistence_type;this.rt="localStorage"===e?Ha:za;var t="localStorage"===e?za:Ha;t.J(this.et)&&(this.rt.J(this.et)||this.optInOut(es(t.J(this.et))),t.X(this.et,this.A.cross_subdomain_cookie))}return this.rt}Z(){return!!this.A.respect_dnt&&!!Zs([null==gn?void 0:gn.doNotTrack,null==gn?void 0:gn.msDoNotTrack,Nn.doNotTrack],e=>es(e))}};var Ka=Ds("[Dead Clicks]"),Ja=()=>!0,Qa=e=>{var t,n=!(null==(t=e.instance.persistence)||!t.get_property(ai)),s=e.instance.config.capture_dead_clicks;return Zn(s)?s:n};let Xa=class{get lazyLoadedDeadClicksAutocapture(){return this.st}constructor(e,t,n){this.instance=e,this.isEnabled=t,this.onCapture=n,this.startIfEnabled()}onRemoteConfig(e){this.instance.persistence&&this.instance.persistence.register({[ai]:null==e?void 0:e.captureDeadClicks}),this.startIfEnabled()}startIfEnabled(){this.isEnabled(this)&&this.nt(()=>{this.ot()})}nt(e){var t,n;null!=(t=Nn.__PosthogExtensions__)&&t.initDeadClicksAutocapture&&e(),null==(n=Nn.__PosthogExtensions__)||null==n.loadExternalDependency||n.loadExternalDependency(this.instance,"dead-clicks-autocapture",t=>{t?Ka.error("failed to load script",t):e()})}ot(){var e;if(vn){if(!this.st&&null!=(e=Nn.__PosthogExtensions__)&&e.initDeadClicksAutocapture){var t=Bn(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};t.__onCapture=this.onCapture,this.st=Nn.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this.st.start(vn),Ka.info("starting...")}}else Ka.error("`document` not found. Cannot start.")}stop(){this.st&&(this.st.stop(),this.st=void 0,Ka.info("stopping..."))}};var er=Ds("[ExceptionAutocapture]");let tr=class{constructor(e){var t,n,s;this.lt=()=>{var e;if(pn&&this.isEnabled&&null!=(e=Nn.__PosthogExtensions__)&&e.errorWrappingFunctions){var t=Nn.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,n=Nn.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,s=Nn.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.ut&&this.A.capture_unhandled_errors&&(this.ut=t(this.captureException.bind(this))),!this.ht&&this.A.capture_unhandled_rejections&&(this.ht=n(this.captureException.bind(this))),!this.dt&&this.A.capture_console_errors&&(this.dt=s(this.captureException.bind(this)))}catch(fa){er.error("failed to start",fa),this.vt()}}},this._instance=e,this.ct=!(null==(t=this._instance.persistence)||!t.props[ti]),this.A=this.ft(),this.gt=new ss({refillRate:null!==(n=this._instance.config.error_tracking.__exceptionRateLimiterRefillRate)&&void 0!==n?n:1,bucketSize:null!==(s=this._instance.config.error_tracking.__exceptionRateLimiterBucketSize)&&void 0!==s?s:10,refillInterval:1e4,R:er}),this.startIfEnabled()}ft(){var e=this._instance.config.capture_exceptions,t={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return Bn(e)?t=Sn({},t,e):($n(e)?this.ct:e)&&(t=Sn({},t,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),t}get isEnabled(){return this.A.capture_console_errors||this.A.capture_unhandled_errors||this.A.capture_unhandled_rejections}startIfEnabled(){this.isEnabled&&(er.info("enabled"),this.nt(this.lt))}nt(e){var t,n;null!=(t=Nn.__PosthogExtensions__)&&t.errorWrappingFunctions&&e(),null==(n=Nn.__PosthogExtensions__)||null==n.loadExternalDependency||n.loadExternalDependency(this._instance,"exception-autocapture",t=>{if(t)return er.error("failed to load script",t);e()})}vt(){var e,t,n;null==(e=this.ut)||e.call(this),this.ut=void 0,null==(t=this.ht)||t.call(this),this.ht=void 0,null==(n=this.dt)||n.call(this),this.dt=void 0}onRemoteConfig(e){var t=e.autocaptureExceptions;this.ct=!!t||!1,this.A=this.ft(),this._instance.persistence&&this._instance.persistence.register({[ti]:this.ct}),this.startIfEnabled()}captureException(e){var t,n,s=null!==(t=null==e||null==(n=e.$exception_list)||null==(n=n[0])?void 0:n.type)&&void 0!==t?t:"Exception";this.gt.consumeRateLimit(s)?er.info("Skipping exception capture because of client rate limiting.",{exception:s}):this._instance.exceptions.sendExceptionEvent(e)}};function nr(e,t,n){try{if(!(t in e))return()=>{};var s=e[t],i=n(s);return zn(i)&&(i.prototype=i.prototype||{},Object.defineProperties(i,{__posthog_wrapped__:{enumerable:!1,value:!0}})),e[t]=i,()=>{e[t]=s}}catch(a){return()=>{}}}let sr=class{constructor(e){var t;this._instance=e,this._t=(null==pn||null==(t=pn.location)?void 0:t.pathname)||""}get isEnabled(){return"history_change"===this._instance.config.capture_pageview}startIfEnabled(){this.isEnabled&&(Ms.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this.yt&&this.yt(),this.yt=void 0,Ms.info("History API monitoring stopped")}monitorHistoryChanges(){var e,t;if(pn&&pn.history){var n=this;null!=(e=pn.history.pushState)&&e.__posthog_wrapped__||nr(pn.history,"pushState",e=>function(t,s,i){e.call(this,t,s,i),n.bt("pushState")}),null!=(t=pn.history.replaceState)&&t.__posthog_wrapped__||nr(pn.history,"replaceState",e=>function(t,s,i){e.call(this,t,s,i),n.bt("replaceState")}),this.wt()}}bt(e){try{var t,n=null==pn||null==(t=pn.location)?void 0:t.pathname;if(!n)return;n!==this._t&&this.isEnabled&&this._instance.capture("$pageview",{navigation_type:e}),this._t=n}catch(fa){Ms.error("Error capturing "+e+" pageview",fa)}}wt(){if(!this.yt){var e=()=>{this.bt("popstate")};Ys(pn,"popstate",e),this.yt=()=>{pn&&pn.removeEventListener("popstate",e)}}}};function ir(e){var t,n;return(null==(t=JSON.stringify(e,(n=[],function(e,t){if(Bn(t)){for(;n.length>0&&n[n.length-1]!==this;)n.pop();return n.includes(t)?"[Circular]":(n.push(t),t)}return t})))?void 0:t.length)||0}function ar(e,t){if(void 0===t&&(t=6606028.8),e.size>=t&&e.data.length>1){var n=Math.floor(e.data.length/2),s=e.data.slice(0,n),i=e.data.slice(n);return[ar({size:ir(s),data:s,sessionId:e.sessionId,windowId:e.windowId}),ar({size:ir(i),data:i,sessionId:e.sessionId,windowId:e.windowId})].flatMap(e=>e)}return[e]}var rr=(e=>(e[e.DomContentLoaded=0]="DomContentLoaded",e[e.Load=1]="Load",e[e.FullSnapshot=2]="FullSnapshot",e[e.IncrementalSnapshot=3]="IncrementalSnapshot",e[e.Meta=4]="Meta",e[e.Custom=5]="Custom",e[e.Plugin=6]="Plugin",e))(rr||{}),or=(e=>(e[e.Mutation=0]="Mutation",e[e.MouseMove=1]="MouseMove",e[e.MouseInteraction=2]="MouseInteraction",e[e.Scroll=3]="Scroll",e[e.ViewportResize=4]="ViewportResize",e[e.Input=5]="Input",e[e.TouchMove=6]="TouchMove",e[e.MediaInteraction=7]="MediaInteraction",e[e.StyleSheetRule=8]="StyleSheetRule",e[e.CanvasMutation=9]="CanvasMutation",e[e.Font=10]="Font",e[e.Log=11]="Log",e[e.Drag=12]="Drag",e[e.StyleDeclaration=13]="StyleDeclaration",e[e.Selection=14]="Selection",e[e.AdoptedStyleSheet=15]="AdoptedStyleSheet",e[e.CustomElement=16]="CustomElement",e))(or||{}),lr="[SessionRecording]",cr="redacted",dr={initiatorTypes:["audio","beacon","body","css","early-hint","embed","fetch","frame","iframe","icon","image","img","input","link","navigation","object","ping","script","track","video","xmlhttprequest"],maskRequestFn:e=>e,recordHeaders:!1,recordBody:!1,recordInitialRequests:!1,recordPerformance:!1,performanceEntryTypeToObserve:["first-input","navigation","paint","resource"],payloadSizeLimitBytes:1e6,payloadHostDenyList:[".lr-ingest.io",".ingest.sentry.io",".clarity.ms","analytics.google.com","bam.nr-data.net"]},ur=["authorization","x-forwarded-for","authorization","cookie","set-cookie","x-api-key","x-real-ip","remote-addr","forwarded","proxy-authorization","x-csrf-token","x-csrftoken","x-xsrf-token"],pr=["password","secret","passwd","api_key","apikey","auth","credentials","mysql_pwd","privatekey","private_key","token"],mr=["/s/","/e/","/i/"];function hr(e,t,n,s){if(qn(e))return e;var i=(null==t?void 0:t["content-length"])||new Blob([e]).size;return Vn(i)&&(i=parseInt(i)),i>n?lr+" "+s+" body too large to record ("+i+" bytes)":e}function xr(e,t){if(qn(e))return e;var n=e;return ca(n,!1)||(n=lr+" "+t+" body "+cr),zs(pr,e=>{var s,i;null!=(s=n)&&s.length&&-1!==(null==(i=n)?void 0:i.indexOf(e))&&(n=lr+" "+t+" body "+cr+" as might contain: "+e)}),n}let fr=class{constructor(e,t){var n,s;void 0===t&&(t={}),this.St={},this.kt=e=>{if(!this.St[e]){var t,n;this.St[e]=!0;var s=this.$t(e);null==(t=(n=this.t).onBlockedNode)||t.call(n,e,s)}},this.xt=e=>{var t=this.$t(e);if("svg"!==(null==t?void 0:t.nodeName)&&t instanceof Element){var n=t.closest("svg");if(n)return[this._rrweb.mirror.getId(n),n]}return[e,t]},this.$t=e=>this._rrweb.mirror.getNode(e),this.Et=e=>{var t,n,s,i,a,r,o,l;return(null!==(t=null==(n=e.removes)?void 0:n.length)&&void 0!==t?t:0)+(null!==(s=null==(i=e.attributes)?void 0:i.length)&&void 0!==s?s:0)+(null!==(a=null==(r=e.texts)?void 0:r.length)&&void 0!==a?a:0)+(null!==(o=null==(l=e.adds)?void 0:l.length)&&void 0!==o?o:0)},this.throttleMutations=e=>{if(3!==e.type||0!==e.data.source)return e;var t=e.data,n=this.Et(t);t.attributes&&(t.attributes=t.attributes.filter(e=>{var[t]=this.xt(e.id);return!this.gt.consumeRateLimit(t)&&e}));var s=this.Et(t);return 0!==s||n===s?e:void 0},this._rrweb=e,this.t=t,this.gt=new ss({bucketSize:null!==(n=this.t.bucketSize)&&void 0!==n?n:100,refillRate:null!==(s=this.t.refillRate)&&void 0!==s?s:10,refillInterval:1e3,$:this.kt,R:Ms})}};var gr=Uint8Array,vr=Uint16Array,br=Uint32Array,yr=new gr([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),wr=new gr([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),jr=new gr([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Cr=function(e,t){for(var n=new vr(31),s=0;s<31;++s)n[s]=t+=1<>>1|(21845&Er)<<1;Ir=(61680&(Ir=(52428&Ir)>>>2|(13107&Ir)<<2))>>>4|(3855&Ir)<<4,Sr[Er]=((65280&Ir)>>>8|(255&Ir)<<8)>>>1}var Ar=function(e,t,n){for(var s=e.length,i=0,a=new vr(t);i>>15-e[i];return r},Tr=new gr(288);for(Er=0;Er<144;++Er)Tr[Er]=8;for(Er=144;Er<256;++Er)Tr[Er]=9;for(Er=256;Er<280;++Er)Tr[Er]=7;for(Er=280;Er<288;++Er)Tr[Er]=8;var Mr=new gr(32);for(Er=0;Er<32;++Er)Mr[Er]=5;var Dr=Ar(Tr,9),Lr=Ar(Mr,5),Pr=function(e){return(e/8|0)+(7&e&&1)},Rr=function(e,t,n){(null==n||n>e.length)&&(n=e.length);var s=new(e instanceof vr?vr:e instanceof br?br:gr)(n-t);return s.set(e.subarray(t,n)),s},Or=function(e,t,n){n<<=7&t;var s=t/8|0;e[s]|=n,e[s+1]|=n>>>8},zr=function(e,t,n){n<<=7&t;var s=t/8|0;e[s]|=n,e[s+1]|=n>>>8,e[s+2]|=n>>>16},Br=function(e,t){for(var n=[],s=0;sp&&(p=a[s].s);var m=new vr(p+1),h=Hr(n[d-1],m,0);if(h>t){s=0;var x=0,f=h-t,g=1<t))break;x+=g-(1<>>=f;x>0;){var b=a[s].s;m[b]=0&&x;--s){var y=a[s].s;m[y]==t&&(--m[y],++x)}h=t}return[new gr(m),h]},Hr=function(e,t,n){return-1==e.s?Math.max(Hr(e.l,t,n+1),Hr(e.r,t,n+1)):t[e.s]=n},$r=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new vr(++t),s=0,i=e[0],a=1,r=function(e){n[s++]=e},o=1;o<=t;++o)if(e[o]==i&&o!=t)++a;else{if(!i&&a>2){for(;a>138;a-=138)r(32754);a>2&&(r(a>10?a-11<<5|28690:a-3<<5|12305),a=0)}else if(a>3){for(r(i),--a;a>6;a-=6)r(8304);a>2&&(r(a-3<<5|8208),a=0)}for(;a--;)r(i);a=1,i=e[o]}return[n.subarray(0,s),t]},Vr=function(e,t){for(var n=0,s=0;s>>8,e[i+2]=255^e[i],e[i+3]=255^e[i+1];for(var a=0;a4&&!_[jr[S-1]];--S);var E,I,A,T,M=c+5<<3,D=Vr(i,Tr)+Vr(a,Mr)+r,L=Vr(i,p)+Vr(a,x)+r+14+3*S+Vr(C,_)+(2*C[16]+3*C[17]+7*C[18]);if(M<=D&&M<=L)return Ur(t,d,e.subarray(l,l+c));if(Or(t,d,1+(L15&&(Or(t,d,z[N]>>>5&127),d+=z[N]>>>12)}}}else E=Dr,I=Tr,A=Lr,T=Mr;for(N=0;N255){B=s[N]>>>18&31,zr(t,d,E[B+257]),d+=I[B+257],B>7&&(Or(t,d,s[N]>>>23&31),d+=yr[B]);var H=31&s[N];zr(t,d,A[H]),d+=T[H],H>3&&(zr(t,d,s[N]>>>5&8191),d+=wr[H])}else zr(t,d,E[s[N]]),d+=I[s[N]];return zr(t,d,E[256]),d+I[256]},qr=new br([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Gr=function(){for(var e=new br(256),t=0;t<256;++t){for(var n=t,s=9;--s;)n=(1&n&&3988292384)^n>>>1;e[t]=n}return e}(),Zr=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8};function Yr(e,t){void 0===t&&(t={});var n=function(){var e=4294967295;return{p:function(t){for(var n=e,s=0;s>>8;e=n},d:function(){return 4294967295^e}}}(),s=e.length;n.p(e);var i=function(e,t,n,s){return function(e,t,n,s,i){var a=e.length,r=new gr(s+a+5*(1+Math.floor(a/7e3))+i),o=r.subarray(s,r.length-i),l=0;if(!t||a<8)for(var c=0;c<=a;c+=65535){var d=c+65535;d>>13,m=8191&u,h=(1<7e3||F>24576)&&A>423){l=Wr(e,o,0,y,w,j,N,F,k,c-k,l),F=C=N=0,k=c;for(var T=0;T<286;++T)w[T]=0;for(T=0;T<30;++T)j[T]=0}var M=2,D=0,L=m,P=E-I&32767;if(A>2&&S==b(c-P))for(var R=Math.min(p,A)-1,O=Math.min(32767,c),z=Math.min(258,A);P<=O&&--L&&E!=I;){if(e[c+M]==e[c+M-P]){for(var B=0;BM){if(M=B,D=P,B>R)break;var H=Math.min(P,B-2),$=0;for(T=0;T$&&($=U,I=V)}}}P+=(E=I)-(I=x[E])+32768&32767}if(D){y[F++]=268435456|_r[M]<<18|kr[D];var W=31&_r[M],q=31&kr[D];N+=yr[W]+wr[q],++w[257+W],++j[q],_=c+M,++C}else y[F++]=e[c],++w[e[c]]}}l=Wr(e,o,!0,y,w,j,N,F,k,c-k,l)}return Rr(r,0,s+Pr(l)+i)}(e,null==t.level?6:t.level,null==t.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):12+t.mem,n,s)}(e,t,function(e){return 10+(e.filename&&e.filename.length+1||0)}(t),8),a=i.length;return function(e,t){var n=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=t.level<2?4:9==t.level?2:0,e[9]=3,0!=t.mtime&&Zr(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),n){e[3]=8;for(var s=0;s<=n.length;++s)e[s+10]=n.charCodeAt(s)}}(i,t),Zr(i,a-8,n.d()),Zr(i,a-4,s),i}function Kr(e,t){var n=e.length;if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var s=new gr(e.length+(e.length>>>1)),i=0,a=function(e){s[i++]=e},r=0;rs.length){var o=new gr(i+8+(n-r<<1));o.set(s),s=o}var l=e.charCodeAt(r);l<128||t?a(l):l<2048?(a(192|l>>>6),a(128|63&l)):l>55295&&l<57344?(a(240|(l=65536+(1047552&l)|1023&e.charCodeAt(++r))>>>18),a(128|l>>>12&63),a(128|l>>>6&63),a(128|63&l)):(a(224|l>>>12),a(128|l>>>6&63),a(128|63&l))}return Rr(s,0,i)}var Jr="disabled",Qr="sampled",Xr="active",eo="buffering",to="paused",no="trigger",so=no+"_activated",io=no+"_pending",ao=no+"_"+Jr;function ro(e,t){return t.some(t=>"regex"===t.matching&&new RegExp(t.url).test(e))}class oo{constructor(e){this.Rt=e}triggerStatus(e){var t=this.Rt.map(t=>t.triggerStatus(e));return t.includes(so)?so:t.includes(io)?io:ao}stop(){this.Rt.forEach(e=>e.stop())}}class lo{constructor(e){this.Rt=e}triggerStatus(e){var t=new Set;for(var n of this.Rt)t.add(n.triggerStatus(e));switch(t.delete(ao),t.size){case 0:return ao;case 1:return Array.from(t)[0];default:return io}}stop(){this.Rt.forEach(e=>e.stop())}}class co{triggerStatus(){return io}stop(){}}var uo=e=>"sessionRecording"in e;class po{constructor(e){this.It=[],this.Pt=[],this.urlBlocked=!1,this._instance=e}onConfig(e){var t,n;this.It=(uo(e)?null==(t=e.sessionRecording)?void 0:t.urlTriggers:null==e?void 0:e.urlTriggers)||[],this.Pt=(uo(e)?null==(n=e.sessionRecording)?void 0:n.urlBlocklist:null==e?void 0:e.urlBlocklist)||[]}onRemoteConfig(e){this.onConfig(e)}Tt(e){var t;return 0===this.It.length?ao:(null==(t=this._instance)?void 0:t.get_property(vi))===e?so:io}triggerStatus(e){var t=this.Tt(e),n=t===so?so:t===io?io:ao;return this._instance.register_for_session({$sdk_debug_replay_url_trigger_status:n}),n}checkUrlTriggerConditions(e,t,n){if(void 0!==pn&&pn.location.href){var s=pn.location.href,i=this.urlBlocked,a=ro(s,this.Pt);i&&a||(a&&!i?e():!a&&i&&t(),ro(s,this.It)&&n("url"))}}stop(){}}class mo{constructor(e){this.linkedFlag=null,this.linkedFlagSeen=!1,this.Ct=()=>{},this._instance=e}triggerStatus(){var e=io;return qn(this.linkedFlag)&&(e=ao),this.linkedFlagSeen&&(e=so),this._instance.register_for_session({$sdk_debug_replay_linked_flag_trigger_status:e}),e}onConfig(e,t){var n;if(this.linkedFlag=(uo(e)?null==(n=e.sessionRecording)?void 0:n.linkedFlag:null==e?void 0:e.linkedFlag)||null,!qn(this.linkedFlag)&&!this.linkedFlagSeen){var s=Vn(this.linkedFlag)?this.linkedFlag:this.linkedFlag.flag,i=Vn(this.linkedFlag)?null:this.linkedFlag.variant;this.Ct=this._instance.onFeatureFlags((e,n)=>{var a=!1;if(Bn(n)&&s in n){var r=n[s];a=Zn(r)?!0===r:i?r===i:!!r}this.linkedFlagSeen=a,a&&t(s,i)})}}onRemoteConfig(e,t){this.onConfig(e,t)}stop(){this.Ct()}}class ho{constructor(e){this.Mt=[],this._instance=e}onConfig(e){var t;this.Mt=(uo(e)?null==(t=e.sessionRecording)?void 0:t.eventTriggers:null==e?void 0:e.eventTriggers)||[]}onRemoteConfig(e){this.onConfig(e)}Ot(e){var t;return 0===this.Mt.length?ao:(null==(t=this._instance)?void 0:t.get_property(bi))===e?so:io}triggerStatus(e){var t=this.Ot(e),n=t===so?so:t===io?io:ao;return this._instance.register_for_session({$sdk_debug_replay_event_trigger_status:n}),n}stop(){}}function xo(e){return e.isRecordingEnabled?eo:Jr}function fo(e){if(!e.receivedFlags)return eo;if(!e.isRecordingEnabled)return Jr;if(e.urlTriggerMatching.urlBlocked)return to;var t=!0===e.isSampled,n=new oo([e.eventTriggerMatching,e.urlTriggerMatching,e.linkedFlagMatching]).triggerStatus(e.sessionId);return t?Qr:n===so?Xr:n===io?eo:!1===e.isSampled?Jr:Xr}function go(e){if(!e.receivedFlags)return eo;if(!e.isRecordingEnabled)return Jr;if(e.urlTriggerMatching.urlBlocked)return to;var t=new lo([e.eventTriggerMatching,e.urlTriggerMatching,e.linkedFlagMatching]).triggerStatus(e.sessionId),n=t!==ao,s=Zn(e.isSampled);return n&&t===io?eo:n&&t===ao||s&&!e.isSampled?Jr:!0===e.isSampled?Qr:Xr}var vo="[SessionRecording]",bo=Ds(vo);function yo(){var e;return null==Nn||null==(e=Nn.__PosthogExtensions__)||null==(e=e.rrweb)?void 0:e.record}var wo=[or.MouseMove,or.MouseInteraction,or.Scroll,or.ViewportResize,or.Input,or.TouchMove,or.MediaInteraction,or.Drag],jo=e=>({rrwebMethod:e,enqueuedAt:Date.now(),attempt:1});function Co(e){return function(e){for(var t="",n=0;n{this.ui()},this.hi=()=>{this.tryAddCustomEvent("browser offline",{})},this.di=()=>{this.tryAddCustomEvent("browser online",{})},this.vi=()=>{if(null!=vn&&vn.visibilityState){var e="window "+vn.visibilityState;this.tryAddCustomEvent(e,{})}},this._instance=e,this.Dt=!1,this.ci="/s/",this.fi=void 0,this.Kt=!1,!this._instance.sessionManager)throw bo.error("started without valid sessionManager"),new Error(vo+" started without valid sessionManager. This is a bug.");if("always"===this._instance.config.cookieless_mode)throw new Error(vo+' cannot be used with cookieless_mode="always"');this.Zt=new mo(this._instance),this.Xt=new po(this._instance),this.Qt=new ho(this._instance);var{sessionId:t,windowId:n}=this.jt.checkAndGetSessionAndWindowId();this.Ft=t,this.pi=n,this.H=this.gi(),this.At>=this.jt.sessionTimeoutMs&&bo.warn("session_idle_threshold_ms ("+this.At+") is greater than the session timeout ("+this.jt.sessionTimeoutMs+"). Session will never be detected as idle")}startIfEnabledOrStop(e){this.Bt?(this.mi(e),Ys(pn,"beforeunload",this.li),Ys(pn,"offline",this.hi),Ys(pn,"online",this.di),Ys(pn,"visibilitychange",this.vi),this.yi(),this.bi(),qn(this.ri)&&(this.ri=this._instance.on("eventCaptured",e=>{try{if("$pageview"===e.event){var t=null!=e&&e.properties.$current_url?this.wi(null==e?void 0:e.properties.$current_url):"";if(!t)return;this.tryAddCustomEvent("$pageview",{href:t})}}catch(n){bo.error("Could not add $pageview to rrweb session",n)}})),this.si||(this.si=this.jt.onSessionId((e,t,n)=>{var s,i;n&&(this.tryAddCustomEvent("$session_id_change",{sessionId:e,windowId:t,changeReason:n}),null==(s=this._instance)||null==(s=s.persistence)||s.unregister(bi),null==(i=this._instance)||null==(i=i.persistence)||i.unregister(vi))}))):this.stopRecording()}stopRecording(){var e,t,n,s;this.Dt&&this.fi&&(this.fi(),this.fi=void 0,this.Dt=!1,null==pn||pn.removeEventListener("beforeunload",this.li),null==pn||pn.removeEventListener("offline",this.hi),null==pn||pn.removeEventListener("online",this.di),null==pn||pn.removeEventListener("visibilitychange",this.vi),this.gi(),clearInterval(this.Si),null==(e=this.ri)||e.call(this),this.ri=void 0,null==(t=this.ai)||t.call(this),this.ai=void 0,null==(n=this.si)||n.call(this),this.si=void 0,null==(s=this.oi)||s.call(this),this.oi=void 0,this.Qt.stop(),this.Xt.stop(),this.Zt.stop(),bo.info("stopped"))}ki(){var e;null==(e=this._instance.persistence)||e.unregister(gi)}$i(e){var t,n=this.Ft!==e,s=this.Vt;if(Gn(s)){var i=this.Ut,a=n||!Zn(i),r=a?function(e,t){return function(e){for(var t=0,n=0;n{this.xi("linked_flag_matched",{flag:e,variant:t})}),this.Kt=!0,this.startIfEnabledOrStop()}yi(){Gn(this.Vt)&&qn(this.oi)&&(this.oi=this.jt.onSessionId(e=>{this.$i(e)}))}Ei(e){if(this._instance.persistence){var t,n=this._instance.persistence,s=()=>{var t,s,i,a,r,o,l,c,d,u=null==(t=e.sessionRecording)?void 0:t.sampleRate,p=qn(u)?null:parseFloat(u);qn(p)&&this.ki();var m=null==(s=e.sessionRecording)?void 0:s.minimumDurationMilliseconds;n.register({[li]:!!e.sessionRecording,[ci]:null==(i=e.sessionRecording)?void 0:i.consoleLogRecordingEnabled,[di]:Sn({capturePerformance:e.capturePerformance},null==(a=e.sessionRecording)?void 0:a.networkPayloadCapture),[ui]:null==(r=e.sessionRecording)?void 0:r.masking,[pi]:{enabled:null==(o=e.sessionRecording)?void 0:o.recordCanvas,fps:null==(l=e.sessionRecording)?void 0:l.canvasFps,quality:null==(c=e.sessionRecording)?void 0:c.canvasQuality},[mi]:p,[hi]:$n(m)?null:m,[xi]:null==(d=e.sessionRecording)?void 0:d.scriptConfig})};s(),null==(t=this.ni)||t.call(this),this.ni=this.jt.onSessionId(s)}}log(e,t){var n;void 0===t&&(t="log"),null==(n=this._instance.sessionRecording)||n.onRRwebEmit({type:6,data:{plugin:"rrweb/console@1",payload:{level:t,trace:[],payload:[JSON.stringify(e)]}},timestamp:Date.now()})}mi(e){var t;$n(Object.assign)||$n(Array.from)||(this.Dt||this._instance.config.disable_session_recording||this._instance.consent.isOptedOut())||(this.Dt=!0,this.jt.checkAndGetSessionAndWindowId(),yo()?this.Ri():null==(t=Nn.__PosthogExtensions__)||null==t.loadExternalDependency||t.loadExternalDependency(this._instance,this.Ii,e=>{if(e)return bo.error("could not load recorder",e);this.Ri()}),bo.info("starting"),this.status===Xr&&this.xi(e||"recording_initialized"))}get Ii(){var e;return(null==(e=this._instance)||null==(e=e.persistence)||null==(e=e.get_property(xi))?void 0:e.script)||"recorder"}Pi(e){var t;return 3===e.type&&-1!==wo.indexOf(null==(t=e.data)?void 0:t.source)}Ti(e){var t=this.Pi(e);t||this.ii||e.timestamp-this.ei>this.At&&(this.ii=!0,clearInterval(this.Si),this.tryAddCustomEvent("sessionIdle",{eventTimestamp:e.timestamp,lastActivityTimestamp:this.ei,threshold:this.At,bufferLength:this.H.data.length,bufferSize:this.H.size}),this.ui());var n=!1;if(t&&(this.ei=e.timestamp,this.ii)){var s="unknown"===this.ii;this.ii=!1,s||(this.tryAddCustomEvent("sessionNoLongerIdle",{reason:"user activity",type:e.type}),n=!0)}if(!this.ii){var{windowId:i,sessionId:a}=this.jt.checkAndGetSessionAndWindowId(!t,e.timestamp),r=this.Ft!==a,o=this.pi!==i;this.pi=i,this.Ft=a,r||o?(this.stopRecording(),this.startIfEnabledOrStop("session_id_changed")):n&&this.Ci()}}Mi(e){try{return e.rrwebMethod(),!0}catch(t){return this.ti.length<10?this.ti.push({enqueuedAt:e.enqueuedAt||Date.now(),attempt:e.attempt++,rrwebMethod:e.rrwebMethod}):bo.warn("could not emit queued rrweb event.",t,e),!1}}tryAddCustomEvent(e,t){return this.Mi(jo(()=>yo().addCustomEvent(e,t)))}Oi(){return this.Mi(jo(()=>yo().takeFullSnapshot()))}Ri(){var e,t,n,s,i={blockClass:"ph-no-capture",blockSelector:void 0,ignoreClass:"ph-ignore-input",maskTextClass:"ph-mask",maskTextSelector:void 0,maskTextFn:void 0,maskAllInputs:!0,maskInputOptions:{password:!0},maskInputFn:void 0,slimDOMOptions:{},collectFonts:!1,inlineStylesheet:!0,recordCrossOriginIframes:!1},a=this._instance.config.session_recording;for(var[r,o]of Object.entries(a||{}))r in i&&("maskInputOptions"===r?i.maskInputOptions=Sn({password:!0},o):i[r]=o);this.Ht&&this.Ht.enabled&&(i.recordCanvas=!0,i.sampling={canvas:this.Ht.fps},i.dataURLOptions={type:"image/webp",quality:this.Ht.quality}),this.Gt&&(i.maskAllInputs=null===(t=this.Gt.maskAllInputs)||void 0===t||t,i.maskTextSelector=null!==(n=this.Gt.maskTextSelector)&&void 0!==n?n:void 0,i.blockSelector=null!==(s=this.Gt.blockSelector)&&void 0!==s?s:void 0);var l=yo();if(l){this.Fi=null!==(e=this.Fi)&&void 0!==e?e:new fr(l,{refillRate:this._instance.config.session_recording.__mutationThrottlerRefillRate,bucketSize:this._instance.config.session_recording.__mutationThrottlerBucketSize,onBlockedNode:(e,t)=>{var n="Too many mutations on node '"+e+"'. Rate limiting. This could be due to SVG animations or something similar";bo.info(n,{node:t}),this.log(vo+" "+n,"warn")}});var c=this.Ai();this.fi=l(Sn({emit:e=>{this.onRRwebEmit(e)},plugins:c},i)),this.ei=Date.now(),this.ii=Zn(this.ii)?this.ii:"unknown",this.tryAddCustomEvent("$session_options",{sessionRecordingOptions:i,activePlugins:c.map(e=>null==e?void 0:e.name)}),this.tryAddCustomEvent("$posthog_config",{config:this._instance.config})}else bo.error("onScriptLoaded was called but rrwebRecord is not available. This indicates something has gone wrong.")}Ci(){if(this.Si&&clearInterval(this.Si),!0!==this.ii){var e=this.Lt;e&&(this.Si=setInterval(()=>{this.Oi()},e))}}Ai(){var e,t,n=[],s=null==(e=Nn.__PosthogExtensions__)||null==(e=e.rrwebPlugins)?void 0:e.getRecordConsolePlugin;s&&this.qt&&n.push(s());var i=null==(t=Nn.__PosthogExtensions__)||null==(t=t.rrwebPlugins)?void 0:t.getRecordNetworkPlugin;return this.Wt&&zn(i)&&(!ba.includes(location.hostname)||this._forceAllowLocalhostNetworkCapture?n.push(i(((e,t)=>{var n,s,i,a={payloadSizeLimitBytes:dr.payloadSizeLimitBytes,performanceEntryTypeToObserve:[...dr.performanceEntryTypeToObserve],payloadHostDenyList:[...t.payloadHostDenyList||[],...dr.payloadHostDenyList]},r=!1!==e.session_recording.recordHeaders&&t.recordHeaders,o=!1!==e.session_recording.recordBody&&t.recordBody,l=!1!==e.capture_performance&&t.recordPerformance,c=(n=a,i=Math.min(1e6,null!==(s=n.payloadSizeLimitBytes)&&void 0!==s?s:1e6),e=>(null!=e&&e.requestBody&&(e.requestBody=hr(e.requestBody,e.requestHeaders,i,"Request")),null!=e&&e.responseBody&&(e.responseBody=hr(e.responseBody,e.responseHeaders,i,"Response")),e)),d=t=>{return c(((e,t)=>{var n,s=ya(e.name),i=0===t.indexOf("http")?null==(n=ya(t))?void 0:n.pathname:t;"/"===i&&(i="");var a=null==s?void 0:s.pathname.replace(i||"","");if(!(s&&a&&mr.some(e=>0===a.indexOf(e))))return e})((s=(n=t).requestHeaders,qn(s)||zs(Object.keys(null!=s?s:{}),e=>{ur.includes(e.toLowerCase())&&(s[e]=cr)}),n),e.api_host));var n,s},u=zn(e.session_recording.maskNetworkRequestFn);return u&&zn(e.session_recording.maskCapturedNetworkRequestFn)&&Ms.warn("Both `maskNetworkRequestFn` and `maskCapturedNetworkRequestFn` are defined. `maskNetworkRequestFn` will be ignored."),u&&(e.session_recording.maskCapturedNetworkRequestFn=t=>{var n=e.session_recording.maskNetworkRequestFn({url:t.name});return Sn({},t,{name:null==n?void 0:n.url})}),a.maskRequestFn=zn(e.session_recording.maskCapturedNetworkRequestFn)?t=>{var n,s=d(t);return s&&null!==(n=null==e.session_recording.maskCapturedNetworkRequestFn?void 0:e.session_recording.maskCapturedNetworkRequestFn(s))&&void 0!==n?n:void 0}:e=>function(e){if(!$n(e))return e.requestBody=xr(e.requestBody,"Request"),e.responseBody=xr(e.responseBody,"Response"),e}(d(e)),Sn({},dr,a,{recordHeaders:r,recordBody:o,recordPerformance:l,recordInitialRequests:l})})(this._instance.config,this.Wt))):bo.info("NetworkCapture not started because we are on localhost.")),n}onRRwebEmit(e){var t;if(this.Di(),e&&Bn(e)){if(e.type===rr.Meta){var n=this.wi(e.data.href);if(this.ji=n,!n)return;e.data.href=n}else this.Li();if(this.Xt.checkUrlTriggerConditions(()=>this.Ni(),()=>this.Ui(),e=>this.zi(e)),!this.Xt.urlBlocked||(s=e).type===rr.Custom&&"recording paused"===s.data.tag){var s;e.type===rr.FullSnapshot&&this.Ci(),e.type===rr.FullSnapshot&&this.Kt&&this.Nt.triggerStatus(this.sessionId)===io&&this.Bi();var i=this.Fi?this.Fi.throttleMutations(e):e;if(i){var a=function(e){var t=e;if(t&&Bn(t)&&6===t.type&&Bn(t.data)&&"rrweb/console@1"===t.data.plugin){t.data.payload.payload.length>10&&(t.data.payload.payload=t.data.payload.payload.slice(0,10),t.data.payload.payload.push("...[truncated]"));for(var n=[],s=0;s2e3?n.push(t.data.payload.payload[s].slice(0,2e3)+"...[truncated]"):n.push(t.data.payload.payload[s]);return t.data.payload.payload=n,e}return e}(i);if(this.Ti(a),!0!==this.ii||No(a)){if(No(a)){var r=a.data.payload;if(r){var o=r.lastActivityTimestamp,l=r.threshold;a.timestamp=o+l}}var c=null===(t=this._instance.config.session_recording.compress_events)||void 0===t||t?function(e){try{if(e.type===rr.FullSnapshot)return Sn({},e,{data:Co(e.data),cv:"2024-10"});if(e.type===rr.IncrementalSnapshot&&e.data.source===or.Mutation)return Sn({},e,{cv:"2024-10",data:Sn({},e.data,{texts:Co(e.data.texts),attributes:Co(e.data.attributes),removes:Co(e.data.removes),adds:Co(e.data.adds)})});if(e.type===rr.IncrementalSnapshot&&e.data.source===or.StyleSheetRule)return Sn({},e,{cv:"2024-10",data:Sn({},e.data,{adds:e.data.adds?Co(e.data.adds):void 0,removes:e.data.removes?Co(e.data.removes):void 0})})}catch(t){bo.error("could not compress event - will use uncompressed event",t)}return e}(a):a,d={$snapshot_bytes:ir(c),$snapshot_data:c,$session_id:this.Ft,$window_id:this.pi};this.status!==Jr?this.qi(d):this.gi()}}}}}Li(){if(!this._instance.config.capture_pageview&&pn){var e=this.wi(pn.location.href);this.ji!==e&&(this.tryAddCustomEvent("$url_changed",{href:e}),this.ji=e)}}Di(){if(this.ti.length){var e=[...this.ti];this.ti=[],e.forEach(e=>{Date.now()-e.enqueuedAt<=2e3&&this.Mi(e)})}}wi(e){var t=this._instance.config.session_recording;if(t.maskNetworkRequestFn){var n,s={url:e};return null==(n=s=t.maskNetworkRequestFn(s))?void 0:n.url}return e}Bi(){if(!this.H||0===this.H.data.length)return this.gi();for(var e=-1,t=this.H.data.length-1;t>=0;t--)if(this.H.data[t].type===rr.Meta){e=t;break}return e>=0?(this.H.data=this.H.data.slice(e),this.H.size=this.H.data.reduce((e,t)=>e+ir(t),0),this.H):this.gi()}gi(){return this.H={size:0,data:[],sessionId:this.Ft,windowId:this.pi},this.H}ui(){this.Hi&&(clearTimeout(this.Hi),this.Hi=void 0);var e=this.Jt,t=this.zt,n=Gn(t)&&t>=0,s=Gn(e)&&n&&t{this.ui()},2e3),this.H):(this.H.data.length>0&&ar(this.H).forEach(e=>{this.Wi({$snapshot_bytes:e.size,$snapshot_data:e.data,$session_id:e.sessionId,$window_id:e.windowId,$lib:"web",$lib_version:Fn.LIB_VERSION})}),this.gi())}qi(e){var t,n=2+((null==(t=this.H)?void 0:t.data.length)||0);!this.ii&&(this.H.size+e.$snapshot_bytes+n>943718.4||this.H.sessionId!==this.Ft)&&(this.H=this.ui()),this.H.size+=e.$snapshot_bytes,this.H.data.push(e.$snapshot_data),this.Hi||this.ii||(this.Hi=setTimeout(()=>{this.ui()},2e3))}Wi(e){this._instance.capture("$snapshot",e,{_url:this._instance.requestRouter.endpointFor("api",this.ci),_noTruncate:!0,_batchKey:"recordings",skip_client_rate_limiting:!0})}zi(e){var t;this.Nt.triggerStatus(this.sessionId)===io&&(null==(t=this._instance)||null==(t=t.persistence)||t.register({["url"===e?vi:bi]:this.Ft}),this.ui(),this.xi(e+"_trigger_matched"))}Ni(){this.Xt.urlBlocked||(this.Xt.urlBlocked=!0,clearInterval(this.Si),bo.info("recording paused due to URL blocker"),this.tryAddCustomEvent("recording paused",{reason:"url blocker"}))}Ui(){this.Xt.urlBlocked&&(this.Xt.urlBlocked=!1,this.Oi(),this.Ci(),this.tryAddCustomEvent("recording resumed",{reason:"left blocked url"}),bo.info("recording resumed"))}bi(){0!==this.Qt.Mt.length&&qn(this.ai)&&(this.ai=this._instance.on("eventCaptured",e=>{try{this.Qt.Mt.includes(e.event)&&this.zi("event")}catch(t){bo.error("Could not activate event trigger",t)}}))}overrideLinkedFlag(){this.Zt.linkedFlagSeen=!0,this.Oi(),this.xi("linked_flag_overridden")}overrideSampling(){var e;null==(e=this._instance.persistence)||e.register({[gi]:!0}),this.Oi(),this.xi("sampling_overridden")}overrideTrigger(e){this.zi(e)}xi(e,t){this._instance.register_for_session({$session_recording_start_reason:e}),bo.info(e.replace("_"," "),t),An(["recording_initialized","session_id_changed"],e)||this.tryAddCustomEvent(e,t)}get sdkDebugProperties(){var{sessionStartTimestamp:e}=this.jt.checkAndGetSessionAndWindowId(!0);return{$recording_status:this.status,$sdk_debug_replay_internal_buffer_length:this.H.data.length,$sdk_debug_replay_internal_buffer_size:this.H.size,$sdk_debug_current_session_duration:this.zt,$sdk_debug_session_start:e}}}var _o=Ds("[SegmentIntegration]");var ko="posthog-js";function So(e,t){var{organization:n,projectId:s,prefix:i,severityAllowList:a=["error"],sendExceptionsToPostHog:r=!0}=void 0===t?{}:t;return t=>{var o,l,c,d,u;if("*"!==a&&!a.includes(t.level)||!e.__loaded)return t;t.tags||(t.tags={});var p=e.requestRouter.endpointFor("ui","/project/"+e.config.token+"/person/"+e.get_distinct_id());t.tags["PostHog Person URL"]=p,e.sessionRecordingStarted()&&(t.tags["PostHog Recording URL"]=e.get_session_replay_url({withTimestamp:!0}));var m=(null==(o=t.exception)?void 0:o.values)||[],h=m.map(e=>Sn({},e,{stacktrace:e.stacktrace?Sn({},e.stacktrace,{type:"raw",frames:(e.stacktrace.frames||[]).map(e=>Sn({},e,{platform:"web:javascript"}))}):void 0})),x={$exception_message:(null==(l=m[0])?void 0:l.value)||t.message,$exception_type:null==(c=m[0])?void 0:c.type,$exception_personURL:p,$exception_level:t.level,$exception_list:h,$sentry_event_id:t.event_id,$sentry_exception:t.exception,$sentry_exception_message:(null==(d=m[0])?void 0:d.value)||t.message,$sentry_exception_type:null==(u=m[0])?void 0:u.type,$sentry_tags:t.tags};return n&&s&&(x.$sentry_url=(i||"https://sentry.io/organizations/")+n+"/issues/?project="+s+"&query="+t.event_id),r&&e.exceptions.sendExceptionEvent(x),t}}class Eo{constructor(e,t,n,s,i,a){this.name=ko,this.setupOnce=function(r){r(So(e,{organization:t,projectId:n,prefix:s,severityAllowList:i,sendExceptionsToPostHog:null==a||a}))}}}var Io=null!=pn&&pn.location?Ca(pn.location.hash,"__posthog")||Ca(location.hash,"state"):null,Ao="_postHogToolbarParams",To=Ds("[Toolbar]"),Mo=function(e){return e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.LOADING=1]="LOADING",e[e.LOADED=2]="LOADED",e}(Mo||{});class Do{constructor(e){this.instance=e}Gi(e){Nn.ph_toolbar_state=e}Vi(){var e;return null!==(e=Nn.ph_toolbar_state)&&void 0!==e?e:Mo.UNINITIALIZED}maybeLoadToolbar(e,t,n){if(void 0===e&&(e=void 0),void 0===t&&(t=void 0),void 0===n&&(n=void 0),!pn||!vn)return!1;e=null!=e?e:pn.location,n=null!=n?n:pn.history;try{if(!t){try{pn.localStorage.setItem("test","test"),pn.localStorage.removeItem("test")}catch(fa){return!1}t=null==pn?void 0:pn.localStorage}var s,i=Io||Ca(e.hash,"__posthog")||Ca(e.hash,"state"),a=i?Vs(()=>JSON.parse(atob(decodeURIComponent(i))))||Vs(()=>JSON.parse(decodeURIComponent(i))):null;return a&&"ph_authorize"===a.action?((s=a).source="url",s&&Object.keys(s).length>0&&(a.desiredHash?e.hash=a.desiredHash:n?n.replaceState(n.state,"",e.pathname+e.search):e.hash="")):((s=JSON.parse(t.getItem(Ao)||"{}")).source="localstorage",delete s.userIntent),!(!s.token||this.instance.config.token!==s.token||(this.loadToolbar(s),0))}catch(fa){return!1}}Ji(e){var t=Nn.ph_load_toolbar||Nn.ph_load_editor;!qn(t)&&zn(t)?t(e,this.instance):To.warn("No toolbar load function found")}loadToolbar(e){var t=!(null==vn||!vn.getElementById(Li));if(!pn||t)return!1;var n="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,s=Sn({token:this.instance.config.token},e,{apiURL:this.instance.requestRouter.endpointFor("ui")},n?{instrument:!1}:{});if(pn.localStorage.setItem(Ao,JSON.stringify(Sn({},s,{source:void 0}))),this.Vi()===Mo.LOADED)this.Ji(s);else if(this.Vi()===Mo.UNINITIALIZED){var i;this.Gi(Mo.LOADING),null==(i=Nn.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this.instance,"toolbar",e=>{if(e)return To.error("[Toolbar] Failed to load",e),void this.Gi(Mo.UNINITIALIZED);this.Gi(Mo.LOADED),this.Ji(s)}),Ys(pn,"turbolinks:load",()=>{this.Gi(Mo.UNINITIALIZED),this.loadToolbar(s)})}return!0}Ki(e){return this.loadToolbar(e)}maybeLoadEditor(e,t,n){return void 0===e&&(e=void 0),void 0===t&&(t=void 0),void 0===n&&(n=void 0),this.maybeLoadToolbar(e,t,n)}}var Lo=Ds("[TracingHeaders]");class Po{constructor(e){this.Yi=void 0,this.Xi=void 0,this.lt=()=>{var e,t;$n(this.Yi)&&(null==(e=Nn.__PosthogExtensions__)||null==(e=e.tracingHeadersPatchFns)||e._patchXHR(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager)),$n(this.Xi)&&(null==(t=Nn.__PosthogExtensions__)||null==(t=t.tracingHeadersPatchFns)||t._patchFetch(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager))},this._instance=e}nt(e){var t,n;null!=(t=Nn.__PosthogExtensions__)&&t.tracingHeadersPatchFns&&e(),null==(n=Nn.__PosthogExtensions__)||null==n.loadExternalDependency||n.loadExternalDependency(this._instance,"tracing-headers",t=>{if(t)return Lo.error("failed to load script",t);e()})}startIfEnabledOrStop(){var e,t;this._instance.config.__add_tracing_headers?this.nt(this.lt):(null==(e=this.Yi)||e.call(this),null==(t=this.Xi)||t.call(this),this.Yi=void 0,this.Xi=void 0)}}var Ro=Ds("[Web Vitals]"),Oo=9e5;class zo{constructor(e){var t;this.Qi=!1,this.C=!1,this.H={url:void 0,metrics:[],firstMetricTimestamp:void 0},this.Zi=()=>{clearTimeout(this.te),0!==this.H.metrics.length&&(this._instance.capture("$web_vitals",this.H.metrics.reduce((e,t)=>Sn({},e,{["$web_vitals_"+t.name+"_event"]:Sn({},t),["$web_vitals_"+t.name+"_value"]:t.value}),{})),this.H={url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.ie=e=>{var t,n=null==(t=this._instance.sessionManager)?void 0:t.checkAndGetSessionAndWindowId(!0);if($n(n))Ro.error("Could not read session ID. Dropping metrics!");else{this.H=this.H||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var s=this.ee();$n(s)||(qn(null==e?void 0:e.name)||qn(null==e?void 0:e.value)?Ro.error("Invalid metric received",e):this.re&&e.value>=this.re?Ro.error("Ignoring metric with value >= "+this.re,e):(this.H.url!==s&&(this.Zi(),this.te=setTimeout(this.Zi,this.flushToCaptureTimeoutMs)),$n(this.H.url)&&(this.H.url=s),this.H.firstMetricTimestamp=$n(this.H.firstMetricTimestamp)?Date.now():this.H.firstMetricTimestamp,e.attribution&&e.attribution.interactionTargetElement&&(e.attribution.interactionTargetElement=void 0),this.H.metrics.push(Sn({},e,{$current_url:s,$session_id:n.sessionId,$window_id:n.windowId,timestamp:Date.now()})),this.H.metrics.length===this.allowedMetrics.length&&this.Zi()))}},this.lt=()=>{var e,t,n,s,i=Nn.__PosthogExtensions__;$n(i)||$n(i.postHogWebVitalsCallbacks)||({onLCP:e,onCLS:t,onFCP:n,onINP:s}=i.postHogWebVitalsCallbacks),e&&t&&n&&s?(this.allowedMetrics.indexOf("LCP")>-1&&e(this.ie.bind(this)),this.allowedMetrics.indexOf("CLS")>-1&&t(this.ie.bind(this)),this.allowedMetrics.indexOf("FCP")>-1&&n(this.ie.bind(this)),this.allowedMetrics.indexOf("INP")>-1&&s(this.ie.bind(this)),this.C=!0):Ro.error("web vitals callbacks not loaded - not starting")},this._instance=e,this.Qi=!(null==(t=this._instance.persistence)||!t.props[ii]),this.startIfEnabled()}get allowedMetrics(){var e,t,n=Bn(this._instance.config.capture_performance)?null==(e=this._instance.config.capture_performance)?void 0:e.web_vitals_allowed_metrics:void 0;return $n(n)?(null==(t=this._instance.persistence)?void 0:t.props[ri])||["CLS","FCP","INP","LCP"]:n}get flushToCaptureTimeoutMs(){return(Bn(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals_delayed_flush_ms:void 0)||5e3}get re(){var e=Bn(this._instance.config.capture_performance)&&Gn(this._instance.config.capture_performance.__web_vitals_max_value)?this._instance.config.capture_performance.__web_vitals_max_value:Oo;return 0{t?Ro.error("failed to load script",t):e()})}ee(){var e=pn?pn.location.href:void 0;return e||Ro.error("Could not determine current URL"),e}}var Bo=Ds("[Heatmaps]");function Ho(e){return Bn(e)&&"clientX"in e&&"clientY"in e&&Gn(e.clientX)&&Gn(e.clientY)}class $o{constructor(e){var t;this.rageclicks=new xa,this.Qi=!1,this.C=!1,this.se=null,this.instance=e,this.Qi=!(null==(t=this.instance.persistence)||!t.props[ei])}get flushIntervalMilliseconds(){var e=5e3;return Bn(this.instance.config.capture_heatmaps)&&this.instance.config.capture_heatmaps.flush_interval_milliseconds&&(e=this.instance.config.capture_heatmaps.flush_interval_milliseconds),e}get isEnabled(){return $n(this.instance.config.capture_heatmaps)?$n(this.instance.config.enable_heatmaps)?this.Qi:this.instance.config.enable_heatmaps:!1!==this.instance.config.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this.C)return;Bo.info("starting..."),this.ne(),this.se=setInterval(this.oe.bind(this),this.flushIntervalMilliseconds)}else{var e,t;clearInterval(null!==(e=this.se)&&void 0!==e?e:void 0),null==(t=this.ae)||t.stop(),this.getAndClearBuffer()}}onRemoteConfig(e){var t=!!e.heatmaps;this.instance.persistence&&this.instance.persistence.register({[ei]:t}),this.Qi=t,this.startIfEnabled()}getAndClearBuffer(){var e=this.H;return this.H=void 0,e}le(e){this.ue(e.originalEvent,"deadclick")}ne(){pn&&vn&&(Ys(pn,"beforeunload",this.oe.bind(this)),Ys(vn,"click",e=>this.ue(e||(null==pn?void 0:pn.event)),{capture:!0}),Ys(vn,"mousemove",e=>this.he(e||(null==pn?void 0:pn.event)),{capture:!0}),this.ae=new Xa(this.instance,Ja,this.le.bind(this)),this.ae.startIfEnabled(),this.C=!0)}de(e,t){var n=this.instance.scrollManager.scrollY(),s=this.instance.scrollManager.scrollX(),i=this.instance.scrollManager.scrollElement(),a=function(e,t,n){for(var s=e;s&&zi(s)&&!Bi(s,"body");){if(s===n)return!1;if(An(t,null==pn?void 0:pn.getComputedStyle(s).position))return!0;s=Ji(s)}return!1}(Zi(e),["fixed","sticky"],i);return{x:e.clientX+(a?0:s),y:e.clientY+(a?0:n),target_fixed:a,type:t}}ue(e,t){var n;if(void 0===t&&(t="click"),!Oi(e.target)&&Ho(e)){var s=this.de(e,t);null!=(n=this.rageclicks)&&n.isRageClick(e.clientX,e.clientY,(new Date).getTime())&&this.ve(Sn({},s,{type:"rageclick"})),this.ve(s)}}he(e){!Oi(e.target)&&Ho(e)&&(clearTimeout(this.ce),this.ce=setTimeout(()=>{this.ve(this.de(e,"mousemove"))},500))}ve(e){if(pn){var t=pn.location.href;this.H=this.H||{},this.H[t]||(this.H[t]=[]),this.H[t].push(e)}}oe(){this.H&&!Hn(this.H)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}}class Vo{constructor(e){this._instance=e}doPageView(e,t){var n,s=this.fe(e,t);return this.pe={pathname:null!==(n=null==pn?void 0:pn.location.pathname)&&void 0!==n?n:"",pageViewId:t,timestamp:e},this._instance.scrollManager.resetContext(),s}doPageLeave(e){var t;return this.fe(e,null==(t=this.pe)?void 0:t.pageViewId)}doEvent(){var e;return{$pageview_id:null==(e=this.pe)?void 0:e.pageViewId}}fe(e,t){var n=this.pe;if(!n)return{$pageview_id:t};var s={$pageview_id:t,$prev_pageview_id:n.pageViewId},i=this._instance.scrollManager.getContext();if(i&&!this._instance.config.disable_scroll_properties){var{maxScrollHeight:a,lastScrollY:r,maxScrollY:o,maxContentHeight:l,lastContentY:c,maxContentY:d}=i;if(!($n(a)||$n(r)||$n(o)||$n(l)||$n(c)||$n(d))){a=Math.ceil(a),r=Math.ceil(r),o=Math.ceil(o),l=Math.ceil(l),c=Math.ceil(c),d=Math.ceil(d);var u=a<=1?1:ns(r/a,0,1,Ms),p=a<=1?1:ns(o/a,0,1,Ms),m=l<=1?1:ns(c/l,0,1,Ms),h=l<=1?1:ns(d/l,0,1,Ms);s=Bs(s,{$prev_pageview_last_scroll:r,$prev_pageview_last_scroll_percentage:u,$prev_pageview_max_scroll:o,$prev_pageview_max_scroll_percentage:p,$prev_pageview_last_content:c,$prev_pageview_last_content_percentage:m,$prev_pageview_max_content:d,$prev_pageview_max_content_percentage:h})}}return n.pathname&&(s.$prev_pageview_pathname=n.pathname),n.timestamp&&(s.$prev_pageview_duration=(e.getTime()-n.timestamp.getTime())/1e3),s}}var Uo=!!wn||!!yn,Wo="text/plain",qo=(e,t)=>{var[n,s]=e.split("?"),i=Sn({},t);null==s||s.split("&").forEach(e=>{var[t]=e.split("=");delete i[t]});var a=function(e,t){var n,s;void 0===t&&(t="&");var i=[];return zs(e,function(e,t){$n(e)||$n(t)||"undefined"===t||(n=encodeURIComponent(e instanceof File?e.name:e.toString()),s=encodeURIComponent(t),i[i.length]=s+"="+n)}),i.join(t)}(i);return n+"?"+(a?(s?s+"&":"")+a:s)},Go=(e,t)=>JSON.stringify(e,(e,t)=>"bigint"==typeof t?t.toString():t,t),Zo=e=>{var t,{data:n,compression:s}=e;if(n){if(s===va.GZipJS){var i=Yr(Kr(Go(n)),{mtime:0}),a=new Blob([i],{type:Wo});return{contentType:Wo,body:a,estimatedSize:a.size}}if(s===va.Base64){var r=function(e){var t,n,s,i,a,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o=0,l=0,c="",d=[];if(!e)return e;e=function(e){var t,n,s,i,a="";for(t=n=0,s=(e=(e+"").replace(/\r\n/g,"\n").replace(/\r/g,"\n")).length,i=0;i127&&r<2048?String.fromCharCode(r>>6|192,63&r|128):String.fromCharCode(r>>12|224,r>>6&63|128,63&r|128),Wn(o)||(n>t&&(a+=e.substring(t,n)),a+=o,t=n=i+1)}return n>t&&(a+=e.substring(t,e.length)),a}(e);do{t=(a=e.charCodeAt(o++)<<16|e.charCodeAt(o++)<<8|e.charCodeAt(o++))>>18&63,n=a>>12&63,s=a>>6&63,i=63&a,d[l++]=r.charAt(t)+r.charAt(n)+r.charAt(s)+r.charAt(i)}while(o{var t,n,{contentType:s,body:i,estimatedSize:a}=null!==(t=Zo(e))&&void 0!==t?t:{},r=new Headers;zs(e.headers,function(e,t){r.append(t,e)}),s&&r.append("Content-Type",s);var o=e.url,l=null;if(jn){var c=new jn;l={signal:c.signal,timeout:setTimeout(()=>c.abort(),e.timeout)}}yn(o,Sn({method:(null==e?void 0:e.method)||"GET",headers:r,keepalive:"POST"===e.method&&(a||0)<52428.8,body:i,signal:null==(n=l)?void 0:n.signal},e.fetchOptions)).then(t=>t.text().then(n=>{var s={statusCode:t.status,text:n};if(200===t.status)try{s.json=JSON.parse(n)}catch(i){Ms.error(i)}null==e.callback||e.callback(s)})).catch(t=>{Ms.error(t),null==e.callback||e.callback({statusCode:0,text:t})}).finally(()=>l?clearTimeout(l.timeout):null)}}),wn&&Yo.push({transport:"XHR",method:e=>{var t,n=new wn;n.open(e.method||"GET",e.url,!0);var{contentType:s,body:i}=null!==(t=Zo(e))&&void 0!==t?t:{};zs(e.headers,function(e,t){n.setRequestHeader(t,e)}),s&&n.setRequestHeader("Content-Type",s),e.timeout&&(n.timeout=e.timeout),e.disableXHRCredentials||(n.withCredentials=!0),n.onreadystatechange=()=>{if(4===n.readyState){var t={statusCode:n.status,text:n.responseText};if(200===n.status)try{t.json=JSON.parse(n.responseText)}catch(s){}null==e.callback||e.callback(t)}},n.send(i)}}),null!=gn&&gn.sendBeacon&&Yo.push({transport:"sendBeacon",method:e=>{var t=qo(e.url,{beacon:"1"});try{var n,{contentType:s,body:i}=null!==(n=Zo(e))&&void 0!==n?n:{},a="string"==typeof i?new Blob([i],{type:s}):i;gn.sendBeacon(t,a)}catch(r){}}});var Ko=function(e,t){if(!function(e){try{new RegExp(e)}catch(t){return!1}return!0}(t))return!1;try{return new RegExp(t).test(e)}catch(n){return!1}};function Jo(e,t,n){return Go({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:n})}var Qo={exact:(e,t)=>t.some(t=>e.some(e=>t===e)),is_not:(e,t)=>t.every(t=>e.every(e=>t!==e)),regex:(e,t)=>t.some(t=>e.some(e=>Ko(t,e))),not_regex:(e,t)=>t.every(t=>e.every(e=>!Ko(t,e))),icontains:(e,t)=>t.map(Xo).some(t=>e.map(Xo).some(e=>t.includes(e))),not_icontains:(e,t)=>t.map(Xo).every(t=>e.map(Xo).every(e=>!t.includes(e)))},Xo=e=>e.toLowerCase(),el=Ds("[Error tracking]");let tl=class{constructor(e){var t,n;this.ge=[],this._e=new ys([new ws,new As,new Cs,new js,new Es,new Ss,new Fs,new Is],[xs,vs]),this._instance=e,this.ge=null!==(t=null==(n=this._instance.persistence)?void 0:n.get_property(ni))&&void 0!==t?t:[]}onRemoteConfig(e){var t,n,s,i=null!==(t=null==(n=e.errorTracking)?void 0:n.suppressionRules)&&void 0!==t?t:[],a=null==(s=e.errorTracking)?void 0:s.captureExtensionExceptions;this.ge=i,this._instance.persistence&&this._instance.persistence.register({[ni]:this.ge,[si]:a})}get me(){var e,t=!!this._instance.get_property(si),n=this._instance.config.error_tracking.captureExtensionExceptions;return null!==(e=null!=n?n:t)&&void 0!==e&&e}buildProperties(e,t){return this._e.buildFromUnknown(e,{syntheticException:null==t?void 0:t.syntheticException,mechanism:{handled:null==t?void 0:t.handled}})}sendExceptionEvent(e){if(this.ye(e))el.info("Skipping exception capture because a suppression rule matched");else{if(this.me||!this.be(e))return this._instance.capture("$exception",e,{_noTruncate:!0,_batchKey:"exceptionEvent"});el.info("Skipping exception capture because it was thrown by an extension")}}ye(e){var t=e.$exception_list;if(!t||!On(t)||0===t.length)return!1;var n=t.reduce((e,t)=>{var{type:n,value:s}=t;return Vn(n)&&n.length>0&&e.$exception_types.push(n),Vn(s)&&s.length>0&&e.$exception_values.push(s),e},{$exception_types:[],$exception_values:[]});return this.ge.some(e=>{var t=e.values.map(e=>{var t,s=Qo[e.operator],i=On(e.value)?e.value:[e.value],a=null!==(t=n[e.key])&&void 0!==t?t:[];return i.length>0&&s(i,a)});return"OR"===e.type?t.some(Boolean):t.every(Boolean)})}be(e){var t=e.$exception_list;return!(!t||!On(t))&&t.flatMap(e=>{var t,n;return null!==(t=null==(n=e.stacktrace)?void 0:n.frames)&&void 0!==t?t:[]}).some(e=>e.filename&&e.filename.startsWith("chrome-extension://"))}};var nl="Mobile",sl="iOS",il="Android",al="Tablet",rl=il+" "+al,ol="iPad",ll="Apple",cl=ll+" Watch",dl="Safari",ul="BlackBerry",pl="Samsung",ml=pl+"Browser",hl=pl+" Internet",xl="Chrome",fl=xl+" OS",gl=xl+" "+sl,vl="Internet Explorer",bl=vl+" "+nl,yl="Opera",wl=yl+" Mini",jl="Edge",Cl="Microsoft "+jl,Nl="Firefox",Fl=Nl+" "+sl,_l="Nintendo",kl="PlayStation",Sl="Xbox",El=il+" "+nl,Il=nl+" "+dl,Al="Windows",Tl=Al+" Phone",Ml="Nokia",Dl="Ouya",Ll="Generic",Pl=Ll+" "+nl.toLowerCase(),Rl=Ll+" "+al.toLowerCase(),Ol="Konqueror",zl="(\\d+(\\.\\d+)?)",Bl=new RegExp("Version/"+zl),Hl=new RegExp(Sl,"i"),$l=new RegExp(kl+" \\w+","i"),Vl=new RegExp(_l+" \\w+","i"),Ul=new RegExp(ul+"|PlayBook|BB10","i"),Wl={"NT3.51":"NT 3.11","NT4.0":"NT 4.0","5.0":"2000",5.1:"XP",5.2:"XP","6.0":"Vista",6.1:"7",6.2:"8",6.3:"8.1",6.4:"10","10.0":"10"},ql=function(e,t){return t=t||"",An(e," OPR/")&&An(e,"Mini")?wl:An(e," OPR/")?yl:Ul.test(e)?ul:An(e,"IE"+nl)||An(e,"WPDesktop")?bl:An(e,ml)?hl:An(e,jl)||An(e,"Edg/")?Cl:An(e,"FBIOS")?"Facebook "+nl:An(e,"UCWEB")||An(e,"UCBrowser")?"UC Browser":An(e,"CriOS")?gl:An(e,"CrMo")||An(e,xl)?xl:An(e,il)&&An(e,dl)?El:An(e,"FxiOS")?Fl:An(e.toLowerCase(),Ol.toLowerCase())?Ol:((e,t)=>{return t&&An(t,ll)||An(n=e,dl)&&!An(n,xl)&&!An(n,il);var n})(e,t)?An(e,nl)?Il:dl:An(e,Nl)?Nl:An(e,"MSIE")||An(e,"Trident/")?vl:An(e,"Gecko")?Nl:""},Gl={[bl]:[new RegExp("rv:"+zl)],[Cl]:[new RegExp(jl+"?\\/"+zl)],[xl]:[new RegExp("("+xl+"|CrMo)\\/"+zl)],[gl]:[new RegExp("CriOS\\/"+zl)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+zl)],[dl]:[Bl],[Il]:[Bl],[yl]:[new RegExp("(Opera|OPR)\\/"+zl)],[Nl]:[new RegExp(Nl+"\\/"+zl)],[Fl]:[new RegExp("FxiOS\\/"+zl)],[Ol]:[new RegExp("Konqueror[:/]?"+zl,"i")],[ul]:[new RegExp(ul+" "+zl),Bl],[El]:[new RegExp("android\\s"+zl,"i")],[hl]:[new RegExp(ml+"\\/"+zl)],[vl]:[new RegExp("(rv:|MSIE )"+zl)],Mozilla:[new RegExp("rv:"+zl)]},Zl=function(e,t){var n=ql(e,t),s=Gl[n];if($n(s))return null;for(var i=0;i[Sl,e&&e[1]||""]],[new RegExp(_l,"i"),[_l,""]],[new RegExp(kl,"i"),[kl,""]],[Ul,[ul,""]],[new RegExp(Al,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[Tl,""];if(new RegExp(nl).test(t)&&!/IEMobile\b/.test(t))return[Al+" "+nl,""];var n=/Windows NT ([0-9.]+)/i.exec(t);if(n&&n[1]){var s=n[1],i=Wl[s]||"";return/arm/i.test(t)&&(i="RT"),[Al,i]}return[Al,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>{if(e&&e[3]){var t=[e[3],e[4],e[5]||"0"];return[sl,t.join(".")]}return[sl,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var t="";return e&&e.length>=3&&(t=$n(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("("+il+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+il+")","i"),e=>{if(e&&e[2]){var t=[e[2],e[3],e[4]||"0"];return[il,t.join(".")]}return[il,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{var t=["Mac OS X",""];if(e&&e[1]){var n=[e[1],e[2],e[3]||"0"];t[1]=n.join(".")}return t}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[fl,""]],[/Linux|debian/i,["Linux",""]]],Kl=function(e){return Vl.test(e)?_l:$l.test(e)?kl:Hl.test(e)?Sl:new RegExp(Dl,"i").test(e)?Dl:new RegExp("("+Tl+"|WPDesktop)","i").test(e)?Tl:/iPad/.test(e)?ol:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?cl:Ul.test(e)?ul:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(Ml,"i").test(e)?Ml:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(e)||/(kf[a-z]+)( bui|\)).+silk\//i.test(e)?"Kindle Fire":/(Android|ZTE)/i.test(e)?!new RegExp(nl).test(e)||/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(e)?/pixel[\daxl ]{1,6}/i.test(e)&&!/pixel c/i.test(e)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(e)||/lmy47v/i.test(e)&&!/QTAQZ3/i.test(e)?il:rl:il:new RegExp("(pda|"+nl+")","i").test(e)?Pl:new RegExp(al,"i").test(e)&&!new RegExp(al+" pc","i").test(e)?Rl:""},Jl="https?://(.*)",Ql=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],Xl=Hs(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],Ql),ec="",tc=["li_fat_id"];function nc(e,t,n){if(!vn)return{};var s,i=t?Hs([],Ql,n||[]):[],a=sc(ja(vn.URL,i,ec),e),r=(s={},zs(tc,function(e){var t=za.J(e);s[e]=t||null}),s);return Bs(r,a)}function sc(e,t){var n=Xl.concat(t||[]),s={};return zs(n,function(t){var n=wa(e,t);s[t]=n||null}),s}function ic(e){var t,n=(t=e)?0===t.search(Jl+"google.([^/?]*)")?"google":0===t.search(Jl+"bing.com")?"bing":0===t.search(Jl+"yahoo.com")?"yahoo":0===t.search(Jl+"duckduckgo.com")?"duckduckgo":null:null,s="yahoo"!=n?"q":"p",i={};if(!Wn(n)){i.$search_engine=n;var a=vn?wa(vn.referrer,s):"";a.length&&(i.ph_keyword=a)}return i}function ac(){return navigator.language||navigator.userLanguage}function rc(){return(null==vn?void 0:vn.referrer)||"$direct"}function oc(e,t){var n=e?Hs([],Ql,t||[]):[],s=null==bn?void 0:bn.href.substring(0,1e3);return{r:rc().substring(0,1e3),u:s?ja(s,n,ec):void 0}}function lc(e){var t,{r:n,u:s}=e,i={$referrer:n,$referring_domain:null==n?void 0:"$direct"==n?"$direct":null==(t=ya(n))?void 0:t.host};if(s){i.$current_url=s;var a=ya(s);i.$host=null==a?void 0:a.host,i.$pathname=null==a?void 0:a.pathname;var r=sc(s);Bs(i,r)}if(n){var o=ic(n);Bs(i,o)}return i}function cc(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(fa){return}}function dc(){try{return(new Date).getTimezoneOffset()}catch(fa){return}}var uc=Ds("[FeatureFlags]"),pc="$active_feature_flags",mc="$override_feature_flags",hc="$feature_flag_payloads",xc="$override_feature_flag_payloads",fc="$feature_flag_request_id",gc=e=>{var t={};for(var[n,s]of $s(e||{}))s&&(t[n]=s);return t},vc=function(e){return e.FeatureFlags="feature_flags",e.Recordings="recordings",e}({});let bc=class{constructor(e){this.we=!1,this.Se=!1,this.ke=!1,this.$e=!1,this.xe=!1,this.Ee=!1,this.Re=!1,this._instance=e,this.featureFlagEventHandlers=[]}Ie(){var e=this._instance.config.evaluation_environments;return null!=e&&e.length?e.filter(e=>{var t=e&&"string"==typeof e&&e.trim().length>0;return t||uc.error("Invalid evaluation environment found:",e,"Expected non-empty string"),t}):[]}Pe(){return this.Ie().length>0}flags(){if(this._instance.config.__preview_remote_config)this.Ee=!0;else{var e=!this.Te&&(this._instance.config.advanced_disable_feature_flags||this._instance.config.advanced_disable_feature_flags_on_first_load);this.Ce({disableFlags:e})}}get hasLoadedFlags(){return this.Se}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var e=this._instance.get_property(ji),t=this._instance.get_property(mc),n=this._instance.get_property(xc);if(!n&&!t)return e||{};var s=Bs({},e||{}),i=[...new Set([...Object.keys(n||{}),...Object.keys(t||{})])];for(var a of i){var r,o,l=s[a],c=null==t?void 0:t[a],d=$n(c)?null!==(r=null==l?void 0:l.enabled)&&void 0!==r&&r:!!c,u=$n(c)?l.variant:"string"==typeof c?c:void 0,p=null==n?void 0:n[a],m=Sn({},l,{enabled:d,variant:d?null!=u?u:null==l?void 0:l.variant:void 0});d!==(null==l?void 0:l.enabled)&&(m.original_enabled=null==l?void 0:l.enabled),u!==(null==l?void 0:l.variant)&&(m.original_variant=null==l?void 0:l.variant),p&&(m.metadata=Sn({},null==l?void 0:l.metadata,{payload:p,original_payload:null==l||null==(o=l.metadata)?void 0:o.payload})),s[a]=m}return this.we||(uc.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:n,finalDetails:s}),this.we=!0),s}getFlagVariants(){var e=this._instance.get_property(yi),t=this._instance.get_property(mc);if(!t)return e||{};for(var n=Bs({},e),s=Object.keys(t),i=0;i{this.Ce()},5))}Me(){clearTimeout(this.Te),this.Te=void 0}ensureFlagsLoaded(){this.Se||this.ke||this.Te||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this.$e=e}Ce(e){var t;if(this.Me(),!this._instance.L())if(this.ke)this.xe=!0;else{var n={token:this._instance.config.token,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:Sn({},(null==(t=this._instance.persistence)?void 0:t.get_initial_props())||{},this._instance.get_property(Ci)||{}),group_properties:this._instance.get_property(Ni)};(null!=e&&e.disableFlags||this._instance.config.advanced_disable_feature_flags)&&(n.disable_flags=!0),this.Pe()&&(n.evaluation_environments=this.Ie());var s=this._instance.config.__preview_remote_config,i=s?"/flags/?v=2":"/flags/?v=2&config=true",a=this._instance.config.advanced_only_evaluate_survey_feature_flags?"&only_evaluate_survey_feature_flags=true":"",r=this._instance.requestRouter.endpointFor("api",i+a);s&&(n.timezone=cc()),this.ke=!0,this._instance.Oe({method:"POST",url:r,data:n,compression:this._instance.config.disable_compression?void 0:va.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:e=>{var t,s,i=!0;if(200===e.statusCode&&(this.xe||(this.$anon_distinct_id=void 0),i=!1),this.ke=!1,this.Ee||(this.Ee=!0,this._instance.Fe(null!==(s=e.json)&&void 0!==s?s:{})),!n.disable_flags||this.xe)if(this.Re=!i,e.json&&null!=(t=e.json.quotaLimited)&&t.includes(vc.FeatureFlags))uc.warn("You have hit your feature flags quota limit, and will not be able to load feature flags until the quota is reset. Please visit https://posthog.com/docs/billing/limits-alerts to learn more.");else{var a;n.disable_flags||this.receivedFeatureFlags(null!==(a=e.json)&&void 0!==a?a:{},i),this.xe&&(this.xe=!1,this.Ce())}}})}}getFeatureFlag(e,t){if(void 0===t&&(t={}),this.Se||this.getFlags()&&this.getFlags().length>0){var n=this.getFlagVariants()[e],s=""+n,i=this._instance.get_property(fc)||void 0,a=this._instance.get_property(ki)||{};if((t.send_event||!("send_event"in t))&&(!(e in a)||!a[e].includes(s))){var r,o,l,c,d,u,p,m,h;On(a[e])?a[e].push(s):a[e]=[s],null==(r=this._instance.persistence)||r.register({[ki]:a});var x=this.getFeatureFlagDetails(e),f={$feature_flag:e,$feature_flag_response:n,$feature_flag_payload:this.getFeatureFlagPayload(e)||null,$feature_flag_request_id:i,$feature_flag_bootstrapped_response:(null==(o=this._instance.config.bootstrap)||null==(o=o.featureFlags)?void 0:o[e])||null,$feature_flag_bootstrapped_payload:(null==(l=this._instance.config.bootstrap)||null==(l=l.featureFlagPayloads)?void 0:l[e])||null,$used_bootstrap_value:!this.Re};$n(null==x||null==(c=x.metadata)?void 0:c.version)||(f.$feature_flag_version=x.metadata.version);var g,v=null!==(d=null==x||null==(u=x.reason)?void 0:u.description)&&void 0!==d?d:null==x||null==(p=x.reason)?void 0:p.code;v&&(f.$feature_flag_reason=v),null!=x&&null!=(m=x.metadata)&&m.id&&(f.$feature_flag_id=x.metadata.id),$n(null==x?void 0:x.original_variant)&&$n(null==x?void 0:x.original_enabled)||(f.$feature_flag_original_response=$n(x.original_variant)?x.original_enabled:x.original_variant),null!=x&&null!=(h=x.metadata)&&h.original_payload&&(f.$feature_flag_original_payload=null==x||null==(g=x.metadata)?void 0:g.original_payload),this._instance.capture("$feature_flag_called",f)}return n}uc.warn('getFeatureFlag for key "'+e+"\" failed. Feature flags didn't load in time.")}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){return this.getFlagPayloads()[e]}getRemoteConfigPayload(e,t){var n=this._instance.config.token,s={distinct_id:this._instance.get_distinct_id(),token:n};this.Pe()&&(s.evaluation_environments=this.Ie()),this._instance.Oe({method:"POST",url:this._instance.requestRouter.endpointFor("api","/flags/?v=2&config=true"),data:s,compression:this._instance.config.disable_compression?void 0:va.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:n=>{var s,i=null==(s=n.json)?void 0:s.featureFlagPayloads;t((null==i?void 0:i[e])||void 0)}})}isFeatureEnabled(e,t){if(void 0===t&&(t={}),this.Se||this.getFlags()&&this.getFlags().length>0){var n=this.getFeatureFlag(e,t);return $n(n)?void 0:!!n}uc.warn('isFeatureEnabled for key "'+e+"\" failed. Feature flags didn't load in time.")}addFeatureFlagsHandler(e){this.featureFlagEventHandlers.push(e)}removeFeatureFlagsHandler(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter(t=>t!==e)}receivedFeatureFlags(e,t){if(this._instance.persistence){this.Se=!0;var n=this.getFlagVariants(),s=this.getFlagPayloads(),i=this.getFlagsWithDetails();!function(e,t,n,s,i){void 0===n&&(n={}),void 0===s&&(s={}),void 0===i&&(i={});var a=(e=>{var t=e.flags;return t?(e.featureFlags=Object.fromEntries(Object.keys(t).map(e=>{var n;return[e,null!==(n=t[e].variant)&&void 0!==n?n:t[e].enabled]})),e.featureFlagPayloads=Object.fromEntries(Object.keys(t).filter(e=>t[e].enabled).filter(e=>{var n;return null==(n=t[e].metadata)?void 0:n.payload}).map(e=>{var n;return[e,null==(n=t[e].metadata)?void 0:n.payload]}))):uc.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),e})(e),r=a.flags,o=a.featureFlags,l=a.featureFlagPayloads;if(o){var c=e.requestId;if(On(o)){uc.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var d={};if(o)for(var u=0;uthis.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t,n){var s,i=(this._instance.get_property(wi)||[]).find(t=>t.flagKey===e),a={["$feature_enrollment/"+e]:t},r={$feature_flag:e,$feature_enrollment:t,$set:a};i&&(r.$early_access_feature_name=i.name),n&&(r.$feature_enrollment_stage=n),this._instance.capture("$feature_enrollment_update",r),this.setPersonPropertiesForFlags(a,!1);var o=Sn({},this.getFlagVariants(),{[e]:t});null==(s=this._instance.persistence)||s.register({[pc]:Object.keys(gc(o)),[yi]:o}),this.Ae()}getEarlyAccessFeatures(e,t,n){void 0===t&&(t=!1);var s=this._instance.get_property(wi),i=n?"&"+n.map(e=>"stage="+e).join("&"):"";if(s&&!t)return e(s);this._instance.Oe({url:this._instance.requestRouter.endpointFor("api","/api/early_access_features/?token="+this._instance.config.token+i),method:"GET",callback:t=>{var n,s;if(t.json){var i=t.json.earlyAccessFeatures;return null==(n=this._instance.persistence)||n.unregister(wi),null==(s=this._instance.persistence)||s.register({[wi]:i}),e(i)}}})}De(){var e=this.getFlags(),t=this.getFlagVariants();return{flags:e.filter(e=>t[e]),flagVariants:Object.keys(t).filter(e=>t[e]).reduce((e,n)=>(e[n]=t[n],e),{})}}Ae(e){var{flags:t,flagVariants:n}=this.De();this.featureFlagEventHandlers.forEach(s=>s(t,n,{errorsLoading:e}))}setPersonPropertiesForFlags(e,t){void 0===t&&(t=!0);var n=this._instance.get_property(Ci)||{};this._instance.register({[Ci]:Sn({},n,e)}),t&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister(Ci)}setGroupPropertiesForFlags(e,t){void 0===t&&(t=!0);var n=this._instance.get_property(Ni)||{};0!==Object.keys(n).length&&Object.keys(n).forEach(t=>{n[t]=Sn({},n[t],e[t]),delete e[t]}),this._instance.register({[Ni]:Sn({},n,e)}),t&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var t=this._instance.get_property(Ni)||{};this._instance.register({[Ni]:Sn({},t,{[e]:{}})})}else this._instance.unregister(Ni)}reset(){this.Se=!1,this.ke=!1,this.$e=!1,this.xe=!1,this.Ee=!1,this.Re=!1,this.$anon_distinct_id=void 0,this.Me(),this.we=!1}};var yc=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"];let wc=class{constructor(e,t){var n,s;this.A=e,this.props={},this.je=!1,this.Le=(s="",(n=e).token&&(s=n.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),n.persistence_name?"ph_"+n.persistence_name:"ph_"+s+"_posthog"),this.it=this.Ne(e),this.load(),e.debug&&Ms.info("Persistence loaded",e.persistence,Sn({},this.props)),this.update_config(e,e,t),this.save()}isDisabled(){return!!this.Ue}Ne(e){-1===yc.indexOf(e.persistence.toLowerCase())&&(Ms.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var t=e.persistence.toLowerCase();return"localstorage"===t&&Ha.G()?Ha:"localstorage+cookie"===t&&Va.G()?Va:"sessionstorage"===t&&Ga.G()?Ga:"memory"===t?Wa:"cookie"===t?za:Va.G()?Va:za}properties(){var e={};return zs(this.props,function(t,n){if(n===yi&&Bn(t))for(var s=Object.keys(t),i=0;i{this.props.hasOwnProperty(n)&&this.props[n]!==t||(this.props[n]=e,s=!0)}),s)return this.save(),!0}return!1}register(e,t){if(Bn(e)){this.ze=$n(t)?this.He:t;var n=!1;if(zs(e,(t,s)=>{e.hasOwnProperty(s)&&this.props[s]!==t&&(this.props[s]=t,n=!0)}),n)return this.save(),!0}return!1}unregister(e){e in this.props&&(delete this.props[e],this.save())}update_campaign_params(){if(!this.je){var e=nc(this.A.custom_campaign_params,this.A.mask_personal_data_properties,this.A.custom_personal_data_properties);Hn(Ws(e))||this.register(e),this.je=!0}}update_search_keyword(){var e;this.register((e=null==vn?void 0:vn.referrer)?ic(e):{})}update_referrer_info(){var e;this.register_once({$referrer:rc(),$referring_domain:null!=vn&&vn.referrer&&(null==(e=ya(vn.referrer))?void 0:e.host)||"$direct"},void 0)}set_initial_person_info(){this.props[Ai]||this.props[Ti]||this.register_once({[Mi]:oc(this.A.mask_personal_data_properties,this.A.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};zs([Ti,Ai],t=>{var n=this.props[t];n&&zs(n,function(t,n){e["$initial_"+Mn(n)]=t})});var t,n,s=this.props[Mi];if(s){var i=(t=lc(s),n={},zs(t,function(e,t){n["$initial_"+Mn(t)]=e}),n);Bs(e,i)}return e}safe_merge(e){return zs(this.props,function(t,n){n in e||(e[n]=t)}),e}update_config(e,t,n){if(this.He=this.ze=e.cookie_expiration,this.set_disabled(e.disable_persistence||!!n),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),e.persistence!==t.persistence){var s=this.Ne(e),i=this.props;this.clear(),this.it=s,this.props=i,this.save()}}set_disabled(e){this.Ue=e,this.Ue?this.remove():this.save()}set_cross_subdomain(e){e!==this.Be&&(this.Be=e,this.remove(),this.save())}set_secure(e){e!==this.qe&&(this.qe=e,this.remove(),this.save())}set_event_timer(e,t){var n=this.props[Qs]||{};n[e]=t,this.props[Qs]=n,this.save()}remove_event_timer(e){var t=(this.props[Qs]||{})[e];return $n(t)||(delete this.props[Qs][e],this.save()),t}get_property(e){return this.props[e]}set_property(e,t){this.props[e]=t,this.save()}};!function(e){e.Button="button",e.Tab="tab",e.Selector="selector"}({}),function(e){e.TopLeft="top_left",e.TopRight="top_right",e.TopCenter="top_center",e.MiddleLeft="middle_left",e.MiddleRight="middle_right",e.MiddleCenter="middle_center",e.Left="left",e.Center="center",e.Right="right",e.NextToTrigger="next_to_trigger"}({});var jc=function(e){return e.Popover="popover",e.API="api",e.Widget="widget",e.ExternalSurvey="external_survey",e}({});!function(e){e.Open="open",e.MultipleChoice="multiple_choice",e.SingleChoice="single_choice",e.Rating="rating",e.Link="link"}({}),function(e){e.NextQuestion="next_question",e.End="end",e.ResponseBased="response_based",e.SpecificQuestion="specific_question"}({}),function(e){e.Once="once",e.Recurring="recurring",e.Always="always"}({});var Cc=function(e){return e.SHOWN="survey shown",e.DISMISSED="survey dismissed",e.SENT="survey sent",e}({}),Nc=function(e){return e.SURVEY_ID="$survey_id",e.SURVEY_NAME="$survey_name",e.SURVEY_RESPONSE="$survey_response",e.SURVEY_ITERATION="$survey_iteration",e.SURVEY_ITERATION_START_DATE="$survey_iteration_start_date",e.SURVEY_PARTIALLY_COMPLETED="$survey_partially_completed",e.SURVEY_SUBMISSION_ID="$survey_submission_id",e.SURVEY_QUESTIONS="$survey_questions",e.SURVEY_COMPLETED="$survey_completed",e}({}),Fc=function(e){return e.Popover="popover",e.Inline="inline",e}({});let _c=class{constructor(){this.We={},this.We={}}on(e,t){return this.We[e]||(this.We[e]=[]),this.We[e].push(t),()=>{this.We[e]=this.We[e].filter(e=>e!==t)}}emit(e,t){for(var n of this.We[e]||[])n(t);for(var s of this.We["*"]||[])s(e,t)}},kc=class e{constructor(e){this.Ge=new _c,this.Ve=(e,t)=>this.Je(e,t)&&this.Ke(e,t)&&this.Ye(e,t),this.Je=(e,t)=>null==t||!t.event||(null==e?void 0:e.event)===(null==t?void 0:t.event),this._instance=e,this.Xe=new Set,this.Qe=new Set}init(){var e,t;$n(null==(e=this._instance)?void 0:e.Ze)||(null==(t=this._instance)||t.Ze((e,t)=>{this.on(e,t)}))}register(e){var t,n;if(!$n(null==(t=this._instance)?void 0:t.Ze)&&(e.forEach(e=>{var t,n;null==(t=this.Qe)||t.add(e),null==(n=e.steps)||n.forEach(e=>{var t;null==(t=this.Xe)||t.add((null==e?void 0:e.event)||"")})}),null!=(n=this._instance)&&n.autocapture)){var s,i=new Set;e.forEach(e=>{var t;null==(t=e.steps)||t.forEach(e=>{null!=e&&e.selector&&i.add(null==e?void 0:e.selector)})}),null==(s=this._instance)||s.autocapture.setElementSelectors(i)}}on(e,t){var n;null!=t&&0!=e.length&&(this.Xe.has(e)||this.Xe.has(null==t?void 0:t.event))&&this.Qe&&(null==(n=this.Qe)?void 0:n.size)>0&&this.Qe.forEach(e=>{this.tr(t,e)&&this.Ge.emit("actionCaptured",e.name)})}ir(e){this.onAction("actionCaptured",t=>e(t))}tr(e,t){if(null==(null==t?void 0:t.steps))return!1;for(var n of t.steps)if(this.Ve(e,n))return!0;return!1}onAction(e,t){return this.Ge.on(e,t)}Ke(t,n){if(null!=n&&n.url){var s,i=null==t||null==(s=t.properties)?void 0:s.$current_url;if(!i||"string"!=typeof i)return!1;if(!e.er(i,null==n?void 0:n.url,(null==n?void 0:n.url_matching)||"contains"))return!1}return!0}static er(t,n,s){switch(s){case"regex":return!!pn&&Ko(t,n);case"exact":return n===t;case"contains":var i=e.rr(n).replace(/_/g,".").replace(/%/g,".*");return Ko(t,i);default:return!1}}static rr(e){return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}Ye(t,n){if((null!=n&&n.href||null!=n&&n.tag_name||null!=n&&n.text)&&!this.sr(t).some(t=>!(null!=n&&n.href&&!e.er(t.href||"",null==n?void 0:n.href,(null==n?void 0:n.href_matching)||"exact")||null!=n&&n.tag_name&&t.tag_name!==(null==n?void 0:n.tag_name)||null!=n&&n.text&&!e.er(t.text||"",null==n?void 0:n.text,(null==n?void 0:n.text_matching)||"exact")&&!e.er(t.$el_text||"",null==n?void 0:n.text,(null==n?void 0:n.text_matching)||"exact"))))return!1;if(null!=n&&n.selector){var s,i=null==t||null==(s=t.properties)?void 0:s.$element_selectors;if(!i)return!1;if(!i.includes(null==n?void 0:n.selector))return!1}return!0}sr(e){return null==(null==e?void 0:e.properties.$elements)?[]:null==e?void 0:e.properties.$elements}};var Sc=Ds("[Surveys]"),Ec="seenSurvey_",Ic=(e,t)=>{var n="$survey_"+t+"/"+e.id;return e.current_iteration&&e.current_iteration>0&&(n="$survey_"+t+"/"+e.id+"/"+e.current_iteration),n},Ac=e=>{var t=""+Ec+e.id;return e.current_iteration&&e.current_iteration>0&&(t=""+Ec+e.id+"_"+e.current_iteration),t},Tc=[jc.Popover,jc.Widget,jc.API],Mc={ignoreConditions:!1,ignoreDelay:!1,displayType:Fc.Popover};let Dc=class{constructor(e){this._instance=e,this.nr=new Map,this.ar=new Map}register(e){var t;$n(null==(t=this._instance)?void 0:t.Ze)||(this.lr(e),this.ur(e))}ur(e){var t=e.filter(e=>{var t,n;return(null==(t=e.conditions)?void 0:t.actions)&&(null==(n=e.conditions)||null==(n=n.actions)||null==(n=n.values)?void 0:n.length)>0});0!==t.length&&(null==this.hr&&(this.hr=new kc(this._instance),this.hr.init(),this.hr.ir(e=>{this.onAction(e)})),t.forEach(e=>{var t,n,s,i,a;e.conditions&&null!=(t=e.conditions)&&t.actions&&null!=(n=e.conditions)&&null!=(n=n.actions)&&n.values&&(null==(s=e.conditions)||null==(s=s.actions)||null==(s=s.values)?void 0:s.length)>0&&(null==(i=this.hr)||i.register(e.conditions.actions.values),null==(a=e.conditions)||null==(a=a.actions)||null==(a=a.values)||a.forEach(t=>{if(t&&t.name){var n=this.ar.get(t.name);n&&n.push(e.id),this.ar.set(t.name,n||[e.id])}}))}))}lr(e){var t;0!==e.filter(e=>{var t,n;return(null==(t=e.conditions)?void 0:t.events)&&(null==(n=e.conditions)||null==(n=n.events)||null==(n=n.values)?void 0:n.length)>0}).length&&(null==(t=this._instance)||t.Ze((e,t)=>{this.onEvent(e,t)}),e.forEach(e=>{var t;null==(t=e.conditions)||null==(t=t.events)||null==(t=t.values)||t.forEach(t=>{if(t&&t.name){var n=this.nr.get(t.name);n&&n.push(e.id),this.nr.set(t.name,n||[e.id])}})}))}onEvent(e,t){var n,s,i=(null==(n=this._instance)||null==(n=n.persistence)?void 0:n.props[_i])||[];if(Cc.SHOWN===e&&t&&i.length>0){var a;Sc.info("survey event matched, removing survey from activated surveys",{event:e,eventPayload:t,existingActivatedSurveys:i});var r=null==t||null==(a=t.properties)?void 0:a.$survey_id;if(r){var o=i.indexOf(r);o>=0&&(i.splice(o,1),this.dr(i))}}else if(this.nr.has(e)){Sc.info("survey event name matched",{event:e,eventPayload:t,surveys:this.nr.get(e)});var l=[];null==(s=this._instance)||s.getSurveys(t=>{l=t.filter(t=>{var n;return null==(n=this.nr.get(e))?void 0:n.includes(t.id)})});var c=l.filter(n=>{var s,i=null==(s=n.conditions)||null==(s=s.events)||null==(s=s.values)?void 0:s.find(t=>t.name===e);return!!i&&(!i.propertyFilters||Object.entries(i.propertyFilters).every(e=>{var n,[s,i]=e,a=null==t||null==(n=t.properties)?void 0:n[s];if($n(a)||Wn(a))return!1;var r=[String(a)],o=Qo[i.operator];return o?o(i.values,r):(Sc.warn("Unknown property comparison operator: "+i.operator),!1)}))});this.dr(i.concat(c.map(e=>e.id)||[]))}}onAction(e){var t,n=(null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[_i])||[];this.ar.has(e)&&this.dr(n.concat(this.ar.get(e)||[]))}dr(e){var t;Sc.info("updating activated surveys",{activatedSurveys:e}),null==(t=this._instance)||null==(t=t.persistence)||t.register({[_i]:[...new Set(e)]})}getSurveys(){var e;return(null==(e=this._instance)||null==(e=e.persistence)?void 0:e.props[_i])||[]}getEventToSurveys(){return this.nr}vr(){return this.hr}},Lc=class{constructor(e){this.cr=void 0,this._surveyManager=null,this.pr=!1,this.gr=!1,this._r=[],this._instance=e,this._surveyEventReceiver=null}onRemoteConfig(e){if(!this._instance.config.disable_surveys){var t=e.surveys;if(qn(t))return Sc.warn("Flags not loaded yet. Not loading surveys.");var n=On(t);this.cr=n?t.length>0:t,Sc.info("flags response received, isSurveysEnabled: "+this.cr),this.loadIfEnabled()}}reset(){localStorage.removeItem("lastSeenSurveyDate");for(var e=[],t=0;tlocalStorage.removeItem(e))}loadIfEnabled(){if(!this._surveyManager)if(this.gr)Sc.info("Already initializing surveys, skipping...");else if(this._instance.config.disable_surveys)Sc.info("Disabled. Not loading surveys.");else if(this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())Sc.info("Not loading surveys in cookieless mode without consent.");else{var e=null==Nn?void 0:Nn.__PosthogExtensions__;if(e){if(!$n(this.cr)||this._instance.config.advanced_enable_surveys){var t=this.cr||this._instance.config.advanced_enable_surveys;this.gr=!0;try{var n=e.generateSurveys;if(n)return void this.mr(n,t);var s=e.loadExternalDependency;if(!s)return void this.yr("PostHog loadExternalDependency extension not found.");s(this._instance,"surveys",n=>{n||!e.generateSurveys?this.yr("Could not load surveys script",n):this.mr(e.generateSurveys,t)})}catch(i){throw this.yr("Error initializing surveys",i),i}finally{this.gr=!1}}}else Sc.error("PostHog Extensions not found.")}}mr(e,t){this._surveyManager=e(this._instance,t),this._surveyEventReceiver=new Dc(this._instance),Sc.info("Surveys loaded successfully"),this.br({isLoaded:!0})}yr(e,t){Sc.error(e,t),this.br({isLoaded:!1,error:e})}onSurveysLoaded(e){return this._r.push(e),this._surveyManager&&this.br({isLoaded:!0}),()=>{this._r=this._r.filter(t=>t!==e)}}getSurveys(e,t){if(void 0===t&&(t=!1),this._instance.config.disable_surveys)return Sc.info("Disabled. Not loading surveys."),e([]);var n=this._instance.get_property(Fi);if(n&&!t)return e(n,{isLoaded:!0});if(this.pr)return e([],{isLoaded:!1,error:"Surveys are already being loaded"});try{this.pr=!0,this._instance.Oe({url:this._instance.requestRouter.endpointFor("api","/api/surveys/?token="+this._instance.config.token),method:"GET",timeout:this._instance.config.surveys_request_timeout_ms,callback:t=>{var n;this.pr=!1;var s=t.statusCode;if(200!==s||!t.json){var i="Surveys API could not be loaded, status: "+s;return Sc.error(i),e([],{isLoaded:!1,error:i})}var a,r=t.json.surveys||[],o=r.filter(e=>{return!(!(t=e).start_date||t.end_date)&&(function(e){var t;return!(null==(t=e.conditions)||null==(t=t.events)||null==(t=t.values)||!t.length)}(e)||function(e){var t;return!(null==(t=e.conditions)||null==(t=t.actions)||null==(t=t.values)||!t.length)}(e));var t});return o.length>0&&(null==(a=this._surveyEventReceiver)||a.register(o)),null==(n=this._instance.persistence)||n.register({[Fi]:r}),e(r,{isLoaded:!0})}})}catch(s){throw this.pr=!1,s}}br(e){for(var t of this._r)try{if(!e.isLoaded)return t([],e);this.getSurveys(t)}catch(n){Sc.error("Error in survey callback",n)}}getActiveMatchingSurveys(e,t){if(void 0===t&&(t=!1),!qn(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);Sc.warn("init was not called")}wr(e){var t=null;return this.getSurveys(n=>{var s;t=null!==(s=n.find(t=>t.id===e))&&void 0!==s?s:null}),t}Sr(e){if(qn(this._surveyManager))return{eligible:!1,reason:"SDK is not enabled or survey functionality is not yet loaded"};var t="string"==typeof e?this.wr(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(e){if(qn(this._surveyManager))return Sc.warn("init was not called"),{visible:!1,disabledReason:"SDK is not enabled or survey functionality is not yet loaded"};var t=this.Sr(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return qn(this._surveyManager)?(Sc.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:"SDK is not enabled or survey functionality is not yet loaded"})):new Promise(n=>{this.getSurveys(t=>{var s,i=null!==(s=t.find(t=>t.id===e))&&void 0!==s?s:null;if(i){var a=this.Sr(i);n({visible:a.eligible,disabledReason:a.reason})}else n({visible:!1,disabledReason:"Survey not found"})},t)})}renderSurvey(e,t){var n;if(qn(this._surveyManager))Sc.warn("init was not called");else{var s="string"==typeof e?this.wr(e):e;if(null!=s&&s.id)if(Tc.includes(s.type)){var i=null==vn?void 0:vn.querySelector(t);if(i)return null!=(n=s.appearance)&&n.surveyPopupDelaySeconds?(Sc.info("Rendering survey "+s.id+" with delay of "+s.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout(()=>{var e,t;Sc.info("Rendering survey "+s.id+" with delay of "+(null==(e=s.appearance)?void 0:e.surveyPopupDelaySeconds)+" seconds"),null==(t=this._surveyManager)||t.renderSurvey(s,i),Sc.info("Survey "+s.id+" rendered")},1e3*s.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(s,i);Sc.warn("Survey element not found")}else Sc.warn("Surveys of type "+s.type+" cannot be rendered in the app");else Sc.warn("Survey not found")}}displaySurvey(e,t){var n;if(qn(this._surveyManager))Sc.warn("init was not called");else{var s=this.wr(e);if(s){var i=s;if(null!=(n=s.appearance)&&n.surveyPopupDelaySeconds&&t.ignoreDelay&&(i=Sn({},s,{appearance:Sn({},s.appearance,{surveyPopupDelaySeconds:0})})),!1===t.ignoreConditions){var a=this.canRenderSurvey(s);if(!a.visible)return void Sc.warn("Survey is not eligible to be displayed: ",a.disabledReason)}t.displayType!==Fc.Inline?this._surveyManager.handlePopoverSurvey(i):this.renderSurvey(i,t.selector)}else Sc.warn("Survey not found")}}};var Pc=Ds("[RateLimiter]");let Rc=class{constructor(e){var t,n;this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=e=>{var t=e.text;if(t&&t.length)try{(JSON.parse(t).quota_limited||[]).forEach(e=>{Pc.info((e||"events")+" is quota limited."),this.serverLimits[e]=(new Date).getTime()+6e4})}catch(n){return void Pc.warn('could not rate limit - continuing. Error: "'+(null==n?void 0:n.message)+'"',{text:t})}},this.instance=e,this.captureEventsPerSecond=(null==(t=e.config.rate_limiting)?void 0:t.events_per_second)||10,this.captureEventsBurstLimit=Math.max((null==(n=e.config.rate_limiting)?void 0:n.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond),this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}clientRateLimitContext(e){var t,n,s;void 0===e&&(e=!1);var i=(new Date).getTime(),a=null!==(t=null==(n=this.instance.persistence)?void 0:n.get_property(Ii))&&void 0!==t?t:{tokens:this.captureEventsBurstLimit,last:i};a.tokens+=(i-a.last)/1e3*this.captureEventsPerSecond,a.last=i,a.tokens>this.captureEventsBurstLimit&&(a.tokens=this.captureEventsBurstLimit);var r=a.tokens<1;return r||e||(a.tokens=Math.max(0,a.tokens-1)),!r||this.lastEventRateLimited||e||this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited. Config is set to "+this.captureEventsPerSecond+" events per second and "+this.captureEventsBurstLimit+" events burst limit."},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=r,null==(s=this.instance.persistence)||s.set_property(Ii,a),{isRateLimited:r,remainingTokens:a.tokens}}isServerRateLimited(e){var t=this.serverLimits[e||"events"]||!1;return!1!==t&&(new Date).getTime()e(this.remoteConfig)):(Oc.error("PostHog Extensions not found. Cannot load remote config."),e())}$r(e){this._instance.Oe({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback:t=>{e(t.json)}})}load(){try{if(this.remoteConfig)return Oc.info("Using preloaded remote config",this.remoteConfig),void this.Fe(this.remoteConfig);if(this._instance.L())return void Oc.warn("Remote config is disabled. Falling back to local config.");this.kr(e=>{if(!e)return Oc.info("No config found after loading remote JS config. Falling back to JSON."),void this.$r(e=>{this.Fe(e)});this.Fe(e)})}catch(fa){Oc.error("Error loading remote config",fa)}}Fe(e){e?this._instance.config.__preview_remote_config?(this._instance.Fe(e),!1!==e.hasFeatureFlags&&this._instance.featureFlags.ensureFlagsLoaded()):Oc.info("__preview_remote_config is disabled. Logging config instead",e):Oc.error("Failed to fetch remote config from PostHog.")}}var Bc=3e3;class Hc{constructor(e,t){this.Er=!0,this.Rr=[],this.Ir=ns((null==t?void 0:t.flush_interval_ms)||Bc,250,5e3,Ms.createLogger("flush interval"),Bc),this.Pr=e}enqueue(e){this.Rr.push(e),this.Tr||this.Cr()}unload(){this.Mr();var e=this.Rr.length>0?this.Or():{},t=Object.values(e);[...t.filter(e=>0===e.url.indexOf("/e")),...t.filter(e=>0!==e.url.indexOf("/e"))].map(e=>{this.Pr(Sn({},e,{transport:"sendBeacon"}))})}enable(){this.Er=!1,this.Cr()}Cr(){var e=this;this.Er||(this.Tr=setTimeout(()=>{if(this.Mr(),this.Rr.length>0){var t=this.Or(),n=function(){var n=t[s],i=(new Date).getTime();n.data&&On(n.data)&&zs(n.data,e=>{e.offset=Math.abs(e.timestamp-i),delete e.timestamp}),e.Pr(n)};for(var s in t)n()}},this.Ir))}Mr(){clearTimeout(this.Tr),this.Tr=void 0}Or(){var e={};return zs(this.Rr,t=>{var n,s=t,i=(s?s.batchKey:null)||s.url;$n(e[i])&&(e[i]=Sn({},s,{data:[]})),null==(n=e[i].data)||n.push(s.data)}),this.Rr=[],e}}var $c=["retriesPerformedSoFar"];class Vc{constructor(e){this.Fr=!1,this.Ar=3e3,this.Rr=[],this._instance=e,this.Rr=[],this.Dr=!0,!$n(pn)&&"onLine"in pn.navigator&&(this.Dr=pn.navigator.onLine,Ys(pn,"online",()=>{this.Dr=!0,this.oe()}),Ys(pn,"offline",()=>{this.Dr=!1}))}get length(){return this.Rr.length}retriableRequest(e){var{retriesPerformedSoFar:t}=e,n=En(e,$c);Gn(t)&&t>0&&(n.url=qo(n.url,{retry_count:t})),this._instance.Oe(Sn({},n,{callback:e=>{200!==e.statusCode&&(e.statusCode<400||e.statusCode>=500)&&(null!=t?t:0)<10?this.jr(Sn({retriesPerformedSoFar:t},n)):null==n.callback||n.callback(e)}}))}jr(e){var t=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=t+1;var n,s,i,a,r,o=(n=t,s=3e3*Math.pow(2,n),i=s/2,a=Math.min(18e5,s),r=(Math.random()-.5)*(a-i),Math.ceil(a+r)),l=Date.now()+o;this.Rr.push({retryAt:l,requestOptions:e});var c="Enqueued failed request for retry in "+o;navigator.onLine||(c+=" (Browser is offline)"),Ms.warn(c),this.Fr||(this.Fr=!0,this.Lr())}Lr(){this.Nr&&clearTimeout(this.Nr),this.Nr=setTimeout(()=>{this.Dr&&this.Rr.length>0&&this.oe(),this.Lr()},this.Ar)}oe(){var e=Date.now(),t=[],n=this.Rr.filter(n=>n.retryAt0)for(var{requestOptions:s}of n)this.retriableRequest(s)}unload(){for(var{requestOptions:e}of(this.Nr&&(clearTimeout(this.Nr),this.Nr=void 0),this.Rr))try{this._instance.Oe(Sn({},e,{transport:"sendBeacon"}))}catch(t){Ms.error(t)}this.Rr=[]}}class Uc{constructor(e){this.Ur=()=>{var e,t,n,s;this.zr||(this.zr={});var i=this.scrollElement(),a=this.scrollY(),r=i?Math.max(0,i.scrollHeight-i.clientHeight):0,o=a+((null==i?void 0:i.clientHeight)||0),l=(null==i?void 0:i.scrollHeight)||0;this.zr.lastScrollY=Math.ceil(a),this.zr.maxScrollY=Math.max(a,null!==(e=this.zr.maxScrollY)&&void 0!==e?e:0),this.zr.maxScrollHeight=Math.max(r,null!==(t=this.zr.maxScrollHeight)&&void 0!==t?t:0),this.zr.lastContentY=o,this.zr.maxContentY=Math.max(o,null!==(n=this.zr.maxContentY)&&void 0!==n?n:0),this.zr.maxContentHeight=Math.max(l,null!==(s=this.zr.maxContentHeight)&&void 0!==s?s:0)},this._instance=e}getContext(){return this.zr}resetContext(){var e=this.zr;return setTimeout(this.Ur,0),e}startMeasuringScrollPosition(){Ys(pn,"scroll",this.Ur,{capture:!0}),Ys(pn,"scrollend",this.Ur,{capture:!0}),Ys(pn,"resize",this.Ur)}scrollElement(){if(!this._instance.config.scroll_root_selector)return null==pn?void 0:pn.document.documentElement;var e=On(this._instance.config.scroll_root_selector)?this._instance.config.scroll_root_selector:[this._instance.config.scroll_root_selector];for(var t of e){var n=null==pn?void 0:pn.document.querySelector(t);if(n)return n}}scrollY(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollTop||0}return pn&&(pn.scrollY||pn.pageYOffset||pn.document.documentElement.scrollTop)||0}scrollX(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollLeft||0}return pn&&(pn.scrollX||pn.pageXOffset||pn.document.documentElement.scrollLeft)||0}}var Wc=e=>oc(null==e?void 0:e.config.mask_personal_data_properties,null==e?void 0:e.config.custom_personal_data_properties);class qc{constructor(e,t,n,s){this.Br=e=>{var t=this.qr();if(!t||t.sessionId!==e){var n={sessionId:e,props:this.Hr(this._instance)};this.Wr.register({[Ei]:n})}},this._instance=e,this.Gr=t,this.Wr=n,this.Hr=s||Wc,this.Gr.onSessionId(this.Br)}qr(){return this.Wr.props[Ei]}getSetOnceProps(){var e,t=null==(e=this.qr())?void 0:e.props;return t?"r"in t?lc(t):{$referring_domain:t.referringDomain,$pathname:t.initialPathName,utm_source:t.utm_source,utm_campaign:t.utm_campaign,utm_medium:t.utm_medium,utm_content:t.utm_content,utm_term:t.utm_term}:{}}getSessionProps(){var e={};return zs(Ws(this.getSetOnceProps()),(t,n)=>{"$current_url"===n&&(n="url"),e["$session_entry_"+Mn(n)]=t}),e}}var Gc=Ds("[SessionId]");class Zc{on(e,t){return this.Vr.on(e,t)}constructor(e,t,n){var s;if(this.Jr=[],this.Vr=new _c,this.Kr=(e,t)=>Math.abs(e-t)>this.sessionTimeoutMs,!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if("always"===e.config.cookieless_mode)throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this.A=e.config,this.Wr=e.persistence,this.pi=void 0,this.Ft=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this.Yr=t||La,this.Xr=n||La;var i=this.A.persistence_name||this.A.token,a=this.A.session_idle_timeout_seconds||1800;if(this._sessionTimeoutMs=1e3*ns(a,60,36e3,Gc.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.Qr(),this.Zr="ph_"+i+"_window_id",this.ts="ph_"+i+"_primary_window_exists",this.es()){var r=Ga.K(this.Zr),o=Ga.K(this.ts);r&&!o?this.pi=r:Ga.X(this.Zr),Ga.Y(this.ts,!0)}if(null!=(s=this.A.bootstrap)&&s.sessionID)try{var l=(()=>{var e=this.A.bootstrap.sessionID.replace(/-/g,"");if(32!==e.length)throw new Error("Not a valid UUID");if("7"!==e[12])throw new Error("Not a UUIDv7");return parseInt(e.substring(0,12),16)})();this.rs(this.A.bootstrap.sessionID,(new Date).getTime(),l)}catch(c){Gc.error("Invalid sessionID in bootstrap",c)}this.ss()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return $n(this.Jr)&&(this.Jr=[]),this.Jr.push(e),this.Ft&&e(this.Ft,this.pi),()=>{this.Jr=this.Jr.filter(t=>t!==e)}}es(){return"memory"!==this.A.persistence&&!this.Wr.Ue&&Ga.G()}ns(e){e!==this.pi&&(this.pi=e,this.es()&&Ga.Y(this.Zr,e))}os(){return this.pi?this.pi:this.es()?Ga.K(this.Zr):null}rs(e,t,n){e===this.Ft&&t===this._sessionActivityTimestamp&&n===this._sessionStartTimestamp||(this._sessionStartTimestamp=n,this._sessionActivityTimestamp=t,this.Ft=e,this.Wr.register({[fi]:[t,e,n]}))}ls(){if(this.Ft&&this._sessionActivityTimestamp&&this._sessionStartTimestamp)return[this._sessionActivityTimestamp,this.Ft,this._sessionStartTimestamp];var e=this.Wr.props[fi];return On(e)&&2===e.length&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this.rs(null,null,null)}ss(){Ys(pn,"beforeunload",()=>{this.es()&&Ga.X(this.ts)},{capture:!1})}checkAndGetSessionAndWindowId(e,t){if(void 0===e&&(e=!1),void 0===t&&(t=null),"always"===this.A.cookieless_mode)throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var n=t||(new Date).getTime(),[s,i,a]=this.ls(),r=this.os(),o=Gn(a)&&a>0&&Math.abs(n-a)>864e5,l=!1,c=!i,d=!e&&this.Kr(n,s);c||d||o?(i=this.Yr(),r=this.Xr(),Gc.info("new session ID generated",{sessionId:i,windowId:r,changeReason:{noSessionId:c,activityTimeout:d,sessionPastMaximumLength:o}}),a=n,l=!0):r||(r=this.Xr(),l=!0);var u=0===s||!e||o?n:s,p=0===a?(new Date).getTime():a;return this.ns(r),this.rs(i,u,p),e||this.Qr(),l&&this.Jr.forEach(e=>e(i,r,l?{noSessionId:c,activityTimeout:d,sessionPastMaximumLength:o}:void 0)),{sessionId:i,windowId:r,sessionStartTimestamp:p,changeReason:l?{noSessionId:c,activityTimeout:d,sessionPastMaximumLength:o}:void 0,lastActivityTimestamp:s}}Qr(){clearTimeout(this.us),this.us=setTimeout(()=>{var[e]=this.ls();if(this.Kr((new Date).getTime(),e)){var t=this.Ft;this.resetSessionId(),this.Vr.emit("forcedIdleReset",{idleSessionId:t})}},1.1*this.sessionTimeoutMs)}}var Yc=["$set_once","$set"],Kc=Ds("[SiteApps]");class Jc{constructor(e){this._instance=e,this.hs=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}ds(e,t){if(t){var n=this.globalsForEvent(t);this.hs.push(n),this.hs.length>1e3&&(this.hs=this.hs.slice(10))}}get siteAppLoaders(){var e;return null==(e=Nn._POSTHOG_REMOTE_CONFIG)||null==(e=e[this._instance.config.token])?void 0:e.siteApps}init(){if(this.isEnabled){var e=this._instance.Ze(this.ds.bind(this));this.vs=()=>{e(),this.hs=[],this.vs=void 0}}}globalsForEvent(e){var t,n,s,i,a,r,o;if(!e)throw new Error("Event payload is required");var l={},c=this._instance.get_property("$groups")||[],d=this._instance.get_property("$stored_group_properties")||{};for(var[u,p]of Object.entries(d))l[u]={id:c[u],type:u,properties:p};var{$set_once:m,$set:h}=e;return{event:Sn({},En(e,Yc),{properties:Sn({},e.properties,h?{$set:Sn({},null!==(t=null==(n=e.properties)?void 0:n.$set)&&void 0!==t?t:{},h)}:{},m?{$set_once:Sn({},null!==(s=null==(i=e.properties)?void 0:i.$set_once)&&void 0!==s?s:{},m)}:{}),elements_chain:null!==(a=null==(r=e.properties)?void 0:r.$elements_chain)&&void 0!==a?a:"",distinct_id:null==(o=e.properties)?void 0:o.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:l}}setupSiteApp(e){var t=this.apps[e.id],n=()=>{var n;!t.errored&&this.hs.length&&(Kc.info("Processing "+this.hs.length+" events for site app with id "+e.id),this.hs.forEach(e=>null==t.processEvent?void 0:t.processEvent(e)),t.processedBuffer=!0),Object.values(this.apps).every(e=>e.processedBuffer||e.errored)&&(null==(n=this.vs)||n.call(this))},s=!1,i=i=>{t.errored=!i,t.loaded=!0,Kc.info("Site app with id "+e.id+" "+(i?"loaded":"errored")),s&&n()};try{var{processEvent:a}=e.init({posthog:this._instance,callback:e=>{i(e)}});a&&(t.processEvent=a),s=!0}catch(r){Kc.error("Error while initializing PostHog app with config id "+e.id,r),i(!1)}if(s&&t.loaded)try{n()}catch(o){Kc.error("Error while processing buffered events PostHog app with config id "+e.id,o),t.errored=!0}}cs(){var e=this.siteAppLoaders||[];for(var t of e)this.apps[t.id]={id:t.id,loaded:!1,errored:!1,processedBuffer:!1};for(var n of e)this.setupSiteApp(n)}fs(e){if(0!==Object.keys(this.apps).length){var t=this.globalsForEvent(e);for(var n of Object.values(this.apps))try{null==n.processEvent||n.processEvent(t)}catch(s){Kc.error("Error while processing event "+e.event+" for site app "+n.id,s)}}}onRemoteConfig(e){var t,n,s,i=this;if(null!=(t=this.siteAppLoaders)&&t.length)return this.isEnabled?(this.cs(),void this._instance.on("eventCaptured",e=>this.fs(e))):void Kc.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null==(n=this.vs)||n.call(this),null!=(s=e.siteApps)&&s.length)if(this.isEnabled){var a=function(e){var t;Nn["__$$ph_site_app_"+e]=i._instance,null==(t=Nn.__PosthogExtensions__)||null==t.loadSiteApp||t.loadSiteApp(i._instance,o,t=>{if(t)return Kc.error("Error while initializing PostHog app with config id "+e,t)})};for(var{id:r,url:o}of e.siteApps)a(r)}else Kc.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}var Qc=["amazonbot","amazonproductbot","app.hypefactors.com","applebot","archive.org_bot","awariobot","backlinksextendedbot","baiduspider","bingbot","bingpreview","chrome-lighthouse","dataforseobot","deepscan","duckduckbot","facebookexternal","facebookcatalog","http://yandex.com/bots","hubspot","ia_archiver","leikibot","linkedinbot","meta-externalagent","mj12bot","msnbot","nessus","petalbot","pinterest","prerender","rogerbot","screaming frog","sebot-wa","sitebulb","slackbot","slurp","trendictionbot","turnitin","twitterbot","vercel-screenshot","vercelbot","yahoo! slurp","yandexbot","zoombot","bot.htm","bot.php","(bot;","bot/","crawler","ahrefsbot","ahrefssiteaudit","semrushbot","siteauditbot","splitsignalbot","gptbot","oai-searchbot","chatgpt-user","perplexitybot","better uptime bot","sentryuptimebot","uptimerobot","headlesschrome","cypress","google-hoteladsverifier","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleother","google-cloudvertexbot","googleweblight","mediapartners-google","storebot-google","google-inspectiontool","bytespider"],Xc=function(e,t){if(!e)return!1;var n=e.toLowerCase();return Qc.concat(t||[]).some(e=>{var t=e.toLowerCase();return-1!==n.indexOf(t)})},ed=function(e,t){if(!e)return!1;var n=e.userAgent;if(n&&Xc(n,t))return!0;try{var s=null==e?void 0:e.userAgentData;if(null!=s&&s.brands&&s.brands.some(e=>Xc(null==e?void 0:e.brand,t)))return!0}catch(i){}return!!e.webdriver},td=function(e){return e.US="us",e.EU="eu",e.CUSTOM="custom",e}({}),nd="i.posthog.com";class sd{constructor(e){this.ps={},this.instance=e}get apiHost(){var e=this.instance.config.api_host.trim().replace(/\/$/,"");return"https://app.posthog.com"===e?"https://us.i.posthog.com":e}get uiHost(){var e,t=null==(e=this.instance.config.ui_host)?void 0:e.replace(/\/$/,"");return t||(t=this.apiHost.replace("."+nd,".posthog.com")),"https://app.posthog.com"===t?"https://us.posthog.com":t}get region(){return this.ps[this.apiHost]||(/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this.ps[this.apiHost]=td.US:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this.ps[this.apiHost]=td.EU:this.ps[this.apiHost]=td.CUSTOM),this.ps[this.apiHost]}endpointFor(e,t){if(void 0===t&&(t=""),t&&(t="/"===t[0]?t:"/"+t),"ui"===e)return this.uiHost+t;if(this.region===td.CUSTOM)return this.apiHost+t;var n=nd+t;switch(e){case"assets":return"https://"+this.region+"-assets."+n;case"api":return"https://"+this.region+"."+n}}}var id={icontains:(e,t)=>!!pn&&t.href.toLowerCase().indexOf(e.toLowerCase())>-1,not_icontains:(e,t)=>!!pn&&-1===t.href.toLowerCase().indexOf(e.toLowerCase()),regex:(e,t)=>!!pn&&Ko(t.href,e),not_regex:(e,t)=>!!pn&&!Ko(t.href,e),exact:(e,t)=>t.href===e,is_not:(e,t)=>t.href!==e};class ad{constructor(e){var t=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(e){void 0===e&&(e=!1),t.getWebExperiments(e=>{ad.gs("retrieved web experiments from the server"),t._s=new Map,e.forEach(e=>{if(e.feature_flag_key){var n;t._s&&(ad.gs("setting flag key ",e.feature_flag_key," to web experiment ",e),null==(n=t._s)||n.set(e.feature_flag_key,e));var s=t._instance.getFeatureFlag(e.feature_flag_key);Vn(s)&&e.variants[s]&&t.ys(e.name,s,e.variants[s].transforms)}else if(e.variants)for(var i in e.variants){var a=e.variants[i];ad.bs(a)&&t.ys(e.name,i,a.transforms)}})},e)},this._instance=e,this._instance.onFeatureFlags(e=>{this.onFeatureFlags(e)})}onFeatureFlags(e){if(this._is_bot())ad.gs("Refusing to render web experiment since the viewer is a likely bot");else if(!this._instance.config.disable_web_experiments){if(qn(this._s))return this._s=new Map,this.loadIfEnabled(),void this.previewWebExperiment();ad.gs("applying feature flags",e),e.forEach(e=>{var t;if(this._s&&null!=(t=this._s)&&t.has(e)){var n,s=this._instance.getFeatureFlag(e),i=null==(n=this._s)?void 0:n.get(e);s&&null!=i&&i.variants[s]&&this.ys(i.name,s,i.variants[s].transforms)}})}}previewWebExperiment(){var e=ad.getWindowLocation();if(null!=e&&e.search){var t=wa(null==e?void 0:e.search,"__experiment_id"),n=wa(null==e?void 0:e.search,"__experiment_variant");t&&n&&(ad.gs("previewing web experiments "+t+" && "+n),this.getWebExperiments(e=>{this.ws(parseInt(t),n,e)},!1,!0))}}loadIfEnabled(){this._instance.config.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,t,n){if(this._instance.config.disable_web_experiments&&!n)return e([]);var s=this._instance.get_property("$web_experiments");if(s&&!t)return e(s);this._instance.Oe({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this._instance.config.token),method:"GET",callback:t=>{if(200!==t.statusCode||!t.json)return e([]);var n=t.json.experiments||[];return e(n)}})}ws(e,t,n){var s=n.filter(t=>t.id===e);s&&s.length>0&&(ad.gs("Previewing web experiment ["+s[0].name+"] with variant ["+t+"]"),this.ys(s[0].name,t,s[0].variants[t].transforms))}static bs(e){return!qn(e.conditions)&&ad.Ss(e)&&ad.ks(e)}static Ss(e){var t;if(qn(e.conditions)||qn(null==(t=e.conditions)?void 0:t.url))return!0;var n,s,i,a=ad.getWindowLocation();return!!a&&(null==(n=e.conditions)||!n.url||id[null!==(s=null==(i=e.conditions)?void 0:i.urlMatchType)&&void 0!==s?s:"icontains"](e.conditions.url,a))}static getWindowLocation(){return null==pn?void 0:pn.location}static ks(e){var t;if(qn(e.conditions)||qn(null==(t=e.conditions)?void 0:t.utm))return!0;var n=nc();if(n.utm_source){var s,i,a,r,o,l,c,d,u=null==(s=e.conditions)||null==(s=s.utm)||!s.utm_campaign||(null==(i=e.conditions)||null==(i=i.utm)?void 0:i.utm_campaign)==n.utm_campaign,p=null==(a=e.conditions)||null==(a=a.utm)||!a.utm_source||(null==(r=e.conditions)||null==(r=r.utm)?void 0:r.utm_source)==n.utm_source,m=null==(o=e.conditions)||null==(o=o.utm)||!o.utm_medium||(null==(l=e.conditions)||null==(l=l.utm)?void 0:l.utm_medium)==n.utm_medium,h=null==(c=e.conditions)||null==(c=c.utm)||!c.utm_term||(null==(d=e.conditions)||null==(d=d.utm)?void 0:d.utm_term)==n.utm_term;return u&&m&&h&&p}return!1}static gs(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),s=1;s{if(n.selector){var s;ad.gs("applying transform of variant "+t+" for experiment "+e+" ",n);var i=null==(s=document)?void 0:s.querySelectorAll(n.selector);null==i||i.forEach(e=>{var t=e;n.html&&(t.innerHTML=n.html),n.css&&t.setAttribute("style",n.css)})}}):ad.gs("Control variants leave the page unmodified.")}_is_bot(){return gn&&this._instance?ed(gn,this._instance.config.custom_blocked_useragents):void 0}}var rd=Ds("[PostHog ExternalIntegrations]"),od={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};class ld{constructor(e){this._instance=e}nt(e,t){var n;null==(n=Nn.__PosthogExtensions__)||null==n.loadExternalDependency||n.loadExternalDependency(this._instance,e,e=>{if(e)return rd.error("failed to load script",e);t()})}startIfEnabledOrStop(){var e=this,t=function(t){var n,i,a;!s||null!=(n=Nn.__PosthogExtensions__)&&null!=(n=n.integrations)&&n[t]||e.nt(od[t],()=>{var n;null==(n=Nn.__PosthogExtensions__)||null==(n=n.integrations)||null==(n=n[t])||n.start(e._instance)}),!s&&null!=(i=Nn.__PosthogExtensions__)&&null!=(i=i.integrations)&&i[t]&&(null==(a=Nn.__PosthogExtensions__)||null==(a=a.integrations)||null==(a=a[t])||a.stop())};for(var[n,s]of Object.entries(null!==(i=this._instance.config.integrations)&&void 0!==i?i:{})){var i;t(n)}}}var cd="[SessionRecording]",dd=Ds(cd);class ud{get started(){var e;return!(null==(e=this.$s)||!e.isStarted)}get status(){var e;return(null==(e=this.$s)?void 0:e.status)||"lazy_loading"}constructor(e){if(this._forceAllowLocalhostNetworkCapture=!1,this.ni=void 0,this._instance=e,!this._instance.sessionManager)throw dd.error("started without valid sessionManager"),new Error(cd+" started without valid sessionManager. This is a bug.");if("always"===this._instance.config.cookieless_mode)throw new Error(cd+' cannot be used with cookieless_mode="always"')}get Bt(){var e,t=!(null==(e=this._instance.get_property(oi))||!e.enabled),n=!this._instance.config.disable_session_recording,s=this._instance.config.disable_session_recording||this._instance.consent.isOptedOut();return pn&&t&&n&&!s}startIfEnabledOrStop(e){var t;if(!this.Bt||null==(t=this.$s)||!t.isStarted){var n=!$n(Object.assign)&&!$n(Array.from);this.Bt&&n?(this.xs(e),dd.info("starting")):this.stopRecording()}}xs(e){var t,n,s;this.Bt&&(null!=Nn&&null!=(t=Nn.__PosthogExtensions__)&&null!=(t=t.rrweb)&&t.record&&null!=(n=Nn.__PosthogExtensions__)&&n.initSessionRecording?this.Ri(e):null==(s=Nn.__PosthogExtensions__)||null==s.loadExternalDependency||s.loadExternalDependency(this._instance,this.Ii,t=>{if(t)return dd.error("could not load recorder",t);this.Ri(e)}))}stopRecording(){var e;null==(e=this.$s)||e.stop()}ki(){var e;null==(e=this._instance.persistence)||e.unregister(gi)}Ei(e){if(this._instance.persistence){var t,n,s=this._instance.persistence,i=()=>{var t=e.sessionRecording,n=null==t?void 0:t.sampleRate,i=qn(n)?null:parseFloat(n);qn(i)&&this.ki();var a=null==t?void 0:t.minimumDurationMilliseconds;s.register({[oi]:Sn({enabled:!!t},t,{networkPayloadCapture:Sn({capturePerformance:e.capturePerformance},null==t?void 0:t.networkPayloadCapture),canvasRecording:{enabled:null==t?void 0:t.recordCanvas,fps:null==t?void 0:t.canvasFps,quality:null==t?void 0:t.canvasQuality},sampleRate:i,minimumDurationMilliseconds:$n(a)?null:a,endpoint:null==t?void 0:t.endpoint,triggerMatchType:null==t?void 0:t.triggerMatchType,masking:null==t?void 0:t.masking,urlTriggers:null==t?void 0:t.urlTriggers})})};i(),null==(t=this.ni)||t.call(this),this.ni=null==(n=this._instance.sessionManager)?void 0:n.onSessionId(i)}}onRemoteConfig(e){"sessionRecording"in e?(this.Ei(e),this.startIfEnabledOrStop()):dd.info("skipping remote config with no sessionRecording",e)}log(e,t){var n;void 0===t&&(t="log"),null!=(n=this.$s)&&n.log?this.$s.log(e,t):dd.warn("log called before recorder was ready")}get Ii(){var e,t,n=null==(e=this._instance)||null==(e=e.persistence)?void 0:e.get_property(oi);return(null==n||null==(t=n.scriptConfig)?void 0:t.script)||"lazy-recorder"}Ri(e){var t,n;if(null==(t=Nn.__PosthogExtensions__)||!t.initSessionRecording)throw Error("Called on script loaded before session recording is available");this.$s||(this.$s=null==(n=Nn.__PosthogExtensions__)?void 0:n.initSessionRecording(this._instance),this.$s._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),this.$s.start(e)}onRRwebEmit(e){var t;null==(t=this.$s)||null==t.onRRwebEmit||t.onRRwebEmit(e)}overrideLinkedFlag(){var e;null==(e=this.$s)||e.overrideLinkedFlag()}overrideSampling(){var e;null==(e=this.$s)||e.overrideSampling()}overrideTrigger(e){var t;null==(t=this.$s)||t.overrideTrigger(e)}get sdkDebugProperties(){var e;return(null==(e=this.$s)?void 0:e.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(e,t){var n;return!(null==(n=this.$s)||!n.tryAddCustomEvent(e,t))}}var pd={},md=()=>{},hd="posthog",xd=!Uo&&-1===(null==Cn?void 0:Cn.indexOf("MSIE"))&&-1===(null==Cn?void 0:Cn.indexOf("Mozilla")),fd=e=>{var t;return{api_host:"https://us.i.posthog.com",ui_host:null,token:"",autocapture:!0,rageclick:!0,cross_subdomain_cookie:Gs(null==vn?void 0:vn.location),persistence:"localStorage+cookie",persistence_name:"",loaded:md,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageview:"2025-05-24"!==e||"history_change",capture_pageleave:"if_capture_pageview",defaults:null!=e?e:"unset",debug:bn&&Vn(null==bn?void 0:bn.search)&&-1!==bn.search.indexOf("__posthog_debug=true")||!1,cookie_expiration:365,upgrade:!1,disable_session_recording:!1,disable_persistence:!1,disable_web_experiments:!0,disable_surveys:!1,disable_surveys_automatic_display:!1,disable_external_dependency_loading:!1,enable_recording_console_log:void 0,secure_cookie:"https:"===(null==pn||null==(t=pn.location)?void 0:t.protocol),ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,session_recording:{},mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_flags:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_only_evaluate_survey_feature_flags:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,surveys_request_timeout_ms:1e4,on_request_error:e=>{var t="Bad HTTP status: "+e.statusCode+" "+e.text;Ms.error(t)},get_device_id:e=>e,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:"identified_only",before_send:void 0,request_queue_config:{flush_interval_ms:Bc},error_tracking:{},_onCapture:md,__preview_eager_load_replay:!0}},gd=e=>{var t={};$n(e.process_person)||(t.person_profiles=e.process_person),$n(e.xhr_headers)||(t.request_headers=e.xhr_headers),$n(e.cookie_name)||(t.persistence_name=e.cookie_name),$n(e.disable_cookie)||(t.disable_persistence=e.disable_cookie),$n(e.store_google)||(t.save_campaign_params=e.store_google),$n(e.verbose)||(t.debug=e.verbose);var n=Bs({},t,e);return On(e.property_blacklist)&&($n(e.property_denylist)?n.property_denylist=e.property_blacklist:On(e.property_denylist)?n.property_denylist=[...e.property_blacklist,...e.property_denylist]:Ms.error("Invalid value for property_denylist config: "+e.property_denylist)),n};class vd{constructor(){this.__forceAllowLocalhost=!1}get Es(){return this.__forceAllowLocalhost}set Es(e){Ms.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}}class bd{get decideEndpointWasHit(){var e,t;return null!==(e=null==(t=this.featureFlags)?void 0:t.hasLoadedFlags)&&void 0!==e&&e}get flagsEndpointWasHit(){var e,t;return null!==(e=null==(t=this.featureFlags)?void 0:t.hasLoadedFlags)&&void 0!==e&&e}constructor(){this.webPerformance=new vd,this.Rs=!1,this.version=Fn.LIB_VERSION,this.Is=new _c,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=fd(),this.SentryIntegration=Eo,this.sentryIntegration=e=>{return t=So(this,e),{name:ko,processEvent:e=>t(e)};var t},this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.Ps=!1,this.Ts=null,this.Cs=null,this.Ms=null,this.featureFlags=new bc(this),this.toolbar=new Do(this),this.scrollManager=new Uc(this),this.pageViewManager=new Vo(this),this.surveys=new Lc(this),this.experiments=new ad(this),this.exceptions=new tl(this),this.rateLimiter=new Rc(this),this.requestRouter=new sd(this),this.consent=new Ya(this),this.externalIntegrations=new ld(this),this.people={set:(e,t,n)=>{var s=Vn(e)?{[e]:t}:e;this.setPersonProperties(s),null==n||n({})},set_once:(e,t,n)=>{var s=Vn(e)?{[e]:t}:e;this.setPersonProperties(void 0,s),null==n||n({})}},this.on("eventCaptured",e=>Ms.info('send "'+(null==e?void 0:e.event)+'"',e))}init(e,t,n){if(n&&n!==hd){var s,i=null!==(s=pd[n])&&void 0!==s?s:new bd;return i._init(e,t,n),pd[n]=i,pd[hd][n]=i,i}return this._init(e,t,n)}_init(e,t,n){var s,i;if(void 0===t&&(t={}),$n(e)||Un(e))return Ms.critical("PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()"),this;if(this.__loaded)return Ms.warn("You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config={},this.Os=t,this.Fs=[],t.person_profiles&&(this.Cs=t.person_profiles),this.set_config(Bs({},fd(t.defaults),gd(t),{name:n,token:e})),this.config.on_xhr_error&&Ms.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=t.disable_compression?void 0:va.GZipJS;var a=this.As();this.persistence=new wc(this.config,a),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new wc(Sn({},this.config,{persistence:"sessionStorage"}),a);var r=Sn({},this.persistence.props),o=Sn({},this.sessionPersistence.props);this.register({$initialization_time:(new Date).toISOString()}),this.Ds=new Hc(e=>this.js(e),this.config.request_queue_config),this.Ls=new Vc(this),this.__request_queue=[];var l="always"===this.config.cookieless_mode||"on_reject"===this.config.cookieless_mode&&this.consent.isExplicitlyOptedOut();if(l||(this.sessionManager=new Zc(this),this.sessionPropsManager=new qc(this,this.sessionManager,this.persistence)),new Po(this).startIfEnabledOrStop(),this.siteApps=new Jc(this),null==(s=this.siteApps)||s.init(),l||(this.config.__preview_eager_load_replay?this.sessionRecording=new Fo(this):this.sessionRecording=new ud(this),this.sessionRecording.startIfEnabledOrStop()),this.config.disable_scroll_properties||this.scrollManager.startMeasuringScrollPosition(),this.autocapture=new Sa(this),this.autocapture.startIfEnabled(),this.surveys.loadIfEnabled(),this.heatmaps=new $o(this),this.heatmaps.startIfEnabled(),this.webVitalsAutocapture=new zo(this),this.exceptionObserver=new tr(this),this.exceptionObserver.startIfEnabled(),this.deadClicksAutocapture=new Xa(this,Qa),this.deadClicksAutocapture.startIfEnabled(),this.historyAutocapture=new sr(this),this.historyAutocapture.startIfEnabled(),Fn.DEBUG=Fn.DEBUG||this.config.debug,Fn.DEBUG&&Ms.info("Starting in debug mode",{this:this,config:t,thisC:Sn({},this.config),p:r,s:o}),void 0!==(null==(i=t.bootstrap)?void 0:i.distinctID)){var c,d,u=this.config.get_device_id(La()),p=null!=(c=t.bootstrap)&&c.isIdentifiedID?u:t.bootstrap.distinctID;this.persistence.set_property(Si,null!=(d=t.bootstrap)&&d.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:t.bootstrap.distinctID,$device_id:p})}if(this.Ns()){var m,h,x=Object.keys((null==(m=t.bootstrap)?void 0:m.featureFlags)||{}).filter(e=>{var n;return!(null==(n=t.bootstrap)||null==(n=n.featureFlags)||!n[e])}).reduce((e,n)=>{var s;return e[n]=(null==(s=t.bootstrap)||null==(s=s.featureFlags)?void 0:s[n])||!1,e},{}),f=Object.keys((null==(h=t.bootstrap)?void 0:h.featureFlagPayloads)||{}).filter(e=>x[e]).reduce((e,n)=>{var s,i;return null!=(s=t.bootstrap)&&null!=(s=s.featureFlagPayloads)&&s[n]&&(e[n]=null==(i=t.bootstrap)||null==(i=i.featureFlagPayloads)?void 0:i[n]),e},{});this.featureFlags.receivedFeatureFlags({featureFlags:x,featureFlagPayloads:f})}if(l)this.register_once({distinct_id:Pi,$device_id:null},"");else if(!this.get_distinct_id()){var g=this.config.get_device_id(La());this.register_once({distinct_id:g,$device_id:g},""),this.persistence.set_property(Si,"anonymous")}return Ys(pn,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),this.toolbar.maybeLoadToolbar(),t.segment?function(e,t){var n=e.config.segment;if(!n)return t();!function(e,t){var n=e.config.segment;if(!n)return t();var s=n=>{var s=()=>n.anonymousId()||La();e.config.get_device_id=s,n.id()&&(e.register({distinct_id:n.id(),$device_id:s()}),e.persistence.set_property(Si,"identified")),t()},i=n.user();"then"in i&&zn(i.then)?i.then(e=>s(e)):s(i)}(e,()=>{n.register((e=>{Promise&&Promise.resolve||_o.warn("This browser does not have Promise support, and can not use the segment integration");var t=(t,n)=>{if(!n)return t;t.event.userId||t.event.anonymousId===e.get_distinct_id()||(_o.info("No userId set, resetting PostHog"),e.reset()),t.event.userId&&t.event.userId!==e.get_distinct_id()&&(_o.info("UserId set, identifying with PostHog"),e.identify(t.event.userId));var s=e.calculateEventProperties(n,t.event.properties);return t.event.properties=Object.assign({},s,t.event.properties),t};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:()=>!0,load:()=>Promise.resolve(),track:e=>t(e,e.event.event),page:e=>t(e,"$pageview"),identify:e=>t(e,"$identify"),screen:e=>t(e,"$screen")}})(e)).then(()=>{t()})})}(this,()=>this.Us()):this.Us(),zn(this.config._onCapture)&&this.config._onCapture!==md&&(Ms.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",e=>this.config._onCapture(e.event,e))),this.config.ip&&Ms.warn('The `ip` config option has NO EFFECT AT ALL and has been deprecated. Use a custom transformation or "Discard IP data" project setting instead. See https://posthog.com/tutorials/web-redact-properties#hiding-customer-ip-address for more information.'),this}Fe(e){var t,n,s,i,a,r,o,l;if(!vn||!vn.body)return Ms.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout(()=>{this.Fe(e)},500);this.compression=void 0,e.supportedCompression&&!this.config.disable_compression&&(this.compression=An(e.supportedCompression,va.GZipJS)?va.GZipJS:An(e.supportedCompression,va.Base64)?va.Base64:void 0),null!=(t=e.analytics)&&t.endpoint&&(this.analyticsDefaultEndpoint=e.analytics.endpoint),this.set_config({person_profiles:this.Cs?this.Cs:"identified_only"}),null==(n=this.siteApps)||n.onRemoteConfig(e),null==(s=this.sessionRecording)||s.onRemoteConfig(e),null==(i=this.autocapture)||i.onRemoteConfig(e),null==(a=this.heatmaps)||a.onRemoteConfig(e),this.surveys.onRemoteConfig(e),null==(r=this.webVitalsAutocapture)||r.onRemoteConfig(e),null==(o=this.exceptionObserver)||o.onRemoteConfig(e),this.exceptions.onRemoteConfig(e),null==(l=this.deadClicksAutocapture)||l.onRemoteConfig(e)}Us(){try{this.config.loaded(this)}catch(fa){Ms.critical("`loaded` function failed",fa)}this.zs(),this.config.capture_pageview&&setTimeout(()=>{(this.consent.isOptedIn()||"always"===this.config.cookieless_mode)&&this.Bs()},1),new zc(this).load(),this.featureFlags.flags()}zs(){var e;this.is_capturing()&&this.config.request_batching&&(null==(e=this.Ds)||e.enable())}_dom_loaded(){this.is_capturing()&&Os(this.__request_queue,e=>this.js(e)),this.__request_queue=[],this.zs()}_handle_unload(){var e,t;this.config.request_batching?(this.qs()&&this.capture("$pageleave"),null==(e=this.Ds)||e.unload(),null==(t=this.Ls)||t.unload()):this.qs()&&this.capture("$pageleave",null,{transport:"sendBeacon"})}Oe(e){this.__loaded&&(xd?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=qo(e.url,{ip:this.config.ip?1:0}),e.headers=Sn({},this.config.request_headers),e.compression="best-available"===e.compression?this.compression:e.compression,e.disableXHRCredentials=this.config.__preview_disable_xhr_credentials,this.config.__preview_disable_beacon&&(e.disableTransport=["sendBeacon"]),e.fetchOptions=e.fetchOptions||this.config.fetch_options,(e=>{var t,n,s,i=Sn({},e);i.timeout=i.timeout||6e4,i.url=qo(i.url,{_:(new Date).getTime().toString(),ver:Fn.LIB_VERSION,compression:i.compression});var a=null!==(t=i.transport)&&void 0!==t?t:"fetch",r=Yo.filter(e=>!i.disableTransport||!e.transport||!i.disableTransport.includes(e.transport)),o=null!==(n=null==(s=Zs(r,e=>e.transport===a))?void 0:s.method)&&void 0!==n?n:r[0].method;if(!o)throw new Error("No available transport method");o(i)})(Sn({},e,{callback:t=>{var n,s;this.rateLimiter.checkForLimiting(t),t.statusCode>=400&&(null==(n=(s=this.config).on_request_error)||n.call(s,t)),null==e.callback||e.callback(t)}}))))}js(e){this.Ls?this.Ls.retriableRequest(e):this.Oe(e)}_execute_array(e){var t,n=[],s=[],i=[];Os(e,e=>{e&&(t=e[0],On(t)?i.push(e):zn(e)?e.call(this):On(e)&&"alias"===t?n.push(e):On(e)&&-1!==t.indexOf("capture")&&zn(this[t])?i.push(e):s.push(e))});var a=function(e,t){Os(e,function(e){if(On(e[0])){var n=t;zs(e,function(e){n=n[e[0]].apply(n,e.slice(1))})}else this[e[0]].apply(this,e.slice(1))},t)};a(n,this),a(s,this),a(i,this)}Ns(){var e,t;return(null==(e=this.config.bootstrap)?void 0:e.featureFlags)&&Object.keys(null==(t=this.config.bootstrap)?void 0:t.featureFlags).length>0||!1}push(e){this._execute_array([e])}capture(e,t,n){var s;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.Ds){if(this.is_capturing())if(!$n(e)&&Vn(e)){if(this.config.opt_out_useragent_filter||!this._is_bot()){var i=null!=n&&n.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(null==i||!i.isRateLimited){null!=t&&t.$current_url&&!Vn(null==t?void 0:t.$current_url)&&(Ms.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),null==t||delete t.$current_url),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&this.sessionPersistence.update_campaign_params(),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();var a=new Date,r=(null==n?void 0:n.timestamp)||a,o=La(),l={uuid:o,event:e,properties:this.calculateEventProperties(e,t||{},r,o)};i&&(l.properties.$lib_rate_limit_remaining_tokens=i.remainingTokens),(null==n?void 0:n.$set)&&(l.$set=null==n?void 0:n.$set);var c,d=this.Hs(null==n?void 0:n.$set_once);if(d&&(l.$set_once=d),(l=function(e,t){return n=e,s=e=>Vn(e)&&!Wn(t)?e.slice(0,t):e,i=new Set,function e(t,n){return t!==Object(t)?s?s(t):t:i.has(t)?void 0:(i.add(t),On(t)?(a=[],Os(t,t=>{a.push(e(t))})):(a={},zs(t,(t,n)=>{i.has(t)||(a[n]=e(t,n))})),a);var a}(n);var n,s,i}(l,null!=n&&n._noTruncate?null:this.config.properties_string_max_length)).timestamp=r,$n(null==n?void 0:n.timestamp)||(l.properties.$event_time_override_provided=!0,l.properties.$event_time_override_system_time=a),e===Cc.DISMISSED||e===Cc.SENT){var u=null==t?void 0:t[Nc.SURVEY_ID],p=null==t?void 0:t[Nc.SURVEY_ITERATION];c={id:u,current_iteration:p},localStorage.getItem(Ac(c))||localStorage.setItem(Ac(c),"true"),l.$set=Sn({},l.$set,{[Ic({id:u,current_iteration:p},e===Cc.SENT?"responded":"dismissed")]:!0})}var m=Sn({},l.properties.$set,l.$set);if(Hn(m)||this.setPersonPropertiesForFlags(m),!qn(this.config.before_send)){var h=this.Ws(l);if(!h)return;l=h}this.Is.emit("eventCaptured",l);var x={method:"POST",url:null!==(s=null==n?void 0:n._url)&&void 0!==s?s:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:l,compression:"best-available",batchKey:null==n?void 0:n._batchKey};return!this.config.request_batching||n&&(null==n||!n._batchKey)||null!=n&&n.send_instantly?this.js(x):this.Ds.enqueue(x),l}Ms.critical("This capture call is ignored due to client rate limiting.")}}else Ms.error("No event name provided to posthog.capture")}else Ms.uninitializedWarning("posthog.capture")}Ze(e){return this.on("eventCaptured",t=>e(t.event,t))}calculateEventProperties(e,t,n,s,i){if(n=n||new Date,!this.persistence||!this.sessionPersistence)return t;var a=i?void 0:this.persistence.remove_event_timer(e),r=Sn({},t);if(r.token=this.config.token,r.$config_defaults=this.config.defaults,("always"==this.config.cookieless_mode||"on_reject"==this.config.cookieless_mode&&this.consent.isExplicitlyOptedOut())&&(r.$cookieless_mode=!0),"$snapshot"===e){var o=Sn({},this.persistence.properties(),this.sessionPersistence.properties());return r.distinct_id=o.distinct_id,(!Vn(r.distinct_id)&&!Gn(r.distinct_id)||Un(r.distinct_id))&&Ms.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),r}var l,c=function(e,t){if(!Cn)return{};var n,s,i,a=e?Hs([],Ql,t||[]):[],[r,o]=function(e){for(var t=0;t1e3?Cn.substring(0,997)+"...":Cn,$browser_version:Zl(Cn,navigator.vendor),$browser_language:ac(),$browser_language_prefix:(n=ac(),"string"==typeof n?n.split("-")[0]:void 0),$screen_height:null==pn?void 0:pn.screen.height,$screen_width:null==pn?void 0:pn.screen.width,$viewport_height:null==pn?void 0:pn.innerHeight,$viewport_width:null==pn?void 0:pn.innerWidth,$lib:"web",$lib_version:Fn.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})}(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties);if(this.sessionManager){var{sessionId:d,windowId:u}=this.sessionManager.checkAndGetSessionAndWindowId(i,n.getTime());r.$session_id=d,r.$window_id=u}this.sessionPropsManager&&Bs(r,this.sessionPropsManager.getSessionProps());try{var p;this.sessionRecording&&Bs(r,this.sessionRecording.sdkDebugProperties),r.$sdk_debug_retry_queue_size=null==(p=this.Ls)?void 0:p.length}catch(f){r.$sdk_debug_error_capturing_properties=String(f)}if(this.requestRouter.region===td.CUSTOM&&(r.$lib_custom_api_host=this.config.api_host),l="$pageview"!==e||i?"$pageleave"!==e||i?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(n):this.pageViewManager.doPageView(n,s),r=Bs(r,l),"$pageview"===e&&vn&&(r.title=vn.title),!$n(a)){var m=n.getTime()-a;r.$duration=parseFloat((m/1e3).toFixed(3))}Cn&&this.config.opt_out_useragent_filter&&(r.$browser_type=this._is_bot()?"bot":"browser"),(r=Bs({},c,this.persistence.properties(),this.sessionPersistence.properties(),r)).$is_identified=this._isIdentified(),On(this.config.property_denylist)?zs(this.config.property_denylist,function(e){delete r[e]}):Ms.error("Invalid value for property_denylist config: "+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var h=this.config.sanitize_properties;h&&(Ms.error("sanitize_properties is deprecated. Use before_send instead"),r=h(r,e));var x=this.Gs();return r.$process_person_profile=x,x&&!i&&this.Vs("_calculate_event_properties"),r}Hs(e){var t;if(!this.persistence||!this.Gs())return e;if(this.Rs)return e;var n=this.persistence.get_initial_props(),s=null==(t=this.sessionPropsManager)?void 0:t.getSetOnceProps(),i=Bs({},n,s||{},e||{}),a=this.config.sanitize_properties;return a&&(Ms.error("sanitize_properties is deprecated. Use before_send instead"),i=a(i,"$set_once")),this.Rs=!0,Hn(i)?void 0:i}register(e,t){var n;null==(n=this.persistence)||n.register(e,t)}register_once(e,t,n){var s;null==(s=this.persistence)||s.register_once(e,t,n)}register_for_session(e){var t;null==(t=this.sessionPersistence)||t.register(e)}unregister(e){var t;null==(t=this.persistence)||t.unregister(e)}unregister_for_session(e){var t;null==(t=this.sessionPersistence)||t.unregister(e)}Js(e,t){this.register({[e]:t})}getFeatureFlag(e,t){return this.featureFlags.getFeatureFlag(e,t)}getFeatureFlagPayload(e){var t=this.featureFlags.getFeatureFlagPayload(e);try{return JSON.parse(t)}catch(n){return t}}isFeatureEnabled(e,t){return this.featureFlags.isFeatureEnabled(e,t)}reloadFeatureFlags(){this.featureFlags.reloadFeatureFlags()}updateEarlyAccessFeatureEnrollment(e,t,n){this.featureFlags.updateEarlyAccessFeatureEnrollment(e,t,n)}getEarlyAccessFeatures(e,t,n){return void 0===t&&(t=!1),this.featureFlags.getEarlyAccessFeatures(e,t,n)}on(e,t){return this.Is.on(e,t)}onFeatureFlags(e){return this.featureFlags.onFeatureFlags(e)}onSurveysLoaded(e){return this.surveys.onSurveysLoaded(e)}onSessionId(e){var t,n;return null!==(t=null==(n=this.sessionManager)?void 0:n.onSessionId(e))&&void 0!==t?t:()=>{}}getSurveys(e,t){void 0===t&&(t=!1),this.surveys.getSurveys(e,t)}getActiveMatchingSurveys(e,t){void 0===t&&(t=!1),this.surveys.getActiveMatchingSurveys(e,t)}renderSurvey(e,t){this.surveys.renderSurvey(e,t)}displaySurvey(e,t){void 0===t&&(t=Mc),this.surveys.displaySurvey(e,t)}canRenderSurvey(e){return this.surveys.canRenderSurvey(e)}canRenderSurveyAsync(e,t){return void 0===t&&(t=!1),this.surveys.canRenderSurveyAsync(e,t)}identify(e,t,n){if(!this.__loaded||!this.persistence)return Ms.uninitializedWarning("posthog.identify");if(Gn(e)&&(e=e.toString(),Ms.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),e)if(["distinct_id","distinctid"].includes(e.toLowerCase()))Ms.critical('The string "'+e+'" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.');else if(e!==Pi){if(this.Vs("posthog.identify")){var s=this.get_distinct_id();if(this.register({$user_id:e}),!this.get_property("$device_id")){var i=s;this.register_once({$had_persisted_distinct_id:!0,$device_id:i},"")}e!==s&&e!==this.get_property(Js)&&(this.unregister(Js),this.register({distinct_id:e}));var a="anonymous"===(this.persistence.get_property(Si)||"anonymous");e!==s&&a?(this.persistence.set_property(Si,"identified"),this.setPersonPropertiesForFlags(Sn({},n||{},t||{}),!1),this.capture("$identify",{distinct_id:e,$anon_distinct_id:s},{$set:t||{},$set_once:n||{}}),this.Ms=Jo(e,t,n),this.featureFlags.setAnonymousDistinctId(s)):(t||n)&&this.setPersonProperties(t,n),e!==s&&(this.reloadFeatureFlags(),this.unregister(ki))}}else Ms.critical('The string "'+Pi+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.');else Ms.error("Unique user id has not been set in posthog.identify")}setPersonProperties(e,t){if((e||t)&&this.Vs("posthog.setPersonProperties")){var n=Jo(this.get_distinct_id(),e,t);this.Ms!==n?(this.setPersonPropertiesForFlags(Sn({},t||{},e||{})),this.capture("$set",{$set:e||{},$set_once:t||{}}),this.Ms=n):Ms.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}group(e,t,n){if(e&&t){if(this.Vs("posthog.group")){var s=this.getGroups();s[e]!==t&&this.resetGroupPropertiesForFlags(e),this.register({$groups:Sn({},s,{[e]:t})}),n&&(this.capture("$groupidentify",{$group_type:e,$group_key:t,$group_set:n}),this.setGroupPropertiesForFlags({[e]:n})),s[e]===t||n||this.reloadFeatureFlags()}}else Ms.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,t){void 0===t&&(t=!0),this.featureFlags.setPersonPropertiesForFlags(e,t)}resetPersonPropertiesForFlags(){this.featureFlags.resetPersonPropertiesForFlags()}setGroupPropertiesForFlags(e,t){void 0===t&&(t=!0),this.Vs("posthog.setGroupPropertiesForFlags")&&this.featureFlags.setGroupPropertiesForFlags(e,t)}resetGroupPropertiesForFlags(e){this.featureFlags.resetGroupPropertiesForFlags(e)}reset(e){var t,n,s,i;if(Ms.info("reset"),!this.__loaded)return Ms.uninitializedWarning("posthog.reset");var a=this.get_property("$device_id");if(this.consent.reset(),null==(t=this.persistence)||t.clear(),null==(n=this.sessionPersistence)||n.clear(),this.surveys.reset(),this.featureFlags.reset(),null==(s=this.persistence)||s.set_property(Si,"anonymous"),null==(i=this.sessionManager)||i.resetSessionId(),this.Ms=null,"always"===this.config.cookieless_mode)this.register_once({distinct_id:Pi,$device_id:null},"");else{var r=this.config.get_device_id(La());this.register_once({distinct_id:r,$device_id:e?r:a},"")}this.register({$last_posthog_reset:(new Date).toISOString()},1)}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var e,t;return null!==(e=null==(t=this.sessionManager)?void 0:t.checkAndGetSessionAndWindowId(!0).sessionId)&&void 0!==e?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";var{sessionId:t,sessionStartTimestamp:n}=this.sessionManager.checkAndGetSessionAndWindowId(!0),s=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+t);if(null!=e&&e.withTimestamp&&n){var i,a=null!==(i=e.timestampLookBack)&&void 0!==i?i:10;if(!n)return s;s+="?t="+Math.max(Math.floor(((new Date).getTime()-n)/1e3)-a,0)}return s}alias(e,t){return e===this.get_property(Ks)?(Ms.critical("Attempting to create alias for existing People user - aborting."),-2):this.Vs("posthog.alias")?($n(t)&&(t=this.get_distinct_id()),e!==t?(this.Js(Js,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(Ms.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var t=Sn({},this.config);if(Bn(e)){var n,s,i,a,r;Bs(this.config,gd(e));var o=this.As();null==(n=this.persistence)||n.update_config(this.config,t,o),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new wc(Sn({},this.config,{persistence:"sessionStorage"}),o),Ha.G()&&"true"===Ha.J("ph_debug")&&(this.config.debug=!0),this.config.debug&&(Fn.DEBUG=!0,Ms.info("set_config",{config:e,oldConfig:t,newConfig:Sn({},this.config)})),null==(s=this.sessionRecording)||s.startIfEnabledOrStop(),null==(i=this.autocapture)||i.startIfEnabled(),null==(a=this.heatmaps)||a.startIfEnabled(),this.surveys.loadIfEnabled(),this.Ks(),null==(r=this.externalIntegrations)||r.startIfEnabledOrStop()}}startSessionRecording(e){var t,n,s,i,a,r=!0===e,o={sampling:r||!(null==e||!e.sampling),linked_flag:r||!(null==e||!e.linked_flag),url_trigger:r||!(null==e||!e.url_trigger),event_trigger:r||!(null==e||!e.event_trigger)};Object.values(o).some(Boolean)&&(null==(t=this.sessionManager)||t.checkAndGetSessionAndWindowId(),o.sampling&&(null==(n=this.sessionRecording)||n.overrideSampling()),o.linked_flag&&(null==(s=this.sessionRecording)||s.overrideLinkedFlag()),o.url_trigger&&(null==(i=this.sessionRecording)||i.overrideTrigger("url")),o.event_trigger&&(null==(a=this.sessionRecording)||a.overrideTrigger("event")));this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var e;return!(null==(e=this.sessionRecording)||!e.started)}captureException(e,t){var n=new Error("PostHog syntheticException"),s=this.exceptions.buildProperties(e,{handled:!0,syntheticException:n});return this.exceptions.sendExceptionEvent(Sn({},s,t))}loadToolbar(e){return this.toolbar.loadToolbar(e)}get_property(e){var t;return null==(t=this.persistence)?void 0:t.props[e]}getSessionProperty(e){var t;return null==(t=this.sessionPersistence)?void 0:t.props[e]}toString(){var e,t=null!==(e=this.config.name)&&void 0!==e?e:hd;return t!==hd&&(t=hd+"."+t),t}_isIdentified(){var e,t;return"identified"===(null==(e=this.persistence)?void 0:e.get_property(Si))||"identified"===(null==(t=this.sessionPersistence)?void 0:t.get_property(Si))}Gs(){var e,t;return!("never"===this.config.person_profiles||"identified_only"===this.config.person_profiles&&!this._isIdentified()&&Hn(this.getGroups())&&(null==(e=this.persistence)||null==(e=e.props)||!e[Js])&&(null==(t=this.persistence)||null==(t=t.props)||!t[Di]))}qs(){return!0===this.config.capture_pageleave||"if_capture_pageview"===this.config.capture_pageleave&&(!0===this.config.capture_pageview||"history_change"===this.config.capture_pageview)}createPersonProfile(){this.Gs()||this.Vs("posthog.createPersonProfile")&&this.setPersonProperties({},{})}Vs(e){return"never"===this.config.person_profiles?(Ms.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.Js(Di,!0),!0)}As(){if("always"===this.config.cookieless_mode)return!0;var e=this.consent.isOptedOut(),t=this.config.opt_out_persistence_by_default||"on_reject"===this.config.cookieless_mode;return this.config.disable_persistence||e&&!!t}Ks(){var e,t,n,s,i=this.As();return(null==(e=this.persistence)?void 0:e.Ue)!==i&&(null==(n=this.persistence)||n.set_disabled(i)),(null==(t=this.sessionPersistence)?void 0:t.Ue)!==i&&(null==(s=this.sessionPersistence)||s.set_disabled(i)),i}opt_in_capturing(e){var t;"always"!==this.config.cookieless_mode?("on_reject"===this.config.cookieless_mode&&this.consent.isExplicitlyOptedOut()&&(this.reset(!0),this.sessionManager=new Zc(this),this.persistence&&(this.sessionPropsManager=new qc(this,this.sessionManager,this.persistence)),this.sessionRecording=new Fo(this),this.sessionRecording.startIfEnabledOrStop()),this.consent.optInOut(!0),this.Ks(),"on_reject"==this.config.cookieless_mode&&this.surveys.loadIfEnabled(),($n(null==e?void 0:e.captureEventName)||null!=e&&e.captureEventName)&&this.capture(null!==(t=null==e?void 0:e.captureEventName)&&void 0!==t?t:"$opt_in",null==e?void 0:e.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.Bs()):Ms.warn('Consent opt in/out is not valid with cookieless_mode="always" and will be ignored')}opt_out_capturing(){var e;"always"!==this.config.cookieless_mode?("on_reject"===this.config.cookieless_mode&&this.consent.isOptedIn()&&this.reset(!0),this.consent.optInOut(!1),this.Ks(),"on_reject"===this.config.cookieless_mode&&(this.register({distinct_id:Pi,$device_id:null}),this.sessionManager=void 0,this.sessionPropsManager=void 0,null==(e=this.sessionRecording)||e.stopRecording(),this.sessionRecording=void 0,this.Bs())):Ms.warn('Consent opt in/out is not valid with cookieless_mode="always" and will be ignored')}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){var e=this.consent.consent;return e===Za.GRANTED?"granted":e===Za.DENIED?"denied":"pending"}is_capturing(){return"always"===this.config.cookieless_mode||("on_reject"===this.config.cookieless_mode?this.consent.isExplicitlyOptedOut()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this.Ks()}_is_bot(){return gn?ed(gn,this.config.custom_blocked_useragents):void 0}Bs(){vn&&("visible"===vn.visibilityState?this.Ps||(this.Ps=!0,this.capture("$pageview",{title:vn.title},{send_instantly:!0}),this.Ts&&(vn.removeEventListener("visibilitychange",this.Ts),this.Ts=null)):this.Ts||(this.Ts=this.Bs.bind(this),Ys(vn,"visibilitychange",this.Ts)))}debug(e){!1===e?(null==pn||pn.console.log("You've disabled debug mode."),localStorage&&localStorage.removeItem("ph_debug"),this.set_config({debug:!1})):(null==pn||pn.console.log("You're now in debug mode. All calls to PostHog will be logged in your console.\nYou can disable this with `posthog.debug(false)`."),localStorage&&localStorage.setItem("ph_debug","true"),this.set_config({debug:!0}))}L(){var e,t,n,s,i,a,r=this.Os||{};return"advanced_disable_flags"in r?!!r.advanced_disable_flags:!1!==this.config.advanced_disable_flags?!!this.config.advanced_disable_flags:!0===this.config.advanced_disable_decide?(Ms.warn("Config field 'advanced_disable_decide' is deprecated. Please use 'advanced_disable_flags' instead. The old field will be removed in a future major version."),!0):(n="advanced_disable_decide",s=Ms,i=(t="advanced_disable_flags")in(e=r)&&!$n(e[t]),a=n in e&&!$n(e[n]),i?e[t]:!!a&&(s&&s.warn("Config field '"+n+"' is deprecated. Please use '"+t+"' instead. The old field will be removed in a future major version."),e[n]))}Ws(e){if(qn(this.config.before_send))return e;var t=On(this.config.before_send)?this.config.before_send:[this.config.before_send],n=e;for(var s of t){if(n=s(n),qn(n)){var i="Event '"+e.event+"' was rejected in beforeSend function";return Yn(e.event)?Ms.warn(i+". This can cause unexpected behavior."):Ms.info(i),null}n.properties&&!Hn(n.properties)||Ms.warn("Event '"+e.event+"' has no properties after beforeSend function, this is likely an error.")}return n}getPageViewId(){var e;return null==(e=this.pageViewManager.pe)?void 0:e.pageViewId}captureTraceFeedback(e,t){this.capture("$ai_feedback",{$ai_trace_id:String(e),$ai_feedback_text:t})}captureTraceMetric(e,t,n){this.capture("$ai_metric",{$ai_trace_id:String(e),$ai_metric_name:t,$ai_metric_value:String(n)})}}!function(e,t){for(var n=0;n{e.activeTabId=t.payload},showProgress:(e,t)=>{const{tabId:n,title:s,description:i,steps:a}=t.payload;e.tabProgress[n]||(e.tabProgress[n]={...Dd});const r=e.tabProgress[n];r.isVisible=!0,r.progress=0,r.title=s,r.description=i,r.error=void 0,r.steps=a,r.currentStep=a.findIndex(e=>"in_progress"===e.status)},updateProgress:(e,t)=>{const{tabId:n,progress:s}=t.payload;e.tabProgress[n]||(e.tabProgress[n]={...Dd});const i=e.tabProgress[n];i.progress=s,100===s&&(i.steps=i.steps.map(e=>({...e,status:"completed"})),i.currentStep=i.steps.length)},nextStep:(e,t)=>{const n=t.payload;e.tabProgress[n]||(e.tabProgress[n]={...Dd});const s=e.tabProgress[n];s.currentStep>=0&&s.currentStep{const n=t.payload;e.tabProgress[n]||(e.tabProgress[n]={...Dd});const s=e.tabProgress[n];s.steps=s.steps.map(e=>({...e,status:"completed"})),s.isVisible=!1,s.error=void 0,s.steps=[],s.currentStep=-1},setError:(e,t)=>{const{tabId:n,error:s}=t.payload;e.tabProgress[n]||(e.tabProgress[n]={...Dd});const i=e.tabProgress[n];i.error=s,i.isVisible=!0,i.progress=100,i.currentStep>=0&&i.currentStep{const n=t.payload;n&&(e.containers||(e.containers={}),e.containers[n]||(e.containers[n]={...Vd}),e.activeContainerId=n)},setInitialized:(e,t)=>{const{containerId:n,isInitialized:s}=t.payload;n&&(e.containers||(e.containers={}),e.containers[n]||(e.containers[n]={...Vd}),e.containers[n].isInitialized=s)},setJobPolling:(e,t)=>{const{containerId:n,value:s}=t.payload;e.containers[n]&&(e.containers[n].isJobPolling=s)},setJobDetails:(e,t)=>{const{containerId:n,details:s}=t.payload;e.containers[n]&&(e.containers[n].jobDetails=s)},setTrajectory:(e,t)=>{const{containerId:n,trajectory:s}=t.payload;e.containers[n]&&(e.containers[n].trajectory=s)},setLastProcessedStep:(e,t)=>{const{containerId:n,step:s}=t.payload;e.containers[n]&&(e.containers[n].lastProcessedStep=s)},setTaskState:(e,t)=>{const{containerId:n,taskState:s}=t.payload;e.containers[n]&&(e.containers[n].taskState=s)},updateTaskState:(e,t)=>{const{containerId:n,taskState:s}=t.payload;if(e.containers[n]){const t=e.containers[n];t.taskState=t.taskState?{...t.taskState,...s}:s}},resetContainer:(e,t)=>{const n=t.payload,{[n]:s,...i}=e.containers;e.containers=i,e.activeContainerId===n&&(e.activeContainerId=null)},resetAllContainers:e=>{e.containers={},e.activeContainerId=null,e.tabContainers={}},setTabContainer:(e,t)=>{const{tabId:n,containerId:s}=t.payload;e.tabContainers[n]=s},removeTabContainer:(e,t)=>{const n=t.payload;delete e.tabContainers[n]},setActiveContainerForTab:(e,t)=>{const n=t.payload,s=e.tabContainers[n];s&&(e.activeContainerId=s)}}}),{initializeContainer:Wd,setInitialized:qd,setJobPolling:Gd,setJobDetails:Zd,setTrajectory:Yd,setLastProcessedStep:Kd,setTaskState:Jd,updateTaskState:Qd,resetContainer:Xd,resetAllContainers:eu,setTabContainer:tu,removeTabContainer:nu,setActiveContainerForTab:su}=Ud.actions,iu=Ud.reducer,au=Ke({name:"commandQueue",initialState:{pendingCommands:{}},reducers:{enqueueCommand:(e,t)=>{const{commandId:n,type:s,payload:i}=t.payload;e.pendingCommands[n]&&"failed"!==e.pendingCommands[n].status||(e.pendingCommands[n]={status:"pending",command:{type:s,payload:i},timestamp:Date.now()})},setCommandStatus:(e,t)=>{const{commandId:n,status:s}=t.payload;e.pendingCommands[n]&&(e.pendingCommands[n].status=s)},removeCommand:(e,t)=>{delete e.pendingCommands[t.payload]}}}),{enqueueCommand:ru,setCommandStatus:ou,removeCommand:lu}=au.actions,cu=au.reducer,du=Ke({name:"tabs",initialState:{activeTab:"home",tabs:[{id:"home",title:"Home",path:"/"}],isActive:!0,tabStates:{}},reducers:{setActiveTab:(e,t)=>{e.activeTab=t.payload,e.isActive=!0,Object.keys(e.tabStates).forEach(n=>{e.tabStates[n]={...e.tabStates[n],isActive:n===t.payload}}),e.tabStates[t.payload]||(e.tabStates[t.payload]={isActive:!0,activeTab:t.payload})},setTabs:(e,t)=>{const n=t.payload.filter(e=>"/not-defined"!==e.path),s=t.payload.filter(e=>"/not-defined"===e.path);e.tabs=[...n,...s];const i=new Set(t.payload.map(e=>e.id));Object.keys(e.tabStates).forEach(t=>{if(!i.has(t)&&"home"!==t){const n=e.tabStates[t];(null==n?void 0:n.createAgentFormData)||(null==n?void 0:n.createSubagentFormData)||delete e.tabStates[t]}})},updateTabState:(e,t)=>{const{tabId:n,state:s}=t.payload,i=n in e.tabStates;e.tabStates[n]={...i?e.tabStates[n]:{status:!1,isCloudFlow:!0},...s}},removeTab:(e,t)=>{const n=t.payload;if(e.tabStates[n]){(e.tabStates[n].pendingArtifacts||[]).forEach(e=>{e.local_preview_url&&e.local_preview_url.startsWith("blob:")&&URL.revokeObjectURL(e.local_preview_url)})}e.tabs=e.tabs.filter(e=>e.id!==n),delete e.tabStates[n],e.activeTab===n&&(e.activeTab="home")},cleanupTabStates:e=>{const t=new Set(e.tabs.map(e=>e.id));Object.keys(e.tabStates).forEach(n=>{t.has(n)||"home"===n||delete e.tabStates[n]})},setPendingMessage:(e,t)=>{const{tabId:n,messageId:s,content:i,base64_image_list:a,artifacts:r}=t.payload;e.tabStates[n]||(e.tabStates[n]={}),e.tabStates[n].pendingMessage={id:s,content:i,timestamp:(new Date).toISOString().replace(/\.\d{3}Z$/,e=>e.replace("Z","000+00:00")),base64_image_list:a,artifacts:r}},clearPendingMessage:(e,t)=>{var n;const{tabId:s,content:i}=t.payload;if(e.tabStates[s]){if(i){const t=null==(n=e.tabStates[s])?void 0:n.pendingMessage;if(!t||t.content!==i)return}e.tabStates[s]={...e.tabStates[s],pendingMessage:void 0}}},removePendingMessage:(e,t)=>{var n;const{tabId:s,messageId:i,content:a}=t.payload;if(e.tabStates[s]){const t=null==(n=e.tabStates[s])?void 0:n.pendingMessage;t&&t.content===a&&(e.tabStates[s]={...e.tabStates[s],pendingMessage:void 0})}},addPendingArtifacts:(e,t)=>{const{tabId:n,artifacts:s}=t.payload;e.tabStates[n]||(e.tabStates[n]={});const i=e.tabStates[n].pendingArtifacts||[];e.tabStates[n].pendingArtifacts=[...i,...s]},clearPendingArtifacts:(e,t)=>{const{tabId:n}=t.payload;if(e.tabStates[n]){(e.tabStates[n].pendingArtifacts||[]).forEach(e=>{e.local_preview_url&&e.local_preview_url.startsWith("blob:")&&URL.revokeObjectURL(e.local_preview_url)}),e.tabStates[n].pendingArtifacts=[]}},removePendingArtifact:(e,t)=>{var n;const{tabId:s,artifactId:i}=t.payload;if(null==(n=e.tabStates[s])?void 0:n.pendingArtifacts){const t=e.tabStates[s].pendingArtifacts.find(e=>e.artifact_id===i);(null==t?void 0:t.local_preview_url)&&t.local_preview_url.startsWith("blob:")&&URL.revokeObjectURL(t.local_preview_url),e.tabStates[s].pendingArtifacts=e.tabStates[s].pendingArtifacts.filter(e=>e.artifact_id!==i)}},setChatInputText:(e,t)=>{const{tabId:n,text:s}=t.payload;e.tabStates[n]||(e.tabStates[n]={}),e.tabStates[n].chatInputText=s},clearChatInputText:(e,t)=>{const{tabId:n}=t.payload;e.tabStates[n]&&(e.tabStates[n].chatInputText="")},setCreateAgentFormData:(e,t)=>{const{tabId:n,formData:s}=t.payload;e.tabStates[n]||(e.tabStates[n]={}),e.tabStates[n].createAgentFormData=s},clearCreateAgentFormData:(e,t)=>{const{tabId:n}=t.payload;e.tabStates[n]&&delete e.tabStates[n].createAgentFormData},setCreateSubagentFormData:(e,t)=>{const{tabId:n,formData:s}=t.payload;e.tabStates[n]||(e.tabStates[n]={}),e.tabStates[n].createSubagentFormData=s},clearCreateSubagentFormData:(e,t)=>{const{tabId:n}=t.payload;e.tabStates[n]&&delete e.tabStates[n].createSubagentFormData},setTabDeployState:(e,t)=>{const{tabId:n,deployState:s}=t.payload;e.tabStates[n]||(e.tabStates[n]={}),e.tabStates[n].deployState||(e.tabStates[n].deployState={deployStatus:"not_deployed",latestRunStatus:null,loading:!1,deploymentSteps:[],deploymentHistory:[],currentStepIndex:-1,deployUrl:"",customDomainUrl:"",runId:"",errorMessage:null,modifiedEnvs:[],customDomain:null,deployLogs:[]}),e.tabStates[n].deployState={...e.tabStates[n].deployState,...s}},resetTabDeployState:(e,t)=>{const{tabId:n}=t.payload;e.tabStates[n]&&(e.tabStates[n].deployState={deployStatus:"not_deployed",latestRunStatus:null,loading:!1,deploymentSteps:[],deploymentHistory:[],currentStepIndex:-1,deployUrl:"",customDomainUrl:"",runId:"",errorMessage:null,modifiedEnvs:[],customDomain:null,deployLogs:[]})},updateHomeTabPath:(e,t)=>{const n=e.tabs.find(e=>"home"===e.id);n&&(n.path=t.payload)}}}),{setActiveTab:uu,setTabs:pu,updateTabState:mu,removeTab:hu,setPendingMessage:xu,clearPendingMessage:fu,removePendingMessage:gu,cleanupTabStates:vu,addPendingArtifacts:bu,clearPendingArtifacts:yu,removePendingArtifact:wu,setChatInputText:ju,clearChatInputText:Cu,setCreateAgentFormData:Nu,clearCreateAgentFormData:Fu,setCreateSubagentFormData:_u,clearCreateSubagentFormData:ku,setTabDeployState:Su,resetTabDeployState:Eu,updateHomeTabPath:Iu}=du.actions,Au=e=>e.tabs.activeTab,Tu=e=>e.tabs.tabs,Mu=(e,t)=>{var n;return(null==(n=e.tabs.tabStates[t])?void 0:n.pendingArtifacts)||[]},Du=e=>{const t=e.tabs.activeTab,n=e.tabs.tabs.find(e=>e.id===t);if(!n||!t){const t=e.tabs.tabs.find(e=>"home"===e.id);if(t)return t}return n||e.tabs.tabs[0]},Lu=du.reducer;function Pu(){try{const e=sessionStorage.getItem("persist:tabs");if(!e)return;const t=JSON.parse(e),n=JSON.parse(t.tabs||"[]"),s=JSON.parse(t.tabStates||"{}"),i=new Set(n.map(e=>e.id));let a=0;const r={};return Object.keys(s).forEach(e=>{i.has(e)||"home"===e?r[e]=s[e]:a++}),t.tabStates=JSON.stringify(r),sessionStorage.setItem("persist:tabs",JSON.stringify(t)),a}catch(e){return 0}}const Ru="emergent_modal_states";function Ou(){try{const e=localStorage.getItem(Ru);return e?JSON.parse(e):{}}catch(e){return{}}}function zu(e,t){try{const n={...Ou(),[e]:t};localStorage.setItem(Ru,JSON.stringify(n))}catch(n){}}function Bu(e,t=!1){return Ou()[e]??t}function Hu(){return Bu("hasSeenExpoUpgradePopover",!1)}const $u="emergent_invitation_states";function Vu(e){try{const t=localStorage.getItem($u),n=t?JSON.parse(t):{};n[e]=!0,localStorage.setItem($u,JSON.stringify(n))}catch(t){}}function Uu(e){try{const t=localStorage.getItem($u),n=t?JSON.parse(t):{};delete n[e],localStorage.setItem($u,JSON.stringify(n))}catch(t){}}function Wu(){zu("hasSeenClaude45AnnouncementModal",!0)}function qu(){zu("hasSeenModelSelectorTooltip",!0)}function Gu(){zu("hasSeenTeamIntroductionModal",!0)}function Zu(){zu("hasSeenUltraThinkingModal",!0)}function Yu(){zu("hasSeenStandardDiscountModal",!0)}function Ku(){zu("hasSeenMCPIntroductionModal",!0)}function Ju(){zu("hasSeenBroModeIntroductionModal",!0)}function Qu(){return Bu("hasSeenVisualEditsModal",!1)}function Xu(){zu("hasSeenVisualEditsModal",!0)}function ep(){zu("hasSeenModelSelectorTooltip",!1)}function tp(){zu("25milmodal",!0)}function np(){try{const e=ip(),t=ap();localStorage.clear(),rp(e),op(t)}catch(e){localStorage.clear()}}function sp(){try{const e=ip(),t=ap();localStorage.clear(),sessionStorage.clear(),rp(e),op(t)}catch(e){localStorage.clear(),sessionStorage.clear()}}function ip(){try{return Ou()}catch(e){return null}}function ap(){try{const e={};return["utm_source","utm_medium","utm_campaign","utm_content","utm_term","campaign_id","utm_id","gclid","gad_source","gad_campaignid","gbraid","wbraid","fbclid","fbc","fbp","ttclid","li_fat_id","twclid","sc_click_id","epik","rdt_cid","msclkid","amznclickid","user_referrer","first_login_completed","pending_referral_code","referral_applied","referral_modal_data"].forEach(t=>{const n=localStorage.getItem(t);null!==n&&(e[t]=n)}),Object.keys(e).length>0?e:null}catch(e){return null}}function rp(e){if(e)try{localStorage.setItem(Ru,JSON.stringify(e))}catch(t){}}function op(e){if(e)try{Object.entries(e).forEach(([e,t])=>{void 0!==t&&localStorage.setItem(e,t)})}catch(t){}}"undefined"!=typeof window&&(window.resetFeatureModal=function(){zu("hasSeenFeatureModal",!1)},window.resetForkIntro=function(){zu("hasSeenForkIntro",!1)},window.resetMobileAgentIntro=function(){zu("hasSeenMobileAgentIntro",!1)},window.resetProIntroductionModal=function(){zu("hasSeenProIntroductionModal",!1)},window.resetUniversalKeyIntroTooltip=function(){zu("hasSeenUniversalKeyIntroTooltip",!1)},window.resetOneMillionModal=function(){zu("hasSeenClaude45AnnouncementModal",!1)},window.resetModelSelectorTooltip=ep,window.resetTeamIntroductionModal=function(){zu("hasSeenTeamIntroductionModal",!1)},window.resetUltraThinkingModal=function(){zu("hasSeenUltraThinkingModal",!1)},window.resetStandardDiscountModal=function(){zu("hasSeenStandardDiscountModal",!1)},window.resetMCPIntroductionModal=function(){zu("hasSeenMCPIntroductionModal",!1)},window.resetBroModeIntroductionModal=function(){zu("hasSeenBroModeIntroductionModal",!1)},window.resetTestModeModal=function(){zu("hasSeenTestModeModal",!1)},window.resetLockinPriceModal=function(){zu("hasSeenLockinPriceModal",!1)},window.resetBuyCreditsAutoPopup=function(){zu("hasSeenBuyCreditsAutoPopup",!1)},window.resetFundingIntroductionModal=function(){zu("25milmodal",!1)},window.resetVisualEditsModal=function(){zu("hasSeenVisualEditsModal",!1)},window.resetAllModals=function(){try{localStorage.removeItem(Ru)}catch(e){}},window.clearStorageSafely=np,window.clearAllStorageSafely=sp,window.preserveTrackingData=ap,window.restoreTrackingData=op);const lp="cjId",cp=()=>{if("undefined"!=typeof window)try{const e=document.cookie.split(";");for(let t of e){const[e,n]=t.trim().split("=");if(e===lp)return decodeURIComponent(n)}}catch(e){}},dp=(e,t)=>{if("undefined"!=typeof window&&window.dataLayer){const n=cp(),s={event:e,...t,timestamp:(new Date).toISOString(),...n&&{cj_event_id:n}};window.dataLayer.push(s)}},up=(e,t,n,s)=>{const i=localStorage.getItem("utm_source")||void 0,a=localStorage.getItem("utm_campaign")||void 0,r=localStorage.getItem("utm_medium")||void 0,o=localStorage.getItem("utm_content")||void 0,l=localStorage.getItem("utm_term")||void 0,c=localStorage.getItem("user_referrer")||void 0,d=new URLSearchParams(window.location.search),u=d.get("referral")||d.get("ref")||void 0;dp("sign_up",{method:e,user_id:t,user_email:n,utm_source:i,utm_campaign:a,utm_medium:r,utm_content:o,utm_term:l,referrer:c,referral_code:u,signup_page:window.location.pathname,signup_url:window.location.href,...s})},pp=(e,t,n,s,i,a,r,o)=>{const l=localStorage.getItem("utm_source")||void 0,c=localStorage.getItem("utm_campaign")||void 0,d=localStorage.getItem("utm_medium")||void 0,u=localStorage.getItem("utm_term")||void 0,p=localStorage.getItem("utm_content")||void 0,m=localStorage.getItem("referral_code")||void 0;dp("upgrade_intent",{user_id:e,current_tier:t||"free",target_tier:n,billing_period:s,is_organization:i,organization_id:a||void 0,trigger_location:r||"upgrade_modal",utm_source:l,utm_campaign:c,utm_medium:d,utm_term:u,utm_content:p,referral_code:m,currency:o||"USD",intent_date:(new Date).toISOString()})},mp=(e,t,n,s,i,a,r,o,l,c)=>{const d=localStorage.getItem("utm_source")||void 0,u=localStorage.getItem("utm_campaign")||void 0,p=localStorage.getItem("utm_medium")||void 0,m=localStorage.getItem("utm_term")||void 0,h=localStorage.getItem("utm_content")||void 0,x=localStorage.getItem("referral_code")||void 0;dp("subscription_success",{user_id:e,plan_name:t,tier_name:n,credits_per_month:s,billing_period:i||"monthly",is_organization:a||!1,organization_id:r||void 0,organization_name:o||void 0,payment_id:l||void 0,is_razorpay_flow:Boolean(c),utm_source:d,utm_campaign:u,utm_medium:p,utm_term:m,utm_content:h,referral_code:x,subscription_date:(new Date).toISOString()})},hp=(e,t,n,s)=>{if("undefined"!=typeof window)try{const i={amount:t,currency:n,category:s,timestamp:Date.now()};sessionStorage.setItem(`payment_details_${e}`,JSON.stringify(i))}catch(i){}},xp=e=>{if("undefined"==typeof window)return null;try{const t=sessionStorage.getItem(`payment_details_${e}`);if(!t)return null;const n=JSON.parse(t);return Date.now()-n.timestamp>864e5?(sessionStorage.removeItem(`payment_details_${e}`),null):n}catch(t){return null}},fp=e=>{if("undefined"!=typeof window)try{sessionStorage.removeItem(`payment_details_${e}`)}catch(t){}},gp=(e,t,n,s="USD",i="credits")=>{if("undefined"!=typeof window)try{if(!Number.isFinite(n)||n<=0)return;const a=(null==s?void 0:s.toUpperCase())||"USD",r=cp(),o="";window.cj||(window.cj={}),window.cj.order={enterpriseId:1592779,pageType:"conversionConfirmation",userId:e,emailHash:o,orderId:t,actionTrackerId:501794,currency:a,amount:n,category:i,cjeventOrder:r||""};if(document.getElementById("cjapitag"))return void dp("cj_conversion_tracked",{order_id:t,amount:n,currency:a,category:i,cj_event_id:r});const l=document.createElement("script");l.type="text/javascript",l.async=!0,l.id="cjapitag",l.src="https://api.emergent.sh/proxydirectory/tags/1171454318801/tag.js",l.onload=()=>{dp("cj_conversion_tracked",{order_id:t,amount:n,currency:a,category:i,cj_event_id:r})},l.onerror=()=>{};const c=document.getElementsByTagName("script")[0];c&&c.parentNode?c.parentNode.insertBefore(l,c):document.head.appendChild(l)}catch(a){}},vp=()=>!("undefined"==typeof window||!window.electron),bp={listContainers:async()=>await window.electron.ipcRenderer.invoke("docker:list-containers"),listImages:async()=>await window.electron.ipcRenderer.invoke("docker:list-images"),executeCommand:async(e,t)=>await window.electron.ipcRenderer.invoke("docker:execute-command",{command:t,containerId:e}),createContainer:async(e,t,n,s,i)=>await window.electron.ipcRenderer.invoke("docker:create-container",{image:e,containerName:t,portMappings:n,volumePath:s,copyToApp:i}),pullImage:async(e,t)=>{if(t){const e=()=>{window.electron.ipcRenderer.removeAllListeners("docker:pull-progress")};window.electron.ipcRenderer.on("docker:pull-progress",n=>{if(n&&"object"==typeof n){const s={layer:n.layer||"",progress:"number"==typeof n.progress?n.progress:0,status:n.status||"downloading",error:n.error||void 0};t(s),"finished"!==s.status&&"error"!==s.status||e()}})}try{return await window.electron.ipcRenderer.invoke("docker:pull-image",{image:e})}catch(n){throw t&&window.electron.ipcRenderer.removeAllListeners("docker:pull-progress"),n}},cloneRepository:async(e,t,n)=>await window.electron.ipcRenderer.invoke("git:clone",{repoUrl:e,targetPath:t,branch:n}),getProjectPath:async e=>await window.electron.ipcRenderer.invoke("path:get-project-path",e),openTerminal:async e=>await window.electron.ipcRenderer.invoke("terminal:open",{containerId:e}),removeContainer:async e=>await window.electron.ipcRenderer.invoke("docker:remove-container",{containerId:e}),checkPorts:async e=>await window.electron.ipcRenderer.invoke("check-ports",e),writeFile:async(e,t)=>await window.electron.ipcRenderer.invoke("fs:write-file",{filePath:e,content:t}),showDirectoryPicker:async()=>window.electron.ipcRenderer.invoke("show-directory-picker"),showInputDialog:async e=>window.electron.ipcRenderer.invoke("show-input-dialog",e),commitContainer:async e=>await window.electron.ipcRenderer.invoke("docker:commit-container",{containerId:e}),copyToHost:async(e,t)=>await window.electron.ipcRenderer.invoke("docker:copy-to-host",{containerId:e,hostDir:t}),generateRandomPorts:async e=>await window.electron.ipcRenderer.invoke("docker:generate-random-ports",{count:e}),isDockerInstalled:()=>window.electron.ipcRenderer.invoke("docker:is-installed"),isDockerRunning:()=>window.electron.ipcRenderer.invoke("docker:is-running"),startDocker:()=>window.electron.ipcRenderer.invoke("open-docker-app"),executeNeonAction:async(e,t)=>await window.electron.ipcRenderer.invoke("neon:execute",{containerId:e,config:t}),generateNeonScript:(e,t)=>window.electron.ipcRenderer.invoke("neon:generate-script",e,t),getDefaultWorkspaceDir:()=>window.electron.ipcRenderer.invoke("neon:get-default-workspace-dir"),getGitStatus:async(e,t)=>{const n=await window.electron.ipcRenderer.invoke("git:get-status",{containerId:e,initialCommitId:t});if(n.error)throw new Error(n.error);return n.output&&""!==n.output.trim()?n.output.trim().split("\n").filter(e=>""!==e.trim()).map(e=>{const[t,n]=e.split("\t");return{fileName:n||"",status:t||""}}).filter(e=>e.fileName&&""!==e.fileName.trim()):[]},getGitDiff:async(e,t,n)=>{const s=await window.electron.ipcRenderer.invoke("git:get-diff",{containerId:e,fileName:t,initialCommitId:n});if(s.error)throw new Error(s.error);return s.output},checkDockerAvailability:()=>window.electron.ipcRenderer.invoke("docker:check-availability"),checkForUpdates:async()=>await window.electron.ipcRenderer.invoke("update:check"),downloadUpdate:async()=>await window.electron.ipcRenderer.invoke("update:download"),quitAndInstall:async()=>await window.electron.ipcRenderer.invoke("update:quit-and-install"),setSentryUser:async e=>await window.electron.ipcRenderer.invoke("sentry:setUser",e),openExternal:e=>{(e=>{vp()?window.electron.openExternal(e):window.open(e,"_blank")})(e)},initiateGitHubAuth:async()=>await window.electron.ipcRenderer.invoke("github:initiate-auth"),getGitHubRepositories:()=>window.electron.ipcRenderer.invoke("github:repositories")};function yp(e,t,n=30,s="/"){try{const i=new Date;i.setTime(i.getTime()+24*n*60*60*1e3);const a=`expires=${i.toUTCString()}`,r=encodeURIComponent(t);document.cookie=`${e}=${r};${a};path=${s};SameSite=Lax`}catch(i){}}function wp(e){try{const t=e+"=",n=document.cookie.split(";");for(let e=0;en.add(e))}catch{}const i=e.get("fbclid");if(i&&!wp("_fbc")){const e=function(e){try{if(!e)return null;const t=window.location.hostname;let n=0;if(t.includes(".")){const e=t.split(".");e.length>=2&&(n=e.length-1)}const s=Date.now();return`fb.${n}.${s}.${e}`}catch(t){return null}}(i);e&&(yp("_fbc",e,t),n.add("_fbc"))}e.forEach((e,s)=>{null!=e&&""!==e&&(yp(s,e,t),n.add(s))}),yp(jp,JSON.stringify(Array.from(n)),t)}catch(n){}}function Np(e){try{const t=JSON.parse(e);return"object"==typeof t&&null!==t?t:e}catch{return e}}function Fp(){const e={app_version:"1.0.32"},t=["_fbp","_fcp","_ttp","_fbc"],n=wp(jp);if(n)try{return JSON.parse(n).forEach(t=>{const n=wp(t);n&&(e[t]=Np(n))}),t.forEach(t=>{const n=wp(t);if(n){const s=t.startsWith("_")?t.substring(1):t;e[s]=Np(n)}}),e}catch{}const s=function(){try{const e={},t=document.cookie.split(";");for(let n=0;n0){const t=s.substring(0,i),n=s.substring(i+1);e[t]=decodeURIComponent(n)}}return e}catch(e){return{}}}();return Object.entries(s).forEach(([t,n])=>{const s=t.toLowerCase();s.includes("session")||s.includes("token")||s.startsWith("sb-")||(e[t]=Np(n))}),t.forEach(t=>{const n=wp(t);if(n){const s=t.startsWith("_")?t.substring(1):t;e[s]=Np(n)}}),e}let _p=function(e){const t=Rt.create({baseURL:e,headers:{"Content-Type":"application/json"}});return t.interceptors.request.use(async e=>{const{data:{session:t}}=await en.auth.getSession();return(null==t?void 0:t.access_token)&&(e.headers.Authorization=`Bearer ${t.access_token}`),e}),t.interceptors.request.use(e=>e),t.interceptors.response.use(e=>e,async e=>{var t;if(401===(null==(t=e.response)?void 0:t.status)&&"/login"!==window.location.pathname)try{Pu(),dg.dispatch(pu([{id:"home",title:"Home",path:"/"}])),dg.dispatch(uu("home")),dg.dispatch(vu()),sp(),window.location.href="/login"}catch(n){sp(),window.location.href="/login"}return Promise.reject(e)}),t}(Yt.apiBaseUrl);const kp=async e=>_p.get(`/jobs/v0/${e}/`),Sp=e=>_p.post("/actions/pause/",{job_id:e.job_id,agent_type:e.agent_name}),Ep=async e=>{const t=await _p.get(`/budget/${e}`);if(!t.data.success)throw new Error(t.data.data.error);return t.data.data},Ip=async(e,t)=>{const n=await _p.put(`/budget/${e}`,{amount:t});if(!n.data.success)throw new Error(n.data.data.error);return n.data.data},Ap=async(e,t,n=!1,s)=>{try{const i={client_ref_id:t,payload:{processor_type:"env_only",is_cloud:!0,env_image:e.env_image,branch:"",repository:"",...e,...e.testMode&&{test_mode_on:"true"}},model_name:e.model_name,resume:n},a=Fp();if((null==e?void 0:e.organization_id)&&(i.organization_id=e.organization_id),i.ads_metadata=a,s&&(i.finalize_artifact_upload=s),n&&(i.id=t),!t)throw new Error("Either job_id or client_ref_id must be provided");return(await _p.post("/jobs/v0/submit-queue/",i)).data}catch(i){throw i}},Tp=async(e,t,n=!1,s)=>{try{const i={client_ref_id:t,payload:{processor_type:"env_only",is_cloud:!0,env_image:e.env_image,branch:"",repository:"",...e,...e.testMode&&{test_mode_on:"true"}},model_name:e.model_name,resume:n},a=Fp();if((null==e?void 0:e.organization_id)&&(i.organization_id=e.organization_id),i.ads_metadata=a,s&&(i.finalize_artifact_upload=s),n&&(i.id=t),!t)throw new Error("Either job_id or client_ref_id must be provided");return(await _p.post("/jobs/v0/chat/preview",i)).data}catch(i){throw i}},Mp=async(e,t,n)=>_p.get(`/jobs/v0/diff/${e}`,{params:{file_path:t||"",initial_commit_id:n||""}}),Dp=async(e,t,n="EmergentAssistant",s="all",i=!1)=>{try{const a={job_id:e,request_id:t,base_url:Yt.apiBaseUrl,agent_name:n};"messages"===s&&(a.checkout=!1),"all"===s&&(a.checkout=!0),i&&(a.retry=!0);return(await _p.post("/jobs/v0/rollback/cloud/",a)).data}catch(a){throw a}},Lp=async()=>{try{const e=Fp(),t=Object.keys(e).length>0?{ads_metadata:e}:{};return(await _p.post("/user/details",t)).data}catch(e){return{id:null,github_installations:[],error:e.message}}},Pp=async(e,t,n)=>{var s,i,a;const r=new URLSearchParams;r.append("job_id",e),t&&r.append("last_request_id",t);const o=`${Yt.apiBaseUrl}/trajectories/v0/stream?${r.toString()}`;try{const e=await _p.get(o,{headers:{Accept:"text/event-stream","Cache-Control":"no-cache"},responseType:"stream",adapter:"fetch"});if(!e.data)throw new Error("Failed to fetch trajectory: No data returned");const t=e.data.getReader();if(!t)throw new Error("Stream reader could not be created");let r={trajectories:{data:[],updated_data:[],agent_status:!1,chat_mode:null}},c="";for(;;){const{done:e,value:o}=await t.read();if(e){if(c.trim())try{const e=c.split("\n");for(const t of e)if(t.startsWith("data: ")){const e=t.substring(6),n=JSON.parse(e);(null==(s=n.trajectories)?void 0:s.data)&&(r=n)}}catch(l){}break}c+=(new TextDecoder).decode(o);const d=c.split("\n");c=d.pop()||"";for(const t of d)if(t.startsWith("data: "))try{const e=t.substring(6),s=JSON.parse(e);if((null==(i=s.trajectories)?void 0:i.data)&&(null==n?void 0:n.onTrajectoryResult)&&(null==n?void 0:n.cache)){const e=s.trajectories.data.sort((e,t)=>new Date(e.created_at).getTime()-new Date(t.created_at).getTime()).map(e=>({...e.traj_payload,id:e.id,request_id:e.request_id,job_id:e.job_id,traj_payload:e.traj_payload,commit_id:e.commit_id,parent_request_id:e.parent_request_id,status:e.status,created_at:e.created_at,updated_at:e.updated_at})).filter(e=>{var t;const s=null==(t=null==n?void 0:n.cache)?void 0:t.current.trajectory.some(t=>t.id===e.id);return!s});e.length>0&&(null==n?void 0:n.cache)&&(null==n?void 0:n.onTrajectoryResult)&&(n.cache.current.trajectory=[...n.cache.current.trajectory,...e],n.onTrajectoryResult(n.cache.current.trajectory)),r=s}else(null==(a=s.trajectories)?void 0:a.data)&&(r=s);if(s.chunk&&(null==n?void 0:n.onCurrentChunkResult)&&(null==n?void 0:n.cache)){n.cache.current.trajectory.some(e=>e.request_id===s.chunk.request_id)&&s.chunk.completed?n.onCurrentChunkResult(""):n.onCurrentChunkResult(s)}}catch(l){}}return r}catch(l){throw l}},Rp=async(e,t)=>{try{return(await _p.post(`/api/v0/tim/${e}`,{message:t})).data}catch(n){throw n}},Op=async e=>{try{return(await _p.post("/actions/tim/",{job_id:e})).data}catch(t){throw t}},zp=async(e,t=!1,n,s,i="usd",a)=>{try{const r=Fp(),o={currency:i.toLowerCase(),metadata:{hostname:`${window.location.origin}/home`}};Object.keys(r).length>0&&(o.ads_metadata=r);const l=cp();l&&(o.cj_event_id=l),t&&n?(o.plan_id=n,o.mode="subscription"):o.amount=e;const c=(()=>{var e;try{return null==(e=null==window?void 0:window.Rewardful)?void 0:e.referral}catch(t){return}})();c&&(o.client_reference_id=c),s&&(o.organization_id=s),a&&(o.coupon_name=a);const d=await _p.post("/payments/checkout-sessions",o);if(!d.data.sessionId||!d.data.url)throw new Error("Invalid response from checkout session creation");return d.data}catch(r){throw r}},Bp=async(e,t)=>{try{const n=t?{organization_id:t}:{};return(await _p.get(`/payments/${e}/status`,{params:n})).data}catch(n){throw n}},Hp=async()=>{try{return(await _p.get("/payments/manage-subscription")).data}catch(e){throw e}},$p=async e=>{try{return(await _p.post("/payments/subscription/cancel",{user_subscription_id:e})).data}catch(t){throw t}},Vp=async e=>{try{const t=`/llm-proxy/query/request_id/${e}`;return(await _p.get(t)).data}catch(t){throw t}},Up=async e=>{try{return(await _p.post(`/jobs/v0/${e}/clone-environment`)).data}catch(t){throw t}},Wp=async e=>{try{return(await _p.get(`/chat-history/v0/${e}`,{timeout:12e5})).data}catch(t){throw t}},qp=async(e,t)=>{try{return(await _p.patch(`/chat-history/v0/${e}`,t)).data}catch(n){throw n}},Gp=async(e,t,n,s,i)=>{try{return(await _p.post("/jobs/v0/deploy",{job_id:e,image:t,deployment_id:n,acknowledgements:s,is_database_persist:i})).data}catch(a){if(a.response&&a.response.data)throw new Error(a.response.data.detail||a.response.data.error||"Failed to deploy app");throw a}},Zp=async e=>{try{return(await _p.get(`/jobs/v0/deploy/${e}/latest`)).data}catch(t){if(t.response&&t.response.data)throw new Error(t.response.data.detail||t.response.data.error||"Failed to deploy app");throw t}},Yp=async(e,t)=>{try{const n=t?{organization_id:t}:{};return(await _p.get(`/jobs/v0/deploy/${e}/precheck`,{params:n})).data}catch(n){if(n.response&&n.response.data)throw new Error(n.response.data.detail||n.response.data.error||"Failed to get warning information");throw n}},Kp=async e=>{try{return(await _p.get(`/jobs/v0/deploy/${e}/logs`)).data}catch(t){if(t.response&&t.response.data)throw new Error(t.response.data.detail||t.response.data.error||"Failed to get deploy logs");throw t}},Jp=async e=>{try{return(await _p.get(`/jobs/v0/deploy/${e}/history`)).data}catch(t){if(t.response&&t.response.data)throw new Error(t.response.data.detail||t.response.data.error||"Failed to deploy app");throw t}},Qp=async e=>{try{return(await _p.get(`/jobs/v0/deploy/${e}/envs`)).data}catch(t){if(t.response&&t.response.data)throw new Error(t.response.data.detail||t.response.data.error||"Failed to deploy app");throw t}},Xp=async e=>{try{return(await _p.delete(`/jobs/v0/deploy/${e}`)).data}catch(t){if(t.response&&t.response.data)throw new Error(t.response.data.detail||t.response.data.error||"Failed to deploy app");throw t}},em=async(e,t)=>{try{return(await _p.post("/jobs/v0/domains/register",{domain:e,job_id:t})).data}catch(n){if(n.response&&n.response.data)throw new Error(n.response.data.detail||n.response.data.error||"Failed to register domain");throw n}},tm=async(e,t)=>{try{return(await _p.post("/jobs/v0/domains/verify",{domain:e,job_id:t})).data}catch(n){if(n.response&&n.response.data)throw new Error(n.response.data.detail||n.response.data.error||"Failed to verify domain");throw n}},nm=async e=>{try{return(await _p.get(`/jobs/v0/domains/status?domain=${encodeURIComponent(e)}`)).data}catch(t){if(t.response&&t.response.data)throw new Error(t.response.data.detail||t.response.data.error||"Failed to get domain status");throw t}},sm=async e=>{try{const t=e?{organization_id:e}:{};return(await _p.get("/jobs/v0/deployments",{params:t})).data}catch(t){return{error:t.message}}},im=async e=>{try{return(await _p.post(`/jobs/v0/${e}/summary`)).data}catch(t){throw t.response&&t.response.data,t}},am=async e=>{try{return(await _p.get(`/jobs/v0/${e}/summary`)).data}catch(t){throw t.response&&t.response.data,t}},rm=async(e,t)=>{try{return(await _p.post(`/jobs/v0/${e}/fork-environment`,t)).data}catch(n){if(n.response&&n.response.data)throw new Error(n.response.data.detail||n.response.data.error||"Failed to submit fork");throw n}},om=async(e,t)=>{try{return(await _p.post(`/artifacts/job/${e}/upload`,t)).data}catch(n){throw n}},lm=async(e,t)=>{try{await fetch(e,{method:"PUT",body:t,headers:{"Content-Type":t.type}})}catch(n){throw n}},cm=async e=>{try{return(await _p.get(`/artifacts/job/${e}`)).data}catch(t){throw t}},dm=async e=>{try{await _p.delete(`/artifacts/${e}`)}catch(t){throw t}},um=async e=>{try{return(await _p.post(`/artifacts/${e}/download-url`)).data}catch(t){throw t}},pm=async(e,t)=>{try{await _p.post(`/artifacts/${e}/finalize-upload`,t)}catch(n){throw n}},mm=async e=>{try{await _p.post("/artifacts/finalize-upload",e)}catch(t){throw t}},hm=async(e,t)=>{try{return(await _p.get(`/jobs/v0/${e}/artifact/${t}/get_test_cases`)).data}catch(n){throw n}},xm=async()=>{try{return(await _p.get("/jobs/v0/entri/info")).data}catch(e){throw e}},fm=async()=>{try{return(await _p.post("/user/cohort")).data}catch(e){throw e}},gm=async(e,t)=>{try{return(await _p.post(`/rrweb/extract/${e}`,{events:t})).data}catch(n){throw n}},vm=Je("deploy/checkDeployStatus",async({jobId:e,silent:t=!1},{getState:n,rejectWithValue:s})=>{if(!e)return s("No job ID provided");const i=n(),a=Date.now(),r=a-i.deploy.lastCheckedTimestamp,o="running"===i.deploy.deployStatus&&r<3e4;if(r<15e3&&t&&!o)return s("Rate limited");if(r<1e3&&!t)return s("Rate limited");try{const t=await Zp(e);if(!t||"object"!=typeof t)throw new Error("Invalid response format");if(!t.status)throw new Error("Missing status in response");return{response:t,timestamp:a,prevStatus:i.deploy.deployStatus}}catch(l){let e="Failed to get deployment status";return l.response&&l.response.data?l.response.data.detail?e=l.response.data.detail:l.response.data.message?e=l.response.data.message:l.response.data.error&&(e=l.response.data.error):l.message&&(e=l.message),l.response&&l.response.status>=400&&!t&&dn({title:"Deployment Error",description:e,variant:"destructive",duration:2e3}),s(e)}}),bm=Je("deploy/deployApp",async({jobId:e,image:t,deployment_id:n,acknowledgements:s,db_mode:i},{rejectWithValue:a})=>{if(!e)return a("No job ID provided");try{return await Gp(e,t,n,s,i),{jobId:e}}catch(r){let e="Failed to deploy application";return r.response&&r.response.data?r.response.data.detail?e=r.response.data.detail:r.response.data.message?e=r.response.data.message:r.response.data.error&&(e=r.response.data.error):r.message&&(e=r.message),dn({title:"Deployment Error",description:e.includes("deploy in progress")?"A deployment is currently in progress. Please wait for it to complete before starting a new one.":e.includes("max apps per user reached: 5 active apps")?"You’ve reached the maximum limit of 5 active deployments. To deploy a new app, please shut down one of your existing deployments.":e,variant:"destructive",duration:5e3}),a(e)}}),ym=Je("deploy/getDeployLogs",async(e,{rejectWithValue:t})=>{if(!e)return t("No job ID provided");try{const t=await Kp(e),n=[];return t&&(t.build&&Array.isArray(t.build)&&t.build.forEach(e=>{e&&e.trim()&&n.push(e)}),t.manage_secrets&&Array.isArray(t.manage_secrets)&&t.manage_secrets.forEach(e=>{e&&e.trim()&&n.push(e)}),t.mongodb_migrate&&Array.isArray(t.mongodb_migrate)&&t.mongodb_migrate.forEach(e=>{e&&e.trim()&&n.push(e)}),t.deploy&&Array.isArray(t.deploy)&&t.deploy.forEach(e=>{e&&e.trim()&&n.push(e)}),t.health_check&&Array.isArray(t.health_check)&&t.health_check.forEach(e=>{e&&e.trim()&&n.push(e)})),n}catch(n){return t("Failed to fetch deploy logs")}}),wm=Je("deploy/loadDeploymentHistory",async(e,{rejectWithValue:t})=>{if(!e)return t("No job ID provided");try{const t=await Jp(e);return t&&t.runs&&Array.isArray(t.runs)?t.runs:[]}catch(n){return t("Failed to load deployment history")}}),jm=Je("deploy/shutDownDeployment",async(e,{rejectWithValue:t})=>{if(!e)return t("No job ID provided");try{return await Xp(e),{jobId:e}}catch(n){let e="Failed to shut down deployment";return n.response&&n.response.data?n.response.data.detail?e=n.response.data.detail:n.response.data.message?e=n.response.data.message:n.response.data.error&&(e=n.response.data.error):n.message&&(e=n.message),dn({title:"Shutdown Error",description:e,variant:"destructive",duration:2e3}),t(e)}}),Cm=Je("deploy/loadEnvironmentVariables",async(e,{getState:t,rejectWithValue:n})=>{if(!e)return n("No job ID provided");try{const n=t();if(n.deploy.modifiedEnvs&&n.deploy.modifiedEnvs.length>0)return n.deploy.modifiedEnvs;const s=await Qp(e);if(s&&s.envs){return Object.entries(s.envs).map(([e,t],n)=>({id:`env-${n}`,key:e,value:t,originalValue:t,version:0}))}return[]}catch(s){return n("Failed to load environment variables")}}),Nm=Ke({name:"deploy",initialState:{deployStatus:"not_deployed",latestRunStatus:null,loading:!1,deploymentSteps:[],deploymentHistory:[],currentStepIndex:-1,deployUrl:"",customDomainUrl:"",runId:"",currentJobId:null,errorMessage:null,activeTabId:"",modifiedEnvs:[],lastCheckedTimestamp:0,customDomain:null,deployLogs:[]},reducers:{setActiveTabId:(e,t)=>{e.activeTabId=t.payload},saveEnvironmentVariables:(e,t)=>{e.modifiedEnvs=t.payload},resetDeployState:e=>{e.deployStatus="not_deployed",e.latestRunStatus=null,e.deploymentSteps=[],e.currentStepIndex=-1,e.deployUrl="",e.customDomainUrl="",e.runId="",e.errorMessage=null,e.customDomain=null},resetDeploymentSteps:e=>{e.deploymentSteps=[],e.currentStepIndex=-1},setCurrentJobId:(e,t)=>{e.currentJobId=t.payload},setCustomDomain:(e,t)=>{e.customDomain=t.payload}},extraReducers:e=>{e.addCase(vm.pending,(e,t)=>{t.meta.arg.silent||(e.loading=!0)}),e.addCase(vm.fulfilled,(e,t)=>{const{response:n,timestamp:s,prevStatus:i}=t.payload;e.lastCheckedTimestamp=s;let a=n.status;if(n.latest_run&&"running"===n.latest_run.status?a="running":n.latest_run&&n.latest_run.status&&"success"===n.status&&(a=n.latest_run.status),e.deployStatus,e.deployStatus=a,n.latest_run&&(e.latestRunStatus=n.latest_run.status),n.deploy_url&&(e.deployUrl=n.deploy_url),n.custom_domain)if(""!==n.custom_domain.domain&&n.custom_domain.status&&n.custom_domain.dns_records)if(e.customDomain={domain:n.custom_domain.domain,status:n.custom_domain.status,dns_records:Array.isArray(n.custom_domain.dns_records)?n.custom_domain.dns_records:[n.custom_domain.dns_records]},"verified"===n.custom_domain.status){const t=n.custom_domain.domain;e.customDomainUrl=t.startsWith("http")?t:`https://${t}`}else e.customDomainUrl="";else e.customDomain=null,e.customDomainUrl="";else e.customDomain=null,e.customDomainUrl="";if(n.latest_run&&n.latest_run.run_id&&"success"===n.latest_run.status?(e.runId=n.latest_run.run_id,n.latest_run.status&&(e.latestRunStatus=n.latest_run.status)):n.deployed_run_id&&(e.runId=n.deployed_run_id),n.latest_run&&n.latest_run.steps&&Array.isArray(n.latest_run.steps)){JSON.stringify(e.deploymentSteps)!==JSON.stringify(n.latest_run.steps)&&(e.deploymentSteps=n.latest_run.steps);let t=-1;if("running"===n.status&&n.latest_run.steps.every(e=>"pending"===e.status))t=0;else{const e=n.latest_run.steps.findIndex(e=>"running"===e.status);if(-1!==e)t=e;else{for(let e=0;e"pending"===e.status);-1!==e?t=e:"success"===n.status&&(t=n.latest_run.steps.length-1)}}}e.currentStepIndex=t}e.errorMessage=null,e.loading=!1}),e.addCase(vm.rejected,(e,t)=>{"Rate limited"!==t.payload&&(e.errorMessage=t.payload,e.deployStatus="not_deployed",e.latestRunStatus=null,e.deploymentSteps=[],e.currentStepIndex=-1,e.loading=!1)}),e.addCase(bm.pending,e=>{e.loading=!0,e.errorMessage=null}),e.addCase(bm.fulfilled,(e,t)=>{e.deployStatus="running",e.latestRunStatus="running",e.currentJobId=t.payload.jobId,e.loading=!1,e.deploymentSteps=[],e.currentStepIndex=-1}),e.addCase(bm.rejected,(e,t)=>{e.errorMessage=t.payload,e.deployStatus="not_deployed",e.latestRunStatus=null,e.loading=!1}),e.addCase(wm.pending,e=>{e.loading=!0}),e.addCase(wm.fulfilled,(e,t)=>{e.deploymentHistory=t.payload,e.loading=!1}),e.addCase(wm.rejected,e=>{e.loading=!1}),e.addCase(jm.pending,e=>{e.loading=!0}),e.addCase(jm.fulfilled,e=>{e.deployStatus="not_deployed",e.latestRunStatus=null,e.loading=!1,e.deploymentHistory=[],e.deployUrl="",e.customDomainUrl="",e.runId="",e.deploymentSteps=[],e.currentStepIndex=-1}),e.addCase(jm.rejected,e=>{e.loading=!1}),e.addCase(ym.pending,e=>{e.loading=!0}),e.addCase(ym.fulfilled,(e,t)=>{e.deployLogs=t.payload,e.loading=!1}),e.addCase(ym.rejected,e=>{e.loading=!1}),e.addCase(Cm.fulfilled,(e,t)=>{e.modifiedEnvs=t.payload})}}),{setActiveTabId:Fm,saveEnvironmentVariables:_m,resetDeployState:km,resetDeploymentSteps:Sm,setCurrentJobId:Em,setCustomDomain:Im}=Nm.actions,Am=Nm.reducer,Tm=e=>e.deploy.deployStatus,Mm=e=>e.deploy.latestRunStatus,Dm=e=>e.deploy.deploymentSteps,Lm=e=>e.deploy.deploymentHistory,Pm=e=>e.deploy.currentStepIndex,Rm=e=>e.deploy.deployUrl,Om=e=>e.deploy.customDomainUrl,zm=e=>e.deploy.runId,Bm=e=>e.deploy.currentJobId,Hm=e=>e.deploy.errorMessage,$m=e=>e.deploy.modifiedEnvs,Vm=e=>e.deploy.customDomain,Um=e=>e.deploy.deployLogs,Wm={isConnected:!1,isConnecting:!1,primaryAccount:null,installations:[],authWindowOpen:!1,lastConnectionCheck:0,connectionError:null},qm=Ke({name:"github",initialState:Wm,reducers:{setConnected:(e,t)=>{e.isConnected=t.payload,e.isConnecting=!1,e.connectionError=null,e.lastConnectionCheck=Date.now()},setConnecting:(e,t)=>{e.isConnecting=t.payload,t.payload&&(e.connectionError=null)},setConnectionError:(e,t)=>{e.connectionError=t.payload,e.isConnecting=!1},setPrimaryAccount:(e,t)=>{e.primaryAccount=t.payload},setInstallations:(e,t)=>{e.installations=t.payload,e.primaryAccount&&(e.installations=e.installations.map(t=>({...t,isPrimary:t.account_login===e.primaryAccount})))},setAuthWindowOpen:(e,t)=>{e.authWindowOpen=t.payload},resetGitHubState:()=>Wm,updateLastConnectionCheck:e=>{e.lastConnectionCheck=Date.now()}}}),{setConnected:Gm,setConnecting:Zm,setConnectionError:Ym,setPrimaryAccount:Km,setInstallations:Jm,setAuthWindowOpen:Qm,resetGitHubState:Xm,updateLastConnectionCheck:eh}=qm.actions,th=e=>e.github||Wm,nh=e=>{var t;return(null==(t=e.github)?void 0:t.isConnected)??!1},sh=e=>{var t;return Date.now()-((null==(t=e.github)?void 0:t.lastConnectionCheck)??0)>3e5},ih=qm.reducer;var ah=class extends Error{constructor(e){super(e[0].message),i(this,"issues"),this.name="SchemaError",this.issues=e}},rh=(e=>(e.uninitialized="uninitialized",e.pending="pending",e.fulfilled="fulfilled",e.rejected="rejected",e))(rh||{});function oh(e){return{status:e,isUninitialized:"uninitialized"===e,isLoading:"pending"===e,isSuccess:"fulfilled"===e,isError:"rejected"===e}}var lh=Qe;function ch(e,t){if(e===t||!(lh(e)&&lh(t)||Array.isArray(e)&&Array.isArray(t)))return t;const n=Object.keys(t),s=Object.keys(e);let i=n.length===s.length;const a=Array.isArray(t)?[]:{};for(const r of n)a[r]=ch(e[r],t[r]),i&&(i=e[r]===a[r]);return i?e:a}function dh(e){let t=0;for(const n in e)t++;return t}var uh=e=>[].concat(...e);function ph(e){return null!=e}function mh(e,t){if(!e)return t;if(!t)return e;if(function(e){return new RegExp("(^|:)//").test(e)}(t))return t;const n=e.endsWith("/")||!t.startsWith("?")?"/":"";return e=(e=>e.replace(/\/$/,""))(e),`${e}${n}${t=(e=>e.replace(/^\//,""))(t)}`}function hh(e,t,n){return e.has(t)?e.get(t):e.set(t,n(t)).get(t)}var xh=()=>new Map,fh=(...e)=>fetch(...e),gh=e=>e.status>=200&&e.status<=299,vh=e=>/ion\/(vnd\.api\+)?json/.test(e.get("content-type")||"");function bh(e){if(!Qe(e))return e;const t={...e};for(const[n,s]of Object.entries(t))void 0===s&&delete t[n];return t}function yh({baseUrl:e,prepareHeaders:t=e=>e,fetchFn:n=fh,paramsSerializer:s,isJsonContentType:i=vh,jsonContentType:a="application/json",jsonReplacer:r,timeout:o,responseHandler:l,validateStatus:c,...d}={}){return async(p,m,h)=>{const{getState:x,extra:f,endpoint:g,forced:v,type:b}=m;let y,w,{url:j,headers:C=new Headers(d.headers),params:N,responseHandler:F=l??"json",validateStatus:_=c??gh,timeout:k=o,...S}="string"==typeof p?{url:p}:p,E=m.signal;k&&(w=new AbortController,m.signal.addEventListener("abort",w.abort),E=w.signal);let I={...d,signal:E,...S};C=new Headers(bh(C)),I.headers=await t(C,{getState:x,arg:p,extra:f,endpoint:g,forced:v,type:b,extraOptions:h})||C;const A=e=>"object"==typeof e&&(Qe(e)||Array.isArray(e)||"function"==typeof e.toJSON);if(!I.headers.has("content-type")&&A(I.body)&&I.headers.set("content-type",a),A(I.body)&&i(I.headers)&&(I.body=JSON.stringify(I.body,r)),N){const e=~j.indexOf("?")?"&":"?";j+=e+(s?s(N):new URLSearchParams(bh(N)))}j=mh(e,j);const T=new Request(j,I);y={request:new Request(j,I)};let M,D=!1,L=w&&setTimeout(()=>{D=!0,w.abort()},k);try{M=await n(T)}catch(z){return{error:{status:D?"TIMEOUT_ERROR":"FETCH_ERROR",error:String(z)},meta:y}}finally{L&&clearTimeout(L),null==w||w.signal.removeEventListener("abort",w.abort)}const P=M.clone();let R;y.response=P;let O="";try{let e;if(await Promise.all([u(M,F).then(e=>R=e,t=>e=t),P.text().then(e=>O=e,()=>{})]),e)throw e}catch(z){return{error:{status:"PARSING_ERROR",originalStatus:M.status,data:O,error:String(z)},meta:y}}return _(M,R)?{data:R,meta:y}:{error:{status:M.status,data:R},meta:y}};async function u(e,t){if("function"==typeof t)return t(e);if("content-type"===t&&(t=i(e.headers)?"json":"text"),"json"===t){const t=await e.text();return t.length?JSON.parse(t):null}return e.text()}}var wh=class{constructor(e,t=void 0){this.value=e,this.meta=t}},jh=st("__rtkq/focused"),Ch=st("__rtkq/unfocused"),Nh=st("__rtkq/online"),Fh=st("__rtkq/offline");function _h(e){return"query"===e.type}function kh(e){return"infinitequery"===e.type}function Sh(e){return _h(e)||kh(e)}function Eh(e,t,n,s,i,a){return function(e){return"function"==typeof e}(e)?e(t,n,s,i).filter(ph).map(Ih).map(a):Array.isArray(e)?e.map(Ih).map(a):[]}function Ih(e){return"string"==typeof e?{type:e}:e}var Ah=Symbol("forceQueryFn"),Th=e=>"function"==typeof e[Ah];var Mh=class extends ah{constructor(e,t,n,s){super(e),this.value=t,this.schemaName=n,this._bqMeta=s}},Dh=(e,t)=>Array.isArray(e)?e.includes(t):!!e;async function Lh(e,t,n,s){const i=await e["~standard"].validate(t);if(i.issues)throw new Mh(i.issues,t,n,s);return i.value}function Ph(e){return e}var Rh=(e={})=>({...e,[pt]:!0});function Oh(e,{pages:t,pageParams:n},s){const i=t.length-1;return e.getNextPageParam(t[i],t,n[i],n,s)}function zh(e,{pages:t,pageParams:n},s){var i;return null==(i=e.getPreviousPageParam)?void 0:i.call(e,t[0],t,n[0],n,s)}function Bh(e,t,n,s){return Eh(n[e.meta.arg.endpointName][t],ct(e)?e.payload:void 0,lt(e)?e.payload:void 0,e.meta.arg.originalArgs,"baseQueryMeta"in e.meta?e.meta.baseQueryMeta:void 0,s)}function Hh(e,t,n){const s=e[t];s&&n(s)}function $h(e){return("arg"in e?e.arg.fixedCacheKey:e.fixedCacheKey)??e.requestId}function Vh(e,t,n){const s=e[$h(t)];s&&n(s)}var Uh={};var Wh=Symbol.for("RTKQ/skipToken"),qh={status:"uninitialized"},Gh=at(qh,()=>{}),Zh=at(qh,()=>{});var Yh=WeakMap?new WeakMap:void 0,Kh=({endpointName:e,queryArgs:t})=>{let n="";const s=null==Yh?void 0:Yh.get(t);if("string"==typeof s)n=s;else{const e=JSON.stringify(t,(e,t)=>(t="bigint"==typeof t?{$bigint:t.toString()}:t,t=Qe(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t));Qe(t)&&(null==Yh||Yh.set(t,e)),n=e}return`${e}(${n})`};function Jh(...e){return function(t){const n=Xe(e=>{var n;return null==(n=t.extractRehydrationInfo)?void 0:n.call(t,e,{reducerPath:t.reducerPath??"api"})}),s={reducerPath:"api",keepUnusedDataFor:60,refetchOnMountOrArgChange:!1,refetchOnFocus:!1,refetchOnReconnect:!1,invalidationBehavior:"delayed",...t,extractRehydrationInfo:n,serializeQueryArgs(e){let n=Kh;if("serializeQueryArgs"in e.endpointDefinition){const t=e.endpointDefinition.serializeQueryArgs;n=e=>{const n=t(e);return"string"==typeof n?n:Kh({...e,queryArgs:n})}}else t.serializeQueryArgs&&(n=t.serializeQueryArgs);return n(e)},tagTypes:[...t.tagTypes||[]]},i={endpointDefinitions:{},batch(e){e()},apiUid:et(),extractRehydrationInfo:n,hasRehydrationInfo:Xe(e=>null!=n(e))},a={injectEndpoints:function(e){const t=e.endpoints({query:e=>({...e,type:"query"}),mutation:e=>({...e,type:"mutation"}),infiniteQuery:e=>({...e,type:"infinitequery"})});for(const[n,s]of Object.entries(t))if(!0!==e.overrideExisting&&n in i.endpointDefinitions){if("throw"===e.overrideExisting)throw new Error(tt(39))}else{i.endpointDefinitions[n]=s;for(const e of r)e.injectEndpoint(n,s)}return a},enhanceEndpoints({addTagTypes:e,endpoints:t}){if(e)for(const n of e)s.tagTypes.includes(n)||s.tagTypes.push(n);if(t)for(const[n,s]of Object.entries(t))"function"==typeof s?s(i.endpointDefinitions[n]):Object.assign(i.endpointDefinitions[n]||{},s);return a}},r=e.map(e=>e.init(a,s,i));return a.injectEndpoints({endpoints:t.endpoints})}}function Qh(e,...t){return Object.assign(e,...t)}var Xh=({api:e,queryThunk:t,internalState:n,mwApi:s})=>{const i=`${e.reducerPath}/subscriptions`;let a=null,r=null;const{updateSubscriptionOptions:o,unsubscribeQueryResult:l}=e.internalActions,c=()=>n.currentSubscriptions,d={getSubscriptions:c,getSubscriptionCount:e=>{const t=c().get(e);return(null==t?void 0:t.size)??0},isRequestSubscribed:(e,t)=>{var n;const s=c();return!!(null==(n=null==s?void 0:s.get(e))?void 0:n.get(t))}};function u(e){return JSON.parse(JSON.stringify(Object.fromEntries([...e].map(([e,t])=>[e,Object.fromEntries(t)]))))}return(s,c)=>{if(a||(a=u(n.currentSubscriptions)),e.util.resetApiState.match(s))return a={},n.currentSubscriptions.clear(),r=null,[!0,!1];if(e.internalActions.internal_getRTKQSubscriptions.match(s))return[!1,d];const p=((n,s)=>{if(o.match(s)){const{queryCacheKey:e,requestId:t,options:i}=s.payload,a=n.get(e);return(null==a?void 0:a.has(t))&&a.set(t,i),!0}if(l.match(s)){const{queryCacheKey:e,requestId:t}=s.payload,i=n.get(e);return i&&i.delete(t),!0}if(e.internalActions.removeQueryResult.match(s))return n.delete(s.payload.queryCacheKey),!0;if(t.pending.match(s)){const{meta:{arg:e,requestId:t}}=s,i=hh(n,e.queryCacheKey,xh);return e.subscribe&&i.set(t,e.subscriptionOptions??i.get(t)??{}),!0}let i=!1;if(t.rejected.match(s)){const{meta:{condition:e,arg:t,requestId:a}}=s;if(e&&t.subscribe){const e=hh(n,t.queryCacheKey,xh);e.set(a,t.subscriptionOptions??e.get(a)??{}),i=!0}}return i})(n.currentSubscriptions,s);let m=!0;if(p){r||(r=setTimeout(()=>{const t=u(n.currentSubscriptions),[,s]=gt(a,()=>t);c.next(e.internalActions.subscriptionsUpdated(s)),a=t,r=null},500));const o="string"==typeof s.type&&!!s.type.startsWith(i),l=t.rejected.match(s)&&s.meta.condition&&!!s.meta.arg.subscribe;m=!o&&!l}return[m,!1]}},ex=({reducerPath:e,api:t,queryThunk:n,context:s,internalState:i,selectors:{selectQueryEntry:a,selectConfig:r},getRunningQueryThunk:o,mwApi:l})=>{const{removeQueryResult:c,unsubscribeQueryResult:d,cacheEntriesUpserted:u}=t.internalActions,p=i.runningQueries.get(l.dispatch),m=ot(d.match,n.fulfilled,n.rejected,u.match);function h(e){const t=i.currentSubscriptions.get(e);if(!t)return!1;const n=t.size>0,s=void 0!==(null==p?void 0:p[e]);return n||s}const x={};function f(e,t,n){const s=t.getState();for(const i of e){const e=a(s,i);(null==e?void 0:e.endpointName)&&g(i,e.endpointName,t,n)}}function g(e,t,n,i){const r=s.endpointDefinitions[t],l=(null==r?void 0:r.keepUnusedDataFor)??i.keepUnusedDataFor;if(l===1/0)return;const d=Math.max(0,Math.min(l,2147482.647));if(!h(e)){const t=x[e];t&&clearTimeout(t),x[e]=setTimeout(()=>{if(!h(e)){const t=a(n.getState(),e);if(null==t?void 0:t.endpointName){const e=n.dispatch(o(t.endpointName,t.originalArgs));null==e||e.abort()}n.dispatch(c({queryCacheKey:e}))}delete x[e]},1e3*d)}}return(e,n,i)=>{const a=n.getState(),o=r(a);if(m(e)){let t;if(u.match(e))t=e.payload.map(e=>e.queryDescription.queryCacheKey);else{const{queryCacheKey:n}=d.match(e)?e.payload:e.meta.arg;t=[n]}f(t,n,o)}if(t.util.resetApiState.match(e))for(const[t,s]of Object.entries(x))s&&clearTimeout(s),delete x[t];if(s.hasRehydrationInfo(e)){const{queries:t}=s.extractRehydrationInfo(e);f(Object.keys(t),n,o)}}},tx=new Error("Promise never resolved before cacheEntryRemoved."),nx=({api:e,reducerPath:t,context:n,queryThunk:s,mutationThunk:i,internalState:a,selectors:{selectQueryEntry:r,selectApiState:o}})=>{const l=bt(s),c=bt(i),d=ct(s,i),u={};function p(e,t,n){const s=u[e];(null==s?void 0:s.valueResolved)&&(s.valueResolved({data:t,meta:n}),delete s.valueResolved)}function m(e){const t=u[e];t&&(delete u[e],t.cacheEntryRemoved())}function h(t,s,i,a,r){const o=n.endpointDefinitions[t],l=null==o?void 0:o.onCacheEntryAdded;if(!l)return;const c={},d=new Promise(e=>{c.cacheEntryRemoved=e}),p=Promise.race([new Promise(e=>{c.valueResolved=e}),d.then(()=>{throw tx})]);p.catch(()=>{}),u[i]=c;const m=e.endpoints[t].select(Sh(o)?s:i),h=a.dispatch((e,t,n)=>n),x={...a,getCacheEntry:()=>m(a.getState()),requestId:r,extra:h,updateCachedData:Sh(o)?n=>a.dispatch(e.util.updateQueryData(t,s,n)):void 0,cacheDataLoaded:p,cacheEntryRemoved:d},f=l(s,x);Promise.resolve(f).catch(e=>{if(e!==tx)throw e})}return(n,a,o)=>{const x=function(t){if(l(t))return t.meta.arg.queryCacheKey;if(c(t))return t.meta.arg.fixedCacheKey??t.meta.requestId;return e.internalActions.removeQueryResult.match(t)?t.payload.queryCacheKey:e.internalActions.removeMutationResult.match(t)?$h(t.payload):""}(n);function f(e,t,n,s){const i=r(o,t),l=r(a.getState(),t);!i&&l&&h(e,s,t,a,n)}if(s.pending.match(n))f(n.meta.arg.endpointName,x,n.meta.requestId,n.meta.arg.originalArgs);else if(e.internalActions.cacheEntriesUpserted.match(n))for(const{queryDescription:e,value:t}of n.payload){const{endpointName:s,originalArgs:i,queryCacheKey:a}=e;f(s,a,n.meta.requestId,i),p(a,t,{})}else if(i.pending.match(n)){a.getState()[t].mutations[x]&&h(n.meta.arg.endpointName,n.meta.arg.originalArgs,x,a,n.meta.requestId)}else if(d(n))p(x,n.payload,n.meta.baseQueryMeta);else if(e.internalActions.removeQueryResult.match(n)||e.internalActions.removeMutationResult.match(n))m(x);else if(e.util.resetApiState.match(n))for(const e of Object.keys(u))m(e)}},sx=({api:e,context:{apiUid:t},reducerPath:n})=>(n,s)=>{e.util.resetApiState.match(n)&&s.dispatch(e.internalActions.middlewareRegistered(t))},ix=({reducerPath:e,context:t,context:{endpointDefinitions:n},mutationThunk:s,queryThunk:i,api:a,assertTagType:r,refetchQuery:o,internalState:l})=>{const{removeQueryResult:c}=a.internalActions,d=ot(ct(s),lt(s)),u=ot(ct(s,i),ht(s,i));let p=[];function m(n,s){const i=s.getState(),r=i[e];if(p.push(...n),"delayed"===r.config.invalidationBehavior&&function(e){var t;const{queries:n,mutations:s}=e;for(const i of[n,s])for(const e in i)if("pending"===(null==(t=i[e])?void 0:t.status))return!0;return!1}(r))return;const d=p;if(p=[],0===d.length)return;const u=a.util.selectInvalidatedBy(i,d);t.batch(()=>{const e=Array.from(u.values());for(const{queryCacheKey:t}of e){const e=r.queries[t],n=hh(l.currentSubscriptions,t,xh);e&&(0===n.size?s.dispatch(c({queryCacheKey:t})):"uninitialized"!==e.status&&s.dispatch(o(e)))}})}return(e,t)=>{d(e)?m(Bh(e,"invalidatesTags",n,r),t):u(e)?m([],t):a.util.invalidateTags.match(e)&&m(Eh(e.payload,void 0,void 0,void 0,void 0,r),t)}},ax=({reducerPath:e,queryThunk:t,api:n,refetchQuery:s,internalState:i})=>{const{currentPolls:a,currentSubscriptions:r}=i,o=new Set;let l=null;function c(e,t){o.add(e),l||(l=setTimeout(()=>{for(const e of o)u({queryCacheKey:e},t);o.clear(),l=null},0))}function d({queryCacheKey:t},n){const i=n.getState()[e],o=i.queries[t],l=r.get(t);if(!o||"uninitialized"===o.status)return;const{lowestPollingInterval:c,skipPollingIfUnfocused:u}=m(l);if(!Number.isFinite(c))return;const p=a.get(t);(null==p?void 0:p.timeout)&&(clearTimeout(p.timeout),p.timeout=void 0);const h=Date.now()+c;a.set(t,{nextPollTimestamp:h,pollingInterval:c,timeout:setTimeout(()=>{!i.config.focused&&u||n.dispatch(s(o)),d({queryCacheKey:t},n)},c)})}function u({queryCacheKey:t},n){const s=n.getState()[e].queries[t],i=r.get(t);if(!s||"uninitialized"===s.status)return;const{lowestPollingInterval:o}=m(i);if(!Number.isFinite(o))return void p(t);const l=a.get(t),c=Date.now()+o;(!l||c{(n.internalActions.updateSubscriptionOptions.match(e)||n.internalActions.unsubscribeQueryResult.match(e))&&c(e.payload.queryCacheKey,s),(t.pending.match(e)||t.rejected.match(e)&&e.meta.condition)&&c(e.meta.arg.queryCacheKey,s),(t.fulfilled.match(e)||t.rejected.match(e)&&!e.meta.condition)&&d(e.meta.arg,s),n.util.resetApiState.match(e)&&(!function(){for(const e of a.keys())p(e)}(),l&&(clearTimeout(l),l=null),o.clear())}},rx=({api:e,context:t,queryThunk:n,mutationThunk:s})=>{const i=xt(n,s),a=ht(n,s),r=ct(n,s),o={};return(n,s)=>{var l,c;if(i(n)){const{requestId:i,arg:{endpointName:a,originalArgs:r}}=n.meta,l=t.endpointDefinitions[a],c=null==l?void 0:l.onQueryStarted;if(c){const t={},n=new Promise((e,n)=>{t.resolve=e,t.reject=n});n.catch(()=>{}),o[i]=t;const d=e.endpoints[a].select(Sh(l)?r:i),u=s.dispatch((e,t,n)=>n),p={...s,getCacheEntry:()=>d(s.getState()),requestId:i,extra:u,updateCachedData:Sh(l)?t=>s.dispatch(e.util.updateQueryData(a,r,t)):void 0,queryFulfilled:n};c(r,p)}}else if(r(n)){const{requestId:e,baseQueryMeta:t}=n.meta;null==(l=o[e])||l.resolve({data:n.payload,meta:t}),delete o[e]}else if(a(n)){const{requestId:e,rejectedWithValue:t,baseQueryMeta:s}=n.meta;null==(c=o[e])||c.reject({error:n.payload??n.error,isUnhandledError:!t,meta:s}),delete o[e]}}};function ox(e){const{reducerPath:t,queryThunk:n,api:s,context:i,internalState:a}=e,{apiUid:r}=i,o={invalidateTags:st(`${t}/invalidateTags`)},l=e=>e.type.startsWith(`${t}/`),c=[sx,ex,ix,ax,nx,rx];return{middleware:n=>{let o=!1;const u={...e,internalState:a,refetchQuery:d,isThisApiSliceAction:l,mwApi:n},p=c.map(e=>e(u)),m=Xh(u),h=(({reducerPath:e,context:t,api:n,refetchQuery:s,internalState:i})=>{const{removeQueryResult:a}=n.internalActions;function r(n,r){const o=n.getState()[e],l=o.queries,c=i.currentSubscriptions;t.batch(()=>{for(const e of c.keys()){const t=l[e],i=c.get(e);if(!i||!t)continue;const d=[...i.values()];(d.some(e=>!0===e[r])||d.every(e=>void 0===e[r])&&o.config[r])&&(0===i.size?n.dispatch(a({queryCacheKey:e})):"uninitialized"!==t.status&&n.dispatch(s(t)))}})}return(e,t)=>{jh.match(e)&&r(t,"refetchOnFocus"),Nh.match(e)&&r(t,"refetchOnReconnect")}})(u);return e=>a=>{if(!vt(a))return e(a);o||(o=!0,n.dispatch(s.internalActions.middlewareRegistered(r)));const c={...n,next:e},d=n.getState(),[u,x]=m(a,c,d);let f;if(f=u?e(a):x,n.getState()[t]&&(h(a,c,d),l(a)||i.hasRehydrationInfo(a)))for(const e of p)e(a,c,d);return f}},actions:o};function d(t){return e.api.endpoints[t.endpointName].initiate(t.originalArgs,{subscribe:!1,forceRefetch:!0})}}var lx=Symbol(),cx=({createSelector:e=it}={})=>({name:lx,init(t,{baseQuery:n,tagTypes:s,reducerPath:i,serializeQueryArgs:a,keepUnusedDataFor:r,refetchOnMountOrArgChange:o,refetchOnFocus:l,refetchOnReconnect:c,invalidationBehavior:d,onSchemaFailure:u,catchSchemaFailure:p,skipSchemaValidation:m},h){nt();const x=e=>e;Object.assign(t,{reducerPath:i,endpoints:{},internalActions:{onOnline:Nh,onOffline:Fh,onFocus:jh,onFocusLost:Ch},util:{}});const f=function({serializeQueryArgs:e,reducerPath:t,createSelector:n}){const s=e=>Gh,i=e=>Zh;return{buildQuerySelector:function(e,t){return c(e,t,a)},buildInfiniteQuerySelector:function(e,t){const{infiniteQueryOptions:n}=t;return c(e,t,function(e){const t={...e,...oh(e.status)},{isLoading:s,isError:i,direction:a}=t,r="forward"===a,o="backward"===a;return{...t,hasNextPage:d(n,t.data,t.originalArgs),hasPreviousPage:u(n,t.data,t.originalArgs),isFetchingNextPage:s&&r,isFetchingPreviousPage:s&&o,isFetchNextPageError:i&&r,isFetchPreviousPageError:i&&o}})},buildMutationSelector:function(){return e=>{let t;return t="object"==typeof e?$h(e)??Wh:e,n(t===Wh?i:e=>{var n,s;return(null==(s=null==(n=r(e))?void 0:n.mutations)?void 0:s[t])??Zh},a)}},selectInvalidatedBy:function(e,n){const s=e[t],i=new Set;for(const t of n.filter(ph).map(Ih)){const e=s.provided.tags[t.type];if(!e)continue;let n=(void 0!==t.id?e[t.id]:uh(Object.values(e)))??[];for(const t of n)i.add(t)}return uh(Array.from(i.values()).map(e=>{const t=s.queries[e];return t?[{queryCacheKey:e,endpointName:t.endpointName,originalArgs:t.originalArgs}]:[]}))},selectCachedArgsForQuery:function(e,t){return Object.values(o(e)).filter(e=>(null==e?void 0:e.endpointName)===t&&"uninitialized"!==e.status).map(e=>e.originalArgs)},selectApiState:r,selectQueries:o,selectMutations:function(e){var t;return null==(t=r(e))?void 0:t.mutations},selectQueryEntry:l,selectConfig:function(e){var t;return null==(t=r(e))?void 0:t.config}};function a(e){return{...e,...oh(e.status)}}function r(e){return e[t]}function o(e){var t;return null==(t=r(e))?void 0:t.queries}function l(e,t){var n;return null==(n=o(e))?void 0:n[t]}function c(t,i,a){return r=>{if(r===Wh)return n(s,a);const o=e({queryArgs:r,endpointDefinition:i,endpointName:t});return n(e=>l(e,o)??Gh,a)}}function d(e,t,n){return!!t&&null!=Oh(e,t,n)}function u(e,t,n){return!(!t||!e.getPreviousPageParam)&&null!=zh(e,t,n)}}({serializeQueryArgs:a,reducerPath:i,createSelector:e}),{selectInvalidatedBy:g,selectCachedArgsForQuery:v,buildQuerySelector:b,buildInfiniteQuerySelector:y,buildMutationSelector:w}=f;Qh(t.util,{selectInvalidatedBy:g,selectCachedArgsForQuery:v});const{queryThunk:j,infiniteQueryThunk:C,mutationThunk:N,patchQueryData:F,updateQueryData:_,upsertQueryData:k,prefetch:S,buildMatchThunkActions:E}=function({reducerPath:e,baseQuery:t,context:{endpointDefinitions:n},serializeQueryArgs:s,api:i,assertTagType:a,selectors:r,onSchemaFailure:o,catchSchemaFailure:l,skipSchemaValidation:c}){function d(e,t,n=0){const s=[t,...e];return n&&s.length>n?s.slice(0,-1):s}function u(e,t,n=0){const s=[...e,t];return n&&s.length>n?s.slice(1):s}const p=(e,t)=>e.query&&e[t]?e[t]:Ph,m=async(e,{signal:s,abort:i,rejectWithValue:a,fulfillWithValue:m,dispatch:x,getState:f,extra:g})=>{var v,b;const y=n[e.endpointName],{metaSchema:w,skipSchemaValidation:j=c}=y;try{let F=Ph;const _={signal:s,abort:i,dispatch:x,getState:f,extra:g,endpoint:e.endpointName,type:e.type,forced:"query"===e.type?h(e,f()):void 0,queryCacheKey:"query"===e.type?e.queryCacheKey:void 0},k="query"===e.type?e[Ah]:void 0;let S;const E=async(t,n,s,i)=>{if(null==n&&t.pages.length)return Promise.resolve({data:t});const a={queryArg:e.originalArgs,pageParam:n},r=await I(a),o=i?d:u;return{data:{pages:o(t.pages,r.data,s),pageParams:o(t.pageParams,n,s)},meta:r.meta}};async function I(e){let n;const{extraOptions:s,argSchema:i,rawResponseSchema:a,responseSchema:r}=y;if(i&&!Dh(j,"arg")&&(e=await Lh(i,e,"argSchema",{})),k?n=k():y.query?(F=p(y,"transformResponse"),n=await t(y.query(e),_,s)):n=await y.queryFn(e,_,s,e=>t(e,_,s)),n.error)throw new wh(n.error,n.meta);let{data:o}=n;a&&!Dh(j,"rawResponse")&&(o=await Lh(a,n.data,"rawResponseSchema",n.meta));let l=await F(o,n.meta,e);return r&&!Dh(j,"response")&&(l=await Lh(r,l,"responseSchema",n.meta)),{...n,data:l}}if("query"===e.type&&"infiniteQueryOptions"in y){const{infiniteQueryOptions:A}=y,{maxPages:T=1/0}=A;let M;const D={pages:[],pageParams:[]},L=null==(v=r.selectQueryEntry(f(),e.queryCacheKey))?void 0:v.data,P=h(e,f())&&!e.direction||!L?D:L;if("direction"in e&&e.direction&&P.pages.length){const R="backward"===e.direction,O=(R?zh:Oh)(A,P,e.originalArgs);M=await E(P,O,T,R)}else{const{initialPageParam:z=A.initialPageParam}=e,B=(null==L?void 0:L.pageParams)??[],H=B[0]??z,$=B.length;M=await E(P,H,T),k&&(M={data:M.data.pages[0]});for(let V=1;V<$;V++){const U=Oh(A,M.data,e.originalArgs);M=await E(M.data,U,T)}}S=M}else S=await I(e.originalArgs);return w&&!Dh(j,"meta")&&S.meta&&(S.meta=await Lh(w,S.meta,"metaSchema",S.meta)),m(S.data,Rh({fulfilledTimeStamp:Date.now(),baseQueryMeta:S.meta}))}catch(C){let W=C;if(W instanceof wh){let q=p(y,"transformErrorResponse");const{rawErrorResponseSchema:G,errorResponseSchema:Z}=y;let{value:Y,meta:K}=W;try{G&&!Dh(j,"rawErrorResponse")&&(Y=await Lh(G,Y,"rawErrorResponseSchema",K)),w&&!Dh(j,"meta")&&(K=await Lh(w,K,"metaSchema",K));let J=await q(Y,K,e.originalArgs);return Z&&!Dh(j,"errorResponse")&&(J=await Lh(Z,J,"errorResponseSchema",K)),a(J,Rh({baseQueryMeta:K}))}catch(N){W=N}}try{if(W instanceof Mh){const Q={endpoint:e.endpointName,arg:e.originalArgs,type:e.type,queryCacheKey:"query"===e.type?e.queryCacheKey:void 0};null==(b=y.onSchemaFailure)||b.call(y,W,Q),null==o||o(W,Q);const{catchSchemaFailure:X=l}=y;if(X)return a(X(W,Q),Rh({baseQueryMeta:W._bqMeta}))}}catch(N){W=N}throw W}};function h(e,t){const n=r.selectQueryEntry(t,e.queryCacheKey),s=r.selectConfig(t).refetchOnMountOrArgChange,i=null==n?void 0:n.fulfilledTimeStamp,a=e.forceRefetch??(e.subscribe&&s);return!!a&&(!0===a||(Number(new Date)-Number(i))/1e3>=a)}const x=()=>Je(`${e}/executeQuery`,m,{getPendingMeta({arg:e}){const t=n[e.endpointName];return Rh({startedTimeStamp:Date.now(),...kh(t)?{direction:e.direction}:{}})},condition(e,{getState:t}){var s;const i=t(),a=r.selectQueryEntry(i,e.queryCacheKey),o=null==a?void 0:a.fulfilledTimeStamp,l=e.originalArgs,c=null==a?void 0:a.originalArgs,d=n[e.endpointName],u=e.direction;return!(!Th(e)&&("pending"===(null==a?void 0:a.status)||!h(e,i)&&(!_h(d)||!(null==(s=null==d?void 0:d.forceRefetch)?void 0:s.call(d,{currentArg:l,previousArg:c,endpointState:a,state:i})))&&o&&!u))},dispatchConditionRejection:!0}),f=x(),g=x(),v=Je(`${e}/executeMutation`,m,{getPendingMeta:()=>Rh({startedTimeStamp:Date.now()})});function b(e){return t=>{var n,s;return(null==(s=null==(n=null==t?void 0:t.meta)?void 0:n.arg)?void 0:s.endpointName)===e}}return{queryThunk:f,mutationThunk:v,infiniteQueryThunk:g,prefetch:(e,t,n)=>(s,a)=>{const r=(e=>"force"in e)(n)&&n.force,o=(e=>"ifOlderThan"in e)(n)&&n.ifOlderThan,l=(n=!0)=>{const s={forceRefetch:n,isPrefetch:!0};return i.endpoints[e].initiate(t,s)},c=i.endpoints[e].select(t)(a());if(r)s(l());else if(o){const e=null==c?void 0:c.fulfilledTimeStamp;if(!e)return void s(l());(Number(new Date)-Number(new Date(e)))/1e3>=o&&s(l())}else s(l(!1))},updateQueryData:(e,t,n,s=!0)=>(a,r)=>{const o=i.endpoints[e].select(t)(r()),l={patches:[],inversePatches:[],undo:()=>a(i.util.patchQueryData(e,t,l.inversePatches,s))};if("uninitialized"===o.status)return l;let c;if("data"in o)if(ft(o.data)){const[e,t,s]=gt(o.data,n);l.patches.push(...t),l.inversePatches.push(...s),c=e}else c=n(o.data),l.patches.push({op:"replace",path:[],value:c}),l.inversePatches.push({op:"replace",path:[],value:o.data});return 0===l.patches.length||a(i.util.patchQueryData(e,t,l.patches,s)),l},upsertQueryData:(e,t,n)=>s=>s(i.endpoints[e].initiate(t,{subscribe:!1,forceRefetch:!0,[Ah]:()=>({data:n})})),patchQueryData:(e,t,r,o)=>(l,c)=>{const d=n[e],u=s({queryArgs:t,endpointDefinition:d,endpointName:e});if(l(i.internalActions.queryResultPatched({queryCacheKey:u,patches:r})),!o)return;const p=i.endpoints[e].select(t)(c()),m=Eh(d.providesTags,p.data,void 0,t,{},a);l(i.internalActions.updateProvidedBy([{queryCacheKey:u,providedTags:m}]))},buildMatchThunkActions:function(e,t){return{matchPending:mt(xt(e),b(t)),matchFulfilled:mt(ct(e),b(t)),matchRejected:mt(ht(e),b(t))}}}}({baseQuery:n,reducerPath:i,context:h,api:t,serializeQueryArgs:a,assertTagType:x,selectors:f,onSchemaFailure:u,catchSchemaFailure:p,skipSchemaValidation:m}),{reducer:I,actions:A}=function({reducerPath:e,queryThunk:t,mutationThunk:n,serializeQueryArgs:s,context:{endpointDefinitions:i,apiUid:a,extractRehydrationInfo:r,hasRehydrationInfo:o},assertTagType:l,config:c}){const d=st(`${e}/resetApiState`);function u(e,t,n,s){var a;e[a=t.queryCacheKey]??(e[a]={status:"uninitialized",endpointName:t.endpointName}),Hh(e,t.queryCacheKey,e=>{e.status="pending",e.requestId=n&&e.requestId?e.requestId:s.requestId,void 0!==t.originalArgs&&(e.originalArgs=t.originalArgs),e.startedTimeStamp=s.startedTimeStamp,kh(i[s.arg.endpointName])&&"direction"in t&&(e.direction=t.direction)})}function p(e,t,n,s){Hh(e,t.arg.queryCacheKey,e=>{if(e.requestId!==t.requestId&&!s)return;const{merge:a}=i[t.arg.endpointName];if(e.status="fulfilled",a)if(void 0!==e.data){const{fulfilledTimeStamp:s,arg:i,baseQueryMeta:r,requestId:o}=t;let l=at(e.data,e=>a(e,n,{arg:i.originalArgs,baseQueryMeta:r,fulfilledTimeStamp:s,requestId:o}));e.data=l}else e.data=n;else e.data=i[t.arg.endpointName].structuralSharing??1?ch(wt(e.data)?yt(e.data):e.data,n):n;delete e.error,e.fulfilledTimeStamp=t.fulfilledTimeStamp})}const m=Ke({name:`${e}/queries`,initialState:Uh,reducers:{removeQueryResult:{reducer(e,{payload:{queryCacheKey:t}}){delete e[t]},prepare:rt()},cacheEntriesUpserted:{reducer(e,t){for(const n of t.payload){const{queryDescription:s,value:i}=n;u(e,s,!0,{arg:s,requestId:t.meta.requestId,startedTimeStamp:t.meta.timestamp}),p(e,{arg:s,requestId:t.meta.requestId,fulfilledTimeStamp:t.meta.timestamp,baseQueryMeta:{}},i,!0)}},prepare:e=>({payload:e.map(e=>{const{endpointName:t,arg:n,value:a}=e,r=i[t];return{queryDescription:{type:"query",endpointName:t,originalArgs:e.arg,queryCacheKey:s({queryArgs:n,endpointDefinition:r,endpointName:t})},value:a}}),meta:{[pt]:!0,requestId:et(),timestamp:Date.now()}})},queryResultPatched:{reducer(e,{payload:{queryCacheKey:t,patches:n}}){Hh(e,t,e=>{e.data=dt(e.data,n.concat())})},prepare:rt()}},extraReducers(e){e.addCase(t.pending,(e,{meta:t,meta:{arg:n}})=>{u(e,n,Th(n),t)}).addCase(t.fulfilled,(e,{meta:t,payload:n})=>{p(e,t,n,Th(t.arg))}).addCase(t.rejected,(e,{meta:{condition:t,arg:n,requestId:s},error:i,payload:a})=>{Hh(e,n.queryCacheKey,e=>{if(t);else{if(e.requestId!==s)return;e.status="rejected",e.error=a??i}})}).addMatcher(o,(e,t)=>{const{queries:n}=r(t);for(const[s,i]of Object.entries(n))"fulfilled"!==(null==i?void 0:i.status)&&"rejected"!==(null==i?void 0:i.status)||(e[s]=i)})}}),h=Ke({name:`${e}/mutations`,initialState:Uh,reducers:{removeMutationResult:{reducer(e,{payload:t}){const n=$h(t);n in e&&delete e[n]},prepare:rt()}},extraReducers(e){e.addCase(n.pending,(e,{meta:t,meta:{requestId:n,arg:s,startedTimeStamp:i}})=>{s.track&&(e[$h(t)]={requestId:n,status:"pending",endpointName:s.endpointName,startedTimeStamp:i})}).addCase(n.fulfilled,(e,{payload:t,meta:n})=>{n.arg.track&&Vh(e,n,e=>{e.requestId===n.requestId&&(e.status="fulfilled",e.data=t,e.fulfilledTimeStamp=n.fulfilledTimeStamp)})}).addCase(n.rejected,(e,{payload:t,error:n,meta:s})=>{s.arg.track&&Vh(e,s,e=>{e.requestId===s.requestId&&(e.status="rejected",e.error=t??n)})}).addMatcher(o,(e,t)=>{const{mutations:n}=r(t);for(const[s,i]of Object.entries(n))"fulfilled"!==(null==i?void 0:i.status)&&"rejected"!==(null==i?void 0:i.status)||s===(null==i?void 0:i.requestId)||(e[s]=i)})}}),x=Ke({name:`${e}/invalidation`,initialState:{tags:{},keys:{}},reducers:{updateProvidedBy:{reducer(e,t){var n,s,i;for(const{queryCacheKey:a,providedTags:r}of t.payload){f(e,a);for(const{type:t,id:o}of r){const r=(s=(n=e.tags)[t]??(n[t]={}))[i=o||"__internal_without_id"]??(s[i]=[]);r.includes(a)||r.push(a)}e.keys[a]=r}},prepare:rt()}},extraReducers(e){e.addCase(m.actions.removeQueryResult,(e,{payload:{queryCacheKey:t}})=>{f(e,t)}).addMatcher(o,(e,t)=>{var n,s,i;const{provided:a}=r(t);for(const[r,o]of Object.entries(a.tags??{}))for(const[t,l]of Object.entries(o)){const o=(s=(n=e.tags)[r]??(n[r]={}))[i=t||"__internal_without_id"]??(s[i]=[]);for(const t of l)o.includes(t)||o.push(t),e.keys[t]=a.keys[t]}}).addMatcher(ot(ct(t),lt(t)),(e,t)=>{g(e,[t])}).addMatcher(m.actions.cacheEntriesUpserted.match,(e,t)=>{g(e,t.payload.map(({queryDescription:e,value:t})=>({type:"UNKNOWN",payload:t,meta:{requestStatus:"fulfilled",requestId:"UNKNOWN",arg:e}})))})}});function f(e,t){var n;const s=e.keys[t]??[];for(const i of s){const s=i.type,a=i.id??"__internal_without_id",r=null==(n=e.tags[s])?void 0:n[a];r&&(e.tags[s][a]=r.filter(e=>e!==t))}delete e.keys[t]}function g(e,t){const n=t.map(e=>{const t=Bh(e,"providesTags",i,l),{queryCacheKey:n}=e.meta.arg;return{queryCacheKey:n,providedTags:t}});x.caseReducers.updateProvidedBy(e,x.actions.updateProvidedBy(n))}const v=Ke({name:`${e}/subscriptions`,initialState:Uh,reducers:{updateSubscriptionOptions(e,t){},unsubscribeQueryResult(e,t){},internal_getRTKQSubscriptions(){}}}),b=Ke({name:`${e}/internalSubscriptions`,initialState:Uh,reducers:{subscriptionsUpdated:{reducer:(e,t)=>dt(e,t.payload),prepare:rt()}}}),y=Ke({name:`${e}/config`,initialState:{online:"undefined"==typeof navigator||void 0===navigator.onLine||navigator.onLine,focused:"undefined"==typeof document||"hidden"!==document.visibilityState,middlewareRegistered:!1,...c},reducers:{middlewareRegistered(e,{payload:t}){e.middlewareRegistered="conflict"!==e.middlewareRegistered&&a===t||"conflict"}},extraReducers:e=>{e.addCase(Nh,e=>{e.online=!0}).addCase(Fh,e=>{e.online=!1}).addCase(jh,e=>{e.focused=!0}).addCase(Ch,e=>{e.focused=!1}).addMatcher(o,e=>({...e}))}}),w=ut({queries:m.reducer,mutations:h.reducer,provided:x.reducer,subscriptions:b.reducer,config:y.reducer});return{reducer:(e,t)=>w(d.match(t)?void 0:e,t),actions:{...y.actions,...m.actions,...v.actions,...b.actions,...h.actions,...x.actions,resetApiState:d}}}({context:h,queryThunk:j,mutationThunk:N,serializeQueryArgs:a,reducerPath:i,assertTagType:x,config:{refetchOnFocus:l,refetchOnReconnect:c,refetchOnMountOrArgChange:o,keepUnusedDataFor:r,reducerPath:i,invalidationBehavior:d}});Qh(t.util,{patchQueryData:F,updateQueryData:_,upsertQueryData:k,prefetch:S,resetApiState:A.resetApiState,upsertQueryEntries:A.cacheEntriesUpserted}),Qh(t.internalActions,A);const T={currentSubscriptions:new Map,currentPolls:new Map,runningQueries:new Map,runningMutations:new Map},{buildInitiateQuery:M,buildInitiateInfiniteQuery:D,buildInitiateMutation:L,getRunningMutationThunk:P,getRunningMutationsThunk:R,getRunningQueriesThunk:O,getRunningQueryThunk:z}=function({serializeQueryArgs:e,queryThunk:t,infiniteQueryThunk:n,mutationThunk:s,api:i,context:a,internalState:r}){const{runningQueries:o,runningMutations:l}=r,{unsubscribeQueryResult:c,removeMutationResult:d,updateSubscriptionOptions:u}=i.internalActions;return{buildInitiateQuery:function(e,t){return p(e,t)},buildInitiateInfiniteQuery:function(e,t){return p(e,t)},buildInitiateMutation:function(e){return(t,{track:n=!0,fixedCacheKey:i}={})=>(a,r)=>{const o=s({type:"mutation",endpointName:e,originalArgs:t,track:n,fixedCacheKey:i}),c=a(o),{requestId:u,abort:p,unwrap:m}=c,h=(x=e=>({error:e}),c.unwrap().then(e=>({data:e})).catch(x));var x;const f=Object.assign(h,{arg:c.arg,requestId:u,abort:p,unwrap:m,reset:()=>{a(d({requestId:u,fixedCacheKey:i}))}}),g=l.get(a)||{};return l.set(a,g),g[u]=f,f.then(()=>{delete g[u],dh(g)||l.delete(a)}),i&&(g[i]=f,f.then(()=>{g[i]===f&&(delete g[i],dh(g)||l.delete(a))})),f}},getRunningQueryThunk:function(t,n){return s=>{var i;const r=a.endpointDefinitions[t],l=e({queryArgs:n,endpointDefinition:r,endpointName:t});return null==(i=o.get(s))?void 0:i[l]}},getRunningMutationThunk:function(e,t){return e=>{var n;return null==(n=l.get(e))?void 0:n[t]}},getRunningQueriesThunk:function(){return e=>Object.values(o.get(e)||{}).filter(ph)},getRunningMutationsThunk:function(){return e=>Object.values(l.get(e)||{}).filter(ph)}};function p(s,a){const r=(l,{subscribe:d=!0,forceRefetch:p,subscriptionOptions:m,[Ah]:h,...x}={})=>(f,g)=>{var v;const b=e({queryArgs:l,endpointDefinition:a,endpointName:s});let y;const w={...x,type:"query",subscribe:d,forceRefetch:p,subscriptionOptions:m,endpointName:s,originalArgs:l,queryCacheKey:b,[Ah]:h};if(_h(a))y=t(w);else{const{direction:e,initialPageParam:t}=x;y=n({...w,direction:e,initialPageParam:t})}const j=i.endpoints[s].select(l),C=f(y),N=j(g()),{requestId:F,abort:_}=C,k=N.requestId!==F,S=null==(v=o.get(f))?void 0:v[b],E=()=>j(g()),I=Object.assign(h?C.then(E):k&&!S?Promise.resolve(N):Promise.all([S,C]).then(E),{arg:l,requestId:F,subscriptionOptions:m,queryCacheKey:b,abort:_,async unwrap(){const e=await I;if(e.isError)throw e.error;return e.data},refetch:()=>f(r(l,{subscribe:!1,forceRefetch:!0})),unsubscribe(){d&&f(c({queryCacheKey:b,requestId:F}))},updateSubscriptionOptions(e){I.subscriptionOptions=e,f(u({endpointName:s,requestId:F,queryCacheKey:b,options:e}))}});if(!S&&!k&&!h){const e=(T=f,M={},(A=o).has(T)?A.get(T):A.set(T,M).get(T));e[b]=I,I.then(()=>{delete e[b],dh(e)||o.delete(f)})}var A,T,M;return I};return r}}({queryThunk:j,mutationThunk:N,infiniteQueryThunk:C,api:t,serializeQueryArgs:a,context:h,internalState:T});Qh(t.util,{getRunningMutationThunk:P,getRunningMutationsThunk:R,getRunningQueryThunk:z,getRunningQueriesThunk:O});const{middleware:B,actions:H}=ox({reducerPath:i,context:h,queryThunk:j,mutationThunk:N,infiniteQueryThunk:C,api:t,assertTagType:x,selectors:f,getRunningQueryThunk:z,internalState:T});return Qh(t.util,H),Qh(t,{reducer:I,middleware:B}),{name:lx,injectEndpoint(e,n){var s;const i=(s=t.endpoints)[e]??(s[e]={});_h(n)&&Qh(i,{name:e,select:b(e,n),initiate:M(e,n)},E(j,e)),"mutation"===n.type&&Qh(i,{name:e,select:w(),initiate:L(e)},E(N,e)),kh(n)&&Qh(i,{name:e,select:y(e,n),initiate:D(e,n)},E(j,e))}}}});function dx(e){return e.replace(e[0],e[0].toUpperCase())}function ux(e){return"infinitequery"===e.type}function px(e,...t){return Object.assign(e,...t)}cx();var mx=Symbol();function hx(e){const t=Pe.useRef(e),n=Pe.useMemo(()=>ch(t.current,e),[e]);return Pe.useEffect(()=>{t.current!==n&&(t.current=n)},[n]),n}function xx(e){const t=Pe.useRef(e);return Pe.useEffect(()=>{_t(t.current,e)||(t.current=e)},[e]),_t(t.current,e)?t.current:e}var fx=(()=>!("undefined"==typeof window||void 0===window.document||void 0===window.document.createElement))(),gx=(()=>"undefined"!=typeof navigator&&"ReactNative"===navigator.product)(),vx=(()=>fx||gx?Pe.useLayoutEffect:Pe.useEffect)(),bx=e=>e.isUninitialized?{...e,isUninitialized:!1,isFetching:!0,isLoading:void 0===e.data,status:rh.pending}:e;function yx(e,...t){const n={};return t.forEach(t=>{n[t]=e[t]}),n}var wx=["data","status","isLoading","isSuccess","isError","error"];var jx=Symbol(),Cx=Jh(cx(),(({batch:e=jt,hooks:t={useDispatch:Ft,useSelector:Nt,useStore:Ct},createSelector:n=it,unstable__sideEffectsInRender:s=!1,...i}={})=>({name:jx,init(i,{serializeQueryArgs:a},r){const o=i,{buildQueryHooks:l,buildInfiniteQueryHooks:c,buildMutationHook:d,usePrefetch:u}=function({api:e,moduleOptions:{batch:t,hooks:{useDispatch:n,useSelector:s,useStore:i},unstable__sideEffectsInRender:a,createSelector:r},serializeQueryArgs:o,context:l}){const c=a?e=>e():Pe.useEffect;return{buildQueryHooks:function(s){const i=(e,t={})=>{const[n]=p(s,e,t);return h(n),Pe.useMemo(()=>({refetch:()=>x(n)}),[n])},a=({refetchOnReconnect:i,refetchOnFocus:a,pollingInterval:r=0,skipPollingIfUnfocused:o=!1}={})=>{const{initiate:l}=e.endpoints[s],d=n(),[u,p]=Pe.useState(mx),m=Pe.useRef(void 0),h=xx({refetchOnReconnect:i,refetchOnFocus:a,pollingInterval:r,skipPollingIfUnfocused:o});c(()=>{var e,t;const n=null==(e=m.current)?void 0:e.subscriptionOptions;h!==n&&(null==(t=m.current)||t.updateSubscriptionOptions(h))},[h]);const x=Pe.useRef(h);c(()=>{x.current=h},[h]);const f=Pe.useCallback(function(e,n=!1){let s;return t(()=>{var t;null==(t=m.current)||t.unsubscribe(),m.current=s=d(l(e,{subscriptionOptions:x.current,forceRefetch:!n})),p(e)}),s},[d,l]),g=Pe.useCallback(()=>{var t,n;(null==(t=m.current)?void 0:t.queryCacheKey)&&d(e.internalActions.removeQueryResult({queryCacheKey:null==(n=m.current)?void 0:n.queryCacheKey}))},[d]);return Pe.useEffect(()=>()=>{var e;null==(e=null==m?void 0:m.current)||e.unsubscribe()},[]),Pe.useEffect(()=>{u===mx||m.current||f(u,!0)},[u,f]),Pe.useMemo(()=>[f,u,{reset:g}],[f,u,g])},r=m(s,d);return{useQueryState:r,useQuerySubscription:i,useLazyQuerySubscription:a,useLazyQuery(e){const[t,n,{reset:s}]=a(e),i=r(n,{...e,skip:n===mx}),o=Pe.useMemo(()=>({lastArg:n}),[n]);return Pe.useMemo(()=>[t,{...i,reset:s},o],[t,i,s,o])},useQuery(e,t){const n=i(e,t),s=r(e,{selectFromResult:e===Wh||(null==t?void 0:t.skip)?void 0:bx,...t}),a=yx(s,...wx);return Pe.useDebugValue(a),Pe.useMemo(()=>({...s,...n}),[s,n])}}},buildInfiniteQueryHooks:function(e){const n=(n,s={})=>{const[i,a,r,o]=p(e,n,s),l=Pe.useRef(o);c(()=>{l.current=o},[o]);const d=Pe.useCallback(function(e,n){let s;return t(()=>{var t;null==(t=i.current)||t.unsubscribe(),i.current=s=a(r(e,{subscriptionOptions:l.current,direction:n}))}),s},[i,a,r]);h(i);const u=hx(s.skip?Wh:n),m=Pe.useCallback(()=>x(i),[i]);return Pe.useMemo(()=>({trigger:d,refetch:m,fetchNextPage:()=>d(u,"forward"),fetchPreviousPage:()=>d(u,"backward")}),[m,d,u])},s=m(e,u);return{useInfiniteQueryState:s,useInfiniteQuerySubscription:n,useInfiniteQuery(e,t){const{refetch:i,fetchNextPage:a,fetchPreviousPage:r}=n(e,t),o=s(e,{selectFromResult:e===Wh||(null==t?void 0:t.skip)?void 0:bx,...t}),l=yx(o,...wx,"hasNextPage","hasPreviousPage");return Pe.useDebugValue(l),Pe.useMemo(()=>({...o,fetchNextPage:a,fetchPreviousPage:r,refetch:i}),[o,a,r,i])}}},buildMutationHook:function(i){return({selectFromResult:a,fixedCacheKey:o}={})=>{const{select:l,initiate:c}=e.endpoints[i],d=n(),[u,p]=Pe.useState();Pe.useEffect(()=>()=>{(null==u?void 0:u.arg.fixedCacheKey)||null==u||u.reset()},[u]);const m=Pe.useCallback(function(e){const t=d(c(e,{fixedCacheKey:o}));return p(t),t},[d,c,o]),{requestId:h}=u||{},x=Pe.useMemo(()=>l({fixedCacheKey:o,requestId:null==u?void 0:u.requestId}),[o,u,l]),f=Pe.useMemo(()=>a?r([x],a):x,[a,x]),g=s(f,_t),v=null==o?null==u?void 0:u.arg.originalArgs:void 0,b=Pe.useCallback(()=>{t(()=>{u&&p(void 0),o&&d(e.internalActions.removeMutationResult({requestId:h,fixedCacheKey:o}))})},[d,o,u,h]),y=yx(g,...wx,"endpointName");Pe.useDebugValue(y);const w=Pe.useMemo(()=>({...g,originalArgs:v,reset:b}),[g,v,b]);return Pe.useMemo(()=>[m,w],[m,w])}},usePrefetch:function(t,s){const i=n(),a=xx(s);return Pe.useCallback((n,s)=>i(e.util.prefetch(t,n,{...a,...s})),[t,i,a])}};function d(e,t,n){if((null==t?void 0:t.endpointName)&&e.isUninitialized){const{endpointName:e}=t,s=l.endpointDefinitions[e];n!==Wh&&o({queryArgs:t.originalArgs,endpointDefinition:s,endpointName:e})===o({queryArgs:n,endpointDefinition:s,endpointName:e})&&(t=void 0)}let s=e.isSuccess?e.data:null==t?void 0:t.data;void 0===s&&(s=e.data);const i=void 0!==s,a=e.isLoading,r=(!t||t.isLoading||t.isUninitialized)&&!i&&a,c=e.isSuccess||i&&(a&&!(null==t?void 0:t.isError)||e.isUninitialized);return{...e,data:s,currentData:e.data,isFetching:a,isLoading:r,isSuccess:c}}function u(e,t,n){if((null==t?void 0:t.endpointName)&&e.isUninitialized){const{endpointName:e}=t,s=l.endpointDefinitions[e];n!==Wh&&o({queryArgs:t.originalArgs,endpointDefinition:s,endpointName:e})===o({queryArgs:n,endpointDefinition:s,endpointName:e})&&(t=void 0)}let s=e.isSuccess?e.data:null==t?void 0:t.data;void 0===s&&(s=e.data);const i=void 0!==s,a=e.isLoading,r=(!t||t.isLoading||t.isUninitialized)&&!i&&a,c=e.isSuccess||a&&i;return{...e,data:s,currentData:e.data,isFetching:a,isLoading:r,isSuccess:c}}function p(t,s,{refetchOnReconnect:i,refetchOnFocus:a,refetchOnMountOrArgChange:r,skip:o=!1,pollingInterval:d=0,skipPollingIfUnfocused:u=!1,...p}={}){const{initiate:m}=e.endpoints[t],h=n(),x=Pe.useRef(void 0);if(!x.current){const t=h(e.internalActions.internal_getRTKQSubscriptions());x.current=t}const f=hx(o?Wh:s),g=xx({refetchOnReconnect:i,refetchOnFocus:a,pollingInterval:d,skipPollingIfUnfocused:u}),v=xx(p.initialPageParam),b=Pe.useRef(void 0);let{queryCacheKey:y,requestId:w}=b.current||{},j=!1;y&&w&&(j=x.current.isRequestSubscribed(y,w));const C=!j&&void 0!==b.current;return c(()=>{C&&(b.current=void 0)},[C]),c(()=>{var e;const n=b.current;if(f===Wh)return null==n||n.unsubscribe(),void(b.current=void 0);const s=null==(e=b.current)?void 0:e.subscriptionOptions;if(n&&n.arg===f)g!==s&&n.updateSubscriptionOptions(g);else{null==n||n.unsubscribe();const e=h(m(f,{subscriptionOptions:g,forceRefetch:r,...ux(l.endpointDefinitions[t])?{initialPageParam:v}:{}}));b.current=e}},[h,m,r,f,g,C,v,t]),[b,h,m,g]}function m(t,n){return(a,{skip:o=!1,selectFromResult:l}={})=>{const{select:c}=e.endpoints[t],d=hx(o?Wh:a),u=Pe.useRef(void 0),p=Pe.useMemo(()=>r([c(d),(e,t)=>t,e=>d],n,{memoizeOptions:{resultEqualityCheck:_t}}),[c,d]),m=Pe.useMemo(()=>l?r([p],l,{devModeChecks:{identityFunctionCheck:"never"}}):p,[p,l]),h=s(e=>m(e,u.current),_t),x=i(),f=p(x.getState(),u.current);return vx(()=>{u.current=f},[f]),h}}function h(e){Pe.useEffect(()=>()=>{var t,n;null==(n=null==(t=e.current)?void 0:t.unsubscribe)||n.call(t),e.current=void 0},[e])}function x(e){if(!e.current)throw new Error(tt(38));return e.current.refetch()}}({api:i,moduleOptions:{batch:e,hooks:t,unstable__sideEffectsInRender:s,createSelector:n},serializeQueryArgs:a,context:r});return px(o,{usePrefetch:u}),px(r,{batch:e}),{injectEndpoint(e,t){if("query"===t.type){const{useQuery:t,useLazyQuery:n,useLazyQuerySubscription:s,useQueryState:a,useQuerySubscription:r}=l(e);px(o.endpoints[e],{useQuery:t,useLazyQuery:n,useLazyQuerySubscription:s,useQueryState:a,useQuerySubscription:r}),i[`use${dx(e)}Query`]=t,i[`useLazy${dx(e)}Query`]=n}if(function(e){return"mutation"===e.type}(t)){const t=d(e);px(o.endpoints[e],{useMutation:t}),i[`use${dx(e)}Mutation`]=t}else if(ux(t)){const{useInfiniteQuery:t,useInfiniteQuerySubscription:n,useInfiniteQueryState:s}=c(e);px(o.endpoints[e],{useInfiniteQuery:t,useInfiniteQuerySubscription:n,useInfiniteQueryState:s}),i[`use${dx(e)}InfiniteQuery`]=t}}}}}))());const Nx=async()=>{try{return vp()?await window.electron.ipcRenderer.invoke("get-app-version"):"1.0.21"}catch(e){return"1.0.18"}},Fx=yh({baseUrl:Yt.apiBaseUrl,prepareHeaders:async(e,{endpoint:t})=>{var n;const s=await en.auth.getSession();return(null==(n=s.data.session)?void 0:n.access_token)&&e.set("Authorization",`Bearer ${s.data.session.access_token}`),"transcribeAudio"!==t&&e.set("Content-Type","application/json"),e}}),_x=yh({baseUrl:Yt._file_upload_url,prepareHeaders:async e=>{var t;const n=await en.auth.getSession();(null==(t=n.data.session)?void 0:t.access_token)&&e.set("Authorization",`Bearer ${n.data.session.access_token}`);const s=Yt.apiBaseUrl;if(s&&s.includes(".run.app")){const t=s.match(/agent-service-([^-]+)-\d+\..*\.run\.app/);t&&t[1]&&e.set("eph_name",t[1])}return e}}),kx=Cx({reducerPath:"api",baseQuery:Fx,tagTypes:["GitHubInstallations","GitHubRepositories","GitHubBranches","GitHubUserDetails","PreviewURL","Referral","DownloadCode","Credits","ProModePayment","Budget","Jobs","Config","SubscriptionPlans","SubscriptionStatus","Workspace"],endpoints:e=>({archiveJob:e.mutation({query:({jobId:e,deletedBy:t})=>({url:`/jobs/v0/${e}/archive`,method:"POST",body:{deletedBy:t}})}),getGitHubUserDetails:e.query({query:()=>{let e="";try{const t=localStorage.getItem("pending_referral_code");if(t){e=JSON.parse(t).code}}catch(s){}const t=Fp(),n={};return Object.keys(t).length>0&&(n.ads_metadata=t),{url:"/user/details"+(e?`?referral_code=${e}`:""),method:"POST",body:n}},providesTags:["GitHubUserDetails"],transformResponse:e=>{if(e.referral_message){try{const t={shouldShow:!0,message:e.referral_message,reward:e.reward_amount||5,timestamp:Date.now()};localStorage.setItem("referral_modal_data",JSON.stringify(t))}catch(t){}try{localStorage.removeItem("pending_referral_code")}catch(t){}}return e},transformErrorResponse:e=>{var t;return{id:null,github:{authorized:!1,account_name:""},referral_info:{referral_code:"",referrer_email:null,signed_up_at:""},github_installations:[],error:(null==(t=e.data)?void 0:t.detail)||"Failed to fetch user details"}}}),getGitHubInstallations:e.query({query:()=>"/github/installations",providesTags:["GitHubInstallations"],transformResponse:e=>{if(e.error)throw new Error(e.error);return(Array.isArray(e)?e:[]).map(e=>{var t,n,s;return{installation_id:(null==(t=e.account)?void 0:t.login)||e.account_login,account_login:(null==(n=e.account)?void 0:n.login)||e.account_login,account_type:e.target_type||e.account_type,user_github_login:(null==(s=e.account)?void 0:s.login)||e.user_github_login,app_slug:e.app_slug,isPrimary:!1,account:e.account,target_type:e.target_type}})},transformErrorResponse:e=>{var t;return{installations:[],error:(null==(t=e.data)?void 0:t.message)||"Failed to fetch installations"}}}),getGitHubRepositories:e.query({query:e=>e?`/github/repositories?account_login=${encodeURIComponent(e)}`:"/github/repositories",providesTags:(e,t,n)=>[{type:"GitHubRepositories",id:n||"ALL"}],transformResponse:(e,t,n)=>{if(e.error)throw new Error(e.error);const s=e.repositories||[];return n?s.filter(e=>{var t,s;return(null==(t=e.owner)?void 0:t.login)===n||(null==(s=e.full_name)?void 0:s.startsWith(`${n}/`))}):s},transformErrorResponse:e=>{var t;return{repositories:[],error:(null==(t=e.data)?void 0:t.message)||"Failed to fetch repositories"}}}),getGitHubBranches:e.query({query:({accountLogin:e,repoName:t})=>`/github/branches/${encodeURIComponent(e)}/${encodeURIComponent(t)}`,providesTags:(e,t,{accountLogin:n,repoName:s})=>[{type:"GitHubBranches",id:`${n}/${s}`}],transformResponse:e=>{if(e.error)throw new Error(e.error);return Array.isArray(e)?e:Array.isArray(e.branches)?e.branches:[]},transformErrorResponse:e=>{var t;return{branches:[],error:(null==(t=e.data)?void 0:t.message)||"Failed to fetch branches"}}}),createGitHubRepository:e.mutation({query:e=>({url:"/github/repositories",method:"POST",body:e}),invalidatesTags:["GitHubRepositories"]}),pushToGitHub:e.mutation({query:({jobId:e,data:t})=>({url:`/jobs/v0/push_to_github/${e}`,method:"POST",body:t}),invalidatesTags:["GitHubRepositories","GitHubBranches"]}),saveGitHubInstallation:e.mutation({query:({installationId:e,code:t})=>({url:"/github/installation",method:"POST",body:{installation_id:e,code:t}}),invalidatesTags:["GitHubInstallations","GitHubUserDetails"]}),getJobPreviewUrl:e.query({query:e=>`/jobs/v0/${e}/preview`,providesTags:(e,t,n)=>[{type:"PreviewURL",id:n}],transformResponse:e=>e,transformErrorResponse:e=>{var t;return{error:(null==(t=e.data)?void 0:t.message)||"Failed to fetch preview URL"}}}),getCodeDownloadUrl:e.query({query:e=>`/download/pod-backup/download-zip?job_id=${e}`,providesTags:(e,t,n)=>[{type:"DownloadCode",id:n}],transformResponse:e=>e,transformErrorResponse:e=>{var t;return{error:(null==(t=e.data)?void 0:t.message)||"Failed to fetch download URL"}}}),getCreditsBalance:e.query({query:e=>({url:"/credits/balance",params:(null==e?void 0:e.organization_id)?{organization_id:e.organization_id}:{}}),providesTags:["Credits"],transformResponse:e=>{if(e.error)throw new Error(e.error);return e},transformErrorResponse:e=>{var t,n;return{error:(null==(t=e.data)?void 0:t.message)||(null==(n=e.data)?void 0:n.detail)||"Failed to fetch credits balance",ecu_balance:0,top_up_credit_balance:0,monthly_credits_balance:0,monthly_credits_refresh_date:"",subscription:{id:"",name:"",status:"free",expires_at:!1,monthly_credit_limit:5,subscription_details:{id:"",amount:0}}}}}),checkProModePayment:e.query({query:({tag:e})=>`/payments/custom-payments/check?tag=${encodeURIComponent(e)}`,providesTags:["ProModePayment"],transformResponse:e=>e,transformErrorResponse:e=>{var t,n;return{exists:!1,error:(null==(t=e.data)?void 0:t.message)||(null==(n=e.data)?void 0:n.detail)||"Failed to check payment status"}}}),getSubscriptionPlans:e.query({query:e=>({url:"/payments/subscription/plans",params:(null==e?void 0:e.organization_id)?{organization_id:e.organization_id}:{}}),providesTags:["SubscriptionPlans"],transformResponse:e=>e,transformErrorResponse:e=>{var t,n;return{current_subscription:null,available_plans:[],error:(null==(t=e.data)?void 0:t.message)||(null==(n=e.data)?void 0:n.detail)||"Failed to fetch subscription plans"}}}),checkSubscriptionStatus:e.query({query:({paymentId:e,organizationId:t})=>({url:`/payments/${e}/status`,params:t?{organization_id:t}:{}}),providesTags:(e,t,{paymentId:n})=>[{type:"SubscriptionStatus",id:n}],transformResponse:e=>e,transformErrorResponse:e=>{var t,n,s,i;return{status:"failed",message:(null==(t=e.data)?void 0:t.message)||(null==(n=e.data)?void 0:n.detail)||"Failed to check subscription status",error:(null==(s=e.data)?void 0:s.message)||(null==(i=e.data)?void 0:i.detail)||"Failed to check subscription status"}}}),getBudget:e.query({query:({jobId:e,organization_id:t})=>({url:`/budget/${e}`,params:t?{organization_id:t}:{}}),providesTags:(e,t,{jobId:n})=>[{type:"Budget",id:n}],transformResponse:e=>{var t;if(!e.success)throw new Error((null==(t=e.data)?void 0:t.error)||"Failed to fetch budget");return e.data},transformErrorResponse:e=>{var t,n;return{error:(null==(t=e.data)?void 0:t.error)||(null==(n=e.data)?void 0:n.detail)||"Failed to fetch budget information"}}}),updateBudget:e.mutation({query:({jobId:e,amount:t,organization_id:n})=>({url:`/budget/${e}`,method:"PUT",body:{amount:t},params:n?{organization_id:n}:{}}),invalidatesTags:(e,t,{jobId:n})=>[{type:"Budget",id:n}],transformResponse:e=>{var t;if(!e.success)throw new Error((null==(t=e.data)?void 0:t.error)||"Failed to update budget");return e.data},transformErrorResponse:e=>{var t,n;return{error:(null==(t=e.data)?void 0:t.error)||(null==(n=e.data)?void 0:n.detail)||"Failed to update budget"}}}),getJobs:e.query({query:e=>{const t=`/jobs/v0/?limit=${(null==e?void 0:e.limit)||250}`;return(null==e?void 0:e.organization_id)?`${t}&organization_id=${encodeURIComponent(e.organization_id)}`:t},providesTags:(e,t,n)=>[{type:"Jobs",id:(null==n?void 0:n.organization_id)||"ALL"}],transformResponse:e=>(null==e?void 0:e.jobs)||[],transformErrorResponse:e=>{var t,n;return{error:(null==(t=e.data)?void 0:t.message)||(null==(n=e.data)?void 0:n.detail)||"Failed to fetch jobs"}}}),getJob:e.query({query:e=>`/jobs/v0/${e}/`,providesTags:(e,t,n)=>[{type:"Jobs",id:n}],transformResponse:e=>e,transformErrorResponse:e=>{var t,n;return{error:(null==(t=e.data)?void 0:t.message)||(null==(n=e.data)?void 0:n.detail)||"Failed to fetch job"}}}),getConfig:e.query({queryFn:async(e,t,n,s)=>{try{const t=await _g(),n={app_version:t||await Nx()};(null==e?void 0:e.organization_id)&&(n.organization_id=e.organization_id);const i=await s({url:"/repositories/config",params:n});return i.error?{error:i.error}:{data:i.data}}catch(i){return{error:{status:"CUSTOM_ERROR",error:i instanceof Error?i.message:"Failed to fetch config"}}}},providesTags:["Config"]}),uploadFileStream:e.mutation({queryFn:async({jobId:e,file:t,fileName:n,description:s},i)=>{const a=new URLSearchParams({job_id:e,file_name:n});s&&a.set("description",s);const r=await _x({url:`/api/v1/files/stream?${a}`,method:"POST",body:t,headers:{"Content-Type":"application/octet-stream","Content-Length":t.size.toString()}},i,{});return r.error?{error:r.error}:{data:r.data}}}),submitHITL:e.mutation({query:({payload:e,client_ref_id:t,resume:n=!1,finalize_artifact_upload:s})=>{const i={client_ref_id:t,payload:{processor_type:"env_only",is_cloud:!0,env_image:e.env_image,branch:"",repository:"",...e,...e.testMode&&{test_mode_on:"true"}},model_name:e.model_name,resume:n};return s&&(i.finalize_artifact_upload=s),n&&(i.id=t),{url:"/jobs/v0/hitl-queue/",method:"POST",body:i}}}),deployExpoApp:e.mutation({query:e=>({url:`/jobs/v0/${e}/persist-environment`,method:"POST",body:{}}),invalidatesTags:(e,t,n)=>[{type:"Jobs",id:n}],transformResponse:e=>e,transformErrorResponse:e=>{var t,n;return{error:(null==(t=e.data)?void 0:t.detail)||(null==(n=e.data)?void 0:n.error)||"Failed to publish app"}}}),checkDeployStatus:e.query({query:({jobId:e,organization_id:t})=>({url:`/jobs/v0/deploy/${e}/latest`,params:t?{organization_id:t}:{}}),providesTags:(e,t,{jobId:n})=>[{type:"Jobs",id:`deploy-status-${n}`}],transformResponse:e=>{if(!e||"object"!=typeof e)throw new Error("Invalid response format");if(!e.status)throw new Error("Missing status in response");return e},transformErrorResponse:e=>{var t,n,s;let i="Failed to get deployment status";return(null==(t=e.data)?void 0:t.detail)?i=e.data.detail:(null==(n=e.data)?void 0:n.message)?i=e.data.message:(null==(s=e.data)?void 0:s.error)&&(i=e.data.error),{error:i}}}),deployApp:e.mutation({query:({jobId:e,image:t,deployment_id:n,acknowledgements:s,db_mode:i,organization_id:a})=>({url:"/jobs/v0/deploy",method:"POST",body:{job_id:e,image:t,deployment_id:n,acknowledgements:s,is_database_persist:i,...a&&{organization_id:a}}}),invalidatesTags:(e,t,{jobId:n})=>[{type:"Jobs",id:`deploy-status-${n}`},{type:"Jobs",id:n}],transformResponse:(e,t,{jobId:n})=>({jobId:n,status:"success",message:null==e?void 0:e.message}),transformErrorResponse:e=>{var t,n,s;let i="Failed to deploy application";return(null==(t=e.data)?void 0:t.detail)?i=e.data.detail:(null==(n=e.data)?void 0:n.message)?i=e.data.message:(null==(s=e.data)?void 0:s.error)&&(i=e.data.error),i.includes("deploy in progress")?i="A deployment is currently in progress. Please wait for it to complete before starting a new one.":i.includes("max apps per user reached: 5 active apps")&&(i="You've reached the maximum limit of 5 active deployments. To deploy a new app, please shut down one of your existing deployments."),{error:i}}}),rollbackDeployment:e.mutation({query:({jobId:e,image:t,organization_id:n})=>({url:"/jobs/v0/deploy",method:"POST",body:{job_id:e,image:t,acknowledgements:"rollback",is_database_persist:!0,...n&&{organization_id:n}}}),invalidatesTags:(e,t,{jobId:n})=>[{type:"Jobs",id:`deploy-status-${n}`},{type:"Jobs",id:n}],transformResponse:(e,t,{jobId:n})=>({jobId:n,status:"success",message:null==e?void 0:e.message}),transformErrorResponse:e=>{var t,n,s;let i="Failed to rollback deployment";return(null==(t=e.data)?void 0:t.detail)?i=e.data.detail:(null==(n=e.data)?void 0:n.message)?i=e.data.message:(null==(s=e.data)?void 0:s.error)&&(i=e.data.error),i.includes("deploy in progress")&&(i="A deployment is currently in progress. Please wait for it to complete before rolling back."),{error:i}}}),getDeploymentHistory:e.query({query:({jobId:e,organization_id:t})=>({url:`/jobs/v0/deploy/${e}/history`,params:t?{organization_id:t}:{}}),providesTags:(e,t,{jobId:n})=>[{type:"Jobs",id:`deployment-history-${n}`}],transformResponse:e=>{if(!e||"object"!=typeof e)throw new Error("Invalid response format");return e},transformErrorResponse:e=>{var t,n;return{error:(null==(t=e.data)?void 0:t.detail)||(null==(n=e.data)?void 0:n.error)||"Failed to load deployment history"}}}),registerDomain:e.mutation({query:({domain:e,jobId:t,organization_id:n})=>({url:"/jobs/v0/domains/register",method:"POST",body:{domain:e,job_id:t,...n&&{organization_id:n}}}),invalidatesTags:(e,t,{jobId:n})=>[{type:"Jobs",id:`deploy-status-${n}`}],transformResponse:e=>e,transformErrorResponse:e=>{var t,n;return{error:(null==(t=e.data)?void 0:t.detail)||(null==(n=e.data)?void 0:n.error)||"Failed to register domain"}}}),verifyDomain:e.mutation({query:({domain:e,jobId:t,organization_id:n})=>({url:"/jobs/v0/domains/verify",method:"POST",body:{domain:e,job_id:t,...n&&{organization_id:n}}}),invalidatesTags:(e,t,{jobId:n})=>[{type:"Jobs",id:`deploy-status-${n}`}],transformResponse:e=>e,transformErrorResponse:e=>{var t,n;return{error:(null==(t=e.data)?void 0:t.detail)||(null==(n=e.data)?void 0:n.error)||"Failed to verify domain"}}}),connectDomain:e.mutation({query:({domain:e,jobId:t,organization_id:n})=>({url:"/jobs/v0/domains/connect",method:"POST",body:{domain:e,job_id:t,...n&&{organization_id:n}}}),invalidatesTags:(e,t,{jobId:n})=>[{type:"Jobs",id:`deploy-status-${n}`}],transformResponse:e=>e,transformErrorResponse:e=>{var t,n;return{error:(null==(t=e.data)?void 0:t.detail)||(null==(n=e.data)?void 0:n.error)||"Failed to connect domain"}}}),unlinkDomain:e.mutation({query:({domain:e,jobId:t,organization_id:n})=>({url:`/jobs/v0/domains/${encodeURIComponent(e)}/apps/${t}`,method:"DELETE",params:n?{organization_id:n}:{}}),invalidatesTags:(e,t,{jobId:n})=>[{type:"Jobs",id:`deploy-status-${n}`}],transformResponse:e=>e,transformErrorResponse:e=>{var t,n;return{error:(null==(t=e.data)?void 0:t.detail)||(null==(n=e.data)?void 0:n.error)||"Failed to unlink domain"}}}),getDeploymentLogs:e.query({query:({jobId:e,organization_id:t})=>({url:`/jobs/v0/deploy/${e}/logs`,params:t?{organization_id:t}:{}}),providesTags:(e,t,{jobId:n})=>[{type:"Jobs",id:`deployment-logs-${n}`}],transformResponse:e=>{if(!e||"object"!=typeof e)throw new Error("Invalid response format");return e},transformErrorResponse:e=>{var t,n;return{error:(null==(t=e.data)?void 0:t.detail)||(null==(n=e.data)?void 0:n.error)||"Failed to load deployment logs"}}}),shutdownDeployment:e.mutation({query:({jobId:e,organization_id:t})=>({url:`/jobs/v0/deploy/${e}`,method:"DELETE",params:t?{organization_id:t}:{}}),invalidatesTags:(e,t,{jobId:n})=>[{type:"Jobs",id:`deploy-status-${n}`},{type:"Jobs",id:`deployment-history-${n}`}],transformResponse:e=>({message:(null==e?void 0:e.message)||"Deployment shut down successfully"}),transformErrorResponse:e=>{var t,n;return{error:(null==(t=e.data)?void 0:t.detail)||(null==(n=e.data)?void 0:n.error)||"Failed to shutdown deployment"}}}),getEnvironmentVariables:e.query({query:({jobId:e,organization_id:t})=>({url:`/jobs/v0/deploy/${e}/envs`,params:t?{organization_id:t}:{}}),providesTags:(e,t,{jobId:n})=>[{type:"Jobs",id:`env-vars-${n}`}],transformResponse:e=>e,transformErrorResponse:e=>{var t,n;return{error:(null==(t=e.data)?void 0:t.detail)||(null==(n=e.data)?void 0:n.error)||"Failed to get environment variables"}}}),updateEnvironmentVariables:e.mutation({query:({jobId:e,envs:t,organization_id:n})=>({url:`/jobs/v0/deploy/${e}/envs/bulk`,method:"PUT",body:{secrets_with_versions:t.reduce((e,t)=>(e[t.key]={value:t.value,version:t.version},e),{}),...n&&{organization_id:n}}}),invalidatesTags:(e,t,{jobId:n})=>[{type:"Jobs",id:`env-vars-${n}`}],transformResponse:e=>e,transformErrorResponse:e=>{var t,n;return{error:(null==(t=e.data)?void 0:t.detail)||(null==(n=e.data)?void 0:n.error)||"Failed to update environment variables"}}}),getDeployments:e.query({query:e=>{const t=e&&"organization_id"in e?e.organization_id:void 0;return{url:"/jobs/v0/deployments",params:t?{organization_id:t}:{}}},providesTags:["Jobs"],transformResponse:e=>e.map(e=>{var t,n,s;return{id:e.job_id,app_name:e.app_name||e.job_id,deployStatus:e.status||"success",deployUrl:e.deployed_url||"",custom_domain:(null==(t=e.custom_domain)?void 0:t.domain)||"",latest_run:{status:(null==(n=e.latest_run)?void 0:n.status)||e.status||"success",updated_at:(null==(s=e.latest_run)?void 0:s.updated_at)||e.updated_at||e.deployed_at||(new Date).toISOString()},description:e.description||"",deployment_id:e.deployment_id||e.job_id,title:e.title||"Untitled"}}),transformErrorResponse:e=>{var t,n;return{error:(null==(t=e.data)?void 0:t.detail)||(null==(n=e.data)?void 0:n.error)||"Failed to load deployments"}}}),restartEnvironment:e.mutation({query:({jobId:e,upgrade:t=!1})=>({params:{upgrade:t?"true":"false"},url:`/jobs/v0/${e}/restart-environment`,method:"POST"}),invalidatesTags:(e,t,{jobId:n})=>[{type:"Jobs",id:n}],transformResponse:e=>e,transformErrorResponse:e=>{var t,n;return{error:(null==(t=e.data)?void 0:t.detail)||(null==(n=e.data)?void 0:n.error)||"Failed to restart environment"}}}),pauseEnvironment:e.mutation({query:e=>({url:`/jobs/v0/${e}/pause-environment`,method:"POST"}),invalidatesTags:(e,t,n)=>[{type:"Jobs",id:n}],transformResponse:e=>{var t;if(!e.success)throw new Error((null==(t=e.data)?void 0:t.error)||"Failed to pause environment");return e.data},transformErrorResponse:e=>{var t,n;return{error:(null==(t=e.data)?void 0:t.detail)||(null==(n=e.data)?void 0:n.error)||"Failed to pause environment"}}}),createWorkspace:e.mutation({query:({name:e,description:t})=>({url:"/org/create",method:"POST",body:{name:e,description:t}}),invalidatesTags:["Workspace","GitHubUserDetails"],transformResponse:e=>e,transformErrorResponse:e=>{var t,n;return{error:(null==(t=e.data)?void 0:t.detail)||(null==(n=e.data)?void 0:n.error)||"Failed to create workspace"}}}),acceptInvitation:e.mutation({query:({invitation_id:e})=>({url:`/org/invitations/${e}/accept`,method:"POST"}),invalidatesTags:["Workspace","GitHubUserDetails"],transformResponse:e=>e,transformErrorResponse:e=>{var t,n;return{error:(null==(t=e.data)?void 0:t.detail)||(null==(n=e.data)?void 0:n.error)||"Failed to accept invitation"}}}),getOrganizationDetails:e.query({query:e=>`/org/${e}/details`,providesTags:(e,t,n)=>[{type:"Workspace",id:`org-details-${n}`}],transformResponse:e=>e,transformErrorResponse:e=>{var t,n;return{error:(null==(t=e.data)?void 0:t.detail)||(null==(n=e.data)?void 0:n.error)||"Failed to fetch organization details"}}}),changeUserRole:e.mutation({query:({org_id:e,user_id:t,new_role:n})=>({url:`/org/${e}/change-role/${t}`,method:"PATCH",body:{new_role:n}}),invalidatesTags:(e,t,{org_id:n})=>[{type:"Workspace",id:`org-details-${n}`},"GitHubUserDetails"],transformResponse:e=>e,transformErrorResponse:e=>{var t,n;return{error:(null==(t=e.data)?void 0:t.detail)||(null==(n=e.data)?void 0:n.error)||"Failed to change user role"}}}),inviteMembers:e.mutation({query:({org_id:e,invites:t})=>({url:`/org/${e}/invite`,method:"POST",body:{invites:t}}),invalidatesTags:(e,t,{org_id:n})=>[{type:"Workspace",id:`org-details-${n}`},"GitHubUserDetails"],transformResponse:e=>e,transformErrorResponse:e=>{var t,n;return{error:(null==(t=e.data)?void 0:t.detail)||(null==(n=e.data)?void 0:n.error)||"Failed to send invitations"}}}),leaveOrganization:e.mutation({query:({organization_id:e})=>({url:`/org/${e}/leave`,method:"POST"}),invalidatesTags:(e,t,{organization_id:n})=>[{type:"Workspace",id:`org-details-${n}`},"GitHubUserDetails"],transformResponse:e=>e,transformErrorResponse:e=>{var t,n;return{error:(null==(t=e.data)?void 0:t.detail)||(null==(n=e.data)?void 0:n.error)||"Failed to leave organization"}}}),rejectInvitation:e.mutation({query:({invitation_id:e})=>({url:`/org/invitations/${e}/reject`,method:"POST"}),invalidatesTags:()=>["GitHubUserDetails"],transformResponse:e=>e,transformErrorResponse:e=>{var t,n;return{error:(null==(t=e.data)?void 0:t.detail)||(null==(n=e.data)?void 0:n.error)||"Failed to reject invitation"}}}),cancelInvitation:e.mutation({query:({organization_id:e,invitation_id:t})=>({url:`/org/${e}/cancel-invitation/${t}`,method:"POST"}),invalidatesTags:(e,t,{organization_id:n})=>[{type:"Workspace",id:`org-details-${n}`},"GitHubUserDetails"],transformResponse:e=>e,transformErrorResponse:e=>{var t,n;return{error:(null==(t=e.data)?void 0:t.detail)||(null==(n=e.data)?void 0:n.error)||"Failed to remove the user"}}}),deactivateMember:e.mutation({query:({org_id:e,user_id:t})=>({url:`/org/${e}/deactivate-member/${t}`,method:"POST"}),invalidatesTags:(e,t,{org_id:n})=>[{type:"Workspace",id:`org-details-${n}`},"GitHubUserDetails"],transformResponse:e=>e,transformErrorResponse:e=>{var t,n;return{error:(null==(t=e.data)?void 0:t.detail)||(null==(n=e.data)?void 0:n.error)||"Failed to remove member"}}}),updateOrganization:e.mutation({query:({org_id:e,name:t})=>({url:`/org/${e}/update`,method:"PATCH",body:{name:t}}),invalidatesTags:(e,t,{org_id:n})=>[{type:"Workspace",id:`org-details-${n}`},"GitHubUserDetails"],transformResponse:e=>e,transformErrorResponse:e=>{var t,n;return{error:(null==(t=e.data)?void 0:t.detail)||(null==(n=e.data)?void 0:n.error)||"Failed to update organization"}}}),renameJobTitle:e.mutation({query:({job_id:e,title:t})=>({url:`/jobs/v0/${e}/title`,method:"POST",body:{title:t}}),invalidatesTags:(e,t,{job_id:n})=>[{type:"Workspace",id:`org-details-${n}`},"GitHubUserDetails"],transformResponse:e=>e,transformErrorResponse:e=>{var t,n;return{error:(null==(t=e.data)?void 0:t.detail)||(null==(n=e.data)?void 0:n.error)||"Failed to rename Job Title"}}}),transcribeAudio:e.mutation({query:({audio_file:e,language_code:t="en"})=>{const n=new FormData;return n.append("audio_file",e,e.name||"recording.mp3"),n.append("language_code",t),{url:"/transcription/transcribe",method:"POST",body:n,formData:!0}}}),enableAutoHITL:e.mutation({query:e=>({url:`/jobs/v0/auto-hitl/${e}`,method:"POST"}),invalidatesTags:["GitHubUserDetails"],transformResponse:e=>e,transformErrorResponse:e=>{var t,n;return{error:(null==(t=e.data)?void 0:t.detail)||(null==(n=e.data)?void 0:n.error)||"Failed to enable auto-HITL"}}})})}),{useGetGitHubUserDetailsQuery:Sx,useGetGitHubInstallationsQuery:Ex,useGetGitHubRepositoriesQuery:Ix,useGetGitHubBranchesQuery:Ax,useCreateGitHubRepositoryMutation:Tx,usePushToGitHubMutation:Mx,useSaveGitHubInstallationMutation:Dx,useLazyGetJobPreviewUrlQuery:Lx,useLazyGetCodeDownloadUrlQuery:Px,useGetCreditsBalanceQuery:Rx,useLazyCheckProModePaymentQuery:Ox,useGetSubscriptionPlansQuery:zx,useCheckSubscriptionStatusQuery:Bx,useGetBudgetQuery:Hx,useUpdateBudgetMutation:$x,useGetJobsQuery:Vx,useLazyGetJobQuery:Ux,useGetConfigQuery:Wx,useSubmitHITLMutation:qx,useUploadFileStreamMutation:Gx,useDeployExpoAppMutation:Zx,useCheckDeployStatusQuery:Yx,useDeployAppMutation:Kx,useRollbackDeploymentMutation:Jx,useShutdownDeploymentMutation:Qx,useGetDeploymentHistoryQuery:Xx,useRegisterDomainMutation:ef,useVerifyDomainMutation:tf,useConnectDomainMutation:nf,useUnlinkDomainMutation:sf,useLazyGetDeploymentLogsQuery:af,useGetEnvironmentVariablesQuery:rf,useUpdateEnvironmentVariablesMutation:of,useGetDeploymentsQuery:lf,useRestartEnvironmentMutation:cf,useCreateWorkspaceMutation:df,useAcceptInvitationMutation:uf,useGetOrganizationDetailsQuery:pf,useChangeUserRoleMutation:mf,useInviteMembersMutation:hf,useLeaveOrganizationMutation:xf,useRejectInvitationMutation:ff,useCancelInvitationMutation:gf,useDeactivateMemberMutation:vf,useUpdateOrganizationMutation:bf,useRenameJobTitleMutation:yf,useArchiveJobMutation:wf,useTranscribeAudioMutation:jf,useEnableAutoHITLMutation:Cf}=kx,Nf=Cx({reducerPath:"universalKeyApi",baseQuery:yh({baseUrl:Yt.apiBaseUrl,prepareHeaders:async e=>{var t;const n=await en.auth.getSession();return(null==(t=n.data.session)?void 0:t.access_token)&&e.set("Authorization",`Bearer ${n.data.session.access_token}`),e.set("Content-Type","application/json"),e}}),tagTypes:["EmergentKey","UserBudget"],endpoints:e=>({getEmergentKey:e.query({query:e=>{const t=new URLSearchParams;return e&&"organization_id"in e&&e.organization_id&&t.append("organization_id",e.organization_id),"/llm-router/v0/emergent-key"+(t.toString()?`?${t.toString()}`:"")},providesTags:["EmergentKey"],transformResponse:e=>e,transformErrorResponse:e=>{var t;return{error:(null==(t=e.data)?void 0:t.message)||"Failed to fetch emergent key"}}}),updateEmergentKeyConfig:e.mutation({query:e=>{const{organization_id:t,...n}=e,s=new URLSearchParams;return t&&s.append("organization_id",t),{url:"/llm-router/v0/emergent-key/config"+(s.toString()?`?${s.toString()}`:""),method:"PATCH",body:n}},invalidatesTags:["EmergentKey"],transformResponse:e=>e,transformErrorResponse:e=>{var t;return{error:(null==(t=e.data)?void 0:t.message)||"Failed to update emergent key config"}}}),toggleEmergentKey:e.mutation({query:e=>{const{organization_id:t,...n}=e,s=new URLSearchParams;return t&&s.append("organization_id",t),{url:"/llm-router/v0/emergent-key/toggle"+(s.toString()?`?${s.toString()}`:""),method:"POST",body:n}},invalidatesTags:["EmergentKey"],transformResponse:e=>e,transformErrorResponse:e=>{var t;return{error:(null==(t=e.data)?void 0:t.message)||"Failed to toggle emergent key"}}}),regenerateEmergentKey:e.mutation({query:e=>{const t=e||{},{organization_id:n,...s}=t,i=new URLSearchParams;return n&&i.append("organization_id",n),{url:"/llm-router/v0/emergent-key/regenerate"+(i.toString()?`?${i.toString()}`:""),method:"POST",body:s}},invalidatesTags:["EmergentKey"],transformResponse:e=>e,transformErrorResponse:e=>{var t;return{error:(null==(t=e.data)?void 0:t.message)||"Failed to regenerate emergent key"}}}),getUserBudget:e.query({query:e=>{const t=new URLSearchParams;return e&&"organization_id"in e&&e.organization_id&&t.append("organization_id",e.organization_id),"/llm-router/v0/budget"+(t.toString()?`?${t.toString()}`:"")},providesTags:["UserBudget"],transformResponse:e=>e,transformErrorResponse:e=>{var t;return{error:(null==(t=e.data)?void 0:t.message)||"Failed to fetch user budget"}}}),increaseBudget:e.mutation({query:e=>{const{organization_id:t,...n}=e,s=new URLSearchParams;return t&&s.append("organization_id",t),{url:"/llm-router/v0/budget/increase"+(s.toString()?`?${s.toString()}`:""),method:"POST",body:n}},invalidatesTags:["UserBudget"],transformResponse:e=>e,transformErrorResponse:e=>{var t;return{error:(null==(t=e.data)?void 0:t.message)||"Failed to increase budget"}}})})}),{useGetEmergentKeyQuery:Ff,useLazyGetEmergentKeyQuery:_f,useUpdateEmergentKeyConfigMutation:kf,useToggleEmergentKeyMutation:Sf,useRegenerateEmergentKeyMutation:Ef,useGetUserBudgetQuery:If,useLazyGetUserBudgetQuery:Af,useIncreaseBudgetMutation:Tf}=Nf,Mf=Cx({reducerPath:"promodeApi",baseQuery:yh({baseUrl:Yt.apiBaseUrl,prepareHeaders:async e=>{var t;const n=await en.auth.getSession();return(null==(t=n.data.session)?void 0:t.access_token)&&e.set("Authorization",`Bearer ${n.data.session.access_token}`),e.set("Content-Type","application/json"),e}}),tagTypes:["ProModePrompts","AgentTools","MCP"],endpoints:e=>({getBasePrompts:e.query({query:e=>{let t="/prompts/base?include_prompt=true";return(null==e?void 0:e.organization_id)&&(t+=`&organization_id=${e.organization_id}`),t},providesTags:["ProModePrompts"],transformResponse:e=>e,transformErrorResponse:e=>{var t,n;return{error:(null==(t=e.data)?void 0:t.message)||(null==(n=e.data)?void 0:n.detail)||"Failed to fetch base prompts"}}}),getAgentTools:e.query({query:e=>{if("string"==typeof e)return`/prompts/agents/${encodeURIComponent(e)}/tools`;let t=`/prompts/agents/${encodeURIComponent(e.agentName)}/tools`;return e.organization_id&&(t+=`?organization_id=${e.organization_id}`),t},providesTags:["AgentTools"],transformResponse:e=>e,transformErrorResponse:e=>{var t,n;return{error:(null==(t=e.data)?void 0:t.message)||(null==(n=e.data)?void 0:n.detail)||"Failed to fetch agent tools"}}}),getUserPrompts:e.query({query:e=>{const{limit:t=50,offset:n=0,is_main_agent:s,organization_id:i}=e||{};let a=`/prompts/user?limit=${t}&offset=${n}`;return void 0!==s&&(a+=`&is_main_agent=${s}`),i&&(a+=`&organization_id=${i}`),a},providesTags:["ProModePrompts"],transformResponse:e=>e,transformErrorResponse:e=>{var t,n;return{error:(null==(t=e.data)?void 0:t.message)||(null==(n=e.data)?void 0:n.detail)||"Failed to fetch user prompts"}}}),createUserPrompt:e.mutation({query:e=>({url:"/prompts/user",method:"POST",body:e}),invalidatesTags:["ProModePrompts"],transformResponse:e=>e,transformErrorResponse:e=>{var t,n;return{error:(null==(t=e.data)?void 0:t.message)||(null==(n=e.data)?void 0:n.detail)||"Failed to create user prompt"}}}),updateUserPrompt:e.mutation({query:({id:e,data:t})=>({url:`/prompts/user/${e}`,method:"PUT",body:t}),invalidatesTags:["ProModePrompts"],transformResponse:e=>e,transformErrorResponse:e=>{var t,n;return{error:(null==(t=e.data)?void 0:t.message)||(null==(n=e.data)?void 0:n.detail)||"Failed to update user prompt"}}}),getUserPrompt:e.query({query:e=>`/prompts/user/${e}`,providesTags:(e,t,n)=>[{type:"ProModePrompts",id:n}],transformResponse:e=>e,transformErrorResponse:e=>{var t,n;return{error:(null==(t=e.data)?void 0:t.message)||(null==(n=e.data)?void 0:n.detail)||"Failed to fetch user prompt"}}}),deleteUserPrompt:e.mutation({query:e=>({url:`/prompts/user/${e}`,method:"DELETE"}),invalidatesTags:["ProModePrompts"],transformResponse:e=>e,transformErrorResponse:e=>{var t,n;return{error:(null==(t=e.data)?void 0:t.message)||(null==(n=e.data)?void 0:n.detail)||"Failed to delete user prompt"}}}),createMCP:e.mutation({query:e=>({url:"/mcp/",method:"POST",body:e}),invalidatesTags:["MCP"],transformResponse:e=>e,transformErrorResponse:e=>{var t,n;return{error:(null==(t=e.data)?void 0:t.detail)||(null==(n=e.data)?void 0:n.error)||"Failed to create MCP server"}}}),getMCPs:e.query({query:e=>{const{limit:t=50,offset:n=0,organization_id:s}=e||{};let i=`/mcp/?limit=${t}&offset=${n}`;return s&&(i+=`&organization_id=${encodeURIComponent(s)}`),i},providesTags:(e,t,n)=>[{type:"MCP",id:(null==n?void 0:n.organization_id)||"ALL"}],transformResponse:e=>e,transformErrorResponse:e=>{var t,n;return{error:(null==(t=e.data)?void 0:t.detail)||(null==(n=e.data)?void 0:n.error)||"Failed to fetch MCP servers"}}}),getMCPById:e.query({query:e=>`/mcp/${e}`,providesTags:(e,t,n)=>[{type:"MCP",id:n}],transformResponse:e=>e,transformErrorResponse:e=>{var t,n;return{error:(null==(t=e.data)?void 0:t.detail)||(null==(n=e.data)?void 0:n.error)||"Failed to fetch MCP server"}}}),updateMCP:e.mutation({query:({id:e,...t})=>({url:`/mcp/${e}`,method:"PUT",body:t}),invalidatesTags:(e,t,{id:n})=>[{type:"MCP",id:n},"MCP"],transformResponse:e=>e,transformErrorResponse:e=>{var t,n;return{error:(null==(t=e.data)?void 0:t.detail)||(null==(n=e.data)?void 0:n.error)||"Failed to update MCP server"}}}),deleteMCP:e.mutation({query:({id:e,organization_id:t})=>{let n=`/mcp/${e}`;return t&&(n+=`?organization_id=${encodeURIComponent(t)}`),{url:n,method:"DELETE"}},invalidatesTags:(e,t,{organization_id:n})=>[{type:"MCP",id:n||"ALL"},"MCP"],transformResponse:e=>({message:(null==e?void 0:e.message)||"MCP server deleted successfully"}),transformErrorResponse:e=>{var t,n;return{error:(null==(t=e.data)?void 0:t.detail)||(null==(n=e.data)?void 0:n.error)||"Failed to delete MCP server"}}})})}),{useLazyGetBasePromptsQuery:Df,useLazyGetAgentToolsQuery:Lf,useGetUserPromptsQuery:Pf,useLazyGetUserPromptsQuery:Rf,useGetUserPromptQuery:Of,useCreateUserPromptMutation:zf,useUpdateUserPromptMutation:Bf,useCreateMCPMutation:Hf,useGetMCPsQuery:$f,useLazyGetMCPsQuery:Vf,useUpdateMCPMutation:Uf,useDeleteMCPMutation:Wf}=Mf,qf=Ke({name:"menu",initialState:{isOpen:!1,showUniversalKeyTooltip:!1,showModelSelectorTooltip:!1,highlightBroMode:!1},reducers:{openMenu:e=>{e.isOpen=!0},closeMenu:e=>{e.isOpen=!1},toggleMenu:e=>{e.isOpen=!e.isOpen},setShowUniversalKeyTooltip:(e,t)=>{e.showUniversalKeyTooltip=t.payload},setShowModelSelectorTooltip:(e,t)=>{e.showModelSelectorTooltip=t.payload},setHighlightBroMode:(e,t)=>{e.highlightBroMode=t.payload}}}),{openMenu:Gf,closeMenu:Zf,toggleMenu:Yf,setShowUniversalKeyTooltip:Kf,setShowModelSelectorTooltip:Jf,setHighlightBroMode:Qf}=qf.actions,Xf=qf.reducer,eg=Ke({name:"admin",initialState:{isAdminMode:!1},reducers:{enableAdminMode:e=>{e.isAdminMode=!0},disableAdminMode:e=>{e.isAdminMode=!1},toggleAdminMode:e=>{e.isAdminMode=!e.isAdminMode}}}),{enableAdminMode:tg,disableAdminMode:ng,toggleAdminMode:sg}=eg.actions,ig=eg.reducer,ag=Ke({name:"mcp",initialState:{autoEnableServerId:null},reducers:{setAutoEnableServerId:(e,t)=>{e.autoEnableServerId=t.payload},clearAutoEnableServerId:e=>{e.autoEnableServerId=null}}}),{setAutoEnableServerId:rg,clearAutoEnableServerId:og}=ag.actions,lg=ag.reducer,cg={key:"admin",storage:Id},dg=kt({reducer:ut({progress:$d,container:iu,commandQueue:cu,tabs:St({key:"tabs",storage:Md},Lu),deploy:Am,github:ih,[kx.reducerPath]:kx.reducer,[Nf.reducerPath]:Nf.reducer,[Mf.reducerPath]:Mf.reducer,menu:Xf,admin:St(cg,ig),mcp:lg}),middleware:e=>e({serializableCheck:{ignoredActions:[Et,It,At,Tt,Mt,Dt]}}).concat(kx.middleware,Nf.middleware,Mf.middleware)}),ug=Lt(dg);var pg,mg={};var hg=function(){if(pg)return mg;pg=1,Object.defineProperty(mg,"__esModule",{value:!0});const e=()=>"undefined"!=typeof window,t=(t,...n)=>function(e,t,n,s){return new(n||(n=Promise))(function(t,i){function a(e){try{o(s.next(e))}catch(t){i(t)}}function r(e){try{o(s.throw(e))}catch(t){i(t)}}function o(e){var s;e.done?t(e.value):(s=e.value,s instanceof n?s:new n(function(e){e(s)})).then(a,r)}o((s=s.apply(e,[])).next())})}(void 0,0,void 0,function*(){if(e()&&window.blitz)return yield window.blitz(t,...n);throw Error("Blitz is not available, make sure init function has been called.")}),n={init:t=>{try{return(t=>{if(!(((e,t)=>{try{const n=document.getElementById(t)||document.createElement("script");return n.id=t,n.innerText=e,n.crossOrigin="anonymous",document.head.appendChild(n),!0}catch(n){return!1}})(`var exports = { __esModule: true };window._blitzQueue = window._blitzQueue || [];function blitz() {_blitzQueue.push(arguments);}(function () {var a = document.createElement('script');a.type = 'text/javascript';a.async = !0;a.src = 'https://cdn.blitzllama.com/js/blitz.js';var b = document.getElementsByTagName('script')[0];b.parentNode.insertBefore(a, b);})();blitz('init', "${t}");`,"blitz-script")&&e()&&window.blitz))throw Error("Failed to initialize Blitz")})(t),!0}catch(n){return!1}},createUser:e=>{try{return t("createUser",e),!0}catch(n){return!1}},setUserName:e=>{try{return t("setUserName",e),!0}catch(n){return!1}},setUserEmail:e=>{try{return t("setUserEmail",e),!0}catch(n){return!1}},setUserAttribute:(e,n,s)=>{try{return t("setUserAttribute",e,n,s),!0}catch(i){return!1}},setUserProperties:e=>{try{return t("setUserProperties",e),!0}catch(n){return!1}},setSurveyLanguage:e=>{try{return t("setSurveyLanguage",e),!0}catch(n){return!1}},setSurveyTheme:e=>{try{return t("setSurveyTheme",e),!0}catch(n){return!1}},triggerEvent:(e,n)=>{try{return t("triggerEvent",e,n||""),!0}catch(s){return!1}},subscribeEvent:(e,n)=>{try{return t("subscribeEvent",e,n),!0}catch(s){return!1}},logout:()=>{try{return t("logout"),!0}catch(e){return!1}}};return mg.default=n,mg}();const xg=Le(hg);xg.init(Yt.blitzApiKey);const fg=xg,gg=e=>{if(e){const t=e.user_metadata||{};fg.createUser(e.id),fg.setUserEmail(e.email||""),Nd.identify(e.id,{name:t.name||e.email||"Unknown User",email:e.email||"unknown@example.com",isNewUser:!!t.is_new_user,signUpDate:e.created_at||"",lastSignIn:e.last_sign_in_at||"",authProvider:t.provider||"email",hasGithubConnected:!!t.github_connected,userRole:t.role||"user",referrer:document.referrer||localStorage.getItem("user_referrer")||"direct",utmSource:localStorage.getItem("utm_source")||"",utmMedium:localStorage.getItem("utm_medium")||"",utmCampaign:localStorage.getItem("utm_campaign")||"",appVersion:"1.0.32"}),bg("user_identified",{userId:e.id,isNewUser:!!t.is_new_user,authProvider:t.provider||"email",appVersion:"1.0.32"})}else bg("user_session_ended")},vg=(e,t={})=>{const n=dg.getState(),s=n.tabs.activeTab,i=n.tabs.tabStates[s]||{},a={userId:t.userId,jobId:i.jobId||t.jobId,containerId:i.containerId||t.containerId,tabId:s,...t,errorMessage:e instanceof Error?e.message:e,errorStack:e instanceof Error?e.stack:void 0,appVersion:"1.0.32"};Nd.capture("error",a)},bg=(e,t={})=>{const n=dg.getState(),s=n.tabs.activeTab,i=n.tabs.tabStates[s]||{},a=new URLSearchParams(window.location.search),r={jobId:i.jobId||"",containerId:i.containerId||"",tabId:s||"",tabCount:Object.keys(n.tabs.tabStates||{}).length,currentPath:window.location.pathname,referrer:document.referrer,timestamp:(new Date).toISOString(),appVersion:"1.0.32"};a.forEach((e,t)=>{r[`url_param_${t}`]=e}),Object.entries(t).forEach(([e,t])=>{void 0!==t&&("object"==typeof t&&null!==t?r[e]=JSON.stringify(t):"string"==typeof t||"number"==typeof t||"boolean"==typeof t?r[e]=t:null===t&&(r[e]=null))}),Nd.capture(e,r)},yg=(e,t={})=>{bg(`auth_${e}`,{...t,timestamp:(new Date).toISOString()})},wg=(e,t={})=>{bg(`chat_${e}`,{...t,timestamp:(new Date).toISOString()})},jg=(e,t={})=>{bg(`tab_${e}`,{...t,timestamp:(new Date).toISOString()})},Cg=(e,t={})=>{bg(`feature_${e}`,{...t,timestamp:(new Date).toISOString()})},Ng=(e,t={})=>{bg(`task_${e}`,{...t,timestamp:(new Date).toISOString()})},Fg=(e,t={})=>{bg(`onboarding_${e}`,{...t,timestamp:(new Date).toISOString()})},_g=async()=>{var e;try{const t=null==(e=Nd.getFeatureFlag("config_version"))?void 0:e.toString();return null==t?void 0:t.replace(/_/g,".")}catch{try{return await Nx()}catch(t){return}}},kg=e=>!0,Sg=()=>{try{const e=Nd.getFeatureFlag("disable_inputs");return(!0===e||"true"===e)&&"true"===localStorage.getItem("mobile")}catch(e){return!1}},Eg=()=>{try{const e=Nd.getFeatureFlag("mobile_preview_enabled");return!0===e||"true"===e}catch(e){return!1}},Ig=()=>{try{const e=Nd.getFeatureFlag("github_fork_paywall");return!0===e||"true"===e}catch(e){return!1}},Ag=()=>{try{const e=Nd.getFeatureFlag("price_crossed_out");return!0===e||"true"===e}catch(e){return!1}},Tg=()=>{try{const e=Nd.getFeatureFlag("new_workspace_button");return!0===e||"true"===e}catch(e){return!1}},Mg=()=>{try{const e=Nd.getFeatureFlag("public_private_feature");return!0===e||"true"===e}catch(e){return!1}},Dg=()=>{try{const e=Nd.getFeatureFlag("buy_domain_feature");return!0===e||"true"===e}catch(e){return!1}},Lg=(e,t={})=>{bg(`chat_${e}`,{...t,timestamp:(new Date).toISOString()})},Pg=(e,t={})=>{bg(`landing_${e}`,{...t,timestamp:(new Date).toISOString(),page:"landing_page",url:window.location.href,referrer:document.referrer})},Rg=(e,t={})=>{bg(`test_mode_${e}`,{...t,timestamp:(new Date).toISOString()})},Og=(e,t={})=>{bg(`voice_recording_${e}`,{...t,timestamp:(new Date).toISOString()})},zg=()=>{try{const e=Nd.getFeatureFlag("landing_subject_line");return(null==e?void 0:e.toString())||"variant-a"}catch(e){return"variant-a"}},Bg=()=>{try{const e=Nd.getFeatureFlag("is_indian_user");return!0===e||"true"===e}catch(e){return!1}},Hg="event-ask-human",$g="event-finish-tool",Vg="event-deployment-initiated",Ug="event-bulk-write",Wg="user-login";function qg(e,t){try{if(!(null==t?void 0:t.user_id))return;fg.triggerEvent(e,t)}catch(n){}}const Gg=Pe.createContext({user:null,session:null,userDetails:null,loading:!0,refreshSession:async()=>({success:!1}),signOut:async()=>{},signInWithEmail:async()=>({success:!1}),signUpWithEmail:async()=>({success:!1}),signInWithOAuth:async()=>({success:!1}),resetPassword:async()=>({success:!1}),updatePassword:async()=>({success:!1}),resendVerificationEmail:async()=>({success:!1}),verifyInviteCode:async()=>({success:!1})});function Zg({children:e}){const[t,n]=Pe.useState(null),[s,i]=Pe.useState(null),[r,o]=Pe.useState(!0),{toast:l}=un(),c=Re(),{data:d}=Sx(void 0,{skip:!t});Pe.useEffect(()=>{const{data:{subscription:e}}=en.auth.onAuthStateChange(async(e,t)=>{var s,a,r,o,l,c,d;if("SIGNED_OUT"===e)i(null),n(null),gg(null);else if(t&&(i(t),n(t.user),gg(t.user),"SIGNED_IN"===e&&t.user)){u(t.user),qg(Wg,{user_id:t.user.id,user_email:t.user.email,user_id_ends:null==(s=t.user.id)?void 0:s.slice(-1)});const e=sessionStorage.getItem("oauth_provider");if("true"===sessionStorage.getItem("oauth_login_pending")&&e){const n=new Date(t.user.created_at);(new Date).getTime()-n.getTime()<6e4?up(e,t.user.id,t.user.email,{full_name:(null==(a=t.user.user_metadata)?void 0:a.full_name)||(null==(r=t.user.user_metadata)?void 0:r.name),avatar_url:null==(o=t.user.user_metadata)?void 0:o.avatar_url,provider:e}):(l=e,c=t.user.id,d=t.user.email,dp("login",{method:l,user_id:c,user_email:d,login_page:window.location.pathname})),sessionStorage.removeItem("oauth_login_pending"),sessionStorage.removeItem("oauth_provider")}}});return(async()=>{try{const{data:{session:e}}=await en.auth.getSession();e?(i(e),n(e.user),gg(e.user)):gg(null)}catch(e){vg(e instanceof Error?e:String(e),{context:"auth_initialization"}),l({title:"Error",description:"Failed to initialize authentication.",variant:"destructive"})}finally{o(!1)}})(),()=>{e.unsubscribe()}},[l]);const u=async e=>{var t;try{if(null==(t=e.user_metadata)?void 0:t.utm_source)return;const n=localStorage.getItem("utm_source")||"",s=localStorage.getItem("utm_campaign")||"",i=localStorage.getItem("utm_medium")||"",a=localStorage.getItem("utm_content")||"",r=localStorage.getItem("utm_term")||"",o=localStorage.getItem("user_referrer")||"";if(n||s||i||a||r||o){const{error:t}=await en.auth.updateUser({data:{...e.user_metadata,utm_source:n,utm_campaign:s,utm_medium:i,utm_content:a,utm_term:r,user_referrer:o}})}}catch(n){}},p=async()=>{try{yg("logout",{userId:null==t?void 0:t.id}),np(),gg(null),window.location.href="/landing",(null==window?void 0:window.ReactNativeWebView)&&window.ReactNativeWebView.postMessage(JSON.stringify({type:"LOGOUT_EVENT"}))}catch(e){vg(e,{context:"sign_out"}),l({title:"Error",description:"Failed to sign out. Please try again.",variant:"destructive"})}},m={user:t,session:s,userDetails:d,loading:r,signOut:p,signInWithEmail:async(e,t)=>{var n;try{yg("login_attempt",{method:"email",email:e});const{data:s,error:i}=await en.auth.signInWithPassword({email:e,password:t});if(i)return"Email not confirmed"===i.message?(yg("login_failure",{method:"email",email:e,reason:"email_not_confirmed",needsVerification:!0}),c(`/verify?email=${encodeURIComponent(e)}`),{success:!1,error:{needsVerification:!0,message:i.message}}):(yg("login_failure",{method:"email",email:e,reason:i.message,errorCode:i.status||"unknown"}),{success:!1,error:i.message});yg("login_success",{method:"email",email:e,userId:null==(n=null==s?void 0:s.user)?void 0:n.id});return"true"!==localStorage.getItem("first_login_completed")&&(null==s?void 0:s.user)&&(localStorage.setItem("first_login_completed","true"),Fg("first_login",{userId:s.user.id,method:"email",email:e})),{success:!0}}catch(s){return yg("login_failure",{method:"email",email:e,reason:s.message||"unknown_error",isException:!0}),{success:!1,error:s.message||"Failed to sign in"}}},signUpWithEmail:async(e,t,n)=>{try{yg("signup_attempt",{method:"email",email:t});const s=localStorage.getItem("utm_source")||"",i=localStorage.getItem("utm_campaign")||"",a=localStorage.getItem("utm_medium")||"",r=localStorage.getItem("utm_content")||"",o=localStorage.getItem("utm_term")||"",l=localStorage.getItem("user_referrer")||"",c=new URLSearchParams(window.location.search),d=c.toString()?`${window.location.origin}/activate?${c.toString()}`:`${window.location.origin}/activate`,{data:{user:u},error:p}=await en.auth.signUp({email:t,password:n,options:{emailRedirectTo:d,data:{full_name:e,utm_source:s,utm_campaign:i,utm_medium:a,utm_content:r,utm_term:o,user_referrer:l}}});return p?(yg("signup_failure",{method:"email",email:t,reason:p.message,error:p,errorCode:p.status||"unknown"}),{success:!1,error:p.message}):u&&u.identities&&0===u.identities.length?(yg("signup_failure",{method:"email",email:t,reason:"user_already_exists"}),{success:!1,error:"User already exists"}):u&&!u.email_verified?(yg("signup_success",{method:"email",email:t,userId:u.id,needsVerification:!0}),up("email",u.id,t,{needs_verification:!0,full_name:e}),Fg("first_login",{userId:u.id,method:"email",email:t,isSignup:!0,needsVerification:!0}),{success:!0,needsVerification:!0}):(yg("signup_success",{method:"email",email:t,userId:null==u?void 0:u.id}),(null==u?void 0:u.id)&&up("email",u.id,t,{needs_verification:!1,full_name:e}),Fg("first_login",{userId:null==u?void 0:u.id,method:"email",email:t,isSignup:!0}),{success:!0})}catch(s){return yg("signup_failure",{method:"email",email:t,error:s,reason:s.message||"unknown_error",isException:!0}),{success:!1,error:s.message||"Failed to sign up"}}},signInWithOAuth:async e=>{try{yg("login_attempt",{method:e});const n=new URLSearchParams(window.location.search),s=localStorage.getItem("pending_referral_code");if(s&&!n.has("referral")&&!n.has("ref"))try{const e=JSON.parse(s);e.code&&n.set("referral",e.code)}catch(t){n.set("referral",s)}const i=n.toString()?`${window.location.origin}/activate?${n.toString()}`:`${window.location.origin}/activate`,{error:a}=await en.auth.signInWithOAuth({provider:e,options:{redirectTo:i,..."github"===e?{scopes:"repo,read:user,user:email"}:{}}});return a?(yg("login_failure",{method:e,reason:a.message,error:a,errorCode:a.status||"unknown"}),{success:!1,error:a.message}):(sessionStorage.setItem("oauth_login_pending","true"),sessionStorage.setItem("oauth_provider",e),{success:!0})}catch(n){return yg("login_failure",{method:e,error:n,reason:n.message||"unknown_error",isException:!0}),{success:!1,error:n.message||`Failed to sign in with ${e}`}}},resetPassword:async e=>{try{const t=new URLSearchParams(window.location.search),n=t.toString()?`${window.location.origin}/reset-password?${t.toString()}`:`${window.location.origin}/reset-password`,{error:s}=await en.auth.resetPasswordForEmail(e,{redirectTo:n});return s?{success:!1,error:s.message}:{success:!0}}catch(t){return{success:!1,error:t.message||"Failed to send password reset email"}}},updatePassword:async e=>{try{const{error:t}=await en.auth.updateUser({password:e});return await p(),t?{success:!1,error:t.message}:{success:!0}}catch(t){return{success:!1,error:t.message||"Failed to update password"}}},resendVerificationEmail:async e=>{try{const t=new URLSearchParams(window.location.search),n=t.toString()?`${window.location.origin}/activate?${t.toString()}`:`${window.location.origin}/activate`,{error:s}=await en.auth.resend({type:"signup",email:e,options:{emailRedirectTo:n}});return s?{success:!1,error:s.message}:{success:!0}}catch(t){return{success:!1,error:t.message||"Failed to resend verification email"}}},verifyInviteCode:async(e,n)=>{try{const{data:s}=await en.functions.invoke("verify-invite-code",{body:{inviteCode:e.trim(),userId:n||(null==t?void 0:t.id)}});return null===s?{success:!1,error:"Failed to verify invite code"}:s.success?s.banned?{success:!1,banned:!0,error:"Your account has been banned"}:{success:!0}:{success:!1,error:s.error||"Failed to verify invite code"}}catch(s){return{success:!1,error:s.message||"Failed to verify invite code"}}},refreshSession:async()=>{try{const{data:e,error:t}=await en.auth.refreshSession();return t?(vg(t,{context:"refresh_session"}),{success:!1,error:t.message}):(e.session&&(i(e.session),n(e.session.user),gg(e.session.user)),{success:!0})}catch(e){return{success:!1,error:e.message||"Failed to refresh session"}}}};return a.jsx(Gg.Provider,{value:m,children:e})}const Yg=()=>{const e=Pe.useContext(Gg);if(!e)throw new Error("useAuth must be used within an AuthProvider");return e},Kg=Pe.createContext({isLoading:!1,setIsLoading:()=>{}});function Jg({children:e}){const[t,n]=Pe.useState(!1);return a.jsx(Kg.Provider,{value:{isLoading:t,setIsLoading:n},children:e})}const Qg=Pe.createContext(void 0);function Xg({children:e}){var t,n;const s=Oe(),i=Re(),r=Ft(),{user:o}=Yg(),{data:l,isLoading:c}=Sx(void 0,{skip:!o}),d=(null==(t=null==l?void 0:l.organizations)?void 0:t.some(e=>e.created_by===(null==o?void 0:o.id)))||!1,u=[{id:"personal",name:(null==(n=null==o?void 0:o.user_metadata)?void 0:n.name)?`${o.user_metadata.name}'s Personal Space`:"Personal Space",plan:"Free Plan",icon:"👤"},...((null==l?void 0:l.organizations)||[]).map(e=>({id:e.organization_id,name:e.organization_name,plan:"ACTIVE"===e.status?"Team Plan":"Pending Payment",members:e.member_count,icon:"🏢",status:e.status,role:e.role}))],p=Pe.useCallback(()=>{const e=s.pathname.split("/").filter(Boolean);if(0===e.length)return"personal";if("workspace"===e[0]&&e[1]){const t=e[1];return c&&o||u.find(e=>e.id===t)?t:"personal"}return"personal"},[s.pathname,u,c,o])();Pe.useEffect(()=>{r(Iu("personal"===p?"/":`/workspace/${p}`))},[p,r]),Pe.useEffect(()=>{var e;if(o&&!c&&l)try{const t=localStorage.getItem("pending_invitation");if(!t)return;const n=JSON.parse(t);if(Date.now()-n.timestamp>864e5)return void localStorage.removeItem("pending_invitation");(null==(e=l.pending_invitations)?void 0:e.find(e=>e.id===n.invitation_id))||localStorage.removeItem("pending_invitation")}catch(t){localStorage.removeItem("pending_invitation")}},[o,l,c]);const m=Pe.useCallback(e=>{const t="personal"===e?"/":`/workspace/${e}`;s.pathname!==t&&(window.location.href=t),setTimeout(()=>{},100)},[i,s.pathname]),h=Pe.useCallback(()=>u.find(e=>e.id===p),[u,p]),x=Pe.useCallback(()=>"personal"===p,[p]),f=Pe.useCallback(()=>"personal"!==p,[p]),g=Pe.useCallback(()=>f()?p:void 0,[p,f]),v={currentWorkspace:p,workspaces:u,switchWorkspace:m,getCurrentWorkspaceData:h,isPersonalWorkspace:x,isOrganizationWorkspace:f,getCurrentOrganizationId:g,hasCreatedWorkspace:d};return a.jsx(Qg.Provider,{value:v,children:e})}function ev(){const e=Pe.useContext(Qg);if(void 0===e)throw new Error("useWorkspace must be used within a WorkspaceProvider");return e}const tv=Pe.createContext({credits:0,personalCredits:0,orgCredits:0,loading:!0,error:null,tier:"free",personalTier:"free",orgTier:"free",pro_mode:!1,refreshCredits:async()=>{},creditResponse:null,subscriptionPlansResponse:null,personalPlansResponse:null,upgradeDetails:null,currentSubscriptionDetail:null,getUpgradeTierName:()=>"Starter",dailyCreditsEnabled:!1,isTrulyFreeUser:()=>!1});function nv({children:e}){var t,n,s,i,r,o,l;const{user:c}=Yg(),{getCurrentOrganizationId:d}=ev(),u=Oe(),p=d(),[m,h]=Pe.useState({id:"5d98824c-26c1-4dc4-822a-007ad1d5e684",amount:10,name:"Emergent Starter"}),[x,f]=Pe.useState(!1),[g,v]=Pe.useState("free"),[b,y]=Pe.useState(!1),[w,j]=Pe.useState(!1),[C,N]=Pe.useState(null),F=Pe.useRef(null),_=Pe.useRef(0),k=Pe.useRef(null),{data:S,isSuccess:E,isLoading:I}=Sx(void 0,{skip:!c}),{data:A,error:T,isLoading:M,refetch:D}=Rx(p?{organization_id:p}:void 0,{skip:!(null==(t=null==c?void 0:c.user_metadata)?void 0:t.invite_code)||!E,pollingInterval:0}),{data:L,error:P,isLoading:R,refetch:O}=zx(p?{organization_id:p}:void 0,{skip:!(null==(n=null==c?void 0:c.user_metadata)?void 0:n.invite_code)||!E,pollingInterval:0}),{data:z,error:B,isLoading:H,refetch:$}=zx(void 0,{skip:!(null==(s=null==c?void 0:c.user_metadata)?void 0:s.invite_code)||!E,pollingInterval:0}),{data:V,error:U,isLoading:W,refetch:q}=Rx(void 0,{skip:!(null==(i=null==c?void 0:c.user_metadata)?void 0:i.invite_code)||!E,pollingInterval:0}),[G,Z]=Pe.useState("free"),[Y,K]=Pe.useState("free"),[J,Q]=Pe.useState(0),X=(null==A?void 0:A.ecu_balance)||0,ee=(null==V?void 0:V.ecu_balance)||0,te=T&&_.current<3,ne=M||!!te||I||W,se=T&&_.current>=3?"object"==typeof T&&"data"in T&&(null==(r=T.data)?void 0:r.message)||"Failed to fetch credits balance":null,ie=(e,t)=>{if(null==e?void 0:e.current_subscription){const t=e.current_subscription.tier_name.toLowerCase();if(t.includes("team"))return"team";if(t.includes("emergent pro"))return"pro_mode";if(t.includes("standard"))return"standard";if(t.includes("starter"))return"starter";if(t.includes("pro"))return"pro"}const n=t||A;if(!n)return"free";if(!n.subscription||!n.subscription.id)return"free";const s=n.subscription.name.toLowerCase();return s.includes("team")?"team":s.includes("emergent pro")?"pro_mode":s.includes("standard")?"standard":s.includes("starter")?"starter":s.includes("pro")?"pro":"free"};Pe.useEffect(()=>{var e;(null==(e=null==c?void 0:c.user_metadata)?void 0:e.invite_code)&&E&&(D(),O())},[u.pathname,u.search,null==(o=null==c?void 0:c.user_metadata)?void 0:o.invite_code,E,D,O]),Pe.useEffect(()=>{var e;(null==(e=null==c?void 0:c.user_metadata)?void 0:e.invite_code)&&E&&(D(),O())},[p,null==(l=null==c?void 0:c.user_metadata)?void 0:l.invite_code,E,D,O]),Pe.useEffect(()=>{var e,t,n;const s=ie(L,A);v(s);const i=((e,t)=>{var n;if(null==e?void 0:e.current_subscription)return e.current_subscription.tier_name.toLowerCase().includes("emergent pro");const s=t||A;if(null==(n=null==s?void 0:s.subscription)?void 0:n.name)return s.subscription.name.toLowerCase().includes("emergent pro");return!1})(L,A);if(y(i),(null==L?void 0:L.current_subscription)?N({id:L.current_subscription.id,name:L.current_subscription.tier_name,amount:L.current_subscription.amount,ecu_credits:L.current_subscription.ecu_credits??0}):(null==A?void 0:A.subscription)&&A.subscription.id?N({id:A.subscription.id,name:A.subscription.name,amount:(null==(e=A.subscription.subscription_details)?void 0:e.amount)||0,ecu_credits:A.ecu_balance??0}):N(null),(null==A?void 0:A.daily_credits)?f(!0):f(!1),L&&L.plans){const e=null==(t=L.current_subscription)?void 0:t.tier_name.toLowerCase();let n;const s=[];Object.values(L.plans).forEach(e=>{e.monthly_plans&&s.push(...e.monthly_plans),e.yearly_plans&&s.push(...e.yearly_plans)}),s.length>0&&(n=s.find(t=>t.tier_name.toLowerCase()!==e)),n&&h({id:n.id,name:n.tier_name,amount:n.amount})}else(null==(n=null==A?void 0:A.subscription)?void 0:n.subscription_details)&&h({id:A.subscription.subscription_details.id,name:A.subscription.name,amount:A.subscription.subscription_details.amount})},[L,A]),Pe.useEffect(()=>{const e=ie(z,V);Z(e)},[z,V]),Pe.useEffect(()=>{if(d()&&L){const e=ie(L,A);K(e)}else if(d()&&A){const e=ie(void 0,A);K(e)}},[L,A,d]),Pe.useEffect(()=>{d()&&A&&Q(A.ecu_balance||0)},[A,d]),Pe.useEffect(()=>{var e,t;if(T&&c)if(_.current<3){_.current+=1,k.current&&clearTimeout(k.current);const e=1e3*Math.pow(2,_.current-1);k.current=setTimeout(()=>{D(),k.current=null},e)}else bg("credits_fetch_failed",{userId:c.id,errorType:"api_error",errorMessage:"object"==typeof T&&"data"in T&&(null==(e=T.data)?void 0:e.message)||"Failed to fetch credits balance",hasInviteCode:!!(null==(t=c.user_metadata)?void 0:t.invite_code),retryAttempts:_.current}),"object"==typeof T&&"data"in T&&vg(`Credits API returned error after ${_.current} attempts`,{userId:c.id,errorType:"api_response_error",apiResponse:T.data,context:"credits_fetch",retryAttempts:_.current});else T||(_.current=0,k.current&&(clearTimeout(k.current),k.current=null))},[T,c,D]),Pe.useEffect(()=>()=>{F.current&&clearTimeout(F.current),k.current&&clearTimeout(k.current)},[]);const ae={credits:X,personalCredits:ee,orgCredits:J,loading:ne,tier:g,personalTier:G,orgTier:Y,pro_mode:b,error:se,creditResponse:A||null,subscriptionPlansResponse:L||null,personalPlansResponse:z||null,refreshCredits:async()=>{if(!w&&(null==c?void 0:c.user_metadata.invite_code)&&E){_.current=0,k.current&&(clearTimeout(k.current),k.current=null),j(!0);try{await Promise.all([D(),q(),O()])}finally{F.current&&clearTimeout(F.current),F.current=setTimeout(()=>{j(!1),F.current=null},5e3)}}},upgradeDetails:m,currentSubscriptionDetail:C,getUpgradeTierName:(e="organization")=>{if("personal"===e)return"free"===G?"Free":"starter"===G?"Starter":"standard"===G?"Standard":"Pro";if(!m)return"Starter";const t=m.name.replaceAll(" ","").toLowerCase();return t.includes("standard")?"Standard":t.includes("starter")?"Starter":t.includes("pro")?"Pro":"Starter"},dailyCreditsEnabled:x,isTrulyFreeUser:()=>{var e;const t=(null==(e=null==S?void 0:S.organizations)?void 0:e.some(e=>"ACTIVE"===e.status))||!1;return"free"===G&&!t&&!0}};return a.jsx(tv.Provider,{value:ae,children:e})}const sv=()=>{const e=Pe.useContext(tv);if(!e)throw new Error("useCredits must be used within a CreditsProvider");return e},iv="support@emergent.sh",av=3e5,rv="https://help.emergent.sh/",ov="https://help.emergent.sh/articles/549475-deployments-and-custom-domains",lv="https://atlas-kb.com/atlas-e74243keac/articles/546580-understanding-preview-vs-deployed-links?preview=rghmutfqzwoexklyusxsfzqpjxbrkv",cv="https://half-knave-03b.notion.site/Emergent-Tips-and-Tricks-1dc3b3a7b0618095921ac5850421bab5",dv={learnMore:"https://atlas-kb.com/atlas-e74243keac/articles/636555-chat-forking"},uv={discord:"https://discord.gg/X9cqNxYyG8"},pv="https://help.emergent.sh/",mv="https://help.emergent.sh",hv="https://emergententerprise.typeform.com/EmergentBiz",xv="https://expo.dev/client",fv="Use deployment agent to identify the issues. Sharing build error logs when trying to deploy the current app to production. Please analyze these error logs, debug why these are happening and fix them.",gv="I am using emergent deployments, a native functionality that containerizes and deploys applications to Kubernetes. My current deployment is failing with specific errors that need to be resolved through code modifications.The current environment that you are operating in is a sandboxed environment working with MongoDB , the environment where this application would be deployed operates with dedicated atlas provided mongodb.Please analyze the deployment errors below and modify my application code to resolve all issues preventing successful deployment.You should not make any docker related changes, you should only make code level changes that can make the deployment go through.",vv="--logs_identifier--",bv="https://assets.emergent.sh/assets",yv="https://assets.emergent.sh",wv={claude45background:`${yv}/claude_modal_bg.png`,claude45backgroundMobile:`${yv}/claude_mobile_modal_bg.png`,claudeText:`${yv}/ClaudeSonnet45.png`,icons:{code:`${bv}/code.svg`,info:`${bv}/info.svg`,preview:`${bv}/eye.svg`,history:`${bv}/history.svg`,deployCloud:`${bv}/DeployCloud.svg`,redeploy:`${bv}/RedeployNew.svg`,animatedSpinner:`${bv}/animated-spinner.gif`,github:`${bv}/github.svg`,githubIcon:`${bv}/github-icon.svg`,google:`${bv}/Google.svg`,submit:`${bv}/submit-arrow.svg`,task:`${bv}/task.svg`,branch:`${bv}/branch.svg`,branch2:`${bv}/branch2.svg`,emergentLogoNew:`${bv}/emergent-logo-new.svg`,emergentLogoNewBlack:`${bv}/emergent-logo-new-black.svg`,emergentLogoExpoApp:`${yv}/emergent-blue-new.svg`,emergentLogoFavicon:`${yv}/emergent-ico.png`,landingLight:`${bv}/landing-light.png`,bgPatternHome:`${bv}/bg_pattern_home.png`,infoSquare:`${bv}/info-square.svg`,paymentFailed:`${bv}/payment_failed.svg`,copyWhite:`${bv}/copy_white.svg`,eyeOff:`${bv}/eye_off.svg`},fork:{editNote:`${bv}/fork/edit_note.svg`,forkedFrom:`${bv}/fork/forked_from.svg`,session:`${bv}/fork/session.svg`,forkRed:`${bv}/fork/fork_red.svg`,paceCyan:`${bv}/fork/pace_cyan.svg`,matrixCode:`${bv}/fork/matrix_code.gif`,fork:`${bv}/fork/fork.svg`,forkFill:`${bv}/fork/fork-fill.svg`,completed:`${bv}/fork/completed.svg`,dollarCyan:`${bv}/fork/dollar_cyan.svg`,dropdownCyan:`${bv}/fork/dropdown_cyan.svg`,firstState:`${bv}/fork/first_state.svg`,likeCyan:`${bv}/fork/like_cyan.svg`,summary:`${bv}/fork/summary.svg`,summaryCyan:`${bv}/fork/summary_cyan.svg`},teams:{teamAssetDesktop:`${bv}/teams/team_asset_web.png`,teamAssetMobile:`${bv}/teams/team_asset_mobile.png`,org:`${bv}/teams/org.svg`,pendingDot:`${bv}/teams/pending_dot.svg`},landingPage:{landingBg:`${bv}/landing-page/landing-bg.png`,landingBgMobile:`${bv}/landing-page/landing-page-mobile.png`,customAgents:`${bv}/landing-page/custom-agents.png`,footerFiller:`${bv}/landing-page/footer-filler.gif`,landingFillerBackground:`${bv}/landing-page/landing-filler-background.png`,mobile:`${bv}/landing-page/mobile.png`,teams:`${bv}/landing-page/teams.png`,users:`${bv}/landing-page/users.png`},videos:{clouds:`${bv}/videos/clouds.mp4`,bgVid:`${bv}/bg-vid.mp4`},showcase:{whiteArrow:`${bv}/showcase/white_arrow.svg`,image1:`${bv}/showcase/1.png`,image2:`${bv}/showcase/2.png`,image3:`${bv}/showcase/3.png`,image4:`${bv}/showcase/4.png`,image6:`${bv}/showcase/6.png`},feature:{arrowDark:`${bv}/feature/arrow_dark.svg`},oauth:{emergent:`${bv}/oauth/emergent.svg`,envelopeDefault:`${bv}/oauth/envelope-default.svg`,foundationShield:`${bv}/oauth/foundation_shield.svg`,google:`${bv}/oauth/google.svg`,image4:`${bv}/oauth/image 4.png`,layerThree:`${bv}/oauth/layer-three.svg`,nftDefault:`${bv}/oauth/nft-default.svg`,sparkle:`${bv}/oauth/sparkle.svg`},modals:{desktop25mil:`${bv}/modals/Desktop25Mil.png`,mobile25mil:`${bv}/modals/Mobile25Mil.png`,discountButton:`${bv}/modals/DiscountButton.png`},pro:{proBg:`${bv}/pro/pro_bg.png`,secondBanner:`${bv}/pro/secondBanner.png`,darkrobot:`${bv}/pro/darkrobot.svg`,workbench:`${bv}/pro/workbench.svg`,book:`${bv}/pro/book.svg`,external:`${bv}/pro/external.svg`,next:`${bv}/pro/next.svg`,nextArrow:`${bv}/pro/nextArrow.svg`,backGray:`${bv}/pro/back-gray.svg`,bgSvg:`${bv}/pro/bg.svg`},universal:{add:`${bv}/universal/add.svg`,addActive:`${bv}/universal/add-active.svg`,alertBg:`${bv}/universal/alert-bg.svg`,check:`${bv}/universal/check.svg`,claude:`${bv}/universal/claude.svg`,copy:`${bv}/universal/copy.svg`,deleteRegenerate:`${bv}/universal/delete-regenerate.svg`,gemini:`${bv}/universal/gemini.svg`,infoGray:`${bv}/universal/info-gray.svg`,infoOrange:`${bv}/universal/info-orange.svg`,key:`${bv}/universal/key.svg`,nextArrow:`${bv}/universal/next-arrow.svg`,openai:`${bv}/universal/openai.svg`,saveContinue:`${bv}/universal/save-continue.svg`},ultra:{oneMillionUltra:`${bv}/ultra/1M+ultra.png`,oneMillionUltraMobile:`${bv}/ultra/1M+ultra_mobile.png`},mcp:{kuchbhi:`${bv}/mcp/kuchbhi.png`,kuchbhiMobile:`${bv}/mcp/kuchbhi_mobile.png`},deployment:{article:`${bv}/deployment/Article.svg`,goBack:`${bv}/deployment/GoBack.svg`,logWithError:`${bv}/deployment/LogWithError.svg`,logs:`${bv}/deployment/Logs.svg`,webDarkLink:`${bv}/deployment/WebDarkLink.svg`,carbonViewFilled:`${bv}/deployment/carbon_view-filled.svg`,dangerous:`${bv}/deployment/dangerous.svg`,dangerousActive:`${bv}/deployment/dangerous_active.svg`,database:`${bv}/deployment/database.svg`,keyAlert:`${bv}/deployment/key_alert.svg`,mdiCheckAll:`${bv}/deployment/mdi_check-all.svg`,replace:`${bv}/deployment/replace.svg`,replaceBlack:`${bv}/deployment/replace_black.svg`,replaceGrey:`${bv}/deployment/replace_grey.svg`,replaceOrange:`${bv}/deployment/replace_orange.svg`,stripe:`${bv}/deployment/stripe.svg`,timeGreyDeployed:`${bv}/deployment/time_grey_deployed.svg`,warningActive:`${bv}/deployment/warning_active.svg`,warningInactive:`${bv}/deployment/warning_inactive.svg`,webImage:`${bv}/deployment/webImage.svg`},referral:{coin:`${bv}/referral/coin.svg`,credited:`${bv}/referral/credited.svg`,external:`${bv}/referral/external.svg`,giftGreenWithoutGlow:`${bv}/referral/gift-green-withoutGlow.svg`,person:`${bv}/referral/person.svg`,referralImage:`${bv}/referral/referral.png`},payments:{external:`${bv}/payments/external.svg`,externalFilled:`${bv}/payments/external_filled.svg`,infoRed:`${bv}/payments/info-red.svg`,info:`${bv}/payments/info.svg`,question:`${bv}/payments/question.svg`},discountModal:{assetOff:`${bv}/discount-modal/asset_off.png`,bg:`${bv}/discount-modal/bg.png`,text:`${bv}/discount-modal/text.png`},robots:{research:`${bv}/robots/research.svg`,robot1:`${bv}/robots/robot_1.svg`,robot2:`${bv}/robots/robot_2.svg`,robot3:`${bv}/robots/robot_3.svg`,robot4:`${bv}/robots/robot_4.svg`,robot5:`${bv}/robots/robot_5.svg`,robot6:`${bv}/robots/robot_6.svg`,robot7:`${bv}/robots/robot_7.svg`,robot8:`${bv}/robots/robot_8.svg`,robot9:`${bv}/robots/robot_9.svg`,robot10:`${bv}/robots/robot_10.svg`},buy:{buyCoin:`${bv}/Avatars.svg`},upload:{arrowNext:`${bv}/upload/arrow-next.svg`,blueCheck:`${bv}/upload/blue_check.svg`,close:`${bv}/upload/close.svg`,comment:`${bv}/upload/comment.svg`,commented:`${bv}/upload/commented.svg`,delete:`${bv}/upload/delete.svg`,deleteActive:`${bv}/upload/deleteActive.svg`,downloadWhite:`${bv}/upload/download_white.svg`,info:`${bv}/upload/info.svg`,moreIcon:`${bv}/upload/more_icon.svg`,noAssets:`${bv}/upload/no-assets.svg`,uploadNormal:`${bv}/upload/upload_normal.svg`},chips:{surprise:`${bv}/chips/surprise.svg`},panels:{close:`${bv}/panels/close.svg`,link:`${bv}/panels/link.svg`,phone:`${bv}/panels/phone.svg`,shareGray:`${bv}/panels/share-gray.svg`,share:`${bv}/panels/share.svg`},preview:{emergentBlue:`${bv}/preview/emergent_blue.svg`,flappybird:`${bv}/preview/flappybird.png`,gameBoy:`${bv}/preview/game_boy.svg`,gradientArrow:`${bv}/preview/gradient-arrow.svg`,greenArrow:`${bv}/preview/green_arrow.svg`,greenCheck:`${bv}/preview/green_check.svg`,pixelArrow:`${bv}/preview/pixel_arrow.svg`,play:`${bv}/preview/play.svg`,screen:`${bv}/preview/screen.svg`},github:{gitBranchDark:`${bv}/github/GitBranchDark.svg`,githubGreenDark:`${bv}/github/GithubGreenDark.svg`,arrowGreen:`${bv}/github/arrow_green.svg`,emergencyHome:`${bv}/github/emergency_home.svg`,emergencyHomePurple:`${bv}/github/emergency_home_purple.svg`,emergencyHomeRed:`${bv}/github/emergency_home_red.svg`,gitDot:`${bv}/github/git-dot.svg`,gitBranch:`${bv}/github/git_branch.svg`,githubBack:`${bv}/github/github_back.svg`,githubConnected:`${bv}/github/github_connected.svg`,shieldLock:`${bv}/github/shield_lock.svg`},menuIcons:{discord:`${bv}/menu-icons/discord.svg`,discordEndIcon:`${bv}/menu-icons/discord_end_icon.svg`,discordHover:`${bv}/menu-icons/discord_hover.svg`,github:`${bv}/menu-icons/github.svg`,logout:`${bv}/menu-icons/logout.svg`,menu:`${bv}/menu-icons/menu.svg`},files:{csv:`${bv}/files/csv.svg`,doc:`${bv}/files/doc.svg`,other:`${bv}/files/other.svg`,pdf:`${bv}/files/pdf.svg`,ppt:`${bv}/files/ppt.svg`,svg:`${bv}/files/svg.svg`,txt:`${bv}/files/txt.svg`,video:`${bv}/files/video.svg`,zip:`${bv}/files/zip.svg`},cat:{aiAppsBlack:`${bv}/cat/ai_apps_black.svg`,aiAppsWhite:`${bv}/cat/ai_apps_white.svg`,landingPageBlack:`${bv}/cat/landing_page_black.svg`,landingPageWhite:`${bv}/cat/landing_page_white.svg`,microSaasBlack:`${bv}/cat/micro_saas_black.svg`,microSaasWhite:`${bv}/cat/micro_saas_white.svg`,playBlack:`${bv}/cat/play_black.svg`,playWhite:`${bv}/cat/play_white.svg`},tabs:{homeTabIcon:`${bv}/tabs/HomeTab.svg`},subagent:{subagentPanelIcon:`${bv}/subagent/subagentPanel.svg`},tips:{arrowBack:`${bv}/tips/arrow-back.svg`},logo:{borderedLogoDark:`${bv}/logo/borded-logo-dark.svg`,logo:`${bv}/logo/logo.svg`},common:{bot:`${bv}/bot.svg`,githubDark:`${bv}/github_dark.svg`,infoSquaredBlack:`${bv}/info-squared-black.svg`,increaseBudget:`${bv}/increase_budget.svg`,arrowDownBig:`${bv}/ArrowDownBig.svg`,completeTick:`${bv}/Complete_Tick.svg`,copyable:`${bv}/Copyable.svg`,deployTime:`${bv}/DeployTime.svg`,dustBin:`${bv}/DustBin.svg`,eLogoNew:`${bv}/E-logo-new.png`,eLogo:`${bv}/E-logo.png`,githubGreen:`${bv}/GithubGreen.svg`,greenBranch:`${bv}/GreenBranch.svg`,hypeText:`${bv}/HypeText.svg`,joinedBuy:`${bv}/JoinedBuy.svg`,keyPurple:`${bv}/KeyPurple.svg`,landingAuthStar:`${bv}/Landing-Auth-Star.gif`,landingHeroE:`${bv}/Landing-Hero-E.gif`,line:`${bv}/Line.svg`,link:`${bv}/Link.svg`,lockedWeb:`${bv}/LockedWeb.svg`,lockedWebBlue:`${bv}/LockedWebBlue.svg`,plusIcon:`${bv}/PlusIcon.svg`,purpleDownArrow:`${bv}/PurpleDownArrow.svg`,rollbackTime:`${bv}/RollbackTime.svg`,settings:`${bv}/Settings.svg`,sparklingStar:`${bv}/SparklingStar.svg`,stars:`${bv}/Stars.svg`,subscriptionSuccess:`${bv}/SubscriptionSucess.svg`,timeRever:`${bv}/TimeRever.svg`,unlink:`${bv}/Unlink.svg`,whiteCopperCoin:`${bv}/WhiteCopperCoin.svg`,accountSettingsIcon:`${bv}/account-settings-icon.svg`,activeFile:`${bv}/active-file.svg`,adjustIcon:`${bv}/adjust-icon.svg`,agentSleeping:`${bv}/agentsleeping.svg`,alertFill:`${bv}/alert-fill.svg`,alertOrange:`${bv}/alert-orange.svg`,appleWhite:`${bv}/apple-white.svg`,arrowUpRight:`${bv}/arrow-up-right.svg`,arrowUploadReady:`${bv}/arrow-upload-ready.svg`,arrowUploadReadyDark:`${bv}/arrow_upload_ready_dark.svg`,attach:`${bv}/attach.svg`,attachmentCross:`${bv}/attachment-cross.svg`,badgeCheckGray:`${bv}/badge-check-gray.svg`,badgeCheckYellow:`${bv}/badge-check-yellow.svg`,badgeCheck:`${bv}/badge-check.svg`,banner:`${bv}/banner.svg`,bell:`${bv}/bell.svg`,buyCredit:`${bv}/buy_credit.svg`,captivePortal:`${bv}/captive_portal.svg`,close:`${bv}/close.svg`,controls:`${bv}/controls.svg`,copperCoin:`${bv}/copper-coin.svg`,copyPaperclip:`${bv}/copy-paperclip.svg`,copyPurple:`${bv}/copyPurple.svg`,deploy:`${bv}/deploy.svg`,discordLight:`${bv}/discordLight.svg`,expo:`${bv}/expo.svg`,eyeNew:`${bv}/eye_new.svg`,featured:`${bv}/featured.svg`,file:`${bv}/file.svg`,flowbiteRefreshOutline:`${bv}/flowbite_refresh-outline.svg`,fluentEmojiBell:`${bv}/fluent-emoji_bell.svg`,folderAdd:`${bv}/folder-add.svg`,folder:`${bv}/folder.svg`,foregroundImage:`${bv}/foreground-image.png`,githubConnect:`${bv}/github_connect.svg`,globeActive:`${bv}/globe_active.svg`,globeWhite:`${bv}/globe_white.svg`,greenLinkArrow:`${bv}/greenLinkArrow.svg`,iconamoonEditFill:`${bv}/iconamoon_edit-fill.svg`,infoSquare02:`${bv}/info-square-02-contained-filled.svg`,keyboardArrowUp:`${bv}/keyboard_arrow_up.svg`,lineMdLink:`${bv}/line-md_link.svg`,lock:`${bv}/lock.svg`,logoBlue:`${bv}/logo_blue.svg`,mail:`${bv}/mail.svg`,menuInfo:`${bv}/menu-info.svg`,mingcuteQuestionFill:`${bv}/mingcute_question-fill.svg`,newCoin:`${bv}/new_coin.svg`,notificationSound:`${bv}/notification-sound.mp3`,password:`${bv}/password.svg`,pause:`${bv}/pause.svg`,play:`${bv}/play.svg`,recordStopIcon:`${bv}/record-stop-icon.svg`,refresh:`${bv}/refresh.svg`,reply:`${bv}/reply.svg`,repo:`${bv}/repo.svg`,rightArrow:`${bv}/right-arrow.svg`,saveCloud:`${bv}/save-cloud.svg`,send:`${bv}/send.svg`,starsGif:`${bv}/stars.gif`,testFile:`${bv}/test-file.svg`,testModePreview:`${bv}/test-mode-preview.png`,visualEdit:`${bv}/visual_edit.svg`,webImage:`${bv}/webImage.svg`,whiteGithub:`${bv}/white-github.svg`},panelIcons:{panelEdit:`${bv}/panel_icons/panel_edit.json`,panelIntegration:`${bv}/panel_icons/panel_integration.json`,panelTesting:`${bv}/panel_icons/panel_testing.json`,panelVision:`${bv}/panel_icons/panel_vision.json`}},jv="USD",Cv="INR",Nv={[jv]:"$",[Cv]:"₹"};function Fv(e){var t,n,s="";if("string"==typeof e||"number"==typeof e)s+=e;else if("object"==typeof e)if(Array.isArray(e)){var i=e.length;for(t=0;t{const t=Av(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:s}=e;return{getClassGroupId:e=>{const n=e.split("-");return""===n[0]&&1!==n.length&&n.shift(),Sv(n,t)||Iv(e)},getConflictingClassGroupIds:(e,t)=>{const i=n[e]||[];return t&&s[e]?[...i,...s[e]]:i}}},Sv=(e,t)=>{var n;if(0===e.length)return t.classGroupId;const s=e[0],i=t.nextPart.get(s),a=i?Sv(e.slice(1),i):void 0;if(a)return a;if(0===t.validators.length)return;const r=e.join("-");return null==(n=t.validators.find(({validator:e})=>e(r)))?void 0:n.classGroupId},Ev=/^\[(.+)\]$/,Iv=e=>{if(Ev.test(e)){const t=Ev.exec(e)[1],n=null==t?void 0:t.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}},Av=e=>{const{theme:t,prefix:n}=e,s={nextPart:new Map,validators:[]};return Lv(Object.entries(e.classGroups),n).forEach(([e,n])=>{Tv(n,s,e,t)}),s},Tv=(e,t,n,s)=>{e.forEach(e=>{if("string"==typeof e){return void((""===e?t:Mv(t,e)).classGroupId=n)}if("function"==typeof e)return Dv(e)?void Tv(e(s),t,n,s):void t.validators.push({validator:e,classGroupId:n});Object.entries(e).forEach(([e,i])=>{Tv(i,Mv(t,e),n,s)})})},Mv=(e,t)=>{let n=e;return t.split("-").forEach(e=>{n.nextPart.has(e)||n.nextPart.set(e,{nextPart:new Map,validators:[]}),n=n.nextPart.get(e)}),n},Dv=e=>e.isThemeGetter,Lv=(e,t)=>t?e.map(([e,n])=>[e,n.map(e=>"string"==typeof e?t+e:"object"==typeof e?Object.fromEntries(Object.entries(e).map(([e,n])=>[t+e,n])):e)]):e,Pv=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=new Map,s=new Map;const i=(i,a)=>{n.set(i,a),t++,t>e&&(t=0,s=n,n=new Map)};return{get(e){let t=n.get(e);return void 0!==t?t:void 0!==(t=s.get(e))?(i(e,t),t):void 0},set(e,t){n.has(e)?n.set(e,t):i(e,t)}}},Rv=e=>{const{separator:t,experimentalParseClassName:n}=e,s=1===t.length,i=t[0],a=t.length,r=e=>{const n=[];let r,o=0,l=0;for(let u=0;ul?r-l:void 0}};return n?e=>n({className:e,parseClassName:r}):r},Ov=e=>{if(e.length<=1)return e;const t=[];let n=[];return e.forEach(e=>{"["===e[0]?(t.push(...n.sort(),e),n=[]):n.push(e)}),t.push(...n.sort()),t},zv=/\s+/;function Bv(){let e,t,n=0,s="";for(;n{if("string"==typeof e)return e;let t,n="";for(let s=0;st(e),e());return n=(e=>({cache:Pv(e.cacheSize),parseClassName:Rv(e),...kv(e)}))(l),s=n.cache.get,i=n.cache.set,a=r,r(o)};function r(e){const t=s(e);if(t)return t;const a=((e,t)=>{const{parseClassName:n,getClassGroupId:s,getConflictingClassGroupIds:i}=t,a=[],r=e.trim().split(zv);let o="";for(let l=r.length-1;l>=0;l-=1){const e=r[l],{modifiers:t,hasImportantModifier:c,baseClassName:d,maybePostfixModifierPosition:u}=n(e);let p=Boolean(u),m=s(p?d.substring(0,u):d);if(!m){if(!p){o=e+(o.length>0?" "+o:o);continue}if(m=s(d),!m){o=e+(o.length>0?" "+o:o);continue}p=!1}const h=Ov(t).join(":"),x=c?h+"!":h,f=x+m;if(a.includes(f))continue;a.push(f);const g=i(m,p);for(let n=0;n0?" "+o:o)}return o})(e,n);return i(e,a),a}return function(){return a(Bv.apply(null,arguments))}}const Vv=e=>{const t=t=>t[e]||[];return t.isThemeGetter=!0,t},Uv=/^\[(?:([a-z-]+):)?(.+)\]$/i,Wv=/^\d+\/\d+$/,qv=new Set(["px","full","screen"]),Gv=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Zv=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Yv=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,Kv=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Jv=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Qv=e=>eb(e)||qv.has(e)||Wv.test(e),Xv=e=>mb(e,"length",hb),eb=e=>Boolean(e)&&!Number.isNaN(Number(e)),tb=e=>mb(e,"number",eb),nb=e=>Boolean(e)&&Number.isInteger(Number(e)),sb=e=>e.endsWith("%")&&eb(e.slice(0,-1)),ib=e=>Uv.test(e),ab=e=>Gv.test(e),rb=new Set(["length","size","percentage"]),ob=e=>mb(e,rb,xb),lb=e=>mb(e,"position",xb),cb=new Set(["image","url"]),db=e=>mb(e,cb,gb),ub=e=>mb(e,"",fb),pb=()=>!0,mb=(e,t,n)=>{const s=Uv.exec(e);return!!s&&(s[1]?"string"==typeof t?s[1]===t:t.has(s[1]):n(s[2]))},hb=e=>Zv.test(e)&&!Yv.test(e),xb=()=>!1,fb=e=>Kv.test(e),gb=e=>Jv.test(e),vb=$v(()=>{const e=Vv("colors"),t=Vv("spacing"),n=Vv("blur"),s=Vv("brightness"),i=Vv("borderColor"),a=Vv("borderRadius"),r=Vv("borderSpacing"),o=Vv("borderWidth"),l=Vv("contrast"),c=Vv("grayscale"),d=Vv("hueRotate"),u=Vv("invert"),p=Vv("gap"),m=Vv("gradientColorStops"),h=Vv("gradientColorStopPositions"),x=Vv("inset"),f=Vv("margin"),g=Vv("opacity"),v=Vv("padding"),b=Vv("saturate"),y=Vv("scale"),w=Vv("sepia"),j=Vv("skew"),C=Vv("space"),N=Vv("translate"),F=()=>["auto",ib,t],_=()=>[ib,t],k=()=>["",Qv,Xv],S=()=>["auto",eb,ib],E=()=>["","0",ib],I=()=>[eb,ib];return{cacheSize:500,separator:":",theme:{colors:[pb],spacing:[Qv,Xv],blur:["none","",ab,ib],brightness:I(),borderColor:[e],borderRadius:["none","","full",ab,ib],borderSpacing:_(),borderWidth:k(),contrast:I(),grayscale:E(),hueRotate:I(),invert:E(),gap:_(),gradientColorStops:[e],gradientColorStopPositions:[sb,Xv],inset:F(),margin:F(),opacity:I(),padding:_(),saturate:I(),scale:I(),sepia:E(),skew:I(),space:_(),translate:_()},classGroups:{aspect:[{aspect:["auto","square","video",ib]}],container:["container"],columns:[{columns:[ab]}],"break-after":[{"break-after":["auto","avoid","all","avoid-page","page","left","right","column"]}],"break-before":[{"break-before":["auto","avoid","all","avoid-page","page","left","right","column"]}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top",ib]}],overflow:[{overflow:["auto","hidden","clip","visible","scroll"]}],"overflow-x":[{"overflow-x":["auto","hidden","clip","visible","scroll"]}],"overflow-y":[{"overflow-y":["auto","hidden","clip","visible","scroll"]}],overscroll:[{overscroll:["auto","contain","none"]}],"overscroll-x":[{"overscroll-x":["auto","contain","none"]}],"overscroll-y":[{"overscroll-y":["auto","contain","none"]}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[x]}],"inset-x":[{"inset-x":[x]}],"inset-y":[{"inset-y":[x]}],start:[{start:[x]}],end:[{end:[x]}],top:[{top:[x]}],right:[{right:[x]}],bottom:[{bottom:[x]}],left:[{left:[x]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",nb,ib]}],basis:[{basis:F()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",ib]}],grow:[{grow:E()}],shrink:[{shrink:E()}],order:[{order:["first","last","none",nb,ib]}],"grid-cols":[{"grid-cols":[pb]}],"col-start-end":[{col:["auto",{span:["full",nb,ib]},ib]}],"col-start":[{"col-start":S()}],"col-end":[{"col-end":S()}],"grid-rows":[{"grid-rows":[pb]}],"row-start-end":[{row:["auto",{span:[nb,ib]},ib]}],"row-start":[{"row-start":S()}],"row-end":[{"row-end":S()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",ib]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",ib]}],gap:[{gap:[p]}],"gap-x":[{"gap-x":[p]}],"gap-y":[{"gap-y":[p]}],"justify-content":[{justify:["normal","start","end","center","between","around","evenly","stretch"]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal","start","end","center","between","around","evenly","stretch","baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":["start","end","center","between","around","evenly","stretch","baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[v]}],px:[{px:[v]}],py:[{py:[v]}],ps:[{ps:[v]}],pe:[{pe:[v]}],pt:[{pt:[v]}],pr:[{pr:[v]}],pb:[{pb:[v]}],pl:[{pl:[v]}],m:[{m:[f]}],mx:[{mx:[f]}],my:[{my:[f]}],ms:[{ms:[f]}],me:[{me:[f]}],mt:[{mt:[f]}],mr:[{mr:[f]}],mb:[{mb:[f]}],ml:[{ml:[f]}],"space-x":[{"space-x":[C]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[C]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",ib,t]}],"min-w":[{"min-w":[ib,t,"min","max","fit"]}],"max-w":[{"max-w":[ib,t,"none","full","min","max","fit","prose",{screen:[ab]},ab]}],h:[{h:[ib,t,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[ib,t,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[ib,t,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[ib,t,"auto","min","max","fit"]}],"font-size":[{text:["base",ab,Xv]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",tb]}],"font-family":[{font:[pb]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",ib]}],"line-clamp":[{"line-clamp":["none",eb,tb]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",Qv,ib]}],"list-image":[{"list-image":["none",ib]}],"list-style-type":[{list:["none","disc","decimal",ib]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[g]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[g]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:["solid","dashed","dotted","double","none","wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",Qv,Xv]}],"underline-offset":[{"underline-offset":["auto",Qv,ib]}],"text-decoration-color":[{decoration:[e]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:_()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",ib]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",ib]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[g]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top",lb]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",ob]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},db]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[h]}],"gradient-via-pos":[{via:[h]}],"gradient-to-pos":[{to:[h]}],"gradient-from":[{from:[m]}],"gradient-via":[{via:[m]}],"gradient-to":[{to:[m]}],rounded:[{rounded:[a]}],"rounded-s":[{"rounded-s":[a]}],"rounded-e":[{"rounded-e":[a]}],"rounded-t":[{"rounded-t":[a]}],"rounded-r":[{"rounded-r":[a]}],"rounded-b":[{"rounded-b":[a]}],"rounded-l":[{"rounded-l":[a]}],"rounded-ss":[{"rounded-ss":[a]}],"rounded-se":[{"rounded-se":[a]}],"rounded-ee":[{"rounded-ee":[a]}],"rounded-es":[{"rounded-es":[a]}],"rounded-tl":[{"rounded-tl":[a]}],"rounded-tr":[{"rounded-tr":[a]}],"rounded-br":[{"rounded-br":[a]}],"rounded-bl":[{"rounded-bl":[a]}],"border-w":[{border:[o]}],"border-w-x":[{"border-x":[o]}],"border-w-y":[{"border-y":[o]}],"border-w-s":[{"border-s":[o]}],"border-w-e":[{"border-e":[o]}],"border-w-t":[{"border-t":[o]}],"border-w-r":[{"border-r":[o]}],"border-w-b":[{"border-b":[o]}],"border-w-l":[{"border-l":[o]}],"border-opacity":[{"border-opacity":[g]}],"border-style":[{border:["solid","dashed","dotted","double","none","hidden"]}],"divide-x":[{"divide-x":[o]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[o]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[g]}],"divide-style":[{divide:["solid","dashed","dotted","double","none"]}],"border-color":[{border:[i]}],"border-color-x":[{"border-x":[i]}],"border-color-y":[{"border-y":[i]}],"border-color-s":[{"border-s":[i]}],"border-color-e":[{"border-e":[i]}],"border-color-t":[{"border-t":[i]}],"border-color-r":[{"border-r":[i]}],"border-color-b":[{"border-b":[i]}],"border-color-l":[{"border-l":[i]}],"divide-color":[{divide:[i]}],"outline-style":[{outline:["","solid","dashed","dotted","double","none"]}],"outline-offset":[{"outline-offset":[Qv,ib]}],"outline-w":[{outline:[Qv,Xv]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:k()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[g]}],"ring-offset-w":[{"ring-offset":[Qv,Xv]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",ab,ub]}],"shadow-color":[{shadow:[pb]}],opacity:[{opacity:[g]}],"mix-blend":[{"mix-blend":["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity","plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"]}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[s]}],contrast:[{contrast:[l]}],"drop-shadow":[{"drop-shadow":["","none",ab,ib]}],grayscale:[{grayscale:[c]}],"hue-rotate":[{"hue-rotate":[d]}],invert:[{invert:[u]}],saturate:[{saturate:[b]}],sepia:[{sepia:[w]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[s]}],"backdrop-contrast":[{"backdrop-contrast":[l]}],"backdrop-grayscale":[{"backdrop-grayscale":[c]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[d]}],"backdrop-invert":[{"backdrop-invert":[u]}],"backdrop-opacity":[{"backdrop-opacity":[g]}],"backdrop-saturate":[{"backdrop-saturate":[b]}],"backdrop-sepia":[{"backdrop-sepia":[w]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[r]}],"border-spacing-x":[{"border-spacing-x":[r]}],"border-spacing-y":[{"border-spacing-y":[r]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",ib]}],duration:[{duration:I()}],ease:[{ease:["linear","in","out","in-out",ib]}],delay:[{delay:I()}],animate:[{animate:["none","spin","ping","pulse","bounce",ib]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[y]}],"scale-x":[{"scale-x":[y]}],"scale-y":[{"scale-y":[y]}],rotate:[{rotate:[nb,ib]}],"translate-x":[{"translate-x":[N]}],"translate-y":[{"translate-y":[N]}],"skew-x":[{"skew-x":[j]}],"skew-y":[{"skew-y":[j]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",ib]}],accent:[{accent:["auto",e]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",ib]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":_()}],"scroll-mx":[{"scroll-mx":_()}],"scroll-my":[{"scroll-my":_()}],"scroll-ms":[{"scroll-ms":_()}],"scroll-me":[{"scroll-me":_()}],"scroll-mt":[{"scroll-mt":_()}],"scroll-mr":[{"scroll-mr":_()}],"scroll-mb":[{"scroll-mb":_()}],"scroll-ml":[{"scroll-ml":_()}],"scroll-p":[{"scroll-p":_()}],"scroll-px":[{"scroll-px":_()}],"scroll-py":[{"scroll-py":_()}],"scroll-ps":[{"scroll-ps":_()}],"scroll-pe":[{"scroll-pe":_()}],"scroll-pt":[{"scroll-pt":_()}],"scroll-pr":[{"scroll-pr":_()}],"scroll-pb":[{"scroll-pb":_()}],"scroll-pl":[{"scroll-pl":_()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",ib]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[Qv,Xv,tb]}],stroke:[{stroke:[e,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}});function bb(...e){return vb(_v(e))}const yb=e=>"boolean"==typeof e?`${e}`:0===e?"0":e,wb=_v,jb=(e,t)=>n=>{var s;if(null==(null==t?void 0:t.variants))return wb(e,null==n?void 0:n.class,null==n?void 0:n.className);const{variants:i,defaultVariants:a}=t,r=Object.keys(i).map(e=>{const t=null==n?void 0:n[e],s=null==a?void 0:a[e];if(null===t)return null;const r=yb(t)||yb(s);return i[e][r]}),o=n&&Object.entries(n).reduce((e,t)=>{let[n,s]=t;return void 0===s||(e[n]=s),e},{}),l=null==t||null===(s=t.compoundVariants)||void 0===s?void 0:s.reduce((e,t)=>{let{class:n,className:s,...i}=t;return Object.entries(i).every(e=>{let[t,n]=e;return Array.isArray(n)?n.includes({...a,...o}[t]):{...a,...o}[t]===n})?[...e,n,s]:e},[]);return wb(e,r,l,null==n?void 0:n.class,null==n?void 0:n.className)},Cb=jb("inline-flex items-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-all duration-300 ease-in-out focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-20 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input/10 text-background hover:border-input/10 hover:bg-background",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80 px-4 py-3",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-12 pl-3 rounded-[28px] gap-2",sm:"h-9 pl-3 rounded-[28px] gap-2",lg:"h-11 pl-3 rounded-[28px] gap-2",icon:"h-10 w-10"},expandOnHover:{true:"pr-3 hover:pr-6 group",false:"pr-3"}},defaultVariants:{variant:"default",size:"default",expandOnHover:!1}}),Nb=Pe.forwardRef(({className:e,variant:t,size:n,asChild:s=!1,children:i,rightIcon:o,expandOnHover:l,forceHover:c,...d},u)=>{const p=s?r:"button",m=Boolean(o);return a.jsxs(p,{className:bb(Cb({variant:t,size:n,expandOnHover:l,className:e}),m&&"justify-between",!m&&"justify-center",c&&l&&"pr-6"),ref:u,...d,children:[a.jsx("div",{className:"flex items-center w-full",children:i}),o&&a.jsx("div",{className:bb("flex items-center transition-transform duration-300 ease-in-out",l&&c&&"translate-x-2"),children:o})]})});Nb.displayName="Button";const Fb=({children:e,className:t="",containerClassName:n="",dotConfig:s})=>a.jsx("div",{className:`relative h-full md:min-h-screen w-full ${t}`,children:a.jsx("div",{className:`relative h-full md:min-h-screen z-10 ${n}`,children:e})}),_b=Pe.createContext({});function kb(e){const t=Pe.useRef(null);return null===t.current&&(t.current=e()),t.current}const Sb="undefined"!=typeof window,Eb=Sb?Pe.useLayoutEffect:Pe.useEffect,Ib=Pe.createContext(null),Ab=Pe.createContext({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});class Tb extends Pe.Component{getSnapshotBeforeUpdate(e){const t=this.props.childRef.current;if(t&&e.isPresent&&!this.props.isPresent){const e=t.offsetParent,n=e instanceof HTMLElement&&e.offsetWidth||0,s=this.props.sizeRef.current;s.height=t.offsetHeight||0,s.width=t.offsetWidth||0,s.top=t.offsetTop,s.left=t.offsetLeft,s.right=n-s.width-s.left}return null}componentDidUpdate(){}render(){return this.props.children}}function Mb({children:e,isPresent:t,anchorX:n}){const s=Pe.useId(),i=Pe.useRef(null),r=Pe.useRef({width:0,height:0,top:0,left:0,right:0}),{nonce:o}=Pe.useContext(Ab);return Pe.useInsertionEffect(()=>{const{width:e,height:a,top:l,left:c,right:d}=r.current;if(t||!i.current||!e||!a)return;const u="left"===n?`left: ${c}`:`right: ${d}`;i.current.dataset.motionPopId=s;const p=document.createElement("style");return o&&(p.nonce=o),document.head.appendChild(p),p.sheet&&p.sheet.insertRule(`\n [data-motion-pop-id="${s}"] {\n position: absolute !important;\n width: ${e}px !important;\n height: ${a}px !important;\n ${u}px !important;\n top: ${l}px !important;\n }\n `),()=>{document.head.removeChild(p)}},[t]),a.jsx(Tb,{isPresent:t,childRef:i,sizeRef:r,children:Pe.cloneElement(e,{ref:i})})}const Db=({children:e,initial:t,isPresent:n,onExitComplete:s,custom:i,presenceAffectsLayout:r,mode:o,anchorX:l})=>{const c=kb(Lb),d=Pe.useId(),u=Pe.useCallback(e=>{c.set(e,!0);for(const t of c.values())if(!t)return;s&&s()},[c,s]),p=Pe.useMemo(()=>({id:d,initial:t,isPresent:n,custom:i,onExitComplete:u,register:e=>(c.set(e,!1),()=>c.delete(e))}),r?[Math.random(),u]:[n,u]);return Pe.useMemo(()=>{c.forEach((e,t)=>c.set(t,!1))},[n]),Pe.useEffect(()=>{!n&&!c.size&&s&&s()},[n]),"popLayout"===o&&(e=a.jsx(Mb,{isPresent:n,anchorX:l,children:e})),a.jsx(Ib.Provider,{value:p,children:e})};function Lb(){return new Map}function Pb(e=!0){const t=Pe.useContext(Ib);if(null===t)return[!0,null];const{isPresent:n,onExitComplete:s,register:i}=t,a=Pe.useId();Pe.useEffect(()=>{if(e)return i(a)},[e]);const r=Pe.useCallback(()=>e&&s&&s(a),[a,s,e]);return!n&&s?[!1,r]:[!0]}const Rb=e=>e.key||"";function Ob(e){const t=[];return Pe.Children.forEach(e,e=>{Pe.isValidElement(e)&&t.push(e)}),t}const zb=({children:e,custom:t,initial:n=!0,onExitComplete:s,presenceAffectsLayout:i=!0,mode:r="sync",propagate:o=!1,anchorX:l="left"})=>{const[c,d]=Pb(o),u=Pe.useMemo(()=>Ob(e),[e]),p=o&&!c?[]:u.map(Rb),m=Pe.useRef(!0),h=Pe.useRef(u),x=kb(()=>new Map),[f,g]=Pe.useState(u),[v,b]=Pe.useState(u);Eb(()=>{m.current=!1,h.current=u;for(let e=0;e{const f=Rb(e),g=!(o&&!c)&&(u===v||p.includes(f));return a.jsx(Db,{isPresent:g,initial:!(m.current&&!n)&&void 0,custom:t,presenceAffectsLayout:i,mode:r,onExitComplete:g?void 0:()=>{if(!x.has(f))return;x.set(f,!0);let e=!0;x.forEach(t=>{t||(e=!1)}),e&&(null==w||w(),b(h.current),o&&(null==d||d()),s&&s())},anchorX:l,children:e},f)})})},Bb=e=>e;let Hb=Bb;const $b=!1,Vb=["read","resolveKeyframes","update","preRender","render","postRender"],Ub={value:null};function Wb(e,t){let n=!1,s=!0;const i={delta:0,timestamp:0,isProcessing:!1},a=()=>n=!0,r=Vb.reduce((e,n)=>(e[n]=function(e,t){let n=new Set,s=new Set,i=!1,a=!1;const r=new WeakSet;let o={delta:0,timestamp:0,isProcessing:!1},l=0;function c(t){r.has(t)&&(d.schedule(t),e()),l++,t(o)}const d={schedule:(e,t=!1,a=!1)=>{const o=a&&i?n:s;return t&&r.add(e),o.has(e)||o.add(e),e},cancel:e=>{s.delete(e),r.delete(e)},process:e=>{o=e,i?a=!0:(i=!0,[n,s]=[s,n],n.forEach(c),t&&Ub.value&&Ub.value.frameloop[t].push(l),l=0,n.clear(),i=!1,a&&(a=!1,d.process(e)))}};return d}(a,t?n:void 0),e),{}),{read:o,resolveKeyframes:l,update:c,preRender:d,render:u,postRender:p}=r,m=()=>{const a=performance.now();n=!1,i.delta=s?1e3/60:Math.max(Math.min(a-i.timestamp,40),1),i.timestamp=a,i.isProcessing=!0,o.process(i),l.process(i),c.process(i),d.process(i),u.process(i),p.process(i),i.isProcessing=!1,n&&t&&(s=!1,e(m))};return{schedule:Vb.reduce((t,a)=>{const o=r[a];return t[a]=(t,a=!1,r=!1)=>(n||(n=!0,s=!0,i.isProcessing||e(m)),o.schedule(t,a,r)),t},{}),cancel:e=>{for(let t=0;tJb[fre].some(t=>!!e[t])};const Xb=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","ignoreStrict","viewport"]);function ey(e){return e.startsWith("while")||e.startsWith("drag")&&"draggable"!==e||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||Xb.has(e)}let ty=e=>!ey(e);try{(ny=require("@emotion/is-prop-valid").default)&&(ty=e=>e.startsWith("on")?!ey(e):ny(e))}catch(xre){}var ny;function sy(e){if("undefined"==typeof Proxy)return e;const t=new Map;return new Proxy((...t)=>e(...t),{get:(n,s)=>"create"===s?e:(t.has(s)||t.set(s,e(s)),t.get(s))})}const iy=Pe.createContext({});function ay(e){return null!==e&&"object"==typeof e&&"function"==typeof e.start}function ry(e){return"string"==typeof e||Array.isArray(e)}const oy=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],ly=["initial",...oy];function cy(e){return ay(e.animate)||ly.some(t=>ry(e[t]))}function dy(e){return Boolean(cy(e)||e.variants)}function uy(e){const{initial:t,animate:n}=function(e,t){if(cy(e)){const{initial:t,animate:n}=e;return{initial:!1===t||ry(t)?t:void 0,animate:ry(n)?n:void 0}}return!1!==e.inherit?t:{}}(e,Pe.useContext(iy));return Pe.useMemo(()=>({initial:t,animate:n}),[py(t),py(n)])}function py(e){return Array.isArray(e)?e.join(" "):e}const my=Symbol.for("motionComponentSymbol");function hy(e){return e&&"object"==typeof e&&Object.prototype.hasOwnProperty.call(e,"current")}function xy(e,t,n){return Pe.useCallback(s=>{s&&e.onMount&&e.onMount(s),t&&(s?t.mount(s):t.unmount()),n&&("function"==typeof n?n(s):hy(n)&&(n.current=s))},[t])}const{schedule:fy}=Wb(queueMicrotask,!1),gy=e=>e.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),vy="data-"+gy("framerAppearId"),by=Pe.createContext({});function yy(e,t,n,s,i){var a,r;const{visualElement:o}=Pe.useContext(iy),l=Pe.useContext(Kb),c=Pe.useContext(Ib),d=Pe.useContext(Ab).reducedMotion,u=Pe.useRef(null);s=s||l.renderer,!u.current&&s&&(u.current=s(e,{visualState:t,parent:o,props:n,presenceContext:c,blockInitialAnimation:!!c&&!1===c.initial,reducedMotionConfig:d}));const p=u.current,m=Pe.useContext(by);!p||p.projection||!i||"html"!==p.type&&"svg"!==p.type||function(e,t,n,s){const{layoutId:i,layout:a,drag:r,dragConstraints:o,layoutScroll:l,layoutRoot:c}=t;e.projection=new n(e.latestValues,t["data-framer-portal-id"]?void 0:wy(e.parent)),e.projection.setOptions({layoutId:i,layout:a,alwaysMeasureLayout:Boolean(r)||o&&hy(o),visualElement:e,animationType:"string"==typeof a?a:"both",initialPromotionConfig:s,layoutScroll:l,layoutRoot:c})}(u.current,n,i,m);const h=Pe.useRef(!1);Pe.useInsertionEffect(()=>{p&&h.current&&p.update(n,c)});const x=n[vy],f=Pe.useRef(Boolean(x)&&!(null===(a=window.MotionHandoffIsComplete)||void 0===a?void 0:a.call(window,x))&&(null===(r=window.MotionHasOptimisedAnimation)||void 0===r?void 0:r.call(window,x)));return Eb(()=>{p&&(h.current=!0,window.MotionIsMounted=!0,p.updateFeatures(),fy.render(p.render),f.current&&p.animationState&&p.animationState.animateChanges())}),Pe.useEffect(()=>{p&&(!f.current&&p.animationState&&p.animationState.animateChanges(),f.current&&(queueMicrotask(()=>{var e;null===(e=window.MotionHandoffMarkAsComplete)||void 0===e||e.call(window,x)}),f.current=!1))}),p}function wy(e){if(e)return!1!==e.options.allowProjection?e.projection:wy(e.parent)}function jy({preloadedFeatures:e,createVisualElement:t,useRender:n,useVisualState:s,Component:i}){var r,o;function l(e,r){let o;const l={...Pe.useContext(Ab),...e,layoutId:Cy(e)},{isStatic:c}=l,d=uy(e),u=s(e,c);if(!c&&Sb){Pe.useContext(Kb).strict;const e=function(e){const{drag:t,layout:n}=Qb;if(!t&&!n)return{};const s={...t,...n};return{MeasureLayout:(null==t?void 0:t.isEnabled(e))||(null==n?void 0:n.isEnabled(e))?s.MeasureLayout:void 0,ProjectionNode:s.ProjectionNode}}(l);o=e.MeasureLayout,d.visualElement=yy(i,u,l,t,e.ProjectionNode)}return a.jsxs(iy.Provider,{value:d,children:[o&&d.visualElement?a.jsx(o,{visualElement:d.visualElement,...l}):null,n(i,e,xy(u,d.visualElement,r),u,c,d.visualElement)]})}e&&function(e){for(const t in e)Qb[t]={...Qb[t],...e[t]}}(e),l.displayName=`motion.${"string"==typeof i?i:`create(${null!==(o=null!==(r=i.displayName)&&void 0!==r?r:i.name)&&void 0!==o?o:""})`}`;const c=Pe.forwardRef(l);return c[my]=i,c}function Cy({layoutId:e}){const t=Pe.useContext(_b).id;return t&&void 0!==e?t+"-"+e:e}const Ny=e=>t=>"string"==typeof t&&t.startsWith(e),Fy=Ny("--"),_y=Ny("var(--"),ky=e=>!!_y(e)&&Sy.test(e.split("/*")[0].trim()),Sy=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,Ey={};const Iy=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],Ay=new Set(Iy);function Ty(e,{layout:t,layoutId:n}){return Ay.has(e)||e.startsWith("origin")||(t||void 0!==n)&&(!!Ey[e]||"opacity"===e)}const My=e=>Boolean(e&&e.getVelocity),Dy=(e,t)=>t&&"number"==typeof e?t.transform(e):e,Ly=(e,t,n)=>n>t?t:n"number"==typeof e,parse:parseFloat,transform:e=>e},Ry={...Py,transform:e=>Ly(0,1,e)},Oy={...Py,default:1},zy=e=>({test:t=>"string"==typeof t&&t.endsWith(e)&&1===t.split(" ").length,parse:parseFloat,transform:t=>`${t}${e}`}),By=zy("deg"),Hy=zy("%"),$y=zy("px"),Vy=zy("vh"),Uy=zy("vw"),Wy={...Hy,parse:e=>Hy.parse(e)/100,transform:e=>Hy.transform(100*e)},qy={borderWidth:$y,borderTopWidth:$y,borderRightWidth:$y,borderBottomWidth:$y,borderLeftWidth:$y,borderRadius:$y,radius:$y,borderTopLeftRadius:$y,borderTopRightRadius:$y,borderBottomRightRadius:$y,borderBottomLeftRadius:$y,width:$y,maxWidth:$y,height:$y,maxHeight:$y,top:$y,right:$y,bottom:$y,left:$y,padding:$y,paddingTop:$y,paddingRight:$y,paddingBottom:$y,paddingLeft:$y,margin:$y,marginTop:$y,marginRight:$y,marginBottom:$y,marginLeft:$y,backgroundPositionX:$y,backgroundPositionY:$y},Gy={rotate:By,rotateX:By,rotateY:By,rotateZ:By,scale:Oy,scaleX:Oy,scaleY:Oy,scaleZ:Oy,skew:By,skewX:By,skewY:By,distance:$y,translateX:$y,translateY:$y,translateZ:$y,x:$y,y:$y,z:$y,perspective:$y,transformPerspective:$y,opacity:Ry,originX:Wy,originY:Wy,originZ:$y},Zy={...Py,transform:Math.round},Yy={...qy,...Gy,zIndex:Zy,size:$y,fillOpacity:Ry,strokeOpacity:Ry,numOctaves:Zy},Ky={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},Jy=Iy.length;function Qy(e,t,n){const{style:s,vars:i,transformOrigin:a}=e;let r=!1,o=!1;for(const l in t){const e=t[l];if(Ay.has(l))r=!0;else if(Fy(l))i[l]=e;else{const t=Dy(e,Yy[l]);l.startsWith("origin")?(o=!0,a[l]=t):s[l]=t}}if(t.transform||(r||n?s.transform=function(e,t,n){let s="",i=!0;for(let a=0;a({style:{},transform:{},transformOrigin:{},vars:{}});function ew(e,t,n){for(const s in t)My(t[s])||Ty(s,n)||(e[s]=t[s])}function tw(e,t){const n={};return ew(n,e.style||{},e),Object.assign(n,function({transformTemplate:e},t){return Pe.useMemo(()=>{const n={style:{},transform:{},transformOrigin:{},vars:{}};return Qy(n,t,e),Object.assign({},n.vars,n.style)},[t])}(e,t)),n}function nw(e,t){const n={},s=tw(e,t);return e.drag&&!1!==e.dragListener&&(n.draggable=!1,s.userSelect=s.WebkitUserSelect=s.WebkitTouchCallout="none",s.touchAction=!0===e.drag?"none":"pan-"+("x"===e.drag?"y":"x")),void 0===e.tabIndex&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=s,n}const sw=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function iw(e){return"string"==typeof e&&!e.includes("-")&&!!(sw.indexOf(e)>-1||/[A-Z]/u.test(e))}const aw={offset:"stroke-dashoffset",array:"stroke-dasharray"},rw={offset:"strokeDashoffset",array:"strokeDasharray"};function ow(e,t,n){return"string"==typeof e?e:$y.transform(t+n*e)}function lw(e,{attrX:t,attrY:n,attrScale:s,originX:i,originY:a,pathLength:r,pathSpacing:o=1,pathOffset:l=0,...c},d,u){if(Qy(e,c,u),d)return void(e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox));e.attrs=e.style,e.style={};const{attrs:p,style:m,dimensions:h}=e;p.transform&&(h&&(m.transform=p.transform),delete p.transform),h&&(void 0!==i||void 0!==a||m.transform)&&(m.transformOrigin=function(e,t,n){return`${ow(t,e.x,e.width)} ${ow(n,e.y,e.height)}`}(h,void 0!==i?i:.5,void 0!==a?a:.5)),void 0!==t&&(p.x=t),void 0!==n&&(p.y=n),void 0!==s&&(p.scale=s),void 0!==r&&function(e,t,n=1,s=0,i=!0){e.pathLength=1;const a=i?aw:rw;e[a.offset]=$y.transform(-s);const r=$y.transform(t),o=$y.transform(n);e[a.array]=`${r} ${o}`}(p,r,o,l,!1)}const cw=()=>({style:{},transform:{},transformOrigin:{},vars:{},attrs:{}}),dw=e=>"string"==typeof e&&"svg"===e.toLowerCase();function uw(e,t,n,s){const i=Pe.useMemo(()=>{const n={style:{},transform:{},transformOrigin:{},vars:{},attrs:{}};return lw(n,t,dw(s),e.transformTemplate),{...n.attrs,style:{...n.style}}},[t]);if(e.style){const t={};ew(t,e.style,e),i.style={...t,...i.style}}return i}function pw(e=!1){return(t,n,s,{latestValues:i},a)=>{const r=(iw(t)?uw:nw)(n,i,a,t),o=function(e,t,n){const s={};for(const i in e)"values"===i&&"object"==typeof e.values||(ty(i)||!0===n&&ey(i)||!t&&!ey(i)||e.draggable&&i.startsWith("onDrag"))&&(s[i]=e[i]);return s}(n,"string"==typeof t,e),l=t!==Pe.Fragment?{...o,...r,ref:s}:{},{children:c}=n,d=Pe.useMemo(()=>My(c)?c.get():c,[c]);return Pe.createElement(t,{...l,children:d})}}function mw(e){const t=[{},{}];return null==e||e.values.forEach((e,n)=>{t[0][n]=e.get(),t[1][n]=e.getVelocity()}),t}function hw(e,t,n,s){if("function"==typeof t){const[i,a]=mw(s);t=t(void 0!==n?n:e.custom,i,a)}if("string"==typeof t&&(t=e.variants&&e.variants[t]),"function"==typeof t){const[i,a]=mw(s);t=t(void 0!==n?n:e.custom,i,a)}return t}const xw=e=>Array.isArray(e),fw=e=>xw(e)?e[e.length-1]||0:e;function gw(e){const t=My(e)?e.get():e;return n=t,Boolean(n&&"object"==typeof n&&n.mix&&n.toValue)?t.toValue():t;var n}const vw=e=>(t,n)=>{const s=Pe.useContext(iy),i=Pe.useContext(Ib),a=()=>function({scrapeMotionValuesFromProps:e,createRenderState:t,onUpdate:n},s,i,a){const r={latestValues:bw(s,i,a,e),renderState:t()};return n&&(r.onMount=e=>n({props:s,current:e,...r}),r.onUpdate=e=>n(e)),r}(e,t,s,i);return n?a():kb(a)};function bw(e,t,n,s){const i={},a=s(e,{});for(const p in a)i[p]=gw(a[p]);let{initial:r,animate:o}=e;const l=cy(e),c=dy(e);t&&c&&!l&&!1!==e.inherit&&(void 0===r&&(r=t.initial),void 0===o&&(o=t.animate));let d=!!n&&!1===n.initial;d=d||!1===r;const u=d?o:r;if(u&&"boolean"!=typeof u&&!ay(u)){const t=Array.isArray(u)?u:[u];for(let n=0;n{if(!n)return;let a=!!e.drag;if(!a)for(const o in i)if(Ay.has(o)){a=!0;break}if(!a)return;let r=!t;if(t)for(let o=0;o{jw(n,s),qb.render(()=>{lw(s,i,dw(n.tagName),e.transformTemplate),Fw(n,s)})})}})};function Ew(e,t){return function(n,{forwardMotionProps:s}={forwardMotionProps:!1}){return jy({...iw(n)?Sw:ww,preloadedFeatures:e,useRender:pw(s),createVisualElement:t,Component:n})}}function Iw(e,t,n){const s=e.getProps();return hw(s,t,void 0!==n?n:s.custom,e)}function Aw(e,t){return e?e[t]||e.default||e:void 0}const Tw=new Set(["width","height","top","left","right","bottom",...Iy]);function Mw(e,t){-1===e.indexOf(t)&&e.push(t)}function Dw(e,t){const n=e.indexOf(t);n>-1&&e.splice(n,1)}class Lw{constructor(){this.subscriptions=[]}add(e){return Mw(this.subscriptions,e),()=>Dw(this.subscriptions,e)}notify(e,t,n){const s=this.subscriptions.length;if(s)if(1===s)this.subscriptions[0](e,t,n);else for(let i=0;i(void 0===Rw&&zw.set(Zb.isProcessing||$b?Zb.timestamp:performance.now()),Rw),set:e=>{Rw=e,queueMicrotask(Ow)}};class Bw{constructor(e,t={}){this.version="12.5.0",this.canTrackVelocity=null,this.events={},this.updateAndNotify=(e,t=!0)=>{const n=zw.now();this.updatedAt!==n&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(e),this.current!==this.prev&&this.events.change&&this.events.change.notify(this.current),t&&this.events.renderRequest&&this.events.renderRequest.notify(this.current)},this.hasAnimated=!1,this.setCurrent(e),this.owner=t.owner}setCurrent(e){var t;this.current=e,this.updatedAt=zw.now(),null===this.canTrackVelocity&&void 0!==e&&(this.canTrackVelocity=(t=this.current,!isNaN(parseFloat(t))))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return this.on("change",e)}on(e,t){this.events[e]||(this.events[e]=new Lw);const n=this.events[e].add(t);return"change"===e?()=>{n(),qb.read(()=>{this.events.change.getSize()||this.stop()})}:n}clearListeners(){for(const e in this.events)this.events[e].clear()}attach(e,t){this.passiveEffect=e,this.stopPassiveEffect=t}set(e,t=!0){t&&this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e,t)}setWithVelocity(e,t,n){this.set(t),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-n}jump(e,t=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,t&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const e=zw.now();if(!this.canTrackVelocity||void 0===this.prevFrameValue||e-this.updatedAt>30)return 0;const t=Math.min(this.updatedAt-this.prevUpdatedAt,30);return Pw(parseFloat(this.current)-parseFloat(this.prevFrameValue),t)}start(e){return this.stop(),new Promise(t=>{this.hasAnimated=!0,this.animation=e(t),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function Hw(e,t){return new Bw(e,t)}function $w(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,Hw(n))}function Vw(e,t){const n=e.getValue("willChange");if(s=n,Boolean(My(s)&&s.add))return n.add(t);var s}function Uw(e){return e.props[vy]}function Ww(e){let t;return()=>(void 0===t&&(t=e()),t)}const qw=Ww(()=>void 0!==window.ScrollTimeline);class Gw{constructor(e){this.stop=()=>this.runAll("stop"),this.animations=e.filter(Boolean)}get finished(){return Promise.all(this.animations.map(e=>"finished"in e?e.finished:e))}getAll(e){return this.animations[0][e]}setAll(e,t){for(let n=0;nqw()&&n.attachTimeline?n.attachTimeline(e):"function"==typeof t?t(n):void 0);return()=>{n.forEach((e,t)=>{e&&e(),this.animations[t].stop()})}}get time(){return this.getAll("time")}set time(e){this.setAll("time",e)}get speed(){return this.getAll("speed")}set speed(e){this.setAll("speed",e)}get startTime(){return this.getAll("startTime")}get duration(){let e=0;for(let t=0;tt[e]())}flatten(){this.runAll("flatten")}play(){this.runAll("play")}pause(){this.runAll("pause")}cancel(){this.runAll("cancel")}complete(){this.runAll("complete")}}class Zw extends Gw{then(e,t){return Promise.all(this.animations).then(e).catch(t)}}const Yw=e=>1e3*e,Kw=e=>e/1e3;function Jw(e){return"function"==typeof e}function Qw(e,t){e.timeline=t,e.onfinish=null}const Xw=e=>Array.isArray(e)&&"number"==typeof e[0],ej={linearEasing:void 0};function tj(e,t){const n=Ww(e);return()=>{var e;return null!==(e=ej[t])&&void 0!==e?e:n()}}const nj=tj(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch(e){return!1}return!0},"linearEasing"),sj=(e,t,n)=>{const s=t-e;return 0===s?1:(n-e)/s},ij=(e,t,n=10)=>{let s="";const i=Math.max(Math.round(t/n),2);for(let a=0;a`cubic-bezier(${e}, ${t}, ${n}, ${s})`,oj={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:rj([0,.65,.55,1]),circOut:rj([.55,0,1,.45]),backIn:rj([.31,.01,.66,-.59]),backOut:rj([.33,1.53,.69,.99])};function lj(e,t){return e?"function"==typeof e&&nj()?ij(e,t):Xw(e)?rj(e):Array.isArray(e)?e.map(e=>lj(e,t)||oj.easeOut):oj[e]:void 0}const cj=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e;function dj(e,t,n,s){if(e===t&&n===s)return Bb;const i=t=>function(e,t,n,s,i){let a,r,o=0;do{r=t+(n-t)/2,a=cj(r,s,i)-e,a>0?n=r:t=r}while(Math.abs(a)>1e-7&&++o<12);return r}(t,0,1,e,n);return e=>0===e||1===e?e:cj(i(e),t,s)}const uj=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,pj=e=>t=>1-e(1-t),mj=dj(.33,1.53,.69,.99),hj=pj(mj),xj=uj(hj),fj=e=>(e*=2)<1?.5*hj(e):.5*(2-Math.pow(2,-10*(e-1))),gj=e=>1-Math.sin(Math.acos(e)),vj=pj(gj),bj=uj(gj),yj=e=>/^0[^.\s]+$/u.test(e);function wj(e){return"number"==typeof e?0===e:null===e||("none"===e||"0"===e||yj(e))}const jj=e=>Math.round(1e5*e)/1e5,Cj=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;const Nj=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Fj=(e,t)=>n=>Boolean("string"==typeof n&&Nj.test(n)&&n.startsWith(e)||t&&!function(e){return null==e}(n)&&Object.prototype.hasOwnProperty.call(n,t)),_j=(e,t,n)=>s=>{if("string"!=typeof s)return s;const[i,a,r,o]=s.match(Cj);return{[e]:parseFloat(i),[t]:parseFloat(a),[n]:parseFloat(r),alpha:void 0!==o?parseFloat(o):1}},kj={...Py,transform:e=>Math.round((e=>Ly(0,255,e))(e))},Sj={test:Fj("rgb","red"),parse:_j("red","green","blue"),transform:({red:e,green:t,blue:n,alpha:s=1})=>"rgba("+kj.transform(e)+", "+kj.transform(t)+", "+kj.transform(n)+", "+jj(Ry.transform(s))+")"};const Ej={test:Fj("#"),parse:function(e){let t="",n="",s="",i="";return e.length>5?(t=e.substring(1,3),n=e.substring(3,5),s=e.substring(5,7),i=e.substring(7,9)):(t=e.substring(1,2),n=e.substring(2,3),s=e.substring(3,4),i=e.substring(4,5),t+=t,n+=n,s+=s,i+=i),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(s,16),alpha:i?parseInt(i,16)/255:1}},transform:Sj.transform},Ij={test:Fj("hsl","hue"),parse:_j("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:n,alpha:s=1})=>"hsla("+Math.round(e)+", "+Hy.transform(jj(t))+", "+Hy.transform(jj(n))+", "+jj(Ry.transform(s))+")"},Aj={test:e=>Sj.test(e)||Ej.test(e)||Ij.test(e),parse:e=>Sj.test(e)?Sj.parse(e):Ij.test(e)?Ij.parse(e):Ej.parse(e),transform:e=>"string"==typeof e?e:e.hasOwnProperty("red")?Sj.transform(e):Ij.transform(e)},Tj=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;const Mj="number",Dj="color",Lj=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function Pj(e){const t=e.toString(),n=[],s={color:[],number:[],var:[]},i=[];let a=0;const r=t.replace(Lj,e=>(Aj.test(e)?(s.color.push(a),i.push(Dj),n.push(Aj.parse(e))):e.startsWith("var(")?(s.var.push(a),i.push("var"),n.push(e)):(s.number.push(a),i.push(Mj),n.push(parseFloat(e))),++a,"${}")).split("${}");return{values:n,split:r,indexes:s,types:i}}function Rj(e){return Pj(e).values}function Oj(e){const{split:t,types:n}=Pj(e),s=t.length;return e=>{let i="";for(let a=0;a"number"==typeof e?0:e;const Bj={test:function(e){var t,n;return isNaN(e)&&"string"==typeof e&&((null===(t=e.match(Cj))||void 0===t?void 0:t.length)||0)+((null===(n=e.match(Tj))||void 0===n?void 0:n.length)||0)>0},parse:Rj,createTransformer:Oj,getAnimatableNone:function(e){const t=Rj(e);return Oj(e)(t.map(zj))}},Hj=new Set(["brightness","contrast","saturate","opacity"]);function $j(e){const[t,n]=e.slice(0,-1).split("(");if("drop-shadow"===t)return e;const[s]=n.match(Cj)||[];if(!s)return e;const i=n.replace(s,"");let a=Hj.has(t)?1:0;return s!==n&&(a*=100),t+"("+a+i+")"}const Vj=/\b([a-z-]*)\(.*?\)/gu,Uj={...Bj,getAnimatableNone:e=>{const t=e.match(Vj);return t?t.map($j).join(" "):e}},Wj={...Yy,color:Aj,backgroundColor:Aj,outlineColor:Aj,fill:Aj,stroke:Aj,borderColor:Aj,borderTopColor:Aj,borderRightColor:Aj,borderBottomColor:Aj,borderLeftColor:Aj,filter:Uj,WebkitFilter:Uj},qj=e=>Wj[e];function Gj(e,t){let n=qj(e);return n!==Uj&&(n=Bj),n.getAnimatableNone?n.getAnimatableNone(t):void 0}const Zj=new Set(["auto","none","0"]);const Yj=e=>180*e/Math.PI,Kj=e=>{const t=Yj(Math.atan2(e[1],e[0]));return Qj(t)},Jj={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:Kj,rotateZ:Kj,skewX:e=>Yj(Math.atan(e[1])),skewY:e=>Yj(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},Qj=e=>((e%=360)<0&&(e+=360),e),Xj=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),eC=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),tC={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:Xj,scaleY:eC,scale:e=>(Xj(e)+eC(e))/2,rotateX:e=>Qj(Yj(Math.atan2(e[6],e[5]))),rotateY:e=>Qj(Yj(Math.atan2(-e[2],e[0]))),rotateZ:Kj,rotate:Kj,skewX:e=>Yj(Math.atan(e[4])),skewY:e=>Yj(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function nC(e){return e.includes("scale")?1:0}function sC(e,t){if(!e||"none"===e)return nC(t);const n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let s,i;if(n)s=tC,i=n;else{const t=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);s=Jj,i=t}if(!i)return nC(t);const a=s[t],r=i[1].split(",").map(iC);return"function"==typeof a?a(r):r[a]}function iC(e){return parseFloat(e.trim())}const aC=e=>e===Py||e===$y,rC=new Set(["x","y","z"]),oC=Iy.filter(e=>!rC.has(e));const lC={width:({x:e},{paddingLeft:t="0",paddingRight:n="0"})=>e.max-e.min-parseFloat(t)-parseFloat(n),height:({y:e},{paddingTop:t="0",paddingBottom:n="0"})=>e.max-e.min-parseFloat(t)-parseFloat(n),top:(e,{top:t})=>parseFloat(t),left:(e,{left:t})=>parseFloat(t),bottom:({y:e},{top:t})=>parseFloat(t)+(e.max-e.min),right:({x:e},{left:t})=>parseFloat(t)+(e.max-e.min),x:(e,{transform:t})=>sC(t,"x"),y:(e,{transform:t})=>sC(t,"y")};lC.translateX=lC.x,lC.translateY=lC.y;const cC=new Set;let dC=!1,uC=!1;function pC(){if(uC){const e=Array.from(cC).filter(e=>e.needsMeasurement),t=new Set(e.map(e=>e.element)),n=new Map;t.forEach(e=>{const t=function(e){const t=[];return oC.forEach(n=>{const s=e.getValue(n);void 0!==s&&(t.push([n,s.get()]),s.set(n.startsWith("scale")?1:0))}),t}(e);t.length&&(n.set(e,t),e.render())}),e.forEach(e=>e.measureInitialState()),t.forEach(e=>{e.render();const t=n.get(e);t&&t.forEach(([t,n])=>{var s;null===(s=e.getValue(t))||void 0===s||s.set(n)})}),e.forEach(e=>e.measureEndState()),e.forEach(e=>{void 0!==e.suspendedScrollY&&window.scrollTo(0,e.suspendedScrollY)})}uC=!1,dC=!1,cC.forEach(e=>e.complete()),cC.clear()}function mC(){cC.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(uC=!0)})}class hC{constructor(e,t,n,s,i,a=!1){this.isComplete=!1,this.isAsync=!1,this.needsMeasurement=!1,this.isScheduled=!1,this.unresolvedKeyframes=[...e],this.onComplete=t,this.name=n,this.motionValue=s,this.element=i,this.isAsync=a}scheduleResolve(){this.isScheduled=!0,this.isAsync?(cC.add(this),dC||(dC=!0,qb.read(mC),qb.resolveKeyframes(pC))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:e,name:t,element:n,motionValue:s}=this;for(let i=0;i/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e),fC=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function gC(e,t,n=1){const[s,i]=function(e){const t=fC.exec(e);if(!t)return[,];const[,n,s,i]=t;return[`--${null!=n?n:s}`,i]}(e);if(!s)return;const a=window.getComputedStyle(t).getPropertyValue(s);if(a){const e=a.trim();return xC(e)?parseFloat(e):e}return ky(i)?gC(i,t,n+1):i}const vC=e=>t=>t.test(e),bC=[Py,$y,Hy,By,Uy,Vy,{test:e=>"auto"===e,parse:e=>e}],yC=e=>bC.find(vC(e));class wC extends hC{constructor(e,t,n,s,i){super(e,t,n,s,i,!0)}readKeyframes(){const{unresolvedKeyframes:e,element:t,name:n}=this;if(!t||!t.current)return;super.readKeyframes();for(let o=0;o{t.getValue(e).set(n)}),this.resolveNoneKeyframes()}}const jC=(e,t)=>"zIndex"!==t&&(!("number"!=typeof e&&!Array.isArray(e))||!("string"!=typeof e||!Bj.test(e)&&"0"!==e||e.startsWith("url(")));const CC=e=>null!==e;function NC(e,{repeat:t,repeatType:n="loop"},s){const i=e.filter(CC),a=t&&"loop"!==n&&t%2==1?0:i.length-1;return a&&void 0!==s?s:i[a]}class FC{constructor({autoplay:e=!0,delay:t=0,type:n="keyframes",repeat:s=0,repeatDelay:i=0,repeatType:a="loop",...r}){this.isStopped=!1,this.hasAttemptedResolve=!1,this.createdAt=zw.now(),this.options={autoplay:e,delay:t,type:n,repeat:s,repeatDelay:i,repeatType:a,...r},this.updateFinishedPromise()}calcStartTime(){return this.resolvedAt&&this.resolvedAt-this.createdAt>40?this.resolvedAt:this.createdAt}get resolved(){return this._resolved||this.hasAttemptedResolve||(mC(),pC()),this._resolved}onKeyframesResolved(e,t){this.resolvedAt=zw.now(),this.hasAttemptedResolve=!0;const{name:n,type:s,velocity:i,delay:a,onComplete:r,onUpdate:o,isGenerator:l}=this.options;if(!l&&!function(e,t,n,s){const i=e[0];if(null===i)return!1;if("display"===t||"visibility"===t)return!0;const a=e[e.length-1],r=jC(i,t),o=jC(a,t);return!(!r||!o)&&(function(e){const t=e[0];if(1===e.length)return!0;for(let n=0;n{this.resolveFinishedPromise=e})}}const _C=2e4;function kC(e){let t=0;let n=e.next(t);for(;!n.done&&t<_C;)t+=50,n=e.next(t);return t>=_C?1/0:t}const SC=(e,t,n)=>e+(t-e)*n;function EC(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function IC(e,t){return n=>n>0?t:e}const AC=(e,t,n)=>{const s=e*e,i=n*(t*t-s)+s;return i<0?0:Math.sqrt(i)},TC=[Ej,Sj,Ij];function MC(e){const t=(n=e,TC.find(e=>e.test(n)));var n;if(!Boolean(t))return!1;let s=t.parse(e);return t===Ij&&(s=function({hue:e,saturation:t,lightness:n,alpha:s}){e/=360,n/=100;let i=0,a=0,r=0;if(t/=100){const s=n<.5?n*(1+t):n+t-n*t,o=2*n-s;i=EC(o,s,e+1/3),a=EC(o,s,e),r=EC(o,s,e-1/3)}else i=a=r=n;return{red:Math.round(255*i),green:Math.round(255*a),blue:Math.round(255*r),alpha:s}}(s)),s}const DC=(e,t)=>{const n=MC(e),s=MC(t);if(!n||!s)return IC(e,t);const i={...n};return e=>(i.red=AC(n.red,s.red,e),i.green=AC(n.green,s.green,e),i.blue=AC(n.blue,s.blue,e),i.alpha=SC(n.alpha,s.alpha,e),Sj.transform(i))},LC=(e,t)=>n=>t(e(n)),PC=(...e)=>e.reduce(LC),RC=new Set(["none","hidden"]);function OC(e,t){return n=>SC(e,t,n)}function zC(e){return"number"==typeof e?OC:"string"==typeof e?ky(e)?IC:Aj.test(e)?DC:$C:Array.isArray(e)?BC:"object"==typeof e?Aj.test(e)?DC:HC:IC}function BC(e,t){const n=[...e],s=n.length,i=e.map((e,n)=>zC(e)(e,t[n]));return e=>{for(let t=0;t{for(const t in s)n[t]=s[t](e);return n}}const $C=(e,t)=>{const n=Bj.createTransformer(t),s=Pj(e),i=Pj(t);return s.indexes.var.length===i.indexes.var.length&&s.indexes.color.length===i.indexes.color.length&&s.indexes.number.length>=i.indexes.number.length?RC.has(e)&&!i.values.length||RC.has(t)&&!s.values.length?function(e,t){return RC.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}(e,t):PC(BC(function(e,t){var n;const s=[],i={color:0,var:0,number:0};for(let a=0;a{const s=t*r,i=s*e,a=s-n,o=oN(t,r),l=Math.exp(-i);return iN-a/o*l},a=t=>{const s=t*r*e,a=s*n+n,o=Math.pow(r,2)*Math.pow(t,2)*e,l=Math.exp(-s),c=oN(Math.pow(t,2),r);return(-i(t)+iN>0?-1:1)*((a-o)*l)/c}):(i=t=>Math.exp(-t*e)*((t-n)*e+1)-.001,a=t=>Math.exp(-t*e)*(e*e*(n-t)));const o=function(e,t,n){let s=n;for(let i=1;ivoid 0!==e[t])}function uN(e=JC,t=KC){const n="object"!=typeof e?{visualDuration:e,keyframes:[0,1],bounce:t}:e;let{restSpeed:s,restDelta:i}=n;const a=n.keyframes[0],r=n.keyframes[n.keyframes.length-1],o={done:!1,value:a},{stiffness:l,damping:c,mass:d,duration:u,velocity:p,isResolvedFromDuration:m}=function(e){let t={velocity:ZC,stiffness:WC,damping:qC,mass:GC,isResolvedFromDuration:!1,...e};if(!dN(e,cN)&&dN(e,lN))if(e.visualDuration){const n=e.visualDuration,s=2*Math.PI/(1.2*n),i=s*s,a=2*Ly(.05,1,1-(e.bounce||0))*Math.sqrt(i);t={...t,mass:GC,stiffness:i,damping:a}}else{const n=aN(e);t={...t,...n,mass:GC},t.isResolvedFromDuration=!0}return t}({...n,velocity:-Kw(n.velocity||0)}),h=p||0,x=c/(2*Math.sqrt(l*d)),f=r-a,g=Kw(Math.sqrt(l/d)),v=Math.abs(f)<5;let b;if(s||(s=v?QC.granular:QC.default),i||(i=v?XC.granular:XC.default),x<1){const e=oN(g,x);b=t=>{const n=Math.exp(-x*g*t);return r-n*((h+x*g*f)/e*Math.sin(e*t)+f*Math.cos(e*t))}}else if(1===x)b=e=>r-Math.exp(-g*e)*(f+(h+g*f)*e);else{const e=g*Math.sqrt(x*x-1);b=t=>{const n=Math.exp(-x*g*t),s=Math.min(e*t,300);return r-n*((h+x*g*f)*Math.sinh(s)+e*f*Math.cosh(s))/e}}const y={calculatedDuration:m&&u||null,next:e=>{const t=b(e);if(m)o.done=e>=u;else{let n=0;x<1&&(n=0===e?Yw(h):UC(b,e,t));const a=Math.abs(n)<=s,l=Math.abs(r-t)<=i;o.done=a&&l}return o.value=o.done?r:t,o},toString:()=>{const e=Math.min(kC(y),_C),t=ij(t=>y.next(e*t).value,e,30);return e+"ms "+t}};return y}function pN({keyframes:e,velocity:t=0,power:n=.8,timeConstant:s=325,bounceDamping:i=10,bounceStiffness:a=500,modifyTarget:r,min:o,max:l,restDelta:c=.5,restSpeed:d}){const u=e[0],p={done:!1,value:u},m=e=>void 0===o?l:void 0===l||Math.abs(o-e)-h*Math.exp(-e/s),v=e=>f+g(e),b=e=>{const t=g(e),n=v(e);p.done=Math.abs(t)<=c,p.value=p.done?f:n};let y,w;const j=e=>{var t;(t=p.value,void 0!==o&&tl)&&(y=e,w=uN({keyframes:[p.value,m(p.value)],velocity:UC(v,e,p.value),damping:i,stiffness:a,restDelta:c,restSpeed:d}))};return j(0),{calculatedDuration:null,next:e=>{let t=!1;return w||void 0!==y||(t=!0,b(e),j(e)),void 0!==y&&e>=y?w.next(e-y):(!t&&b(e),p)}}}const mN=dj(.42,0,1,1),hN=dj(0,0,.58,1),xN=dj(.42,0,.58,1),fN={linear:Bb,easeIn:mN,easeInOut:xN,easeOut:hN,circIn:gj,circInOut:bj,circOut:vj,backIn:hj,backInOut:xj,backOut:mj,anticipate:fj},gN=e=>{if(Xw(e)){Hb(4===e.length);const[t,n,s,i]=e;return dj(t,n,s,i)}return"string"==typeof e?fN[e]:e};function vN(e,t,{clamp:n=!0,ease:s,mixer:i}={}){const a=e.length;if(Hb(a===t.length),1===a)return()=>t[0];if(2===a&&t[0]===t[1])return()=>t[1];const r=e[0]===e[1];e[0]>e[a-1]&&(e=[...e].reverse(),t=[...t].reverse());const o=function(e,t,n){const s=[],i=n||VC,a=e.length-1;for(let r=0;r{if(r&&n1)for(;sc(Ly(e[0],e[a-1],t)):c}function bN(e){const t=[0];return function(e,t){const n=e[e.length-1];for(let s=1;s<=t;s++){const i=sj(0,t,s);e.push(SC(n,1,i))}}(t,e.length-1),t}function yN({duration:e=300,keyframes:t,times:n,ease:s="easeInOut"}){const i=(e=>Array.isArray(e)&&"number"!=typeof e[0])(s)?s.map(gN):gN(s),a={done:!1,value:t[0]},r=function(e,t){return e.map(e=>e*t)}(n&&n.length===t.length?n:bN(t),e),o=vN(r,t,{ease:Array.isArray(i)?i:(l=t,c=i,l.map(()=>c||xN).splice(0,l.length-1))});var l,c;return{calculatedDuration:e,next:t=>(a.value=o(t),a.done=t>=e,a)}}const wN=e=>{const t=({timestamp:t})=>e(t);return{start:()=>qb.update(t,!0),stop:()=>Gb(t),now:()=>Zb.isProcessing?Zb.timestamp:zw.now()}},jN={decay:pN,inertia:pN,tween:yN,keyframes:yN,spring:uN},CN=e=>e/100;class NN extends FC{constructor(e){super(e),this.holdTime=null,this.cancelTime=null,this.currentTime=0,this.playbackSpeed=1,this.pendingPlayState="running",this.startTime=null,this.state="idle",this.stop=()=>{if(this.resolver.cancel(),this.isStopped=!0,"idle"===this.state)return;this.teardown();const{onStop:e}=this.options;e&&e()};const{name:t,motionValue:n,element:s,keyframes:i}=this.options,a=(null==s?void 0:s.KeyframeResolver)||hC;this.resolver=new a(i,(e,t)=>this.onKeyframesResolved(e,t),t,n,s),this.resolver.scheduleResolve()}flatten(){super.flatten(),this._resolved&&Object.assign(this._resolved,this.initPlayback(this._resolved.keyframes))}initPlayback(e){const{type:t="keyframes",repeat:n=0,repeatDelay:s=0,repeatType:i,velocity:a=0}=this.options,r=Jw(t)?t:jN[t]||yN;let o,l;r!==yN&&"number"!=typeof e[0]&&(o=PC(CN,VC(e[0],e[1])),e=[0,100]);const c=r({...this.options,keyframes:e});"mirror"===i&&(l=r({...this.options,keyframes:[...e].reverse(),velocity:-a})),null===c.calculatedDuration&&(c.calculatedDuration=kC(c));const{calculatedDuration:d}=c,u=d+s;return{generator:c,mirroredGenerator:l,mapPercentToKeyframes:o,calculatedDuration:d,resolvedDuration:u,totalDuration:u*(n+1)-s}}onPostResolved(){const{autoplay:e=!0}=this.options;this.play(),"paused"!==this.pendingPlayState&&e?this.state=this.pendingPlayState:this.pause()}tick(e,t=!1){const{resolved:n}=this;if(!n){const{keyframes:e}=this.options;return{done:!0,value:e[e.length-1]}}const{finalKeyframe:s,generator:i,mirroredGenerator:a,mapPercentToKeyframes:r,keyframes:o,calculatedDuration:l,totalDuration:c,resolvedDuration:d}=n;if(null===this.startTime)return i.next(0);const{delay:u,repeat:p,repeatType:m,repeatDelay:h,onUpdate:x}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-c/this.speed,this.startTime)),t?this.currentTime=e:null!==this.holdTime?this.currentTime=this.holdTime:this.currentTime=Math.round(e-this.startTime)*this.speed;const f=this.currentTime-u*(this.speed>=0?1:-1),g=this.speed>=0?f<0:f>c;this.currentTime=Math.max(f,0),"finished"===this.state&&null===this.holdTime&&(this.currentTime=c);let v=this.currentTime,b=i;if(p){const e=Math.min(this.currentTime,c)/d;let t=Math.floor(e),n=e%1;!n&&e>=1&&(n=1),1===n&&t--,t=Math.min(t,p+1);Boolean(t%2)&&("reverse"===m?(n=1-n,h&&(n-=h/d)):"mirror"===m&&(b=a)),v=Ly(0,1,n)*d}const y=g?{done:!1,value:o[0]}:b.next(v);r&&(y.value=r(y.value));let{done:w}=y;g||null===l||(w=this.speed>=0?this.currentTime>=c:this.currentTime<=0);const j=null===this.holdTime&&("finished"===this.state||"running"===this.state&&w);return j&&void 0!==s&&(y.value=NC(o,this.options,s)),x&&x(y.value),j&&this.finish(),y}get duration(){const{resolved:e}=this;return e?Kw(e.calculatedDuration):0}get time(){return Kw(this.currentTime)}set time(e){e=Yw(e),this.currentTime=e,null!==this.holdTime||0===this.speed?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.speed)}get speed(){return this.playbackSpeed}set speed(e){const t=this.playbackSpeed!==e;this.playbackSpeed=e,t&&(this.time=Kw(this.currentTime))}play(){if(this.resolver.isScheduled||this.resolver.resume(),!this._resolved)return void(this.pendingPlayState="running");if(this.isStopped)return;const{driver:e=wN,onPlay:t,startTime:n}=this.options;this.driver||(this.driver=e(e=>this.tick(e))),t&&t();const s=this.driver.now();null!==this.holdTime?this.startTime=s-this.holdTime:this.startTime?"finished"===this.state&&(this.startTime=s):this.startTime=null!=n?n:this.calcStartTime(),"finished"===this.state&&this.updateFinishedPromise(),this.cancelTime=this.startTime,this.holdTime=null,this.state="running",this.driver.start()}pause(){var e;this._resolved?(this.state="paused",this.holdTime=null!==(e=this.currentTime)&&void 0!==e?e:0):this.pendingPlayState="paused"}complete(){"running"!==this.state&&this.play(),this.pendingPlayState=this.state="finished",this.holdTime=null}finish(){this.teardown(),this.state="finished";const{onComplete:e}=this.options;e&&e()}cancel(){null!==this.cancelTime&&this.tick(this.cancelTime),this.teardown(),this.updateFinishedPromise()}teardown(){this.state="idle",this.stopDriver(),this.resolveFinishedPromise(),this.updateFinishedPromise(),this.startTime=this.cancelTime=null,this.resolver.cancel()}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}}const FN=new Set(["opacity","clipPath","filter","transform"]);function _N(e,t,n,{delay:s=0,duration:i=300,repeat:a=0,repeatType:r="loop",ease:o="easeInOut",times:l}={}){const c={[t]:n};l&&(c.offset=l);const d=lj(o,i);Array.isArray(d)&&(c.easing=d);return e.animate(c,{delay:s,duration:i,easing:Array.isArray(d)?"linear":d,fill:"both",iterations:a+1,direction:"reverse"===r?"alternate":"normal"})}const kN=Ww(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));const SN={anticipate:fj,backInOut:xj,circInOut:bj};class EN extends FC{constructor(e){super(e);const{name:t,motionValue:n,element:s,keyframes:i}=this.options;this.resolver=new wC(i,(e,t)=>this.onKeyframesResolved(e,t),t,n,s),this.resolver.scheduleResolve()}initPlayback(e,t){let{duration:n=300,times:s,ease:i,type:a,motionValue:r,name:o,startTime:l}=this.options;if(!r.owner||!r.owner.current)return!1;var c;if("string"==typeof i&&nj()&&i in SN&&(i=SN[i]),Jw((c=this.options).type)||"spring"===c.type||!aj(c.ease)){const{onComplete:t,onUpdate:r,motionValue:o,element:l,...c}=this.options,d=function(e,t){const n=new NN({...t,keyframes:e,repeat:0,delay:0,isGenerator:!0});let s={done:!1,value:e[0]};const i=[];let a=0;for(;!s.done&&a<2e4;)s=n.sample(a),i.push(s.value),a+=10;return{times:void 0,keyframes:i,duration:a-10,ease:"linear"}}(e,c);1===(e=d.keyframes).length&&(e[1]=e[0]),n=d.duration,s=d.times,i=d.ease,a="keyframes"}const d=_N(r.owner.current,o,e,{...this.options,duration:n,times:s,ease:i});return d.startTime=null!=l?l:this.calcStartTime(),this.pendingTimeline?(Qw(d,this.pendingTimeline),this.pendingTimeline=void 0):d.onfinish=()=>{const{onComplete:n}=this.options;r.set(NC(e,this.options,t)),n&&n(),this.cancel(),this.resolveFinishedPromise()},{animation:d,duration:n,times:s,type:a,ease:i,keyframes:e}}get duration(){const{resolved:e}=this;if(!e)return 0;const{duration:t}=e;return Kw(t)}get time(){const{resolved:e}=this;if(!e)return 0;const{animation:t}=e;return Kw(t.currentTime||0)}set time(e){const{resolved:t}=this;if(!t)return;const{animation:n}=t;n.currentTime=Yw(e)}get speed(){const{resolved:e}=this;if(!e)return 1;const{animation:t}=e;return t.playbackRate}set speed(e){const{resolved:t}=this;if(!t)return;const{animation:n}=t;n.playbackRate=e}get state(){const{resolved:e}=this;if(!e)return"idle";const{animation:t}=e;return t.playState}get startTime(){const{resolved:e}=this;if(!e)return null;const{animation:t}=e;return t.startTime}attachTimeline(e){if(this._resolved){const{resolved:t}=this;if(!t)return Bb;const{animation:n}=t;Qw(n,e)}else this.pendingTimeline=e;return Bb}play(){if(this.isStopped)return;const{resolved:e}=this;if(!e)return;const{animation:t}=e;"finished"===t.playState&&this.updateFinishedPromise(),t.play()}pause(){const{resolved:e}=this;if(!e)return;const{animation:t}=e;t.pause()}stop(){if(this.resolver.cancel(),this.isStopped=!0,"idle"===this.state)return;this.resolveFinishedPromise(),this.updateFinishedPromise();const{resolved:e}=this;if(!e)return;const{animation:t,keyframes:n,duration:s,type:i,ease:a,times:r}=e;if("idle"===t.playState||"finished"===t.playState)return;if(this.time){const{motionValue:e,onUpdate:t,onComplete:o,element:l,...c}=this.options,d=new NN({...c,keyframes:n,duration:s,type:i,ease:a,times:r,isGenerator:!0}),u=Yw(this.time);e.setWithVelocity(d.sample(u-10).value,d.sample(u).value,10)}const{onStop:o}=this.options;o&&o(),this.cancel()}complete(){const{resolved:e}=this;e&&e.animation.finish()}cancel(){const{resolved:e}=this;e&&e.animation.cancel()}static supports(e){const{motionValue:t,name:n,repeatDelay:s,repeatType:i,damping:a,type:r}=e;if(!(t&&t.owner&&t.owner.current instanceof HTMLElement))return!1;const{onUpdate:o,transformTemplate:l}=t.owner.getProps();return kN()&&n&&FN.has(n)&&!o&&!l&&!s&&"mirror"!==i&&0!==a&&"inertia"!==r}}const IN={type:"spring",stiffness:500,damping:25,restSpeed:10},AN={type:"keyframes",duration:.8},TN={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},MN=(e,{keyframes:t})=>t.length>2?AN:Ay.has(e)?e.startsWith("scale")?{type:"spring",stiffness:550,damping:0===t[1]?2*Math.sqrt(550):30,restSpeed:10}:IN:TN;const DN=(e,t,n,s={},i,a)=>r=>{const o=Aw(s,e)||{},l=o.delay||s.delay||0;let{elapsed:c=0}=s;c-=Yw(l);let d={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:t.getVelocity(),...o,delay:-c,onUpdate:e=>{t.set(e),o.onUpdate&&o.onUpdate(e)},onComplete:()=>{r(),o.onComplete&&o.onComplete()},name:e,motionValue:t,element:a?void 0:i};(function({when:e,delay:t,delayChildren:n,staggerChildren:s,staggerDirection:i,repeat:a,repeatType:r,repeatDelay:o,from:l,elapsed:c,...d}){return!!Object.keys(d).length})(o)||(d={...d,...MN(e,d)}),d.duration&&(d.duration=Yw(d.duration)),d.repeatDelay&&(d.repeatDelay=Yw(d.repeatDelay)),void 0!==d.from&&(d.keyframes[0]=d.from);let u=!1;if((!1===d.type||0===d.duration&&!d.repeatDelay)&&(d.duration=0,0===d.delay&&(u=!0)),d.allowFlatten=!o.type&&!o.ease,u&&!a&&void 0!==t.get()){const e=NC(d.keyframes,o);if(void 0!==e)return qb.update(()=>{d.onUpdate(e),d.onComplete()}),new Zw([])}return!a&&EN.supports(d)?new EN(d):new NN(d)};function LN({protectedKeys:e,needsAnimating:t},n){const s=e.hasOwnProperty(n)&&!0!==t[n];return t[n]=!1,s}function PN(e,t,{delay:n=0,transitionOverride:s,type:i}={}){var a;let{transition:r=e.getDefaultTransition(),transitionEnd:o,...l}=t;s&&(r=s);const c=[],d=i&&e.animationState&&e.animationState.getState()[i];for(const u in l){const t=e.getValue(u,null!==(a=e.latestValues[u])&&void 0!==a?a:null),s=l[u];if(void 0===s||d&&LN(d,u))continue;const i={delay:n,...Aw(r||{},u)};let o=!1;if(window.MotionHandoffAnimation){const t=Uw(e);if(t){const e=window.MotionHandoffAnimation(t,u,qb);null!==e&&(i.startTime=e,o=!0)}}Vw(e,u),t.start(DN(u,t,s,e.shouldReduceMotion&&Tw.has(u)?{type:!1}:i,e,o));const p=t.animation;p&&c.push(p)}return o&&Promise.all(c).then(()=>{qb.update(()=>{o&&function(e,t){const n=Iw(e,t);let{transitionEnd:s={},transition:i={},...a}=n||{};a={...a,...s};for(const r in a)$w(e,r,fw(a[r]))}(e,o)})}),c}function RN(e,t,n={}){var s;const i=Iw(e,t,"exit"===n.type?null===(s=e.presenceContext)||void 0===s?void 0:s.custom:void 0);let{transition:a=e.getDefaultTransition()||{}}=i||{};n.transitionOverride&&(a=n.transitionOverride);const r=i?()=>Promise.all(PN(e,i,n)):()=>Promise.resolve(),o=e.variantChildren&&e.variantChildren.size?(s=0)=>{const{delayChildren:i=0,staggerChildren:r,staggerDirection:o}=a;return function(e,t,n=0,s=0,i=1,a){const r=[],o=(e.variantChildren.size-1)*s,l=1===i?(e=0)=>e*s:(e=0)=>o-e*s;return Array.from(e.variantChildren).sort(ON).forEach((e,s)=>{e.notify("AnimationStart",t),r.push(RN(e,t,{...a,delay:n+l(s)}).then(()=>e.notify("AnimationComplete",t)))}),Promise.all(r)}(e,t,i+s,r,o,n)}:()=>Promise.resolve(),{when:l}=a;if(l){const[e,t]="beforeChildren"===l?[r,o]:[o,r];return e().then(()=>t())}return Promise.all([r(),o(n.delay)])}function ON(e,t){return e.sortNodePosition(t)}function zN(e,t){if(!Array.isArray(t))return!1;const n=t.length;if(n!==e.length)return!1;for(let s=0;sPromise.all(t.map(({animation:t,options:n})=>function(e,t,n={}){let s;if(e.notify("AnimationStart",t),Array.isArray(t)){const i=t.map(t=>RN(e,t,n));s=Promise.all(i)}else if("string"==typeof t)s=RN(e,t,n);else{const i="function"==typeof t?Iw(e,t,n.custom):t;s=Promise.all(PN(e,i,n))}return s.then(()=>{e.notify("AnimationComplete",t)})}(e,t,n)))}function WN(e){let t=UN(e),n=ZN(),s=!0;const i=t=>(n,s)=>{var i;const a=Iw(e,s,"exit"===t?null===(i=e.presenceContext)||void 0===i?void 0:i.custom:void 0);if(a){const{transition:e,transitionEnd:t,...s}=a;n={...n,...s,...t}}return n};function a(a){const{props:r}=e,o=HN(e.parent)||{},l=[],c=new Set;let d={},u=1/0;for(let t=0;tu&&x,y=!1;const w=Array.isArray(h)?h:[h];let j=w.reduce(i(p),{});!1===f&&(j={});const{prevResolvedValues:C={}}=m,N={...C,...j},F=t=>{b=!0,c.has(t)&&(y=!0,c.delete(t)),m.needsAnimating[t]=!0;const n=e.getValue(t);n&&(n.liveStyle=!1)};for(const e in N){const t=j[e],n=C[e];if(d.hasOwnProperty(e))continue;let s=!1;s=xw(t)&&xw(n)?!zN(t,n):t!==n,s?null!=t?F(e):c.add(e):void 0!==t&&c.has(e)?F(e):m.protectedKeys[e]=!0}m.prevProp=h,m.prevResolvedValues=j,m.isActive&&(d={...d,...j}),s&&e.blockInitialAnimation&&(b=!1);b&&(!(g&&v)||y)&&l.push(...w.map(e=>({animation:e,options:{type:p}})))}if(c.size){const t={};if("boolean"!=typeof r.initial){const n=Iw(e,Array.isArray(r.initial)?r.initial[0]:r.initial);n&&n.transition&&(t.transition=n.transition)}c.forEach(n=>{const s=e.getBaseTarget(n),i=e.getValue(n);i&&(i.liveStyle=!0),t[n]=null!=s?s:null}),l.push({animation:t})}let p=Boolean(l.length);return!s||!1!==r.initial&&r.initial!==r.animate||e.manuallyAnimateOnMount||(p=!1),s=!1,p?t(l):Promise.resolve()}return{animateChanges:a,setActive:function(t,s){var i;if(n[t].isActive===s)return Promise.resolve();null===(i=e.variantChildren)||void 0===i||i.forEach(e=>{var n;return null===(n=e.animationState)||void 0===n?void 0:n.setActive(t,s)}),n[t].isActive=s;const r=a(t);for(const e in n)n[e].protectedKeys={};return r},setAnimateFunction:function(n){t=n(e)},getState:()=>n,reset:()=>{n=ZN(),s=!0}}}function qN(e,t){return"string"==typeof t?t!==e:!!Array.isArray(t)&&!zN(t,e)}function GN(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function ZN(){return{animate:GN(!0),whileInView:GN(),whileHover:GN(),whileTap:GN(),whileDrag:GN(),whileFocus:GN(),exit:GN()}}class YN{constructor(e){this.isMounted=!1,this.node=e}update(){}}let KN=0;const JN={animation:{Feature:class extends YN{constructor(e){super(e),e.animationState||(e.animationState=WN(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();ay(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:e}=this.node.getProps(),{animate:t}=this.node.prevProps||{};e!==t&&this.updateAnimationControlsSubscription()}unmount(){var e;this.node.animationState.reset(),null===(e=this.unmountControls)||void 0===e||e.call(this)}}},exit:{Feature:class extends YN{constructor(){super(...arguments),this.id=KN++}update(){if(!this.node.presenceContext)return;const{isPresent:e,onExitComplete:t}=this.node.presenceContext,{isPresent:n}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===n)return;const s=this.node.animationState.setActive("exit",!e);t&&!e&&s.then(()=>{t(this.id)})}mount(){const{register:e,onExitComplete:t}=this.node.presenceContext||{};t&&t(this.id),e&&(this.unmount=e(this.id))}unmount(){}}}},QN={x:!1,y:!1};function XN(){return QN.x||QN.y}function eF(e,t,n,s={passive:!0}){return e.addEventListener(t,n,s),()=>e.removeEventListener(t,n)}const tF=e=>"mouse"===e.pointerType?"number"!=typeof e.button||e.button<=0:!1!==e.isPrimary;function nF(e){return{point:{x:e.pageX,y:e.pageY}}}function sF(e,t,n,s){return eF(e,t,(e=>t=>tF(t)&&e(t,nF(t)))(n),s)}function iF({top:e,left:t,right:n,bottom:s}){return{x:{min:t,max:n},y:{min:e,max:s}}}function aF(e){return e.max-e.min}function rF(e,t,n,s=.5){e.origin=s,e.originPoint=SC(t.min,t.max,e.origin),e.scale=aF(n)/aF(t),e.translate=SC(n.min,n.max,e.origin)-e.originPoint,(e.scale>=.9999&&e.scale<=1.0001||isNaN(e.scale))&&(e.scale=1),(e.translate>=-.01&&e.translate<=.01||isNaN(e.translate))&&(e.translate=0)}function oF(e,t,n,s){rF(e.x,t.x,n.x,s?s.originX:void 0),rF(e.y,t.y,n.y,s?s.originY:void 0)}function lF(e,t,n){e.min=n.min+t.min,e.max=e.min+aF(t)}function cF(e,t,n){e.min=t.min-n.min,e.max=e.min+aF(t)}function dF(e,t,n){cF(e.x,t.x,n.x),cF(e.y,t.y,n.y)}const uF=()=>({x:{min:0,max:0},y:{min:0,max:0}});function pF(e){return[e("x"),e("y")]}function mF(e){return void 0===e||1===e}function hF({scale:e,scaleX:t,scaleY:n}){return!mF(e)||!mF(t)||!mF(n)}function xF(e){return hF(e)||fF(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function fF(e){return gF(e.x)||gF(e.y)}function gF(e){return e&&"0%"!==e}function vF(e,t,n){return n+t*(e-n)}function bF(e,t,n,s,i){return void 0!==i&&(e=vF(e,i,s)),vF(e,n,s)+t}function yF(e,t=0,n=1,s,i){e.min=bF(e.min,t,n,s,i),e.max=bF(e.max,t,n,s,i)}function wF(e,{x:t,y:n}){yF(e.x,t.translate,t.scale,t.originPoint),yF(e.y,n.translate,n.scale,n.originPoint)}const jF=.999999999999,CF=1.0000000000001;function NF(e,t){e.min=e.min+t,e.max=e.max+t}function FF(e,t,n,s,i=.5){yF(e,t,n,SC(e.min,e.max,i),s)}function _F(e,t){FF(e.x,t.x,t.scaleX,t.scale,t.originX),FF(e.y,t.y,t.scaleY,t.scale,t.originY)}function kF(e,t){return iF(function(e,t){if(!t)return e;const n=t({x:e.left,y:e.top}),s=t({x:e.right,y:e.bottom});return{top:n.y,left:n.x,bottom:s.y,right:s.x}}(e.getBoundingClientRect(),t))}const SF=({current:e})=>e?e.ownerDocument.defaultView:null,EF=(e,t)=>Math.abs(e-t);class IF{constructor(e,t,{transformPagePoint:n,contextWindow:s,dragSnapToOrigin:i=!1}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.updatePoint=()=>{if(!this.lastMoveEvent||!this.lastMoveEventInfo)return;const e=MF(this.lastMoveEventInfo,this.history),t=null!==this.startEvent,n=function(e,t){const n=EF(e.x,t.x),s=EF(e.y,t.y);return Math.sqrt(n**2+s**2)}(e.offset,{x:0,y:0})>=3;if(!t&&!n)return;const{point:s}=e,{timestamp:i}=Zb;this.history.push({...s,timestamp:i});const{onStart:a,onMove:r}=this.handlers;t||(a&&a(this.lastMoveEvent,e),this.startEvent=this.lastMoveEvent),r&&r(this.lastMoveEvent,e)},this.handlePointerMove=(e,t)=>{this.lastMoveEvent=e,this.lastMoveEventInfo=AF(t,this.transformPagePoint),qb.update(this.updatePoint,!0)},this.handlePointerUp=(e,t)=>{this.end();const{onEnd:n,onSessionEnd:s,resumeAnimation:i}=this.handlers;if(this.dragSnapToOrigin&&i&&i(),!this.lastMoveEvent||!this.lastMoveEventInfo)return;const a=MF("pointercancel"===e.type?this.lastMoveEventInfo:AF(t,this.transformPagePoint),this.history);this.startEvent&&n&&n(e,a),s&&s(e,a)},!tF(e))return;this.dragSnapToOrigin=i,this.handlers=t,this.transformPagePoint=n,this.contextWindow=s||window;const a=AF(nF(e),this.transformPagePoint),{point:r}=a,{timestamp:o}=Zb;this.history=[{...r,timestamp:o}];const{onSessionStart:l}=t;l&&l(e,MF(a,this.history)),this.removeListeners=PC(sF(this.contextWindow,"pointermove",this.handlePointerMove),sF(this.contextWindow,"pointerup",this.handlePointerUp),sF(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),Gb(this.updatePoint)}}function AF(e,t){return t?{point:t(e.point)}:e}function TF(e,t){return{x:e.x-t.x,y:e.y-t.y}}function MF({point:e},t){return{point:e,delta:TF(e,LF(t)),offset:TF(e,DF(t)),velocity:PF(t,.1)}}function DF(e){return e[0]}function LF(e){return e[e.length-1]}function PF(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,s=null;const i=LF(e);for(;n>=0&&(s=e[n],!(i.timestamp-s.timestamp>Yw(t)));)n--;if(!s)return{x:0,y:0};const a=Kw(i.timestamp-s.timestamp);if(0===a)return{x:0,y:0};const r={x:(i.x-s.x)/a,y:(i.y-s.y)/a};return r.x===1/0&&(r.x=0),r.y===1/0&&(r.y=0),r}function RF(e,t,n){return{min:void 0!==t?e.min+t:void 0,max:void 0!==n?e.max+n-(e.max-e.min):void 0}}function OF(e,t){let n=t.min-e.min,s=t.max-e.max;return t.max-t.min{const{dragSnapToOrigin:n}=this.getProps();n?this.pauseAnimation():this.stopAnimation(),t&&this.snapToCursor(nF(e).point)},onStart:(e,t)=>{const{drag:n,dragPropagation:s,onDragStart:i}=this.getProps();if(n&&!s&&(this.openDragLock&&this.openDragLock(),this.openDragLock="x"===(a=n)||"y"===a?QN[a]?null:(QN[a]=!0,()=>{QN[a]=!1}):QN.x||QN.y?null:(QN.x=QN.y=!0,()=>{QN.x=QN.y=!1}),!this.openDragLock))return;var a;this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),pF(e=>{let t=this.getAxisMotionValue(e).get()||0;if(Hy.test(t)){const{projection:n}=this.visualElement;if(n&&n.layout){const s=n.layout.layoutBox[e];if(s){t=aF(s)*(parseFloat(t)/100)}}}this.originPoint[e]=t}),i&&qb.postRender(()=>i(e,t)),Vw(this.visualElement,"transform");const{animationState:r}=this.visualElement;r&&r.setActive("whileDrag",!0)},onMove:(e,t)=>{const{dragPropagation:n,dragDirectionLock:s,onDirectionLock:i,onDrag:a}=this.getProps();if(!n&&!this.openDragLock)return;const{offset:r}=t;if(s&&null===this.currentDirection)return this.currentDirection=function(e,t=10){let n=null;Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x");return n}(r),void(null!==this.currentDirection&&i&&i(this.currentDirection));this.updateAxis("x",t.point,r),this.updateAxis("y",t.point,r),this.visualElement.render(),a&&a(e,t)},onSessionEnd:(e,t)=>this.stop(e,t),resumeAnimation:()=>pF(e=>{var t;return"paused"===this.getAnimationState(e)&&(null===(t=this.getAxisMotionValue(e).animation)||void 0===t?void 0:t.play())})},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:s,contextWindow:SF(this.visualElement)})}stop(e,t){const n=this.isDragging;if(this.cancel(),!n)return;const{velocity:s}=t;this.startAnimation(s);const{onDragEnd:i}=this.getProps();i&&qb.postRender(()=>i(e,t))}cancel(){this.isDragging=!1;const{projection:e,animationState:t}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.panSession&&this.panSession.end(),this.panSession=void 0;const{dragPropagation:n}=this.getProps();!n&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),t&&t.setActive("whileDrag",!1)}updateAxis(e,t,n){const{drag:s}=this.getProps();if(!n||!UF(e,s,this.currentDirection))return;const i=this.getAxisMotionValue(e);let a=this.originPoint[e]+n[e];this.constraints&&this.constraints[e]&&(a=function(e,{min:t,max:n},s){return void 0!==t&&en&&(e=s?SC(n,e,s.max):Math.min(e,n)),e}(a,this.constraints[e],this.elastic[e])),i.set(a)}resolveConstraints(){var e;const{dragConstraints:t,dragElastic:n}=this.getProps(),s=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):null===(e=this.visualElement.projection)||void 0===e?void 0:e.layout,i=this.constraints;t&&hy(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):this.constraints=!(!t||!s)&&function(e,{top:t,left:n,bottom:s,right:i}){return{x:RF(e.x,n,i),y:RF(e.y,t,s)}}(s.layoutBox,t),this.elastic=function(e=zF){return!1===e?e=0:!0===e&&(e=zF),{x:BF(e,"left","right"),y:BF(e,"top","bottom")}}(n),i!==this.constraints&&s&&this.constraints&&!this.hasMutatedConstraints&&pF(e=>{!1!==this.constraints&&this.getAxisMotionValue(e)&&(this.constraints[e]=function(e,t){const n={};return void 0!==t.min&&(n.min=t.min-e.min),void 0!==t.max&&(n.max=t.max-e.min),n}(s.layoutBox[e],this.constraints[e]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:t}=this.getProps();if(!e||!hy(e))return!1;const n=e.current,{projection:s}=this.visualElement;if(!s||!s.layout)return!1;const i=function(e,t,n){const s=kF(e,n),{scroll:i}=t;return i&&(NF(s.x,i.offset.x),NF(s.y,i.offset.y)),s}(n,s.root,this.visualElement.getTransformPagePoint());let a=function(e,t){return{x:OF(e.x,t.x),y:OF(e.y,t.y)}}(s.layout.layoutBox,i);if(t){const e=t(function({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}(a));this.hasMutatedConstraints=!!e,e&&(a=iF(e))}return a}startAnimation(e){const{drag:t,dragMomentum:n,dragElastic:s,dragTransition:i,dragSnapToOrigin:a,onDragTransitionEnd:r}=this.getProps(),o=this.constraints||{},l=pF(r=>{if(!UF(r,t,this.currentDirection))return;let l=o&&o[r]||{};a&&(l={min:0,max:0});const c=s?200:1e6,d=s?40:1e7,u={type:"inertia",velocity:n?e[r]:0,bounceStiffness:c,bounceDamping:d,timeConstant:750,restDelta:1,restSpeed:10,...i,...l};return this.startAxisValueAnimation(r,u)});return Promise.all(l).then(r)}startAxisValueAnimation(e,t){const n=this.getAxisMotionValue(e);return Vw(this.visualElement,e),n.start(DN(e,n,0,t,this.visualElement,!1))}stopAnimation(){pF(e=>this.getAxisMotionValue(e).stop())}pauseAnimation(){pF(e=>{var t;return null===(t=this.getAxisMotionValue(e).animation)||void 0===t?void 0:t.pause()})}getAnimationState(e){var t;return null===(t=this.getAxisMotionValue(e).animation)||void 0===t?void 0:t.state}getAxisMotionValue(e){const t=`_drag${e.toUpperCase()}`,n=this.visualElement.getProps(),s=n[t];return s||this.visualElement.getValue(e,(n.initial?n.initial[e]:void 0)||0)}snapToCursor(e){pF(t=>{const{drag:n}=this.getProps();if(!UF(t,n,this.currentDirection))return;const{projection:s}=this.visualElement,i=this.getAxisMotionValue(t);if(s&&s.layout){const{min:n,max:a}=s.layout.layoutBox[t];i.set(e[t]-SC(n,a,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:e,dragConstraints:t}=this.getProps(),{projection:n}=this.visualElement;if(!hy(t)||!n||!this.constraints)return;this.stopAnimation();const s={x:0,y:0};pF(e=>{const t=this.getAxisMotionValue(e);if(t&&!1!==this.constraints){const n=t.get();s[e]=function(e,t){let n=.5;const s=aF(e),i=aF(t);return i>s?n=sj(t.min,t.max-s,e.min):s>i&&(n=sj(e.min,e.max-i,t.min)),Ly(0,1,n)}({min:n,max:n},this.constraints[e])}});const{transformTemplate:i}=this.visualElement.getProps();this.visualElement.current.style.transform=i?i({},""):"none",n.root&&n.root.updateScroll(),n.updateLayout(),this.resolveConstraints(),pF(t=>{if(!UF(t,e,null))return;const n=this.getAxisMotionValue(t),{min:i,max:a}=this.constraints[t];n.set(SC(i,a,s[t]))})}addListeners(){if(!this.visualElement.current)return;$F.set(this.visualElement,this);const e=sF(this.visualElement.current,"pointerdown",e=>{const{drag:t,dragListener:n=!0}=this.getProps();t&&n&&this.start(e)}),t=()=>{const{dragConstraints:e}=this.getProps();hy(e)&&e.current&&(this.constraints=this.resolveRefConstraints())},{projection:n}=this.visualElement,s=n.addEventListener("measure",t);n&&!n.layout&&(n.root&&n.root.updateScroll(),n.updateLayout()),qb.read(t);const i=eF(window,"resize",()=>this.scalePositionWithinConstraints()),a=n.addEventListener("didUpdate",({delta:e,hasLayoutChanged:t})=>{this.isDragging&&t&&(pF(t=>{const n=this.getAxisMotionValue(t);n&&(this.originPoint[t]+=e[t].translate,n.set(n.get()+e[t].translate))}),this.visualElement.render())});return()=>{i(),e(),s(),a&&a()}}getProps(){const e=this.visualElement.getProps(),{drag:t=!1,dragDirectionLock:n=!1,dragPropagation:s=!1,dragConstraints:i=!1,dragElastic:a=zF,dragMomentum:r=!0}=e;return{...e,drag:t,dragDirectionLock:n,dragPropagation:s,dragConstraints:i,dragElastic:a,dragMomentum:r}}}function UF(e,t,n){return!(!0!==t&&t!==e||null!==n&&n!==e)}const WF=e=>(t,n)=>{e&&qb.postRender(()=>e(t,n))};const qF={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function GF(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}const ZF={correct:(e,t)=>{if(!t.target)return e;if("string"==typeof e){if(!$y.test(e))return e;e=parseFloat(e)}return`${GF(e,t.target.x)}% ${GF(e,t.target.y)}%`}},YF={correct:(e,{treeScale:t,projectionDelta:n})=>{const s=e,i=Bj.parse(e);if(i.length>5)return s;const a=Bj.createTransformer(e),r="number"!=typeof i[0]?1:0,o=n.x.scale*t.x,l=n.y.scale*t.y;i[0+r]/=o,i[1+r]/=l;const c=SC(o,l,.5);return"number"==typeof i[2+r]&&(i[2+r]/=c),"number"==typeof i[3+r]&&(i[3+r]/=c),a(i)}};class KF extends Pe.Component{componentDidMount(){const{visualElement:e,layoutGroup:t,switchLayoutGroup:n,layoutId:s}=this.props,{projection:i}=e;!function(e){for(const t in e)Ey[t]=e[t],Fy(t)&&(Ey[t].isCSSVariable=!0)}(QF),i&&(t.group&&t.group.add(i),n&&n.register&&s&&n.register(i),i.root.didUpdate(),i.addEventListener("animationComplete",()=>{this.safeToRemove()}),i.setOptions({...i.options,onExitComplete:()=>this.safeToRemove()})),qF.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){const{layoutDependency:t,visualElement:n,drag:s,isPresent:i}=this.props,a=n.projection;return a?(a.isPresent=i,s||e.layoutDependency!==t||void 0===t||e.isPresent!==i?a.willUpdate():this.safeToRemove(),e.isPresent!==i&&(i?a.promote():a.relegate()||qb.postRender(()=>{const e=a.getStack();e&&e.members.length||this.safeToRemove()})),null):null}componentDidUpdate(){const{projection:e}=this.props.visualElement;e&&(e.root.didUpdate(),fy.postRender(()=>{!e.currentAnimation&&e.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:e,layoutGroup:t,switchLayoutGroup:n}=this.props,{projection:s}=e;s&&(s.scheduleCheckAfterUnmount(),t&&t.group&&t.group.remove(s),n&&n.deregister&&n.deregister(s))}safeToRemove(){const{safeToRemove:e}=this.props;e&&e()}render(){return null}}function JF(e){const[t,n]=Pb(),s=Pe.useContext(_b);return a.jsx(KF,{...e,layoutGroup:s,switchLayoutGroup:Pe.useContext(by),isPresent:t,safeToRemove:n})}const QF={borderRadius:{...ZF,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:ZF,borderTopRightRadius:ZF,borderBottomLeftRadius:ZF,borderBottomRightRadius:ZF,boxShadow:YF};const XF=(e,t)=>e.depth-t.depth;class e_{constructor(){this.children=[],this.isDirty=!1}add(e){Mw(this.children,e),this.isDirty=!0}remove(e){Dw(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(XF),this.isDirty=!1,this.children.forEach(e)}}const t_=["TopLeft","TopRight","BottomLeft","BottomRight"],n_=t_.length,s_=e=>"string"==typeof e?parseFloat(e):e,i_=e=>"number"==typeof e||$y.test(e);function a_(e,t){return void 0!==e[t]?e[t]:e.borderRadius}const r_=l_(0,.5,vj),o_=l_(.5,.95,Bb);function l_(e,t,n){return s=>st?1:n(sj(e,t,s))}function c_(e,t){e.min=t.min,e.max=t.max}function d_(e,t){c_(e.x,t.x),c_(e.y,t.y)}function u_(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}function p_(e,t,n,s,i){return e=vF(e-=t,1/n,s),void 0!==i&&(e=vF(e,1/i,s)),e}function m_(e,t,[n,s,i],a,r){!function(e,t=0,n=1,s=.5,i,a=e,r=e){Hy.test(t)&&(t=parseFloat(t),t=SC(r.min,r.max,t/100)-r.min);if("number"!=typeof t)return;let o=SC(a.min,a.max,s);e===a&&(o-=t),e.min=p_(e.min,t,n,o,i),e.max=p_(e.max,t,n,o,i)}(e,t[n],t[s],t[i],t.scale,a,r)}const h_=["x","scaleX","originX"],x_=["y","scaleY","originY"];function f_(e,t,n,s){m_(e.x,t,h_,n?n.x:void 0,s?s.x:void 0),m_(e.y,t,x_,n?n.y:void 0,s?s.y:void 0)}function g_(e){return 0===e.translate&&1===e.scale}function v_(e){return g_(e.x)&&g_(e.y)}function b_(e,t){return e.min===t.min&&e.max===t.max}function y_(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function w_(e,t){return y_(e.x,t.x)&&y_(e.y,t.y)}function j_(e){return aF(e.x)/aF(e.y)}function C_(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}class N_{constructor(){this.members=[]}add(e){Mw(this.members,e),e.scheduleRender()}remove(e){if(Dw(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){const e=this.members[this.members.length-1];e&&this.promote(e)}}relegate(e){const t=this.members.findIndex(t=>e===t);if(0===t)return!1;let n;for(let s=t;s>=0;s--){const e=this.members[s];if(!1!==e.isPresent){n=e;break}}return!!n&&(this.promote(n),!0)}promote(e,t){const n=this.lead;if(e!==n&&(this.prevLead=n,this.lead=e,e.show(),n)){n.instance&&n.scheduleRender(),e.scheduleRender(),e.resumeFrom=n,t&&(e.resumeFrom.preserveOpacity=!0),n.snapshot&&(e.snapshot=n.snapshot,e.snapshot.latestValues=n.animationValues||n.latestValues),e.root&&e.root.isUpdating&&(e.isLayoutDirty=!0);const{crossfade:s}=e.options;!1===s&&n.hide()}}exitAnimationComplete(){this.members.forEach(e=>{const{options:t,resumingFrom:n}=e;t.onExitComplete&&t.onExitComplete(),n&&n.options.onExitComplete&&n.options.onExitComplete()})}scheduleRender(){this.members.forEach(e=>{e.instance&&e.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}const F_=["","X","Y","Z"],__={visibility:"hidden"};let k_=0;function S_(e,t,n,s){const{latestValues:i}=t;i[e]&&(n[e]=i[e],t.setStaticValue(e,0),s&&(s[e]=0))}function E_(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;const{visualElement:t}=e.options;if(!t)return;const n=Uw(t);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:t,layoutId:s}=e.options;window.MotionCancelOptimisedAnimation(n,"transform",qb,!(t||s))}const{parent:s}=e;s&&!s.hasCheckedOptimisedAppear&&E_(s)}function I_({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:s,resetTransform:i}){return class{constructor(e={},n=(null==t?void 0:t())){this.id=k_++,this.animationId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,this.nodes.forEach(M_),this.nodes.forEach(B_),this.nodes.forEach(H_),this.nodes.forEach(D_)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=e,this.root=n?n.root||n:this,this.path=n?[...n.path,n]:[],this.parent=n,this.depth=n?n.depth+1:0;for(let t=0;tthis.root.updateBlockedByResize=!1;e(t,()=>{this.root.updateBlockedByResize=!0,n&&n(),n=function(e,t){const n=zw.now(),s=({timestamp:i})=>{const a=i-n;a>=t&&(Gb(s),e(a-t))};return qb.read(s,!0),()=>Gb(s)}(s,250),qF.hasAnimatedSinceResize&&(qF.hasAnimatedSinceResize=!1,this.nodes.forEach(z_))})}i&&this.root.registerSharedNode(i,this),!1!==this.options.animate&&r&&(i||a)&&this.addEventListener("didUpdate",({delta:e,hasLayoutChanged:t,hasRelativeLayoutChanged:n,layout:s})=>{if(this.isTreeAnimationBlocked())return this.target=void 0,void(this.relativeTarget=void 0);const i=this.options.transition||r.getDefaultTransition()||G_,{onLayoutAnimationStart:a,onLayoutAnimationComplete:o}=r.getProps(),l=!this.targetLayout||!w_(this.targetLayout,s),c=!t&&n;if(this.options.layoutRoot||this.resumeFrom||c||t&&(l||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0),this.setAnimationOrigin(e,c);const t={...Aw(i,"layout"),onPlay:a,onComplete:o};(r.shouldReduceMotion||this.options.layoutRoot)&&(t.delay=0,t.type=!1),this.startAnimation(t)}else t||z_(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=s})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const e=this.getStack();e&&e.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,Gb(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach($_),this.animationId++)}getTransformTemplate(){const{visualElement:e}=this.options;return e&&e.getProps().transformTemplate}willUpdate(e=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked())return void(this.options.onExitComplete&&this.options.onExitComplete());if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&E_(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let i=0;i{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){!this.snapshot&&this.instance&&(this.snapshot=this.measure(),!this.snapshot||aF(this.snapshot.measuredBox.x)||aF(this.snapshot.measuredBox.y)||(this.snapshot=void 0))}updateLayout(){if(!this.instance)return;if(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead()||this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let n=0;njF&&(t.x=1),t.yjF&&(t.y=1)}(this.layoutCorrected,this.treeScale,this.path,n),!t.layout||t.target||1===this.treeScale.x&&1===this.treeScale.y||(t.target=t.layout.layoutBox,t.targetWithTransforms={x:{min:0,max:0},y:{min:0,max:0}});const{target:l}=t;l?(this.projectionDelta&&this.prevProjectionDelta?(u_(this.prevProjectionDelta.x,this.projectionDelta.x),u_(this.prevProjectionDelta.y,this.projectionDelta.y)):this.createProjectionDeltas(),oF(this.projectionDelta,this.layoutCorrected,l,this.latestValues),this.treeScale.x===r&&this.treeScale.y===o&&C_(this.projectionDelta.x,this.prevProjectionDelta.x)&&C_(this.projectionDelta.y,this.prevProjectionDelta.y)||(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",l))):this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender())}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(e=!0){var t;if(null===(t=this.options.visualElement)||void 0===t||t.scheduleRender(),e){const e=this.getStack();e&&e.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta={x:{translate:0,scale:1,origin:0,originPoint:0},y:{translate:0,scale:1,origin:0,originPoint:0}},this.projectionDelta={x:{translate:0,scale:1,origin:0,originPoint:0},y:{translate:0,scale:1,origin:0,originPoint:0}},this.projectionDeltaWithTransform={x:{translate:0,scale:1,origin:0,originPoint:0},y:{translate:0,scale:1,origin:0,originPoint:0}}}setAnimationOrigin(e,t=!1){const n=this.snapshot,s=n?n.latestValues:{},i={...this.latestValues},a={x:{translate:0,scale:1,origin:0,originPoint:0},y:{translate:0,scale:1,origin:0,originPoint:0}};this.relativeParent&&this.relativeParent.options.layoutRoot||(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!t;const r={x:{min:0,max:0},y:{min:0,max:0}},o=(n?n.source:void 0)!==(this.layout?this.layout.source:void 0),l=this.getStack(),c=!l||l.members.length<=1,d=Boolean(o&&!c&&!0===this.options.crossfade&&!this.path.some(q_));let u;this.animationProgress=0,this.mixTargetDelta=t=>{const n=t/1e3;var l,p,m,h,x,f;U_(a.x,e.x,n),U_(a.y,e.y,n),this.setTargetDelta(a),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(dF(r,this.layout.layoutBox,this.relativeParent.layout.layoutBox),m=this.relativeTarget,h=this.relativeTargetOrigin,x=r,f=n,W_(m.x,h.x,x.x,f),W_(m.y,h.y,x.y,f),u&&(l=this.relativeTarget,p=u,b_(l.x,p.x)&&b_(l.y,p.y))&&(this.isProjectionDirty=!1),u||(u={x:{min:0,max:0},y:{min:0,max:0}}),d_(u,this.relativeTarget)),o&&(this.animationValues=i,function(e,t,n,s,i,a){i?(e.opacity=SC(0,void 0!==n.opacity?n.opacity:1,r_(s)),e.opacityExit=SC(void 0!==t.opacity?t.opacity:1,0,o_(s))):a&&(e.opacity=SC(void 0!==t.opacity?t.opacity:1,void 0!==n.opacity?n.opacity:1,s));for(let r=0;r{qF.hasAnimatedSinceResize=!0,this.currentAnimation=function(e,t,n){const s=My(e)?e:Hw(e);return s.start(DN("",s,t,n)),s.animation}(0,1e3,{...e,onUpdate:t=>{this.mixTargetDelta(t),e.onUpdate&&e.onUpdate(t)},onStop:()=>{},onComplete:()=>{e.onComplete&&e.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const e=this.getStack();e&&e.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(1e3),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const e=this.getLead();let{targetWithTransforms:t,target:n,layout:s,latestValues:i}=e;if(t&&n&&s){if(this!==e&&this.layout&&s&&J_(this.options.animationType,this.layout.layoutBox,s.layoutBox)){n=this.target||{x:{min:0,max:0},y:{min:0,max:0}};const t=aF(this.layout.layoutBox.x);n.x.min=e.target.x.min,n.x.max=n.x.min+t;const s=aF(this.layout.layoutBox.y);n.y.min=e.target.y.min,n.y.max=n.y.min+s}d_(t,n),_F(t,i),oF(this.projectionDeltaWithTransform,this.layoutCorrected,t,i)}}registerSharedNode(e,t){this.sharedNodes.has(e)||this.sharedNodes.set(e,new N_);this.sharedNodes.get(e).add(t);const n=t.options.initialPromotionConfig;t.promote({transition:n?n.transition:void 0,preserveFollowOpacity:n&&n.shouldPreserveFollowOpacity?n.shouldPreserveFollowOpacity(t):void 0})}isLead(){const e=this.getStack();return!e||e.lead===this}getLead(){var e;const{layoutId:t}=this.options;return t&&(null===(e=this.getStack())||void 0===e?void 0:e.lead)||this}getPrevLead(){var e;const{layoutId:t}=this.options;return t?null===(e=this.getStack())||void 0===e?void 0:e.prevLead:void 0}getStack(){const{layoutId:e}=this.options;if(e)return this.root.sharedNodes.get(e)}promote({needsReset:e,transition:t,preserveFollowOpacity:n}={}){const s=this.getStack();s&&s.promote(this,n),e&&(this.projectionDelta=void 0,this.needsReset=!0),t&&this.setOptions({transition:t})}relegate(){const e=this.getStack();return!!e&&e.relegate(this)}resetSkewAndRotation(){const{visualElement:e}=this.options;if(!e)return;let t=!1;const{latestValues:n}=e;if((n.z||n.rotate||n.rotateX||n.rotateY||n.rotateZ||n.skewX||n.skewY)&&(t=!0),!t)return;const s={};n.z&&S_("z",e,s,this.animationValues);for(let i=0;i{var t;return null===(t=e.currentAnimation)||void 0===t?void 0:t.stop()}),this.root.nodes.forEach(P_),this.root.sharedNodes.clear()}}}function A_(e){e.updateLayout()}function T_(e){var t;const n=(null===(t=e.resumeFrom)||void 0===t?void 0:t.snapshot)||e.snapshot;if(e.isLead()&&e.layout&&n&&e.hasListeners("didUpdate")){const{layoutBox:t,measuredBox:s}=e.layout,{animationType:i}=e.options,a=n.source!==e.layout.source;"size"===i?pF(e=>{const s=a?n.measuredBox[e]:n.layoutBox[e],i=aF(s);s.min=t[e].min,s.max=s.min+i}):J_(i,n.layoutBox,t)&&pF(s=>{const i=a?n.measuredBox[s]:n.layoutBox[s],r=aF(t[s]);i.max=i.min+r,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[s].max=e.relativeTarget[s].min+r)});const r={x:{translate:0,scale:1,origin:0,originPoint:0},y:{translate:0,scale:1,origin:0,originPoint:0}};oF(r,t,n.layoutBox);const o={x:{translate:0,scale:1,origin:0,originPoint:0},y:{translate:0,scale:1,origin:0,originPoint:0}};a?oF(o,e.applyTransform(s,!0),n.measuredBox):oF(o,t,n.layoutBox);const l=!v_(r);let c=!1;if(!e.resumeFrom){const s=e.getClosestProjectingParent();if(s&&!s.resumeFrom){const{snapshot:i,layout:a}=s;if(i&&a){const r={x:{min:0,max:0},y:{min:0,max:0}};dF(r,n.layoutBox,i.layoutBox);const o={x:{min:0,max:0},y:{min:0,max:0}};dF(o,t,a.layoutBox),w_(r,o)||(c=!0),s.options.layoutRoot&&(e.relativeTarget=o,e.relativeTargetOrigin=r,e.relativeParent=s)}}}e.notifyListeners("didUpdate",{layout:t,snapshot:n,delta:o,layoutDelta:r,hasLayoutChanged:l,hasRelativeLayoutChanged:c})}else if(e.isLead()){const{onExitComplete:t}=e.options;t&&t()}e.options.transition=void 0}function M_(e){e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||(e.isSharedProjectionDirty=Boolean(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty)),e.isTransformDirty||(e.isTransformDirty=e.parent.isTransformDirty))}function D_(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function L_(e){e.clearSnapshot()}function P_(e){e.clearMeasurements()}function R_(e){e.isLayoutDirty=!1}function O_(e){const{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify("BeforeLayoutMeasure"),e.resetTransform()}function z_(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function B_(e){e.resolveTargetDelta()}function H_(e){e.calcProjection()}function $_(e){e.resetSkewAndRotation()}function V_(e){e.removeLeadSnapshot()}function U_(e,t,n){e.translate=SC(t.translate,0,n),e.scale=SC(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function W_(e,t,n,s){e.min=SC(t.min,n.min,s),e.max=SC(t.max,n.max,s)}function q_(e){return e.animationValues&&void 0!==e.animationValues.opacityExit}const G_={duration:.45,ease:[.4,0,.1,1]},Z_=e=>"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),Y_=Z_("applewebkit/")&&!Z_("chrome/")?Math.round:Bb;function K_(e){e.min=Y_(e.min),e.max=Y_(e.max)}function J_(e,t,n){return"position"===e||"preserve-aspect"===e&&(s=j_(t),i=j_(n),a=.2,!(Math.abs(s-i)<=a));var s,i,a}function Q_(e){var t;return e!==e.root&&(null===(t=e.scroll)||void 0===t?void 0:t.wasRoot)}const X_=I_({attachResizeListener:(e,t)=>eF(e,"resize",t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),ek={current:void 0},tk=I_({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!ek.current){const e=new X_({});e.mount(window),e.setOptions({layoutScroll:!0}),ek.current=e}return ek.current},resetTransform:(e,t)=>{e.style.transform=void 0!==t?t:"none"},checkIsScrollRoot:e=>Boolean("fixed"===window.getComputedStyle(e).position)}),nk={pan:{Feature:class extends YN{constructor(){super(...arguments),this.removePointerDownListener=Bb}onPointerDown(e){this.session=new IF(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:SF(this.node)})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:t,onPan:n,onPanEnd:s}=this.node.getProps();return{onSessionStart:WF(e),onStart:WF(t),onMove:n,onEnd:(e,t)=>{delete this.session,s&&qb.postRender(()=>s(e,t))}}}mount(){this.removePointerDownListener=sF(this.node.current,"pointerdown",e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}},drag:{Feature:class extends YN{constructor(e){super(e),this.removeGroupControls=Bb,this.removeListeners=Bb,this.controls=new VF(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Bb}unmount(){this.removeGroupControls(),this.removeListeners()}},ProjectionNode:tk,MeasureLayout:JF}};function sk(e,t){const n=function(e){if(e instanceof EventTarget)return[e];if("string"==typeof e){const t=document.querySelectorAll(e);return t?Array.from(t):[]}return Array.from(e)}(e),s=new AbortController;return[n,{passive:!0,...t,signal:s.signal},()=>s.abort()]}function ik(e){return!("touch"===e.pointerType||XN())}function ak(e,t,n){const{props:s}=e;e.animationState&&s.whileHover&&e.animationState.setActive("whileHover","Start"===n);const i=s["onHover"+n];i&&qb.postRender(()=>i(t,nF(t)))}function rk(e,t){const n=`${t}PointerCapture`;if(e.target instanceof Element&&n in e.target&&void 0!==e.pointerId)try{e.target[n](e.pointerId)}catch(s){}}const ok=(e,t)=>!!t&&(e===t||ok(e,t.parentElement)),lk=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);const ck=new WeakSet;function dk(e){return t=>{"Enter"===t.key&&e(t)}}function uk(e,t){e.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}function pk(e){return tF(e)&&!XN()}function mk(e,t,n={}){const[s,i,a]=sk(e,n),r=e=>{const n=e.currentTarget;if(!n||!pk(e)||ck.has(n))return;ck.add(n),rk(e,"set");const s=t(n,e),a=(e,t)=>{n.removeEventListener("pointerup",r),n.removeEventListener("pointercancel",o),rk(e,"release"),pk(e)&&ck.has(n)&&(ck.delete(n),"function"==typeof s&&s(e,{success:t}))},r=e=>{const t=!!e.isTrusted&&(s=e,i=n instanceof Element?n.getBoundingClientRect():{left:0,top:0,right:window.innerWidth,bottom:window.innerHeight},s.clientXi.right||s.clientYi.bottom);var s,i;a(e,!t&&(!(n instanceof Element)||ok(n,e.target)))},o=e=>{a(e,!1)};n.addEventListener("pointerup",r,i),n.addEventListener("pointercancel",o,i),n.addEventListener("lostpointercapture",o,i)};return s.forEach(e=>{let t=!1;var s;(e=n.useGlobalTarget?window:e)instanceof HTMLElement&&(t=!0,s=e,lk.has(s.tagName)||-1!==s.tabIndex||null!==e.getAttribute("tabindex")||(e.tabIndex=0)),e.addEventListener("pointerdown",r,i),t&&e.addEventListener("focus",e=>((e,t)=>{const n=e.currentTarget;if(!n)return;const s=dk(()=>{if(ck.has(n))return;uk(n,"down");const e=dk(()=>{uk(n,"up")});n.addEventListener("keyup",e,t),n.addEventListener("blur",()=>uk(n,"cancel"),t)});n.addEventListener("keydown",s,t),n.addEventListener("blur",()=>n.removeEventListener("keydown",s),t)})(e,i),i)}),a}function hk(e,t,n){const{props:s}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&s.whileTap&&e.animationState.setActive("whileTap","Start"===n);const i=s["onTap"+("End"===n?"":n)];i&&qb.postRender(()=>i(t,nF(t)))}const xk=new WeakMap,fk=new WeakMap,gk=e=>{const t=xk.get(e.target);t&&t(e)},vk=e=>{e.forEach(gk)};function bk(e,t,n){const s=function({root:e,...t}){const n=e||document;fk.has(n)||fk.set(n,{});const s=fk.get(n),i=JSON.stringify(t);return s[i]||(s[i]=new IntersectionObserver(vk,{root:e,...t})),s[i]}(t);return xk.set(e,n),s.observe(e),()=>{xk.delete(e),s.unobserve(e)}}const yk={some:0,all:1};const wk={inView:{Feature:class extends YN{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:e={}}=this.node.getProps(),{root:t,margin:n,amount:s="some",once:i}=e,a={root:t?t.current:void 0,rootMargin:n,threshold:"number"==typeof s?s:yk[s]};return bk(this.node.current,a,e=>{const{isIntersecting:t}=e;if(this.isInView===t)return;if(this.isInView=t,i&&!t&&this.hasEnteredView)return;t&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",t);const{onViewportEnter:n,onViewportLeave:s}=this.node.getProps(),a=t?n:s;a&&a(e)})}mount(){this.startObserver()}update(){if("undefined"==typeof IntersectionObserver)return;const{props:e,prevProps:t}=this.node;["amount","margin","root"].some(function({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}(e,t))&&this.startObserver()}unmount(){}}},tap:{Feature:class extends YN{mount(){const{current:e}=this.node;e&&(this.unmount=mk(e,(e,t)=>(hk(this.node,t,"Start"),(e,{success:t})=>hk(this.node,e,t?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}},focus:{Feature:class extends YN{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(":focus-visible")}catch(t){e=!0}e&&this.node.animationState&&(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){this.isActive&&this.node.animationState&&(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=PC(eF(this.node.current,"focus",()=>this.onFocus()),eF(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}},hover:{Feature:class extends YN{mount(){const{current:e}=this.node;e&&(this.unmount=function(e,t,n={}){const[s,i,a]=sk(e,n),r=e=>{if(!ik(e))return;const{target:n}=e,s=t(n,e);if("function"!=typeof s||!n)return;const a=e=>{ik(e)&&(s(e),n.removeEventListener("pointerleave",a))};n.addEventListener("pointerleave",a,i)};return s.forEach(e=>{e.addEventListener("pointerenter",r,i)}),a}(e,(e,t)=>(ak(this.node,t,"Start"),e=>ak(this.node,e,"End"))))}unmount(){}}}},jk={layout:{ProjectionNode:tk,MeasureLayout:JF}},Ck={current:null},Nk={current:!1};const Fk=[...bC,Aj,Bj],_k=new WeakMap;const kk=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class Sk{scrapeMotionValuesFromProps(e,t,n){return{}}constructor({parent:e,props:t,presenceContext:n,reducedMotionConfig:s,blockInitialAnimation:i,visualState:a},r={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=hC,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const e=zw.now();this.renderScheduledAtthis.bindToMotionValue(t,e)),Nk.current||function(){if(Nk.current=!0,Sb)if(window.matchMedia){const e=window.matchMedia("(prefers-reduced-motion)"),t=()=>Ck.current=e.matches;e.addListener(t),t()}else Ck.current=!1}(),this.shouldReduceMotion="never"!==this.reducedMotionConfig&&("always"===this.reducedMotionConfig||Ck.current),this.parent&&this.parent.children.add(this),this.update(this.props,this.presenceContext)}unmount(){this.projection&&this.projection.unmount(),Gb(this.notifyUpdate),Gb(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent&&this.parent.children.delete(this);for(const e in this.events)this.events[e].clear();for(const e in this.features){const t=this.features[e];t&&(t.unmount(),t.isMounted=!1)}this.current=null}bindToMotionValue(e,t){this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)();const n=Ay.has(e);n&&this.onBindTransform&&this.onBindTransform();const s=t.on("change",t=>{this.latestValues[e]=t,this.props.onUpdate&&qb.preRender(this.notifyUpdate),n&&this.projection&&(this.projection.isTransformDirty=!0)}),i=t.on("renderRequest",this.scheduleRender);let a;window.MotionCheckAppearSync&&(a=window.MotionCheckAppearSync(this,e,t)),this.valueSubscriptions.set(e,()=>{s(),i(),a&&a(),t.owner&&t.stop()})}sortNodePosition(e){return this.current&&this.sortInstanceNodePosition&&this.type===e.type?this.sortInstanceNodePosition(this.current,e.current):0}updateFeatures(){let e="animation";for(e in Qb){const t=Qb[e];if(!t)continue;const{isEnabled:n,Feature:s}=t;if(!this.features[e]&&s&&n(this.props)&&(this.features[e]=new s(this)),this.features[e]){const t=this.features[e];t.isMounted?t.update():(t.mount(),t.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):{x:{min:0,max:0},y:{min:0,max:0}}}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,t){this.latestValues[e]=t}update(e,t){(e.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=t;for(let n=0;nt.variantChildren.delete(e)}addValue(e,t){const n=this.values.get(e);t!==n&&(n&&this.removeValue(e),this.bindToMotionValue(e,t),this.values.set(e,t),this.latestValues[e]=t.get())}removeValue(e){this.values.delete(e);const t=this.valueSubscriptions.get(e);t&&(t(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,t){if(this.props.values&&this.props.values[e])return this.props.values[e];let n=this.values.get(e);return void 0===n&&void 0!==t&&(n=Hw(null===t?void 0:t,{owner:this}),this.addValue(e,n)),n}readValue(e,t){var n;let s=void 0===this.latestValues[e]&&this.current?null!==(n=this.getBaseTargetFromProps(this.props,e))&&void 0!==n?n:this.readValueFromInstance(this.current,e,this.options):this.latestValues[e];var i;return null!=s&&("string"==typeof s&&(xC(s)||yj(s))?s=parseFloat(s):(i=s,!Fk.find(vC(i))&&Bj.test(t)&&(s=Gj(e,t))),this.setBaseTarget(e,My(s)?s.get():s)),My(s)?s.get():s}setBaseTarget(e,t){this.baseTarget[e]=t}getBaseTarget(e){var t;const{initial:n}=this.props;let s;if("string"==typeof n||"object"==typeof n){const i=hw(this.props,n,null===(t=this.presenceContext)||void 0===t?void 0:t.custom);i&&(s=i[e])}if(n&&void 0!==s)return s;const i=this.getBaseTargetFromProps(this.props,e);return void 0===i||My(i)?void 0!==this.initialValues[e]&&void 0===s?void 0:this.baseTarget[e]:i}on(e,t){return this.events[e]||(this.events[e]=new Lw),this.events[e].add(t)}notify(e,...t){this.events[e]&&this.events[e].notify(...t)}}class Ek extends Sk{constructor(){super(...arguments),this.KeyframeResolver=wC}sortInstanceNodePosition(e,t){return 2&e.compareDocumentPosition(t)?1:-1}getBaseTargetFromProps(e,t){return e.style?e.style[t]:void 0}removeValueFromRenderState(e,{vars:t,style:n}){delete t[e],delete n[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:e}=this.props;My(e)&&(this.childSubscription=e.on("change",e=>{this.current&&(this.current.textContent=`${e}`)}))}}class Ik extends Ek{constructor(){super(...arguments),this.type="html",this.renderInstance=Cw}readValueFromInstance(e,t){if(Ay.has(t))return((e,t)=>{const{transform:n="none"}=getComputedStyle(e);return sC(n,t)})(e,t);{const s=(n=e,window.getComputedStyle(n)),i=(Fy(t)?s.getPropertyValue(t):s[t])||0;return"string"==typeof i?i.trim():i}var n}measureInstanceViewportBox(e,{transformPagePoint:t}){return kF(e,t)}build(e,t,n){Qy(e,t,n.transformTemplate)}scrapeMotionValuesFromProps(e,t,n){return yw(e,t,n)}}class Ak extends Ek{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=uF,this.updateDimensions=()=>{this.current&&!this.renderState.dimensions&&jw(this.current,this.renderState)}}getBaseTargetFromProps(e,t){return e[t]}readValueFromInstance(e,t){if(Ay.has(t)){const e=qj(t);return e&&e.default||0}return t=Nw.has(t)?t:gy(t),e.getAttribute(t)}scrapeMotionValuesFromProps(e,t,n){return _w(e,t,n)}onBindTransform(){this.current&&!this.renderState.dimensions&&qb.postRender(this.updateDimensions)}build(e,t,n){lw(e,t,this.isSVGTag,n.transformTemplate)}renderInstance(e,t,n,s){Fw(e,t,0,s)}mount(e){this.isSVGTag=dw(e.tagName),super.mount(e)}}const Tk=sy(Ew({...JN,...wk,...nk,...jk},(e,t)=>iw(e)?new Ak(t):new Ik(t,{allowProjection:e!==Pe.Fragment})));function Mk({className:e=""}){return a.jsxs("svg",{className:`h-5 w-5 animate-spin ${e}`,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[a.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),a.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]})} /** * @license lucide-react v0.469.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dk=(...e)=>e.filter((e,t,n)=>Boolean(e)&&""!==e.trim()&&n.indexOf(e)===t).join(" ").trim(); /** * @license lucide-react v0.469.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */ var Lk={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}; /** * @license lucide-react v0.469.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pk=Pe.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:s,className:i="",children:a,iconNode:r,...o},l)=>Pe.createElement("svg",{ref:l,...Lk,width:t,height:t,stroke:e,strokeWidth:s?24*Number(n)/Number(t):n,className:Dk("lucide",i),...o},[...r.map(([e,t])=>Pe.createElement(e,t)),...Array.isArray(a)?a:[a]])),Rk=(e,t)=>{const n=Pe.forwardRef(({className:n,...s},i)=>{return Pe.createElement(Pk,{ref:i,iconNode:t,className:Dk(`lucide-${a=e,a.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`,n),...s});var a});return n.displayName=`${e}`,n},Ok=Rk("Archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]),zk=Rk("ArrowDown",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]),Bk=Rk("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]),Hk=Rk("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]),$k=Rk("ArrowUp",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]),Vk=Rk("Bug",[["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M9 7.13v-1a3.003 3.003 0 1 1 6 0v1",key:"d7y7pr"}],["path",{d:"M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6",key:"xs1cw7"}],["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M6.53 9C4.6 8.8 3 7.1 3 5",key:"32zzws"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"M3 21c0-2.1 1.7-3.9 3.8-4",key:"4p0ekp"}],["path",{d:"M20.97 5c0 2.1-1.6 3.8-3.5 4",key:"18gb23"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M17.2 17c2.1.1 3.8 1.9 3.8 4",key:"k3fwyw"}]]),Uk=Rk("Camera",[["path",{d:"M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z",key:"1tc9qg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]]),Wk=Rk("ChartColumn",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]]),qk=Rk("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]),Gk=Rk("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]),Zk=Rk("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]),Yk=Rk("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]),Kk=Rk("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]),Jk=Rk("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]),Qk=Rk("CircleCheckBig",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]),Xk=Rk("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]),eS=Rk("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]),tS=Rk("Circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]),nS=Rk("ClipboardCheck",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"m9 14 2 2 4-4",key:"df797q"}]]),sS=Rk("Clipboard",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}]]),iS=Rk("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]),aS=Rk("Coffee",[["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M14 2v2",key:"6buw04"}],["path",{d:"M16 8a1 1 0 0 1 1 1v8a4 4 0 0 1-4 4H7a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1h14a4 4 0 1 1 0 8h-1",key:"pwadti"}],["path",{d:"M6 2v2",key:"colzsn"}]]),rS=Rk("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]),oS=Rk("DollarSign",[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]]),lS=Rk("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]),cS=Rk("Ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]),dS=Rk("EyeOff",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]),uS=Rk("Eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),pS=Rk("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]),mS=Rk("File",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}]]),hS=Rk("Folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]),xS=Rk("Image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]),fS=Rk("Info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]),gS=Rk("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]),vS=Rk("Mail",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]]),bS=Rk("MessageCircleWarning",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]),yS=Rk("Minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]),wS=Rk("Pause",[["rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",key:"zuxfzm"}],["rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",key:"1okwgv"}]]),jS=Rk("Pipette",[["path",{d:"m2 22 1-1h3l9-9",key:"1sre89"}],["path",{d:"M3 21v-3l9-9",key:"hpe2y6"}],["path",{d:"m15 6 3.4-3.4a2.1 2.1 0 1 1 3 3L18 9l.4.4a2.1 2.1 0 1 1-3 3l-3.8-3.8a2.1 2.1 0 1 1 3-3l.4.4Z",key:"196du1"}]]),CS=Rk("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]),NS=Rk("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]),FS=Rk("QrCode",[["rect",{width:"5",height:"5",x:"3",y:"3",rx:"1",key:"1tu5fj"}],["rect",{width:"5",height:"5",x:"16",y:"3",rx:"1",key:"1v8r4q"}],["rect",{width:"5",height:"5",x:"3",y:"16",rx:"1",key:"1x03jg"}],["path",{d:"M21 16h-3a2 2 0 0 0-2 2v3",key:"177gqh"}],["path",{d:"M21 21v.01",key:"ents32"}],["path",{d:"M12 7v3a2 2 0 0 1-2 2H7",key:"8crl2c"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M12 3h.01",key:"n36tog"}],["path",{d:"M12 16v.01",key:"133mhm"}],["path",{d:"M16 12h1",key:"1slzba"}],["path",{d:"M21 12v.01",key:"1lwtk9"}],["path",{d:"M12 21v-1",key:"1880an"}]]),_S=Rk("RefreshCcw",[["path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"14sxne"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16",key:"1hlbsb"}],["path",{d:"M16 16h5v5",key:"ccwih5"}]]),kS=Rk("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]),SS=Rk("RotateCw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]]),ES=Rk("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]),IS=Rk("ServerCrash",[["path",{d:"M6 10H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-2",key:"4b9dqc"}],["path",{d:"M6 14H4a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2h-2",key:"22nnkd"}],["path",{d:"M6 6h.01",key:"1utrut"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"m13 6-4 6h6l-4 6",key:"14hqih"}]]),AS=Rk("Share2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]),TS=Rk("Share",[["path",{d:"M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8",key:"1b2hhj"}],["polyline",{points:"16 6 12 2 8 6",key:"m901s6"}],["line",{x1:"12",x2:"12",y1:"2",y2:"15",key:"1p0rca"}]]),MS=Rk("Star",[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]]),DS=Rk("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]),LS=Rk("TrendingUp",[["polyline",{points:"22 7 13.5 15.5 8.5 10.5 2 17",key:"126l90"}],["polyline",{points:"16 7 22 7 22 13",key:"kwv8wd"}]]),PS=Rk("Undo2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]),RS=Rk("Undo",[["path",{d:"M3 7v6h6",key:"1v2h90"}],["path",{d:"M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13",key:"1r6uu6"}]]),OS=Rk("Unlink",[["path",{d:"m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71",key:"yqzxt4"}],["path",{d:"m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71",key:"4qinb0"}],["line",{x1:"8",x2:"8",y1:"2",y2:"5",key:"1041cp"}],["line",{x1:"2",x2:"5",y1:"8",y2:"8",key:"14m1p5"}],["line",{x1:"16",x2:"16",y1:"19",y2:"22",key:"rzdirn"}],["line",{x1:"19",x2:"22",y1:"16",y2:"16",key:"ox905f"}]]),zS=Rk("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]]),BS=Rk("Video",[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]]),HS=Rk("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),$S=b,VS=y,US=Pe.forwardRef(({className:e,children:t,...n},s)=>a.jsxs(o,{ref:s,className:bb("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm font-normal shadow-sm ring-offset-background data-[placeholder]:text-tertiary focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1 group",e),...n,children:[t,a.jsx(l,{asChild:!0,children:a.jsx(Gk,{className:"h-4 w-4 opacity-50 transition-transform duration-200 group-data-[state=open]:rotate-180"})})]})); /** * @license lucide-react v0.469.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */US.displayName=o.displayName;const WS=Pe.forwardRef(({className:e,...t},n)=>a.jsx(c,{ref:n,className:bb("flex cursor-default items-center justify-center py-1",e),...t,children:a.jsx(Kk,{className:"w-4 h-4"})}));WS.displayName=c.displayName;const qS=Pe.forwardRef(({className:e,...t},n)=>a.jsx(d,{ref:n,className:bb("flex cursor-default items-center justify-center py-1",e),...t,children:a.jsx(Gk,{className:"w-4 h-4"})}));qS.displayName=d.displayName;const GS=Pe.forwardRef(({className:e,children:t,position:n="popper",...s},i)=>a.jsx(u,{children:a.jsxs(p,{ref:i,className:bb("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2","popper"===n&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...s,children:[a.jsx(WS,{}),a.jsx(m,{className:bb("p-1","popper"===n&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),a.jsx(qS,{})]})}));GS.displayName=p.displayName;Pe.forwardRef(({className:e,...t},n)=>a.jsx(h,{ref:n,className:bb("py-1.5 pl-8 pr-2 text-base font-semibold",e),...t})).displayName=h.displayName;const ZS=Pe.forwardRef(({className:e,children:t,...n},s)=>a.jsxs(x,{ref:s,className:bb("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-base outline-none focus:bg-[#222] focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[a.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:a.jsx(f,{children:a.jsx(qk,{className:"w-4 h-4"})})}),a.jsx(g,{children:t})]}));ZS.displayName=x.displayName;Pe.forwardRef(({className:e,...t},n)=>a.jsx(v,{ref:n,className:bb("-mx-1 my-1 h-px bg-muted",e),...t})).displayName=v.displayName;const YS=Le(Ot()),KS=Pe.forwardRef(({className:e,type:t,...n},s)=>a.jsx("input",{type:t,className:bb("flex h-10 w-full rounded-md border border-input bg-background px-4 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:s,...n}));KS.displayName="Input";const JS={CREDIT_BALANCE_BUTTON_CLICKED:"credit_balance_button_clicked",BUY_CREDITS_BUTTON_CLICKED:"buy_credits_button_clicked",TIER_UPGRADE_BUTTON_CLICKED:"tier_upgrade_button_clicked",PLAN_UPGRADE_BUTTON_CLICKED:"plan_upgrade_button_clicked",CONTACT_US_BUTTON_CLICKED:"payment_modal_contact_us_button_clicked",BUY_CREDITS_MODAL_EVENTS:{MODAL_OPENED:"buy_credits_modal_opened",MODAL_CLOSED:"buy_credits_modal_closed",BUNDLE_SELECTED:"credit_bundle_selected",BUNDLE_PURCHASE_CLICKED:"credit_bundle_purchase_clicked",CUSTOM_AMOUNT_INPUT_CHANGED:"custom_amount_input_changed",CUSTOM_AMOUNT_PURCHASE_CLICKED:"custom_amount_purchase_clicked",CUSTOM_AMOUNT_VALIDATION_ERROR:"custom_amount_validation_error",PRICING_INFO_LEARN_MORE_CLICKED:"pricing_info_learn_more_clicked",PAYMENT_LOADING_MODAL_OPENED:"payment_loading_modal_opened"},BUY_CREDITS_AUTO_POPUP_SHOWN:"buy_credits_auto_popup_shown"},QS="job_name_updated",XS="job_deleted",eE="social_share_clicked",tE={MCP_INTRODUCTION_MODAL_OPENED:"mcp_introduction_modal_opened",MCP_INTRODUCTION_MODAL_CLOSED:"mcp_introduction_modal_closed",BRO_MODE_INTRODUCTION_MODAL_OPENED:"bro_mode_introduction_modal_opened",BRO_MODE_INTRODUCTION_MODAL_CLOSED:"bro_mode_introduction_modal_closed",BRO_MODE_INTRODUCTION_TRY_CLICKED:"bro_mode_introduction_try_clicked",BRO_MODE_INTRODUCTION_LEARN_MORE_CLICKED:"bro_mode_introduction_learn_more_clicked",VISUAL_EDITS_MODAL_OPENED:"visual_edits_modal_opened",VISUAL_EDITS_MODAL_CLOSED:"visual_edits_modal_closed",VISUAL_EDITS_MODAL_GOT_IT_CLICKED:"visual_edits_modal_got_it_clicked",VISUAL_EDITS_MODAL_LEARN_MORE_CLICKED:"visual_edits_modal_learn_more_clicked",SUBSCRIPTION_PAYMENT_RESULT_MODAL_EVENTS:{PAYMENT_STATUS_POLLING_STARTED:"payment_status_polling_started"},PAYMENT_LOADING_MODAL_OPENED:"payment_loading_modal_opened",UPDATE_TIER_CLICKED:"update_tier_clicked"},nE=JS,sE={ADVANCED_CONTROL_CLICKED:"advanced_control_button_clicked",ATTACH_FILE_CLICKED:"attach_file_button_clicked",SELECT_TEMPLATE_UPDATED:"select_template_value_updated",BUDGET_VALUE_UPDATED:"budget_value_updated",MODEL_VALUE_UPDATED:"model_value_updated",RECENT_TASK_OPENED:"recent_task_clicked",REFERRAL_ICON_CLICKED:"referral_icon_clicked",REFERRAL_TERM_CONDITION_CLICKED:"referral_terms_and_condition_clicked",NEW_JOB_CREATED:"created_new_job",FOOTER_EVENTS:{HOME_BUTTON_CLICKED:"footer_home_button_clicked",AFFILIATES_BUTTON_CLICKED:"footer_affiliates_button_clicked",ENTERPRISE_BUTTON_CLICKED:"footer_enterprise_button_clicked",PRIVACY_POLICY_BUTTON_CLICKED:"footer_privacy_policy_button_clicked",TERM_OF_SERVICE_BUTTON_CLICKED:"footer_term_of_service_button_clicked"},GITHUB_EVENTS:{CONNECT_TO_GITHUB_ICON_CLICKED:"connect_to_github_icon_clicked",CONNECT_TO_GITHUB_CTA_CLICKED:"connect_to_github_cta_clicked",GITHUB_REPO_TAB_CHANGED:"github_repo_category_changed"},USER_MENU_EVENTS:{ACCOUNT_SETTING_CLICKED:"user_menu_account_setting_clicked",HELP_CENTER_CLICKED:"user_menu_help_center_clicked",JOIN_DISCORD_CLICKED:"user_menu_join_discord_clicked"}},iE={UPGRADE_PLAN_CLICKED:"setting_upgrade_plan_clicked",UNIVERSAL_KEYS_EVENTS:{UNIVERSAL_KEY_TAB_OPENED:"universal_key_tab_opened",UNIVERSAL_KEY_COPIED:"copied_universal_key",UNIVERSAL_KEY_TOGGLED:"toggled_universal_key",UNIVERSAL_KEY_REGENERATE_CTA_CLICKED:"regenerate_universal_key_cta_clicked",UNIVERSAL_KEY_REGENERATED:"regenerated_universal_key",ADD_BALANCE_CTA_CLICKED:"add_balance_cta_clicked",TRANSFER_CREDIT_UPDATED:"updated_transfer_credit_value",CREDIT_TRANSFERED:"transfer_credit_cta_clicked",AUTO_RECHARGE_TOGGLE_CLICKED:"auto_recharge_toggle_clicked",AUTO_RECHARGE_CONFIRMED:"auto_recharge_credit_save_cta_clicked",AUTO_RECHARGE_UPDATED_VALUE:"auto_recharge_updated_value"},MANAGE_AGENTS_EVENTS:{MANAGE_AGENTS_TAB_OPENED:"manage_agents_tab_opened",NEW_AGENT_CREATION:"creating_new_agent",NEW_SUB_AGENT_CREATION:"creating_new_sub_agent",EXISTING_AGENT_OPENED:"existing_agent_opened",NEW_MCP_CREATED:"new_mcp_created"},LLM_PROVIDER_TOGGLED:"llm_provider_toggled"},aE={WAKE_UP_AGENT:"wake_up_agent_clicked"},rE="chat_screen_buy_credits_button_clicked";function oE({selectedImage:e,setSelectedImage:t,globalConfig:n,label:s="Docker Image",description:i,isCloudFlow:r}){var o,l,c;const{toast:d}=un(),[u,p]=Pe.useState([]),[m,h]=Pe.useState(!0),[x,f]=Pe.useState(!1),[g,v]=Pe.useState({}),[b,y]=Pe.useState({}),[w,j]=Pe.useState(!1),C=vp();Pe.useEffect(()=>{(async()=>{if(C)try{h(!0);const e=await bp.listImages();p(e)}catch(e){d({title:"Error",description:"Failed to fetch Docker images",variant:"destructive"})}finally{h(!1)}else h(!1)})()},[C]);const N=e=>{var t;const s=null==(t=null==n?void 0:n.templates)?void 0:t.find(t=>(null==t?void 0:t.env_image)===e);if(s)return(null==s?void 0:s.name)||(null==s?void 0:s.env_image);const i=null==u?void 0:u.find(t=>(null==t?void 0:t.env_image)===e);return i?(null==i?void 0:i.repo_name)||(null==i?void 0:i.env_image):""};return a.jsxs("div",{children:[a.jsx("div",{className:"flex items-center justify-between mb-2",children:a.jsx("p",{className:"text-[#FFFFFF50] font-['Inter'] text-sm",children:s})}),x?a.jsx(KS,{id:"imageInput",value:e,onChange:e=>{var n,s;t(null==(n=null==e?void 0:e.target)?void 0:n.value),bg(sE.SELECT_TEMPLATE_UPDATED,{selectedImage:N(null==(s=null==e?void 0:e.target)?void 0:s.value)})},placeholder:"Enter container image name/tag",className:"mb-4"}):a.jsxs($S,{value:e,onValueChange:e=>{t(e),bg(sE.SELECT_TEMPLATE_UPDATED,{selectedImage:N(e)})},disabled:m,open:w,onOpenChange:j,children:[a.jsx(US,{className:"w-full h-14 bg-[#FFFFFF0A] border border-[#ffffff12] rounded-lg text-[#DDDDE6] hover:border-[#ffffff30] transition-colors data-[state=open]:border-[#ffffff30] ",children:m?a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(gS,{className:"w-4 h-4 animate-spin"}),a.jsx("span",{children:"Loading images..."})]}):a.jsx(VS,{placeholder:"Select an image",children:(()=>{var t;const s=null==(t=null==n?void 0:n.templates)?void 0:t.find(t=>t.env_image===e);if(s)return s.name||s.env_image;const i=u.find(t=>t.env_image===e);return i?i.repo_name||i.env_image:e||"Select an image"})()})}),a.jsx(GS,{className:"bg-[#131314] border border-[#222]",children:u.length>0||(null==(o=null==n?void 0:n.templates)?void 0:o.length)>0?a.jsx(a.Fragment,{children:r?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"py-2 px-2 text-xs font-medium text-[#666]",children:"Select Template"}),null==(l=null==n?void 0:n.templates)?void 0:l.filter(e=>e.is_cloud_flow).map((e,t)=>a.jsx(ZS,{value:e.env_image,className:"relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-base outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 text-[#DDDDE6] hover:bg-[#222] focus:bg-[#222]",children:a.jsx("div",{className:"flex items-center justify-between w-full",children:a.jsx("span",{className:"truncate",children:e.name||e.env_image})})},`cloud-${e.env_image}-${t}`))]}):a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"py-2 px-2 text-xs font-medium text-[#666]",children:"Template Docker Images"}),null==(c=null==n?void 0:n.templates)?void 0:c.filter(e=>!e.is_cloud_flow).map((e,t)=>{const n=u.find(t=>t.env_image===e.env_image);return n&&e.image_tag&&(n.digest,e.image_tag),g[e.env_image],a.jsx(ZS,{value:e.env_image,className:"relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-base outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 text-[#DDDDE6] hover:bg-[#222] focus:bg-[#222]",children:a.jsx("div",{className:"flex items-center justify-between w-full",children:a.jsx("span",{className:"truncate",children:e.name||e.env_image})})},`template-${e.env_image}-${t}`)}),a.jsx("div",{className:"h-px bg-[#222] my-2"}),a.jsx("div",{className:"py-2 px-2 text-xs font-medium text-[#666]",children:"Local Docker Images"}),u.filter(e=>{var t;return!(null==(t=null==n?void 0:n.templates)?void 0:t.some(t=>t.env_image===e.env_image))}).map((e,t)=>a.jsx(ZS,{value:e.env_image,className:"relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-base outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 text-[#DDDDE6] hover:bg-[#222] focus:bg-[#222]",children:a.jsx("div",{className:"flex items-center justify-between w-full",children:a.jsx("span",{className:"truncate",children:e.env_image})})},`local-${e.env_image}-${t}`))]})}):a.jsx("div",{className:"py-6 text-center text-sm text-[#666]",children:m?"Loading images...":"No images found"})})]}),!e&&a.jsx("p",{className:"mt-1 text-sm text-destructive",children:"Container image is required"})]})}const lE=Pe.forwardRef(({className:e,...t},n)=>a.jsx(w,{ref:n,className:bb("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",e),...t,children:a.jsx(j,{className:bb("flex items-center justify-center text-current"),children:a.jsx(qk,{className:"h-4 w-4"})})}));lE.displayName=w.displayName;const cE=jb("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function dE({className:e,variant:t,...n}){return a.jsx("div",{className:bb(cE({variant:t}),e),...n})}const uE=M,pE=D;Pe.forwardRef(({className:e,inset:t,children:n,...s},i)=>a.jsxs(C,{ref:i,className:bb("flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",t&&"pl-8",e),...s,children:[n,a.jsx(Yk,{className:"ml-auto"})]})).displayName=C.displayName;Pe.forwardRef(({className:e,...t},n)=>a.jsx(N,{ref:n,className:bb("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...t})).displayName=N.displayName;const mE=Pe.forwardRef(({className:e,sideOffset:t=4,...n},s)=>a.jsx(F,{children:a.jsx(_,{ref:s,sideOffset:t,className:bb("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));mE.displayName=_.displayName;Pe.forwardRef(({className:e,inset:t,...n},s)=>a.jsx(k,{ref:s,className:bb("relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",t&&"pl-8",e),...n})).displayName=k.displayName;Pe.forwardRef(({className:e,children:t,checked:n,...s},i)=>a.jsxs(S,{ref:i,className:bb("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...s,children:[a.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:a.jsx(E,{children:a.jsx(qk,{className:"h-4 w-4"})})}),t]})).displayName=S.displayName;Pe.forwardRef(({className:e,children:t,...n},s)=>a.jsxs(I,{ref:s,className:bb("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[a.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:a.jsx(E,{children:a.jsx(tS,{className:"h-2 w-2 fill-current"})})}),t]})).displayName=I.displayName;Pe.forwardRef(({className:e,inset:t,...n},s)=>a.jsx(A,{ref:s,className:bb("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n})).displayName=A.displayName;Pe.forwardRef(({className:e,...t},n)=>a.jsx(T,{ref:n,className:bb("-mx-1 my-1 h-px bg-muted",e),...t})).displayName=T.displayName;const hE=({description:e})=>a.jsxs(L,{children:[a.jsx(P,{asChild:!0,children:a.jsx("button",{className:"inline-flex items-center ml-2 text-[#666] hover:text-[#999] focus:outline-none",children:a.jsx(fS,{size:14})})}),a.jsx(R,{children:a.jsxs(O,{className:"max-w-xs bg-[#1A1A1A] text-[#DDDDE6] text-sm px-4 py-2.5 rounded-lg shadow-lg z-[9999]",sideOffset:5,children:[e,a.jsx(z,{className:"fill-[#1A1A1A]"})]})})]});function xE({selectedSkills:e=[],setSelectedSkills:t,skills:n,loadingSkills:s,label:i="Skills",description:r}){return a.jsxs("div",{children:[a.jsxs("p",{className:"text-[#999] font-['Inter'] mb-2",children:[i,r&&a.jsx(hE,{description:r})]}),a.jsxs(uE,{children:[a.jsx(pE,{asChild:!0,children:a.jsxs(Nb,{variant:"outline",role:"combobox",disabled:s,className:bb("w-full h-12 bg-[#0E0E0F] border border-[#222] rounded-lg text-[#DDDDE6] hover:border-[#333] transition-colors relative data-[state=open]:border-[#333] md:text-base ",!e.length&&"text-muted-foreground"),children:[a.jsx("div",{className:"absolute left-4 inset-y-0 flex items-center md:text-base",children:s?a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(gS,{className:"h-4 w-4 animate-spin"}),a.jsx("span",{children:"Loading skills..."})]}):0===e.length?"Select skills":`${e.length} selected`}),a.jsx("div",{className:"absolute right-4 top-1/2 -translate-y-1/2",children:a.jsx(Gk,{className:"h-4 w-4 shrink-0"})})]})}),a.jsx(mE,{className:"w-[var(--radix-dropdown-menu-trigger-width)] p-1 bg-[#131314] border border-[#222]",children:a.jsxs("div",{className:"max-h-[300px] overflow-y-auto",children:[(n||[]).map(n=>a.jsxs("div",{className:"flex items-center space-x-3 px-3 py-2 hover:bg-[#1A1A1A] rounded-md cursor-pointer",onClick:()=>{(null==e?void 0:e.includes(n.name))?t(e.filter(e=>e!==n.name)):t([...e,n.name])},children:[a.jsx(lE,{checked:null==e?void 0:e.includes(n.name),className:"border-[#666]"}),a.jsxs("div",{className:"text-[#DDDDE6] md:text-base",children:[n.name,a.jsxs("div",{className:"text-xs text-[#666]",children:["Version: ",n.latest_version]})]})]},n.id)),0===n.length&&!s&&a.jsx("div",{className:"p-2 text-[#666] text-center",children:"No skills available"})]})})]}),(null==e?void 0:e.length)>0&&a.jsx("div",{className:"flex gap-1 mt-2 flex-wrap",children:null==e?void 0:e.map(n=>a.jsxs(dE,{variant:"secondary",className:"bg-[#222] text-[#DDDDE6] hover:bg-[#333]",children:[n,a.jsxs("button",{className:"ml-1 ring-offset-background rounded-full outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",onKeyDown:s=>{"Enter"===s.key&&t(e.filter(e=>e!==n))},onClick:()=>t(e.filter(e=>e!==n)),children:[a.jsx(HS,{className:"h-3 w-3"}),a.jsxs("span",{className:"sr-only",children:["Remove ",n]})]})]},n))})]})}var fE=async(e,t=100,n="auto",s="auto",i=null,a=null)=>{if(!(e instanceof Blob))throw new TypeError(`Expected a Blob or File, but got ${typeof e}.`);if(0===e.size)throw new Error("Failed to load the image. The file might be corrupt or empty.");if(t<=0)throw new RangeError("Quality must be greater than 0.");if("number"==typeof n&&n<0||"number"==typeof s&&s<0)throw new RangeError("Invalid width or height value!");let r=i?(e=>({png:"image/png",webp:"image/webp",bmp:"image/bmp",gif:"image/gif",jpeg:"image/jpeg"}[e]||"image/jpeg"))(i):e.type,o=t<1?t:t/100;return new Promise((t,i)=>{let l=new FileReader;l.onload=()=>{let e=new Image;e.src=l.result,e.onload=()=>{let l=document.createElement("canvas"),c=((e,t="auto",n="auto")=>{let s="auto"===t||0===t,i="auto"===n||0===n;if(!s&&!i)return{width:t,height:n};if(!s){let n=e.naturalWidth/t;return{width:t,height:Math.round(100*(e.naturalHeight/n+Number.EPSILON))/100}}if(!i){let t=e.naturalHeight/n;return{width:Math.round(100*(e.naturalWidth/t+Number.EPSILON))/100,height:n}}return{width:e.naturalWidth,height:e.naturalHeight}})(e,n,s);l.width=c.width,l.height=c.height;let d=l.getContext("2d");d?(a&&"image/png"===r&&(d.fillStyle=a,d.fillRect(0,0,l.width,l.height)),d.drawImage(e,0,0,l.width,l.height),l.toBlob(e=>{if(null===e)return i(new Error("Failed to generate image blob."));t(new Blob([e],{type:r}))},r,o)):i(new Error("Failed to get canvas context."))},e.onerror=()=>{i(new Error("Failed to load the image. The file might be corrupt or empty."))}},l.onerror=()=>i(new Error("Failed to read the blob as a Data URL.")),l.readAsDataURL(e)})}; /*! * image-resize-compress * Copyright(c) 2024 Álef Duarte * MIT Licensed */function gE({maxWidth:e=2e3,maxHeight:t=2e3,quality:n=30,format:s="jpeg"}={}){const i=Pe.useCallback(async(i,a)=>{try{const r={maxWidth:(null==a?void 0:a.maxWidth)||e,maxHeight:(null==a?void 0:a.maxHeight)||t,quality:(null==a?void 0:a.quality)||n,format:(null==a?void 0:a.format)||s},o=await fE(i,r.quality,r.maxWidth,r.maxHeight,r.format),l=await new Promise((e,t)=>{const n=new FileReader;n.onloadend=()=>{const t=n.result.split(",")[1];e(t)},n.onerror=t,n.readAsDataURL(o)}),c=(i.size-o.size)/i.size*100;return{blob:o,base64:l,originalSize:i.size,compressedSize:o.size,compressionRatio:c}}catch(r){return null}},[e,t,n,s]),a=Pe.useCallback(async(e,t)=>{try{const n=e.map(e=>i(e,t));return await Promise.all(n)}catch(n){return e.map(()=>null)}},[i]),r=Pe.useCallback(e=>{switch(e){case"jpeg":default:return"image/jpeg";case"webp":return"image/webp";case"png":return"image/png"}},[]),o=Pe.useCallback(async n=>n.size>1048576||new Promise(s=>{const i=new Image;i.onload=()=>{const n=i.width>e||i.height>t;URL.revokeObjectURL(i.src),s(n)},i.onerror=()=>{URL.revokeObjectURL(i.src),s(!0)},i.src=URL.createObjectURL(n)}),[e,t]);return{compressImage:i,compressImages:a,getMimeType:r,shouldCompress:o}}function vE({maxImages:e=5,maxSizeInMB:t=5,maxPixelDimensions:n=8e3,maxPixelDimensionsMultiple:s=2e3,initialImages:i=[],onImagesChange:a}={}){const[r,o]=Pe.useState(i),[l,c]=Pe.useState(!1),{toast:d}=un(),{compressImage:u,getMimeType:p}=gE({maxWidth:2e3,maxHeight:2e3,quality:30,format:"jpeg"}),m=Pe.useCallback(async e=>{try{const t=await u(e);return t?{mime_type:p("jpeg"),img_base64:t.base64,originalFile:e}:null}catch(t){return null}},[u,p]),h=Pe.useCallback(async(e,t)=>new Promise(i=>{const a=new Image,r=t?s:n;a.onload=()=>{const e=a.width<=r&&a.height<=r;URL.revokeObjectURL(a.src),i({width:a.width,height:a.height,isValid:e,maxDimension:r})},a.onerror=()=>{URL.revokeObjectURL(a.src),i({width:0,height:0,isValid:!1,maxDimension:r})},a.src=URL.createObjectURL(e)}),[n,s]),x=Pe.useCallback(async s=>{var i;if(!s||0===s.length)return;const l=Array.isArray(s)?s:Array.from(s);if(r.length+l.length>e)return void d({title:"Too many images",description:`You can only upload a maximum of ${e} images`,variant:"destructive"});const u=1024*t*1024,p=l.filter(e=>e.size>u);if(p.length>0)return void d({title:"File too large",description:`${p.length>1?"Some files are":"File is"} larger than ${t}MB limit`,variant:"destructive"});const x=["image/jpeg","image/png","image/gif","image/webp"];if(l.filter(e=>!x.includes(e.type)).length>0)return void d({title:"Invalid file type",description:"Only JPEG, PNG, GIF, and WebP images are allowed",variant:"destructive"});const f=r.length+l.length>1,g=await Promise.all(l.map(e=>h(e,f))),v=g.filter(e=>!e.isValid);if(v.length>0){const e=(null==(i=g[0])?void 0:i.maxDimension)||n,t=f?"multiple images":"single image";return void d({title:"Image dimensions too large",description:`${v.length>1?"Some images have":"Image has"} dimensions larger than ${e}x${e} pixels (limit for ${t})`,variant:"destructive"})}c(!0);try{const e=l.map(e=>m(e)),t=(await Promise.all(e)).filter(e=>null!==e),n=[...r,...t];o(n),null==a||a(n)}catch(b){d({title:"Error",description:"Failed to process images. Please try again.",variant:"destructive"})}finally{c(!1)}},[r,e,t,n,a,m,h,d]),f=Pe.useCallback(()=>{const e=document.createElement("input");return e.type="file",e.accept="image/jpeg,image/png,image/gif,image/webp",e.multiple=!0,e.style.display="none",e.onchange=t=>{const n=t.target;x(n.files),document.body.removeChild(e)},e},[x]),g=Pe.useCallback(()=>{const e=f();document.body.appendChild(e),setTimeout(()=>{e.click()},0)},[f]),v=Pe.useCallback(e=>{const t=[...r];t.splice(e,1),o(t),null==a||a(t)},[r,a]),b=Pe.useCallback(()=>{o([]),null==a||a([])},[a]);return{images:r,isProcessing:l,openFilePicker:g,removeImage:v,handleImageSelect:x,clearImages:b}}const bE=["image/jpeg","image/png","image/gif","image/webp"],yE=["image/jpeg","image/png","image/gif","image/webp"],wE=5242880,jE={maxWidth:2e3,maxHeight:2e3,quality:30,format:"jpeg"},CE=e=>{const t=e.type.startsWith("image/"),n="image/svg+xml"===e.type,s=bE.includes(e.type),i=yE.includes(e.type);return t?n||t&&!i?{strategy:"artifact_only",needsCompression:!1,canSendToAgent:!1,supportsDualMode:!1}:t&&!s&&i?{strategy:"dual_mode",needsCompression:!1,canSendToAgent:!0,supportsDualMode:!0}:t&&s&&i?{strategy:"compress_and_dual",needsCompression:!0,canSendToAgent:!0,supportsDualMode:!0}:{strategy:"artifact_only",needsCompression:!1,canSendToAgent:!1,supportsDualMode:!1}:{strategy:"artifact_only",needsCompression:!1,canSendToAgent:!1,supportsDualMode:!1}},NE=async(e,t)=>{try{const n=await t(e);if(!n)return{shouldUseBase64:!1};n.compressedSize;return n.compressedSize<=wE?{shouldUseBase64:!0,base64Data:n.base64,compressedSize:n.compressedSize}:{shouldUseBase64:!1,compressedSize:n.compressedSize}}catch(n){return{shouldUseBase64:!1}}},FE=async e=>new Promise((t,n)=>{const s=new FileReader;s.onload=()=>{const e=s.result.split(",")[1];t(e)},s.onerror=n,s.readAsDataURL(e)}),_E=Pe.forwardRef(({className:e,...t},n)=>a.jsx("textarea",{className:bb("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 ring-offset-background placeholder:text-white/20 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 ",e),ref:n,...t}));_E.displayName="Textarea";const kE=({className:e,size:t=200,duration:n=15,anchor:s=90,borderWidth:i=1.5,colorFrom:r="#ffaa40",colorTo:o="#9c40ff",delay:l=0})=>a.jsx("div",{style:{"--size":t,"--duration":n,"--anchor":s,"--border-width":i,"--color-from":r,"--color-to":o,"--delay":`-${l}s`},className:bb("pointer-events-none absolute inset-0 rounded-[inherit] [border:calc(var(--border-width)*1px)_solid_transparent]","![mask-clip:padding-box,border-box] ![mask-composite:intersect] [mask:linear-gradient(transparent,transparent),linear-gradient(white,white)]","after:absolute after:aspect-square after:w-[calc(var(--size)*1px)] after:animate-border-beam after:[animation-delay:var(--delay)] after:[background:linear-gradient(to_left,var(--color-from),var(--color-to),transparent)] after:[offset-anchor:calc(var(--anchor)*1%)_50%] after:[offset-path:rect(0_auto_auto_0_round_calc(var(--size)*1px))]",e)}),SE=({width:e=20,height:t=20,fill:n="#E6E6E6",className:s=""})=>a.jsx("svg",{width:e,height:t,viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:s,children:a.jsx("path",{d:"M9.93305 11.8684C9.14357 11.8684 8.47252 11.5921 7.91989 11.0395C7.36726 10.4868 7.09094 9.81579 7.09094 9.02631V3.3421C7.09094 2.55263 7.36726 1.88158 7.91989 1.32895C8.47252 0.776316 9.14357 0.5 9.93305 0.5C10.7225 0.5 11.3936 0.776316 11.9462 1.32895C12.4988 1.88158 12.7752 2.55263 12.7752 3.3421V9.02631C12.7752 9.81579 12.4988 10.4868 11.9462 11.0395C11.3936 11.5921 10.7225 11.8684 9.93305 11.8684ZM8.98568 17.5526V15.5868C7.53305 15.3816 6.28978 14.7658 5.25589 13.7395C4.222 12.7132 3.59421 11.4658 3.37252 9.99737C3.34094 9.72894 3.412 9.5 3.58568 9.31052C3.75936 9.12105 3.98042 9.02631 4.24884 9.02631C4.51726 9.02631 4.74242 9.11726 4.92431 9.29916C5.10621 9.48105 5.22842 9.70589 5.29094 9.97368C5.512 11.0789 6.06084 11.9868 6.93747 12.6974C7.8141 13.4079 8.81263 13.7632 9.93305 13.7632C11.0699 13.7632 12.0725 13.4041 12.9409 12.686C13.8094 11.9679 14.3541 11.0638 14.5752 9.97368C14.6383 9.70526 14.7608 9.48042 14.9427 9.29916C15.1246 9.11789 15.3495 9.02695 15.6173 9.02631C15.885 9.02568 16.1061 9.12042 16.2804 9.31052C16.4547 9.50063 16.5258 9.72958 16.4936 9.99737C16.2725 11.4342 15.6488 12.6737 14.6225 13.7158C13.5962 14.7579 12.3488 15.3816 10.8804 15.5868V17.5526C10.8804 17.821 10.7895 18.0462 10.6076 18.2281C10.4257 18.41 10.2008 18.5006 9.93305 18.5C9.66526 18.4994 9.44042 18.4084 9.25852 18.2272C9.07663 18.0459 8.98568 17.821 8.98568 17.5526Z",fill:n})}),EE=({width:e=20,height:t=20,fill:n="black",className:s=""})=>a.jsxs("svg",{width:e,height:t,viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:s,children:[a.jsx("g",{clipPath:"url(#clip0_5272_57732)",children:a.jsx("path",{d:"M7 13.75H13C13.2125 13.75 13.3907 13.6781 13.5345 13.5343C13.6782 13.3906 13.75 13.2125 13.75 13V7C13.75 6.7875 13.6782 6.60933 13.5345 6.4655C13.3907 6.32183 13.2125 6.25 13 6.25H7C6.7875 6.25 6.60942 6.32183 6.46575 6.4655C6.32192 6.60933 6.25 6.7875 6.25 7V13C6.25 13.2125 6.32192 13.3906 6.46575 13.5343C6.60942 13.6781 6.7875 13.75 7 13.75ZM10.0067 20C8.62775 20 7.33192 19.7375 6.11925 19.2125C4.90642 18.6875 3.84583 17.9708 2.9375 17.0625C2.02917 16.1542 1.3125 15.093 0.7875 13.879C0.2625 12.665 0 11.3678 0 9.9875C0 8.60717 0.2625 7.31 0.7875 6.096C1.3125 4.882 2.02917 3.825 2.9375 2.925C3.84583 2.025 4.907 1.3125 6.121 0.7875C7.335 0.2625 8.63217 0 10.0125 0C11.3928 0 12.69 0.2625 13.904 0.7875C15.118 1.3125 16.175 2.025 17.075 2.925C17.975 3.825 18.6875 4.88333 19.2125 6.1C19.7375 7.31667 20 8.61442 20 9.99325C20 11.3723 19.7375 12.6681 19.2125 13.8807C18.6875 15.0936 17.975 16.1527 17.075 17.058C16.175 17.9632 15.1167 18.6798 13.9 19.208C12.6833 19.736 11.3856 20 10.0067 20Z",fill:n})}),a.jsx("defs",{children:a.jsx("clipPath",{id:"clip0_5272_57732",children:a.jsx("rect",{width:"20",height:"20",fill:"white"})})})]}),IE=wv.icons.githubIcon,AE=wv.github.githubConnected,TE=({isConnected:e,isActive:t,githubUrl:n,githubTooltip:s,handleGithubSettings:i,onClearGithubUrl:r})=>{const o=()=>e?AE:IE;return n?a.jsxs("div",{className:"relative flex items-center bg-[#2EE572]/5 border border-[#2EE572]/20 rounded-[30px] px-3 group",children:[a.jsxs(Nb,{className:bb("pointer-events-auto flex items-center gap-1 p-0 justify-center h-9 bg-transparent hover:bg-transparent"),type:"button",onClick:i,children:[a.jsx("img",{src:o(),alt:"GitHub Repository",className:bb("transition-transform duration-200 transform size-4 md:size-5",e&&"scale-[1.2] mt-[2px] mr-1.5")}),a.jsx("span",{className:"text-sm font-medium text-[#2EE572] truncate max-w-[100px]",children:n.split("/").pop()})]}),a.jsx("button",{title:"Clear selected repository",type:"button",onClick:e=>{e.stopPropagation(),r()},className:"z-10 w-0 overflow-hidden transition-all duration-200 bg-transparent rounded-full hover:bg-transparent group-hover:w-auto group-hover:pl-1",children:a.jsx(HS,{size:16,className:"text-[#2ee571cd]"})})]}):a.jsxs(L,{children:[a.jsx(P,{asChild:!0,children:a.jsx(Nb,{className:bb("p-2 pointer-events-auto rounded-[30px] flex items-center justify-center h-[32px] md:h-9 transition-all ease-out duration-100 gap-2","bg-white bg-opacity-5 text-[#CCCCCC] hover:bg-white/10"),type:"button",onClick:i,children:a.jsxs("div",{className:"relative flex items-center gap-1",children:[a.jsx("div",{className:"relative flex items-center",children:a.jsx("img",{src:o(),alt:"GitHub",className:bb("size-5 transition-transform duration-200 transform",e&&"scale-[1.4] mt-[2px]")})}),e&&a.jsx(Gk,{className:"w-4 h-4 transition-transform duration-200 "+(t?"rotate-180":"")})]})})}),s&&a.jsx(R,{children:a.jsx(O,{className:"max-w-xs bg-[#fff] text-[#0f0f10] font-medium tracking-[-0.3px] text-sm px-4 py-2.5 rounded-lg shadow-lg z-[9999]",sideOffset:5,asChild:!0,children:a.jsxs(Tk.div,{initial:{opacity:0,y:-2,scale:1},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-10,scale:1},transition:{type:"tween",ease:"easeOut",duration:.4},children:[s,a.jsx(z,{className:"fill-[#fff]"})]})})})]})},ME=B,DE=L,LE=P,PE=Pe.forwardRef(({className:e,sideOffset:t=4,...n},s)=>a.jsx(O,{ref:s,sideOffset:t,className:bb("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md",e),...n}));PE.displayName=O.displayName;const RE=z,OE=({size:e=24,color:t="currentColor",className:n})=>a.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:n,children:[a.jsx("path",{d:"M3.5 11.75L11.6718 3.57843C12.7763 2.47386 14.5673 2.47386 15.6718 3.57843C16.7763 4.683 16.7763 6.47386 15.6718 7.57843M15.6718 7.57843L9.5 13.75M15.6718 7.57843C16.7763 6.47386 18.5673 6.47386 19.6718 7.57843C20.7763 8.683 20.7763 10.4739 19.6718 11.5784L12.7073 18.5429C12.3168 18.9334 12.3168 19.5666 12.7073 19.9571L14 21.2498",stroke:t,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),a.jsx("path",{d:"M17.4999 9.74933L11.3282 15.9211C10.2237 17.0256 8.43274 17.0256 7.32825 15.9211C6.22375 14.8165 6.22375 13.0256 7.32825 11.9211L13.4999 5.74951",stroke:t,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),zE=({size:e=16,color:t="#E8E8E6",className:n})=>a.jsx("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:n,children:a.jsx("path",{d:"M8.43865 1.6001C9.07985 1.6001 9.59961 2.11988 9.59961 2.76103C9.59961 2.91653 9.70969 3.08344 9.90745 3.16182C9.96233 3.18356 10.0168 3.20625 10.0707 3.22979L10.1434 3.25557C10.3127 3.30343 10.4748 3.26076 10.5714 3.16416C11.0255 2.71063 11.7614 2.71115 12.2152 3.16494L12.8347 3.78447L12.9145 3.87275C13.2869 4.32919 13.2605 5.00287 12.8347 5.42823C12.7245 5.53847 12.6851 5.73408 12.7699 5.92823L12.8379 6.09228L12.8714 6.16182C12.9581 6.31554 13.1026 6.40008 13.2386 6.4001C13.8798 6.4001 14.3996 6.91988 14.3996 7.56103V8.43914C14.3996 9.08034 13.8798 9.6001 13.2386 9.6001C13.1026 9.6001 12.9582 9.68466 12.8714 9.83842L12.8379 9.90794C12.8161 9.96274 12.7934 10.0174 12.7699 10.0712C12.685 10.2655 12.7243 10.4615 12.8347 10.5719C13.2886 11.0259 13.2886 11.7618 12.8347 12.2157L12.2152 12.8352C11.7613 13.2891 11.0254 13.2891 10.5714 12.8352C10.4749 12.7387 10.3127 12.6961 10.1434 12.7439L10.0707 12.7704C10.0171 12.7938 9.96273 12.8159 9.90817 12.8376C9.71041 12.916 9.59977 13.0828 9.59961 13.2384C9.59961 13.8798 9.07929 14.4001 8.43793 14.4001H7.56133C6.91993 14.4001 6.39961 13.8798 6.39961 13.2384C6.39946 13.1022 6.31496 12.9576 6.16133 12.8712L6.09179 12.8376C6.03681 12.8159 5.98177 12.7932 5.92774 12.7696C5.73338 12.685 5.53792 12.7251 5.42774 12.8352C5.00238 13.261 4.32871 13.2874 3.87227 12.915L3.78399 12.8352L3.16445 12.2157C2.71067 11.7619 2.71015 11.026 3.16367 10.5719L3.20195 10.5267C3.27081 10.4288 3.29609 10.289 3.25508 10.1439L3.2293 10.0712C3.20576 10.0173 3.18307 9.96282 3.16133 9.90794C3.08295 9.71018 2.91604 9.6001 2.76055 9.6001C2.11939 9.6001 1.59961 9.08034 1.59961 8.43914V7.56103C1.59961 6.91988 2.11939 6.4001 2.76055 6.4001C2.91602 6.40008 3.0823 6.28987 3.16055 6.09228L3.2293 5.92823L3.25508 5.85557C3.29607 5.71039 3.27089 5.5705 3.20195 5.47275L3.16367 5.42823C2.70998 4.97453 2.70998 4.23817 3.16367 3.78447L3.78399 3.16416L3.87227 3.08447C4.32858 2.71224 5.00237 2.7388 5.42774 3.16416C5.53798 3.27438 5.73335 3.31456 5.92774 3.22979C5.98196 3.20613 6.03661 3.18288 6.09179 3.16103C6.28938 3.08279 6.39959 2.91651 6.39961 2.76103C6.39961 2.11988 6.91939 1.6001 7.56055 1.6001H8.43865ZM7.56055 2.4001C7.36123 2.4001 7.19961 2.56171 7.19961 2.76103C7.19959 3.29991 6.83431 3.72823 6.38633 3.90557C6.33973 3.92402 6.2931 3.94261 6.24727 3.96259C5.80447 4.15569 5.24263 4.11185 4.86133 3.73057C4.7377 3.60693 4.54707 3.59094 4.40664 3.68369L4.35039 3.73057L3.73008 4.35088C3.5888 4.49215 3.5888 4.72054 3.73008 4.86182C4.0875 5.21926 4.14847 5.73546 3.99571 6.16338L3.96211 6.24775C3.94212 6.29359 3.92353 6.34022 3.90508 6.38682C3.72775 6.8348 3.29942 7.20008 2.76055 7.2001C2.56123 7.2001 2.39961 7.36171 2.39961 7.56103V8.43914C2.39961 8.6385 2.56123 8.8001 2.76055 8.8001C3.29942 8.8001 3.7276 9.16562 3.90508 9.61338C3.92339 9.65954 3.94228 9.70546 3.96211 9.7509C4.15545 10.1938 4.11127 10.756 3.73008 11.1376C3.58863 11.2791 3.58858 11.5086 3.73008 11.6501L4.34961 12.2696L4.40664 12.3165C4.54705 12.4091 4.73779 12.3932 4.86133 12.2696C5.24267 11.888 5.80509 11.8436 6.24805 12.0368C6.29363 12.0567 6.33998 12.0755 6.38633 12.0939L6.46914 12.1306C6.87835 12.3258 7.19946 12.7333 7.19961 13.2384C7.19961 13.4379 7.36175 13.6001 7.56133 13.6001H8.43793C8.63745 13.6001 8.79961 13.4379 8.79961 13.2384C8.79977 12.6995 9.16505 12.2714 9.61289 12.0939C9.65905 12.0755 9.70497 12.0567 9.75041 12.0368L9.83473 12.0032C10.263 11.8502 10.7794 11.9119 11.1371 12.2696C11.2786 12.4111 11.5081 12.4111 11.6496 12.2696L12.2691 11.6501C12.4106 11.5086 12.4106 11.2791 12.2691 11.1376C11.8876 10.7561 11.8433 10.194 12.0371 9.7509C12.057 9.7053 12.0758 9.6589 12.0942 9.61258L12.1309 9.52978C12.3263 9.12114 12.7336 8.8001 13.2386 8.8001C13.438 8.8001 13.5996 8.6385 13.5996 8.43914V7.56103C13.5996 7.36171 13.438 7.2001 13.2386 7.2001C12.7334 7.20008 12.3261 6.8787 12.1309 6.46963L12.0942 6.38682L12.0363 6.24854C11.8426 5.8055 11.8875 5.24315 12.2691 4.86182C12.3927 4.73827 12.4086 4.54754 12.316 4.40713L12.2691 4.3501L11.6496 3.73057C11.5259 3.60685 11.3348 3.59112 11.1942 3.68369L11.1371 3.73057C10.7555 4.11176 10.1933 4.15594 9.75041 3.96259L9.61289 3.90557C9.16513 3.72809 8.79961 3.29991 8.79961 2.76103C8.79961 2.56171 8.63801 2.4001 8.43865 2.4001H7.56055ZM7.99961 5.6001C9.32513 5.6001 10.3996 6.67462 10.3996 8.0001C10.3996 9.32562 9.32513 10.4001 7.99961 10.4001C6.67413 10.4001 5.59961 9.32562 5.59961 8.0001C5.59961 6.67462 6.67413 5.6001 7.99961 5.6001ZM7.99961 6.4001C7.11595 6.4001 6.39961 7.11644 6.39961 8.0001C6.39961 8.88378 7.11595 9.6001 7.99961 9.6001C8.88329 9.6001 9.59961 8.88378 9.59961 8.0001C9.59961 7.11644 8.88329 6.4001 7.99961 6.4001Z",fill:t})}),BE=({size:e=20,primaryColor:t="#80FFF9",secondaryColor:n="#1D1D1E",className:s,...i})=>a.jsxs("svg",{width:e,height:e,viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:s,...i,children:[a.jsx("path",{d:"M14.5039 4C15.8846 4 17.0039 5.11929 17.0039 6.5V13.5C17.0039 14.8807 15.8846 16 14.5039 16H5.50391C4.12319 16 3.00391 14.8807 3.00391 13.5V6.5C3.00391 5.11929 4.12319 4 5.50391 4H14.5039Z",fill:t}),a.jsx("path",{d:"M5 12C5 10.8954 5.89543 10 7 10H13C14.1046 10 15 10.8954 15 12C15 13.1046 14.1046 14 13 14H7C5.89543 14 5 13.1046 5 12Z",fill:n}),a.jsx("rect",{width:"2",height:"2",rx:"1",transform:"matrix(1 0 0 -1 7 13)",fill:t}),a.jsx("rect",{width:"2",height:"2",rx:"1",transform:"matrix(1 0 0 -1 11 13)",fill:t}),a.jsx("rect",{y:"9.00195",width:"2",height:"4",rx:"1",fill:t}),a.jsx("rect",{x:"18",y:"9.00195",width:"2",height:"4",rx:"1",fill:t})]}),HE=Pe.createContext(void 0);function $E({children:e}){const[t,n]=Pe.useState(new Map);return a.jsx(HE.Provider,{value:{openModal:e=>{n(t=>{const n=new Map(t);return n.set(e.type,e),n})},closeModal:e=>{n(e?t=>{const n=new Map(t);return n.delete(e),n}:new Map)},updateModal:(e,t)=>{n(n=>{const s=new Map(n),i=s.get(e);return i&&s.set(e,{...i,...t}),s})},activeModals:t},children:e})}function VE(){const e=Pe.useContext(HE);if(!e)throw new Error("useModal must be used within a ModalProvider");return e}function UE(){const{openModal:e,closeModal:t,activeModals:n}=VE();return{open:t=>e({type:"upgrade-tier",...t}),close:()=>t("upgrade-tier"),isOpen:n.has("upgrade-tier"),config:n.get("upgrade-tier")}}function WE(){const{openModal:e,closeModal:t,activeModals:n}=VE();return{open:(t={})=>e({type:"account-settings",...t}),close:()=>t("account-settings"),isOpen:n.has("account-settings"),config:n.get("account-settings")}}function qE(){const{openModal:e,closeModal:t,activeModals:n}=VE();return{open:()=>e({type:"account-settings",initialTab:"universal-key"}),close:()=>t("account-settings"),isOpen:n.has("account-settings"),config:n.get("account-settings")}}function GE(){const{openModal:e,closeModal:t,activeModals:n}=VE();return{open:(t={})=>e({type:"buy-credits",...t}),close:()=>t("buy-credits"),isOpen:n.has("buy-credits"),config:n.get("buy-credits")}}function ZE(){const{openModal:e,closeModal:t,activeModals:n}=VE();return{open:(t={})=>e({type:"team-workspace",...t}),close:()=>t("team-workspace"),isOpen:n.has("team-workspace"),config:n.get("team-workspace")}}function YE(){var e;const t=ZE();return{open:e=>{let n={organizationId:e.organizationId,organizationName:e.organizationName,mode:e.mode||"invite",backendEnabled:e.backendEnabled||!1};t.open(n)},close:()=>t.close(),isOpen:t.isOpen&&"invite"===(null==(e=t.config)?void 0:e.mode),config:t.config}}function KE(){const{openModal:e,closeModal:t,activeModals:n}=VE();return{open:(t={})=>e({type:"referral",...t}),close:()=>t("referral"),isOpen:n.has("referral"),config:n.get("referral")}}function JE(){const{openModal:e,closeModal:t,activeModals:n}=VE();return{open:t=>e({type:"data-details",...t}),close:()=>t("data-details"),isOpen:n.has("data-details"),config:n.get("data-details")}}function QE(){const{openModal:e,closeModal:t,activeModals:n}=VE();return{open:(t={})=>e({type:"new-mcp-server",...t}),close:()=>t("new-mcp-server"),isOpen:n.has("new-mcp-server"),config:n.get("new-mcp-server")}}function XE(){const{openModal:e,closeModal:t,updateModal:n,activeModals:s}=VE();return{open:(t={})=>e({type:"mcp-tools",...t}),close:()=>t("mcp-tools"),update:e=>n("mcp-tools",e),isOpen:s.has("mcp-tools"),config:s.get("mcp-tools")}}const eI=()=>{const{openModal:e,closeModal:t,activeModals:n}=VE();return{open:t=>e({type:"share-preview",...t}),close:()=>t("share-preview"),isOpen:n.has("share-preview"),config:n.get("share-preview")}},tI=({size:e=16,color:t="#E8E8E6",className:n})=>a.jsx("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:n,children:a.jsx("path",{d:"M14 6.5C14 6.63261 13.9473 6.75979 13.8536 6.85355C13.7598 6.94732 13.6326 7 13.5 7C13.3674 7 13.2402 6.94732 13.1464 6.85355C13.0527 6.75979 13 6.63261 13 6.5V3.7075L8.85437 7.85375C8.76055 7.94757 8.63331 8.00028 8.50062 8.00028C8.36794 8.00028 8.2407 7.94757 8.14688 7.85375C8.05305 7.75993 8.00035 7.63268 8.00035 7.5C8.00035 7.36732 8.05305 7.24007 8.14688 7.14625L12.2925 3H9.5C9.36739 3 9.24021 2.94732 9.14645 2.85355C9.05268 2.75979 9 2.63261 9 2.5C9 2.36739 9.05268 2.24021 9.14645 2.14645C9.24021 2.05268 9.36739 2 9.5 2H13.5C13.6326 2 13.7598 2.05268 13.8536 2.14645C13.9473 2.24021 14 2.36739 14 2.5V6.5ZM11.5 8C11.3674 8 11.2402 8.05268 11.1464 8.14645C11.0527 8.24021 11 8.36739 11 8.5V13H3V5H7.5C7.63261 5 7.75979 4.94732 7.85355 4.85355C7.94732 4.75979 8 4.63261 8 4.5C8 4.36739 7.94732 4.24021 7.85355 4.14645C7.75979 4.05268 7.63261 4 7.5 4H3C2.73478 4 2.48043 4.10536 2.29289 4.29289C2.10536 4.48043 2 4.73478 2 5V13C2 13.2652 2.10536 13.5196 2.29289 13.7071C2.48043 13.8946 2.73478 14 3 14H11C11.2652 14 11.5196 13.8946 11.7071 13.7071C11.8946 13.5196 12 13.2652 12 13V8.5C12 8.36739 11.9473 8.24021 11.8536 8.14645C11.7598 8.05268 11.6326 8 11.5 8Z",fill:t,fillOpacity:"0.4"})}),nI=()=>{const[e,t]=Pe.useState(!1);return Pe.useEffect(()=>{const e=()=>{t(window.innerWidth<768)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),{isMobile:e}};function sI(e){return!!e&&(!e.includes("+")&&(e.endsWith("@emergentbase.com")||e.endsWith("@emergent.sh")))}function iI(){const{user:e}=Yg(),t=Nt(e=>e.admin.isAdminMode);if(!e||!e.email)return!1;const n=sI(e.email);return!!t&&n}const aI=ze.createContext({drawerRef:{current:null},overlayRef:{current:null},onPress:()=>{},onRelease:()=>{},onDrag:()=>{},onNestedDrag:()=>{},onNestedOpenChange:()=>{},onNestedRelease:()=>{},openProp:void 0,dismissible:!1,isOpen:!1,isDragging:!1,keyboardIsOpen:{current:!1},snapPointsOffset:null,snapPoints:null,handleOnly:!1,modal:!1,shouldFade:!1,activeSnapPoint:null,onOpenChange:()=>{},setActiveSnapPoint:()=>{},closeDrawer:()=>{},direction:"bottom",shouldAnimate:{current:!0},shouldScaleBackground:!1,setBackgroundColorOnScale:!0,noBodyStyles:!1,container:null,autoFocus:!1}),rI=()=>{const e=ze.useContext(aI);if(!e)throw new Error("useDrawerContext must be used within a Drawer.Root");return e};function oI(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function lI(){return dI(/^iPad/)||dI(/^Mac/)&&navigator.maxTouchPoints>1}function cI(){return dI(/^iPhone/)||lI()}function dI(e){return"undefined"!=typeof window&&null!=window.navigator?e.test(window.navigator.platform):void 0}!function(e){if("undefined"==typeof document)return;let t=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",t.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}("[data-vaul-drawer]{touch-action:none;will-change:transform;transition:transform .5s cubic-bezier(.32, .72, 0, 1);animation-duration:.5s;animation-timing-function:cubic-bezier(0.32,0.72,0,1)}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=bottom][data-state=open]{animation-name:slideFromBottom}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=bottom][data-state=closed]{animation-name:slideToBottom}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=top][data-state=open]{animation-name:slideFromTop}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=top][data-state=closed]{animation-name:slideToTop}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=left][data-state=open]{animation-name:slideFromLeft}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=left][data-state=closed]{animation-name:slideToLeft}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=right][data-state=open]{animation-name:slideFromRight}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=right][data-state=closed]{animation-name:slideToRight}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=bottom]{transform:translate3d(0,var(--initial-transform,100%),0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=top]{transform:translate3d(0,calc(var(--initial-transform,100%) * -1),0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=left]{transform:translate3d(calc(var(--initial-transform,100%) * -1),0,0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=right]{transform:translate3d(var(--initial-transform,100%),0,0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=top]{transform:translate3d(0,var(--snap-point-height,0),0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=bottom]{transform:translate3d(0,var(--snap-point-height,0),0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=left]{transform:translate3d(var(--snap-point-height,0),0,0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=right]{transform:translate3d(var(--snap-point-height,0),0,0)}[data-vaul-overlay][data-vaul-snap-points=false]{animation-duration:.5s;animation-timing-function:cubic-bezier(0.32,0.72,0,1)}[data-vaul-overlay][data-vaul-snap-points=false][data-state=open]{animation-name:fadeIn}[data-vaul-overlay][data-state=closed]{animation-name:fadeOut}[data-vaul-animate=false]{animation:none!important}[data-vaul-overlay][data-vaul-snap-points=true]{opacity:0;transition:opacity .5s cubic-bezier(.32, .72, 0, 1)}[data-vaul-overlay][data-vaul-snap-points=true]{opacity:1}[data-vaul-drawer]:not([data-vaul-custom-container=true])::after{content:'';position:absolute;background:inherit;background-color:inherit}[data-vaul-drawer][data-vaul-drawer-direction=top]::after{top:initial;bottom:100%;left:0;right:0;height:200%}[data-vaul-drawer][data-vaul-drawer-direction=bottom]::after{top:100%;bottom:initial;left:0;right:0;height:200%}[data-vaul-drawer][data-vaul-drawer-direction=left]::after{left:initial;right:100%;top:0;bottom:0;width:200%}[data-vaul-drawer][data-vaul-drawer-direction=right]::after{left:100%;right:initial;top:0;bottom:0;width:200%}[data-vaul-overlay][data-vaul-snap-points=true]:not([data-vaul-snap-points-overlay=true]):not(\n[data-state=closed]\n){opacity:0}[data-vaul-overlay][data-vaul-snap-points-overlay=true]{opacity:1}[data-vaul-handle]{display:block;position:relative;opacity:.7;background:#e2e2e4;margin-left:auto;margin-right:auto;height:5px;width:32px;border-radius:1rem;touch-action:pan-y}[data-vaul-handle]:active,[data-vaul-handle]:hover{opacity:1}[data-vaul-handle-hitarea]{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);width:max(100%,2.75rem);height:max(100%,2.75rem);touch-action:inherit}@media (hover:hover) and (pointer:fine){[data-vaul-drawer]{user-select:none}}@media (pointer:fine){[data-vaul-handle-hitarea]:{width:100%;height:100%}}@keyframes fadeIn{from{opacity:0}to{opacity:1}}@keyframes fadeOut{to{opacity:0}}@keyframes slideFromBottom{from{transform:translate3d(0,var(--initial-transform,100%),0)}to{transform:translate3d(0,0,0)}}@keyframes slideToBottom{to{transform:translate3d(0,var(--initial-transform,100%),0)}}@keyframes slideFromTop{from{transform:translate3d(0,calc(var(--initial-transform,100%) * -1),0)}to{transform:translate3d(0,0,0)}}@keyframes slideToTop{to{transform:translate3d(0,calc(var(--initial-transform,100%) * -1),0)}}@keyframes slideFromLeft{from{transform:translate3d(calc(var(--initial-transform,100%) * -1),0,0)}to{transform:translate3d(0,0,0)}}@keyframes slideToLeft{to{transform:translate3d(calc(var(--initial-transform,100%) * -1),0,0)}}@keyframes slideFromRight{from{transform:translate3d(var(--initial-transform,100%),0,0)}to{transform:translate3d(0,0,0)}}@keyframes slideToRight{to{transform:translate3d(var(--initial-transform,100%),0,0)}}");const uI="undefined"!=typeof window?Pe.useLayoutEffect:Pe.useEffect;function pI(...e){return(...t)=>{for(let n of e)"function"==typeof n&&n(...t)}}const mI="undefined"!=typeof document&&window.visualViewport;function hI(e){let t=window.getComputedStyle(e);return/(auto|scroll)/.test(t.overflow+t.overflowX+t.overflowY)}function xI(e){for(hI(e)&&(e=e.parentElement);e&&!hI(e);)e=e.parentElement;return e||document.scrollingElement||document.documentElement}const fI=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);let gI,vI=0;function bI(e={}){let{isDisabled:t}=e;uI(()=>{if(!t)return vI++,1===vI&&cI()&&(gI=function(){let e,t=0,n=n=>{e=xI(n.target),e===document.documentElement&&e===document.body||(t=n.changedTouches[0].pageY)},s=n=>{if(!e||e===document.documentElement||e===document.body)return void n.preventDefault();let s=n.changedTouches[0].pageY,i=e.scrollTop,a=e.scrollHeight-e.clientHeight;0!==a&&((i<=0&&s>t||i>=a&&s{let t=e.target;jI(t)&&t!==document.activeElement&&(e.preventDefault(),t.style.transform="translateY(-2000px)",t.focus(),requestAnimationFrame(()=>{t.style.transform=""}))},a=e=>{let t=e.target;jI(t)&&(t.style.transform="translateY(-2000px)",requestAnimationFrame(()=>{t.style.transform="",mI&&(mI.height{wI(t)}):mI.addEventListener("resize",()=>wI(t),{once:!0}))}))},r=()=>{window.scrollTo(0,0)},o=window.pageXOffset,l=window.pageYOffset,c=pI(function(e,t,n){let s=e.style[t];return e.style[t]=n,()=>{e.style[t]=s}}(document.documentElement,"paddingRight",window.innerWidth-document.documentElement.clientWidth+"px"));window.scrollTo(0,0);let d=pI(yI(document,"touchstart",n,{passive:!1,capture:!0}),yI(document,"touchmove",s,{passive:!1,capture:!0}),yI(document,"touchend",i,{passive:!1,capture:!0}),yI(document,"focus",a,!0),yI(window,"scroll",r));return()=>{c(),d(),window.scrollTo(o,l)}}()),()=>{vI--,0===vI&&(null==gI||gI())}},[t])}function yI(e,t,n,s){return e.addEventListener(t,n,s),()=>{e.removeEventListener(t,n,s)}}function wI(e){let t=document.scrollingElement||document.documentElement;for(;e&&e!==t;){let t=xI(e);if(t!==document.documentElement&&t!==document.body&&t!==e){let n=t.getBoundingClientRect().top,s=e.getBoundingClientRect().top;e.getBoundingClientRect().bottom>t.getBoundingClientRect().bottom+24&&(t.scrollTop+=s-n)}e=t.parentElement}}function jI(e){return e instanceof HTMLInputElement&&!fI.has(e.type)||e instanceof HTMLTextAreaElement||e instanceof HTMLElement&&e.isContentEditable}function CI(...e){return Pe.useCallback(function(...e){return t=>e.forEach(e=>function(e,t){"function"==typeof e?e(t):null!=e&&(e.current=t)}(e,t))}(...e),e)}const NI=new WeakMap;function FI(e,t,n=!1){if(!(e&&e instanceof HTMLElement))return;let s={};Object.entries(t).forEach(([t,n])=>{t.startsWith("--")?e.style.setProperty(t,n):(s[t]=e.style[t],e.style[t]=n)}),n||NI.set(e,s)}const _I=e=>{switch(e){case"top":case"bottom":return!0;case"left":case"right":return!1;default:return e}};function kI(e,t){if(!e)return null;const n=window.getComputedStyle(e),s=n.transform||n.webkitTransform||n.mozTransform;let i=s.match(/^matrix3d\((.+)\)$/);return i?parseFloat(i[1].split(", ")[_I(t)?13:12]):(i=s.match(/^matrix\((.+)\)$/),i?parseFloat(i[1].split(", ")[_I(t)?5:4]):null)}function SI(e,t){if(!e)return()=>{};const n=e.style.cssText;return Object.assign(e.style,t),()=>{e.style.cssText=n}}const EI={DURATION:.5,EASE:[.32,.72,0,1]},II=16,AI="vaul-dragging";function TI(e){const t=ze.useRef(e);return ze.useEffect(()=>{t.current=e}),ze.useMemo(()=>(...e)=>null==t.current?void 0:t.current.call(t,...e),[])}function MI({prop:e,defaultProp:t,onChange:n=()=>{}}){const[s,i]=function({defaultProp:e,onChange:t}){const n=ze.useState(e),[s]=n,i=ze.useRef(s),a=TI(t);return ze.useEffect(()=>{i.current!==s&&(a(s),i.current=s)},[s,i,a]),n}({defaultProp:t,onChange:n}),a=void 0!==e,r=a?e:s,o=TI(n);return[r,ze.useCallback(t=>{if(a){const n="function"==typeof t?t(e):t;n!==e&&o(n)}else i(t)},[a,e,i,o])]}let DI=null;const LI=ze.forwardRef(function({...e},t){const{overlayRef:n,snapPoints:s,onRelease:i,shouldFade:a,isOpen:r,modal:o,shouldAnimate:l}=rI(),c=CI(t,n),d=s&&s.length>0;if(!o)return null;const u=ze.useCallback(e=>i(e),[i]);return ze.createElement(H,{onMouseUp:u,ref:c,"data-vaul-overlay":"","data-vaul-snap-points":r&&d?"true":"false","data-vaul-snap-points-overlay":r&&a?"true":"false","data-vaul-animate":(null==l?void 0:l.current)?"true":"false",...e})});LI.displayName="Drawer.Overlay";const PI=ze.forwardRef(function({onPointerDownOutside:e,style:t,onOpenAutoFocus:n,...s},i){const{drawerRef:a,onPress:r,onRelease:o,onDrag:l,keyboardIsOpen:c,snapPointsOffset:d,activeSnapPointIndex:u,modal:p,isOpen:m,direction:h,snapPoints:x,container:f,handleOnly:g,shouldAnimate:v,autoFocus:b}=rI(),[y,w]=ze.useState(!1),j=CI(i,a),C=ze.useRef(null),N=ze.useRef(null),F=ze.useRef(!1),_=x&&x.length>0;!function(){const{direction:e,isOpen:t,shouldScaleBackground:n,setBackgroundColorOnScale:s,noBodyStyles:i}=rI(),a=ze.useRef(null),r=Pe.useMemo(()=>document.body.style.backgroundColor,[]);function o(){return(window.innerWidth-26)/window.innerWidth}ze.useEffect(()=>{if(t&&n){a.current&&clearTimeout(a.current);const t=document.querySelector("[data-vaul-drawer-wrapper]")||document.querySelector("[vaul-drawer-wrapper]");if(!t)return;s&&!i&&SI(document.body,{background:"black"}),SI(t,{transformOrigin:_I(e)?"top":"left",transitionProperty:"transform, border-radius",transitionDuration:`${EI.DURATION}s`,transitionTimingFunction:`cubic-bezier(${EI.EASE.join(",")})`});const n=SI(t,{borderRadius:"8px",overflow:"hidden",..._I(e)?{transform:`scale(${o()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`}:{transform:`scale(${o()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)`}});return()=>{n(),a.current=window.setTimeout(()=>{r?document.body.style.background=r:document.body.style.removeProperty("background")},1e3*EI.DURATION)}}},[t,n,r])}();function k(e){C.current=null,F.current=!1,o(e)}return ze.useEffect(()=>{_&&window.requestAnimationFrame(()=>{w(!0)})},[]),ze.createElement($,{"data-vaul-drawer-direction":h,"data-vaul-drawer":"","data-vaul-delayed-snap-points":y?"true":"false","data-vaul-snap-points":m&&_?"true":"false","data-vaul-custom-container":f?"true":"false","data-vaul-animate":(null==v?void 0:v.current)?"true":"false",...s,ref:j,style:d&&d.length>0?{"--snap-point-height":`${d[null!=u?u:0]}px`,...t}:t,onPointerDown:e=>{g||(null==s.onPointerDown||s.onPointerDown.call(s,e),C.current={x:e.pageX,y:e.pageY},r(e))},onOpenAutoFocus:e=>{null==n||n(e),b||e.preventDefault()},onPointerDownOutside:t=>{null==e||e(t),p&&!t.defaultPrevented?c.current&&(c.current=!1):t.preventDefault()},onFocusOutside:e=>{p||e.preventDefault()},onPointerMove:e=>{if(N.current=e,g)return;if(null==s.onPointerMove||s.onPointerMove.call(s,e),!C.current)return;const t=e.pageY-C.current.y,n=e.pageX-C.current.x,i="touch"===e.pointerType?10:2,a=((e,t,n=0)=>{if(F.current)return!0;const s=Math.abs(e.y),i=Math.abs(e.x),a=i>s,r=["bottom","right"].includes(t)?1:-1;if("left"===t||"right"===t){if(!(e.x*r<0)&&i>=0&&i<=n)return a}else if(!(e.y*r<0)&&s>=0&&s<=n)return!a;return F.current=!0,!0})({x:n,y:t},h,i);a?l(e):(Math.abs(n)>i||Math.abs(t)>i)&&(C.current=null)},onPointerUp:e=>{null==s.onPointerUp||s.onPointerUp.call(s,e),C.current=null,F.current=!1,o(e)},onPointerOut:e=>{null==s.onPointerOut||s.onPointerOut.call(s,e),k(N.current)},onContextMenu:e=>{null==s.onContextMenu||s.onContextMenu.call(s,e),N.current&&k(N.current)}})});PI.displayName="Drawer.Content";ze.forwardRef(function({preventCycle:e=!1,children:t,...n},s){const{closeDrawer:i,isDragging:a,snapPoints:r,activeSnapPoint:o,setActiveSnapPoint:l,dismissible:c,handleOnly:d,isOpen:u,onPress:p,onDrag:m}=rI(),h=ze.useRef(null),x=ze.useRef(!1);function f(){h.current&&window.clearTimeout(h.current),x.current=!1}return ze.createElement("div",{onClick:function(){x.current?f():window.setTimeout(()=>{!function(){if(a||e||x.current)return void f();if(f(),!r||0===r.length)return void(c||i());if(o===r[r.length-1]&&c)return void i();const t=r.findIndex(e=>e===o);if(-1===t)return;const n=r[t+1];l(n)}()},120)},onPointerCancel:f,onPointerDown:e=>{d&&p(e),h.current=window.setTimeout(()=>{x.current=!0},250)},onPointerMove:e=>{d&&m(e)},ref:s,"data-vaul-drawer-visible":u?"true":"false","data-vaul-handle":"","aria-hidden":"true",...n},ze.createElement("span",{"data-vaul-handle-hitarea":"","aria-hidden":"true"},t))}).displayName="Drawer.Handle";const RI={Root:function({open:e,onOpenChange:t,children:n,onDrag:s,onRelease:i,snapPoints:a,shouldScaleBackground:r=!1,setBackgroundColorOnScale:o=!0,closeThreshold:l=.25,scrollLockTimeout:c=100,dismissible:d=!0,handleOnly:u=!1,fadeFromIndex:p=a&&a.length-1,activeSnapPoint:m,setActiveSnapPoint:h,fixed:x,modal:f=!0,onClose:g,nested:v,noBodyStyles:b=!1,direction:y="bottom",defaultOpen:w=!1,disablePreventScroll:j=!0,snapToSequentialPoint:C=!1,preventScrollRestoration:N=!1,repositionInputs:F=!0,onAnimationEnd:_,container:k,autoFocus:S=!1}){var E,I;const[A=!1,T]=MI({defaultProp:w,prop:e,onChange:e=>{null==t||t(e),e||v||de(),setTimeout(()=>{null==_||_(e)},1e3*EI.DURATION),e&&!f&&"undefined"!=typeof window&&window.requestAnimationFrame(()=>{document.body.style.pointerEvents="auto"}),e||(document.body.style.pointerEvents="auto")}}),[M,D]=ze.useState(!1),[L,P]=ze.useState(!1),[R,O]=ze.useState(!1),z=ze.useRef(null),B=ze.useRef(null),H=ze.useRef(null),$=ze.useRef(null),V=ze.useRef(null),U=ze.useRef(!1),W=ze.useRef(null),q=ze.useRef(0),Z=ze.useRef(!1),Y=ze.useRef(!w),K=ze.useRef(0),J=ze.useRef(null),Q=ze.useRef((null==(E=J.current)?void 0:E.getBoundingClientRect().height)||0),X=ze.useRef((null==(I=J.current)?void 0:I.getBoundingClientRect().width)||0),ee=ze.useRef(0),te=ze.useCallback(e=>{a&&e===re.length-1&&(B.current=new Date)},[]),{activeSnapPoint:ne,activeSnapPointIndex:se,setActiveSnapPoint:ie,onRelease:ae,snapPointsOffset:re,onDrag:oe,shouldFade:le,getPercentageDragged:ce}=function({activeSnapPointProp:e,setActiveSnapPointProp:t,snapPoints:n,drawerRef:s,overlayRef:i,fadeFromIndex:a,onSnapPointChange:r,direction:o="bottom",container:l,snapToSequentialPoint:c}){const[d,u]=MI({prop:e,defaultProp:null==n?void 0:n[0],onChange:t}),[p,m]=ze.useState("undefined"!=typeof window?{innerWidth:window.innerWidth,innerHeight:window.innerHeight}:void 0);ze.useEffect(()=>{function e(){m({innerWidth:window.innerWidth,innerHeight:window.innerHeight})}return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const h=ze.useMemo(()=>d===(null==n?void 0:n[n.length-1])||null,[n,d]),x=ze.useMemo(()=>{var e;return null!=(e=null==n?void 0:n.findIndex(e=>e===d))?e:null},[n,d]),f=n&&n.length>0&&(a||0===a)&&!Number.isNaN(a)&&n[a]===d||!n,g=ze.useMemo(()=>{const e=l?{width:l.getBoundingClientRect().width,height:l.getBoundingClientRect().height}:"undefined"!=typeof window?{width:window.innerWidth,height:window.innerHeight}:{width:0,height:0};var t;return null!=(t=null==n?void 0:n.map(t=>{const n="string"==typeof t;let s=0;if(n&&(s=parseInt(t,10)),_I(o)){const i=n?s:p?t*e.height:0;return p?"bottom"===o?e.height-i:-e.height+i:i}const i=n?s:p?t*e.width:0;return p?"right"===o?e.width-i:-e.width+i:i}))?t:[]},[n,p,l]),v=ze.useMemo(()=>null!==x?null==g?void 0:g[x]:null,[g,x]),b=ze.useCallback(e=>{var t;const l=null!=(t=null==g?void 0:g.findIndex(t=>t===e))?t:null;r(l),FI(s.current,{transition:`transform ${EI.DURATION}s cubic-bezier(${EI.EASE.join(",")})`,transform:_I(o)?`translate3d(0, ${e}px, 0)`:`translate3d(${e}px, 0, 0)`}),g&&l!==g.length-1&&void 0!==a&&l!==a&&l{if(d||e){var t;const s=null!=(t=null==n?void 0:n.findIndex(t=>t===e||t===d))?t:-1;g&&-1!==s&&"number"==typeof g[s]&&b(g[s])}},[d,e,n,g,b]),{isLastSnapPoint:h,activeSnapPoint:d,shouldFade:f,getPercentageDragged:function(e,t){if(!n||"number"!=typeof x||!g||void 0===a)return null;const s=x===a-1;if(x>=a&&t)return 0;if(s&&!t)return 1;if(!f&&!s)return null;const i=s?x+1:x-1,r=s?g[i]-g[i-1]:g[i+1]-g[i],o=e/Math.abs(r);return s?1-o:o},setActiveSnapPoint:u,activeSnapPointIndex:x,onRelease:function({draggedDistance:e,closeDrawer:t,velocity:s,dismissible:r}){if(void 0===a)return;const l="bottom"===o||"right"===o?(null!=v?v:0)-e:(null!=v?v:0)+e,d=0===x,u=e>0;if(x===a-1&&FI(i.current,{transition:`opacity ${EI.DURATION}s cubic-bezier(${EI.EASE.join(",")})`}),!c&&s>2&&!u)return void(r?t():b(g[0]));if(!c&&s>2&&u&&g&&n)return void b(g[n.length-1]);const p=null==g?void 0:g.reduce((e,t)=>"number"!=typeof e||"number"!=typeof t?e:Math.abs(t-l).4&&Math.abs(e)<.4*m){const e=u?1:-1;if(e>0&&h&&n)return void b(g[n.length-1]);if(d&&e<0&&r&&t(),null===x)return;return void b(g[x+e])}b(p)},onDrag:function({draggedDistance:e}){if(null===v)return;const t="bottom"===o||"right"===o?v-e:v+e;("bottom"===o||"right"===o)&&tg[g.length-1]||FI(s.current,{transform:_I(o)?`translate3d(0, ${t}px, 0)`:`translate3d(${t}px, 0, 0)`})},snapPointsOffset:g}}({snapPoints:a,activeSnapPointProp:m,setActiveSnapPointProp:h,drawerRef:J,fadeFromIndex:p,overlayRef:z,onSnapPointChange:te,direction:y,container:k,snapToSequentialPoint:C});bI({isDisabled:!A||L||!f||R||!M||!F||!j});const{restorePositionSetting:de}=function({isOpen:e,modal:t,nested:n,hasBeenOpened:s,preventScrollRestoration:i,noBodyStyles:a}){const[r,o]=ze.useState(()=>"undefined"!=typeof window?window.location.href:""),l=ze.useRef(0),c=ze.useCallback(()=>{if(oI()&&null===DI&&e&&!a){DI={position:document.body.style.position,top:document.body.style.top,left:document.body.style.left,height:document.body.style.height,right:"unset"};const{scrollX:e,innerHeight:t}=window;document.body.style.setProperty("position","fixed","important"),Object.assign(document.body.style,{top:-l.current+"px",left:-e+"px",right:"0px",height:"auto"}),window.setTimeout(()=>window.requestAnimationFrame(()=>{const e=t-window.innerHeight;e&&l.current>=t&&(document.body.style.top=-(l.current+e)+"px")}),300)}},[e]),d=ze.useCallback(()=>{if(oI()&&null!==DI&&!a){const e=-parseInt(document.body.style.top,10),t=-parseInt(document.body.style.left,10);Object.assign(document.body.style,DI),window.requestAnimationFrame(()=>{i&&r!==window.location.href?o(window.location.href):window.scrollTo(t,e)}),DI=null}},[r]);return ze.useEffect(()=>{function e(){l.current=window.scrollY}return e(),window.addEventListener("scroll",e),()=>{window.removeEventListener("scroll",e)}},[]),ze.useEffect(()=>{if(t)return()=>{"undefined"!=typeof document&&(document.querySelector("[data-vaul-drawer]")||d())}},[t,d]),ze.useEffect(()=>{!n&&s&&(e?(!window.matchMedia("(display-mode: standalone)").matches&&c(),t||window.setTimeout(()=>{d()},500)):d())},[e,s,r,t,n,c,d]),{restorePositionSetting:d}}({isOpen:A,modal:f,nested:null!=v&&v,hasBeenOpened:M,preventScrollRestoration:N,noBodyStyles:b});function ue(){return(window.innerWidth-26)/window.innerWidth}function pe(e,t){var n;let s=e;const i=null==(n=window.getSelection())?void 0:n.toString(),a=J.current?kI(J.current,y):null,r=new Date;if("SELECT"===s.tagName)return!1;if(s.hasAttribute("data-vaul-no-drag")||s.closest("[data-vaul-no-drag]"))return!1;if("right"===y||"left"===y)return!0;if(B.current&&r.getTime()-B.current.getTime()<500)return!1;if(null!==a&&("bottom"===y?a>0:a<0))return!0;if(i&&i.length>0)return!1;if(V.current&&r.getTime()-V.current.getTime()s.clientHeight){if(0!==s.scrollTop)return V.current=new Date,!1;if("dialog"===s.getAttribute("role"))return!0}s=s.parentNode}return!0}function me(e){!function(){if(!L||!J.current)return;J.current.classList.remove(AI),U.current=!1,P(!1),$.current=new Date}(),null==g||g(),e||T(!1),setTimeout(()=>{a&&ie(a[0])},1e3*EI.DURATION)}function he(){if(!J.current)return;const e=document.querySelector("[data-vaul-drawer-wrapper]"),t=kI(J.current,y);FI(J.current,{transform:"translate3d(0, 0, 0)",transition:`transform ${EI.DURATION}s cubic-bezier(${EI.EASE.join(",")})`}),FI(z.current,{transition:`opacity ${EI.DURATION}s cubic-bezier(${EI.EASE.join(",")})`,opacity:"1"}),r&&t&&t>0&&A&&FI(e,{borderRadius:"8px",overflow:"hidden",..._I(y)?{transform:`scale(${ue()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`,transformOrigin:"top"}:{transform:`scale(${ue()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)`,transformOrigin:"left"},transitionProperty:"transform, border-radius",transitionDuration:`${EI.DURATION}s`,transitionTimingFunction:`cubic-bezier(${EI.EASE.join(",")})`},!0)}return ze.useEffect(()=>{window.requestAnimationFrame(()=>{Y.current=!0})},[]),ze.useEffect(()=>{var e;function t(){if(!J.current||!F)return;if(jI(document.activeElement)||Z.current){var e;const t=(null==(e=window.visualViewport)?void 0:e.height)||0,n=window.innerHeight;let s=n-t;const i=J.current.getBoundingClientRect().height||0,r=i>.8*n;ee.current||(ee.current=i);const o=J.current.getBoundingClientRect().top;if(Math.abs(K.current-s)>60&&(Z.current=!Z.current),a&&a.length>0&&re&&se){s+=re[se]||0}if(K.current=s,i>t||Z.current){const e=J.current.getBoundingClientRect().height;let n=e;e>t&&(n=t-(r?o:26)),J.current.style.height=x?e-Math.max(s,0)+"px":`${Math.max(n,t-o)}px`}else(function(){const e=navigator.userAgent;return"undefined"!=typeof window&&(/Firefox/.test(e)&&/Mobile/.test(e)||/FxiOS/.test(e))})()||(J.current.style.height=`${ee.current}px`);a&&a.length>0&&!Z.current?J.current.style.bottom="0px":J.current.style.bottom=`${Math.max(s,0)}px`}}return null==(e=window.visualViewport)||e.addEventListener("resize",t),()=>{var e;return null==(e=window.visualViewport)?void 0:e.removeEventListener("resize",t)}},[se,a,re]),ze.useEffect(()=>(A&&(FI(document.documentElement,{scrollBehavior:"auto"}),B.current=new Date),()=>{!function(e,t){if(!(e&&e instanceof HTMLElement))return;let n=NI.get(e);n&&(e.style[t]=n[t])}(document.documentElement,"scrollBehavior")}),[A]),ze.useEffect(()=>{f||window.requestAnimationFrame(()=>{document.body.style.pointerEvents="auto"})},[f]),ze.createElement(G,{defaultOpen:w,onOpenChange:e=>{(d||e)&&(e?D(!0):me(!0),T(e))},open:A},ze.createElement(aI.Provider,{value:{activeSnapPoint:ne,snapPoints:a,setActiveSnapPoint:ie,drawerRef:J,overlayRef:z,onOpenChange:t,onPress:function(e){var t,n;(d||a)&&(J.current&&!J.current.contains(e.target)||(Q.current=(null==(t=J.current)?void 0:t.getBoundingClientRect().height)||0,X.current=(null==(n=J.current)?void 0:n.getBoundingClientRect().width)||0,P(!0),H.current=new Date,cI()&&window.addEventListener("touchend",()=>U.current=!1,{once:!0}),e.target.setPointerCapture(e.pointerId),q.current=_I(y)?e.pageY:e.pageX))},onRelease:function(e){if(!L||!J.current)return;J.current.classList.remove(AI),U.current=!1,P(!1),$.current=new Date;const t=kI(J.current,y);if(!e||!pe(e.target,!1)||!t||Number.isNaN(t))return;if(null===H.current)return;const n=$.current.getTime()-H.current.getTime(),s=q.current-(_I(y)?e.pageY:e.pageX),r=Math.abs(s)/n;if(r>.05&&(O(!0),setTimeout(()=>{O(!1)},200)),a){return ae({draggedDistance:s*("bottom"===y||"right"===y?1:-1),closeDrawer:me,velocity:r,dismissible:d}),void(null==i||i(e,!0))}if("bottom"===y||"right"===y?s>0:s<0)return he(),void(null==i||i(e,!0));if(r>.4)return me(),void(null==i||i(e,!1));var o;const c=Math.min(null!=(o=J.current.getBoundingClientRect().height)?o:0,window.innerHeight);var u;const p=Math.min(null!=(u=J.current.getBoundingClientRect().width)?u:0,window.innerWidth),m="left"===y||"right"===y;if(Math.abs(t)>=(m?p:c)*l)return me(),void(null==i||i(e,!1));null==i||i(e,!0),he()},onDrag:function(e){var t;if(J.current&&L){const n="bottom"===y||"right"===y?1:-1,i=(q.current-(_I(y)?e.pageY:e.pageX))*n,o=i>0,l=a&&!d&&!o;if(l&&0===se)return;const c=Math.abs(i),u=document.querySelector("[data-vaul-drawer-wrapper]");let m=c/("bottom"===y||"top"===y?Q.current:X.current);const h=ce(c,o);if(null!==h&&(m=h),l&&m>=1)return;if(!U.current&&!pe(e.target,o))return;if(J.current.classList.add(AI),U.current=!0,FI(J.current,{transition:"none"}),FI(z.current,{transition:"none"}),a&&oe({draggedDistance:i}),o&&!a){const e=(t=i,8*(Math.log(t+1)-2)),s=Math.min(-1*e,0)*n;return void FI(J.current,{transform:_I(y)?`translate3d(0, ${s}px, 0)`:`translate3d(${s}px, 0, 0)`})}const x=1-m;if((le||p&&se===p-1)&&(null==s||s(e,m),FI(z.current,{opacity:`${x}`,transition:"none"},!0)),u&&z.current&&r){const e=Math.min(ue()+m*(1-ue()),1),t=8-8*m,n=Math.max(0,14-14*m);FI(u,{borderRadius:`${t}px`,transform:_I(y)?`scale(${e}) translate3d(0, ${n}px, 0)`:`scale(${e}) translate3d(${n}px, 0, 0)`,transition:"none"},!0)}if(!a){const e=c*n;FI(J.current,{transform:_I(y)?`translate3d(0, ${e}px, 0)`:`translate3d(${e}px, 0, 0)`})}}},dismissible:d,shouldAnimate:Y,handleOnly:u,isOpen:A,isDragging:L,shouldFade:le,closeDrawer:me,onNestedDrag:function(e,t){if(t<0)return;const n=(window.innerWidth-II)/window.innerWidth,s=n+t*(1-n),i=t*II-16;FI(J.current,{transform:_I(y)?`scale(${s}) translate3d(0, ${i}px, 0)`:`scale(${s}) translate3d(${i}px, 0, 0)`,transition:"none"})},onNestedOpenChange:function(e){const t=e?(window.innerWidth-II)/window.innerWidth:1,n=e?-16:0;W.current&&window.clearTimeout(W.current),FI(J.current,{transition:`transform ${EI.DURATION}s cubic-bezier(${EI.EASE.join(",")})`,transform:_I(y)?`scale(${t}) translate3d(0, ${n}px, 0)`:`scale(${t}) translate3d(${n}px, 0, 0)`}),!e&&J.current&&(W.current=setTimeout(()=>{const e=kI(J.current,y);FI(J.current,{transition:"none",transform:_I(y)?`translate3d(0, ${e}px, 0)`:`translate3d(${e}px, 0, 0)`})},500))},onNestedRelease:function(e,t){const n=_I(y)?window.innerHeight:window.innerWidth,s=t?(n-II)/n:1,i=t?-16:0;t&&FI(J.current,{transition:`transform ${EI.DURATION}s cubic-bezier(${EI.EASE.join(",")})`,transform:_I(y)?`scale(${s}) translate3d(0, ${i}px, 0)`:`scale(${s}) translate3d(${i}px, 0, 0)`})},keyboardIsOpen:Z,modal:f,snapPointsOffset:re,activeSnapPointIndex:se,direction:y,shouldScaleBackground:r,setBackgroundColorOnScale:o,noBodyStyles:b,container:k,autoFocus:S}},n))},Content:PI,Overlay:LI,Trigger:V,Portal:function(e){const t=rI(),{container:n=t.container,...s}=e;return ze.createElement(Z,{container:n,...s})},Close:q,Title:U,Description:W};function OI({...e}){return a.jsx(RI.Root,{"data-slot":"drawer",...e})}function zI({...e}){return a.jsx(RI.Trigger,{"data-slot":"drawer-trigger",...e})}function BI({...e}){return a.jsx(RI.Portal,{"data-slot":"drawer-portal",...e})}function HI({...e}){return a.jsx(RI.Close,{"data-slot":"drawer-close",...e})}function $I({className:e,...t}){return a.jsx(RI.Overlay,{"data-slot":"drawer-overlay",className:bb("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/60",e),...t})}function VI({className:e,children:t,handleColor:n="bg-[#252525]/15",...s}){return a.jsxs(BI,{"data-slot":"drawer-portal",children:[a.jsx($I,{}),a.jsx(RI.Content,{"data-slot":"drawer-content",className:bb("group/drawer-content bg-background fixed z-50 flex h-auto flex-col","data-[vaul-drawer-direction=top]:inset-x-0 data-[vaul-drawer-direction=top]:top-0 data-[vaul-drawer-direction=top]:mb-24 data-[vaul-drawer-direction=top]:max-h-[99vh] data-[vaul-drawer-direction=top]:rounded-b-lg data-[vaul-drawer-direction=top]:border-b","data-[vaul-drawer-direction=bottom]:inset-x-0 data-[vaul-drawer-direction=bottom]:bottom-0 data-[vaul-drawer-direction=bottom]:mt-24 data-[vaul-drawer-direction=bottom]:max-h-[99vh] data-[vaul-drawer-direction=bottom]:rounded-t-2xl data-[vaul-drawer-direction=bottom]:border-none data-[vaul-drawer-direction=bottom]:bg-transparent","data-[vaul-drawer-direction=right]:inset-y-0 data-[vaul-drawer-direction=right]:right-0 data-[vaul-drawer-direction=right]:w-3/4 data-[vaul-drawer-direction=right]:border-l data-[vaul-drawer-direction=right]:sm:max-w-sm","data-[vaul-drawer-direction=left]:inset-y-0 data-[vaul-drawer-direction=left]:left-0 data-[vaul-drawer-direction=left]:w-3/4 data-[vaul-drawer-direction=left]:border-r data-[vaul-drawer-direction=left]:sm:max-w-sm",e),...s,children:a.jsxs("div",{className:"relative flex justify-center",children:[a.jsx("div",{className:bb(["mx-auto absolute top-5 z-50 h-1 w-[44px] shrink-0 rounded-full group-data-[vaul-drawer-direction=bottom]/drawer-content:block",n])}),t]})})]})}function UI({className:e,...t}){return a.jsx("div",{"data-slot":"drawer-header",className:bb("flex flex-col gap-0.5 p-4 group-data-[vaul-drawer-direction=bottom]/drawer-content:text-center group-data-[vaul-drawer-direction=top]/drawer-content:text-center md:gap-1.5 md:text-left",e),...t})}function WI({className:e,...t}){return a.jsx("div",{"data-slot":"drawer-footer",className:bb("mt-auto flex flex-col gap-2 p-4",e),...t})}function qI({className:e,...t}){return a.jsx(RI.Title,{"data-slot":"drawer-title",className:bb("text-foreground font-semibold",e),...t})}function GI({className:e,...t}){return a.jsx(RI.Description,{"data-slot":"drawer-description",className:bb("text-muted-foreground text-sm",e),...t})}function ZI({trigger:e,title:t,description:n,children:s,footer:i,open:r,onOpenChange:o,maxWidth:l="max-w-sm",contentPadding:c="p-3",showDefaultFooter:d=!0,handleColor:u="bg-[#252525]/15",onSubmit:p,onCancel:m,submitText:h="Submit",cancelText:x="Cancel",submitDisabled:f=!1,customerHeader:g,triggerColor:v,showCancel:b=!1}){return a.jsxs(OI,{open:r,onOpenChange:o,children:[a.jsx(zI,{asChild:!0,children:e}),a.jsx(VI,{handleColor:u,children:a.jsxs("div",{className:`mx-auto w-full bg-[#111112] border border-[#333333] rounded-t-[24px] ${l}`,children:[g,(t||n)&&a.jsxs(UI,{children:[t&&a.jsx(qI,{children:t}),n&&a.jsx(GI,{children:n}),b&&a.jsx("button",{type:"button",title:"Close",onClick:()=>{null==m||m()},className:"absolute flex items-center justify-center w-8 h-8 p-1 rounded-full top-3 right-4 bg-white/5 hover:bg-white/10",children:a.jsx(HS,{className:"w-5 h-5"})})]}),a.jsx("div",{className:bb("pb-0",c),children:s}),(i||d)&&a.jsx(WI,{className:"bg-[#111112]",children:i||a.jsxs(a.Fragment,{children:[a.jsx(Nb,{onClick:()=>{null==p||p()},disabled:f,children:h}),a.jsx(HI,{asChild:!0,children:a.jsx(Nb,{variant:"outline",onClick:()=>{null==m||m()},children:x})})]})})]})})]})}const YI=({checked:e,onCheckedChange:t,disabled:n=!1,className:s="",checkedColor:i="#29BCCC"})=>a.jsx("button",{title:"Toggle Key Status",type:"button",role:"switch","aria-checked":e?"true":"false",disabled:n,onClick:s=>{s.stopPropagation(),!n&&t(!e)},className:`relative inline-flex h-8 w-14 items-center rounded-full transition-colors focus:outline-none disabled:opacity-50 disabled:cursor-not-allowed ${s}`,style:{backgroundColor:e?i:"#131314"},children:a.jsx(zt.div,{className:"relative",animate:{x:e?28:4},transition:{type:"spring",stiffness:500,damping:30},children:a.jsxs("div",{className:"relative w-6 h-6",children:[a.jsx("div",{className:"absolute inset-0 rounded-full",style:{background:"rgba(255, 255, 255, 0.05)"}}),a.jsx("div",{className:"absolute inset-0 rounded-full",style:{background:"\n linear-gradient(180deg, #242528 0%, #111113 100%),\n linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.2) 100%)\n ",filter:"\n drop-shadow(0px 0.85px 2.12px rgba(0, 0, 0, 0.36))\n drop-shadow(0px 3.6px 3.6px rgba(0, 0, 0, 0.31))\n drop-shadow(0px 8.27px 5.09px rgba(0, 0, 0, 0.18))\n drop-shadow(0px 14.84px 5.93px rgba(0, 0, 0, 0.05))\n drop-shadow(0px 23.1px 6.57px rgba(0, 0, 0, 0.01))\n "}}),a.jsx("div",{className:"absolute inset-0 rounded-full",style:{background:"\n radial-gradient(circle at center,\n rgba(255, 255, 255, 0.1) 0%,\n rgba(255, 255, 255, 0.03) 50%,\n transparent 100%\n )\n ",boxShadow:"\n inset 0px 1.48px 2.97px rgba(255, 255, 255, 0.03),\n inset 0px 1.27px 0.85px rgba(255, 255, 255, 0.02),\n inset 0px 0.21px 0.21px rgba(255, 255, 255, 0.1)\n "}})]})})}),KI=({size:e=24,color:t="#CCCCCC",className:n=""})=>a.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:n,children:a.jsx("path",{d:"M5.74011 12.8965C5.28525 12.3384 5.31804 11.5154 5.83817 10.9953L13.4172 3.4163L13.5254 3.31823C14.0836 2.86338 14.9065 2.89617 15.4267 3.4163C15.9468 3.93643 15.9796 4.75938 15.5247 5.31753L15.4267 5.42577L8.85238 12L15.4267 18.5743C15.9816 19.1293 15.9816 20.0288 15.4267 20.5838C14.8717 21.1387 13.9721 21.1387 13.4172 20.5838L5.83817 13.0048L5.74011 12.8965Z",fill:t})}),JI=({size:e=24,color:t="#C4C4CC",className:n=""})=>a.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:n,style:{width:e,height:e},children:a.jsx("path",{d:"M14.5 4.9999C13.9696 4.9999 13.4609 5.21061 13.0858 5.58568C12.7107 5.96076 12.5 6.46946 12.5 6.9999C12.5 7.53033 12.7107 8.03904 13.0858 8.41411C13.4609 8.78918 13.9696 8.9999 14.5 8.9999C15.0304 8.9999 15.5391 8.78918 15.9142 8.41411C16.2893 8.03904 16.5 7.53033 16.5 6.9999C16.5 6.46946 16.2893 5.96076 15.9142 5.58568C15.5391 5.21061 15.0304 4.9999 14.5 4.9999ZM10.626 5.9999C10.8484 5.14166 11.3496 4.38158 12.0507 3.83897C12.7519 3.29636 13.6134 3.00195 14.5 3.00195C15.3866 3.00195 16.2481 3.29636 16.9493 3.83897C17.6504 4.38158 18.1516 5.14166 18.374 5.9999H20C20.2652 5.9999 20.5196 6.10525 20.7071 6.29279C20.8946 6.48033 21 6.73468 21 6.9999C21 7.26511 20.8946 7.51947 20.7071 7.707C20.5196 7.89454 20.2652 7.9999 20 7.9999H18.374C18.1516 8.85814 17.6504 9.61822 16.9493 10.1608C16.2481 10.7034 15.3866 10.9978 14.5 10.9978C13.6134 10.9978 12.7519 10.7034 12.0507 10.1608C11.3496 9.61822 10.8484 8.85814 10.626 7.9999H4C3.73478 7.9999 3.48043 7.89454 3.29289 7.707C3.10536 7.51947 3 7.26511 3 6.9999C3 6.73468 3.10536 6.48033 3.29289 6.29279C3.48043 6.10525 3.73478 5.9999 4 5.9999H10.626ZM9.5 14.9999C8.96957 14.9999 8.46086 15.2106 8.08579 15.5857C7.71071 15.9608 7.5 16.4695 7.5 16.9999C7.5 17.5303 7.71071 18.039 8.08579 18.4141C8.46086 18.7892 8.96957 18.9999 9.5 18.9999C10.0304 18.9999 10.5391 18.7892 10.9142 18.4141C11.2893 18.039 11.5 17.5303 11.5 16.9999C11.5 16.4695 11.2893 15.9608 10.9142 15.5857C10.5391 15.2106 10.0304 14.9999 9.5 14.9999ZM5.626 15.9999C5.84844 15.1417 6.34957 14.3816 7.05074 13.839C7.7519 13.2964 8.6134 13.002 9.5 13.002C10.3866 13.002 11.2481 13.2964 11.9493 13.839C12.6504 14.3816 13.1516 15.1417 13.374 15.9999H20C20.2652 15.9999 20.5196 16.1053 20.7071 16.2928C20.8946 16.4803 21 16.7347 21 16.9999C21 17.2651 20.8946 17.5195 20.7071 17.707C20.5196 17.8945 20.2652 17.9999 20 17.9999H13.374C13.1516 18.8581 12.6504 19.6182 11.9493 20.1608C11.2481 20.7034 10.3866 20.9978 9.5 20.9978C8.6134 20.9978 7.7519 20.7034 7.05074 20.1608C6.34957 19.6182 5.84844 18.8581 5.626 17.9999H4C3.73478 17.9999 3.48043 17.8945 3.29289 17.707C3.10536 17.5195 3 17.2651 3 16.9999C3 16.7347 3.10536 16.4803 3.29289 16.2928C3.48043 16.1053 3.73478 15.9999 4 15.9999H5.626Z",fill:t})}),QI=({size:e=20,className:t="",gradientId:n="mcp-gradient"})=>{const s=`${n}-clip`;return a.jsxs("svg",{width:e,height:e,viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,style:{width:`${e}px`,height:`${e}px`},children:[a.jsx("g",{clipPath:`url(#${s})`,children:a.jsx("path",{d:"M18.667 4.33105H20V15.665H18.667V16.998H1.33301V15.665H0V4.33105H1.33301V2.99805H18.667V4.33105ZM2 7.33203V12.665H3.66699V8.99902H4.33301V12.665H5.66602V8.99902H6.33301V12.665H8V7.33203H2ZM9 7.33203V12.665H13V10.999H10.667V8.99902H13V7.33203H9ZM14 7.33203V12.665H15.667V10.999H18.333V7.33203H14ZM16.667 8.66504V9.66504H15.667V8.66504H16.667Z",fill:`url(#${n})`})}),a.jsxs("defs",{children:[a.jsxs("linearGradient",{id:n,x1:"1.75",y1:"0.548044",x2:"8.73257",y2:"20.107",gradientUnits:"userSpaceOnUse",children:[a.jsx("stop",{stopColor:"#FFF4DF"}),a.jsx("stop",{offset:"1",stopColor:"#F49B57"})]}),a.jsx("clipPath",{id:s,children:a.jsx("rect",{width:"20",height:"20",fill:"white"})})]})]})},XI=({className:e="",color:t="#E6E6E6",size:n=20,style:s})=>a.jsxs("svg",{width:n,height:n,viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,style:s,children:[a.jsx("mask",{id:`mask0_3584_37997_${Math.random()}`,style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:"0",y:"0",width:"20",height:"20",children:a.jsx("rect",{width:"20",height:"20",fill:"#D9D9D9"})}),a.jsx("g",{mask:`url(#mask0_3584_37997_${Math.random()})`,children:a.jsx("path",{d:"M9.99935 18.3327C8.86046 18.3327 7.78407 18.1139 6.77018 17.6764C5.75629 17.2389 4.87088 16.6417 4.11393 15.8848C3.35699 15.1278 2.75977 14.2424 2.32227 13.2285C1.88477 12.2146 1.66602 11.1382 1.66602 9.99935C1.66602 8.84657 1.88477 7.76671 2.32227 6.75977C2.75977 5.75282 3.35699 4.87088 4.11393 4.11393C4.87088 3.35699 5.75629 2.75977 6.77018 2.32227C7.78407 1.88477 8.86046 1.66602 9.99935 1.66602C11.1521 1.66602 12.232 1.88477 13.2389 2.32227C14.2459 2.75977 15.1278 3.35699 15.8848 4.11393C16.6417 4.87088 17.2389 5.75282 17.6764 6.75977C18.1139 7.76671 18.3327 8.84657 18.3327 9.99935C18.3327 11.1382 18.1139 12.2146 17.6764 13.2285C17.2389 14.2424 16.6417 15.1278 15.8848 15.8848C15.1278 16.6417 14.2459 17.2389 13.2389 17.6764C12.232 18.1139 11.1521 18.3327 9.99935 18.3327ZM9.99935 16.6243C10.3605 16.1243 10.673 15.6035 10.9368 15.0618C11.2007 14.5202 11.416 13.9438 11.5827 13.3327H8.41602C8.58268 13.9438 8.79796 14.5202 9.06185 15.0618C9.32574 15.6035 9.63824 16.1243 9.99935 16.6243ZM7.83268 16.291C7.58268 15.8327 7.36393 15.357 7.17643 14.8639C6.98893 14.3709 6.83268 13.8605 6.70768 13.3327H4.24935C4.65213 14.0271 5.1556 14.6313 5.75977 15.1452C6.36393 15.6591 7.0549 16.041 7.83268 16.291ZM12.166 16.291C12.9438 16.041 13.6348 15.6591 14.2389 15.1452C14.8431 14.6313 15.3466 14.0271 15.7493 13.3327H13.291C13.166 13.8605 13.0098 14.3709 12.8223 14.8639C12.6348 15.357 12.416 15.8327 12.166 16.291ZM3.54102 11.666H6.37435C6.33268 11.3882 6.30143 11.1139 6.2806 10.8431C6.25977 10.5723 6.24935 10.291 6.24935 9.99935C6.24935 9.70768 6.25977 9.42643 6.2806 9.1556C6.30143 8.88477 6.33268 8.61046 6.37435 8.33268H3.54102C3.47157 8.61046 3.41949 8.88477 3.38477 9.1556C3.35004 9.42643 3.33268 9.70768 3.33268 9.99935C3.33268 10.291 3.35004 10.5723 3.38477 10.8431C3.41949 11.1139 3.47157 11.3882 3.54102 11.666ZM8.04102 11.666H11.9577C11.9993 11.3882 12.0306 11.1139 12.0514 10.8431C12.0723 10.5723 12.0827 10.291 12.0827 9.99935C12.0827 9.70768 12.0723 9.42643 12.0514 9.1556C12.0306 8.88477 11.9993 8.61046 11.9577 8.33268H8.04102C7.99935 8.61046 7.9681 8.88477 7.94727 9.1556C7.92643 9.42643 7.91602 9.70768 7.91602 9.99935C7.91602 10.291 7.92643 10.5723 7.94727 10.8431C7.9681 11.1139 7.99935 11.3882 8.04102 11.666ZM13.6243 11.666H16.4577C16.5271 11.3882 16.5792 11.1139 16.6139 10.8431C16.6487 10.5723 16.666 10.291 16.666 9.99935C16.666 9.70768 16.6487 9.42643 16.6139 9.1556C16.5792 8.88477 16.5271 8.61046 16.4577 8.33268H13.6243C13.666 8.61046 13.6973 8.88477 13.7181 9.1556C13.7389 9.42643 13.7493 9.70768 13.7493 9.99935C13.7493 10.291 13.7389 10.5723 13.7181 10.8431C13.6973 11.1139 13.666 11.3882 13.6243 11.666ZM13.291 6.66602H15.7493C15.3466 5.97157 14.8431 5.3674 14.2389 4.85352C13.6348 4.33963 12.9438 3.95768 12.166 3.70768C12.416 4.16602 12.6348 4.64171 12.8223 5.13477C13.0098 5.62782 13.166 6.13824 13.291 6.66602ZM8.41602 6.66602H11.5827C11.416 6.0549 11.2007 5.47852 10.9368 4.93685C10.673 4.39518 10.3605 3.87435 9.99935 3.37435C9.63824 3.87435 9.32574 4.39518 9.06185 4.93685C8.79796 5.47852 8.58268 6.0549 8.41602 6.66602ZM4.24935 6.66602H6.70768C6.83268 6.13824 6.98893 5.62782 7.17643 5.13477C7.36393 4.64171 7.58268 4.16602 7.83268 3.70768C7.0549 3.95768 6.36393 4.33963 5.75977 4.85352C5.1556 5.3674 4.65213 5.97157 4.24935 6.66602Z",fill:t})})]});var eA,tA,nA,sA,iA,aA={exports:{}};function rA(){if(tA)return eA;tA=1;return eA="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"}function oA(){if(sA)return nA;sA=1;var e=rA();function t(){}function n(){}return n.resetWarningCache=t,nA=function(){function s(t,n,s,i,a,r){if(r!==e){var o=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw o.name="Invariant Violation",o}}function i(){return s}s.isRequired=s;var a={array:s,bigint:s,bool:s,func:s,number:s,object:s,string:s,symbol:s,any:s,arrayOf:i,element:s,elementType:s,instanceOf:i,node:s,objectOf:i,oneOf:i,oneOfType:i,shape:i,exact:i,checkPropTypes:n,resetWarningCache:t};return a.PropTypes=a,a}}function lA(){return iA||(iA=1,aA.exports=oA()()),aA.exports}const cA=Le(lA()),dA=({size:e=24,color:t="white",opacity:n=.3,className:s="",...i})=>a.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 24 24",fill:"none",className:s,style:{opacity:n},...i,children:[a.jsx("mask",{id:"mask0_3643_39837",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:"0",y:"0",width:"24",height:"24",children:a.jsx("rect",{width:"24",height:"24",fill:"#D9D9D9"})}),a.jsx("g",{mask:"url(#mask0_3643_39837)",children:a.jsx("path",{d:"M6.12129 21.7843C5.58252 21.7843 5.12129 21.5925 4.73762 21.2088C4.35395 20.8251 4.16211 20.3639 4.16211 19.8251V10.0292C4.16211 9.49044 4.35395 9.02922 4.73762 8.64554C5.12129 8.26187 5.58252 8.07003 6.12129 8.07003H7.10089V6.11085C7.10089 4.75575 7.57844 3.60065 8.53354 2.64554C9.48864 1.69044 10.6437 1.21289 11.9988 1.21289C13.3539 1.21289 14.509 1.69044 15.4642 2.64554C16.4193 3.60065 16.8968 4.75575 16.8968 6.11085V8.07003H17.8764C18.4152 8.07003 18.8764 8.26187 19.2601 8.64554C19.6437 9.02922 19.8356 9.49044 19.8356 10.0292V19.8251C19.8356 20.3639 19.6437 20.8251 19.2601 21.2088C18.8764 21.5925 18.4152 21.7843 17.8764 21.7843H6.12129ZM11.9988 16.8864C12.5376 16.8864 12.9988 16.6945 13.3825 16.3109C13.7662 15.9272 13.958 15.466 13.958 14.9272C13.958 14.3884 13.7662 13.9272 13.3825 13.5435C12.9988 13.1598 12.5376 12.968 11.9988 12.968C11.4601 12.968 10.9988 13.1598 10.6152 13.5435C10.2315 13.9272 10.0397 14.3884 10.0397 14.9272C10.0397 15.466 10.2315 15.9272 10.6152 16.3109C10.9988 16.6945 11.4601 16.8864 11.9988 16.8864ZM9.06007 8.07003H14.9376V6.11085C14.9376 5.29452 14.6519 4.60065 14.0805 4.02922C13.509 3.45779 12.8152 3.17207 11.9988 3.17207C11.1825 3.17207 10.4886 3.45779 9.91721 4.02922C9.34578 4.60065 9.06007 5.29452 9.06007 6.11085V8.07003Z",fill:t})})]});dA.propTypes={size:cA.oneOfType([cA.number,cA.string]),color:cA.string,opacity:cA.number,className:cA.string,onClick:cA.func,onMouseEnter:cA.func,onMouseLeave:cA.func,style:cA.object,"aria-label":cA.string,"aria-hidden":cA.bool,role:cA.string,id:cA.string,"data-testid":cA.string};const uA=({size:e=24,width:t,height:n,color:s="#224BC6",className:i})=>{const r=t||e,o=n||e;return a.jsx("svg",{width:r,height:o,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:i,children:a.jsx("path",{d:"M10.8213 5.93167C10.9705 5.48892 11.6047 5.48889 11.7539 5.93167L12.6582 8.61721C13.1079 9.95302 14.1686 11.002 15.5205 11.4463L18.2383 12.3389C18.6866 12.4862 18.6866 13.1134 18.2383 13.2608L15.5205 14.1543C14.1686 14.5986 13.1079 15.6466 12.6582 16.9824L11.7539 19.668C11.6048 20.111 10.9704 20.111 10.8213 19.668L9.917 16.9824C9.46731 15.6467 8.40659 14.5986 7.0547 14.1543L4.33595 13.2608C3.88806 13.1132 3.88798 12.4863 4.33595 12.3389L7.0547 11.4463C8.40665 11.002 9.46729 9.95302 9.917 8.61721L10.8213 5.93167ZM16.8984 4.13284C16.9581 3.95574 17.2118 3.9557 17.2715 4.13284L17.6084 5.13382C17.804 5.71436 18.2649 6.17014 18.8526 6.36331L19.8652 6.69632C20.0445 6.7553 20.0446 7.00555 19.8652 7.06448L18.8526 7.39749C18.2648 7.59072 17.8039 8.04628 17.6084 8.62698L17.2715 9.62698C17.2118 9.80417 16.9581 9.80417 16.8984 9.62698L16.5615 8.62698C16.366 8.04634 15.905 7.59076 15.3174 7.39749L14.3047 7.06448C14.1254 7.00554 14.1254 6.75525 14.3047 6.69632L15.3174 6.36331C15.905 6.1701 16.3659 5.71433 16.5615 5.13382L16.8984 4.13284Z",fill:s})})},pA=({size:e=36,color:t="#E57E5C",className:n="",...s})=>a.jsxs("svg",{width:e,height:e,viewBox:"0 0 36 36",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:n,...s,children:[a.jsx("path",{d:"M17.1016 10.4995C17.1016 10.0025 17.5039 9.6001 18.001 9.6001C18.498 9.6001 18.9004 10.0025 18.9004 10.4995V17.1001H25.501C25.998 17.1001 26.4004 17.5025 26.4004 17.9995C26.4004 18.4966 25.998 18.8989 25.501 18.8989H18.001C17.5039 18.8989 17.1016 18.4966 17.1016 17.9995V10.4995Z",fill:t}),a.jsx("path",{d:"M17.9922 4.50098C21.5724 4.50103 25.0064 5.92262 27.5381 8.4541C30.0698 10.9858 31.4922 14.4206 31.4922 18.001C31.492 21.5811 30.0696 25.0143 27.5381 27.5459C25.0064 30.0775 21.5724 31.5009 17.9922 31.501C17.4954 31.5007 17.0928 31.0965 17.0928 30.5996V30.5967C17.093 30.1 17.4955 29.6966 17.9922 29.6963C21.0938 29.6962 24.0694 28.4645 26.2627 26.2715C28.4559 24.0782 29.6883 21.1027 29.6885 18.001C29.6885 14.8991 28.456 11.9239 26.2627 9.73047C24.0693 7.53708 21.0941 6.30376 17.9922 6.30371C17.7537 6.30356 17.5251 6.20868 17.3564 6.04004C17.1879 5.87138 17.0929 5.64275 17.0928 5.4043V5.40039C17.0928 4.90353 17.4954 4.50129 17.9922 4.50098ZM8.98535 19.5C9.53736 19.5002 9.98409 19.947 9.98438 20.499V24.5H13.9961C14.5482 24.5 14.9958 24.947 14.9961 25.499C14.9961 26.0514 14.5484 26.499 13.9961 26.499H9.98438V30.5C9.98438 31.0522 9.53754 31.4998 8.98535 31.5C8.4331 31.4999 7.98535 31.0523 7.98535 30.5V26.499H3.99512C3.44288 26.4989 2.99609 26.0513 2.99609 25.499C2.99643 24.947 3.44309 24.5001 3.99512 24.5H7.98535V20.499C7.98564 19.947 8.43327 19.5001 8.98535 19.5ZM5.99219 12C6.82052 12.0001 7.49219 12.6716 7.49219 13.5C7.49203 14.3282 6.82043 14.9999 5.99219 15C5.16386 15 4.49235 14.3283 4.49219 13.5C4.49219 12.6716 5.16376 12 5.99219 12ZM8.99414 7.5C9.82257 7.5 10.4941 8.17157 10.4941 9C10.494 9.82829 9.82247 10.5 8.99414 10.5C8.1659 10.4999 7.4943 9.82823 7.49414 9C7.49414 8.17164 8.1658 7.50011 8.99414 7.5ZM13.4941 4.5C14.3226 4.5 14.9941 5.17157 14.9941 6C14.9941 6.82843 14.3226 7.5 13.4941 7.5C12.6658 7.49989 11.9941 6.82836 11.9941 6C11.9941 5.17164 12.6658 4.50011 13.4941 4.5Z",fill:t})]}),mA=Pe.forwardRef(({className:e,...t},n)=>a.jsx(Y,{className:bb("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:a.jsx(K,{className:bb("pointer-events-none block h-4 w-4 rounded-full bg-[#FFFFFF] shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0 ")})}));mA.displayName=Y.displayName;const hA=({width:e=20,height:t=20,fill:n="#E58D73",className:s})=>a.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:t,viewBox:"0 0 20 20",fill:"none",className:s,children:a.jsx("path",{d:"M5.13405 12.64L8.28605 10.88L8.33405 10.72L8.28605 10.64H8.12605L7.59805 10.608L5.80605 10.56L4.23805 10.48L2.71805 10.4L2.33405 10.32L1.99805 9.84L2.03005 9.6L2.35005 9.392L2.81405 9.424L3.82205 9.504L5.34205 9.6L6.44605 9.664L8.07805 9.856H8.33405L8.36605 9.744L8.28605 9.68L8.22205 9.616L6.63805 8.56L4.94205 7.44L4.04605 6.784L3.56605 6.464L3.32605 6.144L3.23005 5.472L3.66205 4.992L4.25405 5.04L4.39805 5.072L4.99005 5.536L6.27005 6.512L7.91805 7.76L8.15805 7.952L8.25405 7.888L8.27005 7.84L8.15805 7.664L7.27805 6L6.31805 4.336L5.88605 3.648L5.77405 3.232C5.72605 3.072 5.71005 2.912 5.71005 2.752L6.19005 2.08L6.47805 2L7.15005 2.096L7.40605 2.32L7.82205 3.28L8.47805 4.768L9.51805 6.784L9.83805 7.392L9.99805 7.936L10.046 8.096H10.158V8.016L10.238 6.864L10.398 5.472L10.558 3.68L10.606 3.168L10.862 2.56L11.342 2.24L11.758 2.416L12.078 2.88L12.03 3.168L11.854 4.4L11.438 6.336L11.198 7.648H11.342L11.502 7.472L12.158 6.608L13.262 5.232L13.742 4.672L14.318 4.08L14.686 3.792H15.374L15.87 4.544L15.646 5.328L14.942 6.224L14.35 6.976L13.502 8.112L12.99 9.024L13.038 9.088H13.15L15.07 8.672L16.094 8.496L17.31 8.288L17.87 8.544L17.934 8.8L17.71 9.344L16.398 9.664L14.862 9.984L12.574 10.512L12.542 10.528L12.574 10.576L13.598 10.672L14.046 10.704H15.134L17.15 10.864L17.678 11.184L17.982 11.616L17.934 11.936L17.118 12.352L16.03 12.096L13.47 11.488L12.606 11.28H12.478V11.344L13.214 12.064L14.542 13.264L16.238 14.816L16.318 15.2L16.11 15.52L15.886 15.488L14.414 14.368L13.838 13.888L12.558 12.8H12.478V12.912L12.766 13.344L14.334 15.696L14.414 16.416L14.302 16.64L13.886 16.8L13.454 16.704L12.526 15.424L11.566 13.984L10.814 12.672L10.734 12.736L10.27 17.568L10.062 17.808L9.58205 18L9.18205 17.68L8.95805 17.2L9.18205 16.208L9.43805 14.928L9.64605 13.904L9.83805 12.64L9.95005 12.224V12.192H9.83805L8.87805 13.52L7.43805 15.488L6.28605 16.704L6.01405 16.816L5.53405 16.576L5.58205 16.128L5.83805 15.76L7.43805 13.712L8.39805 12.448L9.03805 11.712L9.02205 11.632H8.97405L4.75005 14.384L3.99805 14.48L3.67805 14.16L3.71005 13.68L3.87005 13.52L5.15005 12.64H5.13405Z",fill:n})}),xA=wv.common.logoBlue;let fA=null;const gA=({models:e,selectedModelId:t,onModelChange:n,className:s,disabled:i=!1,placeholder:r="Select Model",currentUserTier:o="free",isEmergentUser:l=!1,onUpgradeRequired:c,buttonClassName:d})=>{var u;const[p,m]=Pe.useState(!1),[h,x]=Pe.useState({top:0,left:0,width:320}),[f,g]=Pe.useState(!1),v=Pe.useRef(Math.random().toString(36).substring(2,15)),b=Pe.useRef(null),y=Pe.useRef(null),w=Pe.useRef(null),j=Oe(),C=Ft(),N=Nt(e=>{var t;return null==(t=e.menu)?void 0:t.showModelSelectorTooltip}),F=Nt(e=>{var t;return null==(t=e.menu)?void 0:t.highlightBroMode}),{isOrganizationWorkspace:_}=ev(),k=e.filter(e=>!e.unavailable_tier||o!==e.unavailable_tier),S=e.find(e=>e.id===t),E=()=>{if(!y.current)return;const e=y.current.getBoundingClientRect(),t=Math.min(50*k.length+16,300),n=e.width;let s=e.bottom+8,i=e.left;s+t>window.innerHeight&&(s=e.top-t-8),i+n>window.innerWidth&&(i=window.innerWidth-n-16),i<0&&(i=16),x({top:s,left:i,width:n})};Pe.useEffect(()=>{F&&N?fA||(fA=v.current,E(),m(!0),g(!0)):N&&!Bu("hasSeenModelSelectorTooltip",!1)&&"/"===j.pathname?fA||(fA=v.current,E(),m(!0),qu()):N||fA!==v.current||(fA=null,p&&(m(!1),g(!1)))},[N,j.pathname,F]),Pe.useEffect(()=>()=>{fA===v.current&&(fA=null)},[]),Pe.useEffect(()=>{const e=e=>{if(!b.current||!y.current)return;const t=e.target;!p||b.current.contains(t)||y.current.contains(t)||w.current&&w.current.contains(t)||(m(!1),N&&fA===v.current&&(C(Jf(!1)),fA===v.current&&(fA=null)),f&&(g(!1),C(Qf(!1))))},t=()=>{p&&E()};return p&&(document.addEventListener("mousedown",e),window.addEventListener("scroll",t,!0),window.addEventListener("resize",t)),()=>{document.removeEventListener("mousedown",e),window.removeEventListener("scroll",t,!0),window.removeEventListener("resize",t)}},[p]);const I=t=>{const s=e.find(e=>e.id===t);if(s&&(i=s,!_()&&i.user_tier&&o!==i.user_tier))return c&&c(),void m(!1);var i;n(t),m(!1),N&&(C(Jf(!1)),fA===v.current&&(fA=null)),F&&C(Qf(!1))},A=()=>{qu(),C(Jf(!1)),fA===v.current&&(fA=null)};return a.jsxs("div",{className:bb("relative w-full",s),children:[a.jsxs("button",{ref:y,type:"button",disabled:i,className:bb("h-[56px] bg-[#FFFFFF0A] w-full border border-[#ffffff12] rounded-lg px-4 flex items-center gap-2 transition-colors duration-200 hover:border-[#333]",p&&"border-[#80FFF9] bg-[#5CD2E51A] text-[#80FFF9]",i&&"opacity-50 cursor-not-allowed",d),onClick:e=>{e.stopPropagation(),i||(p||E(),m(!p))},children:[(null==(u=null==S?void 0:S.name.toLowerCase())?void 0:u.includes("composite"))?a.jsx("img",{src:xA,alt:"Emergent Logo",width:20,height:20,className:"hidden md:block"}):(null==S?void 0:S.icon)?a.jsx(S.icon,{className:bb("hidden md:block",p&&"text-[#80FFF9]")}):null,a.jsx("span",{className:bb("text-[#DDDDE6] flex-1 text-[14px] flex flex-nowrap whitespace-nowrap capitalize",p&&"text-[#80FFF9]",!S&&"text-[#999]"),children:S?S.name:r}),a.jsx(Gk,{className:bb("w-5 h-5 transition-transform duration-200 text-[#DDDDE6]",p&&"rotate-180 text-[#80FFF9]")})]}),p&&Be.createPortal(a.jsx("div",{ref:b,className:"fixed z-[9999] bg-[#131314] border border-[#222] rounded-lg shadow-lg overflow-y-auto max-h-[300px]",style:{top:`${h.top}px`,left:`${h.left}px`,width:`${h.width}px`,minWidth:"320px"},children:a.jsx("div",{className:"flex flex-col p-2",children:k.map(e=>{return a.jsx("div",{className:bb("flex items-center px-2 md:min-h-[40px] rounded-[8px] py-[6px] text-[#DDDDE6] hover:bg-[#2D2D2F]/40 font-medium cursor-pointer relative",t===e.id&&"text-[#80FFF9]"),onClick:t=>{t.stopPropagation(),I(e.id)},children:a.jsxs("div",{className:"flex items-start justify-between w-full",children:[a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsx("div",{className:"min-w-[15px] flex items-center justify-center",children:e.name&&e.name.toLowerCase().includes("composite")?a.jsx("div",{className:"w-5 h-5 flex items-center justify-center rounded-[20px] bg-white/10",children:a.jsx("img",{src:xA,alt:"Emergent Logo",width:16,height:16,className:"hidden md:block"})}):e.icon?a.jsx("div",{className:"w-5 h-5 flex items-center justify-center rounded-[20px] bg-white/10",children:a.jsx(e.icon,{className:bb("hidden md:block w-4 h-4",t===e.id&&"text-[#80FFF9]")})}):null}),a.jsxs("div",{className:"flex flex-col",children:[a.jsxs("span",{className:"text-[12px] text-nowrap flex items-center gap-[2px] md:text-[13px] text-[#E8E8E6]",children:[e.name,"pro_mode"==e.user_tier&&a.jsx(uA,{color:"#FF8C66"})]}),e.description&&a.jsx("span",{className:"text-[10px] md:text-[12px] text-[#8A8F98] font-inter",children:e.description})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:["pro_mode"==e.user_tier&&a.jsx("div",{className:"bg-[#FF8C661A] px-[6px] flex items-center justify-center rounded-[6px] h-[18px]",children:a.jsx("span",{className:"text-[#FF8C66] text-xs font-['Inter'] font-medium",children:(n=e.name,"Claude 4.5 Sonnet"===n?"Beta":"PRO")})}),t===e.id&&!e.showNew&&a.jsx(qk,{className:"h-4 w-4 text-[#66EAFF]"})]})]})},e.id);var n})})}),document.body),p&&N&&fA===v.current&&"/"===j.pathname&&Be.createPortal(a.jsxs(zt.div,{ref:w,initial:{opacity:0,x:-6},animate:{opacity:1,x:0},exit:{opacity:0,x:-6},transition:{duration:.3,ease:"easeOut"},className:"fixed z-[9999] max-w-[280px] p-4 bg-[#FFFFFF] border-[#2E2F34] text-white shadow-2xl rounded-[12px]",style:{backdropFilter:"blur(20px)",...(()=>{const e=k.findIndex(e=>e.name.toLowerCase().includes("extended"));if(-1===e)return{top:h.top,left:h.left+340};return{top:h.top+8+40*e+20-60,left:h.left+340}})()},children:[a.jsxs("div",{className:"flex flex-col gap-4",children:[a.jsxs("div",{className:"flex flex-col gap-2",children:[a.jsxs("div",{className:"flex items-center gap-[2px]",children:[a.jsx(hA,{fill:"#000000"}),a.jsx("span",{className:"text-[15px] font-['Inter'] font-semibold text-[#0F0F10]",children:"pro_mode"===o?"Try Now":"Try Claude 4.5 - 1M context"})]}),a.jsx("p",{className:"text-[12px] font-medium font-['Inter'] text-[#0F0F1080] leading-[16px]",children:"pro_mode"===o?"Experience Anthropic's latest 4.5 sonnet model with 1M context window":"Get your hands on Anthropic's latest 4.5 sonnet model with 1M context window"})]}),a.jsx("div",{className:"flex items-center justify-end w-full gap-2",children:a.jsxs("button",{onClick:e=>{e.stopPropagation(),e.preventDefault(),"pro_mode"===o?A():c&&(A(),c())},className:"px-3 py-[6px] flex gap-2 items-center justify-center bg-[#0B0B0B] hover:bg-[#333333] font-['Inter'] rounded-[6px] text-[#FFFFFF] text-[12px] font-medium transition-colors",type:"button",children:["pro_mode"===o?"Try Now":"Upgrade to Pro",a.jsx(uA,{color:"#ffffff"})]})})]}),a.jsxs("div",{className:"absolute z-[999] flex items-center justify-center transform -translate-y-1/2 -left-[24px] top-1/2",children:[a.jsx("div",{className:"w-2 h-2 bg-white rounded-full"}),a.jsx("div",{className:"bg-white min-w-4 min-h-[1px] mr-[2px]"})]})]}),document.body),p&&f&&F&&Be.createPortal(a.jsxs(zt.div,{ref:w,initial:{opacity:0,x:-6},animate:{opacity:1,x:0},exit:{opacity:0,x:-6},transition:{duration:.3,ease:"easeOut"},className:"fixed z-[9999] max-w-[280px] p-3 bg-[#FFFFFF] border-[#2E2F34] text-white shadow-2xl rounded-[12px]",style:{backdropFilter:"blur(20px)",top:h.top+8+0+20-30,left:h.left+340},children:[a.jsxs("div",{className:"flex flex-col gap-3",children:[a.jsxs("div",{className:"flex flex-col gap-1",children:[a.jsx("div",{className:"flex items-center gap-[6px]",children:a.jsx("span",{className:"text-[15px] font-['Inter'] font-semibold text-[#0F0F10]",children:"Try Claude 4.5 Sonnet"})}),a.jsx("p",{className:"text-[12px] font-medium font-['Inter'] text-[#0F0F1080] leading-[16px]",children:"Experience Anthropic's latest 4.5 sonnet model with enhanced reasoning and deep context understanding."})]}),a.jsx("div",{className:"flex items-center justify-end w-full gap-2",children:a.jsxs("button",{onClick:e=>{e.stopPropagation(),e.preventDefault();const t=k.find(e=>"Claude 4.5 Sonnet"===e.name);t&&I(t.id),g(!1),C(Qf(!1)),C(Jf(!1))},className:"px-[8px] py-[2px] flex gap-2 items-center justify-center bg-[#0B0B0B] hover:bg-[#333333] font-['Inter'] rounded-[6px] text-[#FFFFFF] text-[12px] font-medium transition-colors",type:"button",children:["Try Now",a.jsx(uA,{color:"#ffffff",size:20})]})})]}),a.jsxs("div",{className:"absolute z-[999] flex items-center justify-center transform -translate-y-1/2 -left-[24px] top-1/2",children:[a.jsx("div",{className:"w-2 h-2 bg-white rounded-full"}),a.jsx("div",{className:"bg-white min-w-4 min-h-[1px] mr-[2px]"})]})]}),document.body)]})},vA=({privacy:e,iconSize:t=20,textClassName:n="font-medium font-inter text-[#FFFFFF]"})=>a.jsx(a.Fragment,{children:"public"===e?a.jsxs(a.Fragment,{children:[a.jsx(XI,{size:t}),a.jsx("span",{className:n,children:"Public"})]}):a.jsxs(a.Fragment,{children:[a.jsx(dA,{size:t,color:"#ffffff",opacity:1}),a.jsx("span",{className:n,children:"Private"})]})}),bA=wv.common.copyPaperclip,yA=wv.common.logoBlue,wA=wv.common.copperCoin,jA=wv.universal.claude,CA=wv.universal.openai,NA=wv.icons.submit,FA=wv.icons.github,_A=wv.github.githubConnected;let kA=null;const SA=(e,t)=>{var n,s;if(!t)return{model:null,name:null,icon:CA};if("bro-mode"===t)return{model:{id:"bro-mode",name:"Bro Mode",description:"Advanced AI with enhanced reasoning"},name:"Bro Mode",icon:jA};const i=e.find(e=>e.id===t),a=null==i?void 0:i.name,r=(null==(n=null==a?void 0:a.toLowerCase())?void 0:n.includes("composite"))?yA:(null==(s=null==a?void 0:a.toLowerCase())?void 0:s.includes("claude"))?jA:CA;return{model:i,name:a,icon:r}},EA=({value:e,onChange:t,placeholder:n="",maxHeight:s="200px",onAttachClick:i,onSubmit:r,disabled:o,onPaste:l,attachIcon:c,attachTooltip:d,githubTooltip:u,isSubmitting:p,handleSettingsClick:m,handleGithubSettings:h,showGithubSettings:x,showControls:f,className:g,hasUserConnectedGithub:v,githubUrl:b,onClearGithubUrl:y,handleExperimentalChange:w,experimentalEnabled:j,isUploadAssetEnabled:C=!1,userPrompts:N=[],isLoadingUserPrompts:F=!1,selectedCustomAgent:_=null,onCustomAgentChange:k,shouldShowUserPrompts:S=!1,mobileEnabled:E=!1,onMobileEnabled:I,e15Enabled:A=!1,onE15Enabled:T,prototypeEnabled:M=!1,onPrototypeEnabled:D,showMobileAgentIntro:B=!1,onMobileAgentIntroShown:H,selectedImage:$,setSelectedImage:V,globalConfig:U,perInstanceCostLimit:W,setPerInstanceCostLimit:q,availableModels:G=[],selectedModelId:Z,onModelChange:Y,showModelSelector:K=!1,onPrivacyChange:J,ultraMode:Q=!1,onUltraModeChange:X,testMode:ee=!1,onTestModeChange:te,selectedMcpTools:ne=[],onMcpToolsChange:se,onFocusChange:ie,isRecording:ae=!1,isTranscribing:re=!1,onVoiceClick:oe})=>{var le,ce;const{tier:de,isTrulyFreeUser:ue}=sv(),{data:pe}=Sx(),me=iI(),{toast:he}=un(),xe=(()=>{try{const e=Nd.getFeatureFlag("test_mode_enabled");return!0===e||"true"===e}catch(e){return!1}})()&&me,fe=Ft(),ge=Nt(e=>{var t;return null==(t=e.menu)?void 0:t.showModelSelectorTooltip}),ve=Nt(e=>{var t;return null==(t=e.menu)?void 0:t.highlightBroMode}),{isOrganizationWorkspace:be,currentWorkspace:ye}=ev(),{setTabs:we,setActiveTab:je}=Hee(),Ce=Oe(),[Ne,Fe]=Pe.useState(""),[_e,ke]=Pe.useState(!1),Se=Pe.useRef(Math.random().toString(36).substring(2,15)),[Ee,Ie]=Pe.useState(0),[Ae,Te]=Pe.useState(!1),[Me,De]=Pe.useState(!1),[Le,Re]=Pe.useState(),ze=()=>"free"===de,[He,$e]=Pe.useState(()=>void 0!==j?j:ze()),Ve=void 0!==j?j:He;Pe.useEffect(()=>{void 0!==j&&$e(j)},[j]),Pe.useEffect(()=>{if(void 0===j){const e=ze();$e(e)}},[de,j]),Pe.useEffect(()=>{w(!!Ve)},[Ve]);const[Ue,We]=Pe.useState(!1),[qe,Ge]=Pe.useState({top:0,left:0}),[Ze,Ye]=Pe.useState(!1),[Ke,Je]=Pe.useState(!1),[Qe,Xe]=Pe.useState({top:0,left:0}),[et,tt]=Pe.useState("free"===de?"public":"private"),[nt,st]=Pe.useState(!1),it=WE(),at=UE(),[rt,ot]=Pe.useState(!1),[lt,ct]=Pe.useState("main"),{getCurrentOrganizationId:dt}=ev(),ut=dt(),{data:pt}=$f(ut?{organization_id:ut}:void 0,{skip:!1}),mt=W||"5",[ht,xt]=Pe.useState(!1);Pe.useEffect(()=>{J&&J(et)},[et,J]),Pe.useEffect(()=>{tt("free"===de?"public":"private")},[de]);const[ft,gt]=Pe.useState(Bu("hasSeenMobileAgentIntro",!1)),{isMobile:vt}=nI(),bt=Pe.useRef(null),yt=Pe.useRef(null),wt=Pe.useRef(null),jt=Pe.useRef(null),Ct=Pe.useRef(null),_t=(e=>{try{const t=Nd.getFeatureFlag("feature_referral");return!0===t||"true"===t||e}catch(t){return!1}})(me),kt=(e=>{try{const t=Nd.getFeatureFlag("feature_custom_agents");return!0===t||"true"===t||e}catch(t){return!1}})(me)||"pro_mode"===de||(null==pe?void 0:pe.is_pro_enabled),St=Mg(),Et=(null==U?void 0:U.e15_experimental)&&("pro_mode"===de||be()||me),It=null==U?void 0:U.prototype_agent_experimental,At=K&&G.length>0&&!vt,Tt=["a dashboard for...","a beautiful landing page for...","an app for...","a clone of netflix...","a game where..."];Pe.useEffect(()=>{const e=setTimeout(()=>{Lt()},_e?50:100);return()=>clearTimeout(e)},[Ne,_e]),Pe.useEffect(()=>{ve&&ge&&vt&&(ot(!0),ct("models"),setTimeout(()=>{fe(Qf(!1)),fe(Jf(!1))},500))},[ve,ge,vt,fe]);const Mt=()=>{if(!wt.current)return;const e=wt.current.getBoundingClientRect();let t=e.bottom+8,n=e.left;t+120>window.innerHeight&&(t=e.top-120-8),n+180>window.innerWidth&&(n=window.innerWidth-180-16),n<0&&(n=16),Ge({top:t,left:n})},Dt=()=>{if(!Ct.current)return;const e=Ct.current.getBoundingClientRect();let t=e.bottom+8,n=e.left;n+276>window.innerWidth&&(n=window.innerWidth-276-16),t+124>window.innerHeight&&(t=e.top-124-8),n<16&&(n=16),Xe({top:t,left:n})};Pe.useEffect(()=>{const e=e=>{if(!yt.current||!wt.current)return;const t=e.target;!Ue||yt.current.contains(t)||wt.current.contains(t)||We(!1)},t=()=>{Ue&&Mt()};return Ue&&(document.addEventListener("mousedown",e),window.addEventListener("scroll",t,!0),window.addEventListener("resize",t)),()=>{document.removeEventListener("mousedown",e),window.removeEventListener("scroll",t,!0),window.removeEventListener("resize",t)}},[Ue]),Pe.useEffect(()=>{const e=e=>{if(!jt.current||!Ct.current)return;const t=e.target;!Ke||jt.current.contains(t)||Ct.current.contains(t)||Je(!1)},t=()=>{Ke&&Dt()};return Ke&&(document.addEventListener("mousedown",e),window.addEventListener("scroll",t,!0),window.addEventListener("resize",t)),()=>{document.removeEventListener("mousedown",e),window.removeEventListener("scroll",t,!0),window.removeEventListener("resize",t)}},[Ke]),Pe.useEffect(()=>{B&&!ft&&(Mt(),We(!0),setTimeout(()=>{xt(!0)},300),null==H||H())},[B,ft,H]),Pe.useEffect(()=>{ge&&K&&G.length>0&&"/"===Ce.pathname?vt&&(kA||(kA=Se.current,ct("main"),ot(!0)),fe(Jf(!1))):ge||kA!==Se.current||(kA=null)},[ge,vt,K,G.length,fe,Ce.pathname]),Pe.useEffect(()=>()=>{kA===Se.current&&(kA=null)},[]);const Lt=()=>{const e=Tt[Ee%Tt.length];if(_e||Ne!==e)return _e&&""===Ne?(ke(!1),void Ie(Ee+1)):void Fe(_e?e.substring(0,Ne.length-1):e.substring(0,Ne.length+1));setTimeout(()=>{ke(!0)},2e3)};Pe.useEffect(()=>{const e=bt.current;if(e){e.style.height="auto";const t=Math.min(e.scrollHeight,parseInt(s));e.style.height=`${t}px`}},[e,s]),Pe.useEffect(()=>{if(!f){const e=setInterval(()=>{De(e=>!e)},1e3);return()=>clearInterval(e)}},[f]);const Pt=()=>{const e=`create-agent-${Date.now()}-${Math.random().toString(36).substring(2,11)}`;we(t=>[...t,{id:e,title:"Create New Agent",tabHeading:"Create New Agent",path:"/create-agent",level:"personal"!==ye?"organization":"user",organization_id:"personal"!==ye?ye:void 0,state:{tabId:e,fromTextarea:!0,workspaceContext:{isOrganizationWorkspace:"personal"!==ye,currentOrganizationId:"personal"!==ye?ye:void 0}}}]),je(e),We(!1)},Rt=()=>{be()?it.open({initialTab:"shared-agents"}):it.open({initialTab:"manage-agents"}),We(!1)},Ot=Pe.useCallback(()=>{xt(!1),gt(!0),zu("hasSeenMobileAgentIntro",!0)},[]),zt=e=>{e.stopPropagation(),$e(!1),w(!1),null==k||k(null),We(!1),I(!0),T(!1),D(!1)},Bt=e=>{let t="Custom Agent";return"base_main_prompt"==e?t="React + FastAPI Agent":"base_main_nextjs_prompt"==e?t="NextJS Agent":"base_main_expo_prompt"==e?t="Mobile Agent":"base_python_prompt"==e&&(t="Python Agent"),t};return a.jsxs(a.Fragment,{children:[Le&&vt&&a.jsx("div",{className:"fixed top-0 bottom-0 z-[-1] left-0 right-0 w-full h-full bg-black/20 backdrop-blur-lg"}),a.jsxs("div",{className:bb(`${g} relative rounded-t-[18px] md:rounded-[18px] z-[1] w-full overflow-clip ${Ae?"ring-2 ring-[#80FFF9] ring-opacity-70":""} flex flex-col justify-between border border-[#333333] bg-[#18181A]`),onDragOver:e=>{e.preventDefault(),e.stopPropagation()},onDragEnter:e=>{e.preventDefault(),e.stopPropagation(),Te(!0)},onDragLeave:e=>{e.preventDefault(),e.stopPropagation(),e.currentTarget.contains(e.relatedTarget)||Te(!1)},onDrop:e=>{e.preventDefault(),e.stopPropagation(),Te(!1);const t=e.dataTransfer.files;if(t.length>0){const e=new Event("custom-file-drop",{bubbles:!0});if(Object.defineProperty(e,"files",{value:t,writable:!1}),document.dispatchEvent(e),l){const e={clipboardData:{files:t,items:Array.from(t).map(e=>({kind:"file",type:e.type,getAsFile:()=>e}))},preventDefault:()=>{}};l(e)}else i()}},children:[Ae&&a.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-[#141415]/90 rounded-[18px]",children:a.jsx("div",{className:"text-[#80FFF9] text-center",children:a.jsx("p",{className:"font-medium font-brockmann",children:"Drop files here"})})}),a.jsx(_E,{id:"mainTaskInput",ref:bt,value:e,onChange:t,onKeyDown:e=>{"Enter"===e.key&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),o||p||r())},onFocus:()=>{Re(!0),null==ie||ie(!0)},onBlur:()=>{Re(!1),null==ie||ie(!1)},placeholder:"",className:bb("h-full relative w-full bg-[#18181A] rounded-t-[18px] text-[16px] resize-none min-h-[120px] md:min-h-[100px] p-3 pb-4 md:p-4 border-0 focus:ring-0 focus-visible:ring-0 focus-visible:ring-offset-0 caret-[#80FFF9] font-brockmann font-medium overflow-auto",Le&&"max-md:mt-[68px]"),onPaste:l,style:{maxHeight:s,transition:"height 0.1s ease-out"}}),a.jsx("button",{type:"button",className:bb("absolute rounded-full top-2.5 left-2.5 size-9 items-center justify-center bg-white/5 hidden",Le&&"max-md:flex max-md:visible"),title:"Close Dropdown",onClick:()=>{Re(!1)},children:a.jsx(HS,{size:20})}),""===e&&a.jsx("div",{className:bb("absolute top-0 left-0 max-md:p-3 md:p-4 pointer-events-none text-white/30 font-[Inter] font-medium text-[16px]",Le&&"max-md:top-[68px]"),children:a.jsx("span",{children:`Build me ${Ne}`})}),a.jsxs("div",{className:"flex items-center justify-between w-full p-2.5 bg-[#18181A] ",children:[a.jsxs("div",{className:"flex flex-row items-center gap-2",children:[a.jsx("div",{className:"rounded-lg bg-none",children:a.jsxs(L,{children:[a.jsx(P,{asChild:!0,children:a.jsx("button",{className:bb("p-2 pointer-events-auto rounded-[30px] group/paperclip flex items-center justify-center size-9 hover:bg-white/10 bg-white bg-opacity-5 "),type:"button",onClick:i,children:a.jsx("img",{src:bA,alt:"Attach",className:"transition-transform duration-200 transform min-w-4 min-h-4 md:size-5 group-hover/paperclip:rotate-45"})})}),d&&a.jsx(R,{children:a.jsx(O,{className:"max-w-xs bg-[#fff] text-[#0f0f10] font-medium tracking-[-0.3px] text-sm px-4 py-2.5 rounded-lg shadow-lg z-[9999]",sideOffset:5,asChild:!0,children:a.jsxs(Tk.div,{initial:{opacity:0,y:-2,scale:1},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-10,scale:1},transition:{type:"tween",ease:"easeOut",duration:.4},children:[d,a.jsx(z,{className:"fill-[#fff]"})]})})})]})}),a.jsx("div",{className:"relative rounded-lg max-md:hidden bg-none",children:a.jsx(TE,{isConnected:v||!!b,isActive:x||!!b,githubUrl:b,githubTooltip:u,handleGithubSettings:h||(()=>{}),onClearGithubUrl:y})}),!ue()&&a.jsx("div",{className:"relative rounded-lg bg-none",children:a.jsxs("button",{ref:wt,type:"button",className:bb("p-2 pl-3 h-9 max-w-[150px] min-w-0 flex items-center gap-1.5 transition-colors duration-200 rounded-[30px] bg-white/5 hover:bg-white/10 ",Ue&&"bg-[#80FFF91A] text-[#80FFF9]"),onClick:e=>{e.stopPropagation(),vt?Ye(!0):(Ue||Mt(),We(!Ue))},children:[a.jsx(BE,{size:20,className:bb("shrink-0",Ue&&"text-[#80FFF9]"),primaryColor:Ue?"#80FFF9":"#fff"}),a.jsxs("span",{className:bb("grow text-[#E6E6E6] text-[12px] md:text-[14px] whitespace-nowrap capitalize truncate",Ue&&"text-[#80FFF9]"),children:[_&&((null==(le=N.find(e=>e.id===_))?void 0:le.prompt_name.replaceAll("_user"," ").replaceAll("_"," "))||"Custom Agent"),!_&&!E&&!A&&!M&&a.jsxs(a.Fragment,{children:["E-1",Ve?a.jsx("span",{children:".1"}):""]}),!_&&A&&!M&&a.jsx(a.Fragment,{children:"E-1.5"}),!_&&M&&a.jsx(a.Fragment,{children:"Prototype"}),!_&&E&&!M&&a.jsx(a.Fragment,{children:"Mobile"})]}),a.jsx(Gk,{className:"shrink-0 size-4 opacity-30 transition-transform duration-200 "+(Ue?"rotate-180":"")})]})}),!ue()&&!vt&&a.jsx("div",{className:"relative rounded-lg bg-none",children:a.jsx(ME,{children:a.jsxs(L,{delayDuration:0,children:[a.jsx(P,{asChild:!0,children:a.jsxs("div",{title:"Fix",className:bb("transition-colors duration-200 hover:opacity-80 h-9 text-[14px] font-medium flex items-center gap-1 hover:bg-[#FFFFFF]/10 p-2 rounded-full cursor-pointer",Q?"bg-[#FF8C661A]":"bg-[#FFFFFF0D]"),onClick:e=>{e.preventDefault(),"pro_mode"===de||be()?null==X||X(!Q):(ot(!1),at.open({triggerLocation:"default"}))},children:[a.jsx(pA,{size:20,color:Q?"#FF8C66":"#E6E6E6"})," ",a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsxs("div",{className:bb("flex items-center gap-[2px]",Q?"text-[#FF8C66]":""),children:[" ","Ultra"]})," ",a.jsx(mA,{checked:Q,onCheckedChange:e=>{"pro_mode"===de||be()?null==X||X(e):(ot(!1),at.open({triggerLocation:"default"}))},onClick:e=>e.stopPropagation(),className:"data-[state=unchecked]:bg-[#3B3B3B] data-[state=checked]:bg-[#FF8C66] scale-[0.8]"})]})]})}),a.jsx(O,{className:" bg-[#fff] text-[#0f0f10] font-medium tracking-[-0.3px] text-sm px-4 py-2.5 rounded-lg shadow-lg z-[9999] max-w-[200px]",sideOffset:5,asChild:!0,children:a.jsxs(Tk.div,{initial:{opacity:0,y:-2,scale:1},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-10,scale:1},transition:{type:"tween",ease:"easeOut",duration:.4},children:[a.jsxs("div",{className:"flex flex-col gap-1",children:[a.jsx("div",{className:"font-semibold font-inter",children:"Ultra thinking with 16k thinking tokens"}),a.jsx("div",{className:"text-xs opacity-50 font-inter text-[#0F0F10]",children:"Allow agent to reason deeply through complex problems"})]}),a.jsx(z,{className:"fill-[#fff]"})]})})]})})}),vt&&Q&&a.jsxs("button",{title:"Ultra Thinking",type:"button",className:bb("transition-colors duration-200 hover:opacity-80 h-[40px] w-[40px] justify-center flex items-center gap-[6px] hover:bg-[#FFFFFF]/10 p-2 rounded-full",Q?"bg-[#FF8C661A]":"bg-[#FFFFFF0D]"),onClick:e=>{e.preventDefault(),"pro_mode"===de||be()?null==X||X(!Q):(ot(!1),at.open({triggerLocation:"default"}))},children:[a.jsx(pA,{size:20,color:Q?"#FF8C66":"#E6E6E6"})," "]}),At&&a.jsx("div",{className:"relative rounded-full bg-none",children:a.jsx(gA,{models:G,selectedModelId:Z,onModelChange:Y||(()=>{}),buttonClassName:"rounded-full p-2 max-h-9 bg-white/5 border-none gap-1 [&>svg:last-child]:opacity-30 [&>svg:last-child]:size-4 [&>svg:last-child]:ml-0.5",className:"max-h-9",currentUserTier:de,isEmergentUser:me,onUpgradeRequired:()=>at.open({})})}),Ue&&!vt&&Be.createPortal(a.jsx("div",{ref:yt,className:"fixed z-[9999] md:w-[300px] bg-[#191918] border border-[#303030] rounded-[10px] shadow-lg overflow-y-auto model-dropdown max-h-[300px]",style:{top:`${qe.top}px`,left:`${qe.left}px`},children:a.jsxs("div",{className:"flex flex-col p-2",children:[a.jsx("div",{className:bb("px-2 md:min-h-[40px] rounded-[8px] py-[6px] text-[#DDDDE6] hover:bg-[#2D2D2F]/40 font-medium cursor-pointer",!Ve&&!E&&!A&&!M&&!_&&" text-[#80FFF9]"),onClick:e=>{e.stopPropagation(),$e(!1),w(!1),null==k||k(null),We(!1),I(!1),T(!1),D(!1)},children:a.jsxs("div",{className:"flex items-center justify-between w-full",children:[a.jsxs("div",{className:"flex flex-col",children:[a.jsx("span",{className:"text-[12px] md:text-[13px] text-[#E8E8E6]",children:"E-1"}),a.jsx("span",{className:"text-[10px] md:text-[12px] text-[#8A8F98] font-inter",children:"Stable & thorough"})]}),!Ve&&!E&&!A&&!M&&!_&&a.jsx(qk,{className:"h-4 w-4 text-[#66EAFF]"})]})}),a.jsx("div",{className:bb("px-2 min-h-[40px] rounded-[8px] py-[6px] text-[#DDDDE6] hover:bg-[#2D2D2F]/40 font-medium cursor-pointer",Ve&&!E&&!A&&!M&&!_&&" text-[#80FFF9]"),onClick:e=>{e.stopPropagation(),$e(!0),w(!0),null==k||k(null),We(!1),I(!1),T(!1),D(!1)},children:a.jsxs("div",{className:"flex items-center justify-between w-full",children:[a.jsxs("div",{className:"flex flex-col",children:[a.jsx("span",{className:"flex items-center text-[12px] md:text-[13px] text-[#E8E8E6]",children:"E-1.1"}),a.jsx("span",{className:"text-[10px] md:text-[12px] text-[#FFFFFF]/50 font-inter",children:"Fast & flexible"})]}),Ve&&!A&&!M&&!_&&a.jsx(qk,{className:"h-4 w-4 text-[#80FFF9]"})]})}),Et&&a.jsx("div",{className:bb("px-2 min-h-[40px] rounded-[8px] py-[6px] text-[#DDDDE6] hover:bg-[#2D2D2F]/40 font-medium cursor-pointer",A&&!E&&!M&&!_&&" text-[#80FFF9]"),onClick:e=>{e.stopPropagation(),$e(!1),w(!1),null==k||k(null),We(!1),I(!1),T(!0),D(!1)},children:a.jsxs("div",{className:"flex items-center justify-between w-full",children:[a.jsxs("div",{className:"flex flex-col",children:[a.jsx("span",{className:"flex items-center text-[12px] md:text-[13px] text-[#E8E8E6]",children:"E-1.5"}),a.jsx("span",{className:"text-[10px] md:text-[12px] text-[#FFFFFF]/50 font-inter",children:"Focused & Diligent"})]}),A&&!_?a.jsx(qk,{className:"h-4 w-4 text-[#80FFF9]"}):a.jsx("span",{className:"text-[12px] bg-[#F49B571A] text-[#F49B57] rounded-full px-2 py-[2px]",children:"Beta"})]})}),It&&a.jsx("div",{className:bb("px-2 min-h-[40px] rounded-[8px] py-[6px] text-[#DDDDE6] hover:bg-[#2D2D2F]/40 font-medium cursor-pointer",M&&!E&&!_&&" text-[#80FFF9]"),onClick:e=>{e.stopPropagation(),$e(!1),w(!1),null==k||k(null),We(!1),I(!1),T(!1),D(!0)},children:a.jsxs("div",{className:"flex items-center justify-between w-full",children:[a.jsxs("div",{className:"flex flex-col",children:[a.jsx("span",{className:"flex items-center text-[12px] md:text-[13px] text-[#E8E8E6]",children:"Prototype"}),a.jsx("span",{className:"text-[10px] md:text-[12px] text-[#FFFFFF]/50 font-inter",children:"Frontend Only Apps"})]}),M&&!_&&a.jsx(qk,{className:"h-4 w-4 text-[#80FFF9]"})]})}),a.jsx(ME,{children:a.jsxs(L,{open:!vt&&ht||void 0,delayDuration:ft?0:9999999,children:[a.jsx(P,{asChild:!0,children:a.jsx("div",{className:bb("relative transition-all duration-200",ht?"before:absolute before:inset-[-4px] bg-[#2D2D2F]/40 rounded-[8px] before:shadow-lg before:pointer-events-none":""),children:a.jsx("div",{className:bb("px-2 min-h-[40px] rounded-[8px] py-[6px] text-[#DDDDE6] hover:bg-[#2D2D2F]/40 font-medium cursor-pointer",E&&!_&&" text-[#80FFF9]"),onClick:e=>{ht&&Ot(),zt(e)},children:a.jsxs("div",{className:"flex items-center justify-between w-full",children:[a.jsxs("div",{className:"flex flex-col",children:[a.jsx("span",{className:"flex items-center text-[12px] md:text-[13px] text-[#E8E8E6]",children:"Mobile"}),a.jsx("span",{className:"text-[10px] md:text-[12px] text-[#FFFFFF]/50 font-inter",children:"Agent for mobile apps"})]}),E&&!_&&a.jsx(qk,{className:"h-4 w-4 text-[#80FFF9]"})]})})})}),a.jsx(O,{side:"right",align:"center",sideOffset:30,className:bb(ft?"bg-[#DDDDE6] font-['Inter'] text-black border-0":"relative p-0 bg-none border-none bg-transparent"),children:ft?null:a.jsxs(Tk.div,{initial:{opacity:0,x:-6},animate:{opacity:1,x:0},exit:{opacity:0,x:-6},transition:{duration:.3,ease:"easeOut"},className:"max-w-[280px] p-4 bg-[#FFFFFF] border-[#2E2F34] text-white shadow-2xl rounded-[12px]",style:{backdropFilter:"blur(20px)"},children:[a.jsxs("div",{className:"flex flex-col gap-4",children:[a.jsxs("div",{className:"flex flex-col gap-2",children:[a.jsx("div",{className:"flex items-center justify-between",children:a.jsx("span",{className:"text-[16px] font-['Inter'] font-semibold text-[#0F0F10]",children:"Introducing Mobile agent"})}),a.jsx("p",{className:"text-[12px] font-medium font-['Inter'] text-[#0F0F1080] leading-[16px]",children:"Select “Mobile” agent from the agent dropdown and start building mobile apps."})]}),a.jsxs("div",{className:"flex items-center justify-end w-full gap-2",children:[a.jsx("button",{onClick:()=>{window.open(mv,"_blank")},className:"px-3 py-[6px] bg-[#0B0B0B24] hover:bg-[#0B0B0B]/20 font-['Inter'] rounded-[6px] text-[#000000]/50 text-[12px] font-medium transition-colors",type:"button",children:"Learn More"}),a.jsx("button",{onClick:e=>{e.stopPropagation(),Ot()},className:"px-3 py-[6px] bg-[#0B0B0B] hover:bg-[#333333] font-['Inter'] rounded-[6px] text-[#FFFFFF] text-[12px] font-medium transition-colors",type:"button",children:"Okay, Got it"})]})]}),a.jsxs("div",{className:"absolute z-[999] flex items-center justify-center transform -translate-y-1/2 -left-[24px] top-1/2",children:[a.jsx("div",{className:"w-2 h-2 bg-white rounded-full"}),a.jsx("div",{className:"bg-white min-w-4 min-h-[1px] mr-[2px]"})]})]})})]})}),(S||be())&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"h-px bg-[#242424] my-2"}),F&&a.jsx("div",{className:"px-3 py-2 text-[#8A8F98] text-[12px] md:text-[13px]",children:"Loading custom agents..."}),!F&&N.map(e=>a.jsx("div",{className:bb("px-2 min-h-[40px] rounded-[8px] py-[6px] text-[#DDDDE6] hover:bg-[#2D2D2F]/40 font-medium cursor-pointer",_===e.id&&" text-[#80FFF9]"),onClick:t=>{t.stopPropagation(),null==k||k(e.id),We(!1)},children:a.jsxs("div",{className:"flex items-center justify-between w-full",children:[a.jsxs("div",{className:"flex flex-col",children:[a.jsx("span",{className:"text-[12px] md:text-[13px] truncate max-w-[160px] capitalize",children:e.prompt_name.replaceAll("_"," ").replaceAll("_user","")}),a.jsx("span",{className:"text-[10px] md:text-[12px] text-[#FFFFFF]/50",children:Bt(e.parent_prompt)})]}),_===e.id&&a.jsx(qk,{className:"h-4 w-4 text-[#80FFF9] flex-shrink-0"})]})},e.id)),!F&&N.length>0&&a.jsx(a.Fragment,{children:a.jsx("div",{className:"h-px bg-[#242424] my-2"})}),a.jsxs("div",{className:"px-2 py-[6px] text-[#DDDDE6] group hover:bg-[#F8FF990F] font-medium cursor-pointer rounded-[8px] flex items-center gap-2",onClick:e=>{e.stopPropagation(),Pt()},children:[a.jsx(NS,{className:"w-4 h-4 group-hover:text-[#F8FF99] text-[#E8E8E6]"}),a.jsx("span",{className:"text-[13px] group-hover:text-[#F8FF99] md:text-[13px]",children:"Create New Agent"})]}),a.jsxs("div",{className:"px-2 py-[6px] justify-between text-[#DDDDE6] hover:bg-[#2D2D2F]/40 font-medium cursor-pointer rounded-[8px] flex items-center gap-2",onClick:e=>{e.stopPropagation(),Rt()},children:[a.jsxs("div",{className:"flex items-center gap-[6px]",children:[a.jsx(zE,{size:16,color:"#E8E8E6"}),a.jsxs("span",{className:"text-[12px] md:text-[13px]",children:[" ","Manage Agents"]})]}),a.jsx(tI,{})]})]})]})}),document.body),St&&Ke&&!vt&&Be.createPortal(a.jsxs("div",{ref:jt,className:"fixed z-[9999] bg-[#18181A] border border-[#242424] rounded-[12px] shadow-lg overflow-hidden",style:{top:`${Qe.top}px`,left:`${Qe.left}px`},children:[a.jsxs("div",{className:"flex items-center px-4 py-3 hover:bg-[#242424] cursor-pointer transition-colors",onClick:()=>{Cg("privacy_selection_changed",{selectedPrivacy:"public",previousPrivacy:et,source:"dropdown",userTier:de}),tt("public"),Je(!1)},children:[a.jsx("div",{className:"min-w-[20px] min-h-[20px] max-w-[20px] max-h-[20px] rounded-full border border-white flex items-center justify-center mr-4",children:"public"===et&&a.jsx("div",{className:"w-[10px] h-[10px] rounded-full bg-[#D9D9D9]"})}),a.jsxs("div",{className:"flex flex-col gap-[2px]",children:[a.jsxs("div",{className:bb("flex items-center gap-1 text-sm font-medium text-white/60","public"===et&&"text-white"),children:["Public"," ",a.jsx(XI,{size:14,className:bb("public"!==et&&"opacity-60")})]}),a.jsx("div",{className:bb("text-xs text-white/50","public"===et&&"text-white"),children:"Anyone can view and explore"})]})]}),a.jsxs("div",{className:"flex items-center px-4 py-3 hover:bg-[#242424] cursor-pointer transition-colors",onClick:()=>{Cg("privacy_selection_changed",{selectedPrivacy:"private",previousPrivacy:et,source:"dropdown",userTier:de,wasBlocked:"free"===de}),"free"===de?(st(!1),at.open({triggerLocation:"default"})):tt("private"),Je(!1)},children:[a.jsx("div",{className:"min-w-[20px] min-h-[20px] max-w-[20px] max-h-[20px] rounded-full border border-white flex items-center justify-center mr-4",children:"private"===et&&a.jsx("div",{className:"w-[10px] h-[10px] rounded-full bg-[#D9D9D9]"})}),a.jsx("div",{className:"flex items-center",children:a.jsxs("div",{className:"flex flex-col gap-[2px]",children:[a.jsxs("div",{className:bb("flex items-center gap-1 text-sm font-medium text-white/60","private"===et&&"text-white"),children:["Private"," ",a.jsx(dA,{size:14,opacity:"private"===et?1:.3})]}),a.jsx("div",{className:bb("text-xs text-white/50","private"===et&&"text-white"),children:"Only visible to yourself, unless shared"})]})})]})]}),document.body)]}),a.jsxs("div",{className:"flex items-center gap-2",children:[St&&"free"===de&&a.jsxs("button",{ref:Ct,type:"button",className:bb("rounded-full gap-1 h-9 max-md:w-9 flex items-center justify-center p-2 text-[12px] md:text-[14px] font-medium transition-colors","free"===de?Ke?"bg-[#80FFF91A] text-[#80FFF9] hover:bg-white/10":"bg-[#FFFFFF0D] text-[#E6E6E6] hover:bg-white/10":"bg-[#FFFFFF0D] text-[#E6E6E6] cursor-default opacity-80"),onClick:e=>{e.stopPropagation(),Cg("privacy_button_clicked",{currentPrivacy:et,userTier:de,isFreeUser:"free"===de,isMobile:vt,action:"free"!==de?"disabled_click":vt?"open_mobile_sheet":"toggle_dropdown"}),"free"===de&&(vt?st(!0):(Ke||Dt(),Je(!Ke)))},children:["public"===et?a.jsx(XI,{size:20,color:Ke?"#80FFF9":void 0}):a.jsx(dA,{size:18,color:Ke?"#80FFF9":"#ffffff",opacity:1}),!vt&&("public"===et?"Public":"Private")]}),a.jsx(ME,{children:a.jsxs(L,{delayDuration:0,children:[a.jsx(P,{asChild:!0,children:a.jsx("button",{className:bb("p-2 rounded-full flex items-center justify-center hover:bg-white/10 ","size-9",f?"bg-[#66EAFF0D] border-[#66EAFF1F] border-[1px]":"bg-white bg-opacity-5"),type:"button",onClick:()=>{vt?(ct("main"),ot(!0)):null==m||m(),bg(sE.ADVANCED_CONTROL_CLICKED)},children:a.jsx(Tk.div,{initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},transition:{duration:.3,ease:"easeOut"},children:f?a.jsx(JI,{color:"#66eaff",size:18}):Me?a.jsx(QI,{size:18}):a.jsx(JI,{className:"w-6 h-6 max-md",color:"#ccc",size:18})},f?"options":Me?"mcp":"options")})}),a.jsx(O,{className:"max-w-xs bg-[#fff] text-[#0f0f10] font-medium tracking-[-0.3px] text-sm px-4 py-2.5 rounded-lg shadow-lg z-[9999]",sideOffset:5,asChild:!0,children:a.jsxs(Tk.div,{initial:{opacity:0,y:-2,scale:1},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-10,scale:1},transition:{type:"tween",ease:"easeOut",duration:.4},children:["Advanced Controls",a.jsx(z,{className:"fill-[#fff]"})]})})]})}),oe&&a.jsx("div",{className:"rounded-lg bg-none",children:a.jsxs(L,{children:[a.jsx(P,{asChild:!0,children:a.jsx("button",{className:bb("p-2 pointer-events-auto rounded-[30px] flex items-center justify-center size-9 transition-colors duration-200",ae?"bg-white text-black hover:bg-white":"bg-white bg-opacity-5 hover:bg-white hover:bg-opacity-5",re&&"opacity-50 cursor-not-allowed"),type:"button",onClick:()=>{Og(ae?"recording_stopped":"recording_started",{component:"TextareaWithAttachmentV2"}),oe()},disabled:re,children:re?a.jsx(gS,{className:"w-4 h-4 md:w-5 md:h-5 animate-spin"}):ae?a.jsx(Tk.div,{animate:{scale:[1,1.2,1]},transition:{duration:1.5,repeat:1/0,ease:"easeInOut"},children:a.jsx(EE,{width:"16",height:"16",fill:"currentColor",className:"md:size-[18px]"})}):a.jsx(SE,{width:"16",height:"16",fill:"currentColor",className:"md:size-[18px]"})})}),a.jsx(R,{children:a.jsx(O,{className:"max-w-xs bg-[#fff] text-[#0f0f10] font-medium tracking-[-0.3px] text-sm px-4 py-2.5 rounded-lg shadow-lg z-[9999]",sideOffset:5,asChild:!0,children:a.jsxs(Tk.div,{initial:{opacity:0,y:-2,scale:1},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-10,scale:1},transition:{type:"tween",ease:"easeOut",duration:.4},children:[re?"Transcribing audio...":ae?"Stop recording":"Start voice recording",a.jsx(z,{className:"fill-[#fff]"})]})})})]})}),a.jsx(Nb,{disabled:o,className:"px-[24px] md:py-[8px] rounded-[30px] h-9 w-[44px] md:w-[56px] text-white transition-colors bg-[#ECECEC] flex items-center justify-center",onClick:r,type:"button",children:a.jsx("div",{className:"flex items-center justify-center w-full",children:p?a.jsx(gS,{className:"w-5 h-5 text-black animate-spin"}):a.jsx("img",{src:NA,alt:"Submit",className:"min-w-6 min-h-6 max-w-6 max-h-6"})})})]})]}),!_t&&!kt&&a.jsx(kE,{size:250,duration:12,delay:9,colorFrom:"#80FFF9",colorTo:"transparent"}),a.jsx(ZI,{open:rt,onOpenChange:e=>{ot(e),e||ct("main")},trigger:a.jsx("div",{}),showDefaultFooter:!1,contentPadding:"p-0",maxWidth:"max-w-full",children:a.jsxs("div",{className:"max-h-[70vh] pb-4 overflow-y-auto bg-[#111112] rounded-t-[24px]",children:[a.jsxs("div",{className:"flex items-center sticky z-[100] top-0 justify-center w-full py-4 border-b border-[#242424] bg-[#111112]",children:["main"!==lt&&a.jsx(Nb,{variant:"ghost",size:"sm",onClick:()=>ct("main"),className:"absolute w-8 h-8 p-1 left-4 hover:bg-white/10",children:a.jsx(KI,{})}),a.jsx("span",{className:"font-medium font-inter text-[18px]",children:"main"===lt?"Advanced Controls":"models"===lt?"Select Model":"templates"===lt?"Select Template":"mcp-tools"===lt?"Select MCP Tools":"Custom Agents"}),a.jsx("button",{type:"button",title:"Close",onClick:()=>{ot(!1)},className:"absolute p-1 rounded-full top-4 right-4 bg-white/5 hover:bg-white/10",children:a.jsx(HS,{className:"w-4 h-4"})})]}),"main"===lt&&a.jsxs("div",{className:"p-4 space-y-4 text-white",children:[a.jsxs("div",{title:"Ultra Mode",className:bb("transition-colors duration-200 w-full hover:opacity-80 min-h-[40px] text-[16px] font-medium flex items-center gap-[6px] p-4 rounded-[8px] justify-between cursor-pointer",Q?"bg-[#FF8C661A]":"bg-[#FFFFFF0D]"),onClick:e=>{e.preventDefault(),"pro_mode"===de||be()?null==X||X(!Q):(ot(!1),at.open({triggerLocation:"default"}))},children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(pA,{size:24,color:Q?"#FF8C66":"#E6E6E6"}),a.jsxs("div",{className:bb("flex items-center font-inter font-medium gap-[2px]",Q?"text-[#FF8C66]":""),children:["Ultra thinking ",a.jsx(uA,{color:"#FF8C66",size:20})]})]}),a.jsx(mA,{checked:Q,onCheckedChange:e=>{"pro_mode"===de||be()?null==X||X(e):(ot(!1),at.open({triggerLocation:"default"}))},onClick:e=>e.stopPropagation(),className:"data-[state=unchecked]:bg-[#3B3B3B] data-[state=checked]:bg-[#FF8C66]"})]}),xe&&a.jsxs("div",{title:"Test Mode",className:bb("transition-colors duration-200 w-full hover:opacity-80 min-h-[40px] text-[16px] font-medium flex items-center gap-[6px] p-4 rounded-[8px] justify-between cursor-pointer",ee?"bg-[#66EAFF1A]":"bg-[#FFFFFF0D]"),onClick:e=>{e.preventDefault(),null==te||te(!ee)},children:[a.jsx("div",{className:"flex items-center gap-2",children:a.jsx("div",{className:bb("flex items-center font-inter font-medium gap-[2px]",ee?"text-[#66EAFF]":""),children:"Test Mode"})}),a.jsx(mA,{checked:ee,onCheckedChange:e=>{null==te||te(e)},onClick:e=>e.stopPropagation(),className:"data-[state=unchecked]:bg-[#3B3B3B] data-[state=checked]:bg-[#66EAFF]"})]}),K&&G.length>0&&a.jsx("div",{className:"flex w-full",onClick:()=>ct("models"),children:a.jsxs("div",{className:"flex flex-col w-full gap-2",children:[a.jsx("span",{className:"font-medium text-[#898F99] text-[14px] font-inter",children:"Select Model"}),a.jsxs("div",{className:" rounded-[12px] p-3 px-4 border border-[#242424] w-full flex items-center justify-between gap-3",children:[(()=>{var e;const t=SA(G,Z);return a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("img",{alt:"Modal Icon",src:t.icon,className:"w-5 h-5"}),a.jsx("span",{className:"font-medium font-inter text-[#FFFFFF]",children:t.name||"Select model"}),"pro_mode"==(null==(e=t.model)?void 0:e.user_tier)&&a.jsx("div",{className:"bg-[#FF8C661A] px-[6px] flex items-center justify-center rounded-[6px] h-[18px]",children:a.jsx("span",{className:"text-[#FF8C66] text-xs font-['Inter'] font-medium",children:"PRO"})})]})})(),a.jsx(KI,{className:"w-4 h-4 rotate-180",color:"#DDDDE6"})]})]})}),a.jsxs("div",{className:"flex flex-col gap-2",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"font-medium text-[#898F99] text-[14px] font-inter",children:"Select MCP Tools"}),a.jsx("span",{className:"font-medium px-2 py-[2px] bg-[#FFBD66] text-[#19191A] rounded-[6px] text-[12px] font-inter",children:"new"})]}),a.jsxs("button",{type:"button",onClick:()=>ct("mcp-tools"),className:bb("w-full rounded-[12px] p-3 px-4 border border-[#242424] text-[#DDDDE6] hover:border-[#333] transition-colors flex items-center justify-between gap-3",ne&&ne.length>0&&"pl-3"),children:[a.jsxs("div",{className:"flex items-center flex-1 gap-3 overflow-hidden",children:[(!ne||0===ne.length)&&a.jsx(OE,{size:20}),a.jsx("div",{className:"flex flex-wrap items-center flex-1 gap-2 overflow-hidden",children:ne&&ne.length>0?a.jsxs("div",{className:"flex flex-wrap items-center flex-1 gap-2 overflow-hidden",children:[ne.slice(0,1).map((e,t)=>{const n=null==pt?void 0:pt.find(t=>t.id===e);return n?a.jsxs("div",{className:"flex items-center gap-2 bg-[#FFFFFF]/10 px-2 py-1 rounded-full",children:[n.icon?a.jsx("img",{src:n.icon,alt:n.display_name,className:"flex-shrink-0 w-4 h-4 rounded-sm"}):a.jsx(OE,{size:16}),a.jsx("span",{className:"text-sm text-[#DDDDE6] flex-shrink-0",children:n.display_name})]},`${e}-${t}`):null}),ne.length>1&&a.jsx("div",{className:"flex items-center gap-2 bg-[#FFFFFF]/10 px-2 py-1 rounded-full",children:a.jsxs("span",{className:"text-sm text-[#DDDDE6]",children:["+",ne.length-1," more"]})})]}):a.jsx("span",{className:"font-medium font-inter text-[#FFFFFF]",children:"Select MCP Tools"})})]}),a.jsx(KI,{className:"flex-shrink-0 w-4 h-4 rotate-180",color:"#DDDDE6"})]})]}),a.jsx("div",{className:"flex",onClick:()=>null==h?void 0:h(),children:a.jsxs("div",{className:"flex flex-col w-full gap-2",children:[a.jsx("span",{className:"font-medium text-[#898F99] text-[14px] font-inter",children:"GitHub"}),a.jsxs("div",{className:" rounded-[12px] p-3 px-4 border border-[#242424] flex items-center justify-between gap-3",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("img",{src:v&&b?_A:FA,alt:"GitHub",className:"w-6 h-6"}),a.jsx("span",{className:"font-medium font-inter text-[#FFFFFF]",children:v?b?b.split("/").pop():"Select repository":"Connect to GitHub"})]}),a.jsx(KI,{className:"w-4 h-4 rotate-180",color:"#DDDDE6"})]})]})}),a.jsx("div",{className:"flex w-full",onClick:()=>ct("templates"),children:a.jsxs("div",{className:"flex flex-col w-full gap-2",children:[a.jsx("span",{className:"font-medium text-[#898F99] text-[14px] font-inter",children:"Select Template"}),a.jsxs("div",{className:" w-full rounded-[12px] p-3 px-4 border flex items-center justify-between gap-2 border-[#242424]",children:[a.jsx("span",{className:"font-medium font-inter text-[#FFFFFF]",children:(()=>{var e;if(!$)return"Default template";const t=null==(e=null==U?void 0:U.templates)?void 0:e.find(e=>e.env_image===$);return(null==t?void 0:t.name)||(null==t?void 0:t.env_image)||$})()}),a.jsx(KI,{className:"w-4 h-4 rotate-180",color:"#DDDDE6"})]})]})}),St&&"free"!==de&&a.jsxs("div",{className:"flex flex-col gap-2",children:[a.jsx("span",{className:"font-medium text-[#898F99] text-[14px] font-inter",children:"Privacy"}),a.jsx("div",{className:"rounded-[12px] p-3 px-4 border border-[#242424] flex items-center gap-3",children:a.jsx(vA,{privacy:et})})]}),a.jsxs("div",{className:"flex flex-col gap-2",children:[a.jsx("span",{className:"font-medium text-[#898F99] text-[14px] font-inter",children:"Budget (Credits)"}),a.jsxs("div",{className:" rounded-[12px] border border-[#242424] relative",children:[a.jsx("button",{type:"button",title:"Decrease budget",onClick:()=>{const e=parseInt(mt);if(e>1){const t=(e-1).toString();null==q||q(t)}},className:"absolute left-3 top-1/2 transform -translate-y-1/2 z-10 w-[32px] h-[32px] flex items-center justify-center text-[#666] hover:text-[#999] transition-colors hover:bg-[#0F181A] rounded-sm",children:a.jsx(yS,{className:"h-4 w-4 text-[#DDDDE6]"})}),a.jsxs("div",{className:"flex items-center justify-center p-3 px-4",children:[a.jsx("img",{alt:"Budget",className:"text-[#B4A456] w-5 h-5 mr-2",src:wA}),a.jsx("input",{type:"number",min:"1",step:"1",value:mt,onChange:e=>{"0"!==e.target.value&&(null==q||q(e.target.value))},placeholder:"5",className:"w-16 bg-transparent text-center focus:outline-none text-[#FFFFFF] font-inter text-lg font-semibold [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none"})]}),a.jsx("button",{type:"button",title:"Increase budget",onClick:()=>{const e=(parseInt(mt)+1).toString();null==q||q(e)},className:"absolute right-3 top-1/2 transform -translate-y-1/2 z-10 w-[32px] h-[32px] flex items-center justify-center text-[#666] hover:text-[#999] transition-colors hover:bg-[#0F181A] rounded-sm",children:a.jsx(NS,{className:"h-4 w-4 text-[#DDDDE6]"})})]})]})]}),"models"===lt&&a.jsx("div",{className:"p-4 space-y-3",children:G.map(e=>a.jsx("div",{className:"p-4 rounded-[12px] cursor-pointer transition-colors bg-[#FFFFFF05]",onClick:()=>{if(!((e,t,n=!1)=>!!n||(e.user_tier?t===e.user_tier:!e.unavailable_tier||t!==e.unavailable_tier))(e,de,be()))return ot(!1),at.open({}),void ct("main");null==Y||Y(e.id),ct("main")},children:a.jsxs("div",{className:"flex items-start justify-between",children:[a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsx("img",{alt:"Logo",className:"w-6 h-6 mt-1",src:SA([e],e.id).icon}),a.jsxs("div",{className:"flex flex-col",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:bb("font-medium font-inter text-[#E6E6E6]",Z===e.id&&"text-[#5CD2E5]"),children:e.name}),"pro_mode"==e.user_tier&&a.jsx("div",{className:"bg-[#FF8C661A] px-[6px] flex items-center justify-center rounded-[6px] h-[18px]",children:a.jsx("span",{className:"text-[#FF8C66] text-xs font-['Inter'] font-medium",children:"PRO"})})]}),e.description&&a.jsx("div",{className:"text-[14px] font-inter text-white/50",children:e.description})]})]}),Z===e.id&&a.jsx(qk,{className:"h-6 w-6 text-[#5CD2E5]"})]})},e.id))}),"templates"===lt&&a.jsx("div",{className:"p-4 space-y-3",children:null==(ce=null==U?void 0:U.templates)?void 0:ce.map(e=>a.jsx("div",{className:"p-4 rounded-[12px] cursor-pointer transition-colors bg-[#FFFFFF05]",onClick:()=>{null==V||V(e.env_image),ct("main")},children:a.jsxs("div",{className:bb("flex items-start justify-between"),children:[a.jsx("div",{children:a.jsx("div",{className:bb("font-medium text-white",$==e.env_image&&"text-[#5CD2E5]"),children:e.name||e.env_image})}),$===e.env_image&&a.jsx(qk,{className:"h-6 w-6 text-[#5CD2E5]"})]})},e.env_image))}),"mcp-tools"===lt&&a.jsx("div",{className:"p-4 space-y-3",children:pt&&Array.isArray(pt)&&pt.length>0?[...pt].sort((e,t)=>new Date(t.created_at).getTime()-new Date(e.created_at).getTime()).map(e=>{const t=(null==ne?void 0:ne.includes(e.id))||!1;return a.jsx("div",{className:"p-4 rounded-[12px] relative transition-colors bg-[#FFFFFF05] hover:bg-[#FFFFFF08]",children:a.jsxs("div",{className:"flex items-start justify-between",children:[a.jsxs("div",{className:"flex items-start flex-1 min-w-0 gap-3",children:[a.jsx("div",{className:"flex items-center justify-center min-w-10 min-h-10 bg-[#272729] rounded-[12px]",children:e.icon?a.jsx("img",{src:e.icon,alt:e.display_name,className:"flex-shrink-0 w-6 h-6 rounded-sm"}):a.jsx(OE,{size:24})}),a.jsxs("div",{className:"flex flex-col flex-1 min-w-0",children:[a.jsx("div",{className:bb("font-medium font-inter text-[#E6E6E6]"),children:e.display_name}),e.description&&a.jsx("div",{className:"text-[14px] font-inter truncate text-white/50 mb-1",children:e.description})]})]}),"public"===e.type&&e.key_required?a.jsxs("button",{type:"button",className:"text-[#C4C4CC] backdrop-blur-lg flex items-center gap-1 px-[10px] rounded-full py-[6px] font-medium bg-[#FFFFFF14]",title:"Configure Button",onClick:()=>{he({title:"Configuration Required",description:"Please open the desktop app to configure this MCP server.",duration:5e3})},children:[a.jsx(zE,{size:20,color:"#E6E6E6"}),"Configure"]}):a.jsx(YI,{checked:t,onCheckedChange:t=>{if(!("pro_mode"===de||me||(null==pe?void 0:pe.is_pro_enabled)||be()))return ot(!1),he({title:"Pro Feature",description:"MCP tools are available for Pro users. Upgrade to use this feature.",duration:5e3}),void at.open({});if(t){const t=[...ne||[],e.id];null==se||se(t)}else{const t=(null==ne?void 0:ne.filter(t=>t!==e.id))||[];null==se||se(t)}},disabled:!1,checkedColor:"#F49B57"})]})},e.id)}):a.jsxs("div",{className:"p-8 text-center",children:[a.jsx(OE,{size:48,className:"mx-auto mb-4 opacity-50"}),a.jsx("div",{className:"mb-2 font-medium text-white/70",children:"No MCP tools available"}),a.jsx("div",{className:"text-sm text-white/50",children:"Contact your administrator to set up MCP tools"})]})})]})}),St&&a.jsxs(ZI,{open:nt,onOpenChange:st,title:"Privacy Settings",showDefaultFooter:!1,maxWidth:"max-w-sm",contentPadding:"p-0",showCancel:!0,onCancel:()=>{st(!1)},trigger:a.jsx(a.Fragment,{}),children:[a.jsx("div",{className:"h-[1px] w-full bg-[#242424]"}),a.jsxs("div",{className:"p-4",children:[a.jsxs("div",{className:"flex items-center py-4 transition-colors cursor-pointer",onClick:()=>{Cg("privacy_selection_changed",{selectedPrivacy:"public",previousPrivacy:et,source:"mobile_bottom_sheet",userTier:de}),tt("public"),st(!1)},children:[a.jsx("div",{className:"min-w-[20px] min-h-[20px] max-w-[20px] max-h-[20px] rounded-full border border-white flex items-center justify-center mr-4",children:"public"===et&&a.jsx("div",{className:"w-[10px] h-[10px] rounded-full bg-[#D9D9D9]"})}),a.jsxs("div",{className:"flex flex-col gap-[2px]",children:[a.jsxs("div",{className:bb("flex items-center gap-1 text-sm font-medium text-white/60","public"===et&&"text-white"),children:["Public"," ",a.jsx(XI,{size:14,className:bb("public"!==et&&"opacity-60")})]}),a.jsx("div",{className:bb("text-xs text-white/50","public"===et&&"text-white"),children:"Anyone can view and explore"})]})]}),a.jsxs("div",{className:"flex items-center py-4 transition-colors cursor-pointer",onClick:()=>{Cg("privacy_selection_changed",{selectedPrivacy:"private",previousPrivacy:et,source:"mobile_bottom_sheet",userTier:de,wasBlocked:"free"===de}),"free"===de?(st(!1),at.open({triggerLocation:"default"})):tt("private"),st(!1)},children:[a.jsx("div",{className:"min-w-[20px] min-h-[20px] max-w-[20px] max-h-[20px] rounded-full border border-white flex items-center justify-center mr-4",children:"private"===et&&a.jsx("div",{className:"w-[10px] h-[10px] rounded-full bg-[#D9D9D9]"})}),a.jsx("div",{className:"flex items-center",children:a.jsxs("div",{className:"flex flex-col gap-[2px]",children:[a.jsxs("div",{className:bb("flex items-center gap-1 text-sm font-medium text-white/60","private"===et&&"text-white"),children:["Private"," ",a.jsx(dA,{size:14,opacity:"private"===et?1:.3})]}),a.jsx("div",{className:bb("text-xs text-white/50","private"===et&&"text-white"),children:"Only visible to yourself, unless shared"})]})})]})]})]}),a.jsxs(ZI,{open:Ze,onOpenChange:Ye,title:"Select Agent",showDefaultFooter:!1,maxWidth:"max-w-sm",contentPadding:"p-0",showCancel:!0,onCancel:()=>{Ye(!1)},trigger:a.jsx(a.Fragment,{}),children:[a.jsx("div",{className:"h-[1px] w-full bg-[#242424]"}),a.jsxs("div",{className:"flex flex-col gap-2 p-4 max-h-[70dvh] overflow-y-auto",children:[a.jsx("div",{className:bb("h-auto p-4 text-[#DDDDE6] hover:bg-[#2D2D2F]/40 bg-[#FFFFFF]/5 rounded-[12px] font-medium cursor-pointer",!Ve&&!E&&!A&&!M&&!_&&" text-[#80FFF9]"),onClick:e=>{e.stopPropagation(),$e(!1),w(!1),null==k||k(null),Ye(!1),I(!1),T(!1),D(!1)},children:a.jsxs("div",{className:"flex items-start justify-between w-full",children:[a.jsxs("div",{className:"flex flex-col",children:[a.jsx("span",{className:"text-[16px] text-[#E8E8E6]",children:"E-1"}),a.jsx("span",{className:"text-[14px] text-[#8A8F98] font-inter",children:"Stable & thorough"})]}),!Ve&&!E&&!A&&!M&&!_&&a.jsx(qk,{className:"h-4 w-4 text-[#66EAFF]"})]})}),a.jsx("div",{className:bb("bg-[#FFFFFF]/5 h-auto rounded-[12px] p-4 text-[#DDDDE6] hover:bg-[#2D2D2F]/40 font-medium cursor-pointer",Ve&&!E&&!A&&!M&&!_&&" text-[#80FFF9]"),onClick:e=>{e.stopPropagation(),$e(!0),w(!0),null==k||k(null),Ye(!1),I(!1),T(!1),D(!1)},children:a.jsxs("div",{className:"flex items-start justify-between w-full",children:[a.jsxs("div",{className:"flex flex-col",children:[a.jsx("span",{className:"flex items-center text-[16px] text-[#E8E8E6]",children:"E-1.1"}),a.jsx("span",{className:"text-[14px] text-[#FFFFFF]/50 font-inter",children:"Fast & flexible"})]}),Ve&&!A&&!M&&!_&&a.jsx(qk,{className:"h-4 w-4 text-[#80FFF9]"})]})}),Et&&a.jsx("div",{className:bb("bg-[#FFFFFF]/5 h-auto rounded-[12px] p-4 text-[#DDDDE6] hover:bg-[#2D2D2F]/40 font-medium cursor-pointer",A&&!E&&!M&&!_&&" text-[#80FFF9]"),onClick:e=>{e.stopPropagation(),$e(!1),w(!1),null==k||k(null),Ye(!1),I(!1),T(!0),D(!1)},children:a.jsxs("div",{className:"flex items-start justify-between w-full",children:[a.jsxs("div",{className:"flex flex-col",children:[a.jsx("span",{className:"flex items-center text-[16px] text-[#E8E8E6]",children:"E-1.5"}),a.jsx("span",{className:"text-[14px] text-[#FFFFFF]/50 font-inter",children:"Focused & Diligent"})]}),A&&!_?a.jsx(qk,{className:"h-4 w-4 text-[#80FFF9]"}):a.jsx("span",{className:"text-[12px] bg-[#F49B571A] text-[#F49B57] rounded-full px-2 py-[2px]",children:"Beta"})]})}),It&&a.jsx("div",{className:bb("bg-[#FFFFFF]/5 h-auto rounded-[12px] p-4 text-[#DDDDE6] hover:bg-[#2D2D2F]/40 font-medium cursor-pointer",M&&!E&&!_&&" text-[#80FFF9]"),onClick:e=>{e.stopPropagation(),$e(!1),w(!1),null==k||k(null),Ye(!1),I(!1),T(!1),D(!0)},children:a.jsxs("div",{className:"flex items-start justify-between w-full",children:[a.jsxs("div",{className:"flex flex-col",children:[a.jsx("span",{className:"flex items-center text-[16px] text-[#E8E8E6]",children:"Prototype"}),a.jsx("span",{className:"text-[14px] text-[#FFFFFF]/50 font-inter",children:"Experimental Agent"})]}),M&&!_&&a.jsx(qk,{className:"h-4 w-4 text-[#80FFF9]"})]})}),a.jsx("div",{className:bb("bg-[#FFFFFF]/5 rounded-[12px] h-auto p-4 text-[#DDDDE6] hover:bg-[#2D2D2F]/40 font-medium cursor-pointer",E&&!_&&" text-[#80FFF9]"),onClick:e=>{ht&&Ot(),zt(e),Ye(!1)},children:a.jsxs("div",{className:"flex items-start justify-between w-full",children:[a.jsxs("div",{className:"flex flex-col",children:[a.jsx("span",{className:"flex items-center text-[16px] text-[#E8E8E6]",children:"Mobile"}),a.jsx("span",{className:"text-[14px] text-[#FFFFFF]/50 font-inter",children:"Agent for mobile apps"})]}),E&&!_&&a.jsx(qk,{className:"h-4 w-4 text-[#80FFF9]"})]})}),(S||be())&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:" bg-[#242424] my-2"}),F&&a.jsx("div",{className:"px-3 py-2 text-[#8A8F98] text-[12px] md:text-[13px]",children:"Loading custom agents..."}),!F&&N.map(e=>a.jsx("div",{className:bb("bg-[#FFFFFF]/5 rounded-[12px] h-auto p-4 text-[#DDDDE6] hover:bg-[#2D2D2F]/40 font-medium cursor-pointer",_===e.id&&" text-[#80FFF9]"),onClick:t=>{t.stopPropagation(),null==k||k(e.id),Ye(!1)},children:a.jsxs("div",{className:"flex items-start justify-between w-full",children:[a.jsxs("div",{className:"flex flex-col",children:[a.jsx("span",{className:"text-[16px] truncate max-w-[160px] capitalize",children:e.prompt_name.replaceAll("_"," ").replaceAll("_user","")}),a.jsx("span",{className:"text-[14px] text-[#FFFFFF]/50",children:Bt(e.parent_prompt)})]}),_===e.id&&a.jsx(qk,{className:"h-4 w-4 text-[#80FFF9] flex-shrink-0"})]})},e.id)),!F&&N.length>0&&a.jsx(a.Fragment,{children:a.jsx("div",{className:"h-px bg-[#242424] my-2"})}),a.jsxs("div",{className:"px-2 py-[6px] text-[#DDDDE6] group hover:bg-[#F8FF990F] font-medium cursor-pointer rounded-[8px] flex items-center gap-2",onClick:e=>{e.stopPropagation(),Pt(),Ye(!1)},children:[a.jsx(NS,{className:"w-4 h-4 group-hover:text-[#F8FF99] text-[#E8E8E6]"}),a.jsx("span",{className:"text-[16px] group-hover:text-[#F8FF99] md:text-[13px]",children:"Create New Agent"})]}),a.jsxs("div",{className:"px-2 py-[6px] justify-between text-[#DDDDE6] hover:bg-[#2D2D2F]/40 font-medium cursor-pointer rounded-[8px] flex items-center gap-2",onClick:e=>{e.stopPropagation(),Rt(),Ye(!1)},children:[a.jsxs("div",{className:"flex items-center gap-[6px]",children:[a.jsx(zE,{size:16,color:"#E8E8E6"}),a.jsxs("span",{className:"text-[16px] md:text-[13px]",children:[" ","Manage Agents"]})]}),a.jsx(tI,{})]})]})]})]})]})]})},IA=G,AA=Pe.forwardRef(({className:e,...t},n)=>a.jsx(V,{ref:n,className:bb("focus:outline-none focus:ring-0 focus-visible:ring-0 focus-visible:ring-offset-0 focus-visible:outline-none",e),...t}));AA.displayName=V.displayName;const TA=Z,MA=Pe.forwardRef(({className:e,...t},n)=>a.jsx(q,{ref:n,className:bb("focus:outline-none focus:ring-0 focus-visible:ring-0 focus-visible:ring-offset-0 focus-visible:outline-none",e),...t}));MA.displayName=q.displayName;const DA=Pe.forwardRef(({className:e,...t},n)=>a.jsx(H,{ref:n,className:bb("fixed inset-0 z-[60] bg-[#0e0e0f50] backdrop-blur-[5px] data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 focus:outline-none focus:ring-0 focus-visible:ring-0 focus-visible:ring-offset-0 focus-visible:outline-none",e),...t}));DA.displayName=H.displayName;const LA=Pe.forwardRef(({className:e,children:t,...n},s)=>{const i=Pe.useRef(!0);return Pe.useEffect(()=>{i.current=!0;const e=setTimeout(()=>{i.current=!1},300);return()=>clearTimeout(e)},[]),a.jsxs(TA,{children:[a.jsx(DA,{}),a.jsx($,{ref:s,className:bb("fixed left-[50%] top-[50%] z-[60] grid w-full translate-x-[-50%] translate-y-[-50%] gap-0 bg-[#0E0E0F] border border-[#242424] rounded-[16px] shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] overflow-hidden focus:outline-none focus:ring-0 focus-visible:ring-0 focus-visible:ring-offset-0 focus-visible:outline-none",e),onOpenAutoFocus:e=>{e.preventDefault()},onInteractOutside:e=>{const t=e.target;t&&t.closest&&t.closest("[data-radix-dialog-content]")&&e.preventDefault()},onClick:e=>{e.stopPropagation()},...n,children:t})]})});LA.displayName=$.displayName;const PA=({className:e,...t})=>a.jsx("div",{className:bb("flex flex-col space-y-1.5 text-center sm:text-left bg-[#111112] border-b border-[#242424] p-6 focus:outline-none focus:ring-0 focus-visible:ring-0 focus-visible:ring-offset-0 focus-visible:outline-none",e),...t});PA.displayName="DialogHeader";const RA=({className:e,...t})=>a.jsx("div",{className:bb("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2 bg-[#111112] border-t border-[#242424] p-6 focus:outline-none focus:ring-0 focus-visible:ring-0 focus-visible:ring-offset-0 focus-visible:outline-none",e),...t});RA.displayName="DialogFooter";const OA=Pe.forwardRef(({className:e,...t},n)=>a.jsx(U,{ref:n,className:bb("text-[24px] font-[500] leading-[32px] text-[#DDDDE6] focus:outline-none focus:ring-0 focus-visible:ring-0 focus-visible:ring-offset-0 focus-visible:outline-none",e),...t}));OA.displayName=U.displayName;const zA=Pe.forwardRef(({className:e,...t},n)=>a.jsx(W,{ref:n,className:bb("text-[15px] font-[500] leading-[24px] text-[#737780] font-['Inter'] focus:outline-none focus:ring-0 focus-visible:ring-0 focus-visible:ring-offset-0 focus-visible:outline-none",e),...t}));zA.displayName=W.displayName;const BA=({height:e="100%",gridHeight:t="500%",top:n="0",gridSizeX:s=20,gridSizeY:i=15,gridLineWidth:r=1,gridOpacity:o=.4,fadeIntensity:l=70,backgroundColor:c="#0F0F10",showFade:d=!0})=>{const u={container:{position:"absolute",inset:0,top:n,width:"100%",height:e,opacity:.8,backgroundColor:c,filter:"backdrop(blur(100px))"},gridContainer:{position:"relative",width:"100%",height:"100%",overflow:"hidden",perspective:"450px"},gridFade:{position:"absolute",zIndex:10,width:"100%",height:"100%",background:d?`radial-gradient(ellipse at 50% 50%, rgba(15, 15, 16, 0) 0%, rgba(15, 15, 16, 1) ${l}%)`:"transparent"},gridLines:{width:"100%",height:t,backgroundImage:`\n linear-gradient(to right, rgba(128, 128, 128, ${o}) ${r}px, transparent ${r/2}px),\n linear-gradient(to bottom, rgba(128, 128, 128, ${o}) ${r}px, transparent ${r/2}px)\n `,backgroundSize:`${s}px ${i}px`,transformOrigin:"100% 0 0",animation:"retro-grid-animation 15s linear infinite"}};return a.jsxs("div",{style:u.container,className:"pointer-events-none md:overflow-auto",children:[a.jsx("style",{children:"\n @keyframes retro-grid-animation {\n 0% {\n transform: rotateX(45deg) translateY(-50%);\n }\n 100% {\n transform: rotateX(45deg) translateY(0);\n }\n }\n "}),a.jsxs("div",{style:u.gridContainer,children:[a.jsx("div",{style:u.gridFade}),a.jsx("div",{style:u.gridLines})]})]})},HA=wv.logo.borderedLogoDark;function $A({triggerElement:e=null,defaultView:t="login",onSuccess:n,open:s,onOpenChange:i,openView:r,enableWelcomeModal:o=!1}){const[l,c]=Pe.useState(t),d=Re();return a.jsxs(IA,{open:s,onOpenChange:i,children:[a.jsx(AA,{asChild:!0,children:e}),a.jsxs(LA,{className:"max-w-[90vw] w-[900px] bg-[#131314] border-[#ffffff12] text-white md:max-h-[90vh] md:min-h-[628px] overflow-y-auto p-0",children:[a.jsxs(MA,{className:"absolute top-4 right-4 z-30 opacity-70 hover:opacity-100 transition-opacity",children:[a.jsx(HS,{className:"h-6 w-6 text-white"}),a.jsx("span",{className:"sr-only",children:"Close"})]}),a.jsx("div",{className:"flex flex-col gap-8 justify-center py-8 md:pb-[66px] md:pt-[56px] relative z-20",children:a.jsx("div",{className:"mt-6 space-y-6 max-w-[568px] mx-auto flex flex-col items-center w-full",children:a.jsxs("div",{className:"flex flex-col items-center w-full p-8 pt-0 space-y-6 text-center",children:[a.jsx("div",{className:"flex justify-center",children:a.jsx("img",{src:HA,className:"h-12 mb-4 md:h-24 w-fit",alt:"Emergent Logo"})}),a.jsxs("div",{className:"flex flex-col gap-2",children:[a.jsx("h2",{className:"text-[20px] text-nowrap md:text-[40px] font-brockmann font-medium text-white",children:"Continue with Emergent"}),a.jsx("div",{className:"inline-block text-[#898E98]",children:a.jsx("span",{className:" text-[13px] md:text-[16px] text-wrap md:whitespace-nowrap",children:"To use Emergent, Create a new account or log into an existing one."})})]}),a.jsxs("div",{className:"flex flex-col w-full pt-4 space-y-3 md:space-y-4 max-w-[414px] items-center",children:[a.jsx("button",{onClick:()=>d("/login"),className:"max-h-[40px] md:max-h-[56px] relative justify-center border-2 border-[#000000] rounded-[28px] text-white bg-[#1A1A1A] hover:bg-[#1D1D1D] w-full flex items-center gap-3 py-4 text-base font-semibold leading-6 tracking-wide transition-colors px-14",children:"Log In"}),a.jsx("button",{onClick:()=>d("/register"),className:"max-h-[40px] md:max-h-[56px] relative justify-center w-full flex items-center gap-3 py-4 text-base font-semibold leading-6 tracking-wide text-black transition-colors bg-white rounded-[28px] hover:bg-gray-100 px-14",children:"Sign Up"})]})]})})}),a.jsx(BA,{height:"50%",top:"50%",gridSizeX:70,gridSizeY:30,fadeIntensity:90,gridLineWidth:.3,gridOpacity:.6,backgroundColor:"#131314"})]})]})}const VA=wv.chips.surprise;function UA({config:e,showChips:t,onChipClick:n,hideRefreshButton:s=!1}){const[i,r]=Pe.useState({}),[o,l]=Pe.useState([]),[c,d]=Pe.useState(new Set),[u,p]=Pe.useState(0),{tier:m,isTrulyFreeUser:h}=sv();Pe.useEffect(()=>{if((null==e?void 0:e.prompt_suggestions)&&Array.isArray(e.prompt_suggestions)){const t=e.prompt_suggestions.reduce((e,t)=>(e[t.category]||(e[t.category]=[]),e[t.category].push(t),e),{});r(t)}},[e]);const x=(e=!1)=>Object.keys(i).map(t=>{const n=i[t];if(e&&c.size>0){const e=n.filter(e=>!c.has(`${e.category}-${e.label}`)),t=e.length>0?e:n;return t[Math.floor(Math.random()*t.length)]}return n[Math.floor(Math.random()*n.length)]}),f=e=>{const t=new Set(c);e.forEach(e=>{t.add(`${e.category}-${e.label}`)});const n=Object.values(i).flat().length;if(t.size>.8*n){const t=new Set(e.map(e=>`${e.category}-${e.label}`));d(t)}else d(t)};Pe.useEffect(()=>{if(0===o.length&&Object.keys(i).length>0){const e=x(!1);l(e),f(e)}},[i]);const g=(null==e?void 0:e.prompt_suggestions)&&Array.isArray(e.prompt_suggestions)&&e.prompt_suggestions.length>0;return a.jsx(zb,{mode:"wait",children:t&&g&&o.length>0&&a.jsx(Tk.div,{initial:{opacity:0,y:10,height:0},animate:{opacity:1,y:0,height:"auto"},exit:{opacity:0,y:-10,height:0},transition:{duration:.3,ease:"easeInOut",height:{duration:.3,ease:"easeInOut"}},className:"space-y-4",children:a.jsxs(Tk.div,{className:"flex relative items-center pt-4 flex-wrap gap-[6px] justify-between w-full md:gap-[16px]",variants:{hidden:{opacity:0},visible:{opacity:1,transition:{staggerChildren:.05,delayChildren:.4}},exit:{opacity:0,transition:{staggerChildren:.03,staggerDirection:-1}}},initial:"hidden",animate:"visible",exit:"exit",children:[a.jsxs("div",{className:"flex flex-wrap gap-[6px] md:gap-3 justify-center w-full",children:[o.map((e,t)=>a.jsxs(Tk.button,{variants:{hidden:{opacity:0,scale:1,y:4},visible:{opacity:1,scale:1,y:0,transition:{duration:.5,ease:"easeInOut"}},exit:{opacity:0,scale:1,y:-4,transition:{duration:.5,ease:"easeInOut"}}},onClick:()=>(e=>{n(e.prompt)})(e),whileHover:{y:-4,transition:{duration:.2,ease:"easeOut"}},whileTap:{scale:.95,transition:{duration:.1}},className:"group relative flex text-[#FFFFFF80] hover:text-[#FFFFFF] items-center gap-[6px] p-[6px] md:p-[10px] pr-[12px] bg-[#131314] hover:bg-[#18181A] border border-transparent hover:border-[#323232] rounded-[8px] transition-colors duration-200 cursor-pointer "+(h()?"border-opacity-0":""),children:[a.jsx("img",{src:e.icon_url,alt:"Surprise",className:"w-4 h-4"}),a.jsx("span",{className:"text-sm leading-4 font-medium font-brockmann group-hover:drop-shadow-[0_0_8px_rgba(255,255,255,0.3)] transition-all duration-200",children:e.label})]},`${e.category}-${e.label}-${t}`)),a.jsxs(Tk.button,{variants:{hidden:{opacity:0,scale:1,y:4},visible:{opacity:1,scale:1,y:0,transition:{duration:.5,ease:"easeInOut"}},exit:{opacity:0,scale:1,y:-4,transition:{duration:.5,ease:"easeInOut"}}},onClick:()=>{const e=Object.values(i).flat(),t=e[Math.floor(Math.random()*e.length)];n(t.prompt)},whileHover:{y:-4,transition:{duration:.2,ease:"easeOut"}},whileTap:{scale:.95,transition:{duration:.1}},className:"group flex items-center gap-2 p-[6px] text-[14px] md:p-[10px] pr-[12px] bg-[#131314] font-medium text-[#FFFFFF80] hover:text-[#FFFFFF] border border-[#232324] border-opacity-0 hover:bg-[#18181A] hover:border-[#323232] rounded-[8px] font-brockmann "+(h()?"border-opacity-0":""),children:[a.jsx("img",{src:VA,alt:"Surprise",className:"w-4 h-4"}),a.jsx("span",{className:"leading-4 group-hover:drop-shadow-[0_0_8px_rgba(255,255,255,0.3)] transition-all duration-200",children:"Surprise Me"})]})]}),!s&&a.jsx(Tk.button,{variants:{hidden:{opacity:0,scale:1,y:4},visible:{opacity:1,scale:1,y:0,transition:{duration:.5,ease:"easeInOut"}},exit:{opacity:0,scale:1,y:-4,transition:{duration:.5,ease:"easeInOut"}}},onClick:async()=>{p(e=>e+180);const e=x(!0);l(e),f(e)},whileTap:{scale:.95,transition:{duration:.1}},className:"group hidden md:absolute right-0 md:flex items-center gap-2 p-[6px] md:p-[10px] text-[#7B7B80] hover:text-white hover:bg-[#18181A] rounded-[8px] transition-colors duration-200",title:"Refresh suggestions",children:a.jsx(Tk.div,{animate:{rotate:u},transition:{duration:.5,ease:"easeInOut"},children:a.jsx(kS,{className:"w-4 h-4"})})})]})},"chips-container")})}function WA(e){return["/verify","/activate","/reset-password","/login","/register","/oauth"].some(t=>e.includes(t))}function qA(){const e=Ft(),t=Oe(),{toast:n}=un(),s=Nt(th),i=Nt(nh),a=Nt(sh),r=WA(t.pathname),{user:o}=Yg(),{data:l,error:c,isLoading:d,refetch:u}=Sx(void 0,{skip:!a||r||!o,pollingInterval:3e5}),{data:p=[],isLoading:m}=Ex(void 0,{skip:!i}),h=Pe.useCallback(async(t=!1)=>{try{t||e(Zm(!0));const n=await u();if(n.data){const s=n.data.github.authorized,i=n.data.github.account_name;if(t||(e(Gm(s)),e(Km(i))),s&&i){e(Jm([{installation_id:i,account_login:i,account_type:"User",user_github_login:i,app_slug:"emergent-ai",isPrimary:!0,account:{login:i,id:0,type:"User"},target_type:"User"}]))}return s}throw new Error("Failed to fetch user details")}catch(n){const s=n.message||"Failed to check GitHub connection";return t||e(Ym(s)),!1}},[e,u]),x=Pe.useCallback(async()=>{try{e(Zm(!0)),f()}catch(t){e(Ym(t.message||"Authentication failed"))}},[e]),f=Pe.useCallback(t=>{const{isPopup:n=!1,onSuccess:s,pollingEnabled:i=!0}=t||{};try{const t=Kt;if(n){e(Qm(!0));const n=window.open(t,"github-auth","width=600,height=700");if(i&&n){const t=setInterval(()=>{try{n.closed&&(clearInterval(t),e(Qm(!1)),setTimeout(()=>{h().then(e=>{e&&s&&s()})},1e3))}catch(i){}},1e3)}}else window.open(t,"_blank")}catch(a){e(Ym(a.message||"Failed to open GitHub installation")),e(Qm(!1))}},[e,h]),[g]=Dx(),v=Pe.useCallback(async(t,s)=>{try{const e=await g({installationId:t,code:s}).unwrap();if(e.success)return n({title:"GitHub Connected",description:"Successfully connected to GitHub!"}),await h(),!0;throw new Error(e.error||"Failed to save installation")}catch(i){const t=i.message||"Failed to save GitHub installation";return e(Ym(t)),n({title:"GitHub Connection Failed",description:t,variant:"destructive"}),!1}},[g,n,e,h]);return Pe.useEffect(()=>{p.length>0&&e(Jm(p))},[p,e]),Pe.useEffect(()=>{l&&(e(Gm(l.github.authorized)),e(Km(l.github.account_name)))},[l,e]),Pe.useEffect(()=>{c&&e(Ym("Failed to fetch user details"))},[c,e]),{isConnected:s.isConnected,isConnecting:s.isConnecting,primaryAccount:s.primaryAccount,installations:s.installations,connectionError:s.connectionError,authWindowOpen:s.authWindowOpen,isLoadingUserDetails:d,isLoadingInstallations:m,checkGitHubConnection:h,authenticate:x,redirectToGitHubInstallation:f,saveInstallation:v,setIsConnected:t=>e(Gm(t)),setIsConnecting:t=>e(Zm(t))}}var GA=Pe.forwardRef((e,t)=>a.jsx(J.label,{...e,ref:t,onMouseDown:t=>{var n;t.target.closest("button, input, select, textarea")||(null==(n=e.onMouseDown)||n.call(e,t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));GA.displayName="Label";var ZA=GA;const YA=jb("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),KA=Pe.forwardRef(({className:e,...t},n)=>a.jsx(ZA,{ref:n,className:bb(YA(),e),...t}));function JA({tabs:e,activeTab:t,onTabChange:n,className:s,fontSize:i="text-base",activeTabBgColor:r="bg-[#272729]",fontColor:o="text-white",padding:l="py-2 md:py-3"}){return a.jsx("div",{className:bb("w-full",s),children:a.jsx("div",{className:"grid w-full grid-cols-2 rounded-xl",children:e.map(e=>a.jsxs("button",{onClick:()=>n(e.id),className:bb(`rounded-lg ${l} ${o} font-[Brockmann] ${i} flex justify-center items-center gap-2 font-medium transition-colors`,t===e.id?r:"opacity-30"),children:[e.icon,e.label]},e.id))})})}function QA({tabId:e,activeTab:t,children:n,className:s}){return e!==t?null:a.jsx("div",{className:bb("mt-4",s),children:n})}function XA({hoverIcon:e,icon:t,className:n,children:s,onClick:i,hoveringEndIcon:r,buttonClassName:o,loadingState:l=!1,loadingNode:c,disabled:d=!1}){const[u,p]=Pe.useState(!1);return a.jsxs(zt.button,{disabled:d,onClick:i,type:"button",onMouseEnter:()=>p(!0),onMouseLeave:()=>p(!1),className:bb("flex font-medium max-h-[36px] px-0 py-[10px] text-[14px] gap-3 justify-between items-center",n),transition:{duration:.15},children:[a.jsxs("div",{className:bb("flex items-center gap-3"),children:[t&&!l&&a.jsx(zt.img,{src:u&&e?e:t,alt:"icon",className:"w-5 h-5 transition-all ease-in-out group-hover/rotate:-rotate-12",initial:{opacity:1},animate:{},transition:{duration:.2}}),l&&c,a.jsx(zt.span,{animate:{},transition:{duration:.2},children:s})]}),r&&a.jsx(zt.img,{src:r,alt:"end icon",className:"w-5 h-5",initial:{opacity:0,x:-5},animate:{opacity:u?1:0,x:u?0:-5},transition:{duration:.2}})]})}KA.displayName=ZA.displayName;const eT=wv.common.whiteGithub,tT=wv.common.githubGreen,nT=wv.common.greenLinkArrow;function sT({className:e}){const{isConnecting:t,setIsConnecting:n,redirectToGitHubInstallation:s,setIsConnected:i,isConnected:r}=qA();Pe.useEffect(()=>{r&&t&&n(!1)},[r,t,n]);const o=async()=>{try{const e=await Lp();return!(!e||!e.github||!0!==e.github.authorized)&&(i(!0),dn({title:"Success",description:"Successfully connected to GitHub"}),!0)}catch(e){return!1}finally{n(!1)}};return a.jsx(XA,{disabled:t,loadingNode:a.jsx(gS,{className:"animate-spin"}),loadingState:t,hoveringEndIcon:nT,hoverIcon:tT,icon:eT,className:bb(" hover:bg-[#2EE5720F] px-[10px] w-full hover:text-[#2EE572] opacity-70 hover:opacity-100 rounded-[8px]",e),onClick:async()=>{try{n(!0),bg(sE.GITHUB_EVENTS.CONNECT_TO_GITHUB_CTA_CLICKED),s({isPopup:!0,pollingEnabled:!1,onSuccess:async()=>{await o()&&window.location.reload()}}),(()=>{let e=0;const t=setInterval(async()=>{e++;const s=await o();(s||e>=10)&&(clearInterval(t),s?window.location.reload():e>=10&&n(!1))},3e3);setTimeout(()=>{clearInterval(t),n(!1)},31e3)})()}catch(e){n(!1),dn({title:"Error",description:"Failed to connect to GitHub",variant:"destructive"})}},children:"Connect to Github"})}function iT(e,t){if(!e||!t)return e||[];return e.map(e=>({...e,isPrimary:e.account_login===t})).sort((e,t)=>e.isPrimary?-1:t.isPrimary?1:"Organization"===e.account_type&&"Organization"!==t.account_type?-1:"Organization"!==e.account_type&&"Organization"===t.account_type?1:e.account_login.localeCompare(t.account_login))}function aT({color:e="#2EE572",size:t=16,innerSize:n=8,animate:s=!1,className:i}){const r=`${e}20`;return a.jsxs("div",{className:bb("rounded-full flex items-center justify-center",s&&"relative",i),style:{width:`${t}px`,height:`${t}px`,backgroundColor:r},children:[a.jsx("div",{className:bb("rounded-full",s&&"animate-pulse"),style:{width:`${n}px`,height:`${n}px`,backgroundColor:e}}),s&&a.jsx("div",{className:"absolute inset-0 rounded-full opacity-75 animate-ping",style:{backgroundColor:r}})]})}const rT=wv.common.lock,oT=wv.common.repo,lT=wv.icons.branch,cT=wv.icons.githubIcon,dT=wv.feature.arrowDark,uT=Pe.forwardRef(({githubUrl:e,branchName:t,onGithubUrlChange:n,onBranchNameChange:s,className:i,onClose:r},o)=>{var l,c,d,u,p;const[m,h]=Pe.useState("private"),[x,f]=Pe.useState(!1),[g,v]=Pe.useState(""),[b,y]=Pe.useState(""),[w,j]=Pe.useState(""),[C,N]=Pe.useState(""),[F,_]=Pe.useState(""),[k,S]=Pe.useState([]),[E,I]=Pe.useState([]),[A,T]=Pe.useState(""),[M,D]=Pe.useState(""),[L,P]=Pe.useState(""),[R,O]=Pe.useState(!1),[z,B]=Pe.useState(!1),[H,$]=Pe.useState([]),[V,U]=Pe.useState([]),[W,q]=Pe.useState(null),[G,Z]=Pe.useState(!1),[Y,K]=Pe.useState(!1),[J,Q]=Pe.useState(!1),[X,ee]=Pe.useState(!1),[te,ne]=Pe.useState(!1),[se,ie]=Pe.useState(""),[ae,re]=Pe.useState(!1),[oe,le]=Pe.useState(!1),{isMobile:ce}=nI(),[de,ue]=Pe.useState(!!ce),{user:pe}=Yg(),[me,he]=Pe.useState(window.innerHeight),xe=ce&&me<.75*window.screen.height,fe=()=>`absolute z-50 w-full bg-[#131314] border border-[#242424] rounded-md shadow-lg overflow-y-auto ${xe?"bottom-full mb-1 max-h-[30vh]":"top-full max-h-[40vh]"}`,ge=Pe.useRef(null),ve=Pe.useRef(null),be=Pe.useRef(null),ye=Pe.useRef(null),we=Pe.useRef(null),[je,Ce]=Pe.useState(""),Ne=Pe.useRef(!1),[Fe,_e]=Pe.useState(null),ke=e=>{_e(e)},[Se,Ee]=Pe.useState([]),Ie=Pe.useRef(null),{redirectToGitHubInstallation:Ae,isConnected:Te}=qA(),{data:Me=[],isLoading:De,refetch:Le}=Ex(),Re=WA(Oe().pathname),{data:ze}=Sx(void 0,{skip:Re||!pe}),{data:Be,isFetching:He,error:$e,refetch:Ve}=Ax(Fe?{accountLogin:Fe.accountLogin,repoName:Fe.repoName}:{accountLogin:"",repoName:""},{skip:!Fe}),{data:Ue=[],isLoading:We}=Ix(F&&"add-new-account"!==F?F:"",{skip:!F||"add-new-account"===F});Pe.useImperativeHandle(o,()=>({reset:()=>{v(""),y(""),j(""),N(""),ie(""),_(""),S([]),I([]),T(""),D(""),P(""),$([]),U([]),K(!1),Q(!1),ee(!1),ne(!1),q(null),we.current=null,Ce(""),ke(null)}}));const qe=[{id:"private",label:"Private Repository",icon:a.jsx("img",{src:rT,alt:"Lock"})},{id:"public",label:"Public Repository",icon:a.jsx(XI,{className:"w-5 h-5"})}];Pe.useEffect(()=>{e&&("public"===m?j(e):v(e)),t&&("public"===m?N(t):y(t))},[]);const Ge=e=>{f(!0),h(e),bg(sE.GITHUB_EVENTS.GITHUB_REPO_TAB_CHANGED,{selectedTab:e}),"public"===e?(n(w),s(C)):(n(g),s(b)),setTimeout(()=>{f(!1)},100)};Pe.useEffect(()=>{O(De)},[De]),Pe.useEffect(()=>{B(We)},[We]),Pe.useEffect(()=>{Z(He)},[He]),Pe.useEffect(()=>{if(Be){$(Be),U(Be),Ne.current=!1;const e=Be.find(e=>"main"===e.name||"master"===e.name);e?Xe(e.name):Be.length>0&&Xe(Be[0].name)}else $e&&(q("Failed to fetch branches. Please try again."),$([]),U([]),Ne.current=!1)},[Be,$e]),Pe.useEffect(()=>{if(!F||"add-new-account"===F)return;const e=Ue||[];S(e),""===A.trim()&&I(e)},[F,null==Ue?void 0:Ue.length,A]),Pe.useEffect(()=>{const e=setTimeout(()=>{if(""===A.trim())I(k);else{const e=A.toLowerCase(),t=k.filter(t=>t.name.toLowerCase().includes(e)||t.full_name.toLowerCase().includes(e));I(t)}},100);return()=>clearTimeout(e)},[k,A]),Pe.useEffect(()=>{const e="public"===m?L:M;if(""===e.trim())U(H);else{const t=e.toLowerCase(),n=H.filter(e=>e.name.toLowerCase().includes(t));U(n)}},[H,M,L,m]),Pe.useEffect(()=>{const e=()=>{he(window.innerHeight)};return window.addEventListener("resize",e),window.addEventListener("orientationchange",e),window.visualViewport&&window.visualViewport.addEventListener("resize",e),()=>{window.removeEventListener("resize",e),window.removeEventListener("orientationchange",e),window.visualViewport&&window.visualViewport.removeEventListener("resize",e)}},[]),Pe.useEffect(()=>{const e=e=>{setTimeout(()=>{!ae||e.target.closest(".installation-dropdown")||e.target.closest(".installation-input")||re(!1),!ge.current||ge.current.contains(e.target)||ge.current.contains(document.activeElement)||K(!1),!ve.current||ve.current.contains(e.target)||ve.current.contains(document.activeElement)||Q(!1),!be.current||be.current.contains(e.target)||be.current.contains(document.activeElement)||ee(!1),!ye.current||ye.current.contains(e.target)||ye.current.contains(document.activeElement)||ne(!1)},50)};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e),Ie.current&&clearTimeout(Ie.current)}},[]);const Ze=(e,t=!1)=>{if(!e)return;if(Ne.current&&!t)return;Ne.current=!0;const[n,i]=e.split("/");if(!n||!i)return q("Invalid repository name format"),void(Ne.current=!1);const a=(null==Fe?void 0:Fe.accountLogin)===n&&(null==Fe?void 0:Fe.repoName)===i;a||t||($([]),U([]),D(""),"public"===m?N(""):y(""),s("")),q(null),ke({accountLogin:n,repoName:i}),(t||a)&&setTimeout(async()=>{try{const e=await Ve();if(e.data){$(e.data),U(e.data);const t=e.data.find(e=>"main"===e.name||"master"===e.name);t?Xe(t.name):e.data.length>0&&Xe(e.data[0].name)}}catch(e){}},100)},Ye=e=>`https://github.com/${e}`,Ke=e=>{if(!e)return"";const t=e.match(/github\.com\/([\w.-]+\/[\w.-]+)/);if(t){let e=t[1];return e.endsWith(".git")&&(e=e.slice(0,-4)),e}return""},Je=e=>{"add-new-account"!==e?(_(e),S([]),I([]),$([]),s(""),Ce("")):et()},Qe=e=>{"public"===m?(j(e),N("")):(v(e),y("")),n(e),s(""),$([]),U([]),D("");const t=Ke(e);t&&(we.current=null,setTimeout(()=>{Ze(t,!0)},100))},Xe=e=>{"public"===m?N(e):y(e),s(e)},et=async()=>{try{le(!0),q(null),Ae({isPopup:!0,onSuccess:()=>{Le()}})}catch(e){q(e instanceof Error?e.message:"An unexpected error occurred")}finally{le(!1)}},tt=()=>{"public"===m?(j(""),N(""),ie("")):(v(""),y("")),n(""),s(""),we.current=null,ke(null),$([]),U([]),D(""),P("")},nt=e=>{const t=e.target.value;if(ie(""),!t)return j(""),void("public"===m&&n(""));const s=(e=>{if(!e)return"";let t=e.endsWith(".git")?e.slice(0,-4):e;return t.startsWith("http://")?t=t.replace("http://","https://"):t.startsWith("https://")||(t=`https://${t}`),t})(t);if(!(i=s)||!/^https?:\/\/github\.com\/[\w.-]+\/[\w.-]+(\.git)?$/.test(i))return ie("Please enter a valid GitHub repository URL"),void j(t);var i;if(j(s),"public"===m){n(s);const e=Ke(s);e&&e!==Ke(w)&&(we.current=null,setTimeout(()=>{Ze(e,!0)},100))}},st=R||z||G||x;Pe.useEffect(()=>{const e="public"===m?w:g;if(e){if("public"===m?C:b);else if(H.length>0){const e=H.find(e=>"main"===e.name||"master"===e.name);Xe(e?e.name:H[0].name)}if(0===H.length&&!G&&Fe&&!Ne.current){const t=Ke(e);t&&(we.current&&we.current===t||(we.current=t,Ze(t)))}}},[m,H,G,w,C,g,b,Fe]),Pe.useEffect(()=>{var e;if(!Me||0===Me.length||!(null==(e=null==ze?void 0:ze.github)?void 0:e.account_name)||Se.length>0)return;(()=>{var e,t;try{const n=ze.github.account_name,s=iT(Me,n),i=(null==(e=s.find(e=>e.isPrimary))?void 0:e.installation_id)||(null==(t=s[0])?void 0:t.installation_id);_(i),Ee(s)}catch(n){q("Failed to process GitHub installations. Please try again.")}})()},[null==Me?void 0:Me.length,null==(l=null==ze?void 0:ze.github)?void 0:l.account_name,Se.length]);return ce?a.jsx("div",{className:bb("space-y-4 relative",i),children:a.jsx(ZI,{trigger:a.jsx("div",{}),title:"",open:!0,onOpenChange:e=>{!e&&r&&r()},onCancel:()=>{ue(!1),r&&r()},maxWidth:"max-w-full",showDefaultFooter:!1,footer:a.jsx(Nb,{onClick:()=>{r&&r()},children:a.jsxs("div",{className:"flex items-center justify-center w-full gap-4",children:["Submit",a.jsx("img",{src:dT,alt:"Arrow",className:"w-5 h-5"})]})}),children:a.jsxs("div",{className:"space-y-4 h-[70dvh] overflow-y-auto px-0",children:[a.jsx(JA,{tabs:qe,activeTab:m,onTabChange:Ge,className:"w-full p-2 rounded-2xl",fontSize:"text-sm",fontColor:"text-white/80",padding:"py-3"}),x&&a.jsx("div",{className:"flex items-center justify-center py-8",children:a.jsx(gS,{className:"h-8 w-8 text-[#4ADE80] animate-spin"})}),!x&&a.jsxs(a.Fragment,{children:[a.jsx(QA,{tabId:"public",activeTab:m,className:"px-2 py-0 pt-2 pb-6",children:a.jsx("div",{className:"flex flex-col gap-6",children:a.jsxs("div",{className:"flex flex-col items-center gap-6",children:[a.jsxs("div",{className:"flex flex-col flex-1 w-full gap-2",children:[a.jsx("div",{className:"flex items-center justify-between gap-1",children:a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(XI,{className:"w-5 h-5 text-[#898F99]"}),a.jsx(KA,{htmlFor:"public-repo-selector",className:"text-[#898F99] font-[Inter] text-sm font-medium",children:"Repository URL"})]})}),a.jsx("div",{className:"flex items-center gap-2",children:a.jsxs("div",{className:"relative flex-1",ref:be,children:[a.jsxs("div",{className:bb("flex items-center justify-between w-full h-14 bg-[#131314] border rounded-[8px] p-3 text-white repository-input",x&&"opacity-70 cursor-not-allowed",X&&"border-white/50",se?"border-[#FF4545]":"border-[#242424]"),onClick:e=>{e.preventDefault(),e.stopPropagation(),x||ee(!0)},children:[a.jsxs("div",{className:"flex items-center w-full",children:[a.jsx(ES,{className:"h-4 w-4 text-[#8F8F98] mr-2"}),a.jsx(KS,{type:"text",value:w,onChange:nt,onClick:e=>{e.stopPropagation(),x||ee(!0)},onFocus:e=>{e.stopPropagation(),x||ee(!0)},onBlur:e=>{var t;const n=e.relatedTarget;(null==(t=be.current)?void 0:t.contains(n))||setTimeout(()=>{var e;(null==(e=be.current)?void 0:e.contains(document.activeElement))||ee(!1)},150)},placeholder:"Enter a GitHub repository URL",className:"w-full p-0 bg-transparent border-0 focus-visible:ring-0 focus-visible:ring-offset-0 text-[#C4C4CC] font-medium font-['Inter']",disabled:x})]}),a.jsx("div",{className:"flex items-center justify-center w-8 h-8 ml-2 cursor-pointer",onClick:e=>{e.preventDefault(),e.stopPropagation(),x||ee(!X)},children:x?a.jsx(gS,{className:"h-5 w-5 animate-spin text-[#8F8F98]"}):a.jsx(Gk,{className:bb("h-5 w-5 transition-transform duration-200",X?"transform rotate-180":"","text-[#8F8F98]")})})]}),X&&a.jsx("div",{className:fe(),children:a.jsxs("div",{className:"p-2",children:[a.jsxs("div",{className:"px-3 py-2 text-[#8F8F98] text-sm",children:["Enter a GitHub repository URL (e.g., https://github.com/username/repo)",a.jsx("br",{}),a.jsx("span",{className:"text-[#6B7280] text-xs",children:"Only GitHub URLs are supported. .git suffix will be automatically removed."})]}),!se&&!!Ke(w)&&a.jsxs("div",{className:"px-3 min-h-[40px] rounded-[8px] py-2 text-[#DDDDE6] hover:bg-[#2D2D2F]/40 font-medium cursor-pointer flex items-center justify-between",onClick:()=>{Qe(w),ee(!1)},children:[a.jsx("div",{className:"flex items-center gap-2",children:a.jsx("span",{children:Ke(w)})}),a.jsx(qk,{className:"h-4 w-4 text-[#1BB4CC]"})]})]})}),w&&a.jsx(Nb,{type:"button",variant:"ghost",size:"icon",onClick:e=>{e.preventDefault(),e.stopPropagation(),tt(),ee(!1),ne(!1)},className:"absolute w-8 h-8 transform -translate-y-1/2 rounded-full right-10 top-1/2 hover:bg-transparent focus:outline-none",title:"Clear selected repository",children:a.jsx(HS,{className:"h-4 w-4 text-[#8F8F98] mx-auto"})})]})}),se&&a.jsx("div",{className:"text-[#FF4545] text-sm font-medium font-['Inter'] mt-1",children:se})]}),a.jsxs("div",{className:"flex flex-col items-start flex-1 w-full gap-2",children:[a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("img",{alt:"Branch",src:lT,className:"w-5 h-5"}),a.jsx(KA,{htmlFor:"public-branch-name",className:"text-[#898F99] font-[Inter] text-sm font-medium",children:"Branch"})]}),a.jsxs("div",{className:"relative w-full",ref:ye,children:[a.jsxs("div",{className:bb("flex items-center justify-between w-full h-14 bg-[#131314] border border-[#242424] rounded-[8px] p-3 text-white repository-input",(x||!w)&&"opacity-70 cursor-not-allowed",te&&"border-white/50"),onClick:e=>{e.preventDefault(),e.stopPropagation(),!x&&w&&ne(!0)},children:[a.jsx("div",{className:"relative flex items-center w-full",children:a.jsx(KS,{type:"text",value:te?L:C,onClick:e=>{e.stopPropagation(),!x&&w&&(ne(!0),P(""))},onFocus:e=>{e.stopPropagation(),!x&&w&&(ne(!0),P(""))},onBlur:e=>{var t;const n=e.relatedTarget;(null==(t=ye.current)?void 0:t.contains(n))||setTimeout(()=>{var e;(null==(e=ye.current)?void 0:e.contains(document.activeElement))||(ne(!1),P(""))},150)},onChange:e=>{e.stopPropagation(),te&&P(e.target.value)},placeholder:G?"Loading branches...":0===H.length&&w?"No branches found":w?"Enter or select branch name":"Select a repository first",className:"w-full p-0 bg-transparent border-0 focus-visible:ring-0 focus-visible:ring-offset-0 text-[#C4C4CC] font-medium font-['Inter']",disabled:x||!w})}),a.jsx("div",{className:"flex items-center justify-center w-8 h-8 ml-2 cursor-pointer",onClick:e=>{e.preventDefault(),e.stopPropagation(),!x&&w&&ne(!te)},children:x?a.jsx(gS,{className:"h-5 w-5 animate-spin text-[#8F8F98]"}):a.jsx(Gk,{className:bb("h-5 w-5 transition-transform duration-200",te?"transform rotate-180":"",w?"text-[#8F8F98]":"text-[#8F8F98]/50",x||!w?"opacity-50 cursor-not-allowed":"")})})]}),te&&w&&a.jsx("div",{className:fe(),children:a.jsx("div",{className:"py-1 overflow-y-auto",children:G?null:0===H.length?a.jsx("div",{className:"px-3 py-2 text-[#8F8F98] text-sm",children:"No branches available for this repository"}):a.jsx(a.Fragment,{children:0===V.length?a.jsx("div",{className:"px-3 py-2 text-[#8F8F98] text-sm",children:L?"No matching branches found":"No branches found"}):a.jsx("div",{className:"flex flex-col gap-[6px] p-2",children:V.map(e=>a.jsx("div",{className:bb("px-3 min-h-[40px] rounded-[8px] py-2 text-[#DDDDE6] hover:bg-[#2D2D2F]/40 font-medium cursor-pointer",e.name===C&&"bg-[#172426] text-[#1BB4CC] hover:bg-[#172426] hover:text-[#1BB4CC]"),onClick:t=>{t.preventDefault(),t.stopPropagation(),P(""),ne(!1),setTimeout(()=>{Xe(e.name)},50)},children:a.jsxs("div",{className:"flex items-center justify-between w-full",children:[a.jsx("span",{children:e.name}),e.name===C&&a.jsx(qk,{className:"h-4 w-4 text-[#1BB4CC]"})]})},e.name))})})})})]})]})]})})}),a.jsx(QA,{tabId:"private",activeTab:m,className:"px-2 py-0 pt-2 pb-6",children:R?a.jsx("div",{className:"flex items-center justify-center py-8",children:a.jsx(gS,{className:"h-8 w-8 text-[#4ADE80] animate-spin"})}):Te?a.jsxs("div",{className:"flex flex-col gap-6",children:[a.jsxs("div",{className:"flex flex-col gap-2",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("img",{alt:"GitHub",src:cT,className:"w-4 h-4"}),a.jsx(KA,{htmlFor:"installation-selector",className:"text-[#898F99] font-[Inter] text-sm font-medium",children:"Connected Organizations"})]}),a.jsxs("div",{className:"flex items-center gap-1 font-[Inter] text-sm font-medium text-[#2EE572]",children:[a.jsx(aT,{color:"#2EE572",size:20,innerSize:8,animate:!0,className:""})," ",(null==(it=Se.find(e=>e.isPrimary))?void 0:it.installation_id)||"Primary Account"]})]}),a.jsxs("div",{className:"relative",children:[a.jsxs("div",{className:`flex items-center justify-between w-full h-14 bg-[#131314] border ${ae?"border-white/50":"border-[#242424]"} rounded-md p-3 text-white installation-input`,onClick:()=>{K(!1),Q(!1),re(!ae)},children:[a.jsx("div",{className:"flex items-center w-full",children:a.jsx("div",{className:"relative flex-1",children:F?a.jsxs("div",{className:"flex items-center",children:[(null==(at=Se.find(e=>e.installation_id===F))?void 0:at.account_login)||"Select a GitHub account","User"===(null==(rt=Se.find(e=>e.installation_id===F))?void 0:rt.account_type)&&!(null==(ot=Se.find(e=>e.installation_id===F))?void 0:ot.isPrimary)&&a.jsx("span",{className:"text-xs text-[#DDDDE6] rounded-full bg-[#FFFFFF0D] ml-1 px-2 py-1 font-['Inter'] font-medium",children:"Collaborator"})]}):a.jsx("span",{className:"text-[#8F8F98]",children:"Select a GitHub account"})})}),a.jsx(Gk,{className:"h-4 w-4 text-[#898F99] transition-transform "+(ae?"rotate-180":"")})]}),Se.length>0&&ae&&a.jsx("div",{className:`${fe()} installation-dropdown`,children:a.jsxs("div",{className:"flex flex-col gap-[6px] p-2",children:[Se.map(e=>a.jsx("div",{className:bb("px-3 min-h-[40px] rounded-[8px] py-2 text-[#DDDDE6] hover:bg-[#2D2D2F]/40 font-medium cursor-pointer",F===e.installation_id&&"bg-[#172426] text-[#1BB4CC] hover:bg-[#172426] hover:text-[#1BB4CC]"),onClick:()=>{Je(e.installation_id),re(!1)},children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{children:e.account_login}),"User"===e.account_type&&!e.isPrimary&&a.jsx("span",{className:"text-xs text-[#DDDDE6] rounded-full bg-[#FFFFFF0D] ml-1 px-2 py-1 font-['Inter'] font-medium",children:"Collaborator"})]}),F===e.installation_id&&a.jsx(qk,{className:"h-4 w-4 text-[#1BB4CC]"})]})},e.installation_id)),a.jsx("div",{className:"border-t border-[#ffffff12] my-1"}),a.jsx("div",{className:"px-3 min-h-[40px] rounded-[8px] py-2 text-[#4ADE80] hover:bg-[#172426] hover:text-[#4ADE80] font-medium cursor-pointer",onClick:()=>{et(),re(!1)},children:a.jsxs("div",{className:"flex items-center gap-2",children:[oe?a.jsx(gS,{className:"w-4 h-4 animate-spin"}):a.jsx(NS,{className:"w-4 h-4"}),oe?"Adding Account...":"Add New Github Organizations"]})})]})})]})]}),a.jsxs("div",{className:"flex flex-col items-center w-full gap-4 md:flex-row",children:[a.jsxs("div",{className:"flex flex-col flex-1 w-full gap-2 md:w-fit",children:[a.jsx("div",{className:"flex items-center justify-between gap-1",children:a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("img",{alt:"Repository",src:oT,className:"w-5 h-5"}),a.jsx(KA,{htmlFor:"repo-selector",className:"text-[#898F99] font-[Inter] text-sm font-medium",children:"Select Repo"})]})}),a.jsx("div",{className:"flex items-center gap-2",children:a.jsxs("div",{className:"relative flex-1",ref:ge,children:[a.jsxs("div",{className:bb("flex items-center justify-between w-full h-14 bg-[#131314] border border-[#242424] rounded-[8px] p-3 text-white repository-input",(!F||z&&0===k.length)&&"opacity-70 cursor-not-allowed",Y&&"border-white/50"),onClick:e=>{e.preventDefault(),e.stopPropagation(),F&&!z&&k.length>0&&(re(!1),K(!0))},children:[a.jsxs("div",{className:"flex items-center w-full",children:[a.jsx(ES,{className:"h-4 w-4 text-[#8F8F98] mr-2"}),a.jsx(KS,{type:"text",value:A,onChange:e=>{e.stopPropagation(),T(e.target.value)},onClick:e=>{e.stopPropagation(),F&&!z&&k.length>0&&(re(!1),K(!0))},onFocus:e=>{e.stopPropagation(),F&&!z&&k.length>0&&(re(!1),K(!0))},onBlur:e=>{var t;const n=e.relatedTarget;(null==(t=ge.current)?void 0:t.contains(n))||setTimeout(()=>{var e;(null==(e=ge.current)?void 0:e.contains(document.activeElement))||K(!1)},150)},placeholder:z?"Loading repositories...":0===k.length?"No repositories found":je?`Selected: ${je}`:"Search for a repository",className:"w-full p-0 bg-transparent border-0 focus-visible:ring-0 focus-visible:ring-offset-0 text-[#C4C4CC] font-medium font-['Inter']",disabled:!F||z&&0===k.length})]}),a.jsx("div",{className:"flex items-center justify-center w-8 h-8 cursor-pointer",onClick:e=>{e.preventDefault(),e.stopPropagation(),F&&!z&&k.length>0&&(re(!1),K(!Y))},children:z?a.jsx(gS,{className:"h-5 w-5 animate-spin text-[#8F8F98]"}):a.jsx(Gk,{className:bb("h-5 w-5 transition-transform duration-200",Y?"transform rotate-180":"",F&&0!==k.length?"text-[#8F8F98]":"text-[#8F8F98]/50",!F||z||0===k.length?"opacity-50 cursor-not-allowed":"")})})]}),g&&a.jsx(Nb,{type:"button",variant:"ghost",size:"icon",onClick:e=>{e.preventDefault(),e.stopPropagation(),tt(),Ce(""),T(""),K(!1),Q(!1)},className:"absolute w-8 h-8 transform -translate-y-1/2 rounded-full right-10 top-1/2 hover:bg-transparent focus:outline-none",title:"Clear selected repository",children:a.jsx(HS,{className:"h-4 w-4 text-[#8F8F98] mx-auto"})}),Y&&F&&a.jsx("div",{className:fe(),children:a.jsx("div",{className:"py-1 overflow-y-auto",children:z?a.jsxs("div",{className:"flex items-center justify-center p-4",children:[a.jsx(gS,{className:"h-5 w-5 text-[#4ADE80] animate-spin mr-2"}),a.jsx("span",{className:"text-white",children:"Loading repositories..."})]}):0===E.length?a.jsx("div",{className:"px-3 py-2 text-[#8F8F98] text-sm",children:A?"No repositories match your search":"No repositories found"}):a.jsx("div",{className:"flex flex-col gap-[6px] p-2",children:E.map(e=>a.jsx("div",{className:bb("px-3 min-h-[40px] rounded-[8px] py-2 text-[#DDDDE6] hover:bg-[#2D2D2F]/40 font-medium cursor-pointer",je===e.name&&"bg-[#172426] text-[#1BB4CC] hover:bg-[#172426] hover:text-[#1BB4CC]"),onClick:t=>{t.preventDefault(),t.stopPropagation(),Ce(e.name),T(e.name),D(""),K(!1),setTimeout(()=>{Qe(Ye(e.full_name))},50)},children:a.jsxs("div",{className:"flex items-center justify-between w-full",children:[a.jsx("span",{children:e.name}),je===e.name&&a.jsx(qk,{className:"h-4 w-4 text-[#1BB4CC]"})]})},e.id))})})})]})})]}),a.jsxs("div",{className:"flex flex-col items-start w-full gap-2 md:w-fit",children:[a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("img",{alt:"Branch",src:lT,className:"w-5 h-5"}),a.jsx(KA,{htmlFor:"branch-name",className:"text-[#898F99] font-[Inter] text-sm font-medium",children:"Select Branch"})]}),a.jsxs("div",{className:"relative w-full md:w-48",ref:ve,children:[a.jsxs("div",{className:bb("flex items-center justify-between w-full h-14 bg-[#131314] border border-[#242424] rounded-[8px] p-3 text-white repository-input",(!g||G)&&"opacity-70 cursor-not-allowed",J&&"border-white/50"),onClick:e=>{e.preventDefault(),e.stopPropagation(),g&&!G&&(re(!1),K(!1),Q(!0))},children:[a.jsx("div",{className:"relative flex items-center w-full",children:a.jsx(KS,{type:"text",value:J?M:b,onClick:e=>{e.stopPropagation(),g&&!G&&(re(!1),K(!1),Q(!0),D(""))},onFocus:e=>{e.stopPropagation(),g&&!G&&(re(!1),K(!1),Q(!0),D(""))},onBlur:e=>{var t;const n=e.relatedTarget;(null==(t=ve.current)?void 0:t.contains(n))||setTimeout(()=>{var e;(null==(e=ve.current)?void 0:e.contains(document.activeElement))||(Q(!1),D(""))},150)},onChange:e=>{e.stopPropagation(),J&&D(e.target.value)},placeholder:G?"Loading branches...":0===H.length&&g?"No branches found":g?"Enter or select branch name":"Select a repository first",className:"w-full p-0 bg-transparent border-0 focus-visible:ring-0 focus-visible:ring-offset-0 text-[#C4C4CC] font-medium font-['Inter']",disabled:!g||G})}),a.jsx("div",{className:"flex items-center justify-center w-8 h-8 ml-2 cursor-pointer",onClick:e=>{e.preventDefault(),e.stopPropagation(),g&&!G&&(re(!1),K(!1),Q(!J))},children:G?a.jsx(gS,{className:"h-5 w-5 animate-spin text-[#8F8F98]"}):a.jsx(Gk,{className:bb("h-5 w-5 transition-transform duration-200",J?"transform rotate-180":"",g?"text-[#8F8F98]":"text-[#8F8F98]/50",!g||G?"opacity-50 cursor-not-allowed":"")})})]}),J&&g&&a.jsx("div",{className:`${fe()} rounded-[8px]`,children:a.jsx("div",{className:"py-1 overflow-y-auto",children:G?null:0===H.length?a.jsx("div",{className:"px-3 py-2 text-[#8F8F98] text-sm",children:"No branches available for this repository"}):a.jsx(a.Fragment,{children:0===V.length?a.jsx("div",{className:"px-3 py-2 text-[#8F8F98] text-sm",children:M?"No matching branches found":"No branches found"}):a.jsx("div",{className:"flex flex-col gap-[6px] p-2",children:V.map(e=>a.jsx("div",{className:bb("px-3 min-h-[40px] rounded-[8px] py-2 text-[#DDDDE6] hover:bg-[#2D2D2F]/40 font-medium cursor-pointer",e.name===b&&"bg-[#172426] text-[#1BB4CC] hover:bg-[#172426] hover:text-[#1BB4CC]"),onClick:t=>{t.preventDefault(),t.stopPropagation(),D(""),Q(!1),setTimeout(()=>{Xe(e.name)},50)},children:a.jsxs("div",{className:"flex items-center justify-between w-full",children:[a.jsx("span",{children:e.name}),e.name===b&&a.jsx(qk,{className:"h-4 w-4 text-[#1BB4CC]"})]})},e.name))})})})})]})]})]}),W&&a.jsx("p",{className:"text-[#FF4545] font-[Inter] text-sm font-medium",children:W}),!st&&!W&&Se.length>0&&F&&"add-new-account"!==F&&0===k.length&&a.jsx("p",{className:"text-[#DDDDE6]/50 font-[Inter] text-sm font-medium",children:"No repositories found for this account"}),!st&&!W&&A&&0===E.length&&k.length>0&&a.jsx("p",{className:"text-[#DDDDE6]/50 font-[Inter] text-sm font-medium",children:"No repositories match your search"}),!st&&!G&&!W&&g&&!G&&0===H.length&&a.jsx("p",{className:"text-[#DDDDE6]/50 font-[Inter] text-sm font-medium",children:"No branches found for this repository. Please check if the repository is empty or has any branches."})]}):a.jsxs("div",{className:"relative p-6 overflow-hidden rounded-lg",children:[a.jsx("div",{className:"absolute inset-0 overflow-hidden",children:a.jsx("div",{className:"absolute inset-0",style:{backgroundImage:"repeating-linear-gradient(\n 45deg,\n transparent,\n transparent 4px,\n rgba(255, 255, 255, 0.03) 4px,\n rgba(255, 255, 255, 0.03) 6px,\n transparent 6px,\n transparent 10px\n )"}})}),a.jsxs("div",{className:"relative z-10 flex flex-col items-center justify-between space-y-8",children:[a.jsxs("div",{className:"flex flex-col items-center space-y-2",children:[a.jsx("h2",{className:"text-base text-center font-['Inter'] font-bold text-white",children:"Github Authentication Required"}),a.jsx("p",{className:"text-[#5C5F66] text-base text-center font-['Inter'] max-w-md",children:"Connect your GitHub account to access all your private and public repositories."})]}),a.jsx("div",{className:"flex items-center justify-center",children:a.jsx(sT,{className:"rounded-full px-4 bg-[#009939] hover:bg-[#00993950] transition-all ease-in-out opacity-100"})})]})]})})]})]})})}):a.jsxs("div",{className:bb("space-y-4 border border-[#ffffff12] rounded-xl bg-gradient-to-br from-[#131314] via-[#161618] to-[#1A1A1C] backdrop-blur-sm",i),children:[a.jsx(JA,{tabs:qe,activeTab:m,onTabChange:Ge,className:"w-full p-2.5 pb-0 bg-white/02"}),x&&a.jsx("div",{className:"flex items-center justify-center py-8",children:a.jsx(gS,{className:"h-8 w-8 text-[#4ADE80] animate-spin"})}),!x&&a.jsxs(a.Fragment,{children:[a.jsx(QA,{tabId:"public",activeTab:m,className:"px-2.5 pt-2 pb-6",children:a.jsx("div",{className:"flex flex-col gap-6",children:a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("div",{className:"flex flex-col flex-1 gap-2",children:[a.jsx("div",{className:"flex items-center justify-between gap-1",children:a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(XI,{className:"w-5 h-5 text-[#898F99]"}),a.jsx(KA,{htmlFor:"public-repo-selector",className:"text-[#898F99] font-[Inter] text-sm font-medium",children:"Repository URL"})]})}),a.jsx("div",{className:"flex items-center gap-2",children:a.jsxs("div",{className:"relative flex-1",ref:be,children:[a.jsxs("div",{className:bb("flex items-center justify-between w-full h-14 bg-[#131314] border rounded-[8px] p-3 text-white repository-input",x&&"opacity-70 cursor-not-allowed",X&&"border-white/50",se?"border-[#FF4545]":"border-[#242424]"),onClick:e=>{e.preventDefault(),e.stopPropagation(),x||ee(!0)},children:[a.jsxs("div",{className:"flex items-center w-full",children:[a.jsx(ES,{className:"h-4 w-4 text-[#8F8F98] mr-2"}),a.jsx(KS,{type:"text",value:w,onChange:nt,onClick:e=>{e.stopPropagation(),x||ee(!0)},onFocus:e=>{e.stopPropagation(),x||ee(!0)},onBlur:e=>{var t;const n=e.relatedTarget;(null==(t=be.current)?void 0:t.contains(n))||setTimeout(()=>{var e;(null==(e=be.current)?void 0:e.contains(document.activeElement))||ee(!1)},150)},placeholder:"Enter a GitHub repository URL",className:"w-full p-0 bg-transparent border-0 focus-visible:ring-0 focus-visible:ring-offset-0 text-[#C4C4CC] font-medium font-['Inter']",disabled:x})]}),a.jsx("div",{className:"flex items-center justify-center w-8 h-8 ml-2 cursor-pointer",onClick:e=>{e.preventDefault(),e.stopPropagation(),x||ee(!X)},children:x?a.jsx(gS,{className:"h-5 w-5 animate-spin text-[#8F8F98]"}):a.jsx(Gk,{className:bb("h-5 w-5 transition-transform duration-200",X?"transform rotate-180":"","text-[#8F8F98]")})})]}),X&&a.jsx("div",{className:"absolute z-50 w-full top-full bg-[#131314] border border-[#242424] rounded-md shadow-lg max-h-[40vh] overflow-y-auto",children:a.jsxs("div",{className:"p-2",children:[a.jsxs("div",{className:"px-3 py-2 text-[#8F8F98] text-sm",children:["Enter a GitHub repository URL (e.g., https://github.com/username/repo)",a.jsx("br",{}),a.jsx("span",{className:"text-[#6B7280] text-xs",children:"Only GitHub URLs are supported. .git suffix will be automatically removed."})]}),!se&&!!Ke(w)&&a.jsxs("div",{className:"px-3 min-h-[40px] rounded-[8px] py-2 text-[#DDDDE6] hover:bg-[#2D2D2F]/40 font-medium cursor-pointer flex items-center justify-between",onClick:()=>{Qe(w),ee(!1)},children:[a.jsx("div",{className:"flex items-center gap-2",children:a.jsx("span",{children:Ke(w)})}),a.jsx(qk,{className:"h-4 w-4 text-[#1BB4CC]"})]})]})}),w&&a.jsx(Nb,{type:"button",variant:"ghost",size:"icon",onClick:e=>{e.preventDefault(),e.stopPropagation(),tt(),ee(!1),ne(!1)},className:"absolute w-8 h-8 transform -translate-y-1/2 rounded-full right-10 top-1/2 hover:bg-transparent focus:outline-none",title:"Clear selected repository",children:a.jsx(HS,{className:"h-4 w-4 text-[#8F8F98] mx-auto"})})]})}),se&&a.jsx("div",{className:"text-[#FF4545] text-sm font-medium font-['Inter'] mt-1",children:se})]}),a.jsxs("div",{className:"flex flex-col gap-2",children:[a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("img",{alt:"Branch",src:lT,className:"w-5 h-5"}),a.jsx(KA,{htmlFor:"public-branch-name",className:"text-[#898F99] font-[Inter] text-sm font-medium",children:"Branch"})]}),a.jsxs("div",{className:"relative w-48",ref:ye,children:[a.jsxs("div",{className:bb("flex items-center justify-between w-full h-14 bg-[#131314] border border-[#242424] rounded-[8px] p-3 text-white repository-input",(x||!w)&&"opacity-70 cursor-not-allowed",te&&"border-white/50"),onClick:e=>{e.preventDefault(),e.stopPropagation(),!x&&w&&ne(!0)},children:[a.jsx("div",{className:"relative flex items-center w-full",children:a.jsx(KS,{type:"text",value:te?L:C,onClick:e=>{e.stopPropagation(),!x&&w&&(ne(!0),P(""))},onFocus:e=>{e.stopPropagation(),!x&&w&&(ne(!0),P(""))},onBlur:e=>{var t;const n=e.relatedTarget;(null==(t=ye.current)?void 0:t.contains(n))||setTimeout(()=>{var e;(null==(e=ye.current)?void 0:e.contains(document.activeElement))||(ne(!1),P(""))},150)},onChange:e=>{e.stopPropagation(),te&&P(e.target.value)},placeholder:G?"Loading branches...":0===H.length&&w?"No branches found":w?"Enter or select branch name":"Select a repository first",className:"w-full p-0 bg-transparent border-0 focus-visible:ring-0 focus-visible:ring-offset-0 text-[#C4C4CC] font-medium font-['Inter']",disabled:x||!w})}),a.jsx("div",{className:"flex items-center justify-center w-8 h-8 ml-2 cursor-pointer",onClick:e=>{e.preventDefault(),e.stopPropagation(),!x&&w&&ne(!te)},children:x?a.jsx(gS,{className:"h-5 w-5 animate-spin text-[#8F8F98]"}):a.jsx(Gk,{className:bb("h-5 w-5 transition-transform duration-200",te?"transform rotate-180":"",w?"text-[#8F8F98]":"text-[#8F8F98]/50",x||!w?"opacity-50 cursor-not-allowed":"")})})]}),te&&w&&a.jsx("div",{className:"absolute z-50 w-full top-full bg-[#131314] border border-[#242424] rounded-md shadow-lg max-h-[40vh] overflow-y-auto",children:a.jsx("div",{className:"py-1 overflow-y-auto",children:G?null:0===H.length?a.jsx("div",{className:"px-3 py-2 text-[#8F8F98] text-sm",children:"No branches available for this repository"}):a.jsx(a.Fragment,{children:0===V.length?a.jsx("div",{className:"px-3 py-2 text-[#8F8F98] text-sm",children:L?"No matching branches found":"No branches found"}):a.jsx("div",{className:"flex flex-col gap-[6px] p-2",children:V.map(e=>a.jsx("div",{className:bb("px-3 min-h-[40px] rounded-[8px] py-2 text-[#DDDDE6] hover:bg-[#2D2D2F]/40 font-medium cursor-pointer",e.name===C&&"bg-[#172426] text-[#1BB4CC] hover:bg-[#172426] hover:text-[#1BB4CC]"),onClick:t=>{t.preventDefault(),t.stopPropagation(),P(""),ne(!1),setTimeout(()=>{Xe(e.name)},50)},children:a.jsxs("div",{className:"flex items-center justify-between w-full",children:[a.jsx("span",{children:e.name}),e.name===C&&a.jsx(qk,{className:"h-4 w-4 text-[#1BB4CC]"})]})},e.name))})})})})]})]})]})})}),a.jsx(QA,{tabId:"private",activeTab:m,className:"px-6 py-0 pt-2 pb-6",children:R?a.jsx("div",{className:"flex items-center justify-center py-8",children:a.jsx(gS,{className:"h-8 w-8 text-[#4ADE80] animate-spin"})}):Te?a.jsxs("div",{className:"flex flex-col gap-6",children:[a.jsxs("div",{className:"flex flex-col gap-2",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("img",{alt:"GitHub",src:cT,className:"w-4 h-4"}),a.jsx(KA,{htmlFor:"installation-selector",className:"text-[#898F99] font-[Inter] text-sm font-medium",children:"Connected Organizations"})]}),a.jsxs("div",{className:"flex items-center gap-1 font-[Inter] text-sm font-medium text-[#2EE572]",children:[a.jsx(aT,{color:"#2EE572",size:20,innerSize:8,animate:!0,className:""})," ",(null==(c=Se.find(e=>e.isPrimary))?void 0:c.installation_id)||"Primary Account"]})]}),a.jsxs("div",{className:"relative",children:[a.jsxs("div",{className:`flex items-center justify-between w-full h-14 bg-[#131314] border ${ae?"border-white/50":"border-[#242424]"} rounded-md p-3 text-white installation-input`,onClick:()=>{K(!1),Q(!1),re(!ae)},children:[a.jsx("div",{className:"flex items-center w-full",children:a.jsx("div",{className:"relative flex-1",children:F?a.jsxs("div",{className:"flex items-center",children:[(null==(d=Se.find(e=>e.installation_id===F))?void 0:d.account_login)||"Select a GitHub account","User"===(null==(u=Se.find(e=>e.installation_id===F))?void 0:u.account_type)&&!(null==(p=Se.find(e=>e.installation_id===F))?void 0:p.isPrimary)&&a.jsx("span",{className:"text-xs text-[#DDDDE6] rounded-full bg-[#FFFFFF0D] ml-1 px-2 py-1 font-['Inter'] font-medium",children:"Collaborator"})]}):a.jsx("span",{className:"text-[#8F8F98]",children:"Select a GitHub account"})})}),a.jsx(Gk,{className:"h-4 w-4 text-[#898F99] transition-transform "+(ae?"rotate-180":"")})]}),Se.length>0&&ae&&a.jsx("div",{className:"absolute z-50 w-full top-full bg-[#131314] border border-[#242424] rounded-md shadow-lg max-h-[40vh] overflow-y-auto installation-dropdown",children:a.jsxs("div",{className:"flex flex-col gap-[6px] p-2",children:[Se.map(e=>a.jsx("div",{className:bb("px-3 min-h-[40px] rounded-[8px] py-2 text-[#DDDDE6] hover:bg-[#2D2D2F]/40 font-medium cursor-pointer",F===e.installation_id&&"bg-[#172426] text-[#1BB4CC] hover:bg-[#172426] hover:text-[#1BB4CC]"),onClick:()=>{Je(e.installation_id),re(!1)},children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{children:e.account_login}),"User"===e.account_type&&!e.isPrimary&&a.jsx("span",{className:"text-xs text-[#DDDDE6] rounded-full bg-[#FFFFFF0D] ml-1 px-2 py-1 font-['Inter'] font-medium",children:"Collaborator"})]}),F===e.installation_id&&a.jsx(qk,{className:"h-4 w-4 text-[#1BB4CC]"})]})},e.installation_id)),a.jsx("div",{className:"border-t border-[#ffffff12] my-1"}),a.jsx("div",{className:"px-3 min-h-[40px] rounded-[8px] py-2 text-[#4ADE80] hover:bg-[#172426] hover:text-[#4ADE80] font-medium cursor-pointer",onClick:()=>{et(),re(!1)},children:a.jsxs("div",{className:"flex items-center gap-2",children:[oe?a.jsx(gS,{className:"w-4 h-4 animate-spin"}):a.jsx(NS,{className:"w-4 h-4"}),oe?"Adding Account...":"Add New Github Organizations"]})})]})})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"flex flex-col flex-1 gap-2",children:[a.jsx("div",{className:"flex items-center justify-between gap-1",children:a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("img",{alt:"Repository",src:oT,className:"w-5 h-5"}),a.jsx(KA,{htmlFor:"repo-selector",className:"text-[#898F99] font-[Inter] text-sm font-medium",children:"Select Repo"})]})}),a.jsx("div",{className:"flex items-center gap-2",children:a.jsxs("div",{className:"relative flex-1",ref:ge,children:[a.jsxs("div",{className:bb("flex items-center justify-between w-full h-14 bg-[#131314] border border-[#242424] rounded-[8px] p-3 text-white repository-input",(!F||z&&0===k.length)&&"opacity-70 cursor-not-allowed",Y&&"border-white/50"),onClick:e=>{e.preventDefault(),e.stopPropagation(),F&&!z&&k.length>0&&(re(!1),K(!0))},children:[a.jsxs("div",{className:"flex items-center w-full",children:[a.jsx(ES,{className:"h-4 w-4 text-[#8F8F98] mr-2"}),a.jsx(KS,{type:"text",value:A,onChange:e=>{e.stopPropagation(),T(e.target.value)},onClick:e=>{e.stopPropagation(),F&&!z&&k.length>0&&(re(!1),K(!0))},onFocus:e=>{e.stopPropagation(),F&&!z&&k.length>0&&(re(!1),K(!0))},onBlur:e=>{var t;const n=e.relatedTarget;(null==(t=ge.current)?void 0:t.contains(n))||setTimeout(()=>{var e;(null==(e=ge.current)?void 0:e.contains(document.activeElement))||K(!1)},150)},placeholder:z?"Loading repositories...":0===k.length?"No repositories found":je?`Selected: ${je}`:"Search for a repository",className:"w-full p-0 bg-transparent border-0 focus-visible:ring-0 focus-visible:ring-offset-0 text-[#C4C4CC] font-medium font-['Inter']",disabled:!F||z&&0===k.length})]}),a.jsx("div",{className:"flex items-center justify-center w-8 h-8 cursor-pointer",onClick:e=>{e.preventDefault(),e.stopPropagation(),F&&!z&&k.length>0&&(re(!1),K(!Y))},children:z?a.jsx(gS,{className:"h-5 w-5 animate-spin text-[#8F8F98]"}):a.jsx(Gk,{className:bb("h-5 w-5 transition-transform duration-200",Y?"transform rotate-180":"",F&&0!==k.length?"text-[#8F8F98]":"text-[#8F8F98]/50",!F||z||0===k.length?"opacity-50 cursor-not-allowed":"")})})]}),g&&a.jsx(Nb,{type:"button",variant:"ghost",size:"icon",onClick:e=>{e.preventDefault(),e.stopPropagation(),tt(),Ce(""),T(""),K(!1),Q(!1)},className:"absolute w-8 h-8 transform -translate-y-1/2 rounded-full right-10 top-1/2 hover:bg-transparent focus:outline-none",title:"Clear selected repository",children:a.jsx(HS,{className:"h-4 w-4 text-[#8F8F98] mx-auto"})}),Y&&F&&a.jsx("div",{className:"absolute top-full w-full bg-[#131314] border border-[#242424] rounded-md shadow-lg z-50",children:a.jsx("div",{className:"max-h-[40vh] overflow-y-auto py-1",children:z?a.jsxs("div",{className:"flex items-center justify-center p-4",children:[a.jsx(gS,{className:"h-5 w-5 text-[#4ADE80] animate-spin mr-2"}),a.jsx("span",{className:"text-white",children:"Loading repositories..."})]}):0===E.length?a.jsx("div",{className:"px-3 py-2 text-[#8F8F98] text-sm",children:A?"No repositories match your search":"No repositories found"}):a.jsx("div",{className:"flex flex-col gap-[6px] p-2",children:E.map(e=>a.jsx("div",{className:bb("px-3 min-h-[40px] rounded-[8px] py-2 text-[#DDDDE6] hover:bg-[#2D2D2F]/40 font-medium cursor-pointer",je===e.name&&"bg-[#172426] text-[#1BB4CC] hover:bg-[#172426] hover:text-[#1BB4CC]"),onClick:t=>{t.preventDefault(),t.stopPropagation(),Ce(e.name),T(e.name),D(""),K(!1),setTimeout(()=>{Qe(Ye(e.full_name))},50)},children:a.jsxs("div",{className:"flex items-center justify-between w-full",children:[a.jsx("span",{children:e.name}),je===e.name&&a.jsx(qk,{className:"h-4 w-4 text-[#1BB4CC]"})]})},e.id))})})})]})})]}),a.jsxs("div",{className:"flex flex-col items-start gap-2",children:[a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("img",{alt:"Branch",src:lT,className:"w-5 h-5"}),a.jsx(KA,{htmlFor:"branch-name",className:"text-[#898F99] font-[Inter] text-sm font-medium",children:"Select Branch"})]}),a.jsxs("div",{className:"relative w-48",ref:ve,children:[a.jsxs("div",{className:bb("flex items-center justify-between w-full h-14 bg-[#131314] border border-[#242424] rounded-[8px] p-3 text-white repository-input",(!g||G)&&"opacity-70 cursor-not-allowed",J&&"border-white/50"),onClick:e=>{e.preventDefault(),e.stopPropagation(),g&&!G&&(re(!1),K(!1),Q(!0))},children:[a.jsx("div",{className:"relative flex items-center w-full",children:a.jsx(KS,{type:"text",value:J?M:b,onClick:e=>{e.stopPropagation(),g&&!G&&(re(!1),K(!1),Q(!0),D(""))},onFocus:e=>{e.stopPropagation(),g&&!G&&(re(!1),K(!1),Q(!0),D(""))},onBlur:e=>{var t;const n=e.relatedTarget;(null==(t=ve.current)?void 0:t.contains(n))||setTimeout(()=>{var e;(null==(e=ve.current)?void 0:e.contains(document.activeElement))||(Q(!1),D(""))},150)},onChange:e=>{e.stopPropagation(),J&&D(e.target.value)},placeholder:G?"Loading branches...":0===H.length&&g?"No branches found":g?"Enter or select branch name":"Select a repository first",className:"w-full p-0 bg-transparent border-0 focus-visible:ring-0 focus-visible:ring-offset-0 text-[#C4C4CC] font-medium font-['Inter']",disabled:!g||G})}),a.jsx("div",{className:"flex items-center justify-center w-8 h-8 ml-2 cursor-pointer",onClick:e=>{e.preventDefault(),e.stopPropagation(),g&&!G&&(re(!1),K(!1),Q(!J))},children:G?a.jsx(gS,{className:"h-5 w-5 animate-spin text-[#8F8F98]"}):a.jsx(Gk,{className:bb("h-5 w-5 transition-transform duration-200",J?"transform rotate-180":"",g?"text-[#8F8F98]":"text-[#8F8F98]/50",!g||G?"opacity-50 cursor-not-allowed":"")})})]}),J&&g&&a.jsx("div",{className:"absolute top-full w-full bg-[#131314] border border-[#242424] rounded-[8px] shadow-lg z-50",children:a.jsx("div",{className:"max-h-[40vh] overflow-y-auto py-1",children:G?null:0===H.length?a.jsx("div",{className:"px-3 py-2 text-[#8F8F98] text-sm",children:"No branches available for this repository"}):a.jsx(a.Fragment,{children:0===V.length?a.jsx("div",{className:"px-3 py-2 text-[#8F8F98] text-sm",children:M?"No matching branches found":"No branches found"}):a.jsx("div",{className:"flex flex-col gap-[6px] p-2",children:V.map(e=>a.jsx("div",{className:bb("px-3 min-h-[40px] rounded-[8px] py-2 text-[#DDDDE6] hover:bg-[#2D2D2F]/40 font-medium cursor-pointer",e.name===b&&"bg-[#172426] text-[#1BB4CC] hover:bg-[#172426] hover:text-[#1BB4CC]"),onClick:t=>{t.preventDefault(),t.stopPropagation(),D(""),Q(!1),setTimeout(()=>{Xe(e.name)},50)},children:a.jsxs("div",{className:"flex items-center justify-between w-full",children:[a.jsx("span",{children:e.name}),e.name===b&&a.jsx(qk,{className:"h-4 w-4 text-[#1BB4CC]"})]})},e.name))})})})})]})]})]}),W&&a.jsx("p",{className:"text-[#FF4545] font-[Inter] text-sm font-medium",children:W}),!st&&!W&&Se.length>0&&F&&"add-new-account"!==F&&0===k.length&&a.jsx("p",{className:"text-[#DDDDE6]/50 font-[Inter] text-sm font-medium",children:"No repositories found for this account"}),!st&&!W&&A&&0===E.length&&k.length>0&&a.jsx("p",{className:"text-[#DDDDE6]/50 font-[Inter] text-sm font-medium",children:"No repositories match your search"}),!st&&!G&&!W&&g&&!G&&0===H.length&&a.jsx("p",{className:"text-[#DDDDE6]/50 font-[Inter] text-sm font-medium",children:"No branches found for this repository. Please check if the repository is empty or has any branches."})]}):a.jsxs("div",{className:"relative p-6 overflow-hidden rounded-lg",children:[a.jsx("div",{className:"absolute inset-0 overflow-hidden",children:a.jsx("div",{className:"absolute inset-0",style:{backgroundImage:"repeating-linear-gradient(\n 45deg,\n transparent,\n transparent 4px,\n rgba(255, 255, 255, 0.05) 4px,\n rgba(255, 255, 255, 0.05) 6px,\n transparent 6px,\n transparent 10px\n )"}})}),a.jsxs("div",{className:"relative z-10 flex items-start justify-between",children:[a.jsxs("div",{className:"flex flex-col items-start space-y-2",children:[a.jsx("h2",{className:"text-base font-['Inter'] font-bold text-white",children:"Github Authentication Required"}),a.jsx("p",{className:"text-[#5C5F66] text-base font-['Inter'] max-w-md",children:"Connect your GitHub account to access all your private and public repositories."})]}),a.jsx("div",{className:"flex items-center justify-center",children:a.jsx(sT,{className:"rounded-full px-4 bg-[#009939] hover:bg-[#00993950] transition-all ease-in-out opacity-100"})})]})]})})]})]});var it,at,rt,ot}),pT=()=>{const e=Oe(),{user:t}=Yg(),n=WA(e.pathname),{data:s,isLoading:i,refetch:a}=Sx(void 0,{skip:n||!t}),r=Pe.useMemo(()=>{if(!(null==s?void 0:s.referral_info))return null;const{referral_code:e,referrer_email:t,subscription_reward_amount:n,total_referral_credits_earned:i,number_of_invitations:a}=s.referral_info;return{referralCode:e||"",referrerEmail:t||null,isReferred:!!t,canApplyReferralCode:!t,subscription_reward_amount:n||50,total_referral_credits_earned:i||0,number_of_invitations:a||0}},[s]),o=Pe.useMemo(()=>!!(null==r?void 0:r.isReferred),[r]),l=Pe.useMemo(()=>!!(null==r?void 0:r.canApplyReferralCode),[r]),c=Pe.useCallback(async()=>{if(!(null==r?void 0:r.referralCode))return!1;try{return await navigator.clipboard.writeText(r.referralCode),!0}catch(e){return!1}},[null==r?void 0:r.referralCode]),d=Pe.useCallback(e=>{if(!e||"string"!=typeof e)return!1;const t=e.trim();if(t.length<3||t.length>50)return!1;return/^[a-zA-Z0-9]+$/.test(t)},[]),u=i,p=Pe.useCallback(()=>{!n&&t&&a()},[n,t,a]);return{referralInfo:r,isLoading:u,copyReferralCode:c,isValidReferralCode:d,refetch:p,isUserReferred:o,canUserApplyReferral:l}},mT=({size:e=24,color:t="#DD99FF",className:n="",...s})=>a.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:n,...s,children:[a.jsx("circle",{opacity:"0.16",cx:"12",cy:"12",r:"10.8",fill:t}),a.jsx("path",{d:"M11.1361 16.3201H12.8641V12.8641H16.3201V11.1361H12.8641V7.68011H11.1361V11.1361H7.68011V12.8641H11.1361V16.3201ZM12.0001 20.6401C10.8049 20.6401 9.68171 20.4133 8.63051 19.9597C7.57931 19.5061 6.66491 18.8905 5.88731 18.1129C5.10971 17.3353 4.49411 16.4209 4.04051 15.3697C3.58691 14.3185 3.36011 13.1953 3.36011 12.0001C3.36011 10.8049 3.58691 9.68171 4.04051 8.63051C4.49411 7.57931 5.10971 6.66491 5.88731 5.88731C6.66491 5.10971 7.57931 4.49411 8.63051 4.04051C9.68171 3.58691 10.8049 3.36011 12.0001 3.36011C13.1953 3.36011 14.3185 3.58691 15.3697 4.04051C16.4209 4.49411 17.3353 5.10971 18.1129 5.88731C18.8905 6.66491 19.5061 7.57931 19.9597 8.63051C20.4133 9.68171 20.6401 10.8049 20.6401 12.0001C20.6401 13.1953 20.4133 14.3185 19.9597 15.3697C19.5061 16.4209 18.8905 17.3353 18.1129 18.1129C17.3353 18.8905 16.4209 19.5061 15.3697 19.9597C14.3185 20.4133 13.1953 20.6401 12.0001 20.6401Z",fill:t})]}),hT=(e,t=!1)=>{if(!e)return"";const n={month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!0};return t&&(n.second="2-digit",n.hour12=!1),new Date(e).toLocaleString("en-US",n)},xT=e=>e?new Date(e).toLocaleString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}):"",fT=e=>e?new Date(e).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric"}):"",gT=({size:e=24,color:t="#4D4D4D",className:n="",...s})=>a.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:n,...s,children:[a.jsx("path",{d:"M8.92217 10.6793C8.92217 10.404 9.14532 10.0213 9.42058 10.0213H15.4016C15.6769 10.0213 15.9 10.404 15.9 10.6793C15.9 10.9546 15.6769 11.3373 15.4016 11.3373H9.42058C9.14532 11.3373 8.92217 10.9546 8.92217 10.6793Z",fill:t}),a.jsx("path",{d:"M8.92217 13.6703C8.92217 13.395 9.14532 13.0123 9.42058 13.0123H14.4048C14.68 13.0123 14.9032 13.395 14.9032 13.6703C14.9032 13.9456 14.68 14.3283 14.4048 14.3283H9.42058C9.14532 14.3283 8.92217 13.9456 8.92217 13.6703Z",fill:t}),a.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M10.9158 6.93867C10.9158 6.74035 10.9946 6.55016 11.1348 6.40993C11.275 6.2697 11.4652 6.19092 11.6635 6.19092H16.8969C17.69 6.19092 18.4506 6.50604 19.0115 7.06696C19.5723 7.62788 19.8874 8.38865 19.8874 9.18191V15.1639C19.8874 15.9571 19.5723 16.7179 19.0115 17.2788C18.4506 17.8398 17.69 18.1549 16.8969 18.1549H7.98813L5.21394 20.9265C5.10938 21.031 4.97623 21.1021 4.83129 21.1309C4.68635 21.1597 4.53613 21.1449 4.3996 21.0883C4.26307 21.0318 4.14635 20.936 4.0642 20.8132C3.98204 20.6904 3.93812 20.5459 3.93799 20.3981L3.93799 11.9236C3.93799 11.7253 4.01676 11.5351 4.15696 11.3949C4.29717 11.2547 4.48733 11.1759 4.68561 11.1759C4.8839 11.1759 5.07406 11.2547 5.21427 11.3949C5.35447 11.5351 5.43324 11.7253 5.43324 11.9236V18.5936L7.37009 16.6594H16.8969C17.2934 16.6594 17.6737 16.5018 17.9542 16.2214C18.2346 15.9409 18.3921 15.5605 18.3921 15.1639V9.18191C18.3921 8.78528 18.2346 8.40489 17.9542 8.12443C17.6737 7.84397 17.2934 7.68641 16.8969 7.68641H11.6635C11.4652 7.68641 11.275 7.60763 11.1348 7.4674C10.9946 7.32717 10.9158 7.13698 10.9158 6.93867Z",fill:t}),a.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4.24564 2.5311C4.30119 2.37566 4.40342 2.24119 4.53835 2.14611C4.67327 2.05103 4.83429 2 4.99933 2C5.16438 2 5.32539 2.05103 5.46032 2.14611C5.59524 2.24119 5.69748 2.37566 5.75303 2.5311L6.33597 4.17616C6.37578 4.28846 6.44015 4.39045 6.52438 4.4747C6.60862 4.55895 6.71059 4.62333 6.82287 4.66314L8.46899 5.24618C8.62441 5.30174 8.75885 5.40399 8.85392 5.53894C8.94898 5.67389 9 5.83493 9 6C9 6.16508 8.94898 6.32612 8.85392 6.46106C8.75885 6.59601 8.62441 6.69826 8.46899 6.75382L6.82287 7.33686C6.71059 7.37668 6.60862 7.44106 6.52438 7.52531C6.44015 7.60955 6.37578 7.71155 6.33597 7.82384L5.75303 9.4689C5.69748 9.62435 5.59524 9.75882 5.46032 9.85389C5.32539 9.94897 5.16438 10 4.99933 10C4.83429 10 4.67327 9.94897 4.53835 9.85389C4.40342 9.75882 4.30119 9.62435 4.24564 9.4689L3.6627 7.82251C3.62289 7.71021 3.55852 7.60822 3.47428 7.52397C3.39005 7.43972 3.28808 7.37534 3.1758 7.33553L1.53102 6.75382C1.37559 6.69826 1.24115 6.59601 1.14609 6.46106C1.05102 6.32612 1 6.16508 1 6C1 5.83493 1.05102 5.67389 1.14609 5.53894C1.24115 5.40399 1.37559 5.30174 1.53102 5.24618L3.17713 4.66314C3.28941 4.62333 3.39138 4.55895 3.47562 4.4747C3.55985 4.39045 3.62422 4.28846 3.66403 4.17616L4.24564 2.5311Z",fill:t})]}),vT=({size:e=24,color:t="#4D4D4D",className:n="",...s})=>a.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:n,...s,children:a.jsx("path",{d:"M7.125 2C5.74609 2 4.625 3.12109 4.625 4.5V19.5C4.625 20.8789 5.74609 22 7.125 22H15.875C17.2539 22 18.375 20.8789 18.375 19.5V4.5C18.375 3.12109 17.2539 2 15.875 2H7.125ZM10.25 18.875H12.75C13.0938 18.875 13.375 19.1562 13.375 19.5C13.375 19.8438 13.0938 20.125 12.75 20.125H10.25C9.90625 20.125 9.625 19.8438 9.625 19.5C9.625 19.1562 9.90625 18.875 10.25 18.875Z",fill:t})}),bT=({size:e=24,width:t,height:n,color:s="#4D4D4D",fill:i,className:r,style:o,onClick:l,...c})=>{const d=t||e,u=n||e,p=i||s;return a.jsx("svg",{width:d,height:u,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:r,style:o,onClick:l,...c,children:a.jsx("path",{d:"M20.1846 13.5137C20.1662 14.4446 20.1332 15.2279 20.0996 15.833C20.0751 16.2761 20.0434 16.719 20.0059 17.1611L20.0039 17.1826L20 17.2314C19.9903 17.8612 19.6891 18.4137 19.248 18.8652C18.8017 19.3212 18.1851 19.7039 17.4707 20.0127C16.0399 20.6315 14.1052 21 12 21C9.89486 21 7.96008 20.632 6.5293 20.0137C5.8149 19.7045 5.19835 19.3216 4.75195 18.8652C4.31086 18.4141 4.0096 17.861 4 17.2314L3.99316 17.1611L3.9707 16.8848C3.94378 16.5345 3.91987 16.1838 3.90039 15.833C3.85827 15.0605 3.83036 14.2872 3.81543 13.5137C4.29536 13.9275 4.88626 14.2829 5.5293 14.5752C7.21607 15.3419 9.50412 15.7998 12 15.7998C14.4959 15.7998 16.7839 15.3419 18.4707 14.5752C19.1137 14.2829 19.7046 13.9271 20.1846 13.5137ZM9.2002 17.2998C8.98815 17.2998 8.78477 17.3843 8.63477 17.5342C8.48482 17.6841 8.40048 17.8876 8.40039 18.0996C8.40039 18.3118 8.48474 18.516 8.63477 18.666C8.78476 18.8158 8.98821 18.9004 9.2002 18.9004C9.4122 18.9003 9.61566 18.8159 9.76562 18.666C9.91565 18.516 10 18.3118 10 18.0996C9.99991 17.8876 9.91557 17.6841 9.76562 17.5342C9.61565 17.3842 9.41226 17.2999 9.2002 17.2998ZM6.59961 16.5996C6.38762 16.5997 6.1841 16.6841 6.03418 16.834C5.88415 16.984 5.7998 17.1882 5.7998 17.4004C5.79992 17.6124 5.88425 17.8159 6.03418 17.9658C6.18411 18.1157 6.38759 18.2001 6.59961 18.2002C6.81178 18.2002 7.01599 18.1158 7.16602 17.9658C7.3159 17.8159 7.40028 17.6124 7.40039 17.4004C7.40039 17.1882 7.31604 16.984 7.16602 16.834C7.01599 16.684 6.81178 16.5996 6.59961 16.5996ZM4 5.59961C4 6.24218 4.30382 6.80594 4.75195 7.26465C5.19835 7.72065 5.8149 8.10429 6.5293 8.41309C7.96009 9.03187 9.89443 9.40039 12 9.40039C14.1056 9.40039 16.0399 9.03148 17.4707 8.41309C18.1851 8.1039 18.8011 7.72102 19.2471 7.26465C19.6957 6.80589 20 6.22667 20 5.58398L20.0303 6.11816C20.0491 6.47015 20.0744 6.97252 20.0996 7.5752C20.1424 8.60158 20.1847 9.92137 20.1963 11.2861C20.145 11.9916 19.465 12.804 17.9746 13.4814C16.4762 14.163 14.364 14.5996 12 14.5996C9.63601 14.5996 7.52378 14.1632 6.02539 13.4824C4.5347 12.8044 3.85491 11.9913 3.80371 11.2861C3.81571 9.92103 3.85759 8.60153 3.90039 7.5752C3.92794 6.91655 3.96097 6.25773 3.99902 5.59961L4 5.58203V5.59961ZM9.2002 11.0996C8.98819 11.0996 8.78476 11.1842 8.63477 11.334C8.48474 11.484 8.40039 11.6882 8.40039 11.9004C8.40052 12.1124 8.48485 12.3159 8.63477 12.4658C8.78476 12.6156 8.98818 12.7002 9.2002 12.7002C9.41223 12.7001 9.61565 12.6157 9.76562 12.4658C9.91554 12.3159 9.99987 12.1124 10 11.9004C10 11.6882 9.91565 11.484 9.76562 11.334C9.61566 11.1841 9.41223 11.0997 9.2002 11.0996ZM6.59961 10.4004C6.38765 10.4005 6.1841 10.4839 6.03418 10.6338C5.88415 10.7838 5.7998 10.988 5.7998 11.2002C5.79988 11.4122 5.88426 11.6157 6.03418 11.7656C6.18411 11.9156 6.38758 11.9999 6.59961 12C6.81178 12 7.01599 11.9157 7.16602 11.7656C7.31589 11.6157 7.40032 11.4122 7.40039 11.2002C7.40039 10.988 7.31604 10.7838 7.16602 10.6338C7.01599 10.4838 6.81175 10.4004 6.59961 10.4004ZM12 3C13.9814 3 15.7466 3.34777 16.9941 3.8877C17.6189 4.15769 18.0869 4.46482 18.3896 4.77441C18.9037 5.3003 18.9038 5.8999 18.3896 6.42578C18.0864 6.73538 17.6189 7.04152 16.9941 7.31152C15.7465 7.85111 13.9816 8.20019 12 8.2002C10.0184 8.2002 8.25345 7.85151 7.00586 7.31152C6.38106 7.04152 5.91315 6.73538 5.61035 6.42578C5.09617 5.8999 5.09625 5.3003 5.61035 4.77441C5.91355 4.46482 6.38106 4.15769 7.00586 3.8877C8.25344 3.34818 10.0186 3 12 3Z",fill:p})})},yT=({size:e=24,width:t,height:n,color:s="#4D4D4D",fill:i,className:r,style:o,onClick:l,...c})=>{const d=t||e,u=n||e,p=i||s;return a.jsx("svg",{width:d,height:u,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:r,style:o,onClick:l,...c,children:a.jsx("path",{d:"M12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2ZM12.5107 7.7373C12.1812 6.92076 11.9035 6.64719 11.5078 7.62207C10.6422 9.69969 9.60868 10.6895 7.57422 11.5469C7.36996 11.6412 7.00239 11.8057 7 12C7.00264 12.1942 7.36761 12.3578 7.57422 12.4521C9.60626 13.3071 10.6422 14.3002 11.5078 16.3779C11.9082 17.37 12.1869 17.0582 12.5107 16.2627C13.3788 14.2545 14.3482 13.3223 16.3955 12.4521C16.61 12.3499 16.9637 12.2143 17 12.0107V11.9873C16.9641 11.785 16.6125 11.6473 16.3955 11.5449V11.5469C14.3485 10.6768 13.3787 9.74605 12.5107 7.7373Z",fill:p})})},wT=({size:e=24,width:t,height:n,color:s="#4D4D4D",fill:i,className:r,style:o,onClick:l,...c})=>{const d=t||e,u=n||e,p=i||s;return a.jsx("svg",{width:d,height:u,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:r,style:o,onClick:l,...c,children:a.jsx("path",{d:"M18.72 14.7602C19.07 13.9102 19.26 13.0002 19.26 12.0002C19.26 11.2802 19.15 10.5902 18.96 9.95019C18.31 10.1002 17.63 10.1802 16.92 10.1802C15.466 10.1818 14.0329 9.83371 12.7415 9.16541C11.4502 8.49711 10.3384 7.52815 9.5 6.34019C8.60396 8.51093 6.91172 10.2568 4.77 11.2202C4.73 11.4702 4.73 11.7402 4.73 12.0002C4.73 12.9549 4.91804 13.9003 5.2834 14.7823C5.64875 15.6643 6.18425 16.4658 6.85933 17.1409C8.22272 18.5042 10.0719 19.2702 12 19.2702C13.05 19.2702 14.06 19.0402 14.97 18.6302C15.54 19.7202 15.8 20.2602 15.78 20.2602C14.14 20.8102 12.87 21.0802 12 21.0802C9.58 21.0802 7.27 20.1302 5.57 18.4202C4.53505 17.3901 3.76627 16.1237 3.33 14.7302H2V10.1802H3.09C3.42024 8.5727 4.17949 7.0846 5.28719 5.87378C6.39489 4.66296 7.80971 3.7746 9.38153 3.30295C10.9534 2.8313 12.6235 2.79396 14.2149 3.1949C15.8062 3.59583 17.2593 4.42008 18.42 5.58019C19.6798 6.83577 20.5393 8.43648 20.89 10.1802H22V14.7302H21.94L18.38 18.0002L13.08 17.4002V15.7302H17.91L18.72 14.7602ZM9.27 11.7702C9.57 11.7702 9.86 11.8902 10.07 12.1102C10.281 12.323 10.3995 12.6105 10.3995 12.9102C10.3995 13.2099 10.281 13.4974 10.07 13.7102C9.86 13.9202 9.57 14.0402 9.27 14.0402C8.64 14.0402 8.13 13.5402 8.13 12.9102C8.13 12.2802 8.64 11.7702 9.27 11.7702ZM14.72 11.7702C15.35 11.7702 15.85 12.2802 15.85 12.9102C15.85 13.5402 15.35 14.0402 14.72 14.0402C14.09 14.0402 13.58 13.5402 13.58 12.9102C13.58 12.6078 13.7001 12.3179 13.9139 12.1041C14.1277 11.8903 14.4177 11.7702 14.72 11.7702Z",fill:p})})},jT=({width:e=20,height:t=20,fill:n="white",className:s,style:i,...r})=>a.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:t,viewBox:"0 0 20 20",fill:"none",className:s,style:i,...r,children:a.jsx("path",{d:"M5.66504 11.9571C6.06881 11.9574 6.39941 12.2879 6.39941 12.6915C6.3992 13.0949 6.06867 13.4247 5.66504 13.4249H4.59277C5.19315 14.3275 6.00712 15.068 6.96289 15.5802C7.91877 16.0924 8.98667 16.3612 10.0713 16.3614C12.7448 16.3614 15.044 14.7683 16.0869 12.4855C16.2265 12.17 16.5788 12.0157 16.9092 12.089C17.015 12.1142 17.1141 12.1629 17.1992 12.2306C17.2842 12.2982 17.354 12.3833 17.4023 12.4806C17.4506 12.5778 17.477 12.6846 17.4795 12.7931C17.482 12.9017 17.4599 13.01 17.416 13.1095C16.1454 15.8914 13.3397 17.8292 10.0713 17.8292C7.33177 17.8292 4.92251 16.4636 3.46094 14.379V15.6271C3.46094 16.0308 3.13052 16.3614 2.72656 16.3614C2.32268 16.3613 1.99219 16.0307 1.99219 15.6271V12.6915C1.99219 12.2879 2.32268 11.9572 2.72656 11.9571H5.66504ZM10.0713 6.6007C10.1417 6.60074 10.2103 6.62124 10.2695 6.65929C10.3288 6.69738 10.3761 6.75149 10.4053 6.81554L11.2129 8.60656L13.0049 9.42101C13.069 9.4502 13.124 9.49753 13.1621 9.55675C13.2001 9.61588 13.2207 9.68472 13.2207 9.75499C13.2207 9.82524 13.2001 9.89411 13.1621 9.95324C13.124 10.0125 13.069 10.0598 13.0049 10.089L11.2129 10.8966L10.3975 12.6876C10.3683 12.7515 10.3217 12.8058 10.2627 12.8439C10.2034 12.882 10.1339 12.9025 10.0635 12.9025C9.99313 12.9024 9.92441 12.8819 9.86523 12.8439C9.80601 12.8058 9.75871 12.7516 9.72949 12.6876L8.92188 10.9034L7.12988 10.089C6.84344 9.95685 6.84344 9.5463 7.12988 9.41417L8.92188 8.60656L9.7373 6.81554C9.76645 6.75162 9.81301 6.69737 9.87207 6.65929C9.93132 6.6212 10.0008 6.6007 10.0713 6.6007ZM3.87891 4.98058C3.98712 4.97005 4.09691 4.98385 4.19922 5.02062C4.30136 5.0574 4.39409 5.11659 4.4707 5.19347C4.7056 5.4357 4.75681 5.81695 4.57324 6.09581C4.10325 6.80037 3.75782 7.60043 3.58887 8.4591C3.52277 8.78938 3.21479 9.01766 2.87695 9.01769C2.76803 9.01771 2.65994 8.99305 2.56152 8.9464C2.46336 8.89979 2.37639 8.83227 2.30762 8.74816C2.23874 8.66387 2.19014 8.56475 2.16406 8.4591C2.138 8.35347 2.13549 8.24342 2.15723 8.13683C2.36107 7.12385 2.76303 6.16035 3.33984 5.30285C3.40022 5.21268 3.48009 5.13689 3.57324 5.08117C3.66643 5.02546 3.77083 4.99112 3.87891 4.98058ZM15.6641 5.19347C15.9871 4.86328 16.5377 4.92151 16.7949 5.30285C17.3605 6.15431 17.7645 7.10921 17.9775 8.13683C17.9993 8.24342 17.9968 8.35347 17.9707 8.4591C17.9446 8.56475 17.896 8.66387 17.8271 8.74816C17.7583 8.8324 17.6706 8.89978 17.5723 8.9464C17.4739 8.99295 17.3666 9.01771 17.2578 9.01769C16.92 9.01767 16.611 8.78939 16.5449 8.4591C16.3686 7.6005 16.0315 6.80032 15.5615 6.09581C15.3706 5.8096 15.4218 5.4357 15.6641 5.19347ZM10.8018 2.56554C10.8018 2.09577 11.2282 1.7509 11.6836 1.83898C12.7117 2.05187 13.674 2.4555 14.5186 3.02062C14.9076 3.2776 14.9589 3.82808 14.6211 4.15831C14.3787 4.4005 14.0042 4.45168 13.7178 4.26085C13.0201 3.79114 12.2196 3.4463 11.3604 3.27745C11.0299 3.2114 10.8018 2.90313 10.8018 2.56554ZM8.45117 1.83898C8.90654 1.7509 9.33301 2.09577 9.33301 2.56554C9.33294 2.90304 9.10523 3.2108 8.76758 3.26964C7.9083 3.4458 7.11521 3.78429 6.41016 4.25402C6.12371 4.44486 5.74823 4.39273 5.50586 4.1505C5.18321 3.82755 5.23466 3.27749 5.61621 3.02062C6.46074 2.4555 7.42306 2.05187 8.45117 1.83898Z",fill:n})}),CT=wv.panelIcons.panelTesting,NT=wv.panelIcons.panelEdit,FT=wv.panelIcons.panelVision,_T=wv.panelIcons.panelIntegration,kT=[{key:"testing",color:"#4D320F",bgColor:"#BBA1E5",icon:"code",iconColor:"#4D320F",text:"Testing Agent",runningText:"is Running",beforeBorder:"before:border-[#BBA1E520]",panelLottie:CT,gradients:{running:"linear-gradient(to bottom, rgba(255, 255, 255, 0.05) 0%, rgba(187, 161, 229, 0.3) 100%)",waiting:"linear-gradient(to bottom, rgba(255, 255, 255, 0.05) 0%, rgba(187, 161, 229, 0.2) 100%)",stopping:"linear-gradient(to bottom, rgba(255, 255, 255, 0.05) 0%, rgba(244, 155, 87, 0.2) 100%)"}},{key:"replace",color:"#4D320F",bgColor:"#F8CC55",icon:"code",iconColor:"#4D320F",text:"Edit Agent",runningText:"is Running",beforeBorder:"before:border-[#4D320F20]",panelLottie:NT,gradients:{running:"linear-gradient(to bottom, rgba(255, 255, 255, 0.05) 0%, rgba(248, 204, 85, 0.2) 100%)",waiting:"linear-gradient(to bottom, rgba(255, 255, 255, 0.05) 0%, rgba(248, 204, 85, 0.2) 100%)",stopping:"linear-gradient(to bottom, rgba(255, 255, 255, 0.05) 0%, rgba(244, 155, 87, 0.2) 100%)"}},{key:"vision",color:"#661F3D",bgColor:"#E5A8A1",icon:"vision",iconColor:"#661F3D",text:"Image Agent",runningText:"is Running",beforeBorder:"before:border-[#E5A8A120]",panelLottie:FT,gradients:{running:"linear-gradient(to bottom, rgba(255, 255, 255, 0.05) 0%, rgba(229, 168, 161, 0.2) 100%)",waiting:"linear-gradient(to bottom, rgba(255, 255, 255, 0.05) 0%, rgba(229, 168, 161, 0.2) 100%)",stopping:"linear-gradient(to bottom, rgba(255, 255, 255, 0.05) 0%, rgba(244, 155, 87, 0.2) 100%)"}},{key:"support",color:"#661F3D",bgColor:"#E5A8A1",icon:"vision",iconColor:"#661F3D",text:"Support Agent",runningText:"is Running",beforeBorder:"before:border-[#E5A8A120]",panelLottie:FT,gradients:{running:"linear-gradient(to bottom, rgba(255, 255, 255, 0.05) 0%, rgba(229, 168, 161, 0.2) 100%)",waiting:"linear-gradient(to bottom, rgba(255, 255, 255, 0.05) 0%, rgba(229, 168, 161, 0.2) 100%)",stopping:"linear-gradient(to bottom, rgba(255, 255, 255, 0.05) 0%, rgba(244, 155, 87, 0.2) 100%)"}},{key:"troubleshoot",color:"#661F3D",bgColor:"#E5A8A1",icon:"vision",iconColor:"#661F3D",text:"Triage Agent",runningText:"is Running",beforeBorder:"before:border-[#E5A8A120]",panelLottie:FT,gradients:{running:"linear-gradient(to bottom, rgba(255, 255, 255, 0.05) 0%, rgba(229, 168, 161, 0.2) 100%)",waiting:"linear-gradient(to bottom, rgba(255, 255, 255, 0.05) 0%, rgba(229, 168, 161, 0.2) 100%)",stopping:"linear-gradient(to bottom, rgba(255, 255, 255, 0.05) 0%, rgba(244, 155, 87, 0.2) 100%)"}},{key:"integration",color:"#243045",bgColor:"#A1BFE5",icon:"integration",iconColor:"#243045",text:"Integration Agent",runningText:"is Running",beforeBorder:"before:border-[#A1BFE520]",panelLottie:_T,gradients:{running:"linear-gradient(to bottom, rgba(255, 255, 255, 0.05) 0%, rgba(161, 191, 229, 0.3) 100%)",waiting:"linear-gradient(to bottom, rgba(255, 255, 255, 0.05) 0%, rgba(161, 191, 229, 0.2) 100%)",stopping:"linear-gradient(to bottom, rgba(255, 255, 255, 0.05) 0%, rgba(244, 155, 87, 0.2) 100%)"}},{key:"design",color:"#243045",bgColor:"#A1BFE5",icon:"design",iconColor:"#243045",text:"Design Agent",runningText:"is Running",beforeBorder:"before:border-[#A1BFE520]",panelLottie:_T,gradients:{running:"linear-gradient(to bottom, rgba(255, 255, 255, 0.05) 0%, rgba(161, 191, 229, 0.3) 100%)",waiting:"linear-gradient(to bottom, rgba(255, 255, 255, 0.05) 0%, rgba(161, 191, 229, 0.2) 100%)",stopping:"linear-gradient(to bottom, rgba(255, 255, 255, 0.05) 0%, rgba(244, 155, 87, 0.2) 100%)"}},{key:"deployment",color:"#4D320F",bgColor:"#BBA1E5",icon:"code",iconColor:"#4D320F",text:"Reviewer Agent",runningText:"is Running",beforeBorder:"before:border-[#BBA1E520]",panelLottie:CT,gradients:{running:"linear-gradient(to bottom, rgba(255, 255, 255, 0.05) 0%, rgba(187, 161, 229, 0.3) 100%)",waiting:"linear-gradient(to bottom, rgba(255, 255, 255, 0.05) 0%, rgba(187, 161, 229, 0.2) 100%)",stopping:"linear-gradient(to bottom, rgba(255, 255, 255, 0.05) 0%, rgba(244, 155, 87, 0.2) 100%)"}}],ST=e=>{if(!e)return"Subagent";const t=e.includes("testing"),n=e.includes("integration"),s=e.includes("vision"),i=e.includes("troubleshoot"),a=e.includes("support"),r=e.includes("replace"),o=e.includes("design"),l=e.includes("deployment");return t?"Testing Agent":n?"Memory Agent":s?"Image Agent":i?"Triage Agent":a?"Support Agent":r?"Edit Agent":o?"Design Agent":l?"Reviewer Agent":"Subagent"},ET=e=>{const t=(e=>{if(!e)return"Subagent";const t=e.includes("testing"),n=e.includes("integration"),s=e.includes("vision"),i=e.includes("troubleshoot"),a=e.includes("support"),r=e.includes("replace"),o=e.includes("design"),l=e.includes("deployment");return t?"testing":n?"integration":s?"vision":i?"troubleshoot":a?"support":r?"replace":o?"design":l?"deployment":"Subagent"})(e);return kT.find(e=>e.key===t)||kT[0]},IT=(e,t="USD")=>"USD"===t?.2*e:"INR"===t?17*e:e;function AT(e,t=!0){const n=function(e){const t="string"==typeof e?parseFloat(e):e;if(isNaN(t))return"0";const[n,s]=t.toString().split("."),i=n.replace(/\B(?=(\d{3})+(?!\d))/g,",");return s?`${i}.${s}`:i}(e);return t?`₹${n}`:`$${n}`}function TT(){const{toast:e}=un(),{user:t}=Yg(),[n,s]=Pe.useState(!1),[i,a]=Pe.useState(null),[r,o]=Pe.useState(!1),{upgradeDetails:l,subscriptionPlansResponse:c,tier:d}=sv(),[u,p]=Pe.useState({isLoading:!1,isSuccess:!1,isError:!1}),[m,h]=Pe.useState(null),[x,f]=Pe.useState({showModal:!1,status:"success"}),[g,v]=Pe.useState(!1),b=c,y=Pe.useMemo(()=>{if(null==b?void 0:b.topup_bundles){const e=b.topup_bundles.map((e,t)=>({amount:e.credits,price:e.amount,selected:1===t,discount:e.bonus_credits?e.credits-(e.original_credits||e.credits):0,currency:e.currency}));return null===m&&e.length>1&&h(e[1].amount),e}return null===m&&h(250),[{amount:100,price:20,selected:!1,discount:0,currency:"USD"},{amount:250,price:50,selected:!0,discount:0,currency:"USD"},{amount:500,price:100,selected:!1,discount:0,currency:"USD"},{amount:3e3,price:500,selected:!1,discount:20,currency:"USD"},{amount:6e3,price:1e3,selected:!1,discount:20,currency:"USD"}]},[null==b?void 0:b.topup_bundles,m]),w=(e,t,n,s)=>{p({isLoading:!0,isSuccess:!1,isError:!1,paymentType:e,amount:t,currency:n,planName:s})},j=(e,t)=>{p({isLoading:!1,isSuccess:!1,isError:!0,errorMessage:e,paymentType:t})},C=()=>{p({isLoading:!1,isSuccess:!1,isError:!1})},N=(e,t,n,s,i)=>{f({showModal:!0,status:e,planName:t,errorMessage:n,paymentId:s,organizationId:i})},F=async(n,s,i)=>{var a,r,o,l;try{const d=!0===(null==i?void 0:i.isSubscription),u=null==i?void 0:i.planId,p=(null==(r=null==(a=null==i?void 0:i.planName)?void 0:a.toLowerCase())?void 0:r.includes("team"))?"Team":(null==i?void 0:i.planName)||"Pro Plan",m=d?0:(null==n?void 0:n.price)||10,h=(null==n?void 0:n.currency)||"USD";let x;w(d?"subscription":"credits",null==n?void 0:n.amount,h,d?p:void 0);try{const e=null==n?void 0:n.couponCode;x=await zp(m,d,u,s,h,e)}catch(c){return C(),void e({title:"Error",description:(null==(l=null==(o=c.response)?void 0:o.data)?void 0:l.detail)||"Failed to create checkout session. Please try again.",variant:"destructive"})}if("ORGANIZATION"===(null==x?void 0:x.userType)&&(s=null==x?void 0:x.userId),(null==x?void 0:x.paymentId)&&hp(x.paymentId,m,h,d?(null==p?void 0:p.toLowerCase().includes("team"))?"team_subscription":"subscription":"credits"),"RAZORPAY"===(null==x?void 0:x.paymentGateway)){let e;try{e=await Bp(x.paymentId,s)}catch(c){return C(),void j("Error checking payment status. Please try again.",d?"subscription":"credits")}if("RAZORPAY"===e.paymentGateway&&(e.razorpayOrderId||e.razorpaySubscriptionId)){const n=document.createElement("script");n.src="https://checkout.razorpay.com/v1/checkout.js",n.async=!0,n.id="razorpay-checkout-script",n.onload=()=>{var n,i,a,r;const o={key:e.keyId,amount:e.razorpayOrderId?100*e.amount:void 0,currency:e.currency||"INR",name:"Emergent",description:d?"Subscription":"Credits Top-up",image:"https://emergent-website-migrate.s3.us-west-2.amazonaws.com/website/emergent_square.png",order_id:e.razorpayOrderId,subscription_id:e.razorpaySubscriptionId,handler:async function(e){d&&N("pending",p,void 0,x.paymentId,s);try{const e=await Bp(x.paymentId,s);if(d)N(e.status,p,"failed"===e.status?"Payment verification failed":void 0,x.paymentId,s);else if(e&&"success"===e.status){const e=new URLSearchParams;e.set("payment_id",x.paymentId),e.set("payment_status","success"),s&&e.set("organization_id",s),window.location.href=`${window.location.pathname}?${e.toString()}`}else{const e=new URLSearchParams;e.set("payment_id",x.paymentId),e.set("payment_status","failed"),s&&e.set("organization_id",s),window.location.href=`${window.location.pathname}?${e.toString()}`}}catch(c){if(d)N("failed",p,"Error verifying payment",x.paymentId,s);else{const e=new URLSearchParams;e.set("payment_id",x.paymentId),e.set("payment_status","failed"),s&&e.set("organization_id",s),window.location.href=`${window.location.pathname}?${e.toString()}`}}},prefill:{email:(null==t?void 0:t.email)||"",name:(null==(n=null==t?void 0:t.user_metadata)?void 0:n.custom_name)||(null==(a=null==(i=null==t?void 0:t.user_metadata)?void 0:i.full_name)?void 0:a.split(" ")[0])||(null==(r=null==t?void 0:t.email)?void 0:r.split("@")[0])||""},theme:{color:"#ffffff",font:{family:"Inter",size:14}},modal:{ondismiss:function(){if(d)N("cancelled",p,void 0,x.paymentId,s);else{const e=new URLSearchParams;e.set("payment_id",x.paymentId),e.set("payment_status","cancelled"),s&&e.set("organization_id",s),window.location.href=`${window.location.pathname}?${e.toString()}`}}}},l=new window.Razorpay(o);C(),l.open()},n.onerror=()=>{C(),j("Failed to load payment gateway",d?"subscription":"credits"),_()},document.body.appendChild(n)}else C(),j("Failed to get Razorpay order details",d?"subscription":"credits")}else window.location.href=x.url}catch(c){C(),j("Error processing payment. Please try again.",(null==i?void 0:i.isSubscription)?"subscription":"credits")}},_=()=>{const e=document.getElementById("razorpay-checkout-script");e&&e.parentNode&&e.parentNode.removeChild(e)};return Pe.useEffect(()=>()=>{_()},[]),{isLoading:n,processingBundleAmount:i,isUpgradeLoading:r,bundles:y,selectedBundleAmount:m,handleBundleSelect:e=>{h(e)},getSelectedBundle:()=>y.find(e=>e.amount===m),handleBuyCredits:async(n,i,r=!1)=>{var o,l,c,u;s(!0),a(n.amount);try{w("credits",n.amount,n.currency),(null==t?void 0:t.id)&&((e,t,n,s,i=!1,a)=>{const r=localStorage.getItem("utm_source")||void 0,o=localStorage.getItem("utm_campaign")||void 0,l=localStorage.getItem("utm_medium")||void 0;dp("topup_intent",{user_id:e,credits_amount:t,price_usd:n,user_tier:s,is_custom_amount:i,organization_id:a||"personal",checkout_type:"stripe",utm_source:r,utm_campaign:o,utm_medium:l,page_url:window.location.href,page_path:window.location.pathname})})(t.id,n.amount,n.price,d||"free",r,i);const e=await zp(n.price,!1,void 0,i,n.currency);(null==e?void 0:e.paymentId)&&hp(e.paymentId,n.price,n.currency,"credits"),(null==e?void 0:e.url)&&(window.location.href=e.url)}catch(p){j((null==(l=null==(o=p.response)?void 0:o.data)?void 0:l.detail)||"Failed to create checkout session. Please try again.","credits"),e({title:"Error",description:(null==(u=null==(c=p.response)?void 0:c.data)?void 0:u.detail)||"Failed to create checkout session. Please try again.",variant:"destructive"})}finally{s(!1),a(null)}},handleRazorpayPayment:F,handleUpgradeToPro:async t=>{var n,s,i,a;o(!0);try{if(!(null==l?void 0:l.id))throw new Error("No Subscription available at this moment for this account");w("subscription",void 0,"USD","Pro Plan");const e=await zp(0,!0,null==l?void 0:l.id,t,"USD");(null==e?void 0:e.paymentId)&&hp(e.paymentId,0,"USD","subscription"),(null==e?void 0:e.url)&&(window.location.href=e.url)}catch(r){j((null==(s=null==(n=r.response)?void 0:n.data)?void 0:s.detail)||"Failed to create checkout session. Please try again.","subscription"),e({title:"Error",description:(null==(a=null==(i=r.response)?void 0:i.data)?void 0:a.detail)||"Failed to create checkout session. Please try again.",variant:"destructive"})}finally{o(!1)}},handleUpgradeToProMode:async t=>{var n,s,i,a,r,l;o(!0);try{w("subscription",void 0,t,"Pro Mode");let e=null;if(null==c?void 0:c.plans){const t=c.plans.emergent_pro;t&&(e=(null==(n=t.monthly_plans)?void 0:n[0])||(null==(s=t.yearly_plans)?void 0:s[0]))}else{const t=(null==c?void 0:c.available_plans)||(null==c?void 0:c.personal_plans);t&&(e=t.find(e=>e.tier_name.toLowerCase().includes("pro")))}if(!e)throw new Error("Emergent Pro plan is not available for upgrade at this moment");if(t.toUpperCase()===Cv){const n={amount:0,price:0,selected:!1,discount:0,currency:t||"USD"};await F(n,"",{isSubscription:!0,planId:e.id,planName:"pro",planType:"personal"})}else{const n=await zp(0,!0,e.id,void 0,t||"USD");(null==n?void 0:n.paymentId)&&hp(n.paymentId,0,t||"USD","subscription"),(null==n?void 0:n.url)&&(window.location.href=n.url)}}catch(d){j((null==(a=null==(i=d.response)?void 0:i.data)?void 0:a.detail)||d.message||"An error occurred during upgrade","subscription"),e({title:"Error",description:(null==(l=null==(r=d.response)?void 0:r.data)?void 0:l.detail)||"Failed to create checkout session. Please try again.",variant:"destructive"})}finally{o(!1)}},handleManageSubscription:async(t="",n)=>{o(!0);try{let s;n.toUpperCase()===Cv?(s=await $p(t),"success"===(null==s?void 0:s.status)?(v(!0),e({title:"Subscription Cancelled",description:s.message,variant:"default"})):e({title:"Error",description:s.detail,variant:"destructive"})):(s=await Hp(),s&&s.url?window.location.href=s.url:e({title:"Error",description:s.detail,variant:"destructive"}))}catch(s){e({title:"Error",description:"Failed to get subscription management URL",variant:"destructive"})}finally{o(!1)}},paymentModalState:u,showPaymentLoading:w,showPaymentSuccess:(e,t,n,s,i)=>{p({isLoading:!1,isSuccess:!0,isError:!1,successData:e,paymentType:t,amount:n,currency:s,planName:i})},showPaymentError:j,hidePaymentModals:C,subscriptionPaymentResult:x,showSubscriptionPaymentResult:N,hideSubscriptionPaymentResult:()=>{f({showModal:!1,status:"success"})},subscriptionCancelledSuccessfully:g,setSubscriptionCancelledSuccessfully:v,cleanupRazorpayScript:_}}var MT="dot_88b245";const DT=({size:e=40,color:t="black",speed:n=1.5})=>a.jsx("div",{className:"container_f5d1e6",style:{"--uib-size":e+"px","--uib-color":t,"--uib-speed":n+"s"},children:a.jsxs("div",{className:"inner_0ac679",children:[a.jsx("div",{className:MT}),a.jsx("div",{className:MT}),a.jsx("div",{className:MT}),a.jsx("div",{className:MT}),a.jsx("div",{className:MT}),a.jsx("div",{className:MT})]})});const LT=({size:e=40,color:t="black",speed:n=.9,stroke:s=5})=>a.jsx("div",{className:"container_2e2e0b",style:{"--uib-size":e+"px","--uib-color":t,"--uib-speed":n+"s","--uib-stroke":s+"px"},children:a.jsx("div",{className:"inner_010d1a"})});function PT({isOpen:e,paymentType:t,amount:n,planName:s}){const i=()=>"subscription"===t?s||"Pro":null;return e?(Pe.useEffect(()=>{bg(tE.PAYMENT_LOADING_MODAL_OPENED,{paymentType:t,amount:n,planName:s})},[t,n,s]),Be.createPortal(a.jsx(Bt,{children:a.jsxs("div",{className:"fixed inset-0 z-[9999]",children:[a.jsx(zt.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},className:"absolute inset-0 bg-[#18181A]"}),a.jsx("div",{className:"relative w-full h-full overflow-y-auto",children:a.jsx(zt.div,{initial:{opacity:0,scale:.95,y:20},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:20},transition:{duration:.2,ease:"easeOut"},className:"min-h-full w-full flex items-center justify-center bg-[#18181A] px-4 py-8",onClick:e=>e.stopPropagation(),children:a.jsx("div",{className:"relative max-w-[90%] md:max-w-[611px] bg-[#1C1C1F] text-white border-[#2E2F34] p-6 md:p-[94px] md:px-[120px] rounded-[20px] w-full min-h-[400px] md:min-h-[500px] flex flex-col justify-center",children:a.jsx("div",{className:"flex flex-col items-center justify-center py-6 flex-1",children:a.jsxs(zt.div,{className:"flex flex-col items-center justify-center gap-[48px] font-brockmann",initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.3},children:[a.jsx("div",{className:"relative",children:a.jsx(DT,{size:"32",speed:"1.75",color:"#80FFF9"})}),a.jsxs("div",{className:"flex flex-col items-center gap-1",children:[a.jsxs("div",{className:"flex items-center flex-col",children:[a.jsx("p",{className:"font-['Brockmann'] font-medium text-[24px] md:text-[32px] leading-[32px] md:leading-[40px] tracking-[-0.02em] text-center text-white",children:"credits"===t?`Processing ${n} credits purchase`:"Setting up your"}),i()&&a.jsxs("span",{className:"font-['Brockmann'] font-medium text-[24px] md:text-[32px] leading-[32px] md:leading-[40px] tracking-[-0.02em] text-center text-[#F3CA5F] drop-shadow-[0px_0px_20px_rgba(243,202,95,0.4)] [text-shadow:0px_0.73px_0.73px_rgba(0,0,0,0.1)]",children:[i()," plan"]})]}),a.jsx("span",{className:"font-['Inter'] mt-2 font-medium text-[16px] leading-[20px] text-[#FFFFFF]/60 text-center",children:"credits"===t?"Redirecting to payment gateway, please wait...":"This will just take a moment"})]})]})})})})})]})}),document.body)):null}const RT=({children:e,onClick:t,variant:n="dark",size:s="md",glowing:i=!1,animated:r=!1,elevationEffect:o=!1,fullWidthOnMobile:l=!1,className:c="",disabled:d,type:u="button",...p})=>{const[m,h]=Pe.useState(!1),[x,f]=Pe.useState(.15);Pe.useEffect(()=>{if(!i||!r)return;const e=setInterval(()=>{f(e=>{const t=e+(.05*Math.random()-.025);return Math.max(.1,Math.min(.3,t))})},100);return()=>clearInterval(e)},[i,r]);const g=i?{position:"relative",zIndex:0}:{},v=o?"transform transition-all duration-800 hover:-translate-y-2 \n hover:shadow-[0px_19px_41px_0px_hsla(0,0%,100%,0.1),0px_75px_75px_0px_hsla(0,0%,100%,0.15),0px_169px_101px_0px_hsla(0,0%,100%,0.1),0px_300px_120px_0px_hsla(0,0%,100%,0.03),0px_469px_131px_0px_hsla(0,0%,100%,0)]\n shadow-[0px_19px_41px_0px_hsla(0,0%,100%,0.1),0px_75px_75px_0px_hsla(0,0%,100%,0.1),0px_169px_101px_0px_hsla(0,0%,100%,0.1),0px_300px_120px_0px_hsla(0,0%,100%,0.03),0px_469px_131px_0px_hsla(0,0%,100%,0)]":"",b=o?{transition:"all 800ms cubic-bezier(0.34, 1.56, 0.64, 1)"}:{};return a.jsxs("div",{className:"relative inline-block w-full "+(l?"":"max-md:w-[85%]"),children:[i&&a.jsx("div",{className:"absolute inset-0 rounded-full blur-xl transition-opacity "+(r?"duration-500":""),style:{background:"dark"===n?"rgba(255, 255, 255, 0.2)":"rgba(26, 26, 26, 0.2)",opacity:m?2*x:x,transform:"scale(1.2)",zIndex:-1}}),a.jsx("button",{type:u,disabled:d,onClick:t,onMouseEnter:()=>h(!0),onMouseLeave:()=>h(!1),className:`relative justify-center font-semibold leading-6 tracking-wide flex items-center gap-3 ${{sm:"py-2 px-6 text-sm",md:"py-4 px-14 text-base",lg:"py-5 px-16 text-lg"}[s]} ${{dark:"border-2 border-black rounded-full text-white bg-[#1A1A1A] hover:bg-[#1D1D1D]",light:"border-2 border-black rounded-full text-black bg-white hover:bg-gray-100"}[n]} ${v} ${c} before:absolute before:inset-0 before:-m-1 before:rounded-full before:border before:border-[#FFFFFF26] before:-z-10 disabled:bg-[#999999] disabled:cursor-not-allowed max-md:h-[40px]`,style:{...g,...b},...p,children:e})]})},OT=({width:e=40,height:t=40,className:n="",onClick:s,role:i="button",tabIndex:r=0,...o})=>a.jsxs("svg",{width:e,height:t,viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:n,onClick:s,onKeyDown:e=>{!s||"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),s())},role:s?i:void 0,tabIndex:s?r:void 0,style:{cursor:"pointer",outline:"none"},...o,children:[a.jsx("rect",{width:"40",height:"40",rx:"10",fill:"white",fillOpacity:"0.06"}),a.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M13.308 13.308C13.7186 12.8973 14.3844 12.8973 14.7951 13.308L20 18.5129L25.2048 13.308C25.6156 12.8973 26.2813 12.8973 26.692 13.308C27.1027 13.7186 27.1027 14.3844 26.692 14.7951L21.4871 20L26.692 25.2048C27.1027 25.6156 27.1027 26.2813 26.692 26.692C26.2813 27.1026 25.6156 27.1026 25.2048 26.692L20 21.4871L14.7951 26.692C14.3844 27.1026 13.7186 27.1026 13.308 26.692C12.8973 26.2813 12.8973 25.6156 13.308 25.2048L18.5129 20L13.308 14.7951C12.8973 14.3844 12.8973 13.7186 13.308 13.308Z",fill:"currentColor"})]}),zT=wv.common.subscriptionSuccess,BT=wv.common.rightArrow,HT=wv.icons.paymentFailed;function $T({isOpen:e,onOpenChange:t,status:n,planName:s,errorMessage:i,paymentId:r,organizationId:o,onClose:l}){const[c,d]=Pe.useState(n),[u,p]=Pe.useState(i),[m,h]=Pe.useState(!1),[x,f]=Pe.useState(void 0),{switchWorkspace:g,isPersonalWorkspace:v,isOrganizationWorkspace:b}=ev(),y=Re(),{user:w}=Yg();Pe.useEffect(()=>{if(!e||!r||"pending"!==n)return;bg(tE.SUBSCRIPTION_PAYMENT_RESULT_MODAL_EVENTS.PAYMENT_STATUS_POLLING_STARTED,{paymentId:r,organizationId:o,status:n,planName:s}),h(!0),d("pending");let t=0;const i=4e3;let a=[],l=!0;const c=async()=>{if(l)try{const e=await Bp(r,o);if(!l)return;if("success"===e.status){d("success"),(null==e?void 0:e.ecu_amount)&&f(e.ecu_amount);try{const t=r?`gtm_razorpay_success_${r}`:void 0;if(!(t?sessionStorage.getItem(t):"1")&&(null==w?void 0:w.id)){mp(w.id,s||"",s||"",(null==e?void 0:e.ecu_amount)||x||0,void 0,Boolean(o),o,void 0,r,!0);const n=r?xp(r):null;if(n){const t=e.amount||n.amount,s=e.currency||n.currency;gp(w.id,r||"",t,s,n.category),fp(r||"")}t&&sessionStorage.setItem(t,"1")}}catch{}return void h(!1)}if("failed"===e.status)return d("failed"),p("Payment verification failed"),void h(!1);if(t++,t<10&&l){const e=setTimeout(c,i);a.push(e)}else l&&(d("failed"),p("Payment verification timed out. Please check your subscription status."),h(!1))}catch(e){if(!l)return;if(t++,t<10&&l){const e=setTimeout(c,i);a.push(e)}else l&&(d("failed"),p("Error verifying payment status"),h(!1))}},u=setTimeout(c,i);return a.push(u),()=>{l=!1,a.forEach(e=>clearTimeout(e)),a=[],h(!1)}},[e,r,o,n]),Pe.useEffect(()=>{d(n),p(i)},[n,i]);const j=()=>"success"===c?s?`${s} Plan Activated`:"Subscription Activated":"cancelled"===c?"Payment failed":"pending"===c?"Verifying Payment":"Payment Failed",C=()=>"success"===c?x?`You now have ${x} credits refreshed monthly.`:s?`Your ${s} subscription is now active and ready to use.`:"Your subscription is now active and ready to use.":"cancelled"===c?a.jsxs(a.Fragment,{children:["Your payment could not be processed.",a.jsx("br",{}),"Please try again"]}):"pending"===c?"Please wait while we verify your payment...":u||"There was an issue processing your payment. Please try again.",N=()=>{if("pending"!==c&&!m)if("success"===c){null==l||l();const e=s&&(s.toLowerCase().includes("team")||s.toLowerCase().includes("teams")||s.toLowerCase().includes("organization")||s.toLowerCase().includes("org"))||!1,t=s&&(s.toLowerCase().includes("pro")||s.toLowerCase().includes("standard")||s.toLowerCase().includes("starter")||s.toLowerCase().includes("personal"))||!1;v();const n=b();e&&o?(g(o),y(`/workspace/${o}`)):t&&n?(g("personal"),y("/")):window.location.reload()}else t(!1)};return e?Be.createPortal(a.jsx(Bt,{children:a.jsxs("div",{className:"fixed inset-0 z-[9999]",children:[a.jsx(zt.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},className:"absolute inset-0 bg-[#18181A]",onClick:N}),a.jsx("div",{className:"relative w-full h-full overflow-y-auto",children:a.jsx(zt.div,{initial:{opacity:0,scale:.95,y:20},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:20},transition:{duration:.2,ease:"easeOut"},className:"min-h-full w-full flex items-center justify-center bg-[#18181A] px-4 py-8",onClick:e=>e.stopPropagation(),children:a.jsxs("div",{className:"relative max-w-[95%] md:max-w-[600px] bg-[#1C1C1F] text-white border-[#2E2F34] p-6 md:p-12 rounded-[20px] w-full min-h-[400px] md:min-h-[500px] flex flex-col justify-center",children:[("success"===c||"cancelled"===c)&&a.jsx("button",{onClick:N,className:"absolute top-4 right-4 md:top-6 md:right-6 text-gray-400 hover:text-white transition-colors z-[9999]",children:a.jsx(OT,{width:32,height:32,className:"md:w-8 md:h-8 rounded-full"})}),a.jsx("div",{className:"flex flex-col items-center justify-center py-8 md:py-16 max-w-full overflow-hidden flex-1",children:a.jsxs(zt.div,{className:"flex flex-col items-center justify-center gap-4 md:gap-6 font-brockmann w-full max-w-full",initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.3},children:["success"===c?a.jsx("img",{src:zT,alt:"Success",className:"w-12 h-12 md:w-16 md:h-16"}):"pending"===c?a.jsx(DT,{size:"32",speed:"1.75",color:"#80FFF9"}):a.jsx("img",{src:HT,alt:"Failed",className:"w-12 h-12 md:w-16 md:h-16"}),a.jsxs("div",{className:"flex flex-col items-center max-w-full px-4",children:[a.jsx("p",{className:"text-[16px] md:text-[24px] lg:text-[28px] md:leading-[32px] font-medium text-center break-words",children:"success"===c?a.jsx("span",{className:"font-['Brockmann'] font-medium text-[24px] md:text-[32px] leading-[32px] md:leading-[40px] tracking-[-0.02em] text-center text-[#F3CA5F] drop-shadow-[0px_0px_20px_rgba(243,202,95,0.4)] [text-shadow:0px_0.73px_0.73px_rgba(0,0,0,0.1)]",children:j()}):a.jsx("span",{className:"font-['Brockmann'] font-medium text-[24px] md:text-[32px] leading-[32px] md:leading-[40px] tracking-[-0.02em] text-center text-white",children:j()})}),"pending"===c?a.jsx("span",{className:"font-['Brockmann'] font-medium text-[18px] leading-[24px] tracking-normal text-[#666666] text-center",children:C()}):"success"===c?x?a.jsxs("span",{className:"font-['Brockmann'] font-medium text-[18px] leading-[24px] tracking-normal text-[#666666] text-center",children:["You now have ",a.jsxs("span",{className:"font-['Brockmann'] font-medium text-[18px] leading-[24px] tracking-normal text-[#666666] text-white",children:[x," credits"]})," refreshed monthly."]}):a.jsx("span",{className:"font-['Brockmann'] font-medium text-[18px] leading-[24px] tracking-normal text-[#666666] text-center",children:s?`Your ${s} subscription is now active and ready to use.`:"Your subscription is now active and ready to use."}):a.jsx("span",{className:"font-['Brockmann'] font-medium text-[18px] leading-[24px] tracking-normal text-center text-[#666666]",children:C()})]}),"pending"!==c&&a.jsx(RT,{onClick:N,variant:"light",className:`w-full h-[45px] md:h-[48px] max-w-[280px] md:max-w-[320px] mx-auto text-center ${m?"opacity-50 cursor-not-allowed":""} flex rounded-[30px] p-2 gap-2 bg-white drop-shadow-[0px_0px_20px_rgba(255,255,255,0.4)] [box-shadow:inset_0px_2.18px_3.64px_1.45px_rgba(255,255,255,0.4)]`,type:"button",disabled:m,children:a.jsxs("span",{className:"px-4 py-3 font-['Brockmann'] font-semibold text-[16px] leading-[24px] tracking-[-0.02em] text-[#0E0E0F] whitespace-nowrap flex items-center gap-2",children:["success"===c?"Start Vibing":"cancelled"===c?"Retry Payment":"pending"===c?"Please Wait":"Close","success"===c&&a.jsx("img",{src:BT,alt:"Arrow",className:"w-6 h-6"})]})})]})})]})})})]})}),document.body):null}function VT({isOpen:e,onClose:t,onConfirm:n,title:s="Cancel Subscription",message:i="Are you sure you want to cancel your subscription? This action cannot be undone and you will lose access to premium features.",confirmText:r="Yes, Cancel",cancelText:o="Keep Subscription",planName:l="Pro"}){if(!e)return null;return Be.createPortal(a.jsx("div",{className:"fixed inset-0 z-[10000] flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:e=>{e.target===e.currentTarget&&t()},children:a.jsx("div",{className:"bg-[#1C1C1F] rounded-[20px] p-6 mx-4 w-[80%] md:w-[45%] relative",children:a.jsxs("div",{className:"flex flex-col",children:[a.jsxs("div",{className:"flex justify-between",children:[a.jsxs("h1",{className:"text-2xl font-['Brockmann'] font-medium text-white leading-8 drop-shadow-[0_0_20px_rgba(243,202,95,0.4)] mb-4 mr-4",children:["Cancel ",a.jsxs("span",{className:"text-[#F3CA5F] drop-shadow-[0_0.73px_0.73px_rgba(0,0,0,0.1)] tracking-[-0.02em]",children:[l,"?"]})]}),a.jsx("button",{onClick:t,className:"absolute top-6 right-6 text-gray-400 hover:text-white transition-colors",children:a.jsx(OT,{width:32,height:32,className:"rounded-full"})})]}),a.jsxs("div",{children:[a.jsxs("p",{className:"text-base font-['Inter'] font-medium leading-6 text-white opacity-60 mb-4",children:["Your ",l," subscription will remain active until the end of your current billing cycle. After that, you'll lose access to all the ",l," features."]}),a.jsx("p",{className:"text-base font-['Inter'] font-medium leading-6 text-white opacity-60 mb-[52px]",children:"Are you sure you want to cancel the subscription?"})]}),a.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 justify-end",children:[a.jsx("button",{onClick:t,className:"rounded-[10px] px-5 py-2.5 gap-1.5 bg-white/[0.04] text-[15px] font-medium leading-5 tracking-[-0.2px] text-white font-['Brockmann']",children:"Keep subscription"}),a.jsx("button",{onClick:n,className:"rounded-[10px] px-5 py-2.5 gap-1.5 bg-[#CC5252] text-[15px] font-semibold leading-5 tracking-[-0.2px] text-white font-['Brockmann']",children:"Yes, Cancel Subscription"})]})]})})}),document.body)}const UT=Pe.createContext(null),WT="success",qT="error",GT="info",ZT="top-left",YT="top-center",KT="top-right",JT="bottom-left",QT="bottom-center",XT="bottom-right",eM=({color:e="#5FE55C"})=>a.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.jsx("path",{d:"M10 19C8.755 19 7.585 18.7638 6.49 18.2913C5.395 17.8188 4.4425 17.1775 3.6325 16.3675C2.8225 15.5575 2.18125 14.605 1.70875 13.51C1.23625 12.415 1 11.245 1 10C1 8.755 1.23625 7.585 1.70875 6.49C2.18125 5.395 2.8225 4.4425 3.6325 3.6325C4.4425 2.8225 5.395 2.18125 6.49 1.70875C7.585 1.23625 8.755 1 10 1C11.245 1 12.415 1.23625 13.51 1.70875C14.605 2.18125 15.5575 2.8225 16.3675 3.6325C17.1775 4.4425 17.8188 5.395 18.2913 6.49C18.7638 7.585 19 8.755 19 10C19 11.245 18.7638 12.415 18.2913 13.51C17.8188 14.605 17.1775 15.5575 16.3675 16.3675C15.5575 17.1775 14.605 17.8188 13.51 18.2913C12.415 18.7638 11.245 19 10 19Z",fill:e}),a.jsx("path",{d:"M13.7155 7C13.8953 7 14.0623 7.03135 14.2164 7.09406C14.3706 7.15677 14.5076 7.24666 14.6275 7.36371C14.7474 7.48077 14.8373 7.61246 14.8972 7.75878C14.9572 7.9051 14.9914 8.07023 15 8.25418C15 8.4214 14.9679 8.58236 14.9037 8.73704C14.8394 8.89172 14.7474 9.02759 14.6275 9.14465L9.52794 14.13C9.40805 14.2471 9.26889 14.337 9.11047 14.3997C8.95204 14.4624 8.7872 14.4958 8.61593 14.5C8.44466 14.5 8.27981 14.4686 8.12139 14.4059C7.96296 14.3432 7.82381 14.2513 7.70392 14.13L5.37893 11.8599C5.25905 11.7429 5.16699 11.607 5.10276 11.4523C5.03854 11.2977 5.00428 11.1367 5 10.9695C5 10.7939 5.03425 10.6309 5.10276 10.4804C5.17127 10.3298 5.26333 10.1961 5.37893 10.079C5.49454 9.96196 5.62942 9.87416 5.78356 9.81564C5.9377 9.75711 6.10683 9.72366 6.29094 9.7153C6.46221 9.7153 6.62706 9.74666 6.78548 9.80936C6.94391 9.87207 7.08307 9.96196 7.20295 10.079L8.61593 11.4586L12.8035 7.36371C12.9234 7.24666 13.0625 7.15677 13.2209 7.09406C13.3794 7.03135 13.5442 7 13.7155 7Z",fill:"#172218"})]}),tM=({color:e="#5FE55C"})=>a.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:a.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4.42462 4.42462C4.76684 4.08242 5.32167 4.08242 5.66389 4.42462L10.0013 8.76204L14.3387 4.42462C14.6809 4.08242 15.2357 4.08242 15.578 4.42462C15.9202 4.76684 15.9202 5.32167 15.578 5.66388L11.2405 10.0013L15.578 14.3386C15.9202 14.6809 15.9202 15.2357 15.578 15.578C15.2357 15.9202 14.6809 15.9202 14.3387 15.578L10.0013 11.2405L5.66389 15.578C5.32167 15.9202 4.76684 15.9202 4.42462 15.578C4.08242 15.2357 4.08242 14.6809 4.42462 14.3386L8.76205 10.0013L4.42462 5.66388C4.08242 5.32167 4.08242 4.76684 4.42462 4.42462Z",fill:e})}),nM=({toast:e,onRemove:t,position:n})=>{const[s,i]=Pe.useState(!1);Pe.useEffect(()=>{const n=Math.min(e.duration||2e3,2e3),s=setTimeout(()=>{i(!0),setTimeout(()=>{t(e.id)},300)},n);return()=>clearTimeout(s)},[e.id,e.duration,t]);const r=()=>{switch(e.type){case WT:return"#5FE55C";case qT:return"#FF8080";default:return"#5FE55C"}};return a.jsxs("div",{className:`flex items-center p-4 rounded-xl min-w-fit pointer-events-auto ${(()=>{if(s)return"animate-out slide-out-to-bottom-full duration-300 ease-in";switch(n){case ZT:case JT:return"animate-in slide-in-from-left-full duration-300 ease-out";case KT:case XT:return"animate-in slide-in-from-right-full duration-300 ease-out";case YT:return"animate-in slide-in-from-top-full duration-300 ease-out";default:return"animate-in slide-in-from-bottom-full duration-300 ease-out"}})()}`,style:(()=>{switch(e.type){case WT:return{background:"radial-gradient(50% 50% at 50% 50%, rgba(95, 229, 92, 0.15) 0%, rgba(95, 229, 92, 0.08) 100%)",backdropFilter:"blur(25px)"};case qT:return{background:"radial-gradient(50% 50% at 50% 50%, rgba(255, 128, 128, 0.15) 0%, rgba(255, 128, 128, 0.08) 100%)",backdropFilter:"blur(25px)"};default:return{background:"radial-gradient(50% 50% at 50% 50%, rgba(95, 229, 92, 0.15) 0%, rgba(95, 229, 92, 0.08) 100%)",backdropFilter:"blur(25px)"}}})(),onClick:e=>e.stopPropagation(),children:[e.type===WT?a.jsx(eM,{}):null,a.jsx("span",{className:"ml-2 text-[16px] flex-1 font-medium leading-5 whitespace-pre-line break-words",style:{color:r(),textShadow:(()=>{switch(e.type){case WT:return"0 0 20px rgba(95, 229, 92, 0.20)";case qT:return"0 0 20px rgba(239, 68, 68, 0.20)";default:return"0 0 20px rgba(95, 229, 92, 0.20)"}})(),fontFamily:'Brockmann, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',fontSize:"16px",fontWeight:"500",lineHeight:"20px",letterSpacing:"-0.2px"},children:e.message}),a.jsx("button",{title:"Close",onClick:()=>{i(!0),setTimeout(()=>{t(e.id)},300)},className:"flex-shrink-0 ml-6 transition-opacity cursor-pointer pointer-events-auto opacity-60 hover:opacity-80",type:"button",children:a.jsx(tM,{color:r()})})]})},sM=({toasts:e,removeToast:t,position:n})=>{if(0===e.length)return null;return Be.createPortal(a.jsx("div",{className:(()=>{switch(n){case ZT:return"fixed top-4 left-4 z-[99999] flex flex-col gap-3 max-md:left-2 max-md:right-2 max-md:w-auto";case YT:return"fixed top-4 left-1/2 transform -translate-x-1/2 z-[99999] flex flex-col gap-3 max-md:left-2 max-md:right-2 max-md:transform-none max-md:translate-x-0";case KT:return"fixed top-4 right-4 z-[99999] flex flex-col gap-3 max-md:left-2 max-md:right-2";case JT:return"fixed bottom-4 left-4 z-[99999] flex flex-col-reverse gap-3 max-md:left-2 max-md:right-2 max-md:w-auto";case QT:return"fixed bottom-4 left-1/2 transform z-[99999] -translate-x-1/2 z-[9999] flex flex-col-reverse gap-3 max-md:left-2 max-md:right-2 max-md:transform-none max-md:translate-x-0";case XT:return"fixed bottom-4 right-4 z-[99999] flex flex-col-reverse gap-3 max-md:left-2 max-md:right-2";default:return"fixed bottom-4 left-1/2 z-[99999] transform -translate-x-1/2 z-[9999] flex flex-col-reverse gap-3 max-md:left-2 max-md:right-2 max-md:transform-none max-md:translate-x-0"}})(),children:e.map(e=>a.jsx(nM,{toast:e,onRemove:t,position:n},e.id))}),document.body)},iM=({children:e})=>{const[t,n]=Pe.useState([]),[s,i]=Pe.useState(QT),r=e=>{n(t=>t.filter(t=>t.id!==e))},o={addToast:(e,t=WT,s=2e3,i)=>{const a=Date.now()+Math.random(),r={id:a,message:e,type:t,duration:Math.min(s,2e3),uniqueId:i};return n(e=>{if(i){const t=e.findIndex(e=>e.uniqueId===i);if(-1!==t){const n=[...e];return n[t]=r,n}}return[...e,r]}),a},removeToast:r,removeAllToasts:()=>{n([])},toasts:t,position:s,changePosition:e=>{i(e)}};return a.jsxs(UT.Provider,{value:o,children:[e,a.jsx(sM,{toasts:t,removeToast:r,position:s})]})},aM=()=>{const e=Pe.useContext(UT);if(!e)throw new Error("useNewToast must be used within a ToastProvider");const{addToast:t,removeToast:n,removeAllToasts:s,changePosition:i}=e;return{newToast:{success:(e,n,s)=>t(e,WT,n,s),error:(e,n,s)=>t(e,qT,n,s),info:(e,n,s)=>t(e,GT,n,s)},removeToast:n,removeAllToasts:s,changePosition:i}},rM=({size:e=24,width:t,height:n,className:s="",fill:i,gradientColors:r={start:"#FFF4DF",end:"#FFD702"}})=>{const o=t||e,l=n||e,c=`team-people-gradient-${Math.random().toString(36).substring(2,11)}`;return a.jsxs("svg",{width:o,height:l,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:s,children:[a.jsx("path",{d:"M12 4.28906C11.6627 4.28906 11.3286 4.35551 11.0169 4.48461C10.7053 4.6137 10.4221 4.80292 10.1835 5.04146C9.945 5.28 9.75578 5.56319 9.62669 5.87486C9.49759 6.18653 9.43114 6.52057 9.43114 6.85792C9.43114 7.19527 9.49759 7.52931 9.62669 7.84098C9.75578 8.15265 9.945 8.43584 10.1835 8.67438C10.4221 8.91292 10.7053 9.10214 11.0169 9.23123C11.3286 9.36033 11.6627 9.42678 12 9.42678C12.6813 9.42678 13.3347 9.15613 13.8165 8.67438C14.2982 8.19262 14.5689 7.53922 14.5689 6.85792C14.5689 6.17662 14.2982 5.52322 13.8165 5.04146C13.3347 4.55971 12.6813 4.28906 12 4.28906ZM17.7857 5.57221C17.2742 5.57221 16.7837 5.77539 16.422 6.13707C16.0603 6.49875 15.8571 6.98929 15.8571 7.50078C15.8571 8.01227 16.0603 8.50281 16.422 8.86448C16.7837 9.22616 17.2742 9.42935 17.7857 9.42935C18.2972 9.42935 18.7877 9.22616 19.1494 8.86448C19.5111 8.50281 19.7143 8.01227 19.7143 7.50078C19.7143 6.98929 19.5111 6.49875 19.1494 6.13707C18.7877 5.77539 18.2972 5.57221 17.7857 5.57221ZM6.21429 5.57221C5.7028 5.57221 5.21226 5.77539 4.85058 6.13707C4.4889 6.49875 4.28571 6.98929 4.28571 7.50078C4.28571 8.01227 4.4889 8.50281 4.85058 8.86448C5.21226 9.22616 5.7028 9.42935 6.21429 9.42935C6.72578 9.42935 7.21631 9.22616 7.57799 8.86448C7.93967 8.50281 8.14286 8.01227 8.14286 7.50078C8.14286 6.98929 7.93967 6.49875 7.57799 6.13707C7.21631 5.77539 6.72578 5.57221 6.21429 5.57221ZM8.14286 11.9918C8.14523 11.6523 8.28174 11.3276 8.5226 11.0885C8.76346 10.8493 9.08913 10.7151 9.42857 10.7151H14.5714C14.9124 10.7151 15.2394 10.8505 15.4806 11.0916C15.7217 11.3328 15.8571 11.6598 15.8571 12.0008V15.8579C15.8575 16.2626 15.7941 16.6648 15.6694 17.0498C15.3847 17.9224 14.7983 18.6649 14.0154 19.1441C13.2325 19.6232 12.3044 19.8075 11.3978 19.664C10.4912 19.5204 9.6655 19.0584 9.06893 18.3608C8.47236 17.6632 8.14402 16.7758 8.14286 15.8579V11.9918ZM6.85714 12.0008C6.85714 11.5315 6.98186 11.0931 7.20171 10.7151H4.28571C3.94472 10.7151 3.6177 10.8505 3.37658 11.0916C3.13546 11.3328 3 11.6598 3 12.0008V15.2151C2.99983 15.7413 3.12886 16.2596 3.37578 16.7243C3.6227 17.189 3.97994 17.586 4.41614 17.8804C4.85234 18.1748 5.35415 18.3576 5.8775 18.4127C6.40085 18.4679 6.92974 18.3937 7.41771 18.1966C7.04845 17.4719 6.85633 16.67 6.85714 15.8566V12.0008ZM17.1429 12.0008V15.8579C17.1429 16.7001 16.941 17.4946 16.5823 18.1966C17.0703 18.3937 17.5991 18.4679 18.1225 18.4127C18.6459 18.3576 19.1477 18.1748 19.5839 17.8804C20.0201 17.586 20.3773 17.189 20.6242 16.7243C20.8711 16.2596 21.0002 15.7413 21 15.2151V12.0008C21 11.6598 20.8645 11.3328 20.6234 11.0916C20.3823 10.8505 20.0553 10.7151 19.7143 10.7151H16.7983C17.0169 11.0931 17.1429 11.5315 17.1429 12.0008Z",fill:i||`url(#${c})`}),!i&&a.jsx("defs",{children:a.jsxs("linearGradient",{id:c,x1:"4.575",y1:"1.59014",x2:"13.4881",y2:"21.9877",gradientUnits:"userSpaceOnUse",children:[a.jsx("stop",{stopColor:r.start}),a.jsx("stop",{offset:"1",stopColor:r.end})]})})]})},oM=({size:e=20,width:t,height:n,fill:s="#E6E6E6",className:i,onClick:r,style:o})=>{const l=t||e,c=n||e;return a.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:l,height:c,viewBox:"0 0 20 20",fill:"none",className:i,onClick:r,style:o,children:a.jsx("path",{d:"M14.6377 3C16.4946 3.00001 18 4.50536 18 6.3623V12.8555C17.9998 14.7122 16.4945 16.2178 14.6377 16.2178H5.3623C3.50549 16.2178 2.00021 14.7122 2 12.8555V6.3623C2.00001 4.50536 3.50536 3.00001 5.3623 3H14.6377ZM3.15918 7.87012V12.8555C3.15939 14.0719 4.14582 15.0576 5.3623 15.0576H14.6377C15.8542 15.0576 16.8406 14.0719 16.8408 12.8555V7.87012H3.15918ZM8.2168 10.3086C8.56715 10.3446 8.84072 10.6402 8.84082 11C8.84082 11.3599 8.56724 11.6564 8.2168 11.6924L8.14453 11.6963H5.3623C4.97811 11.6963 4.66699 11.3842 4.66699 11C4.6671 10.6159 4.97818 10.3047 5.3623 10.3047H8.14453L8.2168 10.3086ZM5.3623 4.15918C4.14569 4.15919 3.15919 5.14569 3.15918 6.3623V6.71094H16.8408V6.3623C16.8408 5.14569 15.8543 4.15919 14.6377 4.15918H5.3623Z",fill:s})})},lM=({size:e=32,width:t,height:n,className:s="",onClick:i,style:r,fillStart:o="white",fillEnd:l="white"})=>{const c=t||e,d=n||e,u=`paint0_linear_collab_${Math.random().toString(36).substr(2,9)}`;return a.jsxs("svg",{width:c,height:d,viewBox:"0 0 32 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:s,onClick:i,style:r,children:[a.jsx("path",{d:"M13.3291 16.959C13.6453 17.9178 14.1369 18.8099 14.7793 19.5889C13.7779 20.3746 12.5718 20.8562 11.3047 20.9766V27.999H4.11523V20.0273C4.11523 19.4739 4.33528 18.9431 4.72656 18.5518C5.11793 18.1604 5.64868 17.9404 6.20215 17.9404H10.6787C11.1738 17.9496 11.6657 17.8544 12.1221 17.6621C12.5784 17.4698 12.9898 17.1839 13.3291 16.8232V16.959ZM15.1543 11.8252C15.5241 11.7771 15.8996 11.8621 16.2129 12.0645C16.5263 12.267 16.7581 12.5745 16.8662 12.9316L17.7217 15.4883C17.9554 16.2028 18.4094 16.8251 19.0186 17.2656C19.6277 17.706 20.3607 17.9423 21.1123 17.9404H25.5996C26.1531 17.9404 26.6838 18.1604 27.0752 18.5518C27.4664 18.9431 27.6865 19.474 27.6865 20.0273V27.999H20.4863V20.9766C19.2121 20.85 18.0018 20.3565 17.002 19.5566C16.0021 18.7567 15.2556 17.6842 14.8525 16.4688L13.9756 13.8291C13.9027 13.6202 13.8758 13.3979 13.8975 13.1777C13.9191 12.9576 13.9884 12.7444 14.1006 12.5537C14.2128 12.3631 14.3659 12.2 14.5479 12.0742C14.7297 11.9485 14.9364 11.8629 15.1543 11.8252ZM7.72559 11.3037C8.0613 11.3037 8.39394 11.3706 8.7041 11.499C9.01411 11.6275 9.29591 11.8155 9.5332 12.0527C9.77056 12.2901 9.95942 12.5717 10.0879 12.8818C10.2163 13.192 10.2822 13.5247 10.2822 13.8604C10.2822 14.196 10.2163 14.5287 10.0879 14.8389C9.95943 15.149 9.77057 15.4306 9.5332 15.668C9.29583 15.9053 9.01425 16.0942 8.7041 16.2227C8.39394 16.3511 8.0613 16.417 7.72559 16.417C7.38988 16.417 7.05722 16.3511 6.74707 16.2227C6.43694 16.0942 6.15534 15.9053 5.91797 15.668C5.68068 15.4307 5.49272 15.1489 5.36426 14.8389C5.23579 14.5287 5.16895 14.1961 5.16895 13.8604C5.16896 13.5247 5.2358 13.192 5.36426 12.8818C5.49273 12.5719 5.6807 12.29 5.91797 12.0527C6.15526 11.8155 6.43706 11.6275 6.74707 11.499C7.05722 11.3706 7.38988 11.3037 7.72559 11.3037ZM24.0654 11.3037C24.4011 11.3037 24.7338 11.3706 25.0439 11.499C25.354 11.6275 25.6357 11.8155 25.873 12.0527C26.1104 12.2901 26.2993 12.5718 26.4277 12.8818C26.5562 13.192 26.6221 13.5247 26.6221 13.8604C26.6221 14.5384 26.3525 15.1885 25.873 15.668C25.3936 16.1473 24.7434 16.417 24.0654 16.417C23.3876 16.4169 22.7372 16.1473 22.2578 15.668C21.7785 15.1886 21.5098 14.5382 21.5098 13.8604C21.5098 13.5247 21.5756 13.192 21.7041 12.8818C21.8325 12.5719 22.0206 12.29 22.2578 12.0527C22.4952 11.8153 22.7777 11.6275 23.0879 11.499C23.3979 11.3707 23.7299 11.3038 24.0654 11.3037ZM20.7637 6.17969C21.0392 6.17978 21.3036 6.28914 21.499 6.4834C21.6933 6.67884 21.8027 6.94321 21.8027 7.21875C21.8027 7.49441 21.6934 7.75958 21.499 7.95508L20.0273 9.43652C19.9304 9.53414 19.8154 9.61212 19.6885 9.66504C19.5614 9.71798 19.4248 9.74508 19.2871 9.74512C19.1495 9.74512 19.0128 9.71794 18.8857 9.66504C18.7586 9.61208 18.6429 9.53429 18.5459 9.43652C18.4481 9.33952 18.3704 9.22383 18.3174 9.09668C18.2644 8.96956 18.2373 8.83301 18.2373 8.69531C18.2373 8.55761 18.2644 8.42105 18.3174 8.29395C18.3703 8.16696 18.4483 8.05199 18.5459 7.95508L20.0273 6.4834C20.2228 6.28906 20.488 6.17969 20.7637 6.17969ZM9.99023 6.31543C10.2323 6.28952 10.4759 6.34872 10.6787 6.4834L12.2021 7.95508C12.2998 8.05199 12.3778 8.16697 12.4307 8.29395C12.4836 8.42105 12.5107 8.55761 12.5107 8.69531C12.5107 8.833 12.4836 8.96957 12.4307 9.09668C12.3777 9.22383 12.2999 9.33952 12.2021 9.43652C12.1047 9.53323 11.9885 9.60921 11.8613 9.66113C11.7343 9.71301 11.5982 9.74005 11.4609 9.73926C11.3167 9.7457 11.1727 9.72196 11.0381 9.66992C10.9035 9.61787 10.7811 9.53827 10.6787 9.43652L9.24902 7.95508C9.10859 7.75628 9.04164 7.51414 9.06055 7.27148C9.07952 7.02874 9.18287 6.79963 9.35254 6.625C9.5222 6.45041 9.74817 6.34137 9.99023 6.31543ZM15.374 4C15.6506 4.00001 15.9157 4.11012 16.1113 4.30566C16.3069 4.50124 16.4169 4.7664 16.417 5.04297V7.12988C16.417 7.40662 16.307 7.67248 16.1113 7.86816C15.9157 8.06368 15.6506 8.17381 15.374 8.17383C15.0973 8.17383 14.8314 8.06385 14.6357 7.86816C14.4402 7.6725 14.3301 7.40653 14.3301 7.12988V5.04297C14.3302 4.76651 14.4403 4.50121 14.6357 4.30566C14.8314 4.10998 15.0973 4 15.374 4Z",fill:`url(#${u})`}),a.jsx("defs",{children:a.jsxs("linearGradient",{id:u,x1:"15.9009",y1:"4",x2:"15.9009",y2:"27.999",gradientUnits:"userSpaceOnUse",children:[a.jsx("stop",{stopColor:o}),a.jsx("stop",{offset:"1",stopColor:l,stopOpacity:"0.6"})]})})]})},cM=({size:e=20,color:t="#CCCCCC",className:n})=>a.jsx("svg",{width:e,height:e,viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:n,children:a.jsx("path",{d:"M3.33398 16.6654V14.332C3.33398 13.8598 3.45551 13.4258 3.69857 13.0299C3.94162 12.6341 4.26454 12.332 4.66732 12.1237C5.52843 11.6931 6.40343 11.3702 7.29232 11.1549C8.18121 10.9397 9.08398 10.832 10.0007 10.832H10.2923C10.1395 11.082 10.025 11.3494 9.94857 11.6341C9.87218 11.9188 9.83398 12.207 9.83398 12.4987C9.08398 12.5126 8.33746 12.6133 7.5944 12.8008C6.85135 12.9883 6.12565 13.2626 5.41732 13.6237C5.29232 13.6931 5.19162 13.7904 5.11523 13.9154C5.03885 14.0404 5.00065 14.1793 5.00065 14.332V14.9987H10.8965L12.5632 16.6654H3.33398ZM10.0007 9.9987C9.08398 9.9987 8.29926 9.67231 7.64648 9.01953C6.99371 8.36675 6.66732 7.58203 6.66732 6.66536C6.66732 5.7487 6.99371 4.96398 7.64648 4.3112C8.29926 3.65842 9.08398 3.33203 10.0007 3.33203C10.9173 3.33203 11.702 3.65842 12.3548 4.3112C13.0076 4.96398 13.334 5.7487 13.334 6.66536C13.334 7.58203 13.0076 8.36675 12.3548 9.01953C11.702 9.67231 10.9173 9.9987 10.0007 9.9987ZM10.0007 8.33203C10.459 8.33203 10.8513 8.16884 11.1777 7.84245C11.5041 7.51606 11.6673 7.1237 11.6673 6.66536C11.6673 6.20703 11.5041 5.81467 11.1777 5.48828C10.8513 5.16189 10.459 4.9987 10.0007 4.9987C9.54232 4.9987 9.14996 5.16189 8.82357 5.48828C8.49718 5.81467 8.33398 6.20703 8.33398 6.66536C8.33398 7.1237 8.49718 7.51606 8.82357 7.84245C9.14996 8.16884 9.54232 8.33203 10.0007 8.33203ZM14.9173 16.6654L12.0007 13.7487C11.8201 13.5681 11.6916 13.3737 11.6152 13.1654C11.5388 12.957 11.5007 12.7487 11.5007 12.5404C11.5007 12.0959 11.6604 11.7001 11.9798 11.3529C12.2993 11.0056 12.709 10.832 13.209 10.832C13.5979 10.832 13.9034 10.9223 14.1257 11.1029C14.3479 11.2834 14.6118 11.5265 14.9173 11.832C15.1951 11.5543 15.4486 11.3181 15.6777 11.1237C15.9069 10.9293 16.2229 10.832 16.6257 10.832C17.1395 10.832 17.5527 11.0091 17.8652 11.3633C18.1777 11.7174 18.334 12.1168 18.334 12.5612C18.334 12.7695 18.2923 12.9779 18.209 13.1862C18.1257 13.3945 18.0007 13.582 17.834 13.7487L14.9173 16.6654Z",fill:t})}),dM=({size:e=24,color:t="#B3F8FF",className:n})=>a.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:n,children:a.jsx("path",{d:"M20.1818 18.3619H22V20.18H2V18.3619H3.81818V4.7255C3.81818 4.48439 3.91396 4.25316 4.08445 4.08267C4.25494 3.91219 4.48617 3.81641 4.72727 3.81641H13.8182C14.0593 3.81641 14.2905 3.91219 14.461 4.08267C14.6315 4.25316 14.7273 4.48439 14.7273 4.7255V18.3619H18.3636V11.0891H16.5455V9.27095H19.2727C19.5138 9.27095 19.7451 9.36673 19.9156 9.53722C20.086 9.70771 20.1818 9.93894 20.1818 10.18V18.3619ZM5.63636 5.63459V18.3619H12.9091V5.63459H5.63636ZM7.45455 11.0891H11.0909V12.9073H7.45455V11.0891ZM7.45455 7.45277H11.0909V9.27095H7.45455V7.45277Z",fill:t})}),uM=({size:e=24,color:t="#CCCCCC",className:n=""})=>a.jsxs("svg",{width:e,height:e,viewBox:"0 0 25 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:n,children:[a.jsx("path",{opacity:"0.5",d:"M22.6518 9.13063C22.634 8.85133 22.3245 8.7023 22.0884 8.85255L16.8328 12.197C15.5325 13.025 14.6836 13.5655 13.7507 13.7807C12.9279 13.9705 12.0727 13.9705 11.2498 13.7807C10.3169 13.5655 9.46808 13.025 8.16776 12.197L2.9122 8.85255C2.6761 8.7023 2.36654 8.85132 2.34878 9.13061C2.30018 9.89445 2.30023 10.7967 2.3003 11.8818L2.3003 12.041C2.30029 13.3049 2.30029 14.3101 2.36655 15.1211C2.4344 15.9515 2.57633 16.6597 2.9067 17.3081C3.44011 18.3549 4.29123 19.2061 5.3381 19.7395C5.98649 20.0698 6.69462 20.2118 7.52509 20.2796C8.33605 20.3459 9.3412 20.3459 10.6051 20.3459H14.3954C15.6593 20.3459 16.6645 20.3459 17.4755 20.2796C18.306 20.2118 19.0141 20.0698 19.6625 19.7395C20.7094 19.2061 21.5605 18.3549 22.0939 17.3081C22.4243 16.6597 22.5662 15.9515 22.634 15.1211C22.7003 14.3101 22.7003 13.305 22.7003 12.0411L22.7003 11.8818C22.7004 10.7967 22.7004 9.89446 22.6518 9.13063Z",fill:t}),a.jsx("path",{d:"M14.3951 3.65625H10.6048C9.34094 3.65624 8.33573 3.65624 7.52475 3.7225C6.69429 3.79035 5.98616 3.93228 5.33776 4.26265C4.42781 4.72629 3.66575 5.42999 3.13168 6.29362C3.00542 6.49781 3.07782 6.76123 3.28036 6.89012L9.01514 10.5395C10.517 11.4952 11.083 11.8404 11.6663 11.9749C12.2149 12.1014 12.785 12.1014 13.3336 11.9749C13.9169 11.8404 14.4829 11.4952 15.9848 10.5395L21.7196 6.8901C21.9221 6.76122 21.9945 6.49779 21.8682 6.29361C21.3342 5.42998 20.5721 4.72629 19.6622 4.26265C19.0138 3.93228 18.3056 3.79035 17.4752 3.7225C16.6642 3.65624 15.659 3.65624 14.3951 3.65625Z",fill:t})]}),pM=wv.fork.fork,mM=wv.github.gitDot,hM="free",xM="Pro",fM="Standard",gM="Starter",vM=12,bM=750,yM=1,wM=2,jM=3,CM={background:"\n linear-gradient(90deg, #ffffff30, #00000050),\n #F3CA5F\n ",backgroundSize:"cover",backgroundPosition:"center",backgroundBlendMode:"overlay, normal",boxShadow:"\n 0px 0px 20px 0px #F3CA5F66,\n 0px 2.18px 3.64px 1.45px #FFFFFF66 inset,\n 0px -1.45px 0px 0px #00000033 inset,\n 0px 0.73px 0.73px 0.73px #0000001A\n "},NM={background:"#fff",backgroundSize:"cover",backgroundPosition:"center",backgroundBlendMode:"overlay, normal"};function FM({isOpen:e,onOpenChange:t,organizationId:n,organizationName:s,planType:i="personal",triggerLocation:r="default",shouldShowModelSelectorTooltipAfterClose:o=!1,onReturnFlow:l}){var c,d;const{toast:u}=un(),{newToast:p}=aM(),[m,h]=Pe.useState(null),[x,f]=Pe.useState(null),[g,v]=Pe.useState(!1),[b,y]=Pe.useState(!1),[w,j]=Pe.useState(null),C=Ft(),{hasCreatedWorkspace:N}=ev(),{user:F,userDetails:_}=Yg(),{subscriptionPlansResponse:k,personalPlansResponse:S,tier:E,personalTier:I,creditResponse:A,dailyCreditsEnabled:T,loading:M}=sv();"razorpay"===(null==_?void 0:_.payment_provider)&&(null==_||_.country_code);const D=null==(c=null==_?void 0:_.organizations)?void 0:c.find(e=>e.created_by===(null==F?void 0:F.id)&&"PENDING"!==e.status),L=null==(d=null==_?void 0:_.organizations)?void 0:d.some(e=>e.created_by===(null==F?void 0:F.id)&&"PENDING"===e.status),{data:P}=Rx(void 0,{skip:!F}),{data:R,isLoading:O}=zx(n?{organization_id:n}:void 0,{skip:!n}),{data:z}=Rx(n?{organization_id:n}:void 0,{skip:!n});Pe.useEffect(()=>{(async()=>{if(e&&F)try{const e=await fm();j(e)}catch(t){}})()},[e,F]);const B="personal"===i?S:n&&R?R:k,H="personal"===i?M:n?O:M,$=e=>{if(!(null==e?void 0:e.plans))return[];const t=[];return Object.values(e.plans).forEach(e=>{e.monthly_plans&&t.push(...e.monthly_plans),e.yearly_plans&&t.push(...e.yearly_plans)}),t},V=(e,t)=>{const n=$(B);return t?n.filter(e=>e.billing_period===t):n},U="personal"===i?null==S?void 0:S.current_subscription:n&&R?null==R?void 0:R.current_subscription:null==B?void 0:B.current_subscription,W=n&&z?z:A,{handleManageSubscription:q,isUpgradeLoading:G,handleRazorpayPayment:Z,paymentModalState:Y,hidePaymentModals:K,subscriptionPaymentResult:J,hideSubscriptionPaymentResult:Q,subscriptionCancelledSuccessfully:X}=TT(),[ee,te]=Pe.useState("monthly"),ne=Pe.useRef(jv),se=ne.current.toUpperCase()===Cv,[ie,ae]=Pe.useState(null),[re,oe]=Pe.useState(!1),[le,ce]=Pe.useState(""),[de,ue]=Pe.useState(!1),[pe,me]=Pe.useState(""),{isMobile:he}=nI(),xe=Ig(),fe=(()=>{try{const e=Nd.getFeatureFlag("enterprise_plan_enabled");return!0===e||"true"===e}catch(e){return!1}})();Pe.useEffect(()=>{e&&(U&&(te("YEARLY"===U.billing_period?"annually":"monthly"),_e(U.tier_name)&&f(U.id)),v(!1))},[e,U]);const ge=e=>{t(e),o&&setTimeout(()=>{ep(),C(Jf(!0))},300),l&&setTimeout(()=>{l()},300)},ve=e=>{te(e)},be=async(e,t)=>{h(e.id);try{if(se){const n={amount:0,price:0,selected:!1,discount:0,currency:ne.current||"USD",couponCode:null==ie?void 0:ie.code};await Z(n,t,{isSubscription:!0,planId:e.id,planName:e.tier_name,planType:i})}else{const{url:n}=await zp(0,!0,e.id,t);n&&(window.location.href=n)}}catch(n){u({title:"Error",description:n.response.data.detail,variant:"destructive"})}finally{h(null)}},ye=()=>!!((null==P?void 0:P.daily_credits)&&P&&P.daily_credit_per_day>0),we=()=>a.jsx(a.Fragment,{children:ye()?a.jsxs("div",{className:"flex items-start",children:[a.jsx(yT,{fill:"#CCC",className:"w-5 h-5 mr-2 mt-0.5"}),a.jsx("span",{className:"text-[14px] leading-5",children:a.jsx("span",{className:"text-[#ccc] font-medium font-inter ",children:P.daily_credit_per_day===P.daily_credit_max_per_window?`${P.daily_credit_max_per_window} free monthly credits`:`${P.daily_credit_per_day} daily credits (upto ${P.daily_credit_max_per_window} per month)`})})]}):null}),je=Pe.useMemo(()=>a.jsxs(a.Fragment,{children:[xe&&a.jsxs("div",{className:"flex items-start",children:[a.jsx("img",{title:"Github",src:mM,className:"w-5 h-5 mr-2 mt-0.5"}),a.jsx("span",{className:"text-[14px] leading-5",children:a.jsx("span",{className:"text-[#CCC] font-inter",children:"Save to Github"})})]}),xe&&a.jsxs("div",{className:"flex items-start",children:[a.jsx("img",{title:"Fork",src:pM,className:"w-5 h-5 mr-2 mt-0.5"}),a.jsx("span",{className:"text-[14px] leading-5",children:a.jsx("span",{className:"text-[#CCC] font-inter",children:"Fork"})})]})]}),[xe]),Ce=async e=>{if("free-tier"!==e.id){h(e.id);try{if(null==F?void 0:F.id){const t=(null==U?void 0:U.tier_name)||"free",s=Ne(e.tier_name),a="YEARLY"===e.billing_period?"yearly":"monthly",o="team"===i||!!n;pp(F.id,t,s,a,o,n,r)}const t="team"===i&&n;if(se){const s={amount:0,price:0,selected:!1,discount:0,currency:ne.current||"USD",couponCode:null==ie?void 0:ie.code};await Z(s,t?n:void 0,{isSubscription:!0,planId:e.id,planName:e.tier_name,planType:i})}else{const{url:s}=await zp(0,!0,e.id,t?n:void 0);s&&(window.location.href=s)}}catch(t){u({title:"Error",description:t.response.data.detail,variant:"destructive"})}finally{h(null)}}else u({title:"Downgrade to Free",description:"Please contact support to downgrade to the free tier.",variant:"default"})},Ne=e=>{const t=Re(e);return t.includes("teams")?"Team":t.includes("standard")?fM:t.includes("starter")?gM:t.includes("pro")?xM:e},Fe=e=>Ne(e)===xM,_e=e=>{const t=Ne(e);return t===fM||t===gM},ke=e=>"Team"===Ne(e),Se=e=>"YEARLY"===e.billing_period?Math.ceil(Math.round(e.amount/vM*100)/100):e.amount,Ee=()=>a.jsxs("div",{className:"flex items-center",children:[a.jsx(gS,{className:"w-4 h-4 mr-2 animate-spin"}),a.jsx("span",{children:"Processing..."})]}),Ie=()=>{var e;return"initiated_cancellation"===(null==(e=null==W?void 0:W.subscription)?void 0:e.status)},Ae=()=>"personal"===i?!U:E===hM,Te=e=>Fe(e)||ke(e)?CM:NM,Me=(e,t)=>bb("w-full p-[10px] max-h-[40px] pr-[16px] text-[14px] leading-5 font-semibold rounded-full items-center flex justify-center","font-brockmann text-black tracking-[-0.2px] gap-1"),De=e=>{const t="gap-1 mb-4 font-semibold flex items-center font-['Inter']";return ke(e)?bb(t,"text-transparent bg-clip-text"):bb(t,Fe(e)?"text-[#F3CA5F]":"text-[#fff]")},Le=(e,t)=>{const n="rounded-full py-[8px] px-3 font-inter font-medium",s="bg-[#252529]";return"monthly"===t?bb(n,"max-md:w-full","monthly"===e&&s):bb(n,"flex-1 text-nowrap flex items-center justify-center gap-1","annually"===e&&s)},Re=e=>e.toLowerCase().replace(/\s+/g,""),Oe=e=>{if(!Ae()&&U&&"YEARLY"===U.billing_period&&"monthly"===ee&&Re(e.tier_name)===Re(U.tier_name)&&"MONTHLY"===e.billing_period)return!0;if("personal"===i&&ke(e.tier_name)&&N){const t=null==k?void 0:k.current_subscription;if(t&&"YEARLY"===t.billing_period&&"monthly"===ee&&Re(e.tier_name)===Re(t.tier_name)&&"MONTHLY"===e.billing_period)return!0}return!1},ze=e=>ke(e.tier_name)?a.jsx(Ke,{}):Fe(e.tier_name)?a.jsx(Ye,{}):_e(e.tier_name)?a.jsx(Qe,{}):null,He=(e,t)=>{const s=U&&Re(e.tier_name)===Re(U.tier_name);if(s&&U){if("MONTHLY"===U.billing_period&&"YEARLY"===e.billing_period)return"Upgrade to Annual";if("YEARLY"===U.billing_period&&"MONTHLY"===e.billing_period)return"Downgrade to Monthly";if(U.billing_period===e.billing_period){if(U.id===e.id)return"Current Plan";if(e.ecu_credits&&U.ecu_credits){if(e.ecu_credits>U.ecu_credits)return"Upgrade Current Plan";if(e.ecu_creditsU.amount?"Upgrade Current Plan":e.amount{if(!U)return"upgrade";if("team"===i&&!U.tier_name.toLowerCase().includes("team"))return"upgrade";if("personal"===i&&U.tier_name.toLowerCase().includes("team"))return"downgrade";const t=e=>{const t=e.toLowerCase().replace(/\s+/g,"");return t.includes("free")?0:t.includes("standard")||t.includes("starter")?1:t.includes("pro")?2:t.includes("teams")?3:4},n=t(U.tier_name),s=t(e.tier_name);return s>n?"upgrade":sU.amount?"upgrade":"downgrade"})(e)?"Upgrade":"Downgrade";return`${a} to ${Ne(e.tier_name)}`},$e=e=>{if("YEARLY"!==e.billing_period)return null;const t=V(0,"MONTHLY"),n=null==t?void 0:t.find(t=>Re(t.tier_name)===Re(e.tier_name)&&t.ecu_credits===e.ecu_credits);return(null==n?void 0:n.amount)||null},Ve=Pe.useMemo(()=>$(B).some(e=>"YEARLY"===e.billing_period),[B,i,n]),Ue=Pe.useMemo(()=>Ae()&&!he&&"personal"===i,[Ae,he,i,E,U]),We=Pe.useMemo(()=>{const e={};if(!(null==B?void 0:B.plans))return[];const t="team"===i||!!n,s=D&&"PENDING"!==D.status;Object.entries(B.plans).forEach(([n,a])=>{var r,o,l;const c="annually"===ee?a.yearly_plans:a.monthly_plans;if(c&&c.length>0){ne.current=(null==(l=null==(o=null==(r=null==c?void 0:c.team_plans)?void 0:r[0])?void 0:o.currency)?void 0:l.toUpperCase())||"USD";const n=c[0].tier_name,a=Re(n),d=a.includes("team");if(t&&!d)return;if("personal"===i&&d&&s)return;if(a.includes("standard")||a.includes("starter")){const t=[...c].sort((e,t)=>(e.ecu_credits||0)-(t.ecu_credits||0)),s=t[0];e[n]||(e[n]=[]),e[n].push({...s,variants:t})}else c.forEach(t=>{e[t.tier_name]||(e[t.tier_name]=[]),e[t.tier_name].push(t)})}});const a=[];Object.values(e).forEach(e=>{var t,n;e.length>0&&(ne.current=(null==(n=null==(t=e[0])?void 0:t.currency)?void 0:n.toUpperCase())||"USD"),a.push(...e)});const r=e=>{const t=Re(e);return t.includes("standard")||t.includes("starter")?yM:t.includes("pro")?wM:t.includes("teams")||t.includes("team")?4:jM};return a.sort((e,t)=>r(e.tier_name)-r(t.tier_name))},[B,i,U,ee,n,D]),qe=e=>e.includes("md:max-w-md")?"md:max-w-md":e.includes("md:max-w-3xl")?"md:max-w-3xl":e.includes("md:max-w-5xl")?"md:max-w-5xl":(e.includes("md:max-w-7xl"),"md:max-w-7xl"),Ge=Pe.useMemo(()=>{const e=(e=>{const t=fe?1:0;return e.length+t})(We),t=(e=>1===e?"md:grid-cols-1 md:max-w-md md:mx-auto":2===e?"md:grid-cols-2 md:max-w-3xl md:mx-auto":3===e?"md:grid-cols-3 md:max-w-5xl md:mx-auto":"md:grid-cols-4 md:max-w-7xl md:mx-auto")(e);return{totalCards:e,gridColumns:t,maxWidth:qe(t)}},[We,i,Ue,he,fe]),Ze=()=>{(async e=>{if(!e.trim())return p.error("Please enter a coupon code"),void me("Please enter a coupon code");ue(!0),me("");try{const t=e.toUpperCase();let n=0;switch(t){case"INSIDEIIMUPI40":n=40;break;case"INSIDEIIMCARD40":n=10;break;case"STUDENTCARD50":case"STUDENTUPI50":n=50;break;case"AISENSYUPI30":case"AISENSYCARD30":n=30;break;default:return p.error("Invalid coupon code"),me("Invalid coupon code"),void ue(!1)}ae({code:t,discount:n}),p.success("Coupon Applied! The discount will be auto applied at the checkout"),oe(!1),ce(""),me("")}catch(t){me("Failed to validate coupon. Please try again.")}finally{ue(!1)}})(le)},Ye=()=>a.jsxs("div",{className:"flex-grow space-y-2",children:[a.jsxs("div",{className:"flex items-start",children:[a.jsx(uA,{color:"#CCC",className:"w-5 h-5 mr-2 mt-0.5"}),a.jsx("span",{className:"text-[14px] leading-5",children:a.jsx("span",{className:"text-[#CCC] font-medium font-inter",children:"Everything in Standard"})})]}),a.jsxs("div",{className:"flex items-start",children:[a.jsx(hA,{fill:"#FF8C66",className:"w-5 h-5 mr-2 mt-0.5"}),a.jsx("span",{className:"text-[14px] leading-5",children:a.jsx("span",{className:"text-[#FF8C66] font-medium font-inter",children:"1M context window"})}),a.jsx(uA,{color:"#FF8C66",className:"ml-1 mt-0.5",size:20})]}),a.jsxs("div",{className:"flex items-start",children:[a.jsx(pA,{color:"#FF8C66",className:"w-5 h-5 mr-2 mt-0.5"}),a.jsx("span",{className:"text-[14px] leading-5",children:a.jsx("span",{className:"text-[#FF8C66] font-medium font-inter",children:"Ultra thinking"})}),a.jsx(uA,{color:"#FF8C66",className:"ml-1 mt-0.5",size:20})]}),a.jsxs("div",{className:"flex items-start",children:[a.jsx(gT,{color:"#CCC",className:"w-5 h-5 mr-2 mt-0.5"}),a.jsx("span",{className:"text-[14px] leading-5",children:a.jsx("span",{className:"font-medium text-[#CCC] font-inter",children:"System Prompt Edit"})})]}),a.jsxs("div",{className:"flex items-start",children:[a.jsx(BE,{primaryColor:"#CCC",className:"w-5 h-5 mr-2 mt-0.5"}),a.jsx("span",{className:"text-[14px] leading-5",children:a.jsx("span",{className:"text-[#CCC] font-inter",children:"Ability to build Custom Agents"})})]}),a.jsxs("div",{className:"flex items-start",children:[a.jsx(vT,{color:"#CCC",className:"w-5 h-5 mr-2 mt-0.5"}),a.jsx("span",{className:"text-[14px] leading-5",children:a.jsx("span",{className:"text-[#CCC] font-inter",children:"Mobile App Development"})})]}),a.jsxs("div",{className:"flex items-start",children:[a.jsx(bT,{fill:"#CCC",className:"w-5 h-5 mr-2 mt-0.5"}),a.jsx("span",{className:"text-[14px] leading-5",children:a.jsx("span",{className:"text-[#CCC] font-inter",children:"2x Bigger Machine"})})]}),a.jsxs("div",{className:"flex items-start",children:[a.jsx(yT,{fill:"#CCC",className:"w-5 h-5 mr-2 mt-0.5"}),a.jsx("span",{className:"text-[14px] leading-5",children:a.jsxs("span",{className:"text-[#CCC] font-inter",children:[bM," Monthly Credits"]})})]}),ye()?we():null,a.jsxs("div",{className:"flex items-start",children:[a.jsx(wT,{fill:"#CCC",className:"w-5 h-5 mr-2 mt-0.5"}),a.jsx("span",{className:"text-[14px] leading-5",children:a.jsx("span",{className:"text-[#CCC] font-inter",children:"Priority Support"})})]})]}),Ke=()=>a.jsxs("div",{className:"flex-grow space-y-2",children:[a.jsxs("div",{className:"flex items-start",children:[a.jsx(uA,{color:"#CCC",className:"w-5 h-5 mr-2 mt-0.5"}),a.jsx("span",{className:"text-[14px] leading-5",children:a.jsx("span",{className:"font-medium font-inter text-[#CCC]",children:"Everything in Pro"})})]}),a.jsxs("div",{className:"flex items-start",children:[a.jsx(yT,{fill:"#CCC",className:"w-5 h-5 mr-2 mt-0.5"}),a.jsx("span",{className:"text-[14px] leading-5",children:a.jsx("span",{className:"text-[#CCC] font-inter",children:"Shared team pool: 1250 credits per month"})})]}),a.jsxs("div",{className:"flex items-start",children:[a.jsx(oM,{fill:"#CCC",className:"w-5 h-5 mr-2 mt-0.5"}),a.jsx("span",{className:"text-[14px] leading-5",children:a.jsx("span",{className:"text-[#CCC] font-inter",children:"Central billing and administration"})})]}),a.jsxs("div",{className:"flex items-start",children:[a.jsx(lM,{fillStart:"#ccc",className:"w-5 h-5 mr-2 mt-0.5"}),a.jsx("span",{className:"text-[14px] leading-5",children:a.jsx("span",{className:"text-[#CCC] font-inter",children:"Collaborative workspace"})})]}),a.jsxs("div",{className:"flex items-start",children:[a.jsx(cM,{className:"w-5 h-5 mr-2 mt-0.5 text-[#ccc]"}),a.jsx("span",{className:"text-[14px] leading-5",children:a.jsx("span",{className:"text-[#CCC] font-inter",children:"Upto 5 members in a team"})})]}),a.jsxs("div",{className:"flex items-start",children:[a.jsx(wT,{fill:"#CCC",className:"w-5 h-5 mr-2 mt-0.5"}),a.jsx("span",{className:"text-[14px] leading-5",children:a.jsx("span",{className:"text-[#CCC] font-inter",children:"For additional members and team support, contact us"})})]})]}),Je=()=>a.jsxs("div",{className:"flex-grow space-y-2",children:[a.jsxs("div",{className:"flex items-start",children:[a.jsx(rM,{fill:"#CCC",className:"w-5 h-5 mr-2 mt-0.5"}),a.jsx("span",{className:"text-[14px] leading-5",children:a.jsx("span",{className:"font-medium font-inter text-[#CCC]",children:"Everything in Teams"})})]}),a.jsxs("div",{className:"flex items-start",children:[a.jsx(qk,{className:"w-5 h-5 mr-2 mt-0.5"}),a.jsx("span",{className:"text-[14px] leading-5",children:a.jsx("span",{className:"text-[#CCC] font-inter",children:"Single sign-on (SSO)"})})]}),a.jsxs("div",{className:"flex items-start",children:[a.jsx(wT,{fill:"#CCC",className:"w-5 h-5 mr-2 mt-0.5"}),a.jsx("span",{className:"text-[14px] leading-5",children:a.jsx("span",{className:"text-[#CCC] font-inter",children:"Dedicated Enterprise Support"})})]})]}),Qe=()=>a.jsxs("div",{className:"flex-grow space-y-2",children:[a.jsxs("div",{className:"flex items-start",children:[a.jsx(vT,{color:"#CCC",className:"w-5 h-5 mr-2 mt-0.5"}),a.jsx("span",{className:"text-[14px] leading-5",children:a.jsx("span",{className:"text-[#CCC] font-inter",children:"Mobile App Development"})})]}),a.jsxs("div",{className:"flex items-start",children:[a.jsx(dA,{color:"#CCC",opacity:1,className:"w-5 h-5 mr-2 mt-0.5"}),a.jsx("span",{className:"text-[14px] leading-5",children:a.jsx("span",{className:"text-[#CCC] font-inter",children:"Private Apps"})})]}),ye()?we():null,a.jsxs("div",{className:"flex items-start",children:[a.jsx(jT,{fill:"#ccc",className:"w-5 h-5 mr-2 mt-0.5"}),a.jsx("span",{className:"text-[14px] leading-5",children:a.jsx("span",{className:"text-[#ccc] font-inter",children:"Ability to buy additional credits"})})]}),je]}),Xe=()=>a.jsxs("div",{className:"flex-grow space-y-2 md:space-y-2",children:[ye()?we():null,a.jsxs("div",{className:"flex items-start",children:[a.jsx(qk,{className:"w-5 h-5 text-white mr-2 mt-0.5"}),a.jsx("span",{className:"text-[14px] leading-5",children:a.jsx("span",{className:"text-gray-400 font-inter",children:"Basic access to all features"})})]})]});return e?H?Be.createPortal(a.jsx(Bt,{children:a.jsx(zt.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},className:"fixed inset-0 z-[9999] bg-black/50 flex items-center justify-center",children:a.jsx(zt.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},transition:{duration:.2},className:"bg-[#1C1C1F] border border-[#2E2F34] rounded-[20px] p-8 max-w-md mx-4 text-center",children:a.jsxs("div",{className:"flex flex-col items-center gap-4",children:[a.jsx("div",{className:"w-8 h-8 border-2 border-[#F3CA5F] border-t-transparent rounded-full animate-spin"}),a.jsx("div",{className:"font-medium text-white",children:"Loading latest plans..."}),a.jsx("div",{className:"text-sm text-gray-400",children:"Please wait while we fetch the most up-to-date pricing"})]})})})}),document.body):a.jsxs(a.Fragment,{children:[Be.createPortal(a.jsx(Bt,{children:a.jsxs("div",{className:"fixed inset-0 z-[9999]",children:[a.jsx(zt.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},className:"absolute inset-0 bg-[#18181A]",onClick:()=>ge(!1)}),a.jsx("div",{className:"relative w-full h-full overflow-y-auto",children:a.jsxs(zt.div,{className:"min-h-full w-full flex items-center justify-center bg-[#18181A] px-4 py-8",onClick:e=>e.stopPropagation(),children:[a.jsx("button",{type:"button",onClick:()=>ge(!1),disabled:null!==m,className:bb("fixed top-4 right-4 md:right-6 z-[1000] p-2 bg-[#FFFFFF1A] backdrop-blur-lg hover:bg-[#242424] rounded-full transition-colors",null!==m&&"opacity-50 cursor-not-allowed",Xt),"aria-label":"Close modal",children:a.jsx(HS,{className:"w-5 h-5 text-[#FFFFFF]"})}),a.jsxs("div",{className:"flex flex-col w-full mx-auto max-w-8xl md:items-center",children:[a.jsx("div",{className:"flex items-start justify-start w-full mb-8 md:justify-center md:items-center",children:a.jsxs("div",{className:"flex flex-col items-start justify-center gap-1 md:items-center",children:[a.jsx("h2",{className:"text-[22px] md:text-[28px] font-medium text-[#E6E6E6]",children:"team"===i?"team"===i&&U&&U.tier_name.toLowerCase().includes("team")?`Manage plan for ${s}`:`Choose plan for ${s}`:Ae()?"Choose your plan":"Manage your plan"}),Ae()?a.jsx("span",{className:"text-[#FFFFFF]/40 md:text-center max-md:text-[16px] text-start md:text-nowrap font-inter font-medium",children:"team"===i?`Select a team plan for ${s} workspace.`:"Pick a plan that best suits you. Upgrade or downgrade at any time."}):a.jsxs("span",{className:"text-[#FFFFFF]/40 md:text-center max-md:text-[16px] text-start md:text-nowrap font-inter font-medium",children:[Ie()?"Plan cancels on":"Monthly credits refreshes on",a.jsx("span",{className:"text-[#FFFFFF] font-inter font-medium ml-1",children:fT((()=>{if(null==W?void 0:W.subscription){if(Ie()){const e=W.subscription.expires_at;return"string"==typeof e?e:void 0}return W.monthly_credits_refresh_date||void 0}})())})]})]})}),Ve&&a.jsxs("div",{className:"bg-[#151517] rounded-full flex items-center text-[14px] border-[#FFFFFF1F] border p-1 mb-4",children:[a.jsx("button",{type:"button",onClick:()=>ve("monthly"),className:Le(ee,"monthly"),children:"Monthly"}),a.jsxs("button",{type:"button",onClick:()=>ve("annually"),className:Le(ee,"annually"),children:["Annually"," ",a.jsxs("div",{className:" text-[#f3ca5f] font-inter text-[14px] font-semibold rounded-full",children:["Save ",17,"%"]})]})]}),ne.current===Cv&&"personal"===i&&a.jsx("div",{className:"mb-6",children:ie?a.jsxs("div",{className:"flex items-center justify-center duration-300 animate-in fade-in-0 slide-in-from-top-2",children:[a.jsxs("div",{className:"flex",children:[a.jsxs("svg",{className:"self-center",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.jsx("path",{d:"M10 18C8.89333 18 7.85333 17.79 6.88 17.37C5.90667 16.95 5.06 16.38 4.34 15.66C3.62 14.94 3.05 14.0933 2.63 13.12C2.21 12.1467 2 11.1067 2 10C2 8.89333 2.21 7.85333 2.63 6.88C3.05 5.90667 3.62 5.06 4.34 4.34C5.06 3.62 5.90667 3.05 6.88 2.63C7.85333 2.21 8.89333 2 10 2C11.1067 2 12.1467 2.21 13.12 2.63C14.0933 3.05 14.94 3.62 15.66 4.34C16.38 5.06 16.95 5.90667 17.37 6.88C17.79 7.85333 18 8.89333 18 10C18 11.1067 17.79 12.1467 17.37 13.12C16.95 14.0933 16.38 14.94 15.66 15.66C14.94 16.38 14.0933 16.95 13.12 17.37C12.1467 17.79 11.1067 18 10 18Z",fill:"#5FE55C"}),a.jsx("path",{d:"M13.1332 7C13.285 7 13.426 7.02648 13.5562 7.07943C13.6864 7.13239 13.8021 7.20829 13.9033 7.30713C14.0046 7.40598 14.0805 7.51719 14.1311 7.64075C14.1817 7.76431 14.2107 7.90375 14.2179 8.05909C14.2179 8.2003 14.1908 8.33621 14.1365 8.46683C14.0823 8.59745 14.0046 8.71219 13.9033 8.81104L9.59703 13.0209C9.49579 13.1198 9.37828 13.1957 9.2445 13.2486C9.11072 13.3016 8.97152 13.3298 8.82689 13.3333C8.68226 13.3333 8.54306 13.3069 8.40928 13.2539C8.2755 13.2009 8.15799 13.1233 8.05675 13.0209L6.09343 11.104C5.99219 11.0051 5.91445 10.8904 5.86021 10.7598C5.80598 10.6291 5.77705 10.4932 5.77344 10.352C5.77344 10.2037 5.80236 10.0661 5.86021 9.93896C5.91807 9.81187 5.9958 9.6989 6.09343 9.60006C6.19105 9.50121 6.30494 9.42707 6.43511 9.37765C6.56527 9.32822 6.70809 9.29998 6.86357 9.29292C7.0082 9.29292 7.1474 9.3194 7.28118 9.37235C7.41496 9.42531 7.53247 9.50121 7.63371 9.60006L8.82689 10.765L12.363 7.30713C12.4643 7.20829 12.5818 7.13239 12.7156 7.07943C12.8493 7.02648 12.9885 7 13.1332 7Z",fill:"#172218"})]}),a.jsx("span",{className:"ml-1 text-[#5FE55C] font-inter text-[14px] font-medium leading-[20px] uppercaseRetry",children:ie.code})]}),a.jsx("button",{onClick:()=>{ae(null),ce(""),me(""),oe(!1)},className:"ml-2 text-white/50 font-inter text-[16px] font-medium leading-[20px]",children:"Remove"})]}):re?a.jsx("div",{className:"relative min-w-[300px] animate-in fade-in-0 slide-in-from-top-2 duration-300",children:a.jsxs("div",{className:"relative w-full flex items-center rounded-[12px] pl-4 pr-2 py-2 transition-colors "+(pe?"border border-[rgba(255,128,128,0.30)]":"border border-white/10 focus-within:border-[rgba(255,255,255,0.20)]"),children:[a.jsx("input",{type:"text",value:le,onChange:e=>ce(e.target.value.toUpperCase()),onKeyDown:e=>{"Enter"===e.key&&le.trim()&&!de&&(e.preventDefault(),Ze())},placeholder:"Enter code",className:"bg-transparent flex-1 text-white placeholder-[#FFF]/30 focus:outline-none text-[14px] font-medium",autoFocus:!0}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("button",{onClick:()=>{oe(!1),ce(""),me("")},className:"flex items-center justify-center transition-colors rounded-full w-7 h-7 bg-white/10",children:a.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:a.jsx("path",{d:"M12 4L4 12M4 4L12 12",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",opacity:"0.60"})})}),a.jsx("button",{onClick:Ze,disabled:de||!le.trim(),className:"w-7 h-7 rounded-full flex items-center justify-center transition-colors bg-white "+(le?"cursor-pointer":"bg-opacity-20"),children:a.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:a.jsx("path",{d:"M15.2803 5.73438C15.505 5.7344 15.7279 5.77923 15.9355 5.86523C16.143 5.95126 16.3324 6.07652 16.4912 6.23535C16.812 6.55627 16.9921 6.99252 16.9922 7.44629C16.9921 7.89995 16.8119 8.33539 16.4912 8.65625L9.49219 15.6562C9.32753 15.8209 9.13115 15.9509 8.91602 16.04C8.70088 16.1291 8.47016 16.1758 8.2373 16.1758C8.00442 16.1758 7.77376 16.1291 7.55859 16.04C7.34344 15.9509 7.14711 15.8209 6.98242 15.6562L3.50488 12.1787L3.50586 12.1777C3.34717 12.0219 3.21871 11.8372 3.13086 11.6328C3.04131 11.4243 2.99426 11.1996 2.99219 10.9727C2.99021 10.7454 3.03406 10.5189 3.12012 10.3086C3.20611 10.0986 3.33273 9.9076 3.49316 9.74707C3.65383 9.58641 3.84538 9.45911 4.05566 9.37305C4.26593 9.28703 4.49157 9.24317 4.71875 9.24512C4.94571 9.24712 5.17033 9.29429 5.37891 9.38379C5.58311 9.47151 5.76809 9.59938 5.92383 9.75781H5.9248L8.23633 12.0693L14.0693 6.23535C14.2281 6.07648 14.4175 5.95128 14.625 5.86523C14.8326 5.77923 15.0556 5.73442 15.2803 5.73438ZM7.53223 15.1064C7.6247 15.1989 7.73564 15.2722 7.85645 15.3223C7.94697 15.3597 8.04252 15.3829 8.13965 15.3926L8.04297 15.3779C7.97906 15.3652 7.91596 15.3463 7.85547 15.3213C7.73474 15.2712 7.62464 15.1979 7.53223 15.1055L5.5957 13.1689L7.53223 15.1064ZM8.61816 15.3213C8.59576 15.3306 8.57276 15.3381 8.5498 15.3457C8.57263 15.3381 8.59588 15.3315 8.61816 15.3223C8.64819 15.3098 8.6774 15.2955 8.70605 15.2803C8.67763 15.2954 8.64804 15.3089 8.61816 15.3213ZM16.0029 8.03711C15.9836 8.06074 15.9632 8.08366 15.9414 8.10547L8.94141 15.1055C8.89525 15.1516 8.84502 15.1934 8.79102 15.2295L8.86914 15.1719C8.89447 15.1512 8.91921 15.1296 8.94238 15.1064L15.9414 8.10645C15.9852 8.06266 16.0238 8.01464 16.0576 7.96387L16.0029 8.03711ZM3.83984 10.6035C3.82804 10.6324 3.81746 10.6617 3.80859 10.6914C3.79983 10.721 3.7929 10.751 3.78711 10.7812V10.7803C3.79875 10.7197 3.81639 10.6599 3.83984 10.6025C3.85147 10.5742 3.8646 10.5465 3.87891 10.5195L3.83984 10.6035Z",fill:"black"})})})]})]})}):a.jsx("div",{className:"text-center duration-300 animate-in fade-in-0 slide-in-from-top-2",children:a.jsx("button",{onClick:e=>{e.preventDefault(),e.stopPropagation(),oe(!0)},className:"text-white/50 hover:text-white/40 font-inter text-[14px] font-medium leading-[20px]",children:"Have a promo code?"})})}),a.jsxs("div",{className:bb("flex flex-col gap-4 w-full","md:grid md:gap-6 md:justify-center",Ge.gridColumns),children:[We.map(e=>{const t=e.variants,s=t&&x?t.find(e=>e.id===x)||t[0]:(null==t?void 0:t[0])||e,o=U&&s.id===U.id&&s.billing_period===U.billing_period,l=(e=>{if(!Ae()&&U&&"MONTHLY"===U.billing_period&&"annually"===ee&&Re(e.tier_name)===Re(U.tier_name)&&"YEARLY"===e.billing_period)return!0;if("personal"===i&&ke(e.tier_name)&&N){const t=null==k?void 0:k.current_subscription;if(t&&"MONTHLY"===t.billing_period&&"annually"===ee&&Re(e.tier_name)===Re(t.tier_name)&&"YEARLY"===e.billing_period)return!0}return!1})(s);return Oe(s),a.jsxs("div",{className:bb("rounded-[16px] pb-6 p-6 flex flex-col relative transition-colors duration-200 w-full min-h-[300px] md:min-h-[400px]","bg-[#262629]"),children:[ke(e.tier_name)?a.jsx("div",{children:a.jsxs("h3",{className:De(e.tier_name),style:{background:"linear-gradient(152.98deg, #FFF4DF -8.63%, #FFD702 95.68%)",backgroundClip:"text",WebkitBackgroundClip:"text",WebkitTextFillColor:"transparent",textShadow:"0 0 40px rgba(255, 215, 2, 0.4)"},children:[Ne(e.tier_name)," ",a.jsx(rM,{size:24,className:"ml-1"})]})}):a.jsxs("h3",{className:De(e.tier_name),children:[Ne(e.tier_name)," ",Fe(e.tier_name)&&a.jsx(uA,{color:"#F3CA5F",size:24,height:24,width:24})]}),a.jsx("div",{className:"flex flex-col mb-6",children:a.jsxs("div",{className:"flex items-baseline",children:[Ag()&&"YEARLY"===s.billing_period&&$e(s)&&a.jsxs("span",{className:"font-semibold text-[24px] tracking-[-0.2px] text-[#FFFFFF88] line-through mr-4 relative",children:[AT($e(s)||0,ne.current===Cv)," ",a.jsx("span",{className:"absolute inset-0 transform -translate-y-1/2 border-t-2 border-red-400 top-1/2"})]}),a.jsxs("span",{className:"font-semibold text-[32px] tracking-[-0.2px]",children:[AT(Se(s),ne.current===Cv)," "]}),a.jsx("span",{className:"ml-2 text-[#E6E6E6] font-medium font-inter",children:"/ month"})]})}),o?a.jsxs("button",{type:"button",className:"bg-[#FFFFFF29] text-[#FFFFFF] rounded-full flex text-[14px] gap-2 font-semibold w-full p-[10px] max-h-[40px] pr-[16px] items-center justify-center",children:["Current Active Plan",(Fe(e.tier_name)||ke(e.tier_name))&&a.jsx(uA,{color:"#ffffff",size:24,height:24,width:24})]}):l?a.jsxs("button",{type:"button",style:Te(e.tier_name),className:Me(),onClick:()=>{"personal"===i&&ke(s.tier_name)?(e=>{if(null==F?void 0:F.id){const t=(null==U?void 0:U.tier_name)||"free";pp(F.id,t,Ne(e.tier_name),"yearly",!0,null==D?void 0:D.id,r,ne.current)}D?be(e,D.id):Ce(e)})(s):(e=>{if(!U)return;const t=V(0,"YEARLY");let s;if(s=e&&e.ecu_credits?null==t?void 0:t.find(t=>t.tier_name.toLowerCase()===e.tier_name.toLowerCase()&&t.ecu_credits===e.ecu_credits):null==t?void 0:t.find(e=>e.tier_name.toLowerCase()===U.tier_name.toLowerCase()),s){if(null==F?void 0:F.id){const e=U.tier_name;pp(F.id,e,e,"yearly","team"===i||!!n,n,r)}Ce(s)}})(s),bg(tE.UPDATE_TIER_CLICKED,{planType:i,plan:e,selectedVariant:s,currency:ne.current})},disabled:null!==m,children:[null!==m?Ee():"Upgrade to Annual",(Fe(e.tier_name)||ke(e.tier_name))&&a.jsx(uA,{color:"#0F0F10",size:24,height:24,width:24})]}):a.jsxs("button",{type:"button",style:Te(e.tier_name),className:Me(),onClick:()=>{"personal"===i&&ke(s.tier_name)&&Oe(s)?p.info("Please contact support to downgrade your team subscription"):Ce(s),bg(nE.PLAN_UPGRADE_BUTTON_CLICKED,{planType:i,plan:e,selectedVariant:s,currency:ne.current})},disabled:m===s.id,children:[m===s.id?Ee():He(s),(Fe(e.tier_name)||ke(e.tier_name))&&a.jsx(uA,{color:"#0F0F10",size:24,height:24,width:24})]}),t&&t.length>1&&_e(e.tier_name)&&a.jsxs("div",{className:"relative mt-2",children:[a.jsxs("button",{type:"button",onClick:()=>v(!g),className:bb("w-full px-3 py-2 bg-[#262629] rounded-full border border-[#FFFFFF1F] flex items-center justify-between hover:bg-[#313134] transition-colors hover:border-[#FFFFFF4D]",g&&"border-[#FFFFFF4D] bg-[#313134] "),children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(yT,{color:"#FFFFFF",size:20}),a.jsxs("span",{className:"text-[14px] font-inter font-medium text-white",children:[s.ecu_credits," ","credits/month"]})]}),a.jsx(Gk,{className:bb("w-6 h-6 text-[#FFFFFF]/30 transition-transform",g&&"rotate-180")})]}),g&&a.jsx("div",{className:"absolute top-full left-0 gap-2 flex flex-col right-0 mt-1 p-2 bg-[#1A1A1C] border border-[#3A3A3B] rounded-lg overflow-hidden z-10",children:t.map(e=>a.jsxs("button",{type:"button",onClick:()=>{f(e.id),v(!1)},className:bb("w-full rounded-[8px] text-left p-2 hover:bg-[#FFFFFF0F] transition-colors flex items-center text-white/60 justify-between",s.id===e.id&&"bg-[#80FFF90F] text-[#80FFF9]"),children:[a.jsxs("span",{className:"text-[14px] font-medium font-inter",children:[e.ecu_credits," credits/month"]}),s.id===e.id&&a.jsx(qk,{color:"#80FFF9",size:20})]},e.id))})]}),a.jsx("div",{className:"mb-6"}),ze(s)]},e.id)}),fe&&a.jsxs("div",{className:"bg-[#66F0FF1A] rounded-[16px] pb-6 p-6 flex flex-col transition-colors duration-200 w-full",children:[a.jsxs("h3",{className:"mb-2 text-[16px] flex items-center gap-1 font-semibold text-[#B2F8FF] font-['Inter']",children:["Enterprise ",a.jsx(dM,{})]}),a.jsx("span",{className:"text-[#B2F8FF]/50 text-[14px] font-inter font-medium mb-6 md:mb-9 ",children:"Enterprise-grade features for your entire organization"}),a.jsxs("button",{type:"button",className:"w-full mb-6 p-[10px] max-h-[40px] pr-[16px] gap-[10px] text-[14px] font-semibold rounded-full items-center flex justify-center bg-[#66F0FF] text-[#293333] border-[#66F0FF1F]",onClick:()=>{bg("enterprise_demo_clicked",{userId:(null==F?void 0:F.id)||"",userEmail:(null==F?void 0:F.email)||"",userName:(null==_?void 0:_.name)||(null==F?void 0:F.email)||"",currentTier:(null==U?void 0:U.tier_name)||"free",source:"upgrade_tier_modal",timestamp:(new Date).toISOString(),currency:ne.current}),window.open(hv,"_blank","noopener,noreferrer")},children:["Book a demo ",a.jsx(uM,{color:"#293333"})]}),a.jsx(Je,{})]}),Ae()&&he&&"personal"===i&&a.jsxs("div",{className:"bg-[#262629] rounded-[16px] pb-6 p-6 flex flex-col transition-colors duration-200 w-full min-h-[350px]",children:[a.jsx("h3",{className:"mb-2 text-[16px] font-semibold text-[#E6E6E6] font-['Inter']",children:"Free"}),a.jsxs("div",{className:"flex items-baseline mb-6",children:[a.jsxs("span",{className:"font-semibold text-[32px] tracking-[-0.2px]",children:[AT(0,ne.current===Cv)," "]}),a.jsx("span",{className:"ml-2 text-[#E6E6E6] font-medium font-inter",children:"/ month"})]}),a.jsx("button",{type:"button",className:"w-full mb-6 md:mb-10 p-[10px] min-h-[48px] pr-[16px] text-[14px] leading-5 font-semibold rounded-full items-center flex justify-center bg-white/15 text-white border-[#3A3A3B] hover:bg-[#3A3A3B]",children:"Current Active Plan"}),a.jsx(Xe,{})]})]}),Ue&&a.jsxs("div",{className:bb("bg-[#262629] rounded-[16px] pb-6 p-6 transition-colors duration-200 w-full flex justify-between mt-5 mx-auto",Ge.maxWidth),children:[a.jsxs("div",{className:"flex flex-col",children:[a.jsx("h3",{className:"mb-2 text-[16px] font-semibold text-[#E6E6E6] font-['Inter']",children:"Free"}),a.jsxs("div",{className:"flex items-baseline mb-6",children:[a.jsxs("span",{className:"font-semibold text-[32px] tracking-[-0.2px]",children:[AT(0,ne.current===Cv)," "]}),a.jsx("span",{className:"ml-2 text-[#E6E6E6] font-medium font-inter",children:"/ month"})]}),a.jsx(Xe,{})]}),a.jsx("button",{type:"button",className:" mb-6 md:mb-10 p-[10px] max-h-[40px] px-[24px] text-[14px] leading-5 font-semibold rounded-full items-center flex justify-center bg-white/15 text-white border-[#FFFFFF1F] hover:bg-[#3A3A3B]",onClick:()=>{ge(!1),setTimeout(()=>{const e=document.getElementById("mainTaskInput");e&&e.focus()},300)},children:"Start Building"})]}),Ae()&&a.jsx("div",{className:"flex items-center justify-center w-full mt-6 flex-nowrap",children:a.jsxs("span",{className:"text-[#FFFFFF66] font-inter text-[14px] flex gap-2 text-center text-nowrap",children:["Need help?"," ",a.jsxs("a",{href:rv,target:"_blank",rel:"noopener noreferrer",className:"text-[#FFFFFF] font-inter flex items-center gap-2",children:["Contact Us ",a.jsx(tI,{color:"#FFFFFF"})]})]})}),!Ae()&&a.jsxs("div",{className:bb("flex flex-col-reverse items-center justify-between w-full gap-4 max-md:pt-6 md:flex-row md:pt-4 mx-auto",Ge.maxWidth),children:[a.jsx("div",{className:"flex justify-center flex-nowrap",children:a.jsxs("span",{className:"text-[#FFFFFF66] font-inter text-[14px] flex gap-2 text-center text-nowrap",children:["Need help?"," ",a.jsxs("a",{href:rv,target:"_blank",rel:"noopener noreferrer",className:"text-[#FFFFFF] font-inter flex items-center gap-2",onClick:()=>bg(nE.CONTACT_US_BUTTON_CLICKED,{currency:ne.current}),children:["Contact Us ",a.jsx(tI,{color:"#FFFFFF"})]})]})}),Ae()||se&&Ie()||X?null:a.jsx("button",{type:"button",onClick:()=>{var e;"team"===i&&n?p.info("Please contact support to manage your subscription"):se?y(!0):q(null==(e=null==W?void 0:W.subscription)?void 0:e.id,ne.current)},disabled:G,className:bb("text-[#FFFFFF66] max-md:w-full max-md:min-h-[48px] justify-center text-[14px] py-2 px-4 rounded-full flex items-center gap-1",G&&"opacity-50 cursor-not-allowed"),children:G?Ee():a.jsxs(a.Fragment,{children:[Ie()?"Resume":"Cancel"," Subscription",a.jsx(KI,{className:"rotate-180",color:"#FFFFFF66",size:16})]})})]})]})]})})]})}),document.body),Y.isLoading&&a.jsx(PT,{isOpen:Y.isLoading,onOpenChange:K,paymentType:Y.paymentType||"subscription",amount:Y.amount,currency:Y.currency,planName:Y.planName}),a.jsx($T,{isOpen:J.showModal,onOpenChange:Q,status:J.status,planName:J.planName,errorMessage:J.errorMessage,paymentId:J.paymentId,organizationId:J.organizationId,onClose:()=>{Q(),t(!1)}}),a.jsx(VT,{isOpen:b,onClose:()=>{y(!1)},onConfirm:()=>{var e;y(!1),q(null==(e=null==W?void 0:W.subscription)?void 0:e.id,ne.current)},planName:(null==U?void 0:U.tier_name)||"Pro"})]}):null}const _M=wv.common.bot,kM=wv.pro.secondBanner,SM=wv.feature.arrowDark,EM=[{number:"1",title:"Define Your Agent's Personality & Role",description:"Describe who your agent is and what they're great at."},{number:"2",title:"Map Out the Workflow & Logic",description:"Break down how they should approach tasks step by step."},{number:"3",title:"Add Guardrails for Better Decisions",description:"Establish do's and don'ts so your agent makes the right decisions."}],IM=({isOpen:e,onOpenChange:t})=>{const{user:n}=Yg(),{currentWorkspace:s}=ev(),{isMobile:i}=nI(),{setTabs:r,setActiveTab:o}=Hee();return a.jsx(IA,{open:e,onOpenChange:t,children:a.jsxs(LA,{className:"md:w-[900px] max-h-[80vh] max-w-[90vw] md:h-[650px] p-0 bg-[#18181A] rounded-2xl overflow-hidden",children:[a.jsx(MA,{className:"absolute z-10 flex items-center justify-center w-8 h-8 text-white transition-all duration-200 rounded-full md:w-10 md:h-10 backdrop-blur-lg top-4 right-4 md:right-6 md:top-6 hover:bg-white/10",children:a.jsx(HS,{className:"w-6 h-6 md:w-6 md:h-6"})}),a.jsxs("div",{className:"relative flex w-[inherit] h-full max-md:flex-col-reverse",children:[a.jsxs("div",{className:"flex flex-col justify-center flex-1 gap-4 md:px-[40px] md:py-12",children:[a.jsxs("div",{className:"flex flex-col gap-2",children:[a.jsxs("div",{className:"flex flex-col gap-8 max-md:px-5 max-md:pt-6",children:[a.jsx("img",{src:_M,alt:"Custom Agents",className:"w-12 h-12 max-md:hidden"}),a.jsx(zt.h1,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.5,delay:.1},className:"text-[20px] md:text-[28px] leading-[32px] font-semibold tracking-[-2%] text-white",children:"Introducing Custom Agents"})]}),a.jsx(zt.p,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.5,delay:.2},className:"text-[#737780] max-md:px-5 text-[14px] font-['Inter'] md:text-[15px] text-wrap whitespace-pre-wrap break-words leading-[20px] md:leading-[24px]",children:"Create and monetize expert-level AI agents tailored to custom use cases."})]}),a.jsx(zt.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.5,delay:.3},className:"flex flex-col gap-[16px] max-md:px-5",children:EM.map((e,t)=>a.jsx("div",{className:"flex items-start gap-4 bg-[#80FFF908] p-4 rounded-[8px]",children:a.jsxs("div",{className:"flex flex-col gap-1",children:[a.jsx("h3",{className:"text-[16px] text-[#80FFF9] font-medium",children:e.title}),a.jsx("p",{className:"text-[14px] font-[500] text-[#80FFF966] font-['Inter']",children:e.description})]})},t))}),a.jsx(zt.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.5,delay:.7},className:"sticky max-md:px-5 bottom-4 max-md:pb-6",children:a.jsxs("button",{type:"button",onClick:()=>{const e=`create-agent-${Date.now()}-${Math.random().toString(36).substring(2,11)}`;r(t=>[...t,{id:e,title:"Create New Agent",path:"/create-agent",level:s&&"personal"!==s?"organization":"user",organization_id:s&&"personal"!==s?s:void 0,created_by:null==n?void 0:n.id,state:{tabId:e,fromModal:!0}}]),o(e),t(!1)},className:"flex items-center max-md:max-h-[48px] mt-4 md:mt-[36px] justify-center w-full gap-4 text-[16px] font-semibold text-black transition-all duration-200 transform bg-white shadow-lg h-14 rounded-xl hover:bg-gray-100 hover:shadow-xl hover:-translate-y-1",children:["Create Your First Agent",a.jsx("img",{src:SM,alt:"Arrow",className:"w-5 h-5"})]})})]}),a.jsx("div",{className:"relative max-md:max-h-[200px] flex-1 overflow-hidden bg-gradient-to-br from-[#DD99FF20] to-[#BB77DD20]",children:a.jsx("img",{src:kM,alt:"Right Banner",className:"object-cover w-full h-full md:object-fill "})})]})]})})},AM=()=>{const[e,t]=Pe.useState(!1),{user:n}=Yg(),s=iI(),{getCurrentOrganizationId:i}=ev(),a=i(),{data:r,isLoading:o,error:l,refetch:c}=Wx(a?{organization_id:a}:void 0,{pollingInterval:3e5});return Pe.useEffect(()=>{r&&t(TM(r,n||void 0,s))},[r,n,s]),{config:r,loading:o,error:l?new Error("Failed to fetch config"):null,refetch:c,universalKeyEnabled:e}},TM=(e,t,n)=>{var s,i;if(n)return!0;if(!0===(null==(s=null==e?void 0:e.feature_flags)?void 0:s.universal_key))return!0;if(Array.isArray(null==(i=null==e?void 0:e.feature_flags)?void 0:i.universal_key)&&(null==t?void 0:t.id)){const n=t.id.slice(-1).toLowerCase();return e.feature_flags.universal_key.includes(n)}return!1},MM=({width:e=20,height:t=20,fill:n="white",className:s})=>a.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:t,viewBox:"0 0 20 20",fill:"none",className:s,children:a.jsx("path",{d:"M8.13671 7.82399V6.30398C8.13671 6.17596 8.18431 6.07991 8.29527 6.01598L11.3241 4.256C11.7364 4.01602 12.228 3.90406 12.7353 3.90406C14.6382 3.90406 15.8434 5.3921 15.8434 6.97604C15.8434 7.088 15.8434 7.21602 15.8274 7.34404L12.6877 5.488C12.4975 5.37605 12.3071 5.37605 12.1169 5.488L8.13671 7.82399ZM15.209 13.7441V10.112C15.209 9.88789 15.1138 9.7279 14.9236 9.61594L10.9434 7.27995L12.2437 6.5279C12.3547 6.46397 12.4499 6.46397 12.5609 6.5279L15.5896 8.28789C16.4619 8.79996 17.0484 9.88789 17.0484 10.9438C17.0484 12.1598 16.335 13.2798 15.209 13.7439V13.7441ZM7.20114 10.544L5.90086 9.77608C5.78989 9.71215 5.7423 9.6161 5.7423 9.48808V5.96811C5.7423 4.25615 7.04259 2.96006 8.80278 2.96006C9.46883 2.96006 10.0871 3.18413 10.6106 3.58409L7.48672 5.40816C7.29649 5.52012 7.20129 5.68011 7.20129 5.90418V10.5442L7.20114 10.544ZM9.99999 12.176L8.13671 11.12V8.8801L9.99999 7.82414L11.8631 8.8801V11.12L9.99999 12.176ZM11.1972 17.0401C10.5311 17.0401 9.91282 16.816 9.3894 16.4161L12.5132 14.5919C12.7034 14.48 12.7987 14.3201 12.7987 14.096V9.45596L14.1149 10.2239C14.2258 10.2878 14.2734 10.3839 14.2734 10.5119V14.0319C14.2734 15.7438 12.9572 17.0401 11.1972 17.0401ZM7.43898 13.4721L4.41018 11.7121C3.53797 11.2 2.95134 10.1121 2.95134 9.05615C2.95134 7.82414 3.68077 6.72015 4.80657 6.25611V9.9041C4.80657 10.1282 4.90177 10.2882 5.092 10.4001L9.05638 12.72L7.75609 13.4721C7.64513 13.5361 7.54993 13.5361 7.43898 13.4721ZM7.26465 16.0961C5.47278 16.0961 4.15658 14.736 4.15658 13.056C4.15658 12.928 4.17249 12.8 4.18826 12.672L7.3121 14.4961C7.50234 14.608 7.69273 14.608 7.88297 14.4961L11.8631 12.1762V13.6962C11.8631 13.8242 11.8155 13.9202 11.7045 13.9841L8.67574 15.7441C8.26344 15.9841 7.77185 16.0961 7.26451 16.0961H7.26465ZM11.1972 18C13.1159 18 14.7174 16.624 15.0823 14.8C16.8582 14.3359 18 12.6559 18 10.944C18 9.82396 17.5243 8.73603 16.668 7.95201C16.7473 7.61598 16.7949 7.27995 16.7949 6.94407C16.7949 4.65612 14.9554 2.944 12.8305 2.944C12.4025 2.944 11.9901 3.00794 11.5778 3.15201C10.8642 2.44799 9.88099 2 8.80278 2C6.88403 2 5.28254 3.37593 4.91768 5.19999C3.14173 5.66404 2 7.34404 2 9.056C2 10.176 2.47567 11.264 3.33197 12.048C3.25269 12.384 3.20509 12.72 3.20509 13.0559C3.20509 15.3438 5.04456 17.0559 7.16946 17.0559C7.59753 17.0559 8.00984 16.9921 8.42215 16.848C9.13565 17.552 10.1188 18 11.1972 18Z",fill:n})}),DM=wv.chips.surprise;function LM({config:e,showChips:t,onChipClick:n}){const[s,i]=Pe.useState({}),[r,o]=Pe.useState([]),[l,c]=Pe.useState(new Set),[d,u]=Pe.useState(0),{isTrulyFreeUser:p}=sv();Pe.useEffect(()=>{if((null==e?void 0:e.prompt_suggestions)&&Array.isArray(e.prompt_suggestions)){const t=e.prompt_suggestions.reduce((e,t)=>(e[t.category]||(e[t.category]=[]),e[t.category].push(t),e),{});i(t)}},[e]);const m=(e=!1)=>Object.keys(s).map(t=>{const n=s[t];if(e&&l.size>0){const e=n.filter(e=>!l.has(`${e.category}-${e.label}`)),t=e.length>0?e:n;return t[Math.floor(Math.random()*t.length)]}return n[Math.floor(Math.random()*n.length)]}),h=e=>{const t=new Set(l);e.forEach(e=>{t.add(`${e.category}-${e.label}`)});const n=Object.values(s).flat().length;if(t.size>.8*n){const t=new Set(e.map(e=>`${e.category}-${e.label}`));c(t)}else c(t)};Pe.useEffect(()=>{if(0===r.length&&Object.keys(s).length>0){const e=m(!1);o(e),h(e)}},[s]);const x=(null==e?void 0:e.prompt_suggestions)&&Array.isArray(e.prompt_suggestions)&&e.prompt_suggestions.length>0;return a.jsx(zb,{mode:"wait",children:t&&x&&r.length>0&&a.jsxs("div",{className:"flex gap-3 p-2 px-3 pb-3 overflow-x-auto overflow-clip hide-scrollbars",children:[r.map((e,t)=>a.jsxs(Tk.button,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.3,ease:"easeInOut",delay:.05*t},onClick:()=>(e=>{n(e.prompt)})(e),whileTap:{scale:.95,transition:{duration:.1}},className:"group relative min-w-fit pl-3 py-4 pr-4 flex text-[#FFFFFF] hover:text-[#FFFFFF] items-center gap-[6px] bg-[#18181A] rounded-[12px] transition-colors duration-200 cursor-pointer "+(p()?"border-opacity-0":""),children:[a.jsx("img",{src:e.icon_url,alt:"Chip icon",className:"w-4 h-4"}),a.jsx("span",{className:"text-sm leading-4 font-medium font-brockmann drop-shadow-[0_0_8px_rgba(255,255,255,0.3)] transition-all duration-200",children:e.label})]},`${e.category}-${e.label}-${t}`)),a.jsxs(Tk.button,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.3,ease:"easeInOut",delay:.05*r.length},onClick:()=>{const e=Object.values(s).flat(),t=e[Math.floor(Math.random()*e.length)];n(t.prompt)},whileTap:{scale:.95,transition:{duration:.1}},className:"group relative min-w-fit pl-3 py-4 pr-4 flex text-[#FFFFFF] hover:text-[#FFFFFF] items-center gap-[6px] bg-[#18181A] rounded-[12px] transition-colors duration-200 cursor-pointer "+(p()?"border-opacity-0":""),children:[a.jsx("img",{src:DM,alt:"Surprise",className:"w-4 h-4"}),a.jsx("span",{className:"text-sm leading-4 font-medium font-brockmann drop-shadow-[0_0_8px_rgba(255,255,255,0.3)] transition-all duration-200",children:"Surprise Me"})]}),a.jsx(Tk.button,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.3,ease:"easeInOut",delay:.05*(r.length+1)},onClick:async()=>{u(e=>e+180);const e=m(!0);o(e),h(e)},whileTap:{scale:.95,transition:{duration:.1}},className:"group relative min-w-fit p-4 flex text-[#7B7B80] hover:text-white items-center gap-[6px] bg-[#18181A] hover:bg-[#202022] rounded-[12px] transition-colors duration-200 cursor-pointer",title:"Refresh suggestions",children:a.jsx(Tk.div,{animate:{rotate:d},transition:{duration:.5,ease:"easeInOut"},children:a.jsx(kS,{className:"w-4 h-4"})})})]})})}const PM=wv.common.attachmentCross,RM=wv.common.attach,OM=wv.common.close,zM=wv.common.copperCoin;function BM({tabId:e,onClearTabId:t,isReferralModalOpen:n,setIsReferralModalOpen:s,isCustomAgentsModalOpen:i,setIsCustomAgentsModalOpen:r,showMobileAgentIntro:o,onMobileAgentIntroShown:l,jobsLength:c}){const{toast:d}=un(),{config:u,loading:p}=AM(),[m,{isLoading:h}]=jf(),{getTabState:x,updateTabState:f,setTabs:g,setActiveTab:v}=Hee(),{session:b,user:y}=Yg(),{tier:w,isTrulyFreeUser:j}=sv(),{getCurrentOrganizationId:C,isOrganizationWorkspace:N}=ev(),{isConnected:F}=qA(),_=iI(),{data:k}=Sx(),S=!0,E=Mg()&&"free"!==w,[I,A]=Pe.useState([]),[T,M]=Pe.useState(!1),{compressImage:D}=gE(jE),L=C(),P=L?{organization_id:L}:{},{data:R,isLoading:O}=Pf(P,{skip:!("pro_mode"===w||_||(null==k?void 0:k.is_pro_enabled)||N())}),{data:z}=$f(L?{organization_id:L}:void 0,{skip:!1}),[H,$]=Pe.useState({taskInput:"",selectedImage:"",selectedAgent:"",selectedModel:"",perInstanceCostLimit:"25",selectedSkills:[],selectedImages:[],loadingImages:!1,githubUrl:"",branchName:"",projectType:"new_app",selectedCustomAgent:null,privacy:"free"===w?"public":"private",ultraMode:!1,testMode:"pro_mode"===w,selectedMcpTools:[]}),[V,U]=Pe.useState(!1),[W,q]=Pe.useState(!1),[G,Z]=Pe.useState(!1),[Y,K]=Pe.useState(!0),[J,Q]=Pe.useState(!1),[X,ee]=Pe.useState(!1),[te,ne]=Pe.useState(!1),[se,ie]=Pe.useState(!1),[ae,re]=Pe.useState(!1),[oe,le]=Pe.useState(null),ce=h,de=XE(),[ue,pe]=Pe.useState(!1),me=()=>"free"===w&&!(()=>{try{return!0===Nd.getFeatureFlag("e1_enabled")}catch(e){return!1}})(),he=(e,t,n=!1)=>!!n||(e.user_tier?t===e.user_tier:!e.unavailable_tier||t!==e.unavailable_tier),xe=()=>{if(!(null==u?void 0:u.model_list))return"";const e=u.model_list.find(e=>he(e,w,N()));return(null==e?void 0:e.name)||""},[fe,ge]=Pe.useState(()=>me()),[ve,be]=Pe.useState(!1),[ye,we]=Pe.useState(!1),[je,Ce]=Pe.useState([]),{isMobile:Ne}=nI(),Fe=Pe.useRef(!1),_e=Pe.useRef(null),ke=Pe.useRef(new Set),Se=Pe.useRef(null),Ee=e=>{$(t=>({...t,...e}))};Pe.useEffect(()=>{var t,n,s;if(!e||!u)return;if(ke.current.has(e))return;const i=x(e),a=null==(n=null==(t=u.form_layouts)?void 0:t.new_app)?void 0:n.cloud,r=(null==a?void 0:a.defaults)||{},o=xe(),l=localStorage.getItem("landingPageTask");Ee({taskInput:l||(i.task||r.taskDescription||""),selectedImage:i.selectedImage||r.dockerImage||"",selectedAgent:i.selectedAgent||r.agent||"",selectedModel:i.model_name||o||r.baseModel||"",perInstanceCostLimit:i.per_instance_cost_limit||(null==(s=r.budget)?void 0:s.toString())||"25",selectedSkills:i.agentic_skills||r.skills||[],selectedImages:i.selectedImages||[],githubUrl:i.repository||"",branchName:i.branch||"",projectType:i.projectType||"new_app",selectedCustomAgent:i.selectedCustomAgent||null,selectedMcpTools:i.selectedMcpServerIds||[]}),l&&localStorage.removeItem("landingPageTask"),ke.current.add(e)},[u,x,e,w]),Pe.useEffect(()=>{if(!(null==u?void 0:u.model_list)||!H.selectedModel)return;const e=u.model_list.find(e=>e.name===H.selectedModel);if(e&&!he(e,w,N())){const e=xe();e&&Ee({selectedModel:e})}},[w,H.selectedModel,u]),Pe.useEffect(()=>{Ee({testMode:"pro_mode"===w})},[w]),Pe.useEffect(()=>{if(!e||0===ke.current.size)return;const t=x(e).selectedMcpServerIds||[];JSON.stringify(t)!==JSON.stringify(Se.current)&&(Se.current=t,Ee({selectedMcpTools:t}))},[e,x]),Pe.useEffect(()=>{if(!e||0===ke.current.size)return;const t={task:H.taskInput,selectedImage:H.selectedImage,image:H.selectedImage,selectedAgent:H.selectedAgent,model_name:H.selectedModel,per_instance_cost_limit:H.perInstanceCostLimit,agentic_skills:H.selectedSkills,selectedImages:H.selectedImages,repository:H.githubUrl,branch:H.branchName,projectType:H.projectType,selectedCustomAgent:H.selectedCustomAgent,privacy:H.privacy,ultraMode:H.ultraMode,testMode:H.testMode,selectedMcpServerIds:H.selectedMcpTools,isCloudFlow:!0};f(e,t)},[H,e,f]),Pe.useEffect(()=>{(null==u?void 0:u.skills)&&Ce(u.skills)},[u]),Pe.useEffect(()=>{var e;if(H.selectedAgent&&u){const t=null==(e=u.agent_names)?void 0:e.find(e=>e.name===H.selectedAgent);if(null==t?void 0:t.sub_agents){const e=t.sub_agents.filter(e=>je.some(t=>t.name===e));Ee({selectedSkills:e})}else Ee({selectedSkills:[]})}},[H.selectedAgent,je,u]),Pe.useEffect(()=>{var e,t,n,s,i,a,r,o,l,c,d,p,m;if(!u)return;const h=null==(t=null==(e=u.form_layouts)?void 0:e.new_app)?void 0:t.cloud,x=(null==h?void 0:h.defaults)||{};ye&&u.prototype_agent_experimental?Ee({selectedAgent:u.prototype_agent_experimental.agent||x.agent||"",selectedImage:u.prototype_agent_experimental.dockerImage||x.dockerImage||"",perInstanceCostLimit:(null==(n=u.prototype_agent_experimental.budget)?void 0:n.toString())||(null==(s=x.budget)?void 0:s.toString())||"25",selectedModel:u.prototype_agent_experimental.baseModel||x.baseModel||""}):ve&&u.e15_experimental?Ee({selectedAgent:u.e15_experimental.agent||x.agent||"",selectedImage:u.e15_experimental.dockerImage||x.dockerImage||"",perInstanceCostLimit:(null==(i=u.e15_experimental.budget)?void 0:i.toString())||(null==(a=x.budget)?void 0:a.toString())||"25",selectedModel:u.e15_experimental.baseModel||x.baseModel||""}):fe&&u.e1_experimental?Ee({selectedAgent:u.e1_experimental.agent||x.agent||"",selectedImage:u.e1_experimental.dockerImage||x.dockerImage||"",perInstanceCostLimit:(null==(r=u.e1_experimental.budget)?void 0:r.toString())||(null==(o=x.budget)?void 0:o.toString())||"25"}):Ee(ue?{selectedAgent:(null==(c=null==(l=u.agent_names)?void 0:l.find(e=>"expo_fullstack_v0"===e.name))?void 0:c.name)||"",selectedImage:(null==(p=null==(d=u.templates)?void 0:d.find(e=>"expo"===e.id))?void 0:p.env_image)||""}:{selectedAgent:x.agent||"",selectedImage:x.dockerImage||"",perInstanceCostLimit:(null==(m=x.budget)?void 0:m.toString())||"25"})},[fe,ve,ye,u,ue]),Pe.useEffect(()=>{""!==H.taskInput||Y||K(!0)},[H.taskInput,Y]),Pe.useEffect(()=>{if(!y)return;const e=me();ge(e)},[y,w]),Pe.useEffect(()=>{const t=C();g(n=>n.some(t=>t.id===e)?n:[...n,{id:e,title:"Setting up Task",path:"/not-defined",state:{tabId:e,sourceTabId:e,isCloudFlow:!0},status:!1,isCloudFlow:!0,...t&&{organization_id:t,level:"organization"}}]),f(e,{isCloudFlow:!0,...t&&{organization_id:t,level:"organization"}})},[e,C]);const Ie=vE({maxImages:5,maxSizeInMB:5,maxPixelDimensions:8e3,maxPixelDimensionsMultiple:2e3,onImagesChange:e=>Ee({selectedImages:e})});Pe.useEffect(()=>{Ee({loadingImages:Ie.isProcessing})},[Ie.isProcessing]);const Ae=e=>{Ee({taskInput:e}),ge(!0),pe(!1)},Te=e=>{ge(e)},Me=e=>{be(e)},De=e=>{we(e)},Le=()=>{Ee({githubUrl:"",branchName:""}),_e.current&&_e.current.reset()},Re=t=>{if(!t||0===t.length)return;const n=Array.from(t);if(I.length+n.length>5)return void d({title:"Too many attachments",description:"Maximum 5 attachments allowed",variant:"destructive"});const s=n.filter(e=>e.size>209715200);if(s.length>0)return void d({title:"File too large",description:`Files must be smaller than 200MB. ${s.length} file(s) exceed this limit.`,variant:"destructive"});const i=[...I,...n];A(i);const a=x(e);f(e,{...a,selectedFiles:i}),d({title:"Files selected",description:`${n.length} file(s) selected for upload`})},Oe=()=>{{const e=document.createElement("input");e.type="file",e.multiple=!0,e.style.display="none",e.onchange=t=>{const n=t.target;n.files&&Re(n.files),document.body.removeChild(e)},document.body.appendChild(e),e.click()}bg(sE.ATTACH_FILE_CLICKED)},ze=t=>{const n=I.filter((e,n)=>n!==t);A(n);const s=x(e);f(e,{...s,selectedFiles:n})},Be=async e=>{try{Og("transcription_started",{component:"ChatInput",audioSize:e.size});const t=new File([e],"recording.mp3",{type:"audio/mp3"}),n=await m({audio_file:t,language_code:"en"}).unwrap();if(!n.text)throw new Error("No transcription data received");{const e=H.taskInput,t=e?`${e} ${n.text}`:n.text;Ee({taskInput:t}),Og("transcription_completed",{component:"ChatInput",textLength:n.text.length})}}catch(t){Og("transcription_failed",{component:"ChatInput",error:t instanceof Error?t.message:"Unknown error"}),d({title:"Transcription Error",description:"Failed to transcribe audio. Please try again.",variant:"destructive"})}},He=()=>{ae?oe&&ae&&(oe.stop(),re(!1),le(null)):(async()=>{try{const e=await navigator.mediaDevices.getUserMedia({audio:!0}),t=new MediaRecorder(e),n=[];t.ondataavailable=e=>{n.push(e.data)},t.onstop=async()=>{const t=new Blob(n,{type:"audio/mp3"});await Be(t),e.getTracks().forEach(e=>e.stop())},t.start(),le(t),re(!0)}catch(e){d({title:"Recording Error",description:"Could not access microphone. Please check permissions.",variant:"destructive"})}})()},$e=e=>{var t,n,s;const i=null==(n=null==(t=null==u?void 0:u.form_layouts)?void 0:t[H.projectType])?void 0:n.cloud,a=null==(s=null==i?void 0:i.fields)?void 0:s.find(t=>t.id===e);return!1!==(null==a?void 0:a.show)},Ve=YS(async()=>{var n,s,i,a;try{if(Fe.current)return;if(Fe.current=!0,ee(!0),Ng("submitted",{userId:null==y?void 0:y.id,projectType:H.projectType,isCloudFlow:!0,taskInputLength:H.taskInput.length,taskInput:H.taskInput.substring(0,100),hasImages:H.selectedImages.length>0,imageCount:H.selectedImages.length,selectedModel:H.selectedModel,selectedAgent:H.selectedAgent,budget:H.perInstanceCostLimit,tabId:e}),!H.selectedImage||!H.taskInput)return void d({title:"Error",description:"Please fill in all required fields",variant:"destructive"});if(H.githubUrl&&!H.branchName)return void d({title:"Branch Required",description:"Please select a branch for the GitHub repository",variant:"destructive"});let r=[],o=[];if(I&&I.length>0){M(!0);try{const e=await(async(e,t,n)=>{const s=[],i=[...e],a=new Map;for(let o=0;o{});r=e.base64Images,o=e.filesToUploadAsArtifacts}finally{M(!1)}}const l=[...H.selectedImages||[],...r],c=C(),p={...{task:H.taskInput,selectedImage:H.selectedImage,image:H.selectedImage,selectedAgent:H.selectedAgent,model_name:H.selectedModel,per_instance_cost_limit:H.perInstanceCostLimit,agentic_skills:H.selectedSkills,selectedImages:l,repository:H.githubUrl,branch:H.branchName||"",projectType:H.projectType,selectedCustomAgent:H.selectedCustomAgent,privacy:H.privacy,ultraMode:H.ultraMode,testMode:H.testMode,test_mode_on:H.testMode,selectedMcpTools:(null==(n=null==H?void 0:H.selectedMcpTools)?void 0:n.flatMap(e=>(null==e?void 0:e.mcpServers)?Object.keys(e.mcpServers):[]))||[],selectedMcpServers:H.selectedMcpTools,...c&&{organization_id:c,level:"organization"},fromCreateTask:!0,tabId:e,parentTabId:e,isCloudFlow:!0,client_ref_id:null,needsApiCall:!0,pending_client_ref_id:crypto.randomUUID(),id:e,title:"Setting up Task",path:"/chat",experimental:fe,e15Enabled:ve,selectedFiles:o,base64_image_list:l.length>0?l:void 0,state:{tabId:e,sourceTabId:e}},...H.selectedCustomAgent?{user_prompt_id:H.selectedCustomAgent}:{prompt_name:ye&&(null==(s=null==u?void 0:u.prototype_agent_experimental)?void 0:s.agent)?u.prototype_agent_experimental.agent:ve&&(null==(i=null==u?void 0:u.e15_experimental)?void 0:i.agent)?u.e15_experimental.agent:fe&&(null==(a=null==u?void 0:u.e1_experimental)?void 0:a.agent)?u.e1_experimental.agent:"auto_prompt_selector_dev"}};Ie.clearImages(),Ee({selectedImages:[]}),pe(!1),A([]),f(e,p),g(t=>t.some(t=>t.id===e)?t.map(t=>t.id===e?{...t,path:"/chat",title:"Setting up Task",state:p,...c&&{organization_id:c,level:"organization"}}:t):[...t,{id:e,title:"Setting up Task",path:"/chat",state:p,...c&&{organization_id:c,level:"organization"}}]),v(e),Le(),t()}catch(r){d({title:"Error",description:"Failed to create task. Please try again.",variant:"destructive"}),Ng("abandoned",{userId:null==y?void 0:y.id,reason:"submission_error",error:String(r),tabId:e})}finally{Fe.current=!1,ee(!1)}},700),Ue=async()=>{var t;if(bg(sE.NEW_JOB_CREATED,{isUserLoggedIn:b&&y}),b&&y){const s=x(e),i=[];if(I&&I.length>0)for(const e of I)if(e.type.startsWith("image/"))try{const t=await new Promise((t,n)=>{const s=new FileReader;s.onload=()=>{const e=s.result.split(",")[1];t(e)},s.onerror=n,s.readAsDataURL(e)});i.push({mime_type:e.type,img_base64:t})}catch(n){}const a=[...H.selectedImages||[],...i],r=C(),o={...s,selectedImages:a,base64_image_list:a.length>0?a:void 0,selectedMcpTools:(null==(t=null==H?void 0:H.selectedMcpTools)?void 0:t.flatMap(e=>(null==e?void 0:e.mcpServers)?Object.keys(e.mcpServers):[]))||[],selectedMcpServers:H.selectedMcpTools,jobsLength:c,needsApiCall:!0,...r&&{organization_id:r,level:"organization"}};f(e,o),setTimeout(()=>{Ve()},100)}else ne(!0)},We=e=>{bg(sE.BUDGET_VALUE_UPDATED,{updatedValue:e})};return u?a.jsxs(a.Fragment,{children:[a.jsx($A,{enableWelcomeModal:!0,open:te,onOpenChange:ne,defaultView:"signup",onSuccess:e=>{}}),a.jsx(IM,{isOpen:i,onOpenChange:r}),a.jsx(FM,{isOpen:se,onOpenChange:ie}),a.jsx(B,{delayDuration:200,children:a.jsx("div",{className:"relative w-full",children:a.jsxs("div",{className:"w-full max-w-4xl mx-auto max-md:pt-0 md:p-6",children:[a.jsx(Tk.div,{initial:{opacity:0,y:-20},animate:{opacity:1,y:0},transition:{duration:.3,ease:"easeOut"},children:a.jsxs("div",{className:"max-md:fixed max-md:bottom-0 max-md:left-0 max-md:right-0",children:[0===I.length&&a.jsx("div",{className:"md:hidden",children:a.jsx(LM,{config:u,showChips:Y&&!V&&!J&&(Ne||!W),taskInput:H.taskInput,onChipClick:Ae,onSurpriseMe:()=>{}})}),a.jsxs("div",{className:bb("md:bg-[#FFFFFF0D] max-md:rounded-t-[18px] md:rounded-[18px] ","p-[0px]"),style:{background:Ne||j()?"transparent":"none"},onMouseEnter:()=>{},onMouseLeave:()=>{},children:[a.jsx("div",{className:"relative max-md:hidden",children:a.jsx(zb,{mode:"wait",children:!j()&&!1})}),a.jsxs("div",{children:[I.length>0&&Ne&&a.jsx("div",{className:"max-w-[94%] mx-auto bg-[#18181A] border border-[#222] border-b-0 rounded-t-[18px] p-3",children:a.jsxs("div",{className:"flex flex-wrap gap-3",children:[(H.loadingImages||T)&&a.jsxs("div",{className:"flex items-center justify-center w-full py-4",children:[a.jsx(gS,{className:"h-6 w-6 text-[#999] animate-spin mr-2"}),a.jsx("span",{className:"text-[#999]",children:T?"Processing and compressing files...":"Processing files..."})]}),!H.loadingImages&&!T&&I.map((e,t)=>{var n;const s=e.type.startsWith("image/"),i=s?URL.createObjectURL(e):null;return a.jsxs("div",{className:"relative w-12 h-12 rounded-md border border-[#333] group",children:[s&&i?a.jsx("img",{src:i,alt:e.name,className:"w-full h-full object-cover z-[1] rounded-md"}):a.jsx("div",{className:"w-full h-full bg-[#2A2A2C] rounded-md flex items-center justify-center z-[1]",children:a.jsx("span",{className:"text-[#999] text-xs font-mono",children:(null==(n=e.name.split(".").pop())?void 0:n.toUpperCase())||"FILE"})}),a.jsx("button",{type:"button",onClick:()=>ze(t),className:"absolute top-[-8px] right-[-8px] bg-transparent z-[2] rounded-full p-1 transition-opacity","aria-label":"Remove file",children:a.jsx("div",{className:"p-1 bg-white rounded-full",children:a.jsx("img",{src:PM,alt:"Remove file",className:"w-3 h-3"})})})]},`${e.name}-${t}`)})]})}),a.jsx("div",{className:"relative w-full ",children:a.jsx(EA,{value:H.taskInput,onChange:t=>{Ee({taskInput:t.target.value}),t.target.value.length%50==0&&Ng("started",{userId:null==y?void 0:y.id,taskInputLength:t.target.value.length,isTyping:!0,tabId:e})},handleExperimentalChange:Te,experimentalEnabled:fe,e15Enabled:ve,onE15Enabled:Me,prototypeEnabled:ye,onPrototypeEnabled:De,ultraMode:H.ultraMode,onUltraModeChange:e=>Ee({ultraMode:e}),testMode:H.testMode,onTestModeChange:e=>Ee({testMode:e}),className:"relative bg-[#18181A] w-full rounded-t-[12px] md:rounded-b-[12px] text-[#DDDDE6]\n placeholder:text-[#666] md:text-base focus-visible:ring-1 focus:ring-1 z-10",onAttachClick:Oe,attachIcon:RM,attachTooltip:"Attach files & images",isUploadAssetEnabled:S,onPaste:e=>{var t;const n=null==(t=e.clipboardData)?void 0:t.items;if(n){const t=Array.from(n).filter(e=>"file"===e.kind);if(0===t.length)return;e.preventDefault();const s=t.map(e=>e.getAsFile()).filter(Boolean);s.length>0&&Re(s)}},handleSettingsClick:()=>{G||(W?(Z(!0),q(!1),setTimeout(()=>{U(!V),Z(!1)},300)):U(!V))},showControls:V,onFocusChange:e=>Q(e),onSubmit:Ue,disabled:X||!H.taskInput||Sg(),isSubmitting:X,showGithubSettings:W,handleGithubSettings:()=>{bg(sE.GITHUB_EVENTS.CONNECT_TO_GITHUB_ICON_CLICKED),b?G||(V?(Z(!0),U(!1),setTimeout(()=>{q(!W),Z(!1)},300)):q(!W)):ne(!0)},hasUserConnectedGithub:F,githubUrl:H.githubUrl,onClearGithubUrl:Le,userPrompts:(null==R?void 0:R.user_prompts)||[],isLoadingUserPrompts:O,selectedCustomAgent:H.selectedCustomAgent,onCustomAgentChange:e=>Ee({selectedCustomAgent:e}),shouldShowUserPrompts:"pro_mode"===w||_||(null==k?void 0:k.is_pro_enabled),mobileEnabled:ue,onMobileEnabled:pe,showMobileAgentIntro:o,onMobileAgentIntroShown:l,showModelSelector:!0,availableModels:(null==(qe=null==u?void 0:u.model_list)?void 0:qe.map(e=>({id:e.name,name:e.display_name,description:e.description,icon:"openai"===e.provider?MM:hA,showNew:"openai"===e.provider,user_tier:e.user_tier,unavailable_tier:e.unavailable_tier})))||[],selectedModelId:H.selectedModel,onModelChange:e=>Ee({selectedModel:e}),selectedImage:H.selectedImage,setSelectedImage:e=>Ee({selectedImage:e}),globalConfig:u,perInstanceCostLimit:H.perInstanceCostLimit,setPerInstanceCostLimit:e=>Ee({perInstanceCostLimit:e}),onPrivacyChange:e=>{e!==H.privacy&&Ee({privacy:e})},selectedMcpTools:H.selectedMcpTools,onMcpToolsChange:e=>Ee({selectedMcpTools:e}),isRecording:ae,isTranscribing:ce,onVoiceClick:He})}),I.length>0&&!Ne&&a.jsx("div",{className:"mt-[-20px] max-w-[94%] mx-auto bg-[#1D1D1F] border border-[#222] rounded-lg p-3",children:a.jsxs("div",{className:"flex flex-wrap gap-3 pt-4",children:[(H.loadingImages||T)&&a.jsxs("div",{className:"flex items-center justify-center w-full py-4",children:[a.jsx(gS,{className:"h-6 w-6 text-[#999] animate-spin mr-2"}),a.jsx("span",{className:"text-[#999]",children:T?"Processing and compressing files...":"Processing files..."})]}),!H.loadingImages&&!T&&I.map((e,t)=>{var n;const s=e.type.startsWith("image/"),i=s?URL.createObjectURL(e):null;return a.jsxs("div",{className:"relative w-12 h-12 rounded-md border border-[#333] group",children:[s&&i?a.jsx("img",{src:i,alt:e.name,className:"w-full h-full object-cover z-[1] rounded-md"}):a.jsx("div",{className:"w-full h-full bg-[#2A2A2C] rounded-md flex items-center justify-center z-[1]",children:a.jsx("span",{className:"text-[#999] text-xs font-mono",children:(null==(n=e.name.split(".").pop())?void 0:n.toUpperCase())||"FILE"})}),a.jsx("button",{type:"button",onClick:()=>ze(t),className:"absolute top-[-8px] right-[-8px] bg-transparent z-[2] rounded-full p-1 transition-opacity","aria-label":"Remove file",children:a.jsx("div",{className:"p-1 bg-white rounded-full",children:a.jsx("img",{src:PM,alt:"Remove file",className:"w-3 h-3"})})})]},`${e.name}-${t}`)})]})})]})]})]})}),0===I.length&&!Ne&&a.jsx("div",{className:j()?"grayscale":"",children:a.jsx(UA,{config:u,showChips:Y&&!V&&(Ne||!W),taskInput:H.taskInput,onChipClick:Ae,onSurpriseMe:()=>{}})}),a.jsxs(zb,{children:[!V&&W&&a.jsx(Tk.div,{initial:{opacity:0,height:0,scale:.8},animate:{opacity:1,height:"auto",scale:1},exit:{opacity:0,height:0,scale:.8},transition:{duration:.3,ease:"easeInOut"},children:a.jsx("div",{className:"w-full bg-[#131314] mt-3",children:a.jsx(uT,{ref:_e,githubUrl:H.githubUrl,branchName:H.branchName,onGithubUrlChange:e=>Ee({githubUrl:e}),onBranchNameChange:e=>Ee({branchName:e}),onClose:()=>{q(!1)}})})}),V&&!W&&a.jsx(Tk.div,{initial:{opacity:0,height:0,scale:.8},animate:{opacity:1,height:"auto",scale:1},exit:{opacity:0,height:0,scale:.8},transition:{duration:.3,ease:"easeInOut"},children:(()=>{var e,t;return a.jsxs("div",{className:"w-full bg-[#0F181A] border border-[#66EAFF1F] rounded-[16px] transition-colors mt-3",children:[a.jsxs("div",{className:"flex items-center justify-between w-full gap-4 px-5 pt-5",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(JI,{color:"#66eaff",size:20}),a.jsx("span",{className:"text-[#66EAFF] font-brockmann font-medium",children:"Advanced Controls"})]}),a.jsx("img",{alt:"Close",src:OM,className:"w-5 h-5 cursor-pointer",onClick:()=>{G||U(!1)}})]}),a.jsxs("div",{className:"flex flex-col px-5 pt-5 space-y-2",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("p",{className:"text-[#FFFFFF50] font-inter font-medium text-[14px]",children:"Select MCPs to use"}),a.jsx("span",{className:"text-[#131314] px-2 py-[2px] font-semibold font-inter text-[12px] rounded-full bg-[#F49B57]",children:"New"})]}),a.jsxs("button",{type:"button",onClick:()=>de.open({formState:H,updateFormState:Ee,organizationId:C()}),className:bb("w-full h-14 bg-[#FFFFFF0A] border border-[#ffffff12] rounded-lg text-[#DDDDE6] hover:border-[#333] transition-colors px-4 flex items-center justify-between",H.selectedMcpTools.length>0&&"pl-3"),children:[a.jsxs("div",{className:"flex items-center gap-3",children:[H.selectedMcpTools.length<=0&&a.jsx(OE,{size:20}),a.jsx("div",{className:"flex flex-wrap items-center gap-2",children:H.selectedMcpTools.length>0?a.jsxs(a.Fragment,{children:[H.selectedMcpTools.slice(0,3).map((e,t)=>{const n=null==z?void 0:z.find(t=>t.id===e);return a.jsxs("div",{className:"group relative flex items-center gap-2 bg-[#FFFFFF]/10 px-2 py-2 rounded-full hover:bg-[#FFFFFF]/15 cursor-pointer transition-all duration-200 ease-out",children:[(null==n?void 0:n.icon)?a.jsx("img",{src:n.icon,alt:n.display_name,className:"flex-shrink-0 w-4 h-4 rounded-sm"}):a.jsx(OE,{size:16}),a.jsx("span",{className:"text-sm text-[#DDDDE6] flex-shrink-0",children:(null==n?void 0:n.display_name)||e}),a.jsx("button",{title:"Close",type:"button",onClick:e=>{e.stopPropagation();const n=H.selectedMcpTools.filter((e,n)=>n!==t);Ee({selectedMcpTools:n})},className:"flex items-center justify-center w-4 h-4 transition-all duration-150 rounded-full opacity-50 right-2 hover:opacity-80",children:a.jsx(HS,{size:16})})]},`${e}-${t}`)}),H.selectedMcpTools.length>3&&a.jsx("div",{className:"flex items-center gap-2 bg-[#FFFFFF]/10 px-2 py-2 rounded-full",children:a.jsxs("span",{className:"text-sm text-[#DDDDE6]",children:["+",H.selectedMcpTools.length-3," more"]})})]}):a.jsx("span",{children:"Select MCP Tools"})})]}),a.jsx(Gk,{size:20})]})]}),a.jsxs("div",{className:"grid grid-cols-1 gap-5 px-5 py-5 md:grid-cols-2",children:[$e("dockerImage")&&a.jsx(oE,{selectedImage:H.selectedImage,setSelectedImage:e=>Ee({selectedImage:e}),globalConfig:u,label:"Select Template",isCloudFlow:!0}),$e("budget")&&a.jsxs("div",{className:"flex flex-col justify-between h-full",children:[a.jsx("p",{className:"text-[#FFFFFF50] font-inter text-sm",children:"Budget (Credits)"}),a.jsxs("div",{className:"relative flex items-center",children:[a.jsx("button",{type:"button",title:"Decrease budget",onClick:()=>{const e=parseInt(H.perInstanceCostLimit);e>1&&(Ee({perInstanceCostLimit:(e-1).toString()}),We(e-1))},className:"w-[40px] h-[40px] flex items-center justify-center absolute left-1 text-[#666] hover:text-[#999] transition-colors hover:bg-[#0F181A] rounded-sm",children:a.jsx(yS,{className:"h-6 w-6 text-[#DDDDE6]"})}),a.jsxs("div",{className:"w-full h-[56px] bg-[#FFFFFF0A] border border-[#ffffff12] rounded-lg text-[#DDDDE6] px-4 flex items-center justify-center hover:border-[#333]",children:[a.jsx("img",{alt:"Budget",className:"text-[#B4A456] w-5 h-5",src:zM}),a.jsx("input",{type:"number",min:"1",step:"1",value:H.perInstanceCostLimit,onChange:e=>{"0"!==e.target.value&&(Ee({perInstanceCostLimit:e.target.value}),We(e.target.value))},disabled:p,placeholder:p?"Loading...":" - - ",className:"w-20 bg-transparent text-left focus:outline-none text-[#DDDDE6] font-inter text-xl font-semibold leading-[120%] tracking-[-0.4px] [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none"})]}),a.jsx("button",{type:"button",title:"Increase budget",onClick:()=>{const e=parseInt(H.perInstanceCostLimit);Ee({perInstanceCostLimit:(e+1).toString()}),We(e+1)},className:"w-[40px] h-[40px] flex items-center justify-center absolute right-1 text-[#666] hover:text-[#999] transition-colors hover:bg-[#0F181A] rounded-sm",children:a.jsx(NS,{className:"h-6 w-6 text-[#DDDDE6]"})})]})]}),E&&a.jsxs("div",{className:"flex flex-col justify-between h-full col-span-2",children:[a.jsx("p",{className:"text-[#FFFFFF50] font-inter text-sm mb-2",children:"Privacy"}),a.jsx("div",{className:" h-[56px] bg-[#FFFFFF0A] border border-[#ffffff12] rounded-lg text-[#DDDDE6] px-4 w-full flex items-center gap-3 hover:border-[#333]",children:a.jsx(vA,{privacy:H.privacy})})]})]}),"free"==w&&a.jsxs("div",{className:"flex flex-col w-full px-5 space-y-2",children:[a.jsx("p",{className:"text-[#FFFFFF50] font-inter text-sm",children:"Model"}),a.jsx(gA,{models:(null==(e=null==u?void 0:u.model_list)?void 0:e.map(e=>({id:e.name,name:e.display_name,description:e.description,icon:"openai"===e.provider?MM:hA,showNew:"openai"===e.provider,user_tier:e.user_tier,unavailable_tier:e.unavailable_tier})))||[],selectedModelId:H.selectedModel,onModelChange:e=>{Ee({selectedModel:e}),bg(sE.MODEL_VALUE_UPDATED,{selectedModel:e})},currentUserTier:w,isEmergentUser:_,onUpgradeRequired:()=>ie(!0),disabled:p,placeholder:p?"Loading models...":"Select Model"})]}),a.jsxs("div",{className:"grid grid-cols-1 gap-5 px-5 py-5",children:[$e("agent")&&a.jsxs("div",{className:"flex flex-col space-y-2",children:[a.jsx("p",{className:"text-[#FFFFFF50] font-inter text-sm",children:"Agent"}),a.jsxs($S,{value:H.selectedAgent,onValueChange:e=>Ee({selectedAgent:e}),disabled:p,children:[a.jsx(US,{className:"w-full h-14 bg-[#FFFFFF0A] border border-[#ffffff12] rounded-lg text-[#DDDDE6] hover:border-[#333] transition-colors data-[state=open]:border-[#333]",children:p?a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(gS,{className:"w-4 h-4 animate-spin"}),a.jsx("span",{children:"Loading agents..."})]}):a.jsx(VS,{placeholder:"Select Agent"})}),a.jsx(GS,{className:"bg-[#131314] border border-[#222]",children:null==(t=null==u?void 0:u.agent_names)?void 0:t.map((e,t)=>a.jsx(ZS,{value:e.name,className:"text-[#DDDDE6] hover:bg-[#222] focus:bg-[#222]",children:e.display_name},`${e.name}-${t}`))})]})]}),$e("skills")&&a.jsx(xE,{selectedSkills:H.selectedSkills,setSelectedSkills:e=>Ee({selectedSkills:e}),skills:je,loadingSkills:!1,label:"Skills"})]})]})})()})]})]})})})]}):a.jsx("div",{className:"flex items-center min-h-[300px] justify-center w-full h-full",children:a.jsx(gS,{className:"w-8 h-8 text-white opacity-25 animate-spin"})});var qe}function HM({className:e=""}){const{user:t}=Yg();return a.jsxs("footer",{className:bb("absolute overflow-clip flex flex-row md:flex-row items-center justify-between w-screen px-3 py-3 md:px-6 md:py-6 bottom-12",e),children:[a.jsx("div",{className:"items-center hidden mb-2 md:flex md:mb-0",children:a.jsx("img",{src:"/logo-text.svg",alt:"Emergent Logo",className:"w-[80px] md:w-[113px] h-[40px]"})}),a.jsxs("div",{className:"flex-col items-center hidden w-full gap-2 md:flex md:w-auto sm:items-end sm:justify-end md:items-center md:flex-row md:gap-6",children:[a.jsxs("div",{className:"flex items-end justify-end md:items-center gap-4 text-[#666666] text-[13px] md:text-[0.8rem]",children:[t&&a.jsx(He,{to:"/home",className:"hover:text-[#2EBBE5] transition-colors",onClick:()=>bg(sE.FOOTER_EVENTS.HOME_BUTTON_CLICKED),children:"Home"}),a.jsx(He,{to:"/affiliates",className:"hover:text-[#2EBBE5] transition-colors",onClick:()=>bg(sE.FOOTER_EVENTS.AFFILIATES_BUTTON_CLICKED),children:"Affiliates"}),a.jsx(He,{to:"https://emergent.sh/enterprise",target:"_blank",className:"hover:text-[#2EBBE5] transition-colors",onClick:()=>bg(sE.FOOTER_EVENTS.ENTERPRISE_BUTTON_CLICKED),children:"Enterprise"}),a.jsx(He,{to:"/privacy-policy",className:"hover:text-[#2EBBE5] transition-colors",onClick:()=>bg(sE.FOOTER_EVENTS.PRIVACY_POLICY_BUTTON_CLICKED),children:"Privacy Policy"}),a.jsx(He,{to:"/terms-of-service",className:"hover:text-[#2EBBE5] transition-colors",onClick:()=>bg(sE.FOOTER_EVENTS.TERM_OF_SERVICE_BUTTON_CLICKED),children:"Terms of Service"})]}),a.jsxs("div",{className:"hidden md:flex items-center gap-2 font-ndot text-[#666666] text-[12px] md:text-[1rem]",children:["Copyright ",a.jsx("img",{src:"data:image/svg+xml,%3csvg%20width='18'%20height='18'%20viewBox='0%200%2018%2018'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M7.66308%2011.941H10.5431C10.7471%2011.941%2010.9181%2011.872%2011.0561%2011.734C11.1941%2011.596%2011.2631%2011.425%2011.2631%2011.221V9.78096H9.82308V10.501H8.38308V7.62096H9.82308V8.34096H11.2631V6.90096C11.2631%206.69696%2011.1941%206.52596%2011.0561%206.38796C10.9181%206.24996%2010.7471%206.18096%2010.5431%206.18096H7.66308C7.45908%206.18096%207.28808%206.24996%207.15008%206.38796C7.01208%206.52596%206.94308%206.69696%206.94308%206.90096V11.221C6.94308%2011.425%207.01208%2011.596%207.15008%2011.734C7.28808%2011.872%207.45908%2011.941%207.66308%2011.941ZM9.10308%2016.261C8.10708%2016.261%207.17108%2016.072%206.29508%2015.694C5.41908%2015.316%204.65708%2014.803%204.00908%2014.155C3.36108%2013.507%202.84808%2012.745%202.47008%2011.869C2.09208%2010.993%201.90308%2010.057%201.90308%209.06096C1.90308%208.06496%202.09208%207.12896%202.47008%206.25296C2.84808%205.37696%203.36108%204.61496%204.00908%203.96696C4.65708%203.31896%205.41908%202.80596%206.29508%202.42796C7.17108%202.04996%208.10708%201.86096%209.10308%201.86096C10.0991%201.86096%2011.0351%202.04996%2011.9111%202.42796C12.7871%202.80596%2013.5491%203.31896%2014.1971%203.96696C14.8451%204.61496%2015.3581%205.37696%2015.7361%206.25296C16.1141%207.12896%2016.3031%208.06496%2016.3031%209.06096C16.3031%2010.057%2016.1141%2010.993%2015.7361%2011.869C15.3581%2012.745%2014.8451%2013.507%2014.1971%2014.155C13.5491%2014.803%2012.7871%2015.316%2011.9111%2015.694C11.0351%2016.072%2010.0991%2016.261%209.10308%2016.261ZM9.10308%2014.821C10.7111%2014.821%2012.0731%2014.263%2013.1891%2013.147C14.3051%2012.031%2014.8631%2010.669%2014.8631%209.06096C14.8631%207.45296%2014.3051%206.09096%2013.1891%204.97496C12.0731%203.85896%2010.7111%203.30096%209.10308%203.30096C7.49508%203.30096%206.13308%203.85896%205.01708%204.97496C3.90108%206.09096%203.34308%207.45296%203.34308%209.06096C3.34308%2010.669%203.90108%2012.031%205.01708%2013.147C6.13308%2014.263%207.49508%2014.821%209.10308%2014.821Z'%20fill='%23666666'/%3e%3c/svg%3e",alt:"Copyright Logo"})," Emergentlabs 2025"]})]})]})}const $M=()=>{const{user:e,session:t}=Yg(),[n,s]=Pe.useState(!1),[i,r]=Pe.useState("login");return a.jsxs(a.Fragment,{children:[a.jsx($A,{enableWelcomeModal:!0,open:n,onOpenChange:s,defaultView:"login",openView:i,onSuccess:()=>{r("login"),s(!1)}}),a.jsxs("section",{className:"shadow-xl hidden md:block overflow-hidden md:py-20 pb-[15rem] md:pb-[20rem] mt-[10rem] relative",children:[a.jsx(BA,{height:"70%",top:"30%",gridSizeX:50,gridSizeY:30,gridLineWidth:.3,gridOpacity:.6}),a.jsx("div",{className:"relative z-20 flex flex-col items-center justify-center w-full h-full",children:a.jsxs("div",{className:"flex flex-col items-center",children:[a.jsxs("div",{className:"flex flex-col items-center md:gap-4",children:[a.jsx("h2",{className:"text-[40px] md:text-[80px] md:leading-[80px] font-medium text-white",children:"Start building with"}),a.jsx("h2",{className:"text-[#00FF66] font-ndot text-[34px] md:text-[72px] md:leading-[72px] uppercase",children:"Emergent Today"})]}),a.jsx("button",{onClick:n=>{n.preventDefault(),e&&t?window.requestAnimationFrame(()=>{const e=document.getElementById("mainTaskInput");e&&(e.scrollIntoView({behavior:"smooth",block:"center"}),setTimeout(()=>{e.focus()},500))}):s(!0)},className:"relative flex items-center gap-3 py-4 text-base font-semibold leading-6 tracking-wide text-black transition-colors bg-white rounded-full mt-14 px-14 hover:bg-gray-100 get-started-button before:absolute before:inset-0 before:-m-1 before:rounded-full before:border before:border-[#FFFFFF26] before:-z-10",children:e&&t?"Keep Building":"Get Started"})]})}),a.jsx(HM,{})]})]})},VM=Pe.forwardRef(({className:e,...t},n)=>a.jsx("div",{className:"relative w-full overflow-auto",children:a.jsx("table",{ref:n,className:bb("w-full caption-bottom text-sm",e),...t})}));VM.displayName="Table";const UM=Pe.forwardRef(({className:e,...t},n)=>a.jsx("thead",{ref:n,className:bb("[&_tr]:border-b",e),...t}));UM.displayName="TableHeader";const WM=Pe.forwardRef(({className:e,...t},n)=>a.jsx("tbody",{ref:n,className:bb("[&_tr:last-child]:border-0",e),...t}));WM.displayName="TableBody";Pe.forwardRef(({className:e,...t},n)=>a.jsx("tfoot",{ref:n,className:bb("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",e),...t})).displayName="TableFooter";const qM=Pe.forwardRef(({className:e,...t},n)=>a.jsx("tr",{ref:n,className:bb("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",e),...t}));qM.displayName="TableRow";const GM=Pe.forwardRef(({className:e,...t},n)=>a.jsx("th",{ref:n,className:bb("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",e),...t}));GM.displayName="TableHead";const ZM=Pe.forwardRef(({className:e,...t},n)=>a.jsx("td",{ref:n,className:bb("p-4 align-middle [&:has([role=checkbox])]:pr-0",e),...t}));ZM.displayName="TableCell";Pe.forwardRef(({className:e,...t},n)=>a.jsx("caption",{ref:n,className:bb("mt-4 text-sm text-muted-foreground",e),...t})).displayName="TableCaption";const YM=Pe.forwardRef(({className:e,...t},n)=>a.jsx("div",{ref:n,className:bb("rounded-2xl border bg-card text-card-foreground shadow-sm",e),...t}));YM.displayName="Card";const KM=Pe.forwardRef(({className:e,...t},n)=>a.jsx("div",{ref:n,className:bb("flex flex-col space-y-1.5 p-6",e),...t}));KM.displayName="CardHeader";const JM=Pe.forwardRef(({className:e,...t},n)=>a.jsx("div",{ref:n,className:bb("text-2xl font-semibold leading-none tracking-tight",e),...t}));JM.displayName="CardTitle";const QM=Pe.forwardRef(({className:e,...t},n)=>a.jsx("div",{ref:n,className:bb("text-sm text-muted-foreground",e),...t}));QM.displayName="CardDescription";const XM=Pe.forwardRef(({className:e,...t},n)=>a.jsx("div",{ref:n,className:bb("p-6 pt-0",e),...t}));XM.displayName="CardContent";Pe.forwardRef(({className:e,...t},n)=>a.jsx("div",{ref:n,className:bb("flex items-center p-6 pt-0",e),...t})).displayName="CardFooter";const eD=wv.common.captivePortal,tD=wv.icons.animatedSpinner,nD=wv.deployment.replace,sD=wv.deployment.timeGreyDeployed,iD=wv.deployment.goBack,aD=e=>{const t=new Date,n=Math.floor((t.getTime()-e.getTime())/1e3);if(n<60)return`${n} sec${1!==n?"s":""} ago`;const s=Math.floor(n/60);if(s<60)return`${s} min${1!==s?"s":""} ago`;const i=Math.floor(s/60);if(i<24)return`${i} hr${1!==i?"s":""} ago`;const a=Math.floor(i/24);if(a<30)return`${a} day${1!==a?"s":""} ago`;const r=Math.floor(a/30);if(r<12)return`${r} month${1!==r?"s":""} ago`;const o=Math.floor(r/12);return`${o} year${1!==o?"s":""} ago`};function rD({status:e,deployment:t,deployUrl:n}){if("running"===e)return"";const s=null==t?void 0:t.custom_domain;return s&&""!==s&&""!==s.trim()?s.includes("http")?s:`https://${s}`:n||""}function oD({deployment:e,index:t,hoveredCard:n,onHoverStart:s,onHoverEnd:i,onClick:r,fromRedeployModal:o=!1,onReplaceClick:l,allowHover:c=!0}){const d=e.deployStatus,u=(e=>"running"===e?{bgColor:"#1588FC20",color:"#33DDFF",text:"Deploying",animate:!0}:"success"===e?{bgColor:"#2EE57220",color:"#2EE572",text:"Live",animate:!0}:"failed"===e?{bgColor:"#ffffff10",color:"#ED5B5B",text:"Failed",animate:!1}:{bgColor:"#73778020",color:"#737780",text:"Unknown",animate:!1})(d),p=e.deployUrl,m=e.id.substring(0,6),h=new Date(e.latest_run.updated_at),x=null!=h?`Deployed ${aD(h)}`:"Unknown";return a.jsx(zt.div,{initial:{opacity:0,y:20,scale:.95},animate:{opacity:1,y:0,scale:1},whileHover:c?{y:-4,boxShadow:"0px 10px 25px rgba(0, 0, 0, 0.2)",transition:{type:"tween",ease:"easeInOut",duration:.3}}:{},transition:{type:"tween",ease:"easeInOut",duration:.2,delay:.1*t},onHoverStart:()=>s(e.id),onHoverEnd:i,onClick:()=>r(e),children:a.jsxs("div",{className:bb("rounded-[16px] overflow-clip bg-[#2626291A] border h-full flex flex-col justify-between cursor-pointer transition-all duration-200",n===e.id?"border-[#FFFFFF20] shadow-lg":"border-[#FFFFFF0F]",o?"bg-[#161617]":"cursor-pointer "),children:[a.jsxs("div",{className:"px-4 py-4",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:bb("text-[12px] md:text-[14px] font-['Inter'] font-medium transition-colors duration-200",n===e.id?"text-[#ffffff80]":"text-[#ffffff50]"),children:["# EMT-",m]}),a.jsxs("div",{className:bb("flex items-center gap-[6px] px-[10px] py-[6px] rounded-[8px] transition-all duration-200"),style:{backgroundColor:n===e.id?u.bgColor.replace("20","30"):u.bgColor},children:["running"!=d&&a.jsx(aT,{color:"failed"!=d?u.color:"#ffffff60",size:16,innerSize:8,animate:u.animate}),"running"===d&&a.jsx("img",{src:tD,alt:"Loading...",className:"w-6 h-6"}),a.jsx("span",{className:bb("text-[15px] font-medium transition-colors duration-200"),style:{color:"failed"!=d?u.color:"#ffffff60",opacity:n===e.id?1:.9},children:u.text})]})]}),a.jsx("div",{className:bb("mt-5 text-[20px] md:text-[24px] font-medium font-brockmann transition-colors duration-200 capitalize line-clamp-1",n===e.id?"text-white/95":"text-white/80"),children:e.title}),a.jsx("div",{className:bb("mt-2 text-[14px] md:text-[16px] font-['Inter'] font-medium transition-colors duration-200 truncate line-clamp-2",n===e.id?"text-white/40":"text-white/20"),children:e.description}),a.jsxs("div",{className:"flex gap-4",children:["failed"!=d&&a.jsxs("a",{href:rD({status:d,deployment:e,deployUrl:p}),target:"_blank",rel:"noopener noreferrer",className:bb("flex mt-5 w-full items-center justify-center gap-2 px-4 py-2 md:min-h-[44px] rounded-[10px] transition-all duration-200",n===e.id&&"running"!==d?"bg-[#FFFFFF15]":"bg-[#FFFFFF0F]",n===e.id&&"running"!==d?"hover:bg-[#ffffff20]":"hover:bg-[#3A3A3C]","running"===d&&"opacity-30 cursor-not-allowed hover:bg-[#FFFFFF0F]"),onClick:e=>e.stopPropagation(),children:[a.jsx("span",{className:bb("transition-colors duration-200",n===e.id?"text-white/90":"text-white/70"),children:"Visit"}),a.jsx("img",{src:eD,alt:"Visit",className:"w-4 h-4"})]}),o&&a.jsxs("div",{className:bb("flex mt-5 w-full items-center justify-center gap-2 px-4 py-2 rounded-[10px] md:min-h-[44px] cursor-pointer transition-all duration-200 bg-[#80FFF914] hover:bg-[#80FFF920]","running"===e.deployStatus?"opacity-30 cursor-not-allowed":"opacity-100 cursor-pointer"),onClick:t=>{t.stopPropagation(),l&&"running"!==e.deployStatus&&l(e)},children:[a.jsx("span",{className:bb("transition-colors duration-200",(e.id,"text-[#80FFF9]")),children:"Replace"}),a.jsx("img",{src:nD,alt:"Visit",className:"w-6 h-6"})]})]})]}),"failed"!=d&&a.jsxs("div",{className:bb("flex items-center px-4 justify-between py-3 bg-[#FFFFFF05] min-h-[44px] text-[14px] transition-colors duration-200",n===e.id?"text-[#FFFFFF80]":"text-[#FFFFFF33]"),children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("img",{src:sD,alt:"Deploy Time",className:bb("w-5 h-5 opacity-20 ",n===e.id?"opacity-30":"opacity-20")}),a.jsx("span",{className:"text-[12px] md:text-[14px]",children:x})]}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("span",{className:bb("text-[12px] md:text-[14px]",n===e.id?"text-[#FFFFFF80] block":" hidden"),children:"View Task"}),a.jsx("img",{src:iD,alt:"Visit",className:"w-4 h-4 rotate-180"})]})]})]})},e.id)}const lD=wv.common.copperCoin,cD=wv.common.webImage;function dD({handleJobClick:e,organizationId:t}){const[n,s]=Pe.useState(null),[i,r]=Pe.useState([]),[o,l]=Pe.useState(!0),[c]=Ux(),d=Pe.useCallback(async()=>{try{l(!0);const e=await sm(t);if("error"in e)r([]);else{const t=e.map(e=>({id:e.job_id,app_name:e.app_name||"Unnamed App",deployStatus:e.status,deployUrl:e.deployed_url||"",custom_domain:e.custom_domain||"",latest_run:{status:e.status,updated_at:e.deployed_at||null},description:e.task||"No task available",deployment_id:e.deployment_id,title:e.title||"Untitled"})).sort((e,t)=>{const n=new Date(e.latest_run.updated_at).getTime();return new Date(t.latest_run.updated_at).getTime()-n});r(t)}}catch(e){r([])}finally{l(!1)}},[t]);Pe.useEffect(()=>{d()},[d]);const u=async t=>{try{const n=await c(t.id);if("error"in n)return;const s=n.data;s&&e(s)}catch(n){}},p=Array(6-Math.min(i.length,6)).fill(null);return o?a.jsx("div",{className:"flex flex-col mt-2 mb-8 space-y-5 min-h-[546px] bg-[#0F0F10] md:border-[#252629] md:border p-8 rounded-[16px]",children:a.jsx("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-3",children:Array(6).fill(null).map((e,t)=>a.jsxs(YM,{className:"bg-[#111112] border-[#FFFFFF0F] h-[300px] animate-pulse",children:[a.jsx(KM,{className:"p-5",children:a.jsx("div",{className:"h-4 w-24 bg-[#FFFFFF14] rounded"})}),a.jsxs(XM,{className:"p-5 pt-0",children:[a.jsx("div",{className:"h-4 w-full bg-[#FFFFFF14] rounded mb-4"}),a.jsx("div",{className:"h-4 w-3/4 bg-[#FFFFFF14] rounded"})]})]},`loading-${t}`))})}):a.jsx("div",{className:"flex flex-col relative mt-2 mb-8 space-y-5 max-h-[650px] overflow-y-scroll min-h-[546px] bg-[#0F0F10] md:border-[#252629] md:border md:p-6 overflow-clip rounded-[16px]",children:0===i.length?a.jsxs("div",{className:"md:flex flex-col space-y-5 md:border-[#252629] md:border rounded-[16px]",children:[a.jsx("div",{className:"hidden grid-cols-1 gap-6 md:grid md:grid-cols-3",children:Array(6).fill(null).map((e,t)=>a.jsxs(YM,{className:"bg-[#111112] border-[#FFFFFF0F] hidden md:h-[300px]",children:[a.jsx(KM,{className:"p-5",children:a.jsx("div",{className:"h-4 w-24 bg-[#FFFFFF14] rounded"})}),a.jsxs(XM,{className:"p-5 pt-0",children:[a.jsx("div",{className:"h-4 w-full bg-[#FFFFFF14] rounded mb-4"}),a.jsx("div",{className:"h-4 w-3/4 bg-[#FFFFFF14] rounded"})]})]},`empty-grid-${t}`))}),a.jsxs("div",{className:"absolute rounded-[16px] backdrop-blur-[2px] left-0 right-0 bottom-0 top-0 h-full md:border md:border-[#242424]/60 flex flex-col items-center justify-center text-center",children:[a.jsx("div",{className:"mb-4",children:a.jsx("img",{src:cD,alt:"Globe",className:"w-[56px] h-[56px] mx-auto"})}),a.jsx("h3",{className:"mb-2 text-[24px] font-medium text-white/80",children:"0 apps deployed"}),a.jsx("p",{className:"max-w-md text-white/30 font-medium text-[16px]",children:"Deploy your application to a production-ready environment.This will make it publicly accessible with managed infrastructure"}),a.jsxs("div",{className:"mt-7 bg-[#242119] rounded-[12px] p-[14px] flex items-center gap-2",children:[a.jsx("img",{src:lD,alt:"Credits",className:"w-5 h-5"}),a.jsxs("span",{className:"text-[#F3CA5F] text-[15px] font-medium font-['Inter']",children:[a.jsx("span",{className:"text-[#E6D9B8]",children:"Deployment costs"})," 50 credits/month"]})]})]})]}):a.jsxs("div",{className:"grid h-full grid-cols-1 gap-6 md:grid-cols-3",children:[i.map((e,t)=>a.jsx(oD,{deployment:e,index:t,hoveredCard:n,onHoverStart:s,onHoverEnd:()=>s(null),onClick:u},e.id)),p.map((e,t)=>a.jsx(YM,{className:"bg-[#101011] hidden md:block border-[#282829] h-[290px] md:border-dotted"},`empty-${t}`))]})})}const uD=({className:e="",width:t=16,height:n=16,color:s="#80FFF9",opacity:i=1,backgroundColor:r,onClick:o})=>a.jsxs("svg",{width:t,height:n,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,style:{opacity:i},onClick:o,role:o?"button":void 0,tabIndex:o?0:void 0,children:[r&&a.jsx("rect",{width:"16",height:"16",fill:r}),a.jsx("path",{d:"M7 16V8.4L2 3.4V6H0V0H6V2H3.4L9 7.6V16H7ZM10.85 6.6L9.4 5.15L12.6 2H10V0H16V6H14V3.4L10.85 6.6Z",fill:s})]}),pD=({width:e=16,height:t=16,className:n,fill:s="white",fillOpacity:i=.6})=>a.jsx("svg",{width:e,height:t,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:n,children:a.jsx("path",{d:"M2.3999 13.5999V9.77324L9.27546 2.92879C9.46212 2.74212 9.66953 2.60731 9.89768 2.52435C10.1258 2.44138 10.354 2.3999 10.5821 2.3999C10.831 2.3999 11.0695 2.44657 11.2977 2.5399C11.5258 2.63324 11.7332 2.77324 11.9199 2.9599L13.071 4.11101C13.2369 4.29768 13.3666 4.50509 13.4599 4.73324C13.5532 4.96138 13.5999 5.18953 13.5999 5.41768C13.5999 5.64583 13.5584 5.87916 13.4755 6.11768C13.3925 6.3562 13.2577 6.56879 13.071 6.75546L6.22657 13.5999H2.3999ZM4.26657 11.7332H5.44879L9.21324 7.93768L8.65324 7.34657L8.06212 6.78657L4.26657 10.551V11.7332ZM8.65324 7.34657L8.06212 6.78657L9.21324 7.93768L8.65324 7.34657Z",fill:s,fillOpacity:i})}),mD=({width:e=16,height:t=16,className:n,fill:s="#CCCCCC"})=>a.jsx("svg",{width:e,height:t,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:n,children:a.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7.19913 3.2C7.06585 3.1998 6.9363 3.24398 6.83092 3.32557C6.72553 3.40716 6.65031 3.52152 6.61713 3.6506L6.44193 4.3346H9.69453L9.51873 3.6506C9.48557 3.52162 9.41044 3.40734 9.30518 3.32576C9.19991 3.24418 9.0705 3.19993 8.93733 3.2H7.19913ZM10.9335 4.3352L10.6809 3.3518C10.5815 2.96496 10.3562 2.62219 10.0405 2.37745C9.72485 2.13272 9.33675 1.99993 8.93733 2H7.19913C6.79971 1.99993 6.41161 2.13272 6.09595 2.37745C5.78028 2.62219 5.55498 2.96496 5.45553 3.3518L5.20293 4.3352H3.26553C3.1064 4.3352 2.95379 4.39841 2.84126 4.51094C2.72874 4.62346 2.66553 4.77607 2.66553 4.9352C2.66553 5.09433 2.72874 5.24694 2.84126 5.35946C2.95379 5.47199 3.1064 5.5352 3.26553 5.5352H3.32553L4.05453 12.3902C4.10151 12.8324 4.31049 13.2415 4.64118 13.5387C4.97188 13.8359 5.40088 14.0003 5.84553 14H10.2855C10.7301 14.0001 11.1589 13.8357 11.4895 13.5385C11.8201 13.2413 12.029 12.8323 12.0759 12.3902L12.8043 5.5352H12.8655C13.0247 5.5352 13.1773 5.47199 13.2898 5.35946C13.4023 5.24694 13.4655 5.09433 13.4655 4.9352C13.4655 4.77607 13.4023 4.62346 13.2898 4.51094C13.1773 4.39841 13.0247 4.3352 12.8655 4.3352H10.9335ZM11.5983 5.5352H4.53273L5.24793 12.2636C5.26365 12.4111 5.33341 12.5475 5.44376 12.6465C5.55412 12.7456 5.69724 12.8002 5.84553 12.8H10.2855C10.4337 12.8001 10.5767 12.7453 10.6869 12.6463C10.7971 12.5473 10.8668 12.4109 10.8825 12.2636L11.5977 5.5352H11.5983ZM6.86553 6.8C7.02466 6.8 7.17727 6.86321 7.28979 6.97574C7.40231 7.08826 7.46553 7.24087 7.46553 7.4V10.4C7.46553 10.5591 7.40231 10.7117 7.28979 10.8243C7.17727 10.9368 7.02466 11 6.86553 11C6.7064 11 6.55379 10.9368 6.44126 10.8243C6.32874 10.7117 6.26553 10.5591 6.26553 10.4V7.4C6.26553 7.24087 6.32874 7.08826 6.44126 6.97574C6.55379 6.86321 6.7064 6.8 6.86553 6.8ZM9.26553 6.8C9.42466 6.8 9.57727 6.86321 9.68979 6.97574C9.80231 7.08826 9.86553 7.24087 9.86553 7.4V10.4C9.86553 10.5591 9.80231 10.7117 9.68979 10.8243C9.57727 10.9368 9.42466 11 9.26553 11C9.1064 11 8.95379 10.9368 8.84126 10.8243C8.72874 10.7117 8.66553 10.5591 8.66553 10.4V7.4C8.66553 7.24087 8.72874 7.08826 8.84126 6.97574C8.95379 6.86321 9.1064 6.8 9.26553 6.8Z",fill:s})}),hD=({isOpen:e,onClose:t,onAction:n,position:s})=>{const i=Pe.useRef(null);if(Pe.useEffect(()=>{const n=e=>{i.current&&!i.current.contains(e.target)&&t()};if(e)return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[e,t]),!e)return null;const r=[{id:"rename",label:"Rename",icon:a.jsx(pD,{width:20,height:20})},{id:"delete",label:"Delete",icon:a.jsx(mD,{width:20,height:20})}];return a.jsx("div",{className:"fixed inset-0 z-[999]",style:{backgroundColor:"transparent"},children:a.jsx("div",{ref:i,className:"shadow-lg p-1.5 flex flex-col top-10 -left-[120px] rounded-xl border bg-[#18181A] border-[#242424] absolute",style:{top:s.top,left:s.left,transform:"translateX(-50%)"},children:r.map(e=>a.jsxs("button",{onClick:()=>{n(e.id),t()},className:"text-left hover:bg-[#2C2C2E] transition-colors flex items-center gap-3 text-sm text-[#FFFFFF] justify-between w-[148px] h-9 rounded-lg py-2 px-1.5",children:[a.jsx("span",{className:"flex-shrink-0",children:e.icon}),a.jsx("span",{className:"flex-1 font-medium",children:e.label}),e.hasExternalIcon&&e.externalIcon]},e.id))})})},xD=({isOpen:e,onClose:t,onSave:n,currentName:s})=>{const[i,r]=Pe.useState(s),o=Pe.useRef(null);Pe.useEffect(()=>{e&&(r(s),setTimeout(()=>{o.current&&o.current.focus()},100))},[e,s]),Pe.useEffect(()=>{const n=e=>{"Escape"===e.key&&t()},s=e=>{"Enter"===e.key&&i.trim()&&l()};if(e)return document.addEventListener("keydown",n),document.addEventListener("keydown",s),()=>{document.removeEventListener("keydown",n),document.removeEventListener("keydown",s)}},[e,i,t]);const l=()=>{i.trim()&&i!==s&&n(i.trim()),t()},c=()=>{r(s),t()};return e?a.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-[999] p-4",onClick:e=>{e.target===e.currentTarget&&c()},children:a.jsxs("div",{className:"flex flex-col w-full md:w-[644px] top-[336px] left-[434px] rounded-[20px] p-6 bg-[#262628]",children:[a.jsxs("div",{className:"flex items-center justify-between mb-6",children:[a.jsx("h2",{className:"text-white font-semibold font-['Brockmann'] font-medium text-[23px] leading-[32px] tracking-[0%]",children:"Rename task"}),a.jsx("button",{onClick:c,className:"rounded-lg transition-colors",children:a.jsx(OT,{})})]}),a.jsx("div",{className:"mb-6",children:a.jsx("input",{ref:o,type:"text",value:i,onChange:e=>r(e.target.value),className:"font-inter flex w-full md:w-[596px] h-14 rounded-xl border border-[#313133] p-4 gap-4 bg-[#313133] border-white/20",placeholder:"Enter task name",maxLength:100})}),a.jsxs("div",{className:"flex gap-3 justify-end",children:[a.jsx("button",{onClick:c,className:"flex w-[100px] h-12 rounded-[28px] px-5 gap-2 bg-[#323233] cursor-pointer hover:bg-[#323233] transition-colors duration-300 ease-out px-6 py-3",children:a.jsx("span",{className:"font-['Brockmann'] font-medium text-base leading-6 tracking-[0px] text-[#DCDCE5]",children:"Cancel"})}),a.jsx("button",{onClick:l,className:"flex w-[100px] h-12 rounded-[28px] px-8 gap-2 bg-white text-black cursor-pointer hover:bg-gray-100 transition-colors duration-300 ease-out px-6 py-3",children:a.jsx("span",{className:"font-['Brockmann'] font-semibold text-base leading-6 tracking-[-0.2px] text-[#0E0E0F]",children:"Save"})})]})]})}):null},fD=e=>{switch(e){case"gold":return"text-[#F3CA5F] drop-shadow-[0_0_20px_rgba(243,202,95,0.4)] [text-shadow:0px_0.73px_0.73px_rgba(0,0,0,0.1)]";case"red":return"text-[#CC5252]";case"warning":return"text-[#F59E0B]";default:return"text-white"}},gD=(e,t=!0)=>{const n="rounded-[10px] px-5 py-2.5 gap-1.5 text-[15px] font-medium leading-5 tracking-[-0.2px] font-['Brockmann'] transition-all duration-200";return"danger"===e?`${n} bg-[#CC5252] hover:bg-[#B73E3E] text-white ${t?"font-semibold":"font-medium"}`:"warning"===e?`${n} bg-[#F59E0B] hover:bg-[#D97706] text-white ${t?"font-semibold":"font-medium"}`:"secondary"===e?`${n} bg-white/[0.04] hover:bg-white/[0.08] text-white`:`${n} bg-[#F3CA5F] hover:bg-[#E7A93C] text-black ${t?"font-semibold":"font-medium"}`},vD=e=>{switch(e){case"sm":return"w-full max-w-[400px] sm:w-[80%] md:w-[35%]";case"lg":return"w-full max-w-[800px] sm:w-[90%] md:w-[60%]";default:return"w-full max-w-[600px] sm:w-[85%] md:w-[45%]"}};function bD({isOpen:e,onClose:t,onConfirm:n,onCancel:s,title:i,description:r,headerContent:o,bodyContent:l,footerContent:c,primaryButton:d,secondaryButton:u,titleColor:p="white",showCloseIcon:m=!0,allowBackdropClose:h=!0,className:x,containerClassName:f,size:g="md",children:v}){if(!e)return null;return Be.createPortal(a.jsx("div",{className:`fixed inset-0 z-[9999] flex items-center justify-center bg-black/60 backdrop-blur-sm p-4 ${f||""}`,onClick:e=>{h&&e.target===e.currentTarget&&t()},children:a.jsx("div",{className:`bg-[#1C1C1F] rounded-[20px] ${vD(g)} relative max-h-[90vh] overflow-y-auto ${x||""}`,children:a.jsxs("div",{className:"flex flex-col p-5 md:p-6",children:[o?a.jsx("div",{className:"mb-5 md:mb-4",children:o}):a.jsxs("div",{className:"flex justify-between items-start mb-5 md:mb-4",children:[a.jsx("h1",{className:`text-xl md:text-2xl font-['Brockmann'] font-medium leading-6 md:leading-8 ${fD(p)} flex-1 mr-4`,children:i}),m&&a.jsx("button",{onClick:t,className:"flex-shrink-0 text-gray-400 hover:text-white transition-colors",children:a.jsx(OT,{width:24,height:24,className:"rounded-full md:w-8 md:h-8"})})]}),l?a.jsx("div",{className:"mb-[50px] md:mb-14",children:l}):v?a.jsx("div",{className:"mb-[50px] md:mb-14",children:v}):r?a.jsx("div",{className:"mb-[50px] md:mb-14",children:a.jsx("p",{className:"text-sm md:text-base font-['Inter'] font-medium leading-5 md:leading-6 text-white opacity-60 break-words",children:r})}):null,c?a.jsx("div",{className:"mt-auto",children:c}):d||u?a.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 sm:justify-end mt-auto",children:[u&&a.jsx("button",{onClick:()=>{(null==s?void 0:s())||t()},disabled:u.disabled||u.loading,className:`${gD(u.variant||"secondary",!1)} ${u.disabled?"opacity-50 cursor-not-allowed":""} w-full sm:w-auto bg-transparent border border-white/20 hover:bg-white/10 transition-colors`,children:u.loading?"Loading...":u.text}),d&&a.jsx("button",{onClick:n,disabled:d.disabled||d.loading,className:`${gD(d.variant||"primary",!0)} ${d.disabled?"opacity-50 cursor-not-allowed":""} w-full sm:w-auto bg-[#CC5252] hover:bg-[#CC5252]-600 transition-colors gap-1.5`,children:d.loading?"Loading...":d.text})]}):null]})})}),document.body)}const yD=({size:e=16,color:t="white",opacity:n=1,className:s="",onClick:i,...r})=>{const o=e/4;return a.jsx("svg",{width:e,height:o,viewBox:"0 0 16 4",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:s,onClick:i,style:{cursor:"pointer"},...r,children:a.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3.55556 2.00043C3.55556 2.47193 3.36825 2.92411 3.03486 3.25751C2.70146 3.59091 2.24927 3.77821 1.77778 3.77821C1.30628 3.77821 0.854097 3.59091 0.520699 3.25751C0.187301 2.92411 0 2.47193 0 2.00043C0 1.52894 0.187301 1.07675 0.520699 0.743356C0.854097 0.409958 1.30628 0.222656 1.77778 0.222656C2.24927 0.222656 2.70146 0.409958 3.03486 0.743356C3.36825 1.07675 3.55556 1.52894 3.55556 2.00043ZM8 0.222656C8.4715 0.222656 8.92368 0.409958 9.25708 0.743356C9.59048 1.07675 9.77778 1.52894 9.77778 2.00043C9.77778 2.47193 9.59048 2.92411 9.25708 3.25751C8.92368 3.59091 8.4715 3.77821 8 3.77821C7.5285 3.77821 7.07632 3.59091 6.74292 3.25751C6.40952 2.92411 6.22222 2.47193 6.22222 2.00043C6.22222 1.52894 6.40952 1.07675 6.74292 0.743356C7.07632 0.409958 7.5285 0.222656 8 0.222656ZM14.2222 0.222656C14.6937 0.222656 15.1459 0.409958 15.4793 0.743356C15.8127 1.07675 16 1.52894 16 2.00043C16 2.47193 15.8127 2.92411 15.4793 3.25751C15.1459 3.59091 14.6937 3.77821 14.2222 3.77821C13.7507 3.77821 13.2985 3.59091 12.9651 3.25751C12.6317 2.92411 12.4444 2.47193 12.4444 2.00043C12.4444 1.52894 12.6317 1.07675 12.9651 0.743356C13.2985 0.409958 13.7507 0.222656 14.2222 0.222656Z",fill:t,fillOpacity:n})})},wD=wv.common.globeWhite,jD=wv.common.globeActive,CD=wv.icons.task,ND=(e,t=100)=>e.length>t?e.slice(0,t)+"...":e,FD=e=>{if("ENV_INITIATED"!==(null==e?void 0:e.state))return!1;if(!(null==e?void 0:e.created_at))return!1;const t=new Date(e.created_at).getTime();return(Date.now()-t)/6e4<10};function _D({jobs:e,handleJobClick:t,handleReload:n,reloading:s,setIsJobIdDialogOpen:i,loading:r=!1,refetchJobs:o}){const l=iI(),{currentWorkspace:c,isPersonalWorkspace:d}=ev(),[u]=yf(),{newToast:p}=aM(),{setTabs:m,getTabByJobId:h}=Hee(),{user:x}=Yg(),[f,g]=Pe.useState("recent"),v=Pe.useMemo(()=>"object"==typeof c?null==c?void 0:c.id:c,[c]),b=Pe.useMemo(()=>{if(!(null==e?void 0:e.length))return[];const t=d();return e.filter(e=>{var n;const s=e.organization_id||(null==(n=e.payload)?void 0:n.organization_id);return t?!s:s===v})},[e,v,d]),y=e=>{if(!!e.payload.forked_from){const t=b.find(t=>t.id===e.payload.forked_from),n=t?t.payload.original_task||t.payload.task:e.payload.forked_from,s=b.filter(t=>t.payload.forked_from===e.payload.forked_from).sort((e,t)=>new Date(e.created_at).getTime()-new Date(t.created_at).getTime()).findIndex(t=>t.id===e.id)+1;return a.jsxs(ZM,{className:"text-[#FFFFFFCC] text-[13px] px-6 w-[45%]",children:[a.jsx("div",{className:"text-sm font-medium leading-6 tracking-normal text-white font-inter text-opacity-80 line-clamp-1",children:e.title?e.title:a.jsx("span",{className:"opacity-60",children:"Untitled"})}),a.jsxs("span",{className:"text-[#80FFF9] text-[14px] font-medium font-inter",children:["Fork"," ",a.jsx("span",{className:"font-inter font-medium px-[6px] leading-[20px] rounded-[5px] bg-[#80FFF915]",children:s})," ","from"," "]}),"- ",a.jsx("span",{className:"font-inter text-opacity-50 text-[13px] lineheight-5 font-medium text-white",children:ND(n)})]})}return a.jsxs(ZM,{className:"text-[#FFFFFFCC] text-[13px] px-6 w-[45%]",children:[a.jsx("div",{className:"text-sm font-medium leading-6 tracking-normal text-white font-inter text-opacity-80 line-clamp-1",children:e.title?e.title:a.jsx("span",{className:"opacity-60",children:"Untitled"})}),a.jsx("span",{className:"font-inter font-medium text-[13px] lineheight-5 tracking-normal text-white align-middle text-opacity-50 line-clamp-2",children:ND(JSON.stringify(e.payload.task).replace(/"/g,""))||""})]})},[w,j]=Pe.useState({currentPage:1,tasksPerPage:50,menuState:{isOpen:!1,jobId:null,position:{top:0,left:0}},renameModalState:{isOpen:!1,jobId:null,currentName:""},deleteModalState:{isOpen:!1,jobId:null,jobName:""}}),C=b.length,N=Math.ceil(C/w.tasksPerPage)||1,F=(w.currentPage-1)*w.tasksPerPage+1,_=Math.min(w.currentPage*w.tasksPerPage,C),k=e=>{e>=1&&e<=N&&j(t=>({...t,currentPage:e}))},S=()=>{j(e=>({...e,deleteModalState:{isOpen:!1,jobId:null,jobName:""}}))},[E]=wf(),I=Pe.useMemo(()=>(()=>{const e=[];if(N<=5){for(let t=1;t<=N;t++)e.push(t);return e}let t,n;w.currentPage<=3?(t=1,n=5):w.currentPage>=N-2?(t=N-5+1,n=N):(t=w.currentPage-2,n=w.currentPage+2);for(let s=t;s<=n;s++)e.push(s);return e})(),[w.currentPage,N]),A=Pe.useMemo(()=>{const e=(w.currentPage-1)*w.tasksPerPage,t=w.currentPage*w.tasksPerPage;return b.slice(e,t)},[b,w.currentPage,w.tasksPerPage]),T=e=>{const t=e.updated_at||e.created_at,n=Date.now()-new Date(t).getTime(),s=Math.floor(n/6e4);if(s<60)return s<1?"Few seconds ago":`${s} min ago`;const i=Math.floor(s/60);if(i<24)return`${i<0?0:i} hrs ago`;const a=Math.floor(i/24);return`${a} day${a>1?"s":""} ago`},M=()=>a.jsxs(qM,{className:"w-full hover:bg-transparent",children:[a.jsx(ZM,{className:"rounded-l-lg w-[15%]",children:a.jsx("div",{className:"h-4 w-16 bg-[#252629] rounded animate-pulse"})}),a.jsx(ZM,{className:"w-[45%]",children:a.jsx("div",{className:"h-4 w-full bg-[#252629] rounded animate-pulse "})}),a.jsx(ZM,{className:"rounded-r-lg w-[20%]",children:a.jsx("div",{className:"h-4 bg-[#252629] rounded animate-pulse"})})]});return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex-col hidden px-4 space-y-5 md:flex",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center space-x-2 md:space-x-4",children:[a.jsxs("div",{onClick:()=>g("recent"),className:"flex items-center space-x-1 cursor-pointer",children:[a.jsx("img",{alt:"Recent tasks",src:CD,className:bb("h-5 md:h-6 w-fit opacity-30","recent"===f&&"opacity-100")}),a.jsx("h2",{className:bb("text-[12px] md:text-lg text-white/30","recent"===f&&"text-white"),children:"Recent Tasks"})]}),a.jsx("div",{className:"w-[2px] h-[18px] bg-white/20"}),a.jsxs("div",{onClick:()=>g("deployed"),className:"flex items-center space-x-1 cursor-pointer",children:[a.jsx("img",{alt:"Recent tasks",src:"deployed"===f?jD:wD,className:bb("h-5 md:h-6 opacity-50 w-5 md:w-6","deployed"===f&&"opacity-100")}),a.jsx("h2",{className:bb("text-[12px] md:text-lg text-[#898E98]","deployed"===f&&"bg-gradient-to-r from-[#80fff9] to-[#1588fc] text-transparent bg-clip-text"),children:"Deployed Apps"})]})]}),a.jsxs("div",{className:"flex gap-2",children:[l&&a.jsx(Nb,{variant:"ghost",size:"icon",className:"w-8 h-8 text-muted-foreground hover:bg-transparent",onClick:()=>i(!0),children:a.jsx(NS,{className:"w-4 h-4"})}),"recent"===f&&a.jsx(Nb,{variant:"ghost",size:"icon",className:"w-8 h-8 text-muted-foreground hover:bg-transparent",onClick:n,disabled:s||r,children:a.jsx(SS,{className:"h-4 w-4 "+(s?"animate-spin":"")})})]})]}),"recent"===f&&a.jsxs("div",{className:"relative rounded-2xl border border-[#252629] bg-[rgba(15,15,16,0.01)] backdrop-blur-[2.5px] overflow-clip",children:[a.jsx("div",{className:"sticky top-0 z-10 mb-4",children:a.jsx("table",{className:"w-full border-separate border-spacing-0",children:a.jsx("thead",{children:a.jsxs("tr",{className:"bg-[#18181A]",children:[a.jsx("th",{className:"text-white/40 font-[Inter] font-normal px-6 py-3 rounded-tl-lg text-[12px] tracking-[1px] w-[15%] text-left",children:"ID"}),a.jsx("th",{className:"text-white/40 font-[Inter] font-normal px-6 py-3 text-[12px] tracking-[1px] w-[45%] text-left",children:"TASK"}),a.jsx("th",{className:"text-white/40 font-[Inter] font-normal px-6 py-3 text-[12px] tracking-[1px] w-[20%] text-left",children:"LAST MODIFIED"}),a.jsx("th",{className:"text-white/40 font-[Inter] font-normal px-6 py-3 text-[12px] tracking-[1px] w-[5%] text-left"})]})})})}),a.jsx("div",{className:"min-h-[500px] max-h-[500px] overflow-y-auto relative text-[12px]",children:a.jsxs(VM,{className:"relative w-full border-separate border-spacing-0",children:[a.jsx(UM,{className:"hidden",children:a.jsxs(qM,{className:"bg-[#18181A] hover:bg-[#18181A]",children:[a.jsx(GM,{className:"text-[#8F8F98] font-normal px-6 rounded-tl-lg text-sm font-berkeley w-[15%]",children:"ID"}),a.jsx(GM,{className:"text-[#8F8F98] font-normal px-6 text-sm font-berkeley w-[45%]",children:"Task"})]})}),a.jsx(WM,{className:"w-full",children:r?Array(5).fill(0).map((e,t)=>a.jsx(M,{},`shimmer-${t}`)):0==b.length?a.jsx(qM,{className:"hover:bg-transparent",children:a.jsx(ZM,{colSpan:3,className:"py-8 text-center hover:bg-transparent",children:a.jsxs("div",{className:"flex flex-col items-center gap-4",children:[a.jsx("div",{className:"text-[#8F8F98] text-sm",children:"No tasks yet"}),a.jsx("div",{className:"text-[#92929A] text-xs max-w-lg",children:"Click the plus button at the top to create your first task and start building"})]})})}):A.map(e=>a.jsxs(qM,{className:"hover:bg-[#1C1C1E] transition-colors cursor-pointer max-h-[68px]",onClick:()=>t(e),children:[a.jsx(ZM,{className:"text-[#92929A] text-[12px] md:text-[14px] px-6 py-4 w-[15%] font-inter align-top leading-6",children:`EMT - ${e.id.slice(0,6)}`}),y(e),a.jsx(ZM,{className:"text-[#C2C2CC] text-[12px] md:text-[14px] pl-8 pr-6 py-4 w-[20%] font-inter opacity-50 align-top leading-6",children:T(e)}),a.jsx(ZM,{className:"pl-2 pr-0 py-4 w-[5%] text-right align-top",children:a.jsx("div",{className:"flex items-center justify-end gap-2 mr-6",children:a.jsx("button",{title:"Options",className:"pb-1.5 rounded transition-colors inline-flex items-center justify-center "+(FD(e)?"opacity-50 cursor-not-allowed":""),onClick:t=>{t.stopPropagation(),FD(e)||((e,t)=>{e.stopPropagation();const n=e.currentTarget.getBoundingClientRect();j(e=>({...e,menuState:{isOpen:!0,jobId:t,position:{top:n.bottom+2,left:n.right-80}}}))})(t,e.id)},disabled:FD(e),children:a.jsx(yD,{className:"p-1.5 bg-[#FFFFFF0A] flex w-8 h-8 rounded-md p-1.5 gap-[11.43px] bg-white/[0.15] "+(FD(e)?"opacity-40":"opacity-40 hover:opacity-80"),size:32})})})})]},e.id))})]})}),a.jsxs("div",{className:"flex items-center justify-between px-6 py-3 bg-[#18181a] text-[#8f8f98]",children:[a.jsxs("p",{className:"text-[14px] font-[Inter] font-medium leading-4 text-white/40 w-[200px]",children:["Showing ",F,"-",_," out of ",C]}),a.jsxs("div",{className:"flex items-center space-x-1",children:[a.jsx("button",{title:"Left",onClick:()=>k(w.currentPage-1),disabled:1===w.currentPage,className:"flex items-center justify-center w-8 h-8 rounded-[8px] hover:bg-[#2d2d2d] disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:a.jsx(Zk,{className:"object-contain w-6 h-6"})}),I.map(e=>{return a.jsx("button",{onClick:()=>k(e),className:(t=e===w.currentPage,"flex items-center justify-center font-[Inter] text-[12px] hover:rounded-[8px] w-8 h-8 text-sm transition-colors "+(t?"bg-[#2d2d2d] text-white bg-[#FFF]/5 border border-white/[6%] rounded-[8px]":"hover:bg-[#2d2d2d] text-[#8f8f98]")),children:e},e);var t}),a.jsx("button",{title:"Right",onClick:()=>k(w.currentPage+1),disabled:w.currentPage===N,className:"flex items-center justify-center w-8 h-8 rounded-[8px] hover:bg-[#2d2d2d] disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:a.jsx(Yk,{className:"object-contain w-6 h-6"})})]}),a.jsxs("div",{className:"flex items-center space-x-2 text-sm",children:[a.jsx("p",{className:"text-[14px] font-[Inter] font-medium leading-4 text-white/40",children:"Tasks per page :"}),a.jsxs("div",{className:"relative",children:[a.jsxs("select",{"aria-label":"Select",value:w.tasksPerPage,onChange:e=>{return t=Number(e.target.value),j(e=>({...e,tasksPerPage:t})),void j(e=>({...e,currentPage:1}));var t},className:"appearance-none bg-[#1A1A1A] font-[Inter] border px-3 py-1 pr-8 text-[#FFF] text-sm focus:outline-none focus:border-[#FFF] border-opacity-[12px] cursor-pointer rounded-[8px]",children:[a.jsx("option",{value:10,children:"10"}),a.jsx("option",{value:25,children:"25"}),a.jsx("option",{value:50,children:"50"})]}),a.jsx(Gk,{className:"absolute right-2 top-1/2 transform -translate-y-1/2 w-3 h-3 pointer-events-none text-[#8f8f98]"})]})]})]})]}),"deployed"===f&&a.jsx(dD,{handleJobClick:t,organizationId:d()?void 0:c})]}),a.jsx(hD,{isOpen:w.menuState.isOpen,onClose:()=>{j(e=>({...e,menuState:{isOpen:!1,jobId:null,position:{top:0,left:0}}}))},onAction:n=>{const s=e.find(e=>e.id===w.menuState.jobId);switch(n){case"rename":s&&j(e=>({...e,renameModalState:{isOpen:!0,jobId:s.id,currentName:s.title}}));break;case"preview":t(s);break;case"share":break;case"delete":const n=e.find(e=>e.id===w.menuState.jobId);n&&j(e=>({...e,deleteModalState:{isOpen:!0,jobId:n.id,jobName:n.title||"this task"},menuState:{...e.menuState,isOpen:!1}}))}},position:w.menuState.position}),a.jsx(xD,{isOpen:w.renameModalState.isOpen,onClose:()=>{j(e=>({...e,renameModalState:{isOpen:!1,jobId:null,currentName:""}}))},onSave:async e=>{if(w.renameModalState.jobId)try{await u({job_id:w.renameModalState.jobId,title:e}).unwrap(),await o(),bg(QS,{jobId:w.renameModalState.jobId,newName:e});const t=h(w.renameModalState.jobId);m(n=>n.map(n=>n.id===(null==t?void 0:t.id)?{...n,tabHeading:e}:n)),p.success("Task Renamed Successfully")}catch(t){p.error("Task Renamed Failed")}},currentName:w.renameModalState.currentName}),w.deleteModalState.isOpen&&a.jsx(bD,{isOpen:w.deleteModalState.isOpen,onClose:S,onConfirm:async()=>{var e;if(w.deleteModalState.jobId)try{const e=await E({jobId:w.deleteModalState.jobId,deletedBy:(null==x?void 0:x.id)||""}).unwrap();if(null==e?void 0:e.success){p.success((null==e?void 0:e.message)||"Job deleted successfully");const t=h(w.deleteModalState.jobId);(null==t?void 0:t.id)&&m(e=>e.filter(e=>e.id!==t.id)),await o(),bg(XS,{jobId:w.deleteModalState.jobId,deletedBy:(null==x?void 0:x.id)||""})}else p.error((null==e?void 0:e.message)||"Unable to delete this job.")}catch(t){p.error((null==(e=null==t?void 0:t.data)?void 0:e.message)||(null==t?void 0:t.message)||"Failed to delete the job. Please try again.")}finally{S()}},title:"Delete this task?",bodyContent:(()=>{var t,n,s;const i=w.deleteModalState.jobId,r=!!i&&(null==e?void 0:e.some(e=>{var t;return(null==(t=null==e?void 0:e.payload)?void 0:t.forked_from)===i})),o=null==e?void 0:e.find(e=>e.id===i),l=null==(t=null==o?void 0:o.payload)?void 0:t.forked_from,c=l?null==e?void 0:e.find(e=>e.id===l):null,d=!(!l||!c);return a.jsxs(a.Fragment,{children:[a.jsxs("p",{className:"text-sm md:text-base font-['Inter'] font-medium leading-5 md:leading-6 break-words",children:[a.jsx("span",{className:"text-white opacity-60 font-['Inter']",children:"Are you sure you want to delete "}),a.jsxs("span",{className:"text-[#80FFF9] font-['Inter']",children:['"',w.deleteModalState.jobName,'"']}),a.jsx("span",{className:"text-white opacity-60 font-['Inter']",children:"? This action cannot be undone."})]}),r&&!d&&a.jsxs("div",{className:"flex flex-col w-full h-24 rounded-lg p-3 gap-1.5 bg-[#66F0FF1A] backdrop-blur-[50px] mt-6",children:[a.jsx(uD,{className:"p-1",width:24,height:24}),a.jsx("p",{className:"text-sm font-['Inter'] font-medium leading-5 text-[#80FFF9] break-words",children:"This task has been forked. Deleting it won't affect the forked versions, but you'll lose the original context."})]}),d&&a.jsxs("div",{className:"flex flex-col w-full h-24 rounded-lg p-3 gap-1.5 bg-[#66F0FF1A] backdrop-blur-[50px] mt-6",children:[a.jsx(uD,{className:"p-1",width:24,height:24}),a.jsxs("p",{className:"text-sm font-['Inter'] font-medium leading-5 text-[#80FFF9] break-words",children:["This is a forked task continuing from ",a.jsxs("span",{className:"text-white font-['Inter']",children:['"',c.title||(null==(n=c.payload)?void 0:n.original_task)||(null==(s=c.payload)?void 0:s.task),'"']}),". Deleting it won't affect the parent task."]})]})]})})(),primaryButton:{text:"Confirm",variant:"danger"},secondaryButton:{text:"Nevermind",variant:"secondary"}})]})}const kD=()=>crypto.randomUUID(),SD=Pe.forwardRef(({className:e,...t},n)=>a.jsx(Q,{ref:n,className:bb("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",e),...t}));SD.displayName=Q.displayName;const ED=Pe.forwardRef(({className:e,...t},n)=>a.jsx(X,{ref:n,className:bb("aspect-square h-full w-full",e),...t}));ED.displayName=X.displayName;const ID=Pe.forwardRef(({className:e,...t},n)=>a.jsx(ee,{ref:n,className:bb("flex h-full w-full items-center justify-center rounded-full bg-muted",e),...t}));ID.displayName=ee.displayName;const AD=({squareSize:e=4,gridGap:t=6,flickerChance:n=.3,color:s="rgb(0, 0, 0)",width:i,height:r,className:o,maxOpacity:l=.3})=>{const c=Pe.useRef(null),d=Pe.useRef(null),[u,p]=Pe.useState(!1),[m,h]=Pe.useState({width:0,height:0}),x=Pe.useMemo(()=>(e=>{if("undefined"==typeof window)return"rgba(0, 0, 0,";const t=document.createElement("canvas");t.width=t.height=1;const n=t.getContext("2d");if(!n)return"rgba(255, 0, 0,";n.fillStyle=e,n.fillRect(0,0,1,1);const[s,i,a]=Array.from(n.getImageData(0,0,1,1).data);return`rgba(${s}, ${i}, ${a},`})(s),[s]),f=Pe.useCallback((n,s,i)=>{const a=window.devicePixelRatio||1;n.width=s*a,n.height=i*a,n.style.width=`${s}px`,n.style.height=`${i}px`;const r=Math.floor(s/(e+t)),o=Math.floor(i/(e+t)),c=new Float32Array(r*o);for(let e=0;e{for(let s=0;s{n.clearRect(0,0,s,i),n.fillStyle="transparent",n.fillRect(0,0,s,i);for(let c=0;c{const e=c.current,t=d.current;if(!e||!t)return;const n=e.getContext("2d");if(!n)return;let s,a;const o=()=>{const n=i||t.clientWidth,s=r||t.clientHeight;h({width:n,height:s}),a=f(e,n,s)};o();let l=0;const m=t=>{if(!u)return;const i=(t-l)/1e3;l=t,g(a.squares,i),v(n,e.width,e.height,a.cols,a.rows,a.squares,a.dpr),s=requestAnimationFrame(m)},x=new ResizeObserver(()=>{o()});x.observe(t);const b=new IntersectionObserver(([e])=>{p(e.isIntersecting)},{threshold:0});return b.observe(e),u&&(s=requestAnimationFrame(m)),()=>{cancelAnimationFrame(s),x.disconnect(),b.disconnect()}},[f,g,v,i,r,u]),a.jsx("div",{ref:d,className:`w-full h-full ${o}`,children:a.jsx("canvas",{ref:c,className:"pointer-events-none",style:{width:m.width,height:m.height}})})},TD=({size:e=24,color:t="#000000",className:n=""})=>a.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:n,children:a.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M19.6395 11.1294C20.1202 11.61 20.1202 12.3894 19.6395 12.87L14.1011 18.4084C13.6204 18.889 12.8412 18.889 12.3606 18.4084C11.8798 17.9277 11.8798 17.1485 12.3606 16.6679L15.7979 13.2304L5.23081 13.2304C4.55106 13.2304 4 12.6794 4 11.9996C4 11.32 4.55106 10.7689 5.23081 10.7689L15.7979 10.7689L12.3606 7.3315C11.8798 6.85087 11.8798 6.07161 12.3606 5.59098C12.8412 5.1103 13.6204 5.1103 14.1011 5.59098L19.6395 11.1294Z",fill:t})});function MD({isOpen:e,onOpenChange:t,onWorkspaceCreated:n,onCloseMenu:s}){const{toast:i}=un(),[r,o]=Pe.useState(""),[l,c]=Pe.useState(""),[d,{isLoading:u}]=df(),{newToast:p}=aM(),m=r.trim().length>0;Pe.useEffect(()=>{e&&s&&s()},[e,s]);const h=async()=>{if(m)try{const e=await d({name:r,description:l}).unwrap();p.success("Workspace Created"),t(!1),o(""),c(""),null==n||n(e.id,e.name)}catch(e){i({title:"Error",description:(null==e?void 0:e.error)||"Failed to create workspace. Please try again.",variant:"destructive"})}};return e?Be.createPortal(a.jsx(Bt,{children:a.jsxs("div",{className:"fixed inset-0 z-[999]",children:[a.jsx(zt.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},className:"absolute inset-0 bg-[#0C0C0D]",onClick:()=>t(!1)}),a.jsxs("div",{className:"relative w-full h-full overflow-y-auto",children:[a.jsx("div",{className:"absolute inset-0 z-0 pointer-events-none",children:a.jsx(AD,{color:"rgb(115, 119, 128)",squareSize:4,gridGap:6,flickerChance:.3,maxOpacity:.1,className:"w-full h-full bg-[#0E0E0F]"})}),a.jsxs(zt.div,{initial:{opacity:0,scale:.95,y:20},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:20},transition:{duration:.2,ease:"easeOut"},className:"min-h-full w-full bg-[#18181A] md:max-w-none max-w-[90%] mx-auto",style:{display:"grid",gridTemplateColumns:"1fr auto 1fr",gridTemplateRows:"1fr auto 1fr"},onClick:e=>e.stopPropagation(),children:[a.jsx("div",{className:"bg-[#242426] h-[1px] pointer-events-none",style:{gridColumn:"1 / 4",gridRow:"2",alignSelf:"start",zIndex:1e3}}),a.jsx("div",{className:"bg-[#242426] h-[1px] pointer-events-none",style:{gridColumn:"1 / 4",gridRow:"2",alignSelf:"end",zIndex:1e3}}),a.jsx("div",{className:"bg-[#242426] w-[1px] pointer-events-none",style:{gridRow:"1 / 4",gridColumn:"2",justifySelf:"start",zIndex:1e3}}),a.jsx("div",{className:"bg-[#242426] w-[1px] pointer-events-none",style:{gridRow:"1 / 4",gridColumn:"2",justifySelf:"end",zIndex:1e3}}),a.jsx("button",{type:"button",onClick:()=>t(!1),disabled:u,className:bb("fixed top-4 right-4 md:top-8 md:right-8 z-10 p-2 bg-[#FFF]/10 backdrop-blur-lg hover:bg-[white]/15 rounded-full transition-colors",u&&"opacity-50 cursor-not-allowed"),"aria-label":"Close modal",children:a.jsx(HS,{className:"w-5 h-5 text-[#939399] hover:text-[#C4C4CC]"})}),a.jsxs("div",{className:"flex flex-col w-full bg-[#0E0E0F] p-6 py-16 md:p-[64px] md:py-[104px] relative",style:{gridRow:"2",gridColumn:"2"},children:[a.jsxs("div",{className:"pointer-events-none absolute top-4 left-4 w-[18px] h-[18px]",style:{zIndex:10},children:[a.jsx("div",{className:"absolute w-2 h-2 transform -translate-x-1/2 -translate-y-1/2 rounded-full bg-white/40 top-1/2 left-1/2"}),a.jsx("div",{className:"w-[13px] h-[13px] border-[5px] border-white/[0.06] rounded-full absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2"})]}),a.jsxs("div",{className:"pointer-events-none absolute top-4 right-4 w-[18px] h-[18px]",style:{zIndex:10},children:[a.jsx("div",{className:"absolute w-2 h-2 transform -translate-x-1/2 -translate-y-1/2 rounded-full bg-white/40 top-1/2 left-1/2"}),a.jsx("div",{className:"w-[13px] h-[13px] border-[5px] border-white/[0.06] rounded-full absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2"})]}),a.jsxs("div",{className:"pointer-events-none absolute bottom-4 left-4 w-[18px] h-[18px]",style:{zIndex:10},children:[a.jsx("div",{className:"absolute w-2 h-2 transform -translate-x-1/2 -translate-y-1/2 rounded-full bg-white/40 top-1/2 left-1/2"}),a.jsx("div",{className:"w-[13px] h-[13px] border-[5px] border-white/[0.06] rounded-full absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2"})]}),a.jsxs("div",{className:"pointer-events-none absolute bottom-4 right-4 w-[18px] h-[18px]",style:{zIndex:10},children:[a.jsx("div",{className:"absolute w-2 h-2 transform -translate-x-1/2 -translate-y-1/2 rounded-full bg-white/40 top-1/2 left-1/2"}),a.jsx("div",{className:"w-[13px] h-[13px] border-[5px] border-white/[0.06] rounded-full absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2"})]}),a.jsxs("div",{className:"flex flex-col max-md:items-center md:items-start max-md:justify-center md:justify-start w-full mb-8 md:mb-[56px]",children:[a.jsx("h2",{className:"text-[28px] md:text-[36px] md:leading-[40px] font-medium text-[#fff]",children:"New Workspace"}),a.jsx("p",{className:"mt-4 text-[#FFFFFF]/40 max-md:text-center max-w-md font-inter text-[16px]",children:"Create a new place to make projects or collaborate with others."})]}),a.jsx("div",{className:"w-full",children:a.jsx("form",{onSubmit:e=>{e.preventDefault(),h()},className:"space-y-6",children:a.jsxs("div",{className:"space-y-2",children:[a.jsx("label",{htmlFor:"workspace-name",className:"block font-medium text-[#CCCCCC] max-md:text-center",children:"Workspace Name"}),a.jsx("input",{type:"text",id:"workspace-name",value:r,onChange:e=>o(e.target.value),placeholder:"e.g. Design Team, Project Alpha",className:"w-full p-3 md:p-4 bg-[#151517] border border-[#303033] rounded-lg text-[#FFFFFF] placeholder-[#FFFFFF]/40 focus:outline-none focus:border-[#303033] transition-colors font-inter font-medium text-sm md:text-base",maxLength:50,disabled:u,autoFocus:!0})]})})}),a.jsx("div",{className:"flex flex-col w-full gap-4 mt-8 sm:flex-row",children:a.jsx("button",{type:"button",onClick:h,disabled:!m||u,className:bb("flex items-center w-full justify-center gap-2 px-4 md:px-6 py-3 rounded-full text-base md:text-[18px] h-12 md:h-[56px] font-semibold text-black transition-all flex-1 sm:flex-none sm:min-w-[200px]",m&&!u?"bg-[#FFFFFF]":"bg-[#FFFFFF]/20 text-[#FFFFFF]/60 cursor-not-allowed"),children:u?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"w-4 h-4 border-2 border-current rounded-full border-t-transparent animate-spin"}),"Creating..."]}):a.jsxs(a.Fragment,{children:["Continue to Plan",a.jsx(TD,{size:20,color:m?"#000000":"#FFFFFF60"})]})})})]})]})]})]})}),document.body):null}const DD=({onClick:e,className:t,disabled:n=!1,size:s="md",variant:i="default"})=>{const r=bb("w-full flex items-center justify-center space-x-2 rounded-[10px] transition-colors duration-200 text-[#FFF] font-medium","hover:bg-gray-700 disabled:opacity-50 disabled:cursor-not-allowed",{sm:"p-2 text-sm",md:"p-3 text-base",lg:"p-4 text-lg"}[s],"compact"===i&&"max-h-[36px] mt-2","default"===i&&"border border-white/10",t);return a.jsxs("button",{type:"button",onClick:e,disabled:n,className:r,style:{background:"radial-gradient(50% 50% at 50% 50%, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 100%)"},children:[a.jsx(NS,{className:{sm:"w-4 h-4",md:"w-5 h-5",lg:"w-6 h-6"}[s]}),a.jsx("span",{children:"New Workspace"})]})},LD=({size:e=24,fill:t="white",className:n="",width:s,height:i})=>{const r=s||e,o=i||e;return a.jsx("svg",{width:r,height:o,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:n,children:a.jsx("path",{d:"M3.11133 20V4H12.0002V7.55556H20.8891V20H3.11133ZM4.88911 18.2222H6.66688V16.4444H4.88911V18.2222ZM4.88911 14.6667H6.66688V12.8889H4.88911V14.6667ZM4.88911 11.1111H6.66688V9.33333H4.88911V11.1111ZM4.88911 7.55556H6.66688V5.77778H4.88911V7.55556ZM8.44466 18.2222H10.2224V16.4444H8.44466V18.2222ZM8.44466 14.6667H10.2224V12.8889H8.44466V14.6667ZM8.44466 11.1111H10.2224V9.33333H8.44466V11.1111ZM8.44466 7.55556H10.2224V5.77778H8.44466V7.55556ZM12.0002 18.2222H19.1113V9.33333H12.0002V11.1111H13.778V12.8889H12.0002V14.6667H13.778V16.4444H12.0002V18.2222ZM15.5558 12.8889V11.1111H17.3336V12.8889H15.5558ZM15.5558 16.4444V14.6667H17.3336V16.4444H15.5558Z",fill:t})})},PD=({size:e=24,color:t="#22C55E",className:n=""})=>a.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:n,children:a.jsx("path",{d:"M20 6L9 17L4 12",stroke:t,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),RD=({size:e=24,color:t="#EF4444",className:n=""})=>a.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:n,children:a.jsx("path",{d:"M18 6L6 18M6 6L18 18",stroke:t,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})});function OD({invitation:e,onAcceptInvitation:t,onDeclineInvitation:n,isAcceptingInvitation:s,variant:i="selector"}){var r;const o="switcher"===i;return a.jsxs("div",{className:bb("flex items-center gap-3 rounded-[8px] transition-colors hover:bg-[#FFFFFF0D] cursor-pointer mb-2 p-2"),children:[a.jsx("div",{className:"rounded-full "+(o?"w-8 h-8 p-2":"p-2"),style:{background:"linear-gradient(180deg, #364D36 0%, rgba(47, 66, 46, 0.593809) 40.62%, rgba(36, 51, 36, 0) 100%)"},children:a.jsx(uM,{size:o?16:24,color:"#37FF33"})}),a.jsxs("div",{className:"flex flex-col flex-1",children:[a.jsx("div",{className:"text-sm font-medium capitalize text-[#E6E6E6]",children:e.organization_name}),a.jsx("div",{className:bb("text-[12px] font-medium font-inter text-[#CCCCCC] capitalize",o?"text-[12px] font-inter text-white/50":""),children:null==(r=null==e?void 0:e.role)?void 0:r.toLowerCase()})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[n&&a.jsx("button",{type:"button",onClick:t=>{t.stopPropagation(),n(e.id,e.organization_name)},disabled:s,className:" transition-colors duration-200 rounded-full bg-[#FFFFFF1A] disabled:opacity-50 disabled:cursor-not-allowed",title:"Decline Invitation",children:a.jsx(RD,{size:28,color:"#FFFFFF99",className:" bg-[#FFFFFF1A] rounded-full p-1"})}),a.jsx("button",{type:"button",onClick:n=>{n.stopPropagation(),t(e.id,e.organization_name)},disabled:s,className:"transition-colors duration-200 rounded-full bg-[#7BFF78] hover:bg-green-600/30 disabled:opacity-50 disabled:cursor-not-allowed",title:"Accept Invitation",children:s?a.jsx("div",{className:"w-4 h-4 text-green-400 border-2 border-current rounded-full border-t-transparent animate-spin"}):a.jsx(PD,{size:28,color:"#000000",className:"bg-[#7BFF78] rounded-full p-1"})})]})]})}const zD=({className:e="h-6 w-6",size:t=24,outerFill:n="#131314"})=>{const s=`paint0_linear_active_dot_${Math.random().toString(36).substring(2,11)}`;return a.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,children:[a.jsx("path",{d:"M0.000244141 12C0.000244141 5.37258 5.37283 0 12.0002 0C18.6277 0 24.0002 5.37258 24.0002 12C24.0002 18.6274 18.6277 24 12.0002 24C5.37283 24 0.000244141 18.6274 0.000244141 12Z",fill:n}),a.jsx("circle",{cx:"12.0002",cy:"12",r:"6",fill:`url(#${s})`}),a.jsx("defs",{children:a.jsxs("linearGradient",{id:s,x1:"12.0002",y1:"6",x2:"12.0002",y2:"18",gradientUnits:"userSpaceOnUse",children:[a.jsx("stop",{stopColor:"#00FF66"}),a.jsx("stop",{offset:"1",stopColor:"#62ECFE"})]})})]})},BD=wv.teams.org,HD=()=>{var e,t;const{user:n}=Yg(),{currentWorkspace:s,workspaces:i,getCurrentWorkspaceData:r}=ev();Oe();const{toast:o}=un(),[l,c]=Pe.useState(!1),[d,u]=Pe.useState(!1),[p,m]=Pe.useState(!1),[h,x]=Pe.useState(null);Pe.useEffect(()=>{const e=()=>c(!1),t=()=>c(!0);return window.addEventListener("close-workspace-switcher",e),window.addEventListener("open-workspace-switcher",t),()=>{window.removeEventListener("close-workspace-switcher",e),window.removeEventListener("open-workspace-switcher",t)}},[]);const{data:f,isLoading:g,refetch:v}=Sx(void 0,{skip:!n}),{personalTier:b}=sv(),y=(null==(e=null==f?void 0:f.organizations)?void 0:e.some(e=>e.created_by===(null==n?void 0:n.id)))||!1,[w,{isLoading:j}]=uf(),[C,{isLoading:N}]=ff(),F=async(e,t)=>{try{await w({invitation_id:e}).unwrap();o({title:"Invitation Accepted",description:`Successfully joined "${t}" workspace`,variant:"default"}),localStorage.removeItem("pending_invitation")}catch(n){o({title:"Error",description:(null==n?void 0:n.error)||"Failed to accept invitation. Please try again.",variant:"destructive"})}},_=async(e,t)=>{var n;try{await C({invitation_id:e}).unwrap(),o({title:"Invitation Declined",description:`Successfully declined invitation to "${t}" workspace`,variant:"default"})}catch(s){o({title:"Error",description:(null==(n=null==s?void 0:s.data)?void 0:n.detail)||"Failed to decline invitation. Please try again.",variant:"destructive"})}},k=()=>{var e;return n&&(null==(e=null==n?void 0:n.email)?void 0:e.slice(0,1).toUpperCase())||"U"},S=e=>{if("personal"===e.id)return b.toLowerCase().includes("pro")?"Pro":b.toLowerCase().includes("standard")?"Standard":b.toLowerCase().includes("starter")?"Starter":b.charAt(0).toUpperCase()+b.slice(1);{if(E(e))return"Payment Pending";const t=e.role||"MEMBER";return t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()}},E=e=>"PENDING"===(null==e?void 0:e.status),I=r();return a.jsxs("div",{className:"relative flex justify-center",children:[a.jsxs("button",{type:"button",onClick:()=>{c(!l),v()},className:"flex items-center justify-center px-4 py-[10px] max-h-[40px] hover:bg-white/15 rounded-full text-white transition-colors duration-200",style:{background:"personal"===s?"#FFFFFF14":"radial-gradient(50% 50% at 50% 50%, rgba(63, 243, 200, 0.1) 0%, rgba(63, 243, 200, 0.05) 100%)",backdropFilter:"blur(50px)"},children:[a.jsx("div",{className:"flex items-center justify-center w-5 h-5 text-sm rounded-full",children:"personal"===s?a.jsxs(SD,{className:"h-5 w-5 bg-[#2A2A2B]",children:[a.jsx(ED,{src:null==(t=null==n?void 0:n.user_metadata)?void 0:t.avatar_url,alt:"User Avatar"}),a.jsx(ID,{className:"bg-[#2A2A2B] text-[#FFFFFFCC] font-brockmann font-medium text-center text-[12px] leading-5 -tracking-[0.32px]",children:k()})]}):a.jsx("img",{src:BD,alt:"Organization",className:"w-10 h-10"})}),a.jsx("div",{className:"flex-1 ml-2 text-center",children:a.jsx("p",{className:"text-[16px] font-medium truncate capitalize "+("personal"===s?"text-[#FFFFFFCC]":""),style:"personal"!==s?{background:"linear-gradient(180deg, #00FF66 0%, #62ECFE 100%)",WebkitBackgroundClip:"text",WebkitTextFillColor:"transparent",backgroundClip:"text",color:"transparent",filter:"drop-shadow(0px 0px 17.94px #00FF6680) drop-shadow(0px 0px 17.94px #62ECFE33)"}:{},children:g?"Loading...":(e=>{var t,s,i;if("personal"===e.id){const e=((null==(t=null==n?void 0:n.user_metadata)?void 0:t.name)||(null==(s=null==n?void 0:n.user_metadata)?void 0:s.full_name)||(null==(i=null==n?void 0:n.email)?void 0:i.split("@")[0])||"Personal").split(" ")[0];return e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()+"'s Space"}return e.name+"'s Space"})(I)})})]}),l&&a.jsx("div",{className:"absolute top-full left-1/2 transform -translate-x-1/2 mt-2 w-[360px] bg-[#19191A] rounded-[16px] border border-[#303030] shadow-xl z-50",children:a.jsxs("div",{className:"p-2",children:[a.jsx("p",{className:"text-white/30 text-[10px] font-ndot font-normal tracking-[2px] leading-4 uppercase",children:"SWITCH WORKSPACE"}),a.jsxs("div",{className:"mt-1 space-y-2 ",children:[g?a.jsx("div",{className:"flex items-center justify-center p-4",children:a.jsx("div",{className:"text-[#FFFFFFCC] text-sm",children:"Loading workspaces..."})}):i.map(e=>{var t;const r=s===e.id;return E(e),a.jsx("div",{className:"",children:a.jsxs("button",{type:"button",onClick:()=>(e=>{const t=i.find(t=>t.id===e);if("PENDING"===(null==t?void 0:t.status))return x({id:t.id,name:t.name}),m(!0),void c(!1);if(s===e)return void c(!1);c(!1);const n="personal"===e?"Personal Space":`${(null==t?void 0:t.name)||"workspace"}'s Space`,a=`${"personal"===e?"/":`/workspace/${e}`}?switching=${encodeURIComponent(n)}`;window.location.href=a})(e.id),className:bb("w-full flex items-center max-h-[58px] justify-between p-[10px] rounded-[10px] transition-colors duration-200 group hover:bg-[#FFFFFF0D]",r&&"bg-[#FFFFFF0D]"),style:{background:r&&"personal"!==e.id?"radial-gradient(50% 50% at 50% 50%, rgba(50, 245, 179, 0.1) 0%, rgba(50, 245, 179, 0.05) 100%)":void 0},children:[a.jsxs("div",{className:"flex items-center w-full space-x-3",children:[a.jsx("div",{className:bb("flex items-center justify-center w-8 h-8 bg-[#2A2A2B] rounded-full","personal"!==e.id&&r&&"bg-[#FFFFFF0A] rounded-[8px] p-2"),children:"personal"===e.id?a.jsxs(SD,{className:"w-6 h-6",children:[a.jsx(ED,{src:null==(t=null==n?void 0:n.user_metadata)?void 0:t.avatar_url,alt:"User Avatar"}),a.jsx(ID,{className:"bg-[#2A2A2B] text-normal font-medium",children:k()})]}):r?a.jsx("img",{src:BD,alt:"Organization",className:"w-6 h-6"}):a.jsx(LD,{size:16,className:"opacity-80"})}),a.jsxs("div",{className:"flex justify-between flex-1 w-full text-left",children:[a.jsxs("div",{className:"flex-1 w-full text-left",children:[a.jsx("p",{className:bb("font-medium font-brockmann text-[14px] leading-5 -tracking-[0.2px] capitalize",r&&"personal"!==e.id?"":"text-white/80"),style:{background:r&&"personal"!==e.id?"linear-gradient(180deg, #00FF66 0%, #62ECFE 100%)":void 0,WebkitBackgroundClip:r&&"personal"!==e.id?"text":void 0,WebkitTextFillColor:r&&"personal"!==e.id?"transparent":void 0,backgroundClip:r&&"personal"!==e.id?"text":void 0},children:"personal"===e.id?"Personal Space":e.name}),a.jsxs("div",{className:bb("text-[12px] font-inter font-medium leading-4 capitalize",r&&"personal"!==e.id?"":"text-white/50",E(e)&&"text-[#FF8C66]"),style:{background:r&&"personal"!==e.id?"linear-gradient(180deg, #00FF66 0%, #62ECFE 100%)":void 0,WebkitBackgroundClip:r&&"personal"!==e.id?"text":void 0,WebkitTextFillColor:r&&"personal"!==e.id?"transparent":void 0,backgroundClip:r&&"personal"!==e.id?"text":void 0},children:[S(e),e.members&&!E(e)?` • ${e.members} members`:null]})]}),E(e)&&a.jsx("button",{type:"button",className:"rounded-full border-[#FFFFFF0D] bg-[#FF8C6612] text-[#FF8C66] font-semibold text-[14px] px-4 py-[6px] max-h-[32px]",children:"Pending"})]})]}),r&&a.jsx(zD,{className:"self-start w-5 h-5 text-teal-400"})]})},e.id)}),!g&&(null==f?void 0:f.pending_invitations)&&f.pending_invitations.length>0&&a.jsx(a.Fragment,{children:f.pending_invitations.map(e=>a.jsx(OD,{invitation:e,onAcceptInvitation:F,onDeclineInvitation:_,isAcceptingInvitation:j||N,variant:"switcher"},e.id))})]}),!g&&!y&&Tg()&&a.jsx(DD,{onClick:()=>{c(!1),u(!0)},variant:"compact"})]})}),l&&a.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>c(!1)}),a.jsx(MD,{isOpen:d,onOpenChange:u,onWorkspaceCreated:(e,t)=>{x({id:e,name:t}),m(!0)}}),h&&a.jsx(FM,{isOpen:p,onOpenChange:m,organizationId:h.id,organizationName:h.name,planType:"team"})]})},$D=wv.discountModal.bg,VD=wv.discountModal.text,UD=wv.discountModal.assetOff,WD=wv.common.stars;function qD({isOpen:e,onOpenChange:t,onClaimDiscount:n,onClose:s}){const i=()=>{null==n||n()};return e?a.jsx(Bt,{children:a.jsx("div",{className:"fixed top-0 left-0 bottom-0 right-0 w-full h-full z-[999] flex items-center justify-center bg-[#0e0e0f50] backdrop-blur-[5px]",children:a.jsxs(zt.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},transition:{duration:.3,ease:"easeOut"},className:"max-w-[95vw] md:max-w-[900px] md:h-[700px] w-full max-h-[90dvh] relative bg-[#131314] text-white border border-[#1A1A1A] rounded-2xl overflow-hidden",children:[a.jsx("img",{src:$D,alt:"Background",className:"absolute inset-0 w-full h-full object-cover z-[0]"}),a.jsx("button",{title:"Close",className:"absolute top-4 right-4 md:top-6 md:right-6 z-[99] bg-[#FFFFFF05] backdrop-blur-lg hover:bg-[#FFFFFF12] p-2 rounded-full transition-colors",onClick:()=>{null==s||s(),t(!1)},children:a.jsx(HS,{className:"w-5 h-5 md:w-6 md:h-6"})}),a.jsxs("div",{className:"relative z-[10] flex flex-col items-center justify-center gap-[48px] h-full",children:[a.jsx(zt.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.5,ease:"easeOut"},className:"flex justify-center",children:a.jsx("img",{src:VD,alt:"Discount Text",className:"w-[320px] mt-[56px] max-w-full h-auto"})}),a.jsxs(zt.button,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.5,ease:"easeOut",delay:.1},onClick:i,className:"flex justify-center items-center gap-2 w-[300px] h-12 px-2 py-2 rounded-[30px] bg-gradient-to-b from-[#0F6] to-[#62ECFE] hover:opacity-90 transition-opacity",style:{boxShadow:"0 0 32.572px 0 rgba(98, 236, 254, 0.20), 0 0 32.572px 0 rgba(0, 255, 102, 0.50)"},children:[a.jsx("span",{className:"text-black font-semibold",children:"Subscribe Now"}),a.jsx("span",{children:a.jsx("img",{src:WD,alt:"Stars",className:"w-6 h-6"})})]}),a.jsx(zt.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.5,ease:"easeOut",delay:.2},className:"flex justify-center",children:a.jsx("img",{src:UD,alt:"Discount Asset",className:"w-[320px] max-w-full h-auto cursor-pointer hover:opacity-90 transition-opacity",onClick:i})})]})]})})}):null}const GD=wv.common.foregroundImage,ZD=({isFreeUser:e})=>e?a.jsx(Tk.img,{src:GD,alt:"Overlay",className:"fixed w-full top-0 right-0 bottom-0 left-0 h-full object-cover pointer-events-none z-[100]",style:{mixBlendMode:"screen"},initial:{opacity:0},animate:{opacity:.25},transition:{duration:1,ease:"easeOut"}}):null,YD=({isFreeUser:e,session:t,userName:n})=>{const s={hidden:{opacity:0,y:20},visible:{opacity:1,y:0,transition:{duration:.8,ease:"easeOut"}}},{isMobile:i}=nI();return a.jsx(YM,{className:"flex bg-transparent border-0 max-md:items-center max-md:h-full max-md:flex md:space-y-1",children:a.jsx(KM,{className:"max-md:absolute max-md:w-full max-md:transform max-md:-translate-x-1/2 max-md:-translate-y-1/2 max-md:top-1/2 max-md:left-1/2 max-md:pb-[200px]",children:a.jsxs(Tk.div,{variants:{hidden:{opacity:0},visible:{opacity:1,transition:{staggerChildren:.2,delayChildren:.3}}},initial:"hidden",animate:"visible",className:"w-full",children:[i&&a.jsx(QM,{className:"flex items-center justify-center w-full h-6 md:py-1 mb-[10px] max-md:text-[14px] text-[16px]",children:a.jsx(Tk.span,{variants:s,style:{background:"linear-gradient(180deg, #00FF66 0%, #62ECFE 100%)",backgroundClip:"text",WebkitBackgroundClip:"text",WebkitTextFillColor:"transparent",textShadow:"0 0 22.43px rgba(98, 236, 254, 0.20), 0 0 22.43px rgba(0, 255, 102, 0.50)",fontWeight:400,lineHeight:"24px",letterSpacing:"1.6px",textTransform:"uppercase",textAlign:"center"},children:a.jsxs("span",{className:"font-ndot",children:["Welcome",t?`, ${n}`:""]})})}),a.jsx(JM,{className:"flex items-center justify-center w-full font-medium font-brockmann",children:a.jsx(Tk.span,{variants:s,transition:{duration:.8,ease:"easeOut",delay:.4},className:"animate-text bg-gradient-to-r text-center text-[6.7vw] md:text-[40px] max-text-[40px] from-[#80FFF9] to-[#F7E7D9] text-transparent bg-clip-text "+(e?"[text-shadow:0_0_40px_rgba(232,232,230,0.40)]":""),children:a.jsx("span",{className:"",children:e?"Where ideas become reality":"What will you build today?"})})}),e&&a.jsx(Tk.p,{variants:s,transition:{duration:.8,ease:"easeOut",delay:.8},className:"flex items-center justify-center mt-4",children:a.jsx("p",{className:"text-center text-[#595959] max-md:text-[16px] md:text-[18px] font-medium leading-6 tracking-[-0.18px]",children:"Build fully functional apps and websites through simple conversations"})})]})})})},KD=wv.common.eLogo,JD=({isFreeUser:e,jobs:t,showBottomPage:n,setShowBottomPage:s})=>e?a.jsxs(a.Fragment,{children:[a.jsx(zb,{children:0==t.length&&!n&&a.jsx(Tk.div,{className:"max-md:hidden fixed -bottom-[60px] left-1/2 -translate-x-1/2 pointer-events-none z-[-1] w-full",initial:{opacity:0},animate:{opacity:1},transition:{duration:.6,ease:"easeOut",opacity:{duration:.8,ease:"easeInOut"}},exit:{opacity:0,transition:{duration:.3,ease:"easeOut"}},children:a.jsx("img",{src:KD,alt:"Emergent Logo",className:"w-auto h-[400px] md:w-[350px] md:h-[350px] object-cover mx-auto"})})}),0==t.length&&!n&&a.jsxs(Tk.div,{onClick:()=>s(!0),className:"max-md:hidden fixed bottom-5 inset-x-0 w-fit mx-auto flex justify-center items-center px-4 py-2 h-9 min-w-[42px] min-h-9 cursor-pointer bg-white/10 backdrop-blur-xl hover:backdrop-blur-xl rounded-[8px]",initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:20},transition:{duration:.6,ease:"easeOut",opacity:{duration:.5,ease:"easeInOut"}},whileHover:{y:-4,transition:{duration:.2,ease:"easeOut"}},children:[a.jsx("p",{className:"text-[var(--text-tertiary)] select-none text-[16px] text-white leading-[18px]",children:"Explore showcases"}),a.jsx("div",{className:"ml-2",children:a.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[a.jsx("path",{d:"M4 13L8 9L12 13",stroke:"#858481","stroke-width":"0.886667","stroke-linecap":"round","stroke-linejoin":"round"}),a.jsx("path",{d:"M4 9L8 5L12 9",stroke:"#B9B9B7","stroke-width":"0.886667","stroke-linecap":"round","stroke-linejoin":"round"})]})})]})]}):null,QD=()=>{const e=26,t=39,n=39,s=128,i=255,r=249,o=window.innerWidth<640?6:10,l=a=>Array.from({length:o},(l,c)=>{const d=c/(o-1),u="left"===a?Math.max(.2,d):Math.max(.2,1-d);let p;if("left"===a){p=`rgb(${Math.round(e+(s-e)*d)}, ${Math.round(t+(i-t)*d)}, ${Math.round(n+(r-n)*d)})`}else{p=`rgb(${Math.round(s+(e-s)*d)}, ${Math.round(i+(t-i)*d)}, ${Math.round(r+(n-r)*d)})`}return{index:c,opacity:u,color:p}}),c=l("left"),d=l("right");return a.jsx("div",{className:"flex flex-col items-center justify-center w-full p-4 pt-8 pb-0 rounded-lg md:p-8 hidden md:flex",children:a.jsxs("div",{className:"flex items-center justify-center w-full",children:[c.map(e=>a.jsx("div",{className:"mx-1 rounded-full md:mx-2",style:{width:window.innerWidth<640?"3px":"4px",height:window.innerWidth<640?"3px":"4px",opacity:e.opacity,backgroundColor:e.color}},`left-${e.index}`)),a.jsx("div",{className:"mx-2 text-nowrap md:mx-4 md:text-xl animate-text bg-gradient-to-r from-[#80FFF9] to-[#F7E7D9] text-transparent bg-clip-text",children:"From the Community"}),d.map(e=>a.jsx("div",{className:"mx-1 rounded-full md:mx-2",style:{width:window.innerWidth<640?"3px":"4px",height:window.innerWidth<640?"3px":"4px",opacity:e.opacity,backgroundColor:e.color}},`right-${e.index}`))]})})},XD=wv.common.arrowUpRight,eL=({title:e,description:t,imageLink:n,hrefLink:s,className:i,handleOnClick:r,job_id:o})=>{const[l,c]=Pe.useState(!1);return a.jsxs(Tk.div,{className:bb("bg-[#18181A] rounded-2xl h-[280px] flex-1 overflow-hidden relative cursor-pointer",i),onHoverStart:()=>c(!0),onHoverEnd:()=>c(!1),onClick:()=>r(o),id:`showcase-card-${o}`,initial:{borderColor:"transparent"},animate:{borderColor:l?"#333333":"transparent",boxShadow:l?"0 0 10px rgba(51, 51, 51, 0.3)":"none"},transition:{duration:.2},style:{border:"1px solid"},children:[a.jsxs("div",{className:"relative z-10 flex flex-col gap-4 px-5 pt-8",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx(Tk.span,{className:"text-lg font-medium font-brockmann",initial:{color:"#ffffff"},animate:{color:l?"#66eaff":"#ffffff"},transition:{duration:.2,ease:"easeOut"},children:e}),a.jsx(Tk.img,{src:XD,title:"Open Link",initial:{opacity:0,x:-10},animate:{opacity:l?1:0,x:l?0:-10},transition:{duration:.2,ease:"easeOut"}})]}),a.jsx("p",{className:"text-sm font-medium text-white opacity-30 font-inter",children:t})]}),a.jsx(Tk.div,{className:"absolute max-h-[150px] inset-0 bg-gradient-to-b from-[#0F0F1000] to-[#0F0F10] z-[15]",animate:{opacity:l?.4:1,y:l?190:80},transition:{duration:.2}}),a.jsx(Tk.div,{className:"absolute w-full bottom-0 z-[20] px-[10px]",animate:{y:l?"90%":"40%"},transition:{duration:.2,ease:"easeInOut"},children:a.jsx("img",{src:n,className:"w-full object-cover min-h-[180px] rounded-lg",alt:e,loading:"eager"})})]})},tL=wv.common.featured,nL=wv.cat.aiAppsBlack,sL=wv.cat.aiAppsWhite,iL=wv.cat.landingPageBlack,aL=wv.cat.landingPageWhite,rL=wv.cat.microSaasBlack,oL=wv.cat.microSaasWhite,lL=wv.cat.playWhite,cL=wv.cat.playBlack,dL=({showCaseData:e})=>{var t,n;const{setTabs:s,updateTabState:i,setActiveTab:r,getTabByJobId:o}=Hee(),{user:l}=Yg(),[c]=Ux(),[d,u]=Pe.useState(null==(t=e[0])?void 0:t.category_name),p=Pe.useRef(!1),m=Pe.useRef(null);Pe.useEffect(()=>{var t;u(null==(t=e[0])?void 0:t.category_name)},[e]),Pe.useEffect(()=>()=>{m.current&&clearTimeout(m.current)},[]);const h=(null==(n=e.filter(e=>e.category_name===d)[0])?void 0:n.apps)||[],x=Pe.useCallback((e,t,n)=>{var a;if(!e.payload.task)return;if(!(e.payload.container_id||e.id))return;const o=`tab-${Date.now()}-${Math.random().toString(36).slice(2,11)}`,l={containerId:e.payload.container_id||e.id,initial_commit_id:e.payload.initial_commit_id,task:e.payload.task,jobId:e.id,tabId:o,fromJobList:!0,isCloudFlow:null==(a=e.payload)?void 0:a.is_cloud,clientRefId:e.client_ref_id,modelName:e.payload.model_name,promptName:e.payload.prompt_name,promptVersion:e.payload.prompt_version,costLimit:e.payload.per_instance_cost_limit,agentName:e.payload.agent_name,portMapping:e.payload.portMapping,previewUrl:t,showCase:!0};s(t=>[...t,{id:o,title:`${e.payload.task}`,path:"/chat",state:l,tabHeading:n}]),i(o,l),r(o)},[s,i,r]),f=Pe.useCallback(async(e,t,n)=>{if(p.current)return;if(m.current&&clearTimeout(m.current),p.current=!0,!l)return window.open(t,"_blank"),void(m.current=setTimeout(()=>{p.current=!1},1e3));const s=o(e.trim());if(s)return r(s.id),void(m.current=setTimeout(()=>{p.current=!1},500));try{const s=await c(e.trim()).unwrap();x(s,t,n)}catch(i){}finally{m.current=setTimeout(()=>{p.current=!1},1e3)}},[l,c,x,o,r]),g=(e,t,n)=>{const s=t||n;switch(e){case"AI Apps":return s?nL:sL;case"Landing":return s?iL:aL;case"Digital Sidekicks":return s?rL:oL;case"Hack & Play":return s?cL:lL;default:return tL}};return a.jsxs("section",{className:" flex-col md:pb-20 md:gap-[16px] items-center max-md:hidden md:flex",children:[a.jsx("div",{className:"flex flex-wrap justify-between gap-2 p-6 pt-4 mx-auto md:gap-4 md:w-full md:max-w-5xl",children:e.map((e,t)=>{const n=d===e.category_name;return a.jsxs("button",{onClick:()=>u(e.category_name),id:`showcase-category-${e.category_name}`,className:bb("md:h-[48px] gap-1 md:gap-[6px] font-brockmann flex items-center justify-center text-[24px] flex-grow flex-1 transition-all duration-300 ease-in-out px-4 py-2 whitespace-nowrap rounded-full ",n?"bg-white text-[#0F0F10] font-semibold hover:bg-white/90":"bg-[#1D1D1F] text-white font-medium hover:bg-[#2D2D2F]"),children:[a.jsx("img",{src:g(e.category_name,n,!1),alt:`${e.category_name} Icon`,className:n?"min-w-5 min-h-5":"min-w-5 min-h-5 opacity-60"}),a.jsx("span",{className:bb("text-[14px] md:text-[16px] font-brockmann capitalize",n?"text-[#0F0F10] font-semibold":"text-white font-medium opacity-60"),children:e.category_name})]},e.category_name+t)})}),a.jsx(Tk.div,{className:"w-full px-4",initial:{opacity:0},animate:{opacity:1},transition:{duration:.2},children:a.jsx(zb,{mode:"wait",children:a.jsx(Tk.div,{className:"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4",initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.2},children:h.map((e,t)=>a.jsx(eL,{title:e.name,description:e.description,imageLink:e.image||"https://s3-alpha-sig.figma.com/img/8133/f6ec/448fb87c3cb4871ded0d5a981369605f?Expires=1743379200&Key-Pair-Id=APKAQ4GOSFWCW27IBOMQ&Signature=d9A8rwjeZQrHQOGWyQZNxi9qXlHsOfx4C8QMqY~KtEh16KQQLyi8BfqcXdp334IxRyc1G0Fw1xYsaxnHlTMGB~4-QRGatbr7f~j1BSsG1hKiaFNLXPo0BarLiIAKQNWSNV3rFdkIZct2dTSGRlRY5o3bR2PeVoNXxDWA~lpf9kFgehmhYLi4IwMFr0yqvSvzjOqnYIRYzml6xCVE325kQxp-8AK0GTeU1ns9mu87eVeKwXKniigyGebSSU1XWd2jeIOLL2zytjKx3eup8EnG4JHrHr1BZSBNP84pMZQeQqpWii52LAhdkx-qUa9lsmFjAgsV5P4nl~zp7DeO4jI0lw__",hrefLink:e.preview_url,handleOnClick:()=>f(e.job_id,e.preview_url,e.name),job_id:e.job_id,className:"h-[280px] w-full"},e.job_id+t))},d)})})]})},uL=({isFreeUser:e,isMobile:t,jobs:n,showBottomPage:s,globalConfig:i})=>t?null:a.jsxs(Tk.div,{initial:{opacity:0,y:20},animate:{opacity:e&&!s?0:1,y:e&&!s?20:0,marginTop:e&&0===n.length?s?"100px":"300px":"100px"},transition:{duration:.8,ease:[.33,1,.68,1],opacity:{duration:s?.8:.6,ease:s?"easeInOut":"easeOut"},marginTop:{duration:s?.4:.5,ease:s?"easeOut":"easeIn"},y:{duration:s?.8:.6,ease:s?"easeOut":"easeIn"}},className:"flex flex-col items-center justify-center md:mt-0",children:[a.jsx(QD,{}),a.jsx("div",{className:"w-full max-w-6xl",children:a.jsx(dL,{showCaseData:(null==i?void 0:i.portfolio)||[]})})]}),pL=wv.common.banner,mL=wv.videos.bgVid,hL=wv.icons.bgPatternHome;function xL({redirectToRegister:e=!0}){var t,n,s,i,r,o,l,c;const{getCurrentOrganizationId:d,getCurrentWorkspaceData:u}=ev(),{data:p=[],isLoading:m,refetch:h}=Vx({organization_id:d()}),{config:x}=AM(),[f,g]=Pe.useState(!1),[v,b]=Pe.useState(!1),[y,w]=Pe.useState(""),[j,C]=Pe.useState((null==(t=null==x?void 0:x.overload_lock)?void 0:t.enabled)||!1),[N,F]=Pe.useState(!1),[_,k]=Pe.useState(!1),S=UE(),E=function(){const{openModal:e,closeModal:t,activeModals:n}=VE();return{open:(t={})=>e({type:"one-million",...t}),close:()=>t("one-million"),isOpen:n.has("one-million"),config:n.get("one-million")}}(),I=KE(),A=function(){const{openModal:e,closeModal:t,activeModals:n}=VE();return{open:t=>e({type:"job-id",...t}),close:()=>t("job-id"),isOpen:n.has("job-id"),config:n.get("job-id")}}(),T=(()=>{const{openModal:e,closeModal:t,activeModals:n}=VE();return{open:(t={})=>e({type:"funding-introduction",...t}),close:()=>t("funding-introduction"),isOpen:n.has("funding-introduction"),config:n.get("funding-introduction")}})(),M=(()=>{const{openModal:e,closeModal:t,activeModals:n}=VE();return{open:(t={})=>e({type:"pro",...t}),close:()=>t("pro"),isOpen:n.has("pro"),config:n.get("pro")}})(),{isMobile:D}=nI();Pe.useEffect(()=>{"pro_mode"===localStorage.getItem("showThankYou")&&!M.isOpen&&p.length>0&&(M.open({shouldShowThankYou:!0}),localStorage.removeItem("showThankYou"),localStorage.removeItem("utm_term"))},[M,p.length]);const L=Pe.useRef(null),{session:P,user:R}=Yg(),{checkGitHubConnection:O}=qA(),[z,B]=$e(),{isTrulyFreeUser:H,tier:$,loading:V,personalPlansResponse:U}=sv(),W=Nt(e=>{var t;return null==(t=e.menu)?void 0:t.showModelSelectorTooltip}),q=Pe.useMemo(()=>H()&&!V,[H,V]),[G,Z]=Pe.useState(!1),{data:Y}=Sx(void 0,{skip:!R}),K=function(){const{openModal:e,closeModal:t,activeModals:n}=VE();return{open:t=>e({type:"pending-invitation",...t}),close:()=>t("pending-invitation"),isOpen:n.has("pending-invitation"),config:n.get("pending-invitation")}}(),J=function(){const{openModal:e,closeModal:t,activeModals:n}=VE();return{open:(t={})=>e({type:"standard-discount",...t}),close:()=>t("standard-discount"),isOpen:n.has("standard-discount"),config:n.get("standard-discount")}}(),Q=function(){const{openModal:e,closeModal:t,activeModals:n}=VE();return{open:(t={})=>e({type:"mcp-introduction",...t}),close:()=>t("mcp-introduction"),isOpen:n.has("mcp-introduction"),config:n.get("mcp-introduction")}}(),[X,ee]=Pe.useState([]),[te,ne]=Pe.useState(null),[se,ie]=Pe.useState(null),ae=Pe.useRef(!1),[re,oe]=Pe.useState(!1),le=Pe.useRef(0),ce=Pe.useRef(null);Pe.useEffect(()=>{let e=null;if(q){const t=e=>{const t=e.target.scrollTop;t>0&&oe(!0),0===t&&oe(!1),le.current=t},n=ce.current;n&&(n.addEventListener("scroll",t,{passive:!0}),e=()=>n.removeEventListener("scroll",t))}return()=>{e&&e()}},[q,V]);const[de,ue]=Pe.useState(()=>{const e=localStorage.getItem("embeddedTaskTabId");if(!e){const e=kD();return localStorage.setItem("embeddedTaskTabId",e),e}return e||kD()});Pe.useEffect(()=>{R&&fg.createUser(null==R?void 0:R.id)},[R]);const pe=()=>{if(!(null==Y?void 0:Y.pending_invitations)||K.isOpen||te)return;let e=null;try{const t=localStorage.getItem("pending_invitation");if(t){const n=JSON.parse(t);e=n.invitation_id}}catch(n){}const t=Y.pending_invitations.find(t=>{const s=e===t.id,i=!X.includes(t.id),a=!function(e){try{const t=localStorage.getItem($u);return!0===(t?JSON.parse(t):{})[e]}catch(n){return!1}}(t.organization_id);return!(!s||!i)||i&&a});if(t){const e={id:t.id,organization_id:t.organization_id,organization_name:t.organization_name,role:t.role,invited_by:t.invited_by,invited_by_email:t.invited_by,inviter_name:t.inviter_name,expires_at:t.expires_at,created_at:t.created_at};ne(t.id);const n=()=>{ee(e=>[...e,t.id]),ne(null),Vu(t.organization_id),localStorage.removeItem("pending_invitation")};K.open({invitation:e,onAccept:n,onDecline:n})}},me=Re(),he=Oe(),{setTabs:xe,setActiveTab:fe,updateTabState:ge,state:ve,getTabByJobId:be,activeTab:ye}=Hee(),{refreshCredits:we,credits:je}=sv();Pe.useEffect(()=>{if("redirect"!==new URLSearchParams(window.location.search).get("utm_shift"))return;const e=navigator.userAgent||navigator.vendor,t=/android/i.test(e),n=/iPad|iPhone|iPod/.test(e),s=new URLSearchParams(window.location.search);s.delete("utm_shift");const i="https://app.emergent.sh/home",a=s.toString(),r=a?`${i}?${a}`:i;n?window.location.href=`x-safari-https://${r.replace("https://","")}`:t&&(window.location.href=`intent://${r.replace("https://","")}#Intent;scheme=https;package=com.android.chrome;end`)},[]),Pe.useEffect(()=>{P?(g(!1),"home"===ve.activeTab&&(null!==L.current&&"home"!==L.current&&we(),ge("home",{isCloudFlow:!0})),L.current=ve.activeTab):g(!1)},[P,ve.activeTab,null==he?void 0:he.pathname]),Pe.useEffect(()=>{"home"===ye&&h()},[ye]),Pe.useEffect(()=>{P&&h()},[d(),h,P]),Pe.useEffect(()=>{const e=()=>{var e;!j&&(null==(e=null==x?void 0:x.overload_lock)?void 0:e.enabled)&&C(!0)};return document.addEventListener("click",e),()=>{document.removeEventListener("click",e)}},[j,x]);Pe.useEffect(()=>{P?(O(),g(!1),Pu()):g(!1)},[P]);const Ce=e=>{var t,n,s,i,a,r;const o=e._openedInAdminMode;if(!e.payload.task)return;if(!(e.payload.container_id||e.id))return;const l=be(e.id);if(l)return void fe(l.id);const c=`tab-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,u=`/root/runs/${e.id}/trajectory.json`;let p=null;e.payload.forked_from?p={parent_job_id:e.payload.forked_from,parent_job_title:null}:(null==(t=e.payload.forked)?void 0:t.parent_job_id)&&(p=e.payload.forked);const m=e.organization_id||(null==(n=e.payload)?void 0:n.organization_id),h={containerId:e.payload.container_id||e.id,initial_commit_id:e.payload.initial_commit_id,task:e.payload.task,jobId:e.id,title:(null==(s=e.payload)?void 0:s.original_task)||e.payload.task,trajPath:u,tabId:c,fromJobList:!0,isCloudFlow:null==(i=e.payload)?void 0:i.is_cloud,clientRefId:e.client_ref_id,modelName:e.payload.model_name,promptName:e.payload.prompt_name,promptVersion:e.payload.prompt_version,costLimit:e.payload.per_instance_cost_limit,agentName:e.payload.agent_name,portMapping:e.payload.portMapping,created_by:e.created_by,forked:p,isAdminModeJob:o,originalOrganizationId:o?m:void 0,originalOrganizationName:o?e.organization_name||(null==(a=e.payload)?void 0:a.organization_name):void 0,tabHeading:e.title},x=d();let f,g,v,b;if(o)f="user",g=void 0,v=void 0,b="/chat";else{f=m?"organization":"user",g=m||x,v=e.organization_name||(null==(r=e.payload)?void 0:r.organization_name);const t=d();b=t?`/workspace/${t}/chat`:"/chat"}xe(t=>[...t,{id:c,title:`${e.payload.task}`,path:b,level:f,organization_id:g,organization_name:v,state:h,tabHeading:e.title??""}]),ge(c,h),fe(c),me(`${b}?id=${e.id}`),bg(sE.RECENT_TASK_OPENED,e)};if(!Bu("hasSeenTeamsIntroModal",!1)){const e=YE();let t=u();(null==t?void 0:t.id.includes("org"))&&"ADMIN"==(null==t?void 0:t.role)&&(e.open({organizationId:t.id,organizationName:t.name,mode:"welcome",backendEnabled:!0,onInvitesSent:()=>{}}),zu("hasSeenTeamsIntroModal",!0))}const Ne=()=>{var e;const t=new Date,n=new Date((null==(e=null==x?void 0:x.overload_lock)?void 0:e.locked_until)||"").getTime()-t.getTime(),s=Math.floor(n/864e5),i=Math.floor(n%864e5/36e5),a=Math.floor(n%36e5/6e4);return{days:s<10?`0${s}`:`${s}`,hours:i<10?`0${i}`:`${i}`,minutes:a<10?`0${a}`:`${a}`}};Pe.useEffect(()=>{(async()=>{if(P&&R&&!ae.current)try{ae.current=!0;const e=await fm();ie(e)}catch(e){ae.current=!1}})()},[J]),Pe.useEffect(()=>{K.isOpen||te||pe()},[Y]);const[Fe,_e]=Pe.useState(K.isOpen);let ke;return Pe.useEffect(()=>{Fe&&!K.isOpen&&(te&&(ee(e=>[...e,te]),ne(null)),setTimeout(()=>{pe()},500)),_e(K.isOpen)},[K.isOpen,te]),Pe.useEffect(()=>{!W&&_&&k(!1)},[W,_]),Pe.useEffect(()=>{!S.isOpen&&_&&k(!1)},[S.isOpen,_]),Pe.useEffect(()=>{_&&Q.isOpen&&(Ku(),Q.close())},[_,Q]),Pe.useEffect(()=>{!(R&&P&&p.length>0)||Bu("hasSeenClaude45AnnouncementModal",!1)||E.isOpen||V||_||T.isOpen||E.open({onGetStarted:()=>{},onClose:()=>{},onShowUpgradeModal:()=>{S.open({triggerLocation:"oneMillionModal",shouldShowModelSelectorTooltipAfterClose:!1})},onPreventOtherModals:e=>{k(e)}})},[R,P,p.length,E.isOpen,V,_,T.isOpen]),Pe.useEffect(()=>{const e=z.get("job_id");if(e&&p.length>0){const t=p.find(t=>t.id===e);t&&(Ce(t),z.delete("job_id"),B(z))}},[p,z,B,Ce]),Pe.useEffect(()=>{var e,t;0===p.length&&R&&!D&&fg.triggerEvent("no-jobs-created",{user_id:null==R?void 0:R.id,user_email:null==R?void 0:R.email,tier:$,user_id_ends:null==(e=null==R?void 0:R.id)?void 0:e.slice(-1)}),0===p.length&&R&&D&&fg.triggerEvent("no-jobs-created-mobile",{user_id:null==R?void 0:R.id,user_email:null==R?void 0:R.email,tier:$,user_id_ends:null==(t=null==R?void 0:R.id)?void 0:t.slice(-1)})},[null==p?void 0:p.length,R]),ke=(null==(n=null==R?void 0:R.user_metadata)?void 0:n.custom_name)?R.user_metadata.custom_name:(null==(s=null==R?void 0:R.user_metadata)?void 0:s.full_name)?R.user_metadata.full_name.split(" ")[0]:null==(i=null==R?void 0:R.email)?void 0:i.split("@")[0],Pe.useEffect(()=>{f||V||!R||bg("home_loaded",{userId:null==R?void 0:R.id,userName:ke,credits:je,tier:$})},[V,f,null==R?void 0:R.id]),f||V?a.jsx("div",{className:"flex items-center justify-center min-h-screen",children:a.jsxs("div",{className:"flex flex-col items-center space-y-4 text-center",children:[a.jsx(Mk,{className:"mx-auto"}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading"})]})}):a.jsx(a.Fragment,{children:a.jsxs("div",{ref:ce,className:"relative flex flex-col items-center h-full overflow-y-scroll md:h-screen justify-between md:block "+(q?"bg-cover bg-center bg-no-repeat mix-blend-screen":""),style:{...q&&!D?{backgroundImage:`url(${hL})`}:{}},children:[a.jsx("img",{alt:"Background",src:hL,className:"fixed top-0 bottom-0 pointer-events-none left-0 right-0 z-[-1] object-cover h-[100dvh]"}),a.jsx(ZD,{isFreeUser:q||D}),a.jsx(zb,{children:j&&a.jsxs(Tk.div,{className:"absolute top-0 left-0 z-20 w-full",initial:{y:"-100%"},animate:{y:0},exit:{y:"-100%"},transition:{type:"spring",stiffness:100,damping:20},children:[a.jsxs("div",{className:"relative min-h-[300px] sm:min-h-[450px] lg:min-h-[400px]",children:[a.jsx("img",{alt:"Banner",src:pL,className:"absolute inset-0 z-20 object-cover w-full h-full"}),a.jsx("div",{className:"absolute top-0 left-0 w-full h-full overflow-hidden",children:a.jsx("div",{className:"flex w-full h-full max-md:hidden",children:[...Array(4)].map((e,t)=>a.jsx("video",{src:mL,autoPlay:!0,loop:!0,muted:!0,className:"flex-shrink-0 object-cover w-full h-full opacity-10",style:{maxWidth:"25%",transform:`rotate(${180*t}deg)`}},t))})}),a.jsx("div",{className:"absolute top-0 left-0 z-30 w-full h-full pb-10",children:a.jsx("div",{className:"flex px-4 py-6 w-full min-h-[300px] sm:min-h-[750px] lg:min-h-[400px] sm:px-8 sm:py-8 lg:px-[72px] lg:py-12",children:a.jsxs("div",{className:"flex flex-col items-start justify-between w-full space-y-8",children:[a.jsxs("div",{className:"flex flex-col space-y-2 max-w-full lg:max-w-[600px]",children:[a.jsx("span",{className:"text-[#242F33] text-lg font-semibold leading-6 font-sans sm:text-xl sm:leading-7 lg:text-[28px] lg:leading-9",children:null==(r=null==x?void 0:x.overload_lock)?void 0:r.title}),a.jsx("span",{className:"text-[#242F33] text-sm font-normal leading-5 opacity-60 font-sans sm:text-base sm:leading-6 lg:text-[18px] lg:leading-7",children:null==(o=null==x?void 0:x.overload_lock)?void 0:o.description})]}),a.jsxs("div",{className:"flex flex-col w-full gap-6 lg:flex-row lg:items-center lg:justify-between lg:gap-0",children:[a.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:gap-8 lg:gap-16",children:[a.jsxs("div",{className:"flex flex-col items-start gap-1 lg:gap-2",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-[#242F33] text-xl font-semibold leading-6 font-sans sm:text-2xl sm:leading-7 lg:text-[28px] lg:leading-9",children:null==(l=null==x?void 0:x.overload_lock)?void 0:l.capacity}),a.jsx(aT,{color:"#CB6565"})]}),a.jsx("span",{className:"text-[#242F33] text-sm font-normal leading-5 opacity-60 font-sans sm:text-base sm:leading-6 lg:text-[18px] lg:leading-7",children:"System Capacity"})]}),a.jsxs("div",{className:"flex flex-col items-start gap-1 lg:gap-2",children:[a.jsx("div",{className:"flex items-center gap-2",children:a.jsx("span",{className:"text-[#242F33] text-xl font-semibold leading-6 font-sans sm:text-2xl sm:leading-7 lg:text-[28px] lg:leading-9",children:null==(c=null==x?void 0:x.overload_lock)?void 0:c.concurrent_tasks})}),a.jsx("span",{className:"text-[#242F33] text-sm font-normal leading-5 opacity-60 font-sans sm:text-base sm:leading-6 lg:text-[18px] lg:leading-7",children:"Concurrent running tasks"})]})]}),a.jsxs("div",{className:"flex flex-col gap-1 lg:gap-1",children:[a.jsxs("div",{className:"flex items-center gap-2 lg:justify-end",children:[a.jsx("div",{className:"p-2 bg-white rounded-lg flex items-center justify-center lg:p-[10px] lg:rounded-[12px]",children:a.jsxs("span",{className:"text-[#3D494D] text-lg font-semibold leading-6 font-sans sm:text-xl sm:leading-7 lg:text-[28px] lg:leading-9",children:[Ne().days,a.jsx("span",{className:"text-xs lg:text-sm",children:"d"})]})}),a.jsx("div",{className:"p-2 bg-white rounded-lg flex items-center justify-center lg:p-[10px] lg:rounded-[12px]",children:a.jsxs("span",{className:"text-[#3D494D] text-lg font-semibold leading-6 font-sans sm:text-xl sm:leading-7 lg:text-[28px] lg:leading-9",children:[Ne().hours,a.jsx("span",{className:"text-xs lg:text-sm",children:"h"})]})}),a.jsx("div",{className:"p-2 bg-white rounded-lg flex items-center justify-center lg:p-[10px] lg:rounded-[12px]",children:a.jsxs("span",{className:"text-[#3D494D] text-lg font-semibold leading-6 font-sans sm:text-xl sm:leading-7 lg:text-[28px] lg:leading-9",children:[Ne().minutes,a.jsx("span",{className:"text-xs lg:text-sm",children:"m"})]})})]}),a.jsx("span",{className:"text-[#242F33] text-sm font-normal leading-5 opacity-60 font-sans sm:text-base sm:leading-6 lg:text-[18px] lg:leading-7 lg:text-right",children:"Estimated time to come back"})]})]})]})})})]}),a.jsx("div",{className:"h-12 bg-black/20 backdrop-blur-sm sm:h-16 lg:h-20"})]})}),a.jsx("div",{className:bb("flex flex-col items-center w-full mt-[80px]","md:mt-[120px] "),children:a.jsxs("div",{className:"flex flex-col items-center w-full h-full md:max-w-6xl",children:[!q&&!D&&P&&a.jsx(HD,{}),a.jsx(YD,{isFreeUser:q,session:P,userName:ke}),a.jsx("div",{"data-component":"embedded-task",className:"w-full h-full",children:a.jsx(BM,{tabId:de,onClearTabId:()=>{const e=kD();localStorage.setItem("embeddedTaskTabId",e),ue(e)},isReferralModalOpen:I.isOpen,setIsReferralModalOpen:e=>e?I.open():I.close(),isCustomAgentsModalOpen:N,setIsCustomAgentsModalOpen:F,showMobileAgentIntro:G,onMobileAgentIntroShown:()=>Z(!1),jobsLength:p.length})}),a.jsx(JD,{isFreeUser:q,jobs:p,showBottomPage:re,setShowBottomPage:oe})]})}),a.jsx("div",{className:"flex items-center justify-center w-full",children:a.jsx("div",{className:"w-full max-w-6xl",children:!D&&(null==p?void 0:p.length)>0&&R&&P&&a.jsx(Tk.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{type:"spring",stiffness:100,damping:10,delay:.6},className:"mt-[100px]",children:a.jsx(_D,{jobs:p,handleJobClick:Ce,handleReload:async()=>{b(!0),await h(),b(!1)},reloading:v,setIsJobIdDialogOpen:e=>{e?A.open({jobIdInput:y,setJobIdInput:w,handleJobClick:Ce}):A.close()},loading:m,refetchJobs:h})})})}),a.jsx(uL,{isFreeUser:q,isMobile:D,jobs:p,showBottomPage:re,globalConfig:x}),a.jsx($M,{}),a.jsx(qD,{isOpen:J.isOpen,onOpenChange:J.close,onClaimDiscount:async()=>{var e;Yu();const t=null==(e=null==U?void 0:U.available_plans)?void 0:e.find(e=>"emergent standard"===e.tier_name.toLowerCase()&&"MONTHLY"===e.billing_period),{url:n}=await zp(0,!0,null==t?void 0:t.id,void 0);n&&(window.location.href=n)},onClose:()=>{Yu()}})]})})}const fL=Pe.createContext(void 0),gL=({children:e,initialConfig:t})=>{const[n,s]=Pe.useState({show:!1,level:"info",content:"",dismissible:!0,...t}),[i,r]=Pe.useState(0),o=Pe.useCallback(e=>{s({...e,show:!0})},[]),l=Pe.useCallback(()=>{s(e=>({...e,show:!1}))},[]),c=Pe.useCallback(e=>{s(t=>({...t,...e}))},[]),d=Pe.useCallback(e=>{r(e)},[]);Pe.useEffect(()=>{n.show||r(0)},[n.show]);const u=Pe.useCallback((e,t=!0)=>{o({level:"info",content:e,dismissible:t})},[o]),p=Pe.useCallback((e,t=!0)=>{o({level:"warning",content:e,dismissible:t})},[o]),m=Pe.useCallback((e,t=!0)=>{o({level:"error",content:e,dismissible:t})},[o]),h=Pe.useCallback((e,t=!0)=>{o({level:"success",content:e,dismissible:t})},[o]),x={bannerConfig:n,bannerHeight:i,showBanner:o,hideBanner:l,updateBanner:c,setBannerHeight:d,showInfo:u,showWarning:p,showError:m,showSuccess:h};return a.jsx(fL.Provider,{value:x,children:e})},vL=()=>{const e=Pe.useContext(fL);if(void 0===e)throw new Error("useAlert must be used within an AlertProvider");return e},bL=()=>Ft(),yL=Nt;function wL(e){return()=>e}function jL(e){e()}function CL(e,t){return n=>e(t(n))}function NL(e,t){return()=>e(t)}function FL(e){return void 0!==e}function _L(){}function kL(e,t){return t(e),e}function SL(e,t){return t(e)}function EL(...e){return e}function IL(e,t){return e(1,t)}function AL(e,t){e(0,t)}function TL(e){e(2)}function ML(e){return e(4)}function DL(e,t){return IL(e,function(e,t){return n=>e(t,n)}(t,0))}function LL(e,t){const n=e(1,e=>{n(),t(e)});return n}function PL(e){let t,n;return s=>i=>{t=i,n&&clearTimeout(n),n=setTimeout(()=>{s(t)},e)}}function RL(e,t){return e===t}function OL(e=RL){let t;return n=>s=>{e(t,s)||(t=s,n(s))}}function zL(e){return t=>n=>{e(n)&&t(n)}}function BL(e){return t=>CL(t,e)}function HL(e){return t=>()=>{t(e)}}function $L(e,...t){const n=function(...e){return t=>e.reduceRight(SL,t)}(...t);return(t,s)=>{switch(t){case 2:return void TL(e);case 1:return IL(e,n(s))}}}function VL(e,t){return n=>s=>{n(t=e(t,s))}}function UL(e){return t=>n=>{e>0?e--:t(n)}}function WL(e){let t,n=null;return s=>i=>{n=i,!t&&(t=setTimeout(()=>{t=void 0,s(n)},e))}}function qL(...e){const t=new Array(e.length);let n=0,s=null;const i=Math.pow(2,e.length)-1;return e.forEach((e,a)=>{const r=Math.pow(2,a);IL(e,e=>{const o=n;n|=r,t[a]=e,o!==i&&n===i&&s&&(s(),s=null)})}),e=>a=>{const r=()=>{e([a].concat(t))};n===i?r():s=r}}function GL(e){let t=e;const n=YL();return(e,s)=>{switch(e){case 0:t=s;break;case 1:s(t);break;case 4:return t}return n(e,s)}}function ZL(e,t){return kL(GL(t),t=>DL(e,t))}function YL(){const e=[];return(t,n)=>{switch(t){case 0:return void e.slice().forEach(e=>{e(n)});case 2:return void e.splice(0,e.length);case 1:return e.push(n),()=>{const t=e.indexOf(n);t>-1&&e.splice(t,1)}}}}function KL(e){return kL(YL(),t=>DL(e,t))}function JL(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:QL(),singleton:n}}const QL=()=>Symbol();function XL(...e){const t=YL(),n=new Array(e.length);let s=0;const i=Math.pow(2,e.length)-1;return e.forEach((e,a)=>{const r=Math.pow(2,a);IL(e,e=>{n[a]=e,s|=r,s===i&&AL(t,n)})}),function(e,a){switch(e){case 2:return void TL(t);case 1:return s===i&&a(n),IL(t,a)}}}function eP(e,t=RL){return $L(e,OL(t))}function tP(...e){return function(t,n){switch(t){case 2:return;case 1:return function(...e){return()=>{e.map(jL)}}(...e.map(e=>IL(e,n)))}}}var nP=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(nP||{});const sP=JL(()=>{const e=GL(3);return{log:GL((t,n,s=1)=>{var i;null!=(i=(typeof globalThis>"u"?window:globalThis).VIRTUOSO_LOG_LEVEL)||ML(e)}),logLevel:e}},[],{singleton:!0});function iP(e,t,n){return aP(e,t,n).callbackRef}function aP(e,t,n){const s=ze.useRef(null);let i=e=>{};const a=ze.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(t=>{const s=()=>{const n=t[0].target;null!==n.offsetParent&&e(n)};n?s():requestAnimationFrame(s)}):null,[e,n]);return i=e=>{e&&t?(null==a||a.observe(e),s.current=e):(s.current&&(null==a||a.unobserve(s.current)),s.current=null)},{callbackRef:i,ref:s}}function rP(e,t,n,s,i,a,r,o,l){const c=ze.useCallback(n=>{const l=function(e,t,n,s){const i=e.length;if(0===i)return null;const a=[];for(let r=0;r{if(null==n||!n.offsetParent)return;const i=n.getBoundingClientRect(),a=i.width;let o,l;if(t){const e=t.getBoundingClientRect(),n=i.top-e.top;l=e.height-Math.max(0,n),o=n+t.scrollTop}else{const e=r.current.ownerDocument.defaultView;l=e.innerHeight-Math.max(0,i.top),o=i.top+e.scrollY}s.current={offsetTop:o,visibleHeight:l,visibleWidth:a},e(s.current)},[e,t]),{callbackRef:a,ref:r}=aP(i,!0,n),o=ze.useCallback(()=>{i(r.current)},[i,r]);return ze.useEffect(()=>{var e;if(t){t.addEventListener("scroll",o);const e=new ResizeObserver(()=>{requestAnimationFrame(o)});return e.observe(t),()=>{t.removeEventListener("scroll",o),e.unobserve(t)}}{const t=null==(e=r.current)?void 0:e.ownerDocument.defaultView;return null==t||t.addEventListener("scroll",o),null==t||t.addEventListener("resize",o),()=>{null==t||t.removeEventListener("scroll",o),null==t||t.removeEventListener("resize",o)}}},[o,t,r]),a}const cP=JL(()=>{const e=YL(),t=YL(),n=GL(0),s=YL(),i=GL(0),a=YL(),r=YL(),o=GL(0),l=GL(0),c=GL(0),d=GL(0),u=YL(),p=YL(),m=GL(!1),h=GL(!1),x=GL(!1);return DL($L(e,BL(({scrollTop:e})=>e)),t),DL($L(e,BL(({scrollHeight:e})=>e)),r),DL(t,i),{deviation:n,fixedFooterHeight:c,fixedHeaderHeight:l,footerHeight:d,headerHeight:o,horizontalDirection:h,scrollBy:p,scrollContainerState:e,scrollHeight:r,scrollingInProgress:m,scrollTo:u,scrollTop:t,skipAnimationFrameInResizeObserver:x,smoothScrollTargetReached:s,statefulScrollTop:i,viewportHeight:a}},[],{singleton:!0}),dP={lvl:0};function uP(e,t){const n=e.length;if(0===n)return[];let{index:s,value:i}=t(e[0]);const a=[];for(let r=1;r({index:e,value:t}))}(yP(e,hP(e,t)[0],n))}function vP(e,t){if(pP(e))return dP;const{k:n,l:s,r:i}=e;if(t===n){if(pP(s))return i;if(pP(i))return s;{const[t,n]=FP(s);return wP(jP(e,{k:t,l:CP(s),v:n}))}}return wP(jP(e,tt&&(o=o.concat(yP(i,t,n))),s>=t&&s<=n&&o.push({k:s,v:r}),s<=n&&(o=o.concat(yP(a,t,n))),o}function wP(e){const{l:t,lvl:n,r:s}=e;if(s.lvl>=n-1&&t.lvl>=n-1)return e;if(n>s.lvl+1){if(NP(t))return SP(jP(e,{lvl:n-1}));if(!pP(t)&&!pP(t.r))return jP(t.r,{l:jP(t,{r:t.r.l}),lvl:n,r:jP(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}if(NP(e))return EP(jP(e,{lvl:n-1}));if(pP(s)||pP(s.l))throw new Error("Unexpected empty nodes");{const t=s.l,i=NP(t)?s.lvl-1:s.lvl;return jP(t,{l:jP(e,{lvl:n-1,r:t.l}),lvl:t.lvl+1,r:EP(jP(s,{l:t.r,lvl:i}))})}}function jP(e,t){return _P(void 0!==t.k?t.k:e.k,void 0!==t.v?t.v:e.v,void 0!==t.lvl?t.lvl:e.lvl,void 0!==t.l?t.l:e.l,void 0!==t.r?t.r:e.r)}function CP(e){return pP(e.r)?e.l:wP(jP(e,{r:CP(e.r)}))}function NP(e){return pP(e)||e.lvl>e.r.lvl}function FP(e){return pP(e.r)?[e.k,e.v]:FP(e.r)}function _P(e,t,n,s=dP,i=dP){return{k:e,l:s,lvl:n,r:i,v:t}}function kP(e){return EP(SP(e))}function SP(e){const{l:t}=e;return pP(t)||t.lvl!==e.lvl?e:jP(t,{r:jP(e,{l:t.r})})}function EP(e){const{lvl:t,r:n}=e;return pP(n)||pP(n.r)||n.lvl!==t||n.r.lvl!==t?e:jP(n,{l:jP(e,{r:n.l}),lvl:t+1})}function IP(e,t){return!(!e||e.startIndex!==t.startIndex||e.endIndex!==t.endIndex)}function AP(e,t){return!(!e||e[0]!==t[0]||e[1]!==t[1])}const TP=JL(()=>({recalcInProgress:GL(!1)}),[],{singleton:!0});function MP(e,t,n){return e[DP(e,t,n)]}function DP(e,t,n,s=0){let i=e.length-1;for(;s<=i;){const a=Math.floor((s+i)/2),r=n(e[a],t);if(0===r)return a;if(-1===r){if(i-s<2)return a-1;i=a-1}else{if(i===s)return a;s=a+1}}throw new Error(`Failed binary finding record in array - ${e.join(",")}, searched for ${t}`)}function LP(e,t){return Math.round(e.getBoundingClientRect()[t])}function PP(e){return!pP(e.groupOffsetTree)}function RP({index:e},t){return t===e?0:t0?o+n:o}function BP(e,t){if(!PP(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function HP(e,t,n){if(function(e){return typeof e.groupIndex<"u"}(e))return t.groupIndices[e.groupIndex]+1;{let s=BP("LAST"===e.index?n:e.index,t);return s=Math.max(0,s,Math.min(n,s)),s}}function $P(e,t,n,s=0){return s>0&&(t=Math.max(t,MP(e,s,RP).offset)),uP(function(e,t,n,s){const i=DP(e,t,s),a=DP(e,n,s,i);return e.slice(i,a+1)}(e,t,n,OP),qP)}function VP(e,[t,n,s,i]){t.length>0&&s("received item sizes",t,nP.DEBUG);const a=e.sizeTree;let r=a,o=0;if(n.length>0&&pP(a)&&2===t.length){const e=t[0].size,s=t[1].size;r=n.reduce((t,n)=>xP(xP(t,n,e),n+1,s),r)}else[r,o]=function(e,t){let n=pP(e)?0:1/0;for(const s of t){const{endIndex:t,size:i,startIndex:a}=s;if(n=Math.min(n,a),pP(e)){e=xP(e,0,i);continue}const r=gP(e,a-1,t+1);if(r.some(GP(s)))continue;let o=!1,l=!1;for(const{end:n,start:s,value:c}of r)o?(t>=s||i===c)&&(e=vP(e,s)):(l=c!==i,o=!0),n>t&&t>=s&&c!==i&&(e=xP(e,t+1,c));l&&(e=xP(e,a,i))}return[e,n]}(r,t);if(r===a)return e;const{lastIndex:l,lastOffset:c,lastSize:d,offsetTree:u}=WP(e.offsetTree,o,r,i);return{groupIndices:n,groupOffsetTree:n.reduce((e,t)=>xP(e,t,zP(t,u,i)),fP()),lastIndex:l,lastOffset:c,lastSize:d,offsetTree:u,sizeTree:r}}function UP(e,t){let n=0,s=0;for(;ne.start===s&&(e.end===t||e.end===1/0)&&e.value===n}const ZP={offsetHeight:"height",offsetWidth:"width"},YP=JL(([{log:e},{recalcInProgress:t}])=>{const n=YL(),s=YL(),i=ZL(s,0),a=YL(),r=YL(),o=GL(0),l=GL([]),c=GL(void 0),d=GL(void 0),u=GL((e,t)=>LP(e,ZP[t])),p=GL(void 0),m=GL(0),h={groupIndices:[],groupOffsetTree:fP(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:fP()},x=ZL($L(n,qL(l,e,m),VL(VP,h),OL()),h),f=ZL($L(l,OL(),VL((e,t)=>({current:t,prev:e.current}),{current:[],prev:[]}),BL(({prev:e})=>e)),[]);DL($L(l,zL(e=>e.length>0),qL(x,m),BL(([e,t,n])=>{const s=e.reduce((e,s,i)=>xP(e,s,zP(s,t.offsetTree,n)||i),fP());return{...t,groupIndices:e,groupOffsetTree:s}})),x),DL($L(s,qL(x),zL(([e,{lastIndex:t}])=>e[{endIndex:t,size:n,startIndex:e}])),n),DL(c,d);const g=ZL($L(c,BL(e=>void 0===e)),!0);DL($L(d,zL(e=>void 0!==e&&pP(ML(x).sizeTree)),BL(e=>[{endIndex:0,size:e,startIndex:0}])),n);const v=KL($L(n,qL(x),VL(({sizes:e},[t,n])=>({changed:n!==e,sizes:n}),{changed:!1,sizes:h}),BL(e=>e.changed)));IL($L(o,VL((e,t)=>({diff:e.prev-t,prev:t}),{diff:0,prev:0}),BL(e=>e.diff)),e=>{const{groupIndices:n}=ML(x);if(e>0)AL(t,!0),AL(a,e+UP(e,n));else if(e<0){const t=ML(f);t.length>0&&(e-=UP(-e,t)),AL(r,e)}}),IL($L(o,qL(e)),([e,t])=>{e<0&&t("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:o},nP.ERROR)});const b=KL(a);DL($L(a,qL(x),BL(([e,t])=>{const n=t.groupIndices.length>0,s=[],i=t.lastSize;if(n){const n=mP(t.sizeTree,0);let a=0,r=0;for(;a{let i=t.ranges;return 0!==t.prevSize&&(i=[...t.ranges,{endIndex:n+e-1,size:t.prevSize,startIndex:t.prevIndex}]),{prevIndex:n+e,prevSize:s,ranges:i}},{prevIndex:e,prevSize:0,ranges:s}).ranges}return bP(t.sizeTree).reduce((t,{k:n,v:s})=>({prevIndex:n+e,prevSize:s,ranges:[...t.ranges,{endIndex:n+e-1,size:t.prevSize,startIndex:t.prevIndex}]}),{prevIndex:0,prevSize:i,ranges:[]}).ranges})),n);const y=KL($L(r,qL(x,m),BL(([e,{offsetTree:t},n])=>zP(-e,t,n))));return DL($L(r,qL(x,m),BL(([e,t,n])=>{if(t.groupIndices.length>0){if(pP(t.sizeTree))return t;let s=fP();const i=ML(f);let a=0,r=0,o=0;for(;a<-e;){o=i[r];const e=i[r+1]-o-1;r++,a+=e+1}if(s=bP(t.sizeTree).reduce((t,{k:n,v:s})=>xP(t,Math.max(0,n+e),s),s),a!==-e){s=xP(s,0,mP(t.sizeTree,o));s=xP(s,1,hP(t.sizeTree,1-e)[1])}return{...t,sizeTree:s,...WP(t.offsetTree,0,s,n)}}{const s=bP(t.sizeTree).reduce((t,{k:n,v:s})=>xP(t,Math.max(0,n+e),s),fP());return{...t,sizeTree:s,...WP(t.offsetTree,0,s,n)}}})),x),{beforeUnshiftWith:b,data:p,defaultItemSize:d,firstItemIndex:o,fixedItemSize:c,gap:m,groupIndices:l,itemSize:u,listRefresh:v,shiftWith:r,shiftWithOffset:y,sizeRanges:n,sizes:x,statefulTotalCount:i,totalCount:s,trackItemSizes:g,unshiftWith:a}},EL(sP,TP),{singleton:!0});function KP(e){return e.reduce((e,t)=>(e.groupIndices.push(e.totalCount),e.totalCount+=t+1,e),{groupIndices:[],totalCount:0})}const JP=JL(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:s,scrollTop:i}])=>{const a=YL(),r=YL(),o=KL($L(a,BL(KP)));return DL($L(o,BL(e=>e.totalCount)),n),DL($L(o,BL(e=>e.groupIndices)),e),DL($L(XL(i,t,s),zL(([e,t])=>PP(t)),BL(([e,t,n])=>hP(t.groupOffsetTree,Math.max(e-n,0),"v")[0]),OL(),BL(e=>[e])),r),{groupCounts:a,topItemsIndexes:r}},EL(YP,cP)),QP=JL(([{log:e}])=>{const t=GL(!1),n=KL($L(t,zL(e=>e),OL()));return IL(t,t=>{t&&ML(e)("props updated",{},nP.DEBUG)}),{didMount:n,propsReady:t}},EL(sP),{singleton:!0}),XP=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function eR(e){const t="number"==typeof e?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!XP)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const tR=JL(([{gap:e,listRefresh:t,sizes:n,totalCount:s},{fixedFooterHeight:i,fixedHeaderHeight:a,footerHeight:r,headerHeight:o,scrollingInProgress:l,scrollTo:c,smoothScrollTargetReached:d,viewportHeight:u},{log:p}])=>{const m=YL(),h=YL(),x=GL(0);let f=null,g=null,v=null;function b(){f&&(f(),f=null),v&&(v(),v=null),g&&(clearTimeout(g),g=null),AL(l,!1)}return DL($L(m,qL(n,u,s,x,o,r,p),qL(e,a,i),BL(([[e,n,s,i,a,r,o,c],u,p,x])=>{const y=eR(e),{align:w,behavior:j,offset:C}=y,N=i-1,F=HP(y,n,N);let _=zP(F,n.offsetTree,u)+r;"end"===w?(_+=p+hP(n.sizeTree,F)[1]-s+x,F===N&&(_+=o)):"center"===w?_+=(p+hP(n.sizeTree,F)[1]-s+x)/2:_-=a,C&&(_+=C);const k=t=>{b(),t?(c("retrying to scroll to",{location:e},nP.DEBUG),AL(m,e)):(AL(h,!0),c("list did not change, scroll successful",{},nP.DEBUG))};if(b(),"smooth"===j){let e=!1;v=IL(t,t=>{e=e||t}),f=LL(d,()=>{k(e)})}else f=LL($L(t,function(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return e=>{e&&(t(!0),clearTimeout(n))}}}(150)),k);return g=setTimeout(()=>{b()},1200),AL(l,!0),c("scrolling from index to",{behavior:j,index:F,top:_},nP.DEBUG),{behavior:j,top:_}})),c),{scrollTargetReached:h,scrollToIndex:m,topListHeight:x}},EL(YP,cP,sP),{singleton:!0});function nR(e,t){0==e?t():requestAnimationFrame(()=>{nR(e-1,t)})}function sR(e,t){const n=t-1;return"number"==typeof e?e:"LAST"===e.index?n:e.index}const iR=JL(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:s},{scrollTargetReached:i,scrollToIndex:a},{didMount:r}])=>{const o=GL(!0),l=GL(0),c=GL(!0);return DL($L(r,qL(l),zL(([e,t])=>!!t),HL(!1)),o),DL($L(r,qL(l),zL(([e,t])=>!!t),HL(!1)),c),IL($L(XL(t,r),qL(o,n,e,c),zL(([[,e],t,{sizeTree:n},s,i])=>e&&(!pP(n)||FL(s))&&!t&&!i),qL(l)),([,e])=>{LL(i,()=>{AL(c,!0)}),nR(4,()=>{LL(s,()=>{AL(o,!0)}),AL(a,e)})}),{initialItemFinalLocationReached:c,initialTopMostItemIndex:l,scrolledToInitialItem:o}},EL(YP,cP,tR,QP),{singleton:!0});function aR(e,t){return Math.abs(e-t)<1.01}const rR="up",oR="down",lR={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},cR=JL(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:s,scrollTop:i,viewportHeight:a}])=>{const r=GL(!1),o=GL(!0),l=YL(),c=YL(),d=GL(4),u=GL(0),p=ZL($L(tP($L(eP(i),UL(1),HL(!0)),$L(eP(i),UL(1),HL(!1),PL(100))),OL()),!1),m=ZL($L(tP($L(n,HL(!0)),$L(n,HL(!1),PL(200))),OL()),!1);DL($L(XL(eP(i),eP(u)),BL(([e,t])=>e<=t),OL()),o),DL($L(o,WL(50)),c);const h=KL($L(XL(s,eP(a),eP(t),eP(e),eP(d)),VL((e,[{scrollHeight:t,scrollTop:n},s,i,a,r])=>{const o={scrollHeight:t,scrollTop:n,viewportHeight:s};if(n+s-t>-r){let t,s;return n>e.state.scrollTop?(t="SCROLLED_DOWN",s=e.state.scrollTop-n):(t="SIZE_DECREASED",s=e.state.scrollTop-n||e.scrollTopDelta),{atBottom:!0,atBottomBecause:t,scrollTopDelta:s,state:o}}let l;return l=o.scrollHeight>e.state.scrollHeight?"SIZE_INCREASED":se&&e.atBottom===t.atBottom))),x=ZL($L(s,VL((e,{scrollHeight:t,scrollTop:n,viewportHeight:s})=>{if(aR(e.scrollHeight,t))return{changed:!1,jump:0,scrollHeight:t,scrollTop:n};{const i=t-(n+s)<1;return e.scrollTop!==n&&i?{changed:!0,jump:e.scrollTop-n,scrollHeight:t,scrollTop:n}:{changed:!0,jump:0,scrollHeight:t,scrollTop:n}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),zL(e=>e.changed),BL(e=>e.jump)),0);DL($L(h,BL(e=>e.atBottom)),r),DL($L(r,WL(50)),l);const f=GL(oR);DL($L(s,BL(({scrollTop:e})=>e),OL(),VL((e,t)=>ML(m)?{direction:e.direction,prevScrollTop:t}:{direction:te.direction)),f),DL($L(s,WL(50),HL("none")),f);const g=GL(0);return DL($L(p,zL(e=>!e),HL(0)),g),DL($L(i,WL(100),qL(p),zL(([e,t])=>!!t),VL(([e,t],[n])=>[t,n],[0,0]),BL(([e,t])=>t-e)),g),{atBottomState:h,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:c,atTopThreshold:u,isAtBottom:r,isAtTop:o,isScrolling:p,lastJumpDueToItemResize:x,scrollDirection:f,scrollVelocity:g}},EL(cP)),dR="top",uR="bottom",pR="none";function mR(e,t,n){return"number"==typeof e?n===rR&&t===dR||n===oR&&t===uR?e:0:n===rR?t===dR?e.main:e.reverse:t===uR?e.main:e.reverse}function hR(e,t){var n;return"number"==typeof e?e:null!=(n=e[t])?n:0}const xR=JL(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:s,viewportHeight:i}])=>{const a=YL(),r=GL(0),o=GL(0),l=GL(0);return{increaseViewportBy:o,listBoundary:a,overscan:l,topListHeight:r,visibleRange:ZL($L(XL(eP(s),eP(i),eP(n),eP(a,AP),eP(l),eP(r),eP(t),eP(e),eP(o)),BL(([e,t,n,[s,i],a,r,o,l,c])=>{const d=e-l,u=r+o,p=Math.max(n-d,0);let m=pR;const h=hR(c,dR),x=hR(c,uR);return s-=l,i+=n+o,(s+=n+o)>e+u-h&&(m=rR),(i-=l)null!=e),OL(AP)),[0,0])}},EL(cP),{singleton:!0});const fR={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function gR(e,t,n,s,i,a){const{lastIndex:r,lastOffset:o,lastSize:l}=i;let c=0,d=0;if(e.length>0){c=e[0].offset;const t=e[e.length-1];d=t.offset+t.size}const u=n-r,p=c,m=o+u*l+(u-1)*s-d;return{bottom:d,firstItemIndex:a,items:bR(e,i,a),offsetBottom:m,offsetTop:c,top:p,topItems:bR(t,i,a),topListHeight:t.reduce((e,t)=>t.size+e,0),totalCount:n}}function vR(e,t,n,s,i,a){let r=0;if(n.groupIndices.length>0)for(const c of n.groupIndices){if(c-r>=e)break;r++}const o=e+r,l=sR(t,o);return gR(Array.from({length:o}).map((e,t)=>({data:a[t+l],index:t+l,offset:0,size:0})),[],o,i,n,s)}function bR(e,t,n){if(0===e.length)return[];if(!PP(t))return e.map(e=>({...e,index:e.index+n,originalIndex:e.index}));const s=e[0].index,i=e[e.length-1].index,a=[],r=gP(t.groupOffsetTree,s,i);let o,l=0;for(const c of e){let e;(!o||o.end{const x=GL([]),f=GL(0),g=YL();DL(a.topItemsIndexes,x);const v=ZL($L(XL(m,h,eP(l,AP),eP(i),eP(s),eP(c),d,eP(x),eP(t),eP(n),e),zL(([e,t,,n,,,,,,,s])=>{const i=s&&s.length!==n;return e&&!t&&!i}),BL(([,,[e,t],n,s,i,a,r,o,l,c])=>{const d=s,{offsetTree:u,sizeTree:p}=d,m=ML(f);if(0===n)return{...fR,totalCount:n};if(0===e&&0===t)return 0===m?{...fR,totalCount:n}:vR(m,i,s,o,l,c||[]);if(pP(p))return m>0?null:gR(function(e,t,n){if(PP(t)){const s=BP(e,t);return[{index:hP(t.groupOffsetTree,s)[0],offset:0,size:0},{data:null==n?void 0:n[0],index:s,offset:0,size:0}]}return[{data:null==n?void 0:n[0],index:e,offset:0,size:0}]}(sR(i,n),d,c),[],n,l,d,o);const h=[];if(r.length>0){const e=r[0],t=r[r.length-1];let n=0;for(const s of gP(p,e,t)){const i=s.value,a=Math.max(s.start,e),r=Math.min(s.end,t);for(let e=a;e<=r;e++)h.push({data:null==c?void 0:c[e],index:e,offset:n,size:i}),n+=i}}if(!a)return gR([],h,n,l,d,o);const x=r.length>0?r[r.length-1]+1:0,g=$P(u,e,t,x);if(0===g.length)return null;const v=n-1;return gR(kL([],n=>{for(const s of g){const i=s.value;let a=i.offset,r=s.start;const o=i.size;if(i.offset=t);e++)n.push({data:null==c?void 0:c[e],index:e,offset:a,size:o}),a+=o+l}}),h,n,l,d,o)}),zL(e=>null!==e),OL()),fR);DL($L(e,zL(FL),BL(e=>null==e?void 0:e.length)),i),DL($L(v,BL(e=>e.topListHeight)),u),DL(u,o),DL($L(v,BL(e=>[e.top,e.bottom])),r),DL($L(v,BL(e=>e.items)),g);const b=KL($L(v,zL(({items:e})=>e.length>0),qL(i,e),zL(([{items:e},t])=>e[e.length-1].originalIndex===t-1),BL(([,e,t])=>[e-1,t]),OL(AP),BL(([e])=>e))),y=KL($L(v,WL(200),zL(({items:e,topItems:t})=>e.length>0&&e[0].originalIndex===t.length),BL(({items:e})=>e[0].index),OL())),w=KL($L(v,zL(({items:e})=>e.length>0),BL(({items:e})=>{let t=0,n=e.length-1;for(;"group"===e[t].type&&tt;)n--;return{endIndex:e[n].index,startIndex:e[t].index}}),OL(IP)));return{endReached:b,initialItemCount:f,itemsRendered:g,listState:v,rangeChanged:w,startReached:y,topItemsIndexes:x,...p}},EL(YP,JP,xR,iR,tR,cR,QP,TP),{singleton:!0}),wR=JL(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:s},{listState:i}])=>{const a=YL(),r=ZL($L(XL(n,e,s,t,i),BL(([e,t,n,s,i])=>e+t+n+s+i.offsetBottom+i.bottom)),0);return DL(eP(r),a),{totalListHeight:r,totalListHeightChanged:a}},EL(cP,yR),{singleton:!0}),jR=JL(([{viewportHeight:e},{totalListHeight:t}])=>{const n=GL(!1);return{alignToBottom:n,paddingTopAddition:ZL($L(XL(n,e,t),zL(([e])=>e),BL(([,e,t])=>Math.max(0,e-t)),WL(0),OL()),0)}},EL(cP,wR),{singleton:!0}),CR=JL(()=>({context:GL(null)})),NR=({itemBottom:e,itemTop:t,locationParams:{align:n,behavior:s,...i},viewportBottom:a,viewportTop:r})=>ta?{...i,align:null!=n?n:"end",behavior:s}:null,FR=JL(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:s,fixedHeaderHeight:i,headerHeight:a,scrollingInProgress:r,scrollTop:o,viewportHeight:l},{scrollToIndex:c}])=>{const d=YL();return DL($L(d,qL(t,l,n,a,i,s,o),qL(e),BL(([[e,t,n,s,i,a,o,l],c])=>{const{align:d,behavior:u,calculateViewLocation:p=NR,done:m,...h}=e,x=HP(e,t,s-1),f=zP(x,t.offsetTree,c)+i+a,g=p({itemBottom:f+hP(t.sizeTree,x)[1],itemTop:f,locationParams:{align:d,behavior:u,...h},viewportBottom:l+n-o,viewportTop:l+a});return g?m&&LL($L(r,zL(e=>!e),UL(ML(r)?1:2)),m):m&&m(),g}),zL(e=>null!==e)),c),{scrollIntoView:d}},EL(YP,cP,tR,yR,sP),{singleton:!0});function _R(e){return!!e&&("smooth"===e?"smooth":"auto")}const kR=JL(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:s},{atBottomState:i,isAtBottom:a},{scrollToIndex:r},{scrolledToInitialItem:o},{didMount:l,propsReady:c},{log:d},{scrollingInProgress:u},{context:p},{scrollIntoView:m}])=>{const h=GL(!1),x=YL();let f=null;function g(e){AL(r,{align:"end",behavior:e,index:"LAST"})}function v(e){const t=LL(i,t=>{e&&!t.atBottom&&"SIZE_INCREASED"===t.notAtBottomBecause&&!f&&(ML(d)("scrolling to bottom due to increased size",{},nP.DEBUG),g("auto"))});setTimeout(t,100)}IL($L(XL($L(eP(t),UL(1)),l),qL(eP(h),a,o,u),BL(([[e,t],n,s,i,a])=>{let r=t&&i,o="auto";return r&&(o=((e,t)=>"function"==typeof e?_R(e(t)):t&&_R(e))(n,s||a),r=r&&!!o),{followOutputBehavior:o,shouldFollow:r,totalCount:e}}),zL(({shouldFollow:e})=>e)),({followOutputBehavior:t,totalCount:s})=>{f&&(f(),f=null),ML(n)?requestAnimationFrame(()=>{ML(d)("following output to ",{totalCount:s},nP.DEBUG),g(t)}):f=LL(e,()=>{ML(d)("following output to ",{totalCount:s},nP.DEBUG),g(t),f=null})}),IL($L(XL(eP(h),t,c),zL(([e,,t])=>e&&t),VL(({value:e},[,t])=>({refreshed:e===t,value:t}),{refreshed:!1,value:0}),zL(({refreshed:e})=>e),qL(h,t)),([,e])=>{ML(o)&&v(!1!==e)}),IL(x,()=>{v(!1!==ML(h))}),IL(XL(eP(h),i),([e,t])=>{e&&!t.atBottom&&"VIEWPORT_HEIGHT_DECREASING"===t.notAtBottomBecause&&g("auto")});const b=GL(null),y=YL();return DL(tP($L(eP(s),BL(e=>{var t;return null!=(t=null==e?void 0:e.length)?t:0})),$L(eP(t))),y),IL($L(XL($L(y,UL(1)),l),qL(eP(b),o,u,p),BL(([[e,t],n,s,i,a])=>t&&s&&(null==n?void 0:n({context:a,totalCount:e,scrollingInProgress:i}))),zL(e=>!!e),WL(0)),t=>{f&&(f(),f=null),ML(n)?requestAnimationFrame(()=>{ML(d)("scrolling into view",{}),AL(m,t)}):f=LL(e,()=>{ML(d)("scrolling into view",{}),AL(m,t),f=null})}),{autoscrollToBottom:x,followOutput:h,scrollIntoViewOnChange:b}},EL(YP,cR,tR,iR,QP,sP,cP,CR,FR)),SR=JL(([{data:e,firstItemIndex:t,gap:n,sizes:s},{initialTopMostItemIndex:i},{initialItemCount:a,listState:r},{didMount:o}])=>(DL($L(o,qL(a),zL(([,e])=>0!==e),qL(i,s,t,n,e),BL(([[,e],t,n,s,i,a=[]])=>vR(e,t,n,s,i,a))),r),{}),EL(YP,iR,yR,QP),{singleton:!0}),ER=JL(([{didMount:e},{scrollTo:t},{listState:n}])=>{const s=GL(0);return IL($L(e,qL(s),zL(([,e])=>0!==e),BL(([,e])=>({top:e}))),e=>{LL($L(n,UL(1),zL(e=>e.items.length>1)),()=>{requestAnimationFrame(()=>{AL(t,e)})})}),{initialScrollTop:s}},EL(QP,cP,yR),{singleton:!0}),IR=JL(([{scrollVelocity:e}])=>{const t=GL(!1),n=YL(),s=GL(!1);return DL($L(e,qL(s,t,n),zL(([e,t])=>!!t),BL(([e,t,n,s])=>{const{enter:i,exit:a}=t;if(n){if(a(e,s))return!1}else if(i(e,s))return!0;return n}),OL()),t),IL($L(XL(t,e,n),qL(s)),([[e,t,n],s])=>{e&&s&&s.change&&s.change(t,n)}),{isSeeking:t,scrollSeekConfiguration:s,scrollSeekRangeChanged:n,scrollVelocity:e}},EL(cR),{singleton:!0}),AR=JL(([{scrollContainerState:e,scrollTo:t}])=>{const n=YL(),s=YL(),i=YL(),a=GL(!1),r=GL(void 0);return DL($L(XL(n,s),BL(([{scrollHeight:e,scrollTop:t,viewportHeight:n},{offsetTop:s}])=>({scrollHeight:e,scrollTop:Math.max(0,t-s),viewportHeight:n}))),e),DL($L(t,qL(s),BL(([e,{offsetTop:t}])=>({...e,top:e.top+t}))),i),{customScrollParent:r,useWindowScroll:a,windowScrollContainerState:n,windowScrollTo:i,windowViewportRect:s}},EL(cP)),TR=JL(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:s},{initialTopMostItemIndex:i},{didMount:a},{useWindowScroll:r,windowScrollContainerState:o,windowViewportRect:l}])=>{const c=YL(),d=GL(void 0),u=GL(null),p=GL(null);return DL(o,u),DL(l,p),IL($L(c,qL(t,s,r,u,p,n)),([e,t,n,s,i,a,r])=>{const o=function(e){return bP(e).map(({k:e,v:t},n,s)=>{const i=s[n+1];return{endIndex:i?i.k-1:1/0,size:t,startIndex:e}})}(t.sizeTree);s&&null!==i&&null!==a&&(n=i.scrollTop-a.offsetTop),e({ranges:o,scrollTop:n-=r})}),DL($L(d,zL(FL),BL(MR)),i),DL($L(a,qL(d),zL(([,e])=>void 0!==e),OL(),BL(([,e])=>e.ranges)),e),{getState:c,restoreStateFrom:d}},EL(YP,cP,iR,QP,AR));function MR(e){return{align:"start",index:0,offset:e.scrollTop}}const DR=JL(([{topItemsIndexes:e}])=>{const t=GL(0);return DL($L(t,zL(e=>e>=0),BL(e=>Array.from({length:e}).map((e,t)=>t))),e),{topItemCount:t}},EL(yR));function LR(e){let t,n=!1;return()=>(n||(n=!0,t=e()),t)}const PR=LR(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),RR=JL(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:s},{isAtBottom:i,isScrolling:a,lastJumpDueToItemResize:r,scrollDirection:o},{listState:l},{beforeUnshiftWith:c,gap:d,shiftWithOffset:u,sizes:p},{log:m},{recalcInProgress:h}])=>{const x=KL($L(l,qL(r),VL(([,e,t,n],[{bottom:s,items:i,offsetBottom:a,totalCount:r},o])=>{const l=s+a;let c=0;return t===r&&e.length>0&&i.length>0&&(0===i[0].originalIndex&&0===e[0].originalIndex||(c=l-n,0!==c&&(c+=o))),[c,i,r,l]},[0,[],0,0]),zL(([e])=>0!==e),qL(s,o,n,i,m,h),zL(([,e,t,n,,,s])=>!s&&!n&&0!==e&&t===rR),BL(([[e],,,,,t])=>(t("Upward scrolling compensation",{amount:e},nP.DEBUG),e))));function f(n){n>0?(AL(t,{behavior:"auto",top:-n}),AL(e,0)):(AL(e,0),AL(t,{behavior:"auto",top:-n}))}return IL($L(x,qL(e,a)),([t,n,s])=>{s&&PR()?AL(e,n-t):f(-t)}),IL($L(XL(ZL(a,!1),e,h),zL(([e,t,n])=>!e&&!n&&0!==t),BL(([e,t])=>t),WL(1)),f),DL($L(u,BL(e=>({top:-e}))),t),IL($L(c,qL(p,d),BL(([e,{groupIndices:t,lastSize:n,sizeTree:s},i])=>{function a(e){return e*(n+i)}if(0===t.length)return a(e);{let n=0;const i=mP(s,0);let r=0,o=0;for(;re&&(n-=i,s=e-r+1),r+=s,n+=a(s),o++}return n}})),n=>{AL(e,n),requestAnimationFrame(()=>{AL(t,{top:n}),requestAnimationFrame(()=>{AL(e,0),AL(h,!1)})})}),{deviation:e}},EL(cP,cR,yR,YP,sP,TP)),OR=JL(([e,t,n,s,i,a,r,o,l,c,d])=>({...e,...t,...n,...s,...i,...a,...r,...o,...l,...c,...d}),EL(xR,SR,QP,IR,wR,ER,jR,AR,FR,sP,CR)),zR=JL(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:s,gap:i,groupIndices:a,itemSize:r,sizeRanges:o,sizes:l,statefulTotalCount:c,totalCount:d,trackItemSizes:u},{initialItemFinalLocationReached:p,initialTopMostItemIndex:m,scrolledToInitialItem:h},x,f,g,{listState:v,topItemsIndexes:b,...y},{scrollToIndex:w},j,{topItemCount:C},{groupCounts:N},F])=>(DL(y.rangeChanged,F.scrollSeekRangeChanged),DL($L(F.windowViewportRect,BL(e=>e.visibleHeight)),x.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:s,gap:i,groupCounts:N,initialItemFinalLocationReached:p,initialTopMostItemIndex:m,scrolledToInitialItem:h,sizeRanges:o,topItemCount:C,topItemsIndexes:b,totalCount:d,...g,groupIndices:a,itemSize:r,listState:v,scrollToIndex:w,statefulTotalCount:c,trackItemSizes:u,...y,...F,...x,sizes:l,...f}),EL(YP,iR,cP,TR,kR,yR,tR,RR,DR,JP,OR));function BR(e,t){const n={},s={};let i=0;const a=e.length;for(;i(n[s]=function(e){let t,n;const s=()=>null==t?void 0:t();return function(i,a){switch(i){case 1:return a?n===a?void 0:(s(),n=a,t=IL(e,a),t):(s(),_L);case 2:return s(),void(n=null)}}}(e[t.events[s]]),n),{})}const u=ze.forwardRef((u,p)=>{const{children:m,...h}=u,[x]=ze.useState(()=>kL(function(e){const t=new Map,n=({constructor:e,dependencies:s,id:i,singleton:a})=>{if(a&&t.has(i))return t.get(i);const r=e(s.map(e=>n(e)));return a&&t.set(i,r),r};return n(e)}(e),e=>{c(e,h)})),[f]=ze.useState(NL(d,x));HR(()=>{for(const e of o)e in h&&IL(f[e],h[e]);return()=>{Object.values(f).map(TL)}},[h,f,x]),HR(()=>{c(x,h)}),ze.useImperativeHandle(p,wL(function(e){return r.reduce((n,s)=>(n[s]=n=>{AL(e[t.methods[s]],n)},n),{})}(x)));const g=n;return a.jsx(l.Provider,{value:x,children:n?a.jsx(g,{...BR([...s,...i,...o],h),children:m}):m})});return{Component:u,useEmitter:(e,t)=>{const n=ze.useContext(l)[e];HR(()=>IL(n,t),[t,n])},useEmitterValue:ze.version.startsWith("18")?e=>{const t=ze.useContext(l)[e],n=ze.useCallback(e=>IL(t,e),[t]);return ze.useSyncExternalStore(n,()=>ML(t),()=>ML(t))}:e=>{const t=ze.useContext(l)[e],[n,s]=ze.useState(NL(ML,t));return HR(()=>IL(t,e=>{e!==n&&s(wL(e))}),[t,n]),n},usePublisher:e=>{const t=ze.useContext(l);return ze.useCallback(n=>{AL(t[e],n)},[t,e])}}}const VR=ze.createContext(void 0),UR=ze.createContext(void 0),WR=typeof document<"u"?ze.useLayoutEffect:ze.useEffect;function qR(e){return"self"in e}function GR(e,t,n,s=_L,i,a){const r=ze.useRef(null),o=ze.useRef(null),l=ze.useRef(null),c=ze.useCallback(n=>{let s,i,r;const c=n.target;if(function(e){return"body"in e}(c)||qR(c)){const e=qR(c)?c:c.defaultView;r=a?e.scrollX:e.scrollY,s=a?e.document.documentElement.scrollWidth:e.document.documentElement.scrollHeight,i=a?e.innerWidth:e.innerHeight}else r=a?c.scrollLeft:c.scrollTop,s=a?c.scrollWidth:c.scrollHeight,i=a?c.offsetWidth:c.offsetHeight;const d=()=>{e({scrollHeight:s,scrollTop:Math.max(r,0),viewportHeight:i})};n.suppressFlushSync?d():Ve.flushSync(d),null!==o.current&&(r===o.current||r<=0||r===s-i)&&(o.current=null,t(!0),l.current&&(clearTimeout(l.current),l.current=null))},[e,t,a]);return ze.useEffect(()=>{const e=i||r.current;return s(i||r.current),c({suppressFlushSync:!0,target:e}),e.addEventListener("scroll",c,{passive:!0}),()=>{s(null),e.removeEventListener("scroll",c)}},[r,c,n,s,i]),{scrollByCallback:function(e){a&&(e={behavior:e.behavior,left:e.top}),r.current.scrollBy(e)},scrollerRef:r,scrollToCallback:function(n){const s=r.current;if(!s||(a?"offsetWidth"in s&&0===s.offsetWidth:"offsetHeight"in s&&0===s.offsetHeight))return;const i="smooth"===n.behavior;let c,d,u;qR(s)?(d=Math.max(LP(s.document.documentElement,a?"width":"height"),a?s.document.documentElement.scrollWidth:s.document.documentElement.scrollHeight),c=a?s.innerWidth:s.innerHeight,u=a?window.scrollX:window.scrollY):(d=s[a?"scrollWidth":"scrollHeight"],c=LP(s,a?"width":"height"),u=s[a?"scrollLeft":"scrollTop"]);const p=d-c;if(n.top=Math.ceil(Math.max(Math.min(p,n.top),0)),aR(c,d)||n.top===u)return e({scrollHeight:d,scrollTop:u,viewportHeight:c}),void(i&&t(!0));i?(o.current=n.top,l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{l.current=null,o.current=null,t(!0)},1e3)):o.current=null,a&&(n={behavior:n.behavior,left:n.top}),s.scrollTo(n)}}}const ZR="-webkit-sticky",YR="sticky",KR=LR(()=>{if(typeof document>"u")return YR;const e=document.createElement("div");return e.style.position=ZR,e.style.position===ZR?ZR:YR});function JR(e){return e}const QR=JL(()=>{const e=GL(e=>`Item ${e}`),t=GL(e=>`Group ${e}`),n=GL({}),s=GL(JR),i=GL("div"),a=GL(_L),r=(e,t=null)=>ZL($L(n,BL(t=>t[e]),OL()),t);return{components:n,computeItemKey:s,EmptyPlaceholder:r("EmptyPlaceholder"),FooterComponent:r("Footer"),GroupComponent:r("Group","div"),groupContent:t,HeaderComponent:r("Header"),HeaderFooterTag:i,ItemComponent:r("Item","div"),itemContent:e,ListComponent:r("List","div"),ScrollerComponent:r("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:r("ScrollSeekPlaceholder"),TopItemListComponent:r("TopItemList")}}),XR=JL(([e,t])=>({...e,...t}),EL(zR,QR)),eO=({height:e})=>a.jsx("div",{style:{height:e}}),tO={overflowAnchor:"none",position:KR(),zIndex:1},nO={overflowAnchor:"none"},sO={...nO,display:"inline-block",height:"100%"},iO=ze.memo(function({showTopList:e=!1}){const t=wO("listState"),n=jO("sizeRanges"),s=wO("useWindowScroll"),i=wO("customScrollParent"),r=jO("windowScrollContainerState"),o=jO("scrollContainerState"),l=i||s?r:o,c=wO("itemContent"),d=wO("context"),u=wO("groupContent"),p=wO("trackItemSizes"),m=wO("itemSize"),h=wO("log"),x=jO("gap"),f=wO("horizontalDirection"),{callbackRef:g}=rP(n,m,p,e?_L:l,h,x,i,f,wO("skipAnimationFrameInResizeObserver")),[v,b]=ze.useState(0);yO("deviation",e=>{v!==e&&b(e)});const y=wO("EmptyPlaceholder"),w=wO("ScrollSeekPlaceholder")||eO,j=wO("ListComponent"),C=wO("ItemComponent"),N=wO("GroupComponent"),F=wO("computeItemKey"),_=wO("isSeeking"),k=wO("groupIndices").length>0,S=wO("alignToBottom"),E=wO("initialItemFinalLocationReached"),I=e?{}:{boxSizing:"border-box",...f?{display:"inline-block",height:"100%",marginLeft:0!==v?v:S?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:0!==v?v:S?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...E?{}:{visibility:"hidden"}};return!e&&0===t.totalCount&&y?a.jsx(y,{...cO(y,d)}):a.jsx(j,{...cO(j,d),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:g,style:I,children:(e?t.topItems:t.items).map(e=>{const n=e.originalIndex,s=F(n+t.firstItemIndex,e.data,d);return _?Pe.createElement(w,{...cO(w,d),height:e.size,index:e.index,key:s,type:e.type||"item",..."group"===e.type?{}:{groupIndex:e.groupIndex}}):"group"===e.type?Pe.createElement(N,{...cO(N,d),"data-index":n,"data-item-index":e.index,"data-known-size":e.size,key:s,style:tO},u(e.index,d)):Pe.createElement(C,{...cO(C,d),...dO(C,e.data),"data-index":n,"data-item-group-index":e.groupIndex,"data-item-index":e.index,"data-known-size":e.size,key:s,style:f?sO:nO},k?c(e.index,e.groupIndex,e.data,d):c(e.index,e.data,d))})})}),aO={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},rO={outline:"none",overflowX:"auto",position:"relative"},oO=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),lO={position:KR(),top:0,width:"100%",zIndex:1};function cO(e,t){if("string"!=typeof e)return{context:t}}function dO(e,t){return{item:"string"==typeof e?void 0:t}}const uO=ze.memo(function(){const e=wO("HeaderComponent"),t=jO("headerHeight"),n=wO("HeaderFooterTag"),s=iP(ze.useMemo(()=>e=>{t(LP(e,"height"))},[t]),!0,wO("skipAnimationFrameInResizeObserver")),i=wO("context");return e?a.jsx(n,{ref:s,children:a.jsx(e,{...cO(e,i)})}):null}),pO=ze.memo(function(){const e=wO("FooterComponent"),t=jO("footerHeight"),n=wO("HeaderFooterTag"),s=iP(ze.useMemo(()=>e=>{t(LP(e,"height"))},[t]),!0,wO("skipAnimationFrameInResizeObserver")),i=wO("context");return e?a.jsx(n,{ref:s,children:a.jsx(e,{...cO(e,i)})}):null});function mO({useEmitter:e,useEmitterValue:t,usePublisher:n}){return ze.memo(function({children:s,style:i,context:r,...o}){const l=n("scrollContainerState"),c=t("ScrollerComponent"),d=n("smoothScrollTargetReached"),u=t("scrollerRef"),p=t("horizontalDirection")||!1,{scrollByCallback:m,scrollerRef:h,scrollToCallback:x}=GR(l,d,c,u,void 0,p);return e("scrollTo",x),e("scrollBy",m),a.jsx(c,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:h,style:{...p?rO:aO,...i},tabIndex:0,...o,...cO(c,r),children:s})})}function hO({useEmitter:e,useEmitterValue:t,usePublisher:n}){return ze.memo(function({children:s,style:i,context:r,...o}){const l=n("windowScrollContainerState"),c=t("ScrollerComponent"),d=n("smoothScrollTargetReached"),u=t("totalListHeight"),p=t("deviation"),m=t("customScrollParent"),h=ze.useRef(null),x=t("scrollerRef"),{scrollByCallback:f,scrollerRef:g,scrollToCallback:v}=GR(l,d,c,x,m);return WR(()=>{var e;return g.current=m||(null==(e=h.current)?void 0:e.ownerDocument.defaultView),()=>{g.current=null}},[g,m]),e("windowScrollTo",v),e("scrollBy",f),a.jsx(c,{ref:h,"data-virtuoso-scroller":!0,style:{position:"relative",...i,...0!==u?{height:u+p}:{}},...o,...cO(c,r),children:s})})}const xO=({children:e})=>{const t=ze.useContext(VR),n=jO("viewportHeight"),s=jO("fixedItemHeight"),i=wO("alignToBottom"),r=wO("horizontalDirection"),o=iP(ze.useMemo(()=>CL(n,e=>LP(e,r?"width":"height")),[n,r]),!0,wO("skipAnimationFrameInResizeObserver"));return ze.useEffect(()=>{t&&(n(t.viewportHeight),s(t.itemHeight))},[t,n,s]),a.jsx("div",{"data-viewport-type":"element",ref:o,style:oO(i),children:e})},fO=({children:e})=>{const t=ze.useContext(VR),n=jO("windowViewportRect"),s=jO("fixedItemHeight"),i=wO("customScrollParent"),r=lP(n,i,wO("skipAnimationFrameInResizeObserver")),o=wO("alignToBottom");return ze.useEffect(()=>{t&&(s(t.itemHeight),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,s]),a.jsx("div",{"data-viewport-type":"window",ref:r,style:oO(o),children:e})},gO=({children:e})=>{const t=wO("TopItemListComponent")||"div",n=wO("headerHeight"),s={...lO,marginTop:`${n}px`},i=wO("context");return a.jsx(t,{style:s,...cO(t,i),children:e})},vO=ze.memo(function(e){const t=wO("useWindowScroll"),n=wO("topItemsIndexes").length>0,s=wO("customScrollParent"),i=wO("context");return a.jsxs(s||t?NO:CO,{...e,context:i,children:[n&&a.jsx(gO,{children:a.jsx(iO,{showTopList:!0})}),a.jsxs(s||t?fO:xO,{children:[a.jsx(uO,{}),a.jsx(iO,{}),a.jsx(pO,{})]})]})}),{Component:bO,useEmitter:yO,useEmitterValue:wO,usePublisher:jO}=$R(XR,{required:{},optional:{restoreStateFrom:"restoreStateFrom",context:"context",followOutput:"followOutput",scrollIntoViewOnChange:"scrollIntoViewOnChange",itemContent:"itemContent",groupContent:"groupContent",overscan:"overscan",increaseViewportBy:"increaseViewportBy",totalCount:"totalCount",groupCounts:"groupCounts",topItemCount:"topItemCount",firstItemIndex:"firstItemIndex",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",atBottomThreshold:"atBottomThreshold",atTopThreshold:"atTopThreshold",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedItemHeight:"fixedItemHeight",itemSize:"itemSize",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"HeaderFooterTag",data:"data",initialItemCount:"initialItemCount",initialScrollTop:"initialScrollTop",alignToBottom:"alignToBottom",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",horizontalDirection:"horizontalDirection",skipAnimationFrameInResizeObserver:"skipAnimationFrameInResizeObserver"},methods:{scrollToIndex:"scrollToIndex",scrollIntoView:"scrollIntoView",scrollTo:"scrollTo",scrollBy:"scrollBy",autoscrollToBottom:"autoscrollToBottom",getState:"getState"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",totalListHeightChanged:"totalListHeightChanged",itemsRendered:"itemsRendered",groupIndices:"groupIndices"}},vO),CO=mO({useEmitter:yO,useEmitterValue:wO,usePublisher:jO}),NO=hO({useEmitter:yO,useEmitterValue:wO,usePublisher:jO}),FO=bO,_O=JL(()=>{const e=GL(e=>a.jsxs("td",{children:["Item $",e]})),t=GL(null),n=GL(e=>a.jsxs("td",{colSpan:1e3,children:["Group ",e]})),s=GL(null),i=GL(null),r=GL({}),o=GL(JR),l=GL(_L),c=(e,t=null)=>ZL($L(r,BL(t=>t[e]),OL()),t);return{components:r,computeItemKey:o,context:t,EmptyPlaceholder:c("EmptyPlaceholder"),FillerRow:c("FillerRow"),fixedFooterContent:i,fixedHeaderContent:s,itemContent:e,groupContent:n,ScrollerComponent:c("Scroller","div"),scrollerRef:l,ScrollSeekPlaceholder:c("ScrollSeekPlaceholder"),TableBodyComponent:c("TableBody","tbody"),TableComponent:c("Table","table"),TableFooterComponent:c("TableFoot","tfoot"),TableHeadComponent:c("TableHead","thead"),TableRowComponent:c("TableRow","tr"),GroupComponent:c("Group","tr")}});EL(zR,_O),KR();const kO={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},SO={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:EO,floor:IO,max:AO,min:TO,round:MO}=Math;function DO(e,t,n){return Array.from({length:t-e+1}).map((t,s)=>({data:null===n?null:n[s+e],index:s+e}))}function LO(e,t){return e&&e.width===t.width&&e.height===t.height}function PO(e,t){return e&&e.column===t.column&&e.row===t.row}const RO=JL(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:s},{footerHeight:i,headerHeight:a,scrollBy:r,scrollContainerState:o,scrollTo:l,scrollTop:c,smoothScrollTargetReached:d,viewportHeight:u},p,m,{didMount:h,propsReady:x},{customScrollParent:f,useWindowScroll:g,windowScrollContainerState:v,windowScrollTo:b,windowViewportRect:y},w])=>{const j=GL(0),C=GL(0),N=GL(kO),F=GL({height:0,width:0}),_=GL({height:0,width:0}),k=YL(),S=YL(),E=GL(0),I=GL(null),A=GL({column:0,row:0}),T=YL(),M=YL(),D=GL(!1),L=GL(0),P=GL(!0),R=GL(!1),O=GL(!1);IL($L(h,qL(L),zL(([e,t])=>!!t)),()=>{AL(P,!1)}),IL($L(XL(h,P,_,F,L,R),zL(([e,t,n,s,,i])=>e&&!t&&0!==n.height&&0!==s.height&&!i)),([,,,,e])=>{AL(R,!0),nR(1,()=>{AL(k,e)}),LL($L(c),()=>{AL(t,[0,0]),AL(P,!0)})}),DL($L(M,zL(e=>null!=e&&e.scrollTop>0),HL(0)),C),IL($L(h,qL(M),zL(([,e])=>null!=e)),([,e])=>{e&&(AL(F,e.viewport),AL(_,e.item),AL(A,e.gap),e.scrollTop>0&&(AL(D,!0),LL($L(c,UL(1)),e=>{AL(D,!1)}),AL(l,{top:e.scrollTop})))}),DL($L(F,BL(({height:e})=>e)),u),DL($L(XL(eP(F,LO),eP(_,LO),eP(A,(e,t)=>e&&e.column===t.column&&e.row===t.row),eP(c)),BL(([e,t,n,s])=>({gap:n,item:t,scrollTop:s,viewport:e}))),T),DL($L(XL(eP(j),s,eP(A,PO),eP(_,LO),eP(F,LO),eP(I),eP(C),eP(D),eP(P),eP(L)),zL(([,,,,,,,e])=>!e),BL(([e,[t,n],s,i,a,r,o,,l,c])=>{const{column:d,row:u}=s,{height:p,width:m}=i,{width:h}=a;if(0===o&&(0===e||0===h))return kO;if(0===m){const t=sR(c,e);return function(e){return{...SO,items:e}}(DO(t,t+Math.max(o-1,0),r))}const x=OO(h,m,d);let f,g;l?0===t&&0===n&&o>0?(f=0,g=o-1):(f=x*IO((t+u)/(p+u)),g=x*EO((n+u)/(p+u))-1,g=TO(e-1,AO(g,x-1)),f=TO(g,AO(0,f))):(f=0,g=-1);const v=DO(f,g,r),{bottom:b,top:y}=zO(a,s,i,v),w=EO(e/x);return{bottom:b,itemHeight:p,items:v,itemWidth:m,offsetBottom:w*p+(w-1)*u-b,offsetTop:y,top:y}})),N),DL($L(I,zL(e=>null!==e),BL(e=>e.length)),j),DL($L(XL(F,_,N,A),zL(([e,t,{items:n}])=>n.length>0&&0!==t.height&&0!==e.height),BL(([e,t,{items:n},s])=>{const{bottom:i,top:a}=zO(e,s,t,n);return[a,i]}),OL(AP)),t);const z=GL(!1);DL($L(c,qL(z),BL(([e,t])=>t||0!==e)),z);const B=KL($L(XL(N,j),zL(([{items:e}])=>e.length>0),qL(z),zL(([[e,t],n])=>{const s=e.items[e.items.length-1].index===t-1;return(n||e.bottom>0&&e.itemHeight>0&&0===e.offsetBottom&&e.items.length===t)&&s}),BL(([[,e]])=>e-1),OL())),H=KL($L(eP(N),zL(({items:e})=>e.length>0&&0===e[0].index),HL(0),OL())),$=KL($L(eP(N),qL(D),zL(([{items:e},t])=>e.length>0&&!t),BL(([{items:e}])=>({endIndex:e[e.length-1].index,startIndex:e[0].index})),OL(IP),WL(0)));DL($,m.scrollSeekRangeChanged),DL($L(k,qL(F,_,j,A),BL(([e,t,n,s,i])=>{const a=eR(e),{align:r,behavior:o,offset:l}=a;let c=a.index;"LAST"===c&&(c=s-1),c=AO(0,c,TO(s-1,c));let d=BO(t,i,n,c);return"end"===r?d=MO(d-t.height+n.height):"center"===r&&(d=MO(d-t.height/2+n.height/2)),l&&(d+=l),{behavior:o,top:d}})),l);const V=ZL($L(N,BL(e=>e.offsetBottom+e.bottom)),0);return DL($L(y,BL(e=>({height:e.visibleHeight,width:e.visibleWidth}))),F),{customScrollParent:f,data:I,deviation:E,footerHeight:i,gap:A,headerHeight:a,increaseViewportBy:e,initialItemCount:C,itemDimensions:_,overscan:n,restoreStateFrom:M,scrollBy:r,scrollContainerState:o,scrollHeight:S,scrollTo:l,scrollToIndex:k,scrollTop:c,smoothScrollTargetReached:d,totalCount:j,useWindowScroll:g,viewportDimensions:F,windowScrollContainerState:v,windowScrollTo:b,windowViewportRect:y,...m,gridState:N,horizontalDirection:O,initialTopMostItemIndex:L,totalListHeight:V,...p,endReached:B,propsReady:x,rangeChanged:$,startReached:H,stateChanged:T,stateRestoreInProgress:D,...w}},EL(xR,cP,cR,IR,QP,AR,sP));function OO(e,t,n){return AO(1,IO((e+n)/(IO(t)+n)))}function zO(e,t,n,s){const{height:i}=n;if(void 0===i||0===s.length)return{bottom:0,top:0};const a=BO(e,t,n,s[0].index);return{bottom:BO(e,t,n,s[s.length-1].index)+i,top:a}}function BO(e,t,n,s){const i=OO(e.width,n.width,t.column),a=IO(s/i),r=a*n.height+AO(0,a-1)*t.row;return r>0?r+t.row:r}const HO=JL(()=>{const e=GL(e=>`Item ${e}`),t=GL({}),n=GL(null),s=GL("virtuoso-grid-item"),i=GL("virtuoso-grid-list"),a=GL(JR),r=GL("div"),o=GL(_L),l=(e,n=null)=>ZL($L(t,BL(t=>t[e]),OL()),n),c=GL(!1),d=GL(!1);return DL(eP(d),c),{components:t,computeItemKey:a,context:n,FooterComponent:l("Footer"),HeaderComponent:l("Header"),headerFooterTag:r,itemClassName:s,ItemComponent:l("Item","div"),itemContent:e,listClassName:i,ListComponent:l("List","div"),readyStateChanged:c,reportReadyState:d,ScrollerComponent:l("Scroller","div"),scrollerRef:o,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder","div")}}),$O=JL(([e,t])=>({...e,...t}),EL(RO,HO)),VO=ze.memo(function(){const e=KO("gridState"),t=KO("listClassName"),n=KO("itemClassName"),s=KO("itemContent"),i=KO("computeItemKey"),r=KO("isSeeking"),o=JO("scrollHeight"),l=KO("ItemComponent"),c=KO("ListComponent"),d=KO("ScrollSeekPlaceholder"),u=KO("context"),p=JO("itemDimensions"),m=JO("gap"),h=KO("log"),x=KO("stateRestoreInProgress"),f=JO("reportReadyState"),g=iP(ze.useMemo(()=>e=>{const t=e.parentElement.parentElement.scrollHeight;o(t);const n=e.firstChild;if(n){const{height:e,width:t}=n.getBoundingClientRect();p({height:e,width:t})}m({column:ez("column-gap",getComputedStyle(e).columnGap,h),row:ez("row-gap",getComputedStyle(e).rowGap,h)})},[o,p,m,h]),!0,!1);return WR(()=>{e.itemHeight>0&&e.itemWidth>0&&f(!0)},[e]),x?null:a.jsx(c,{className:t,ref:g,...cO(c,u),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(t=>{const o=i(t.index,t.data,u);return r?a.jsx(d,{...cO(d,u),height:e.itemHeight,index:t.index,width:e.itemWidth},o):Pe.createElement(l,{...cO(l,u),className:n,"data-index":t.index,key:o},s(t.index,t.data,u))})})}),UO=ze.memo(function(){const e=KO("HeaderComponent"),t=JO("headerHeight"),n=KO("headerFooterTag"),s=iP(ze.useMemo(()=>e=>{t(LP(e,"height"))},[t]),!0,!1),i=KO("context");return e?a.jsx(n,{ref:s,children:a.jsx(e,{...cO(e,i)})}):null}),WO=ze.memo(function(){const e=KO("FooterComponent"),t=JO("footerHeight"),n=KO("headerFooterTag"),s=iP(ze.useMemo(()=>e=>{t(LP(e,"height"))},[t]),!0,!1),i=KO("context");return e?a.jsx(n,{ref:s,children:a.jsx(e,{...cO(e,i)})}):null}),qO=({children:e})=>{const t=ze.useContext(UR),n=JO("itemDimensions"),s=JO("viewportDimensions"),i=iP(ze.useMemo(()=>e=>{s(e.getBoundingClientRect())},[s]),!0,!1);return ze.useEffect(()=>{t&&(s({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,s,n]),a.jsx("div",{ref:i,style:oO(!1),children:e})},GO=({children:e})=>{const t=ze.useContext(UR),n=JO("windowViewportRect"),s=JO("itemDimensions"),i=KO("customScrollParent"),r=lP(n,i,!1);return ze.useEffect(()=>{t&&(s({height:t.itemHeight,width:t.itemWidth}),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,s]),a.jsx("div",{ref:r,style:oO(!1),children:e})},ZO=ze.memo(function({...e}){const t=KO("useWindowScroll"),n=KO("customScrollParent"),s=n||t?XO:QO,i=n||t?GO:qO,r=KO("context");return a.jsx(s,{...e,...cO(s,r),children:a.jsxs(i,{children:[a.jsx(UO,{}),a.jsx(VO,{}),a.jsx(WO,{})]})})}),{useEmitter:YO,useEmitterValue:KO,usePublisher:JO}=$R($O,{optional:{context:"context",totalCount:"totalCount",overscan:"overscan",itemContent:"itemContent",components:"components",computeItemKey:"computeItemKey",data:"data",initialItemCount:"initialItemCount",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"headerFooterTag",listClassName:"listClassName",itemClassName:"itemClassName",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",restoreStateFrom:"restoreStateFrom",initialTopMostItemIndex:"initialTopMostItemIndex",increaseViewportBy:"increaseViewportBy"},methods:{scrollTo:"scrollTo",scrollBy:"scrollBy",scrollToIndex:"scrollToIndex"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",stateChanged:"stateChanged",readyStateChanged:"readyStateChanged"}},ZO),QO=mO({useEmitter:YO,useEmitterValue:KO,usePublisher:JO}),XO=hO({useEmitter:YO,useEmitterValue:KO,usePublisher:JO});function ez(e,t,n){return"normal"!==t&&!(null!=t&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,nP.WARN),"normal"===t?0:parseInt(null!=t?t:"0",10)}class tz extends Pe.Component{constructor(){super(...arguments),i(this,"state",{hasError:!1,error:null}),i(this,"handleRetry",()=>{this.setState({hasError:!1,error:null}),window.location.reload()})}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){vg(e,{errorInfo:t.componentStack,context:"error_boundary"})}render(){var e;return this.state.hasError?a.jsx("div",{className:"flex flex-col items-center justify-center min-h-screen p-4",children:a.jsxs("div",{className:"max-w-md text-center",children:[a.jsx("h2",{className:"text-2xl font-bold mb-4",children:"Something went wrong"}),a.jsx("p",{className:"text-gray-500 mb-6",children:(null==(e=this.state.error)?void 0:e.message)||"An unexpected error occurred"}),a.jsx(Nb,{onClick:this.handleRetry,children:"Try again"})]})}):this.props.children}}var nz,sz="vercel.ai.error",iz=Symbol.for(sz),az=class e extends Error{constructor({name:e,message:t,cause:n}){super(t),this[nz]=!0,this.name=e,this.cause=n}static isInstance(t){return e.hasMarker(t,sz)}static hasMarker(e,t){const n=Symbol.for(t);return null!=e&&"object"==typeof e&&n in e&&"boolean"==typeof e[n]&&!0===e[n]}};nz=iz;var rz=az;function oz(e){return null==e?"unknown error":"string"==typeof e?e:e instanceof Error?e.message:JSON.stringify(e)}var lz,cz="AI_InvalidArgumentError",dz=`vercel.ai.error.${cz}`,uz=Symbol.for(dz),pz=class extends rz{constructor({message:e,cause:t,argument:n}){super({name:cz,message:e,cause:t}),this[lz]=!0,this.argument=n}static isInstance(e){return rz.hasMarker(e,dz)}};lz=uz;var mz,hz="AI_JSONParseError",xz=`vercel.ai.error.${hz}`,fz=Symbol.for(xz),gz=class extends rz{constructor({text:e,cause:t}){super({name:hz,message:`JSON parsing failed: Text: ${e}.\nError message: ${oz(t)}`,cause:t}),this[mz]=!0,this.text=e}static isInstance(e){return rz.hasMarker(e,xz)}};mz=fz;var vz,bz="AI_TypeValidationError",yz=`vercel.ai.error.${bz}`,wz=Symbol.for(yz);vz=wz;var jz=class e extends rz{constructor({value:e,cause:t}){super({name:bz,message:`Type validation failed: Value: ${JSON.stringify(e)}.\nError message: ${oz(t)}`,cause:t}),this[vz]=!0,this.value=e}static isInstance(e){return rz.hasMarker(e,yz)}static wrap({value:t,cause:n}){return e.isInstance(n)&&n.value===t?n:new e({value:t,cause:n})}};var Cz,Nz={exports:{}};const Fz=Le(function(){if(Cz)return Nz.exports;Cz=1;const e="undefined"!=typeof Buffer,t=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,n=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;function s(s,a,r){null==r&&null!==a&&"object"==typeof a&&(r=a,a=void 0),e&&Buffer.isBuffer(s)&&(s=s.toString()),s&&65279===s.charCodeAt(0)&&(s=s.slice(1));const o=JSON.parse(s,a);if(null===o||"object"!=typeof o)return o;const l=r&&r.protoAction||"error",c=r&&r.constructorAction||"error";if("ignore"===l&&"ignore"===c)return o;if("ignore"!==l&&"ignore"!==c){if(!1===t.test(s)&&!1===n.test(s))return o}else if("ignore"!==l&&"ignore"===c){if(!1===t.test(s))return o}else if(!1===n.test(s))return o;return i(o,{protoAction:l,constructorAction:c,safe:r&&r.safe})}function i(e,{protoAction:t="error",constructorAction:n="error",safe:s}={}){let i=[e];for(;i.length;){const e=i;i=[];for(const a of e){if("ignore"!==t&&Object.prototype.hasOwnProperty.call(a,"__proto__")){if(!0===s)return null;if("error"===t)throw new SyntaxError("Object contains forbidden prototype property");delete a.__proto__}if("ignore"!==n&&Object.prototype.hasOwnProperty.call(a,"constructor")&&Object.prototype.hasOwnProperty.call(a.constructor,"prototype")){if(!0===s)return null;if("error"===n)throw new SyntaxError("Object contains forbidden prototype property");delete a.constructor}for(const e in a){const t=a[e];t&&"object"==typeof t&&i.push(t)}}}return e}function a(e,t,n){const i=Error.stackTraceLimit;Error.stackTraceLimit=0;try{return s(e,t,n)}finally{Error.stackTraceLimit=i}}return Nz.exports=a,Nz.exports.default=a,Nz.exports.parse=a,Nz.exports.safeParse=function(e,t){const n=Error.stackTraceLimit;Error.stackTraceLimit=0;try{return s(e,t,{safe:!0})}catch(i){return null}finally{Error.stackTraceLimit=n}},Nz.exports.scan=i,Nz.exports}());var _z=(({prefix:e,size:t=16,alphabet:n="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",separator:s="-"}={})=>{const i=((e,t=21)=>(n=t)=>{let s="",i=0|n;for(;i--;)s+=e[Math.random()*e.length|0];return s})(n,t);if(null==e)return i;if(n.includes(s))throw new pz({argument:"separator",message:`The separator "${s}" must not be part of the alphabet "${n}".`});return t=>`${e}${s}${i(t)}`})(),kz=Symbol.for("vercel.ai.validator");function Sz(e){return function(e){return"object"==typeof e&&null!==e&&kz in e&&!0===e[kz]&&"validate"in e}(e)?e:(t=e,n=e=>{const n=t.safeParse(e);return n.success?{success:!0,value:n.data}:{success:!1,error:n.error}},{[kz]:!0,validate:n});var t,n}function Ez({text:e,schema:t}){try{const n=Fz.parse(e);if(null==t)return{success:!0,value:n,rawValue:n};const s=function({value:e,schema:t}){const n=Sz(t);try{if(null==n.validate)return{success:!0,value:e};const t=n.validate(e);return t.success?t:{success:!1,error:jz.wrap({value:e,cause:t.error})}}catch(s){return{success:!1,error:jz.wrap({value:e,cause:s})}}}({value:n,schema:t});return s.success?{...s,rawValue:n}:s}catch(n){return{success:!1,error:gz.isInstance(n)?n:new gz({text:e,cause:n})}}}new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");var Iz={code:"0",name:"text",parse:e=>{if("string"!=typeof e)throw new Error('"text" parts expect a string value.');return{type:"text",value:e}}},Az={code:"3",name:"error",parse:e=>{if("string"!=typeof e)throw new Error('"error" parts expect a string value.');return{type:"error",value:e}}},Tz={code:"4",name:"assistant_message",parse:e=>{if(!(null!=e&&"object"==typeof e&&"id"in e&&"role"in e&&"content"in e&&"string"==typeof e.id&&"string"==typeof e.role&&"assistant"===e.role&&Array.isArray(e.content)&&e.content.every(e=>null!=e&&"object"==typeof e&&"type"in e&&"text"===e.type&&"text"in e&&null!=e.text&&"object"==typeof e.text&&"value"in e.text&&"string"==typeof e.text.value)))throw new Error('"assistant_message" parts expect an object with an "id", "role", and "content" property.');return{type:"assistant_message",value:e}}},Mz={code:"5",name:"assistant_control_data",parse:e=>{if(null==e||"object"!=typeof e||!("threadId"in e)||!("messageId"in e)||"string"!=typeof e.threadId||"string"!=typeof e.messageId)throw new Error('"assistant_control_data" parts expect an object with a "threadId" and "messageId" property.');return{type:"assistant_control_data",value:{threadId:e.threadId,messageId:e.messageId}}}},Dz={code:"6",name:"data_message",parse:e=>{if(null==e||"object"!=typeof e||!("role"in e)||!("data"in e)||"string"!=typeof e.role||"data"!==e.role)throw new Error('"data_message" parts expect an object with a "role" and "data" property.');return{type:"data_message",value:e}}};function Lz(e){const t=["ROOT"];let n=-1,s=null;function i(e,i,a){switch(e){case'"':n=i,t.pop(),t.push(a),t.push("INSIDE_STRING");break;case"f":case"t":case"n":n=i,s=i,t.pop(),t.push(a),t.push("INSIDE_LITERAL");break;case"-":t.pop(),t.push(a),t.push("INSIDE_NUMBER");break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":n=i,t.pop(),t.push(a),t.push("INSIDE_NUMBER");break;case"{":n=i,t.pop(),t.push(a),t.push("INSIDE_OBJECT_START");break;case"[":n=i,t.pop(),t.push(a),t.push("INSIDE_ARRAY_START")}}function a(e,s){switch(e){case",":t.pop(),t.push("INSIDE_OBJECT_AFTER_COMMA");break;case"}":n=s,t.pop()}}function r(e,s){switch(e){case",":t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break;case"]":n=s,t.pop()}}for(let l=0;l=0;l--){switch(t[l]){case"INSIDE_STRING":o+='"';break;case"INSIDE_OBJECT_KEY":case"INSIDE_OBJECT_AFTER_KEY":case"INSIDE_OBJECT_AFTER_COMMA":case"INSIDE_OBJECT_START":case"INSIDE_OBJECT_BEFORE_VALUE":case"INSIDE_OBJECT_AFTER_VALUE":o+="}";break;case"INSIDE_ARRAY_START":case"INSIDE_ARRAY_AFTER_COMMA":case"INSIDE_ARRAY_AFTER_VALUE":o+="]";break;case"INSIDE_LITERAL":{const t=e.substring(s,e.length);"true".startsWith(t)?o+="true".slice(t.length):"false".startsWith(t)?o+="false".slice(t.length):"null".startsWith(t)&&(o+="null".slice(t.length))}}}return o}[Iz,Az,Tz,Mz,Dz].map(e=>e.code);var Pz=[{code:"0",name:"text",parse:e=>{if("string"!=typeof e)throw new Error('"text" parts expect a string value.');return{type:"text",value:e}}},{code:"2",name:"data",parse:e=>{if(!Array.isArray(e))throw new Error('"data" parts expect an array value.');return{type:"data",value:e}}},{code:"3",name:"error",parse:e=>{if("string"!=typeof e)throw new Error('"error" parts expect a string value.');return{type:"error",value:e}}},{code:"8",name:"message_annotations",parse:e=>{if(!Array.isArray(e))throw new Error('"message_annotations" parts expect an array value.');return{type:"message_annotations",value:e}}},{code:"9",name:"tool_call",parse:e=>{if(null==e||"object"!=typeof e||!("toolCallId"in e)||"string"!=typeof e.toolCallId||!("toolName"in e)||"string"!=typeof e.toolName||!("args"in e)||"object"!=typeof e.args)throw new Error('"tool_call" parts expect an object with a "toolCallId", "toolName", and "args" property.');return{type:"tool_call",value:e}}},{code:"a",name:"tool_result",parse:e=>{if(null==e||"object"!=typeof e||!("toolCallId"in e)||"string"!=typeof e.toolCallId||!("result"in e))throw new Error('"tool_result" parts expect an object with a "toolCallId" and a "result" property.');return{type:"tool_result",value:e}}},{code:"b",name:"tool_call_streaming_start",parse:e=>{if(null==e||"object"!=typeof e||!("toolCallId"in e)||"string"!=typeof e.toolCallId||!("toolName"in e)||"string"!=typeof e.toolName)throw new Error('"tool_call_streaming_start" parts expect an object with a "toolCallId" and "toolName" property.');return{type:"tool_call_streaming_start",value:e}}},{code:"c",name:"tool_call_delta",parse:e=>{if(null==e||"object"!=typeof e||!("toolCallId"in e)||"string"!=typeof e.toolCallId||!("argsTextDelta"in e)||"string"!=typeof e.argsTextDelta)throw new Error('"tool_call_delta" parts expect an object with a "toolCallId" and "argsTextDelta" property.');return{type:"tool_call_delta",value:e}}},{code:"d",name:"finish_message",parse:e=>{if(null==e||"object"!=typeof e||!("finishReason"in e)||"string"!=typeof e.finishReason)throw new Error('"finish_message" parts expect an object with a "finishReason" property.');const t={finishReason:e.finishReason};return"usage"in e&&null!=e.usage&&"object"==typeof e.usage&&"promptTokens"in e.usage&&"completionTokens"in e.usage&&(t.usage={promptTokens:"number"==typeof e.usage.promptTokens?e.usage.promptTokens:Number.NaN,completionTokens:"number"==typeof e.usage.completionTokens?e.usage.completionTokens:Number.NaN}),{type:"finish_message",value:t}}},{code:"e",name:"finish_step",parse:e=>{if(null==e||"object"!=typeof e||!("finishReason"in e)||"string"!=typeof e.finishReason)throw new Error('"finish_step" parts expect an object with a "finishReason" property.');const t={finishReason:e.finishReason,isContinued:!1};return"usage"in e&&null!=e.usage&&"object"==typeof e.usage&&"promptTokens"in e.usage&&"completionTokens"in e.usage&&(t.usage={promptTokens:"number"==typeof e.usage.promptTokens?e.usage.promptTokens:Number.NaN,completionTokens:"number"==typeof e.usage.completionTokens?e.usage.completionTokens:Number.NaN}),"isContinued"in e&&"boolean"==typeof e.isContinued&&(t.isContinued=e.isContinued),{type:"finish_step",value:t}}},{code:"f",name:"start_step",parse:e=>{if(null==e||"object"!=typeof e||!("messageId"in e)||"string"!=typeof e.messageId)throw new Error('"start_step" parts expect an object with an "id" property.');return{type:"start_step",value:{messageId:e.messageId}}}},{code:"g",name:"reasoning",parse:e=>{if("string"!=typeof e)throw new Error('"reasoning" parts expect a string value.');return{type:"reasoning",value:e}}},{code:"h",name:"source",parse:e=>{if(null==e||"object"!=typeof e)throw new Error('"source" parts expect a Source object.');return{type:"source",value:e}}},{code:"i",name:"redacted_reasoning",parse:e=>{if(null==e||"object"!=typeof e||!("data"in e)||"string"!=typeof e.data)throw new Error('"redacted_reasoning" parts expect an object with a "data" property.');return{type:"redacted_reasoning",value:{data:e.data}}}},{code:"j",name:"reasoning_signature",parse:e=>{if(null==e||"object"!=typeof e||!("signature"in e)||"string"!=typeof e.signature)throw new Error('"reasoning_signature" parts expect an object with a "signature" property.');return{type:"reasoning_signature",value:{signature:e.signature}}}},{code:"k",name:"file",parse:e=>{if(null==e||"object"!=typeof e||!("data"in e)||"string"!=typeof e.data||!("mimeType"in e)||"string"!=typeof e.mimeType)throw new Error('"file" parts expect an object with a "data" and "mimeType" property.');return{type:"file",value:e}}}],Rz=Object.fromEntries(Pz.map(e=>[e.code,e]));Object.fromEntries(Pz.map(e=>[e.name,e.code]));var Oz=Pz.map(e=>e.code),zz=e=>{const t=e.indexOf(":");if(-1===t)throw new Error("Failed to parse stream string. No separator found.");const n=e.slice(0,t);if(!Oz.includes(n))throw new Error(`Failed to parse stream string. Invalid code ${n}.`);const s=n,i=e.slice(t+1),a=JSON.parse(i);return Rz[s].parse(a)},Bz="\n".charCodeAt(0);function Hz(e,t){const n=new Uint8Array(t);let s=0;for(const i of e)n.set(i,s),s+=i.length;return e.length=0,n}async function $z({stream:e,update:t,onToolCall:n,onFinish:s,generateId:i=_z,getCurrentDate:a=()=>new Date,lastMessage:r}){var o,l;const c="assistant"===(null==r?void 0:r.role);let d=c?1+(null!=(l=null==(o=r.toolInvocations)?void 0:o.reduce((e,t)=>{var n;return Math.max(e,null!=(n=t.step)?n:0)},0))?l:0):0;const u=c?structuredClone(r):{id:i(),createdAt:a(),role:"assistant",content:"",parts:[]};let p,m,h;function x(e,t){const n=u.parts.find(t=>"tool-invocation"===t.type&&t.toolInvocation.toolCallId===e);null!=n?n.toolInvocation=t:u.parts.push({type:"tool-invocation",toolInvocation:t})}const f=[];let g=c?null==r?void 0:r.annotations:void 0;const v={};let b={completionTokens:NaN,promptTokens:NaN,totalTokens:NaN},y="unknown";function w(){const e=[...f];(null==g?void 0:g.length)&&(u.annotations=g);const n={...structuredClone(u),revisionId:i()};t({message:n,data:e,replaceLastMessage:c})}await async function({stream:e,onTextPart:t,onReasoningPart:n,onReasoningSignaturePart:s,onRedactedReasoningPart:i,onSourcePart:a,onFilePart:r,onDataPart:o,onErrorPart:l,onToolCallStreamingStartPart:c,onToolCallDeltaPart:d,onToolCallPart:u,onToolResultPart:p,onMessageAnnotationsPart:m,onFinishMessagePart:h,onFinishStepPart:x,onStartStepPart:f}){const g=e.getReader(),v=new TextDecoder,b=[];let y=0;for(;;){const{value:e}=await g.read();if(e&&(b.push(e),y+=e.length,e[e.length-1]!==Bz))continue;if(0===b.length)break;const w=Hz(b,y);y=0;const j=v.decode(w,{stream:!0}).split("\n").filter(e=>""!==e).map(zz);for(const{type:g,value:v}of j)switch(g){case"text":await(null==t?void 0:t(v));break;case"reasoning":await(null==n?void 0:n(v));break;case"reasoning_signature":await(null==s?void 0:s(v));break;case"redacted_reasoning":await(null==i?void 0:i(v));break;case"file":await(null==r?void 0:r(v));break;case"source":await(null==a?void 0:a(v));break;case"data":await(null==o?void 0:o(v));break;case"error":await(null==l?void 0:l(v));break;case"message_annotations":await(null==m?void 0:m(v));break;case"tool_call_streaming_start":await(null==c?void 0:c(v));break;case"tool_call_delta":await(null==d?void 0:d(v));break;case"tool_call":await(null==u?void 0:u(v));break;case"tool_result":await(null==p?void 0:p(v));break;case"finish_message":await(null==h?void 0:h(v));break;case"finish_step":await(null==x?void 0:x(v));break;case"start_step":await(null==f?void 0:f(v));break;default:throw new Error(`Unknown stream part type: ${g}`)}}}({stream:e,onTextPart(e){null==p?(p={type:"text",text:e},u.parts.push(p)):p.text+=e,u.content+=e,w()},onReasoningPart(e){var t;null==h?(h={type:"text",text:e},null!=m&&m.details.push(h)):h.text+=e,null==m?(m={type:"reasoning",reasoning:e,details:[h]},u.parts.push(m)):m.reasoning+=e,u.reasoning=(null!=(t=u.reasoning)?t:"")+e,w()},onReasoningSignaturePart(e){null!=h&&(h.signature=e.signature)},onRedactedReasoningPart(e){null==m&&(m={type:"reasoning",reasoning:"",details:[]},u.parts.push(m)),m.details.push({type:"redacted",data:e.data}),h=void 0,w()},onFilePart(e){u.parts.push({type:"file",mimeType:e.mimeType,data:e.data}),w()},onSourcePart(e){u.parts.push({type:"source",source:e}),w()},onToolCallStreamingStartPart(e){null==u.toolInvocations&&(u.toolInvocations=[]),v[e.toolCallId]={text:"",step:d,toolName:e.toolName,index:u.toolInvocations.length};const t={state:"partial-call",step:d,toolCallId:e.toolCallId,toolName:e.toolName,args:void 0};u.toolInvocations.push(t),x(e.toolCallId,t),w()},onToolCallDeltaPart(e){const t=v[e.toolCallId];t.text+=e.argsTextDelta;const{value:n}=function(e){if(void 0===e)return{value:void 0,state:"undefined-input"};let t=Ez({text:e});return t.success?{value:t.value,state:"successful-parse"}:(t=Ez({text:Lz(e)}),t.success?{value:t.value,state:"repaired-parse"}:{value:void 0,state:"failed-parse"})}(t.text),s={state:"partial-call",step:t.step,toolCallId:e.toolCallId,toolName:t.toolName,args:n};u.toolInvocations[t.index]=s,x(e.toolCallId,s),w()},async onToolCallPart(e){const t={state:"call",step:d,...e};if(null!=v[e.toolCallId]?u.toolInvocations[v[e.toolCallId].index]=t:(null==u.toolInvocations&&(u.toolInvocations=[]),u.toolInvocations.push(t)),x(e.toolCallId,t),w(),n){const t=await n({toolCall:e});if(null!=t){const n={state:"result",step:d,...e,result:t};u.toolInvocations[u.toolInvocations.length-1]=n,x(e.toolCallId,n),w()}}},onToolResultPart(e){const t=u.toolInvocations;if(null==t)throw new Error("tool_result must be preceded by a tool_call");const n=t.findIndex(t=>t.toolCallId===e.toolCallId);if(-1===n)throw new Error("tool_result must be preceded by a tool_call with the same toolCallId");const s={...t[n],state:"result",...e};t[n]=s,x(e.toolCallId,s),w()},onDataPart(e){f.push(...e),w()},onMessageAnnotationsPart(e){null==g?g=[...e]:g.push(...e),w()},onFinishStepPart(e){d+=1,p=e.isContinued?p:void 0,m=void 0,h=void 0},onStartStepPart(e){c||(u.id=e.messageId),u.parts.push({type:"step-start"}),w()},onFinishMessagePart(e){y=e.finishReason,null!=e.usage&&(b=function({promptTokens:e,completionTokens:t}){return{promptTokens:e,completionTokens:t,totalTokens:e+t}}(e.usage))},onErrorPart(e){throw new Error(e)}}),null==s||s({message:u,finishReason:y,usage:b})}async function Vz({stream:e,update:t,onFinish:n,getCurrentDate:s=()=>new Date,generateId:i=_z}){const a={type:"text",text:""},r={id:i(),createdAt:s(),role:"assistant",content:"",parts:[a]};await async function({stream:e,onTextPart:t}){const n=e.pipeThrough(new TextDecoderStream).getReader();for(;;){const{done:e,value:s}=await n.read();if(e)break;await t(s)}}({stream:e,onTextPart:e=>{r.content+=e,a.text+=e,t({message:{...r},data:[],replaceLastMessage:!1})}}),null==n||n(r,{usage:{completionTokens:NaN,promptTokens:NaN,totalTokens:NaN},finishReason:"unknown"})}var Uz=()=>fetch;function Wz(e){return null==e?void 0:e.reduce((e,t)=>{var n;return Math.max(e,null!=(n=t.step)?n:0)},0)}function qz(e){var t;return null!=(t=e.parts)?t:[...e.toolInvocations?e.toolInvocations.map(e=>({type:"tool-invocation",toolInvocation:e})):[],...e.reasoning?[{type:"reasoning",reasoning:e.reasoning,details:[{type:"text",text:e.reasoning}]}]:[],...e.content?[{type:"text",text:e.content}]:[]]}function Gz(e){return e.map(e=>({...e,parts:qz(e)}))}function Zz(e,t){if(e===t)return!0;if(null==e||null==t)return!1;if("object"!=typeof e&&"object"!=typeof t)return e===t;if(e.constructor!==t.constructor)return!1;if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if(Array.isArray(e)){if(e.length!==t.length)return!1;for(let n=0;n{const{name:t,type:n}=e;return{name:t,contentType:n,url:await new Promise((t,n)=>{const s=new FileReader;s.onload=e=>{var n;t(null==(n=e.target)?void 0:n.result)},s.onerror=e=>n(e),s.readAsDataURL(e)})}}));if(Array.isArray(e))return e;throw new Error("Invalid attachments type")}function Kz(e){if("assistant"!==e.role)return!1;const t=e.parts.reduce((e,t,n)=>"step-start"===t.type?n:e,-1),n=e.parts.slice(t+1).filter(e=>"tool-invocation"===e.type);return n.length>0&&n.every(e=>"result"in e.toolInvocation)}var Jz=Object.prototype.hasOwnProperty;const Qz=new WeakMap,Xz=()=>{},eB=Xz(),tB=Object,nB=e=>e===eB,sB=e=>"function"==typeof e,iB=(e,t)=>({...e,...t}),aB=e=>sB(e.then),rB={},oB={},lB="undefined",cB=typeof window!=lB,dB=typeof document!=lB,uB=cB&&"Deno"in window,pB=(e,t)=>{const n=Qz.get(e);return[()=>!nB(t)&&e.get(t)||rB,s=>{if(!nB(t)){const i=e.get(t);t in oB||(oB[t]=i),n[5](t,iB(i,s),i||rB)}},n[6],()=>!nB(t)&&t in oB?oB[t]:!nB(t)&&e.get(t)||rB]};let mB=!0;const[hB,xB]=cB&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[Xz,Xz],fB={isOnline:()=>mB,isVisible:()=>{const e=dB&&document.visibilityState;return nB(e)||"hidden"!==e}},gB={initFocus:e=>(dB&&document.addEventListener("visibilitychange",e),hB("focus",e),()=>{dB&&document.removeEventListener("visibilitychange",e),xB("focus",e)}),initReconnect:e=>{const t=()=>{mB=!0,e()},n=()=>{mB=!1};return hB("online",t),hB("offline",n),()=>{xB("online",t),xB("offline",n)}}},vB=!ze.useId,bB=!cB||uB,yB=e=>cB&&typeof window.requestAnimationFrame!=lB?window.requestAnimationFrame(e):setTimeout(e,1),wB=bB?Pe.useEffect:Pe.useLayoutEffect,jB="undefined"!=typeof navigator&&navigator.connection,CB=!bB&&jB&&(["slow-2g","2g"].includes(jB.effectiveType)||jB.saveData),NB=new WeakMap,FB=(e,t)=>e===`[object ${t}]`;let _B=0;const kB=e=>{const t=typeof e,n=(s=e,tB.prototype.toString.call(s));var s;const i=FB(n,"Date"),a=FB(n,"RegExp"),r=FB(n,"Object");let o,l;if(tB(e)!==e||i||a)o=i?e.toJSON():"symbol"==t?e.toString():"string"==t?JSON.stringify(e):""+e;else{if(o=NB.get(e),o)return o;if(o=++_B+"~",NB.set(e,o),Array.isArray(e)){for(o="@",l=0;l{if(sB(e))try{e=e()}catch(n){e=""}const t=e;return[e="string"==typeof e?e:(Array.isArray(e)?e.length:e)?kB(e):"",t]};let EB=0;const IB=()=>++EB;async function AB(...e){const[t,n,s,i]=e,a=iB({populateCache:!0,throwOnError:!0},"boolean"==typeof i?{revalidate:i}:i||{});let r=a.populateCache;const o=a.rollbackOnError;let l=a.optimisticData;const c=a.throwOnError;if(sB(n)){const e=n,s=[],i=t.keys();for(const n of i)!/^\$(inf|sub)\$/.test(n)&&e(t.get(n)._k)&&s.push(n);return Promise.all(s.map(d))}return d(n);async function d(n){const[i]=SB(n);if(!i)return;const[d,u]=pB(t,i),[p,m,h,x]=Qz.get(t),f=()=>{const e=p[i];return(sB(a.revalidate)?a.revalidate(d().data,n):!1!==a.revalidate)&&(delete h[i],delete x[i],e&&e[0])?e[0](2).then(()=>d().data):d().data};if(e.length<3)return f();let g,v=s,b=!1;const y=IB();m[i]=[y,0];const w=!nB(l),j=d(),C=j.data,N=j._c,F=nB(N)?C:N;if(w&&(l=sB(l)?l(F,C):l,u({data:l,_c:F})),sB(v))try{v=v(F)}catch(_){g=_,b=!0}if(v&&aB(v)){if(v=await v.catch(e=>{g=e,b=!0}),y!==m[i][0]){if(b)throw g;return v}b&&w&&(e=>"function"==typeof o?o(e):!1!==o)(g)&&(r=!0,u({data:F,_c:eB}))}if(r&&!b)if(sB(r)){const e=r(v,F);u({data:e,error:eB,_c:eB})}else u({data:v,error:eB,_c:eB});if(m[i][1]=IB(),Promise.resolve(f()).then(()=>{u({_c:eB})}),!b)return v;if(c)throw g}}const TB=(e,t)=>{for(const n in e)e[n][0]&&e[n][0](t)},MB=function e(t,n){var s,i;if(t===n)return!0;if(t&&n&&(s=t.constructor)===n.constructor){if(s===Date)return t.getTime()===n.getTime();if(s===RegExp)return t.toString()===n.toString();if(s===Array){if((i=t.length)===n.length)for(;i--&&e(t[i],n[i]););return-1===i}if(!s||"object"==typeof t){for(s in i=0,t){if(Jz.call(t,s)&&++i&&!Jz.call(n,s))return!1;if(!(s in n)||!e(t[s],n[s]))return!1}return Object.keys(n).length===i}}return t!=t&&n!=n},[DB,LB]=((e,t)=>{if(!Qz.has(e)){const n=iB(gB,t),s=Object.create(null),i=AB.bind(eB,e);let a=Xz;const r=Object.create(null),o=(e,t)=>{const n=r[e]||[];return r[e]=n,n.push(t),()=>n.splice(n.indexOf(t),1)},l=(t,n,s)=>{e.set(t,n);const i=r[t];if(i)for(const e of i)e(n,s)},c=()=>{if(!Qz.has(e)&&(Qz.set(e,[s,Object.create(null),Object.create(null),Object.create(null),i,l,o]),!bB)){const t=n.initFocus(setTimeout.bind(eB,TB.bind(eB,s,0))),i=n.initReconnect(setTimeout.bind(eB,TB.bind(eB,s,1)));a=()=>{t&&t(),i&&i(),Qz.delete(e)}}};return c(),[e,i,c,a]}return[e,Qz.get(e)[4]]})(new Map),PB=iB({onLoadingSlow:Xz,onSuccess:Xz,onError:Xz,onErrorRetry:(e,t,n,s,i)=>{const a=n.errorRetryCount,r=i.retryCount,o=~~((Math.random()+.5)*(1<<(r<8?r:8)))*n.errorRetryInterval;!nB(a)&&r>a||setTimeout(s,o,i)},onDiscarded:Xz,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:CB?1e4:5e3,focusThrottleInterval:5e3,dedupingInterval:2e3,loadingTimeout:CB?5e3:3e3,compare:MB,isPaused:()=>!1,cache:DB,mutate:LB,fallback:{}},fB),RB=Pe.createContext({}),OB=cB&&window.__SWR_DEVTOOLS_USE__,zB=OB?window.__SWR_DEVTOOLS_USE__:[],BB=zB.concat(e=>(t,n,s)=>e(t,n&&((...e)=>{const[s]=SB(t),[,,,i]=Qz.get(DB);if(s.startsWith("$inf$"))return n(...e);const a=i[s];return nB(a)?n(...e):(delete i[s],a)}),s));OB&&(window.__SWR_DEVTOOLS_REACT__=ze);const HB=ze.use||(e=>{switch(e.status){case"pending":throw e;case"fulfilled":return e.value;case"rejected":throw e.reason;default:throw e.status="pending",e.then(t=>{e.status="fulfilled",e.value=t},t=>{e.status="rejected",e.reason=t}),e}}),$B={dedupe:!0},VB=Promise.resolve(eB),UB=(WB=(e,t,n)=>{const{cache:s,compare:i,suspense:a,fallbackData:r,revalidateOnMount:o,revalidateIfStale:l,refreshInterval:c,refreshWhenHidden:d,refreshWhenOffline:u,keepPreviousData:p}=n,[m,h,x,f]=Qz.get(s),[g,v]=SB(e),b=Pe.useRef(!1),y=Pe.useRef(!1),w=Pe.useRef(g),j=Pe.useRef(t),C=Pe.useRef(n),N=()=>C.current,F=()=>N().isVisible()&&N().isOnline(),[_,k,S,E]=pB(s,g),I=Pe.useRef({}).current,A=nB(r)?nB(n.fallback)?eB:n.fallback[g]:r,T=(e,t)=>{for(const n in I){const s=n;if("data"===s){if(!i(e[s],t[s])){if(!nB(e[s]))return!1;if(!i(H,t[s]))return!1}}else if(t[s]!==e[s])return!1}return!0},M=Pe.useMemo(()=>{const e=!!g&&!!t&&(nB(o)?!N().isPaused()&&!a&&!1!==l:o),n=t=>{const n=iB(t);return delete n._k,e?{isValidating:!0,isLoading:!0,...n}:n},s=_(),i=E(),r=n(s),c=s===i?r:n(i);let d=r;return[()=>{const e=n(_());return T(e,d)?(d.data=e.data,d.isLoading=e.isLoading,d.isValidating=e.isValidating,d.error=e.error,d):(d=e,e)},()=>c]},[s,g]),D=te.useSyncExternalStore(Pe.useCallback(e=>S(g,(t,n)=>{T(n,t)||e()}),[s,g]),M[0],M[1]),L=!b.current,P=m[g]&&m[g].length>0,R=D.data,O=nB(R)?A&&aB(A)?HB(A):A:R,z=D.error,B=Pe.useRef(O),H=p?nB(R)?nB(B.current)?O:B.current:R:O,$=!(P&&!nB(z))&&(L&&!nB(o)?o:!N().isPaused()&&(a?!nB(O)&&l:nB(O)||l)),V=!!(g&&t&&L&&$),U=nB(D.isValidating)?V:D.isValidating,W=nB(D.isLoading)?V:D.isLoading,q=Pe.useCallback(async e=>{const t=j.current;if(!g||!t||y.current||N().isPaused())return!1;let s,a,r=!0;const o=e||{},l=!x[g]||!o.dedupe,c=()=>vB?!y.current&&g===w.current&&b.current:g===w.current,d={isValidating:!1,isLoading:!1},u=()=>{k(d)},p=()=>{const e=x[g];e&&e[1]===a&&delete x[g]},f={isValidating:!0};nB(_().data)&&(f.isLoading=!0);try{if(l&&(k(f),n.loadingTimeout&&nB(_().data)&&setTimeout(()=>{r&&c()&&N().onLoadingSlow(g,n)},n.loadingTimeout),x[g]=[t(v),IB()]),[s,a]=x[g],s=await s,l&&setTimeout(p,n.dedupingInterval),!x[g]||x[g][1]!==a)return l&&c()&&N().onDiscarded(g),!1;d.error=eB;const e=h[g];if(!nB(e)&&(a<=e[0]||a<=e[1]||0===e[1]))return u(),l&&c()&&N().onDiscarded(g),!1;const o=_().data;d.data=i(o,s)?o:s,l&&c()&&N().onSuccess(s,g,n)}catch(C){p();const e=N(),{shouldRetryOnError:t}=e;e.isPaused()||(d.error=C,l&&c()&&(e.onError(C,g,e),(!0===t||sB(t)&&t(C))&&(N().revalidateOnFocus&&N().revalidateOnReconnect&&!F()||e.onErrorRetry(C,g,e,e=>{const t=m[g];t&&t[0]&&t[0](3,e)},{retryCount:(o.retryCount||0)+1,dedupe:!0}))))}return r=!1,u(),!0},[g,s]),G=Pe.useCallback((...e)=>AB(s,w.current,...e),[]);if(wB(()=>{j.current=t,C.current=n,nB(R)||(B.current=R)}),wB(()=>{if(!g)return;const e=q.bind(eB,$B);let t=0;if(N().revalidateOnFocus){const e=Date.now();t=e+N().focusThrottleInterval}const n=((e,t,n)=>{const s=t[e]||(t[e]=[]);return s.push(n),()=>{const e=s.indexOf(n);e>=0&&(s[e]=s[s.length-1],s.pop())}})(g,m,(n,s={})=>{if(0==n){const n=Date.now();N().revalidateOnFocus&&n>t&&F()&&(t=n+N().focusThrottleInterval,e())}else if(1==n)N().revalidateOnReconnect&&F()&&e();else{if(2==n)return q();if(3==n)return q(s)}});return y.current=!1,w.current=g,b.current=!0,k({_k:v}),$&&(x[g]||(nB(O)||bB?e():yB(e))),()=>{y.current=!0,n()}},[g]),wB(()=>{let e;function t(){const t=sB(c)?c(_().data):c;t&&-1!==e&&(e=setTimeout(n,t))}function n(){_().error||!d&&!N().isVisible()||!u&&!N().isOnline()?t():q($B).then(t)}return t(),()=>{e&&(clearTimeout(e),e=-1)}},[c,d,u,g]),Pe.useDebugValue(H),a){const e=g&&nB(O);if(!vB&&bB&&e)throw new Error("Fallback data is required when using Suspense in SSR.");e&&(j.current=t,C.current=n,y.current=!1);const s=f[g],i=!nB(s)&&e?G(s):VB;if(HB(i),!nB(z)&&e)throw z;const a=e?q($B):VB;!nB(H)&&e&&(a.status="fulfilled",a.value=!0),HB(a)}return{mutate:G,get data(){return I.data=!0,H},get error(){return I.error=!0,z},get isValidating(){return I.isValidating=!0,U},get isLoading(){return I.isLoading=!0,W}}},function(...e){const t=(()=>{const e=Pe.useContext(RB);return Pe.useMemo(()=>iB(PB,e),[e])})(),[n,s,i]=(e=>sB(e[1])?[e[0],e[1],e[2]||{}]:[e[0],null,(null===e[1]?e[2]:e[1])||{}])(e),a=((e,t)=>{const n=iB(e,t);if(t){const{use:s,fallback:i}=e,{use:a,fallback:r}=t;s&&a&&(n.use=s.concat(a)),i&&r&&(n.fallback=iB(i,r))}return n})(t,i);let r=WB;const{use:o}=a,l=(o||[]).concat(BB);for(let c=l.length;c--;)r=l[c](r);return r(n,s||a.fetcher||null,a)});var WB,qB,GB;function ZB(){if(GB)return qB;return GB=1,qB=function(e,t){if("function"!=typeof e)throw new TypeError(`Expected the first argument to be a \`function\`, got \`${typeof e}\`.`);let n,s=0;return function(...i){clearTimeout(n);const a=Date.now(),r=t-(a-s);r<=0?(s=a,e.apply(this,i)):n=setTimeout(()=>{s=Date.now(),e.apply(this,i)},r)}}}const YB=Le(ZB());function KB(e,t){return null!=t?YB(e,t):e}function JB(e){const[t,n]=Pe.useState(e);return Pe.useEffect(()=>{Zz(e,t)||n(e)},[e,t]),t}var QB=function({api:e="/api/chat",id:t,initialMessages:n,initialInput:s="",sendExtraMessageFields:i,onToolCall:a,experimental_prepareRequestBody:r,maxSteps:o=1,streamProtocol:l="data",onResponse:c,onFinish:d,onError:u,credentials:p,headers:m,body:h,generateId:x=_z,fetch:f,keepLastMessageOnError:g=!0,experimental_throttle:v}={}){const[b]=Pe.useState(x),y=null!=t?t:b,w="string"==typeof e?[e,y]:y,j=JB(null!=n?n:[]),C=Pe.useMemo(()=>Gz(j),[j]),{data:N,mutate:F}=UB([w,"messages"],null,{fallbackData:C}),_=Pe.useRef(N||[]);Pe.useEffect(()=>{_.current=N||[]},[N]);const{data:k,mutate:S}=UB([w,"streamData"],null),E=Pe.useRef(k);Pe.useEffect(()=>{E.current=k},[k]);const{data:I="ready",mutate:A}=UB([w,"status"],null),{data:T,mutate:M}=UB([w,"error"],null),D=Pe.useRef(null),L=Pe.useRef({credentials:p,headers:m,body:h});Pe.useEffect(()=>{L.current={credentials:p,headers:m,body:h}},[p,m,h]);const P=Pe.useCallback(async(t,n="generate")=>{var s,p;A("submitted"),M(void 0);const m=Gz(t.messages),h=m.length,b=Wz(null==(s=m[m.length-1])?void 0:s.toolInvocations);try{const s=new AbortController;D.current=s;const o=KB(F,v),u=KB(S,v),h=_.current;o(m,!1);const b=i?m:m.map(({role:e,content:t,experimental_attachments:n,data:s,annotations:i,toolInvocations:a,parts:r})=>({role:e,content:t,...void 0!==n&&{experimental_attachments:n},...void 0!==s&&{data:s},...void 0!==i&&{annotations:i},...void 0!==a&&{toolInvocations:a},...void 0!==r&&{parts:r}})),w=E.current;await async function({api:e,body:t,streamProtocol:n="data",credentials:s,headers:i,abortController:a,restoreMessagesOnFailure:r,onResponse:o,onUpdate:l,onFinish:c,onToolCall:d,generateId:u,fetch:p=Uz(),lastMessage:m,requestType:h="generate"}){var x,f,g;const v="resume"===h?p(`${e}?chatId=${t.id}`,{method:"GET",headers:{"Content-Type":"application/json",...i},signal:null==(x=null==a?void 0:a())?void 0:x.signal,credentials:s}):p(e,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json",...i},signal:null==(f=null==a?void 0:a())?void 0:f.signal,credentials:s}),b=await v.catch(e=>{throw r(),e});if(o)try{await o(b)}catch(y){throw y}if(!b.ok)throw r(),new Error(null!=(g=await b.text())?g:"Failed to fetch the chat response.");if(!b.body)throw new Error("The response body is empty.");switch(n){case"text":return void(await Vz({stream:b.body,update:l,onFinish:c,generateId:u}));case"data":return void(await $z({stream:b.body,update:l,lastMessage:m,onToolCall:d,onFinish({message:e,finishReason:t,usage:n}){c&&null!=e&&c(e,{usage:n,finishReason:t})},generateId:u}));default:throw new Error(`Unknown stream protocol: ${n}`)}}({api:e,body:null!=(p=null==r?void 0:r({id:y,messages:m,requestData:t.data,requestBody:t.body}))?p:{id:y,messages:b,data:t.data,...L.current.body,...t.body},streamProtocol:l,credentials:L.current.credentials,headers:{...L.current.headers,...t.headers},abortController:()=>D.current,restoreMessagesOnFailure(){g||o(h,!1)},onResponse:c,onUpdate({message:e,data:t,replaceLastMessage:n}){A("streaming"),o([...n?m.slice(0,m.length-1):m,e],!1),(null==t?void 0:t.length)&&u([...null!=w?w:[],...t],!1)},onToolCall:a,onFinish:d,generateId:x,fetch:f,lastMessage:m[m.length-1],requestType:n}),D.current=null,A("ready")}catch(j){if("AbortError"===j.name)return D.current=null,A("ready"),null;u&&j instanceof Error&&u(j),M(j),A("error")}const w=_.current;(function({originalMaxToolInvocationStep:e,originalMessageCount:t,maxSteps:n,messages:s}){var i;const a=s[s.length-1];return n>1&&null!=a&&(s.length>t||Wz(a.toolInvocations)!==e)&&Kz(a)&&(null!=(i=Wz(a.toolInvocations))?i:0){var a,r;const o=await Yz(i),l=_.current.concat({...e,id:null!=(a=e.id)?a:x(),createdAt:null!=(r=e.createdAt)?r:new Date,experimental_attachments:o.length>0?o:void 0,parts:qz(e)});return P({messages:l,headers:n,body:s,data:t})},[P,x]),O=Pe.useCallback(async({data:e,headers:t,body:n}={})=>{const s=_.current;if(0===s.length)return null;const i=s[s.length-1];return P({messages:"assistant"===i.role?s.slice(0,-1):s,headers:t,body:n,data:e})},[P]),z=Pe.useCallback(()=>{D.current&&(D.current.abort(),D.current=null)},[]),B=Pe.useCallback(async()=>{const e=_.current;P({messages:e},"resume")},[P]),H=Pe.useCallback(e=>{"function"==typeof e&&(e=e(_.current));const t=Gz(e);F(t,!1),_.current=t},[F]),$=Pe.useCallback(e=>{"function"==typeof e&&(e=e(E.current)),S(e,!1),E.current=e},[S]),[V,U]=Pe.useState(s),W=Pe.useCallback(async(e,t={},n)=>{var s;if(null==(s=null==e?void 0:e.preventDefault)||s.call(e),!V&&!t.allowEmptySubmit)return;n&&(L.current={...L.current,...n});const i=await Yz(t.experimental_attachments),a={messages:_.current.concat({id:x(),createdAt:new Date,role:"user",content:V,experimental_attachments:i.length>0?i:void 0,parts:[{type:"text",text:V}]}),headers:t.headers,body:t.body,data:t.data};P(a),U("")},[V,x,P]),q=Pe.useCallback(({toolCallId:e,result:t})=>{const n=_.current;if(function({messages:e,toolCallId:t,toolResult:n}){var s;const i=e[e.length-1],a=i.parts.find(e=>"tool-invocation"===e.type&&e.toolInvocation.toolCallId===t);if(null==a)return;const r={...a.toolInvocation,state:"result",result:n};a.toolInvocation=r,i.toolInvocations=null==(s=i.toolInvocations)?void 0:s.map(e=>e.toolCallId===t?r:e)}({messages:n,toolCallId:e,toolResult:t}),F([...n.slice(0,n.length-1),{...n[n.length-1]}],!1),"submitted"===I||"streaming"===I)return;Kz(n[n.length-1])&&P({messages:n})},[F,I,P]);return{messages:null!=N?N:[],id:y,setMessages:H,data:k,setData:$,error:T,append:R,reload:O,stop:z,experimental_resume:B,input:V,setInput:U,handleInputChange:e=>{U(e.target.value)},handleSubmit:W,isLoading:"submitted"===I||"streaming"===I,status:I,addToolResult:q}};const XB=e=>{if(!e)return!1;if(e.includes("..")||e.endsWith(".")||e.endsWith("/")||e.startsWith("/")||e.includes("//")||e.includes(" ")||e.includes("~")||e.includes("^")||e.includes(":")||e.includes("?")||e.includes("*")||e.includes("[")||e.includes("@{")||"@"===e||e.includes("\\"))return!1;const t=e.split("/");for(const n of t)if(n.startsWith(".")||n.endsWith(".lock"))return!1;return/^[a-zA-Z0-9\-\.\/\_]+$/.test(e)},eH=e=>e.replace(/\s+/g,"-");function tH(e){const t=e.match(/https:\/\/[^\s]+/g);return null==t?void 0:t.find(e=>e.includes("atlas-kb.com")||e.includes("notion.site"))}function nH(){const e=new Date;return`conflict_${e.getDate().toString().padStart(2,"0")}${(e.getMonth()+1).toString().padStart(2,"0")}${e.getFullYear().toString().slice(-2)}_${e.toTimeString().slice(0,2)+e.toTimeString().slice(3,5)}`}function sH(e,t){const{defaultErrorMessage:n,needsForcePush:s=!1,allowConflictDetection:i=!0}=t,{errorMessage:a,fullErrorText:r,errorString:o}=function(e,t){var n,s;let i=t,a="";const r=JSON.stringify(e);return(null==(n=null==e?void 0:e.data)?void 0:n.detail)?(i=e.data.detail,a=e.data.detail):(null==(s=null==e?void 0:e.data)?void 0:s.message)?(i=e.data.message,a=e.data.message):(null==e?void 0:e.message)&&(i=e.message,a=e.message),{errorMessage:i,fullErrorText:a,errorString:r}}(e,n);if(function(e,t){return["GITHUB PUSH PROTECTION","Push cannot contain secrets","Secret push protection is enabled"].some(n=>e.includes(n)||t.includes(n))}(r,o))return{type:"secret_protection",errorMessage:a,fullErrorText:r,learnMoreUrl:tH(r)};if(function(e,t){return["Updates were rejected because the remote contains work that you do not have locally","remote contains work that you do not have locally"].some(n=>e.includes(n)||t.includes(n))}(r,o)){const e=i&&!s;return{type:"remote_rejection",errorMessage:a,fullErrorText:r,shouldShowConflictUI:e,shouldGenerateProposedBranch:e}}return{type:"generic",errorMessage:a,fullErrorText:r}}function iH(e,t){const{repositories:n,isCreatingNewRepo:s,selectedInstallation:i}=t;if(!e)return{isValid:!1,errorMessage:s?"Enter a name for your new repository":"Repository name is required"};if(!(e=>!!e&&!e.endsWith(".git")&&XB(e))(e))return{isValid:!1,errorMessage:"Invalid repository name. Names must follow Git naming rules: only alphanumeric characters and - . / _ are allowed. Cannot contain spaces, consecutive dots (..), begin/end with /, end with ., or contain special characters."};if(s){return n.some(t=>t.name.toLowerCase()===e.toLowerCase())?{isValid:!1,errorMessage:`Repository "${e}" already exists.`}:{isValid:!0,successMessage:`New repo "${e}" will be created and your current changes will be pushed to it.`}}return{isValid:!0}}function aH(e,t){const{branches:n,selectedRepository:s,isCreatingNewRepo:i}=t;if(!e)return{isValid:!1,errorMessage:"Branch name is required"};if(!XB(e))return{isValid:!1,errorMessage:"Invalid branch name. Names must follow Git naming rules: only alphanumeric characters and - . / _ are allowed. Cannot contain spaces, consecutive dots (..), begin/end with /, end with ., or contain special characters."};if(i)return{isValid:!0};if(s){if(!n.some(t=>t.name===e))return{isValid:!0,successMessage:`New branch "${e}" will be created and your current changes will be pushed to it.`}}return{isValid:!0}}function rH(e){const{jobId:t,selectedInstallation:n,isCreatingNewRepo:s,newRepoName:i,selectedRepository:a,branchName:r,repositories:o,isLoading:l,secretProtectionError:c}=e;if(!t)return{isValid:!1,errorMessage:"Job ID is required"};if(!n)return{isValid:!1,errorMessage:"Please select a GitHub account"};if(s){const e=iH(i,{repositories:o,isCreatingNewRepo:!0,selectedInstallation:n});if(!e.isValid)return e}else if(!a)return{isValid:!1,errorMessage:"Please select a repository"};const d=aH(r,{branches:[],selectedRepository:a,isCreatingNewRepo:s});return d.isValid?l?{isValid:!1,errorMessage:"Please wait for loading to complete"}:c?{isValid:!1,errorMessage:"Please resolve secret protection issues before pushing"}:{isValid:!0}:d}const oH=({value:e,feedbackType:t="tooltip",defaultText:n="Copy",copiedText:s="Copied!",tooltipText:i="Copy",copiedTooltipText:r="Copied",feedbackDuration:o=1e3,className:l="",buttonClassName:c="",tooltipClassName:d="",children:u,showIcon:p=!0,iconOnly:m=!1,iconProps:h={size:16},copiedClassName:x,onCopy:f,showTooltipOnHover:g=!0,tooltipEnabled:v=!0,tooltipOpen:b,onTooltipOpenChange:y,...w})=>{const[j,C]=Pe.useState(!1),[N,F]=Pe.useState(void 0),_=Pe.useRef(null);Pe.useEffect(()=>()=>{_.current&&clearTimeout(_.current)},[]);const k=async()=>{try{const n="function"==typeof e?e():e;await navigator.clipboard.writeText(n),_.current&&clearTimeout(_.current),C(!0),v&&"tooltip"===t&&F(!0),f&&f(n),_.current=setTimeout(()=>{C(!1),v&&"tooltip"===t&&N&&F(!1)},o)}catch(n){}},S=j?qk:rS,E=j?nS:sS,I=h.clipboard?E:S,A=bb("inline-flex items-center justify-center rounded-md font-inter","transition-all duration-200 focus:outline-none",c||"px-3 py-1 text-sm bg-gray-800 text-white hover:bg-gray-700",j&&"border"===t&&"ring-2 ring-green-400 ring-offset-1"),T=()=>u||(m?a.jsx(I,{...h}):p?a.jsxs(a.Fragment,{children:[a.jsx(I,{...h}),n&&a.jsx("span",{className:"ml-1",children:"text"!==t&&"icon-text"!==t||!j?n:s})]}):"text"!==t&&"icon-text"!==t||!j?n:s),M=void 0!==b?b:N;return v&&"tooltip"===t?a.jsx(ME,{children:a.jsxs(DE,{open:M,onOpenChange:e=>{y?y(e):F(e)},delayDuration:g?0:9999999,children:[a.jsx(LE,{asChild:!0,children:a.jsx("button",{className:bb(A,l,j&&x),onClick:k,type:"button",...w,children:T()})}),a.jsx(PE,{className:bb(d,"bg-[#DDDDE6] text-black border-0"),children:j?r:i})]})}):a.jsx("button",{className:bb(A,l,("text"===t||"icon-text"===t)&&j&&x),onClick:k,type:"button",...w,children:T()})},lH=wv.common.repo,cH=wv.common.saveCloud,dH=wv.common.githubConnect,uH=wv.common.line,pH=wv.icons.github,mH=wv.menuIcons.github,hH=wv.icons.branch,xH=wv.icons.infoSquare,fH=wv.github.arrowGreen,gH=wv.github.shieldLock,vH=wv.github.emergencyHome,bH=wv.github.emergencyHomeRed,yH=wv.github.gitBranch,wH=wv.github.githubGreenDark,jH=wv.github.githubBack,CH=wv.github.gitBranchDark,NH=wv.github.emergencyHomePurple;function FH({isOpen:e,triggerRef:t,children:n,className:s="",scrollableContainerRef:i}){const[r,o]=Pe.useState({top:0,left:0,width:0}),l=Pe.useCallback(()=>{if(e&&t.current){const e=t.current.getBoundingClientRect();if(0===e.width||0===e.height)return;const n=window.innerHeight,s=window.innerWidth,i=300,a=n-e.bottom,r=e.top,l=8,c=120,d=Math.min(i,200);let u=e.bottom+4,p=!1;ad+50&&(u=e.top-d-4,p=!0);const m=s-2*l,h=Math.min(e.width,m);let x=u;if(p)x=Math.max(l,u);else{const e=Math.min(d,a-l);x=Math.min(u,n-e-l)}const f={top:x,left:Math.max(l,Math.min(e.left,s-h-l)),width:h};o(f)}},[e,t]);return Pe.useEffect(()=>{l()},[l]),Pe.useEffect(()=>{if(!e)return;const t=()=>l(),n=()=>l();window.addEventListener("scroll",t,!0),window.addEventListener("resize",n);const s=null==i?void 0:i.current;return s&&s.addEventListener("scroll",t),()=>{window.removeEventListener("scroll",t,!0),window.removeEventListener("resize",n),s&&s.removeEventListener("scroll",t)}},[e,l,i]),e?Be.createPortal(a.jsx("div",{className:`fixed z-[9999] bg-[#131314] border border-[#242424] rounded-md shadow-lg pointer-events-auto ${s}`,style:{top:r.top,left:r.left,width:r.width,maxHeight:"300px",overflowY:"auto",overflowX:"hidden"},"data-portal-dropdown":s,onMouseDown:e=>{e.stopPropagation()},onClick:e=>{e.stopPropagation()},onFocus:e=>{e.stopPropagation()},onWheel:e=>{e.stopPropagation()},children:n}),document.body):null}function _H({podIsPaused:e,isOpen:t,onOpenChange:n,jobId:s,lastGithubUsed:i,onSuccess:r}){var o,l,c,d,u,p;const[m,h]=Pe.useState({showBranchDropdown:!1,showCustomBranchInput:!1,showRepositoryDropdown:!1,showInstallationDropdown:!1}),x=e=>{h(t=>({...t,...e}))},{user:f}=Yg(),[g,v]=Pe.useState("main"),[b,y]=Pe.useState(!1),[w,j]=Pe.useState(""),[C,N]=Pe.useState(!1),[F,_]=Pe.useState([]),[k,S]=Pe.useState(""),[E,I]=Pe.useState(!1),[A,T]=Pe.useState(!0),[M,D]=Pe.useState(""),[L,P]=Pe.useState(""),[R,O]=Pe.useState(!1),[z,B]=Pe.useState(""),[H,$]=Pe.useState(null),[V,U]=Pe.useState(!1),[W,q]=Pe.useState(""),[G,Z]=Pe.useState(!1),[Y,K]=Pe.useState(!1),[J,Q]=Pe.useState(null),[X,ee]=Pe.useState(!1),[te,ne]=Pe.useState(null),[se,ie]=Pe.useState(null),ae=Pe.useRef(null),re=Pe.useRef(null),oe=Pe.useRef(null),le=Pe.useRef(null),ce=Oe(),de=["/verify","/activate","/reset-password","/login","/register","/oauth"].some(e=>ce.pathname.startsWith(e)),{data:ue,refetch:pe}=Sx(void 0,{skip:!t||de||!f}),{data:me,isLoading:he,refetch:xe}=Ex(void 0,{skip:!t||!(null==(o=null==ue?void 0:ue.github)?void 0:o.authorized)}),fe=Pe.useMemo(()=>{if(!M||!me)return"";const e=me.find(e=>e.installation_id===M);return(null==e?void 0:e.account_login)||""},[M,me]),{data:ge,isLoading:ve,refetch:be}=Ix(fe,{skip:!M||!fe}),ye=Pe.useMemo(()=>L&&!R&&fe?{accountLogin:fe,repoName:L}:null,[L,R,fe]),{data:we,isFetching:je,refetch:Ce}=Ax(ye||{accountLogin:"",repoName:""},{skip:!ye}),Ne=()=>fe,Fe=()=>{if(R)return z;const e=null==ge?void 0:ge.find(e=>e.name===L);return(null==e?void 0:e.name)||""},[_e,{isLoading:ke}]=Tx(),[Se,{isLoading:Ee}]=Mx(),[Ie,Ae]=Pe.useState(!1),[Te,Me]=Pe.useState(!1),De=Pe.useMemo(()=>{var e;return iT(me,null==(e=null==ue?void 0:ue.github)?void 0:e.account_name)},[me,null==(l=null==ue?void 0:ue.github)?void 0:l.account_name]),Le=ge||[],Re=(null==(c=null==ue?void 0:ue.github)?void 0:c.authorized)||!1,{toast:ze}=un(),{redirectToGitHubInstallation:Be,isConnecting:He,setIsConnecting:$e}=qA(),Ve=e=>{if(!e){if(X&&te&&r){const e={branch:te.branch,repo:te.repo,owner:te.owner,provider:"github"};r(e)}h({showBranchDropdown:!1,showCustomBranchInput:!1,showRepositoryDropdown:!1,showInstallationDropdown:!1}),N(!1),v("main"),_([]),S(""),I(!1),T(!0),D(""),P(""),O(!1),B(""),j(""),$(null),U(!1),q(""),Z(!1),K(!1),Q(null),ee(!1),ne(null),ie(null),Ae(!1),Me(!1)}n(e)},Ue=Pe.useCallback(()=>{if(H&&H.includes("Conflict Detected")){N(!0),U(!0);const e=new Date,t=e.toISOString().slice(0,10).replace(/-/g,""),n=e.toTimeString().slice(0,2)+e.toTimeString().slice(3,5);q(`conflict_${t}_${n}`)}else N(!1),U(!1),q("")},[H]);Pe.useEffect(()=>{Ue()},[Ue]),Pe.useEffect(()=>{if(!t)return;if(T(!0),N(!1),v("main"),ue){const e=setTimeout(()=>{T(!1)},500);return()=>clearTimeout(e)}const e=setTimeout(()=>{T(!1)},5e3);return()=>clearTimeout(e)},[t,ue]);const We=Pe.useCallback(()=>{P(""),j(""),_([]),O(!1),B(""),I(!1),v("main"),setTimeout(()=>{const e=document.querySelector(".repository-input input");e&&(e.value="")},0)},[]);Pe.useEffect(()=>{M&&We()},[M,We]),Pe.useEffect(()=>{Re&&He&&$e(!1)},[Re,He,$e]);const qe=Pe.useMemo(()=>{if(!we||!Array.isArray(we)||0===we.length)return"main";if(i){const e=we.find(e=>e.name===i.branch);if(e)return e.name}const e=we.find(e=>"main"===e.name||"master"===e.name);return e?e.name:we[0].name},[we,i]);Pe.useEffect(()=>{we&&Array.isArray(we)?(_(we),v(qe)):_([])},[we,qe,R,L]);const Ge=Pe.useRef(R);Pe.useEffect(()=>{if(Ge.current&&!R&&L&&fe&&!je){const e=setTimeout(async()=>{try{await Ce()}catch(e){}},50);return()=>clearTimeout(e)}Ge.current=R},[R,L,fe,je,Ce]);const Ze=Le.filter(e=>!w||e.name.toLowerCase().includes(w.toLowerCase())),Ye=Pe.useRef(g),Ke=Pe.useRef(L);Pe.useEffect(()=>{const e=Ye.current!==g,t=Ke.current!==L;if((e||t)&&(Y&&(K(!1),Z(!1),N(!1),q(""),$(null)),J)){const e=Ne(),t=Fe();J.repository===t&&J.branch===g&&J.owner===e&&!Y&&(K(!0),N(!0),q(nH()))}Ye.current=g,Ke.current=L},[g,L,Y,J]),Pe.useEffect(()=>{Y&&le.current&&setTimeout(()=>{if(le.current){const e=le.current,t=e.scrollHeight-e.clientHeight,n=e.scrollTop,s=t-n,i=800,a=performance.now(),r=e=>e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1,o=t=>{const l=t-a,c=Math.min(l/i,1),d=r(c);e.scrollTop=n+s*d,c<1&&requestAnimationFrame(o)};requestAnimationFrame(o)}},150)},[Y]);const Je=()=>Te?{isValid:!0}:iH(z,{repositories:Le,isCreatingNewRepo:R,selectedInstallation:M}),Qe=()=>aH(g,{branches:F,selectedRepository:L,isCreatingNewRepo:R}),Xe=()=>{const e=De.find(e=>e.installation_id===M);return"User"===(null==e?void 0:e.account_type)&&!(null==e?void 0:e.isPrimary)},et=async t=>{var i;t.preventDefault(),Ae(!0);try{if(!s||!M)return;if(e)return ze({title:"Pod is paused",description:"Please unpause your pod before pushing to GitHub",variant:"destructive"}),void n(!1);const t=Ne(),a=Fe();if(!t||!a)return;if((()=>{if(!J)return!1;const e=Ne(),t=Fe();return J.repository===t&&J.branch===g&&J.owner===e})())return void ze({title:"Conflict detected",description:"This repository and branch combination has a conflict. Please resolve it using the options below.",variant:"destructive"});R&&(Me(!0),await _e({installation_id:M,org:"User"!==(null==(i=De.find(e=>e.installation_id===M))?void 0:i.account_type)?t:void 0,name:a}).unwrap(),await new Promise(e=>setTimeout(e,1500))),await Se({jobId:s,data:{account_login:t,repo_name:a,branch_name:g,is_new_repo:R,force:C}}).unwrap(),K(!1),Z(!1),N(!1),$(null),Q(null),ne({branch:g,repo:a,owner:t,isNewRepo:R,isNewBranch:!1}),ee(!0),Me(!1)}catch(a){const e=sH(a,{defaultErrorMessage:"Failed to push to GitHub",needsForcePush:C,allowConflictDetection:!0});switch(e.type){case"secret_protection":return void ie({fullError:e.fullErrorText,learnMoreUrl:e.learnMoreUrl,isExpanded:!1});case"remote_rejection":if(e.shouldShowConflictUI)return K(!0),N(!0),q(nH()),void Q({repository:Fe(),branch:g,owner:Ne()})}$(e.errorMessage),ze({title:"Error",description:e.errorMessage,variant:"destructive"})}finally{Ae(!1),Me(!1)}},tt=A||he||ve,nt=Ie||Ee||ke,st=async()=>{$e(!0);const e=async()=>{try{const e=await pe();return!(!e.data||!e.data.github||!0!==e.data.github.authorized)&&(await xe(),ze({title:"Success",description:"Successfully connected to GitHub"}),!0)}catch(e){return!1}finally{$e(!1)}};try{Be({isPopup:!0,pollingEnabled:!1,onSuccess:async()=>{await e()}}),(()=>{let t=0;const n=setInterval(async()=>{t++;const s=await e();(s||t>=10)&&(clearInterval(n),!s&&t>=10&&$e(!1))},3e3);setTimeout(()=>{clearInterval(n),$e(!1)},31e3)})()}catch(t){$e(!1),ze({title:"Error",description:"Failed to connect to GitHub",variant:"destructive"})}};Pe.useEffect(()=>{const e=e=>{const t=e.target;!m.showInstallationDropdown||t.closest(".installation-dropdown")||t.closest(".installation-input")||x({showInstallationDropdown:!1}),!m.showRepositoryDropdown||t.closest(".repository-dropdown")||t.closest(".repository-input")||t.closest(".repo-toggle-buttons")||x({showRepositoryDropdown:!1}),!m.showBranchDropdown||t.closest(".branch-dropdown")||t.closest(".branch-input")||t.closest("#branch-selector")||x({showBranchDropdown:!1}),!m.showCustomBranchInput||t.closest("[data-portal-dropdown='branch-dropdown custom-branch-input']")||t.closest("#branch-selector")||(t.closest(".modal-backdrop")||t.closest("[data-dialog-close]"))&&(x({showCustomBranchInput:!1}),S(""))};if((m.showInstallationDropdown||m.showRepositoryDropdown||m.showBranchDropdown||m.showCustomBranchInput)&&!m.showCustomBranchInput)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[m.showInstallationDropdown,m.showRepositoryDropdown,m.showBranchDropdown,m.showCustomBranchInput]),Pe.useEffect(()=>{t||x({showInstallationDropdown:!1,showRepositoryDropdown:!1,showBranchDropdown:!1,showCustomBranchInput:!1})},[t]);const it=Pe.useMemo(()=>{var e;if(0===De.length||he||M)return null;if(i&&i.owner){const e=De.find(e=>e.account_login===i.owner);if(e)return e.installation_id}const t=De.find(e=>e.isPrimary);return t?t.installation_id:(null==(e=De[0])?void 0:e.installation_id)||null},[i,De,he,M]);Pe.useEffect(()=>{it&&D(it)},[it]);const at=Pe.useMemo(()=>{if(!i||ve||0===Le.length||!M)return{repoName:"",branchName:"main"};const e=De.find(e=>e.installation_id===M);return e&&e.account_login===i.owner?{repoName:i.repo,branchName:i.branch||"main"}:{repoName:"",branchName:"main"}},[i,Le,ve,M,De]);return Pe.useEffect(()=>{at.repoName&&(P(at.repoName),j(at.repoName)),v(at.branchName)},[at]),Re?a.jsx(a.Fragment,{children:a.jsx(IA,{open:t,onOpenChange:Ve,children:a.jsxs(LA,{className:bb("max-w-[700px] p-0 overflow-visible transition-all duration-300 ease-in-out top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2",G||X&&"overflow-hidden"),hideclosebutton:!0,children:[He&&a.jsx("div",{className:"absolute inset-0 z-50 flex flex-col items-center justify-center bg-[#0F0F10]/90 backdrop-blur-sm",children:a.jsxs("div",{className:"flex flex-col items-center justify-center p-6 rounded-lg",children:[a.jsx(gS,{className:"w-12 h-12 text-[#00E573] animate-spin mb-4"}),a.jsx("p",{className:"text-lg font-medium text-white",children:"Connecting to GitHub..."})]})}),!G&&!X&&a.jsxs("div",{className:"flex items-center gap-2 px-4 md:px-8 max-h-[98px] py-6 border-b border-[#242424]",children:[a.jsx("div",{className:"flex items-center justify-center bg-[#ffffff05] p-2 rounded-full",children:a.jsx("img",{src:mH,alt:"GitHub",className:"w-6 h-6"})}),a.jsx("h2",{className:"text-[22px] font-medium text-white",children:"Save to Github"}),a.jsx(MA,{className:"ml-auto",children:a.jsx(HS,{className:"w-5 h-5 text-gray-400 hover:text-white"})})]}),a.jsxs("div",{ref:le,className:"relative max-h-[500px] overflow-y-auto",children:[tt&&a.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center bg-[#0F0F10] transition-opacity duration-300 ease-in-out",children:[a.jsx(gS,{className:"h-8 w-8 text-[#00FF85] animate-spin mb-4"}),a.jsx("p",{className:"text-[#DDDDE6]/70 text-sm",children:A?"Connecting to GitHub...":he?"Loading GitHub accounts...":"Loading repositories..."})]}),X&&te?a.jsxs(a.Fragment,{children:[a.jsx("img",{src:uH,className:"absolute top-0 left-0 right-0 z-[-1] w-full pointer-events-none",alt:"Line"}),a.jsx(MA,{className:"absolute z-20 p-2 rounded-md group backdrop-blur-lg bg-white/5 top-8 right-8",children:a.jsx(HS,{className:"w-5 h-5 text-gray-400 group-hover:text-white"})}),a.jsx("div",{className:"p-8 pt-[10rem] space-y-6",children:a.jsxs("div",{className:"flex flex-col items-start w-full gap-6",children:[a.jsx("img",{src:wH,alt:"GitHub",className:"w-16 h-16 mb-4"}),a.jsxs("div",{className:"space-y-2 text-start",children:[a.jsx("h2",{className:"text-2xl font-medium text-white",children:"Successfully Saved to GitHub!"}),a.jsxs("p",{className:"text-[#737780] font-medium font-['Inter']",children:["Your changes have been saved to"," ",a.jsxs("span",{className:"text-[#fff] font-medium font-['Inter']",children:[te.owner,"/",te.repo,",",a.jsx("br",{})]}),"Continue working on your task or view the codebase on GitHub."]})]}),a.jsxs("div",{onClick:()=>{const e=`https://github.com/${te.owner}/${te.repo}/tree/${te.branch}`;window.open(e,"_blank")},className:"bg-[#18181A] mb-4 w-full cursor-pointer flex justify-between items-center border border-[#242424] rounded-lg p-4 gap-2",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("img",{src:pH,alt:"GitHub",className:"w-6 h-6"}),a.jsxs("span",{className:"font-medium font-['Inter'] text-white text-nowrap",children:[te.owner," \\ ",te.repo]})]}),a.jsxs("div",{className:"flex items-center",children:[a.jsx("img",{src:yH,alt:"Branch",className:"w-5 h-5 opacity-50 grayscale"}),a.jsx("span",{className:"font-medium text-[#626266] truncate",children:te.branch})]})]}),a.jsx("div",{className:"flex items-center gap-2 cursor-pointer group hover:opacity-80",children:a.jsxs("span",{className:"flex group-hover:text-[#2EE572] items-center text-nowrap gap-2 text-[#626266] font-medium",children:["View on GitHub",a.jsx("img",{src:fH,alt:"Arrow",className:bb("w-6 h-6 grayscale opacity-35 group-hover:opacity-100 group-hover:grayscale-0")})]})})]})]})})]}):G?a.jsxs("div",{className:"p-4 space-y-6 md:p-8",children:[a.jsxs("div",{className:"flex items-start w-full gap-2",children:[a.jsxs("div",{className:"space-y-1",children:[a.jsx("h2",{className:"text-2xl font-medium text-white",children:"Confirm force push to"}),a.jsxs("p",{className:"text-[#E38F45] font-medium text-[22px] leading-[28px] tracking-[-2%]",children:['"',g,'"']})]}),a.jsx("div",{onClick:()=>Z(!1),className:"z-20 rounded-sm p-1 group ml-auto bg-[#FFFFFF05] backdrop-blur-lg hover:bg-[#FFFFFF12]",children:a.jsx(HS,{className:"z-20 w-5 h-5 text-gray-400 group-hover:text-white top-12 right-12"})})]}),a.jsx("div",{className:"space-y-4",children:a.jsxs("p",{className:"text-[#B7BECC] font-['Inter'] font-medium leading-[24px] text-[15px] md:max-w-[80%]",children:["Are you sure you want to force push? ",a.jsx("br",{}),"This will replace everything on"," ",a.jsxs("span",{className:"font-semibold text-[#FFA04D]",children:["'",g,"'"]})," ","with your current changes — and can't be undone."]})})]}):a.jsxs("form",{onSubmit:et,className:"p-4 space-y-4 md:space-y-6 md:p-8",onClick:e=>{},children:[a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("img",{src:pH,alt:"GitHub",className:"w-5 h-5 opacity-70"}),a.jsx("span",{className:"text-sm text-gray-400",children:"Connected Organizations"})]}),a.jsxs("div",{className:"relative",children:[a.jsxs("div",{ref:re,className:`flex items-center justify-between w-full h-14 bg-[#131314] border ${m.showInstallationDropdown?"border-white/50":"border-[#242424]"} rounded-md p-3 text-white installation-input`,onClick:()=>{x({showRepositoryDropdown:!1,showBranchDropdown:!1,showInstallationDropdown:!m.showInstallationDropdown})},children:[a.jsx("div",{className:"flex items-center w-full",children:a.jsx("div",{className:"relative flex-1",children:M?a.jsxs("div",{className:"flex items-center",children:[(null==(d=De.find(e=>e.installation_id===M))?void 0:d.account_login)||"Select a GitHub account","User"===(null==(u=De.find(e=>e.installation_id===M))?void 0:u.account_type)&&!(null==(p=De.find(e=>e.installation_id===M))?void 0:p.isPrimary)&&a.jsx("span",{className:"text-xs text-[#DDDDE6] rounded-full bg-[#FFFFFF0D] ml-1 px-2 py-1 font-['Inter'] font-medium",children:"Collaborator"})]}):a.jsx("span",{className:"text-[#8F8F98]",children:"Select a GitHub account"})})}),a.jsx(Gk,{className:"h-4 w-4 text-[#898F99] transition-transform duration-200 "+(m.showInstallationDropdown?"rotate-180":"")})]}),a.jsx(FH,{isOpen:De.length>0&&m.showInstallationDropdown,triggerRef:re,className:"installation-dropdown",scrollableContainerRef:le,children:a.jsxs("div",{className:"flex flex-col gap-[6px] p-2",children:[De.map(e=>a.jsx("div",{className:bb("px-3 min-h-[40px] rounded-[8px] py-2 text-[#DDDDE6] hover:bg-[#2D2D2F]/40 font-medium cursor-pointer",M===e.installation_id&&"bg-[#172426] text-[#1BB4CC] hover:bg-[#172426] hover:text-[#1BB4CC]"),onClick:()=>{if(e.installation_id===M)return void x({showInstallationDropdown:!1});P(""),j(""),_([]),O(!1),B(""),I(!1),x({showRepositoryDropdown:!1,showBranchDropdown:!1,showInstallationDropdown:!1}),D(e.installation_id);const t=document.querySelector(".repository-input input");t&&(t.value="")},children:a.jsxs("div",{className:"flex items-center justify-between w-full",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{children:e.account_login}),"User"===e.account_type&&!e.isPrimary&&a.jsx("span",{className:"text-xs text-[#DDDDE6] rounded-full bg-[#FFFFFF0D] ml-1 px-2 py-1 font-['Inter'] font-medium",children:"Collaborator"})]}),M===e.installation_id&&a.jsx(qk,{className:"h-4 w-4 text-[#1BB4CC]"})]})},e.installation_id)),a.jsx("div",{className:"border-t border-[#ffffff12]"}),a.jsx("div",{className:"px-3 min-h-[40px] rounded-[8px] py-2 text-[#4ADE80] hover:bg-[#4ADE80]/10 font-medium "+(He?"opacity-50 cursor-not-allowed":"cursor-pointer"),onClick:()=>{He||(st(),x({showInstallationDropdown:!1}))},children:a.jsxs("div",{className:"flex items-center gap-2",children:[He?a.jsx(gS,{className:"w-4 h-4 animate-spin"}):a.jsx(NS,{className:"w-4 h-4"}),He?"Connecting...":"Add New Github Organizations"]})})]})})]}),0===De.length&&!A&&!he&&a.jsx("p",{className:"text-[#FF4545] text-sm",children:"No GitHub accounts connected. Please connect a GitHub account."})]}),a.jsxs("div",{className:"space-y-3",children:[a.jsx("div",{className:"flex items-center justify-between",children:a.jsxs("div",{className:"flex items-center justify-between w-full gap-2",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("img",{src:lH,alt:"Repository",className:"w-5 h-5"}),a.jsx("span",{className:"text-[#898F99] text-sm font-medium font-[Inter]",children:"Selected Repo"})]}),M&&a.jsx("button",{type:"button",className:"flex items-center justify-center w-6 h-6 ml-1 rounded-full hover:bg-blue-400/5 group",onClick:async()=>{!M||ve||b||(y(!0),await be(),y(!1))},disabled:ve||b,title:"Refresh repositories",children:a.jsx(kS,{className:"h-3.5 w-3.5 text-[#898F99] group-hover:text-white "+(b?"animate-spin":"")})})]})}),a.jsxs("div",{className:"relative",children:[a.jsxs("div",{ref:oe,className:`flex items-center justify-between w-full h-14 bg-[#131314] border ${m.showRepositoryDropdown?"border-white/50":"border-[#242424]"} rounded-md p-3 text-white repository-input`,children:[a.jsxs("div",{className:"flex items-center w-full",children:[a.jsx(ES,{className:"h-4 w-4 text-[#8F8F98] mr-2"}),a.jsxs("div",{className:"relative flex-1",children:[a.jsx(KS,{type:"text",value:w,onChange:e=>{const t=e.target.value,n=eH(t);if(j(n),n!==w&&(P(""),_([]),v("main")),R)return B(n),void I(!1);const s=Le.find(e=>e.name.toLowerCase()===n.toLowerCase());if(s)P(s.name),x({showRepositoryDropdown:!1}),I(!1);else if(n){P(""),x({showRepositoryDropdown:!0});const e=Le.some(e=>e.name.toLowerCase().includes(n.toLowerCase()));I(!e&&n.length>0),_([])}else P(""),I(!1),_([])},onFocus:()=>{R||x({showBranchDropdown:!1,showInstallationDropdown:!1,showRepositoryDropdown:!0})},placeholder:R?"Enter new repository name":"Search for a repository",className:"w-full p-0 bg-transparent border-0 focus-visible:ring-0 focus-visible:ring-offset-0",disabled:!M||R&&Xe()}),L&&!R&&a.jsx("button",{type:"button",className:"absolute right-0 flex items-center justify-center w-6 mr-1 h-6 transform hover:bg-[#ffffff05] -translate-y-1/2 rounded-full top-1/2",onClick:()=>{P(""),j(""),_([]),v("main"),x({showRepositoryDropdown:!0})},title:"Clear selected repository",children:a.jsx(HS,{className:"h-3.5 w-3.5 text-[#898F99]"})})]})]}),a.jsxs("div",{className:"flex text-sm text-nowrap bg-[#ffffff15] p-[6px] rounded-full font-semibold cursor-pointer repo-toggle-buttons",children:[a.jsx("span",{className:"px-[10px] py-1 rounded-full transition-colors "+(R?"text-white/50 hover:text-white/80 font-medium":"bg-white text-black"),onClick:async()=>{if(O(!1),x({showBranchDropdown:!1,showInstallationDropdown:!1,showRepositoryDropdown:!!(M&&Le.length>0)}),w){const t=Le.find(e=>e.name.toLowerCase()===w.toLowerCase());if(t){if(P(t.name),j(t.name),I(!1),fe)try{await Ce()}catch(e){}}else P(""),I(!0),_([]),v("main")}else if(L){const t=Le.find(e=>e.name===L);if(t){if(j(t.name),I(!1),fe)try{await Ce()}catch(e){}}else P(""),_([]),v("main")}else _([]),v("main")},children:"Select Repo"}),a.jsx("span",{className:"px-[10px] py-1 rounded-full transition-colors "+(R?"bg-white text-black ":Xe()?"text-white/20 cursor-not-allowed":"text-white/50 hover:text-white/80 font-medium"),onClick:()=>{if(!Xe()){if(O(!0),x({showRepositoryDropdown:!1,showBranchDropdown:!1,showInstallationDropdown:!1}),P(""),I(!1),w)B(w);else{const e=Le.find(e=>e.name===L);e&&(B(e.name),j(e.name))}_([]),v("main")}},children:"Create New"})]})]}),a.jsx(FH,{isOpen:Le.length>0&&Ze.length>0&&m.showRepositoryDropdown&&!R,triggerRef:oe,className:"repository-dropdown",scrollableContainerRef:le,children:a.jsx("div",{className:"px-2 py-1 flex flex-col gap-[6px]",children:Ze.map(e=>a.jsx("div",{className:bb("px-3 min-h-[40px] rounded-[8px] py-2 text-[#DDDDE6] hover:bg-[#2D2D2F]/40 font-medium cursor-pointer",e.permissions.push?"":"opacity-20",L===e.name&&"bg-[#172426] text-[#1BB4CC]"),onClick:t=>{t.preventDefault(),t.stopPropagation(),e.permissions.push?(P(e.name),j(e.name),O(!1),B(""),x({showRepositoryDropdown:!1}),I(!1)):ze({title:"You don't have push access to this repository.",description:"Please select a repository you have push access to.",variant:"destructive"})},children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{children:e.name}),(null==i?void 0:i.repo)===e.name&&(null==i?void 0:i.owner)===Ne()&&a.jsx(dE,{variant:"secondary",className:"bg-green-700",children:"Last used"})]})},e.id))})}),M&&R&&Xe()&&a.jsxs("p",{className:"text-[#FF4545] text-sm mt-2 flex items-center gap-1",children:[a.jsx("img",{src:xH,alt:"Info",className:"w-3 h-3"}),a.jsx("span",{children:"You don't have permission to create repositories in an organization where you're a collaborator."})]}),M&&R&&!z&&a.jsx("p",{className:"text-[#DDDDE6]/50 text-sm mt-2",children:"Enter a name for your new repository"}),M&&R&&z&&!Je().isValid&&a.jsx("p",{className:"text-[#FF4545] text-sm mt-2",children:Je().errorMessage}),M&&R&&z&&Je().isValid&&a.jsx("span",{className:"text-[#CCC] text-sm mt-2 flex items-center gap-1",children:Je().successMessage&&a.jsxs(a.Fragment,{children:[a.jsx("img",{src:xH,alt:"Info",className:"w-3 h-3"}),a.jsx("span",{className:"text-[#00FF85]",children:Je().successMessage})]})}),M&&0===Le.length&&a.jsx("p",{className:"text-[#DDDDE6]/50 text-sm mt-2",children:"No repositories found. Enter a name to create a new one."}),M&&!R&&E&&w&&a.jsxs("p",{className:"text-[#FF4545] text-sm mt-2 flex items-center gap-1",children:[a.jsx("img",{src:xH,alt:"Info",className:"w-3 h-3"}),a.jsxs("span",{children:["Repository"," ",a.jsxs("span",{className:"font-semibold",children:['"',w,'"']})," ",'doesn\'t exist. Switch to "Create New" to create it.']})]})]})]}),a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("img",{src:hH,alt:"Branch",className:"w-5 h-5"}),a.jsx("span",{className:"text-[#898F99] text-sm font-medium font-[Inter]",children:"Branch"})]}),L&&!R&&a.jsx("div",{className:"flex items-center gap-2",children:a.jsx("button",{type:"button",className:"flex items-center justify-center w-6 h-6 ml-1 rounded-full hover:bg-blue-400/5 group",onClick:async()=>{!L||je||R||await Ce()},disabled:je,title:"Refresh branches",children:a.jsx(kS,{className:"h-3.5 w-3.5 text-[#898F99] group-hover:text-white "+(b?"animate-spin":"")})})})]}),je?a.jsx("div",{className:"flex items-center justify-center h-14 bg-[#131314] border border-[#242424] rounded-md",children:a.jsx(gS,{className:"h-4 w-4 text-[#00FF85] animate-spin"})}):R?a.jsxs("div",{className:"space-y-2",children:[a.jsx("div",{className:"relative",children:a.jsx("div",{className:"flex items-center justify-between w-full h-14 bg-[#131314] border border-[#242424] rounded-md p-3 text-white",children:a.jsx("div",{className:"flex items-center w-full branch-input",children:a.jsxs("div",{className:"relative flex-1",children:[a.jsx(KS,{type:"text",value:g,onChange:e=>{const t=e.target.value,n=eH(t);v(n),m.showCustomBranchInput},placeholder:"Branch name (e.g., main)",className:"w-full p-0 bg-transparent border-0 focus-visible:ring-0 focus-visible:ring-offset-0",disabled:!M||!z&&R}),g&&a.jsx(Nb,{type:"button",variant:"ghost",size:"icon",className:"absolute right-0 w-6 h-6 transform -translate-y-1/2 rounded-full top-1/2",onClick:()=>{v("main")},title:"Clear branch name",disabled:!M||!z&&R,children:a.jsx(HS,{className:"h-3.5 w-3.5 text-[#898F99]"})})]})})})}),g&&!Qe().isValid&&a.jsx("div",{className:"text-[#FF4545] text-sm mt-2",children:Qe().errorMessage})]}):a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"relative",children:[a.jsxs("div",{className:"relative",children:[a.jsxs("div",{ref:ae,className:bb(`flex items-center justify-between w-full h-14 bg-[#131314] border ${m.showBranchDropdown?"border-white/50":"border-[#242424]"} rounded-md p-3 text-[#C4C4CC] branch-input`,Y?"border border-[#E38F4533]":se?"border border-[#A199FF33]":""),onClick:()=>{M&&L&&0!==F.length&&x({showRepositoryDropdown:!1,showInstallationDropdown:!1,showBranchDropdown:!m.showBranchDropdown})},id:"branch-selector",children:[a.jsx("div",{className:"flex items-center w-full",children:a.jsx("div",{className:"relative flex-1",children:g?a.jsx("div",{className:"flex items-center",children:g}):a.jsx("span",{className:"text-[#8F8F98]",children:"Select a branch"})})}),(Y||se)&&a.jsx("img",{src:Y?vH:NH,alt:"Branch",className:"w-6 h-6 mr-4"}),a.jsx(Gk,{className:"h-4 w-4 text-[#898F99] transition-transform duration-200 "+(m.showBranchDropdown?"rotate-180":"")})]}),a.jsx(FH,{isOpen:F.length>0&&m.showBranchDropdown,triggerRef:ae,className:"branch-dropdown",scrollableContainerRef:le,children:a.jsxs("div",{className:"flex flex-col gap-[6px] p-2 max-h-[210px]",children:[F.map(e=>a.jsx("div",{className:bb("px-3 min-h-[40px] rounded-[8px] py-2 text-[#DDDDE6] hover:bg-[#2D2D2F]/40 font-medium cursor-pointer",g===e.name&&"bg-[#172426] text-[#1BB4CC] hover:bg-[#172426] hover:text-[#1BB4CC]"),onClick:()=>{v(e.name),x({showBranchDropdown:!1,showRepositoryDropdown:!1,showInstallationDropdown:!1})},children:a.jsxs("div",{className:"flex items-center justify-between w-full",children:[a.jsx("span",{children:e.name}),g===e.name&&a.jsx(qk,{className:"h-4 w-4 text-[#1BB4CC]"})]})},e.name)),a.jsx("div",{className:"border-t border-[#ffffff12] mt-2"}),a.jsx("div",{className:"px-3 min-h-[40px] rounded-[8px] py-2 text-[#4ADE80] hover:bg-[#4ADE80]/10 font-medium cursor-pointer",onClick:e=>{e.preventDefault(),e.stopPropagation(),S(g||"main"),x({showCustomBranchInput:!0,showBranchDropdown:!1})},children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(NS,{className:"w-4 h-4"}),"Create New Branch"]})})]})})]}),a.jsx(FH,{isOpen:m.showCustomBranchInput,triggerRef:ae,className:"branch-dropdown custom-branch-input",scrollableContainerRef:le,children:a.jsxs("div",{className:"p-3 space-y-3",onMouseDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),children:[a.jsx("div",{className:"text-sm text-[#898F99]",children:"Enter a new branch name:"}),a.jsx("div",{className:"flex items-center w-full branch-input",children:a.jsx("div",{className:"relative flex-1",children:a.jsx(KS,{type:"text",value:k,onChange:e=>{const t=eH(e.target.value);S(t)},onKeyDown:e=>{"Enter"===e.key&&XB(k)&&(v(k),x({showCustomBranchInput:!1})),"Escape"===e.key&&(x({showCustomBranchInput:!1}),S(""))},placeholder:"Branch name (e.g., feature/my-new-branch)",className:"w-full p-2 bg-[#1A1A1C] border border-[#242424] rounded-md focus-visible:ring-0 focus-visible:border-white/50 focus-visible:ring-offset-0 text-white",autoFocus:!0})})}),k&&!XB(k)&&a.jsx("div",{className:"text-[#FF4545] text-xs",children:"Invalid branch name. Names must follow Git naming rules."}),a.jsxs("div",{className:"flex justify-end gap-2 mt-3",children:[a.jsx(Nb,{type:"button",variant:"outline",size:"sm",onClick:()=>{x({showCustomBranchInput:!1}),S("")},className:"border-[#242424] text-gray-300 hover:bg-[#1a1a1c] bg-transparent",children:"Cancel"}),a.jsx(Nb,{type:"button",size:"sm",onClick:()=>{XB(k)&&(v(k),x({showCustomBranchInput:!1}))},disabled:!XB(k),className:"bg-[#00FF85] hover:bg-[#00FF85]/90 text-black font-medium",children:"Use Branch"})]})]})})]}),g&&!Qe().isValid&&a.jsx("div",{className:"text-[#FF4545] text-sm mt-2",children:Qe().errorMessage}),L&&!R&&je&&a.jsxs("div",{className:"text-[#898F99] text-sm font-medium font-[Inter] flex items-center gap-1",children:[a.jsx(gS,{className:"w-3 h-3 animate-spin"}),a.jsx("span",{children:"Checking branches..."})]}),g&&Qe().isValid&&Qe().successMessage&&L&&!je&&a.jsxs("div",{className:"text-[#898F99] text-sm font-medium font-[Inter] flex items-center gap-1",children:[a.jsx("img",{src:xH,alt:"Info",className:"w-3 h-3"}),a.jsx("span",{className:"text-[#00FF85]",children:Qe().successMessage})]})]}),Y&&!G?a.jsxs("div",{className:"space-y-[10px]",children:[a.jsxs("div",{className:"bg-[#1F1B18] rounded-[10px] p-3 flex items-start gap-6",children:[a.jsxs("div",{className:"flex flex-col gap-2",children:[a.jsxs("div",{className:"flex items-center gap-[6px]",children:[a.jsx("img",{alt:"Warning",src:vH,className:"w-5 h-5"}),a.jsx("span",{className:"text-[#E38F45] text-[14px] font-medium font-['Inter']",children:"Changes conflict detected"})]}),a.jsxs("p",{className:"text-[#99897A] text-[13px] font-['Inter'] leading-[20px] font-medium",children:["Your changes conflict with what's already on the"," ",a.jsxs("span",{className:"text-[#FFE4CC] font-semibold font-['Inter']",children:["'",g,"'"]})," ","branch. You can force push to replace it, but this will permanently erase what's currently there."]})]}),a.jsx("button",{type:"button",onClick:()=>Z(!0),className:"ml-auto bg-[#2E2720] text-[#CC9666] w-fit text-nowrap font-medium px-[10px] py-[6px] rounded-[6px] tracking-[-0.2px]",children:"Force Push anyway"})]}),a.jsxs("div",{className:"bg-[#00E5731A] rounded-[10px] p-3 flex flex-col gap-4",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("img",{alt:"Warning",src:yH,className:"w-5 h-5"}),a.jsx("span",{className:"text-[#00E573] font-medium text-[14px] font-['Inter']",children:"Recommended Solution"})]}),a.jsxs("p",{className:"text-[#FFFFFF60] text-[13px] font-medium font-['Inter']",children:[a.jsx("span",{className:"font-semibold font-['Inter'] text-white",children:"Save your changes to a new branch."})," ","This keeps your work safe and allows for proper conflict resolution on GitHub."]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("label",{className:"text-[#FFFFFF] text-[13px] font-['Inter'] font-medium",children:"Proposed branch name :"}),a.jsx(KS,{type:"text",value:W,onChange:e=>q(e.target.value),className:"w-full px-4 py-3 bg-[#80FFF90D] border border-[#80FFF94D] text-white focus:border-[#80FFF9] focus:ring-[#80FFF94D]",placeholder:"Enter branch name"})]})]})]}):null,se&&a.jsx("div",{className:"space-y-4",children:a.jsx("div",{className:"bg-[#A199FF0D] rounded-[10px] p-4",children:a.jsx("div",{className:"flex items-start gap-3",children:a.jsxs("div",{className:"flex-1 space-y-3",children:[a.jsxs("div",{className:"flex justify-between gap-2",children:[a.jsxs("div",{className:"flex flex-col gap-2",children:[a.jsxs("div",{className:"flex items-start gap-[6px]",children:[a.jsx("img",{src:gH,alt:"Warning",className:"w-5 h-5"}),a.jsx("h4",{className:"text-[#A199FF] font-medium font-['Inter'] text-[16px] mb-1 leading-[20px]",children:"Security Protection Activated"})]}),a.jsx("p",{className:"text-[#A199FF50] font-medium text-[13px] font-['Inter'] leading-[20px]",children:"We detected a secret key in your code and blocked this upload to protect you."})]}),(null==se?void 0:se.learnMoreUrl)&&a.jsx("button",{type:"button",onClick:()=>window.open(null==se?void 0:se.learnMoreUrl,"_blank"),className:" text-[#FFFFFF60] flex gap-1 items-center px-3 hover:bg-[#FFFFFF]/10 transition-all duration-150 ease-out hover:text-[#ffffff80] bg-[#FFFFFF0F] w-fit text-nowrap font-medium text-[16px] h-8 rounded-[8px]",children:"Learn how to fix this?"})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("button",{type:"button",onClick:()=>ie(e=>e?{...e,isExpanded:!e.isExpanded}:null),className:bb("flex items-center gap-2 font-['Inter'] text-[#ffffff40] hover:text-[#FFFFFF80] text-[13px] font-medium transition-colors",{"text-[#FFFFFF80]":null==se?void 0:se.isExpanded}),children:["View error details",a.jsx(Gk,{className:"w-4 h-4 transition-transform "+((null==se?void 0:se.isExpanded)?"rotate-180":"")})]}),(null==se?void 0:se.isExpanded)&&a.jsxs("div",{className:"bg-[#FFFFFF08] rounded-[8px] relative backdrop-blur-lg p-3 md:max-w-[600px] mt-2 max-h-[300px]",children:[a.jsx(oH,{showIcon:!0,iconOnly:!0,className:"absolute border-none opacity-45 hover:opacity-100 bg-none right-3 top-3",value:null==se?void 0:se.fullError,tooltipText:"Copy",copiedTooltipText:"Copied",buttonClassName:"p-0",feedbackType:"tooltip",iconProps:{size:16},onCopy:()=>{navigator.clipboard.writeText(null==se?void 0:se.fullError)}}),a.jsx("pre",{className:"text-[#FFFFFF50] text-[14px] whitespace-pre-wrap break-words w-full leading-[16px] max-h-[200px] font-[400] overflow-y-auto font-jetbrains",children:null==se?void 0:se.fullError})]})]})]})})})}),H&&!se&&a.jsxs("div",{className:"flex flex-col gap-2",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("img",{src:bH,alt:"Error",className:"w-5 h-5"}),a.jsx("h4",{className:"text-red-400 font-medium text-[14px] font-[Inter] leading-[20px]",children:"Error"})]}),a.jsxs("div",{className:"bg-[#FFFFFF08] rounded-[8px] relative backdrop-blur-lg p-3 md:max-w-[600px] mt-2 max-h-[300px]",children:[a.jsx(oH,{showIcon:!0,iconOnly:!0,value:H,className:"absolute border-none opacity-45 hover:opacity-100 bg-none right-3 top-3",tooltipText:"Copy",copiedTooltipText:"Copied",buttonClassName:"p-0",feedbackType:"tooltip",iconProps:{size:16},onCopy:()=>{navigator.clipboard.writeText(H)}}),a.jsx("pre",{className:"text-[#FFFFFF50] text-[14px] whitespace-pre-wrap break-words w-full leading-[16px] max-h-[200px] font-[400] overflow-y-auto font-jetbrains",children:H})]})]})]})]})]}),a.jsx(RA,{className:"flex justify-end p-4 md:p-6 border-t rounded-b-lg border-[#242424] ",children:X?a.jsx(Nb,{type:"button",onClick:()=>{ee(!1),ne(null),n(!1),r&&r(te)},className:"bg-[#272729] hover:bg-[#272729]/90 px-5 font-semibold text-[#DCDCE5]",children:"Okay, Got It"}):Y&&!G?a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx("button",{type:"button",onClick:()=>n(!1),className:"mr-2 text-[#ACACB2] bg-[#222224] hover:bg-[#22222490] px-4 pl-3 py-3 rounded-[28px] ",disabled:nt,children:"Cancel"}),a.jsx("button",{type:"button",onClick:async()=>{Ae(!0);try{if(!s||!M||!W)return;const e=Ne(),t=Fe();if(!e||!t)return;await Se({jobId:s,data:{account_login:e,repo_name:t,branch_name:W,is_new_repo:R,force:!1}}).unwrap(),K(!1),Z(!1),N(!1),$(null),Q(null),ne({branch:W,repo:t,owner:e,isNewRepo:R,isNewBranch:!0}),ee(!0)}catch(e){const t=sH(e,{defaultErrorMessage:"Failed to create branch and push to GitHub",needsForcePush:!1,allowConflictDetection:!1});if("secret_protection"===t.type)return void ie({fullError:t.fullErrorText,learnMoreUrl:t.learnMoreUrl,isExpanded:!1});$(t.errorMessage),ze({title:"Error",description:t.errorMessage,variant:"destructive"})}finally{Ae(!1)}},disabled:nt||!function(e){return e?XB(e)?{isValid:!0}:{isValid:!1,errorMessage:"Invalid branch name. Names must follow Git naming rules."}:{isValid:!1,errorMessage:"Branch name is required"}}(W).isValid,className:"bg-[#00FF85] font-semibold flex items-center gap-2 rounded-[28px] pl-4 pr-3 py-3 hover:bg-[#00FF85]/90 text-black",children:nt?a.jsxs(a.Fragment,{children:[a.jsx(gS,{className:"w-4 h-4 mr-2 animate-spin"}),"Creating Branch..."]}):a.jsxs("div",{className:"flex items-center gap-2 font-semibold",children:["Create Branch & Push",a.jsx("img",{src:CH,alt:"Branch",className:"w-6 h-6"})]})})]}):G?a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx("button",{type:"button",onClick:()=>Z(!1),className:" text-[#ACACB2] px-4 py-3 pr-3 bg-[#222224] hover:bg-[#22222490] rounded-[28px]",disabled:nt,children:a.jsxs("div",{className:"flex items-center gap-2 font-medium",children:[a.jsx("img",{src:jH,alt:"Back",className:"w-6 h-6"}),"Go Back"]})}),a.jsx("button",{type:"button",onClick:()=>{(async()=>{Ae(!0);try{if(!s||!M)return;const e=Ne(),t=Fe();if(!e||!t)return;await Se({jobId:s,data:{account_login:e,repo_name:t,branch_name:g,is_new_repo:R,force:!0}}).unwrap(),K(!1),Z(!1),N(!1),$(null),Q(null),ne({branch:g,repo:t,owner:e,isNewRepo:R,isNewBranch:!1}),ee(!0)}catch(e){const t=sH(e,{defaultErrorMessage:"Failed to force push to GitHub",needsForcePush:!0,allowConflictDetection:!1});if("secret_protection"===t.type)return void ie({fullError:t.fullErrorText,learnMoreUrl:t.learnMoreUrl,isExpanded:!1});$(t.errorMessage),ze({title:"Error",description:t.errorMessage,variant:"destructive"})}finally{Ae(!1)}})()},disabled:nt,className:"bg-[#FFA04D] hover:bg-[#FFA04D]/90 flex items-center gap-2 rounded-[28px] pl-4 pr-3 text-[#111112] font-medium",children:nt?a.jsxs(a.Fragment,{children:[a.jsx(gS,{className:"w-4 h-4 mr-2 animate-spin"}),"Force Pushing..."]}):a.jsxs("div",{className:"flex items-center font-semibold tracking-[-0.2px] gap-2 text-[#111112]",children:['Force Push to "',g,'"',a.jsx("img",{src:cH,alt:"Save Cloud",className:"w-6 h-6"})]})})]}):a.jsxs("div",{className:"flex justify-end w-full gap-2",children:[a.jsx("button",{type:"button",onClick:()=>n(!1),className:" bg-[#272729] rounded-full font-medium px-5 py-3 text-gray-300 hover:bg-[#27272990]",disabled:nt,children:"Cancel"}),a.jsx("button",{type:"submit",onClick:et,disabled:nt||!rH({jobId:s,selectedInstallation:M,isCreatingNewRepo:R,newRepoName:z,selectedRepository:L,branchName:g,repositories:Le,isLoading:tt}).isValid,className:bb("bg-[#00FF85] rounded-full max-md:max-w-[200px] flex items-center gap-1 px-5 py-3 hover:bg-[#00FF85]/90 text-black font-semibold",nt&&"opacity-50 cursor-not-allowed","disabled:opacity-50"),children:nt?a.jsxs(a.Fragment,{children:[a.jsx(gS,{className:"w-4 h-4 mr-2 animate-spin"}),ke?"Creating Repository...":R?"Creating & Pushing...":"Pushing..."]}):a.jsxs("div",{className:"flex items-center gap-2",children:[R?"Create & Push to Github":"Push to Github",a.jsx("img",{src:cH,alt:"Save Cloud",className:"w-6 h-6"})]})})]})})]})})}):a.jsx(a.Fragment,{children:a.jsx(IA,{open:t,onOpenChange:Ve,children:a.jsxs(LA,{className:"md:max-w-[620px] md:min-h-[600px] transition-all duration-300 ease-in-out bg-[#0F0F10] overflow-hidden",hideclosebutton:!0,children:[He&&a.jsx("div",{className:"absolute inset-0 z-50 flex flex-col items-center justify-center bg-[#0F0F10]/90 backdrop-blur-sm",children:a.jsxs("div",{className:"flex flex-col items-center justify-center p-6 rounded-lg",children:[a.jsx(gS,{className:"w-12 h-12 text-[#00E573] animate-spin mb-4"}),a.jsx("p",{className:"text-lg font-medium text-white",children:"Connecting to GitHub..."})]})}),a.jsx("img",{src:uH,alt:"Line",className:"absolute top-0 left-0 right-0 z-[-1] w-full pointer-events-none"}),a.jsx(MA,{className:"z-20 ml-auto bg-[#FFFFFF05] backdrop-blur-lg hover:bg-[#FFFFFF12]",children:a.jsx(HS,{className:"absolute z-20 w-5 h-5 text-gray-400 hover:text-white top-12 right-12"})}),a.jsx("div",{className:"flex items-center p-[40px] pt-[80px] gap-1 z-10",children:a.jsx("img",{src:dH,alt:"GitHub"})}),a.jsxs("div",{className:"p-[40px] pt-[0px] flex flex-col items-start gap-4 h-[300px] z-10",children:[a.jsx("span",{className:"text-white text-[24px] font-medium font-brockmann",children:"Connect Github to Emergent"}),a.jsx("span",{className:"text-[18px] text-[#8A8F98]",children:"Connect your GitHub account to effortlessly save, sync, and access your work in all repositories, anytime."})]}),a.jsxs("div",{className:"flex items-center justify-end gap-4 border border-[#242424] p-[20px] bg-[#111112]",children:[a.jsx(Nb,{onClick:()=>n(!1),className:"flex items-center px-[20px] w-fit justify-center bg-[#272729] hover:bg-[#343434] text-white",disabled:He,children:a.jsx("div",{className:"flex items-center justify-center w-full text-[16px]",children:"Cancel"})}),a.jsx(Nb,{onClick:st,className:"max-w-[200px] w-full bg-[#00E573] hover:bg-[##00E573]/90 text-[#0E0E0F] font-brockmann font-semibold hover:bg-[#00E573]/80",disabled:He,children:a.jsx("div",{className:"flex items-center justify-center w-full text-[16px]",children:He?a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(gS,{className:"w-4 h-4 animate-spin"}),"Connecting..."]}):"Connect GitHub"})})]})]})})})}const kH=wv.files.pdf,SH=wv.files.csv,EH=wv.files.doc,IH=wv.files.ppt,AH=wv.files.txt,TH=wv.files.video,MH=wv.files.svg,DH=wv.files.other,LH=wv.files.zip,PH=e=>{if(!e)return"";if(0===e)return"0 B";const t=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/Math.pow(1024,t)).toFixed(1))+" "+["B","KB","MB","GB"][t]},RH=(e,t=20)=>{if(e.length<=t)return e;const n=e.lastIndexOf(".");if(-1===n)return e.substring(0,t-3)+"...";const s=e.substring(n),i=e.substring(0,n),a=t-s.length-3;return a<=0?"..."+s:i.substring(0,a)+"..."+s};function OH({artifact:e}){const t=(n=e.file_name,!(!(s=e.mime_type)||!["image/jpeg","image/png","image/gif","image/webp"].includes(s))||[".jpg",".jpeg",".png",".gif",".webp"].some(e=>n.toLowerCase().endsWith(e)));var n,s;const i=((e,t)=>"image/svg+xml"===t||e.toLowerCase().endsWith(".svg"))(e.file_name,e.mime_type),r=((e,t)=>{if(!e&&!t)return DH;const n=(null==e?void 0:e.toLowerCase())||"";return n.endsWith(".pdf")||"application/pdf"===t?kH:n.endsWith(".csv")||"text/csv"===t?SH:n.endsWith(".doc")||n.endsWith(".docx")||"application/msword"===t||"application/vnd.openxmlformats-officedocument.wordprocessingml.document"===t?EH:n.endsWith(".ppt")||n.endsWith(".pptx")||"application/vnd.ms-powerpoint"===t||"application/vnd.openxmlformats-officedocument.presentationml.presentation"===t?IH:n.endsWith(".txt")||n.endsWith(".md")||n.endsWith(".log")||"text/plain"===t||"text/markdown"===t?AH:n.endsWith(".zip")||n.endsWith(".tar")||n.endsWith(".rar")||n.endsWith(".7z")?LH:n.endsWith(".mp4")||n.endsWith(".avi")||n.endsWith(".mov")||n.endsWith(".wmv")||n.endsWith(".mkv")||(null==t?void 0:t.startsWith("video/"))?TH:n.endsWith(".svg")||"image/svg+xml"===t?MH:n.endsWith(".xls")||n.endsWith(".xlsx")||"application/vnd.ms-excel"===t||"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"===t?SH:DH})(e.file_name,e.mime_type),o=r===LH,l=e.local_preview_url||e.file_path;return t?a.jsx("div",{className:"flex items-center gap-2 min-h-[44px] max-h-[44px] max-w-[44px] min-w-[44px] rounded-[8px] overflow-clip",children:a.jsx("img",{src:l,alt:e.file_name,className:"flex h-[44px] object-cover w-[44px] items-center justify-center"})}):i&&l?a.jsx("div",{className:"flex items-center gap-2 min-h-[44px] max-h-[44px] max-w-[44px] min-w-[44px] rounded-[8px] overflow-clip",children:a.jsx("img",{src:l,alt:e.file_name,className:"flex h-[44px] object-contain w-[44px] items-center justify-center",onError:e=>{const t=e.target;t.src=MH,t.className="w-8 h-8"}})}):a.jsx("div",{className:"flex items-center gap-2 min-h-[44px] max-h-[44px] min-w-[100px] p-1 pr-4 bg-[#FFFFFF0D] rounded-[8px]",children:a.jsxs("div",{className:"flex items-center flex-1 h-full min-w-0 gap-2",children:[a.jsx("img",{src:r,alt:"File",className:bb("w-8 h-8",o&&"p-1")}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("div",{className:"text-[14px] font-medium font-['Inter'] text-[#FFFFFFCC] truncate text-nowrap",children:RH(e.file_name,20)}),e.file_size&&a.jsx("div",{className:"text-[12px] font-['Inter'] font-medium text-white/40 mt-0.5",children:PH(e.file_size)})]})]})},e.artifact_id)}const zH=wv.common.whiteGithub,BH=wv.github.gitDot,HH=wv.fork.fork,$H=wv.icons.animatedSpinner,VH=({isOpen:e,onOpenChange:t,isGitHubConnected:n=!1,onSaveToGitHub:s,isGitHubDisabled:i=!1,onForkClick:r,isForkDisabled:o=!1,forkStatus:l=null,ultraMode:c=!1,onUltraModeChange:d,isUltraDisabled:u=!1,tier:p,onUpgradeRequired:m,getCurrentOrganizationId:h})=>a.jsxs(ZI,{open:e,onOpenChange:t,showDefaultFooter:!1,contentPadding:"p-0",showCancel:!0,onCancel:()=>t(!1),title:"Settings",maxWidth:"max-w-sm",trigger:a.jsx(a.Fragment,{}),children:[a.jsx("div",{className:"h-[1px] w-full bg-[#242424]"}),a.jsx("div",{className:"space-y-4 bg-[#111112] px-4 pb-4 rounded-t-2xl",children:a.jsxs("div",{className:"flex flex-col pt-4 space-y-4",children:[a.jsxs("div",{className:bb("flex items-center justify-between p-4 rounded-[12px] transition-colors",c?"bg-[#FF8C661A]":"bg-[#FFFFFF0F]"),children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(pA,{color:c?"#FF8C66":"#ffffff",size:24}),a.jsx("div",{className:"flex flex-col items-start",children:a.jsx("span",{className:bb("font-medium transition-colors",c?"text-[#FF8C66]":"text-white"),children:"Ultra thinking"})})]}),a.jsx(mA,{checked:c,onCheckedChange:e=>{"pro_mode"===p||(null==h?void 0:h())?null==d||d(e):null==m||m()},disabled:u,className:"data-[state=unchecked]:bg-[#3B3B3B] data-[state=checked]:bg-[#FF8C66]"})]}),a.jsxs("button",{disabled:i,onClick:()=>{null==s||s(),t(!1)},className:bb("flex items-center justify-between p-4 rounded-[12px] bg-[#FFFFFF0F] hover:bg-[#FFFFFF14] transition-colors",i&&"opacity-50 cursor-not-allowed"),children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("img",{src:n?BH:zH,alt:"GitHub",className:bb("w-6 h-6",n?"scale-[1.2]":"")}),a.jsx("span",{className:"font-medium text-white",children:"Save to GitHub"})]}),a.jsx("div",{className:"w-2 h-2 rounded-full bg-white/30"})]}),a.jsxs("button",{disabled:o||"running"===l,onClick:()=>{null==r||r(),t(!1)},className:bb("flex items-center justify-between p-4 rounded-[12px] transition-colors","running"===l?"bg-[#80FFF90D] cursor-not-allowed":"bg-[#FFFFFF0F] hover:bg-[#FFFFFF14]",o&&"running"!==l&&"opacity-50 cursor-not-allowed"),children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("img",{src:"running"===l?$H:HH,alt:"Fork",className:"w-6 h-6"}),a.jsx("span",{className:bb("font-medium","running"===l?"text-[#80FFF9]":"text-white"),children:"running"===l?"Forking...":"Fork"})]}),a.jsx("div",{className:"w-2 h-2 rounded-full bg-white/30"})]})]})})]}),UH=({size:e=20,color:t="currentColor",className:n=""})=>a.jsx("svg",{width:e,height:e,viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:n,children:a.jsx("path",{d:"M7.58584 4.5374C8.08417 3.07906 10.0992 3.0349 10.69 4.4049L10.74 4.53823L11.4125 6.5049C11.5666 6.95592 11.8157 7.36865 12.1429 7.71525C12.47 8.06184 12.8678 8.33424 13.3092 8.51406L13.49 8.58156L15.4567 9.25323C16.915 9.75156 16.9592 11.7666 15.59 12.3574L15.4567 12.4074L13.49 13.0799C13.0388 13.2339 12.6259 13.4829 12.2792 13.8101C11.9324 14.1373 11.6599 14.5351 11.48 14.9766L11.4125 15.1566L10.7408 17.1241C10.2425 18.5824 8.2275 18.6266 7.6375 17.2574L7.58584 17.1241L6.91417 15.1574C6.76015 14.7062 6.51115 14.2933 6.18395 13.9466C5.85676 13.5998 5.459 13.3273 5.0175 13.1474L4.8375 13.0799L2.87084 12.4082C1.41167 11.9099 1.3675 9.8949 2.7375 9.3049L2.87084 9.25323L4.8375 8.58156C5.28853 8.42744 5.70126 8.17839 6.04786 7.8512C6.39445 7.52402 6.66685 7.12631 6.84667 6.6849L6.91417 6.5049L7.58584 4.5374ZM15.83 1.66406C15.9859 1.66406 16.1387 1.70779 16.271 1.79029C16.4032 1.87278 16.5097 1.99073 16.5783 2.13073L16.6183 2.22823L16.91 3.08323L17.7658 3.3749C17.9221 3.42798 18.059 3.52624 18.1594 3.65724C18.2597 3.78824 18.3189 3.94608 18.3294 4.11075C18.3399 4.27542 18.3013 4.43951 18.2185 4.58222C18.1357 4.72493 18.0124 4.83985 17.8642 4.9124L17.7658 4.9524L16.9108 5.24406L16.6192 6.0999C16.566 6.25609 16.4677 6.39298 16.3366 6.49322C16.2056 6.59347 16.0477 6.65256 15.883 6.663C15.7184 6.67344 15.5543 6.63477 15.4117 6.55188C15.269 6.46899 15.1541 6.34562 15.0817 6.1974L15.0417 6.0999L14.75 5.2449L13.8942 4.95323C13.7379 4.90015 13.601 4.80188 13.5006 4.67088C13.4003 4.53988 13.3411 4.38205 13.3306 4.21738C13.3201 4.05271 13.3587 3.88862 13.4415 3.74591C13.5243 3.60319 13.6476 3.48828 13.7958 3.41573L13.8942 3.37573L14.7492 3.08406L15.0408 2.22823C15.097 2.06358 15.2033 1.92065 15.3449 1.81948C15.4864 1.7183 15.656 1.66396 15.83 1.66406Z",fill:t})}),WH=wv.common.attach,qH=wv.common.folderAdd,GH=wv.common.pause,ZH=wv.common.send,YH=wv.common.attachmentCross,KH=wv.common.whiteGithub,JH=wv.common.visualEdit,QH=wv.icons.animatedSpinner,XH=wv.github.gitDot,e$=wv.fork.fork,t$=wv.upload.close,n$=Pe.memo(()=>a.jsx("img",{src:JH,alt:"Visual Editing",className:"w-4 h-4",style:{filter:"brightness(0) saturate(100%) invert(71%) sepia(43%) saturate(424%) hue-rotate(182deg) brightness(102%) contrast(101%)"}})),s$=Pe.memo(({elementName:e})=>a.jsxs("div",{className:"flex items-center",style:{gap:"4px",padding:"6px 8px",height:"24px",borderRadius:"6px",backgroundColor:"rgba(1, 97, 209, 0.2)",border:"1px solid rgba(83, 169, 255, 0.4)"},children:[a.jsx("div",{className:"flex items-center justify-center",style:{width:"12px",height:"12px",flexShrink:0},children:a.jsx("svg",{width:"10",height:"10",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:a.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5.93934 1.06066L7 0L8.06066 1.06066L12.9393 5.93934L14 7L12.9393 8.06066L8.06066 12.9393L7 14L5.93934 12.9393L1.06066 8.06066L0 7L1.06066 5.93934L5.93934 1.06066ZM2.12132 7L7 11.8787L11.8787 7L7 2.12132L2.12132 7Z",fill:"#53A9FF"})})}),a.jsx("span",{style:{fontWeight:500,fontSize:"14px",lineHeight:"1em",color:"#53A9FF",textAlign:"center"},children:e})]})),i$=Pe.memo(({status:e,colors:t})=>{const n=t[e].color||"#5FD3F3";return a.jsx("div",{className:bb("w-4 h-4 rounded-lg flex justify-center items-center","stopped"!=e&&"exit_cost"!=e&&"animate-status-pulse"),style:{backgroundColor:`${n}20`,"--status-pulse-color":`${n}70`,"--status-pulse-transparent":`${n}00`},children:a.jsx("div",{className:"w-2 h-2 rounded",style:{backgroundColor:n}})})}),a$=Pe.memo(({status:e,colors:t,statusText:n})=>a.jsx("span",{className:"text-[15px] md:text-[16px] font-medium md:text-nowrap",style:{color:t[e].color},children:n[e]})),r$=Pe.memo(({onSubmit:e,placeholder:t="Message Neo",isDisabled:n,agentState:s,agentStatus:i,setAgentStatus:r,containerId:o,jobDetails:l,acc_cost:c,max_budget:d,isCloudFlow:u,inputValue:p,modelName:m,agentName:h,isSubagentActive:x,hideStatus:f=!1,disableWhenSubagentActive:g=!1,onPause:v,onOpenSubagentPanel:b,showFinishSubagentText:y,pauseWasClicked:w,onImagesChange:j,lastGithubUsed:C,subagentName:N,onGitHubPush:F,handleDeploy:_,modalOpen:k,setModalOpen:S,fromSubagentPanel:E=!1,isPauseLoading:I,buildMode:A,forked_status:T,onOpenUploadAssetsModal:M,ultraMode:D=!1,onUltraModeChange:R,autoMessageEnabled:B=!1,visualEditMode:H=!1,onVisualEditModeChange:$,selectedElementName:V=null,isDebugScriptReady:U=!1,enableVisualEdit:W,hasUnsavedVisualEditChanges:q=!1,onSaveVisualEditChanges:G,onDiscardVisualEditChanges:Z,showUnsavedChangesModal:Y})=>{const{toast:K}=un(),J=bL(),Q=yL(Au),X=yL(e=>Mu(e,Q)),ee=yL(e=>E?"":((e,t)=>{var n;return(null==(n=e.tabs.tabStates[t])?void 0:n.chatInputText)||""})(e,Q)),[te]=qx(),[ne,{isLoading:se}]=jf(),[ie]=Cf(),[ae,re]=Pe.useState(ee),[oe,le]=Pe.useState(!1),[ce,de]=Pe.useState(!1),[ue,pe]=Pe.useState(!1),[me,he]=Pe.useState(!1),[xe,fe]=Pe.useState(!1),[ge,ve]=Pe.useState(!1),[be,ye]=Pe.useState(!1),[we,je]=Pe.useState(!1),[Ce,Ne]=Pe.useState(!1),[Fe,_e]=Pe.useState(!1),[ke,Se]=Pe.useState(null),Ee=se,Ie=UE(),Ae=Pe.useRef(null),Te=Pe.useRef(null),Me=Pe.useRef(null),De=Pe.useRef(!1);U&&(De.current=!0);const[Le,Re]=Pe.useState("normal"),{isMobile:Oe}=nI(),ze=I??!1,{isConnected:Be}=qA(),{user:He}=Yg(),{getCurrentOrganizationId:$e}=ev(),{credits:Ve,dailyCreditsEnabled:Ue,tier:We,creditResponse:qe,refreshCredits:Ge}=sv(),Ze=iI(),{getPendingMessage:Ye,getActiveTab:Ke,removePendingMessage:Je}=Hee(),[Qe,Xe]=Pe.useState(!1),[et,tt]=Pe.useState(!1),{data:nt}=Sx(void 0,{skip:!He}),{isMobile:st}=nI(),it=Ig(),at=Pe.useMemo(()=>Ze&&ce,[Ze,ce]),{compressImage:rt,getMimeType:ot}=gE({maxWidth:2e3,maxHeight:2e3,quality:30,format:"jpeg"});Pe.useEffect(()=>{tt(true)},[l,kg]),Pe.useEffect(()=>{if(!Bu("hasSeenForkIntro",!1)&&!("waiting"!==i&&"subagent_waiting"!==i||"build"!==A||x)&&!st){const e=setTimeout(()=>{he(!0)},1e3);return()=>clearTimeout(e)}},[i,A,x]),Pe.useEffect(()=>{const e=e=>{if((e.metaKey||e.ctrlKey)&&"e"===e.key){const t=(W||De.current&&!1!==W)&&!E&&!st,n="waiting"!==i&&"subagent_waiting"!==i||"build"!==A||x||!De.current;if(!t||n)return;e.preventDefault(),e.stopPropagation();const s=!H;if(!s&&q)return void(null==Y||Y({onConfirm:ct,title:"You have unsaved changes",description:"Are you sure you want to exit the visual editor? You will lose your unsaved changes.",confirmButton:{text:"Confirm",variant:"default"},cancelButton:{text:"Cancel",variant:"outline"}}));bg(s?"visual_edit_enabled":"visual_edit_disabled",{jobId:null==l?void 0:l.job_id,agentStatus:i,enableVisualEdit:W,source:"keyboard_shortcut"}),null==$||$(s)}};return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)}},[W,E,st,i,A,x,H,q,null==l?void 0:l.job_id,$,Q]);const lt=Pe.useCallback(async()=>{G&&await G()},[G]),ct=Pe.useCallback(()=>{Z&&Z(),null==$||$(!1),bg("visual_edit_discarded",{jobId:null==l?void 0:l.job_id,agentStatus:i})},[Z,$,null==l?void 0:l.job_id,i]);Pe.useEffect(()=>{const e=e=>{(e.metaKey||e.ctrlKey)&&"s"===e.key&&H&&q&&(e.preventDefault(),e.stopPropagation(),bg("visual_edit_saved",{jobId:null==l?void 0:l.job_id,agentStatus:i,source:"keyboard_shortcut"}),lt())};return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)}},[H,q,lt,null==l?void 0:l.job_id,i]);const dt=Pe.useCallback(()=>{he(!1),zu("hasSeenForkIntro",!0)},[]),ut=vE({maxImages:5,maxSizeInMB:200,maxPixelDimensions:8e3,maxPixelDimensionsMultiple:2e3,onImagesChange:j}),pt=function({maxFiles:e=10,maxSizeInMB:t=50,allowedTypes:n=[],jobId:s,onUploadComplete:i,onUploadError:a}={}){const[r,o]=Pe.useState([]),[l,c]=Pe.useState([]),[d,u]=Pe.useState(!1),{toast:p}=un(),m=Pe.useCallback(e=>{const s=1024*t*1024;return e.size>s?`File size exceeds ${t}MB limit`:n.length>0&&!n.some(t=>t.startsWith(".")?e.name.toLowerCase().endsWith(t.toLowerCase()):e.type.toLowerCase().includes(t.toLowerCase()))?`File type not allowed. Allowed types: ${n.join(", ")}`:null},[t,n]),h=Pe.useCallback(t=>{if(!t)return;const n=Array.from(t),s=[],i=[];r.length+n.length>e&&i.push(`Cannot add more than ${e} files`),n.forEach(e=>{const t=m(e);t?i.push(`${e.name}: ${t}`):s.push({file:e,name:e.name,size:e.size,type:e.type,lastModified:e.lastModified})}),i.length>0&&p({title:"File Validation Error",description:i.join("\n"),variant:"destructive"}),s.length>0&&o(e=>[...e,...s])},[r.length,e,m,p]),x=Pe.useCallback(e=>{h(e)},[h]),f=Pe.useCallback(()=>{const e=document.createElement("input");return e.type="file",e.multiple=!0,e.style.display="none",n.length>0&&(e.accept=n.join(",")),e.onchange=t=>{const n=t.target;x(n.files),document.body.removeChild(e)},e},[n,x]),g=Pe.useCallback(()=>{const e=f();document.body.appendChild(e),setTimeout(()=>{e.click()},0)},[f]),v=Pe.useCallback(async e=>{if(!s)throw new Error("Job ID is required for file upload");const t=`${e.name}-${Date.now()}`;c(n=>[...n,{artifactId:t,fileName:e.name,progress:0,status:"uploading"}]);try{const n={file_name:e.name,mime_type:e.type},a=await om(s,n);c(e=>e.map(e=>e.artifactId===t?{...e,progress:33,artifactId:a.artifact_id,file_path:a.file_path}:e)),await lm(a.upload_url,e.file),c(e=>e.map(e=>e.artifactId===a.artifact_id?{...e,progress:66}:e));const r={entity_id:s,entity_type:"job",visibility:"public",file_name:e.name,description:e.description||void 0,file_path:a.file_path};await pm(a.artifact_id,r),c(e=>e.map(e=>e.artifactId===a.artifact_id?{...e,progress:100,status:"completed"}:e)),null==i||i(a.artifact_id,e.name),p({title:"Upload Complete",description:`${e.name} uploaded successfully`})}catch(n){c(e=>e.map(e=>e.artifactId===t?{...e,status:"failed",error:n.message}:e)),null==a||a(e.name,n.message),p({title:"Upload Failed",description:`Failed to upload ${e.name}: ${n.message}`,variant:"destructive"})}},[s,i,a,p]),b=Pe.useCallback(async e=>{if(0!==e.length)if(s){u(!0);try{const n=[];for(const i of e){const e=`${i.name}-${Date.now()}`;c(t=>[...t,{artifactId:e,fileName:i.name,progress:0,status:"uploading"}]);try{const t={file_name:i.name,mime_type:i.type},a=await om(s,t);c(t=>t.map(t=>t.artifactId===e?{...t,progress:25,artifactId:a.artifact_id,file_path:a.file_path}:t)),await lm(a.upload_url,i.file),c(e=>e.map(e=>e.artifactId===a.artifact_id?{...e,progress:50}:e)),n.push({artifact_id:a.artifact_id,entity_id:s,entity_type:"job",visibility:"public",file_name:i.name,description:i.description||void 0,file_path:a.file_path})}catch(t){c(n=>n.map(n=>n.artifactId===e?{...n,status:"failed",error:t.message}:n)),null==a||a(i.name,t.message),p({title:"Upload Failed",description:`Failed to upload ${i.name}: ${t.message}`,variant:"destructive"})}}if(n.length>0)try{await mm({artifacts:n}),c(e=>e.map(e=>n.find(t=>t.artifact_id===e.artifactId)?{...e,progress:100,status:"completed"}:e)),n.forEach(e=>{null==i||i(e.artifact_id,e.file_name)}),p({title:"Upload Complete",description:`${n.length} file(s) uploaded successfully`})}catch(t){c(e=>e.map(e=>n.find(t=>t.artifact_id===e.artifactId)?{...e,status:"failed",error:t.message}:e)),p({title:"Finalization Failed",description:`Failed to finalize uploads: ${t.message}`,variant:"destructive"})}o([])}catch(t){p({title:"Upload Failed",description:"Failed to upload files. Please try again.",variant:"destructive"})}finally{u(!1)}}else p({title:"Error",description:"Job ID is required for file upload",variant:"destructive"});else p({title:"No Files",description:"Please select files to upload",variant:"destructive"})},[r,s,i,a,p]),y=Pe.useCallback(e=>{o(t=>t.filter((t,n)=>n!==e))},[]),w=Pe.useCallback(()=>{o([]),c([])},[]),j=Pe.useCallback(()=>{c(e=>e.filter(e=>"completed"!==e.status))},[]);return{files:r,uploadProgress:l,isProcessing:d,handleFileSelect:x,openFilePicker:g,uploadFile:v,uploadAllFiles:b,removeFile:y,clearFiles:w,clearCompletedUploads:j,hasFiles:r.length>0,hasUploads:l.length>0}}({maxFiles:5,maxSizeInMB:200,jobId:null==l?void 0:l.job_id,onUploadComplete:(e,t)=>{},onUploadError:(e,t)=>{}}),mt=Pe.useCallback(e=>{if(!e||0===e.length)return;const t=Array.from(e),n=t.filter(e=>e.size>209715200);if(n.length>0)K({title:"File too large",description:`Files must be smaller than 200MB. ${n.length} file(s) exceed this limit.`,variant:"destructive"});else if(E||!et){const e=t.filter(e=>e.type.startsWith("image/")&&["image/jpeg","image/png","image/gif","image/webp"].includes(e.type)),n=t.filter(e=>!e.type.startsWith("image/")),s=ut.images.length+pt.files.length+X.length;if(s+t.length>5)return void K({title:"Too many attachments",description:`Maximum 5 attachments allowed. Currently have ${s} (${X.length} uploaded + ${ut.images.length+pt.files.length} selected), trying to add ${t.length}.`,variant:"destructive"});e.length>0&&ut.handleImageSelect(e),n.length>0&&(null==l?void 0:l.job_id)&&pt.handleFileSelect(n)}else{if(X.length>=5)return void K({title:"Too many attachments",description:`Maximum 5 attachments allowed. You already have ${X.length} uploaded files.`,variant:"destructive"});if(X.length+t.length>5)return void K({title:"Too many attachments",description:`Maximum 5 attachments allowed. You have ${X.length} uploaded files, trying to add ${t.length} more.`,variant:"destructive"});null==M||M(t)}},[E,et,M,ut,pt,null==l?void 0:l.job_id,X,K]),ht=Pe.useCallback(e=>{const t=e.target.files;if(t&&t.length>0)if(E||!et)mt(t);else{const e=Array.from(t);null==M||M(e)}Me.current&&(Me.current.value="")},[E,mt,et,M]),xt=Pe.useCallback(()=>{Dt||(!E&&X.length>=5?K({title:"Too many attachments",description:`Maximum 5 attachments allowed. You already have ${X.length} uploaded files.`,variant:"destructive"}):E||!et?ft():fe(!xe))},[E,xe,et,X,K]),ft=Pe.useCallback(()=>{!E&&X.length>=5?K({title:"Too many attachments",description:`Maximum 5 attachments allowed. You already have ${X.length} uploaded files.`,variant:"destructive"}):(Me.current?Me.current.click():ut.openFilePicker(),fe(!1))},[ut,E,X,K]),gt=Pe.useCallback(()=>{X.length>=5?K({title:"Too many attachments",description:`Maximum 5 attachments allowed. You already have ${X.length} uploaded files.`,variant:"destructive"}):(Me.current&&Me.current.click(),fe(!1))},[X,K]),vt=Pe.useCallback(e=>{J(wu({tabId:Q,artifactId:e})),K({title:"File removed",description:"Attachment has been removed successfully"})},[J,Q,K]);Pe.useEffect(()=>{p&&re(p)},[p]),Pe.useEffect(()=>{E||re(ee)},[ee,Q,E]),Pe.useEffect(()=>{if(E)return;const e=setTimeout(()=>{J(ju({tabId:Q,text:ae}))},300);return()=>clearTimeout(e)},[ae,Q,J,E]),Pe.useEffect(()=>{const e=e=>{Te.current&&!Te.current.contains(e.target)&&fe(!1)};return xe&&document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[xe]),Pe.useEffect(()=>{if(B&&"waiting"===i&&!E)return void Re("auto_message");Ue&&qe&&"free"===We&&qe.ecu_balance<=5&&!E?Re("credit_exhausted"):Re("normal")},[qe,Ue,B,i,E,We]);const bt=Pe.useCallback(async()=>{(null==l?void 0:l.job_id)&&(null==s?void 0:s.agent_running)&&v&&v({origin:E?"SubagentButton":"MainInput"})},[null==l?void 0:l.job_id,null==s?void 0:s.agent_running,v]),yt=Pe.useCallback(async()=>{if((null==l?void 0:l.job_id)&&!be){ye(!0);try{await Up(l.job_id),K({title:"Clone Complete",description:"Environment has been successfully cloned."})}catch(e){K({title:"Clone Failed",description:(null==e?void 0:e.message)||"Failed to clone environment.",variant:"destructive"})}finally{ye(!1)}}},[null==l?void 0:l.job_id,be,K]),wt=Pe.useCallback(async t=>{var n,s,i;const a=t||ae.trim();if(!(null==l?void 0:l.job_id)||!a)return;if(at)return await Rp(l.job_id,a),re(""),void(!E&&X.length>0&&J(yu({tabId:Q})));const o=ut.images.length>0?ut.images.map(e=>({mime_type:e.mime_type,img_base64:e.img_base64})):[];let c=[];if(!E)try{c=await Promise.all(X.filter(e=>{if(!e.readByAgent)return!1;const t=e.mime_type&&["image/jpeg","image/png","image/gif","image/webp"].includes(e.mime_type),n=/\.(jpg|jpeg|png|gif|webp)$/i.test(e.file_name);return t||n}).map(async e=>{try{const t=e.local_preview_url||e.file_path;if(!t)return null;const n=await fetch(t);if(!n.ok)return null;const s=await n.blob(),i=await rt(s);return i?{mime_type:ot("jpeg"),img_base64:i.base64}:null}catch(t){return null}}))}catch(h){c=[]}const d=[...o,...c.filter(e=>null!==e)],u=a,p=d;e(u,d,E?[]:X),re(""),E||J(Cu({tabId:Q})),ut.images.length>0&&ut.clearImages(),!E&&X.length>0&&J(yu({tabId:Q}));try{const e=$e(),t=null==He?void 0:He.id,n={processor_type:"env_only",is_cloud:!0,task:u,prompt_name:"",prompt_version:"latest",work_space_dir:"",model_name:m||"claude-3-5-sonnet-20241022",env_image:"",base64_image_list:p,human_timestamp:(new Date).toISOString(),is_pro_user:"pro_mode"===We,thinking_level:D?"ultra_mode":"thinking",...e&&{organization_id:e},...t&&{user_id:t}};let s;!E&&X.length>0&&(s={artifacts:X.map(e=>({artifact_id:e.artifact_id,entity_id:e.entity_id,entity_type:e.entity_type,visibility:e.visibility,file_name:e.file_name,description:e.description,file_path:e.file_path}))}),await te({payload:n,client_ref_id:null==l?void 0:l.job_id,resume:!0,finalize_artifact_upload:s}).unwrap(),r&&r("running")}catch(h){Je(Ke().id,u),re(u);const e=(null==(n=null==h?void 0:h.data)?void 0:n.detail)||(null==(i=null==(s=null==h?void 0:h.response)?void 0:s.data)?void 0:i.detail)||(null==h?void 0:h.message)||"Failed to resume agent";K({title:"Error",description:e,variant:"destructive"})}},[null==l?void 0:l.job_id,o,ae,u,K,m,ut,Ze,ce,null==He?void 0:He.id,at]),jt=Pe.useCallback(async e=>{if(Ce)return;const t=null==nt?void 0:nt.llm_auto_hitl_enabled;if(bg("auto_answer_button_clicked",{location:e,jobId:null==l?void 0:l.job_id,agentStatus:i}),(null==l?void 0:l.job_id)&&t){Ne(!0);try{const e=await ie(l.job_id).unwrap();if(null==e?void 0:e.auto_answer){const t=`${e.auto_answer}`;wt(t)}}catch(n){}finally{Ne(!1)}}else Ne(!0),wt("Assume Default and Proceed"),Ne(!1)},[Ce,null==l?void 0:l.job_id,i,ie,wt]),Ct=Pe.useMemo(()=>{const e=e=>{const t=((e,t,n)=>{const s={running:"#67CB65",waiting:"#5FD3F3",stopped:"#7B7B80",stopping:"#F49B57",subagent_stopping:"#F49B57",exit_cost:"#7B7B80",forking:"#80FFF9"},i="running"===e||"subagent_running"===e||"subagent_waiting"===e;if(n&&t&&i)return ET(t).bgColor;return e.startsWith("subagent_")&&i?"#DD99FF":s[e]||s.stopped})(e,N,x);return{color:t}};return{running:e("running"),waiting:e("waiting"),exit_cost:e("exit_cost"),stopped:e("stopped"),stopping:e("stopping"),subagent_running:e("subagent_running"),subagent_waiting:e("subagent_waiting"),subagent_stopping:e("subagent_stopping"),forking:e("forking")}},[N,x]),Nt=Pe.useMemo(()=>{const e=()=>h||"Agent",t=()=>N?ST(N):"Subagent";return{exit_cost:`${e()} is offline`,running:`${e()} is running...`,waiting:`${e()} is waiting...`,stopped:`${e()} is offline`,stopping:`${e()} is stopping gracefully. Usually takes a min`,subagent_running:`${t()} is running...`,subagent_waiting:`${t()} is waiting...`,subagent_stopping:`${t()} is gracefully stopping...`,forking:"Forking is in progress..."}},[h,N]),Ft=(e="bottom",t="0%",n=.2)=>{const s={running:`linear-gradient(to ${e}, rgba(255, 255, 255, 0.02) 0%, rgba(103, 203, 101, 0.2) 100%)`,waiting:`linear-gradient(to ${e}, rgba(255, 255, 255, 0.02) 0%, rgba(95, 211, 243, 0.2) 100%)`,stopped:`linear-gradient(to ${e}, rgba(255, 255, 255, 0.02) 0%, rgba(123, 123, 128, 0.2) 100%)`,stopping:`linear-gradient(to ${e}, rgba(255, 255, 255, 0.02) 0%, rgba(244, 155, 87, 0.2) 100%)`,exit_cost:`linear-gradient(to ${e}, rgba(255, 255, 255, 0.02) 0%, rgba(123, 123, 128, 0.2) 100%)`};if(E)return s[i]||s.stopped;if(x&&N){const t=i.startsWith("subagent_")?i.replace("subagent_",""):"waiting";return((e,t,n="bottom")=>ET(e).gradients[t].replace("to bottom",`to ${n}`))(N,t,e)}if(i.startsWith("subagent_"))return`linear-gradient(to ${e}, rgba(255, 255, 255, 0.2) 0%, rgba(221, 153, 255, 1) 100%)`;return s[i]||s.stopped},_t=Pe.useMemo(()=>{if(ze)return a.jsx(gS,{className:"w-6 h-6 text-gray-500 animate-spin"});switch(i){case"running":case"subagent_running":case"stopping":case"subagent_stopping":return a.jsx("img",{src:GH,className:"w-6 h-6",alt:"pause"});default:return a.jsx("img",{src:ZH,className:"w-6 h-6",alt:"send"})}},[i,ze]),kt=Pe.useCallback(()=>{it&&"free"===We?Ie.open({}):le(!0)},[We,it]),St=Pe.useCallback(()=>{it&&"free"===We?Ie.open({}):"running"!==T&&(me&&dt(),k&&S&&S({...k,fork:!k.fork}))},[me,dt,k,We,it]),Et=Pe.useCallback(async()=>{var e,t,n;if(!ue&&(null==l?void 0:l.job_id))if(ce)de(!1);else{pe(!0);try{await Op(l.job_id),de(!0),K({title:"HIM mode activated",description:"You can now send messages as HIM"})}catch(s){const i=(null==(e=null==s?void 0:s.data)?void 0:e.detail)||(null==(n=null==(t=null==s?void 0:s.response)?void 0:t.data)?void 0:n.detail)||(null==s?void 0:s.message)||"Failed to initialize HIM session";K({title:"Error",description:i,variant:"destructive"})}finally{pe(!1)}}},[ue,null==l?void 0:l.job_id,ce,K]),It=Pe.useCallback(async()=>{try{const e=await navigator.mediaDevices.getUserMedia({audio:!0}),t=new MediaRecorder(e),n=[];t.ondataavailable=e=>{n.push(e.data)},t.onstop=async()=>{const t=new Blob(n,{type:"audio/mp3"});await Tt(t),e.getTracks().forEach(e=>e.stop())},t.start(),Se(t),_e(!0),Og("recording_started",{component:"ChatInput"})}catch(e){K({title:"Recording Error",description:"Could not access microphone. Please check permissions.",variant:"destructive"})}},[K]),At=Pe.useCallback(()=>{ke&&Fe&&(ke.stop(),_e(!1),Se(null),Og("recording_stopped",{component:"ChatInput"}))},[ke,Fe]),Tt=Pe.useCallback(async e=>{try{Og("transcription_started",{component:"ChatInput",audioSize:e.size});const t=new File([e],"recording.mp3",{type:"audio/mp3"}),n=await ne({audio_file:t,language_code:"en"}).unwrap();if(!n.text)throw new Error("No transcription data received");{const e=ae?`${ae} ${n.text}`:n.text;re(e),Og("transcription_completed",{component:"ChatInput",textLength:n.text.length})}}catch(t){Og("transcription_failed",{component:"ChatInput",error:t instanceof Error?t.message:"Unknown error"}),K({title:"Transcription Error",description:"Failed to transcribe audio. Please try again.",variant:"destructive"})}},[ne,ae,K]),Mt=Pe.useCallback(()=>{Fe?At():It()},[Fe,At,It]),Dt=Pe.useMemo(()=>{var e;return(!Ze||"true"===localStorage.getItem("mobile"))&&(!!H||("running"==T||("brainstorming_done"==A&&"running"===i||(!(!x&&"subagent_waiting"!==i||E)||(!!(null==(e=Ye(Ke().id))?void 0:e.content)||n)))))},[n,g,x,Ke,Ye,c,d,Ze,A,i,H]),Lt=Pe.useCallback(()=>{const e=Ae.current;e&&(e.style.height="auto",e.style.height=`${Math.min(e.scrollHeight,200)}px`)},[]),Pt=Pe.useCallback(e=>{re(e.target.value),requestAnimationFrame(Lt)},[Lt]);Pe.useEffect(()=>{Lt()},[Lt]),Pe.useEffect(()=>{Lt()},[ae,Lt]);const Rt=Pe.useCallback(e=>{if(e.preventDefault(),!Dt||"subagent_running"===i||"running"===i)if(at)wt();else if("running"===i||"subagent_running"===i||"stopping"===i||"subagent_stopping"===i)bt();else if("waiting"===i&&!E||"subagent_waiting"===i&&E){if(!ae.trim())return;wt(),re("")}},[ae,n,ut,i,bt,wt,l,Dt,Ze,ce,null==He?void 0:He.id]),Ot=Pe.useMemo(()=>{let e=!1;return(ze||"subagent_waiting"===i||"running"===i&&"brainstorming_done"===A||w||!(null==l?void 0:l.job_id))&&(e=!0),"subagent_waiting"===i&&E&&(e=!1),"running"==T&&(e=!0),H&&(e=!0),e},[ze,i,y,w,A,E,x,T,null==l?void 0:l.job_id,H]),Ht=Pe.useCallback(()=>H?"Save your changes to continue chatting":"running"==T?"Please wait for forking to finish":t,[t,c,d,T,H]),{ForkDisabled:$t,ForkDisabledReason:Vt}=Pe.useMemo(()=>H?{ForkDisabled:!0,ForkDisabledReason:"Cannot fork while in visual edit mode"}:"waiting"!==i&&"subagent_waiting"!==i?{ForkDisabled:!0,ForkDisabledReason:"Please wait for the agent to finish before forking"}:"build"!==A?{ForkDisabled:!0,ForkDisabledReason:"Please wait for agent to write code before forking"}:x?{ForkDisabled:!0,ForkDisabledReason:"Cannot fork while subagent is active"}:Ve<=0?{ForkDisabled:!0,ForkDisabledReason:"Insufficient credits to fork"}:{ForkDisabled:!1,ForkDisabledReason:null},[i,A,x,Ve,H]);return a.jsx(Bt,{children:a.jsxs(zt.div,{initial:{y:100,opacity:0},animate:{y:0,opacity:1},exit:{y:100,opacity:0},transition:{type:"spring",stiffness:300,damping:30},className:bb("flex flex-col md:p-1 p-0 max-w-full sm:max-w-4xl md:pt-1 pt-0 w-full md:rounded-[14px] rounded-b-l-none rounded-b-r-none md:backdrop-blur-[40px] xs:backdrop-blur-[0px] shadow-sm md:bg-[#1A1A1C] rounded-t-l-[14px] rounded-t-r-[14px]",st&&"border border-b-0 border-[#333333] rounded-[14px] rounded-b-none"),style:{background:st?"transparent":Ft()},children:["normal"==Le&&a.jsx("div",{className:"flex items-center justify-between w-full px-2 md:px-3 md:py-2",children:a.jsxs("div",{className:bb("flex items-center gap-2 ",!E&&X.length>0?"w-full":"max-w-[50%]"),children:[ut.images.length>0&&a.jsx("div",{className:"flex items-center gap-2 pt-1",children:a.jsx("div",{className:"flex flex-wrap gap-2",children:ut.isProcessing?a.jsxs("div",{className:"flex items-center justify-center py-1",children:[a.jsx(gS,{className:"h-4 w-4 text-[#999] animate-spin mr-2"}),a.jsx("span",{className:"text-[#999] text-xs",children:"Processing..."})]}):ut.images.map((e,t)=>a.jsxs("div",{className:"relative w-16 h-16 md:w-20 md:h-20 rounded-md border border-[#333] group",children:[a.jsx("img",{src:`data:${e.mime_type};base64,${e.img_base64}`,alt:`Selected image ${t+1}`,className:"w-full h-full object-cover z-[1] rounded-md"}),a.jsx("button",{onClick:()=>ut.removeImage(t),className:"absolute top-[-6px] right-[-6px] bg-transparent z-[2] rounded-full p-1 transition-opacity","aria-label":"Remove image",type:"button",children:a.jsx("div",{className:"bg-white rounded-full p-[2px]",children:a.jsx("img",{src:YH,alt:"Remove image",className:"w-2 h-2"})})})]},t))})}),pt.hasFiles&&a.jsx("div",{className:"flex items-center gap-2 pt-1",children:a.jsx("div",{className:"flex flex-wrap gap-2",children:pt.isProcessing?a.jsxs("div",{className:"flex items-center justify-center py-1",children:[a.jsx(gS,{className:"h-4 w-4 text-[#999] animate-spin mr-2"}),a.jsx("span",{className:"text-[#999] text-xs",children:"Uploading..."})]}):pt.files.map((e,t)=>a.jsxs("div",{className:"relative w-16 h-16 overflow-hidden rounded-lg md:w-20 md:h-20 group backdrop-blur-md",style:{background:"linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 100%)",backdropFilter:"blur(10px)",border:"1px solid rgba(255, 255, 255, 0.1)"},children:[a.jsxs("div",{className:"flex flex-col items-center justify-center w-full h-full p-2",children:[a.jsx("div",{className:"w-8 h-8 mb-1 flex items-center justify-center rounded bg-[#FFFFFF20]",children:a.jsx("img",{src:qH,alt:"File",className:"w-5 h-5 invert opacity-70"})}),a.jsx("div",{className:"text-[8px] text-white/90 text-center leading-tight truncate max-w-full",children:e.name.length>8?`${e.name.substring(0,8)}...`:e.name}),a.jsxs("div",{className:"text-[6px] text-white/50 text-center mt-1",children:[(e.size/1024/1024).toFixed(1),"MB"]})]}),a.jsx("button",{onClick:()=>pt.removeFile(t),className:"absolute top-[-6px] right-[-6px] bg-transparent z-[2] rounded-full p-1 transition-opacity","aria-label":"Remove file",type:"button",children:a.jsx("div",{className:"bg-white rounded-full p-[2px]",children:a.jsx("img",{src:YH,alt:"Remove file",className:"w-2 h-2"})})})]},t))})}),!E&&X.length>0&&a.jsx("div",{className:"w-full",children:a.jsx("div",{className:"flex max-w-full gap-2 pb-1 overflow-x-auto overflow-y-hidden flex-nowrap scrollbar-thin scrollbar-thumb-white/20 scrollbar-track-transparent hover:scrollbar-thumb-white/30",children:X.map(e=>a.jsxs("div",{className:"relative flex-shrink-0 group",children:[a.jsx(OH,{artifact:e}),a.jsx("button",{type:"button",onClick:()=>vt(e.artifact_id),className:"absolute top-[-5px] right-[-5px] bg-transparent rounded-full p-1 transition-opacity opacity-0 group-hover:opacity-100","aria-label":"Remove attachment",children:a.jsx("div",{className:"p-1 bg-white rounded-full",children:a.jsx("img",{src:YH,alt:"Remove attachment",className:"w-2 h-2"})})})]},e.artifact_id))})}),0===ut.images.length&&!pt.hasFiles&&(E||0===X.length)&&!f&&!st&&a.jsxs("div",{className:"flex items-center gap-2 md:gap-4",children:[a.jsx("div",{className:"flex items-center gap-2 min-w-[58vw] md:min-w-fit md:gap-4",children:H?a.jsxs(a.Fragment,{children:[a.jsx(n$,{}),a.jsx("span",{className:"text-[15px] md:text-[16px] font-medium md:text-nowrap",style:{color:"#95C6FF"},children:V?"Editing":"Visual Editing..."}),V&&a.jsx(s$,{elementName:V})]}):a.jsxs(a.Fragment,{children:[a.jsx(i$,{status:i,colors:Ct}),a.jsx(a$,{status:i,colors:Ct,statusText:Nt})]})}),"subagent_waiting"===i&&b&&a.jsx("button",{onClick:b,className:"ml-2 px-2 py-1 text-xs font-semibold rounded-md transition-colors",style:{backgroundColor:`${Ct.subagent_waiting.color}`,color:ET(N||"").color},type:"button",children:"Reply"})]})]})}),"credit_exhausted"==Le&&a.jsx("div",{className:"max-md:py-1",children:a.jsxs("div",{className:"flex items-center justify-between w-full px-2 md:px-3 md:py-2",children:[a.jsxs("div",{className:bb("flex items-center gap-2"),children:[a.jsx(yT,{fill:"#CCC",className:"w-5 h-5"}),a.jsx("span",{className:"max-md:text-[14px]",children:(()=>{if(!qe||!Ue)return null;const e=qe.ecu_balance;return e<=0?Oe?"Credit Exhausted":"You have exhausted all of your credits.":e<=5?a.jsxs(a.Fragment,{children:[e.toFixed(2)," free credit remaining!"]}):null})()})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("button",{onClick:()=>{Ie.open({})},className:"text-[14px] text-[#F5CC62] flex gap-1 items-center font-medium p-1 pl-[6px] pr-4 rounded-[8px] bg-[#F5CC621F]",children:[a.jsx("div",{className:"self-center object-contain w-5 h-5",children:a.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.jsx("circle",{opacity:"0.16",cx:"10",cy:"10",r:"9",fill:"#F4D475"}),a.jsx("circle",{cx:"10.0001",cy:"9.99961",r:"5.85",stroke:"#0F0F10","stroke-width":"0.9"}),a.jsx("path",{d:"M9.27981 13.6008H10.7198V10.7208H13.5998V9.28078H10.7198V6.40078H9.27981V9.28078H6.3998V10.7208H9.27981V13.6008ZM9.9998 17.2008C9.00381 17.2008 8.0678 17.0118 7.1918 16.6338C6.3158 16.2558 5.5538 15.7428 4.9058 15.0948C4.2578 14.4468 3.7448 13.6848 3.3668 12.8088C2.9888 11.9328 2.7998 10.9968 2.7998 10.0008C2.7998 9.00478 2.9888 8.06878 3.3668 7.19278C3.7448 6.31678 4.2578 5.55478 4.9058 4.90678C5.5538 4.25878 6.3158 3.74578 7.1918 3.36778C8.0678 2.98978 9.00381 2.80078 9.9998 2.80078C10.9958 2.80078 11.9318 2.98978 12.8078 3.36778C13.6838 3.74578 14.4458 4.25878 15.0938 4.90678C15.7418 5.55478 16.2548 6.31678 16.6328 7.19278C17.0108 8.06878 17.1998 9.00478 17.1998 10.0008C17.1998 10.9968 17.0108 11.9328 16.6328 12.8088C16.2548 13.6848 15.7418 14.4468 15.0938 15.0948C14.4458 15.7428 13.6838 16.2558 12.8078 16.6338C11.9318 17.0118 10.9958 17.2008 9.9998 17.2008Z",fill:"#F4D475"})]})}),a.jsx("p",{children:"Buy Credits"})]}),a.jsx("button",{title:"Close",onClick:()=>{Re("normal")},className:"flex items-center justify-center w-4 h-4 hover:bg-[#FFFFFF0D] rounded-[8px]",children:a.jsx(HS,{})})]})]})}),"auto_message"==Le&&!st&&a.jsx("div",{className:"px-2 md:px-3 md:py-2",children:a.jsxs("div",{className:"flex items-center justify-between w-full",children:[a.jsxs("div",{className:"flex items-center gap-2 md:gap-4",children:[a.jsx("div",{className:"flex items-center gap-2 min-w-[58vw] md:min-w-fit md:gap-4",children:H?a.jsxs(a.Fragment,{children:[a.jsx(n$,{}),a.jsx("span",{className:"text-[15px] md:text-[16px] font-medium md:text-nowrap",style:{color:"#95C6FF"},children:V?"Editing":"Visual Editing..."}),V&&a.jsx(s$,{elementName:V})]}):a.jsxs(a.Fragment,{children:[a.jsx(i$,{status:i,colors:Ct}),a.jsx(a$,{status:i,colors:Ct,statusText:Nt})]})}),"subagent_waiting"===i&&b&&a.jsx("button",{onClick:b,className:"ml-2 px-2 py-1 text-xs font-semibold rounded-md transition-colors",style:{backgroundColor:`${Ct.subagent_waiting.color}`,color:ET(N||"").color},type:"button",children:"Reply"})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("button",{onClick:()=>jt("desktop"),disabled:Ce,className:"px-[6px] flex items-center gap-1 py-1 text-[15px] font-semibold rounded-md transition-colors bg-white text-[#000000] disabled:opacity-50 disabled:cursor-not-allowed",type:"button",children:Ce?a.jsxs(a.Fragment,{children:[a.jsx(gS,{size:20,className:"animate-spin"}),"Generating..."]}):a.jsxs(a.Fragment,{children:[a.jsx(UH,{size:20}),"Auto Answer"]})}),a.jsx("button",{title:"Close",onClick:()=>{Re("normal")},className:"flex items-center justify-center w-4 h-4 hover:bg-[#FFFFFF0D] rounded-[8px]",type:"button",children:a.jsx(HS,{})})]})]})}),a.jsxs("form",{onSubmit:Rt,className:bb("flex flex-1 flex-col md:bg-background bg-[#1A1A1C] rounded-none rounded-tl-[14px] rounded-tr-[14px] border border-1 relative md:rounded-xl",Qe?"border-[#5FD3F3]/50 border-2 border-dashed":"border-[#252526]"),onDragOver:e=>{e.preventDefault(),e.stopPropagation()},onDragEnter:e=>{e.preventDefault(),e.stopPropagation(),Xe(!0)},onDragLeave:e=>{e.preventDefault(),e.stopPropagation(),e.currentTarget.contains(e.relatedTarget)||Xe(!1)},onDrop:e=>{e.preventDefault(),e.stopPropagation(),Xe(!1);const t=e.dataTransfer.files;t.length>0&&mt(t)},children:[Qe&&a.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-background/80 rounded-xl",children:a.jsx("div",{className:"text-[#5FD3F3] text-center",children:a.jsx("p",{className:"font-medium",children:"Drop files here"})})}),a.jsx("textarea",{ref:Ae,value:ae,onChange:Pt,onFocus:()=>{Ge()},onPaste:e=>{var t;const n=null==(t=e.clipboardData)?void 0:t.items;if(!n)return;const s=Array.from(n).filter(e=>E||!et?e.type.startsWith("image/"):"file"===e.kind);if(0===s.length)return;e.preventDefault();const i=s.map(e=>e.getAsFile()).filter(Boolean);i.length>0&&mt(i)},className:bb("w-full resize-none md:bg-background bg-[#1A1A1C] outline-none text-[16px] px-4 py-3 min-h-[64px] overflow-y-auto placeholder:text-white/50 "+(Dt?"cursor-not-allowed opacity-20":""),E?"max-h-[120px]":"max-h-[200px]",st?"rounded-none rounded-tl-[14px] rounded-tr-[14px]":"rounded-xl"),style:{lineHeight:"1.5"},onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),Rt(e))},placeholder:Ht(),rows:2,disabled:Dt}),a.jsxs("div",{className:bb("flex items-center justify-between p-2.5 md:bg-background bg-[#1A1A1C]",st?"rounded-none":"rounded-xl"),children:[a.jsxs("div",{className:"relative flex items-center gap-2",ref:Te,children:[a.jsx("button",{type:"button",onClick:()=>{E||!et?xt():gt()},className:bb("p-2 transition-colors duration-200 rounded-[30px] bg-[#FFFFFF14] hover:bg-gray-100/10 group/paperclip",{"opacity-50 cursor-not-allowed":Dt}),disabled:Dt,children:a.jsx("img",{src:xe?t$:WH,alt:"Attach",className:bb("size-5 transition-transform duration-200 transform ",!xe&&"group-hover/paperclip:rotate-45")})}),a.jsx("input",{ref:Me,type:"file",accept:E||!et?"image/jpeg,image/png,image/gif,image/webp":"*/*",multiple:!0,onChange:ht,style:{display:"none"},"aria-hidden":"true"}),a.jsxs("button",{disabled:"waiting"!==i&&"subagent_waiting"!==i||"build"!=A||x||H,type:"button",onClick:kt,className:bb("p-2 pr-2.5 h-9 transition-colors duration-200 rounded-full flex items-center gap-1 bg-[#FFFFFF14] hover:bg-gray-100/10","waiting"!==i&&"subagent_waiting"!==i||"build"!=A||x||H?"opacity-50 cursor-not-allowed":"",E||st?"hidden":""),children:[a.jsx("img",{src:Be?XH:KH,alt:"GitHub",className:bb("size-5",Be&&"scale-[1.2] mt-1")}),a.jsx("span",{className:"text-sm font-medium text-[#E6E6E6]",children:"Save to GitHub"})]}),Ze&&(null==l?void 0:l.createdBy)&&a.jsx("button",{type:"button",disabled:"build"!=A||ue,onClick:Et,className:bb("p-2 h-9 transition-colors duration-200 rounded-full flex items-center gap-1 disabled:opacity-50 disabled:cursor-not-allowed",E?"hidden":"",ce?"bg-blue-500/20 border border-blue-500/50 hover:bg-blue-500/30":"bg-[#FFFFFF14] hover:bg-gray-100/10"),children:ue?a.jsx(gS,{className:"text-gray-400 size-5 animate-spin"}):a.jsx("span",{className:bb("text-[14px] font-medium mx-0.5",ce?"text-blue-400":"text-[#E6E6E6]"),children:"HIM"})}),a.jsx("div",{className:bb("relative transition-all duration-200",E||st?"hidden":""),children:a.jsxs("button",{type:"button",disabled:$t,onClick:St,className:bb("p-2 pr-2.5 h-9 transition-colors duration-200 rounded-full flex items-center gap-1 bg-[#FFFFFF14] hover:bg-gray-100/10 disabled:opacity-50 disabled:cursor-not-allowed","running"===T?"bg-[#80FFF90D] hover:bg-[#80FFF90D] disabled:opacity-100 cursor-not-allowed":""),children:["running"==T?a.jsx("img",{src:QH,alt:"Fork",className:"size-5"}):a.jsx("img",{src:e$,alt:"Fork",className:"size-[18px] ml-0.5"}),a.jsx("span",{className:bb("text-[14px] font-medium text-[#E6E6E6]","running"==T?"text-[#80FFF9]":""),children:"running"===T?"Forking...":"Fork"})]})}),Ze&&a.jsx("div",{className:bb("relative transition-all duration-200",E||st?"hidden":""),children:a.jsxs("button",{type:"button",disabled:be||!(null==l?void 0:l.job_id),onClick:yt,className:bb("p-2 pr-2.5 h-9 transition-colors duration-200 rounded-full flex items-center gap-1 bg-[#FFFFFF14] hover:bg-gray-100/10 disabled:opacity-50 disabled:cursor-not-allowed",be?"bg-[#80FFF90D] hover:bg-[#80FFF90D] disabled:opacity-100 cursor-not-allowed":""),children:[a.jsx("div",{className:"flex items-center justify-center w-5 h-5",children:be?a.jsx(gS,{className:"w-4 h-4 animate-spin text-[#80FFF9]"}):a.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{d:"M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"})})}),a.jsx("span",{className:bb("text-[14px] font-medium text-[#E6E6E6]",be?"text-[#80FFF9]":""),children:be?"Cloning...":"Clone"})]})}),a.jsxs("button",{type:"button",disabled:"waiting"!==i&&"subagent_waiting"!==i||"build"!=A||x||H,onClick:e=>{e.preventDefault(),e.stopPropagation()},className:bb("flex items-center gap-1 p-2 h-9 rounded-full transition-colors duration-200",D?"bg-[#FF8C661A]":"bg-[#FFFFFF14] hover:bg-gray-100/10",E||st?"hidden":"","disabled:opacity-50 disabled:cursor-not-allowed"),children:[a.jsx(pA,{color:D?"#FF8C66":"#ffffff",size:20}),a.jsx("span",{className:bb("text-[14px] font-medium transition-colors",D?"text-[#FF8C66]":"text-[#E6E6E6]"),children:"Ultra"}),a.jsx(mA,{checked:D,onCheckedChange:e=>{"pro_mode"===We||$e()?null==R||R(!D):Ie.open({})},className:"data-[state=unchecked]:bg-[#3B3B3B] data-[state=checked]:bg-[#FF8C66] scale-[0.8]"})]}),(W||De.current&&!1!==W)&&!E&&!st&&a.jsx(ME,{children:a.jsxs(L,{delayDuration:0,children:[a.jsx(P,{asChild:!0,children:a.jsx("button",{type:"button",disabled:"waiting"!==i&&"subagent_waiting"!==i||"build"!=A||x||!De.current,onClick:e=>{e.preventDefault(),e.stopPropagation();const t=!H;t||!q?(bg(t?"visual_edit_enabled":"visual_edit_disabled",{jobId:null==l?void 0:l.job_id,agentStatus:i,enableVisualEdit:W}),null==$||$(t)):null==Y||Y({onConfirm:ct,title:"You have unsaved changes",description:"Are you sure you want to exit the visual editor? You will lose your unsaved changes.",confirmButton:{text:"Confirm",variant:"default"},cancelButton:{text:"Cancel",variant:"outline"}})},className:bb("flex items-center justify-center w-[40px] h-[40px] rounded-full transition-colors duration-200",H?"bg-[#0161D1]":"bg-[#FFFFFF14] hover:bg-gray-100/10","disabled:opacity-50 disabled:cursor-not-allowed"),children:a.jsx("img",{src:JH,alt:"Visual Edit",className:"w-5 h-5"})})}),a.jsx(O,{className:"max-w-xs bg-[#fff] text-[#0f0f10] font-medium tracking-[-0.3px] text-sm p-[10px] rounded-lg shadow-lg z-[9999]",sideOffset:5,asChild:!0,children:a.jsxs(zt.div,{initial:{opacity:0,y:-2,scale:1},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-10,scale:1},transition:{type:"tween",ease:"easeOut",duration:.4},className:"flex items-center gap-1",children:[a.jsx("span",{children:H?"Disable Edit Mode":"Enable Edit Mode"}),a.jsxs("div",{className:"flex items-center gap-[2px]",children:[a.jsx("div",{className:"flex items-center justify-center h-5 px-1 rounded bg-[rgba(0,0,0,0.14)] border border-[rgba(0,0,0,0.08)]",children:a.jsx("span",{className:"text-xs font-medium text-[rgba(0,0,0,0.4)] font-brockmann",children:navigator.platform.toLowerCase().includes("mac")?"⌘":"ctrl"})}),a.jsx("div",{className:"flex items-center justify-center w-5 h-5 rounded bg-[rgba(0,0,0,0.14)] border border-[rgba(0,0,0,0.08)]",children:a.jsx("span",{className:"text-xs font-medium text-[rgba(0,0,0,0.4)] font-brockmann",children:"E"})})]}),a.jsx(z,{className:"fill-[#fff]"})]})})]})}),st&&!E&&a.jsx("button",{title:"Options",type:"button",onClick:()=>ve(!0),className:"p-2 transition-colors duration-200 rounded-full bg-[#FFFFFF14] hover:bg-gray-100/10",children:a.jsx(JI,{size:20,className:"md:hidden"})}),Oe&&D&&a.jsx("button",{title:"Fix",type:"button",className:bb("transition-colors duration-200 hover:opacity-80 size-9 flex items-center hover:bg-[#FFFFFF]/10 p-2 rounded-full",D?"bg-[#FF8C661A]":"bg-[#FFFFFF0D]"),onClick:()=>null==R?void 0:R(!D),children:a.jsx(pA,{size:20,color:D?"#FF8C66":"#E6E6E6"})})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[B&&Oe&&a.jsx("button",{onClick:()=>jt("mobile"),disabled:Ce,className:" px-[6px] md:hidden flex items-center h-[40px] pr-3 gap-1 py-1 text-[15px] font-semibold rounded-full transition-colors bg-white text-[#000000] disabled:opacity-50 disabled:cursor-not-allowed",type:"button",children:Ce?a.jsxs(a.Fragment,{children:[a.jsx(gS,{size:20,className:"animate-spin"}),"Generating..."]}):a.jsxs(a.Fragment,{children:[a.jsx(UH,{size:20}),"Auto Answer"]})}),a.jsx("button",{type:"button",onClick:Mt,className:bb("p-2 transition-colors duration-200 rounded-[30px] flex items-center justify-center size-9",Fe?"bg-white text-black hover:bg-white":"bg-[#FFFFFF14] hover:bg-[#FFFFFF14]",Ee&&"opacity-50 cursor-not-allowed",{"opacity-50 cursor-not-allowed":Dt}),disabled:Dt||Ee,title:Ee?"Transcribing audio...":Fe?"Stop recording":"Start voice recording",children:Ee?a.jsx(gS,{className:"w-5 h-5 animate-spin"}):Fe?a.jsx(zt.div,{animate:{scale:[1,1.2,1]},transition:{duration:1,repeat:1/0,ease:"easeInOut"},children:a.jsx(EE,{width:18,height:18,fill:"currentColor"})}):a.jsx(SE,{width:18,height:18,fill:"currentColor"})}),a.jsxs("button",{onClick:Rt,className:`flex ${"subagent_running"===i&&y?"w-auto px-3":"w-[48px] px-[12px]"} py-[6px] justify-center items-center gap-[10px] max-md:h-9 rounded-[38px] bg-[#DDDDE6] ${Ot?"opacity-50 cursor-not-allowed":""}`,type:"submit",disabled:Ot,children:["subagent_running"===i&&y&&a.jsx("span",{className:"text-sm font-medium text-black max-md:hidden",children:"Finish Sub-Agent"}),_t]})]})]})]}),a.jsx("div",{className:"flex flex-row justify-between items-center w-full md:hidden p-[10px]",style:{background:Ft("right","90%")},children:!f&&a.jsxs("div",{className:"flex items-center gap-2 md:gap-4",children:[a.jsx("div",{className:"flex items-center gap-2 min-w-[58vw] md:min-w-fit md:gap-4",children:H?a.jsxs(a.Fragment,{children:[a.jsx(n$,{}),a.jsx("span",{className:"text-[15px] md:text-[16px] font-medium md:text-nowrap",style:{color:"#95C6FF"},children:V?"Editing":"Visual Editing..."}),V&&a.jsx(s$,{elementName:V})]}):a.jsxs(a.Fragment,{children:[a.jsx(i$,{status:i,colors:Ct}),a.jsx(a$,{status:i,colors:Ct,statusText:Nt})]})}),"subagent_waiting"===i&&b&&a.jsx("button",{onClick:b,className:"ml-2 px-2 py-1 text-xs font-semibold rounded-md transition-colors",style:{backgroundColor:`${Ct.subagent_waiting.color}`,color:ET(N||"").color},type:"button",children:"Reply"})]})}),a.jsx(VH,{isOpen:ge,onOpenChange:ve,isGitHubConnected:Be,onSaveToGitHub:kt,isGitHubDisabled:"waiting"!==i&&"subagent_waiting"!==i||"build"!==A||x,onForkClick:St,isForkDisabled:$t,forkStatus:T,ultraMode:D,onUltraModeChange:R,isUltraDisabled:"waiting"!==i&&"subagent_waiting"!==i||"build"!==A||x,tier:We,onUpgradeRequired:()=>Ie.open({}),getCurrentOrganizationId:$e}),oe&&a.jsx(_H,{isOpen:oe,onOpenChange:e=>le(e),jobId:(null==l?void 0:l.job_id)||"",onSuccess:e=>{e&&F&&F(e),le(!1)},lastGithubUsed:C})]})})}),o$=({searchState:e,updateSearchQuery:t,navigateToPrevMatch:n,navigateToNextMatch:s,toggleSearch:i})=>{const r=(...e)=>e.filter(Boolean).join(" ");return a.jsx(zb,{children:e.isActive&&a.jsxs(Tk.div,{className:"absolute left-0 right-0 z-[999] flex items-center gap-2 p-2 mx-auto border border-white/15 rounded-lg shadow-lg bg-white/5 top-4 w-96 bg-clip-padding backdrop-filter backdrop-blur-xl",initial:{y:-50,opacity:0},animate:{y:0,opacity:1},exit:{y:-50,opacity:0},transition:{duration:.2,ease:"easeInOut"},children:[a.jsx(ES,{size:18,className:"text-gray-400"}),a.jsx("input",{autoFocus:!0,type:"text",value:e.query,onChange:e=>t(e.target.value),placeholder:"Search messages...",className:"flex-1 text-sm text-white bg-transparent border-none outline-none placeholder:text-white/30"}),e.matches.length>0&&a.jsxs("div",{className:"flex items-center gap-1 text-sm text-gray-400",children:[a.jsxs("span",{children:[e.currentMatchIndex+1," "]})," of ",a.jsx("span",{children:e.matches.length})]}),a.jsx("button",{onClick:n,disabled:0===e.matches.length,className:r("p-1 hover:bg-white/10 rounded transition-colors",0===e.matches.length?"opacity-50 cursor-not-allowed":""),title:"Previous match (Shift+Enter)",children:a.jsx($k,{size:18,className:"text-gray-400"})}),a.jsx("button",{onClick:s,disabled:0===e.matches.length,className:r("p-1 hover:bg-white/10 rounded transition-colors",0===e.matches.length?"opacity-50 cursor-not-allowed":""),title:"Next match (Enter)",children:a.jsx(zk,{size:18,className:"text-gray-400"})}),a.jsx("button",{onClick:()=>i(!1),className:"p-1 transition-colors rounded hover:bg-white/10",title:"Close search (Esc)",children:a.jsx(HS,{size:18,className:"text-gray-400"})})]})})};function l$({isCloudFlow:e,containerId:t,jobId:n,trajPath:s,isActive:i,onJobDetailsResult:a=()=>{},onTrajectoryResult:r,onAgentStateResult:o,onCurrentChunkResult:l,onBrainStormingResult:c,onLogsResult:d=()=>{},onError:u,onMessage:p=()=>{}}){Pe.useRef(`polling-${Date.now().toString(36)}`);const m=Pe.useRef(!1),h=Pe.useRef({containerId:t,jobId:n,trajPath:s}),[x,f]=Pe.useState("disconnected"),[g,v]=Pe.useState(!0),b=Pe.useRef(!0),y=function(){const[e,t]=Pe.useState("visible"===document.visibilityState);return Pe.useEffect(()=>{const e=()=>{t("visible"===document.visibilityState)};return document.addEventListener("visibilitychange",e),()=>{document.removeEventListener("visibilitychange",e)}},[]),e}(),w=Pe.useRef({jobDetails:null,trajectory:[],agentState:null,logs:null,currentChunk:null,lastRequestId:null}),j=Pe.useRef(null),C=Pe.useRef(()=>{m.current&&(m.current=!1,j.current&&(clearTimeout(j.current),j.current=null),f("disconnected"))});Pe.useEffect(()=>{h.current={containerId:t,jobId:n,trajPath:s}},[t,n,s]);const N=Pe.useCallback(async()=>{var e;if(m.current){try{f("connecting");let n={trajectories:{data:[],updated_data:[],agent_status:!1,agent_status_new:"paused",chat_mode:null}};if(h.current.jobId)try{if(n=await Pp(h.current.jobId,w.current.lastRequestId||void 0,{onTrajectoryResult:r,onCurrentChunkResult:l,cache:w}),n.trajectories){let t=[...w.current.trajectory];if((null==(e=n.trajectories.updated_data)?void 0:e.length)>0){const e=n.trajectories.updated_data.sort((e,t)=>new Date(e.created_at).getTime()-new Date(t.created_at).getTime()).map(e=>({...e.traj_payload,id:e.id,request_id:e.request_id,job_id:e.job_id,traj_payload:e.traj_payload,commit_id:e.commit_id,parent_request_id:e.parent_request_id,status:e.status,created_at:e.created_at,updated_at:e.updated_at}));for(const n of e){const e=t.findIndex(e=>e.id===n.id);-1!==e?t[e]={...t[e],...n}:t.push(n)}}w.current.trajectory=t,r(t);const s={agent_running:n.trajectories.agent_status,job_running:n.trajectories.agent_status,agent_status_new:n.trajectories.agent_status_new,chat_mode:n.trajectories.chat_mode,pod_state_display:n.trajectories.pod_state_display,pod_state_hitl:n.trajectories.pod_state_hitl,show_upgrade:n.trajectories.show_upgrade},i={chat_mode:n.trajectories.chat_mode||null};c&&c(i),o(s);const a=[...n.trajectories.data||[],...n.trajectories.updated_data||[]];if(a.length>0){const e=a.reduce((e,t)=>new Date(t.created_at).getTime()>new Date(e.created_at).getTime()?t:e,a[0]).request_id;w.current.lastRequestId=e,e!==w.current.lastRequestId&&(w.current.lastRequestId=e)}}}catch(t){return u(t instanceof Error?t.message:String(t)),f("error"),void(g?f("reconnecting"):C.current())}f("connected")}catch(t){u(t instanceof Error?t.message:String(t)),f("error"),t instanceof Error&&"Container is not running"===t.message&&C.current()}m.current&&(j.current=setTimeout(N,2e3))}},[g,e,a,r,o,l,d,u,p]),F=Pe.useCallback(()=>{if(m.current)return;if(!i)return;if(!y)return;(h.current.containerId||h.current.jobId||h.current.trajPath)&&(m.current=!0,f("connecting"),N())},[i,y,N]);Pe.useEffect(()=>{C.current=()=>{m.current&&(m.current=!1,j.current&&(clearTimeout(j.current),j.current=null),f("disconnected"))}},[]);const _=Pe.useCallback(()=>{C.current()},[]),k=Pe.useCallback(()=>{w.current.trajectory=[],w.current.lastRequestId=null,m.current&&(C.current(),i&&y&&F())},[i,y,F]);return Pe.useEffect(()=>{if(b.current){b.current=!1;const e=h.current.containerId||h.current.jobId||h.current.trajPath;return void(i&&y&&e&&!m.current&&setTimeout(()=>{i&&y&&!m.current&&F()},50))}if(i&&y){(h.current.containerId||h.current.jobId||h.current.trajPath)&&!m.current&&F()}else m.current&&C.current()},[i,y,F]),Pe.useEffect(()=>()=>{m.current&&(j.current&&(clearTimeout(j.current),j.current=null),m.current=!1)},[]),{startPolling:F,stopPolling:_,resetPolling:k,connectionStatus:x,autoReconnect:g,setAutoReconnect:v,isTabVisible:y}}const c$=Pe.forwardRef(({className:e,children:t,...n},s)=>a.jsxs(ne,{ref:s,className:bb("relative overflow-hidden",e),...n,children:[a.jsx(se,{className:"h-full w-full rounded-[inherit]",children:t}),a.jsx(d$,{}),a.jsx(ie,{})]}));c$.displayName=ne.displayName;const d$=Pe.forwardRef(({className:e,orientation:t="vertical",...n},s)=>a.jsx(ae,{ref:s,orientation:t,className:bb("flex touch-none select-none transition-colors","vertical"===t&&"h-full w-2.5 border-l border-l-transparent p-[1px]","horizontal"===t&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:a.jsx(re,{className:"relative flex-1 rounded-full bg-border"})}));d$.displayName=ae.displayName;const u$=wv.common.folder,p$=wv.common.testFile,m$=wv.common.file,h$=wv.common.activeFile,x$=wv.icons.code,f$=e=>{e.editor.defineTheme("github-dark",{base:"vs-dark",inherit:!0,rules:[{token:"deleted",foreground:"ff4a4a",fontStyle:"italic"},{token:"inserted",foreground:"4af94a"}],colors:{"editor.background":"#111112","editor.foreground":"#cccccc","editor.lineHighlightBackground":"#1e1e1e","editorLineNumber.foreground":"#6e7681","editorLineNumber.activeForeground":"#cccccc","editorGutter.background":"#111112","diffEditor.insertedTextBackground":"#23863a33","diffEditor.removedTextBackground":"#da363333","diffEditor.insertedLineBackground":"#23863a22","diffEditor.removedLineBackground":"#da363322"}})},g$=({isOpen:e,onClose:t,onOpenVSCode:n,containerId:s,modifiedFiles:i,initialCommitId:r,isCloudFlow:o,jobId:l})=>{const[c,d]=Pe.useState("all"),[u,p]=Pe.useState(""),[m,h]=Pe.useState(null),[x,f]=Pe.useState(null),[g,v]=Pe.useState(!1),[b,y]=Pe.useState(null),w=Pe.useMemo(()=>i.map(e=>({...e,parentFolder:e.fileName?e.fileName.split("/").slice(0,-1).join("/"):""})),[i]),j=Pe.useMemo(()=>{const e={};return w.forEach(t=>{const n=t.parentFolder||"";e[n]||(e[n]=[]),e[n].push(t)}),e},[w]),C=Pe.useCallback(async e=>{var t,n,i;v(!0),y(null),f(null);try{let a;if(o&&l){const s=await Mp(l,e,r);if(!(null==(i=null==(n=null==(t=s.data)?void 0:t.data)?void 0:n.data)?void 0:i.diff))return void y("No changes in this file");a=atob(s.data.data.data.diff)}else a=await bp.getGitDiff(s,e,r);if(!a.trim())return void y("No changes in this file");if(a.length>1e5)return void y("Diff is too large to render. Please use VS Code to view this diff.");const c=a.split("\n");let d="",u="";for(const e of c)e.startsWith("--- a/")||e.startsWith("+++ b/")||e.startsWith("@@")||(e.startsWith("-")?d+=e.slice(1)+"\n":e.startsWith("+")?u+=e.slice(1)+"\n":(d+=e+"\n",u+=e+"\n"));f({originalContent:d.trim(),modifiedContent:u.trim()})}catch(a){y(a.message)}finally{v(!1)}},[s,r,o,l]);return Pe.useEffect(()=>{e&&i.length>0&&!m&&h(i[0].fileName)},[e,i]),Pe.useEffect(()=>{m&&C(m)},[m,C]),e?a.jsx(IA,{open:e,onOpenChange:e=>!e&&t(),children:a.jsxs(LA,{className:"max-w-[90vw] w-[90vw] h-[90vh] max-h-[90vh] p-0 gap-0 bg-[#111112]",hideclosebutton:!0,children:[a.jsx(PA,{className:"border-b border-[#333333] bg-[#111112] p-0",children:a.jsxs("div",{className:"flex",children:[a.jsx("div",{className:"w-[30%] p-4 border-r border-[#333333]",children:a.jsxs("div",{className:"relative flex-1",children:[a.jsx(ES,{className:"absolute left-2 top-1/2 transform -translate-y-1/2 w-4 h-4 text-[#666666]"}),a.jsx(KS,{value:u,onChange:e=>p(e.target.value),className:"pl-8 pr-14 bg-[#1e1e1e] border-[#333333] text-[#cccccc] h-8 text-sm",placeholder:"Search files..."}),a.jsx("span",{className:"absolute right-2 top-1/2 transform -translate-y-1/2 text-xs text-[#666666]",children:"⌘ K"})]})}),a.jsxs("div",{className:"w-[70%] p-4 flex justify-between items-center space-x-2",children:[a.jsxs("div",{className:"flex items-center space-x-2",children:[a.jsx("img",{alt:"Active file",src:h$,className:"w-4 h-4"}),a.jsx("h2",{className:"text-[#cccccc] text-sm font-medium",children:m||"No file selected"})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("button",{className:"flex items-center gap-2 px-3 py-1.5 bg-[#2A2A2A] rounded hover:bg-[#3A3A3A] transition-colors",onClick:n,children:[a.jsx("img",{src:x$,className:"w-4 h-4"}),a.jsx("span",{className:"text-[#CCCCCC] text-sm",children:"Open in VS Code"})]}),a.jsx("button",{className:"p-1.5 hover:bg-[#2A2A2A] rounded transition-colors",onClick:t,children:a.jsx(HS,{className:"w-4 h-4 text-[#CCCCCC]"})})]})]})]})}),a.jsxs("div",{className:"flex h-[calc(90vh-4rem)]",children:[a.jsxs("div",{className:"w-[30%] min-w-[30%] border-r border-[#333333] h-full",children:[a.jsx("div",{className:"border-b border-[#333333]",children:a.jsxs("div",{className:"flex text-[#cccccc]",children:[a.jsxs("button",{className:bb("flex-1 flex items-center justify-center gap-2 py-3 transition-colors","text-[#DDDDE6] text-center font-inter text-xs font-semibold leading-4 tracking-[0.48px] uppercase","all"===c?"border-b-2 border-[#ff6b6b] opacity-100":"opacity-60 hover:opacity-100"),onClick:()=>d("all"),children:[a.jsx("img",{src:u$,className:"w-4 h-4"}),"ALL FILES"]}),a.jsxs("button",{className:bb("flex-1 flex items-center justify-center gap-2 py-3 transition-colors","text-[#DDDDE6] text-center font-inter text-xs font-semibold leading-4 tracking-[0.48px] uppercase","test"===c?"border-b-2 border-[#ff6b6b] opacity-100":"opacity-60 hover:opacity-100"),onClick:()=>d("test"),children:[a.jsx("img",{src:p$,className:"w-4 h-4"}),"TEST FILES"]}),a.jsxs("button",{className:bb("flex-1 flex items-center justify-center gap-2 py-3 transition-colors","text-[#DDDDE6] text-center font-inter text-xs font-semibold leading-4 tracking-[0.48px] uppercase","doc"===c?"border-b-2 border-[#ff6b6b] opacity-100":"opacity-60 hover:opacity-100"),onClick:()=>d("doc"),children:[a.jsx("img",{src:m$,className:"w-4 h-4"}),"DOC FILES"]})]})}),a.jsx(c$,{className:"h-[calc(100%-3rem)]",children:a.jsxs("div",{className:"p-2 space-y-2",children:[j[""]&&a.jsx("div",{className:"mb-4",children:j[""].map(e=>a.jsxs("div",{className:bb("flex items-center gap-2 p-2 rounded cursor-pointer text-sm",m===(null==e?void 0:e.fileName)?"bg-[#1A1A1C] text-white":bb("hover:bg-[#1A1A1C]","M"===e.status?"text-[#CCB252]":"text-[#cccccc]")),onClick:()=>h(null==e?void 0:e.fileName),children:[a.jsx("img",{src:h$,className:bb("w-4 h-4","M"===e.status&&"opacity-80")}),a.jsx("span",{children:e.fileName?e.fileName.split("/").pop():""}),a.jsx("span",{className:"ml-auto text-xs opacity-60",children:e.status})]},null==e?void 0:e.fileName))}),Object.entries(j).filter(([e])=>""!==e).map(([e,t])=>a.jsxs("div",{className:"mb-4",children:[a.jsx("div",{className:"mb-2 text-sm font-medium text-gray-500",children:e}),t.map(e=>a.jsxs("div",{className:bb("flex items-center gap-2 p-2 rounded cursor-pointer text-sm",m===e.fileName?"bg-[#1A1A1C] text-white":bb("hover:bg-[#1A1A1C]","M"===e.status?"text-[#CCB252]":"text-[#cccccc]")),onClick:()=>h(e.fileName),children:[a.jsx("img",{src:h$,className:bb("w-4 h-4","M"===e.status&&"opacity-80")}),a.jsx("span",{children:e.fileName?e.fileName.split("/").pop():""}),a.jsx("span",{className:"ml-auto text-xs opacity-60",children:e.status})]},e.fileName))]},e))]})})]}),a.jsx("div",{className:"w-[70%] max-w-[70%] h-full",children:g?a.jsx("div",{className:"flex items-center justify-center h-full",children:a.jsx("div",{className:"text-[#cccccc]",children:"Loading diff..."})}):b?a.jsx("div",{className:"flex items-center justify-center h-full",children:a.jsx("div",{className:"text-[#ff6b6b] max-w-md text-center p-4",children:b})}):x?a.jsx($t,{height:"100%",theme:"github-dark",original:x.originalContent,modified:x.modifiedContent,beforeMount:f$,options:{renderSideBySide:!0,readOnly:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1,automaticLayout:!0,lineNumbers:"on",diffWordWrap:"off",renderOverviewRuler:!1,fontSize:13,fontFamily:"'JetBrains Mono', 'Fira Code','SF Mono', Menlo, Monaco, Consolas, 'Courier New', monospace",lineHeight:20,glyphMargin:!1,folding:!1,renderIndicators:!0,renderMarginRevertIcon:!1,ignoreTrimWhitespace:!1,"bracketPairColorization.enabled":!1}}):a.jsx("div",{className:"flex items-center justify-center h-full",children:a.jsx("div",{className:"text-[#666666]",children:"Select a file to view diff"})})})]})]})}):null},v$=async(e,t)=>{try{const n=await fetch(e);if(!n.ok)throw new Error(`Failed to fetch file: ${n.statusText}`);const s=await n.blob(),i=URL.createObjectURL(s),a=document.createElement("a");a.href=i,a.download=t||"download",a.style.display="none",document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i)}catch(n){const s=document.createElement("a");s.href=e,s.target="_blank",s.download=t||"download",s.style.display="none",document.body.appendChild(s),s.click(),document.body.removeChild(s)}};function b$({image:e,isOpen:t,onClose:n}){Pe.useEffect(()=>{const e=e=>{"Escape"===e.key&&t&&n()};return t&&(document.addEventListener("keydown",e),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",e),document.body.style.overflow="unset"}},[t,n]);return t&&e?Be.createPortal(a.jsxs("div",{className:"fixed inset-0 z-[999] flex items-center justify-center bg-black/80 backdrop-blur-sm",onClick:e=>{e.target===e.currentTarget&&n()},children:[a.jsxs("div",{className:"absolute top-0 left-0 right-0 z-10 flex items-center justify-between p-4 bg-gradient-to-b from-black/50 to-transparent",children:[a.jsx("div",{className:"text-sm text-white/70",children:"Image Preview"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("button",{type:"button",onClick:()=>{if(!e)return;const t=`data:${e.mime_type};base64,${e.img_base64}`,n=e.mime_type.split("/")[1]||"png";((e,t)=>{const n=document.createElement("a");n.href=e,n.download=t,n.style.display="none",document.body.appendChild(n),n.click(),document.body.removeChild(n)})(t,`image-${(new Date).getTime()}.${n}`)},className:"p-2 transition-all duration-200 rounded-lg text-white/70 hover:text-white bg-white/10 hover:bg-white/20",title:"Download image",children:a.jsx(lS,{className:"w-5 h-5"})}),a.jsx("button",{type:"button",onClick:n,className:"p-2 transition-all duration-200 rounded-lg text-white/70 hover:text-white bg-white/10 hover:bg-white/20",title:"Close preview",children:a.jsx(HS,{className:"w-5 h-5"})})]})]}),a.jsx("div",{className:"relative flex items-center justify-center w-full h-full p-8 pt-20",children:a.jsx("img",{src:`data:${e.mime_type};base64,${e.img_base64}`,alt:"Full size preview",className:"object-contain max-w-full max-h-full rounded-lg shadow-2xl",onClick:e=>e.stopPropagation()})})]}),document.body):null}function y$({images:e,className:t}){const[n,s]=Pe.useState(null);return e&&0!==e.length?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:bb("grid gap-2 relative my-4 rounded-lg w-full",1===e.length?"grid-cols-1":2===e.length?"grid-cols-2":"grid-cols-2 md:grid-cols-3",t),children:e.map((e,t)=>a.jsx("div",{className:"relative rounded-lg max-h-[300px] overflow-hidden bg-white/10 flex items-center justify-center cursor-pointer",onClick:()=>s(e),children:a.jsx("img",{src:`data:${e.mime_type};base64,${e.img_base64}`,alt:`Image ${t+1}`,className:"w-full h-full object-contain rounded-lg max-h-[300px]"})},t))}),a.jsx(b$,{image:n,isOpen:!!n,onClose:()=>s(null)})]}):null}function w$({imageUrl:e,imageName:t,isOpen:n,onClose:s}){Pe.useEffect(()=>{const e=e=>{"Escape"===e.key&&n&&s()};return n&&(document.addEventListener("keydown",e),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",e),document.body.style.overflow="unset"}},[n,s]);return n&&e?Be.createPortal(a.jsxs("div",{className:"fixed inset-0 z-[999] flex items-center justify-center bg-black/80 backdrop-blur-sm",onClick:e=>{e.target===e.currentTarget&&s()},children:[a.jsxs("div",{className:"absolute top-0 left-0 right-0 z-10 flex items-center justify-between p-4 bg-gradient-to-b from-black/50 to-transparent",children:[a.jsx("div",{className:"text-sm truncate text-white/70 max-w-[80%]",children:t?`${t} - Image Preview`:"Image Preview"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("button",{type:"button",onClick:async()=>{var n;if(e)try{const s=t||`image-${(new Date).getTime()}`,i=(null==(n=e.split(".").pop())?void 0:n.split("?")[0])||"png",a=s.includes(".")?s:`${s}.${i}`;await v$(e,a)}catch(s){window.open(e,"_blank")}},className:"p-2 transition-all duration-200 rounded-lg text-white/70 hover:text-white bg-white/10 hover:bg-white/20",title:"Download image",children:a.jsx(lS,{className:"w-5 h-5"})}),a.jsx("button",{type:"button",onClick:s,className:"p-2 transition-all duration-200 rounded-lg text-white/70 hover:text-white bg-white/10 hover:bg-white/20",title:"Close preview",children:a.jsx(HS,{className:"w-5 h-5"})})]})]}),a.jsx("div",{className:"relative flex items-center justify-center w-full h-full p-8 pt-20",children:a.jsx("img",{src:e,alt:t||"Full size preview",className:"object-contain max-w-full max-h-full rounded-lg shadow-2xl min-h-[300px] min-w-[300px]",onClick:e=>e.stopPropagation()})})]}),document.body):null}const j$=wv.files.pdf,C$=wv.files.csv,N$=wv.files.doc,F$=wv.files.ppt,_$=wv.files.txt,k$=wv.files.video,S$=wv.files.svg,E$=wv.files.other,I$=wv.files.zip,A$=(e,t,n)=>{if(!e&&!t&&!n)return!1;const s=[".jpg",".jpeg",".png",".gif",".webp",".svg",".bmp",".tiff",".tif",".ico",".avif",".heic",".heif"].some(n=>{const s=!!e&&e.toLowerCase().endsWith(n),i=!!t&&t.toLowerCase().includes(n);return s||i});if(n&&n.startsWith("image/"))return!0;const i=!!t&&["image","img","photo","picture","pic",".jpg",".jpeg",".png",".gif",".webp",".svg",".bmp",".tiff",".tif",".ico",".avif",".heic",".heif"].some(e=>t.toLowerCase().includes(e));return s||i},T$=e=>{if(!e)return"Unknown size";if(0===e)return"0 Bytes";const t=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/Math.pow(1024,t)).toFixed(2))+" "+["Bytes","KB","MB","GB"][t]},M$=(e,t=15)=>{if(e.length<=t)return e;const n=e.split(".").pop()||"",s=e.substring(0,e.lastIndexOf("."));return s.length<=10?e:`${s.substring(0,15)}...${n}`};function D$({images:e,className:t}){const[n,s]=Pe.useState(null),[i,r]=Pe.useState(null);if(!e||0===e.length)return null;return a.jsxs(a.Fragment,{children:[a.jsx("div",{className:bb("flex flex-wrap max-w-4xl overflow-x-auto gap-[10px] relative my-2 mb-0 rounded-lg w-full",t),children:e.map((e,t)=>{const n=A$(e.name,e.url,e.mime_type),o=((e,t)=>{if(!t&&!e)return E$;const n=(null==t?void 0:t.toLowerCase())||"";return n.endsWith(".pdf")||"application/pdf"===e?j$:n.endsWith(".csv")||"text/csv"===e?C$:n.endsWith(".doc")||n.endsWith(".docx")||"application/msword"===e||"application/vnd.openxmlformats-officedocument.wordprocessingml.document"===e?N$:n.endsWith(".zip")||n.endsWith(".tar")||n.endsWith(".rar")||n.endsWith(".7z")||(null==e?void 0:e.includes("zip"))||(null==e?void 0:e.includes("tar"))||(null==e?void 0:e.includes("rar"))||(null==e?void 0:e.includes("7z"))?I$:n.endsWith(".ppt")||n.endsWith(".pptx")||"application/vnd.ms-powerpoint"===e||"application/vnd.openxmlformats-officedocument.presentationml.presentation"===e?F$:n.endsWith(".txt")||n.endsWith(".md")||n.endsWith(".log")||"text/plain"===e||"text/markdown"===e?_$:n.endsWith(".mp4")||n.endsWith(".avi")||n.endsWith(".mov")||n.endsWith(".wmv")||n.endsWith(".mkv")||(null==e?void 0:e.startsWith("video/"))?k$:n.endsWith(".svg")||"image/svg+xml"===e?S$:n.endsWith(".xls")||n.endsWith(".xlsx")||"application/vnd.ms-excel"===e||"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"===e?C$:E$})(e.mime_type,e.name),l=(c=e.mime_type,d=e.name,(null==c?void 0:c.startsWith("image/"))?xS:(null==c?void 0:c.startsWith("video/"))?BS:(null==c?void 0:c.startsWith("text/"))||(null==d?void 0:d.endsWith(".txt"))?pS:(null==c?void 0:c.includes("zip"))||(null==c?void 0:c.includes("tar"))||(null==c?void 0:c.includes("rar"))?Ok:(null==d?void 0:d.endsWith(".pdf"))||(null==d?void 0:d.endsWith(".csv"))||(null==d?void 0:d.endsWith(".xlsx"))?pS:mS);var c,d;const u="private"===e.visibility&&!e.url;return a.jsxs("div",{className:"relative rounded-[12px] p-[6px] min-h-[180px] max-h-[180px] min-w-[180px] max-w-[180px] overflow-hidden bg-[#FFFFFF0F] flex flex-col items-center justify-center transition-colors "+(u?"":"cursor-pointer hover:bg-[#FFFFFF15]"),onClick:()=>(e=>{("private"!==e.visibility||e.url)&&A$(e.name,e.url,e.mime_type)&&s(e)})(e),onMouseEnter:()=>!u&&r(t),onMouseLeave:()=>r(null),children:[n&&e.url?a.jsx("img",{src:e.url,alt:e.name||`Image ${t+1}`,className:"object-cover w-full h-full rounded-lg",onError:t=>{const n=t.target.parentElement;n&&(n.innerHTML=`\n
\n File\n ${M$(e.name)}\n ${T$(e.file_size)}\n
\n `)}}):a.jsxs("div",{className:"flex flex-col items-start justify-between w-full h-full p-3 bg-[#FFFFFF05] rounded-[8px]",children:[a.jsx("div",{className:"flex items-center w-full ",children:o?a.jsx("img",{src:o,alt:"File",className:bb("w-12 h-12 mb-2",o===I$&&"p-1")}):a.jsx(l,{className:"w-12 h-12 mb-2 text-[#FFFFFF60]"})}),a.jsxs("div",{className:"flex flex-col items-start justify-center",children:[a.jsx("span",{className:"text-[12px] text-white/70 text-nowrap text-center break-words mb-1",children:M$(e.name)}),(e.file_size||0)>0&&a.jsx("span",{className:"text-[10px] text-white/50",children:T$(e.file_size)})]})]}),a.jsx("button",{type:"button",onClick:t=>(async(e,t)=>{t.stopPropagation(),("private"!==e.visibility||e.url)&&await v$(e.url,e.name||"download")})(e,t),disabled:u,className:"absolute top-2 right-2 p-1.5 bg-black/50 rounded-lg transition-opacity "+(u?"opacity-0":"hover:bg-black/70 "+(i===t?"opacity-100":"opacity-0")),title:u?"Private file - Download not available":"Download file",children:a.jsx(lS,{className:"w-4 h-4 text-white"})})]},t)})}),n&&A$(n.name,n.url,n.mime_type)&&a.jsx(w$,{imageUrl:n.url,imageName:n.name,isOpen:!!n,onClose:()=>s(null)})]})}const L$=e=>{if(!e||!e.name&&!e.mime_type)return!1;if(e.mime_type&&["image/jpeg","image/jpg","image/png","image/gif","image/webp","image/svg+xml","image/bmp","image/tiff","image/ico","image/avif","image/heic","image/heif"].includes(e.mime_type))return!0;const t=e.name||e.file_name;if(t){return[".jpg",".jpeg",".png",".gif",".webp",".svg",".bmp",".tiff",".tif",".ico",".avif",".heic",".heif"].some(e=>t.toLowerCase().endsWith(e))}return!1},P$=({base64Images:e,artifacts:t,artifactSharedData:n,className:s,fromMember:i})=>{const{imageArtifacts:r,nonImageArtifacts:o,base64Images:l,hasImageArtifacts:c,hasNonImageArtifacts:d,hasBase64:u}=(()=>{const s=t||(null==n?void 0:n.artifacts)||[],i=e||(null==n?void 0:n.base64_image_list)||[],a=s.filter(e=>e.file_name||e.name).map(e=>{let t="";return e.local_preview_base64?t=`data:${e.mime_type||"image/jpeg"};base64,${e.local_preview_base64}`:e.local_preview_url?t=e.local_preview_url:e.file_path?t=e.file_path:e.url&&(t=e.url),{name:e.file_name||e.name||"unnamed",url:t,artifact_type:e.artifact_type,mime_type:e.mime_type,file_size:e.file_size,visibility:e.visibility||(t?"public":"private")}}),r=a.filter(L$),o=a.filter(e=>!L$(e));if(a.length>0){if(i.length>0){const{matchedArtifacts:e,unmatchedBase64:t}=((e,t)=>{const n=[],s=[];return new Set(e.filter(L$).map(e=>{var t;return null==(t=e.name)?void 0:t.toLowerCase()}).filter(e=>void 0!==e)),t.forEach(t=>{e.some(e=>L$(e)&&!0)||s.push(t)}),e.forEach(e=>{L$(e)&&n.push(e)}),{matchedArtifacts:n,unmatchedBase64:s}})(r,i);return{imageArtifacts:e,nonImageArtifacts:o,base64Images:t,hasImageArtifacts:e.length>0,hasNonImageArtifacts:o.length>0,hasBase64:t.length>0}}return{imageArtifacts:r,nonImageArtifacts:o,base64Images:[],hasImageArtifacts:r.length>0,hasNonImageArtifacts:o.length>0,hasBase64:!1}}return{imageArtifacts:[],nonImageArtifacts:[],base64Images:i,hasImageArtifacts:!1,hasNonImageArtifacts:!1,hasBase64:i.length>0}})(),p=[...r,...o];return 0!==p.length||u?a.jsxs("div",{className:bb("enhanced-image-renderer",s),children:[p.length>0&&a.jsx(D$,{images:p,className:i?"justify-start md:ml-[42px]":"justify-end"}),u&&a.jsx(y$,{images:l,className:i?"justify-start md:ml-[42px]":"justify-end"})]}):null},R$=de,O$=Pe.forwardRef(({className:e,...t},n)=>a.jsx(oe,{ref:n,className:bb("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",e),...t}));O$.displayName=oe.displayName;const z$=Pe.forwardRef(({className:e,...t},n)=>a.jsx(le,{ref:n,className:bb("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",e),...t}));z$.displayName=le.displayName;const B$=Pe.forwardRef(({className:e,...t},n)=>a.jsx(ce,{ref:n,className:bb("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...t}));B$.displayName=ce.displayName;const H$=({data:e,searchTerm:t,path:n="",isRoot:s=!1,defaultExpanded:i=!1})=>{const[r,o]=Pe.useState(i||s),l=!!t&&JSON.stringify(e).toLowerCase().includes(t.toLowerCase()),c=e=>{if(!t)return e;const n=new RegExp(`(${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")})`,"gi");return e.split(n).map((e,t)=>n.test(e)?a.jsx("span",{className:"text-white bg-yellow-500/30",children:e},t):e)};if(null===e)return a.jsx("span",{className:"text-gray-500",children:"null"});if(void 0===e)return a.jsx("span",{className:"text-gray-500",children:"undefined"});if("object"!=typeof e){const t=String(e);return a.jsxs("span",{className:"string"==typeof e?"text-green-400":"text-blue-400",children:["string"==typeof e?'"':"",c(t),"string"==typeof e?'"':""]})}if(Array.isArray(e)&&0===e.length)return a.jsx("span",{className:"text-gray-400",children:"[]"});if(0===Object.keys(e).length&&!Array.isArray(e))return a.jsx("span",{className:"text-gray-400",children:"{}"});const d=Array.isArray(e),u=d?e:Object.entries(e);return a.jsxs("div",{className:`${s?"":"ml-4"} ${l&&t?"border-l-2 border-yellow-500 pl-2":""}`,children:[a.jsxs("div",{className:"flex items-center px-1 rounded cursor-pointer hover:bg-gray-800",onClick:()=>o(!r),children:[r?a.jsx(Gk,{className:"w-4 h-4 mr-1 text-gray-400"}):a.jsx(Yk,{className:"w-4 h-4 mr-1 text-gray-400"}),a.jsx("span",{className:"text-gray-300",children:d?`Array(${u.length})`:`Object{${Object.keys(e).length}}`})]}),r&&a.jsx("div",{className:"ml-2",children:d?u.map((e,s)=>a.jsxs("div",{className:"flex",children:[a.jsxs("span",{className:"mr-2 text-gray-500",children:["[",s,"]:"]}),a.jsx(H$,{data:e,searchTerm:t,path:`${n}[${s}]`,defaultExpanded:l&&""!==t})]},`${n}.${s}`)):Object.entries(e).map(([e,s],i)=>a.jsxs("div",{className:"flex",children:[a.jsxs("span",{className:"mr-2 text-purple-400",children:['"',c(e),'":']}),a.jsx(H$,{data:s,searchTerm:t,path:`${n}.${e}`,defaultExpanded:l&&""!==t})]},`${n}.${e}`))})]})};function $$({isOpen:e,onOpenChange:t,containerId:n,message:s}){const{isMobile:i}=nI(),[r,o]=Pe.useState(!1),[l,c]=Pe.useState(null),[d,u]=Pe.useState(null),[p,m]=Pe.useState(""),[h,x]=Pe.useState("formatted");Pe.useEffect(()=>{const t=(null==s?void 0:s.request_id)||n;e&&t&&f()},[e,n,null==s?void 0:s.request_id]);const f=async()=>{const e=(null==s?void 0:s.request_id)||n;if(e){o(!0),c(null);try{const t=await Vp(e);u(t)}catch(t){c(t.message||"Failed to fetch debug information")}finally{o(!1)}}else c("No request ID or container ID available for debugging")},g=()=>{t(!1)},v=e=>{if(!e)return null;if("raw"===h){const t=JSON.stringify(e,null,2);if(!p)return a.jsx("pre",{className:"bg-[#1E1E1E] p-4 rounded-md overflow-auto h-full w-full text-sm",children:t});const n=new RegExp(`(${p.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")})`,"gi"),s=t.split(n);return a.jsx("pre",{className:"bg-[#1E1E1E] p-4 rounded-md overflow-auto h-full w-full text-sm",children:s.map((e,t)=>n.test(e)?a.jsx("span",{className:"text-white bg-yellow-500/30",children:e},t):a.jsx("span",{children:e},t))})}return a.jsx("div",{className:"bg-[#1E1E1E] p-4 rounded-md overflow-auto h-full w-full text-sm font-mono",children:a.jsx(H$,{data:e,searchTerm:p,isRoot:!0,defaultExpanded:!0})})},b=()=>a.jsx("div",{className:"flex-1 overflow-auto",children:r?a.jsxs("div",{className:"flex items-center justify-center h-64",children:[a.jsx(gS,{className:"w-8 h-8 animate-spin text-primary"}),a.jsx("span",{className:"ml-2",children:"Loading debug information..."})]}):l?a.jsx("div",{className:"p-4 text-red-500 rounded-md bg-red-500/10",children:l}):d?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"flex flex-col gap-4 px-4 mb-4",children:a.jsxs("div",{className:"relative flex items-center",children:[a.jsx(ES,{className:"absolute w-4 h-4 text-gray-400 transform -translate-y-1/2 left-3 top-1/2"}),a.jsx("input",{type:"text",placeholder:"Search in JSON...",className:"w-full pl-10 pr-4 py-2 bg-[#1E1E1E] border border-gray-700 rounded-md focus:outline-none focus:ring-1 focus:ring-blue-500",value:p,onChange:e=>m(e.target.value)}),a.jsx(oH,{showIcon:!0,iconOnly:!0,className:"ml-4 border-none bg-none",buttonClassName:Cb({variant:"outline",size:"sm",className:"whitespace-nowrap rounded-lg transition-all ease-in-out duration-200 bg-white/10 border-white/20 border hover:bg-white/20 hover:text-white text-white/40"}),value:JSON.stringify(d,null,2),tooltipText:"Copy",copiedTooltipText:"Copied",feedbackType:"tooltip",iconProps:{size:16},onCopy:()=>{}})]})}),a.jsxs(R$,{defaultValue:"raw",onValueChange:x,children:[a.jsxs(O$,{className:"grid w-full grid-cols-2",children:[a.jsx(z$,{value:"formatted",children:"Formatted"}),a.jsx(z$,{value:"raw",children:"Raw JSON"})]}),a.jsx(B$,{value:"formatted",className:"p-4 overflow-auto",children:v(d)}),a.jsx(B$,{value:"raw",className:"p-4 overflow-auto",children:v(d)})]})]}):a.jsx("div",{className:"flex items-center justify-center h-64 text-gray-400",children:"No debug information available"})});return i?a.jsx(ZI,{trigger:a.jsx("div",{}),title:`Debug Information for ${(null==s?void 0:s.request_id)||n}`,open:e,onOpenChange:t,maxWidth:"max-w-full",showDefaultFooter:!1,footer:a.jsx("div",{className:"flex justify-end w-full",children:a.jsx(Nb,{onClick:g,children:"Close"})}),children:a.jsx("div",{className:"h-[80vh] flex flex-col",children:b()})}):a.jsx(IA,{open:e,onOpenChange:t,children:a.jsxs(LA,{className:"sm:max-w-[90vw] h-[90vh] flex flex-col",children:[a.jsx(PA,{children:a.jsxs(OA,{children:["Debug Information for ",(null==s?void 0:s.request_id)||n]})}),b(),a.jsx(RA,{children:a.jsx(Nb,{onClick:g,children:"Close"})})]})})}const V$=wv.icons.history,U$=({isHovered:e,handleRollback:t,message:n,isCloudFlow:s,className:i,hideImportantActions:r,forkStatus:o,onCopy:l,agentStatus:c,podIsPaused:d=!1})=>{const u=iI(),[p,m]=Pe.useState(!1),{isMobile:h}=nI(),x=()=>d?"Please wake up the agent before rolling back":"subagent_running"===c?"Please wait for the subagent to finish before rolling back":"subagent_stopping"===c?"Can't rollback at the moment - Subagent is stopping":"subagent_waiting"===c?"Please finish the subagent before rolling back":"running"===c?"Can't rollback at the moment - Agent is running":"";return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:bb("inline-flex items-center gap-2",e?"opacity-100 pointer-events-auto":"opacity-0 absolute pointer-events-none",i),children:[n.enable_rollback&&!r&&"running"!==o&&a.jsx(ME,{children:a.jsxs(DE,{delayDuration:0,children:[a.jsx(LE,{asChild:!0,children:a.jsxs("button",{type:"button",className:`p-[6px] ${h?"":" pr-[10px]"} bg-[#222224] hover:bg-[#3c3c40] text-[#7B7B80] disabled:opacity-50 hover:text-[#ccc] flex items-center space-x-1 rounded-lg transition-colors`,onClick:()=>{t&&"waiting"===c&&t()},disabled:d||"waiting"!==c,children:[a.jsx("div",{className:"flex items-center justify-center w-5 h-5",children:a.jsx("img",{src:V$,className:"w-4 h-4 text-[#5C5F66]",alt:"Rollback"})}),!h&&a.jsx("span",{className:"text-[15px] leading-[20px] font-['Inter'] font-medium",children:"Rollback"})]})}),a.jsx(PE,{className:bb("bg-[#272829]/95 backdrop-blur-md border-[#2E2F34] text-white shadow-lg",x()?"":"hidden"),children:x()})]})}),u&&(n.containerId||n.request_id)&&!h&&a.jsx("button",{type:"button",className:"p-[6px] pr-[10px] bg-[#222224] hover:bg-[#3c3c40] text-[#7B7B80] hover:text-[#ccc] flex items-center space-x-1 rounded-lg transition-colors",onClick:()=>{m(!0)},children:a.jsx("div",{className:"flex items-center justify-center w-5 h-5",children:a.jsx(Vk,{className:"w-4 h-4 text-[#5C5F66]"})})}),a.jsx(oH,{value:()=>n.action?[n.content,n.action&&`\nAction: ${n.action}`,n.observation&&`\nObservation: ${n.observation}`,n.thought&&`\nThought: ${n.thought}`].filter(Boolean).join(""):n.content,feedbackType:"icon-text",defaultText:h?"":"Copy",copiedText:"Copied",showIcon:!0,onCopy:e=>{l&&l()},copiedClassName:"",buttonClassName:"p-[6px] bg-white/5 hover:bg-white/15 text-[15px] font-inter font-medium text-white/50 hover:text-white flex items-center space-x-1 rounded-lg transition-colors",iconProps:{size:16,className:"text-white/60"},className:"max-h-full bg-none"})]}),a.jsx($$,{isOpen:p,onOpenChange:m,containerId:n.containerId||n.request_id,message:n})]})},W$=(e,t=80)=>e.split(" ").some(e=>e.length>t),q$=[{pattern:/\b(API key|api key|API_KEY|apikey)\s+([\w\-\.]{20,})/gi,type:"API_KEY"},{pattern:/\b(secondary key|primary key|access key|secret key)\s+([\w\-\.]{20,})/gi,type:"KEY"},{pattern:/\b(database password|db password)\s+([\w\-\.&@!#%^*()+=]{3,})/gi,type:"PASSWORD"},{pattern:/\b(password|pwd)\s+([a-zA-Z0-9\-_\.&@!#%^*()+=]{6,})/gi,type:"PASSWORD"},{pattern:/(mongodb(\+srv)?:\/\/[^\s]+:[^\s]+@[^\s]+)/g,type:"CONNECTION_STRING"},{pattern:/(postgres:\/\/[^\s]+:[^\s]+@[^\s]+)/g,type:"CONNECTION_STRING"},{pattern:/(mysql:\/\/[^\s]+:[^\s]+@[^\s]+)/g,type:"CONNECTION_STRING"},{pattern:/(redis:\/\/[^\s]+:[^\s]+@[^\s]+)/g,type:"CONNECTION_STRING"},{pattern:/([a-zA-Z]+:\/\/[^:\s]+:[^@\s]+@[^\s]+)/g,type:"CONNECTION_STRING"},{pattern:/\b([a-fA-F0-9]{40,64})\b/g,type:"HASH"},{pattern:/(eyJ[a-zA-Z0-9_-]{10,}\.[a-zA-Z0-9_-]{10,}\.[a-zA-Z0-9_-]{10,})/g,type:"JWT"},{pattern:/\b([a-zA-Z0-9_-]+)?api[_-]?key["']?\s*[:=]\s*["']?([\w\-\.]{20,})["']?/gi,type:"API_KEY"},{pattern:/\b([a-zA-Z0-9_-]+)?token["']?\s*[:=]\s*["']?([\w\-\.]{20,})["']?/gi,type:"TOKEN"},{pattern:/\b([a-zA-Z0-9_-]+)?secret["']?\s*[:=]\s*["']?([\w\-\.]{20,})["']?/gi,type:"SECRET"},{pattern:/\b([a-zA-Z0-9_-]+)?password["']?\s*[:=]\s*["']?([\w\-\.]{6,})["']?/gi,type:"PASSWORD"},{pattern:/\bAKIA[0-9A-Z]{16}/g,type:"AWS_KEY"},{pattern:/\bTr0ub4dor&3\b/g,type:"PASSWORD"}],G$=(e,t,n,s="")=>{const i=/^[\s]*[{}\[\]()=><;.]|^[\s]*\w+\(|^\`\`\`/.test(e);return["my-1 overflow-hidden",t||i?"font-mono text-sm":n?"text-[#cfe3e6] font-['Inter'] text-[16px] leading-[28px] font-normal":"text-[#dcdce5] font-['Inter'] text-[16px] leading-[28px] font-normal",W$(e)?"break-words":"",s].filter(Boolean).join(" ")},Z$=e=>W$(e)?{wordBreak:"break-word"}:{},Y$=({originalText:e,truncatedText:t,className:n})=>{const s=t||K$(e);return a.jsx(ME,{children:a.jsxs(DE,{children:[a.jsx(LE,{asChild:!0,children:a.jsx("span",{className:bb("cursor-help border-b border-dotted border-gray-500",n),children:s})}),a.jsx(PE,{children:a.jsx("span",{className:"font-mono text-xs break-all",children:e})})]})})},K$=e=>{if(!e||e.length<=8)return e;return`${e.substring(0,3)}...${e.substring(e.length-3)}`},J$=(e,t,n,s=!1,i=[],r=0)=>{const o=/^[\s]*[{}\[\]()=><;.]|^[\s]*\w+\(|^\`\`\`/.test(e),l=s&&i?i.filter(t=>{const n=t.startIndex-r,s=t.endIndex-r;return n0}).map(t=>({startIndex:Math.max(0,t.startIndex-r),endIndex:Math.min(e.length,t.endIndex-r)})):[],c=(e=>{const t=[];return q$.forEach(({pattern:n,type:s})=>{let i;const a=new RegExp(n.source,n.flags);for(;null!==(i=a.exec(e));){const e=i[0],n=i.index,a=n+e.length;let r=e;if(i.length>1){const a=i[i.length-1];if(a&&e.includes(a)){r=a;const i=e.indexOf(a);if(-1!==i){const e=n+i,r=e+a.length;t.push({originalText:a,startIndex:e,endIndex:r,type:s});continue}}}t.push({originalText:r,startIndex:n,endIndex:a,type:s})}}),t.sort((e,t)=>e.startIndex-t.startIndex)})(e);if(0===c.length&&(!s||0===l.length))return a.jsx("p",{className:bb(G$(e,o,n)),style:Z$(e),children:e},t);const d=X$([...c.map(e=>({type:"sensitive",content:e.originalText,startIndex:e.startIndex,endIndex:e.endIndex})),...l.map(t=>({type:"highlight",content:e.substring(t.startIndex,t.endIndex),startIndex:t.startIndex,endIndex:t.endIndex}))],e);return a.jsx("p",{className:bb(G$(e,o,n)),style:Z$(e),children:d.map((e,n)=>"text"===e.type?e.content:"sensitive"===e.type?a.jsx(Y$,{originalText:e.content},`sensitive-${t}-${n}`):a.jsx("span",{className:"bg-[#ffff4d] text-black rounded px-0.5",children:e.content},`highlight-${t}-${n}`))},t)},Q$=(e,t=[])=>{if(!t||0===t.length)return e;const n=[];let s=0;return[...t].sort((e,t)=>e.startIndex-t.startIndex).forEach((t,i)=>{t.startIndex>s&&n.push(e.substring(s,t.startIndex)),n.push(a.jsx("span",{className:"bg-yellow-500/30 rounded px-0.5",children:e.substring(t.startIndex,t.endIndex)},`highlight-${i}`)),s=t.endIndex}),s{if(0===e.length)return[{type:"text",content:t,startIndex:0,endIndex:t.length}];const n=[...e].sort((e,t)=>e.startIndex-t.startIndex),s=[];let i=0;for(const a of n)a.startIndex>i&&s.push({type:"text",content:t.substring(i,a.startIndex),startIndex:i,endIndex:a.startIndex}),a.startIndex>=i&&(s.push(a),i=a.endIndex);return i{const t=e.split("\n"),n=[];let s=0;return t.forEach((e,i)=>{n.push(s),s+=e.length+(ia.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:s,children:[a.jsx("path",{d:"M5.8 4.8498V10.2723V10.2498V19.2498V4.8498ZM7.6 13.8498H10.75C10.885 13.5048 11.05 13.1823 11.245 12.8823C11.44 12.5823 11.665 12.3048 11.92 12.0498H7.6V13.8498ZM7.6 17.4498H10.4575C10.3825 17.1498 10.3338 16.8498 10.3113 16.5498C10.2888 16.2498 10.2925 15.9498 10.3225 15.6498H7.6V17.4498ZM5.8 21.0498C5.305 21.0498 4.88125 20.8736 4.52875 20.5211C4.17625 20.1686 4 19.7448 4 19.2498V4.8498C4 4.3548 4.17625 3.93105 4.52875 3.57855C4.88125 3.22605 5.305 3.0498 5.8 3.0498H13L18.4 8.4498V10.6998C18.115 10.5798 17.8225 10.4861 17.5225 10.4186C17.2225 10.3511 16.915 10.3023 16.6 10.2723V9.3498H12.1V4.8498H5.8V19.2498H11.2225C11.4625 19.6098 11.7325 19.9436 12.0325 20.2511C12.3325 20.5586 12.6625 20.8248 13.0225 21.0498H5.8ZM16.15 18.3498C16.78 18.3498 17.3125 18.1323 17.7475 17.6973C18.1825 17.2623 18.4 16.7298 18.4 16.0998C18.4 15.4698 18.1825 14.9373 17.7475 14.5023C17.3125 14.0673 16.78 13.8498 16.15 13.8498C15.52 13.8498 14.9875 14.0673 14.5525 14.5023C14.1175 14.9373 13.9 15.4698 13.9 16.0998C13.9 16.7298 14.1175 17.2623 14.5525 17.6973C14.9875 18.1323 15.52 18.3498 16.15 18.3498ZM20.74 21.9498L18.31 19.5198C17.995 19.7298 17.6537 19.8873 17.2862 19.9923C16.9187 20.0973 16.54 20.1498 16.15 20.1498C15.025 20.1498 14.0687 19.7561 13.2812 18.9686C12.4937 18.1811 12.1 17.2248 12.1 16.0998C12.1 14.9748 12.4937 14.0186 13.2812 13.2311C14.0687 12.4436 15.025 12.0498 16.15 12.0498C17.275 12.0498 18.2312 12.4436 19.0187 13.2311C19.8062 14.0186 20.2 14.9748 20.2 16.0998C20.2 16.4898 20.1475 16.8686 20.0425 17.2361C19.9375 17.6036 19.78 17.9448 19.57 18.2598L22 20.6898L20.74 21.9498Z",fill:t}),a.jsx("path",{d:"M16.1516 18.3498C16.7816 18.3498 17.3141 18.1323 17.7491 17.6973C18.1841 17.2623 18.4016 16.7298 18.4016 16.0998C18.4016 15.4698 18.1841 14.9373 17.7491 14.5023C17.3141 14.0673 16.7816 13.8498 16.1516 13.8498C15.5216 13.8498 14.9891 14.0673 14.5541 14.5023C14.1191 14.9373 13.9016 15.4698 13.9016 16.0998C13.9016 16.7298 14.1191 17.2623 14.5541 17.6973C14.9891 18.1323 15.5216 18.3498 16.1516 18.3498ZM20.7416 21.9498L18.3116 19.5198C17.9966 19.7298 17.6553 19.8873 17.2878 19.9923C16.9203 20.0973 16.5416 20.1498 16.1516 20.1498C15.0266 20.1498 14.0703 19.7561 13.2828 18.9686C12.4953 18.1811 12.1016 17.2248 12.1016 16.0998C12.1016 14.9748 12.4953 14.0186 13.2828 13.2311C14.0703 12.4436 15.0266 12.0498 16.1516 12.0498C17.2766 12.0498 18.2328 12.4436 19.0203 13.2311C19.8078 14.0186 20.2016 14.9748 20.2016 16.0998C20.2016 16.4898 20.1491 16.8686 20.0441 17.2361C19.9391 17.6036 19.7816 17.9448 19.5716 18.2598L22.0016 20.6898L20.7416 21.9498Z",fill:n})]}),nV=wv.deployment.logs,sV=wv.deployment.logWithError,iV=wv.deployment.mdiCheckAll,aV=wv.upload.blueCheck,rV=Pe.memo(({message:e,handleRollback:t,isCloudFlow:n,searchActive:s=!1,searchHighlights:i=[],isSubagent:r=!1,isMatchingMessage:o=!1,hideImportantActions:l=!1,podIsPaused:c=!1})=>{const[d,u]=Pe.useState(!1),[p,m]=Pe.useState(!1),h=Pe.useRef(null);Pe.useEffect(()=>{o&&s&&!d&&u(!0)},[o,s,d]);const{cleanContent:x,logs:f,hasLogs:g,hasError:v,assetShared:b,autoAnswered:y,isHealthCheck:w,isVisualEdit:j,visualEditCount:C,visualEditDetails:N}=(e=>{const t=e.split(vv),n=e.includes("USER SHARED ASSETS WITH AGENT"),s=e.includes("Assume Default and Proceed"),i="Call Deployer Agent and Run Health Check to Check for Readiness for Deployment"===e,a=e.includes("VISUAL_EDIT_NOTIFICATION");let r=0,o="";if(a){const t=e.split("|||");t.length>=4&&(r=parseInt(t[1])||0,o=t[2]||"")}return 3===t.length?{cleanContent:"",logs:t[1].split("\n").filter(e=>""!==e.trim()),hasLogs:!0,hasError:t[1].toLowerCase().includes("error")||t[1].toLowerCase().includes("failed")||t[1].toLowerCase().includes("exception")||t[1].toLowerCase().includes("fatal")||t[1].toLowerCase().includes("critical"),assetShared:n,autoAnswered:s,isHealthCheck:i,isVisualEdit:a,visualEditCount:r,visualEditDetails:o}:{cleanContent:e,logs:[],hasLogs:!1,hasError:!1,assetShared:n,autoAnswered:s,isHealthCheck:i,isVisualEdit:a,visualEditCount:r,visualEditDetails:o}})(e.content),{content:F,isAutoResponse:_}=((e,t)=>{if("user"!==t)return{content:e,isAutoResponse:!1};const n=e.match(/([\s\S]*?)<\/auto_response>/);return n?{content:n[1].trim(),isAutoResponse:!0}:{content:e,isAutoResponse:!1}})(x,e.role),k=((e,t)=>{if("user"!==t)return e;const n=e.includes("User has recorded a test case"),s=e.match(/([\s\S]*?)<\/reported_bug>/);return n&&s?s[1].trim():e})(F,e.role),S=eV(k),E=k.split("\n");return a.jsx("div",{onMouseEnter:()=>m(!0),onMouseLeave:()=>m(!1),className:bb("relative group flex justify-center","mb-0"),ref:h,id:e.id,children:a.jsxs("div",{className:bb("my-4 md:my-8 group flex flex-col space-y-[10px] w-full md:max-w-4xl md:pl-12 justify-end items-end "),children:[a.jsx(P$,{base64Images:e.base64_image_list,artifacts:e.artifacts,artifactSharedData:e.artifact_shared_data,className:"justify-end"}),a.jsx("div",{className:bb("px-4 py-1 rounded-xl rounded-br-none overflow-hidden space-y-[10px] flex items-end","user"===e.role?"bg-[#273638] max-4-xl w-4xl":"",g||b||y||w||j||_?"hidden":""),style:{background:"radial-gradient(50% 50% at 50% 50%, rgba(128, 255, 249, 0.16) 0%, rgba(128, 255, 249, 0.08) 100%)"},children:a.jsx("div",{className:"flex items-start gap-3",children:a.jsx("div",{className:"flex-1 min-w-0",children:a.jsx("div",{className:"prose prose-invert max-w-none",children:"user"===e.role?E.map((e,t)=>J$(e,t,!0,s,i,S[t])):d||o&&s?E.map((e,t)=>J$(e,t,!1,s,i,S[t])):a.jsx("p",{className:"text-[#CCEEFF] font-['Inter'] text-[15px] leading-6 font-normal",children:s&&i&&i.length>0?Q$(E[0],i.filter(e=>e.startIndexJ$(e,t,!0,s,i,S[t]))})]}),a.jsxs("div",{className:bb("transition-opacity duration-200 h-5 text-right","opacity-100"),children:[a.jsx("div",{className:bb("inline-flex items-center gap-2 text-[#5C5F66]",p?"opacity-0 pointer-events-none absolute":"opacity-100"),children:a.jsx("span",{className:"font-['Berkeley Mono Trial'] text-[13px] md:text-[15px] leading-[20px]",children:hT(e.timestamp)})}),a.jsx("div",{className:"relative",children:a.jsx(U$,{isHovered:p,message:e,handleRollback:t,isCloudFlow:n||!1,onCopy:async()=>{try{await navigator.clipboard.writeText(e.content)}catch(t){}},podIsPaused:c,className:bb("inline-flex items-center gap-1",p?"opacity-100 pointer-events-auto":"opacity-0 absolute pointer-events-none"),hideImportantActions:l})})]})]})})},(e,t)=>e.message.id===t.message.id&&JSON.stringify(e.message.artifacts)===JSON.stringify(t.message.artifacts)&&e.message.content===t.message.content&&e.message.timestamp===t.message.timestamp&&e.searchActive===t.searchActive&&e.isMatchingMessage===t.isMatchingMessage&&JSON.stringify(e.searchHighlights)===JSON.stringify(t.searchHighlights)),oV=me,lV=he,cV=Pe.forwardRef(({className:e,align:t="center",sideOffset:n=4,...s},i)=>a.jsx(ue,{children:a.jsx(pe,{ref:i,align:t,sideOffset:n,className:bb("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...s})}));function dV({isOpen:e,onOpenChange:t,chatId:n}){const[s,i]=Pe.useState(!1),[r,o]=Pe.useState(!1),[l,c]=Pe.useState(null),[d,u]=Pe.useState(null),[p,m]=Pe.useState(""),[h,x]=Pe.useState(""),{toast:f}=un();Pe.useEffect(()=>{e&&n&&(x(n),g(n))},[e,n]);const g=async(e=h)=>{if(e){i(!0),c(null);try{const t=await Wp(e),n=t.data?t.data:t;u(n),m(JSON.stringify(n.chat_history,null,2))}catch(t){c(t.message||"Failed to fetch chat history")}finally{i(!1)}}};return a.jsx(IA,{open:e,onOpenChange:t,children:a.jsxs(LA,{className:"sm:max-w-[90vw] h-[90vh] overflow-hidden flex flex-col",children:[a.jsx(PA,{children:a.jsx(OA,{children:"Edit Chat History"})}),a.jsx("div",{className:"mb-4",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"flex-1",children:[a.jsx(KA,{htmlFor:"chat-id",className:"text-sm font-medium",children:"Chat ID"}),a.jsx(KS,{id:"chat-id",value:h,onChange:e=>{x(e.target.value)},className:"font-mono text-sm"})]}),a.jsx("div",{className:"pt-6",children:a.jsx(Nb,{onClick:()=>{h&&g(h)},variant:"default",size:"sm",disabled:s||!h,children:s?a.jsxs(a.Fragment,{children:[a.jsx(gS,{className:"w-4 h-4 mr-2 animate-spin"}),"Loading..."]}):"Fetch"})})]})}),a.jsx("div",{className:"flex-1 overflow-hidden",children:s?a.jsxs("div",{className:"flex items-center justify-center h-64",children:[a.jsx(gS,{className:"w-8 h-8 animate-spin text-primary"}),a.jsx("span",{className:"ml-2",children:"Loading chat history..."})]}):l?a.jsx("div",{className:"p-4 text-red-500 rounded-md bg-red-500/10",children:l}):d?a.jsxs(R$,{defaultValue:"edit",children:[a.jsxs(O$,{className:"grid w-full grid-cols-2",children:[a.jsx(z$,{value:"edit",children:"Edit"}),a.jsx(z$,{value:"view",children:"View"})]}),a.jsx(B$,{value:"edit",className:"p-4 overflow-auto",children:a.jsx("textarea",{id:"chat-history",title:"Chat History",className:"w-full h-[60vh] p-4 bg-[#1E1E1E] text-white font-mono text-sm rounded-md focus:outline-none focus:ring-1 focus:ring-blue-500",value:p,onChange:e=>m(e.target.value),spellCheck:"false"})}),a.jsx(B$,{value:"view",className:"p-4 overflow-auto",children:a.jsx("div",{className:"bg-[#1E1E1E] p-4 rounded-md overflow-auto max-h-[60vh] text-sm",children:a.jsx("pre",{className:"font-mono text-white",children:JSON.stringify(d,null,2)})})})]}):a.jsx("div",{className:"flex items-center justify-center h-64 text-gray-400",children:"No chat history available"})}),a.jsxs(RA,{children:[a.jsx(Nb,{onClick:()=>t(!1),variant:"outline",disabled:r,children:"Cancel"}),a.jsx(Nb,{onClick:async()=>{if(h){o(!0),c(null);try{let n;try{n=JSON.parse(p)}catch(e){throw new Error("Invalid JSON format")}const s=await qp(h,{chat_history:n}),i=s.data?s.data:s;u(i),f({title:"Success",description:"Chat history updated successfully"}),t(!1)}catch(n){c(n.message||"Failed to update chat history"),f({title:"Error",description:n.message||"Failed to update chat history",variant:"destructive"})}finally{o(!1)}}},disabled:s||r||!d,children:r?a.jsxs(a.Fragment,{children:[a.jsx(gS,{className:"w-4 h-4 mr-2 animate-spin"}),"Saving..."]}):"Save Changes"})]})]})})}cV.displayName=pe.displayName;const uV=({jobId:e,tabId:t,silent:n=!1,pollingInterval:s=1e4,enabled:i=!0})=>{const a=Ft(),{getCurrentOrganizationId:r}=ev(),{setTabs:o,state:{activeTab:l,tabs:c}}=Hee(),[d,u]=Pe.useState([]),[p,m]=Pe.useState(null),h=Nt(e=>((e,t)=>{var n;return null==(n=e.tabs.tabStates[t])?void 0:n.deployState})(e,t)),x=Nt(Au),f=r(),{data:g,error:v,isLoading:b,isError:y,refetch:w}=Yx({jobId:e,silent:n,organization_id:f},{skip:!i||!e,pollingInterval:i&&e&&("running"===(null==h?void 0:h.deployStatus)||"running"===(null==h?void 0:h.latestRunStatus))?s:0,refetchOnMountOrArgChange:!0});(()=>{var e;for(let n=0;ne.map(e=>e.id===t?{...e,tabHeading:g.app_name||e.tabHeading}:e)))})();const[j,{isLoading:C,error:N}]=Kx(),[F]=ef(),[_]=tf(),[k]=nf(),[S]=sf(),[E]=Jx(),[I]=af(),[A]=Qx(),{data:T,refetch:M}=rf({jobId:e,organization_id:f},{skip:!e}),[D]=of(),{refetch:L}=lf(f?{organization_id:f}:void 0),P=i&&e&&(null==h?void 0:h.deployStatus)&&"not_deployed"!==h.deployStatus&&"loading"!==h.deployStatus&&"running"!==h.latestRunStatus,{data:R}=Xx({jobId:e,organization_id:f},{skip:!P,refetchOnMountOrArgChange:!0});Pe.useEffect(()=>{var n,s;if(!g||!e)return;let i=g.status;g.latest_run&&"running"===g.latest_run.status?i="running":g.latest_run&&g.latest_run.status&&"success"===g.status&&(i="pending"===g.latest_run.status?"loading":g.latest_run.status);let r=-1;if(g.latest_run&&g.latest_run.steps&&Array.isArray(g.latest_run.steps))if("running"===g.status&&g.latest_run.steps.every(e=>"pending"===e.status))r=0;else{const e=g.latest_run.steps.findIndex(e=>"running"===e.status);if(-1!==e)r=e;else{for(let e=0;e"pending"===e.status);-1!==e?r=e:"success"===g.status&&(r=g.latest_run.steps.length-1)}}}let o=null,l="";if(g.custom_domain&&""!==g.custom_domain.domain&&g.custom_domain.status&&g.custom_domain.dns_records&&(o={domain:g.custom_domain.domain,status:g.custom_domain.status,dns_records:Array.isArray(g.custom_domain.dns_records)?g.custom_domain.dns_records:[g.custom_domain.dns_records]},"verified"===g.custom_domain.status)){const e=g.custom_domain.domain;l=e.startsWith("http")?e:`https://${e}`}const c={deployStatus:i,latestRunStatus:(null==(n=g.latest_run)?void 0:n.status)||null,loading:b,deploymentSteps:(null==(s=g.latest_run)?void 0:s.steps)||(null==h?void 0:h.deploymentSteps)||[],currentStepIndex:r,deployUrl:g.deploy_url||(null==h?void 0:h.deployUrl)||"",customDomainUrl:l,customDomain:o,runId:g.latest_run&&g.latest_run.run_id&&"success"===g.latest_run.status?g.latest_run.run_id:g.deployed_run_id||(null==h?void 0:h.runId)||"",errorMessage:null};a(Su({tabId:t,deployState:c}))},[g,e,t,a,null==h?void 0:h.deploymentSteps,null==h?void 0:h.deployUrl,null==h?void 0:h.runId,b]),Pe.useEffect(()=>{if(!R||!e)return;const n=R.runs||[];a(Su({tabId:t,deployState:{deploymentHistory:n}}))},[R,e,t,a]),Pe.useEffect(()=>{e&&i&&("running"===(null==h?void 0:h.deployStatus)||"running"===(null==h?void 0:h.latestRunStatus)?w():"success"!==(null==h?void 0:h.deployStatus)&&"failed"!==(null==h?void 0:h.deployStatus)||w().then(()=>{null==h||h.deployStatus}).catch(e=>{}))},[null==h?void 0:h.deployStatus,null==h?void 0:h.latestRunStatus,e,i,w]),Pe.useEffect(()=>{if(y&&v&&!n){let e="Failed to get deployment status";if("data"in v){const t=v.data;(null==t?void 0:t.detail)?e=t.detail:(null==t?void 0:t.message)?e=t.message:(null==t?void 0:t.error)&&(e=t.error)}else"message"in v&&v.message&&(e=v.message);e.includes("Rate limited")||a(Su({tabId:t,deployState:{errorMessage:e,loading:!1}}))}},[y,v,n,t,a]),Pe.useEffect(()=>{x===t&&p!==t&&i&&e&&(w(),M&&M(),L()),m(x)},[x,t,p,i,e,w,M,L]);const O=Pe.useCallback(()=>{a(Su({tabId:t,deployState:{deployStatus:"not_deployed",latestRunStatus:null,loading:!1,deploymentSteps:[],currentStepIndex:-1,deployUrl:"",customDomainUrl:"",runId:"",errorMessage:null,customDomain:null,deployLogs:{}}}))},[t,a]),z=Pe.useCallback(async e=>{if(e.jobId)try{a(Su({tabId:t,deployState:{loading:!0,errorMessage:null}}));const n={jobId:e.jobId,image:e.image,deployment_id:e.deployment_id,acknowledgements:e.acknowledgements,db_mode:e.db_mode,organization_id:f};await j(n).unwrap(),a(Su({tabId:t,deployState:{deployStatus:"running",latestRunStatus:"running",loading:!1,deploymentSteps:[],currentStepIndex:-1,errorMessage:null}})),dn({title:"Deployment Started",description:"Your application deployment has been initiated successfully.",variant:"default",duration:3e3})}catch(n){const e=(null==n?void 0:n.error)||"Failed to deploy application";throw a(Su({tabId:t,deployState:{deployStatus:"not_deployed",latestRunStatus:null,loading:!1,errorMessage:e}})),dn({title:"Deployment Error",description:e,variant:"destructive",duration:5e3}),n}else dn({title:"Deploy Error",description:"No job ID provided",variant:"destructive",duration:2e3})},[j,t,a,f]),B=Pe.useCallback(async(e,t)=>{try{return await F({domain:e,jobId:t,organization_id:f}).unwrap()}catch(n){throw n}},[F,f]),H=Pe.useCallback(async(e,t)=>{try{return await _({domain:e,jobId:t,organization_id:f}).unwrap()}catch(n){throw n}},[_,f]),$=Pe.useCallback(async(e,t)=>{try{return await k({domain:e,jobId:t,organization_id:f}).unwrap()}catch(n){throw n}},[k,f]),V=Pe.useCallback(async(e,t)=>{try{return await S({domain:e,jobId:t,organization_id:f}).unwrap()}catch(n){throw n}},[S,f]),U=Pe.useCallback(async e=>{if(!e)throw new Error("No job ID provided");try{const n=await I({jobId:e,organization_id:f}).unwrap();return a(Su({tabId:t,deployState:{deployLogs:n}})),n}catch(n){throw n}},[I,t,a,f]),W=Pe.useCallback(async n=>{var s,i,r;if(!e)return void dn({title:"Rollback Error",description:"No job ID provided",variant:"destructive",duration:2e3});const o=null==(s=null==h?void 0:h.deploymentHistory)?void 0:s.find(e=>e.run_id===n||e.id===n);if(o)try{if("running"===(null==h?void 0:h.deployStatus)||"running"===(null==h?void 0:h.latestRunStatus))return void dn({title:"Deployment in Progress",description:"You can only have one deployment in progress at a time. Please wait for the current deployment to complete before rolling back.",variant:"destructive",duration:3e3});dn({title:"Rolling back...",description:"Please wait while we rollback your deployment.",duration:2e3}),a(Su({tabId:t,deployState:{loading:!0,errorMessage:null}})),await j({jobId:e,image:o.run_id,deployment_id:o.run_id,acknowledgements:"rollback",db_mode:!0,organization_id:f}).unwrap(),a(Su({tabId:t,deployState:{deployStatus:"running",latestRunStatus:"running",loading:!1,deploymentSteps:[],currentStepIndex:-1,errorMessage:null}})),dn({title:"Rollback Initiated",description:"Your rollback has been initiated and will be completed shortly.",duration:3e3})}catch(l){let e="Failed to rollback deployment";throw(null==l?void 0:l.message)?e=l.message:(null==(i=null==l?void 0:l.data)?void 0:i.detail)?e=l.data.detail:(null==(r=null==l?void 0:l.data)?void 0:r.message)&&(e=l.data.message),e.includes("deploy in progress")?dn({title:"Deployment in Progress",description:"You can only have one deployment in progress at a time. Please wait for the current deployment to complete before rolling back.",variant:"destructive",duration:3e3}):dn({title:"Rollback Failed",description:e,variant:"destructive",duration:3e3}),a(Su({tabId:t,deployState:{loading:!1,errorMessage:e}})),l}else dn({title:"Rollback Error",description:"Target deployment not found",variant:"destructive",duration:2e3})},[j,t,a,e,null==h?void 0:h.deploymentHistory,null==h?void 0:h.deployStatus,null==h?void 0:h.latestRunStatus,f]),q=Pe.useCallback(async(e,n)=>{var s,i;try{a(Su({tabId:t,deployState:{loading:!0,errorMessage:null}})),await E({jobId:e,image:n,organization_id:f}).unwrap(),a(Su({tabId:t,deployState:{deployStatus:"running",latestRunStatus:"running",loading:!1,deploymentSteps:[],currentStepIndex:-1,errorMessage:null}})),dn({title:"Rollback Initiated",description:"Your rollback has been initiated and will be completed shortly.",duration:3e3})}catch(r){let e="Failed to rollback deployment";throw(null==r?void 0:r.message)?e=r.message:(null==(s=null==r?void 0:r.data)?void 0:s.detail)?e=r.data.detail:(null==(i=null==r?void 0:r.data)?void 0:i.message)&&(e=r.data.message),e.includes("deploy in progress")?dn({title:"Deployment in Progress",description:"You can only have one deployment in progress at a time. Please wait for the current deployment to complete before rolling back.",variant:"destructive",duration:3e3}):dn({title:"Rollback Failed",description:e,variant:"destructive",duration:3e3}),a(Su({tabId:t,deployState:{loading:!1,errorMessage:e}})),r}},[E,t,a,f]),G=Pe.useCallback(async()=>{var n,s;if(e)try{dn({title:"Shutting down...",description:"Please wait while we shut down your deployment.",duration:2e3}),a(Su({tabId:t,deployState:{loading:!0,errorMessage:null}})),await A({jobId:e,organization_id:f}).unwrap(),a(Su({tabId:t,deployState:{deployStatus:"not_deployed",latestRunStatus:null,loading:!1,deploymentSteps:[],currentStepIndex:-1,deployUrl:"",customDomainUrl:"",runId:"",errorMessage:null,customDomain:null,deployLogs:{},deploymentHistory:[]}})),dn({title:"Deployment Shut Down",description:"Your deployment has been successfully shut down.",duration:3e3})}catch(i){let e="Failed to shut down deployment";throw(null==i?void 0:i.message)?e=i.message:(null==(n=null==i?void 0:i.data)?void 0:n.detail)?e=i.data.detail:(null==(s=null==i?void 0:i.data)?void 0:s.message)&&(e=i.data.message),a(Su({tabId:t,deployState:{loading:!1,errorMessage:e}})),dn({title:"Shutdown Failed",description:e,variant:"destructive",duration:3e3}),i}else dn({title:"Shutdown Error",description:"No job ID provided",variant:"destructive",duration:2e3})},[A,t,a,e,f]),Z=Pe.useCallback(async(n,s)=>{if(e)try{if("running"===(null==h?void 0:h.deployStatus)||"running"===(null==h?void 0:h.latestRunStatus))return void dn({title:"Deployment in Progress",description:"You can only have one deployment in progress at a time. Please wait for the current deployment to complete before replacing.",variant:"destructive",duration:3e3});dn({title:"Replacing deployment...",description:"Please wait while we replace your deployment.",duration:2e3}),a(Su({tabId:t,deployState:{loading:!0,errorMessage:null}})),await j({jobId:e,deployment_id:n,db_mode:s,acknowledgements:"replacement",organization_id:f}).unwrap(),a(Su({tabId:t,deployState:{deployStatus:"running",latestRunStatus:"running",loading:!1,deploymentSteps:[],currentStepIndex:-1,errorMessage:null}})),dn({title:"Replacement Initiated",description:"Your deployment replacement has been initiated successfully.",duration:3e3})}catch(i){let e=(null==i?void 0:i.error)||"Failed to replace deployment";throw dn({title:"Replacement Failed",description:e,variant:"destructive",duration:3e3}),a(Su({tabId:t,deployState:{loading:!1,errorMessage:e}})),i}else dn({title:"Replace Deployment Error",description:"No job ID provided",variant:"destructive",duration:2e3})},[j,t,a,e,null==h?void 0:h.deployStatus,null==h?void 0:h.latestRunStatus,f]),Y=Pe.useCallback(e=>(null==e?void 0:e.envs_with_version)?Object.entries(e.envs_with_version).map(([e,t],n)=>{const s=t;return{id:`env-${n}`,key:e,value:s.value,originalValue:s.value,version:s.version||0}}):(null==e?void 0:e.envs)?Object.entries(e.envs).map(([e,t],n)=>{if("string"==typeof t)return{id:`env-${n}`,key:e,value:t,originalValue:t,version:0};if("object"==typeof t&&null!==t&&"value"in t){const s=t;return{id:`env-${n}`,key:e,value:s.value,originalValue:s.value,version:s.version||0}}return{id:`env-${n}`,key:e,value:String(t),originalValue:String(t),version:0}}):[],[]),K=Pe.useCallback(async()=>{if(!e)return[];try{const e=await M();if(e.data){const t=Y(e.data);return u(t),t}return[]}catch(t){return[]}},[e,M,Y]),J=Pe.useCallback(async t=>{if(!e)return null;try{const n=await M();if(!n.data)throw new Error("Failed to fetch latest environment variables");const s=Y(n.data),i=t.map(e=>{const t=s.find(t=>t.key===e.key),n=t?t.version:0;return{...e,version:n}}),a=await D({jobId:e,envs:i,organization_id:f});if(void 0===a.data&&a.error)throw new Error("Environment variables update failed");{const e=i.map(e=>({...e,originalValue:e.value}));return u(e),a.data||{success:!0}}}catch(n){throw n}},[e,D,M,Y,f]),Q=Pe.useCallback(e=>{u(e)},[]),X=Y(T),ee=d.length>0?d:X;return{isLoading:b,isError:y,error:v,deployStatus:(null==h?void 0:h.deployStatus)||"not_deployed",latestRunStatus:(null==h?void 0:h.latestRunStatus)||null,deploymentSteps:(null==h?void 0:h.deploymentSteps)||[],deploymentHistory:(null==h?void 0:h.deploymentHistory)||[],currentStepIndex:(null==h?void 0:h.currentStepIndex)||-1,deployUrl:(null==h?void 0:h.deployUrl)||"",customDomainUrl:(null==h?void 0:h.customDomainUrl)||"",runId:(null==h?void 0:h.runId)||"",errorMessage:(null==h?void 0:h.errorMessage)||null,customDomain:(null==h?void 0:h.customDomain)||null,deployLogs:(null==h?void 0:h.deployLogs)||{},data:g,refetch:w,resetDeployState:O,deployApp:z,registerDomain:B,verifyDomain:H,connectDomain:$,unlinkDomain:V,loadDeployLogs:U,rollbackToDeployment:W,rollbackWithApi:q,shutdownDeployment:G,replaceDeployment:Z,envs:ee,loadEnvironmentVariables:K,updateEnvironmentVariables:J,saveEnvironmentVariables:Q,isDeploying:C,deployError:N}},pV=({width:e=20,height:t=20,fill:n="white",opacity:s=.5,className:i,style:r,onClick:o,"aria-label":l="Globe icon",focusable:c=!1,viewBox:d="0 0 20 20",...u})=>a.jsx("svg",{width:e,height:t,viewBox:d,fill:"none",xmlns:"http://www.w3.org/2000/svg",className:i,style:r,onClick:o,"aria-label":l,focusable:c,...u,children:a.jsx("path",{opacity:s,d:"M10 2.00006C14.4184 2.00006 18 5.58161 18 10.0001C18 14.4185 14.4184 18.0001 10 18.0001C5.58154 18.0001 2 14.4185 2 10.0001C2 5.58161 5.58154 2.00007 10 2.00006ZM3.62568 10.788C3.94054 13.3618 5.77655 15.4633 8.20806 16.1684C7.17013 14.556 6.53788 12.7103 6.37178 10.788H3.62568ZM13.6282 10.788C13.4621 12.7105 12.8291 14.5559 11.791 16.1684C14.223 15.4635 16.0594 13.3621 16.3743 10.788H13.6282ZM7.95312 10.788C8.14159 12.6763 8.85009 14.4748 10 15.9827C11.1499 14.4748 11.8584 12.6763 12.0469 10.788H7.95312ZM11.791 3.8308C12.8293 5.44342 13.4621 7.28937 13.6282 9.21216H16.3743C16.0594 6.63797 14.2231 4.53562 11.791 3.8308ZM10 4.01646C8.84982 5.52452 8.14162 7.32361 7.95312 9.21216H12.0469C11.8584 7.32362 11.1501 5.52453 10 4.01646ZM8.20806 3.8308C5.77642 4.53587 3.94055 6.63827 3.62568 9.21216H6.37178C6.5379 7.28954 7.16988 5.44333 8.20806 3.8308Z",fill:n})}),mV=({width:e=16,height:t=16,stroke:n="#66C2FF",strokeWidth:s=2.66667,strokeLinecap:i="round",strokeLinejoin:r="round",className:o,style:l,onClick:c,"aria-label":d="Double check icon",focusable:u=!1,viewBox:p="0 0 16 16",...m})=>a.jsx("svg",{width:e,height:t,viewBox:p,fill:"none",xmlns:"http://www.w3.org/2000/svg",className:o,style:l,onClick:c,"aria-label":d,focusable:u,...m,children:a.jsx("path",{d:"M1.33337 7.99998L4.00004 10.6666L9.33337 5.33331M9.33337 10.6666L14.6667 5.33331",stroke:n,strokeWidth:s,strokeLinecap:i,strokeLinejoin:r})}),hV=wv.icons.code,xV=wv.icons.info,fV=wv.icons.preview,gV=wv.icons.animatedSpinner,vV=wv.icons.deployCloud,bV=wv.icons.redeploy,yV=({handleVSCodeLink:e,handleShowDiff:t,handlePreviewClick:n,handleInfoClick:s,handleDeployClick:i,handlePublishClick:r,handlePublishBottomSheetOpen:o,showActions:l,hideImportantActions:c,jobId:d,tabId:u,podIsPaused:p=!1,enableDeploy:m=!0,publishConfig:h={},previewUrl:x,buildMode:f})=>{var g,v;const{enablePublish:b=!1,isPublishing:y=!1,isPublished:w=!1}=h,[j,C]=Pe.useState(!1),[N,F]=Pe.useState(!1),_=iI(),{deployStatus:k,latestRunStatus:S,isLoading:E,deploymentHistory:I}=uV({jobId:d,tabId:u||d||"",enabled:!!d&&!p&&"build"===f}),{isMobile:A}=nI(),{getTabByJobId:T}=Hee(),M=(null==(v=null==(g=T(d||""))?void 0:g.state)?void 0:v.showCase)||!1,D=Pe.useMemo(()=>({fontFamily:"Inter",fontWeight:500}),[]),L=Pe.useMemo(()=>d&&i&&!b&&!c&&!M,[d,i,b,c,M]),P=Pe.useMemo(()=>d&&r&&!c&&!M&&b,[d,r,c,M,b]);Pe.useMemo(()=>d&&!b&&i&&!c&&!p&&!M,[d,b,i,c,p,M]),Pe.useMemo(()=>d&&r&&!c&&!M&&b,[d,r,c,M,b]),Pe.useEffect(()=>{},[d,M,p,f]);const R=I.some(e=>"success"===e.status);return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx("div",{className:"flex-1"}),a.jsxs("div",{className:"flex items-center",children:[l&&!c&&a.jsx("div",{className:"flex items-center gap-1",children:a.jsx(ME,{children:a.jsxs("div",{className:"flex items-center gap-1",children:[_&&d&&a.jsx(DE,{delayDuration:100,children:a.jsx(PE,{side:"bottom",className:"bg-[#DDDDE6] text-black border-0",style:D,children:"Edit Chat History"})}),!A&&a.jsxs(DE,{delayDuration:100,children:[a.jsx(LE,{asChild:!0,children:a.jsx(Nb,{variant:"ghost",className:"group h-[36px] w-[36px] p-0 bg-white/10 hover:bg-[#ffffff]/15 backdrop-blur-lg rounded-lg transition-colors duration-200",onClick:s,children:a.jsx("div",{className:"flex items-center justify-center w-full",children:a.jsx("img",{src:xV,alt:"info",className:"w-6 h-6 opacity-60 group-hover:opacity-100"})})})}),a.jsx(PE,{side:"bottom",className:"bg-[#DDDDE6] text-black border-0",style:D,children:"Info"})]})]})})}),l&&a.jsx(a.Fragment,{children:!A&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"",children:a.jsx(Nb,{variant:"default",className:"group h-[36px] ml-2 pl-2 pr-2 md:pr-3 rounded-[8px] hover:bg-white/100 transition-colors duration-200",onClick:e,disabled:p||"build"!=f,children:a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("img",{alt:"code",src:hV,className:"w-6 h-6"}),a.jsx("span",{className:"hidden text-base font-semibold md:block",children:"Code"})]})})}),a.jsx("div",{className:"ml-2",children:a.jsx(Nb,{variant:"default",className:"group h-[36px] pl-2 pr-2 md:pr-3 rounded-[8px] hover:bg-white/100 transition-colors duration-200",onClick:n,disabled:"build"!=f,children:a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("img",{alt:"preview",src:fV,className:"w-6 h-6"}),a.jsx("span",{className:"hidden text-base font-semibold md:block",children:"Preview"})]})})}),L&&a.jsx("div",{className:"ml-2",children:a.jsx(Nb,{variant:"ghost",className:bb("group h-[36px] pl-2 pr-2 md:pr-3 rounded-[8px] hover:bg-white/10 transition-colors duration-200",R?"bg-white/10 grayscale-0":"running"===k||"running"===S?"bg-[#4DA5FF29] text-[#33DDFF]":"bg-gradient-to-r from-[#80FFF9] to-[#1588FC] text-[#0F0F10] hover:text-[#0F0F10] hover:opacity-80",(E||!m)&&"not_deployed"==k&&"opacity-90 grayscale","disabled:grayscale"),onClick:i,disabled:(E||!m)&&"not_deployed"==k,children:a.jsxs("div",{className:"relative flex items-center gap-1",children:[E?a.jsx(gS,{className:"w-5 h-5 animate-spin"}):"running"===k||"running"===S?a.jsx("img",{src:gV,alt:"deploying",className:"w-5 h-5"}):a.jsxs("div",{className:"relative",children:[a.jsx("img",{src:R?bV:vV,alt:"Deploy",className:bb("w-5 h-5 ",!R&&"invert")}),R&&a.jsx(aT,{color:"#2EE572",size:16,innerSize:8,animate:R,className:"absolute -bottom-[4px] -right-[4.5px]"})]}),a.jsx("span",{className:"hidden text-base font-semibold md:block",children:E?"Loading...":"running"===k||"running"===S?"Deploying...":R?"Redeploy":"Deploy"})]})})}),P&&a.jsx("div",{className:"ml-2",children:a.jsxs(oV,{open:N,onOpenChange:F,children:[a.jsx(lV,{asChild:!0,children:w?a.jsx(Nb,{variant:"ghost",className:"group h-[36px] py-2 px-3 rounded-[8px] bg-[#80CCFF33] hover:bg-[#80CCFF33] text-white transition-opacity duration-200",children:a.jsxs("div",{className:"flex items-center gap-[6px]",children:[a.jsx(mV,{width:16,height:16}),a.jsx("span",{className:"hidden text-sm text-[#66C2FF] font-semibold md:block",children:"Published"})]})}):a.jsx(Nb,{variant:"ghost",className:"group h-[36px] py-2 px-3 rounded-[8px] bg-[#0098FE] hover:bg-[#0098FE]/80 text-white transition-opacity duration-200",disabled:y||!m,children:a.jsxs("div",{className:"flex items-center gap-1",children:[y?a.jsx(gS,{className:"w-5 h-5 animate-spin"}):null,a.jsx("span",{className:"hidden text-sm font-semibold md:block",children:y?"Publishing...":"Publish"})]})})}),a.jsx(cV,{className:"w-[400px] mr-3 mt-2 p-4 bg-[#222224] border-none rounded-[16px] text-white",onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>e.preventDefault(),onEscapeKeyDown:e=>{F(!1)},onPointerDownOutside:e=>{F(!1)},onFocusOutside:e=>{e.preventDefault()},onInteractOutside:e=>{e.preventDefault()},children:a.jsxs("div",{className:"space-y-5",children:[a.jsxs("div",{className:"flex flex-col space-y-2",children:[x&&a.jsxs("div",{className:"flex items-center gap-[6px] p-3 bg-[#FFFFFF0F] rounded-[10px]",children:[a.jsx("div",{className:"flex items-center justify-center w-6 h-6 rounded-full",children:a.jsx(pV,{width:20,height:20})}),a.jsx("span",{className:"text-sm text-white font-medium font-['Inter'] truncate flex-1",children:x})]}),a.jsx("p",{className:bb("py-2 rounded-[10px] font-['Inter'] text-sm font-medium mb-4",w?"text-white/30 bg-transparent":"text-[#FFAE66] bg-[#FFAE660A] px-3"),children:"Preview links expire in 30 minutes. Publish your app to make your preview link persistent."})]}),!w&&a.jsx("div",{className:"text-start",children:a.jsx(Nb,{onClick:e=>{e.stopPropagation(),null==r||r()},disabled:y,className:"w-full h-12 bg-gradient-to-b from-[#33CCFF] to-[#337AF2] hover:opacity-90 text-white font-semibold rounded-[10px]",children:a.jsx("div",{className:"flex items-center justify-center w-full gap-2",children:y?a.jsxs(a.Fragment,{children:[a.jsx(gS,{className:"w-5 h-5 mr-2 animate-spin"}),"Publishing..."]}):"Publish"})})})]})})]})})]})})]})]}),a.jsx(dV,{isOpen:j,onOpenChange:C,chatId:d})]})};function wV({title:e,onClick:t,style:n,className:s="",children:i,variant:r="filled",icon:o,hoverIcon:l,disabled:c=!1}){const[d,u]=Pe.useState(!1),p="filled"===r?"bg-[#F3CA5F] text-[#0F0F10]":"border border-blue-500 bg-[#E6E6E6] border-[1px] border-[#333333] text-[#0F0F10]",m=d&&l?l:o;return a.jsx(Nb,{style:n,className:bb("flex items-center gap-[12px] max-h-[44px] rounded-full px-3 py-2 md:px-4 md:py-3 transition-none text-[13px] md:text-[16px]",p,s),onClick:t,onMouseEnter:()=>{u(!0)},onMouseLeave:()=>{u(!1)},disabled:c,children:i||a.jsxs("div",{className:s,children:[a.jsx("span",{className:"font-semibold",children:e}),m&&a.jsx("img",{title:"Icon",src:m,className:"",alt:""})]})})}const jV=wv.common.deploy,CV=wv.icons.preview,NV=({hideImportantActions:e=!1,handleDeploy:t,handlePushToGithub:n,togglePanel:s,podIsPaused:i=!1})=>e?null:a.jsxs("div",{className:"flex flex-col w-full space-y-4",children:[a.jsx("div",{className:"w-full max-w-4xl px-2 mx-auto"}),a.jsx("div",{className:"w-full",children:a.jsxs("div",{className:"flex w-full max-w-4xl gap-4 px-2 pl-0 mx-auto",children:[a.jsx(wV,{title:"Deploy",variant:"filled",className:"flex items-center gap-12 bg-green-400 hover:bg-[#25b75b]",onClick:t,disabled:i,children:a.jsxs("div",{className:"flex items-center justify-center w-full gap-4",children:[a.jsx("span",{className:"font-brockmann text-[16px] leading-[20px] font-semibold tracking-[-0.02em]",children:"Deploy"}),a.jsx("img",{src:jV,alt:"deploy",className:"w-5 h-5"})]})}),a.jsx(wV,{title:"Preview",variant:"filled",className:"flex items-center gap-12 bg-white hover:bg-[#cfcfcf] ",onClick:()=>{s({panelName:"showUrlPreviewPanel"})},disabled:i,children:a.jsxs("div",{className:"flex items-center justify-center w-full gap-4",children:[a.jsx("span",{className:"font-brockmann text-[16px] leading-[20px] font-semibold",children:"Preview"}),a.jsx("img",{src:CV,alt:"preview",className:"w-5 h-5 text-white"})]})})]})})]}),FV=wv.common.bot,_V=({thought:e,action:t,typingSpeed:n=50,className:s="",onContentChange:i,onTypingComplete:r,isExpanded:o=!0,hideRobotIcon:l=!1,marginBottom:c=!0})=>{const[d,u]=Pe.useState(""),[p,m]=Pe.useState(!1),h=Pe.useRef(i),x=Pe.useRef(r);h.current=i,x.current=r;const f=Pe.useRef(null),g=Pe.useRef(0),v=[e,t].filter(Boolean).join("\n\nAction: ");Pe.useEffect(()=>{if(u(""),m(!1),g.current=0,f.current&&(clearTimeout(f.current),f.current=null),!v)return m(!0),void(x.current&&x.current());const e=()=>{if(g.current{f.current&&(clearTimeout(f.current),f.current=null)}},[v,n]),Pe.useEffect(()=>{v&&d===v&&!p&&(m(!0),x.current&&x.current())},[d,v,p]);const b=d.split("\n\nAction: "),y=b[0]||"",w=b[1]||"";return a.jsx("div",{className:bb("flex flex-col w-full space-y-4",c&&"pb-4",s),children:a.jsxs("div",{className:"flex w-full gap-4",children:[!l&&a.jsxs("div",{className:"flex flex-col items-center w-[40px]",children:[a.jsx(SD,{className:"h-[40px] w-[40px] bg-black border border-[#555]/25 flex items-center justify-center",children:a.jsx("img",{src:FV,alt:"Robot",className:"h-[22px] w-[22px]"})}),a.jsx("div",{className:"w-[1px] h-full mt-2 bg-[#555]/25"})]}),a.jsx("div",{className:"flex flex-col flex-1",children:o&&a.jsxs("div",{className:"flex flex-col",children:[y&&a.jsx("div",{className:"overflow-hidden text-[#dcdce5] font-['Inter'] text-[16px] leading-[28px] font-normal",children:y}),w&&a.jsxs("div",{className:"mt-4",children:[a.jsx("span",{className:"font-semibold text-[#A8A9AD]",children:"Action: "}),a.jsx("span",{className:"overflow-hidden text-[#dcdce5] font-['Inter'] text-[16px] leading-[28px] font-normal",children:w})]})]})})]})})},kV=wv.common.reply;function SV({handleSubagentClick:e,message:t,agentState:n,enableLoading:s=!1,runningState:i=!1,panelState:r,isSelected:o=!1,jobDetails:l,agentName:c,onPause:d,isPauseLoading:u}){var p,m;const h=u??!1,x=Pe.useCallback(async()=>{(null==l?void 0:l.job_id)&&(null==n?void 0:n.agent_running)&&d&&d({origin:"MainInput"})},[null==l?void 0:l.job_id,null==n?void 0:n.agent_running,d]);o&&r.showSubagentPanel;const f=ET(t.function_name),g=null==(p=t.function_name)?void 0:p.includes("testing");return a.jsxs("div",{className:"flex md:ml-[52px] items-center gap-2 mt-2",children:[s&&(null==n?void 0:n.agent_running)?a.jsx(a.Fragment,{children:a.jsxs("button",{type:"button",title:"Subagent Button",className:bb("relative p-[6px] flex items-center gap-2 rounded-[6px]",o&&r.showSubagentPanel&&"pr-3"),style:{backgroundColor:i?f.bgColor:o&&r.showSubagentPanel?"#ffffff10":"transparent",color:i?f.color:"#B8B8CC"},onClick:e,children:[o&&r.showSubagentPanel&&i&&a.jsx("div",{className:bb("before:absolute before:inset-0 before:-m-[4px] before:rounded-[10px] before:border-[1.5px] ",i?f.beforeBorder:"before:border-[#ffffff20]")}),a.jsxs("div",{className:"flex items-center gap-1 text-nowrap",children:[a.jsx(LT,{size:"18",stroke:"4",speed:"0.9",color:f.iconColor}),a.jsxs("span",{className:" font-brockmann font-medium text-[14px]",children:[" ",ST(t.function_name)," "]})]}),a.jsx("img",{src:wv.subagent.subagentPanelIcon,alt:"Subagent Trigger",className:"min-h-5 min-w-5"})]})}):a.jsx(a.Fragment,{children:a.jsxs("button",{type:"button",title:"Subagent Button",className:bb("relative p-[6px] flex items-center gap-2 rounded-[6px] hover:bg-[#ffffff10]",!(s&&(null==n?void 0:n.agent_running))&&"cursor-pointer bg-red-400 hover:bg-red-600",o&&r.showSubagentPanel&&"pr-[2rem]"),style:{backgroundColor:o&&r.showSubagentPanel?"#ffffff10":"transparent",color:"#B8B8CC"},onClick:e,children:[o&&r.showSubagentPanel&&i&&a.jsx("div",{className:bb("before:absolute before:inset-0 before:-m-[4px] before:rounded-[10px] before:border-[1.5px] ",i?f.beforeBorder:"before:border-[#ffffff20]")}),a.jsxs("div",{className:"flex items-center gap-1 text-nowrap",children:[a.jsx("img",{alt:"Reply Icon",src:kV,className:"w-4 h-4"}),a.jsxs("span",{className:" font-brockmann font-medium text-[14px]",children:[null==(m=null==t?void 0:t.subagent_trajectory)?void 0:m.length," ",ST(t.function_name)," messages"]})]})]})}),s&&(null==n?void 0:n.agent_running)&&g?a.jsxs("button",{type:"button",title:"Stop Subagent Button",className:"p-[6px] flex items-center px-[8px] gap-[6px] rounded-[6px] bg-[#FFFFFF] hover:bg-[#ffffff90] disabled:opacity-50",onClick:x,disabled:h,children:[h?a.jsx(gS,{className:"w-4 h-4 text-black animate-spin"}):a.jsx("div",{className:"w-3 h-3 bg-black rounded-sm"}),a.jsx("span",{className:" font-brockmann font-semibold text-[14px] text-[#0F0F10]",children:h?"Stopping...":"Stop"})]}):null]})}const EV=wv.fork.fork,IV=wv.payments.question,AV=({message:e,credits:t,handleAddToken:n,podIsPaused:s,modalOpen:i,setModalOpen:r})=>{return"context_limit_reached"===e.action?(o=e.current_token_count,l=e.max_token_count,c=e.error_message_exists,o&&l&&0!==l&&Math.min(c?100:99,Math.round(o/l*100)),a.jsxs("div",{className:"bg-[#1111112] border-[#FFFFFF1F] border p-2 rounded-[16px] flex flex-col gap-2",children:[a.jsx("div",{className:"flex items-center justify-between gap-2 p-[10px] rounded-[8px] bg-[#FFAE6614]",children:a.jsx("div",{className:"flex items-center gap-2",children:a.jsx("span",{className:"font-medium",children:"Agent context used"})})}),a.jsx("div",{className:"flex items-center justify-between gap-2 text-sm bg-[#FFFFFF0D] rounded-lg",children:a.jsxs("div",{className:"flex flex-col items-start gap-6 p-4 py-5",children:[a.jsxs("div",{className:"flex flex-col gap-3",children:[a.jsx("span",{className:"font-medium text-white text-[24px] font-brockmann",children:"Summarize & continue in a fresh session"}),a.jsx("span",{className:"text-[#737780] text-[15px] leading-[24px] font-[500] text-start font-['Inter']",children:"Continue your work in a new conversation while keeping the important context from this session, perfect for continuing complex projects without losing progress."})]}),a.jsxs("div",{className:"flex justify-between w-full border-[#242424]",children:[a.jsx(ME,{children:a.jsxs(DE,{children:[a.jsx(LE,{children:a.jsxs("button",{type:"button",onClick:()=>{i&&r&&r({...i,fork:!i.fork})},disabled:s,className:"pl-4 pr-3 py-[10px] h-[40px] bg-white text-black hover:bg-gray-100 rounded-[10px] font-[600] text-[16px] flex items-center gap-2",children:["Fork Session",a.jsx("img",{src:EV,alt:"Fork",className:"w-5 h-5 invert"})]})}),a.jsxs(PE,{className:bb("bg-[#DDDDE6] text-black border-0",s?"":"hidden"),children:[a.jsx("span",{className:"text-[12px] md:text-[14px] font-['Inter']",children:s?"Please wake up the agent before forking session":""}),a.jsx(RE,{className:"fill-[#DDDDE6]"})]})]})}),a.jsxs("button",{onClick:()=>{window.open(dv.learnMore,"_blank")},className:"pl-4 pr-3 py-[10px] h-[40px] bg-transparent text-white/70 hover:bg-[#FFFFFF0A] rounded-[10px] font-[500] text-[16px] flex items-center gap-2",children:["Learn more about Forking",a.jsx("img",{src:IV,alt:"Question",className:"w-5 h-5"})]})]})]})})]})):null;var o,l,c},TV=wv.common.rollbackTime,MV=({message:e,userName:t,searchActive:n=!1,searchHighlights:s=[],handleRollback:i})=>{if("default_tool"===e.function_name)return a.jsxs("span",{className:"py-2 font-['Inter']",children:["Hey ",t,", Quick input needed :"]});if("ask_human"===e.function_name&&!e.content)return a.jsxs("span",{className:"py-2 font-['Inter']",children:["Hey ",t,", Quick input needed :"]});if("ask_human"===e.function_name&&"fork"==e.action)return a.jsxs("span",{className:"py-2 font-['Inter']",children:["Hey ",t,", Quick input needed :"]});if("rollback"===e.function_name)return a.jsx("div",{className:"relative flex flex-col items-center w-full space-y-4",children:a.jsxs("div",{className:"flex w-full justify-between items-center gap-4 text-[15px] text-[#FFFFFF] font-['Inter'] py-1",children:[a.jsxs("span",{className:"font-['Inter']",children:["Context has been cleared and a"," ",a.jsx("span",{className:"text-[#FF884D]",children:"Code Checkpoint"})," ","has been created at"," ",a.jsx("span",{className:"text-[#FF884D]",children:hT(e.timestamp)})," "]}),a.jsxs("button",{onClick:i,className:"bg-[#FF884D]/10 hover:bg-[#FF884D30] px-[10px] py-[6px] rounded-[8px] flex gap-1 items-center text-[#FF884DCC]",children:[a.jsx("img",{alt:"Time",src:TV,className:"w-5 h-5"}),"Rollback"]})]})});const r=((e,t)=>{if("user"!==t)return e;const n=e.includes("User has recorded a test case"),s=e.match(/([\s\S]*?)<\/reported_bug>/);return n&&s?s[1].trim():e})(e.content,e.role),o=eV(r),l=r.split("\n");return a.jsx("div",{className:"flex flex-col prose prose-invert max-w-none",children:l.map((e,t)=>J$(e,t,!1,n,s,o[t]))})},DV=({size:e=20,color:t="#E5F6FF",className:n=""})=>a.jsx("svg",{width:e,height:e,viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:n,children:a.jsx("path",{d:"M15.2017 5.13281C15.4534 5.13281 15.6872 5.17777 15.903 5.26769C16.1188 5.3576 16.3106 5.48648 16.4785 5.65433C16.6463 5.82217 16.7722 6.011 16.8561 6.2208C16.9401 6.43061 16.988 6.66739 17 6.93114C17 7.17092 16.955 7.40171 16.8651 7.6235C16.7752 7.84529 16.6463 8.04011 16.4785 8.20796L9.33911 15.3563C9.17127 15.5242 8.97645 15.653 8.75466 15.743C8.53286 15.8329 8.30208 15.8808 8.0623 15.8868C7.82252 15.8868 7.59174 15.8419 7.36994 15.752C7.14815 15.662 6.95333 15.5302 6.78548 15.3563L3.53051 12.1013C3.36266 11.9335 3.23378 11.7387 3.14387 11.5169C3.05395 11.2951 3.00599 11.0643 3 10.8245C3 10.5728 3.04796 10.339 3.14387 10.1232C3.23978 9.90738 3.36866 9.71556 3.53051 9.54771C3.69236 9.37987 3.88118 9.25399 4.09698 9.17006C4.31278 9.08614 4.54956 9.03819 4.80732 9.0262C5.0471 9.0262 5.27788 9.07116 5.49968 9.16107C5.72147 9.25099 5.91629 9.37987 6.08414 9.54771L8.0623 11.5259L13.9249 5.65433C14.0927 5.48648 14.2875 5.3576 14.5093 5.26769C14.7311 5.17777 14.9619 5.13281 15.2017 5.13281Z",fill:t})}),LV=({size:e=20,fill:t="#E5F6FF",className:n=""})=>a.jsx("svg",{width:e,height:e,viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:n,children:a.jsx("path",{d:"M13.7862 4.40112C13.904 4.27661 14.0456 4.17697 14.2025 4.1081C14.3594 4.03922 14.5286 4.00251 14.6999 4.00012C14.8713 3.99774 15.0414 4.02974 15.2002 4.09422C15.359 4.15871 15.5033 4.25437 15.6244 4.37556C15.7456 4.49675 15.8413 4.64101 15.9058 4.7998C15.9703 4.95859 16.0023 5.1287 15.9999 5.30007C15.9975 5.47145 15.9608 5.6406 15.8919 5.79754C15.823 5.95448 15.7234 6.09602 15.5989 6.21379L11.842 9.97077C11.837 9.97573 11.833 9.98163 11.8304 9.98812C11.8277 9.99461 11.8263 10.0016 11.8263 10.0086C11.8263 10.0156 11.8277 10.0226 11.8304 10.0291C11.833 10.0356 11.837 10.0415 11.842 10.0464L15.5989 13.8034C15.7196 13.9221 15.8155 14.0635 15.8813 14.2195C15.947 14.3755 15.9812 14.5429 15.9819 14.7122C15.9827 14.8814 15.9498 15.0492 15.8854 15.2057C15.821 15.3622 15.7262 15.5044 15.6065 15.6241C15.4868 15.7438 15.3446 15.8386 15.1881 15.9031C15.0316 15.9676 14.8639 16.0004 14.6947 15.9998C14.5254 15.9991 14.358 15.9649 14.202 15.8992C14.046 15.8335 13.9045 15.7376 13.7858 15.6169L10.0289 11.8599C10.0239 11.855 10.0181 11.851 10.0116 11.8483C10.0051 11.8456 9.99811 11.8442 9.99109 11.8442C9.98406 11.8442 9.9771 11.8456 9.97061 11.8483C9.96412 11.851 9.95822 11.855 9.95326 11.8599L6.19635 15.6169C6.07765 15.7376 5.93624 15.8336 5.78027 15.8993C5.6243 15.9651 5.45685 15.9993 5.28759 16C5.11833 16.0007 4.95061 15.9679 4.79409 15.9035C4.63757 15.839 4.49536 15.7442 4.37566 15.6245C4.25596 15.5049 4.16114 15.3627 4.09666 15.2062C4.03219 15.0497 3.99934 14.882 4.00001 14.7127C4.00068 14.5434 4.03485 14.376 4.10056 14.22C4.16627 14.064 4.26222 13.9226 4.38286 13.8038L8.13977 10.0468C8.14475 10.0419 8.14869 10.036 8.15139 10.0295C8.15408 10.023 8.15547 10.016 8.15547 10.009C8.15547 10.002 8.15408 9.99504 8.15139 9.98854C8.14869 9.98205 8.14475 9.97616 8.13977 9.9712L4.38286 6.21422C4.1456 5.97312 4.01322 5.64803 4.01456 5.30977C4.0159 4.97151 4.15084 4.64748 4.39 4.40826C4.62916 4.16905 4.95315 4.03402 5.2914 4.03261C5.62966 4.03119 5.95477 4.16349 6.19592 4.4007L9.95283 8.15767C9.95779 8.16265 9.96369 8.1666 9.97018 8.16929C9.97667 8.17198 9.98363 8.17337 9.99066 8.17337C9.99768 8.17337 10.0046 8.17198 10.0111 8.16929C10.0176 8.1666 10.0235 8.16265 10.0285 8.15767L13.7862 4.40112Z",fill:t})}),PV=({isRunning:e,envSuccess:t,action:n})=>{if(e)return a.jsxs(a.Fragment,{children:[a.jsx(Mk,{className:"text-[#29CC83]"}),a.jsx("span",{className:"text-[#29CC83]",children:"Running"})]});const s=void 0===t||t||(null==n?void 0:n.includes("file_editor str_replace"));return a.jsx("div",{className:"flex items-center gap-2 select-text",children:s?a.jsx(DV,{size:20}):a.jsx(LV,{size:20})})};function RV(e){let t=e;return(t.startsWith("'")&&t.endsWith("'")||t.startsWith('"')&&t.endsWith('"'))&&(t=t.substring(1,t.length-1)),t=t.replace(/\\n/g,"\n").replace(/\\r/g,"\r").replace(/\\t/g,"\t").replace(/\\'/g,"'").replace(/\\\\/g,"\\"),t}function OV(e,t){try{const n=JSON.parse(e);return!("mcp_tool"!==n.type||!n.tool_name||!n.tool_arguments)&&(!t||n.tool_name===t)}catch{return!1}}function zV(e){try{const t=JSON.parse(e);return"mcp_tool"!==t.type||"mcp_search_replace"!==t.tool_name?null:t.tool_arguments?{path:t.tool_arguments.path||"",oldStr:t.tool_arguments.old_str||"",newStr:t.tool_arguments.new_str||""}:null}catch(t){return null}}function BV(e){const t=e.indexOf("["),n=HV(e,t),s=e.indexOf("[",n+1),i=HV(e,s);if(-1===t||-1===n||-1===s||-1===i)throw new Error("Invalid bulk file creator action format");const a=e.substring(t+1,n),r=e.substring(s+1,i),o=function(e){const t=[],n=/"([^"]+)"|'([^']+)'|([^,\s][^,]*[^,\s])/g;let s;for(;null!==(s=n.exec(e));){const e=s[1]||s[2]||s[3];e&&t.push(e)}return t}(a),l=function(e){let t="",n=null,s=0,i=!1;const a=[];for(let r=0;r({path:e,content:t{var t;switch(null==(t=e.split(".").pop())?void 0:t.toLowerCase()){case"js":case"jsx":return"javascript";case"ts":case"tsx":return"typescript";case"py":return"python";case"json":return"json";case"html":return"html";case"css":return"css";case"md":return"markdown";case"yaml":case"yml":return"yaml";case"sh":case"bash":return"shell";case"c":return"c";case"cpp":case"cc":return"cpp";case"java":return"java";case"go":return"go";case"rs":return"rust";case"php":return"php";case"rb":return"ruby";case"sql":return"sql";case"xml":return"xml";case"swift":return"swift";case"kt":case"kts":return"kotlin";case"dart":return"dart";default:return"plaintext"}},VV=({files:e,isSubagent:t})=>{const[n,s]=Pe.useState(e.length-1),i=Pe.useRef(null),r=Pe.useRef(null),o=Pe.useRef(null),l=Pe.useRef(e.length);return Pe.useEffect(()=>{e.length>l.current&&s(e.length-1),l.current=e.length},[e.length]),Pe.useEffect(()=>{if(i.current&&r.current){const e=i.current,t=r.current,n=e.clientWidth,s=t.clientWidth,a=t.offsetLeft-n/2+s/2;e.scrollTo({left:a,behavior:"smooth"})}setTimeout(()=>{if(o.current){const e=o.current.getModel().getLineCount();o.current.revealLine(e,1)}},100)},[n]),e.length?a.jsx("div",{className:"w-full border border-[#252526] rounded-lg overflow-hidden",children:a.jsxs("div",{className:"flex flex-col",children:[a.jsx("div",{ref:i,className:"flex overflow-x-auto bg-[#252526] scrollbar-thin scrollbar-thumb-[#3E3E42] scrollbar-track-[#252526]",style:{msOverflowStyle:"none",...t?{flexWrap:"nowrap",overflow:"scroll",whiteSpace:"pre-wrap",width:t?"calc(100% - 159px)":"100%"}:{}},children:e.map((e,t)=>{const i=t===n,o=e.path.split("/").pop()||e.path;return a.jsx("button",{ref:i?r:null,className:"px-4 py-2 whitespace-nowrap font-mono text-sm flex-shrink-0 "+(i?"bg-[#1E1E1E] text-[#DD99FF] border-b-2 border-[#DD99FF]":"text-[#E5E5E5] hover:bg-[#2D2D2D]"),onClick:e=>{s(t),e.stopPropagation()},title:e.path,children:o},t)})}),a.jsx("div",{className:"bg-[#252526] px-4 py-2 font-mono text-[#E5E5E5] text-sm flex items-center border-t border-[#3E3E42] border-b border-[#3E3E42] overflow-hidden text-ellipsis whitespace-nowrap",children:a.jsx("span",{className:"text-[#DD99FF]",children:e[n].path})}),a.jsx("div",{className:"h-[400px] w-full",children:e[n]&&e[n].content?a.jsx(Vt,{height:"100%",defaultLanguage:$V(e[n].path),value:e[n].content,theme:"vs-dark",onMount:e=>{o.current=e,setTimeout(()=>{if(o.current){const e=o.current.getModel().getLineCount();o.current.revealLine(e,1)}},100)},options:{readOnly:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1,lineNumbers:"on",renderLineHighlight:"all",contextmenu:!1,folding:!0,scrollbar:{vertical:"visible",horizontal:"visible"},fontSize:13,fontFamily:"'Menlo', 'Monaco', 'Courier New', monospace"}}):a.jsx("div",{className:"h-full w-full flex items-center justify-center bg-[#1E1E1E] text-[#E5E5E5]",children:"No content available for this file"})})]})}):a.jsx("div",{className:"text-[#E5E5E5] p-4",children:"No files to display"})},UV=({path:e,edits:t,isSubagent:n})=>{const[s,i]=Pe.useState(t.length-1),r=Pe.useRef(null),o=Pe.useRef(null),l=Pe.useRef(t.length);return Pe.useEffect(()=>{t.length>l.current&&i(t.length-1),l.current=t.length},[t.length]),Pe.useEffect(()=>{if(r.current&&o.current){const e=r.current,t=o.current,n=e.clientWidth,s=t.clientWidth,i=t.offsetLeft-n/2+s/2;e.scrollTo({left:i,behavior:"smooth"})}},[s]),t.length?(e.split("/").pop(),a.jsx("div",{className:"w-full border border-[#252526] rounded-lg overflow-hidden",children:a.jsxs("div",{className:"flex flex-col",children:[a.jsx("div",{className:"bg-[#252526] px-4 py-2 font-mono text-[#E5E5E5] text-sm flex items-center border-b border-[#3E3E42] overflow-hidden text-ellipsis whitespace-nowrap",children:a.jsx("span",{className:"text-[#DD99FF]",children:e})}),a.jsx("div",{ref:r,className:"flex overflow-x-auto bg-[#252526] scrollbar-thin scrollbar-thumb-[#3E3E42] scrollbar-track-[#252526]",style:{msOverflowStyle:"none",...n?{flexWrap:"nowrap",overflow:"scroll",whiteSpace:"pre-wrap",width:n?"calc(100% - 159px)":"100%"}:{}},children:t.map((e,t)=>{const n=t===s;return a.jsxs("button",{ref:n?o:null,className:"px-4 py-2 whitespace-nowrap font-mono text-sm flex-shrink-0 "+(n?"bg-[#1E1E1E] text-[#DD99FF] border-b-2 border-[#DD99FF]":"text-[#E5E5E5] hover:bg-[#2D2D2D]"),onClick:e=>{i(t),e.stopPropagation()},title:`Edit ${t+1}`,children:["Edit ",t+1]},t)})}),a.jsx("div",{className:"h-[400px] w-full",children:t[s]?a.jsx($t,{height:"100%",language:$V(e),original:t[s].oldStr,modified:t[s].newStr,theme:"vs-dark",options:{readOnly:!0,renderSideBySide:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1,lineNumbers:"on",renderLineHighlight:"all",contextmenu:!1,folding:!0,scrollbar:{vertical:"visible",horizontal:"visible"},originalEditable:!1,enableSplitViewResizing:!0,fontSize:13,fontFamily:"'Menlo', 'Monaco', 'Courier New', monospace"}}):a.jsx("div",{className:"h-full w-full flex items-center justify-center bg-[#1E1E1E] text-[#E5E5E5]",children:"No content available for this edit"})})]})})):a.jsx("div",{className:"text-[#E5E5E5] p-4",children:"No edits to display"})},WV=({action:e,functionName:t,isExpanded:n,setIsExpanded:s,isSubagent:i=!1})=>a.jsx("code",{className:"text-[#CCEDFF99] font-mono text-sm w-full overflow-hidden",children:(()=>{if(!e)return"";if(t&&["str_replace_editor","create_file","view_file","search_replace","insert_text"].includes(t)){const[t,n,s]=e.split(" ");if("view"===n)return a.jsxs("span",{className:"flex items-center gap-2 font-mono text-wrap",children:["Viewed"," ",a.jsx("span",{className:"text-[#FF99FD] font-brockmann",children:s})]});if("str_replace"===n)return a.jsxs("span",{className:"flex items-center gap-2 font-mono",children:["Edited"," ",a.jsx("span",{className:"text-[#FF99FD] font-brockmann",children:s})]});if("create"===n){const t=e.split(" ")[2];return a.jsxs("span",{className:"flex items-center gap-2 font-mono",children:["Created"," ",a.jsx("span",{className:"text-[#FF99FD] font-brockmann",children:t})]})}}else if(e.startsWith("bulk_file_creator")||"bulk_file_writer"===t)try{let r;return r=e.startsWith("bulk_file_creator")?BV(e):"bulk_file_writer"===t&&OV(e,"mcp_bulk_file_writer")?function(e){try{const t=JSON.parse(e);return"mcp_tool"!==t.type||"mcp_bulk_file_writer"!==t.tool_name?[]:t.tool_arguments&&t.tool_arguments.files?t.tool_arguments.files.map(e=>({path:e.path,content:e.content||""})):[]}catch(t){return[]}}(e):BV(e),n?a.jsxs("div",{className:"flex flex-col space-y-2",children:[a.jsxs("div",{className:"text-[#E5E5E5] font-medium",children:[a.jsx("span",{className:"text-[#FF99FD]",children:"Created"})," ",r.length," ",1===r.length?"file":"files"]}),a.jsx(VV,{files:r,isSubagent:i})]}):a.jsx("div",{className:"flex flex-col w-full space-y-1 cursor-pointer",onClick:()=>s(!0),children:a.jsxs("div",{className:"text-[#E5E5E5] font-medium",children:[a.jsx("span",{className:"text-[#FF99FD]",children:"Created"})," ",r.length," ",1===r.length?"file":"files"]})})}catch(o){return a.jsx("span",{className:"text-red-500",children:"Error parsing file content"})}else if("search_replace"===t){if(OV(e,"mcp_search_replace")){const t=zV(e);if(t)return a.jsxs("span",{className:"flex items-center gap-2 font-mono",children:["Edited"," ",a.jsx("span",{className:"text-[#FF99FD] font-brockmann",children:t.path})]})}}else if("multi_search_replace"===t){if(OV(e,"mcp_multi_search_replace"))try{const t=function(e){try{const t=JSON.parse(e);return"mcp_tool"!==t.type||"mcp_multi_search_replace"!==t.tool_name?null:t.tool_arguments&&t.tool_arguments.edits?{path:t.tool_arguments.path||"",edits:t.tool_arguments.edits.map(e=>({oldStr:e.old_str||"",newStr:e.new_str||""}))}:null}catch(o){return null}}(e);if(t)return n?a.jsxs("div",{className:"flex flex-col space-y-2",children:[a.jsxs("div",{className:"text-[#E5E5E5] font-medium",children:[a.jsx("span",{className:"text-[#FF99FD]",children:"Applied"})," ",t.edits.length," ",1===t.edits.length?"edit":"edits"," to"," ",a.jsx("span",{className:"text-[#FF99FD] font-brockmann",children:t.path})]}),a.jsx(UV,{path:t.path,edits:t.edits,isSubagent:i})]}):a.jsx("div",{className:"flex flex-col w-full space-y-1 cursor-pointer",onClick:()=>s(!0),children:a.jsxs("div",{className:"text-[#E5E5E5] font-medium",children:[a.jsx("span",{className:"text-[#FF99FD]",children:"Applied"})," ",t.edits.length," ",1===t.edits.length?"edit":"edits"," to"," ",a.jsx("span",{className:"text-[#FF99FD] font-brockmann",children:t.path})]})})}catch(o){return a.jsx("span",{className:"text-red-500",children:"Error parsing edits"})}}else if("view_bulk"===t&&OV(e,"mcp_view_bulk")){const t=function(e){try{const t=JSON.parse(e);return"mcp_tool"!==t.type||"mcp_view_bulk"!==t.tool_name?[]:t.tool_arguments&&t.tool_arguments.paths?t.tool_arguments.paths:[]}catch(o){return[]}}(e);if(t.length>0)return a.jsxs("span",{className:"flex items-center gap-2 font-mono",children:["Viewing"," ",a.jsx("span",{className:"text-[#FF99FD]",children:t.length})," ",1===t.length?"path":"paths"]})}return n?e:(r=e).length>50?`${r.substring(0,50)}...`:r;var r})()});function qV(){}function GV(){}const ZV=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,YV=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,KV={};function JV(e,t){return(KV.jsx?YV:ZV).test(e)}const QV=/[ \t\n\f\r]/g;function XV(e){return""===e.replace(QV,"")}class eU{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}}function tU(e,t){const n={},s={};for(const i of e)Object.assign(n,i.property),Object.assign(s,i.normal);return new eU(n,s,t)}function nU(e){return e.toLowerCase()}eU.prototype.normal={},eU.prototype.property={},eU.prototype.space=void 0;class sU{constructor(e,t){this.attribute=t,this.property=e}}sU.prototype.attribute="",sU.prototype.booleanish=!1,sU.prototype.boolean=!1,sU.prototype.commaOrSpaceSeparated=!1,sU.prototype.commaSeparated=!1,sU.prototype.defined=!1,sU.prototype.mustUseProperty=!1,sU.prototype.number=!1,sU.prototype.overloadedBoolean=!1,sU.prototype.property="",sU.prototype.spaceSeparated=!1,sU.prototype.space=void 0;let iU=0;const aU=pU(),rU=pU(),oU=pU(),lU=pU(),cU=pU(),dU=pU(),uU=pU();function pU(){return 2**++iU}const mU=Object.freeze(Object.defineProperty({__proto__:null,boolean:aU,booleanish:rU,commaOrSpaceSeparated:uU,commaSeparated:dU,number:lU,overloadedBoolean:oU,spaceSeparated:cU},Symbol.toStringTag,{value:"Module"})),hU=Object.keys(mU);class xU extends sU{constructor(e,t,n,s){let i=-1;if(super(e,t),fU(this,"space",s),"number"==typeof n)for(;++i"role"===t?t:"aria-"+t.slice(4).toLowerCase()});function bU(e,t){return t in e?e[t]:t}function yU(e,t){return bU(e,t.toLowerCase())}const wU=gU({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:dU,acceptCharset:cU,accessKey:cU,action:null,allow:null,allowFullScreen:aU,allowPaymentRequest:aU,allowUserMedia:aU,alt:null,as:null,async:aU,autoCapitalize:null,autoComplete:cU,autoFocus:aU,autoPlay:aU,blocking:cU,capture:null,charSet:null,checked:aU,cite:null,className:cU,cols:lU,colSpan:null,content:null,contentEditable:rU,controls:aU,controlsList:cU,coords:lU|dU,crossOrigin:null,data:null,dateTime:null,decoding:null,default:aU,defer:aU,dir:null,dirName:null,disabled:aU,download:oU,draggable:rU,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:aU,formTarget:null,headers:cU,height:lU,hidden:oU,high:lU,href:null,hrefLang:null,htmlFor:cU,httpEquiv:cU,id:null,imageSizes:null,imageSrcSet:null,inert:aU,inputMode:null,integrity:null,is:null,isMap:aU,itemId:null,itemProp:cU,itemRef:cU,itemScope:aU,itemType:cU,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:aU,low:lU,manifest:null,max:null,maxLength:lU,media:null,method:null,min:null,minLength:lU,multiple:aU,muted:aU,name:null,nonce:null,noModule:aU,noValidate:aU,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:aU,optimum:lU,pattern:null,ping:cU,placeholder:null,playsInline:aU,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:aU,referrerPolicy:null,rel:cU,required:aU,reversed:aU,rows:lU,rowSpan:lU,sandbox:cU,scope:null,scoped:aU,seamless:aU,selected:aU,shadowRootClonable:aU,shadowRootDelegatesFocus:aU,shadowRootMode:null,shape:null,size:lU,sizes:null,slot:null,span:lU,spellCheck:rU,src:null,srcDoc:null,srcLang:null,srcSet:null,start:lU,step:null,style:null,tabIndex:lU,target:null,title:null,translate:null,type:null,typeMustMatch:aU,useMap:null,value:rU,width:lU,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:cU,axis:null,background:null,bgColor:null,border:lU,borderColor:null,bottomMargin:lU,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:aU,declare:aU,event:null,face:null,frame:null,frameBorder:null,hSpace:lU,leftMargin:lU,link:null,longDesc:null,lowSrc:null,marginHeight:lU,marginWidth:lU,noResize:aU,noHref:aU,noShade:aU,noWrap:aU,object:null,profile:null,prompt:null,rev:null,rightMargin:lU,rules:null,scheme:null,scrolling:rU,standby:null,summary:null,text:null,topMargin:lU,valueType:null,version:null,vAlign:null,vLink:null,vSpace:lU,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:aU,disableRemotePlayback:aU,prefix:null,property:null,results:lU,security:null,unselectable:null},space:"html",transform:yU}),jU=gU({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:uU,accentHeight:lU,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:lU,amplitude:lU,arabicForm:null,ascent:lU,attributeName:null,attributeType:null,azimuth:lU,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:lU,by:null,calcMode:null,capHeight:lU,className:cU,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:lU,diffuseConstant:lU,direction:null,display:null,dur:null,divisor:lU,dominantBaseline:null,download:aU,dx:null,dy:null,edgeMode:null,editable:null,elevation:lU,enableBackground:null,end:null,event:null,exponent:lU,externalResourcesRequired:null,fill:null,fillOpacity:lU,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:dU,g2:dU,glyphName:dU,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:lU,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:lU,horizOriginX:lU,horizOriginY:lU,id:null,ideographic:lU,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:lU,k:lU,k1:lU,k2:lU,k3:lU,k4:lU,kernelMatrix:uU,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:lU,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:lU,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:lU,overlineThickness:lU,paintOrder:null,panose1:null,path:null,pathLength:lU,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:cU,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:lU,pointsAtY:lU,pointsAtZ:lU,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:uU,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:uU,rev:uU,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:uU,requiredFeatures:uU,requiredFonts:uU,requiredFormats:uU,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:lU,specularExponent:lU,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:lU,strikethroughThickness:lU,string:null,stroke:null,strokeDashArray:uU,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:lU,strokeOpacity:lU,strokeWidth:null,style:null,surfaceScale:lU,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:uU,tabIndex:lU,tableValues:null,target:null,targetX:lU,targetY:lU,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:uU,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:lU,underlineThickness:lU,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:lU,values:null,vAlphabetic:lU,vMathematical:lU,vectorEffect:null,vHanging:lU,vIdeographic:lU,version:null,vertAdvY:lU,vertOriginX:lU,vertOriginY:lU,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:lU,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:bU}),CU=gU({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform:(e,t)=>"xlink:"+t.slice(5).toLowerCase()}),NU=gU({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:yU}),FU=gU({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform:(e,t)=>"xml:"+t.slice(3).toLowerCase()}),_U={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},kU=/[A-Z]/g,SU=/-[a-z]/g,EU=/^data[-\w.:]+$/i;function IU(e){return"-"+e.toLowerCase()}function AU(e){return e.charAt(1).toUpperCase()}const TU=tU([vU,wU,CU,NU,FU],"html"),MU=tU([vU,jU,CU,NU,FU],"svg");var DU,LU,PU,RU={};function OU(){if(PU)return RU;PU=1;var e=RU&&RU.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(RU,"__esModule",{value:!0}),RU.default=function(e,n){var s=null;if(!e||"string"!=typeof e)return s;var i=(0,t.default)(e),a="function"==typeof n;return i.forEach(function(e){if("declaration"===e.type){var t=e.property,i=e.value;a?n(t,i,e):i&&((s=s||{})[t]=i)}}),s};var t=e(function(){if(LU)return DU;LU=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,s=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,a=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,r=/^[;\s]*/,o=/^\s+|\s+$/g,l="";function c(e){return e?e.replace(o,l):l}return DU=function(o,d){if("string"!=typeof o)throw new TypeError("First argument must be a string");if(!o)return[];d=d||{};var u=1,p=1;function m(e){var n=e.match(t);n&&(u+=n.length);var s=e.lastIndexOf("\n");p=~s?e.length-s:p+e.length}function h(){var e={line:u,column:p};return function(t){return t.position=new x(e),v(),t}}function x(e){this.start=e,this.end={line:u,column:p},this.source=d.source}function f(e){var t=new Error(d.source+":"+u+":"+p+": "+e);if(t.reason=e,t.filename=d.source,t.line=u,t.column=p,t.source=o,!d.silent)throw t}function g(e){var t=e.exec(o);if(t){var n=t[0];return m(n),o=o.slice(n.length),t}}function v(){g(n)}function b(e){var t;for(e=e||[];t=y();)!1!==t&&e.push(t);return e}function y(){var e=h();if("/"==o.charAt(0)&&"*"==o.charAt(1)){for(var t=2;l!=o.charAt(t)&&("*"!=o.charAt(t)||"/"!=o.charAt(t+1));)++t;if(t+=2,l===o.charAt(t-1))return f("End of comment missing");var n=o.slice(2,t-2);return p+=2,m(n),o=o.slice(t),p+=2,e({type:"comment",comment:n})}}function w(){var t=h(),n=g(s);if(n){if(y(),!g(i))return f("property missing ':'");var o=g(a),d=t({type:"declaration",property:c(n[0].replace(e,l)),value:o?c(o[0].replace(e,l)):l});return g(r),d}}return x.prototype.content=o,v(),function(){var e,t=[];for(b(t);e=w();)!1!==e&&(t.push(e),b(t));return t}()}}());return RU}var zU,BU,HU,$U={};function VU(){if(zU)return $U;zU=1,Object.defineProperty($U,"__esModule",{value:!0}),$U.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,s=/^-(webkit|moz|ms|o|khtml)-/,i=/^-(ms)-/,a=function(e,t){return t.toUpperCase()},r=function(e,t){return"".concat(t,"-")};return $U.camelCase=function(o,l){return void 0===l&&(l={}),function(t){return!t||n.test(t)||e.test(t)}(o)?o:(o=o.toLowerCase(),(o=l.reactCompat?o.replace(i,r):o.replace(s,r)).replace(t,a))},$U}const UU=Le(function(){if(HU)return BU;HU=1;var e=(BU&&BU.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(OU()),t=VU();function n(n,s){var i={};return n&&"string"==typeof n?((0,e.default)(n,function(e,n){e&&n&&(i[(0,t.camelCase)(e,s)]=n)}),i):i}return n.default=n,BU=n}()),WU=GU("end"),qU=GU("start");function GU(e){return function(t){const n=t&&t.position&&t.position[e]||{};if("number"==typeof n.line&&n.line>0&&"number"==typeof n.column&&n.column>0)return{line:n.line,column:n.column,offset:"number"==typeof n.offset&&n.offset>-1?n.offset:void 0}}}function ZU(e){return e&&"object"==typeof e?"position"in e||"type"in e?KU(e.position):"start"in e||"end"in e?KU(e):"line"in e||"column"in e?YU(e):"":""}function YU(e){return JU(e&&e.line)+":"+JU(e&&e.column)}function KU(e){return YU(e&&e.start)+"-"+YU(e&&e.end)}function JU(e){return e&&"number"==typeof e?e:1}class QU extends Error{constructor(e,t,n){super(),"string"==typeof t&&(n=t,t=void 0);let s="",i={},a=!1;if(t&&(i="line"in t&&"column"in t||"start"in t&&"end"in t?{place:t}:"type"in t?{ancestors:[t],place:t.position}:{...t}),"string"==typeof e?s=e:!i.cause&&e&&(a=!0,s=e.message,i.cause=e),!i.ruleId&&!i.source&&"string"==typeof n){const e=n.indexOf(":");-1===e?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){const e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}const r=i.place&&"start"in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=r?r.column:void 0,this.fatal=void 0,this.file="",this.message=s,this.line=r?r.line:void 0,this.name=ZU(i.place)||"1:1",this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&"string"==typeof i.cause.stack?i.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}QU.prototype.file="",QU.prototype.name="",QU.prototype.reason="",QU.prototype.message="",QU.prototype.stack="",QU.prototype.column=void 0,QU.prototype.line=void 0,QU.prototype.ancestors=void 0,QU.prototype.cause=void 0,QU.prototype.fatal=void 0,QU.prototype.place=void 0,QU.prototype.ruleId=void 0,QU.prototype.source=void 0;const XU={}.hasOwnProperty,eW=new Map,tW=/[A-Z]/g,nW=new Set(["table","tbody","thead","tfoot","tr"]),sW=new Set(["td","th"]),iW="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function aW(e,t){if(!t||void 0===t.Fragment)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let s;if(t.development){if("function"!=typeof t.jsxDEV)throw new TypeError("Expected `jsxDEV` in options when `development: true`");s=function(e,t){return n;function n(n,s,i,a){const r=Array.isArray(i.children),o=qU(n);return t(s,i,a,r,{columnNumber:o?o.column-1:void 0,fileName:e,lineNumber:o?o.line:void 0},void 0)}}(n,t.jsxDEV)}else{if("function"!=typeof t.jsx)throw new TypeError("Expected `jsx` in production options");if("function"!=typeof t.jsxs)throw new TypeError("Expected `jsxs` in production options");s=function(e,t,n){return s;function s(e,s,i,a){const r=Array.isArray(i.children)?n:t;return a?r(s,i,a):r(s,i)}}(0,t.jsx,t.jsxs)}const i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:s,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:!1!==t.passKeys,passNode:t.passNode||!1,schema:"svg"===t.space?MU:TU,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:!1!==t.tableCellAlignToStyle},a=rW(i,e,void 0);return a&&"string"!=typeof a?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function rW(e,t,n){return"element"===t.type?function(e,t,n){const s=e.schema;let i=s;"svg"===t.tagName.toLowerCase()&&"html"===s.space&&(i=MU,e.schema=i);e.ancestors.push(t);const a=uW(e,t.tagName,!1),r=function(e,t){const n={};let s,i;for(i in t.properties)if("children"!==i&&XU.call(t.properties,i)){const a=dW(e,i,t.properties[i]);if(a){const[i,r]=a;e.tableCellAlignToStyle&&"align"===i&&"string"==typeof r&&sW.has(t.tagName)?s=r:n[i]=r}}if(s){(n.style||(n.style={}))["css"===e.stylePropertyNameCase?"text-align":"textAlign"]=s}return n}(e,t);let o=cW(e,t);nW.has(t.tagName)&&(o=o.filter(function(e){return"string"!=typeof e||!("object"==typeof(t=e)?"text"===t.type&&XV(t.value):XV(t));var t}));return oW(e,r,a,t),lW(r,o),e.ancestors.pop(),e.schema=s,e.create(t,a,r,n)}(e,t,n):"mdxFlowExpression"===t.type||"mdxTextExpression"===t.type?function(e,t){if(t.data&&t.data.estree&&e.evaluater){const n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}pW(e,t.position)}(e,t):"mdxJsxFlowElement"===t.type||"mdxJsxTextElement"===t.type?function(e,t,n){const s=e.schema;let i=s;"svg"===t.name&&"html"===s.space&&(i=MU,e.schema=i);e.ancestors.push(t);const a=null===t.name?e.Fragment:uW(e,t.name,!0),r=function(e,t){const n={};for(const s of t.attributes)if("mdxJsxExpressionAttribute"===s.type)if(s.data&&s.data.estree&&e.evaluater){const t=s.data.estree.body[0];qV(t.type);const i=t.expression;qV(i.type);const a=i.properties[0];qV(a.type),Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else pW(e,t.position);else{const i=s.name;let a;if(s.value&&"object"==typeof s.value)if(s.value.data&&s.value.data.estree&&e.evaluater){const t=s.value.data.estree.body[0];qV(t.type),a=e.evaluater.evaluateExpression(t.expression)}else pW(e,t.position);else a=null===s.value||s.value;n[i]=a}return n}(e,t),o=cW(e,t);return oW(e,r,a,t),lW(r,o),e.ancestors.pop(),e.schema=s,e.create(t,a,r,n)}(e,t,n):"mdxjsEsm"===t.type?function(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);pW(e,t.position)}(e,t):"root"===t.type?function(e,t,n){const s={};return lW(s,cW(e,t)),e.create(t,e.Fragment,s,n)}(e,t,n):"text"===t.type?function(e,t){return t.value}(0,t):void 0}function oW(e,t,n,s){"string"!=typeof n&&n!==e.Fragment&&e.passNode&&(t.node=s)}function lW(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function cW(e,t){const n=[];let s=-1;const i=e.passKeys?new Map:eW;for(;++s4&&"data"===n.slice(0,4)&&EU.test(t)){if("-"===t.charAt(4)){const e=t.slice(5).replace(SU,AU);s="data"+e.charAt(0).toUpperCase()+e.slice(1)}else{const e=t.slice(4);if(!SU.test(e)){let n=e.replace(kU,IU);"-"!==n.charAt(0)&&(n="-"+n),t="data"+n}}i=xU}return new i(s,t)}(e.schema,t);if(!(null==n||"number"==typeof n&&Number.isNaN(n))){if(Array.isArray(n)&&(n=s.commaSeparated?function(e){const t={};return(""===e[e.length-1]?[...e,""]:e).join((t.padRight?" ":"")+","+(!1===t.padLeft?"":" ")).trim()}(n):n.join(" ").trim()),"style"===s.property){let t="object"==typeof n?n:function(e,t){try{return UU(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const t=n,s=new QU("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:t,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw s.file=e.filePath||void 0,s.url=iW+"#cannot-parse-style-attribute",s}}(e,String(n));return"css"===e.stylePropertyNameCase&&(t=function(e){const t={};let n;for(n in e)XU.call(e,n)&&(t[mW(n)]=e[n]);return t}(t)),["style",t]}return["react"===e.elementAttributeNameCase&&s.space?_U[s.property]||s.property:s.attribute,n]}}function uW(e,t,n){let s;if(n)if(t.includes(".")){const e=t.split(".");let n,i=-1;for(;++ii?0:i+t:t>i?i:t,n=n>0?n:0,s.length<1e4)a=Array.from(s),a.unshift(t,n),e.splice(...a);else for(n&&e.splice(t,n);r0?(jW(e,e.length,0,t),e):t}const NW={}.hasOwnProperty;function FW(e){const t={};let n=-1;for(;++n13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||!(65535&~n)||65534==(65535&n)||n>1114111?"�":String.fromCodePoint(n)}function EW(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const IW=$W(/[A-Za-z]/),AW=$W(/[\dA-Za-z]/),TW=$W(/[#-'*+\--9=?A-Z^-~]/);function MW(e){return null!==e&&(e<32||127===e)}const DW=$W(/\d/),LW=$W(/[\dA-Fa-f]/),PW=$W(/[!-/:-@[-`{-~]/);function RW(e){return null!==e&&e<-2}function OW(e){return null!==e&&(e<0||32===e)}function zW(e){return-2===e||-1===e||32===e}const BW=$W(new RegExp("\\p{P}|\\p{S}","u")),HW=$W(/\s/);function $W(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function VW(e){const t=[];let n=-1,s=0,i=0;for(;++n55295&&a<57344){const t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(r=String.fromCharCode(a,t),i=1):r="�"}else r=String.fromCharCode(a);r&&(t.push(e.slice(s,n),encodeURIComponent(r)),s=n+i+1,r=""),i&&(n+=i,i=0)}return t.join("")+e.slice(s)}function UW(e,t,n,s){const i=s?s-1:Number.POSITIVE_INFINITY;let a=0;return function(s){if(zW(s))return e.enter(n),r(s);return t(s)};function r(s){return zW(s)&&a++a))return;const n=t.events.length;let i,o,l=n;for(;l--;)if("exit"===t.events[l][0]&&"chunkFlow"===t.events[l][1].type){if(i){o=t.events[l][1].end;break}i=!0}for(g(r),e=n;es;){const s=n[i];t.containerState=s[1],s[0].exit.call(t,e)}n.length=s}function v(){s.write([null]),i=void 0,s=void 0,t.containerState._closeFlow=void 0}}},GW={tokenize:function(e,t,n){return UW(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}};function ZW(e){return null===e||OW(e)||HW(e)?1:BW(e)?2:void 0}function YW(e,t,n){const s=[];let i=-1;for(;++i1&&e[d][1].end.offset-e[d][1].start.offset>1?2:1;const u={...e[n][1].end},p={...e[d][1].start};JW(u,-o),JW(p,o),a={type:o>1?"strongSequence":"emphasisSequence",start:u,end:{...e[n][1].end}},r={type:o>1?"strongSequence":"emphasisSequence",start:{...e[d][1].start},end:p},i={type:o>1?"strongText":"emphasisText",start:{...e[n][1].end},end:{...e[d][1].start}},s={type:o>1?"strong":"emphasis",start:{...a.start},end:{...r.end}},e[n][1].end={...a.start},e[d][1].start={...r.end},l=[],e[n][1].end.offset-e[n][1].start.offset&&(l=CW(l,[["enter",e[n][1],t],["exit",e[n][1],t]])),l=CW(l,[["enter",s,t],["enter",a,t],["exit",a,t],["enter",i,t]]),l=CW(l,YW(t.parser.constructs.insideSpan.null,e.slice(n+1,d),t)),l=CW(l,[["exit",i,t],["enter",r,t],["exit",r,t],["exit",s,t]]),e[d][1].end.offset-e[d][1].start.offset?(c=2,l=CW(l,[["enter",e[d][1],t],["exit",e[d][1],t]])):c=0,jW(e,n-1,d-n+3,l),d=n+l.length-c-2;break}d=-1;for(;++d=o?(e.exit("codeFencedFenceSequence"),zW(t)?UW(e,u,"whitespace")(t):u(t)):n(t)}function u(s){return null===s||RW(s)?(e.exit("codeFencedFence"),t(s)):n(s)}}};let a,r=0,o=0;return function(t){return function(t){const n=s.events[s.events.length-1];return r=n&&"linePrefix"===n[1].type?n[2].sliceSerialize(n[1],!0).length:0,a=t,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),l(t)}(t)};function l(t){return t===a?(o++,e.consume(t),l):o<3?n(t):(e.exit("codeFencedFenceSequence"),zW(t)?UW(e,c,"whitespace")(t):c(t))}function c(n){return null===n||RW(n)?(e.exit("codeFencedFence"),s.interrupt?t(n):e.check(sq,m,v)(n)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),d(n))}function d(t){return null===t||RW(t)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),c(t)):zW(t)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),UW(e,u,"whitespace")(t)):96===t&&t===a?n(t):(e.consume(t),d)}function u(t){return null===t||RW(t)?c(t):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),p(t))}function p(t){return null===t||RW(t)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),c(t)):96===t&&t===a?n(t):(e.consume(t),p)}function m(t){return e.attempt(i,v,h)(t)}function h(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),x}function x(t){return r>0&&zW(t)?UW(e,f,"linePrefix",r+1)(t):f(t)}function f(t){return null===t||RW(t)?e.check(sq,m,v)(t):(e.enter("codeFlowValue"),g(t))}function g(t){return null===t||RW(t)?(e.exit("codeFlowValue"),f(t)):(e.consume(t),g)}function v(n){return e.exit("codeFenced"),t(n)}}};const aq={name:"codeIndented",tokenize:function(e,t,n){const s=this;return function(t){return e.enter("codeIndented"),UW(e,i,"linePrefix",5)(t)};function i(e){const t=s.events[s.events.length-1];return t&&"linePrefix"===t[1].type&&t[2].sliceSerialize(t[1],!0).length>=4?a(e):n(e)}function a(t){return null===t?o(t):RW(t)?e.attempt(rq,a,o)(t):(e.enter("codeFlowValue"),r(t))}function r(t){return null===t||RW(t)?(e.exit("codeFlowValue"),a(t)):(e.consume(t),r)}function o(n){return e.exit("codeIndented"),t(n)}}},rq={partial:!0,tokenize:function(e,t,n){const s=this;return i;function i(t){return s.parser.lazy[s.now().line]?n(t):RW(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),i):UW(e,a,"linePrefix",5)(t)}function a(e){const a=s.events[s.events.length-1];return a&&"linePrefix"===a[1].type&&a[2].sliceSerialize(a[1],!0).length>=4?t(e):RW(e)?i(e):n(e)}}};const oq={name:"codeText",previous:function(e){return 96!==e||"characterEscape"===this.events[this.events.length-1][1].type},resolve:function(e){let t,n,s=e.length-4,i=3;if(!("lineEnding"!==e[i][1].type&&"space"!==e[i][1].type||"lineEnding"!==e[s][1].type&&"space"!==e[s][1].type))for(t=i;++t=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return ethis.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){const s=t||0;this.setCursor(Math.trunc(e));const i=this.right.splice(this.right.length-s,Number.POSITIVE_INFINITY);return n&&cq(this.left,n),i.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(e){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(e)}pushMany(e){this.setCursor(Number.POSITIVE_INFINITY),cq(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),cq(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&0===this.right.length||e<0&&0===this.left.length))if(e=4?t(i):e.interrupt(s.parser.constructs.flow,n,t)(i)}}};function hq(e,t,n,s,i,a,r,o,l){const c=l||Number.POSITIVE_INFINITY;let d=0;return function(t){if(60===t)return e.enter(s),e.enter(i),e.enter(a),e.consume(t),e.exit(a),u;if(null===t||32===t||41===t||MW(t))return n(t);return e.enter(s),e.enter(r),e.enter(o),e.enter("chunkString",{contentType:"string"}),h(t)};function u(n){return 62===n?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(s),t):(e.enter(o),e.enter("chunkString",{contentType:"string"}),p(n))}function p(t){return 62===t?(e.exit("chunkString"),e.exit(o),u(t)):null===t||60===t||RW(t)?n(t):(e.consume(t),92===t?m:p)}function m(t){return 60===t||62===t||92===t?(e.consume(t),p):p(t)}function h(i){return d||null!==i&&41!==i&&!OW(i)?d999||null===u||91===u||93===u&&!o||94===u&&!l&&"_hiddenFootnoteSupport"in r.parser.constructs?n(u):93===u?(e.exit(a),e.enter(i),e.consume(u),e.exit(i),e.exit(s),t):RW(u)?(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),c):(e.enter("chunkString",{contentType:"string"}),d(u))}function d(t){return null===t||91===t||93===t||RW(t)||l++>999?(e.exit("chunkString"),c(t)):(e.consume(t),o||(o=!zW(t)),92===t?u:d)}function u(t){return 91===t||92===t||93===t?(e.consume(t),l++,d):d(t)}}function fq(e,t,n,s,i,a){let r;return function(t){if(34===t||39===t||40===t)return e.enter(s),e.enter(i),e.consume(t),e.exit(i),r=40===t?41:t,o;return n(t)};function o(n){return n===r?(e.enter(i),e.consume(n),e.exit(i),e.exit(s),t):(e.enter(a),l(n))}function l(t){return t===r?(e.exit(a),o(r)):null===t?n(t):RW(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),UW(e,l,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),c(t))}function c(t){return t===r||null===t||RW(t)?(e.exit("chunkString"),l(t)):(e.consume(t),92===t?d:c)}function d(t){return t===r||92===t?(e.consume(t),c):c(t)}}function gq(e,t){let n;return function s(i){if(RW(i))return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,s;if(zW(i))return UW(e,s,n?"linePrefix":"lineSuffix")(i);return t(i)}}const vq={name:"definition",tokenize:function(e,t,n){const s=this;let i;return function(t){return e.enter("definition"),function(t){return xq.call(s,e,a,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(t)}(t)};function a(t){return i=EW(s.sliceSerialize(s.events[s.events.length-1][1]).slice(1,-1)),58===t?(e.enter("definitionMarker"),e.consume(t),e.exit("definitionMarker"),r):n(t)}function r(t){return OW(t)?gq(e,o)(t):o(t)}function o(t){return hq(e,l,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(t)}function l(t){return e.attempt(bq,c,c)(t)}function c(t){return zW(t)?UW(e,d,"whitespace")(t):d(t)}function d(a){return null===a||RW(a)?(e.exit("definition"),s.parser.defined.push(i),t(a)):n(a)}}},bq={partial:!0,tokenize:function(e,t,n){return function(t){return OW(t)?gq(e,s)(t):n(t)};function s(t){return fq(e,i,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(t)}function i(t){return zW(t)?UW(e,a,"whitespace")(t):a(t)}function a(e){return null===e||RW(e)?t(e):n(e)}}};const yq={name:"hardBreakEscape",tokenize:function(e,t,n){return function(t){return e.enter("hardBreakEscape"),e.consume(t),s};function s(s){return RW(s)?(e.exit("hardBreakEscape"),t(s)):n(s)}}};const wq={name:"headingAtx",resolve:function(e,t){let n,s,i=e.length-2,a=3;"whitespace"===e[a][1].type&&(a+=2);i-2>a&&"whitespace"===e[i][1].type&&(i-=2);"atxHeadingSequence"===e[i][1].type&&(a===i-1||i-4>a&&"whitespace"===e[i-2][1].type)&&(i-=a+1===i?2:4);i>a&&(n={type:"atxHeadingText",start:e[a][1].start,end:e[i][1].end},s={type:"chunkText",start:e[a][1].start,end:e[i][1].end,contentType:"text"},jW(e,a,i-a+1,[["enter",n,t],["enter",s,t],["exit",s,t],["exit",n,t]]));return e},tokenize:function(e,t,n){let s=0;return function(t){return e.enter("atxHeading"),function(t){return e.enter("atxHeadingSequence"),i(t)}(t)};function i(t){return 35===t&&s++<6?(e.consume(t),i):null===t||OW(t)?(e.exit("atxHeadingSequence"),a(t)):n(t)}function a(n){return 35===n?(e.enter("atxHeadingSequence"),r(n)):null===n||RW(n)?(e.exit("atxHeading"),t(n)):zW(n)?UW(e,a,"whitespace")(n):(e.enter("atxHeadingText"),o(n))}function r(t){return 35===t?(e.consume(t),r):(e.exit("atxHeadingSequence"),a(t))}function o(t){return null===t||35===t||OW(t)?(e.exit("atxHeadingText"),a(t)):(e.consume(t),o)}}};const jq=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],Cq=["pre","script","style","textarea"],Nq={concrete:!0,name:"htmlFlow",resolveTo:function(e){let t=e.length;for(;t--&&("enter"!==e[t][0]||"htmlFlow"!==e[t][1].type););t>1&&"linePrefix"===e[t-2][1].type&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2));return e},tokenize:function(e,t,n){const s=this;let i,a,r,o,l;return function(t){return function(t){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(t),c}(t)};function c(o){return 33===o?(e.consume(o),d):47===o?(e.consume(o),a=!0,m):63===o?(e.consume(o),i=3,s.interrupt?t:D):IW(o)?(e.consume(o),r=String.fromCharCode(o),h):n(o)}function d(a){return 45===a?(e.consume(a),i=2,u):91===a?(e.consume(a),i=5,o=0,p):IW(a)?(e.consume(a),i=4,s.interrupt?t:D):n(a)}function u(i){return 45===i?(e.consume(i),s.interrupt?t:D):n(i)}function p(i){const a="CDATA[";return i===a.charCodeAt(o++)?(e.consume(i),6===o?s.interrupt?t:_:p):n(i)}function m(t){return IW(t)?(e.consume(t),r=String.fromCharCode(t),h):n(t)}function h(o){if(null===o||47===o||62===o||OW(o)){const l=47===o,c=r.toLowerCase();return l||a||!Cq.includes(c)?jq.includes(r.toLowerCase())?(i=6,l?(e.consume(o),x):s.interrupt?t(o):_(o)):(i=7,s.interrupt&&!s.parser.lazy[s.now().line]?n(o):a?f(o):g(o)):(i=1,s.interrupt?t(o):_(o))}return 45===o||AW(o)?(e.consume(o),r+=String.fromCharCode(o),h):n(o)}function x(i){return 62===i?(e.consume(i),s.interrupt?t:_):n(i)}function f(t){return zW(t)?(e.consume(t),f):N(t)}function g(t){return 47===t?(e.consume(t),N):58===t||95===t||IW(t)?(e.consume(t),v):zW(t)?(e.consume(t),g):N(t)}function v(t){return 45===t||46===t||58===t||95===t||AW(t)?(e.consume(t),v):b(t)}function b(t){return 61===t?(e.consume(t),y):zW(t)?(e.consume(t),b):g(t)}function y(t){return null===t||60===t||61===t||62===t||96===t?n(t):34===t||39===t?(e.consume(t),l=t,w):zW(t)?(e.consume(t),y):j(t)}function w(t){return t===l?(e.consume(t),l=null,C):null===t||RW(t)?n(t):(e.consume(t),w)}function j(t){return null===t||34===t||39===t||47===t||60===t||61===t||62===t||96===t||OW(t)?b(t):(e.consume(t),j)}function C(e){return 47===e||62===e||zW(e)?g(e):n(e)}function N(t){return 62===t?(e.consume(t),F):n(t)}function F(t){return null===t||RW(t)?_(t):zW(t)?(e.consume(t),F):n(t)}function _(t){return 45===t&&2===i?(e.consume(t),I):60===t&&1===i?(e.consume(t),A):62===t&&4===i?(e.consume(t),L):63===t&&3===i?(e.consume(t),D):93===t&&5===i?(e.consume(t),M):!RW(t)||6!==i&&7!==i?null===t||RW(t)?(e.exit("htmlFlowData"),k(t)):(e.consume(t),_):(e.exit("htmlFlowData"),e.check(Fq,P,k)(t))}function k(t){return e.check(_q,S,P)(t)}function S(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),E}function E(t){return null===t||RW(t)?k(t):(e.enter("htmlFlowData"),_(t))}function I(t){return 45===t?(e.consume(t),D):_(t)}function A(t){return 47===t?(e.consume(t),r="",T):_(t)}function T(t){if(62===t){const n=r.toLowerCase();return Cq.includes(n)?(e.consume(t),L):_(t)}return IW(t)&&r.length<8?(e.consume(t),r+=String.fromCharCode(t),T):_(t)}function M(t){return 93===t?(e.consume(t),D):_(t)}function D(t){return 62===t?(e.consume(t),L):45===t&&2===i?(e.consume(t),D):_(t)}function L(t){return null===t||RW(t)?(e.exit("htmlFlowData"),P(t)):(e.consume(t),L)}function P(n){return e.exit("htmlFlow"),t(n)}}},Fq={partial:!0,tokenize:function(e,t,n){return function(s){return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),e.attempt(XW,t,n)}}},_q={partial:!0,tokenize:function(e,t,n){const s=this;return function(t){if(RW(t))return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),i;return n(t)};function i(e){return s.parser.lazy[s.now().line]?n(e):t(e)}}};const kq={name:"htmlText",tokenize:function(e,t,n){const s=this;let i,a,r;return function(t){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(t),o};function o(t){return 33===t?(e.consume(t),l):47===t?(e.consume(t),y):63===t?(e.consume(t),v):IW(t)?(e.consume(t),C):n(t)}function l(t){return 45===t?(e.consume(t),c):91===t?(e.consume(t),a=0,m):IW(t)?(e.consume(t),g):n(t)}function c(t){return 45===t?(e.consume(t),p):n(t)}function d(t){return null===t?n(t):45===t?(e.consume(t),u):RW(t)?(r=d,T(t)):(e.consume(t),d)}function u(t){return 45===t?(e.consume(t),p):d(t)}function p(e){return 62===e?A(e):45===e?u(e):d(e)}function m(t){const s="CDATA[";return t===s.charCodeAt(a++)?(e.consume(t),6===a?h:m):n(t)}function h(t){return null===t?n(t):93===t?(e.consume(t),x):RW(t)?(r=h,T(t)):(e.consume(t),h)}function x(t){return 93===t?(e.consume(t),f):h(t)}function f(t){return 62===t?A(t):93===t?(e.consume(t),f):h(t)}function g(t){return null===t||62===t?A(t):RW(t)?(r=g,T(t)):(e.consume(t),g)}function v(t){return null===t?n(t):63===t?(e.consume(t),b):RW(t)?(r=v,T(t)):(e.consume(t),v)}function b(e){return 62===e?A(e):v(e)}function y(t){return IW(t)?(e.consume(t),w):n(t)}function w(t){return 45===t||AW(t)?(e.consume(t),w):j(t)}function j(t){return RW(t)?(r=j,T(t)):zW(t)?(e.consume(t),j):A(t)}function C(t){return 45===t||AW(t)?(e.consume(t),C):47===t||62===t||OW(t)?N(t):n(t)}function N(t){return 47===t?(e.consume(t),A):58===t||95===t||IW(t)?(e.consume(t),F):RW(t)?(r=N,T(t)):zW(t)?(e.consume(t),N):A(t)}function F(t){return 45===t||46===t||58===t||95===t||AW(t)?(e.consume(t),F):_(t)}function _(t){return 61===t?(e.consume(t),k):RW(t)?(r=_,T(t)):zW(t)?(e.consume(t),_):N(t)}function k(t){return null===t||60===t||61===t||62===t||96===t?n(t):34===t||39===t?(e.consume(t),i=t,S):RW(t)?(r=k,T(t)):zW(t)?(e.consume(t),k):(e.consume(t),E)}function S(t){return t===i?(e.consume(t),i=void 0,I):null===t?n(t):RW(t)?(r=S,T(t)):(e.consume(t),S)}function E(t){return null===t||34===t||39===t||60===t||61===t||96===t?n(t):47===t||62===t||OW(t)?N(t):(e.consume(t),E)}function I(e){return 47===e||62===e||OW(e)?N(e):n(e)}function A(s){return 62===s?(e.consume(s),e.exit("htmlTextData"),e.exit("htmlText"),t):n(s)}function T(t){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),M}function M(t){return zW(t)?UW(e,D,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):D(t)}function D(t){return e.enter("htmlTextData"),r(t)}}};const Sq={name:"labelEnd",resolveAll:function(e){let t=-1;const n=[];for(;++t=3&&(null===a||RW(a))?(e.exit("thematicBreak"),t(a)):n(a)}function r(t){return t===s?(e.consume(t),i++,r):(e.exit("thematicBreakSequence"),zW(t)?UW(e,a,"whitespace")(t):a(t))}}};const Pq={continuation:{tokenize:function(e,t,n){const s=this;return s.containerState._closeFlow=void 0,e.check(XW,function(n){return s.containerState.furtherBlankLines=s.containerState.furtherBlankLines||s.containerState.initialBlankLine,UW(e,t,"listItemIndent",s.containerState.size+1)(n)},function(n){if(s.containerState.furtherBlankLines||!zW(n))return s.containerState.furtherBlankLines=void 0,s.containerState.initialBlankLine=void 0,i(n);return s.containerState.furtherBlankLines=void 0,s.containerState.initialBlankLine=void 0,e.attempt(Oq,t,i)(n)});function i(i){return s.containerState._closeFlow=!0,s.interrupt=void 0,UW(e,e.attempt(Pq,t,n),"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(i)}}},exit:function(e){e.exit(this.containerState.type)},name:"list",tokenize:function(e,t,n){const s=this,i=s.events[s.events.length-1];let a=i&&"linePrefix"===i[1].type?i[2].sliceSerialize(i[1],!0).length:0,r=0;return function(t){const i=s.containerState.type||(42===t||43===t||45===t?"listUnordered":"listOrdered");if("listUnordered"===i?!s.containerState.marker||t===s.containerState.marker:DW(t)){if(s.containerState.type||(s.containerState.type=i,e.enter(i,{_container:!0})),"listUnordered"===i)return e.enter("listItemPrefix"),42===t||45===t?e.check(Lq,n,l)(t):l(t);if(!s.interrupt||49===t)return e.enter("listItemPrefix"),e.enter("listItemValue"),o(t)}return n(t)};function o(t){return DW(t)&&++r<10?(e.consume(t),o):(!s.interrupt||r<2)&&(s.containerState.marker?t===s.containerState.marker:41===t||46===t)?(e.exit("listItemValue"),l(t)):n(t)}function l(t){return e.enter("listItemMarker"),e.consume(t),e.exit("listItemMarker"),s.containerState.marker=s.containerState.marker||t,e.check(XW,s.interrupt?n:c,e.attempt(Rq,u,d))}function c(e){return s.containerState.initialBlankLine=!0,a++,u(e)}function d(t){return zW(t)?(e.enter("listItemPrefixWhitespace"),e.consume(t),e.exit("listItemPrefixWhitespace"),u):n(t)}function u(n){return s.containerState.size=a+s.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(n)}}},Rq={partial:!0,tokenize:function(e,t,n){const s=this;return UW(e,function(e){const i=s.events[s.events.length-1];return!zW(e)&&i&&"listItemPrefixWhitespace"===i[1].type?t(e):n(e)},"listItemPrefixWhitespace",s.parser.constructs.disable.null.includes("codeIndented")?void 0:5)}},Oq={partial:!0,tokenize:function(e,t,n){const s=this;return UW(e,function(e){const i=s.events[s.events.length-1];return i&&"listItemIndent"===i[1].type&&i[2].sliceSerialize(i[1],!0).length===s.containerState.size?t(e):n(e)},"listItemIndent",s.containerState.size+1)}};const zq={name:"setextUnderline",resolveTo:function(e,t){let n,s,i,a=e.length;for(;a--;)if("enter"===e[a][0]){if("content"===e[a][1].type){n=a;break}"paragraph"===e[a][1].type&&(s=a)}else"content"===e[a][1].type&&e.splice(a,1),i||"definition"!==e[a][1].type||(i=a);const r={type:"setextHeading",start:{...e[n][1].start},end:{...e[e.length-1][1].end}};e[s][1].type="setextHeadingText",i?(e.splice(s,0,["enter",r,t]),e.splice(i+1,0,["exit",e[n][1],t]),e[n][1].end={...e[i][1].end}):e[n][1]=r;return e.push(["exit",r,t]),e},tokenize:function(e,t,n){const s=this;let i;return function(t){let r,o=s.events.length;for(;o--;)if("lineEnding"!==s.events[o][1].type&&"linePrefix"!==s.events[o][1].type&&"content"!==s.events[o][1].type){r="paragraph"===s.events[o][1].type;break}if(!s.parser.lazy[s.now().line]&&(s.interrupt||r))return e.enter("setextHeadingLine"),i=t,function(t){return e.enter("setextHeadingLineSequence"),a(t)}(t);return n(t)};function a(t){return t===i?(e.consume(t),a):(e.exit("setextHeadingLineSequence"),zW(t)?UW(e,r,"lineSuffix")(t):r(t))}function r(s){return null===s||RW(s)?(e.exit("setextHeadingLine"),t(s)):n(s)}}};const Bq={tokenize:function(e){const t=this,n=e.attempt(XW,function(s){if(null===s)return void e.consume(s);return e.enter("lineEndingBlank"),e.consume(s),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n},e.attempt(this.parser.constructs.flowInitial,s,UW(e,e.attempt(this.parser.constructs.flow,s,e.attempt(pq,s)),"linePrefix")));return n;function s(s){if(null!==s)return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),t.currentConstruct=void 0,n;e.consume(s)}}};const Hq={resolveAll:Wq()},$q=Uq("string"),Vq=Uq("text");function Uq(e){return{resolveAll:Wq("text"===e?qq:void 0),tokenize:function(t){const n=this,s=this.parser.constructs[e],i=t.attempt(s,a,r);return a;function a(e){return l(e)?i(e):r(e)}function r(e){if(null!==e)return t.enter("data"),t.consume(e),o;t.consume(e)}function o(e){return l(e)?(t.exit("data"),i(e)):(t.consume(e),o)}function l(e){if(null===e)return!0;const t=s[e];let i=-1;if(t)for(;++i-1){const e=r[0];"string"==typeof e?r[0]=e.slice(s):r.shift()}a>0&&r.push(e[i].slice(0,a))}return r}(r,e)}function p(){const{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=s;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function m(){let e;for(;s._index0){const e=a.tokenStack[a.tokenStack.length-1];(e[1]||dG).call(a,void 0,e[0])}for(s.position={start:oG(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:oG(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},u=-1;++u1:t}function hG(e){const t=String(e),n=/\r?\n|\r/g;let s=n.exec(t),i=0;const a=[];for(;s;)a.push(xG(t.slice(i,s.index),i>0,!0),s[0]),i=s.index+s[0].length,s=n.exec(t);return a.push(xG(t.slice(i),i>0,!1)),a.join("")}function xG(e,t,n){let s=0,i=e.length;if(t){let t=e.codePointAt(s);for(;9===t||32===t;)s++,t=e.codePointAt(s)}if(n){let t=e.codePointAt(i-1);for(;9===t||32===t;)i--,t=e.codePointAt(i-1)}return i>s?e.slice(s,i):""}const fG={blockquote:function(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)},break:function(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:"\n"}]},code:function(e,t){const n=t.value?t.value+"\n":"",s={};t.lang&&(s.className=["language-"+t.lang]);let i={type:"element",tagName:"code",properties:s,children:[{type:"text",value:n}]};return t.meta&&(i.data={meta:t.meta}),e.patch(t,i),i=e.applyData(t,i),i={type:"element",tagName:"pre",properties:{},children:[i]},e.patch(t,i),i},delete:function(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},emphasis:function(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},footnoteReference:function(e,t){const n="string"==typeof e.options.clobberPrefix?e.options.clobberPrefix:"user-content-",s=String(t.identifier).toUpperCase(),i=VW(s.toLowerCase()),a=e.footnoteOrder.indexOf(s);let r,o=e.footnoteCounts.get(s);void 0===o?(o=0,e.footnoteOrder.push(s),r=e.footnoteOrder.length):r=a+1,o+=1,e.footnoteCounts.set(s,o);const l={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+i,id:n+"fnref-"+i+(o>1?"-"+o:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(r)}]};e.patch(t,l);const c={type:"element",tagName:"sup",properties:{},children:[l]};return e.patch(t,c),e.applyData(t,c)},heading:function(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},html:function(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}},imageReference:function(e,t){const n=String(t.identifier).toUpperCase(),s=e.definitionById.get(n);if(!s)return pG(e,t);const i={src:VW(s.url||""),alt:t.alt};null!==s.title&&void 0!==s.title&&(i.title=s.title);const a={type:"element",tagName:"img",properties:i,children:[]};return e.patch(t,a),e.applyData(t,a)},image:function(e,t){const n={src:VW(t.url)};null!==t.alt&&void 0!==t.alt&&(n.alt=t.alt),null!==t.title&&void 0!==t.title&&(n.title=t.title);const s={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,s),e.applyData(t,s)},inlineCode:function(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const s={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,s),e.applyData(t,s)},linkReference:function(e,t){const n=String(t.identifier).toUpperCase(),s=e.definitionById.get(n);if(!s)return pG(e,t);const i={href:VW(s.url||"")};null!==s.title&&void 0!==s.title&&(i.title=s.title);const a={type:"element",tagName:"a",properties:i,children:e.all(t)};return e.patch(t,a),e.applyData(t,a)},link:function(e,t){const n={href:VW(t.url)};null!==t.title&&void 0!==t.title&&(n.title=t.title);const s={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,s),e.applyData(t,s)},listItem:function(e,t,n){const s=e.all(t),i=n?function(e){let t=!1;if("list"===e.type){t=e.spread||!1;const n=e.children;let s=-1;for(;!t&&++s0&&n.children.unshift({type:"text",value:" "}),n.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),a.className=["task-list-item"]}let o=-1;for(;++o0){const s={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},a=qU(t.children[1]),r=WU(t.children[t.children.length-1]);a&&r&&(s.position={start:a,end:r}),i.push(s)}const a={type:"element",tagName:"table",properties:{},children:e.wrap(i,!0)};return e.patch(t,a),e.applyData(t,a)},tableCell:function(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},tableRow:function(e,t,n){const s=n?n.children:void 0,i=0===(s?s.indexOf(t):1)?"th":"td",a=n&&"table"===n.type?n.align:void 0,r=a?a.length:t.children.length;let o=-1;const l=[];for(;++o((e,t)=>{const n=(t,n)=>(e.set(n,t),t),s=i=>{if(e.has(i))return e.get(i);const[a,r]=t[i];switch(a){case 0:case-1:return n(r,i);case 1:{const e=n([],i);for(const t of r)e.push(s(t));return e}case 2:{const e=n({},i);for(const[t,n]of r)e[s(t)]=s(n);return e}case 3:return n(new Date(r),i);case 4:{const{source:e,flags:t}=r;return n(new RegExp(e,t),i)}case 5:{const e=n(new Map,i);for(const[t,n]of r)e.set(s(t),s(n));return e}case 6:{const e=n(new Set,i);for(const t of r)e.add(s(t));return e}case 7:{const{name:e,message:t}=r;return n(new vG[e](t),i)}case 8:return n(BigInt(r),i);case"BigInt":return n(Object(BigInt(r)),i);case"ArrayBuffer":return n(new Uint8Array(r).buffer,r);case"DataView":{const{buffer:e}=new Uint8Array(r);return n(new DataView(e),r)}}return n(new vG[a](r),i)};return s})(new Map,e)(0),yG="",{toString:wG}={},{keys:jG}=Object,CG=e=>{const t=typeof e;if("object"!==t||!e)return[0,t];const n=wG.call(e).slice(8,-1);switch(n){case"Array":return[1,yG];case"Object":return[2,yG];case"Date":return[3,yG];case"RegExp":return[4,yG];case"Map":return[5,yG];case"Set":return[6,yG];case"DataView":return[1,n]}return n.includes("Array")?[1,n]:n.includes("Error")?[7,n]:[2,n]},NG=([e,t])=>0===e&&("function"===t||"symbol"===t),FG=(e,{json:t,lossy:n}={})=>{const s=[];return((e,t,n,s)=>{const i=(e,t)=>{const i=s.push(e)-1;return n.set(t,i),i},a=s=>{if(n.has(s))return n.get(s);let[r,o]=CG(s);switch(r){case 0:{let t=s;switch(o){case"bigint":r=8,t=s.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+o);t=null;break;case"undefined":return i([-1],s)}return i([r,t],s)}case 1:{if(o){let e=s;return"DataView"===o?e=new Uint8Array(s.buffer):"ArrayBuffer"===o&&(e=new Uint8Array(s)),i([o,[...e]],s)}const e=[],t=i([r,e],s);for(const n of s)e.push(a(n));return t}case 2:{if(o)switch(o){case"BigInt":return i([o,s.toString()],s);case"Boolean":case"Number":case"String":return i([o,s.valueOf()],s)}if(t&&"toJSON"in s)return a(s.toJSON());const n=[],l=i([r,n],s);for(const t of jG(s))!e&&NG(CG(s[t]))||n.push([a(t),a(s[t])]);return l}case 3:return i([r,s.toISOString()],s);case 4:{const{source:e,flags:t}=s;return i([r,{source:e,flags:t}],s)}case 5:{const t=[],n=i([r,t],s);for(const[i,r]of s)(e||!NG(CG(i))&&!NG(CG(r)))&&t.push([a(i),a(r)]);return n}case 6:{const t=[],n=i([r,t],s);for(const i of s)!e&&NG(CG(i))||t.push(a(i));return n}}const{message:l}=s;return i([r,{name:o,message:l}],s)};return a})(!(t||n),!!t,new Map,s)(e),s},_G="function"==typeof structuredClone?(e,t)=>t&&("json"in t||"lossy"in t)?bG(FG(e,t)):structuredClone(e):(e,t)=>bG(FG(e,t));function kG(e,t){const n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function SG(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}const EG=function(e){if(null==e)return AG;if("function"==typeof e)return IG(e);if("object"==typeof e)return Array.isArray(e)?function(e){const t=[];let n=-1;for(;++n":"")+")"})}return d;function d(){let c,d,u,p=TG;if((!t||a(i,o,l[l.length-1]||void 0))&&(p=function(e){if(Array.isArray(e))return e;if("number"==typeof e)return[MG,e];return null==e?TG:[e]}(n(i,l)),p[0]===DG))return p;if("children"in i&&i.children){const t=i;if(t.children&&"skip"!==p[0])for(d=(s?t.children.length:-1)+r,u=l.concat(t);d>-1&&d0&&n.push({type:"text",value:"\n"}),n}function VG(e){let t=0,n=e.charCodeAt(t);for(;9===n||32===n;)t++,n=e.charCodeAt(t);return e.slice(t)}function UG(e,t){const n=function(e,t){const n=t||OG,s=new Map,i=new Map,a=new Map,r={...fG,...n.handlers},o={all:function(e){const t=[];if("children"in e){const n=e.children;let s=-1;for(;++s0&&u.push({type:"text",value:" "});let e="string"==typeof n?n:n(l,d);"string"==typeof e&&(e={type:"text",value:e}),u.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+c+(d>1?"-"+d:""),dataFootnoteBackref:"",ariaLabel:"string"==typeof s?s:s(l,d),className:["data-footnote-backref"]},children:Array.isArray(e)?e:[e]})}const m=a[a.length-1];if(m&&"element"===m.type&&"p"===m.tagName){const e=m.children[m.children.length-1];e&&"text"===e.type?e.value+=" ":m.children.push({type:"text",value:" "}),m.children.push(...u)}else a.push(...u);const h={type:"element",tagName:"li",properties:{id:t+"fn-"+c},children:e.wrap(a,!0)};e.patch(i,h),o.push(h)}if(0!==o.length)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:a,properties:{..._G(r),id:"footnote-label"},children:[{type:"text",value:i}]},{type:"text",value:"\n"},{type:"element",tagName:"ol",properties:{},children:e.wrap(o,!0)},{type:"text",value:"\n"}]}}(n),a=Array.isArray(s)?{type:"root",children:s}:s||{type:"root",children:[]};return i&&a.children.push({type:"text",value:"\n"},i),a}function WG(e,t){return e&&"run"in e?async function(n,s){const i=UG(n,{file:s,...t});await e.run(i,s)}:function(n,s){return UG(n,{file:s,...e||t})}}function qG(e){if(e)throw e}var GG,ZG;const YG=Le(function(){if(ZG)return GG;ZG=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,s=Object.getOwnPropertyDescriptor,i=function(e){return"function"==typeof Array.isArray?Array.isArray(e):"[object Array]"===t.call(e)},a=function(n){if(!n||"[object Object]"!==t.call(n))return!1;var s,i=e.call(n,"constructor"),a=n.constructor&&n.constructor.prototype&&e.call(n.constructor.prototype,"isPrototypeOf");if(n.constructor&&!i&&!a)return!1;for(s in n);return void 0===s||e.call(n,s)},r=function(e,t){n&&"__proto__"===t.name?n(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},o=function(t,n){if("__proto__"===n){if(!e.call(t,n))return;if(s)return s(t,n).value}return t[n]};return GG=function e(){var t,n,s,l,c,d,u=arguments[0],p=1,m=arguments.length,h=!1;for("boolean"==typeof u&&(h=u,u=arguments[1]||{},p=2),(null==u||"object"!=typeof u&&"function"!=typeof u)&&(u={});pt.length;let o;s&&t.push(i);try{o=e.apply(this,t)}catch(a){if(s&&n)throw a;return i(a)}s||(o&&o.then&&"function"==typeof o.then?o.then(r,i):o instanceof Error?i(o):r(o))}function i(e,...s){n||(n=!0,t(e,...s))}function r(e){i(null,e)}}(o,i)(...r):s(null,...r)}}(null,...t)},use:function(n){if("function"!=typeof n)throw new TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}};return t}const QG={basename:function(e,t){if(void 0!==t&&"string"!=typeof t)throw new TypeError('"ext" argument must be a string');XG(e);let n,s=0,i=-1,a=e.length;if(void 0===t||0===t.length||t.length>e.length){for(;a--;)if(47===e.codePointAt(a)){if(n){s=a+1;break}}else i<0&&(n=!0,i=a+1);return i<0?"":e.slice(s,i)}if(t===e)return"";let r=-1,o=t.length-1;for(;a--;)if(47===e.codePointAt(a)){if(n){s=a+1;break}}else r<0&&(n=!0,r=a+1),o>-1&&(e.codePointAt(a)===t.codePointAt(o--)?o<0&&(i=a):(o=-1,i=r));s===i?i=r:i<0&&(i=e.length);return e.slice(s,i)},dirname:function(e){if(XG(e),0===e.length)return".";let t,n=-1,s=e.length;for(;--s;)if(47===e.codePointAt(s)){if(t){n=s;break}}else t||(t=!0);return n<0?47===e.codePointAt(0)?"/":".":1===n&&47===e.codePointAt(0)?"//":e.slice(0,n)},extname:function(e){XG(e);let t,n=e.length,s=-1,i=0,a=-1,r=0;for(;n--;){const o=e.codePointAt(n);if(47!==o)s<0&&(t=!0,s=n+1),46===o?a<0?a=n:1!==r&&(r=1):a>-1&&(r=-1);else if(t){i=n+1;break}}if(a<0||s<0||0===r||1===r&&a===s-1&&a===i+1)return"";return e.slice(a,s)},join:function(...e){let t,n=-1;for(;++n2){if(s=i.lastIndexOf("/"),s!==i.length-1){s<0?(i="",a=0):(i=i.slice(0,s),a=i.length-1-i.lastIndexOf("/")),r=l,o=0;continue}}else if(i.length>0){i="",a=0,r=l,o=0;continue}t&&(i=i.length>0?i+"/..":"..",a=2)}else i.length>0?i+="/"+e.slice(r+1,l):i=e.slice(r+1,l),a=l-r-1;r=l,o=0}else 46===n&&o>-1?o++:o=-1}return i}(e,!t);0!==n.length||t||(n=".");n.length>0&&47===e.codePointAt(e.length-1)&&(n+="/");return t?"/"+n:n}(t)},sep:"/"};function XG(e){if("string"!=typeof e)throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const eZ={cwd:function(){return"/"}};function tZ(e){return Boolean(null!==e&&"object"==typeof e&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&void 0===e.auth)}function nZ(e){if("string"==typeof e)e=new URL(e);else if(!tZ(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if("file:"!==e.protocol){const e=new TypeError("The URL must be of scheme file");throw e.code="ERR_INVALID_URL_SCHEME",e}return function(e){if(""!==e.hostname){const e=new TypeError('File URL host must be "localhost" or empty on darwin');throw e.code="ERR_INVALID_FILE_URL_HOST",e}const t=e.pathname;let n=-1;for(;++n0){let[s,...a]=t;const r=n[i][1];KG(r)&&KG(s)&&(s=YG(!0,r,s)),n[i]=[e,s,...a]}}}}const uZ=(new dZ).freeze();function pZ(e,t){if("function"!=typeof t)throw new TypeError("Cannot `"+e+"` without `parser`")}function mZ(e,t){if("function"!=typeof t)throw new TypeError("Cannot `"+e+"` without `compiler`")}function hZ(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function xZ(e){if(!KG(e)||"string"!=typeof e.type)throw new TypeError("Expected node, got `"+e+"`")}function fZ(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function gZ(e){return function(e){return Boolean(e&&"object"==typeof e&&"message"in e&&"messages"in e)}(e)?e:new iZ(e)}const vZ=[],bZ={allowDangerousHtml:!0},yZ=/^(https?|ircs?|mailto|xmpp)$/i,wZ=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function jZ(e){const t=function(e){const t=e.rehypePlugins||vZ,n=e.remarkPlugins||vZ,s=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...bZ}:bZ,i=uZ().use(uG).use(n).use(WG,s).use(t);return i}(e),n=function(e){const t=e.children||"",n=new iZ;"string"==typeof t&&(n.value=t);return n}(e);return function(e,t){const n=t.allowedElements,s=t.allowElement,i=t.components,r=t.disallowedElements,o=t.skipHtml,l=t.unwrapDisallowed,c=t.urlTransform||CZ;for(const a of wZ)Object.hasOwn(t,a.from)&&GV((a.from,a.to&&a.to,a.id));t.className&&(e={type:"element",tagName:"div",properties:{className:t.className},children:"root"===e.type?e.children:[e]});return PG(e,d),aW(e,{Fragment:a.Fragment,components:i,ignoreInvalidStyle:!0,jsx:a.jsx,jsxs:a.jsxs,passKeys:!0,passNode:!0});function d(e,t,i){if("raw"===e.type&&i&&"number"==typeof t)return o?i.children.splice(t,1):i.children[t]={type:"text",value:e.value},t;if("element"===e.type){let t;for(t in xW)if(Object.hasOwn(xW,t)&&Object.hasOwn(e.properties,t)){const n=e.properties[t],s=xW[t];(null===s||s.includes(e.tagName))&&(e.properties[t]=c(String(n||""),t,e))}}if("element"===e.type){let a=n?!n.includes(e.tagName):!!r&&r.includes(e.tagName);if(!a&&s&&"number"==typeof t&&(a=!s(e,t,i)),a&&i&&"number"==typeof t)return l&&e.children?i.children.splice(t,1,...e.children):i.children.splice(t,1),t}}}(t.runSync(t.parse(n),n),e)}function CZ(e){const t=e.indexOf(":"),n=e.indexOf("?"),s=e.indexOf("#"),i=e.indexOf("/");return-1===t||-1!==i&&t>i||-1!==n&&t>n||-1!==s&&t>s||yZ.test(e.slice(0,t))?e:""}function NZ(e,t){const n=String(e);if("string"!=typeof t)throw new TypeError("Expected character");let s=0,i=n.indexOf(t);for(;-1!==i;)s++,i=n.indexOf(t,i+t.length);return s}function FZ(e,t,n){const s=EG((n||{}).ignore||[]),i=function(e){const t=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const n=!e[0]||Array.isArray(e[0])?e:[e];let s=-1;for(;++s0?{type:"text",value:a}:void 0),!1===a?s.lastIndex=n+1:(o!==n&&d.push({type:"text",value:e.value.slice(o,n)}),Array.isArray(a)?d.push(...a):a&&d.push(a),o=n+u[0].length,c=!0),!s.global)break;u=s.exec(e.value)}c?(o?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],s=n.indexOf(")");const i=NZ(e,"(");let a=NZ(e,")");for(;-1!==s&&i>a;)e+=n.slice(0,s+1),n=n.slice(s+1),s=n.indexOf(")"),a++;return[e,n]}(n+s);if(!r[0])return!1;const o={type:"link",title:null,url:a+t+r[0],children:[{type:"text",value:t+r[0]}]};return r[1]?[o,{type:"text",value:r[1]}]:o}function OZ(e,t,n,s){return!(!zZ(s,!0)||/[-\d_]$/.test(n))&&{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function zZ(e,t){const n=e.input.charCodeAt(e.index-1);return(0===e.index||HW(n)||BW(n))&&(!t||47!==n)}function BZ(){this.buffer()}function HZ(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function $Z(){this.buffer()}function VZ(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function UZ(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=EW(this.sliceSerialize(e)).toLowerCase(),n.label=t}function WZ(e){this.exit(e)}function qZ(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=EW(this.sliceSerialize(e)).toLowerCase(),n.label=t}function GZ(e){this.exit(e)}function ZZ(e,t,n,s){const i=n.createTracker(s);let a=i.move("[^");const r=n.enter("footnoteReference"),o=n.enter("reference");return a+=i.move(n.safe(n.associationId(e),{after:"]",before:a})),o(),r(),a+=i.move("]"),a}function YZ(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:function(e,n,s,i){const a=s.createTracker(i);let r=a.move("[^");const o=s.enter("footnoteDefinition"),l=s.enter("label");r+=a.move(s.safe(s.associationId(e),{before:r,after:"]"})),l(),r+=a.move("]:"),e.children&&e.children.length>0&&(a.shift(4),r+=a.move((t?"\n":" ")+s.indentLines(s.containerFlow(e,a.current()),t?JZ:KZ)));return o(),r},footnoteReference:ZZ},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]}}function KZ(e,t,n){return 0===t?e:JZ(e,t,n)}function JZ(e,t,n){return(n?"":" ")+e}ZZ.peek=function(){return"["};const QZ=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];function XZ(e){this.enter({type:"delete",children:[]},e)}function eY(e){this.exit(e)}function tY(e,t,n,s){const i=n.createTracker(s),a=n.enter("strikethrough");let r=i.move("~~");return r+=n.containerPhrasing(e,{...i.current(),before:r,after:"~"}),r+=i.move("~~"),a(),r}function nY(e){return e.length}function sY(e){return null==e?"":String(e)}function iY(e){const t="string"==typeof e?e.codePointAt(0):0;return 67===t||99===t?99:76===t||108===t?108:82===t||114===t?114:0}function aY(e,t,n){return">"+(n?"":" ")+e}function rY(e,t){return oY(e,t.inConstruct,!0)&&!oY(e,t.notInConstruct,!1)}function oY(e,t,n){if("string"==typeof t&&(t=[t]),!t||0===t.length)return n;let s=-1;for(;++s",...l.current()})),c+=l.move(">")):(o=n.enter("destinationRaw"),c+=l.move(n.safe(e.url,{before:c,after:e.title?" ":")",...l.current()}))),o(),e.title&&(o=n.enter(`title${a}`),c+=l.move(" "+i),c+=l.move(n.safe(e.title,{before:c,after:i,...l.current()})),c+=l.move(i),o()),c+=l.move(")"),r(),c}function fY(e,t,n,s){const i=e.referenceType,a=n.enter("imageReference");let r=n.enter("label");const o=n.createTracker(s);let l=o.move("![");const c=n.safe(e.alt,{before:l,after:"]",...o.current()});l+=o.move(c+"]["),r();const d=n.stack;n.stack=[],r=n.enter("reference");const u=n.safe(n.associationId(e),{before:l,after:"]",...o.current()});return r(),n.stack=d,a(),"full"!==i&&c&&c===u?"shortcut"===i?l=l.slice(0,-1):l+=o.move("]"):l+=o.move(u+"]"),l}function gY(e,t,n){let s=e.value||"",i="`",a=-1;for(;new RegExp("(^|[^`])"+i+"([^`]|$)").test(s);)i+="`";for(/[^ \r\n]/.test(s)&&(/^[ \r\n]/.test(s)&&/[ \r\n]$/.test(s)||/^`|`$/.test(s))&&(s=" "+s+" ");++a\u007F]/.test(e.url))}function bY(e,t,n,s){const i=dY(n),a='"'===i?"Quote":"Apostrophe",r=n.createTracker(s);let o,l;if(vY(e,n)){const t=n.stack;n.stack=[],o=n.enter("autolink");let s=r.move("<");return s+=r.move(n.containerPhrasing(e,{before:s,after:">",...r.current()})),s+=r.move(">"),o(),n.stack=t,s}o=n.enter("link"),l=n.enter("label");let c=r.move("[");return c+=r.move(n.containerPhrasing(e,{before:c,after:"](",...r.current()})),c+=r.move("]("),l(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(l=n.enter("destinationLiteral"),c+=r.move("<"),c+=r.move(n.safe(e.url,{before:c,after:">",...r.current()})),c+=r.move(">")):(l=n.enter("destinationRaw"),c+=r.move(n.safe(e.url,{before:c,after:e.title?" ":")",...r.current()}))),l(),e.title&&(l=n.enter(`title${a}`),c+=r.move(" "+i),c+=r.move(n.safe(e.title,{before:c,after:i,...r.current()})),c+=r.move(i),l()),c+=r.move(")"),o(),c}function yY(e,t,n,s){const i=e.referenceType,a=n.enter("linkReference");let r=n.enter("label");const o=n.createTracker(s);let l=o.move("[");const c=n.containerPhrasing(e,{before:l,after:"]",...o.current()});l+=o.move(c+"]["),r();const d=n.stack;n.stack=[],r=n.enter("reference");const u=n.safe(n.associationId(e),{before:l,after:"]",...o.current()});return r(),n.stack=d,a(),"full"!==i&&c&&c===u?"shortcut"===i?l=l.slice(0,-1):l+=o.move("]"):l+=o.move(u+"]"),l}function wY(e){const t=e.options.bullet||"*";if("*"!==t&&"+"!==t&&"-"!==t)throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function jY(e){const t=e.options.rule||"*";if("*"!==t&&"-"!==t&&"_"!==t)throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}tY.peek=function(){return"~"},mY.peek=function(e,t,n){return n.options.emphasis||"*"},hY.peek=function(){return"<"},xY.peek=function(){return"!"},fY.peek=function(){return"!"},gY.peek=function(){return"`"},bY.peek=function(e,t,n){return vY(e,n)?"<":"["},yY.peek=function(){return"["};const CY=EG(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function NY(e,t,n,s){const i=function(e){const t=e.options.strong||"*";if("*"!==t&&"_"!==t)throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}(n),a=n.enter("strong"),r=n.createTracker(s),o=r.move(i+i);let l=r.move(n.containerPhrasing(e,{after:i,before:o,...r.current()}));const c=l.charCodeAt(0),d=pY(s.before.charCodeAt(s.before.length-1),c,i);d.inside&&(l=uY(c)+l.slice(1));const u=l.charCodeAt(l.length-1),p=pY(s.after.charCodeAt(0),u,i);p.inside&&(l=l.slice(0,-1)+uY(u));const m=r.move(i+i);return a(),n.attentionEncodeSurroundingInfo={after:p.outside,before:d.outside},o+l+m}NY.peek=function(e,t,n){return n.options.strong||"*"};const FY={blockquote:function(e,t,n,s){const i=n.enter("blockquote"),a=n.createTracker(s);a.move("> "),a.shift(2);const r=n.indentLines(n.containerFlow(e,a.current()),aY);return i(),r},break:lY,code:function(e,t,n,s){const i=function(e){const t=e.options.fence||"`";if("`"!==t&&"~"!==t)throw new Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}(n),a=e.value||"",r="`"===i?"GraveAccent":"Tilde";if(function(e,t){return Boolean(!1===t.options.fences&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}(e,n)){const e=n.enter("codeIndented"),t=n.indentLines(a,cY);return e(),t}const o=n.createTracker(s),l=i.repeat(Math.max(function(e,t){const n=String(e);let s=n.indexOf(t),i=s,a=0,r=0;if("string"!=typeof t)throw new TypeError("Expected substring");for(;-1!==s;)s===i?++a>r&&(r=a):a=1,i=s+t.length,s=n.indexOf(t,i);return r}(a,i)+1,3)),c=n.enter("codeFenced");let d=o.move(l);if(e.lang){const t=n.enter(`codeFencedLang${r}`);d+=o.move(n.safe(e.lang,{before:d,after:" ",encode:["`"],...o.current()})),t()}if(e.lang&&e.meta){const t=n.enter(`codeFencedMeta${r}`);d+=o.move(" "),d+=o.move(n.safe(e.meta,{before:d,after:"\n",encode:["`"],...o.current()})),t()}return d+=o.move("\n"),a&&(d+=o.move(a+"\n")),d+=o.move(l),c(),d},definition:function(e,t,n,s){const i=dY(n),a='"'===i?"Quote":"Apostrophe",r=n.enter("definition");let o=n.enter("label");const l=n.createTracker(s);let c=l.move("[");return c+=l.move(n.safe(n.associationId(e),{before:c,after:"]",...l.current()})),c+=l.move("]: "),o(),!e.url||/[\0- \u007F]/.test(e.url)?(o=n.enter("destinationLiteral"),c+=l.move("<"),c+=l.move(n.safe(e.url,{before:c,after:">",...l.current()})),c+=l.move(">")):(o=n.enter("destinationRaw"),c+=l.move(n.safe(e.url,{before:c,after:e.title?" ":"\n",...l.current()}))),o(),e.title&&(o=n.enter(`title${a}`),c+=l.move(" "+i),c+=l.move(n.safe(e.title,{before:c,after:i,...l.current()})),c+=l.move(i),o()),r(),c},emphasis:mY,hardBreak:lY,heading:function(e,t,n,s){const i=Math.max(Math.min(6,e.depth||1),1),a=n.createTracker(s);if(function(e,t){let n=!1;return PG(e,function(e){if("value"in e&&/\r?\n|\r/.test(e.value)||"break"===e.type)return n=!0,DG}),Boolean((!e.depth||e.depth<3)&&gW(e)&&(t.options.setext||n))}(e,n)){const t=n.enter("headingSetext"),s=n.enter("phrasing"),r=n.containerPhrasing(e,{...a.current(),before:"\n",after:"\n"});return s(),t(),r+"\n"+(1===i?"=":"-").repeat(r.length-(Math.max(r.lastIndexOf("\r"),r.lastIndexOf("\n"))+1))}const r="#".repeat(i),o=n.enter("headingAtx"),l=n.enter("phrasing");a.move(r+" ");let c=n.containerPhrasing(e,{before:"# ",after:"\n",...a.current()});return/^[\t ]/.test(c)&&(c=uY(c.charCodeAt(0))+c.slice(1)),c=c?r+" "+c:r,n.options.closeAtx&&(c+=" "+r),l(),o(),c},html:hY,image:xY,imageReference:fY,inlineCode:gY,link:bY,linkReference:yY,list:function(e,t,n,s){const i=n.enter("list"),a=n.bulletCurrent;let r=e.ordered?function(e){const t=e.options.bulletOrdered||".";if("."!==t&&")"!==t)throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}(n):wY(n);const o=e.ordered?"."===r?")":".":function(e){const t=wY(e),n=e.options.bulletOther;if(!n)return"*"===t?"-":"*";if("*"!==n&&"+"!==n&&"-"!==n)throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}(n);let l=!(!t||!n.bulletLastUsed)&&r===n.bulletLastUsed;if(!e.ordered){const t=e.children?e.children[0]:void 0;if("*"!==r&&"-"!==r||!t||t.children&&t.children[0]||"list"!==n.stack[n.stack.length-1]||"listItem"!==n.stack[n.stack.length-2]||"list"!==n.stack[n.stack.length-3]||"listItem"!==n.stack[n.stack.length-4]||0!==n.indexStack[n.indexStack.length-1]||0!==n.indexStack[n.indexStack.length-2]||0!==n.indexStack[n.indexStack.length-3]||(l=!0),jY(n)===r&&t){let t=-1;for(;++t-1?t.start:1)+(!1===n.options.incrementListMarker?0:t.children.indexOf(e))+a);let r=a.length+1;("tab"===i||"mixed"===i&&(t&&"list"===t.type&&t.spread||e.spread))&&(r=4*Math.ceil(r/4));const o=n.createTracker(s);o.move(a+" ".repeat(r-a.length)),o.shift(r);const l=n.enter("listItem"),c=n.indentLines(n.containerFlow(e,o.current()),function(e,t,n){if(t)return(n?"":" ".repeat(r))+e;return(n?a:a+" ".repeat(r-a.length))+e});return l(),c},paragraph:function(e,t,n,s){const i=n.enter("paragraph"),a=n.enter("phrasing"),r=n.containerPhrasing(e,s);return a(),i(),r},root:function(e,t,n,s){return(e.children.some(function(e){return CY(e)})?n.containerPhrasing:n.containerFlow).call(n,e,s)},strong:NY,text:function(e,t,n,s){return n.safe(e.value,s)},thematicBreak:function(e,t,n){const s=(jY(n)+(n.options.ruleSpaces?" ":"")).repeat(function(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}(n));return n.options.ruleSpaces?s.slice(0,-1):s}};function _Y(e){const t=e._align;this.enter({type:"table",align:t.map(function(e){return"none"===e?null:e}),children:[]},e),this.data.inTable=!0}function kY(e){this.exit(e),this.data.inTable=void 0}function SY(e){this.enter({type:"tableRow",children:[]},e)}function EY(e){this.exit(e)}function IY(e){this.enter({type:"tableCell",children:[]},e)}function AY(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,TY));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function TY(e,t){return"|"===t?t:e}function MY(e){const t=e||{},n=t.tableCellPadding,s=t.tablePipeAlign,i=t.stringLength,a=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:"\n",inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[\t :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:function(e,t,n){let s=FY.inlineCode(e,t,n);n.stack.includes("tableCell")&&(s=s.replace(/\|/g,"\\$&"));return s},table:function(e,t,n,s){return o(function(e,t,n){const s=e.children;let i=-1;const a=[],r=t.enter("table");for(;++ic&&(c=e[d].length);++al[a])&&(l[a]=e)}t.push(r)}r[d]=t,o[d]=s}let u=-1;if("object"==typeof s&&"length"in s)for(;++ul[u]&&(l[u]=i),m[u]=i),p[u]=r}r.splice(1,0,p),o.splice(1,0,m),d=-1;const h=[];for(;++d0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}WY[43]=UY,WY[45]=UY,WY[46]=UY,WY[95]=UY,WY[72]=[UY,VY],WY[104]=[UY,VY],WY[87]=[UY,$Y],WY[119]=[UY,$Y];const QY={tokenize:function(e,t,n){const s=this;return UW(e,function(e){const i=s.events[s.events.length-1];return i&&"gfmFootnoteDefinitionIndent"===i[1].type&&4===i[2].sliceSerialize(i[1],!0).length?t(e):n(e)},"gfmFootnoteDefinitionIndent",5)},partial:!0};function XY(e,t,n){const s=this;let i=s.events.length;const a=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let r;for(;i--;){const e=s.events[i][1];if("labelImage"===e.type){r=e;break}if("gfmFootnoteCall"===e.type||"labelLink"===e.type||"label"===e.type||"image"===e.type||"link"===e.type)break}return function(i){if(!r||!r._balanced)return n(i);const o=EW(s.sliceSerialize({start:r.end,end:s.now()}));if(94!==o.codePointAt(0)||!a.includes(o.slice(1)))return n(i);return e.enter("gfmFootnoteCallLabelMarker"),e.consume(i),e.exit("gfmFootnoteCallLabelMarker"),t(i)}}function eK(e,t){let n=e.length;for(;n--;)if("labelImage"===e[n][1].type&&"enter"===e[n][0]){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const s={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const a={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},r={type:"chunkString",contentType:"string",start:Object.assign({},a.start),end:Object.assign({},a.end)},o=[e[n+1],e[n+2],["enter",s,t],e[n+3],e[n+4],["enter",i,t],["exit",i,t],["enter",a,t],["enter",r,t],["exit",r,t],["exit",a,t],e[e.length-2],e[e.length-1],["exit",s,t]];return e.splice(n,e.length-n+1,...o),e}function tK(e,t,n){const s=this,i=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let a,r=0;return function(t){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(t),e.exit("gfmFootnoteCallLabelMarker"),o};function o(t){return 94!==t?n(t):(e.enter("gfmFootnoteCallMarker"),e.consume(t),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",l)}function l(o){if(r>999||93===o&&!a||null===o||91===o||OW(o))return n(o);if(93===o){e.exit("chunkString");const a=e.exit("gfmFootnoteCallString");return i.includes(EW(s.sliceSerialize(a)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(o),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(o)}return OW(o)||(a=!0),r++,e.consume(o),92===o?c:l}function c(t){return 91===t||92===t||93===t?(e.consume(t),r++,l):l(t)}}function nK(e,t,n){const s=this,i=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let a,r,o=0;return function(t){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(t),e.exit("gfmFootnoteDefinitionLabelMarker"),l};function l(t){return 94===t?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(t),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",c):n(t)}function c(t){if(o>999||93===t&&!r||null===t||91===t||OW(t))return n(t);if(93===t){e.exit("chunkString");const n=e.exit("gfmFootnoteDefinitionLabelString");return a=EW(s.sliceSerialize(n)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(t),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),u}return OW(t)||(r=!0),o++,e.consume(t),92===t?d:c}function d(t){return 91===t||92===t||93===t?(e.consume(t),o++,c):c(t)}function u(t){return 58===t?(e.enter("definitionMarker"),e.consume(t),e.exit("definitionMarker"),i.includes(a)||i.push(a),UW(e,p,"gfmFootnoteDefinitionWhitespace")):n(t)}function p(e){return t(e)}}function sK(e,t,n){return e.check(XW,t,e.attempt(QY,t,n))}function iK(e){e.exit("gfmFootnoteDefinition")}function aK(e){let t=(e||{}).singleTilde;const n={name:"strikethrough",tokenize:function(e,n,s){const i=this.previous,a=this.events;let r=0;return function(t){if(126===i&&"characterEscape"!==a[a.length-1][1].type)return s(t);return e.enter("strikethroughSequenceTemporary"),o(t)};function o(a){const l=ZW(i);if(126===a)return r>1?s(a):(e.consume(a),r++,o);if(r<2&&!t)return s(a);const c=e.exit("strikethroughSequenceTemporary"),d=ZW(a);return c._open=!d||2===d&&Boolean(l),c._close=!l||2===l&&Boolean(d),n(a)}},resolveAll:function(e,t){let n=-1;for(;++n0;)t-=1,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let s=n.pop();for(;s;){for(const t of s)e.push(t);s=n.pop()}this.map.length=0}}function oK(e,t){let n=!1;const s=[];for(;t-1;){const e=s.events[t][1].type;if("lineEnding"!==e&&"linePrefix"!==e)break;t--}const i=t>-1?s.events[t][1].type:null,a="tableHead"===i||"tableRow"===i?y:o;if(a===y&&s.parser.lazy[s.now().line])return n(e);return a(e)};function o(t){return e.enter("tableHead"),e.enter("tableRow"),function(e){if(124===e)return l(e);return i=!0,r+=1,l(e)}(t)}function l(t){return null===t?n(t):RW(t)?r>1?(r=0,s.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),u):n(t):zW(t)?UW(e,l,"whitespace")(t):(r+=1,i&&(i=!1,a+=1),124===t?(e.enter("tableCellDivider"),e.consume(t),e.exit("tableCellDivider"),i=!0,l):(e.enter("data"),c(t)))}function c(t){return null===t||124===t||OW(t)?(e.exit("data"),l(t)):(e.consume(t),92===t?d:c)}function d(t){return 92===t||124===t?(e.consume(t),c):c(t)}function u(t){return s.interrupt=!1,s.parser.lazy[s.now().line]?n(t):(e.enter("tableDelimiterRow"),i=!1,zW(t)?UW(e,p,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):p(t))}function p(t){return 45===t||58===t?h(t):124===t?(i=!0,e.enter("tableCellDivider"),e.consume(t),e.exit("tableCellDivider"),m):b(t)}function m(t){return zW(t)?UW(e,h,"whitespace")(t):h(t)}function h(t){return 58===t?(r+=1,i=!0,e.enter("tableDelimiterMarker"),e.consume(t),e.exit("tableDelimiterMarker"),x):45===t?(r+=1,x(t)):null===t||RW(t)?v(t):b(t)}function x(t){return 45===t?(e.enter("tableDelimiterFiller"),f(t)):b(t)}function f(t){return 45===t?(e.consume(t),f):58===t?(i=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(t),e.exit("tableDelimiterMarker"),g):(e.exit("tableDelimiterFiller"),g(t))}function g(t){return zW(t)?UW(e,v,"whitespace")(t):v(t)}function v(n){return 124===n?p(n):(null===n||RW(n))&&i&&a===r?(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(n)):b(n)}function b(e){return n(e)}function y(t){return e.enter("tableRow"),w(t)}function w(n){return 124===n?(e.enter("tableCellDivider"),e.consume(n),e.exit("tableCellDivider"),w):null===n||RW(n)?(e.exit("tableRow"),t(n)):zW(n)?UW(e,w,"whitespace")(n):(e.enter("data"),j(n))}function j(t){return null===t||124===t||OW(t)?(e.exit("data"),w(t)):(e.consume(t),92===t?C:j)}function C(t){return 92===t||124===t?(e.consume(t),j):j(t)}}function cK(e,t){let n,s,i,a=-1,r=!0,o=0,l=[0,0,0,0],c=[0,0,0,0],d=!1,u=0;const p=new rK;for(;++an[2]+1){const t=n[2]+1,s=n[3]-n[2]-1;e.add(t,s,[])}}e.add(n[3]+1,0,[["exit",r,t]])}return void 0!==i&&(a.end=Object.assign({},pK(t.events,i)),e.add(i,0,[["exit",a,t]]),a=void 0),a}function uK(e,t,n,s,i){const a=[],r=pK(t.events,n);i&&(i.end=Object.assign({},r),a.push(["exit",i,t])),s.end=Object.assign({},r),a.push(["exit",s,t]),e.add(n+1,0,a)}function pK(e,t){const n=e[t],s="enter"===n[0]?"start":"end";return n[1][s]}const mK={name:"tasklistCheck",tokenize:function(e,t,n){const s=this;return function(t){if(null!==s.previous||!s._gfmTasklistFirstContentOfListItem)return n(t);return e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(t),e.exit("taskListCheckMarker"),i};function i(t){return OW(t)?(e.enter("taskListCheckValueUnchecked"),e.consume(t),e.exit("taskListCheckValueUnchecked"),a):88===t||120===t?(e.enter("taskListCheckValueChecked"),e.consume(t),e.exit("taskListCheckValueChecked"),a):n(t)}function a(t){return 93===t?(e.enter("taskListCheckMarker"),e.consume(t),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),r):n(t)}function r(s){return RW(s)?t(s):zW(s)?e.check({tokenize:hK},t,n)(s):n(s)}}};function hK(e,t,n){return UW(e,function(e){return null===e?n(e):t(e)},"whitespace")}const xK={};function fK(e){const t=e||xK,n=this.data(),s=n.micromarkExtensions||(n.micromarkExtensions=[]),i=n.fromMarkdownExtensions||(n.fromMarkdownExtensions=[]),a=n.toMarkdownExtensions||(n.toMarkdownExtensions=[]);s.push(function(e){return FW([{text:WY},{document:{91:{name:"gfmFootnoteDefinition",tokenize:nK,continuation:{tokenize:sK},exit:iK}},text:{91:{name:"gfmFootnoteCall",tokenize:tK},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:XY,resolveTo:eK}}},aK(e),{flow:{null:{name:"table",tokenize:lK,resolveAll:cK}}},{text:{91:mK}}])}(t)),i.push([{transforms:[PZ],enter:{literalAutolink:IZ,literalAutolinkEmail:AZ,literalAutolinkHttp:AZ,literalAutolinkWww:AZ},exit:{literalAutolink:LZ,literalAutolinkEmail:DZ,literalAutolinkHttp:TZ,literalAutolinkWww:MZ}},{enter:{gfmFootnoteCallString:BZ,gfmFootnoteCall:HZ,gfmFootnoteDefinitionLabelString:$Z,gfmFootnoteDefinition:VZ},exit:{gfmFootnoteCallString:UZ,gfmFootnoteCall:WZ,gfmFootnoteDefinitionLabelString:qZ,gfmFootnoteDefinition:GZ}},{canContainEols:["delete"],enter:{strikethrough:XZ},exit:{strikethrough:eY}},{enter:{table:_Y,tableData:IY,tableHeader:IY,tableRow:SY},exit:{codeText:AY,table:kY,tableData:EY,tableHeader:EY,tableRow:EY}},{exit:{taskListCheckValueChecked:DY,taskListCheckValueUnchecked:DY,paragraph:LY}}]),a.push(function(e){return{extensions:[{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:SZ,notInConstruct:EZ},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:SZ,notInConstruct:EZ},{character:":",before:"[ps]",after:"\\/",inConstruct:SZ,notInConstruct:EZ}]},YZ(e),{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:QZ}],handlers:{delete:tY}},MY(e),{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:PY}}]}}(t))}const gK=({files:e,isSubagent:t})=>{const n=e.findIndex(e=>e.success),[s,i]=Pe.useState(n>=0?n:0),r=Pe.useRef(null),o=Pe.useRef(null),l=Pe.useRef(null);if(Pe.useEffect(()=>{if(r.current&&o.current){const e=r.current,t=o.current,n=e.clientWidth,s=t.clientWidth,i=t.offsetLeft-n/2+s/2;e.scrollTo({left:i,behavior:"smooth"})}},[s]),!e.length)return a.jsx("div",{className:"text-[#E5E5E5] p-4",children:"No files to display"});const c=e[s];return a.jsx("div",{className:"w-full border border-[#252526] rounded-lg overflow-hidden",children:a.jsxs("div",{className:"flex flex-col",children:[a.jsx("div",{ref:r,className:"flex overflow-x-auto bg-[#252526] scrollbar-thin scrollbar-thumb-[#3E3E42] scrollbar-track-[#252526]",style:{msOverflowStyle:"none",...t?{flexWrap:"nowrap",overflow:"scroll",whiteSpace:"pre-wrap",width:t?"calc(100% - 159px)":"100%"}:{}},children:e.map((e,t)=>{const n=t===s,r=e.path.split("/").pop()||e.path,l="error"===e.type,c="directory"===e.type,d="file"===e.type;return a.jsxs("button",{ref:n?o:null,className:"px-4 py-2 whitespace-nowrap font-mono text-sm flex-shrink-0 flex items-center gap-2 "+(n?l?"bg-[#1E1E1E] text-[#FF6B6B] border-b-2 border-[#FF6B6B]":"bg-[#1E1E1E] text-[#DD99FF] border-b-2 border-[#DD99FF]":l?"text-[#FF6B6B99] hover:bg-[#2D2D2D]":"text-[#E5E5E5] hover:bg-[#2D2D2D]"),onClick:e=>{i(t),e.stopPropagation()},title:e.path,children:[l?a.jsx(Jk,{className:"w-3 h-3"}):c?a.jsx(hS,{className:"w-3 h-3"}):d?a.jsx(pS,{className:"w-3 h-3"}):null,r]},t)})}),a.jsxs("div",{className:"bg-[#252526] px-4 py-2 font-mono text-[#E5E5E5] text-sm flex items-center justify-between border-t border-[#3E3E42] border-b border-[#3E3E42] overflow-hidden",children:[a.jsx("span",{className:c.success?"text-[#DD99FF]":"text-[#FF6B6B]",children:c.path}),"error"===c.type&&a.jsx("span",{className:"text-[#FF6B6B] text-xs",children:"Failed to load"}),"directory"===c.type&&a.jsx("span",{className:"text-[#9999FF] text-xs",children:"Directory"})]}),a.jsx("div",{className:"h-[400px] w-full",children:"file"===c.type&&c.output?a.jsx(Vt,{height:"100%",defaultLanguage:$V(c.path),value:c.output,theme:"vs-dark",onMount:e=>{l.current=e},options:{readOnly:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1,lineNumbers:"on",renderLineHighlight:"all",contextmenu:!1,folding:!0,scrollbar:{vertical:"visible",horizontal:"visible"},fontSize:13,fontFamily:"'Menlo', 'Monaco', 'Courier New', monospace"}}):"directory"===c.type&&c.entries?a.jsx("div",{className:"h-full w-full bg-[#1E1E1E] p-4 overflow-auto",children:a.jsx("div",{className:"font-mono text-sm text-[#E5E5E5]",children:c.entries.length>0?a.jsx("div",{className:"flex flex-col gap-1",children:c.entries.map((e,t)=>a.jsx("div",{className:"py-1 px-2 hover:bg-[#2D2D2D] rounded",children:e},t))}):a.jsx("div",{className:"text-[#9999FF99] italic",children:"Empty directory"})})}):"error"===c.type?a.jsx("div",{className:"h-full w-full flex items-center justify-center bg-[#1E1E1E] text-[#FF6B6B] p-8",children:a.jsxs("div",{className:"flex flex-col items-center gap-4 max-w-md text-center",children:[a.jsx(Jk,{className:"w-12 h-12"}),a.jsxs("div",{children:[a.jsx("p",{className:"font-semibold mb-2",children:"Error"}),a.jsx("p",{className:"text-sm text-[#E5E5E599]",children:c.error||"An error occurred"})]})]})}):null})]})})},vK=({message:e})=>a.jsx("div",{className:"p-3 select-text selection:text-[#66EAFF] selection:bg-[#66EAFF] selection:bg-opacity-10",onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),children:(()=>{var t,n,s;if(!e.action)return e.observation;if("search_replace"===e.function_name&&OV(e.action,"mcp_search_replace")){const t=zV(e.action);if(t)return a.jsx("div",{className:"w-full h-[400px] border border-[#252526] rounded-lg overflow-hidden",children:a.jsx($t,{height:"100%",language:$V(t.path),original:t.oldStr,modified:t.newStr,theme:"vs-dark",options:{readOnly:!0,renderSideBySide:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1,lineNumbers:"on",renderLineHighlight:"none",contextmenu:!1,folding:!0,scrollbar:{vertical:"visible",horizontal:"visible"},originalEditable:!1,enableSplitViewResizing:!0}})})}if("multi_search_replace"===e.function_name&&OV(e.action,"mcp_multi_search_replace"))return null;if("view_bulk"===e.function_name&&OV(e.action,"mcp_view_bulk")){if(e.observation){const t=function(e){if(!e||!e.trim())return[];const t=e.split("\n"),n=[];let s=[];for(const i of t)i.startsWith("===FILE:")||i.startsWith("===DIR:")||i.startsWith("===ERROR:")?(s.length>0&&n.push(s.join("\n")),s=[i]):s.push(i);return s.length>0&&n.push(s.join("\n")),n.filter(e=>e.trim()).map(e=>{const t=e.split("\n"),n=t[0];if(n.startsWith("===FILE:")){const e=n.replace("===FILE:","").trim();let s=1;return t[1]&&t[1].trim().endsWith(":")&&(s=2),{path:e,type:"file",success:!0,output:t.slice(s).filter(e=>!e.startsWith("===END")).map(e=>e.replace(/^\d+\|/,"")).join("\n")}}if(n.startsWith("===DIR:")){const e=n.replace("===DIR:","").trim();let s=1;return t[1]&&(t[1].trim().endsWith(":")||t[1].includes("(depth="))&&(s=2),{path:e,type:"directory",success:!0,entries:t.slice(s).filter(e=>!e.startsWith("===END")&&e.trim()).map(e=>e.trim())}}return n.startsWith("===ERROR:")?{path:n.replace("===ERROR:","").trim(),type:"error",success:!1,error:t.slice(1).filter(e=>!e.startsWith("===END")).join("\n").trim()}:null}).filter(e=>null!==e)}(e.observation);if(t.length>0)return a.jsx(gK,{files:t})}return null}const[i,r,o]=e.action.split(" ");if("view"===r)return a.jsx("div",{className:"w-full h-[300px] border border-[#252526] rounded-lg overflow-hidden",children:a.jsx(Vt,{height:"100%",defaultLanguage:$V(o),defaultValue:(null==(t=e.observation)?void 0:t.includes("|"))?null==(n=e.observation)?void 0:n.split("\n").slice(1).map(e=>{const[,...t]=e.split("|");return t.join("|")}).join("\n"):null==(s=null==e?void 0:e.observation)?void 0:s.split("\n").slice(1).join("\n"),theme:"vs-dark",options:{readOnly:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1,lineNumbers:"on",renderLineHighlight:"none",contextmenu:!1,folding:!0,scrollbar:{vertical:"visible",horizontal:"visible"}}})});if("str_replace"===r){const{oldStr:t,newStr:n}=(e=>{const t=(e=e.replace(/--status\b/,"")).split("--old-str");if(t.length<2)return{oldStr:"",newStr:""};const n=t[1].split("--new-str");if(n.length<2)return{oldStr:"",newStr:""};const s=e=>e.trim().replace(/^["']|["']$/g,"").replace(/\\n/g,"\n").replace(/\\t/g,"\t").replace(/\\r/g,"\r").replace(/\\\\/g,"\\");return{oldStr:s(n[0]),newStr:s(n[1])}})(e.action);return a.jsx("div",{className:"w-full h-[400px] border border-[#252526] rounded-lg overflow-hidden",children:a.jsx($t,{height:"100%",language:$V(o),original:t,modified:n,theme:"vs-dark",options:{readOnly:!0,renderSideBySide:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1,lineNumbers:"on",renderLineHighlight:"none",contextmenu:!1,folding:!0,scrollbar:{vertical:"visible",horizontal:"visible"},originalEditable:!1,enableSplitViewResizing:!0}})})}if("create"===r){const t=e.action.match(/--file-text\s+(.*?)$/s),n=t?t[1].replace(/\\'/g,"'").replace(/^'|'$/g,"").replace(/\\n/g,"\n").replace(/\\t/g,"\t").replace(/\\r/g,"\r"):e.observation;return a.jsx("div",{className:"w-full h-[400px] border border-[#252526] rounded-lg overflow-hidden",children:a.jsx(Vt,{height:"100%",defaultLanguage:$V(o),defaultValue:n||"",theme:"vs-dark",options:{readOnly:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1,lineNumbers:"on",renderLineHighlight:"none",contextmenu:!1,folding:!0,scrollbar:{vertical:"visible",horizontal:"visible"}}})})}return e.action.startsWith("bulk_file_creator")||"bulk_file_writer"===e.function_name?null:a.jsx(jZ,{className:"p-0 font-['Inter'] text-[16px]",remarkPlugins:[fK],components:{p:({node:e,...t})=>a.jsx("p",{className:"my-2",...t}),h3:({node:e,...t})=>a.jsx("h3",{className:"mt-4 mb-2 font-bold",...t}),li:({node:e,...t})=>a.jsx("li",{className:"my-1 ml-4",...t}),ul:({node:e,...t})=>a.jsx("ul",{className:"my-2",...t}),del:({node:e,...t})=>a.jsx("del",{className:"text-gray-400 line-through",...t})},children:e.observation})})()}),bK=({message:e,isExpanded:t,setIsExpanded:n,isSubagent:s=!1})=>{var i;if(!e.action||"finish"===e.action||"exit_cost_credit_limit_reached"===e.action||"exit_cost"===e.action||"context_limit_reached"===e.action||"rollback"===e.function_name||"ask_human"===e.function_name)return null;const r=(null==(i=e.content)?void 0:i.includes("thought:"))&&Boolean(e.action);return a.jsxs("div",{onClick:()=>{if(!t&&e.observation){const e=window.getSelection();if(e&&e.toString().length>0)return;n(!0)}},className:bb("max-md:max-w-screen w-full max-w-[calc(896px-52px)] text-wrap backdrop-blur-lg rounded-[12px] text-left select-text",e.observation&&!t&&"cursor-pointer hover:bg-[#202020]"),style:{background:"radial-gradient(50% 50% at 50% 50%, rgba(230, 247, 255, 0.1) 0%, rgba(229, 246, 255, 0.05) 100%)"},children:[a.jsxs("div",{className:"flex items-start justify-between p-3",children:[a.jsxs("div",{className:"flex items-center flex-1 min-w-0 gap-2",children:[a.jsx("div",{className:bb("flex items-start gap-2 text-wrap",t&&"hidden"),children:a.jsx(PV,{isRunning:r,envSuccess:e.env_success,action:e.action})}),a.jsx("div",{className:"flex items-center flex-1 min-w-0 gap-2",children:a.jsx(WV,{action:e.action,functionName:e.function_name,isExpanded:t,setIsExpanded:n,isSubagent:s})})]}),e.observation&&a.jsx("div",{onClick:s=>{s.stopPropagation(),e.observation&&n(!t)},className:"text-[#939399] transition-all duration-200 ml-2 shrink-0 cursor-pointer hover:text-[#E5E5E5] p-1 -m-1",children:a.jsx(Yk,{className:bb("w-5 h-5 transition-transform duration-200 ease-in-out",t&&"rotate-90")})})]}),t&&a.jsx("div",{className:bb("grid transition-[grid-template-rows] duration-200",t?"grid-rows-[1fr]":"grid-rows-[0fr]"),children:a.jsx("div",{className:"overflow-hidden",children:a.jsx("div",{className:"border-t border-[#313131]",children:e.observation&&a.jsx(vK,{message:e})})})})]})},yK=Pe.memo(({children:e,className:t,variant:n="default",customComponents:s={}})=>{const i={...{p:({...e})=>a.jsx("p",{className:"my-4 font-['Inter']",...e}),h1:({...e})=>a.jsx("h1",{className:"mt-8 mb-4 text-[28px] font-bold tracking-tight text-white font-['Inter']",...e}),h2:({...e})=>a.jsx("h2",{className:"mt-6 mb-3 text-2xl font-semibold tracking-tight text-white/90 font-['Inter']",...e}),h3:({...e})=>a.jsx("h3",{className:"mt-5 mb-2 text-xl font-bold text-white/80 font-['Inter']",...e}),h4:({...e})=>a.jsx("h4",{className:"mt-4 mb-2 text-lg font-semibold text-white/70 font-['Inter']",...e}),h5:({...e})=>a.jsx("h5",{className:"mt-3 mb-1 text-base font-medium text-white/60 font-['Inter']",...e}),h6:({...e})=>a.jsx("h6",{className:"mt-2 mb-1 text-sm font-medium tracking-wider uppercase text-white/50 font-['Inter']",...e}),ul:({...e})=>a.jsx("ul",{className:"pl-4 my-3 space-y-1 list-disc font-['Inter']",...e}),ol:({...e})=>a.jsx("ol",{className:"pl-4 my-3 space-y-1 list-decimal font-['Inter']",...e}),li:({...e})=>a.jsx("li",{className:"pl-1 ml-4 font-['Inter']",...e}),blockquote:({...e})=>a.jsx("blockquote",{className:"pl-4 my-4 italic border-l-4 border-blue-500/40 text-white/70 font-['Inter']",...e}),code:({inline:e,className:t,children:n,...s})=>{const i=String(n||"");return!0===e||!1!==e&&!(null==t?void 0:t.startsWith("language-"))&&!i.includes("\n")&&i.length<200?a.jsx("span",{className:" px-1.5 py-0.5 rounded-[6px] text-[12px] font-jetbrains border border-[#80fff920] bg-[#80fff910] text-[#80fff9] whitespace-nowrap inline",...s,children:n}):a.jsx("span",{className:"block p-4 overflow-x-auto text-sm rounded-lg bg-white/5 text-[#dcdce5] font-jetbrains",...s,children:n})},pre:({...e})=>a.jsx("pre",{className:"p-0 my-4 overflow-hidden bg-transparent rounded-md",...e}),a:({...e})=>a.jsx("a",{className:"text-blue-400 transition-colors duration-200 hover:text-blue-300 hover:underline underline-offset-2 font-['Inter']",...e}),table:({...e})=>a.jsx("table",{className:"w-full my-4 border-collapse font-['Inter']",...e}),thead:({...e})=>a.jsx("thead",{className:"bg-gray-800/40 font-['Inter']",...e}),tbody:({...e})=>a.jsx("tbody",{className:"divide-y divide-gray-800/60 font-['Inter']",...e}),tr:({...e})=>a.jsx("tr",{className:"transition-colors duration-150 hover:bg-gray-800/20 font-['Inter']",...e}),th:({...e})=>a.jsx("th",{className:"px-3 py-2 font-semibold text-left text-white/80 font-['Inter']",...e}),td:({...e})=>a.jsx("td",{className:"px-3 py-2 font-['Inter']",...e}),hr:({...e})=>a.jsx("hr",{className:"my-6 border-t border-gray-700/50 font-['Inter']",...e}),strong:({...e})=>a.jsx("strong",{className:"font-bold text-white font-['Inter']",...e}),em:({...e})=>a.jsx("em",{className:"italic text-white/90 font-['Inter']",...e}),img:({...e})=>a.jsx("img",{className:"h-auto max-w-full my-4 rounded-lg shadow-md shadow-black/20",...e,loading:"lazy"}),dl:({...e})=>a.jsx("dl",{className:"my-4 space-y-2 font-['Inter']",...e}),dt:({...e})=>a.jsx("dt",{className:"font-medium text-white/90 font-['Inter']",...e}),dd:({...e})=>a.jsx("dd",{className:"ml-4 text-white/70 font-['Inter']",...e}),details:({...e})=>a.jsx("details",{className:"my-3 overflow-hidden font-['Inter'] border rounded-md border-gray-700/50",...e}),summary:({...e})=>a.jsx("summary",{className:"px-4 py-2 transition-colors font-['Inter'] duration-200 cursor-pointer bg-gray-800/30 hover:bg-gray-800/50",...e}),sup:({...e})=>a.jsx("sup",{className:"text-xs align-super font-['Inter']",...e}),sub:({...e})=>a.jsx("sub",{className:"text-xs align-sub font-['Inter']",...e}),del:({...e})=>a.jsx("del",{className:"text-gray-400 line-through decoration-1 font-['Inter']",...e})},...s};return a.jsx(jZ,{className:bb("selection:text-[#66EAFF] text-wrap break-words selection:bg-[#66EAFF] selection:bg-opacity-10 font-['Inter'] max-w-3xl select-text",{default:"p-0 text-[#dcdce5] font-['Inter'] text-[16px] leading-[28px] font-normal max-w-4xl",compact:"p-0 text-[#dcdce5] font-['Inter'] text-[14px] leading-[24px] font-normal max-w-4xl",minimal:"p-0 text-[#dcdce5] font-['Inter'] text-[14px] leading-[20px] font-normal max-w-4xl"}[n],t,"max-w-[50rem]"),remarkPlugins:[fK],components:i,children:e})},(e,t)=>e.children===t.children&&e.variant===t.variant&&e.className===t.className),wK=wv.common.mingcuteQuestionFill,jK=wv.common.infoSquare02,CK=wv.common.keyboardArrowUp,NK=({message:e,nextMessageExists:t=!1})=>{var n;const[s,i]=Pe.useState(!1),r=e.action&&["fork"].includes(e.action)||e.function_name&&["exit_cost","exit_cost_credit_limit_reached"].includes(e.function_name)?e.content:e.action||"",o=(null==r?void 0:r.length)>650?300:150,l=(null==(n=e.content)?void 0:n.length)>950?400:150;return"ask_human"!==e.function_name&&"exit_cost"!==e.function_name&&"exit_cost_credit_limit_reached"!==e.function_name||t?"ask_human"===e.function_name||"exit_cost"===e.function_name||"exit_cost_credit_limit_reached"===e.function_name?a.jsxs("div",{className:bb("w-full p-[8px] relative rounded-[12px] bg-[#111112] border-[#FFFFFF1F] border-[1px] text-left flex flex-col gap-2"),children:[a.jsxs("div",{onClick:()=>i(!s),className:"flex cursor-pointer items-center font-['Inter'] grayscale font-medium text-[#80FFF9] p-[10px] rounded-[8px] justify-between",style:{background:"radial-gradient(50% 50% at 50% 50%, rgba(230, 247, 255, 0.1) 0%, rgba(229, 246, 255, 0.05) 100%)"},children:[a.jsxs("div",{className:"flex justify-between gap-2",children:[a.jsx("img",{src:wK,alt:"Ask Question",className:"w-6 h-6 font-['Inter']"}),a.jsx("span",{className:"font-['Inter']",children:"Agent asked a question"})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("div",{className:"bg-[#FFFFFF1A] rounded-full text-white px-[12px] py-1 text-[14px] font-medium",children:"Answered"}),a.jsx("button",{onClick:()=>{i(!s)},children:a.jsx("img",{src:CK,alt:"Up",className:bb("transition-transform duration-200",s?"rotate-180":"rotate-0")})})]})]}),s&&a.jsx("div",{className:"bg-[#FFFFFF0D] rounded-[8px] p-4 py-0",children:a.jsx(yK,{children:r||"",variant:"default"})})]}):"default_tool"===e.function_name?a.jsxs("div",{className:bb("w-full p-[8px] relative rounded-[12px] bg-[#111112] border-[#FFFFFF1F] border-[1px] text-left flex flex-col gap-2"),children:[!t&&a.jsxs("div",{className:"flex items-center font-['Inter'] font-medium text-[#80FFF9] p-[10px] rounded-[8px] gap-2",style:{background:"radial-gradient(50% 50% at 50% 50%, rgba(128, 255, 249, 0.1) 0%, rgba(128, 255, 249, 0.05) 100%)"},children:[a.jsx("img",{src:jK,alt:"Ask Question",className:"w-6 h-6 font-['Inter']"}),a.jsx("span",{className:"font-['Inter']",children:"Agent will continue working after your reply"})]}),a.jsx("div",{className:"bg-[#FFFFFF0D] rounded-[8px] p-4 py-0",children:a.jsx(yK,{children:e.content||"",variant:"default"})}),t?null:a.jsx(kE,{size:l,duration:12,delay:9,colorFrom:"#80FFF9",colorTo:"transparent"})]}):null:a.jsxs("div",{className:bb("w-full p-[8px] relative rounded-[12px] bg-[#111112] border-[#FFFFFF1F] border-[1px] text-left flex flex-col gap-2"),children:[a.jsxs("div",{className:"flex items-center font-['Inter'] font-medium text-[#80FFF9] p-[10px] rounded-[8px] gap-2",style:{background:"radial-gradient(50% 50% at 50% 50%, rgba(128, 255, 249, 0.1) 0%, rgba(128, 255, 249, 0.05) 100%)"},children:[a.jsx("img",{src:wK,alt:"Ask Question",className:"w-6 h-6 font-['Inter']"}),a.jsx("span",{className:"font-['Inter']",children:"Agent is asking a question, Please answer it to further continue :"})]}),a.jsx("div",{className:"bg-[#FFFFFF0D] rounded-[8px] p-4 py-0",children:a.jsx(yK,{children:r||"",variant:"default"})}),a.jsx(kE,{size:o,duration:12,delay:9,colorFrom:"#80FFF9",colorTo:"transparent"})]})},FK=({message:e})=>{const[t,n]=Pe.useState(!1);return!e.error||"string"==typeof e.error_message&&e.error_message.includes("context limit")?null:a.jsx("div",{className:"flex items-start gap-2 px-4 py-4 bg-[#CC5254]/10 border border-1 border-[#CC5254]/20 rounded-lg text-sm cursor-pointer",onClick:()=>n(!t),children:a.jsxs("div",{className:"flex flex-col items-start w-full gap-2",children:[a.jsxs("div",{className:"flex items-start justify-between w-full",children:[a.jsxs("div",{className:"flex items-start justify-center gap-2",children:[a.jsx(bS,{className:"w-5 h-5 text-[#E55C5C]"}),a.jsx("p",{className:"text-[#E55C5C] font-['Inter'] text-base leading-6 font-normal",children:"There has been an error"})]}),t?a.jsx(Gk,{className:"w-5 h-5 text-[#E55C5C]"}):a.jsx(Yk,{className:"w-5 h-5 text-[#E55C5C]"})]}),t&&a.jsx("span",{className:"text-[#C4C4CC]/70 font-['Inter'] text-base leading-6 font-normal",children:JSON.stringify(e.error_message)})]})})},_K=({message:e,credits:t,max_budget:n,user:s,session:i})=>s&&i&&void 0!==t&&"exit_cost_credit_limit_reached"===e.action&&t<0?a.jsx("div",{className:"flex flex-col w-full pt-4 space-y-4",children:a.jsxs("div",{className:"flex w-full gap-4",children:[a.jsx("div",{className:"w-[16px] md:w-[120px] h-[1px] bg-[#4D401F] mt-[10px]"}),a.jsx("div",{className:"flex flex-col flex-1",children:a.jsxs("div",{className:"flex flex-col items-start",children:[a.jsxs("div",{className:"flex items-center w-full gap-4",children:[a.jsx("span",{className:"text-[#F5CC62] font-berkeley text-[13px] md:text-[15px] leading-[20px] font-normal",children:"Credit Exhausted"}),a.jsx("div",{className:"h-[1px] flex-1 bg-[#4D401F]"})]}),a.jsx("span",{className:"text-[#5C5F66] font-berkeley mt-2 text-[13px] md:text-[15px] leading-[20px] font-normal text-right",children:xT(e.timestamp)})]})})]})}):null,kK=({message:e,credits:t,max_budget:n})=>"exit_cost_credit_limit_reached"===e.action&&void 0!==t&&void 0!==e.max_budget&&t>0?a.jsx("div",{className:"flex flex-col w-full pt-4 space-y-4",children:a.jsxs("div",{className:"flex w-full gap-4",children:[a.jsx("div",{className:"w-[16px] md:w-[120px] h-[1px] bg-[#4D401F] mt-[10px]"}),a.jsx("div",{className:"flex flex-col flex-1",children:a.jsxs("div",{className:"flex flex-col items-start",children:[a.jsxs("div",{className:"flex items-center w-full gap-4",children:[a.jsx("span",{className:"text-[#F5CC62] font-berkeley text-[13px] md:text-[15px] leading-[20px] font-normal",children:"Credits Recharged"}),a.jsx("div",{className:"h-[1px] flex-1 bg-[#4D401F]"})]}),a.jsx("span",{className:"text-[#5C5F66] font-berkeley mt-2 text-[13px] md:text-[15px] leading-[20px] font-normal text-right",children:xT(e.timestamp)})]})})]})}):"finish"===e.action?a.jsx("div",{className:"flex flex-col w-full pt-4 space-y-4",children:a.jsxs("div",{className:"flex w-full gap-4",children:[a.jsx("div",{className:"w-[16px] md:w-[120px] h-[1px] bg-[#213B2E] mt-[10px]"}),a.jsx("div",{className:"flex flex-col flex-1",children:a.jsxs("div",{className:"flex flex-col items-start",children:[a.jsxs("div",{className:"flex items-center w-full gap-4",children:[a.jsx("span",{className:"text-[#00E573] font-berkeley text-[15px] leading-[20px] font-normal",children:"Agent Finished"}),a.jsx("div",{className:"h-[1px] flex-1 bg-[#213B2E]"})]}),a.jsx("span",{className:"text-[#5C5F66] font-berkeley mt-2 text-[13px] md:text-[15px] leading-[20px] font-normal text-right",children:xT(e.timestamp)})]})})]})}):"deployment_initiated"===e.action?a.jsx("div",{className:"flex flex-col w-full pt-4 space-y-4",children:a.jsxs("div",{className:"flex w-full gap-4",children:[a.jsx("div",{className:"w-[16px] md:w-[120px] h-[1px] bg-gradient-to-b from-[#33CCFF] to-[#337AF2] mt-[10px]"}),a.jsx("div",{className:"flex flex-col flex-1",children:a.jsxs("div",{className:"flex flex-col items-start",children:[a.jsxs("div",{className:"flex items-center w-full gap-4",children:[a.jsx("span",{className:"text-[#33CCFF] font-berkeley text-[15px] leading-[20px] font-normal",children:"Deployment Started"}),a.jsx("div",{className:"h-[1px] flex-1 bg-gradient-to-b from-[#33CCFF] to-[#337AF2]"})]}),a.jsx("span",{className:"text-[#5C5F66] font-berkeley mt-2 text-[13px] md:text-[15px] leading-[20px] font-normal text-right",children:xT(e.timestamp)})]})})]})}):null,SK=wv.common.bot,EK=wv.common.githubDark,IK=wv.common.infoSquaredBlack,AK=wv.common.increaseBudget,TK=wv.icons.preview,MK=Pe.memo(({message:e,onSubagentClick:t,hideRobotIcon:n,handleOpenVsCode:s,handleRollback:i,marginBottom:r=!0,hideSubagentCount:o=!1,isCloudFlow:l=!1,searchActive:c=!1,searchHighlights:d=[],isMatchingMessage:u=!1,isSubagent:p=!1,hideImportantActions:m=!1,handleAddToken:h,lastGithubUsed:x,acc_cost:f,max_budget:g,togglePanel:v,currentChunk:b,isLastMessage:y=!1,agentState:w,nextMessageExists:j=!1,panelState:C,selectedMessageId:N,jobDetails:F,agentName:_,onPause:k,isPauseLoading:S,podIsPaused:E=!1,isSubagentActive:I=!1,modalOpen:A,forkStatus:T,setModalOpen:M,isTyping:D=!1,onTypingComplete:L,agentStatus:P="stopped"})=>{var R,O,z,B,H,$;const[V,U]=Pe.useState(!1),[W,q]=Pe.useState(!1),[G,Z]=Pe.useState(!1),[Y,K]=Pe.useState(!1),J=Pe.useRef(null),Q=Ig(),X=UE(),ee=(null==(R=e.subagent_trajectory)?void 0:R.length)>0&&(!y||y&&I),{toast:te}=un(),{credits:ne,refreshCredits:se,tier:ie}=sv(),{user:ae,session:re}=Yg(),oe=iI();let le;le=(null==(O=null==ae?void 0:ae.user_metadata)?void 0:O.custom_name)?ae.user_metadata.custom_name:(null==(z=null==ae?void 0:ae.user_metadata)?void 0:z.full_name)?ae.user_metadata.full_name.split(" ")[0]:null==(B=null==ae?void 0:ae.email)?void 0:B.split("@")[0],Pe.useEffect(()=>{"exit_cost"!==e.action&&"exit_cost_credit_limit_reached"!==e.action&&"finish"!==e.action&&"context_limit_reached"!==e.action&&"pause"!==e.action||se()},[e.action]),Pe.useEffect(()=>{u&&c&&!V&&U(!0)},[u,c,V]);const ce=async()=>{Q&&"free"===ie?X.open({planType:"personal",triggerLocation:"default"}):e.containerId&&K(!0)},de=()=>{var n;if((null==(n=e.subagent_trajectory)?void 0:n.length)&&t){const n=N===e.id;n&&C.showSubagentPanel?v({panelName:"showSubagentPanel",value:!1}):C.showSubagentPanel&&!n?(v({panelName:"showSubagentPanel",value:!1}),setTimeout(()=>{t(e)},300)):t(e)}};return a.jsxs("div",{ref:J,onMouseEnter:()=>q(!0),onMouseLeave:()=>q(!1),className:bb("relative group selection:text-[#66EAFF] selection:bg-[#66EAFF] selection:bg-opacity-10",r&&"mb-0 my-3 md:my-5 space-y-[10px]"),id:e.id,children:[e.base64_image_list&&e.base64_image_list.length>0&&"screenshot_tool"!==e.function_name&&a.jsx(y$,{images:e.base64_image_list,className:"justify-end"}),"screenshot_tool"===e.function_name&&e.base64_image_list&&e.base64_image_list.length>0&&a.jsx("div",{className:"max-w-4xl mx-auto mb-4",children:a.jsxs("div",{className:"flex items-start w-full md:gap-4",children:[a.jsx("div",{className:"hidden md:block w-10"}),a.jsx("div",{className:"flex-1 w-full",children:a.jsxs("div",{className:"w-full p-3 rounded-[12px] border border-[#FFFFFF1F] text-left",style:{background:"radial-gradient(50% 50% at 50% 50%, rgba(128, 255, 249, 0.1) 0%, rgba(128, 255, 249, 0.05) 100%)"},children:[a.jsx("div",{className:"flex items-center gap-2 mb-3",children:a.jsx("div",{className:"text-sm text-[#80FFF9] font-medium font-['Inter']",children:"Screenshots"})}),a.jsx(y$,{images:e.base64_image_list,className:"justify-start"})]})})]})}),a.jsx(_K,{message:e,credits:ne,max_budget:g,user:ae,session:re}),"deployment_initiated"!=e.action&&a.jsx("div",{className:"overflow-hidden rounded-lg",children:a.jsx("div",{className:"flex flex-col w-full space-y-4",children:a.jsxs("div",{className:"flex items-start w-full max-w-4xl mx-auto md:gap-4 md:w-4xl",children:[!n&&!p&&a.jsx("div",{className:"",children:a.jsx("div",{className:bb("hidden row-span-2 md:block",("rollback"===e.function_name||"deployment_initiated"===e.action)&&"row-span-1"),children:a.jsx(SD,{className:"flex-shrink-0 w-10 h-10",children:a.jsx(ID,{className:"bg-transparent",children:a.jsx("img",{src:SK,alt:"Robot",className:"h-8 w-fit"})})})})}),a.jsxs("div",{className:"flex flex-col flex-1 w-full gap-3",children:["initial-llm"===e.action&&D&&e.content?a.jsx("div",{className:bb("min-w-0 w-full",n&&"col-span-2"),children:a.jsx("div",{className:"flex flex-col w-full prose prose-invert max-w-none",children:a.jsx(_V,{thought:e.content,typingSpeed:50,hideRobotIcon:!0,marginBottom:!1,onTypingComplete:()=>{L&&L()}})})}):!(ae&&re&&(null==e?void 0:e.action)&&!m&&["exit_cost_credit_limit_reached","exit_cost"].includes(e.action)||"exit_cost"===e.function_name)&&(null==e?void 0:e.content)&&a.jsx("div",{className:bb("min-w-0 w-full",n&&"col-span-2"),children:a.jsx("div",{className:"flex flex-col w-full prose prose-invert max-w-none",children:a.jsx(MV,{message:e,userName:le,searchActive:c,searchHighlights:d,handleRollback:i})})}),a.jsxs("div",{className:bb("w-full",n?"col-span-2":"col-span-1","rollback"!==e.function_name?"space-y-1 md:space-y-[10px]":"h-[0px]"),children:[e.action&&"finish"===e.action&&"rollback"!=e.function_name&&!p&&a.jsx(NV,{containerId:e.containerId,isCloudFlow:l,hideImportantActions:m,handleDeploy:async()=>{v({panelName:"showDeployPanel",value:!0})},handleCopyToHost:async()=>{if(e.containerId)try{Z(!0);const t=await bp.showDirectoryPicker();if(t&&!t.canceled&&t.filePaths[0]){const n={type:"copy-to-host-as-archive",hostDir:t.filePaths[0]},s=await bp.executeNeonAction(e.containerId,n);s.success?te({title:"Export as folder",description:s.message}):te({title:"Error",description:s.error||"Failed to copy files",variant:"destructive"})}}catch(t){te({title:"Error",description:"Failed to copy files to host",variant:"destructive"})}finally{Z(!1)}},handleOpenVsCode:s,isLoading:G,handlePushToGithub:ce,togglePanel:v,podIsPaused:E}),"initial-llm"!==e.action&&a.jsx(bK,{message:e,isExpanded:V,setIsExpanded:U,isSubagent:p}),a.jsx(NK,{message:e,nextMessageExists:j}),a.jsx(AV,{message:e,credits:ne,handleAddToken:h,podIsPaused:E,modalOpen:A,setModalOpen:M}),a.jsx(FK,{message:e})]})]})]})})}),ae&&re&&"context_limit_reached"===e.action&&!oe?a.jsx("div",{className:"max-w-4xl pt-[6px] mx-auto",children:a.jsxs("div",{className:"relative flex items-center gap-1 md:gap-4 md:ml-14",children:[a.jsx(wV,{title:"Save Work",className:"flex bg-[#2EE572] hover:bg-[#2ee550] justify-between gap-2 items-center",variant:"outlined",icon:EK,onClick:ce,disabled:E}),a.jsx(wV,{title:"Learn How to Clear Memory",className:"flex items-center justify-between gap-2 font-brockmann",variant:"outlined",icon:IK,onClick:()=>{window.open(cv,"_blank")}})]})}):null,ae&&re&&!m&&"exit_cost_credit_limit_reached"===e.action?a.jsx("div",{className:"max-w-4xl pt-[6px] mx-auto",children:a.jsxs("div",{className:"relative flex items-center gap-4 ml-6 md:ml-14",children:[a.jsx(wV,{title:"free"===ie?"Buy Credits":"Add More Credits",variant:"filled",style:"free"==ie&&"exit_cost_credit_limit_reached"===e.action?{background:"linear-gradient(90deg, #ffffff30, #00000050), #F3CA5F",backgroundSize:"cover",backgroundPosition:"center",backgroundBlendMode:"overlay, normal"}:{},className:bb("flex items-center gap-1 md:gap-4","free"!=ie&&"hover:bg-[#F3CA5F]"),onClick:()=>{if(!h)return;"free"==ie&&bg(rE);const t="exit_cost_credit_limit_reached"===e.action?"add_credits":"increase_budget";h(t)},icon:AK}),a.jsx(wV,{disabled:E,title:"Preview",variant:"outlined",className:"flex items-center gap-4",icon:TK,onClick:()=>{v&&v({panelName:"showUrlPreviewPanel"})}})]})}):null,"rollback"!=e.function_name&&a.jsxs("div",{className:bb("transition-opacity duration-200 h-[25px] max-w-4xl items-center flex justify-between mx-auto","opacity-100"),children:[a.jsxs("div",{className:"flex justify-between items-center text-[#5C5F66]",children:[!y&&(null==(H=e.subagent_trajectory)?void 0:H.length)>0&&a.jsx(SV,{handleSubagentClick:de,message:e,agentState:w,enableLoading:!1,runningState:!1,panelState:C,isSelected:N==e.id,jobDetails:F,agentName:_,onPause:k,isPauseLoading:S}),!(null==e?void 0:e.subagent_trajectory)&&!b&&a.jsx("span",{className:bb("md:ml-14",p&&"ml-4")}),y&&I&&(null==($=e.subagent_trajectory)?void 0:$.length)>0&&a.jsx(SV,{handleSubagentClick:de,message:e,agentState:w,enableLoading:!0,runningState:I,panelState:C,isSelected:N===e.id,jobDetails:F,agentName:_,onPause:k,isPauseLoading:S})]}),"rollback"!=e.function_name&&"deployment_initiated"!==e.action&&a.jsx("div",{className:"text-[#5C5F66] w-full",children:a.jsxs("div",{className:bb("relative flex items-center justify-between",ee&&"justify-end"),children:[a.jsx("div",{className:bb("flex items-center gap-2",ee&&"hidden",W?"opacity-100":"opacity-0 pointer-events-none"),children:a.jsx("span",{className:bb("text-[13px] md:text-[15px] w-full leading-[20px] font-medium font-mono text-nowrap transition-opacity text-[#CCEEFF]/30"),children:hT(e.timestamp)})}),a.jsx("div",{className:bb("relative",(null==w?void 0:w.agent_running)?"":"md:opacity-100 pointer-events-none"),children:a.jsx(U$,{message:e,isHovered:W,forkStatus:T,isCloudFlow:l,hideImportantActions:m,handleRollback:i,agentStatus:P,podIsPaused:E,className:bb(W?"opacity-100":"opacity-0 pointer-events-none")})})]})})]}),!p&&a.jsx(kK,{message:e,credits:ne,max_budget:g}),Y&&!E&&a.jsx(_H,{podIsPaused:E,lastGithubUsed:x,isOpen:Y,onOpenChange:e=>K(e),jobId:e.containerId,onSuccess:()=>K(!1)})]})});function DK({children:e,as:t="p",className:n,duration:s=1,zDistance:i=10,xDistance:r=2,yDistance:o=-2,spread:l=1,scaleDistance:c=1.1,rotateYDistance:d=10,transition:u}){const p=zt.create(t);return a.jsx(p,{className:bb("relative inline-block [perspective:500px]","[--base-color:#a1a1aa] [--base-gradient-color:#000]","dark:[--base-color:#71717a] dark:[--base-gradient-color:#ffffff]",n),style:{color:"var(--base-color)"},children:e.split("").map((t,n)=>{const p=n*s*(1/l)/e.length;return a.jsx(zt.span,{className:bb("inline-block whitespace-pre [transform-style:preserve-3d]"),initial:{translateZ:0,scale:1,rotateY:0,color:"var(--base-color)"},animate:{translateZ:[0,i,0],translateX:[0,r,0],translateY:[0,o,0],scale:[1,c,1],rotateY:[0,d,0],color:["var(--base-color)","var(--base-gradient-color)","var(--base-color)"]},transition:{duration:s,repeat:1/0,repeatDelay:.05*e.length/l,delay:p,ease:"easeInOut",...u},children:t},n)})})}const LK=wv.common.bot;const PK=ze.memo(function({text:e,duration:t=2,spread:n=1,zDistance:s=1,scaleDistance:i=1.1,rotateYDistance:r=20}){return a.jsx("div",{className:"max-w-4xl mx-auto",children:a.jsxs("div",{className:"flex items-start space-x-3",children:[a.jsx("div",{className:"row-span-2",children:a.jsx(SD,{className:"flex-shrink-0 w-10 h-10",children:a.jsx(ID,{className:"bg-transparent",children:a.jsx("img",{src:LK,alt:"Robot",className:"h-8 w-fit"})})})}),a.jsx("div",{className:"flex flex-col w-full space-y-4",children:a.jsx("div",{className:"w-[300px] flex items-center justify-between rounded-xl p-4 pt-2 pl-0",children:a.jsx("div",{className:"flex items-center space-x-3",children:a.jsx(DK,{className:"[--base-color:#0D74CE] [--base-gradient-color:#5EB1EF] text-base",duration:t,spread:n,zDistance:s,scaleDistance:i,rotateYDistance:r,children:e})})})})]})})},(e,t)=>!(e.text!==t.text));PK.displayName="AgentTypingAnimation";const RK=({text:e="Processing next step..."})=>a.jsx("div",{className:"typing-animation-container",children:a.jsx(PK,{text:e,duration:1})});function OK({isOpen:e,onClose:t,messages:n,onSubmit:s,onPause:i,agentState:r,containerId:o,jobDetails:l,togglePanel:c,selectedAgent:d,hideImportantActions:u=!1,userInitials:p,subagentName:m="Subagent",isSubagentActive:h=!1,isCloudFlow:x=!1,pauseWasClicked:f=!1,isPauseLoading:g=!1,searchHighlights:v,isMatchingMessage:b,searchState:y,currentChunk:w,podIsPaused:j=!1,agentStatus:C,setAgentStatus:N}){const[F,_]=Pe.useState(new Set),[k,S]=Pe.useState(!1),E=Pe.useRef(null),[I,A]=Pe.useState(!0),T=Pe.useRef(null),M=Pe.useMemo(()=>[...n].sort((e,t)=>new Date(e.timestamp).getTime()-new Date(t.timestamp).getTime()),[n]),D=()=>{T.current&&clearTimeout(T.current),T.current=setTimeout(()=>{E.current&&E.current.scrollTo({top:E.current.scrollHeight,behavior:"smooth"})},100)};Pe.useEffect(()=>{I&&D()},[M.length]),Pe.useEffect(()=>{e&&D()},[e]),Pe.useEffect(()=>()=>{T.current&&clearTimeout(T.current)},[]);const L=Pe.useMemo(()=>{if(M.length>0)return M[M.length-1].agent_name},[M]);Pe.useEffect(()=>{if(M.length>0){const e=M[M.length-1];"finish"===e.action||e.action||e.observation?S(!1):S(!0)}else S(!1)},[M]);const P=Pe.useMemo(()=>{if(M.length>0){return"finish"===M[M.length-1].action}return!1},[M]);return a.jsx("div",{className:bb("w-full h-full bg-[#0F0F10] max-md:absolute max-md:inset-0 z-[49]",e?"block":"hidden"),children:a.jsxs("div",{className:"flex flex-col h-full",children:[a.jsxs("div",{className:"p-4 md:px-6 md:py-5 bg-[#181818] md:bg-transparent flex items-center justify-between border-b border-[#242424]/60",children:[a.jsxs("div",{className:"text-[#939399] font-['Brockmann'] flex items-center gap-2 text-[15px] md:text-[18px] font-medium leading-[24px] capitalize",children:[ST(m)," (",M.length,")"]}),a.jsx(Nb,{variant:"ghost",size:"icon",onClick:t,className:"w-8 h-8 hover:bg-transparent",children:a.jsx(HS,{className:"w-6 h-6 text-white"})})]}),a.jsxs("div",{ref:E,className:"flex-1 p-6 overflow-x-hidden overflow-y-auto",onScroll:()=>{if(E.current){const{scrollTop:e,scrollHeight:t,clientHeight:n}=E.current,s=Math.abs(t-e-n)<10;A(s)}},style:{scrollBehavior:"smooth",contain:"layout style",willChange:"scroll-position"},children:[M.map(e=>a.jsxs("div",{className:"w-full",style:{contain:"layout"},children:["assistant"===e.role&&e.action&&a.jsx(MK,{currentChunk:"",togglePanel:c,message:e,userInitials:p||"",onMergeToLocal:()=>{},onShowSubagentMessages:()=>{},onSubagentClick:()=>{},handleOpenVsCode:()=>{},handleRollback:()=>{},hideImportantActions:u,isCloudFlow:x,searchActive:y.isActive,searchQuery:y.query,searchHighlights:v,isMatchingMessage:b,isSubagent:!0,handleAddToken:()=>{},acc_cost:0,max_budget:0,selectedMessageId:void 0}),"user"===e.role&&a.jsx(rV,{message:e,isSubagent:!0})]},e.id)),!P&&(null==r?void 0:r.agent_running)&&a.jsxs(a.Fragment,{children:[a.jsx(RK,{}),a.jsx("div",{className:"h-32"})]})]}),!P&&a.jsx("div",{className:"p-2 md:p-4 md:pb-2 border-t flex items-center justify-center border-[#242424]/60",children:a.jsx(r$,{buildMode:"build",onSubmit:(e,t)=>{e.trim()&&s&&(s(e,t),D())},placeholder:`Message ${ST(m)||"Subagent"}`,hideStatus:!0,isDisabled:j,hideTokens:!0,showImages:!0,isCloudFlow:x,agentName:L,agentState:r,agentStatus:C,setAgentStatus:N,containerId:o,jobDetails:l,isSubagentActive:h||k,onPause:i,onAddToken:()=>{},pauseWasClicked:f,isPauseLoading:g,onImagesChange:()=>{},fromSubagentPanel:!0})})]})})}const zK=wv.common.whiteCopperCoin,BK=wv.common.joinedBuy,HK=wv.payments.externalFilled,$K=wv.payments.infoRed;function VK({isOpen:e,onOpenChange:t,location:n="default"}){var s,i;const{tier:r,getUpgradeTierName:o,upgradeDetails:l}=sv(),{currentWorkspace:c}=ev(),{user:d}=Yg(),{isLoading:u,processingBundleAmount:p,bundles:m,handleBuyCredits:h,handleRazorpayPayment:x,paymentModalState:f,hidePaymentModals:g}=TT();Pe.useEffect(()=>{e&&bg(JS.BUY_CREDITS_MODAL_EVENTS.MODAL_OPENED,{tier:r,workspace:c,bundle_count:m.length,currency:w(),is_razorpay_flow:C})},[e]);const v=e=>{bg(JS.BUY_CREDITS_MODAL_EVENTS.MODAL_CLOSED,{tier:r,workspace:c,custom_amount_entered:!!N,custom_amount_value:N?parseInt(N):null}),t(e)};Pe.useEffect(()=>{f.isLoading&&bg(JS.BUY_CREDITS_MODAL_EVENTS.PAYMENT_LOADING_MODAL_OPENED,{payment_type:f.paymentType||"credits",amount:f.amount,currency:f.currency,workspace:c,tier:r})},[f.isLoading]);const b=e=>Nv[e]||Nv[jv],y=e=>e===Cv?{minimum:1700,maximum:17e4}:{minimum:20,maximum:2e3},w=()=>m.length>0?m[0].currency:jv,j=w(),C=w().toUpperCase()===Cv,[N,F]=Pe.useState(""),[_,k]=Pe.useState(!1),[S,E]=Pe.useState(""),I=e=>{const t=parseInt(e,10);return isNaN(t)?0:j===Cv?Math.floor(t/17):t>=500?Math.floor(t/500*3e3):5*t};return e?a.jsxs(a.Fragment,{children:[Be.createPortal(a.jsx(Bt,{children:e&&a.jsxs("div",{className:"fixed inset-0 z-[999] flex items-center justify-center",children:[a.jsx(zt.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},className:"absolute inset-0 bg-black/80 backdrop-blur-sm",onClick:()=>v(!1)}),a.jsx(zt.div,{initial:{opacity:0,scale:.95,y:20},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:20},transition:{duration:.2,ease:"easeOut"},className:"relative flex flex-col items-center md:pb-[40px] max-h-[90dvh] bg-[#18181A] rounded-2xl shadow-2xl overflow-hidden",onClick:e=>e.stopPropagation(),children:a.jsxs("div",{className:"w-full max-w-6xl mx-auto",children:[a.jsxs("div",{className:"flex items-start justify-start w-full p-4 pb-2 md:p-8 md:pb-2",children:[a.jsxs("div",{className:"flex flex-col items-start justify-center gap-1",children:[a.jsx("img",{src:BK,alt:"Add Credits",className:"w-[60px] h-[60px] mb-2"}),a.jsx("h2",{className:"text-[20px] md:text-[26px] font-medium text-[#E6E6E6]",children:"low-credit"===n?"Running low on credits ?":"free"===r?`Upgrade to ${o()}`:"Buy more credits"})]}),a.jsx("button",{type:"button",onClick:()=>v(!1),disabled:u||_,className:bb("p-2 bg-[#FFFFFF05] absolute top-6 right-6 backdrop-blur-lg hover:bg-[#242424] rounded-full transition-colors",(u||_)&&"opacity-50 cursor-not-allowed"),"aria-label":"Close modal",children:a.jsx(HS,{className:"w-5 h-5 text-[#737780]"})})]}),a.jsx("div",{className:"p-4 flex items-center justify-center md:p-8 md:pt-0",children:a.jsxs("div",{className:"w-full space-y-4 max-h-[calc(90dvh-200px)] overflow-y-auto",children:[a.jsx("div",{className:"max-md:hidden",children:a.jsxs("p",{className:"text-sm text-white/50 md:text-[16px]",children:[a.jsx("span",{className:"font-medium",children:"Get "}),a.jsx("span",{className:"text-[#F3CA5F] font-medium",children:"5 Credits"}),a.jsx("span",{className:"font-medium",children:" for just "}),a.jsx("span",{className:"text-[#29CC83]",children:AT(IT(5,(null==(s=m[0])?void 0:s.currency)||"USD"),((null==(i=m[0])?void 0:i.currency)||"USD")===Cv)}),a.jsx("span",{className:"font-medium",children:"! Get our best value bundle with "}),a.jsx("span",{className:"text-[#F3CA5F] font-medium",children:"20% OFF"}),a.jsx("span",{className:"font-medium",children:" or enter a custom amount."})]})}),a.jsx("div",{className:"grid gap-4 md:grid-cols-5",children:m.map(e=>a.jsxs("div",{className:"bg-[#212124] min-w-[190px] items-center group md:min-h-[208px] pt-4 md:pt-8 pb-4 px-4 transition-all ease-in-out duration-100 border rounded-xl overflow-hidden relative "+(e.discount>0?"border-none":"border-[#FFFFFF1F] hover:border-[#FFFFFF4D]"),children:[e.discount>0&&a.jsx(kE,{duration:5,size:100,className:"opacity-50",colorFrom:"#F3CA5F",colorTo:"#F3CA5F"}),a.jsxs("div",{className:"flex items-center justify-between sm:gap-0 md:flex-col",children:[a.jsxs("div",{className:"flex items-center gap-2 md:mb-2 md:flex-col",children:[a.jsx("div",{children:a.jsx("img",{src:zK,alt:"Credits",className:"w-8 h-8 "+(e.discount>0?"":"grayscale group-hover:grayscale-0")})}),a.jsx("div",{className:"md:mb-1 text-sm md:text-[24px] font-semibold",children:e.discount>0?a.jsxs("div",{className:"flex flex-col items-center",children:[a.jsxs("span",{className:"text-[#E6E6E6]/40 line-through text-xs md:text-sm",children:[5*e.amount/6," credits"]}),a.jsxs("span",{className:" tracking-[-0.5px] text-[#F3CA5F] text-nowrap text-sm md:text-[24px]",children:[e.amount," credits"]})]}):a.jsxs("div",{className:"flex flex-col items-center",children:[a.jsx("span",{className:"text-xs text-transparent max-md:hidden md:text-sm",children:" "}),a.jsxs("span",{className:"text-[#E6E6E6] leading-[-0.5px] text-sm md:text-[24px]",children:[e.amount," credits"]})]})})]}),a.jsx("div",{className:"md:mb-6 text-sm md:text-[20px] text-[#E6E6E6]/80 group-hover:text-[#29CC83] transition-colors duration-200 ease-in-out",children:AT(e.price,e.currency===Cv)}),a.jsx("button",{type:"button",onClick:()=>{bg(JS.BUY_CREDITS_MODAL_EVENTS.BUNDLE_PURCHASE_CLICKED,{bundle_amount:e.amount,bundle_price:e.price,bundle_currency:e.currency,bundle_discount:e.discount,workspace:c,is_razorpay_flow:C,is_premium_bundle:e.discount>0});const t=c&&"personal"!==c?c:void 0;C?x(e,t):h(e,t,!1)},disabled:u,className:"w-fit md:w-full py-2 px-4 duration-200 ease-in-out text-black font-semibold rounded-full tracking-[-0.2px] transition-colors "+(e.discount>0?"bg-[#F3CA5F] hover:bg-[#E7A93C] shadow-md":"bg-[#cacacc] group-hover:bg-[#FFD566]"),children:u&&p===e.amount?a.jsxs("div",{className:"flex items-center justify-center",children:[a.jsx(gS,{className:"w-4 h-4 mr-2 animate-spin"}),a.jsx("span",{children:"Paying..."})]}):"Buy Now"})]})]},e.amount))}),a.jsxs("div",{className:"flex flex-col gap-2",children:[a.jsx("div",{className:"bg-[#212124] border border-[#FFFFFF1F] rounded-xl p-[14px] py-[10px] pr-[10px] px-4",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("div",{className:"relative flex items-center flex-1 gap-1",children:[N&&parseInt(N)>=0&&a.jsx("span",{className:"text-[#E6E6E6] font-semibold text-lg",children:b(j)}),a.jsx("input",{type:"text",value:N,onChange:e=>{const t=e.target.value;if(""===t)return F(""),void E("");if(!/^\d+$/.test(t))return;const n=parseInt(t,10);if(isNaN(n))return;const s=y(j);if(!(n>99999))if(F(t),bg(JS.BUY_CREDITS_MODAL_EVENTS.CUSTOM_AMOUNT_INPUT_CHANGED,{amount:n,currency:j,calculated_credits:I(t),is_within_limits:n>=s.minimum&&n<=s.maximum}),ns.maximum){const e=`For amounts over ${AT(s.maximum,j===Cv)}, use our premium bundle above for better value!`;E(e),bg(JS.BUY_CREDITS_MODAL_EVENTS.CUSTOM_AMOUNT_VALIDATION_ERROR,{error_type:"above_maximum",amount:n,maximum_allowed:s.maximum,currency:j,error_message:e})}else E("")},placeholder:` + Enter custom amount (${b(j)})`,className:"w-full text-lg pl-0 text-[#E6E6E6] font-['Inter'] text-[18px] font-semibold bg-transparent border-none outline-none placeholder:text-[#E6E6E6]/20 placeholder:p-0 placeholder:font-medium",inputMode:"numeric",pattern:"[0-9]*"})]}),a.jsx("button",{type:"button",onClick:async()=>{const e=parseInt(N,10),t=y(j);if(!(isNaN(e)||e<1||e>t.maximum)){bg(JS.BUY_CREDITS_MODAL_EVENTS.CUSTOM_AMOUNT_PURCHASE_CLICKED,{amount:e,currency:j,calculated_credits:I(N),workspace:c,is_razorpay_flow:C}),k(!0),E("");try{const t={amount:I(N),price:e,selected:!1,discount:0,currency:j},s=c&&"personal"!==c?c:void 0;C?await x(t,s):await h(t,s,!0),bg("buy_credits_clicked",{userId:null==d?void 0:d.id,credits:t.amount,price:t.price,discount:0,tier:r||"free",isCustomAmount:!0,bundleType:"custom",organizationId:s||"personal",triggerLocation:n,is_razorpay_flow:C})}catch(s){E("Failed to process payment. Please try again.")}finally{k(!1)}}},disabled:!N||parseInt(N,10)y(j).maximum||_||!!S,className:"px-5 py-[6px] rounded-[8px] font-semibold transition-all duration-200 ease-out "+(N&&parseInt(N,10)>=y(j).minimum&&parseInt(N,10)<=y(j).maximum?"bg-[#F3CA5F] hover:bg-[#E7A93C] text-black":"bg-[#FFFFFF20] text-[#18181A] cursor-not-allowed"),children:_?a.jsxs("div",{className:"flex items-center justify-center",children:[a.jsx(gS,{className:"w-4 h-4 mr-2 animate-spin"}),a.jsx("span",{children:"Processing..."})]}):N&&parseInt(N,10)>=y(j).minimum&&parseInt(N,10)<=y(j).maximum&&!S?`Buy ${I(N)} Credits`:"Buy"})]})}),a.jsx(Bt,{mode:"wait",children:S&&a.jsxs(zt.div,{initial:{opacity:0,x:20,height:0},animate:{opacity:1,x:0,height:"auto"},exit:{opacity:0,x:20,height:0},transition:{duration:.2,ease:"easeOut",height:{duration:.15}},className:"text-[14px] font-['Inter'] font-medium text-[#E57373] flex items-center gap-[6px] overflow-hidden",children:[a.jsx("img",{src:$K,alt:"Info",className:"flex-shrink-0 w-5 h-5"}),a.jsx("span",{children:S})]})})]}),a.jsx("div",{className:"pt-4",children:a.jsxs("button",{type:"button",className:"flex items-center text-sm text-white opacity-50 hover:text-white",onClick:()=>{bg(JS.BUY_CREDITS_MODAL_EVENTS.PRICING_INFO_LEARN_MORE_CLICKED,{tier:r,workspace:c,currency:w(),custom_amount_entered:!!N}),window.open("https://atlas-kb.com/atlas-e74243keac/articles/769724-credits-and-pricing","_blank")},children:[a.jsx("span",{className:"font-['Inter'] text-[16px] font-medium",children:"How do credits work?"}),a.jsx("img",{src:HK,alt:"External",className:"w-5 h-5 ml-1"})]})})]})})]})})]})}),document.body),f.isLoading&&a.jsx(PT,{isOpen:f.isLoading,onOpenChange:g,paymentType:f.paymentType||"credits",amount:f.amount,currency:f.currency})]}):null}const UK=wv.common.copperCoin;function WK({isOpen:e,onOpenChange:t,currentCost:n,jobId:s,onBudgetUpdate:i,maxBudget:r=20,variant:o="increase_budget"}){const[l,c]=Pe.useState(5),[d,u]=Pe.useState(!1),[p,m]=Pe.useState(o),{toast:h}=un(),x=()=>{c(e=>Math.min(e+1,500))},f=()=>{l>1&&c(e=>Math.max(e-1,1))},g=e=>{const t=e.target.value;if(""===t)return void c(0);if(!/^[0-9]*\.?[0-9]*$/.test(t))return;if(t.endsWith(".")&&!t.includes(".."))return;const n=parseFloat(t);!isNaN(n)&&n>=0&&n<=500?c(Math.round(100*n)/100):n>500&&c(500)},v=async()=>{if(l<=0)h({title:"Invalid Amount",description:"Budget increase must be greater than 0",variant:"destructive"});else if(l>500)h({title:"Invalid Amount",description:"Budget increase cannot exceed 500 credits",variant:"destructive"});else try{u(!0),await Ip(s,l);const e=await Ep(s);h({title:"Budget Updated",description:`Successfully increased budget to ${e.max_budget.toFixed(3)} Credits`}),i&&i(e.max_budget),t(!1)}catch(e){h({title:"Error",description:e instanceof Error?e.message:"Failed to update budget",variant:"destructive"})}finally{u(!1)}},{tier:b,credits:y}=sv(),w=e=>{e||t(!1)};return a.jsxs(a.Fragment,{children:[a.jsx(IA,{open:e&&"increase_budget"===p,onOpenChange:t,children:a.jsx(LA,{className:"max-w-[95%] sm:max-w-[650px] bg-[#0E0E0F] text-white border border-[#242424] rounded-2xl",children:(e=>{var s;if("increase_budget"===e)return a.jsxs(a.Fragment,{children:[a.jsx(PA,{className:"border-b border-[#2E2F34] md:pb-6 p-4",children:a.jsx("div",{className:"flex items-center justify-between",children:a.jsxs("div",{className:"flex flex-col items-start gap-2 md:gap-5",children:[a.jsx("div",{className:"flex items-center justify-center w-10 h-10 rounded-full",children:a.jsx("img",{src:UK,alt:"Coin",className:"w-8 h-8"})}),a.jsxs("div",{className:"flex flex-col gap-1 md:gap-2",children:[a.jsx(OA,{className:"text-[#C4C4CC] font-brockmann text-[16px] md:text-[22px] text-start font-medium md:leading-[28px] tracking-[-0.44px]",children:"Set Budget Limit"}),a.jsx("p",{className:"text-[#5C5F66] font-inter text-[14px] text-start md:text-base font-medium md:leading-6",children:"Session Budget prevent excessive token usage during a session."})]})]})})}),a.jsxs("div",{className:"p-4 py-8 space-y-4 md:space-y-6 md:px-8 md:py-6",children:[a.jsxs("div",{children:[a.jsx("h3",{className:"text-[#8A8B91] text-[13px] md:text-base md:mb-3",children:"Budget Used"}),a.jsxs("div",{className:"text-[24px] md:text-[32px] font-semibold leading-[38px]",children:[a.jsx("span",{className:"text-[#F3CA5F]",children:null==n?void 0:n.toFixed(3)}),a.jsx("span",{className:"text-[#C4C4CC] mx-2",children:"/"}),a.jsx("span",{className:"text-[#C4C4CC]",children:null==r?void 0:r.toFixed(3)}),a.jsx("span",{className:"text-[#C4C4CC] ml-2 text-xl",children:"Credits"})]})]}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-[#8A8B91] text-[13px] md:text-base mb-3",children:"Increase Budget"}),a.jsxs("div",{className:"flex items-center justify-between bg-[#0E0E0F] border border-[#242424] rounded-xl p-1 md:p-4",children:[a.jsx("button",{type:"button",onClick:f,className:"h-8 w-8 md:w-12 md:h-12 rounded-md md:rounded-xl bg-[#1E1F23] flex items-center justify-center text-2xl font-medium hover:bg-[#2A2B30] transition-colors",disabled:d,children:"-"}),a.jsx("div",{className:"flex items-center",children:a.jsxs("span",{className:" flex items-center md:text-[32px] font-semibold md:leading-[38px] mr-2",children:[a.jsx("img",{src:UK,alt:"Coin",className:"w-[18px] md:w-[28px] h-fit"}),a.jsx(KS,{type:"number",value:0===l?"":l.toString(),onChange:g,min:"0",max:"500",step:"0.01",className:"text-[24px] md:text-[32px] font-semibold md:leading-[38px] bg-transparent border-none text-center p-0 focus:ring-0 focus:outline-none [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none [-moz-appearance:textfield]",disabled:d,placeholder:"0.00"})]})}),a.jsx("button",{type:"button",onClick:x,className:" h-8 w-8 md:w-12 md:h-12 rounded-md md:rounded-xl bg-[#1E1F23] flex items-center justify-center text-2xl font-medium hover:bg-[#2A2B30] transition-colors",disabled:d,children:"+"})]})]}),y{m("add_credits")},children:" Buy Credits"})]}),y>l&&a.jsx("div",{className:"bg-[#f5cc621a] rounded-xl py-[10px] px-3",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-[#F5CC62] text-[13px] md:text-base",children:"Your new budget limit"}),a.jsxs("div",{children:[a.jsx("span",{className:"text-white/80 text-[13px] md:text-base",children:null==n?void 0:n.toFixed(3)}),a.jsx("span",{className:"text-base text-white/90",children:" / "}),a.jsx("span",{className:"text-[#F5CC62] text-[13px] md:text-base",children:null==(s=r+l)?void 0:s.toFixed(3)}),a.jsx("span",{className:"text-white/80 ml-2 text-[13px] md:text-base",children:"Credits"})]})]})})]}),a.jsx(RA,{className:"border-t border-[#2E2F34] p-4 md:mt-6 md:py-4",children:a.jsxs("div",{className:"flex justify-end gap-3 md:px-6",children:[a.jsx(Nb,{variant:"outline",onClick:()=>t(!1),className:"text-[#C4C4CC] px-4 h-[40px] hover:bg-[#242424] md:px-6 md:h-11 text-[16px] md:text-base font-medium",disabled:d,children:"Cancel"}),a.jsx(Nb,{onClick:v,disabled:d||l>y,className:"bg-white px-4 font-semibold h-[40px] text-black hover:bg-[#E5E5E5] md:px-6 md:h-11 text-[16px] md:text-base",children:d?"Updating...":"Confirm"})]})})]})})(p)})}),"free"!==b?a.jsx(VK,{isOpen:e&&"add_credits"===p,onOpenChange:w}):a.jsx(FM,{isOpen:e&&"add_credits"===p,onOpenChange:w})]})}const qK=({width:e=24,height:t=24,fill:n="#0E0E0F",className:s,style:i,maskId:r="mask0_upload_icon",...o})=>a.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:t,viewBox:"0 0 24 24",fill:"none",className:s,style:i,...o,children:[a.jsx("mask",{id:r,style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:"0",y:"0",width:"24",height:"24",children:a.jsx("rect",{width:"24",height:"24",fill:"#D9D9D9"})}),a.jsx("g",{mask:`url(#${r})`,children:a.jsx("path",{d:"M4.55844 18.0473C3.95044 17.3273 3.46244 16.5353 3.09444 15.6713C2.72644 14.8073 2.49444 13.9033 2.39844 12.9593H4.36644C4.46244 13.6473 4.63844 14.3073 4.89444 14.9393C5.15044 15.5713 5.48644 16.1593 5.90244 16.7033L4.55844 18.0473ZM2.39844 11.0393C2.52644 10.0953 2.76644 9.19127 3.11844 8.32727C3.47044 7.46326 3.95044 6.67127 4.55844 5.95127L5.90244 7.29527C5.48644 7.83927 5.15044 8.42727 4.89444 9.05927C4.63844 9.69127 4.46244 10.3513 4.36644 11.0393H2.39844ZM10.9904 21.5513C10.0464 21.4553 9.14644 21.2273 8.29044 20.8673C7.43444 20.5073 6.63844 20.0313 5.90244 19.4393L7.24644 18.0473C7.80644 18.4633 8.39844 18.8073 9.02244 19.0793C9.64644 19.3513 10.3024 19.5353 10.9904 19.6313V21.5513ZM7.29444 5.95127L5.90244 4.55927C6.65444 3.96727 7.46244 3.49127 8.32644 3.13127C9.19044 2.77127 10.0944 2.54327 11.0384 2.44727V4.36727C10.3504 4.46327 9.69044 4.64727 9.05844 4.91927C8.42644 5.19127 7.83844 5.53527 7.29444 5.95127ZM12.9104 21.5513V19.6313C13.6144 19.5353 14.2824 19.3553 14.9144 19.0913C15.5464 18.8273 16.1424 18.4793 16.7024 18.0473L18.0944 19.4393C17.3424 20.0473 16.5304 20.5273 15.6584 20.8793C14.7864 21.2313 13.8704 21.4553 12.9104 21.5513ZM16.7504 5.95127C16.1904 5.53527 15.5904 5.19127 14.9504 4.91927C14.3104 4.64727 13.6464 4.46327 12.9584 4.36727V2.44727C13.9024 2.54327 14.8104 2.77127 15.6824 3.13127C16.5544 3.49127 17.3584 3.96727 18.0944 4.55927L16.7504 5.95127ZM19.4384 18.0473L18.0944 16.7033C18.5104 16.1593 18.8464 15.5713 19.1024 14.9393C19.3584 14.3073 19.5344 13.6473 19.6304 12.9593H21.5984C21.4704 13.9033 21.2304 14.8073 20.8784 15.6713C20.5264 16.5353 20.0464 17.3273 19.4384 18.0473ZM19.6304 11.0393C19.5344 10.3513 19.3584 9.69127 19.1024 9.05927C18.8464 8.42727 18.5104 7.83927 18.0944 7.29527L19.4384 5.95127C20.0464 6.67127 20.5344 7.46326 20.9024 8.32727C21.2704 9.19127 21.5024 10.0953 21.5984 11.0393H19.6304ZM11.0624 16.7993V10.8713L8.56644 13.3673L7.22244 11.9993L12.0224 7.19927L16.8224 11.9993L15.4544 13.3433L12.9824 10.8713V16.7993H11.0624Z",fill:n})})]}),GK=({isOpen:e,onClose:t,rrwebEvents:n,testCasesData:s,isLoadingTestCases:i=!1,onSubmitScript:r,jobId:o})=>{const l=Pe.useRef(null),[c,d]=Pe.useState(null),[u,p]=Pe.useState(!1),[m,h]=Pe.useState({message:"Ready to load rrweb recording",type:"success"}),[x,f]=Pe.useState(""),[g,v]=Pe.useState(!1),[b,y]=Pe.useState(""),[w,j]=Pe.useState(""),[C,N]=Pe.useState(!1),[F,_]=Pe.useState([]),[k,S]=Pe.useState(null),E=async e=>{if(o)try{const n=[],s=new Blob([e.playwright_script],{type:"text/javascript"}),i=new File([s],"generated-playwright-test.js",{type:"text/javascript"});n.push({file:i,description:"Generated Playwright test script from user interaction recording"});const a=new Blob([e.console_logs],{type:"text/plain"}),r=new File([a],"console-logs.txt",{type:"text/plain"});n.push({file:r,description:"Console logs captured during user interaction recording (last 50 entries, TIMESTAMP:MESSAGE format)"});const l=new Blob([e.network_logs],{type:"text/plain"}),c=new File([l],"network-logs.txt",{type:"text/plain"});n.push({file:c,description:"Network requests captured during user interaction recording (last 50 entries, excluding PostHog)"});const d=[];for(const e of n)try{const t={file_name:e.file.name,mime_type:e.file.type},n=await om(o,t);await lm(n.upload_url,e.file),d.push({artifact_id:n.artifact_id,file_path:n.file_path,entity_id:o,entity_type:"job",visibility:"public",file_name:e.file.name,description:e.description})}catch(t){}if(d.length>0)try{await mm({artifacts:d});const e=d.map(e=>({artifact_id:e.artifact_id,file_name:e.file_name,description:e.description}));_(e)}catch(t){}}catch(t){}};Pe.useEffect(()=>{n&&n.length>0&&e?(async e=>{N(!0);try{if(!o)throw new Error("No job ID provided");const t=await gm(o,e);y(t.console_logs),j(t.network_logs),S({prefix:t.hitl_message_prefix,suffix:t.hit_message_suffix}),await E(t)}catch(t){y(`Error extracting console logs: ${t.message}`),j(`Error extracting network logs: ${t.message}`)}finally{N(!1)}})(n):e||(y(""),j(""),f(""),_([]),S(null),p(!1))},[n,e]),Pe.useEffect(()=>{if(!e)return;(async()=>{if(window.rrweb&&window.rrwebPlayer)return v(!0),void h({message:"Scripts loaded, ready to initialize player",type:"success"});try{if(h({message:"Loading rrweb player scripts...",type:"loading"}),window.rrweb||await new Promise((e,t)=>{const n=document.createElement("script");n.src="https://cdnjs.cloudflare.com/ajax/libs/rrweb/2.0.0-alpha.11/rrweb.min.js",n.onload=()=>{e(void 0)},n.onerror=e=>{t(e)},document.head.appendChild(n)}),!window.rrwebPlayer){const e=document.createElement("link");e.rel="stylesheet",e.href="https://cdn.jsdelivr.net/npm/rrweb-player@latest/dist/style.css",e.onload=()=>{},e.onerror=e=>{},document.head.appendChild(e),await new Promise((e,t)=>{const n=document.createElement("script");n.src="https://cdn.jsdelivr.net/npm/rrweb-player@latest/dist/index.js",n.onload=()=>{e(void 0)},n.onerror=e=>{t(e)},document.head.appendChild(n)})}v(!0),h({message:"Scripts loaded, ready to initialize player",type:"success"})}catch(e){h({message:"Error loading rrweb player: "+e.message,type:"error"})}})()},[e]),Pe.useEffect(()=>{if(!e&&c){try{"function"==typeof c.destroy?c.destroy():"function"==typeof c.$destroy&&c.$destroy()}catch(t){}d(null),p(!1),v(!1),h({message:"Ready to load rrweb recording",type:"success"}),l.current&&(l.current.innerHTML="")}},[e,c]),Pe.useEffect(()=>{if(!e||!n||0===n.length||!g||!l.current||c)return;const t=setTimeout(()=>{if(l.current&&!c)try{l.current&&(l.current.innerHTML="");const e=new window.rrwebPlayer({target:l.current,props:{events:n,width:800,height:600,autoPlay:!1,showController:!1,tags:{},loop:!0}});e&&e.addEventListener&&(e.addEventListener("start",()=>p(!0)),e.addEventListener("pause",()=>p(!1)),e.addEventListener("finish",()=>p(!1))),d(e),h({message:`Recording loaded successfully! ${n.length} events found.`,type:"success"})}catch(e){h({message:"Auto-initialization failed: "+e.message,type:"error"})}},200);return()=>clearTimeout(t)},[e,n,c,g]),Pe.useEffect(()=>{if(g&&e&&n&&n.length>0&&!c&&l.current){const e=setTimeout(()=>{try{l.current&&(l.current.innerHTML="");const e=new window.rrwebPlayer({target:l.current,props:{events:n,width:800,height:600,autoPlay:!1,loop:!0,showController:!1,tags:{}}});e&&e.addEventListener&&(e.addEventListener("start",()=>p(!0)),e.addEventListener("pause",()=>p(!1)),e.addEventListener("finish",()=>p(!1))),d(e),h({message:`Recording loaded successfully! ${n.length} events found.`,type:"success"})}catch(e){h({message:"Initialization failed: "+e.message,type:"error"})}},100);return()=>clearTimeout(e)}},[g,e,n,c]),Pe.useEffect(()=>()=>{if(c)try{"function"==typeof c.destroy?c.destroy():"function"==typeof c.$destroy&&c.$destroy()}catch(e){}},[c]);return a.jsx(IA,{open:e,onOpenChange:t,children:a.jsxs(LA,{className:"max-w-[1432px] w-[1432px] h-[736px] bg-[#18181a] border-[#242424] rounded-[20px] text-white flex flex-col p-0",children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-6 border-b border-[#242424] bg-[#18181a]",children:[a.jsxs("div",{className:"flex flex-col gap-1.5",children:[a.jsx("h2",{className:"text-[20px] leading-6 font-medium text-white tracking-[-0.2px]",children:"Review Test session"}),a.jsx("p",{className:"text-[14px] leading-5 font-medium text-[#737780]",children:"Review the generated summary and make any edits before we relay the session."})]}),a.jsx("button",{onClick:t,className:"backdrop-blur-[25px] bg-white/[0.02] w-10 h-10 flex items-center justify-center rounded-[10px] p-2 hover:bg-white/[0.04] transition-colors",children:a.jsx(HS,{className:"w-6 h-6 text-white"})})]}),a.jsxs("div",{className:"flex-1 flex gap-0 overflow-hidden",children:[a.jsxs("div",{className:"w-[716px] bg-[#09090a] border-r border-[#242424] overflow-hidden relative shrink-0 flex items-center justify-center",children:[a.jsx("div",{ref:l,className:"w-full h-full flex items-center justify-center"}),c&&a.jsxs("div",{className:"absolute bottom-4 left-1/2 transform -translate-x-1/2 flex items-center gap-2 bg-black/70 backdrop-blur-sm rounded-lg px-4 py-2",children:[a.jsx("button",{onClick:()=>{u?c&&"function"==typeof c.pause&&(c.pause(),p(!1)):c&&"function"==typeof c.play&&(c.play(),p(!0))},className:"flex items-center justify-center w-10 h-10 rounded-full bg-white/20 hover:bg-white/30 transition-colors text-white",children:u?a.jsx(wS,{className:"w-5 h-5"}):a.jsx(CS,{className:"w-5 h-5 ml-0.5"})}),a.jsx("span",{className:"text-white text-sm",children:u?"Playing":"Paused"})]}),"loading"===m.type&&a.jsx("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center",children:a.jsxs("div",{className:"flex items-center gap-2 text-white",children:[a.jsx(gS,{className:"w-5 h-5 animate-spin"}),a.jsx("span",{children:m.message})]})})]}),a.jsx("div",{className:"w-[716px] flex flex-col overflow-hidden border-l border-[#242424] bg-[#18181a]",children:a.jsxs(R$,{defaultValue:"instructions",className:"h-full flex flex-col",children:[a.jsxs(O$,{className:"flex gap-8 items-center px-4 border-b border-[#242424] bg-transparent rounded-none h-auto py-0 w-full justify-start",children:[a.jsx(z$,{value:"instructions",className:"bg-transparent px-0 py-4 gap-2.5 border-b-[1px] border-transparent data-[state=active]:border-[#80fff9] data-[state=active]:text-[#80fff9] text-white/60 text-base leading-5 tracking-[-0.2px] font-medium rounded-none shadow-none",children:"Custom instructions"}),a.jsx(z$,{value:"script",className:"bg-transparent px-0 py-4 gap-2.5 border-b-[1px] border-transparent data-[state=active]:border-[#80fff9] data-[state=active]:text-[#80fff9] text-white/60 text-base leading-5 tracking-[-0.2px] font-medium rounded-none shadow-none",children:"Generated Test script"}),a.jsx(z$,{value:"console",className:"bg-transparent px-0 py-4 gap-2.5 border-b-[1px] border-transparent data-[state=active]:border-[#80fff9] data-[state=active]:text-[#80fff9] text-white/60 text-base leading-5 tracking-[-0.2px] font-medium rounded-none shadow-none",children:"Console logs"}),a.jsx(z$,{value:"network",className:"bg-transparent px-0 py-4 gap-2.5 border-b-[1px] border-transparent data-[state=active]:border-[#80fff9] data-[state=active]:text-[#80fff9] text-white/60 text-base leading-5 tracking-[-0.2px] font-medium rounded-none shadow-none",children:"Network logs"})]}),a.jsx(B$,{value:"instructions",className:"flex-1 flex flex-col mt-0 min-h-0 overflow-hidden data-[state=inactive]:!hidden px-4 pt-6",children:a.jsx("div",{className:"flex-1 bg-white/[0.02] border border-white/[0.12] rounded-[10px] p-6 overflow-hidden flex flex-col",children:a.jsx(_E,{placeholder:"Add custom instructions for the Agent to follow...",value:x,onChange:e=>f(e.target.value),className:"flex-1 bg-transparent border-none text-white placeholder:text-white/50 placeholder:text-[15px] placeholder:font-medium resize-none focus-visible:ring-0 p-0",rows:10})})}),a.jsx(B$,{value:"script",className:"flex-1 flex flex-col mt-0 min-h-0 overflow-hidden data-[state=inactive]:!hidden px-4 pt-6",children:a.jsx("div",{className:"flex-1 bg-white/[0.02] border border-white/[0.12] rounded-[10px] p-6 overflow-hidden flex flex-col",children:i?a.jsxs("div",{className:"flex items-center gap-2 justify-center h-full text-gray-400",children:[a.jsx(gS,{className:"w-5 h-5 animate-spin"}),a.jsx("span",{children:"Loading test script..."})]}):s?a.jsx("div",{className:"flex-1 overflow-auto",children:a.jsx("pre",{className:"text-sm text-green-400 font-mono whitespace-pre-wrap",children:"string"==typeof s?s:JSON.stringify(s,null,2)})}):a.jsx("div",{className:"flex-1 flex items-center justify-center text-gray-400",children:a.jsxs("div",{className:"text-center",children:[a.jsx("div",{className:"text-3xl mb-2",children:"📝"}),a.jsx("div",{children:"No test script generated yet."})]})})})}),a.jsx(B$,{value:"console",className:"flex-1 flex flex-col mt-0 min-h-0 overflow-hidden data-[state=inactive]:!hidden px-4 pt-6",children:a.jsx("div",{className:"flex-1 bg-white/[0.02] border border-white/[0.12] rounded-[10px] p-6 overflow-hidden flex flex-col",children:C?a.jsxs("div",{className:"flex items-center gap-2 justify-center h-full text-gray-400",children:[a.jsx(gS,{className:"w-5 h-5 animate-spin"}),a.jsx("span",{children:"Extracting console logs..."})]}):a.jsx("div",{className:"flex-1 overflow-auto",children:a.jsx("pre",{className:"text-sm text-gray-300 font-mono whitespace-pre-wrap",children:b||"No console logs captured during recording session."})})})}),a.jsx(B$,{value:"network",className:"flex-1 flex flex-col mt-0 min-h-0 overflow-hidden data-[state=inactive]:!hidden px-4 pt-6",children:a.jsx("div",{className:"flex-1 bg-white/[0.02] border border-white/[0.12] rounded-[10px] p-6 overflow-hidden flex flex-col",children:C?a.jsxs("div",{className:"flex items-center gap-2 justify-center h-full text-gray-400",children:[a.jsx(gS,{className:"w-5 h-5 animate-spin"}),a.jsx("span",{children:"Extracting network logs..."})]}):a.jsx("div",{className:"flex-1 overflow-auto",children:a.jsx("pre",{className:"text-sm text-gray-300 font-mono whitespace-pre-wrap",children:w||"No network requests captured during recording session."})})})})]})})]}),a.jsxs("div",{className:"flex items-center justify-end gap-4 px-6 py-6 border-t border-[#242424] bg-[#18181a]",children:[a.jsx(Nb,{onClick:t,variant:"outline",className:"bg-white/[0.06] border-none text-white/60 hover:bg-white/[0.08] hover:text-white h-12 px-5 rounded-[28px] text-base font-semibold tracking-[-0.2px]",children:"Cancel"}),a.jsx(Nb,{onClick:()=>{if(!s||"string"!=typeof s||!r)return;if(!k)throw new Error("[MODAL_API] No message template available! API extraction may have failed or template was not set.");if(!k.prefix)throw new Error("[MODAL_API] Message template prefix is missing!");if(!k.suffix)throw new Error("[MODAL_API] Message template suffix is missing!");const e=x.trim(),t=e?` ${e} `:" ",n=`${k.prefix}${t}${k.suffix}`.replace(/\?testmode=1/g,"");r(n,F)},disabled:!s||"string"!=typeof s||!r,className:"bg-white text-[#0e0e0f] hover:bg-white/90 h-12 px-5 rounded-[28px] text-base font-semibold tracking-[-0.2px] flex items-center gap-2 leading-6",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("p",{children:"Share with Agent"}),a.jsx(qK,{style:{width:"24px",height:"24px"}})]})})]})]})})};var ZK,YK,KK={exports:{}}; /*! Copyright (c) 2018 Jed Watson. Licensed under the MIT License (MIT), see http://jedwatson.github.io/classnames */const JK=Le((ZK||(ZK=1,YK=KK,function(){var e={}.hasOwnProperty;function t(){for(var e="",t=0;t{if(e)try{const e=await l();return e.data?e.data:void 0}catch(t){return}},[e,l]),x=Pe.useCallback(async(t,s=!0)=>{var a;if(e)try{const a=await c({jobId:e,amount:t,organization_id:i||void 0}).unwrap();return s&&n({title:"Budget Updated",description:`Successfully increased budget to ${a.max_budget.toFixed(3)} Credits`}),a}catch(r){const e=(null==r?void 0:r.error)||(null==(a=null==r?void 0:r.data)?void 0:a.error)||(null==r?void 0:r.message)||"Failed to update budget";return void(s&&n({title:"Error",description:e,variant:"destructive"}))}},[e,c,n,i]);return Pe.useEffect(()=>{e&&t&&l()},[i,e,t,l]),{budgetInfo:a||null,isLoading:p,error:m,fetchBudgetInfo:h,updateBudget:x}}function XK({show:e,onClose:t,selectedPrivacy:n,onPrivacyChange:s,position:i}){const r=Pe.useRef(null),{tier:o}=sv(),l=UE();return Pe.useEffect(()=>{const n=n=>{if(!r.current)return;const s=n.target;e&&!r.current.contains(s)&&t()},s=()=>{e&&t()};return e&&(document.addEventListener("mousedown",n),window.addEventListener("scroll",s,!0),window.addEventListener("resize",s)),()=>{document.removeEventListener("mousedown",n),window.removeEventListener("scroll",s,!0),window.removeEventListener("resize",s)}},[e,t]),e?Be.createPortal(a.jsxs("div",{ref:r,className:"fixed z-[9999] bg-[#18181A] border border-[#242424] rounded-[12px] shadow-lg overflow-hidden",style:{top:`${i.top}px`,left:`${i.left}px`},children:[a.jsxs("div",{className:"flex items-center px-4 py-3 hover:bg-[#242424] cursor-pointer transition-colors",onClick:()=>{Cg("privacy_selection_changed",{selectedPrivacy:"public",previousPrivacy:n,source:"chat_info_panel_dropdown",userTier:o}),s("public"),t()},children:[a.jsx("div",{className:"min-w-[20px] min-h-[20px] max-w-[20px] max-h-[20px] rounded-full border border-white flex items-center justify-center mr-4",children:"public"===n&&a.jsx("div",{className:"w-[10px] h-[10px] rounded-full bg-[#D9D9D9]"})}),a.jsxs("div",{className:"flex flex-col gap-[2px]",children:[a.jsxs("div",{className:bb("flex items-center gap-1 text-sm font-medium text-white/60","public"===n&&"text-white"),children:["Public ",a.jsx(XI,{size:14,className:bb("public"!==n&&"opacity-60")})]}),a.jsx("div",{className:bb("text-xs text-white/50","public"===n&&"text-white"),children:"Anyone can view and explore"})]})]}),a.jsxs("div",{className:"flex items-center px-4 py-3 hover:bg-[#242424] cursor-pointer transition-colors",onClick:()=>{Cg("privacy_selection_changed",{selectedPrivacy:"private",previousPrivacy:n,source:"chat_info_panel_dropdown",userTier:o,wasBlocked:"free"===o}),"free"===o?l.open({triggerLocation:"default"}):s("private"),t()},children:[a.jsx("div",{className:"min-w-[20px] min-h-[20px] max-w-[20px] max-h-[20px] rounded-full border border-white flex items-center justify-center mr-4",children:"private"===n&&a.jsx("div",{className:"w-[10px] h-[10px] rounded-full bg-[#D9D9D9]"})}),a.jsx("div",{className:"flex items-center",children:a.jsxs("div",{className:"flex flex-col gap-[2px]",children:[a.jsxs("div",{className:bb("flex items-center gap-1 text-sm font-medium text-white/60","private"===n&&"text-white"),children:["Private ",a.jsx(dA,{size:14,opacity:"private"===n?1:.3})]}),a.jsx("div",{className:bb("text-xs text-white/50","private"===n&&"text-white"),children:"Only visible to yourself, unless shared"})]})})]})]}),document.body):null}function eJ({show:e,onClose:t,selectedPrivacy:n,onPrivacyChange:s}){const{tier:i}=sv(),r=UE();return e?Be.createPortal(a.jsxs(ZI,{open:e,onOpenChange:t,title:"Privacy Settings",showDefaultFooter:!1,maxWidth:"max-w-sm",contentPadding:"p-0",showCancel:!0,onCancel:t,trigger:a.jsx(a.Fragment,{}),children:[a.jsx("div",{className:"h-[1px] w-full bg-[#242424]"}),a.jsxs("div",{className:"p-4",children:[a.jsxs("div",{className:"flex items-center py-4 transition-colors cursor-pointer",onClick:()=>{Cg("privacy_selection_changed",{selectedPrivacy:"public",previousPrivacy:n,source:"chat_info_panel_mobile_sheet",userTier:i}),s("public"),t()},children:[a.jsx("div",{className:"min-w-[20px] min-h-[20px] max-w-[20px] max-h-[20px] rounded-full border border-white flex items-center justify-center mr-4",children:"public"===n&&a.jsx("div",{className:"w-[10px] h-[10px] rounded-full bg-[#D9D9D9]"})}),a.jsxs("div",{className:"flex flex-col gap-[2px]",children:[a.jsxs("div",{className:bb("flex items-center gap-1 text-sm font-medium text-white/60","public"===n&&"text-white"),children:["Public ",a.jsx(XI,{size:14,className:bb("public"!==n&&"opacity-60")})]}),a.jsx("div",{className:bb("text-xs text-white/50","public"===n&&"text-white"),children:"Anyone can view and explore"})]})]}),a.jsxs("div",{className:"flex items-center py-4 transition-colors cursor-pointer",onClick:()=>{Cg("privacy_selection_changed",{selectedPrivacy:"private",previousPrivacy:n,source:"chat_info_panel_mobile_sheet",userTier:i,wasBlocked:"free"===i}),"free"===i?r.open({triggerLocation:"default"}):s("private"),t()},children:[a.jsx("div",{className:"min-w-[20px] min-h-[20px] max-w-[20px] max-h-[20px] rounded-full border border-white flex items-center justify-center mr-4",children:"private"===n&&a.jsx("div",{className:"w-[10px] h-[10px] rounded-full bg-[#D9D9D9]"})}),a.jsx("div",{className:"flex items-center",children:a.jsxs("div",{className:"flex flex-col gap-[2px]",children:[a.jsxs("div",{className:bb("flex items-center gap-1 text-sm font-medium text-white/60","private"===n&&"text-white"),children:["Private ",a.jsx(dA,{size:14,opacity:"private"===n?1:.3})]}),a.jsx("div",{className:bb("text-xs text-white/50","private"===n&&"text-white"),children:"Only visible to yourself, unless shared"})]})})]})]})]}),document.body):null}const tJ=({title:e,value:t,copyable:n=!1,maxChars:s,onClick:i,className:r,icon:o})=>{const l=s&&t&&t.length>s?`${t.slice(0,s)}...`:t;return a.jsxs("div",{className:"space-y-2",children:[a.jsx("div",{className:"text-[#7B7B80] font-medium font-['Inter'] text-sm",children:e}),a.jsxs("div",{className:bb("flex items-center justify-between gap-2",r),onClick:i,children:[a.jsx("div",{className:"text-[#C4C4CC] font-['Inter'] text-base group-hover:text-[#2EBBE5] transition-colors duration-200",children:l||"—"}),n&&t&&a.jsx(oH,{tooltipEnabled:!0,showTooltipOnHover:!0,tooltipText:"Copy",copiedTooltipText:"Copied",showIcon:!0,iconOnly:!0,className:"border-none bg-none",buttonClassName:Cb({variant:"outline",size:"sm",className:"whitespace-nowrap rounded-lg transition-all ease-in-out duration-200 border-white/20 border hover:bg-white/20 hover:text-white text-white/40"}),value:()=>t,iconProps:{size:16},onCopy:async()=>{await navigator.clipboard.writeText(t)}}),o&&!n&&a.jsx("div",{className:"flex items-center justify-center min-w-[40px] min-h-[36px] cursor-pointer rounded-md hover:bg-white/10 transition-colors duration-200",onClick:i,children:a.jsx("img",{src:o,alt:"icon",className:"w-4 h-4"})})]})]})},nJ=({title:e})=>a.jsx(a.Fragment,{children:a.jsxs("div",{className:"flex items-center w-full gap-2",children:[a.jsx("div",{className:"h-[1px] flex-1 bg-[#FFFFFF12]"}),a.jsx("span",{className:"text-[#FFFFFF4D] text-[14px] font-berkeley uppercase tracking-[1px]",children:e}),a.jsx("div",{className:"h-[1px] max-w-[30px] flex-1 bg-[#FFFFFF12]"})]})}),sJ=wv.upload.moreIcon,iJ=wv.upload.delete,aJ=wv.files.pdf,rJ=wv.files.csv,oJ=wv.files.doc,lJ=wv.files.ppt,cJ=wv.files.txt,dJ=wv.files.video,uJ=wv.files.zip,pJ=wv.files.other,mJ=wv.files.svg,hJ=wv.upload.downloadWhite,xJ=wv.upload.deleteActive,fJ=(e,t)=>{const n=(null==t?void 0:t.toLowerCase())||"";return n.endsWith(".pdf")||"application/pdf"===e?aJ:n.endsWith(".csv")||"text/csv"===e?rJ:n.endsWith(".zip")||n.endsWith(".tar")||n.endsWith(".rar")||n.endsWith(".7z")||(null==e?void 0:e.includes("zip"))||(null==e?void 0:e.includes("tar"))||(null==e?void 0:e.includes("rar"))||(null==e?void 0:e.includes("7z"))?uJ:n.endsWith(".doc")||n.endsWith(".docx")||"application/msword"===e||"application/vnd.openxmlformats-officedocument.wordprocessingml.document"===e?oJ:n.endsWith(".ppt")||n.endsWith(".pptx")||"application/vnd.ms-powerpoint"===e||"application/vnd.openxmlformats-officedocument.presentationml.presentation"===e?lJ:n.endsWith(".txt")||n.endsWith(".md")||n.endsWith(".log")||"text/plain"===e||"text/markdown"===e?cJ:n.endsWith(".mp4")||n.endsWith(".avi")||n.endsWith(".mov")||n.endsWith(".wmv")||n.endsWith(".mkv")||(null==e?void 0:e.startsWith("video/"))?dJ:n.endsWith(".svg")||"image/svg+xml"===e?mJ:n.endsWith(".xls")||n.endsWith(".xlsx")||"application/vnd.ms-excel"===e||"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"===e?rJ:pJ},gJ=(e,t=15)=>{const n=e.lastIndexOf(".");if(-1===n)return e.length>t?e.substring(0,t)+"...":e;const s=e.substring(0,n),i=e.substring(n);return s.length<=t?e:s.substring(0,t)+"..."+i};function vJ({title:e,size:t,id:n,type:s,url:i,visibility:r="public",onRemove:o,onDownload:l}){const[c,d]=Pe.useState(!1),[u,p]=Pe.useState(!1),[m,h]=Pe.useState({top:0,right:0}),x=Pe.useRef(null),f=Pe.useRef(null),g=fJ(s,e)===uJ;Pe.useEffect(()=>{const e=e=>{x.current&&!x.current.contains(e.target)&&d(!1)};return c&&document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[c]);const v=fJ(s,e),b=(w=e,(y=s).startsWith("image/")?xS:y.startsWith("video/")?BS:y.startsWith("text/")||w.endsWith(".txt")?pS:y.includes("zip")||y.includes("tar")||y.includes("rar")?Ok:w.endsWith(".pdf")||w.endsWith(".csv")||w.endsWith(".xlsx")?pS:mS);var y,w;const j=(e=>e.startsWith("image"))(s)&&i,C="private"===r&&!i;return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-center justify-between gap-4 group rounded-[12px] p-2 "+(C?"opacity-60":"hover:bg-[#FFFFFF0A] cursor-pointer"),onClick:e=>{x.current&&x.current.contains(e.target)||("private"!==r||i)&&(j?p(!0):null==l||l(n))},children:[a.jsxs("div",{className:"min-w-[40px] min-h-[40px] max-h-[40px] max-w-[40px] backdrop-blur-sm rounded-[8px] flex items-center justify-center overflow-hidden "+(j?"hover:bg-[#FFFFFF15] transition-colors":""),children:[j&&!C?a.jsx("img",{src:i,alt:e,className:"w-full h-full object-cover rounded-[6px]",onError:e=>{var t;const n=e.target;n.style.display="none",null==(t=n.nextElementSibling)||t.classList.remove("hidden")}}):null,v?a.jsx("img",{src:v,alt:"File",className:`w-10 h-10 ${j?"hidden":""} ${g&&"p-1"}`}):a.jsx(b,{className:"w-5 h-5 text-[#FFFFFF60] "+(j?"hidden":"")})]}),a.jsxs("div",{className:"flex flex-col flex-1",children:[a.jsx("span",{className:"text-[#FFFFFF] font-['Inter'] font-medium max-w-[60%] text-[16px] opacity-60 transition-all duration-100 ease-in-out",children:gJ(e)}),a.jsx("div",{className:"flex flex-col",children:a.jsx("span",{className:"text-[#FFFFFF40] font-['Inter'] font-medium text-[12px] ",children:t})})]}),a.jsx("div",{className:"relative",children:a.jsx("div",{ref:f,className:"hover:bg-[#FFFFFF0F] backdrop-blur-lg rounded-[8px] cursor-pointer p-1 transition-opacity duration-200 "+(c?"opacity-100":"opacity-0 group-hover:opacity-60 hover:!opacity-100"),onClick:e=>{if(e.stopPropagation(),!c&&f.current){const e=f.current.getBoundingClientRect();h({top:e.bottom+4,right:window.innerWidth-e.right})}d(!c)},children:a.jsx("img",{src:sJ,alt:"More",className:"w-6 h-6"})})})]}),c&&Be.createPortal(a.jsxs("div",{ref:x,className:"fixed z-[9999] p-[6px] bg-[#18181A] backdrop-blur-sm rounded-[12px] border border-[#242424] shadow-lg min-w-[140px]",style:{top:m.top,right:m.right},children:[a.jsxs("button",{type:"button",onClick:e=>{e.stopPropagation(),null==o||o(n),d(!1)},className:"flex items-center gap-2 rounded-[8px] w-full p-2 text-left text-[#808080] hover:text-[#CCCCCC] hover:bg-[#ED5B5B0F] transition-colors duration-150 group/remove",children:[a.jsx("img",{src:iJ,alt:"Remove",className:"w-5 h-5 group-hover/remove:hidden"}),a.jsx("img",{src:xJ,alt:"Remove",className:"hidden w-5 h-5 group-hover/remove:block"}),a.jsx("span",{className:" font-medium text-[14px] group-hover/remove:text-[#ED5B5B]",children:"Remove"})]}),a.jsxs("button",{type:"button",onClick:e=>{e.stopPropagation(),("private"!==r||i)&&(null==l||l(n),d(!1))},className:"flex items-center gap-2 w-full p-2 rounded-[8px] py-2 text-left text-[#808080] hover:text-[#CCCCCC] hover:bg-[#FFFFFF0A] transition-colors duration-150 group/download",children:[a.jsx("img",{src:hJ,alt:"Download",className:"w-5 h-5 group-hover/download:hidden opacity-40"}),a.jsx("img",{src:hJ,alt:"Download",className:"hidden w-5 h-5 group-hover/download:block"}),a.jsx("span",{className:" font-medium text-[14px]",children:"Download"})]})]}),document.body),j&&a.jsx(w$,{imageUrl:i,imageName:e,isOpen:u,onClose:()=>p(!1)})]})}const bJ=wv.upload.arrowNext,yJ=wv.upload.noAssets,wJ=wv.upload.uploadNormal,jJ=e=>{const t="string"==typeof e?parseInt(e):e;if(isNaN(t))return"Unknown size";const n=["B","KB","MB","GB"];let s=0,i=t;for(;i>=1024&&s"assets"===e?a.jsx("div",{className:"flex-1 p-6 pt-4 overflow-x-hidden overflow-y-auto",children:t?n?a.jsx("div",{className:"flex items-center justify-center h-full",children:a.jsxs("div",{className:"text-center text-[#666]",children:[a.jsx("div",{className:"animate-spin w-8 h-8 border-2 border-[#5FD3F3] border-t-transparent rounded-full mx-auto mb-4"}),a.jsx("p",{children:"Loading assets..."})]})}):0===s.length?a.jsx("div",{className:"flex items-center justify-center h-full",children:a.jsxs("div",{className:"text-center text-[#666]",children:[a.jsx(mS,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),a.jsx("p",{children:"No assets uploaded"}),a.jsx("p",{className:"mt-1 text-sm",children:"Upload files using the upload button in the chat input"})]})}):a.jsx("div",{className:"flex flex-col gap-2",children:s.map(e=>a.jsx(vJ,{title:e.name,size:jJ(e.file_size||0),type:e.mime_type||"",url:e.public_url||"",visibility:e.visibility,id:e.id,onRemove:t=>r(t,e.name),onDownload:()=>o(e)},e.id))}):a.jsx("div",{className:"flex items-center justify-center h-full",children:a.jsxs("div",{className:"text-center text-[#666]",children:[a.jsx(mS,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),a.jsx("p",{children:"No job selected"}),a.jsx("p",{className:"mt-1 text-sm",children:"Assets will appear here when you have an active job"})]})})}):a.jsx("div",{className:"",children:n?a.jsx("div",{className:"flex items-center justify-center py-8",children:a.jsxs("div",{className:"text-center text-[#666]",children:[a.jsx("div",{className:"animate-spin w-6 h-6 border-2 border-[#5FD3F3] border-t-transparent rounded-full mx-auto mb-2"}),a.jsx("p",{className:"text-sm",children:"Loading assets..."})]})}):0===s.length?a.jsxs("div",{className:"flex flex-col items-center justify-center py-8",children:[a.jsxs("div",{className:"text-center text-[#666] max-w-[450px]",children:[a.jsx("img",{src:yJ,alt:"No Assets",className:"h-12 mx-auto mb-4"}),a.jsx("p",{className:"text-[14px] font-['Inter'] font-medium text-[#FFFFFF20]",children:"Upload assets or sync files to be used as sources"})]}),a.jsx("button",{type:"button",onClick:i,className:"w-full max-w-[180px] mt-5 radial-green text-[#80FFF9] flex justify-center items-center gap-2 p-3 py-2 rounded-[10px] ",children:"Upload Assets"})]}):a.jsxs(a.Fragment,{children:[s.slice(0,3).map(e=>a.jsx(vJ,{title:e.name,size:jJ(e.file_size||0),type:e.mime_type||"",url:e.public_url||"",visibility:e.visibility,id:e.id,onRemove:t=>r(t,e.name),onDownload:()=>o(e)},e.id)),a.jsxs("div",{className:"flex items-center gap-4 mt-4",children:[a.jsxs("button",{type:"button",onClick:i,className:"w-full radial-green text-[#80FFF9] flex justify-center items-center gap-2 p-3 py-2 rounded-[10px] ",children:[a.jsx("img",{src:wJ,alt:"Add",className:"w-5 h-5"}),"Upload Files"]}),s.length>3&&a.jsxs("button",{type:"button",onClick:l,className:"w-full radial-black-upload p-3 py-2 hover:opacity-80 text-[#FFFFFF66] flex justify-center items-center gap-2 rounded-[10px] ",children:["View all (",s.length,")",a.jsx("img",{src:bJ,alt:"Arrow",className:"w-5 h-5"})]})]})]})}),NJ=({size:e,width:t=20,height:n=20,color:s="#F3CA5F",fill:i,className:r="",style:o,onClick:l,...c})=>{const d=e||t,u=e||n,p=i||s;return a.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:d,height:u,viewBox:"0 0 20 20",fill:"none",className:r,style:o,onClick:l,...c,children:[a.jsxs("g",{style:{mixBlendMode:"luminosity"},clipPath:"url(#clip0_12024_101153)",children:[a.jsx("circle",{opacity:"0.1",cx:"10",cy:"10",r:"10",fill:p}),a.jsx("path",{d:"M10 2C14.4183 2 18 5.58172 18 10C18 14.4183 14.4183 18 10 18C5.58172 18 2 14.4183 2 10C2 5.58172 5.58172 2 10 2ZM10.4082 6.58984C10.1446 5.93661 9.92302 5.71814 9.60645 6.49805C8.91401 8.15984 8.0872 8.95183 6.45996 9.6377C6.29657 9.71319 6.00191 9.84453 6 10C6.00211 10.1554 6.29471 10.2868 6.45996 10.3623C8.08527 11.0462 8.91405 11.8399 9.60645 13.502C9.9268 14.2958 10.1491 14.0465 10.4082 13.4102C11.1026 11.8036 11.8788 11.0584 13.5166 10.3623C13.6883 10.2804 13.9713 10.1709 14 10.0078V9.98926C13.9709 9.8277 13.6901 9.71755 13.5166 9.63574V9.6377C11.8789 8.9416 11.1026 8.19694 10.4082 6.58984Z",fill:p}),a.jsx("path",{d:"M10 2C14.4183 2 18 5.58172 18 10C18 14.4183 14.4183 18 10 18C5.58172 18 2 14.4183 2 10C2 5.58172 5.58172 2 10 2ZM10.4082 6.58984C10.1446 5.93661 9.92302 5.71814 9.60645 6.49805C8.91401 8.15984 8.0872 8.95183 6.45996 9.6377C6.29657 9.71319 6.00191 9.84453 6 10C6.00211 10.1554 6.29471 10.2868 6.45996 10.3623C8.08527 11.0462 8.91405 11.8399 9.60645 13.502C9.9268 14.2958 10.1491 14.0465 10.4082 13.4102C11.1026 11.8036 11.8788 11.0584 13.5166 10.3623C13.6883 10.2804 13.9713 10.1709 14 10.0078V9.98926C13.9709 9.8277 13.6901 9.71755 13.5166 9.63574V9.6377C11.8789 8.9416 11.1026 8.19694 10.4082 6.58984Z",fill:"url(#paint0_linear_12024_101153)",style:{mixBlendMode:"overlay"}})]}),a.jsxs("defs",{children:[a.jsxs("linearGradient",{id:"paint0_linear_12024_101153",x1:"10",y1:"2",x2:"10",y2:"18",gradientUnits:"userSpaceOnUse",children:[a.jsx("stop",{stopColor:"white"}),a.jsx("stop",{offset:"1"})]}),a.jsx("clipPath",{id:"clip0_12024_101153",children:a.jsx("rect",{width:"20",height:"20",fill:"white"})})]})]})},FJ=({size:e,width:t=20,height:n=20,color:s="#F3CA5F",fill:i,className:r="",style:o,onClick:l,...c})=>{const d=e||t,u=e||n;return a.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:d,height:u,viewBox:"0 0 20 20",fill:"none",className:r,style:o,onClick:l,...c,children:a.jsx("path",{d:"M8.61905 10.4762C6.31429 10.4762 4.14286 9.90476 2.90476 9V6.32381C4.30476 7.11429 6.34286 7.61905 8.61905 7.61905C10.8952 7.61905 12.9333 7.11429 14.3333 6.32381V8.64762C14.6476 8.6 14.9619 8.57143 15.2857 8.57143C15.6095 8.57143 15.9238 8.6 16.2381 8.64762V3.80952C16.2381 1.70476 12.8286 0 8.61905 0C4.40952 0 1 1.70476 1 3.80952V13.3333C1 15.4381 4.41905 17.1429 8.61905 17.1429H8.89524C8.7165 16.5236 8.62357 15.8827 8.61905 15.2381C4.93333 15.2381 2.90476 13.8095 2.90476 13.3333V11.2095C4.4381 11.9524 6.44762 12.381 8.61905 12.381C8.84762 12.381 9.06667 12.381 9.28572 12.3524C9.66667 11.5619 10.1905 10.8667 10.8286 10.2952C10.1238 10.4095 9.38095 10.4762 8.61905 10.4762ZM8.61905 1.90476C12.3048 1.90476 14.3333 3.33333 14.3333 3.80952C14.3333 4.28571 12.3048 5.71429 8.61905 5.71429C4.93333 5.71429 2.90476 4.28571 2.90476 3.80952C2.90476 3.33333 4.93333 1.90476 8.61905 1.90476ZM18.8095 15.8095V14.8571L19.8571 14.0952C19.9524 14 20.0476 13.9048 19.9524 13.8095L19 12.1905C19 12.0952 18.8095 12.0952 18.7143 12.0952L17.5714 12.5714C17.2857 12.381 17 12.1905 16.7143 12.0952L16.5238 10.8571C16.5238 10.7619 16.4286 10.6667 16.3333 10.6667H14.4286C14.2381 10.6667 14.1429 10.7619 14.1429 10.8571L13.9524 12.0952C13.6667 12.2857 13.4762 12.381 13.1905 12.5714L12.0476 12.0952C11.9524 12.0952 11.8571 12.0952 11.7619 12.1905L10.8095 13.8095C10.8095 13.9048 10.8095 14 10.9048 14.0952L11.9524 14.8571V15.8095L10.9048 16.5714C10.8095 16.6667 10.7143 16.7619 10.8095 16.8571L11.7619 18.4762C11.8571 18.5714 11.9524 18.5714 12.0476 18.5714L13.1905 18.0952C13.381 18.2857 13.6667 18.4762 13.9524 18.5714L14.1429 19.8095C14.2381 19.9048 14.3333 20 14.4286 20H16.3333C16.4286 20 16.5238 19.9048 16.5238 19.8095L16.7143 18.5714C17 18.381 17.1905 18.2857 17.4762 18.0952L18.619 18.4762C18.7143 18.4762 18.8095 18.4762 18.9048 18.381L19.8571 16.7619C19.9524 16.6667 19.9524 16.5714 19.8571 16.5714L18.8095 15.8095ZM15.2857 16.6667C14.5238 16.6667 13.8571 16 13.8571 15.2381C13.8571 14.4762 14.5238 13.8095 15.2857 13.8095C16.0476 13.8095 16.7143 14.4762 16.7143 15.2381C16.7143 16 16.0476 16.6667 15.2857 16.6667Z",fill:"#B1B1B3"})})},_J=({currentUsage:e,machineType:t})=>a.jsxs("div",{className:"flex flex-col justify-between w-full md:flex-row",children:[a.jsxs("div",{className:"w-full md:w-1/2 flex flex-col justify-between items-start bg-white/5 p-5 rounded-[12px]",children:[a.jsxs("div",{className:"flex items-center justify-between w-full",children:[a.jsx("p",{className:"text-[#B1B1B3] font-medium font-['Inter']",children:"Credits Spent"}),a.jsx(NJ,{width:24,height:24})]}),a.jsx("p",{className:"mt-10 md:mt-12 text-[#F2C75B] text-[24px] font-semibold font-['Inter'] leading-[24px]",children:null==e?void 0:e.toFixed(4)})]}),a.jsxs("div",{className:"mt-4 md:mt-0 w-full md:w-1/2 md:ml-4 flex flex-col justify-between items-start bg-white/5 p-5 rounded-[12px]",children:[a.jsxs("div",{className:"flex items-center justify-between w-full",children:[a.jsx("p",{className:"text-[#B1B1B3] font-medium font-['Inter']",children:"Machine type"}),a.jsx(FJ,{width:24,height:24})]}),a.jsx("p",{className:"mt-10 md:mt-12 text-[#FFF] text-[24px] font-semibold font-['Inter'] leading-[24px]",children:t&&t.charAt(0).toUpperCase()+t.slice(1)||"Regular"})]})]}),kJ=wv.common.link,SJ=wv.common.copyable,EJ=wv.common.greenBranch,IJ=wv.menuIcons.github,AJ=wv.icons.branch2,TJ=wv.upload.arrowNext,MJ=wv.upload.uploadNormal;function DJ({isOpen:e,onClose:t,chatInfo:n,onOpenUploadAssetsModal:s}){const{isMobile:i}=nI(),r=Oe(),o=iI(),{deployStatus:l,deployUrl:c,customDomainUrl:d,customDomain:u}=uV({jobId:n.jobId,tabId:"",silent:!0}),[p,m]=Pe.useState("info"),[h,x]=Pe.useState([]),[f,g]=Pe.useState(!1),{toast:v}=un(),b=Pe.useRef(null),{budgetInfo:y}=QK({jobId:n.jobId}),{tier:w}=sv(),j=Mg(),[C,N]=Pe.useState(!1),[F,_]=Pe.useState({top:0,left:0}),[k,S]=Pe.useState("free"===w?"public":"private"),[E,I]=Pe.useState(!1),A=Pe.useRef(null),{data:T}=Of(n.user_prompt_id||"",{skip:!n.user_prompt_id}),M=Pe.useCallback(async()=>{if(n.jobId){g(!0);try{const e=await cm(n.jobId);x(e.reverse())}catch(e){v({title:"Error",description:"Failed to load artifacts",variant:"destructive"})}finally{g(!1)}}},[n.jobId,v]);Pe.useEffect(()=>{e&&n.jobId&&M()},[e,n.jobId,M]);const D=Pe.useCallback(async(e,t)=>{try{await dm(e),x(t=>t.filter(t=>t.id!==e)),v({title:"Deleted",description:`${t} has been deleted`})}catch(n){v({title:"Error",description:`Failed to delete ${t}`,variant:"destructive"})}},[v]),L=Pe.useCallback(async e=>{try{const t=await um(e.id);await v$(t.download_url,e.name||"download")}catch(t){v({title:"Download failed",description:"Failed to get download link for this artifact",variant:"destructive"})}},[v]),P=Pe.useCallback(e=>{const t=e.target.files;if(t&&t.length>0){const e=Array.from(t);s(e)}b.current&&(b.current.value="")},[s]),R=Pe.useCallback(()=>{b.current&&b.current.click()},[]),O=()=>{var e,t,s,i,r,x,g;return a.jsxs(a.Fragment,{children:["info"==p&&a.jsx("div",{className:bb("flex-1 md:p-6 space-y-4 md:space-y-8 h-full overflow-x-hidden overflow-y-auto max-md:pt-4"),children:a.jsxs("div",{className:"p-4 pt-0 space-y-6",children:[a.jsx(_J,{currentUsage:null==y?void 0:y.current_usage,machineType:null==n?void 0:n.machineType}),a.jsxs("div",{className:"space-y-4",children:[a.jsx(tJ,{title:"Model",value:n.modelName}),(o||n.user_prompt_id)&&a.jsx(tJ,{title:"Agent",value:n.user_prompt_id?(null==(e=null==T?void 0:T.prompt_name)?void 0:e.replaceAll("_"," "))||n.promptName||n.user_prompt_id:n.promptName})]}),a.jsx("div",{className:"space-y-4",children:a.jsx(tJ,{title:"Job ID",value:n.jobId,copyable:!0,icon:SJ})}),"success"===l&&a.jsx(nJ,{title:"DEPLOYMENT INFO"}),"success"===l&&a.jsxs("div",{className:"text-[#C4C4CC] font-['Inter'] text-base space-y-4 flex-col flex",children:[a.jsx(tJ,{title:"Live Link",icon:kJ,value:c,onClick:()=>{c&&window.open(c,"_blank")},className:"cursor-pointer group"}),d&&"verified"===(null==u?void 0:u.status)&&a.jsx(tJ,{title:"Custom Domain",icon:kJ,value:u.domain,onClick:()=>{d&&window.open(d,"_blank")},className:"cursor-pointer group"})]}),a.jsxs(a.Fragment,{children:[a.jsx(nJ,{title:"ASSETS"}),a.jsx(CJ,{view:"info",jobId:n.jobId,loading:f,artifacts:h,onUploadClick:R,onDelete:D,onDownload:L,onViewAllClick:()=>m("assets")})]}),n.vscodeUrl&&a.jsx(nJ,{title:"VS CODE INFO"}),a.jsx("div",{className:"space-y-4",children:a.jsxs("div",{className:"text-[#C4C4CC] font-['Inter'] text-base space-y-4 flex-col flex",children:[a.jsx(tJ,{title:"VSCode URL",icon:kJ,value:`${n.vscodeUrl}`,onClick:()=>{window.open(n.vscodeUrl,"_blank")},className:"cursor-pointer group"}),a.jsx(tJ,{title:"VSCode Password",icon:SJ,value:`${n.vscodePassword}`,copyable:!0})]})}),(n.sourceRepo||n.targetRepo)&&a.jsx(nJ,{title:"GITHUB INFO"}),n.sourceRepo&&a.jsxs("div",{className:"bg-[#FFFFFF0D] p-3 rounded-[8px] text-sm flex flex-col gap-2 font-['Inter'] font-medium cursor-pointer hover:opacity-80 transition-opacity duration-200",onClick:()=>{var e,t,s;const i=`https://github.com/${null==(e=n.sourceRepo)?void 0:e.owner}/${null==(t=n.sourceRepo)?void 0:t.repo}/tree/${null==(s=n.sourceRepo)?void 0:s.branch}`;window.open(i,"_blank")},children:[a.jsx("span",{className:"text-[#7B7B80] font-['Inter'] text-sm font-medium",children:"Source Repository"}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("img",{src:IJ,alt:"Github",className:"w-5 h-5"}),a.jsxs("span",{className:"capitalize text-[#C4C4CC] text-nowrap truncate",children:[null==(t=n.sourceRepo)?void 0:t.owner," / ",null==(s=n.sourceRepo)?void 0:s.repo]}),a.jsxs("div",{className:"flex items-center gap-1 ml-2 text-nowrap",children:[a.jsx("img",{src:AJ,alt:"Branch"}),a.jsx("span",{className:"text-[#DADEE5] text-nowrap truncate",children:null==(i=n.sourceRepo)?void 0:i.branch})]})]})]}),n.targetRepo&&a.jsxs("div",{className:"bg-[#FFFFFF0D] p-3 rounded-[8px] text-sm flex flex-col gap-2 font-['Inter'] font-medium cursor-pointer hover:opacity-80 transition-opacity duration-200",onClick:()=>{var e,t,s;const i=`https://github.com/${null==(e=n.targetRepo)?void 0:e.owner}/${null==(t=n.targetRepo)?void 0:t.repo}/tree/${null==(s=n.targetRepo)?void 0:s.branch}`;window.open(i,"_blank")},children:[a.jsx("span",{className:"text-[#7B7B80] font-['Inter'] text-sm font-medium",children:"Most Recent Export"}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("img",{src:IJ,alt:"Github",className:"w-5 h-5"}),a.jsxs("span",{className:"capitalize text-[#C4C4CC]",children:[null==(r=n.targetRepo)?void 0:r.owner," / ",null==(x=n.targetRepo)?void 0:x.repo]}),a.jsxs("div",{className:"flex items-center gap-1 ml-2",children:[a.jsx("img",{src:EJ,alt:"Branch"}),a.jsx("span",{className:"text-[#2EE572]",children:null==(g=n.targetRepo)?void 0:g.branch})]})]})]})]})}),"assets"==p&&a.jsx(CJ,{view:"assets",jobId:n.jobId,loading:f,artifacts:h,onUploadClick:R,onDelete:D,onDownload:L,onViewAllClick:()=>m("assets")})]})};if(i){const n=e&&r.pathname.includes("/chat");return a.jsxs(ZI,{trigger:a.jsx("div",{}),open:n,onOpenChange:e=>{e||t()},maxWidth:"max-w-full",showDefaultFooter:!1,contentPadding:"p-0",showCancel:!0,onCancel:()=>{null==t||t()},title:"Chat Info",children:[a.jsx("div",{className:"h-[1px] bg-[#212121]"}),a.jsx("div",{className:"max-h-[80dvh] flex flex-col bg-[#111112] h-full overflow-clip rounded-t-2xl",children:O()}),a.jsx("input",{"aria-hidden":"true",ref:b,type:"file",accept:"*/*",multiple:!0,onChange:P,style:{display:"none"}})]})}const z=e&&r.pathname.includes("/chat");return a.jsxs("div",{className:bb("md:top-14 max-md:inset-0 h-[calc(100%-4rem)] w-screen md:w-full bg-[#0F0F10] transform transition-transform duration-300 ease-in-out z-50 pointer-events-auto max-md:absolute",z?"block":"hidden"),children:[a.jsxs("div",{className:"flex flex-col h-full",children:[a.jsxs("div",{className:"p-4 md:px-6 md:py-5 bg-[#181818] md:bg-transparent flex items-center justify-between border-b border-[#242424]/60",children:["info"==p&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"text-[#939399] flex items-center gap-2 font-['Brockmann'] text-[15px] md:text-[18px] font-medium leading-[24px]",children:["Run Details",j&&a.jsxs("button",{ref:A,type:"button",className:bb("rounded-full flex items-center gap-[6px] max-h-[32px] py-2 px-3 text-[14px] font-medium transition-colors","free"===w?"bg-[#FFFFFF1A] text-[#E6E6E6] hover:bg-[#FFFFFF2A]":"bg-[#FFFFFF1A] text-[#E6E6E6] cursor-default opacity-80"),onClick:e=>{e.stopPropagation(),Cg("privacy_button_clicked",{currentPrivacy:k,userTier:w,isFreeUser:"free"===w,isMobile:i,source:"chat_info_panel",action:"free"!==w?"disabled_click":i?"open_mobile_sheet":"toggle_dropdown"}),"free"===w&&(i?I(!0):(C||(()=>{if(!A.current)return;const e=A.current.getBoundingClientRect();let t=e.bottom+8,n=e.left;n+276>window.innerWidth&&(n=window.innerWidth-276-16),t+124>window.innerHeight&&(t=e.top-124-8),n<16&&(n=16),_({top:t,left:n})})(),N(!C)))},children:["public"===k?a.jsx(XI,{size:16}):a.jsx(dA,{size:16,color:"#ffffff",opacity:1}),!i&&("public"===k?"Public":"Private")]})]}),a.jsx("button",{type:"button",title:"Close",onClick:t,className:"w-10 h-10 flex items-center justify-center bg-[#FFFFFF05] hover:bg-[#FFFFFF1A] backdrop-blur-lg rounded-[10px]",children:a.jsx(HS,{className:"w-6 h-6 text-[#7B7B80]"})})]}),"assets"==p&&a.jsx(a.Fragment,{children:a.jsxs("div",{className:"text-[#939399] font-['Brockmann'] flex items-center w-full justify-between text-[15px] gap-2 md:text-[18px] font-medium leading-[24px]",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{onClick:()=>{m("info")},className:"w-8 h-8 hover:bg-[#FFFFFF10] flex items-center cursor-pointer justify-center rounded-[8px] backdrop-blur-lg",children:a.jsx("img",{src:TJ,alt:"Arrow",className:"w-6 h-6 rotate-180"})}),"Assets (",h.length,")"]}),a.jsxs("button",{type:"button",onClick:R,className:"text-[16px] pr-4 radial-green text-[#80FFF9] flex justify-center items-center gap-2 p-2 pl-3 min-h-[36px] max-h-[36px] rounded-[10px] ",children:[a.jsx("img",{src:MJ,alt:"Add",className:"w-5 h-5"}),"Upload Files"]})]})})]}),O()]}),a.jsx("input",{"aria-hidden":"true",ref:b,type:"file",accept:"*/*",multiple:!0,onChange:P,style:{display:"none"}}),j&&a.jsxs(a.Fragment,{children:[a.jsx(XK,{show:C&&!i,onClose:()=>N(!1),selectedPrivacy:k,onPrivacyChange:S,position:F}),a.jsx(eJ,{show:E,onClose:()=>I(!1),selectedPrivacy:k,onPrivacyChange:S})]})]})}const LJ=({isOpen:e,onOpenChange:t,vscodeUrl:n,vscodePassword:s,onOpenInBrowser:i})=>{const{isMobile:r}=nI(),o=({showHeader:e=!1}={})=>a.jsxs("div",{className:"relative space-y-4",children:[e&&!r&&a.jsxs("div",{className:"flex flex-col space-y-2",children:[a.jsx(OA,{className:"text-base",children:"VS Code Link"}),a.jsx(zA,{className:"text-sm",children:"Access VS Code in your browser with the following link and password"})]}),a.jsxs("div",{className:"w-full space-y-2",children:[a.jsx("p",{className:"text-sm font-medium text-[#737780]",children:"Link"}),a.jsxs("div",{className:"flex items-center w-full gap-2",children:[a.jsx("input",{type:"text","aria-label":"Link",className:"flex-1 w-full px-3 py-2 bg-[#1A1A1B] border border-[#242424] rounded-md text-[#DDDDE6] text-sm",value:n,readOnly:!0}),a.jsx(oH,{showIcon:!0,iconOnly:!0,className:"border-none bg-none",buttonClassName:Cb({variant:"outline",size:"sm",className:"whitespace-nowrap rounded-lg transition-all ease-in-out duration-200 bg-white/10 border-white/20 border hover:bg-white/20 hover:text-white text-white/40"}),value:n,tooltipText:"Copy",copiedTooltipText:"Copied",feedbackType:"tooltip",iconProps:{size:16},onCopy:()=>{}})]})]}),s&&a.jsxs("div",{className:"w-full space-y-2",children:[a.jsx("p",{className:"text-sm font-medium text-[#737780]",children:"Password"}),a.jsxs("div",{className:"flex items-center w-full gap-2",children:[a.jsx("input",{type:"password","aria-label":"Password",className:"flex-1 w-full px-3 py-2 bg-[#1A1A1B] border border-[#242424] rounded-md text-[#DDDDE6] text-sm",value:s,readOnly:!0}),a.jsx(oH,{showIcon:!0,iconOnly:!0,className:"border-none bg-none",buttonClassName:Cb({variant:"outline",size:"sm",className:"whitespace-nowrap rounded-lg transition-all ease-in-out duration-200 bg-white/10 border-white/20 border hover:bg-white/20 hover:text-white text-white/40"}),value:s,tooltipText:"Copy",copiedTooltipText:"Copied",iconProps:{size:16},onCopy:()=>{}})]})]})]});return r?a.jsxs(ZI,{trigger:a.jsx("div",{}),title:"VS Code Info",description:"",open:e,onOpenChange:t,maxWidth:"max-w-full",showDefaultFooter:!1,footer:a.jsxs("div",{className:"flex-row justify-between bg-[#111112] w-full sm:justify-between flex gap-4",children:[a.jsx(Nb,{className:"flex-1",variant:"secondary",onClick:()=>t(!1),children:a.jsx("div",{className:"flex items-center justify-center w-full",children:"Cancel"})}),a.jsx(Nb,{className:"flex-1",onClick:i,children:a.jsx("div",{className:"flex items-center justify-center w-full",children:"Open in Browser"})})]}),showCancel:!0,contentPadding:"p-0",onCancel:()=>{t(!1)},children:[a.jsx("div",{className:"h-[1px] bg-[#212121]"}),a.jsx("div",{className:" p-4 bg-[#111112] flex flex-col px-3 rounded-t-2xl ",children:o({showHeader:!0})})]}):a.jsx(IA,{open:e,onOpenChange:t,children:a.jsxs(LA,{className:"m-4 mx-auto max-w-[calc(100vw-32px)] sm:max-w-md",children:[a.jsxs(PA,{children:[a.jsx(OA,{children:"VS Code Link"}),a.jsx(zA,{children:"Access VS Code in your browser with the following link and password"})]}),a.jsx("div",{className:"p-6",children:o()}),a.jsxs(RA,{className:"flex-row justify-between w-full sm:justify-between",children:[a.jsx(MA,{asChild:!0,children:a.jsx(Nb,{variant:"secondary",children:"Cancel"})}),a.jsx(Nb,{onClick:i,children:"Open in Browser"})]})]})})};const PJ=(e,t)=>!!e.user_id&&(!!t&&e.user_id!==t),RJ=({task:e,containerId:t,jobId:n,showSubagentPanel:s,selectedMessageId:i,selectedSubagent:a,setSelectedSubagentMessages:r,setIsSubagentActive:o,setAiMessages:l,getCurrentMessages:c,createdByUserId:d})=>{const{user:u}=Yg(),p=Pe.useCallback((e,t,n)=>{const{messages:c,hasActiveSubagent:d}=m(e,n);if(s&&i){const e=c.find(e=>e.id===i);e&&e.subagent_trajectory&&e.subagent_trajectory.length>0&&e.agent_name===a&&r(e.subagent_trajectory)}const u=t?[...c,t]:c;l(t?u:c),o(d)},[e,t,n,s,i,a,r,o,l,c]),m=Pe.useCallback((s,i)=>{var a,r,o;const l=[];let p=[],m=null,h=!1,x=-1,f=0;if(e){const t=((null==c?void 0:c())||[]).find(e=>"user-task"===e.id);"initial-llm"===s[0].action&&(f=1);const n=s[f],p="artifact_share"===(null==(a=null==n?void 0:n.traj_payload)?void 0:a.action);let m=(null==(r=null==t?void 0:t.base64_image_list)?void 0:r.length)?t.base64_image_list:null==n?void 0:n.base64_image_list,h=((e,t,n,s,i)=>({id:"user-task",role:s&&i&&s!==i?"member":"user",content:e,timestamp:t||(new Date).toISOString(),base64_image_list:n||[],...s&&{user_id:s}}))(e,i,m,d,null==u?void 0:u.id);p&&(null==(o=null==n?void 0:n.traj_payload)?void 0:o.artifacts)&&(h={...h,artifacts:n.traj_payload.artifacts,artifact_shared_data:{artifacts:n.traj_payload.artifacts,base64_image_list:n.base64_image_list||[],content:n.thought||"USER SHARED ASSETS WITH AGENT",agent_name:n.agent_name||void 0}}),l.push(h)}if(s.forEach((e,i)=>{var a;if(i===f&&"artifact_share"===(null==(a=e.traj_payload)?void 0:a.action))return;const r=e.agent_name||"EmergentAssistant",o=s[0].agent_name||"EmergentAssistant",c=m||"EmergentAssistant";if(r!==o&&(h=((e,t,n,s)=>{if(t!==n&&"finish"===e[s].action)return!1;if(t!==n&&e[s].action&&!e[s].observation)return!0;const i=!e.slice(s+1).some(e=>e.agent_name===t);return!(t===n||!i)})(s,r,o,i)||h),e.human_message&&r===o){const t=((e,t)=>PJ(e,t)?(e=>({id:`member-${e.step_num}`,role:"member",content:e.human_message||"",timestamp:e.timestamp,base64_image_list:e.base64_image_list,user_id:e.user_id,warning_for_token_limit:!1,current_token_count:0,max_token_count:2e5}))(e):(e=>({id:`user-${e.step_num}`,role:"user",content:e.human_message||"",timestamp:e.timestamp,base64_image_list:e.base64_image_list,user_id:e.user_id,warning_for_token_limit:!1,current_token_count:0,max_token_count:2e5}))(e))(e,null==u?void 0:u.id);l.push(t)}if(null!==m&&r!==c&&p.length>0&&x>=0){l[x].subagent_trajectory=[...p],p=[]}if(r!==o)e.human_message&&p.push(((e,t,n,s)=>({id:`subagent-${PJ(e,s)?"member":"user"}-${e.step_num}`,role:PJ(e,s)?"member":"user",content:e.human_message||"",timestamp:e.timestamp,step_number:e.step_num,job_id:t||null,container_id:n,thought:"",enable_rollback:!1,error:!1,error_message:"",action:void 0,thinking_level:"thinking",observation:void 0,env_success:void 0,function_name:void 0,subagent_trajectory:[],args:void 0,base64_image_list:e.base64_image_list,user_id:e.user_id,warning_for_token_limit:!1,current_token_count:0,max_token_count:2e5,request_id:e.request_id,next_call_agent:e.next_call_agent||null}))(e,n,t,null==u?void 0:u.id)),p.push(((e,t)=>{var n,s;return{id:`subagent-${e.step_num}`,role:"assistant",content:e.thought,action:e.action||"",observation:e.observation||"",env_success:e.env_success,function_name:e.function_name,agent_name:e.agent_name,timestamp:e.timestamp,step_number:e.step_num,job_id:t||null,error:(null==e?void 0:e.error)||!1,request_id:e.request_id,error_message:(null==e?void 0:e.error_message)||"",expertise_type:e.expertise_type,base64_image_list:e.human_message?[]:e.base64_image_list||[],switching_to_build_mode:(null==(n=e.traj_payload)?void 0:n.switching_to_build_mode)||!1,next_call_agent:(null==(s=e.traj_payload)?void 0:s.next_call_agent)||null}})(e,n));else{const n=((e,t)=>{var n,s,i,a,r,o;return{id:`message-${e.step_num}`,role:"assistant",content:e.thought,action:e.action,observation:e.observation,env_success:e.env_success,function_name:e.function_name,agent_name:e.agent_name||"",timestamp:e.timestamp,step_number:e.step_num,containerId:t,error:(null==e?void 0:e.error)||!1,error_message:(null==e?void 0:e.error_message)||"",error_ts:e.error_ts||"",expertise_type:e.expertise_type,request_id:e.request_id,acc_cost:e.acc_cost,max_budget:e.max_bugdet||e.max_budget,artifacts:e.artifacts,thinking_level:e.thinking_level||"thinking",base64_image_list:"screenshot_tool"===e.function_name&&e.base64_image_list||[],enable_rollback:e.enable_rollback,warning_for_token_limit:(null==(n=e.traj_payload)?void 0:n.warning_for_token_limit)||!1,current_token_count:(null==(s=e.traj_payload)?void 0:s.current_token_count)||0,max_token_count:(null==(i=e.traj_payload)?void 0:i.max_token_count)||2e5,switching_to_build_mode:(null==(a=e.traj_payload)?void 0:a.switching_to_build_mode)||!1,forked_job_id:(null==(r=e.traj_payload)?void 0:r.forked_job_id)||null,fork_status:e.fork_status||null,next_call_agent:(null==(o=e.traj_payload)?void 0:o.next_call_agent)||null}})(e,t);l.push(n),x=l.length-1}m=r}),p.length>0&&x>=0){l[x].subagent_trajectory=[...p]}if(s.length>0){const e=s[s.length-1],t=s[0].agent_name||"EmergentAssistant";(e.agent_name!==t&&"finish"===e.action||e.agent_name===t)&&(h=!1)}const g=(e=>{const t=[];let n=0;for(;na.jsxs("svg",{width:t,height:t,viewBox:"0 0 32 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.jsx("rect",{width:t,height:t,rx:"8",fill:e,fillOpacity:"0.1"}),a.jsx("path",{d:"M24.0013 15.9997C24.0013 11.581 20.4193 7.99902 16.0006 7.99902C11.582 7.99902 8 11.581 8 15.9997C8 20.4183 11.582 24.0003 16.0006 24.0003C20.4193 24.0003 24.0013 20.4183 24.0013 15.9997Z",stroke:e,strokeWidth:"1.2"}),a.jsx("path",{d:"M16 16L21 16C21 16.9889 20.7068 17.9556 20.1573 18.7778C19.6079 19.6001 18.827 20.241 17.9134 20.6194C16.9998 20.9978 15.9945 21.0968 15.0246 20.9039C14.0546 20.711 13.1637 20.2348 12.4645 19.5355C11.7652 18.8363 11.289 17.9454 11.0961 16.9754C10.9032 16.0055 11.0022 15.0002 11.3806 14.0866C11.759 13.173 12.3999 12.3921 13.2222 11.8427C14.0444 11.2932 15.0111 11 16 11L16 16Z",fill:e})]}),zJ=e=>{if(!e)return 0;const t=localStorage.getItem("rollback_retry_attempt_job_id_map");return JSON.parse(t||"{}")[e]||0};function BJ({containerId:e,jobId:t,session:n,resetPolling:s,onRollbackSuccess:i,rollbackRequestId:a,maxAttempts:r=3}){const[o,l]=Pe.useState(!1),[c,d]=Pe.useState("INIT"),[u,p]=Pe.useState(zJ(a||"")),m=Pe.useCallback(async(e="all")=>{if(!a)return void dn({title:"Error",description:"No rollback request ID available",variant:"destructive"});l(!0),d("IN_PROGRESS"),u>=r&&d("FAILED");const n=u+1;try{const s=await(async({jobId:e,rollbackRequestId:t,rollbackType:n,currentAttempt:s})=>{let i=null;const a=s>1;if(!e)throw new Error("Job ID not available");return i=await Dp(e,t,void 0,n,a),i})({jobId:t,rollbackRequestId:a,rollbackType:e,currentAttempt:n});if(!s||!1===s.status||"fail"===s.status||"400"===s.http_status_code)throw new Error("Failed to execute rollback command");l(!1),d("COMPLETED"),p(0)}catch(s){l(!1);let e="Error";const t=u+1,n=JSON.parse(localStorage.getItem("rollback_retry_attempt_job_id_map")||"{}");localStorage.setItem("rollback_retry_attempt_job_id_map",JSON.stringify({...n,[a]:t})),t>=r?(d("FAILED"),e="Failed"):d("ERROR"),dn({title:e,description:"Failed to execute rollback command",variant:"destructive"})}},[a,t,i]),h=Pe.useCallback(e=>{e&&d(e),s()},[s]),x=Pe.useCallback(()=>{d("INIT"),l(!1)},[]);return{isRollbackLoading:o,rollbackStatus:c,retryAttempted:u,handleConfirmRollback:m,handleRollbackComplete:h,resetRollbackStatus:x}}const HJ=({color:e="#ED5B5B",size:t=40})=>a.jsxs("svg",{width:t,height:t,viewBox:`0 0 ${t} ${t}`,fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.jsxs("g",{id:"Group 1321315311",children:[a.jsxs("g",{id:"mingcute:copper-coin-fill","clip-path":"url(#clip0_5221_25696)",children:[a.jsx("circle",{id:"Ellipse 6428",cx:"20",cy:"20",r:"19",fill:"white","fill-opacity":"0.05",stroke:e,"stroke-width":"2"}),a.jsxs("g",{id:"Group 1321315310",children:[a.jsx("path",{id:"history_2",d:"M19.9749 30C17.3851 30 15.1378 29.1417 13.2331 27.425C11.3283 25.7083 10.2506 23.5667 10 21H12.0301C12.2807 23.0167 13.1621 24.6875 14.6742 26.0125C16.1863 27.3375 17.9532 28 19.9749 28C22.2139 28 24.1103 27.225 25.6642 25.675C27.218 24.125 27.995 22.2333 27.995 20C27.995 17.7667 27.218 15.875 25.6642 14.325C24.1103 12.775 22.2139 12 19.9749 12C18.538 12 17.2055 12.3542 15.9774 13.0625C14.7494 13.7708 13.7761 14.75 13.0576 16H15.9649V18H10.1504C10.6349 15.6667 11.7962 13.75 13.6341 12.25C15.472 10.75 17.5856 10 19.9749 10C21.3617 10 22.665 10.2625 23.8847 10.7875C25.1044 11.3125 26.1654 12.025 27.0677 12.925C27.9699 13.825 28.6842 14.8833 29.2105 16.1C29.7368 17.3167 30 18.6167 30 20C30 21.3833 29.7368 22.6833 29.2105 23.9C28.6842 25.1167 27.9699 26.175 27.0677 27.075C26.1654 27.975 25.1044 28.6875 23.8847 29.2125C22.665 29.7375 21.3617 30 19.9749 30Z",fill:"white"}),a.jsx("path",{id:"history_2_2",d:"M22.7822 24.2L18.9727 20.4V15H20.9777V19.6L24.1857 22.8L22.7822 24.2Z",fill:"white"})]})]}),a.jsxs("g",{id:"Group 1321315302",children:[a.jsx("circle",{id:"Ellipse 6394",cx:"33",cy:"33",r:"11",fill:"#111112"}),a.jsx("path",{id:"add_circle",d:"M33 40C32.0317 40 31.1217 39.8162 30.27 39.4487C29.4183 39.0812 28.6775 38.5825 28.0475 37.9525C27.4175 37.3225 26.9188 36.5817 26.5513 35.73C26.1837 34.8783 26 33.9683 26 33C26 32.0317 26.1837 31.1217 26.5513 30.27C26.9188 29.4183 27.4175 28.6775 28.0475 28.0475C28.6775 27.4175 29.4183 26.9188 30.27 26.5513C31.1217 26.1837 32.0317 26 33 26C33.9683 26 34.8783 26.1837 35.73 26.5513C36.5817 26.9188 37.3225 27.4175 37.9525 28.0475C38.5825 28.6775 39.0812 29.4183 39.4487 30.27C39.8162 31.1217 40 32.0317 40 33C40 33.9683 39.8162 34.8783 39.4487 35.73C39.0812 36.5817 38.5825 37.3225 37.9525 37.9525C37.3225 38.5825 36.5817 39.0812 35.73 39.4487C34.8783 39.8162 33.9683 40 33 40Z",fill:"#ED5B5B"}),a.jsx("rect",{id:"Rectangle 3474760",x:"32",y:"29",width:"2",height:"5",rx:"1",fill:"#111112"}),a.jsx("rect",{id:"Rectangle 3474761",x:"32",y:"35",width:"2",height:"2",rx:"1",fill:"#111112"})]})]}),a.jsx("defs",{children:a.jsx("clipPath",{id:"clip0_5221_25696",children:a.jsx("rect",{width:t,height:t,fill:"white"})})})]}),$J=[{id:1,label:"Pausing the Agent"},{id:2,label:"Cleaning up the context"},{id:3,label:"Restoring previous workspace state"},{id:4,label:"Finalizing the reversion"}],VJ=({header:e})=>a.jsx("div",{className:"px-6 pt-20 pb-4",children:a.jsx("h2",{className:"text-[24px] font-semibold text-white",children:e})}),UJ=({status:e})=>{switch(e){case"INIT":return a.jsx("div",{className:"flex-1 min-h-0 px-4 pt-4 pb-0 overflow-y-auto",children:a.jsxs("p",{className:"text-[16px] text-[#8A8B91] max-w-[600px] mb-4",children:["You’re about to revert this conversation to an earlier state. Doing so will permanently delete all ",a.jsx("span",{className:"font-medium text-white",children:"messages"})," and ",a.jsx("span",{className:"font-medium text-white",children:"code generated"})," after the selected point."]})});case"IN_PROGRESS":default:return null;case"COMPLETED":return a.jsx("div",{className:"flex-1 min-h-0 px-4 py-6 overflow-y-auto",children:a.jsx("p",{className:"text-[16px] text-[#8A8B91] max-w-[600px] mb-4",children:"Your chat, code, and workspace have been successfully rolled back to the selected point. All changes made after that have been erased."})});case"ERROR":return a.jsx("div",{className:"flex-1 min-h-0 px-4 py-6 overflow-y-auto",children:a.jsx("p",{className:"text-[16px] text-[#8A8B91] max-w-[600px] mb-4",children:"Your attempt to roll back couldn't be completed due to a temporary connection issue or because the snapshot data is still processing."})});case"FAILED":return a.jsx("div",{className:"flex-1 min-h-0 px-4 py-6 overflow-y-auto",children:a.jsx("p",{className:"text-[16px] text-[#8A8B91] max-w-[600px] mb-4",children:"We have tried multiple times to roll back to your selected point, but the operation cannot be completed. Your current session may be unusable."})})}},WJ=({status:e,prompt:t,nextAction:n})=>{switch(e){case"INIT":return a.jsx("div",{className:"flex-1 min-h-0 px-6 pb-2 overflow-y-auto",children:a.jsx("p",{className:"text-[#FF884D] text-base font-medium mb-6",children:t})});case"IN_PROGRESS":default:return null;case"COMPLETED":return a.jsx("div",{className:"flex-1 min-h-0 px-6 py-2 overflow-y-auto",children:a.jsx("p",{className:"text-[#27BF7B] text-base font-medium mb-6",children:t})});case"ERROR":return a.jsxs("div",{className:"flex-1 min-h-0 px-6 py-2 overflow-y-auto",children:[a.jsx("span",{className:"text-[#ED5B5B] text-base font-medium",children:`${t} - `}),n&&a.jsx("span",{className:"text-base font-medium text-white",children:n})]});case"FAILED":return a.jsx("div",{className:"flex-1 min-h-0 px-6 py-2 overflow-y-auto",children:a.jsxs("p",{className:"mb-6 text-base font-medium text-white",children:[a.jsxs("div",{className:"inline-flex gap-2 items-top",children:[a.jsx(IS,{size:35,color:"#ED5B5B"}),t]}),n&&a.jsxs("div",{className:"mt-4 mb-8 text-base font-medium text-white",children:[a.jsxs("div",{className:"inline-flex gap-2 items-top",children:[a.jsx(vS,{size:22,color:"white"}),n]}),a.jsxs("span",{className:"text-base font-medium text-green-500",children:["  ",iv]})]})]})})}},qJ=({currentStatus:e})=>{switch(e){case"COMPLETED":return a.jsxs("div",{className:"relative",children:[a.jsx(iS,{className:"w-6 h-6 text-white"}),a.jsx("div",{className:"absolute -bottom-1 -right-1 bg-[#29CC83] rounded-full w-4 h-4 flex items-center justify-center",children:a.jsx(qk,{className:"w-3 h-3 text-black"})})]});case"IN_PROGRESS":return a.jsx(iS,{className:"w-6 h-6 text-[#FF884D]"});case"INIT":return a.jsx(iS,{className:"w-4 h-4 text-[#FF884D]"});case"FAILED":case"ERROR":return a.jsx(HJ,{size:40,color:"#ED5B5B"});default:return null}},GJ=({currentStatus:e})=>a.jsx("div",{className:"absolute left-5 top-4",children:a.jsx("div",{className:"flex items-center justify-center w-12 h-12 rounded-full bg-[#2A2A2C]",children:a.jsx(qJ,{currentStatus:e})})}),ZJ={INIT:{status:"INIT",header:a.jsx(VJ,{header:"Revert to a Previous Point"}),description:a.jsx(UJ,{status:"INIT"}),prompt:a.jsx(WJ,{status:"INIT",prompt:"This action cannot be undone."}),etaMessage:"Reverting typically takes 1–2 minutes.",buttons:["cancel","confirm"]},IN_PROGRESS:{status:"IN_PROGRESS",header:a.jsx(VJ,{header:"Reverting to the previous point"}),description:a.jsx(UJ,{status:"IN_PROGRESS"}),prompt:a.jsx(WJ,{status:"IN_PROGRESS",prompt:"Are you sure you want to continue?"}),eta:!0,buttons:["inProgress"]},COMPLETED:{status:"COMPLETED",header:a.jsx(VJ,{header:"Rollback Complete !"}),description:a.jsx(UJ,{status:"COMPLETED"}),prompt:a.jsx(WJ,{status:"COMPLETED",prompt:"To continue, send a message to our agent to restart the conversation."}),buttons:["okay"]},ERROR:{status:"ERROR",header:a.jsx(VJ,{header:"Rollback Failed !"}),description:a.jsx(UJ,{status:"ERROR"}),prompt:a.jsx(WJ,{status:"ERROR",prompt:"Please try again",nextAction:"If the problem persists after multiple attempts, a more serious issue may be at play."}),attempts:!0,maxAttempts:3,buttons:["contact","retry"]},FAILED:{status:"FAILED",header:a.jsx(VJ,{header:"Rollback Permanently Failed"}),description:a.jsx(UJ,{status:"FAILED"}),prompt:a.jsx(WJ,{status:"FAILED",prompt:"Unfortunately, your work since the last successful snapshot may not be recoverable through normal means.",nextAction:"Please contact support for assistance with restoring your work"}),buttons:["contact","okay-failed"]}};function YJ({isOpen:e,onOpenChange:t,rollbackRequestId:n,containerId:s,jobId:i,session:r,resetPolling:o,setAiMessages:l}){const[c,d]=Pe.useState(0),[u,p]=Pe.useState(0),[m,h]=Pe.useState("INIT"),[x,f]=Pe.useState("all"),{isRollbackLoading:g,rollbackStatus:v,handleConfirmRollback:b,handleRollbackComplete:y,resetRollbackStatus:w}=BJ({containerId:s,jobId:i,session:r,resetPolling:o,rollbackRequestId:n,onRollbackSuccess:()=>l([]),maxAttempts:av});Pe.useEffect(()=>{let t,n;if(e&&h(v),"IN_PROGRESS"===v&&(t=setInterval(()=>{p(e=>e+1)},1e3),c<$J.length-1)){n=setTimeout(()=>{d(e=>e+1)},[2e3,3e3,4e3,3e3,3e3][c])}return"COMPLETED"===v&&(y(),e&&h("COMPLETED")),"INIT"!==v&&"ERROR"!==v&&"FAILED"!==v||(d(0),p(0)),()=>{clearInterval(t),clearTimeout(n)}},[g,v,c,e]),Pe.useEffect(()=>{const e=zJ(n||"");h(e>=av?"FAILED":"INIT")},[n]),Pe.useEffect(()=>{e&&(w(),h("INIT"),d(0),p(0))},[e,w]);const j=()=>{t(!1)};return a.jsx(IA,{open:e,onOpenChange:j,children:a.jsxs(LA,{hideclosebutton:"IN_PROGRESS"===m,onInteractOutside:e=>{"IN_PROGRESS"===m&&e.preventDefault()},className:"p-0 m-4 mx-auto max-w-[calc(100vw-32px)] md:max-w-[600px] max-h-[85vh] flex flex-col border-[#2A2A2C] bg-[#0E0E0F] overflow-hidden",children:[a.jsxs("div",{className:"relative border-b border-[#1A1A1C]",children:[a.jsx(GJ,{currentStatus:m}),ZJ[m].header]}),ZJ[m].description,ZJ[m].prompt,"INIT"===m?a.jsx("div",{className:"flex-1 min-h-0 px-6 pt-4 pb-10 overflow-y-auto",children:a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center space-x-2",children:[a.jsx("input",{title:"Erase all messages and generated code",type:"radio",id:"confirm-rollback-all",name:"rollback-confirmation",className:"h-4 w-4 accent-[#FF884D] border-[#FF884D] focus:ring-[#FF884D] focus:ring-offset-0 checked:bg-[#FF884D]",onChange:()=>f("all"),checked:"all"===x}),a.jsx(KA,{htmlFor:"confirm-rollback-all",className:"text-white",children:"Erase all messages and generated code"})]}),a.jsxs("div",{className:"flex items-center space-x-2",children:[a.jsx("input",{title:"Erase messages only (keep code)",type:"radio",id:"confirm-rollback-messages",name:"rollback-confirmation",className:"h-4 w-4 accent-[#FF884D] border-[#FF884D] focus:ring-[#FF884D] focus:ring-offset-0 bg-transparent",onChange:()=>f("messages"),checked:"messages"===x}),a.jsx(KA,{htmlFor:"confirm-rollback-messages",className:"text-white",children:"Erase messages only (keep code)"})]})]})}):null,"IN_PROGRESS"===m?a.jsx("div",{className:"flex-1 min-h-0 px-6 py-6 overflow-y-auto",children:a.jsx("div",{className:"space-y-6",children:$J.map((e,t)=>{let n;return n=t