const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/DashboardPage.CdIQUb6l.js","assets/react-vendor.B-7JHCXk.js","assets/useLogsApi.9HYwkSXd.js","assets/chart-vendor.CnaePG5f.js","assets/useWebSocket.BIBnmVVD.js","assets/LoadingStates.DLLdyR0T.js","assets/ui-vendor.QvgZ1zYD.js","assets/ServicesPage.Dp4dNUy5.js","assets/LogsPage._qJDRYPj.js","assets/ResponseTraceModal.Dq-Kluch.js","assets/sparkles.mskT0r-J.js","assets/file-code.DUYmyr6x.js","assets/MetricsPage.BiV4MKEw.js","assets/VerificationPage.CpXiAA-n.js","assets/ContractDiffPage.D_5AHS5U.js","assets/AIStudioNav.BhzXuhZs.js","assets/IncidentDashboardPage.WhmVZou5.js","assets/useDriftApi.CoIWt64d.js","assets/FitnessFunctionsPage.CCV7goA5.js","assets/tag.CTjA4sOS.js","assets/folder.DgQ2oVMC.js","assets/FixturesPage.CpOzLdOZ.js","assets/useFixturesApi.C19mRFeC.js","assets/TestingPage.DiPW8dou.js","assets/ImportPage.C2ukTjau.js","assets/WorkspacesPage.BrFPK6dn.js","assets/FormControls.CmJ8Y9Pr.js","assets/mode.Cna2tdiJ.js","assets/PlaygroundPage.B0DtmhmM.js","assets/PluginsPage.BdsmE76_.js","assets/ChainsPage.8pczSHke.js","assets/GraphPage.m1YDxmUu.js","assets/index.BxnP189x.js","assets/message-square.ybjQZr5a.js","assets/graphLayouts.BFHOZDWM.js","assets/WorldStatePage.D8JmVc-O.js","assets/PerformancePage.Brrld2vw.js","assets/ScenarioStateMachineEditor.CxgbCeWl.js","assets/useHistory.0Ergcj6s.js","assets/ScenarioStudioPage.BYOXjpZc.js","assets/AnalyticsPage.DZR8pmo2.js","assets/PillarAnalyticsPage.CgtLwiBR.js","assets/trending-down.DFymKetv.js","assets/HostedMocksPage.taCpBqZV.js","assets/ApiExplorerPage.MKc6DyZW.js","assets/index.BETGtNIR.js","assets/ApiExplorerPage.cL8M_Kap.css","assets/ObservabilityPage.CWQkcngO.js","assets/TracesPage.BSj8MRlo.js","assets/TestGeneratorPage.CAyeBzXW.js","assets/TestExecutionDashboard.j__yYtZw.js","assets/IntegrationTestBuilder.JwpKh1Na.js","assets/ConformancePage.Cy5_aNVJ.js","assets/ChaosPage.C1VcGQjn.js","assets/ResiliencePage.D0Kdpnnh.js","assets/RecorderPage.Da9YOgUd.js","assets/BehavioralCloningPage.C1odslZv.js","assets/snowflake.D97Aaz1c.js","assets/OrchestrationBuilder.B1dub-eX.js","assets/OrchestrationExecutionView.CvhwXldU.js","assets/PluginRegistryPage.BAOm3ZkE.js","assets/MarketplaceTabs.DPK91rh0.js","assets/TemplateMarketplacePage.BqsEJ6d7.js","assets/ScenarioMarketplacePage.B4g73bzV.js","assets/ShowcasePage.Bl2HVOCZ.js","assets/communityApi.Di9L-taA.js","assets/LearningHubPage.U6XsQ5Gb.js","assets/UserManagementPage.C1zATZZD.js","assets/RegistryLoginPage.Dh-tofzt.js","assets/registryAdminApi.B2D8j2ya.js","assets/RegistryAdminPage.1u3phRty.js","assets/RegistryInvitePage.DZZ1YT-A.js","assets/MockAIPage.aCyHOF9J.js","assets/MockAIOpenApiGeneratorPage.CRUF8UuZ.js","assets/MockAIRulesPage.DNnss9-5.js","assets/VoicePage.sPkRUs-X.js","assets/AIStudioPage.BtcDJaxy.js","assets/SmtpMailboxPage.CYBCqxtN.js","assets/MqttBrokerPage.txXXnlVl.js","assets/send.CyT65HYd.js","assets/KafkaBrokerPage.CHsITh8I.js","assets/TermsPage.Bs6ueNVO.js","assets/index.8BdYuBrS.js","assets/PrivacyPage.DHpIeKCg.js","assets/DPAPage.BQ4nFdp4.js","assets/FAQPage.KqT_4tJ7.js","assets/SupportPage.BslHrGHe.js","assets/PricingPage.DC8hUef5.js","assets/EmailVerificationPage.CWI4y7Dt.js","assets/WaitlistPage.DxQVqxA3.js","assets/tauri.BOSGuS7D.js"])))=>i.map(i=>d[i]); var Qo=Object.defineProperty;var Yo=(s,t,a)=>t in s?Qo(s,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):s[t]=a;var Ws=(s,t,a)=>Yo(s,typeof t!="symbol"?t+"":t,a);import{c as At,p as da,a as Ri,r as h,j as e,b as M,d as Xo,L as ka,u as Li,e as Xr,f as he,g as oe,h as Z,i as el,P as tl,S as ws,K as sl,T as Mt,B as Gs,A as al,k as rl,C as kn,l as wn,V as nl,m as Nn,n as _n,I as Sn,o as il,D as ol,q as Cn,s as Tn,t as Pn,v as En,w as An,x as On,N as $i,y as ll,z as xr,Q as cl,E as dl,F as ul,G as ml}from"./react-vendor.B-7JHCXk.js";import{S as hl,R as Fi,T as gl}from"./ui-vendor.QvgZ1zYD.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const n of document.querySelectorAll('link[rel="modulepreload"]'))r(n);new MutationObserver(n=>{for(const i of n)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function a(n){const i={};return n.integrity&&(i.integrity=n.integrity),n.referrerPolicy&&(i.referrerPolicy=n.referrerPolicy),n.crossOrigin==="use-credentials"?i.credentials="include":n.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(n){if(n.ep)return;n.ep=!0;const i=a(n);fetch(n.href,i)}})();const In={debug:0,info:1,warn:2,error:3};class xl{constructor(){Ws(this,"config");this.config={minLevel:"warn",enableConsole:!0}}shouldLog(t){return In[t]>=In[this.config.minLevel]}formatMessage(t,a,r){const n=new Date().toISOString(),i=r?` ${JSON.stringify(r)}`:"";return`[${n}] [${t.toUpperCase()}] ${a}${i}`}debug(t,a){this.shouldLog("debug")&&this.config.enableConsole&&console.debug(this.formatMessage("debug",t,a))}info(t,a){this.shouldLog("info")&&this.config.enableConsole&&console.info(this.formatMessage("info",t,a))}warn(t,a){this.shouldLog("warn")&&this.config.enableConsole&&console.warn(this.formatMessage("warn",t,a))}error(t,a,r){if(this.shouldLog("error")&&this.config.enableConsole){const n={...r,error:a instanceof Error?{message:a.message,stack:a.stack,name:a.name}:a};console.error(this.formatMessage("error",t,n))}}configure(t){this.config={...this.config,...t}}}const Pe=new xl;function pl(s){if(s instanceof Error)return s.message;if(typeof s=="string")return s;if(s&&typeof s=="object"){if("message"in s&&typeof s.message=="string")return s.message;if("error"in s&&typeof s.error=="string")return s.error}return"An unexpected error occurred"}function ct(s,t,a){if(t&&typeof t=="object"){const n=t.error??t.message;if(typeof n=="string"&&n.trim().length>0)return n;if(n)return JSON.stringify(n)}if(typeof t=="string"&&t.trim().length>0)return t;const r=s.statusText?` ${s.statusText}`:"";return`${a} (HTTP ${s.status}${r})`}function gy(s){if(s instanceof TypeError&&s.message.includes("fetch"))return{message:"Network error: Unable to connect to the server",type:"network"};if(s instanceof Error&&s.message.startsWith("HTTP error! status:")){const t=s.message.match(/status: (\d+)/),a=t?parseInt(t[1],10):void 0;return{message:fl(a),type:"server",statusCode:a,details:s}}return s&&typeof s=="object"&&"issues"in s?{message:"Invalid data received from server",type:"validation",details:s}:{message:pl(s),type:"unknown",details:s}}function fl(s){if(!s)return"Server error occurred";switch(s){case 400:return"Bad request: Please check your input";case 401:return"Unauthorized: Please log in again";case 403:return"Forbidden: You do not have permission to perform this action";case 404:return"Resource not found";case 409:return"Conflict: Resource already exists or cannot be modified";case 422:return"Validation error: Please check your input";case 429:return"Too many requests: Please try again later";case 500:return"Internal server error";case 502:return"Bad gateway: Server is temporarily unavailable";case 503:return"Service unavailable: Please try again later";case 504:return"Gateway timeout: Server took too long to respond";default:return s>=400&&s<500?"Client error occurred":s>=500?"Server error occurred":"An error occurred"}}function xy(s,t){}function py(s){return s.replace(/[<>]/g,"").replace(/javascript:/gi,"").replace(/on\w+=/gi,"").trim()}function fy(s,t={}){var i;const{maxSize:a=10*1024*1024,allowedTypes:r=[],allowedExtensions:n=[]}=t;if(s.size>a)return{valid:!1,error:`File size exceeds maximum allowed size of ${(a/(1024*1024)).toFixed(1)}MB`};if(r.length>0&&!r.includes(s.type))return{valid:!1,error:`File type "${s.type}" is not allowed`};if(n.length>0){const o=(i=s.name.split(".").pop())==null?void 0:i.toLowerCase();if(!o||!n.includes(o))return{valid:!1,error:`File extension "${o}" is not allowed`}}return{valid:!0}}const Yt=()=>!1;class yl{constructor(){Ws(this,"cloud",Yt())}authHeader(){const t=localStorage.getItem("auth_token");return t?{Authorization:`Bearer ${t}`}:{}}async authedFetch(t,a={}){const r=await fetch(t,{...a,headers:{"Content-Type":"application/json",...this.authHeader(),...a.headers}});if(!r.ok){const n=await r.json().catch(()=>({error:"Unknown error"}));throw new Error(ct(r,n,`HTTP ${r.status}`))}if(r.status!==204)return r.json()}async fetchJson(t,a){const r=await fetch(t,{...a,headers:{"Content-Type":"application/json",...a==null?void 0:a.headers}});if(!r.ok){const n=await r.json().catch(()=>({error:"Unknown error"}));throw new Error(ct(r,n,`HTTP error! status: ${r.status}`))}if(this.cloud)return r.json();{const n=await r.json();if(!n.success)throw new Error(n.error||"Request failed");return n.data}}async login(t,a){if(this.cloud){const r=await this.fetchJson("/api/v1/auth/login",{method:"POST",body:JSON.stringify({email:t,password:a})});return{token:r.access_token,refresh_token:r.refresh_token,user:{id:r.user_id,username:r.username,email:t,role:"user"},expires_in:r.access_token_expires_at-Math.floor(Date.now()/1e3)}}else return this.fetchJson("/__mockforge/auth/login",{method:"POST",body:JSON.stringify({username:t,password:a})})}async register(t,a,r){const n=await this.fetchJson("/api/v1/auth/register",{method:"POST",body:JSON.stringify({username:t,email:a,password:r})});return{token:n.access_token,refresh_token:n.refresh_token,user:{id:n.user_id,username:n.username,email:a,role:"user"},expires_in:n.access_token_expires_at-Math.floor(Date.now()/1e3)}}async refreshToken(t){if(this.cloud){const a=await this.fetchJson("/api/v1/auth/token/refresh",{method:"POST",body:JSON.stringify({refresh_token:t})});return{token:a.access_token,refresh_token:a.refresh_token,user:{id:a.user_id,username:a.username,email:"",role:"user"},expires_in:a.access_token_expires_at-Math.floor(Date.now()/1e3)}}else return this.fetchJson("/__mockforge/auth/refresh",{method:"POST",body:JSON.stringify({refresh_token:t})})}async logout(){try{this.cloud||await this.fetchJson("/__mockforge/auth/logout",{method:"POST"})}catch(t){console.warn("Logout request failed:",t)}}async getMe(){return this.authedFetch("/api/v1/users/me")}async updateProfile(t){return this.authedFetch("/api/v1/users/me",{method:"PATCH",body:JSON.stringify(t)})}async changePassword(t,a){return this.authedFetch("/api/v1/auth/change-password",{method:"POST",body:JSON.stringify({current_password:t,new_password:a})})}async updateNotifications(t){return this.authedFetch("/api/v1/users/me/notifications",{method:"PATCH",body:JSON.stringify(t)})}async getPreferences(){return(await this.authedFetch("/api/v1/users/me/preferences")).preferences??{}}async updatePreferences(t){return(await this.authedFetch("/api/v1/users/me/preferences",{method:"PATCH",body:JSON.stringify({preferences:t})})).preferences??{}}async setup2FA(){return this.authedFetch("/api/v1/auth/2fa/setup")}async verify2FASetup(t,a,r){return this.authedFetch("/api/v1/auth/2fa/verify-setup",{method:"POST",body:JSON.stringify({secret:t,code:a,backup_codes:r})})}async disable2FA(t){return this.authedFetch("/api/v1/auth/2fa/disable",{method:"POST",body:JSON.stringify({password:t})})}async get2FAStatus(){return this.authedFetch("/api/v1/auth/2fa/status")}isCloud(){return this.cloud}}const He=new yl,Mn=s=>{try{const t=s.split(".");if(t.length!==3)return{user:null,expiresAt:null};const a=JSON.parse(atob(t[1])),r=a.exp*1e3;return r({user:null,token:null,refreshToken:null,isAuthenticated:!1,isLoading:!1,login:async(a,r)=>{s({isLoading:!0});try{const n=await He.login(a,r);s({user:n.user,token:n.token,refreshToken:n.refresh_token,isAuthenticated:!0,isLoading:!1}),t().startTokenRefresh()}catch(n){s({isLoading:!1});const i=n instanceof Error?n.message:"Login failed";throw Pe.error("Login failed",i),new Error(i)}},logout:async()=>{t().stopTokenRefresh();try{await He.logout()}catch(a){Pe.warn("Logout API call failed",a)}s({user:null,token:null,refreshToken:null,isAuthenticated:!1,isLoading:!1})},refreshTokenAction:async()=>{const{refreshToken:a}=t();if(!a)throw new Error("No refresh token available");try{const r=await He.refreshToken(a);s({token:r.token,refreshToken:r.refresh_token,user:r.user})}catch(r){throw Pe.error("Token refresh failed",r),t().logout(),r}},checkTokenExpiry:()=>{const{token:a}=t();if(!a)return!1;try{const{expiresAt:r}=Mn(a);return r?r-Date.now()>300*1e3:!1}catch{return!1}},checkAuth:async()=>{const{token:a,refreshToken:r,user:n}=t();if(!a){s({isAuthenticated:!1,isLoading:!1});return}s({isLoading:!0});try{const{user:i,expiresAt:o}=Mn(a);if(i&&o&&o>Date.now()){const c=n&&n.username?n:i;s({user:c,isAuthenticated:!0,isLoading:!1}),t().startTokenRefresh()}else if(r)try{await t().refreshTokenAction()}catch{t().logout()}else t().logout()}catch(i){Pe.error("Auth check failed",i),t().logout()}},updateProfile:async a=>{s({isLoading:!0});try{const r=t().user,n={};(r==null?void 0:r.username)!==a.username&&(n.username=a.username),(r==null?void 0:r.email)!==a.email&&(n.email=a.email);let i=a;if(He.isCloud()&&Object.keys(n).length>0){const o=await He.updateProfile(n);i={...a,id:o.user_id,username:o.username,email:o.email}}s({user:i,isLoading:!1})}catch(r){s({isLoading:!1});const n=r instanceof Error?r.message:"Profile update failed";throw Pe.error("Profile update failed",n),new Error(n)}},setAuthenticated:(a,r,n)=>{s({user:a,token:r,refreshToken:n||null,isAuthenticated:!0,isLoading:!1}),t().startTokenRefresh()},startTokenRefresh:()=>{Ns&&clearInterval(Ns),Ns=setInterval(async()=>{const{token:a,refreshToken:r,isAuthenticated:n}=t();if(n&&a&&r)try{JSON.parse(atob(a.split(".")[1])).exp-Math.floor(Date.now()/1e3)<300&&await t().refreshTokenAction()}catch{t().logout()}},6e4)},stopTokenRefresh:()=>{Ns&&(clearInterval(Ns),Ns=null)}}),{name:"mockforge-auth",partialize:s=>({token:s.token,refreshToken:s.refreshToken,user:s.user})}));Ct.subscribe(s=>{s.token?localStorage.setItem("auth_token",s.token):localStorage.removeItem("auth_token")});const Cr=globalThis.fetch,Tr=Yt();function Di(s){const t=new URL(s,window.location.origin).pathname;return t==="/__mockforge/reality/level"?new Response(JSON.stringify({success:!0,data:{level:1,level_name:"Cloud",description:"Cloud-hosted mock",chaos:{enabled:!1,error_rate:0,delay_rate:0},latency:{base_ms:0,jitter_ms:0},mockai:{enabled:!1}}}),{status:200,headers:{"Content-Type":"application/json"}}):t==="/__mockforge/config"?new Response(JSON.stringify({success:!0,data:{latency:{enabled:!1,base_ms:0,jitter_ms:0,tag_overrides:{}},faults:{enabled:!1,failure_rate:0,status_codes:[]},proxy:{enabled:!1,upstream_url:null,timeout_seconds:30},validation:{mode:"disabled",aggregate_errors:!1,validate_responses:!1,overrides:{}}}}),{status:200,headers:{"Content-Type":"application/json"}}):t.startsWith("/__mockforge/time-travel")?new Response(JSON.stringify({success:!0,data:{enabled:!1,current_time:new Date().toISOString(),scale:1,mutations:[],cron_jobs:[]}}),{status:200,headers:{"Content-Type":"application/json"}}):t.startsWith("/__mockforge/reality/presets")?new Response(JSON.stringify({success:!0,data:[]}),{status:200,headers:{"Content-Type":"application/json"}}):t==="/__mockforge/logs"||t.startsWith("/__mockforge/logs?")?new Response(JSON.stringify({success:!0,data:[]}),{status:200,headers:{"Content-Type":"application/json"}}):t==="/__mockforge/routes"?new Response(JSON.stringify({success:!0,data:[]}),{status:200,headers:{"Content-Type":"application/json"}}):new Response(JSON.stringify({success:!0,data:{}}),{status:200,headers:{"Content-Type":"application/json"}})}const bl=["/api/chaos/","/api/observability/","/api/resilience/","/api/recorder/","/api/conformance/","/api/performance/","/api/world-state/","/api/v1/consistency/","/api/v1/drift/","/api/v1/scenario-studio/","/api/v1/snapshots","/api/v2/analytics/"];function zi(s){const t=new URL(s,window.location.origin).pathname;return bl.some(a=>t.startsWith(a))}function qi(s){return new Response(JSON.stringify({}),{status:200,headers:{"Content-Type":"application/json"}})}function vl(){return async(s,t)=>{const a=typeof s=="string"?s:s instanceof URL?s.href:s.url;if(Tr&&a.includes("/__mockforge/"))return Di(a);if(Tr&&zi(a))return qi();const r=Ct.getState(),n=r.token,i=new Headers(t==null?void 0:t.headers);n&&i.set("Authorization",`Bearer ${n}`);const o={...t,headers:i};let c=await Cr(s,o);if(c.status===401&&n)try{await r.refreshTokenAction();const d=Ct.getState().token;d?(i.set("Authorization",`Bearer ${d}`),c=await Cr(s,{...o,headers:i})):r.logout()}catch{r.logout()}return c}}const rt=vl();Tr&&(globalThis.fetch=async(s,t)=>{const a=typeof s=="string"?s:s instanceof URL?s.href:s.url;return a.includes("/__mockforge/")?Di(a):zi(a)?qi():Cr(s,t)});const jl="modulepreload",kl=function(s){return"/"+s},Rn={},G=function(t,a,r){let n=Promise.resolve();if(a&&a.length>0){let o=function(l){return Promise.all(l.map(m=>Promise.resolve(m).then(g=>({status:"fulfilled",value:g}),g=>({status:"rejected",reason:g}))))};document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),d=(c==null?void 0:c.nonce)||(c==null?void 0:c.getAttribute("nonce"));n=o(a.map(l=>{if(l=kl(l),l in Rn)return;Rn[l]=!0;const m=l.endsWith(".css"),g=m?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="proxy.php?url=https%3A%2F%2Fapp.mockforge.dev%2F%24%7Bl%7D"]${g}`))return;const y=document.createElement("link");if(y.rel=m?"stylesheet":jl,m||(y.as="script"),y.crossOrigin="",y.href=l,d&&y.setAttribute("nonce",d),document.head.appendChild(y),m)return new Promise((u,p)=>{y.addEventListener("load",u),y.addEventListener("error",()=>p(new Error(`Unable to preload CSS for ${l}`)))})}))}function i(o){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=o,window.dispatchEvent(c),!c.defaultPrevented)throw o}return n.then(o=>{for(const c of o||[])c.status==="rejected"&&i(c.reason);return t().catch(i)})},wl=(s,t)=>{const a=new Array(s.length+t.length);for(let r=0;r({classGroupId:s,validator:t}),Ui=(s=new Map,t=null,a)=>({nextPart:s,validators:t,classGroupId:a}),Da="-",Ln=[],_l="arbitrary..",Sl=s=>{const t=Tl(s),{conflictingClassGroups:a,conflictingClassGroupModifiers:r}=s;return{getClassGroupId:o=>{if(o.startsWith("[")&&o.endsWith("]"))return Cl(o);const c=o.split(Da),d=c[0]===""&&c.length>1?1:0;return Bi(c,d,t)},getConflictingClassGroupIds:(o,c)=>{if(c){const d=r[o],l=a[o];return d?l?wl(l,d):d:l||Ln}return a[o]||Ln}}},Bi=(s,t,a)=>{if(s.length-t===0)return a.classGroupId;const n=s[t],i=a.nextPart.get(n);if(i){const l=Bi(s,t+1,i);if(l)return l}const o=a.validators;if(o===null)return;const c=t===0?s.join(Da):s.slice(t).join(Da),d=o.length;for(let l=0;ls.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=s.slice(1,-1),a=t.indexOf(":"),r=t.slice(0,a);return r?_l+r:void 0})(),Tl=s=>{const{theme:t,classGroups:a}=s;return Pl(a,t)},Pl=(s,t)=>{const a=Ui();for(const r in s){const n=s[r];en(n,a,r,t)}return a},en=(s,t,a,r)=>{const n=s.length;for(let i=0;i{if(typeof s=="string"){Al(s,t,a);return}if(typeof s=="function"){Ol(s,t,a,r);return}Il(s,t,a,r)},Al=(s,t,a)=>{const r=s===""?t:Vi(t,s);r.classGroupId=a},Ol=(s,t,a,r)=>{if(Ml(s)){en(s(r),t,a,r);return}t.validators===null&&(t.validators=[]),t.validators.push(Nl(a,s))},Il=(s,t,a,r)=>{const n=Object.entries(s),i=n.length;for(let o=0;o{let a=s;const r=t.split(Da),n=r.length;for(let i=0;i"isThemeGetter"in s&&s.isThemeGetter===!0,Rl=s=>{if(s<1)return{get:()=>{},set:()=>{}};let t=0,a=Object.create(null),r=Object.create(null);const n=(i,o)=>{a[i]=o,t++,t>s&&(t=0,r=a,a=Object.create(null))};return{get(i){let o=a[i];if(o!==void 0)return o;if((o=r[i])!==void 0)return n(i,o),o},set(i,o){i in a?a[i]=o:n(i,o)}}},Pr="!",$n=":",Ll=[],Fn=(s,t,a,r,n)=>({modifiers:s,hasImportantModifier:t,baseClassName:a,maybePostfixModifierPosition:r,isExternal:n}),$l=s=>{const{prefix:t,experimentalParseClassName:a}=s;let r=n=>{const i=[];let o=0,c=0,d=0,l;const m=n.length;for(let f=0;fd?l-d:void 0;return Fn(i,u,y,p)};if(t){const n=t+$n,i=r;r=o=>o.startsWith(n)?i(o.slice(n.length)):Fn(Ll,!1,o,void 0,!0)}if(a){const n=r;r=i=>a({className:i,parseClassName:n})}return r},Fl=s=>{const t=new Map;return s.orderSensitiveModifiers.forEach((a,r)=>{t.set(a,1e6+r)}),a=>{const r=[];let n=[];for(let i=0;i0&&(n.sort(),r.push(...n),n=[]),r.push(o)):n.push(o)}return n.length>0&&(n.sort(),r.push(...n)),r}},Dl=s=>({cache:Rl(s.cacheSize),parseClassName:$l(s),sortModifiers:Fl(s),...Sl(s)}),zl=/\s+/,ql=(s,t)=>{const{parseClassName:a,getClassGroupId:r,getConflictingClassGroupIds:n,sortModifiers:i}=t,o=[],c=s.trim().split(zl);let d="";for(let l=c.length-1;l>=0;l-=1){const m=c[l],{isExternal:g,modifiers:y,hasImportantModifier:u,baseClassName:p,maybePostfixModifierPosition:f}=a(m);if(g){d=m+(d.length>0?" "+d:d);continue}let j=!!f,C=r(j?p.substring(0,f):p);if(!C){if(!j){d=m+(d.length>0?" "+d:d);continue}if(C=r(p),!C){d=m+(d.length>0?" "+d:d);continue}j=!1}const T=y.length===0?"":y.length===1?y[0]:i(y).join(":"),N=u?T+Pr:T,w=N+C;if(o.indexOf(w)>-1)continue;o.push(w);const O=n(C,j);for(let L=0;L0?" "+d:d)}return d},Ul=(...s)=>{let t=0,a,r,n="";for(;t{if(typeof s=="string")return s;let t,a="";for(let r=0;r{let a,r,n,i;const o=d=>{const l=t.reduce((m,g)=>g(m),s());return a=Dl(l),r=a.cache.get,n=a.cache.set,i=c,c(d)},c=d=>{const l=r(d);if(l)return l;const m=ql(d,a);return n(d,m),m};return i=o,(...d)=>i(Ul(...d))},Bl=[],De=s=>{const t=a=>a[s]||Bl;return t.isThemeGetter=!0,t},Ji=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Hi=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Vl=/^\d+\/\d+$/,Kl=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Jl=/\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$/,Hl=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Wl=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Gl=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,_s=s=>Vl.test(s),xe=s=>!!s&&!Number.isNaN(Number(s)),Jt=s=>!!s&&Number.isInteger(Number(s)),pr=s=>s.endsWith("%")&&xe(s.slice(0,-1)),Rt=s=>Kl.test(s),Zl=()=>!0,Ql=s=>Jl.test(s)&&!Hl.test(s),Wi=()=>!1,Yl=s=>Wl.test(s),Xl=s=>Gl.test(s),ec=s=>!J(s)&&!H(s),tc=s=>Us(s,Qi,Wi),J=s=>Ji.test(s),rs=s=>Us(s,Yi,Ql),fr=s=>Us(s,ic,xe),Dn=s=>Us(s,Gi,Wi),sc=s=>Us(s,Zi,Xl),wa=s=>Us(s,Xi,Yl),H=s=>Hi.test(s),Zs=s=>Bs(s,Yi),ac=s=>Bs(s,oc),zn=s=>Bs(s,Gi),rc=s=>Bs(s,Qi),nc=s=>Bs(s,Zi),Na=s=>Bs(s,Xi,!0),Us=(s,t,a)=>{const r=Ji.exec(s);return r?r[1]?t(r[1]):a(r[2]):!1},Bs=(s,t,a=!1)=>{const r=Hi.exec(s);return r?r[1]?t(r[1]):a:!1},Gi=s=>s==="position"||s==="percentage",Zi=s=>s==="image"||s==="url",Qi=s=>s==="length"||s==="size"||s==="bg-size",Yi=s=>s==="length",ic=s=>s==="number",oc=s=>s==="family-name",Xi=s=>s==="shadow",Ar=()=>{const s=De("color"),t=De("font"),a=De("text"),r=De("font-weight"),n=De("tracking"),i=De("leading"),o=De("breakpoint"),c=De("container"),d=De("spacing"),l=De("radius"),m=De("shadow"),g=De("inset-shadow"),y=De("text-shadow"),u=De("drop-shadow"),p=De("blur"),f=De("perspective"),j=De("aspect"),C=De("ease"),T=De("animate"),N=()=>["auto","avoid","all","avoid-page","page","left","right","column"],w=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],O=()=>[...w(),H,J],L=()=>["auto","hidden","clip","visible","scroll"],I=()=>["auto","contain","none"],b=()=>[H,J,d],A=()=>[_s,"full","auto",...b()],_=()=>[Jt,"none","subgrid",H,J],$=()=>["auto",{span:["full",Jt,H,J]},Jt,H,J],ae=()=>[Jt,"auto",H,J],U=()=>["auto","min","max","fr",H,J],z=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],R=()=>["start","end","center","stretch","center-safe","end-safe"],P=()=>["auto",...b()],V=()=>[_s,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...b()],v=()=>[s,H,J],x=()=>[...w(),zn,Dn,{position:[H,J]}],K=()=>["no-repeat",{repeat:["","x","y","space","round"]}],de=()=>["auto","cover","contain",rc,tc,{size:[H,J]}],te=()=>[pr,Zs,rs],ee=()=>["","none","full",l,H,J],se=()=>["",xe,Zs,rs],Oe=()=>["solid","dashed","dotted","double"],Ye=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],ne=()=>[xe,pr,zn,Dn],wt=()=>["","none",p,H,J],nt=()=>["none",xe,H,J],it=()=>["none",xe,H,J],mt=()=>[xe,H,J],ht=()=>[_s,"full",...b()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Rt],breakpoint:[Rt],color:[Zl],container:[Rt],"drop-shadow":[Rt],ease:["in","out","in-out"],font:[ec],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Rt],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Rt],shadow:[Rt],spacing:["px",xe],text:[Rt],"text-shadow":[Rt],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",_s,J,H,j]}],container:["container"],columns:[{columns:[xe,J,H,c]}],"break-after":[{"break-after":N()}],"break-before":[{"break-before":N()}],"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"],sr:["sr-only","not-sr-only"],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:O()}],overflow:[{overflow:L()}],"overflow-x":[{"overflow-x":L()}],"overflow-y":[{"overflow-y":L()}],overscroll:[{overscroll:I()}],"overscroll-x":[{"overscroll-x":I()}],"overscroll-y":[{"overscroll-y":I()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:A()}],"inset-x":[{"inset-x":A()}],"inset-y":[{"inset-y":A()}],start:[{start:A()}],end:[{end:A()}],top:[{top:A()}],right:[{right:A()}],bottom:[{bottom:A()}],left:[{left:A()}],visibility:["visible","invisible","collapse"],z:[{z:[Jt,"auto",H,J]}],basis:[{basis:[_s,"full","auto",c,...b()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[xe,_s,"auto","initial","none",J]}],grow:[{grow:["",xe,H,J]}],shrink:[{shrink:["",xe,H,J]}],order:[{order:[Jt,"first","last","none",H,J]}],"grid-cols":[{"grid-cols":_()}],"col-start-end":[{col:$()}],"col-start":[{"col-start":ae()}],"col-end":[{"col-end":ae()}],"grid-rows":[{"grid-rows":_()}],"row-start-end":[{row:$()}],"row-start":[{"row-start":ae()}],"row-end":[{"row-end":ae()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":U()}],"auto-rows":[{"auto-rows":U()}],gap:[{gap:b()}],"gap-x":[{"gap-x":b()}],"gap-y":[{"gap-y":b()}],"justify-content":[{justify:[...z(),"normal"]}],"justify-items":[{"justify-items":[...R(),"normal"]}],"justify-self":[{"justify-self":["auto",...R()]}],"align-content":[{content:["normal",...z()]}],"align-items":[{items:[...R(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...R(),{baseline:["","last"]}]}],"place-content":[{"place-content":z()}],"place-items":[{"place-items":[...R(),"baseline"]}],"place-self":[{"place-self":["auto",...R()]}],p:[{p:b()}],px:[{px:b()}],py:[{py:b()}],ps:[{ps:b()}],pe:[{pe:b()}],pt:[{pt:b()}],pr:[{pr:b()}],pb:[{pb:b()}],pl:[{pl:b()}],m:[{m:P()}],mx:[{mx:P()}],my:[{my:P()}],ms:[{ms:P()}],me:[{me:P()}],mt:[{mt:P()}],mr:[{mr:P()}],mb:[{mb:P()}],ml:[{ml:P()}],"space-x":[{"space-x":b()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":b()}],"space-y-reverse":["space-y-reverse"],size:[{size:V()}],w:[{w:[c,"screen",...V()]}],"min-w":[{"min-w":[c,"screen","none",...V()]}],"max-w":[{"max-w":[c,"screen","none","prose",{screen:[o]},...V()]}],h:[{h:["screen","lh",...V()]}],"min-h":[{"min-h":["screen","lh","none",...V()]}],"max-h":[{"max-h":["screen","lh",...V()]}],"font-size":[{text:["base",a,Zs,rs]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,H,fr]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",pr,J]}],"font-family":[{font:[ac,J,t]}],"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:[n,H,J]}],"line-clamp":[{"line-clamp":[xe,"none",H,fr]}],leading:[{leading:[i,...b()]}],"list-image":[{"list-image":["none",H,J]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",H,J]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:v()}],"text-color":[{text:v()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...Oe(),"wavy"]}],"text-decoration-thickness":[{decoration:[xe,"from-font","auto",H,rs]}],"text-decoration-color":[{decoration:v()}],"underline-offset":[{"underline-offset":[xe,"auto",H,J]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:b()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",H,J]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",H,J]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:x()}],"bg-repeat":[{bg:K()}],"bg-size":[{bg:de()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Jt,H,J],radial:["",H,J],conic:[Jt,H,J]},nc,sc]}],"bg-color":[{bg:v()}],"gradient-from-pos":[{from:te()}],"gradient-via-pos":[{via:te()}],"gradient-to-pos":[{to:te()}],"gradient-from":[{from:v()}],"gradient-via":[{via:v()}],"gradient-to":[{to:v()}],rounded:[{rounded:ee()}],"rounded-s":[{"rounded-s":ee()}],"rounded-e":[{"rounded-e":ee()}],"rounded-t":[{"rounded-t":ee()}],"rounded-r":[{"rounded-r":ee()}],"rounded-b":[{"rounded-b":ee()}],"rounded-l":[{"rounded-l":ee()}],"rounded-ss":[{"rounded-ss":ee()}],"rounded-se":[{"rounded-se":ee()}],"rounded-ee":[{"rounded-ee":ee()}],"rounded-es":[{"rounded-es":ee()}],"rounded-tl":[{"rounded-tl":ee()}],"rounded-tr":[{"rounded-tr":ee()}],"rounded-br":[{"rounded-br":ee()}],"rounded-bl":[{"rounded-bl":ee()}],"border-w":[{border:se()}],"border-w-x":[{"border-x":se()}],"border-w-y":[{"border-y":se()}],"border-w-s":[{"border-s":se()}],"border-w-e":[{"border-e":se()}],"border-w-t":[{"border-t":se()}],"border-w-r":[{"border-r":se()}],"border-w-b":[{"border-b":se()}],"border-w-l":[{"border-l":se()}],"divide-x":[{"divide-x":se()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":se()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...Oe(),"hidden","none"]}],"divide-style":[{divide:[...Oe(),"hidden","none"]}],"border-color":[{border:v()}],"border-color-x":[{"border-x":v()}],"border-color-y":[{"border-y":v()}],"border-color-s":[{"border-s":v()}],"border-color-e":[{"border-e":v()}],"border-color-t":[{"border-t":v()}],"border-color-r":[{"border-r":v()}],"border-color-b":[{"border-b":v()}],"border-color-l":[{"border-l":v()}],"divide-color":[{divide:v()}],"outline-style":[{outline:[...Oe(),"none","hidden"]}],"outline-offset":[{"outline-offset":[xe,H,J]}],"outline-w":[{outline:["",xe,Zs,rs]}],"outline-color":[{outline:v()}],shadow:[{shadow:["","none",m,Na,wa]}],"shadow-color":[{shadow:v()}],"inset-shadow":[{"inset-shadow":["none",g,Na,wa]}],"inset-shadow-color":[{"inset-shadow":v()}],"ring-w":[{ring:se()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:v()}],"ring-offset-w":[{"ring-offset":[xe,rs]}],"ring-offset-color":[{"ring-offset":v()}],"inset-ring-w":[{"inset-ring":se()}],"inset-ring-color":[{"inset-ring":v()}],"text-shadow":[{"text-shadow":["none",y,Na,wa]}],"text-shadow-color":[{"text-shadow":v()}],opacity:[{opacity:[xe,H,J]}],"mix-blend":[{"mix-blend":[...Ye(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":Ye()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[xe]}],"mask-image-linear-from-pos":[{"mask-linear-from":ne()}],"mask-image-linear-to-pos":[{"mask-linear-to":ne()}],"mask-image-linear-from-color":[{"mask-linear-from":v()}],"mask-image-linear-to-color":[{"mask-linear-to":v()}],"mask-image-t-from-pos":[{"mask-t-from":ne()}],"mask-image-t-to-pos":[{"mask-t-to":ne()}],"mask-image-t-from-color":[{"mask-t-from":v()}],"mask-image-t-to-color":[{"mask-t-to":v()}],"mask-image-r-from-pos":[{"mask-r-from":ne()}],"mask-image-r-to-pos":[{"mask-r-to":ne()}],"mask-image-r-from-color":[{"mask-r-from":v()}],"mask-image-r-to-color":[{"mask-r-to":v()}],"mask-image-b-from-pos":[{"mask-b-from":ne()}],"mask-image-b-to-pos":[{"mask-b-to":ne()}],"mask-image-b-from-color":[{"mask-b-from":v()}],"mask-image-b-to-color":[{"mask-b-to":v()}],"mask-image-l-from-pos":[{"mask-l-from":ne()}],"mask-image-l-to-pos":[{"mask-l-to":ne()}],"mask-image-l-from-color":[{"mask-l-from":v()}],"mask-image-l-to-color":[{"mask-l-to":v()}],"mask-image-x-from-pos":[{"mask-x-from":ne()}],"mask-image-x-to-pos":[{"mask-x-to":ne()}],"mask-image-x-from-color":[{"mask-x-from":v()}],"mask-image-x-to-color":[{"mask-x-to":v()}],"mask-image-y-from-pos":[{"mask-y-from":ne()}],"mask-image-y-to-pos":[{"mask-y-to":ne()}],"mask-image-y-from-color":[{"mask-y-from":v()}],"mask-image-y-to-color":[{"mask-y-to":v()}],"mask-image-radial":[{"mask-radial":[H,J]}],"mask-image-radial-from-pos":[{"mask-radial-from":ne()}],"mask-image-radial-to-pos":[{"mask-radial-to":ne()}],"mask-image-radial-from-color":[{"mask-radial-from":v()}],"mask-image-radial-to-color":[{"mask-radial-to":v()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":w()}],"mask-image-conic-pos":[{"mask-conic":[xe]}],"mask-image-conic-from-pos":[{"mask-conic-from":ne()}],"mask-image-conic-to-pos":[{"mask-conic-to":ne()}],"mask-image-conic-from-color":[{"mask-conic-from":v()}],"mask-image-conic-to-color":[{"mask-conic-to":v()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:x()}],"mask-repeat":[{mask:K()}],"mask-size":[{mask:de()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",H,J]}],filter:[{filter:["","none",H,J]}],blur:[{blur:wt()}],brightness:[{brightness:[xe,H,J]}],contrast:[{contrast:[xe,H,J]}],"drop-shadow":[{"drop-shadow":["","none",u,Na,wa]}],"drop-shadow-color":[{"drop-shadow":v()}],grayscale:[{grayscale:["",xe,H,J]}],"hue-rotate":[{"hue-rotate":[xe,H,J]}],invert:[{invert:["",xe,H,J]}],saturate:[{saturate:[xe,H,J]}],sepia:[{sepia:["",xe,H,J]}],"backdrop-filter":[{"backdrop-filter":["","none",H,J]}],"backdrop-blur":[{"backdrop-blur":wt()}],"backdrop-brightness":[{"backdrop-brightness":[xe,H,J]}],"backdrop-contrast":[{"backdrop-contrast":[xe,H,J]}],"backdrop-grayscale":[{"backdrop-grayscale":["",xe,H,J]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[xe,H,J]}],"backdrop-invert":[{"backdrop-invert":["",xe,H,J]}],"backdrop-opacity":[{"backdrop-opacity":[xe,H,J]}],"backdrop-saturate":[{"backdrop-saturate":[xe,H,J]}],"backdrop-sepia":[{"backdrop-sepia":["",xe,H,J]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":b()}],"border-spacing-x":[{"border-spacing-x":b()}],"border-spacing-y":[{"border-spacing-y":b()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",H,J]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[xe,"initial",H,J]}],ease:[{ease:["linear","initial",C,H,J]}],delay:[{delay:[xe,H,J]}],animate:[{animate:["none",T,H,J]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[f,H,J]}],"perspective-origin":[{"perspective-origin":O()}],rotate:[{rotate:nt()}],"rotate-x":[{"rotate-x":nt()}],"rotate-y":[{"rotate-y":nt()}],"rotate-z":[{"rotate-z":nt()}],scale:[{scale:it()}],"scale-x":[{"scale-x":it()}],"scale-y":[{"scale-y":it()}],"scale-z":[{"scale-z":it()}],"scale-3d":["scale-3d"],skew:[{skew:mt()}],"skew-x":[{"skew-x":mt()}],"skew-y":[{"skew-y":mt()}],transform:[{transform:[H,J,"","none","gpu","cpu"]}],"transform-origin":[{origin:O()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:ht()}],"translate-x":[{"translate-x":ht()}],"translate-y":[{"translate-y":ht()}],"translate-z":[{"translate-z":ht()}],"translate-none":["translate-none"],accent:[{accent:v()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:v()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],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",H,J]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":b()}],"scroll-mx":[{"scroll-mx":b()}],"scroll-my":[{"scroll-my":b()}],"scroll-ms":[{"scroll-ms":b()}],"scroll-me":[{"scroll-me":b()}],"scroll-mt":[{"scroll-mt":b()}],"scroll-mr":[{"scroll-mr":b()}],"scroll-mb":[{"scroll-mb":b()}],"scroll-ml":[{"scroll-ml":b()}],"scroll-p":[{"scroll-p":b()}],"scroll-px":[{"scroll-px":b()}],"scroll-py":[{"scroll-py":b()}],"scroll-ps":[{"scroll-ps":b()}],"scroll-pe":[{"scroll-pe":b()}],"scroll-pt":[{"scroll-pt":b()}],"scroll-pr":[{"scroll-pr":b()}],"scroll-pb":[{"scroll-pb":b()}],"scroll-pl":[{"scroll-pl":b()}],"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",H,J]}],fill:[{fill:["none",...v()]}],"stroke-w":[{stroke:[xe,Zs,rs,fr]}],stroke:[{stroke:["none",...v()]}],"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-x","border-w-y","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-x","border-color-y","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"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"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"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},lc=(s,{cacheSize:t,prefix:a,experimentalParseClassName:r,extend:n={},override:i={}})=>(sa(s,"cacheSize",t),sa(s,"prefix",a),sa(s,"experimentalParseClassName",r),_a(s.theme,i.theme),_a(s.classGroups,i.classGroups),_a(s.conflictingClassGroups,i.conflictingClassGroups),_a(s.conflictingClassGroupModifiers,i.conflictingClassGroupModifiers),sa(s,"orderSensitiveModifiers",i.orderSensitiveModifiers),Sa(s.theme,n.theme),Sa(s.classGroups,n.classGroups),Sa(s.conflictingClassGroups,n.conflictingClassGroups),Sa(s.conflictingClassGroupModifiers,n.conflictingClassGroupModifiers),eo(s,n,"orderSensitiveModifiers"),s),sa=(s,t,a)=>{a!==void 0&&(s[t]=a)},_a=(s,t)=>{if(t)for(const a in t)sa(s,a,t[a])},Sa=(s,t)=>{if(t)for(const a in t)eo(s,t,a)},eo=(s,t,a)=>{const r=t[a];r!==void 0&&(s[a]=s[a]?s[a].concat(r):r)},yy=(s,...t)=>typeof s=="function"?Er(Ar,s,...t):Er(()=>lc(Ar(),s),...t),cc=Er(Ar);function D(...s){return cc(Ri(s))}const qn=s=>typeof s=="boolean"?`${s}`:s===0?"0":s,Un=Ri,dc=(s,t)=>a=>{var r;if((t==null?void 0:t.variants)==null)return Un(s,a==null?void 0:a.class,a==null?void 0:a.className);const{variants:n,defaultVariants:i}=t,o=Object.keys(n).map(l=>{const m=a==null?void 0:a[l],g=i==null?void 0:i[l];if(m===null)return null;const y=qn(m)||qn(g);return n[l][y]}),c=a&&Object.entries(a).reduce((l,m)=>{let[g,y]=m;return y===void 0||(l[g]=y),l},{}),d=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((l,m)=>{let{class:g,className:y,...u}=m;return Object.entries(u).every(p=>{let[f,j]=p;return Array.isArray(j)?j.includes({...i,...c}[f]):{...i,...c}[f]===j})?[...l,g,y]:l},[]);return Un(s,o,d,a==null?void 0:a.class,a==null?void 0:a.className)},uc=dc("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium text-foreground transition-all duration-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-sm hover:bg-primary/90 hover:shadow-md active:scale-[0.98]",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90 hover:shadow-md active:scale-[0.98]",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground hover:shadow-sm active:scale-[0.98]",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80 hover:shadow-md active:scale-[0.98]",ghost:"hover:bg-accent hover:text-accent-foreground hover:shadow-sm active:scale-[0.98]",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),k=h.forwardRef(({className:s,variant:t,size:a,asChild:r=!1,...n},i)=>{const o=r?hl:"button";return e.jsx(o,{className:D(uc({variant:t,size:a,className:s})),ref:i,...n})});k.displayName="Button";/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mc=s=>s.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),hc=s=>s.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,a,r)=>r?r.toUpperCase():a.toLowerCase()),Bn=s=>{const t=hc(s);return t.charAt(0).toUpperCase()+t.slice(1)},to=(...s)=>s.filter((t,a,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===a).join(" ").trim(),gc=s=>{for(const t in s)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */var xc={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.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pc=h.forwardRef(({color:s="currentColor",size:t=24,strokeWidth:a=2,absoluteStrokeWidth:r,className:n="",children:i,iconNode:o,...c},d)=>h.createElement("svg",{ref:d,...xc,width:t,height:t,stroke:s,strokeWidth:r?Number(a)*24/Number(t):a,className:to("lucide",n),...!i&&!gc(c)&&{"aria-hidden":"true"},...c},[...o.map(([l,m])=>h.createElement(l,m)),...Array.isArray(i)?i:[i]]));/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const E=(s,t)=>{const a=h.forwardRef(({className:r,...n},i)=>h.createElement(pc,{ref:i,iconNode:t,className:to(`lucide-${mc(Bn(s))}`,`lucide-${s}`,r),...n}));return a.displayName=Bn(s),a};/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fc=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],gs=E("activity",fc);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yc=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],so=E("arrow-left",yc);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bc=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],ao=E("arrow-right",bc);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vc=[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]],jc=E("arrow-up-right",vc);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kc=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]],ro=E("bell",kc);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wc=[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]],Nc=E("book-open",wc);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _c=[["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}]],Sc=E("book",_c);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cc=[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]],Or=E("brain",Cc);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tc=[["path",{d:"M6 22V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v18Z",key:"1b4qmf"}],["path",{d:"M6 12H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h2",key:"i71pzd"}],["path",{d:"M18 9h2a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2h-2",key:"10jefs"}],["path",{d:"M10 6h4",key:"1itunk"}],["path",{d:"M10 10h4",key:"tcdvrf"}],["path",{d:"M10 14h4",key:"kelpxr"}],["path",{d:"M10 18h4",key:"1ulq68"}]],Vn=E("building-2",Tc);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pc=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]],na=E("calendar",Pc);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ec=[["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"}]],As=E("chart-column",Ec);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ac=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"m19 9-5 5-4-4-3 3",key:"2osh9i"}]],Oc=E("chart-line",Ac);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ic=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],no=E("check",Ic);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mc=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Rc=E("chevron-down",Mc);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lc=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Ya=E("chevron-left",Lc);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $c=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Xa=E("chevron-right",$c);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fc=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],Dc=E("chevron-up",Fc);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zc=[["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"}]],tt=E("circle-alert",zc);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qc=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 12-4-4-4 4",key:"177agl"}],["path",{d:"M12 16V8",key:"1sbj14"}]],Uc=E("circle-arrow-up",qc);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bc=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],ua=E("circle-check-big",Bc);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vc=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Me=E("circle-check",Vc);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kc=[["path",{d:"M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z",key:"kmsa83"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Kn=E("circle-play",Kc);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jc=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Jn=E("circle-question-mark",Jc);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hc=[["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"}]],xs=E("circle-x",Hc);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wc=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Vs=E("clock",Wc);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gc=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],io=E("cloud",Gc);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zc=[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]],Ir=E("code-xml",Zc);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qc=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],Yc=E("code",Qc);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xc=[["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"}]],fs=E("copy",Xc);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ed=[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]],td=E("cpu",ed);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sd=[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]],ad=E("credit-card",sd);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rd=[["path",{d:"M11.562 3.266a.5.5 0 0 1 .876 0L15.39 8.87a1 1 0 0 0 1.516.294L21.183 5.5a.5.5 0 0 1 .798.519l-2.834 10.246a1 1 0 0 1-.956.734H5.81a1 1 0 0 1-.957-.734L2.02 6.02a.5.5 0 0 1 .798-.519l4.276 3.664a1 1 0 0 0 1.516-.294z",key:"1vdc57"}],["path",{d:"M5 21h14",key:"11awu3"}]],nd=E("crown",rd);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const id=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],Ms=E("database",id);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const od=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],tn=E("download",od);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ld=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],Os=E("external-link",ld);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cd=[["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"}]],sn=E("eye-off",cd);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dd=[["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"}]],ma=E("eye",dd);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ud=[["path",{d:"M12 6a2 2 0 0 1 3.414-1.414l6 6a2 2 0 0 1 0 2.828l-6 6A2 2 0 0 1 12 18z",key:"b19h5q"}],["path",{d:"M2 6a2 2 0 0 1 3.414-1.414l6 6a2 2 0 0 1 0 2.828l-6 6A2 2 0 0 1 2 18z",key:"h7h5ge"}]],md=E("fast-forward",ud);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hd=[["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 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1",key:"1oajmo"}],["path",{d:"M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1",key:"mpwhp6"}]],gd=E("file-json",hd);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xd=[["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"}]],Rs=E("file-text",xd);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pd=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 3v18",key:"bbkbws"}],["path",{d:"M3 7.5h4",key:"zfgn84"}],["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 16.5h4",key:"1230mu"}],["path",{d:"M17 3v18",key:"in4fa5"}],["path",{d:"M17 7.5h4",key:"myr1c1"}],["path",{d:"M17 16.5h4",key:"go4c1d"}]],fd=E("film",pd);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yd=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],bd=E("folder-open",yd);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vd=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],jd=E("funnel",vd);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kd=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],oo=E("gauge",kd);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wd=[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]],yr=E("git-branch",wd);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nd=[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["path",{d:"M11 18H8a2 2 0 0 1-2-2V9",key:"19pyzm"}]],_d=E("git-compare",Nd);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sd=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],lo=E("globe",Sd);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cd=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],Td=E("grip-vertical",Cd);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pd=[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]],an=E("hard-drive",Pd);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ed=[["path",{d:"M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5",key:"mvr1a0"}],["path",{d:"M3.22 13H9.5l.5-1 2 4.5 2-7 1.5 3.5h5.27",key:"auskq0"}]],Ad=E("heart-pulse",Ed);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Od=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],La=E("history",Od);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Id=[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"r6nss1"}]],co=E("house",Id);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Md=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m8 11 4 4 4-4",key:"1dohi6"}],["path",{d:"M8 5H4a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-4",key:"1ywtjm"}]],Rd=E("import",Md);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ld=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],ia=E("info",Ld);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $d=[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]],Gt=E("key",$d);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fd=[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]],Dd=E("keyboard",Fd);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zd=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],Hn=E("layers",zd);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qd=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.93 4.93 4.24 4.24",key:"1ymg45"}],["path",{d:"m14.83 9.17 4.24-4.24",key:"1cb5xl"}],["path",{d:"m14.83 14.83 4.24 4.24",key:"q42g0n"}],["path",{d:"m9.17 14.83-4.24 4.24",key:"bqpfvv"}],["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}]],Ud=E("life-buoy",qd);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bd=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],Vd=E("link-2",Bd);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kd=[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]],Jd=E("link",Kd);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hd=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Is=E("loader-circle",Hd);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wd=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],Ls=E("lock",Wd);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gd=[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]],uo=E("mail",Gd);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zd=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],Qd=E("menu",Zd);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yd=[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}]],Mr=E("message-circle",Yd);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xd=[["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["rect",{x:"9",y:"2",width:"6",height:"13",rx:"3",key:"s6n7sd"}]],eu=E("mic",Xd);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tu=[["path",{d:"M5 12h14",key:"1ays0h"}]],su=E("minus",tu);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const au=[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]],ru=E("monitor",au);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nu=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],mo=E("moon",nu);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iu=[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]],rn=E("network",iu);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ou=[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]],lu=E("package",ou);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cu=[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]],du=E("palette",cu);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uu=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M9 21V9",key:"1oto5p"}]],mu=E("panels-top-left",uu);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hu=[["rect",{x:"14",y:"3",width:"5",height:"18",rx:"1",key:"kaeet6"}],["rect",{x:"5",y:"3",width:"5",height:"18",rx:"1",key:"1wsw3u"}]],gu=E("pause",hu);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xu=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],er=E("play",xu);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pu=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],kt=E("plus",pu);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fu=[["path",{d:"M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z",key:"w46dr5"}]],yu=E("puzzle",fu);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bu=[["path",{d:"M16.247 7.761a6 6 0 0 1 0 8.478",key:"1fwjs5"}],["path",{d:"M19.075 4.933a10 10 0 0 1 0 14.134",key:"ehdyv1"}],["path",{d:"M4.925 19.067a10 10 0 0 1 0-14.134",key:"1q22gi"}],["path",{d:"M7.753 16.239a6 6 0 0 1 0-8.478",key:"r2q7qm"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]],Wn=E("radio",bu);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vu=[["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"}]],st=E("refresh-cw",vu);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ju=[["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z",key:"m3kijz"}],["path",{d:"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z",key:"1fmvmk"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0",key:"1f8sc4"}],["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}]],ku=E("rocket",ju);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wu=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],nn=E("rotate-ccw",wu);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nu=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],Xt=E("save",Nu);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _u=[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]],tr=E("scroll-text",_u);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Su=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],sr=E("search",Su);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cu=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],Rr=E("server",Cu);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tu=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Tt=E("settings",Tu);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pu=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],on=E("settings-2",Pu);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Eu=[["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"}]],Au=E("share-2",Eu);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ou=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],Zt=E("shield",Ou);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Iu=[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]],Ks=E("square-pen",Iu);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mu=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],Ru=E("square",Mu);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lu=[["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"}]],$u=E("star",Lu);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fu=[["path",{d:"M15 21v-5a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v5",key:"slp6dd"}],["path",{d:"M17.774 10.31a1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.451 0 1.12 1.12 0 0 0-1.548 0 2.5 2.5 0 0 1-3.452 0 1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.77-3.248l2.889-4.184A2 2 0 0 1 7 2h10a2 2 0 0 1 1.653.873l2.895 4.192a2.5 2.5 0 0 1-3.774 3.244",key:"o0xfot"}],["path",{d:"M4 10.95V19a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8.05",key:"wn3emo"}]],Gn=E("store",Fu);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Du=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],ho=E("sun",Du);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zu=[["path",{d:"M12 3v18",key:"108xh3"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}]],Ca=E("table",zu);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qu=[["path",{d:"M14.5 2v17.5c0 1.4-1.1 2.5-2.5 2.5c-1.4 0-2.5-1.1-2.5-2.5V2",key:"125lnx"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M14.5 16h-5",key:"1ox875"}]],Uu=E("test-tube",qu);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bu=[["circle",{cx:"9",cy:"12",r:"3",key:"u3jwor"}],["rect",{width:"20",height:"14",x:"2",y:"5",rx:"7",key:"g7kal2"}]],go=E("toggle-left",Bu);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vu=[["circle",{cx:"15",cy:"12",r:"3",key:"1afu0r"}],["rect",{width:"20",height:"14",x:"2",y:"5",rx:"7",key:"g7kal2"}]],xo=E("toggle-right",Vu);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ku=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],Qe=E("trash-2",Ku);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ju=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],Lr=E("trending-up",Ju);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hu=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Dt=E("triangle-alert",Hu);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wu=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],$r=E("upload",Wu);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gu=[["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"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]],za=E("user-plus",Gu);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zu=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],Qu=E("user",Zu);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yu=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],Fr=E("users",Yu);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xu=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],ln=E("wifi-off",Xu);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const em=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]],oa=E("wifi",em);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tm=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],ha=E("x",tm);/** * @license lucide-react v0.544.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sm=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],dt=E("zap",sm),po={id:"core-brand",name:"MockForge Core",description:"Professional orange-themed design with clean contrast",preview:{primary:"#D35400",secondary:"#FAFBFC",accent:"#10B981"},colors:{light:{"--background":"0 0% 100%","--card":"0 0% 100%","--card-foreground":"220 15% 15%","--popover":"0 0% 100%","--popover-foreground":"220 15% 15%","--primary":"24 86% 42%","--primary-foreground":"0 0% 100%","--secondary":"217.2 32.6% 17.5%","--secondary-foreground":"210 40% 98%","--muted":"210 40% 96.1%","--muted-foreground":"215.4 16.3% 46.9%","--accent":"210 40% 96.1%","--accent-foreground":"222.2 47.4% 11.2%","--destructive":"0 84% 50%","--destructive-foreground":"0 0% 98%","--border":"214.3 31.8% 91.4%","--input":"214.3 31.8% 91.4%","--ring":"215 20% 65%","--brand":"24 86% 42%","--brand-50":"24 100% 97%","--brand-100":"24 95% 92%","--brand-200":"24 90% 84%","--brand-300":"24 85% 70%","--brand-400":"24 85% 55%","--brand-500":"24 86% 42%","--brand-600":"24 88% 36%","--brand-700":"24 92% 30%","--brand-800":"24 95% 24%","--brand-900":"24 98% 18%","--success":"142 76% 36%","--success-50":"142 100% 97%","--success-100":"142 90% 92%","--success-500":"142 76% 36%","--success-600":"142 78% 32%","--warning":"42 96% 50%","--warning-50":"42 100% 96%","--warning-100":"42 95% 90%","--warning-500":"42 96% 50%","--warning-600":"42 98% 45%","--danger":"0 84% 50%","--danger-50":"0 100% 97%","--danger-100":"0 95% 92%","--danger-500":"0 84% 50%","--danger-600":"0 86% 45%","--info":"217 91% 60%","--info-50":"217 100% 97%","--info-100":"217 95% 92%","--info-500":"217 91% 60%","--info-600":"217 93% 55%","--bg-primary":"0 0% 100%","--bg-secondary":"210 40% 98%","--bg-tertiary":"210 40% 96%","--bg-overlay":"0 0% 0% / 0.5","--text-primary":"220 15% 15%","--text-secondary":"220 10% 40%","--text-tertiary":"220 10% 55%","--text-inverse":"0 0% 100%","--radius":"12px"},dark:{"--background":"220 15% 7%","--card":"222 15% 9%","--card-foreground":"210 20% 98%","--popover":"222 16% 11%","--popover-foreground":"210 20% 98%","--primary":"24 86% 52%","--primary-foreground":"220 15% 7%","--secondary":"219 13% 18%","--secondary-foreground":"210 20% 98%","--muted":"219 13% 18%","--muted-foreground":"215 16% 72%","--accent":"219 13% 18%","--accent-foreground":"210 20% 98%","--destructive":"0 84% 60%","--destructive-foreground":"220 15% 7%","--border":"215 15% 20%","--input":"215 15% 20%","--ring":"24 86% 52%","--brand":"24 86% 52%","--brand-50":"24 15% 12%","--brand-100":"24 20% 18%","--brand-200":"24 25% 24%","--brand-300":"24 30% 30%","--brand-400":"24 40% 40%","--brand-500":"24 86% 52%","--brand-600":"24 88% 48%","--brand-700":"24 92% 42%","--brand-800":"24 95% 36%","--brand-900":"24 98% 24%","--success":"142 76% 48%","--success-50":"142 15% 12%","--success-100":"142 20% 18%","--success-500":"142 76% 48%","--success-600":"142 78% 42%","--warning":"42 96% 60%","--warning-50":"42 15% 12%","--warning-100":"42 20% 18%","--warning-500":"42 96% 60%","--warning-600":"42 98% 55%","--danger":"0 84% 60%","--danger-50":"0 15% 12%","--danger-100":"0 20% 18%","--danger-500":"0 84% 60%","--danger-600":"0 86% 55%","--info":"217 91% 65%","--info-50":"217 15% 12%","--info-100":"217 20% 18%","--info-500":"217 91% 65%","--info-600":"217 93% 60%","--bg-primary":"222 15% 9%","--bg-secondary":"220 15% 7%","--bg-tertiary":"219 13% 12%","--bg-overlay":"0 0% 0% / 0.7","--text-primary":"210 20% 98%","--text-secondary":"215 16% 72%","--text-tertiary":"215 12% 55%","--text-inverse":"220 15% 7%","--radius":"12px"}}},am={id:"professional-blue",name:"Professional Blue",description:"Clean corporate blue for business environments",preview:{primary:"#2563EB",secondary:"#F8FAFC",accent:"#10B981"},colors:{light:{"--background":"0 0% 100%","--card":"0 0% 100%","--card-foreground":"222.2 84% 4.9%","--popover":"0 0% 100%","--popover-foreground":"222.2 84% 4.9%","--primary":"221.2 83.2% 53.3%","--primary-foreground":"210 40% 98%","--secondary":"210 40% 96%","--secondary-foreground":"222.2 84% 4.9%","--muted":"210 40% 96%","--muted-foreground":"215.4 16.3% 46.9%","--accent":"210 40% 96%","--accent-foreground":"222.2 84% 4.9%","--destructive":"0 84.2% 60.2%","--destructive-foreground":"210 40% 98%","--border":"214.3 31.8% 91.4%","--input":"214.3 31.8% 91.4%","--ring":"221.2 83.2% 53.3%","--brand":"221.2 83.2% 53.3%","--brand-50":"214.3 31.8% 91.4%","--brand-100":"214.3 31.8% 91.4%","--brand-200":"209.4 31.8% 84%","--brand-300":"209.4 34% 70%","--brand-400":"217.2 32% 54%","--brand-500":"221.2 83.2% 53.3%","--brand-600":"217.2 91.2% 60%","--brand-700":"217.2 91.2% 42%","--brand-800":"217.2 93.2% 30%","--brand-900":"217.2 93.2% 18%","--success":"142 76.2% 36.3%","--success-50":"138 62.8% 94.6%","--success-100":"134 60.3% 84%","--success-500":"142 76.2% 36.3%","--success-600":"142 71% 45%","--warning":"45.4 93.4% 47.5%","--warning-50":"53.8 91.8% 94.6%","--warning-100":"49.8 91.7% 84%","--warning-500":"45.4 93.4% 47.5%","--warning-600":"35.5 91.7% 52%","--danger":"0 84.2% 60.2%","--danger-50":"0 85.7% 97.3%","--danger-100":"0 74.7% 84%","--danger-500":"0 84.2% 60.2%","--danger-600":"0 72% 51%","--info":"199.4 89% 48.3%","--info-50":"199.4 89% 95%","--info-100":"197.4 89% 84%","--info-500":"199.4 89% 48.3%","--info-600":"202.4 89% 48%","--bg-primary":"0 0% 100%","--bg-secondary":"210 40% 98%","--bg-tertiary":"210 40% 96%","--bg-overlay":"0 0% 0% / 0.5","--text-primary":"222.2 84% 4.9%","--text-secondary":"215.4 16.3% 46.9%","--text-tertiary":"215 13.8% 34.1%","--text-inverse":"0 0% 100%","--radius":"12px"},dark:{"--background":"222.2 84% 4.9%","--card":"222.2 84% 4.9%","--card-foreground":"210 40% 98%","--popover":"222.2 84% 4.9%","--popover-foreground":"210 40% 98%","--primary":"217.2 91.2% 59.8%","--primary-foreground":"222.2 84% 4.9%","--secondary":"217.2 32.6% 17.5%","--secondary-foreground":"210 40% 98%","--muted":"217.2 32.6% 17.5%","--muted-foreground":"215 20.2% 65.1%","--accent":"217.2 32.6% 17.5%","--accent-foreground":"210 40% 98%","--destructive":"0 62.8% 30.6%","--destructive-foreground":"210 40% 98%","--border":"217.2 32.6% 17.5%","--input":"217.2 32.6% 17.5%","--ring":"224.3 76.3% 94.1%","--brand":"217.2 91.2% 59.8%","--brand-50":"210 5% 8%","--brand-100":"214.3 31.8% 10%","--brand-200":"217.2 32.6% 17.5%","--brand-300":"216.5 41% 25%","--brand-400":"217.2 32% 35%","--brand-500":"217.2 91.2% 59.8%","--brand-600":"217.2 91.2% 46%","--brand-700":"217.2 91.2% 35%","--brand-800":"217.2 91.2% 25%","--brand-900":"217.2 91.2% 15%","--success":"142 76.2% 36.3%","--success-50":"120 5% 8%","--success-100":"125 60% 10%","--success-500":"142 76.2% 36.3%","--success-600":"142 71% 45%","--warning":"45.4 93.4% 47.5%","--warning-50":"36 4% 8%","--warning-100":"36 93% 10%","--warning-500":"45.4 93.4% 47.5%","--warning-600":"35.5 91.7% 52%","--danger":"0 62.8% 30.6%","--danger-50":"0 5% 6%","--danger-100":"0 45% 10%","--danger-500":"0 62.8% 30.6%","--danger-600":"0 72% 51%","--info":"199.4 89% 48.3%","--info-50":"180 4% 8%","--info-100":"180 89% 10%","--info-500":"199.4 89% 48.3%","--info-600":"202.4 89% 48%","--bg-primary":"222.2 84% 4.9%","--bg-secondary":"217.2 32.6% 17.5%","--bg-tertiary":"217.2 32.6% 17.5%","--bg-overlay":"0 0% 0% / 0.7","--text-primary":"210 40% 98%","--text-secondary":"215 20.2% 65.1%","--text-tertiary":"217.2 10.6% 64.9%","--text-inverse":"222.2 84% 4.9%","--radius":"12px"}}},rm={id:"forest-green",name:"Forest Green",description:"Natural green palette inspired by forest landscapes",preview:{primary:"#16A34A",secondary:"#F0FDF4",accent:"#DC2626"},colors:{light:{"--background":"0 0% 100%","--card":"0 0% 100%","--card-foreground":"222.2 84% 4.9%","--popover":"0 0% 100%","--popover-foreground":"222.2 84% 4.9%","--primary":"142 76% 37%","--primary-foreground":"210 40% 98%","--secondary":"141 84% 96%","--secondary-foreground":"222.2 84% 4.9%","--muted":"141 84% 96%","--muted-foreground":"215.4 16.3% 46.9%","--accent":"141 84% 96%","--accent-foreground":"222.2 84% 4.9%","--destructive":"0 84.2% 60.2%","--destructive-foreground":"210 40% 98%","--border":"141 84% 93%","--input":"141 84% 93%","--ring":"142 76% 37%","--brand":"142 76% 37%","--brand-50":"137 88% 96%","--brand-100":"136 82% 93%","--brand-200":"141 64% 84%","--brand-300":"142 69% 70%","--brand-400":"142 78% 55%","--brand-500":"142 76% 37%","--brand-600":"142 76% 26%","--brand-700":"142 76% 20%","--brand-800":"142 76% 15%","--brand-900":"142 76% 10%","--success":"142 76% 37%","--success-50":"141 84% 96%","--success-100":"141 84% 93%","--success-500":"142 76% 37%","--success-600":"142 76% 26%","--warning":"45.4 93.4% 47.5%","--warning-50":"53.8 91.8% 94.6%","--warning-100":"49.8 91.7% 84%","--warning-500":"45.4 93.4% 47.5%","--warning-600":"35.5 91.7% 52%","--danger":"0 84.2% 60.2%","--danger-50":"0 85.7% 97.3%","--danger-100":"0 74.7% 84%","--danger-500":"0 84.2% 60.2%","--danger-600":"0 72% 51%","--info":"221.2 83.2% 53.3%","--info-50":"214.3 31.8% 91.4%","--info-100":"214.3 31.8% 91.4%","--info-500":"221.2 83.2% 53.3%","--info-600":"217.2 91.2% 60%","--bg-primary":"0 0% 100%","--bg-secondary":"141 84% 96%","--bg-tertiary":"141 84% 93%","--bg-overlay":"0 0% 0% / 0.5","--text-primary":"222.2 84% 4.9%","--text-secondary":"215.4 16.3% 46.9%","--text-tertiary":"215 13.8% 34.1%","--text-inverse":"0 0% 100%","--radius":"12px"},dark:{"--background":"120 10% 3.9%","--card":"120 10% 3.9%","--card-foreground":"120 9% 98%","--popover":"120 10% 3.9%","--popover-foreground":"120 9% 98%","--primary":"142 76% 37%","--primary-foreground":"120 10% 3.9%","--secondary":"120 5% 10%","--secondary-foreground":"120 9% 98%","--muted":"120 5% 10%","--muted-foreground":"120 5% 65%","--accent":"120 5% 10%","--accent-foreground":"120 9% 98%","--destructive":"0 62.8% 30.6%","--destructive-foreground":"120 9% 98%","--border":"120 3.7% 15.9%","--input":"120 3.7% 15.9%","--ring":"142 76% 37%","--brand":"142 76% 37%","--brand-50":"120 3% 8%","--brand-100":"120 5% 10%","--brand-200":"120 5% 15%","--brand-300":"120 5% 20%","--brand-400":"120 5% 25%","--brand-500":"142 76% 37%","--brand-600":"142 76% 26%","--brand-700":"142 76% 20%","--brand-800":"142 76% 15%","--brand-900":"142 76% 10%","--success":"142 76% 37%","--success-50":"120 5% 10%","--success-100":"120 5% 15%","--success-500":"142 76% 37%","--success-600":"142 76% 26%","--warning":"45.4 93.4% 47.5%","--warning-50":"36 4% 8%","--warning-100":"36 93% 10%","--warning-500":"45.4 93.4% 47.5%","--warning-600":"35.5 91.7% 52%","--danger":"0 62.8% 30.6%","--danger-50":"0 5% 6%","--danger-100":"0 45% 10%","--danger-500":"0 62.8% 30.6%","--danger-600":"0 72% 51%","--info":"221.2 83.2% 53.3%","--info-50":"214.3 31% 8%","--info-100":"214.3 31% 12%","--info-500":"221.2 83.2% 53.3%","--info-600":"217.2 91.2% 60%","--bg-primary":"120 10% 3.9%","--bg-secondary":"120 5% 10%","--bg-tertiary":"120 3.7% 15.9%","--bg-overlay":"0 0% 0% / 0.7","--text-primary":"120 9% 98%","--text-secondary":"120 5% 65%","--text-tertiary":"120 3% 50%","--text-inverse":"120 10% 3.9%","--radius":"12px"}}},nm={id:"twilight-purple",name:"Twilight Purple",description:"Elegant purple gradient inspired by sunset skies",preview:{primary:"#8B5CF6",secondary:"#FAF5FF",accent:"#F59E0B"},colors:{light:{"--background":"0 0% 100%","--card":"0 0% 100%","--card-foreground":"222.2 84% 4.9%","--popover":"0 0% 100%","--popover-foreground":"222.2 84% 4.9%","--primary":"255 92% 61%","--primary-foreground":"210 40% 98%","--secondary":"255 92% 96%","--secondary-foreground":"222.2 84% 4.9%","--muted":"255 92% 96%","--muted-foreground":"215.4 16.3% 46.9%","--accent":"255 92% 96%","--accent-foreground":"222.2 84% 4.9%","--destructive":"0 84.2% 60.2%","--destructive-foreground":"210 40% 98%","--border":"255 92% 93%","--input":"255 92% 93%","--ring":"255 92% 61%","--brand":"255 92% 61%","--brand-50":"261 91% 96%","--brand-100":"261 91% 93%","--brand-200":"261 91% 84%","--brand-300":"262 83% 75%","--brand-400":"261 91% 65%","--brand-500":"255 92% 61%","--brand-600":"262 83% 50%","--brand-700":"262 83% 35%","--brand-800":"262 83% 25%","--brand-900":"262 83% 15%","--success":"142 76.2% 36.3%","--success-50":"138 62.8% 94.6%","--success-100":"134 60.3% 84%","--success-500":"142 76.2% 36.3%","--success-600":"142 71% 45%","--warning":"45.4 93.4% 47.5%","--warning-50":"53.8 91.8% 94.6%","--warning-100":"49.8 91.7% 84%","--warning-500":"45.4 93.4% 47.5%","--warning-600":"35.5 91.7% 52%","--danger":"0 84.2% 60.2%","--danger-50":"0 85.7% 97.3%","--danger-100":"0 74.7% 84%","--danger-500":"0 84.2% 60.2%","--danger-600":"0 72% 51%","--info":"221.2 83.2% 53.3%","--info-50":"214.3 31.8% 91.4%","--info-100":"214.3 31.8% 84%","--info-500":"221.2 83.2% 53.3%","--info-600":"217.2 91.2% 60%","--bg-primary":"0 0% 100%","--bg-secondary":"255 92% 96%","--bg-tertiary":"261 91% 93%","--bg-overlay":"0 0% 0% / 0.5","--text-primary":"222.2 84% 4.9%","--text-secondary":"215.4 16.3% 46.9%","--text-tertiary":"215 13.8% 34.1%","--text-inverse":"0 0% 100%","--radius":"12px"},dark:{"--background":"255 10% 3.9%","--card":"255 10% 3.9%","--card-foreground":"255 10% 98%","--popover":"255 10% 3.9%","--popover-foreground":"255 10% 98%","--primary":"255 92% 61%","--primary-foreground":"255 10% 3.9%","--secondary":"255 20% 10%","--secondary-foreground":"255 10% 98%","--muted":"255 20% 10%","--muted-foreground":"255 10% 65%","--accent":"255 20% 10%","--accent-foreground":"255 10% 98%","--destructive":"0 62.8% 30.6%","--destructive-foreground":"255 10% 98%","--border":"255 10% 15.9%","--input":"255 10% 15.9%","--ring":"255 92% 61%","--brand":"255 92% 61%","--brand-50":"255 5% 8%","--brand-100":"255 15% 10%","--brand-200":"255 20% 15%","--brand-300":"255 20% 20%","--brand-400":"255 25% 25%","--brand-500":"255 92% 61%","--brand-600":"262 83% 50%","--brand-700":"262 83% 35%","--brand-800":"262 83% 25%","--brand-900":"262 83% 15%","--success":"142 76.2% 36.3%","--success-50":"125 15% 8%","--success-100":"125 20% 12%","--success-500":"142 76.2% 36.3%","--success-600":"142 71% 45%","--warning":"45.4 93.4% 47.5%","--warning-50":"36 4% 8%","--warning-100":"36 93% 10%","--warning-500":"45.4 93.4% 47.5%","--warning-600":"35.5 91.7% 52%","--danger":"0 62.8% 30.6%","--danger-50":"0 5% 6%","--danger-100":"0 45% 10%","--danger-500":"0 62.8% 30.6%","--danger-600":"0 72% 51%","--info":"221.2 83.2% 53.3%","--info-50":"214.3 31% 8%","--info-100":"214.3 31% 12%","--info-500":"221.2 83.2% 53.3%","--info-600":"217.2 91.2% 60%","--bg-primary":"255 10% 3.9%","--bg-secondary":"255 20% 10%","--bg-tertiary":"255 10% 15.9%","--bg-overlay":"0 0% 0% / 0.7","--text-primary":"255 10% 98%","--text-secondary":"255 10% 65%","--text-tertiary":"255 10% 50%","--text-inverse":"255 10% 3.9%","--radius":"12px"}}},im={id:"ocean-deep",name:"Ocean Deep",description:"Deep blue waves with teal accents for a nautical feel",preview:{primary:"#0EA5E9",secondary:"#F0F9FF",accent:"#EC4899"},colors:{light:{"--background":"0 0% 100%","--card":"0 0% 100%","--card-foreground":"222.2 84% 4.9%","--popover":"0 0% 100%","--popover-foreground":"222.2 84% 4.9%","--primary":"199 89% 48%","--primary-foreground":"210 40% 98%","--secondary":"204 100% 97%","--secondary-foreground":"222.2 84% 4.9%","--muted":"204 100% 97%","--muted-foreground":"215.4 16.3% 46.9%","--accent":"204 100% 97%","--accent-foreground":"222.2 84% 4.9%","--destructive":"0 84.2% 60.2%","--destructive-foreground":"210 40% 98%","--border":"204 94% 94%","--input":"204 94% 94%","--ring":"199 89% 48%","--brand":"199 89% 48%","--brand-50":"204 100% 97%","--brand-100":"204 100% 97%","--brand-200":"204 94% 90%","--brand-300":"204 94% 82%","--brand-400":"202 82% 65%","--brand-500":"199 89% 48%","--brand-600":"199 89% 38%","--brand-700":"199 89% 28%","--brand-800":"199 89% 18%","--brand-900":"199 89% 12%","--success":"142 76.2% 36.3%","--success-50":"138 62.8% 94.6%","--success-100":"134 60.3% 84%","--success-500":"142 76.2% 36.3%","--success-600":"142 71% 45%","--warning":"45.4 93.4% 47.5%","--warning-50":"53.8 91.8% 94.6%","--warning-100":"49.8 91.7% 84%","--warning-500":"45.4 93.4% 47.5%","--warning-600":"35.5 91.7% 52%","--danger":"0 84.2% 60.2%","--danger-50":"0 85.7% 97.3%","--danger-100":"0 74.7% 84%","--danger-500":"0 84.2% 60.2%","--danger-600":"0 72% 51%","--info":"199 89% 48%","--info-50":"204 100% 97%","--info-100":"204 94% 94%","--info-500":"199 89% 48%","--info-600":"199 89% 38%","--bg-primary":"0 0% 100%","--bg-secondary":"204 100% 97%","--bg-tertiary":"204 94% 94%","--bg-overlay":"0 0% 0% / 0.5","--text-primary":"222.2 84% 4.9%","--text-secondary":"215.4 16.3% 46.9%","--text-tertiary":"215 13.8% 34.1%","--text-inverse":"0 0% 100%","--radius":"12px"},dark:{"--background":"222 84% 4.9%","--card":"222 84% 4.9%","--card-foreground":"210 40% 98%","--popover":"222 84% 4.9%","--popover-foreground":"210 40% 98%","--primary":"199 89% 48%","--primary-foreground":"222 84% 4.9%","--secondary":"217.2 32.6% 17.5%","--secondary-foreground":"210 40% 98%","--muted":"217.2 32.6% 17.5%","--muted-foreground":"215 20.2% 65.1%","--accent":"217.2 32.6% 17.5%","--accent-foreground":"210 40% 98%","--destructive":"0 62.8% 30.6%","--destructive-foreground":"210 40% 98%","--border":"217.2 32.6% 17.5%","--input":"217.2 32.6% 17.5%","--ring":"199 89% 48%","--brand":"199 89% 48%","--brand-50":"210 100% 8%","--brand-100":"210 50% 12%","--brand-200":"210 40% 16%","--brand-300":"210 30% 20%","--brand-400":"210 20% 24%","--brand-500":"199 89% 48%","--brand-600":"199 89% 38%","--brand-700":"199 89% 28%","--brand-800":"199 89% 18%","--brand-900":"199 89% 12%","--success":"142 76.2% 36.3%","--success-50":"125 100% 8%","--success-100":"125 80% 12%","--success-500":"142 76.2% 36.3%","--success-600":"142 71% 45%","--warning":"45.4 93.4% 47.5%","--warning-50":"36 80% 8%","--warning-100":"36 93% 10%","--warning-500":"45.4 93.4% 47.5%","--warning-600":"35.5 91.7% 52%","--danger":"0 62.8% 30.6%","--danger-50":"0 80% 6%","--danger-100":"0 45% 10%","--danger-500":"0 62.8% 30.6%","--danger-600":"0 72% 51%","--info":"199 89% 48%","--info-50":"210 100% 8%","--info-100":"210 90% 12%","--info-500":"199 89% 48%","--info-600":"199 89% 38%","--bg-primary":"222 84% 4.9%","--bg-secondary":"217.2 32.6% 17.5%","--bg-tertiary":"217.2 32.6% 17.5%","--bg-overlay":"0 0% 0% / 0.7","--text-primary":"210 40% 98%","--text-secondary":"215 20.2% 65.1%","--text-tertiary":"217.2 10.6% 64.9%","--text-inverse":"222 84% 4.9%","--radius":"12px"}}},om=[po,am,rm,nm,im];function Zn(s){return om.find(t=>t.id===s)}function Qn(){return po}const qa=At()(da((s,t)=>({selectedThemeId:"core-brand",currentTheme:Qn(),mode:"system",resolvedMode:"light",get theme(){return t().mode},setTheme:a=>{t().setMode(a)},setThemePalette:a=>{const r=Zn(a);r&&(s({selectedThemeId:a,currentTheme:r}),t().applyTheme())},setMode:a=>{const r=a==="system"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":a;s({mode:a,resolvedMode:r}),t().applyTheme()},applyTheme:()=>{const{currentTheme:a,resolvedMode:r}=t(),n=a.colors[r];if(!n)return;const i=document.documentElement;i.classList.remove("light","dark"),i.classList.add(r),Object.entries(n).forEach(([o,c])=>{i.style.setProperty(o,c)})},init:()=>{const{selectedThemeId:a}=t(),r=Zn(a)||Qn();s({selectedThemeId:r.id,currentTheme:r});const{mode:n}=t();t().setMode(n)},getResolvedColors:()=>{const{currentTheme:a,resolvedMode:r}=t();return a.colors[r]||{}}}),{name:"mockforge-theme-palette",partialize:s=>({selectedThemeId:s.selectedThemeId,mode:s.mode}),onRehydrateStorage:()=>s=>{s&&s.init()}}));if(typeof window<"u"){const{setMode:s}=qa.getState();window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",()=>{const{mode:t}=qa.getState();t==="system"&&s("system")})}function lm({className:s,size:t="md"}){const{theme:a,setTheme:r}=qa(),n=()=>{r(a==="dark"?"light":"dark")},i={sm:"h-8 w-8",md:"h-9 w-9",lg:"h-10 w-10"},o={sm:"h-4 w-4",md:"h-4 w-4",lg:"h-5 w-5"};return e.jsx(k,{variant:"outline",size:"sm",onClick:n,className:D("btn-hover transition-all duration-200",i[t],s),"aria-label":`Switch to ${a==="light"?"dark":"light"} mode`,children:a==="light"?e.jsx(mo,{className:o[t]}):e.jsx(ho,{className:o[t]})})}const $a=At()(s=>({isOpen:!1,open:()=>s({isOpen:!0}),close:()=>s({isOpen:!1}),setOpen:t=>s({isOpen:t})})),B=h.forwardRef(({className:s,type:t,error:a,errorId:r,"aria-invalid":n,"aria-describedby":i,...o},c)=>{const d=!!a||n===!0||n==="true",l=[i,r].filter(Boolean).join(" ")||void 0;return e.jsx("input",{type:t,className:D("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium 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",d&&"border-red-500 focus-visible:ring-red-500",s),ref:c,"aria-invalid":d||void 0,"aria-describedby":l,...o})});B.displayName="Input";function qe({open:s,onOpenChange:t,children:a}){return e.jsx(fo.Provider,{value:{open:s,onOpenChange:t},children:a})}const fo=M.createContext(null),cn=()=>{const s=M.useContext(fo);if(!s)throw new Error("Dialog components must be used within a Dialog");return s};function Ue({children:s,className:t}){const{open:a,onOpenChange:r}=cn(),n=h.useRef(null),i=h.useRef(null);if(h.useEffect(()=>{if(a)return i.current=document.activeElement,n.current&&n.current.focus(),document.body.style.overflow="hidden",()=>{document.body.style.overflow="",i.current&&i.current.focus()}},[a]),h.useEffect(()=>{if(!a)return;const c=d=>{if(d.key==="Escape"&&(d.preventDefault(),r(!1)),d.key==="Tab"){if(!n.current)return;const l=n.current.querySelectorAll('a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])'),m=l[0],g=l[l.length-1];d.shiftKey&&document.activeElement===m?(d.preventDefault(),g==null||g.focus()):!d.shiftKey&&document.activeElement===g&&(d.preventDefault(),m==null||m.focus())}};return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[a,r]),!a)return null;const o=e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[e.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm",onClick:()=>r(!1),"aria-hidden":"true"}),e.jsx("div",{ref:n,role:"dialog","aria-modal":"true",tabIndex:-1,className:D("relative bg-bg-primary border border-border rounded-lg shadow-xl max-w-md w-full mx-4 max-h-[90vh] overflow-y-auto focus:outline-none",t),children:e.jsx("div",{className:"p-6",children:s})})]});return Xo.createPortal(o,document.body)}function Be({children:s,className:t}){return e.jsx("div",{className:D("flex items-center justify-between pb-4 border-b border-border",t),children:s})}function Ve({children:s,className:t,id:a="dialog-title"}){return e.jsx("h2",{id:a,className:D("text-lg font-semibold text-gray-900 dark:text-gray-100",t),children:s})}function Ge({children:s,className:t,id:a="dialog-description"}){return e.jsx("p",{id:a,className:D("text-sm text-gray-600 dark:text-gray-400 mt-1",t),children:s})}function Ke({children:s,className:t}){return e.jsx("div",{className:D("flex items-center justify-end gap-3 pt-4 border-t border-border",t),children:s})}function Dr({children:s,onClick:t,asChild:a}){const{onOpenChange:r}=cn(),n=()=>{r(!0),t==null||t()};return a&&M.isValidElement(s)?M.cloneElement(s,{...s.props,onClick:n}):e.jsx("div",{onClick:n,children:s})}function ga({onClick:s,className:t}){const{onOpenChange:a}=cn(),r=()=>{a(!1),s==null||s()};return e.jsx(k,{variant:"ghost",size:"sm",className:D("h-8 w-8 p-0 hover:bg-bg-tertiary",t),onClick:r,children:e.jsx(ha,{className:"h-4 w-4"})})}function cm({open:s,onOpenChange:t}){const{user:a}=Ct(),[r,n]=h.useState(""),[i,o]=h.useState(""),[c,d]=h.useState(""),[l,m]=h.useState(!1),[g,y]=h.useState({}),[u,p]=h.useState(null),[f,j]=h.useState(!1),[C,T]=h.useState(!1),[N,w]=h.useState(null),[O,L]=h.useState(""),[I,b]=h.useState(null),[A,_]=h.useState(!1),[$,ae]=h.useState(""),[U,z]=h.useState(!1),[R,P]=h.useState(!0),[V,v]=h.useState(!0),[x,K]=h.useState(!1),[de,te]=h.useState(null),[ee,se]=h.useState(null),[Oe,Ye]=h.useState(!1),[ne,wt]=h.useState(!1),[nt,it]=h.useState(""),[mt,ht]=h.useState(""),[vs,ya]=h.useState(!1);h.useEffect(()=>{if(!s||!a)return;let ve=!1;return n(""),o(""),d(""),y({}),p(null),w(null),L(""),b(null),_(!1),ae(""),z(!1),te(null),se(null),wt(!1),it(""),ht(""),He.getMe().then(fe=>{ve||(j(fe.two_factor_enabled),P(fe.email_notifications),v(fe.security_alerts))}).catch(fe=>{ve||b({kind:"error",message:fe instanceof Error?fe.message:"Failed to load account"})}),()=>{ve=!0}},[s,a]);const cr=async ve=>{ve.preventDefault();const fe={};if(r||(fe.current="Current password is required"),i.length<8&&(fe.new="Password must be at least 8 characters"),i!==c&&(fe.confirm="Passwords do not match"),i&&i===r&&(fe.new="New password must differ from the current password"),y(fe),!(Object.keys(fe).length>0)){m(!0),p(null);try{const Re=await He.changePassword(r,i);p({kind:"success",message:Re.message}),n(""),o(""),d("")}catch(Re){p({kind:"error",message:Re instanceof Error?Re.message:"Failed to change password"})}finally{m(!1)}}},ba=async()=>{T(!0),b(null);try{const ve=await He.setup2FA();w(ve),z(!1)}catch(ve){b({kind:"error",message:ve instanceof Error?ve.message:"Failed to start 2FA setup"})}finally{T(!1)}},dr=()=>{w(null),L(""),b(null)},Hs=async ve=>{if(ve.preventDefault(),!!N){if(O.trim().length<6){b({kind:"error",message:"Enter the 6-digit code from your authenticator app"});return}T(!0),b(null);try{await He.verify2FASetup(N.secret,O.trim(),N.backup_codes),j(!0),w(null),L(""),b({kind:"success",message:"Two-factor authentication is now enabled."})}catch(fe){b({kind:"error",message:fe instanceof Error?fe.message:"Verification failed"})}finally{T(!1)}}},ur=async ve=>{if(ve.preventDefault(),!$){b({kind:"error",message:"Enter your password to disable 2FA"});return}T(!0),b(null);try{await He.disable2FA($),j(!1),_(!1),ae(""),b({kind:"success",message:"Two-factor authentication has been disabled."})}catch(fe){b({kind:"error",message:fe instanceof Error?fe.message:"Failed to disable 2FA"})}finally{T(!1)}},va=async()=>{if(N)try{await navigator.clipboard.writeText(N.backup_codes.join(` `)),z(!0),setTimeout(()=>z(!1),2e3)}catch{}},es=async()=>{Ye(!0),se(null);try{const ve=localStorage.getItem("auth_token"),fe=await fetch("/api/v1/gdpr/export",{headers:{Authorization:`Bearer ${ve}`}});if(!fe.ok){const ss=await fe.json().catch(()=>({}));throw new Error(ss.error||ss.message||`Export failed (${fe.status})`)}const Re=await fe.blob(),gt=URL.createObjectURL(Re),ts=document.createElement("a"),mr=new Date().toISOString().split("T")[0];ts.href=gt,ts.download=`mockforge-data-export-${mr}.json`,document.body.appendChild(ts),ts.click(),document.body.removeChild(ts),URL.revokeObjectURL(gt),se({kind:"success",message:"Your data has been downloaded."})}catch(ve){se({kind:"error",message:ve instanceof Error?ve.message:"Failed to export data"})}finally{Ye(!1)}},ja=async ve=>{if(ve.preventDefault(),nt!=="DELETE"){se({kind:"error",message:"Type DELETE to confirm account erasure."});return}ya(!0),se(null);try{const fe=localStorage.getItem("auth_token"),Re=await fetch("/api/v1/gdpr/erase",{method:"DELETE",headers:{Authorization:`Bearer ${fe}`,"Content-Type":"application/json"},body:JSON.stringify({confirm:!0,reason:mt.trim()||void 0})});if(!Re.ok){const gt=await Re.json().catch(()=>({}));throw new Error(gt.error||gt.message||`Erase failed (${Re.status})`)}Ct.getState().logout(),window.location.href="proxy.php?url=https%3A%2F%2Fapp.mockforge.dev%2F"}catch(fe){se({kind:"error",message:fe instanceof Error?fe.message:"Failed to erase account"}),ya(!1)}},Nt=async ve=>{K(!0),te(null);try{const fe=await He.updateNotifications(ve);P(fe.email_notifications),v(fe.security_alerts)}catch(fe){te({kind:"error",message:fe instanceof Error?fe.message:"Failed to save preferences"})}finally{K(!1)}};return a?e.jsx(qe,{open:s,onOpenChange:t,children:e.jsxs(Ue,{className:"sm:max-w-lg bg-white dark:bg-gray-900 max-h-[90vh] overflow-y-auto",children:[e.jsxs(Be,{className:"space-y-2",children:[e.jsx(Ve,{className:"text-xl font-semibold text-gray-900 dark:text-gray-100",children:"Account Settings"}),e.jsx(Ge,{className:"text-sm text-gray-600 dark:text-gray-400 leading-relaxed",children:"Manage your password, two-factor authentication, and notification preferences."}),e.jsx(ga,{onClick:()=>t(!1)})]}),e.jsxs("div",{className:"space-y-8",children:[e.jsxs("form",{onSubmit:cr,className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-gray-900 dark:text-gray-100",children:[e.jsx(Zt,{className:"h-4 w-4"}),e.jsx("span",{children:"Change password"})]}),u&&e.jsx(Ta,{banner:u}),e.jsx(ns,{id:"currentPassword",label:"Current password",type:"password",value:r,onChange:n,error:g.current}),e.jsx(ns,{id:"newPassword",label:"New password",type:"password",value:i,onChange:o,error:g.new,placeholder:"At least 8 characters"}),e.jsx(ns,{id:"confirmPassword",label:"Confirm new password",type:"password",value:c,onChange:d,error:g.confirm}),e.jsx("div",{className:"flex justify-end",children:e.jsx(k,{type:"submit",disabled:l,children:l?"Updating…":"Update password"})})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-gray-900 dark:text-gray-100",children:[e.jsx(Ls,{className:"h-4 w-4"}),e.jsx("span",{children:"Two-factor authentication"})]}),I&&e.jsx(Ta,{banner:I}),!N&&!A&&e.jsxs("div",{className:"flex items-center justify-between p-3 bg-gray-50 dark:bg-gray-800/50 rounded-md",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:f?"2FA is enabled":"2FA is disabled"}),e.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-400",children:f?"A TOTP code is required to sign in.":"Require a TOTP code at sign-in for added security."})]}),f?e.jsx(k,{type:"button",variant:"outline",onClick:()=>_(!0),disabled:C,children:"Disable"}):e.jsx(k,{type:"button",onClick:ba,disabled:C,children:C?"Starting…":"Enable"})]}),N&&e.jsxs("form",{onSubmit:Hs,className:"space-y-3 rounded-md border border-gray-200 dark:border-gray-700 p-4",children:[e.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300",children:"Scan this QR code with an authenticator app, then enter the 6-digit code to confirm."}),e.jsx("img",{src:N.qr_code_url,alt:"TOTP QR code",className:"mx-auto h-40 w-40 bg-white p-2 rounded"}),e.jsxs("div",{className:"text-xs text-gray-600 dark:text-gray-400",children:["Secret: ",e.jsx("code",{className:"font-mono",children:N.secret})]}),e.jsxs("div",{className:"rounded-md bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 p-3 text-sm",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("strong",{className:"text-yellow-900 dark:text-yellow-200",children:"Save these backup codes"}),e.jsx("button",{type:"button",onClick:va,className:"text-xs inline-flex items-center gap-1 text-yellow-900 dark:text-yellow-200 hover:underline",children:U?e.jsxs(e.Fragment,{children:[e.jsx(Me,{className:"h-3.5 w-3.5"})," Copied"]}):e.jsxs(e.Fragment,{children:[e.jsx(fs,{className:"h-3.5 w-3.5"})," Copy"]})})]}),e.jsx("p",{className:"text-xs mt-1 text-yellow-800 dark:text-yellow-300",children:"Each code works once if you lose access to your authenticator. They won't be shown again."}),e.jsx("pre",{className:"mt-2 text-xs font-mono grid grid-cols-2 gap-1 text-yellow-900 dark:text-yellow-100",children:N.backup_codes.map(ve=>e.jsx("span",{children:ve},ve))})]}),e.jsx(ns,{id:"totpCode",label:"6-digit code",value:O,onChange:L,placeholder:"000000",inputMode:"numeric",maxLength:6}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(k,{type:"button",variant:"outline",onClick:dr,disabled:C,children:"Cancel"}),e.jsx(k,{type:"submit",disabled:C,children:C?"Verifying…":"Verify & enable"})]})]}),A&&e.jsxs("form",{onSubmit:ur,className:"space-y-3 rounded-md border border-gray-200 dark:border-gray-700 p-4",children:[e.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300",children:"Enter your password to disable two-factor authentication."}),e.jsx(ns,{id:"disablePassword",label:"Password",type:"password",value:$,onChange:ae,autoFocus:!0}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(k,{type:"button",variant:"outline",onClick:()=>{_(!1),ae(""),b(null)},disabled:C,children:"Cancel"}),e.jsx(k,{type:"submit",variant:"destructive",disabled:C,children:C?"Disabling…":"Disable 2FA"})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-gray-900 dark:text-gray-100",children:[e.jsx(ro,{className:"h-4 w-4"}),e.jsx("span",{children:"Notifications"})]}),de&&e.jsx(Ta,{banner:de}),e.jsx(Yn,{icon:e.jsx(uo,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),label:"Email notifications",description:"Welcome messages, subscription updates, and API-token reminders.",checked:R,onChange:ve=>{P(ve),Nt({email_notifications:ve})},disabled:x}),e.jsx(Yn,{icon:e.jsx(Zt,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),label:"Security alerts",description:"Emails when your password or 2FA is changed.",checked:V,onChange:ve=>{v(ve),Nt({security_alerts:ve})},disabled:x})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-gray-900 dark:text-gray-100",children:[e.jsx(tn,{className:"h-4 w-4"}),e.jsx("span",{children:"Privacy & data"})]}),ee&&e.jsx(Ta,{banner:ee}),e.jsxs("div",{className:"flex items-start justify-between gap-4 p-3 bg-gray-50 dark:bg-gray-800/50 rounded-md",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:"Export your data"}),e.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-400",children:"Download a JSON file containing all your account data (GDPR right to data portability)."})]}),e.jsx(k,{type:"button",variant:"outline",onClick:es,disabled:Oe,children:Oe?"Preparing…":"Export"})]}),ne?e.jsxs("form",{onSubmit:ja,className:"space-y-3 rounded-md border border-red-200 dark:border-red-800 bg-red-50/50 dark:bg-red-900/10 p-4",children:[e.jsx("p",{className:"text-sm text-red-900 dark:text-red-200",children:"This action is irreversible. All your workspaces, mocks, tokens, and usage data will be erased."}),e.jsx(ns,{id:"deleteConfirm",label:"Type DELETE to confirm",value:nt,onChange:it,placeholder:"DELETE"}),e.jsx(ns,{id:"deleteReason",label:"Reason (optional)",value:mt,onChange:ht,placeholder:"Help us improve — why are you leaving?"}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(k,{type:"button",variant:"outline",onClick:()=>{wt(!1),it(""),ht(""),se(null)},disabled:vs,children:"Cancel"}),e.jsx(k,{type:"submit",variant:"destructive",disabled:vs,children:vs?"Erasing…":"Permanently delete account"})]})]}):e.jsxs("div",{className:"flex items-start justify-between gap-4 p-3 rounded-md border border-red-200 dark:border-red-800 bg-red-50/50 dark:bg-red-900/10",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-red-900 dark:text-red-200",children:"Delete your account"}),e.jsx("div",{className:"text-xs text-red-700 dark:text-red-300",children:"Permanently erase all your data. This cannot be undone."})]}),e.jsxs(k,{type:"button",variant:"destructive",onClick:()=>{wt(!0),se(null)},children:[e.jsx(Qe,{className:"h-4 w-4 mr-1"}),"Delete"]})]})]})]}),e.jsx(Ke,{children:e.jsx(k,{type:"button",variant:"outline",onClick:()=>t(!1),children:"Close"})})]})}):null}function Ta({banner:s}){const t=s.kind==="success"?"text-sm text-green-700 dark:text-green-300 bg-green-100 dark:bg-green-900/30 p-3 rounded-md":"text-sm text-destructive bg-destructive/10 p-3 rounded-md";return e.jsx("div",{className:t,children:s.message})}function ns({id:s,label:t,type:a="text",value:r,onChange:n,placeholder:i,error:o,autoFocus:c,inputMode:d,maxLength:l}){return e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{htmlFor:s,className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:t}),e.jsx(B,{id:s,type:a,value:r,onChange:m=>n(m.target.value),placeholder:i,autoFocus:c,inputMode:d,maxLength:l,className:`bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 ${o?"border-destructive":""}`}),o&&e.jsx("p",{className:"text-xs text-destructive",children:o})]})}function Yn({icon:s,label:t,description:a,checked:r,onChange:n,disabled:i}){return e.jsxs("div",{className:"flex items-start justify-between gap-4 p-3 bg-gray-50 dark:bg-gray-800/50 rounded-md",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[s,e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:t}),e.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-400",children:a})]})]}),e.jsxs("label",{className:"relative inline-flex items-center cursor-pointer shrink-0",children:[e.jsx("input",{type:"checkbox",checked:r,onChange:o=>n(o.target.checked),disabled:i,className:"sr-only peer"}),e.jsx("div",{className:"w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-brand-300 dark:peer-focus:ring-brand-800 rounded-full peer dark:bg-gray-700 peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:start-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-brand-600"})]})]})}function dm({open:s,onOpenChange:t}){const{user:a,updateProfile:r}=Ct(),[n,i]=h.useState({username:(a==null?void 0:a.username)||"",email:(a==null?void 0:a.email)||""}),[o,c]=h.useState(!1),[d,l]=h.useState({});M.useEffect(()=>{a&&s&&(i({username:a.username,email:a.email||""}),l({}))},[a,s]);const m=()=>{const u={};return n.username.trim()?n.username.length<3&&(u.username="Username must be at least 3 characters"):u.username="Username is required",n.email&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(n.email)&&(u.email="Please enter a valid email address"),l(u),Object.keys(u).length===0},g=async u=>{if(u.preventDefault(),!(!m()||!a)){c(!0);try{await r({...a,username:n.username.trim(),email:n.email.trim()||a.email}),t(!1)}catch(p){const f=p instanceof Error?p.message:"Failed to update profile. Please try again.";l({general:f})}finally{c(!1)}}},y=(u,p)=>{i(f=>({...f,[u]:p})),d[u]&&l(f=>({...f,[u]:""}))};return a?e.jsx(qe,{open:s,onOpenChange:t,children:e.jsxs(Ue,{className:"sm:max-w-md bg-white dark:bg-gray-900",children:[e.jsxs(Be,{className:"space-y-2",children:[e.jsx(Ve,{className:"text-xl font-semibold text-gray-900 dark:text-gray-100",children:"Profile Settings"}),e.jsx(Ge,{className:"text-sm text-gray-600 dark:text-gray-400 leading-relaxed",children:"Update your account information and preferences."}),e.jsx(ga,{onClick:()=>t(!1)})]}),e.jsxs("form",{onSubmit:g,className:"space-y-4",children:[d.general&&e.jsx("div",{className:"text-sm text-destructive bg-destructive/10 p-3 rounded-md",children:d.general}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"username",className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:"Username"}),e.jsx(B,{id:"username",type:"text",value:n.username,onChange:u=>y("username",u.target.value),placeholder:"Enter your username",className:`bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 placeholder:text-gray-500 dark:placeholder:text-gray-400 ${d.username?"border-destructive":""}`}),d.username&&e.jsx("p",{className:"text-sm text-destructive",children:d.username})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"email",className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:"Email (Optional)"}),e.jsx(B,{id:"email",type:"email",value:n.email,onChange:u=>y("email",u.target.value),placeholder:"Enter your email address",className:`bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 placeholder:text-gray-500 dark:placeholder:text-gray-400 ${d.email?"border-destructive":""}`}),d.email&&e.jsx("p",{className:"text-sm text-destructive",children:d.email})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:"Role"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:`text-xs px-2 py-1 rounded-full ${a.role==="admin"?"bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200":"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200"}`,children:[a.role==="admin"?"🔑":"👁️"," ",a.role]}),e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:"(Contact administrator to change role)"})]})]})]}),e.jsxs(Ke,{children:[e.jsx(k,{type:"button",variant:"outline",onClick:()=>t(!1),disabled:o,children:"Cancel"}),e.jsx(k,{type:"submit",onClick:g,disabled:o,children:o?"Saving...":"Save Changes"})]})]})}):null}const Je=h.forwardRef(({className:s,...t},a)=>e.jsx(Fi,{className:D("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent 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",s),...t,ref:a,children:e.jsx(gl,{className:D("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));Je.displayName=Fi.displayName;function ys({value:s,defaultValue:t,onValueChange:a,children:r,className:n}){const[i,o]=M.useState(t||s||""),c=s||i,d=l=>{o(l),a==null||a(l)};return e.jsx(un,{value:c,onValueChange:d,children:e.jsx("div",{className:D("w-full",n),children:r})})}function bs({children:s,className:t}){return e.jsx("div",{className:D("inline-flex h-10 items-center justify-center rounded-md bg-bg-tertiary p-1 text-secondary",t),children:s})}function Se({value:s,children:t,className:a}){const r=M.useContext(dn),n=s===(r==null?void 0:r.activeTab);return e.jsx("button",{className:D("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-bg-primary 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",n?"bg-bg-primary text-primary shadow-sm":"text-secondary hover:text-primary",a),onClick:()=>r==null?void 0:r.onTabChange(s),children:t})}function Ce({value:s,children:t,className:a}){var n;return s===((n=M.useContext(dn))==null?void 0:n.activeTab)?e.jsx("div",{className:D("mt-2 ring-offset-bg-primary focus-visible:outline-none",a),children:t}):null}const dn=M.createContext(null);function un({value:s,onValueChange:t,children:a}){return e.jsx(dn.Provider,{value:{activeTab:s,onTabChange:t},children:a})}const um={theme:"system",accentColor:"blue",fontSize:"medium",highContrast:!1},mm={autoScroll:!0,pauseOnError:!1,defaultTimeRange:24,itemsPerPage:100,showTimestamps:!0,compactView:!1},hm={enableSounds:!1,showToasts:!0,toastDuration:5,notifyOnErrors:!0,notifyOnSuccess:!1},gm={defaultScope:"all",searchHistory:[],maxHistoryItems:10,caseSensitive:!1,regexEnabled:!1},xm={sidebarCollapsed:!1,defaultPage:"dashboard",confirmDelete:!0,autoSave:!0,keyboardShortcuts:!0,serverTableDensity:"comfortable"},br={theme:um,logs:mm,notifications:hm,search:gm,ui:xm};let us=null;const pm=800;function is(s,t){return{...s,...t,theme:{...s.theme,...t.theme??{}},logs:{...s.logs,...t.logs??{}},notifications:{...s.notifications,...t.notifications??{}},search:{...s.search,...t.search??{}},ui:{...s.ui,...t.ui??{}}}}function os(s){us&&clearTimeout(us),us=setTimeout(()=>{us=null,s().savePreferences().catch(t=>Pe.warn("Preference auto-save failed",t))},pm)}const et=At()(da((s,t)=>({preferences:br,loading:!1,error:null,updatePreferences:a=>{s({preferences:is(t().preferences,a),error:null}),os(t)},updateTheme:a=>{s({preferences:is(t().preferences,{theme:a}),error:null}),os(t)},updateLogs:a=>{s({preferences:is(t().preferences,{logs:a}),error:null}),os(t)},updateNotifications:a=>{s({preferences:is(t().preferences,{notifications:a}),error:null}),os(t)},updateSearch:a=>{s({preferences:is(t().preferences,{search:a}),error:null}),os(t)},updateUI:a=>{s({preferences:is(t().preferences,{ui:a}),error:null}),os(t)},resetToDefaults:()=>{s({preferences:br,error:null}),os(t)},loadPreferences:async()=>{if(He.isCloud()){s({loading:!0,error:null});try{const a=await He.getPreferences(),r=a&&Object.keys(a).length>0;s(r?{preferences:is(br,a),loading:!1}:{loading:!1})}catch(a){s({loading:!1,error:a instanceof Error?a.message:"Failed to load preferences"}),Pe.warn("Loading preferences from server failed",a)}}},savePreferences:async()=>{if(He.isCloud()){us&&(clearTimeout(us),us=null),s({loading:!0,error:null});try{await He.updatePreferences(t().preferences),s({loading:!1})}catch(a){throw s({loading:!1,error:a instanceof Error?a.message:"Failed to save preferences"}),a}}}}),{name:"mockforge-preferences",partialize:s=>({preferences:s.preferences})})),Fa=At()(da((s,t)=>({theme:"system",resolvedTheme:"light",setTheme:a=>{const r=a==="system"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":a;s({theme:a,resolvedTheme:r});const n=document.documentElement;n.classList.remove("light","dark"),n.classList.add(r)},toggleTheme:()=>{const r=t().resolvedTheme==="light"?"dark":"light";t().setTheme(r)},init:()=>{const{theme:a}=t();t().setTheme(a)}}),{name:"mockforge-theme",onRehydrateStorage:()=>s=>{s&&s.init()}}));typeof window<"u"&&(Fa.getState().init(),window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",()=>{const{theme:t}=Fa.getState();t==="system"&&Fa.getState().setTheme("system")}));function fm({open:s,onOpenChange:t}){const[a,r]=h.useState("theme"),{preferences:n,updateTheme:i,updateLogs:o,updateNotifications:c,updateSearch:d,updateUI:l,resetToDefaults:m,savePreferences:g,loading:y,error:u}=et(),{setTheme:p}=Fa(),f=async()=>{try{await g(),t(!1)}catch(N){Pe.error("Failed to save preferences",N)}},j=()=>{m(),p("system")},C=[{value:"light",label:"Light",icon:ho},{value:"dark",label:"Dark",icon:mo},{value:"system",label:"System",icon:ru}],T=[{value:"blue",label:"Blue",swatch:"#3B82F6"},{value:"green",label:"Green",swatch:"#16A34A"},{value:"purple",label:"Purple",swatch:"#9333EA"},{value:"orange",label:"Orange",swatch:"#C2410C"},{value:"red",label:"Red",swatch:"#DC2626"}];return e.jsx(qe,{open:s,onOpenChange:t,children:e.jsxs(Ue,{className:"sm:max-w-4xl max-h-[90vh] overflow-y-auto bg-white dark:bg-gray-900",children:[e.jsxs(Be,{className:"space-y-2",children:[e.jsxs(Ve,{className:"flex items-center gap-2 text-xl font-semibold text-gray-900 dark:text-gray-100",children:[e.jsx(Tt,{className:"h-5 w-5"}),"Preferences"]}),e.jsx(Ge,{className:"text-sm text-gray-600 dark:text-gray-400 leading-relaxed",children:"Customize your experience with MockForge"}),e.jsx(ga,{onClick:()=>t(!1)})]}),e.jsx(un,{value:a,onValueChange:r,children:e.jsxs(ys,{value:a,onValueChange:r,className:"w-full",children:[e.jsxs(bs,{className:"grid w-full grid-cols-5 bg-gray-100 dark:bg-gray-800",children:[e.jsxs(Se,{value:"theme",className:"flex items-center gap-2 text-gray-700 dark:text-gray-300 data-[state=active]:text-gray-900 dark:data-[state=active]:text-gray-100 data-[state=active]:bg-white dark:data-[state=active]:bg-gray-700",children:[e.jsx(du,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Theme"})]}),e.jsxs(Se,{value:"logs",className:"flex items-center gap-2 text-gray-700 dark:text-gray-300 data-[state=active]:text-gray-900 dark:data-[state=active]:text-gray-100 data-[state=active]:bg-white dark:data-[state=active]:bg-gray-700",children:[e.jsx(Rs,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Logs"})]}),e.jsxs(Se,{value:"notifications",className:"flex items-center gap-2 text-gray-700 dark:text-gray-300 data-[state=active]:text-gray-900 dark:data-[state=active]:text-gray-100 data-[state=active]:bg-white dark:data-[state=active]:bg-gray-700",children:[e.jsx(ro,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Notifications"})]}),e.jsxs(Se,{value:"search",className:"flex items-center gap-2 text-gray-700 dark:text-gray-300 data-[state=active]:text-gray-900 dark:data-[state=active]:text-gray-100 data-[state=active]:bg-white dark:data-[state=active]:bg-gray-700",children:[e.jsx(sr,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Search"})]}),e.jsxs(Se,{value:"ui",className:"flex items-center gap-2 text-gray-700 dark:text-gray-300 data-[state=active]:text-gray-900 dark:data-[state=active]:text-gray-100 data-[state=active]:bg-white dark:data-[state=active]:bg-gray-700",children:[e.jsx(Tt,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"UI"})]})]}),e.jsx(Ce,{value:"theme",className:"space-y-6",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-900 dark:text-gray-100 mb-3 block",children:"Theme Mode"}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:C.map(({value:N,label:w,icon:O})=>e.jsxs("button",{onClick:()=>{i({theme:N}),p(N)},className:`flex items-center gap-2 p-3 rounded-lg border transition-all ${n.theme.theme===N?"border-orange-500 bg-orange-50 dark:bg-orange-900/20 text-orange-700 dark:text-orange-300":"border-gray-300 dark:border-gray-600 hover:border-orange-300 dark:hover:border-orange-600 text-gray-700 dark:text-gray-300"}`,children:[e.jsx(O,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:w})]},N))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-900 dark:text-gray-100 mb-3 block",children:"Accent Color"}),e.jsx("div",{className:"flex gap-2",children:T.map(({value:N,label:w,swatch:O})=>e.jsx("button",{onClick:()=>i({accentColor:N}),className:`w-8 h-8 rounded-full border-2 transition-all ${n.theme.accentColor===N?"border-gray-900 dark:border-gray-100 scale-110 shadow-lg":"border-gray-300 dark:border-gray-600 hover:scale-105"}`,style:{backgroundColor:O},title:w,"aria-label":w},N))})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:"High Contrast"}),e.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400",children:"Increase contrast for better accessibility"})]}),e.jsx(Je,{checked:n.theme.highContrast,onCheckedChange:N=>i({highContrast:N})})]})]})}),e.jsx(Ce,{value:"logs",className:"space-y-6",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:"Auto-scroll"}),e.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400",children:"Automatically scroll to new log entries"})]}),e.jsx(Je,{checked:n.logs.autoScroll,onCheckedChange:N=>o({autoScroll:N})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:"Pause on Error"}),e.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400",children:"Pause log streaming when errors occur"})]}),e.jsx(Je,{checked:n.logs.pauseOnError,onCheckedChange:N=>o({pauseOnError:N})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:"Show Timestamps"}),e.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400",children:"Display timestamps in log entries"})]}),e.jsx(Je,{checked:n.logs.showTimestamps,onCheckedChange:N=>o({showTimestamps:N})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:"Compact View"}),e.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400",children:"Use compact layout for log entries"})]}),e.jsx(Je,{checked:n.logs.compactView,onCheckedChange:N=>o({compactView:N})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-900 dark:text-gray-100 mb-2 block",children:"Default Time Range (hours)"}),e.jsx(B,{type:"number",min:"1",max:"168",value:n.logs.defaultTimeRange,onChange:N=>o({defaultTimeRange:parseInt(N.target.value)||24}),className:"w-24 bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 placeholder:text-gray-500 dark:placeholder:text-gray-400"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-900 dark:text-gray-100 mb-2 block",children:"Items Per Page"}),e.jsx(B,{type:"number",min:"10",max:"1000",step:"10",value:n.logs.itemsPerPage,onChange:N=>o({itemsPerPage:parseInt(N.target.value)||100}),className:"w-24 bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 placeholder:text-gray-500 dark:placeholder:text-gray-400"})]})]})}),e.jsx(Ce,{value:"notifications",className:"space-y-6",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:"Enable Sounds"}),e.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400",children:"Play notification sounds"})]}),e.jsx(Je,{checked:n.notifications.enableSounds,onCheckedChange:N=>c({enableSounds:N})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:"Show Toasts"}),e.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400",children:"Display toast notifications"})]}),e.jsx(Je,{checked:n.notifications.showToasts,onCheckedChange:N=>c({showToasts:N})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:"Notify on Errors"}),e.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400",children:"Show notifications for error events"})]}),e.jsx(Je,{checked:n.notifications.notifyOnErrors,onCheckedChange:N=>c({notifyOnErrors:N})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:"Notify on Success"}),e.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400",children:"Show notifications for successful operations"})]}),e.jsx(Je,{checked:n.notifications.notifyOnSuccess,onCheckedChange:N=>c({notifyOnSuccess:N})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-900 dark:text-gray-100 mb-2 block",children:"Toast Duration (seconds)"}),e.jsx(B,{type:"number",min:"1",max:"30",value:n.notifications.toastDuration,onChange:N=>c({toastDuration:parseInt(N.target.value)||5}),className:"w-24 bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 placeholder:text-gray-500 dark:placeholder:text-gray-400"})]})]})}),e.jsx(Ce,{value:"search",className:"space-y-6",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-900 dark:text-gray-100 mb-3 block",children:"Default Search Scope"}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:[{value:"all",label:"All"},{value:"current",label:"Current Page"},{value:"logs",label:"Logs Only"},{value:"services",label:"Services Only"}].map(({value:N,label:w})=>e.jsx("button",{onClick:()=>d({defaultScope:N}),className:`p-2 text-sm rounded border transition-all ${n.search.defaultScope===N?"border-brand bg-brand/10 text-brand":"border-border hover:border-brand/50"}`,children:w},N))})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:"Case Sensitive"}),e.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400",children:"Match case in search queries"})]}),e.jsx(Je,{checked:n.search.caseSensitive,onCheckedChange:N=>d({caseSensitive:N})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:"Regex Enabled"}),e.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400",children:"Allow regular expressions in search"})]}),e.jsx(Je,{checked:n.search.regexEnabled,onCheckedChange:N=>d({regexEnabled:N})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-900 dark:text-gray-100 mb-2 block",children:"Max History Items"}),e.jsx(B,{type:"number",min:"5",max:"50",value:n.search.maxHistoryItems,onChange:N=>d({maxHistoryItems:parseInt(N.target.value)||10}),className:"w-24 bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 placeholder:text-gray-500 dark:placeholder:text-gray-400"})]})]})}),e.jsx(Ce,{value:"ui",className:"space-y-6",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:"Sidebar Collapsed"}),e.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400",children:"Start with collapsed sidebar"})]}),e.jsx(Je,{checked:n.ui.sidebarCollapsed,onCheckedChange:N=>l({sidebarCollapsed:N})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:"Confirm Delete"}),e.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400",children:"Show confirmation dialogs for delete actions"})]}),e.jsx(Je,{checked:n.ui.confirmDelete,onCheckedChange:N=>l({confirmDelete:N})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:"Auto-save"}),e.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400",children:"Automatically save changes"})]}),e.jsx(Je,{checked:n.ui.autoSave,onCheckedChange:N=>l({autoSave:N})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:"Keyboard Shortcuts"}),e.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400",children:"Enable keyboard shortcuts"})]}),e.jsx(Je,{checked:n.ui.keyboardShortcuts,onCheckedChange:N=>l({keyboardShortcuts:N})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-900 dark:text-gray-100 mb-2 block",children:"Default Page"}),e.jsxs("select",{value:n.ui.defaultPage,onChange:N=>l({defaultPage:N.target.value}),className:"w-full p-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100",children:[e.jsx("option",{value:"dashboard",children:"Dashboard"}),e.jsx("option",{value:"services",children:"Services"}),e.jsx("option",{value:"logs",children:"Logs"}),e.jsx("option",{value:"fixtures",children:"Fixtures"}),e.jsx("option",{value:"metrics",children:"Metrics"}),e.jsx("option",{value:"testing",children:"Testing"}),e.jsx("option",{value:"config",children:"Config"})]})]})]})})]})}),u&&e.jsx("div",{className:"text-sm text-destructive bg-destructive/10 p-3 rounded-md mt-4",children:u}),e.jsxs(Ke,{className:"flex items-center justify-between",children:[e.jsxs(k,{type:"button",variant:"outline",onClick:j,className:"flex items-center gap-2",children:[e.jsx(nn,{className:"h-4 w-4"}),"Reset to Defaults"]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(k,{type:"button",variant:"outline",onClick:()=>t(!1),disabled:y,children:"Cancel"}),e.jsx(k,{type:"button",onClick:f,disabled:y,children:y?"Saving...":"Save Preferences"})]})]})]})})}function ym(){const{user:s,logout:t}=Ct(),a=$a(p=>p.open),[r,n]=h.useState(!1),[i,o]=h.useState(!1),[c,d]=h.useState(!1),[l,m]=h.useState(!1);if(h.useEffect(()=>{if(!r)return;const p=f=>{f.key==="Escape"&&n(!1)};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[r]),!s)return null;const g=p=>{switch(p){case"admin":return"bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-300";case"viewer":return"bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-300";default:return"bg-gray-100 text-gray-800 dark:bg-gray-800 dark:text-gray-300"}},y=p=>{switch(p){case"admin":return"🔑";case"viewer":return"👁️";default:return"👤"}},u=async()=>{n(!1),await t()};return e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>n(!r),className:"flex items-center space-x-2 px-3 py-2 rounded-md hover:bg-accent transition-colors",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("div",{className:"w-8 h-8 bg-primary rounded-full flex items-center justify-center text-gray-900 dark:text-gray-100-foreground text-sm font-medium",children:(s.username||s.email||"U").charAt(0).toUpperCase()}),e.jsxs("div",{className:"text-left",children:[e.jsx("div",{className:"text-sm font-medium",children:s.username}),e.jsxs("div",{className:`text-xs px-2 py-0.5 rounded-full inline-flex items-center space-x-1 ${g(s.role)}`,children:[e.jsx("span",{children:y(s.role)}),e.jsx("span",{children:s.role})]})]})]}),e.jsx("div",{className:"text-muted-foreground",children:r?"▲":"▼"})]}),r&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>n(!1)}),e.jsxs("div",{className:"absolute right-0 mt-2 w-64 bg-card border rounded-md shadow-lg z-20",children:[e.jsx("div",{className:"p-4 border-b",children:e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx("div",{className:"w-10 h-10 bg-primary rounded-full flex items-center justify-center text-gray-900 dark:text-gray-100-foreground font-medium",children:(s.username||s.email||"U").charAt(0).toUpperCase()}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:s.username}),s.email&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s.email}),e.jsxs("div",{className:`text-xs px-2 py-0.5 rounded-full inline-flex items-center space-x-1 mt-1 ${g(s.role)}`,children:[e.jsx("span",{children:y(s.role)}),e.jsx("span",{className:"capitalize",children:s.role})]})]})]})}),e.jsxs("div",{className:"p-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"Account"}),e.jsx("button",{className:"w-full text-left px-3 py-2 text-sm hover:bg-accent rounded-md transition-colors",onClick:()=>{n(!1),o(!0)},children:"Account Settings"}),e.jsx("button",{className:"w-full text-left px-3 py-2 text-sm hover:bg-accent rounded-md transition-colors",onClick:()=>{n(!1),d(!0)},children:"Profile Settings"}),e.jsx("button",{className:"w-full text-left px-3 py-2 text-sm hover:bg-accent rounded-md transition-colors",onClick:()=>{n(!1),m(!0)},children:"Preferences"})]}),e.jsx("div",{className:"border-t my-2"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"System"}),e.jsx("a",{href:"https://docs.mockforge.dev/api/admin-ui-rest.html",target:"_blank",rel:"noopener noreferrer",className:"w-full text-left px-3 py-2 text-sm hover:bg-accent rounded-md transition-colors block",onClick:()=>n(!1),children:"API Documentation"}),e.jsx("button",{className:"w-full text-left px-3 py-2 text-sm hover:bg-accent rounded-md transition-colors",onClick:()=>{n(!1),a()},children:"Help & Support"})]}),e.jsx("div",{className:"border-t my-2"}),e.jsx(k,{variant:"ghost",className:"w-full justify-start text-destructive hover:text-destructive hover:bg-destructive/10",onClick:u,children:"Sign Out"})]})]})]}),e.jsx(cm,{open:i,onOpenChange:o}),e.jsx(dm,{open:c,onOpenChange:d}),e.jsx(fm,{open:l,onOpenChange:m})]})}function bm({open:s,onOpenChange:t}){const[a,r]=h.useState("quickstart"),o=[{keys:`${navigator.userAgent.toUpperCase().indexOf("MAC")>=0?"⌘":"Ctrl"} + K`,description:"Focus global search"},{keys:"Esc",description:"Clear search / Close dialogs"},{keys:"Shift + ?",description:"Open Help & Support"}],c=[{question:"How do I create a new workspace?",answer:'Navigate to the Workspaces page and click the "New Workspace" button. Fill in the required details and click "Create".'},{question:"How do I import fixtures from OpenAPI/Swagger?",answer:'Go to the Import page, select "OpenAPI/Swagger" as the source, upload your spec file or provide a URL, and click "Import".'},{question:"What are chains and how do I use them?",answer:"Chains allow you to link multiple mock responses together in sequence. Create a chain in the Chains page and define the order of responses."},{question:"How do I view real-time logs?",answer:"Visit the Logs page where you can see live request/response logs. Use filters to narrow down specific requests or services."},{question:"Can I export my workspace configuration?",answer:"Yes! Go to the Workspaces page, select your workspace, and use the export option to download your configuration."}];return e.jsx(qe,{open:s,onOpenChange:t,children:e.jsxs(Ue,{className:"sm:max-w-3xl max-h-[90vh] overflow-y-auto bg-white dark:bg-gray-900",children:[e.jsxs(Be,{className:"space-y-2",children:[e.jsxs(Ve,{className:"flex items-center gap-2 text-xl font-semibold text-gray-900 dark:text-gray-100",children:[e.jsx(Jn,{className:"h-5 w-5"}),"Help & Support"]}),e.jsx(Ge,{className:"text-sm text-gray-600 dark:text-gray-400 leading-relaxed",children:"Learn how to use MockForge effectively"}),e.jsx(ga,{onClick:()=>t(!1)})]}),e.jsx(un,{value:a,onValueChange:r,children:e.jsxs(ys,{value:a,onValueChange:r,className:"w-full",children:[e.jsxs(bs,{className:"grid w-full grid-cols-3 bg-gray-100 dark:bg-gray-800",children:[e.jsxs(Se,{value:"quickstart",className:"flex items-center gap-2 text-gray-700 dark:text-gray-300 data-[state=active]:text-gray-900 dark:data-[state=active]:text-gray-100 data-[state=active]:bg-white dark:data-[state=active]:bg-gray-700",children:[e.jsx(ku,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Quick Start"})]}),e.jsxs(Se,{value:"shortcuts",className:"flex items-center gap-2 text-gray-700 dark:text-gray-300 data-[state=active]:text-gray-900 dark:data-[state=active]:text-gray-100 data-[state=active]:bg-white dark:data-[state=active]:bg-gray-700",children:[e.jsx(Dd,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Shortcuts"})]}),e.jsxs(Se,{value:"faq",className:"flex items-center gap-2 text-gray-700 dark:text-gray-300 data-[state=active]:text-gray-900 dark:data-[state=active]:text-gray-100 data-[state=active]:bg-white dark:data-[state=active]:bg-gray-700",children:[e.jsx(Mr,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"FAQ"})]})]}),e.jsx(Ce,{value:"quickstart",className:"space-y-4 mt-4",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 mb-3",children:"Welcome to MockForge!"}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-4",children:"MockForge is a powerful API mocking and testing platform. Here's how to get started:"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"flex-shrink-0 w-8 h-8 bg-orange-100 dark:bg-orange-900 text-orange-600 dark:text-orange-300 rounded-full flex items-center justify-center font-semibold",children:"1"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-gray-100 mb-1",children:"Create a Workspace"}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:'Start by creating a workspace to organize your mocks. Navigate to Workspaces and click "New Workspace".'})]})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"flex-shrink-0 w-8 h-8 bg-orange-100 dark:bg-orange-900 text-orange-600 dark:text-orange-300 rounded-full flex items-center justify-center font-semibold",children:"2"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-gray-100 mb-1",children:"Import or Create Fixtures"}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Import fixtures from OpenAPI/Swagger specs or create them manually in the Fixtures page."})]})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"flex-shrink-0 w-8 h-8 bg-orange-100 dark:bg-orange-900 text-orange-600 dark:text-orange-300 rounded-full flex items-center justify-center font-semibold",children:"3"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-gray-100 mb-1",children:"Configure Services"}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Set up your mock services with specific routes, responses, and behaviors in the Services page."})]})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"flex-shrink-0 w-8 h-8 bg-orange-100 dark:bg-orange-900 text-orange-600 dark:text-orange-300 rounded-full flex items-center justify-center font-semibold",children:"4"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-gray-100 mb-1",children:"Monitor & Test"}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Use the Logs and Metrics pages to monitor requests and the Testing page to validate your mocks."})]})]})]})]})}),e.jsx(Ce,{value:"shortcuts",className:"space-y-4 mt-4",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 mb-3",children:"Keyboard Shortcuts"}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-4",children:"Use these shortcuts to navigate faster:"})]}),e.jsx("div",{className:"space-y-2",children:o.map((d,l)=>e.jsxs("div",{className:"flex items-center justify-between p-3 bg-gray-50 dark:bg-gray-800 rounded-lg",children:[e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:d.description}),e.jsx("kbd",{className:"px-3 py-1 text-sm font-mono bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded shadow-sm text-gray-900 dark:text-gray-100",children:d.keys})]},l))}),e.jsx("div",{className:"mt-6 p-4 bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg",children:e.jsx("p",{className:"text-sm text-blue-800 dark:text-blue-200",children:"💡 Tip: You can enable/disable keyboard shortcuts in Preferences"})})]})}),e.jsx(Ce,{value:"faq",className:"space-y-4 mt-4",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{children:e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 mb-3",children:"Frequently Asked Questions"})}),e.jsx("div",{className:"space-y-4",children:c.map((d,l)=>e.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-800 rounded-lg",children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-gray-100 mb-2",children:d.question}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:d.answer})]},l))})]})})]})}),e.jsxs(Ke,{className:"flex items-center justify-between border-t border-gray-200 dark:border-gray-700 pt-4 mt-4 flex-wrap gap-y-2",children:[e.jsxs("div",{className:"flex items-center gap-4 text-sm flex-wrap",children:[e.jsxs(ka,{to:"/faq",onClick:()=>t(!1),className:"flex items-center gap-1 text-gray-600 dark:text-gray-400 hover:text-orange-600 dark:hover:text-orange-400 transition-colors",children:[e.jsx(Mr,{className:"h-4 w-4"}),"Full FAQ"]}),e.jsxs(ka,{to:"/support",onClick:()=>t(!1),className:"flex items-center gap-1 text-gray-600 dark:text-gray-400 hover:text-orange-600 dark:hover:text-orange-400 transition-colors",children:[e.jsx(Jn,{className:"h-4 w-4"}),"Contact support"]}),e.jsx(ka,{to:"/terms",onClick:()=>t(!1),className:"flex items-center gap-1 text-gray-600 dark:text-gray-400 hover:text-orange-600 dark:hover:text-orange-400 transition-colors",children:"Terms"}),e.jsx(ka,{to:"/privacy",onClick:()=>t(!1),className:"flex items-center gap-1 text-gray-600 dark:text-gray-400 hover:text-orange-600 dark:hover:text-orange-400 transition-colors",children:"Privacy"}),e.jsxs("a",{href:"https://github.com/SaaSy-Solutions/mockforge",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-gray-600 dark:text-gray-400 hover:text-orange-600 dark:hover:text-orange-400 transition-colors",children:[e.jsx(Os,{className:"h-4 w-4"}),"GitHub"]}),e.jsxs("a",{href:"https://docs.mockforge.dev/api/admin-ui-rest.html",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-gray-600 dark:text-gray-400 hover:text-orange-600 dark:hover:text-orange-400 transition-colors",children:[e.jsx(Sc,{className:"h-4 w-4"}),"API Docs"]})]}),e.jsx(k,{type:"button",onClick:()=>t(!1),children:"Close"})]})]})})}const Xn={sm:"h-6 w-auto",md:"h-8 w-auto",lg:"h-10 w-auto",xl:"h-12 w-auto"};function zr({variant:s="full",size:t="md",className:a="",loading:r="eager"}){const[n,i]=h.useState(!1),c=(()=>{if(s==="icon")switch(t){case"sm":return"/mockforge-icon-32.png";case"md":return"/mockforge-icon-32.png";case"lg":return"/mockforge-icon-48.png";case"xl":return"/mockforge-icon-48.png";default:return"/mockforge-icon-48.png"}else switch(t){case"sm":return"/mockforge-logo-40.png";case"md":return"/mockforge-logo-40.png";case"lg":return"/mockforge-logo-40.png";case"xl":return"/mockforge-logo-80.png";default:return"/mockforge-logo-80.png"}})(),d=s==="icon"?"MockForge":"MockForge Logo",l=()=>{Pe.warn(`Failed to load logo image: ${c}. Using fallback.`),i(!0)};return n?e.jsx("div",{className:`flex items-center ${a}`,children:e.jsx("div",{className:`bg-gradient-to-br from-orange-500 via-orange-600 to-red-600 rounded-lg px-3 py-1 ${Xn[t]} flex items-center justify-center text-white font-bold text-sm shadow-md`,title:"MockForge (fallback logo)",children:s==="icon"?"M":"MockForge"})}):e.jsx("img",{src:c,alt:d,className:`${Xn[t]} ${a}`,loading:r,onError:l})}const yo=s=>{const t=["GET","POST","PUT","DELETE","PATCH"],a=["/api/users","/api/users/123","/api/orders","/api/orders/456","/api/products","/api/auth/login","/api/auth/logout","/api/webhooks/stripe","/health","/metrics"],r=[200,201,204,400,401,403,404,422,500,502],n=["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36","curl/7.68.0","PostmanRuntime/7.28.4","MockForge/1.0.0"],i=["192.168.1.100","10.0.0.50","172.16.0.25","203.0.113.1"],o=t[Math.floor(Math.random()*t.length)],c=a[Math.floor(Math.random()*a.length)],d=r[Math.floor(Math.random()*r.length)],l=Math.floor(Math.random()*2e3)+10,m=Math.floor(Math.random()*1e4)+100,g=d>=400&&Math.random()<.3;return{id:`req-${s}-${Date.now()}`,timestamp:new Date().toISOString(),method:o,path:c,status_code:d,response_time_ms:l,client_ip:i[Math.floor(Math.random()*i.length)],user_agent:n[Math.floor(Math.random()*n.length)],headers:{"Content-Type":"application/json",Accept:"application/json",Authorization:"Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...","X-Request-ID":`req-${s}`,"User-Agent":n[Math.floor(Math.random()*n.length)]},request_size_bytes:Math.floor(Math.random()*1e3)+50,response_size_bytes:m,error_message:g?`${d===404?"Resource not found":d===500?"Internal server error":"Bad request"}`:void 0}},ei=Array.from({length:50},(s,t)=>yo(t+1)),ti={hours_ago:24,limit:100},Ss=(s,t)=>{let a=s;if(t.method&&(a=a.filter(r=>r.method===t.method)),t.status_code&&(a=a.filter(r=>r.status_code===t.status_code)),t.path_pattern){const r=t.path_pattern.toLowerCase();a=a.filter(n=>n.path.toLowerCase().includes(r)||n.method.toLowerCase().includes(r)||n.error_message&&n.error_message.toLowerCase().includes(r))}if(t.hours_ago){const r=new Date;r.setHours(r.getHours()-t.hours_ago),a=a.filter(n=>new Date(n.timestamp)>=r)}return t.limit&&(a=a.slice(-t.limit)),a.sort((r,n)=>new Date(n.timestamp).getTime()-new Date(r.timestamp).getTime())};let Cs=null,vm=51;const jm=At((s,t)=>({logs:ei,filteredLogs:Ss(ei,ti),selectedLog:null,filter:ti,autoScroll:!0,isPaused:!1,connectionStatus:"connected",setLogs:a=>{const r=Ss(a,t().filter);s({logs:a,filteredLogs:r})},addLog:a=>{const r=t();if(r.isPaused)return;const n=[...r.logs,a],i=Ss(n,r.filter);s({logs:n,filteredLogs:i})},selectLog:a=>s({selectedLog:a}),setFilter:a=>{const r=t(),n={...r.filter,...a},i=Ss(r.logs,n);s({filter:n,filteredLogs:i})},clearFilter:()=>{const a=t(),r={hours_ago:24,limit:100},n=Ss(a.logs,r);s({filter:r,filteredLogs:n})},setAutoScroll:a=>s({autoScroll:a}),setPaused:a=>s({isPaused:a}),setConnectionStatus:a=>s({connectionStatus:a}),applyFilter:()=>{const a=t(),r=Ss(a.logs,a.filter);s({filteredLogs:r})},clearLogs:()=>s({logs:[],filteredLogs:[],selectedLog:null}),startLogStream:()=>{Cs&&clearInterval(Cs),Cs=setInterval(()=>{const a=t();!a.isPaused&&a.connectionStatus==="connected"&&a.addLog(yo(vm++))},2e3+Math.random()*3e3)},stopLogStream:()=>{Cs&&(clearInterval(Cs),Cs=null)}}));var we;(function(s){s.assertEqual=n=>{};function t(n){}s.assertIs=t;function a(n){throw new Error}s.assertNever=a,s.arrayToEnum=n=>{const i={};for(const o of n)i[o]=o;return i},s.getValidEnumValues=n=>{const i=s.objectKeys(n).filter(c=>typeof n[n[c]]!="number"),o={};for(const c of i)o[c]=n[c];return s.objectValues(o)},s.objectValues=n=>s.objectKeys(n).map(function(i){return n[i]}),s.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{const i=[];for(const o in n)Object.prototype.hasOwnProperty.call(n,o)&&i.push(o);return i},s.find=(n,i)=>{for(const o of n)if(i(o))return o},s.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&Number.isFinite(n)&&Math.floor(n)===n;function r(n,i=" | "){return n.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}s.joinValues=r,s.jsonStringifyReplacer=(n,i)=>typeof i=="bigint"?i.toString():i})(we||(we={}));var si;(function(s){s.mergeShapes=(t,a)=>({...t,...a})})(si||(si={}));const W=we.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Ht=s=>{switch(typeof s){case"undefined":return W.undefined;case"string":return W.string;case"number":return Number.isNaN(s)?W.nan:W.number;case"boolean":return W.boolean;case"function":return W.function;case"bigint":return W.bigint;case"symbol":return W.symbol;case"object":return Array.isArray(s)?W.array:s===null?W.null:s.then&&typeof s.then=="function"&&s.catch&&typeof s.catch=="function"?W.promise:typeof Map<"u"&&s instanceof Map?W.map:typeof Set<"u"&&s instanceof Set?W.set:typeof Date<"u"&&s instanceof Date?W.date:W.object;default:return W.unknown}},F=we.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class Ft extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const a=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,a):this.__proto__=a,this.name="ZodError",this.issues=t}format(t){const a=t||function(i){return i.message},r={_errors:[]},n=i=>{for(const o of i.issues)if(o.code==="invalid_union")o.unionErrors.map(n);else if(o.code==="invalid_return_type")n(o.returnTypeError);else if(o.code==="invalid_arguments")n(o.argumentsError);else if(o.path.length===0)r._errors.push(a(o));else{let c=r,d=0;for(;da.message){const a={},r=[];for(const n of this.issues)if(n.path.length>0){const i=n.path[0];a[i]=a[i]||[],a[i].push(t(n))}else r.push(t(n));return{formErrors:r,fieldErrors:a}}get formErrors(){return this.flatten()}}Ft.create=s=>new Ft(s);const qr=(s,t)=>{let a;switch(s.code){case F.invalid_type:s.received===W.undefined?a="Required":a=`Expected ${s.expected}, received ${s.received}`;break;case F.invalid_literal:a=`Invalid literal value, expected ${JSON.stringify(s.expected,we.jsonStringifyReplacer)}`;break;case F.unrecognized_keys:a=`Unrecognized key(s) in object: ${we.joinValues(s.keys,", ")}`;break;case F.invalid_union:a="Invalid input";break;case F.invalid_union_discriminator:a=`Invalid discriminator value. Expected ${we.joinValues(s.options)}`;break;case F.invalid_enum_value:a=`Invalid enum value. Expected ${we.joinValues(s.options)}, received '${s.received}'`;break;case F.invalid_arguments:a="Invalid function arguments";break;case F.invalid_return_type:a="Invalid function return type";break;case F.invalid_date:a="Invalid date";break;case F.invalid_string:typeof s.validation=="object"?"includes"in s.validation?(a=`Invalid input: must include "${s.validation.includes}"`,typeof s.validation.position=="number"&&(a=`${a} at one or more positions greater than or equal to ${s.validation.position}`)):"startsWith"in s.validation?a=`Invalid input: must start with "${s.validation.startsWith}"`:"endsWith"in s.validation?a=`Invalid input: must end with "${s.validation.endsWith}"`:we.assertNever(s.validation):s.validation!=="regex"?a=`Invalid ${s.validation}`:a="Invalid";break;case F.too_small:s.type==="array"?a=`Array must contain ${s.exact?"exactly":s.inclusive?"at least":"more than"} ${s.minimum} element(s)`:s.type==="string"?a=`String must contain ${s.exact?"exactly":s.inclusive?"at least":"over"} ${s.minimum} character(s)`:s.type==="number"?a=`Number must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${s.minimum}`:s.type==="bigint"?a=`Number must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${s.minimum}`:s.type==="date"?a=`Date must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(s.minimum))}`:a="Invalid input";break;case F.too_big:s.type==="array"?a=`Array must contain ${s.exact?"exactly":s.inclusive?"at most":"less than"} ${s.maximum} element(s)`:s.type==="string"?a=`String must contain ${s.exact?"exactly":s.inclusive?"at most":"under"} ${s.maximum} character(s)`:s.type==="number"?a=`Number must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="bigint"?a=`BigInt must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="date"?a=`Date must be ${s.exact?"exactly":s.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(s.maximum))}`:a="Invalid input";break;case F.custom:a="Invalid input";break;case F.invalid_intersection_types:a="Intersection results could not be merged";break;case F.not_multiple_of:a=`Number must be a multiple of ${s.multipleOf}`;break;case F.not_finite:a="Number must be finite";break;default:a=t.defaultError,we.assertNever(s)}return{message:a}};let km=qr;function wm(){return km}const Nm=s=>{const{data:t,path:a,errorMaps:r,issueData:n}=s,i=[...a,...n.path||[]],o={...n,path:i};if(n.message!==void 0)return{...n,path:i,message:n.message};let c="";const d=r.filter(l=>!!l).slice().reverse();for(const l of d)c=l(o,{data:t,defaultError:c}).message;return{...n,path:i,message:c}};function q(s,t){const a=wm(),r=Nm({issueData:t,data:s.data,path:s.path,errorMaps:[s.common.contextualErrorMap,s.schemaErrorMap,a,a===qr?void 0:qr].filter(n=>!!n)});s.common.issues.push(r)}class Ze{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,a){const r=[];for(const n of a){if(n.status==="aborted")return ie;n.status==="dirty"&&t.dirty(),r.push(n.value)}return{status:t.value,value:r}}static async mergeObjectAsync(t,a){const r=[];for(const n of a){const i=await n.key,o=await n.value;r.push({key:i,value:o})}return Ze.mergeObjectSync(t,r)}static mergeObjectSync(t,a){const r={};for(const n of a){const{key:i,value:o}=n;if(i.status==="aborted"||o.status==="aborted")return ie;i.status==="dirty"&&t.dirty(),o.status==="dirty"&&t.dirty(),i.value!=="__proto__"&&(typeof o.value<"u"||n.alwaysSet)&&(r[i.value]=o.value)}return{status:t.value,value:r}}}const ie=Object.freeze({status:"aborted"}),aa=s=>({status:"dirty",value:s}),ft=s=>({status:"valid",value:s}),ai=s=>s.status==="aborted",ri=s=>s.status==="dirty",$s=s=>s.status==="valid",Ua=s=>typeof Promise<"u"&&s instanceof Promise;var Q;(function(s){s.errToObj=t=>typeof t=="string"?{message:t}:t||{},s.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(Q||(Q={}));class Pt{constructor(t,a,r,n){this._cachedPath=[],this.parent=t,this.data=a,this._path=r,this._key=n}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const ni=(s,t)=>{if($s(t))return{success:!0,data:t.value};if(!s.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const a=new Ft(s.common.issues);return this._error=a,this._error}}};function ge(s){if(!s)return{};const{errorMap:t,invalid_type_error:a,required_error:r,description:n}=s;if(t&&(a||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:n}:{errorMap:(o,c)=>{const{message:d}=s;return o.code==="invalid_enum_value"?{message:d??c.defaultError}:typeof c.data>"u"?{message:d??r??c.defaultError}:o.code!=="invalid_type"?{message:c.defaultError}:{message:d??a??c.defaultError}},description:n}}class be{get description(){return this._def.description}_getType(t){return Ht(t.data)}_getOrReturnCtx(t,a){return a||{common:t.parent.common,data:t.data,parsedType:Ht(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new Ze,ctx:{common:t.parent.common,data:t.data,parsedType:Ht(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const a=this._parse(t);if(Ua(a))throw new Error("Synchronous parse encountered promise.");return a}_parseAsync(t){const a=this._parse(t);return Promise.resolve(a)}parse(t,a){const r=this.safeParse(t,a);if(r.success)return r.data;throw r.error}safeParse(t,a){const r={common:{issues:[],async:(a==null?void 0:a.async)??!1,contextualErrorMap:a==null?void 0:a.errorMap},path:(a==null?void 0:a.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Ht(t)},n=this._parseSync({data:t,path:r.path,parent:r});return ni(r,n)}"~validate"(t){var r,n;const a={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Ht(t)};if(!this["~standard"].async)try{const i=this._parseSync({data:t,path:[],parent:a});return $s(i)?{value:i.value}:{issues:a.common.issues}}catch(i){(n=(r=i==null?void 0:i.message)==null?void 0:r.toLowerCase())!=null&&n.includes("encountered")&&(this["~standard"].async=!0),a.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:a}).then(i=>$s(i)?{value:i.value}:{issues:a.common.issues})}async parseAsync(t,a){const r=await this.safeParseAsync(t,a);if(r.success)return r.data;throw r.error}async safeParseAsync(t,a){const r={common:{issues:[],contextualErrorMap:a==null?void 0:a.errorMap,async:!0},path:(a==null?void 0:a.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Ht(t)},n=this._parse({data:t,path:r.path,parent:r}),i=await(Ua(n)?n:Promise.resolve(n));return ni(r,i)}refine(t,a){const r=n=>typeof a=="string"||typeof a>"u"?{message:a}:typeof a=="function"?a(n):a;return this._refinement((n,i)=>{const o=t(n),c=()=>i.addIssue({code:F.custom,...r(n)});return typeof Promise<"u"&&o instanceof Promise?o.then(d=>d?!0:(c(),!1)):o?!0:(c(),!1)})}refinement(t,a){return this._refinement((r,n)=>t(r)?!0:(n.addIssue(typeof a=="function"?a(r,n):a),!1))}_refinement(t){return new zs({schema:this,typeName:re.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:a=>this["~validate"](a)}}optional(){return Wt.create(this,this._def)}nullable(){return qs.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return St.create(this)}promise(){return Ha.create(this,this._def)}or(t){return Va.create([this,t],this._def)}and(t){return Ka.create(this,t,this._def)}transform(t){return new zs({...ge(this._def),schema:this,typeName:re.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const a=typeof t=="function"?t:()=>t;return new Jr({...ge(this._def),innerType:this,defaultValue:a,typeName:re.ZodDefault})}brand(){return new Hm({typeName:re.ZodBranded,type:this,...ge(this._def)})}catch(t){const a=typeof t=="function"?t:()=>t;return new Hr({...ge(this._def),innerType:this,catchValue:a,typeName:re.ZodCatch})}describe(t){const a=this.constructor;return new a({...this._def,description:t})}pipe(t){return mn.create(this,t)}readonly(){return Wr.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const _m=/^c[^\s-]{8,}$/i,Sm=/^[0-9a-z]+$/,Cm=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Tm=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Pm=/^[a-z0-9_-]{21}$/i,Em=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Am=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Om=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Im="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let vr;const Mm=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Rm=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,Lm=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,$m=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Fm=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Dm=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,bo="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",zm=new RegExp(`^${bo}$`);function vo(s){let t="[0-5]\\d";s.precision?t=`${t}\\.\\d{${s.precision}}`:s.precision==null&&(t=`${t}(\\.\\d+)?`);const a=s.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${a}`}function qm(s){return new RegExp(`^${vo(s)}$`)}function Um(s){let t=`${bo}T${vo(s)}`;const a=[];return a.push(s.local?"Z?":"Z"),s.offset&&a.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${a.join("|")})`,new RegExp(`^${t}$`)}function Bm(s,t){return!!((t==="v4"||!t)&&Mm.test(s)||(t==="v6"||!t)&&Lm.test(s))}function Vm(s,t){if(!Em.test(s))return!1;try{const[a]=s.split(".");if(!a)return!1;const r=a.replace(/-/g,"+").replace(/_/g,"/").padEnd(a.length+(4-a.length%4)%4,"="),n=JSON.parse(atob(r));return!(typeof n!="object"||n===null||"typ"in n&&(n==null?void 0:n.typ)!=="JWT"||!n.alg||t&&n.alg!==t)}catch{return!1}}function Km(s,t){return!!((t==="v4"||!t)&&Rm.test(s)||(t==="v6"||!t)&&$m.test(s))}class $t extends be{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==W.string){const i=this._getOrReturnCtx(t);return q(i,{code:F.invalid_type,expected:W.string,received:i.parsedType}),ie}const r=new Ze;let n;for(const i of this._def.checks)if(i.kind==="min")t.data.lengthi.value&&(n=this._getOrReturnCtx(t,n),q(n,{code:F.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="length"){const o=t.data.length>i.value,c=t.data.lengtht.test(n),{validation:a,code:F.invalid_string,...Q.errToObj(r)})}_addCheck(t){return new $t({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...Q.errToObj(t)})}url(t){return this._addCheck({kind:"url",...Q.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...Q.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...Q.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...Q.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...Q.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...Q.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...Q.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...Q.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...Q.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...Q.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...Q.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...Q.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,offset:(t==null?void 0:t.offset)??!1,local:(t==null?void 0:t.local)??!1,...Q.errToObj(t==null?void 0:t.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,...Q.errToObj(t==null?void 0:t.message)})}duration(t){return this._addCheck({kind:"duration",...Q.errToObj(t)})}regex(t,a){return this._addCheck({kind:"regex",regex:t,...Q.errToObj(a)})}includes(t,a){return this._addCheck({kind:"includes",value:t,position:a==null?void 0:a.position,...Q.errToObj(a==null?void 0:a.message)})}startsWith(t,a){return this._addCheck({kind:"startsWith",value:t,...Q.errToObj(a)})}endsWith(t,a){return this._addCheck({kind:"endsWith",value:t,...Q.errToObj(a)})}min(t,a){return this._addCheck({kind:"min",value:t,...Q.errToObj(a)})}max(t,a){return this._addCheck({kind:"max",value:t,...Q.errToObj(a)})}length(t,a){return this._addCheck({kind:"length",value:t,...Q.errToObj(a)})}nonempty(t){return this.min(1,Q.errToObj(t))}trim(){return new $t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new $t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new $t({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(const a of this._def.checks)a.kind==="min"&&(t===null||a.value>t)&&(t=a.value);return t}get maxLength(){let t=null;for(const a of this._def.checks)a.kind==="max"&&(t===null||a.valuenew $t({checks:[],typeName:re.ZodString,coerce:(s==null?void 0:s.coerce)??!1,...ge(s)});function Jm(s,t){const a=(s.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,n=a>r?a:r,i=Number.parseInt(s.toFixed(n).replace(".","")),o=Number.parseInt(t.toFixed(n).replace(".",""));return i%o/10**n}class Fs extends be{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==W.number){const i=this._getOrReturnCtx(t);return q(i,{code:F.invalid_type,expected:W.number,received:i.parsedType}),ie}let r;const n=new Ze;for(const i of this._def.checks)i.kind==="int"?we.isInteger(t.data)||(r=this._getOrReturnCtx(t,r),q(r,{code:F.invalid_type,expected:"integer",received:"float",message:i.message}),n.dirty()):i.kind==="min"?(i.inclusive?t.datai.value:t.data>=i.value)&&(r=this._getOrReturnCtx(t,r),q(r,{code:F.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),n.dirty()):i.kind==="multipleOf"?Jm(t.data,i.value)!==0&&(r=this._getOrReturnCtx(t,r),q(r,{code:F.not_multiple_of,multipleOf:i.value,message:i.message}),n.dirty()):i.kind==="finite"?Number.isFinite(t.data)||(r=this._getOrReturnCtx(t,r),q(r,{code:F.not_finite,message:i.message}),n.dirty()):we.assertNever(i);return{status:n.value,value:t.data}}gte(t,a){return this.setLimit("min",t,!0,Q.toString(a))}gt(t,a){return this.setLimit("min",t,!1,Q.toString(a))}lte(t,a){return this.setLimit("max",t,!0,Q.toString(a))}lt(t,a){return this.setLimit("max",t,!1,Q.toString(a))}setLimit(t,a,r,n){return new Fs({...this._def,checks:[...this._def.checks,{kind:t,value:a,inclusive:r,message:Q.toString(n)}]})}_addCheck(t){return new Fs({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:Q.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Q.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Q.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Q.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Q.toString(t)})}multipleOf(t,a){return this._addCheck({kind:"multipleOf",value:t,message:Q.toString(a)})}finite(t){return this._addCheck({kind:"finite",message:Q.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Q.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Q.toString(t)})}get minValue(){let t=null;for(const a of this._def.checks)a.kind==="min"&&(t===null||a.value>t)&&(t=a.value);return t}get maxValue(){let t=null;for(const a of this._def.checks)a.kind==="max"&&(t===null||a.valuet.kind==="int"||t.kind==="multipleOf"&&we.isInteger(t.value))}get isFinite(){let t=null,a=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(a===null||r.value>a)&&(a=r.value):r.kind==="max"&&(t===null||r.valuenew Fs({checks:[],typeName:re.ZodNumber,coerce:(s==null?void 0:s.coerce)||!1,...ge(s)});class la extends be{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==W.bigint)return this._getInvalidInput(t);let r;const n=new Ze;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?t.datai.value:t.data>=i.value)&&(r=this._getOrReturnCtx(t,r),q(r,{code:F.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),n.dirty()):i.kind==="multipleOf"?t.data%i.value!==BigInt(0)&&(r=this._getOrReturnCtx(t,r),q(r,{code:F.not_multiple_of,multipleOf:i.value,message:i.message}),n.dirty()):we.assertNever(i);return{status:n.value,value:t.data}}_getInvalidInput(t){const a=this._getOrReturnCtx(t);return q(a,{code:F.invalid_type,expected:W.bigint,received:a.parsedType}),ie}gte(t,a){return this.setLimit("min",t,!0,Q.toString(a))}gt(t,a){return this.setLimit("min",t,!1,Q.toString(a))}lte(t,a){return this.setLimit("max",t,!0,Q.toString(a))}lt(t,a){return this.setLimit("max",t,!1,Q.toString(a))}setLimit(t,a,r,n){return new la({...this._def,checks:[...this._def.checks,{kind:t,value:a,inclusive:r,message:Q.toString(n)}]})}_addCheck(t){return new la({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Q.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Q.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Q.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Q.toString(t)})}multipleOf(t,a){return this._addCheck({kind:"multipleOf",value:t,message:Q.toString(a)})}get minValue(){let t=null;for(const a of this._def.checks)a.kind==="min"&&(t===null||a.value>t)&&(t=a.value);return t}get maxValue(){let t=null;for(const a of this._def.checks)a.kind==="max"&&(t===null||a.valuenew la({checks:[],typeName:re.ZodBigInt,coerce:(s==null?void 0:s.coerce)??!1,...ge(s)});class Ur extends be{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==W.boolean){const r=this._getOrReturnCtx(t);return q(r,{code:F.invalid_type,expected:W.boolean,received:r.parsedType}),ie}return ft(t.data)}}Ur.create=s=>new Ur({typeName:re.ZodBoolean,coerce:(s==null?void 0:s.coerce)||!1,...ge(s)});class Ba extends be{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==W.date){const i=this._getOrReturnCtx(t);return q(i,{code:F.invalid_type,expected:W.date,received:i.parsedType}),ie}if(Number.isNaN(t.data.getTime())){const i=this._getOrReturnCtx(t);return q(i,{code:F.invalid_date}),ie}const r=new Ze;let n;for(const i of this._def.checks)i.kind==="min"?t.data.getTime()i.value&&(n=this._getOrReturnCtx(t,n),q(n,{code:F.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):we.assertNever(i);return{status:r.value,value:new Date(t.data.getTime())}}_addCheck(t){return new Ba({...this._def,checks:[...this._def.checks,t]})}min(t,a){return this._addCheck({kind:"min",value:t.getTime(),message:Q.toString(a)})}max(t,a){return this._addCheck({kind:"max",value:t.getTime(),message:Q.toString(a)})}get minDate(){let t=null;for(const a of this._def.checks)a.kind==="min"&&(t===null||a.value>t)&&(t=a.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(const a of this._def.checks)a.kind==="max"&&(t===null||a.valuenew Ba({checks:[],coerce:(s==null?void 0:s.coerce)||!1,typeName:re.ZodDate,...ge(s)});class ii extends be{_parse(t){if(this._getType(t)!==W.symbol){const r=this._getOrReturnCtx(t);return q(r,{code:F.invalid_type,expected:W.symbol,received:r.parsedType}),ie}return ft(t.data)}}ii.create=s=>new ii({typeName:re.ZodSymbol,...ge(s)});class oi extends be{_parse(t){if(this._getType(t)!==W.undefined){const r=this._getOrReturnCtx(t);return q(r,{code:F.invalid_type,expected:W.undefined,received:r.parsedType}),ie}return ft(t.data)}}oi.create=s=>new oi({typeName:re.ZodUndefined,...ge(s)});class li extends be{_parse(t){if(this._getType(t)!==W.null){const r=this._getOrReturnCtx(t);return q(r,{code:F.invalid_type,expected:W.null,received:r.parsedType}),ie}return ft(t.data)}}li.create=s=>new li({typeName:re.ZodNull,...ge(s)});class Br extends be{constructor(){super(...arguments),this._any=!0}_parse(t){return ft(t.data)}}Br.create=s=>new Br({typeName:re.ZodAny,...ge(s)});class Vr extends be{constructor(){super(...arguments),this._unknown=!0}_parse(t){return ft(t.data)}}Vr.create=s=>new Vr({typeName:re.ZodUnknown,...ge(s)});class Qt extends be{_parse(t){const a=this._getOrReturnCtx(t);return q(a,{code:F.invalid_type,expected:W.never,received:a.parsedType}),ie}}Qt.create=s=>new Qt({typeName:re.ZodNever,...ge(s)});class ci extends be{_parse(t){if(this._getType(t)!==W.undefined){const r=this._getOrReturnCtx(t);return q(r,{code:F.invalid_type,expected:W.void,received:r.parsedType}),ie}return ft(t.data)}}ci.create=s=>new ci({typeName:re.ZodVoid,...ge(s)});class St extends be{_parse(t){const{ctx:a,status:r}=this._processInputParams(t),n=this._def;if(a.parsedType!==W.array)return q(a,{code:F.invalid_type,expected:W.array,received:a.parsedType}),ie;if(n.exactLength!==null){const o=a.data.length>n.exactLength.value,c=a.data.lengthn.maxLength.value&&(q(a,{code:F.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),r.dirty()),a.common.async)return Promise.all([...a.data].map((o,c)=>n.type._parseAsync(new Pt(a,o,a.path,c)))).then(o=>Ze.mergeArray(r,o));const i=[...a.data].map((o,c)=>n.type._parseSync(new Pt(a,o,a.path,c)));return Ze.mergeArray(r,i)}get element(){return this._def.type}min(t,a){return new St({...this._def,minLength:{value:t,message:Q.toString(a)}})}max(t,a){return new St({...this._def,maxLength:{value:t,message:Q.toString(a)}})}length(t,a){return new St({...this._def,exactLength:{value:t,message:Q.toString(a)}})}nonempty(t){return this.min(1,t)}}St.create=(s,t)=>new St({type:s,minLength:null,maxLength:null,exactLength:null,typeName:re.ZodArray,...ge(t)});function Es(s){if(s instanceof Fe){const t={};for(const a in s.shape){const r=s.shape[a];t[a]=Wt.create(Es(r))}return new Fe({...s._def,shape:()=>t})}else return s instanceof St?new St({...s._def,type:Es(s.element)}):s instanceof Wt?Wt.create(Es(s.unwrap())):s instanceof qs?qs.create(Es(s.unwrap())):s instanceof ps?ps.create(s.items.map(t=>Es(t))):s}class Fe extends be{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const t=this._def.shape(),a=we.objectKeys(t);return this._cached={shape:t,keys:a},this._cached}_parse(t){if(this._getType(t)!==W.object){const l=this._getOrReturnCtx(t);return q(l,{code:F.invalid_type,expected:W.object,received:l.parsedType}),ie}const{status:r,ctx:n}=this._processInputParams(t),{shape:i,keys:o}=this._getCached(),c=[];if(!(this._def.catchall instanceof Qt&&this._def.unknownKeys==="strip"))for(const l in n.data)o.includes(l)||c.push(l);const d=[];for(const l of o){const m=i[l],g=n.data[l];d.push({key:{status:"valid",value:l},value:m._parse(new Pt(n,g,n.path,l)),alwaysSet:l in n.data})}if(this._def.catchall instanceof Qt){const l=this._def.unknownKeys;if(l==="passthrough")for(const m of c)d.push({key:{status:"valid",value:m},value:{status:"valid",value:n.data[m]}});else if(l==="strict")c.length>0&&(q(n,{code:F.unrecognized_keys,keys:c}),r.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const l=this._def.catchall;for(const m of c){const g=n.data[m];d.push({key:{status:"valid",value:m},value:l._parse(new Pt(n,g,n.path,m)),alwaysSet:m in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const l=[];for(const m of d){const g=await m.key,y=await m.value;l.push({key:g,value:y,alwaysSet:m.alwaysSet})}return l}).then(l=>Ze.mergeObjectSync(r,l)):Ze.mergeObjectSync(r,d)}get shape(){return this._def.shape()}strict(t){return Q.errToObj,new Fe({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(a,r)=>{var i,o;const n=((o=(i=this._def).errorMap)==null?void 0:o.call(i,a,r).message)??r.defaultError;return a.code==="unrecognized_keys"?{message:Q.errToObj(t).message??n}:{message:n}}}:{}})}strip(){return new Fe({...this._def,unknownKeys:"strip"})}passthrough(){return new Fe({...this._def,unknownKeys:"passthrough"})}extend(t){return new Fe({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new Fe({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:re.ZodObject})}setKey(t,a){return this.augment({[t]:a})}catchall(t){return new Fe({...this._def,catchall:t})}pick(t){const a={};for(const r of we.objectKeys(t))t[r]&&this.shape[r]&&(a[r]=this.shape[r]);return new Fe({...this._def,shape:()=>a})}omit(t){const a={};for(const r of we.objectKeys(this.shape))t[r]||(a[r]=this.shape[r]);return new Fe({...this._def,shape:()=>a})}deepPartial(){return Es(this)}partial(t){const a={};for(const r of we.objectKeys(this.shape)){const n=this.shape[r];t&&!t[r]?a[r]=n:a[r]=n.optional()}return new Fe({...this._def,shape:()=>a})}required(t){const a={};for(const r of we.objectKeys(this.shape))if(t&&!t[r])a[r]=this.shape[r];else{let i=this.shape[r];for(;i instanceof Wt;)i=i._def.innerType;a[r]=i}return new Fe({...this._def,shape:()=>a})}keyof(){return jo(we.objectKeys(this.shape))}}Fe.create=(s,t)=>new Fe({shape:()=>s,unknownKeys:"strip",catchall:Qt.create(),typeName:re.ZodObject,...ge(t)});Fe.strictCreate=(s,t)=>new Fe({shape:()=>s,unknownKeys:"strict",catchall:Qt.create(),typeName:re.ZodObject,...ge(t)});Fe.lazycreate=(s,t)=>new Fe({shape:s,unknownKeys:"strip",catchall:Qt.create(),typeName:re.ZodObject,...ge(t)});class Va extends be{_parse(t){const{ctx:a}=this._processInputParams(t),r=this._def.options;function n(i){for(const c of i)if(c.result.status==="valid")return c.result;for(const c of i)if(c.result.status==="dirty")return a.common.issues.push(...c.ctx.common.issues),c.result;const o=i.map(c=>new Ft(c.ctx.common.issues));return q(a,{code:F.invalid_union,unionErrors:o}),ie}if(a.common.async)return Promise.all(r.map(async i=>{const o={...a,common:{...a.common,issues:[]},parent:null};return{result:await i._parseAsync({data:a.data,path:a.path,parent:o}),ctx:o}})).then(n);{let i;const o=[];for(const d of r){const l={...a,common:{...a.common,issues:[]},parent:null},m=d._parseSync({data:a.data,path:a.path,parent:l});if(m.status==="valid")return m;m.status==="dirty"&&!i&&(i={result:m,ctx:l}),l.common.issues.length&&o.push(l.common.issues)}if(i)return a.common.issues.push(...i.ctx.common.issues),i.result;const c=o.map(d=>new Ft(d));return q(a,{code:F.invalid_union,unionErrors:c}),ie}}get options(){return this._def.options}}Va.create=(s,t)=>new Va({options:s,typeName:re.ZodUnion,...ge(t)});function Kr(s,t){const a=Ht(s),r=Ht(t);if(s===t)return{valid:!0,data:s};if(a===W.object&&r===W.object){const n=we.objectKeys(t),i=we.objectKeys(s).filter(c=>n.indexOf(c)!==-1),o={...s,...t};for(const c of i){const d=Kr(s[c],t[c]);if(!d.valid)return{valid:!1};o[c]=d.data}return{valid:!0,data:o}}else if(a===W.array&&r===W.array){if(s.length!==t.length)return{valid:!1};const n=[];for(let i=0;i{if(ai(i)||ai(o))return ie;const c=Kr(i.value,o.value);return c.valid?((ri(i)||ri(o))&&a.dirty(),{status:a.value,value:c.data}):(q(r,{code:F.invalid_intersection_types}),ie)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([i,o])=>n(i,o)):n(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}Ka.create=(s,t,a)=>new Ka({left:s,right:t,typeName:re.ZodIntersection,...ge(a)});class ps extends be{_parse(t){const{status:a,ctx:r}=this._processInputParams(t);if(r.parsedType!==W.array)return q(r,{code:F.invalid_type,expected:W.array,received:r.parsedType}),ie;if(r.data.lengththis._def.items.length&&(q(r,{code:F.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),a.dirty());const i=[...r.data].map((o,c)=>{const d=this._def.items[c]||this._def.rest;return d?d._parse(new Pt(r,o,r.path,c)):null}).filter(o=>!!o);return r.common.async?Promise.all(i).then(o=>Ze.mergeArray(a,o)):Ze.mergeArray(a,i)}get items(){return this._def.items}rest(t){return new ps({...this._def,rest:t})}}ps.create=(s,t)=>{if(!Array.isArray(s))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ps({items:s,typeName:re.ZodTuple,rest:null,...ge(t)})};class Ja extends be{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:a,ctx:r}=this._processInputParams(t);if(r.parsedType!==W.object)return q(r,{code:F.invalid_type,expected:W.object,received:r.parsedType}),ie;const n=[],i=this._def.keyType,o=this._def.valueType;for(const c in r.data)n.push({key:i._parse(new Pt(r,c,r.path,c)),value:o._parse(new Pt(r,r.data[c],r.path,c)),alwaysSet:c in r.data});return r.common.async?Ze.mergeObjectAsync(a,n):Ze.mergeObjectSync(a,n)}get element(){return this._def.valueType}static create(t,a,r){return a instanceof be?new Ja({keyType:t,valueType:a,typeName:re.ZodRecord,...ge(r)}):new Ja({keyType:$t.create(),valueType:t,typeName:re.ZodRecord,...ge(a)})}}class di extends be{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:a,ctx:r}=this._processInputParams(t);if(r.parsedType!==W.map)return q(r,{code:F.invalid_type,expected:W.map,received:r.parsedType}),ie;const n=this._def.keyType,i=this._def.valueType,o=[...r.data.entries()].map(([c,d],l)=>({key:n._parse(new Pt(r,c,r.path,[l,"key"])),value:i._parse(new Pt(r,d,r.path,[l,"value"]))}));if(r.common.async){const c=new Map;return Promise.resolve().then(async()=>{for(const d of o){const l=await d.key,m=await d.value;if(l.status==="aborted"||m.status==="aborted")return ie;(l.status==="dirty"||m.status==="dirty")&&a.dirty(),c.set(l.value,m.value)}return{status:a.value,value:c}})}else{const c=new Map;for(const d of o){const l=d.key,m=d.value;if(l.status==="aborted"||m.status==="aborted")return ie;(l.status==="dirty"||m.status==="dirty")&&a.dirty(),c.set(l.value,m.value)}return{status:a.value,value:c}}}}di.create=(s,t,a)=>new di({valueType:t,keyType:s,typeName:re.ZodMap,...ge(a)});class ca extends be{_parse(t){const{status:a,ctx:r}=this._processInputParams(t);if(r.parsedType!==W.set)return q(r,{code:F.invalid_type,expected:W.set,received:r.parsedType}),ie;const n=this._def;n.minSize!==null&&r.data.sizen.maxSize.value&&(q(r,{code:F.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),a.dirty());const i=this._def.valueType;function o(d){const l=new Set;for(const m of d){if(m.status==="aborted")return ie;m.status==="dirty"&&a.dirty(),l.add(m.value)}return{status:a.value,value:l}}const c=[...r.data.values()].map((d,l)=>i._parse(new Pt(r,d,r.path,l)));return r.common.async?Promise.all(c).then(d=>o(d)):o(c)}min(t,a){return new ca({...this._def,minSize:{value:t,message:Q.toString(a)}})}max(t,a){return new ca({...this._def,maxSize:{value:t,message:Q.toString(a)}})}size(t,a){return this.min(t,a).max(t,a)}nonempty(t){return this.min(1,t)}}ca.create=(s,t)=>new ca({valueType:s,minSize:null,maxSize:null,typeName:re.ZodSet,...ge(t)});class ui extends be{get schema(){return this._def.getter()}_parse(t){const{ctx:a}=this._processInputParams(t);return this._def.getter()._parse({data:a.data,path:a.path,parent:a})}}ui.create=(s,t)=>new ui({getter:s,typeName:re.ZodLazy,...ge(t)});class mi extends be{_parse(t){if(t.data!==this._def.value){const a=this._getOrReturnCtx(t);return q(a,{received:a.data,code:F.invalid_literal,expected:this._def.value}),ie}return{status:"valid",value:t.data}}get value(){return this._def.value}}mi.create=(s,t)=>new mi({value:s,typeName:re.ZodLiteral,...ge(t)});function jo(s,t){return new Ds({values:s,typeName:re.ZodEnum,...ge(t)})}class Ds extends be{_parse(t){if(typeof t.data!="string"){const a=this._getOrReturnCtx(t),r=this._def.values;return q(a,{expected:we.joinValues(r),received:a.parsedType,code:F.invalid_type}),ie}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){const a=this._getOrReturnCtx(t),r=this._def.values;return q(a,{received:a.data,code:F.invalid_enum_value,options:r}),ie}return ft(t.data)}get options(){return this._def.values}get enum(){const t={};for(const a of this._def.values)t[a]=a;return t}get Values(){const t={};for(const a of this._def.values)t[a]=a;return t}get Enum(){const t={};for(const a of this._def.values)t[a]=a;return t}extract(t,a=this._def){return Ds.create(t,{...this._def,...a})}exclude(t,a=this._def){return Ds.create(this.options.filter(r=>!t.includes(r)),{...this._def,...a})}}Ds.create=jo;class hi extends be{_parse(t){const a=we.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(t);if(r.parsedType!==W.string&&r.parsedType!==W.number){const n=we.objectValues(a);return q(r,{expected:we.joinValues(n),received:r.parsedType,code:F.invalid_type}),ie}if(this._cache||(this._cache=new Set(we.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){const n=we.objectValues(a);return q(r,{received:r.data,code:F.invalid_enum_value,options:n}),ie}return ft(t.data)}get enum(){return this._def.values}}hi.create=(s,t)=>new hi({values:s,typeName:re.ZodNativeEnum,...ge(t)});class Ha extends be{unwrap(){return this._def.type}_parse(t){const{ctx:a}=this._processInputParams(t);if(a.parsedType!==W.promise&&a.common.async===!1)return q(a,{code:F.invalid_type,expected:W.promise,received:a.parsedType}),ie;const r=a.parsedType===W.promise?a.data:Promise.resolve(a.data);return ft(r.then(n=>this._def.type.parseAsync(n,{path:a.path,errorMap:a.common.contextualErrorMap})))}}Ha.create=(s,t)=>new Ha({type:s,typeName:re.ZodPromise,...ge(t)});class zs extends be{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===re.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:a,ctx:r}=this._processInputParams(t),n=this._def.effect||null,i={addIssue:o=>{q(r,o),o.fatal?a.abort():a.dirty()},get path(){return r.path}};if(i.addIssue=i.addIssue.bind(i),n.type==="preprocess"){const o=n.transform(r.data,i);if(r.common.async)return Promise.resolve(o).then(async c=>{if(a.value==="aborted")return ie;const d=await this._def.schema._parseAsync({data:c,path:r.path,parent:r});return d.status==="aborted"?ie:d.status==="dirty"||a.value==="dirty"?aa(d.value):d});{if(a.value==="aborted")return ie;const c=this._def.schema._parseSync({data:o,path:r.path,parent:r});return c.status==="aborted"?ie:c.status==="dirty"||a.value==="dirty"?aa(c.value):c}}if(n.type==="refinement"){const o=c=>{const d=n.refinement(c,i);if(r.common.async)return Promise.resolve(d);if(d instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return c};if(r.common.async===!1){const c=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return c.status==="aborted"?ie:(c.status==="dirty"&&a.dirty(),o(c.value),{status:a.value,value:c.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(c=>c.status==="aborted"?ie:(c.status==="dirty"&&a.dirty(),o(c.value).then(()=>({status:a.value,value:c.value}))))}if(n.type==="transform")if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!$s(o))return ie;const c=n.transform(o.value,i);if(c instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:a.value,value:c}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>$s(o)?Promise.resolve(n.transform(o.value,i)).then(c=>({status:a.value,value:c})):ie);we.assertNever(n)}}zs.create=(s,t,a)=>new zs({schema:s,typeName:re.ZodEffects,effect:t,...ge(a)});zs.createWithPreprocess=(s,t,a)=>new zs({schema:t,effect:{type:"preprocess",transform:s},typeName:re.ZodEffects,...ge(a)});class Wt extends be{_parse(t){return this._getType(t)===W.undefined?ft(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}Wt.create=(s,t)=>new Wt({innerType:s,typeName:re.ZodOptional,...ge(t)});class qs extends be{_parse(t){return this._getType(t)===W.null?ft(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}qs.create=(s,t)=>new qs({innerType:s,typeName:re.ZodNullable,...ge(t)});class Jr extends be{_parse(t){const{ctx:a}=this._processInputParams(t);let r=a.data;return a.parsedType===W.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:a.path,parent:a})}removeDefault(){return this._def.innerType}}Jr.create=(s,t)=>new Jr({innerType:s,typeName:re.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...ge(t)});class Hr extends be{_parse(t){const{ctx:a}=this._processInputParams(t),r={...a,common:{...a.common,issues:[]}},n=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return Ua(n)?n.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Ft(r.common.issues)},input:r.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new Ft(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}Hr.create=(s,t)=>new Hr({innerType:s,typeName:re.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...ge(t)});class gi extends be{_parse(t){if(this._getType(t)!==W.nan){const r=this._getOrReturnCtx(t);return q(r,{code:F.invalid_type,expected:W.nan,received:r.parsedType}),ie}return{status:"valid",value:t.data}}}gi.create=s=>new gi({typeName:re.ZodNaN,...ge(s)});class Hm extends be{_parse(t){const{ctx:a}=this._processInputParams(t),r=a.data;return this._def.type._parse({data:r,path:a.path,parent:a})}unwrap(){return this._def.type}}class mn extends be{_parse(t){const{status:a,ctx:r}=this._processInputParams(t);if(r.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?ie:i.status==="dirty"?(a.dirty(),aa(i.value)):this._def.out._parseAsync({data:i.value,path:r.path,parent:r})})();{const n=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return n.status==="aborted"?ie:n.status==="dirty"?(a.dirty(),{status:"dirty",value:n.value}):this._def.out._parseSync({data:n.value,path:r.path,parent:r})}}static create(t,a){return new mn({in:t,out:a,typeName:re.ZodPipeline})}}class Wr extends be{_parse(t){const a=this._def.innerType._parse(t),r=n=>($s(n)&&(n.value=Object.freeze(n.value)),n);return Ua(a)?a.then(n=>r(n)):r(a)}unwrap(){return this._def.innerType}}Wr.create=(s,t)=>new Wr({innerType:s,typeName:re.ZodReadonly,...ge(t)});var re;(function(s){s.ZodString="ZodString",s.ZodNumber="ZodNumber",s.ZodNaN="ZodNaN",s.ZodBigInt="ZodBigInt",s.ZodBoolean="ZodBoolean",s.ZodDate="ZodDate",s.ZodSymbol="ZodSymbol",s.ZodUndefined="ZodUndefined",s.ZodNull="ZodNull",s.ZodAny="ZodAny",s.ZodUnknown="ZodUnknown",s.ZodNever="ZodNever",s.ZodVoid="ZodVoid",s.ZodArray="ZodArray",s.ZodObject="ZodObject",s.ZodUnion="ZodUnion",s.ZodDiscriminatedUnion="ZodDiscriminatedUnion",s.ZodIntersection="ZodIntersection",s.ZodTuple="ZodTuple",s.ZodRecord="ZodRecord",s.ZodMap="ZodMap",s.ZodSet="ZodSet",s.ZodFunction="ZodFunction",s.ZodLazy="ZodLazy",s.ZodLiteral="ZodLiteral",s.ZodEnum="ZodEnum",s.ZodEffects="ZodEffects",s.ZodNativeEnum="ZodNativeEnum",s.ZodOptional="ZodOptional",s.ZodNullable="ZodNullable",s.ZodDefault="ZodDefault",s.ZodCatch="ZodCatch",s.ZodPromise="ZodPromise",s.ZodBranded="ZodBranded",s.ZodPipeline="ZodPipeline",s.ZodReadonly="ZodReadonly"})(re||(re={}));const Y=$t.create,ue=Fs.create,ar=Ur.create,xi=Br.create,pi=Vr.create;Qt.create;const Et=St.create,at=Fe.create,Wm=Va.create;Ka.create;ps.create;const ko=Ja.create,Gm=Ds.create;Ha.create;Wt.create;qs.create;const wo=at({id:Y(),timestamp:Y(),method:Y(),path:Y(),status_code:ue(),response_time_ms:ue(),client_ip:Y().nullable().optional(),user_agent:Y().nullable().optional(),headers:ko(Y()).nullable().optional(),response_size_bytes:ue(),request_size_bytes:ue().nullable().optional(),error_message:Y().nullable().optional()});at({timestamp:Y(),status:ue(),method:Y(),url:Y(),responseTime:ue(),size:ue(),status_code:ue().nullable().optional(),response_time_ms:ue().nullable().optional()});const Zm=at({id:Y(),name:Y(),description:Y().optional(),is_active:ar().default(!1),created_at:Y().optional(),updated_at:Y().optional(),route_count:ue().optional(),fixture_count:ue().optional()});at({id:Y(),name:Y(),description:Y().optional(),is_active:ar().default(!1),created_at:Y().optional(),updated_at:Y().optional(),fixtures:Et(xi()).optional(),routes:Et(xi()).optional()});const Qm=at({id:Y(),name:Y(),path:Y(),method:Y().optional(),description:Y().optional(),createdAt:Y(),updatedAt:Y(),tags:Et(Y()).optional(),content:Wm([Y(),pi()]).optional(),version:Y().optional(),size_bytes:ue().optional(),last_modified:Y().optional(),route_path:Y().optional(),protocol:Y().optional(),saved_at:Y().optional(),fingerprint:Y().optional(),metadata:ko(pi()).optional(),file_size:ue().optional(),file_path:Y().optional(),size:ue().optional(),created_at:Y().optional(),modified_at:Y().optional()}),Ym=at({id:Y(),name:Y(),status:Gm(["active","inactive","error"]),port:ue().optional(),endpoint:Y().optional(),description:Y().optional(),uptime:ue().optional(),request_count:ue().optional(),error_rate:ue().optional()}),Xm=at({version:Y(),build_time:Y(),git_sha:Y(),http_server:Y().nullable().optional(),ws_server:Y().nullable().optional(),grpc_server:Y().nullable().optional(),graphql_server:Y().nullable().optional(),api_enabled:ar(),admin_port:ue()}),eh=at({os:Y(),arch:Y(),uptime:ue(),memory_usage:ue()}),th=at({total_requests:ue(),active_requests:ue(),average_response_time:ue(),error_rate:ue()}),sh=at({server_type:Y(),address:Y().nullable().optional(),running:ar(),start_time:Y().nullable().optional(),uptime_seconds:ue().nullable().optional(),active_connections:ue(),total_requests:ue()}),ah=at({version:Y(),uptime_seconds:ue(),memory_usage_mb:ue(),cpu_usage_percent:ue(),active_threads:ue(),total_routes:ue(),total_fixtures:ue()}),rh=at({server_info:Xm,system_info:eh,metrics:th,servers:Et(sh),recent_logs:Et(wo),system:ah}).passthrough();at({service:Y(),route:Y(),avg_response_time:ue(),min_response_time:ue(),max_response_time:ue(),p50_response_time:ue(),p95_response_time:ue(),p99_response_time:ue(),total_requests:ue(),histogram:Et(at({range:Y(),count:ue()})).optional()});const nh=Et(Zm),ih=Et(wo),oh=rh,lh=Et(Qm);Et(Ym);function ch(s,t){try{const a=s.safeParse(t);return a.success?{success:!0,data:a.data}:{success:!1,error:a.error}}catch(a){throw Pe.error("[VALIDATION ERROR] Exception",a),a}}async function S(s,t){const a=await rt(s,t);if(!a.ok)throw a.status===401?new Error("Authentication required"):a.status===403?new Error("Access denied"):new Error(`HTTP error! status: ${a.status}`);const r=await a.json();return r.data||r}async function ke(s,t){const a=await rt(s,t);if(!a.ok){if(a.status===401)throw new Error("Authentication required");if(a.status===403)throw new Error("Access denied");const n=await a.json().catch(()=>({error:`HTTP ${a.status}`}));throw new Error(n.error||`HTTP error! status: ${a.status}`)}const r=await a.json();return r.data||r}async function Qs(s,t){const a=await rt(s,t);if(!a.ok){if(a.status===401)throw new Error("Authentication required");if(a.status===403)throw new Error("Access denied");const n=await a.text();let i=`HTTP error! status: ${a.status}`;try{i=JSON.parse(n).error||i}catch{}throw new Error(i)}const r=await a.json();return r.data||r}async function rr(s,t,a){const r=await S(s,a),n=ch(t,r);if(!n.success)throw new Error(`API response validation failed: ${n.error.message}`);return n.data}async function $e(s,t){const a=await fetch(s,t);if(!a.ok){const n=await a.text();let i=`HTTP error! status: ${a.status}`;try{i=JSON.parse(n).error||i}catch{}throw new Error(i)}const r=await a.json();return r.data||r}async function Ys(s,t){const a=await rt(s,t);if(!a.ok){if(a.status===401)throw new Error("Authentication required");if(a.status===403)throw new Error("Access denied");const n=await a.json().catch(()=>({}));throw new Error(ct(a,n,`HTTP error! status: ${a.status}`))}const r=await a.json();return r.data||r}const ls="/__mockforge/chains";let No=class{async listChains(){return S(ls)}async getChain(t){return S(`${ls}/${t}`)}async getGraph(){const t=await S("/__mockforge/graph");return t.success&&t.data?t.data:t}async createChain(t){return S(ls,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({definition:t})})}async updateChain(t,a){return S(`${ls}/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({definition:a})})}async deleteChain(t){return S(`${ls}/${t}`,{method:"DELETE"})}async executeChain(t,a){return S(`${ls}/${t}/execute`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({variables:a||{}})})}async validateChain(t){return S(`${ls}/${t}/validate`,{method:"POST"})}};class dh{async getStateMachines(){return S("/__mockforge/api/state-machines")}async getStateMachine(t){return S(`/__mockforge/api/state-machines/${encodeURIComponent(t)}`)}async createStateMachine(t,a){return S("/__mockforge/api/state-machines",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({state_machine:t,visual_layout:a})})}async updateStateMachine(t,a,r){return S(`/__mockforge/api/state-machines/${encodeURIComponent(t)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({state_machine:a,visual_layout:r})})}async deleteStateMachine(t){await S(`/__mockforge/api/state-machines/${encodeURIComponent(t)}`,{method:"DELETE"})}async getStateInstances(){return S("/__mockforge/api/state-machines/instances")}async getStateInstance(t){return S(`/__mockforge/api/state-machines/instances/${encodeURIComponent(t)}`)}async createStateInstance(t,a){return S("/__mockforge/api/state-machines/instances",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({resource_id:t,resource_type:a})})}async executeTransition(t,a,r){return S(`/__mockforge/api/state-machines/instances/${encodeURIComponent(t)}/transition`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({resource_id:t,to_state:a,context:r})})}async getNextStates(t){return S(`/__mockforge/api/state-machines/instances/${encodeURIComponent(t)}/next-states`)}async getCurrentState(t){return S(`/__mockforge/api/state-machines/instances/${encodeURIComponent(t)}/state`)}async exportStateMachines(){return S("/__mockforge/api/state-machines/export")}async importStateMachines(t){await S("/__mockforge/api/state-machines/import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}}class uh{async generateOpenApiFromTraffic(t){return S("/__mockforge/api/mockai/generate-openapi",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async listRuleExplanations(t){const a=new URLSearchParams;t!=null&&t.rule_type&&a.append("rule_type",t.rule_type),(t==null?void 0:t.min_confidence)!==void 0&&a.append("min_confidence",t.min_confidence.toString());const r=a.toString(),n=`/__mockforge/api/mockai/rules/explanations${r?`?${r}`:""}`;return S(n)}async getRuleExplanation(t){return S(`/__mockforge/api/mockai/rules/${encodeURIComponent(t)}/explanation`)}async learnFromExamples(t){return S("/__mockforge/api/mockai/learn",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}}const mh=Yt(),ye=mh?"/api/v1/workspaces":"/__mockforge/workspaces";class hh{async listWorkspaces(){return rr(ye,nh)}async getWorkspace(t){return S(`${ye}/${t}`)}async createWorkspace(t){return S(ye,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async openWorkspaceFromDirectory(t){return S(`${ye}/open-from-directory`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:t})})}async deleteWorkspace(t){return S(`${ye}/${t}`,{method:"DELETE"})}async setActiveWorkspace(t){return S(`${ye}/${t}/activate`,{method:"POST"})}async getFolder(t,a){return S(`${ye}/${t}/folders/${a}`)}async createFolder(t,a){return S(`${ye}/${t}/folders`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})}async createRequest(t,a){return S(`${ye}/${t}/requests`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})}async importToWorkspace(t,a){return S(`${ye}/${t}/import`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})}async previewImport(t){return S("/__mockforge/import/preview",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async executeRequest(t,a,r){return S(`${ye}/${t}/requests/${a}/execute`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r||{})})}async getRequestHistory(t,a){return S(`${ye}/${t}/requests/${a}/history`)}async getEnvironments(t){return S(`${ye}/${t}/environments`)}async createEnvironment(t,a){return S(`${ye}/${t}/environments`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})}async updateEnvironment(t,a,r){return S(`${ye}/${t}/environments/${a}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)})}async deleteEnvironment(t,a){return S(`${ye}/${t}/environments/${a}`,{method:"DELETE"})}async setActiveEnvironment(t,a){return S(`${ye}/${t}/environments/${a}/activate`,{method:"POST"})}async getEnvironmentVariables(t,a){return S(`${ye}/${t}/environments/${a}/variables`)}async setEnvironmentVariable(t,a,r){return S(`${ye}/${t}/environments/${a}/variables`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)})}async removeEnvironmentVariable(t,a,r){return S(`${ye}/${t}/environments/${a}/variables/${encodeURIComponent(r)}`,{method:"DELETE"})}async getAutocompleteSuggestions(t,a){return S(`${ye}/${t}/autocomplete`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})}async updateWorkspacesOrder(t){return S(`${ye}/order`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspace_ids:t})})}async updateEnvironmentsOrder(t,a){return S(`${ye}/${t}/environments/order`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({environment_ids:a})})}async getSyncStatus(t){return S(`${ye}/${t}/sync/status`)}async configureSync(t,a){return S(`${ye}/${t}/sync/configure`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})}async disableSync(t){return S(`${ye}/${t}/sync/disable`,{method:"POST"})}async triggerSync(t){return S(`${ye}/${t}/sync/trigger`,{method:"POST"})}async getSyncChanges(t){return S(`${ye}/${t}/sync/changes`)}async confirmSyncChanges(t,a){return S(`${ye}/${t}/sync/confirm`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})}async getWorkspaceEncryptionStatus(t){return S(`${ye}/${t}/encryption/status`)}async getWorkspaceEncryptionConfig(t){return S(`${ye}/${t}/encryption/config`)}async enableWorkspaceEncryption(t){return S(`${ye}/${t}/encryption/enable`,{method:"POST"})}async disableWorkspaceEncryption(t){return S(`${ye}/${t}/encryption/disable`,{method:"POST"})}async checkWorkspaceSecurity(t){return S(`${ye}/${t}/encryption/security-check`,{method:"POST"})}async exportWorkspaceEncrypted(t,a){return S(`${ye}/${t}/encryption/export`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({export_path:a})})}async importWorkspaceEncrypted(t,a,r){return S(`${ye}/${a}/encryption/import`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({import_path:t,backup_key:r})})}async updateWorkspaceEncryptionConfig(t,a){return S(`${ye}/${t}/encryption/config`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})}}function gh(s,t){t.forEach(a=>{Object.getOwnPropertyNames(a.prototype).forEach(r=>{r!=="constructor"&&Object.defineProperty(s.prototype,r,Object.getOwnPropertyDescriptor(a.prototype,r)||Object.create(null))})})}gh(No,[dh,uh,hh]);const xh=No;class ph{async importPostman(t){return S("/__mockforge/import/postman",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async importInsomnia(t){return S("/__mockforge/import/insomnia",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async importCurl(t){return S("/__mockforge/import/curl",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async importOpenApi(t){return S("/__mockforge/import/openapi",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async previewImport(t){return S("/__mockforge/import/preview",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async getImportHistory(){return S("/__mockforge/import/history")}async clearImportHistory(){return S("/__mockforge/import/history/clear",{method:"POST"})}}const ds=Yt(),fh="/api/v1/fixtures",ra="/__mockforge/fixtures",Xs=ds?fh:ra;class yh{constructor(){this.getFixtures=this.getFixtures.bind(this),this.createFixture=this.createFixture.bind(this),this.updateFixture=this.updateFixture.bind(this),this.deleteFixture=this.deleteFixture.bind(this),this.deleteFixturesBulk=this.deleteFixturesBulk.bind(this),this.downloadFixture=this.downloadFixture.bind(this),this.renameFixture=this.renameFixture.bind(this),this.moveFixture=this.moveFixture.bind(this)}async getFixtures(){return ds?S(Xs):rr(Xs,lh)}async createFixture(t){return S(Xs,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async updateFixture(t,a){if(!ds)throw new Error("Editing fixture content is only supported on the hosted backend; use rename/move locally.");return S(`${Xs}/${t}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})}async deleteFixture(t){return S(`${Xs}/${t}`,{method:"DELETE"})}async deleteFixturesBulk(t){if(ds){await Promise.all(t.map(a=>this.deleteFixture(a)));return}return S(`${ra}/bulk`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({fixture_ids:t})})}async downloadFixture(t){if(ds){const c=t.content??{id:t.id,name:t.name,path:t.path,method:t.method,description:t.description,tags:t.tags,protocol:t.protocol},d=new Blob([JSON.stringify(c,null,2)],{type:"application/json"}),l=t.name||t.id;return{blob:d,filename:`${l}.json`}}const a=await rt(`${ra}/${t.id}/download`);if(!a.ok)throw a.status===401?new Error("Authentication required"):a.status===403?new Error("Access denied"):new Error(`HTTP error! status: ${a.status}`);const r=await a.blob(),n=a.headers.get("Content-Disposition"),i=n==null?void 0:n.match(/filename="?([^"]+)"?/),o=(i==null?void 0:i[1])||`${t.id}.json`;return{blob:r,filename:o}}async renameFixture(t,a){if(ds){await this.updateFixture(t,{name:a});return}return S(`${ra}/${t}/rename`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({new_name:a})})}async moveFixture(t,a){if(ds){await this.updateFixture(t,{path:a});return}return S(`${ra}/${t}/move`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({new_path:a})})}}const fi=Yt();class bh{async getDashboard(){return fi?S("/api/v1/dashboard"):rr("/__mockforge/dashboard",oh)}async getHealth(){return S(fi?"/api/v1/dashboard/health":"/__mockforge/health")}}class vh{async getServerInfo(){return S("/__mockforge/server-info")}async restartServer(t){return S("/__mockforge/restart",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({reason:t||"Manual restart"})})}async getRestartStatus(){return S("/__mockforge/restart/status")}}const _o=Yt(),jh=_o?"/api/v1/services":"/__mockforge/routes";class kh{async getRoutes(){return _o?[]:S(jh)}}const Ts="/api/v1/services";class wh{constructor(){this.list=this.list.bind(this),this.get=this.get.bind(this),this.create=this.create.bind(this),this.update=this.update.bind(this),this.remove=this.remove.bind(this)}async list(t){const a=t!=null&&t.workspaceId?`${Ts}?workspace_id=${encodeURIComponent(t.workspaceId)}`:Ts;return S(a)}async get(t){return S(`${Ts}/${t}`)}async create(t){return S(Ts,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async update(t,a){return S(`${Ts}/${t}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})}async remove(t){await S(`${Ts}/${t}`,{method:"DELETE"})}}const vy=new wh;class Nh{constructor(){this.getLogs=this.getLogs.bind(this),this.clearLogs=this.clearLogs.bind(this)}async getLogs(t){let a="/__mockforge/logs";if(t&&Object.keys(t).length>0){const r={};for(const[n,i]of Object.entries(t))i!=null&&(r[n]=String(i));Object.keys(r).length>0&&(a=`/__mockforge/logs${"?"+new URLSearchParams(r).toString()}`)}return rr(a,ih)}async clearLogs(){return S("/__mockforge/logs",{method:"DELETE"})}}class _h{constructor(){this.getMetrics=this.getMetrics.bind(this)}async getMetrics(){return S("/__mockforge/metrics")}}class Sh{async getConfig(){return S("/__mockforge/config")}async updateLatency(t){return S("/__mockforge/config/latency",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({config_type:"latency",data:t})})}async updateFaults(t){return S("/__mockforge/config/faults",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({config_type:"faults",data:t})})}async updateProxy(t){return S("/__mockforge/config/proxy",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({config_type:"proxy",data:t})})}async updateProtocols(t){return S("/__mockforge/config/protocols",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({config_type:"protocols",data:t})})}}class Ch{async getValidation(){return S("/__mockforge/validation")}async updateValidation(t){return S("/__mockforge/validation",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}}class Th{async getEnvVars(){return S("/__mockforge/env")}async updateEnvVar(t,a){return S("/__mockforge/env",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:t,value:a})})}}class Ph{async getFileContent(t){return S("/__mockforge/files/content",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async saveFileContent(t){return S("/__mockforge/files/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}}class Eh{async getSmokeTests(){return S("/__mockforge/smoke")}async runSmokeTests(){return S("/__mockforge/smoke/run",{method:"GET"})}}class Ah{async getChaosConfig(){return S("/api/chaos/config")}async getChaosStatus(){return S("/api/chaos/status")}async updateChaosLatency(t){return S("/api/chaos/config/latency",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async updateChaosFaults(t){return S("/api/chaos/config/faults",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async updateChaosTraffic(t){return S("/api/chaos/config/traffic",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async enableChaos(){return S("/api/chaos/enable",{method:"POST"})}async disableChaos(){return S("/api/chaos/disable",{method:"POST"})}async resetChaos(){return S("/api/chaos/reset",{method:"POST"})}async getLatencyMetrics(){return S("/api/chaos/metrics/latency")}async getLatencyStats(){return S("/api/chaos/metrics/latency/stats")}async getNetworkProfiles(){return S("/api/chaos/profiles")}async getNetworkProfile(t){return S(`/api/chaos/profiles/${encodeURIComponent(t)}`)}async applyNetworkProfile(t){return S(`/api/chaos/profiles/${encodeURIComponent(t)}/apply`,{method:"POST"})}async createNetworkProfile(t){return S("/api/chaos/profiles",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async deleteNetworkProfile(t){return S(`/api/chaos/profiles/${encodeURIComponent(t)}`,{method:"DELETE"})}async exportNetworkProfile(t,a="json"){const r=await rt(`/api/chaos/profiles/${encodeURIComponent(t)}/export?format=${a}`);if(!r.ok)throw r.status===401?new Error("Authentication required"):r.status===403?new Error("Access denied"):new Error(`HTTP error! status: ${r.status}`);return a==="yaml"?r.text():r.json()}async importNetworkProfile(t,a){return S("/api/chaos/profiles/import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:t,format:a})})}async updateErrorPattern(t){const r=(await this.getChaosConfig()).fault_injection||{};return r.error_pattern=t,this.updateChaosFaults(r)}}class Oh{async getStatus(){return ke("/__mockforge/time-travel/status")}async enable(t,a){return ke("/__mockforge/time-travel/enable",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({time:t,scale:a})})}async disable(){return ke("/__mockforge/time-travel/disable",{method:"POST"})}async advance(t){return ke("/__mockforge/time-travel/advance",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({duration:t})})}async setTime(t){return ke("/__mockforge/time-travel/set",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({time:t})})}async setScale(t){return ke("/__mockforge/time-travel/scale",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scale:t})})}async reset(){return ke("/__mockforge/time-travel/reset",{method:"POST"})}async listCronJobs(){return ke("/__mockforge/time-travel/cron")}async getCronJob(t){return ke(`/__mockforge/time-travel/cron/${t}`)}async createCronJob(t){return ke("/__mockforge/time-travel/cron",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async deleteCronJob(t){return ke(`/__mockforge/time-travel/cron/${t}`,{method:"DELETE"})}async setCronJobEnabled(t,a){return ke(`/__mockforge/time-travel/cron/${t}/enable`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:a})})}async listMutationRules(){return ke("/__mockforge/time-travel/mutations")}async getMutationRule(t){return ke(`/__mockforge/time-travel/mutations/${t}`)}async createMutationRule(t){return ke("/__mockforge/time-travel/mutations",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async deleteMutationRule(t){return ke(`/__mockforge/time-travel/mutations/${t}`,{method:"DELETE"})}async setMutationRuleEnabled(t,a){return ke(`/__mockforge/time-travel/mutations/${t}/enable`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:a})})}}class Ih{async getRealityLevel(){return ke("/__mockforge/reality/level")}async setRealityLevel(t){return ke("/__mockforge/reality/level",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({level:t})})}async listPresets(){return ke("/__mockforge/reality/presets")}async importPreset(t){return ke("/__mockforge/reality/presets/import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t})})}async exportPreset(t,a){return ke("/__mockforge/reality/presets/export",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:t,description:a})})}}class Mh{async listLifecyclePresets(){return ke("/api/v1/consistency/lifecycle-presets")}async getLifecyclePresetDetails(t){return ke(`/api/v1/consistency/lifecycle-presets/${encodeURIComponent(t)}`)}async applyLifecyclePreset(t,a,r){return ke(`/api/v1/consistency/lifecycle-presets/apply?workspace=${encodeURIComponent(t)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({persona_id:a,preset:r})})}async listEntities(t="default"){return ke(`/api/v1/consistency/entities?workspace=${encodeURIComponent(t)}`)}async getEntity(t,a,r="default"){return ke(`/api/v1/consistency/entities/${encodeURIComponent(t)}/${encodeURIComponent(a)}?workspace=${encodeURIComponent(r)}`)}}class Rh{async listSnapshots(t="default"){return ke(`/api/v1/snapshots?workspace=${encodeURIComponent(t)}`)}async saveSnapshot(t,a="default",r){return ke(`/api/v1/snapshots?workspace=${encodeURIComponent(a)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:t,description:r})})}async loadSnapshot(t,a="default"){return ke(`/api/v1/snapshots/${encodeURIComponent(t)}/load?workspace=${encodeURIComponent(a)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})})}async deleteSnapshot(t,a="default"){return ke(`/api/v1/snapshots/${encodeURIComponent(t)}?workspace=${encodeURIComponent(a)}`,{method:"DELETE"})}async getSnapshotInfo(t,a="default"){return ke(`/api/v1/snapshots/${encodeURIComponent(t)}?workspace=${encodeURIComponent(a)}`)}}class Lh{async getPlugins(t){const a=new URLSearchParams;t!=null&&t.type&&a.append("type",t.type),t!=null&&t.status&&a.append("status",t.status);const r=a.toString()?`?${a.toString()}`:"";return S(`/__mockforge/plugins${r}`)}async getPluginStatus(){return S("/__mockforge/plugins/status")}async getPluginDetails(t){return S(`/__mockforge/plugins/${t}`)}async deletePlugin(t){return S(`/__mockforge/plugins/${t}`,{method:"DELETE"})}async reloadPlugin(t){return S("/__mockforge/plugins/reload",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({plugin_id:t})})}async reloadAllPlugins(){const{plugins:t}=await this.getPlugins(),r=(await Promise.allSettled(t.map(n=>this.reloadPlugin(n.id)))).filter(n=>n.status==="rejected").length;if(r>0)throw new Error(`Failed to reload ${r} plugin(s)`);return{message:`Successfully reloaded ${t.length} plugin(s)`}}}class $h{async verify(t,a){return Ys("/__mockforge/verification/verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pattern:t,expected:a})})}async count(t){return Ys("/__mockforge/verification/count",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pattern:t})})}async verifySequence(t){return Ys("/__mockforge/verification/sequence",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({patterns:t})})}async verifyNever(t){return Ys("/__mockforge/verification/never",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async verifyAtLeast(t,a){return Ys("/__mockforge/verification/at-least",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pattern:t,min:a})})}}class Fh{async uploadRequest(t){const a=await rt("/__mockforge/contract-diff/upload",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),r=await a.json();if(!a.ok)throw new Error(r.error||`HTTP error! status: ${a.status}`);return r}async getCapturedRequests(t){const a=new URLSearchParams;t&&Object.entries(t).forEach(([n,i])=>{i!==void 0&&a.append(n,String(i))});const r=`/__mockforge/contract-diff/captures${a.toString()?`?${a}`:""}`;return Qs(r)}async getCapturedRequest(t){return Qs(`/__mockforge/contract-diff/captures/${t}`)}async analyzeCapturedRequest(t,a){return Qs(`/__mockforge/contract-diff/captures/${t}/analyze`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})}async getStatistics(){return Qs("/__mockforge/contract-diff/statistics")}async generatePatchFile(t,a){return Qs(`/__mockforge/contract-diff/captures/${t}/patch`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})}}class Dh{async getProxyRules(){return $e("/__mockforge/api/proxy/rules")}async getProxyRule(t){return $e(`/__mockforge/api/proxy/rules/${t}`)}async createProxyRule(t){return $e("/__mockforge/api/proxy/rules",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async updateProxyRule(t,a){return $e(`/__mockforge/api/proxy/rules/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})}async deleteProxyRule(t){return $e(`/__mockforge/api/proxy/rules/${t}`,{method:"DELETE"})}async getProxyInspect(t){const a=t?`/__mockforge/api/proxy/inspect?limit=${t}`:"/__mockforge/api/proxy/inspect";return $e(a)}async listPlaygroundEndpoints(t){const a=t?`/?workspace_id=${encodeURIComponent(t)}`:"";return $e(`/__mockforge/playground/endpoints${a}`)}async executeRestRequest(t){return $e("/__mockforge/playground/execute",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async executeGraphQLQuery(t){return $e("/__mockforge/playground/graphql",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async graphQLIntrospect(){return $e("/__mockforge/playground/graphql/introspect")}async getPlaygroundHistory(t){const a=new URLSearchParams;t!=null&&t.limit&&a.append("limit",t.limit.toString()),t!=null&&t.protocol&&a.append("protocol",t.protocol),t!=null&&t.workspace_id&&a.append("workspace_id",t.workspace_id);const r=a.toString()?`/__mockforge/playground/history?${a.toString()}`:"/__mockforge/playground/history";return $e(r)}async replayRequest(t){return $e(`/__mockforge/playground/history/${t}/replay`,{method:"POST"})}async generateCodeSnippet(t){return $e("/__mockforge/playground/snippets",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async getFlows(t){const a=new URLSearchParams;t!=null&&t.limit&&a.append("limit",t.limit.toString()),t!=null&&t.db_path&&a.append("db_path",t.db_path);const r=a.toString()?`/__mockforge/flows?${a.toString()}`:"/__mockforge/flows",n=await $e(r);if(!n.success||!n.data)throw new Error(n.error||"Failed to fetch flows");return n.data}async getFlow(t,a){const r=new URLSearchParams;a!=null&&a.db_path&&r.append("db_path",a.db_path);const n=r.toString()?`/__mockforge/flows/${t}?${r.toString()}`:`/__mockforge/flows/${t}`,i=await $e(n);if(!i.success||!i.data)throw new Error(i.error||"Failed to fetch flow");return i.data}async tagFlow(t,a,r){const n=new URLSearchParams;r!=null&&r.db_path&&n.append("db_path",r.db_path);const i=n.toString()?`/__mockforge/flows/${t}/tag?${n.toString()}`:`/__mockforge/flows/${t}/tag`,o=await $e(i,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(!o.success||!o.data)throw new Error(o.error||"Failed to tag flow");return o.data}async compileFlow(t,a,r){const n=new URLSearchParams;r!=null&&r.db_path&&n.append("db_path",r.db_path);const i=n.toString()?`/__mockforge/flows/${t}/compile?${n.toString()}`:`/__mockforge/flows/${t}/compile`,o=await $e(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(!o.success||!o.data)throw new Error(o.error||"Failed to compile flow");return o.data}async getScenarios(t){const a=new URLSearchParams;t!=null&&t.limit&&a.append("limit",t.limit.toString()),t!=null&&t.db_path&&a.append("db_path",t.db_path);const r=a.toString()?`/__mockforge/scenarios?${a.toString()}`:"/__mockforge/scenarios",n=await $e(r);if(!n.success||!n.data)throw new Error(n.error||"Failed to fetch scenarios");return n.data}async getScenario(t,a){const r=new URLSearchParams;a!=null&&a.db_path&&r.append("db_path",a.db_path);const n=r.toString()?`/__mockforge/scenarios/${t}?${r.toString()}`:`/__mockforge/scenarios/${t}`,i=await $e(n);if(!i.success||!i.data)throw new Error(i.error||"Failed to fetch scenario");return i.data}async exportScenario(t,a="yaml",r){const n=new URLSearchParams;n.append("format",a),r!=null&&r.db_path&&n.append("db_path",r.db_path);const i=`/__mockforge/scenarios/${t}/export?${n.toString()}`,o=await $e(i);if(!o.success||!o.data)throw new Error(o.error||"Failed to export scenario");return o.data.content}}const lt=new xh,zh=new ph,Pa=new yh,xa=new Dh,qh=new bh,pa=new vh,Uh=new kh,Bh=new Nh,Vh=new _h,Js=new Sh,hn=new Ch,Kh=new Th,Jh=new Ph,Hh=new Eh,Wh=new Lh,Gh=new Ah,Ot=new Oh,fa=new Ih,Zh=new Mh,Ea=new Rh,jy=new $h,ky=new Fh;Pe.info("API Services initialized",{apiService:!!lt,importApi:!!zh,fixturesApi:!!Pa,fixturesApiGetFixtures:typeof(Pa==null?void 0:Pa.getFixtures),dashboardApi:!!qh,serverApi:!!pa,routesApi:!!Uh,logsApi:!!Bh,metricsApi:!!Vh,configApi:!!Js,validationApi:!!hn,envApi:!!Kh,filesApi:!!Jh,smokeTestsApi:!!Hh,pluginsApi:!!Wh,chaosApi:!!Gh,timeTravelApi:!!Ot});const yi=!1,wy=[{id:"user-service",name:"User Service",baseUrl:"http://localhost:3000",enabled:!0,tags:["api","users"],description:"Handles user authentication and profile management",createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),routes:[{id:"user-service-get-users",method:"GET",path:"/api/users",statusCode:200,priority:1,has_fixtures:!0,request_count:234,error_count:2,latency_ms:45,enabled:!0,service_id:"user-service",tags:["api","users"]},{id:"user-service-post-users",method:"POST",path:"/api/users",statusCode:201,priority:1,has_fixtures:!0,request_count:89,error_count:0,latency_ms:67,enabled:!0,service_id:"user-service",tags:["api","users"]},{id:"user-service-get-user-id",method:"GET",path:"/api/users/{id}",statusCode:200,priority:1,has_fixtures:!0,request_count:156,error_count:1,latency_ms:32,enabled:!1,service_id:"user-service",tags:["api","users"]}]},{id:"order-service",name:"Order Service",baseUrl:"http://localhost:3001",enabled:!0,tags:["api","orders","ecommerce"],description:"Manages orders and order processing",createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),routes:[{id:"order-service-get-orders",method:"GET",path:"/api/orders",statusCode:200,priority:1,has_fixtures:!0,request_count:445,error_count:5,latency_ms:78,enabled:!0,service_id:"order-service",tags:["api","orders"]},{id:"order-service-post-orders",method:"POST",path:"/api/orders",statusCode:201,priority:1,has_fixtures:!0,request_count:123,error_count:3,latency_ms:234,enabled:!0,service_id:"order-service",tags:["api","orders"]}]},{id:"grpc-inventory",name:"Inventory gRPC",baseUrl:"grpc://localhost:50051",enabled:!1,tags:["grpc","inventory"],description:"gRPC service for inventory management",createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),routes:[{id:"grpc-inventory-get-item",method:"GRPC",path:"inventory.InventoryService/GetItem",statusCode:0,priority:1,has_fixtures:!1,request_count:67,error_count:0,latency_ms:23,enabled:!1,service_id:"grpc-inventory",tags:["grpc","inventory"]},{id:"grpc-inventory-update-stock",method:"GRPC",path:"inventory.InventoryService/UpdateStock",statusCode:0,priority:1,has_fixtures:!1,request_count:34,error_count:1,latency_ms:56,enabled:!1,service_id:"grpc-inventory",tags:["grpc","inventory"]}]}],Ps=(s,t)=>{const a=s.flatMap(o=>o.routes.map(c=>({...c})));if(!t)return a;const{caseSensitive:r,regexEnabled:n}=et.getState().preferences.search;let i;if(n)try{const o=new RegExp(t,r?"":"i");i=c=>o.test(c)}catch{const o=r?t:t.toLowerCase();i=c=>(r?c:c.toLowerCase()).includes(o)}else{const o=r?t:t.toLowerCase();i=c=>(r?c:c.toLowerCase()).includes(o)}return a.filter(o=>(o.method?i(o.method):!1)||i(o.path)||(o.tags?o.tags.some(c=>i(c)):!1))},Qh=!1,Yh=s=>s.method?`${s.method}-${s.path}`:s.path;const Xh=At((s,t)=>({services:[],filteredRoutes:[],isLoading:!1,error:null,isCloud:yi,mutationError:null,workspaceFilter:null,setServices:a=>s({services:a,filteredRoutes:Ps(a)}),setWorkspaceFilter:async a=>{s({workspaceFilter:a}),await t().fetchServices({workspaceId:a})},fetchServices:async a=>{s({isLoading:!0,error:null});try{const r=await rt("/__mockforge/routes");if(!r.ok)throw new Error(`Failed to fetch routes: ${r.statusText}`);const n=await r.json(),i=Array.isArray(n)?n:n.data||[],o=new Map;for(const d of i){const l=(d.path||"").split("/").filter(Boolean),m=l[1]||l[0]||"default",g=`${m}-service`;o.has(g)||o.set(g,{id:g,name:m.charAt(0).toUpperCase()+m.slice(1)+" Service",baseUrl:window.location.origin,enabled:!0,tags:[],description:`Routes for ${m}`,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),routes:[]}),o.get(g).routes.push({id:`${g}-${d.method}-${d.path}`.replace(/[^a-zA-Z0-9-]/g,"-"),method:d.method||"ANY",path:d.path||"/",statusCode:d.status_code||200,priority:d.priority||1,has_fixtures:d.has_fixtures||!1,request_count:d.request_count||0,error_count:d.error_count||0,latency_ms:d.latency_ms||0,enabled:d.enabled!==!1,service_id:g,tags:d.tags||[]})}const c=Array.from(o.values());c.length===0&&Qh||s({services:c,filteredRoutes:Ps(c),isLoading:!1})}catch(r){const n=r instanceof Error?r.message:"Failed to fetch services";Pe.error("Failed to fetch services",r),s({services:[],filteredRoutes:[],error:n,isLoading:!1})}},clearError:()=>s({error:null}),clearMutationError:()=>s({mutationError:null}),updateService:async(a,r)=>{s(n=>({services:n.services.map(i=>i.id===a?{...i,...r}:i)}))},updateServiceDetails:async(a,r)=>{{s({mutationError:"Editing service details requires cloud mode."});return}},toggleRoute:async(a,r,n)=>{const o=t().services.map(c=>c.id===a?{...c,routes:c.routes.map(d=>Yh(d)===r?{...d,enabled:n}:d)}:c);s({services:o,filteredRoutes:Ps(o)})},addService:a=>s(r=>{const n=[...r.services,a];return{services:n,filteredRoutes:Ps(n)}}),createService:async a=>{throw new Error("Creating services requires cloud mode.")},removeService:async a=>{t().services,s(r=>{const n=r.services.filter(i=>i.id!==a);return{services:n,filteredRoutes:Ps(n)}})},setGlobalSearch:a=>s(r=>({filteredRoutes:Ps(r.services,a)}))}));function So({shortcuts:s=[],element:t=null,enabled:a=!0,capture:r=!1}={}){const[n,i]=h.useState(a),o=h.useRef(s);h.useEffect(()=>{o.current=s},[s]);const c=h.useCallback(u=>{if(!n)return;const p=u,f=o.current.filter(j=>j.enabled!==!1);for(const j of f){if(!j.key)continue;if(p.key.toLowerCase()===j.key.toLowerCase()&&!!p.ctrlKey==!!j.ctrl&&!!p.shiftKey==!!j.shift&&!!p.altKey==!!j.alt&&!!p.metaKey==!!j.meta){j.preventDefault!==!1&&p.preventDefault(),j.stopPropagation&&p.stopPropagation(),j.handler(p);break}}},[n]);h.useEffect(()=>{const u=t||document;if(!(!n||!u))return u.addEventListener("keydown",c,r),()=>{u.removeEventListener("keydown",c,r)}},[t,n,c,r]);const d=h.useCallback(u=>{o.current=[...o.current,u]},[]),l=h.useCallback((u,p)=>{o.current=o.current.filter(f=>f.key.toLowerCase()!==u.toLowerCase()?!0:p?!(!!f.ctrl==!!p.ctrl&&!!f.shift==!!p.shift&&!!f.alt==!!p.alt&&!!f.meta==!!p.meta):!1)},[]),m=h.useCallback(()=>i(!0),[]),g=h.useCallback(()=>i(!1),[]),y=h.useCallback(()=>i(u=>!u),[]);return{addShortcut:d,removeShortcut:l,enable:m,disable:g,toggle:y,isEnabled:n}}function e0(s={}){const t=[];return s.onSearch&&t.push({key:"k",ctrl:!0,handler:s.onSearch,description:"Search"}),s.onHelp&&t.push({key:"?",shift:!0,handler:s.onHelp,description:"Help"}),s.onSettings&&t.push({key:",",ctrl:!0,handler:s.onSettings,description:"Settings"}),s.onToggleSidebar&&t.push({key:"b",ctrl:!0,handler:s.onToggleSidebar,description:"Toggle sidebar"}),s.onNewItem&&t.push({key:"n",ctrl:!0,handler:s.onNewItem,description:"New item"}),s.onSave&&t.push({key:"s",ctrl:!0,handler:s.onSave,description:"Save"}),s.onUndo&&t.push({key:"z",ctrl:!0,handler:s.onUndo,description:"Undo"}),s.onRedo&&t.push({key:"y",ctrl:!0,handler:s.onRedo,description:"Redo"}),s.onCopy&&t.push({key:"c",ctrl:!0,handler:s.onCopy,description:"Copy"}),s.onPaste&&t.push({key:"v",ctrl:!0,handler:s.onPaste,description:"Paste"}),s.onCut&&t.push({key:"x",ctrl:!0,handler:s.onCut,description:"Cut"}),s.onSelectAll&&t.push({key:"a",ctrl:!0,handler:s.onSelectAll,description:"Select all"}),So({shortcuts:t,enabled:s.enabled})}function t0(){const s=h.useCallback(a=>{const r=document.getElementById(a);r&&(r.focus(),r.scrollIntoView({behavior:"smooth",block:"start"}))},[]),t=h.useCallback((a,r)=>({href:`#${a}`,onClick:n=>{n.preventDefault(),s(a)},onKeyDown:n=>{(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),s(a))},children:r,className:"sr-only focus:not-sr-only focus:absolute focus:top-0 focus:left-0 focus:z-50 focus:p-4 focus:bg-background focus:text-foreground focus:border focus:border-border focus:rounded-md"}),[s]);return{skipToContent:s,createSkipLink:t}}const s0={"app.brand":"MockForge","app.home":"Home","app.refresh":"Refresh","app.loading":"Loading...","app.pageNotFoundTitle":"Page Not Found","app.pageNotFoundBody":"The page you're looking for doesn't exist yet.","app.goToDashboard":"Go to Dashboard","app.searchPlaceholder":"Global search…","a11y.skipNavigation":"Skip to navigation","a11y.skipMain":"Skip to main content","a11y.skipSearch":"Skip to search","a11y.mainNavigation":"Main navigation","a11y.mainContent":"Main content","a11y.collapseSidebar":"Collapse sidebar","a11y.expandSidebar":"Expand sidebar","a11y.searchScope":"Search scope","search.scope.all":"All","search.scope.current":"Current page","search.scope.logs":"Logs only","search.scope.services":"Services only","nav.core":"Core","nav.servicesData":"Services & Data","nav.protocolBrokers":"Protocol Brokers","nav.orchestration":"Orchestration","nav.observability":"Observability","nav.testing":"Testing","nav.chaosResilience":"Chaos & Resilience","nav.importTemplates":"Import & Templates","nav.aiIntelligence":"AI & Intelligence","nav.community":"Community","nav.plugins":"Plugins","nav.configuration":"Configuration","nav.help":"Help","tab.dashboard":"Dashboard","tab.workspaces":"Workspaces","tab.federation":"Federation","tab.services":"Services","tab.virtualBackends":"Virtual Backends","tab.fixtures":"Fixtures","tab.hostedMocks":"Hosted Mocks","tab.apiExplorer":"API Explorer","tab.tunnels":"Tunnels","tab.proxyInspector":"Proxy Inspector","tab.smtpMailbox":"SMTP Mailbox","tab.mqttBroker":"MQTT Broker","tab.kafkaBroker":"Kafka Broker","tab.faq":"FAQ","tab.support":"Support","tab.chains":"Chains","tab.graph":"Graph","tab.stateMachines":"State Machines","tab.scenarioStudio":"Scenario Studio","tab.orchestrationBuilder":"Orchestration Builder","tab.orchestrationExecution":"Orchestration Execution","tab.observability":"Observability","tab.worldState":"World State","tab.performance":"Performance","tab.systemStatus":"System Status","tab.incidents":"Incidents","tab.logs":"Logs","tab.traces":"Traces","tab.metrics":"Metrics","tab.analytics":"Analytics","tab.pillarAnalytics":"Pillar Analytics","tab.fitnessFunctions":"Fitness Functions","tab.verification":"Verification","tab.contractDiff":"Contract Diff","tab.testing":"Testing","tab.testGenerator":"Test Generator","tab.testExecution":"Test Execution","tab.integrationTests":"Integration Tests","tab.conformance":"Conformance","tab.timeTravel":"Time Travel","tab.chaosEngineering":"Chaos Engineering","tab.resilience":"Resilience","tab.recorder":"Recorder","tab.behavioralCloning":"Behavioral Cloning","tab.import":"Import","tab.templateMarketplace":"Template Marketplace","tab.scenarioMarketplace":"Scenario Marketplace","tab.aiStudio":"AI Studio","tab.mockai":"MockAI","tab.mockaiOpenApiGenerator":"MockAI OpenAPI Generator","tab.mockaiRules":"MockAI Rules","tab.voiceLlm":"Voice + LLM","tab.showcase":"Showcase","tab.learningHub":"Learning Hub","tab.plugins":"Plugins","tab.pluginRegistry":"Plugin Registry","tab.config":"Config","tab.organization":"Organization","tab.billing":"Billing","tab.apiTokens":"API Tokens","tab.publisherKeys":"Publisher Keys","tab.byok":"BYOK Keys","tab.usage":"Plan & Usage","tab.userManagement":"User Management","nav.localOnly.badge":"Local","nav.localOnly.tooltip":"Requires a local MockForge instance","page.config.title":"Configuration","page.config.subtitle":"Manage MockForge settings and preferences","page.plugins.title":"Plugin Management","page.plugins.subtitle":"Manage authentication, template, response, and datasource plugins","page.plugins.error":"Error","page.plugins.marketplaceTitle":"Plugin Marketplace","page.plugins.marketplaceBody":"Browse and install plugins from the official marketplace","page.plugins.browseMarketplace":"Browse Marketplace","page.plugins.installPlugin":"Install Plugin","page.plugins.reloadAll":"Reload All","page.mockai.title":"MockAI","page.mockai.description":"AI-powered mock API intelligence for realistic, context-aware responses","page.mockai.quickActions":"Quick Actions","page.mockai.features":"Features"},a0={"app.brand":"MockForge","app.home":"Inicio","app.refresh":"Actualizar","app.loading":"Cargando...","app.pageNotFoundTitle":"Pagina no encontrada","app.pageNotFoundBody":"La pagina que buscas aun no existe.","app.goToDashboard":"Ir al panel","app.searchPlaceholder":"Busqueda global…","a11y.skipNavigation":"Saltar a navegacion","a11y.skipMain":"Saltar al contenido principal","a11y.skipSearch":"Saltar a busqueda","a11y.mainNavigation":"Navegacion principal","a11y.mainContent":"Contenido principal","a11y.collapseSidebar":"Contraer barra lateral","a11y.expandSidebar":"Expandir barra lateral","a11y.searchScope":"Ambito de busqueda","search.scope.all":"Todo","search.scope.current":"Pagina actual","search.scope.logs":"Solo registros","search.scope.services":"Solo servicios","nav.core":"Nucleo","nav.servicesData":"Servicios y Datos","nav.protocolBrokers":"Brokers de Protocolo","nav.orchestration":"Orquestacion","nav.observability":"Observabilidad","nav.testing":"Pruebas","nav.chaosResilience":"Caos y Resiliencia","nav.importTemplates":"Importar y Plantillas","nav.aiIntelligence":"IA e Inteligencia","nav.community":"Comunidad","nav.plugins":"Plugins","nav.configuration":"Configuracion","nav.help":"Ayuda","nav.localOnly.badge":"Local","nav.localOnly.tooltip":"Requiere una instancia local de MockForge"},bi={en:s0,es:a0},Co=h.createContext(void 0),Wa=["en"];function r0(){const s=localStorage.getItem("mockforge-locale");return(s==="en"||s==="es")&&Wa.includes(s)?s:Wa.includes("es")&&navigator.language.toLowerCase().startsWith("es")?"es":"en"}function n0(s){return Wa.includes(s)?s:"en"}function i0({children:s}){const[t,a]=h.useState(()=>r0()),r=i=>{const o=n0(i);localStorage.setItem("mockforge-locale",o),a(o)},n=h.useMemo(()=>({locale:t,supportedLocales:Wa,setLocale:r,t:(i,o)=>bi[t][i]??bi.en[i]??o??i}),[t]);return e.jsx(Co.Provider,{value:n,children:s})}function nr(){const s=h.useContext(Co);if(!s)throw new Error("useI18n must be used inside I18nProvider");return s}const o0={connected:{color:"bg-green-500",label:"Connected",icon:"wifi"},connecting:{color:"bg-yellow-500",label:"Connecting...",icon:"loader"},reconnecting:{color:"bg-yellow-500",label:"Reconnecting...",icon:"loader"},disconnected:{color:"bg-red-500",label:"Disconnected",icon:"wifi-off"},cloud:{color:"bg-blue-500",label:"Cloud",icon:"cloud"}};function l0({state:s,className:t,showLabel:a=!1,lastConnected:r}){const n=o0[s],i=n.icon==="wifi"?oa:n.icon==="wifi-off"?ln:n.icon==="cloud"?io:Is;return e.jsxs("div",{className:D("flex items-center gap-2",t),role:"status","aria-live":"polite",title:r?`Last connected: ${r.toLocaleTimeString()}`:n.label,children:[e.jsxs("span",{className:"relative flex h-2.5 w-2.5",children:[s==="connected"&&e.jsx("span",{className:D("animate-ping absolute inline-flex h-full w-full rounded-full opacity-75",n.color)}),e.jsx("span",{className:D("relative inline-flex rounded-full h-2.5 w-2.5",n.color)})]}),a&&e.jsxs("span",{className:"text-xs text-gray-600 dark:text-gray-400 flex items-center gap-1",children:[e.jsx(i,{className:D("h-3 w-3",(s==="connecting"||s==="reconnecting")&&"animate-spin")}),n.label]})]})}const c0=At(s=>({backendState:"connecting",wsState:"disconnected",hostedMockStreams:0,setBackendState:t=>s({backendState:t,lastBackendConnected:t==="connected"?new Date:void 0}),setWsState:t=>s({wsState:t,lastWsConnected:t==="connected"?new Date:void 0}),incrementHostedMockStreams:()=>s(t=>({hostedMockStreams:t.hostedMockStreams+1})),decrementHostedMockStreams:()=>s(t=>({hostedMockStreams:Math.max(0,t.hostedMockStreams-1)}))}));function d0({className:s}){const{backendState:t,wsState:a,hostedMockStreams:r}=c0(),n=a==="cloud"&&r>0?"connected":a,i=t==="disconnected"||n==="disconnected"?"disconnected":t==="connecting"||n==="connecting"?"connecting":t==="reconnecting"||n==="reconnecting"?"reconnecting":n==="cloud"?"cloud":"connected";return e.jsx(l0,{state:i,className:s,showLabel:i!=="connected"})}const To=[{titleKey:"nav.core",items:[{id:"dashboard",labelKey:"tab.dashboard",icon:As},{id:"workspaces",labelKey:"tab.workspaces",icon:bd},{id:"federation",labelKey:"tab.federation",icon:Au}]},{titleKey:"nav.servicesData",items:[{id:"services",labelKey:"tab.services",icon:Rr},{id:"virtual-backends",labelKey:"tab.virtualBackends",icon:Ms},{id:"fixtures",labelKey:"tab.fixtures",icon:gd},{id:"hosted-mocks",labelKey:"tab.hostedMocks",icon:io},{id:"tunnels",labelKey:"tab.tunnels",icon:oa},{id:"proxy-inspector",labelKey:"tab.proxyInspector",icon:sr}]},{titleKey:"nav.protocolBrokers",items:[{id:"smtp-mailbox",labelKey:"tab.smtpMailbox",icon:uo},{id:"mqtt-broker",labelKey:"tab.mqttBroker",icon:Wn},{id:"kafka-broker",labelKey:"tab.kafkaBroker",icon:Ms}]},{titleKey:"nav.orchestration",items:[{id:"chains",labelKey:"tab.chains",icon:Vd},{id:"graph",labelKey:"tab.graph",icon:yr},{id:"state-machine-editor",labelKey:"tab.stateMachines",icon:yr},{id:"scenario-studio",labelKey:"tab.scenarioStudio",icon:fd},{id:"orchestration-builder",labelKey:"tab.orchestrationBuilder",icon:yr},{id:"orchestration-execution",labelKey:"tab.orchestrationExecution",icon:Kn}]},{titleKey:"nav.observability",items:[{id:"observability",labelKey:"tab.observability",icon:ma},{id:"world-state",labelKey:"tab.worldState",icon:Hn},{id:"performance",labelKey:"tab.performance",icon:gs},{id:"status",labelKey:"tab.systemStatus",icon:lo},{id:"incidents",labelKey:"tab.incidents",icon:Dt},{id:"logs",labelKey:"tab.logs",icon:Rs},{id:"traces",labelKey:"tab.traces",icon:rn},{id:"metrics",labelKey:"tab.metrics",icon:gs},{id:"analytics",labelKey:"tab.analytics",icon:As},{id:"pillar-analytics",labelKey:"tab.pillarAnalytics",icon:mu},{id:"fitness-functions",labelKey:"tab.fitnessFunctions",icon:Ad},{id:"verification",labelKey:"tab.verification",icon:Me},{id:"contract-diff",labelKey:"tab.contractDiff",icon:_d}]},{titleKey:"nav.testing",items:[{id:"testing",labelKey:"tab.testing",icon:Uu},{id:"test-generator",labelKey:"tab.testGenerator",icon:Ir},{id:"test-execution",labelKey:"tab.testExecution",icon:Kn},{id:"integration-test-builder",labelKey:"tab.integrationTests",icon:Hn},{id:"conformance",labelKey:"tab.conformance",icon:Zt},{id:"time-travel",labelKey:"tab.timeTravel",icon:La}]},{titleKey:"nav.chaosResilience",items:[{id:"chaos",labelKey:"tab.chaosEngineering",icon:dt},{id:"resilience",labelKey:"tab.resilience",icon:Zt},{id:"recorder",labelKey:"tab.recorder",icon:Wn},{id:"behavioral-cloning",labelKey:"tab.behavioralCloning",icon:fs}]},{titleKey:"nav.importTemplates",items:[{id:"import",labelKey:"tab.import",icon:Rd},{id:"template-marketplace",labelKey:"tab.templateMarketplace",icon:Gn},{id:"scenario-marketplace",labelKey:"tab.scenarioMarketplace",icon:Gn}]},{titleKey:"nav.aiIntelligence",items:[{id:"ai-studio",labelKey:"tab.aiStudio",icon:Or},{id:"mockai",labelKey:"tab.mockai",icon:Or},{id:"mockai-openapi-generator",labelKey:"tab.mockaiOpenApiGenerator",icon:Ir},{id:"mockai-rules",labelKey:"tab.mockaiRules",icon:As},{id:"voice",labelKey:"tab.voiceLlm",icon:eu}]},{titleKey:"nav.community",items:[{id:"showcase",labelKey:"tab.showcase",icon:$u},{id:"learning-hub",labelKey:"tab.learningHub",icon:Nc}]},{titleKey:"nav.plugins",items:[{id:"plugins",labelKey:"tab.plugins",icon:yu},{id:"plugin-registry",labelKey:"tab.pluginRegistry",icon:lu}]},{titleKey:"nav.configuration",items:[{id:"config",labelKey:"tab.config",icon:Tt},{id:"organization",labelKey:"tab.organization",icon:Fr},{id:"billing",labelKey:"tab.billing",icon:ad},{id:"api-tokens",labelKey:"tab.apiTokens",icon:Gt},{id:"publisher-keys",labelKey:"tab.publisherKeys",icon:Gt},{id:"byok",labelKey:"tab.byok",icon:Ls},{id:"usage",labelKey:"tab.usage",icon:Oc},{id:"user-management",labelKey:"tab.userManagement",icon:Fr}]},{titleKey:"nav.help",items:[{id:"faq",labelKey:"tab.faq",icon:Mr},{id:"support",labelKey:"tab.support",icon:Ud}]}],u0=Yt(),m0=new Set(["dashboard","workspaces","federation","services","fixtures","hosted-mocks","template-marketplace","scenario-marketplace","plugin-registry","pillar-analytics","status","config","organization","billing","api-tokens","publisher-keys","byok","usage","faq","support"]),vi=To.map(s=>({...s,items:s.items.map(t=>({...t,localOnly:u0&&!m0.has(t.id)}))})),h0=[...To.flatMap(s=>s.items),{id:"api-explorer",labelKey:"tab.apiExplorer",icon:Ir}];function g0({children:s,onRefresh:t}){var ae;const{t:a,locale:r,supportedLocales:n,setLocale:i}=nr(),o=Li(),c=Xr(),d=o.pathname.replace(/^\//,"")||"dashboard",[l,m]=h.useState(!1),{setFilter:g}=jm(),{setGlobalSearch:y}=Xh(),[u,p]=h.useState(""),[f,j]=h.useState(!1),C=$a(U=>U.isOpen),T=$a(U=>U.open),N=$a(U=>U.setOpen),w=et(U=>U.preferences.ui.keyboardShortcuts),O=et(U=>U.preferences.ui.sidebarCollapsed),L=et(U=>U.updateUI),I=et(U=>U.preferences.search.defaultScope),[b,A]=h.useState(I??"all");M.useEffect(()=>{A(I??"all")},[I]);const _=U=>{const z=b==="all"||b==="logs"||b==="current",R=b==="all"||b==="services"||b==="current";g({path_pattern:z?U:void 0}),y(R?U:void 0)};e0({onSearch:()=>{const U=document.getElementById("global-search-input");U&&(U.focus(),U.select())},onHelp:()=>T(),enabled:w});const{createSkipLink:$}=t0();return M.useEffect(()=>{j(navigator.userAgent.toUpperCase().indexOf("MAC")>=0)},[]),e.jsxs("div",{className:"min-h-screen bg-bg-secondary",children:[e.jsxs("nav",{className:"sr-only focus-within:not-sr-only",children:[e.jsx("a",{...$("main-navigation",a("a11y.skipNavigation"))}),e.jsx("a",{...$("main-content",a("a11y.skipMain"))}),e.jsx("a",{...$("global-search-input",a("a11y.skipSearch"))})]}),l&&e.jsxs("div",{className:"fixed inset-0 z-50 md:hidden",children:[e.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm animate-fade-in",onClick:()=>m(!1)}),e.jsxs("aside",{className:"fixed left-0 top-0 h-full w-80 max-w-[90vw] bg-background border-r border-gray-200 dark:border-gray-800 shadow-2xl animate-slide-in-left",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-800 bg-card",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(zr,{variant:"icon",size:"md"}),e.jsx("span",{className:"text-xl font-bold text-gray-900 dark:text-gray-100",children:a("app.brand")})]}),e.jsx(k,{variant:"secondary",size:"sm",onClick:()=>m(!1),className:"h-10 w-10 p-0 rounded-full spring-hover",children:e.jsx(ha,{className:"h-5 w-5"})})]}),e.jsx("nav",{className:"p-6 space-y-6 overflow-y-auto h-[calc(100%-88px)]",children:vi.map((U,z)=>e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"px-2 text-xs font-semibold text-muted-foreground uppercase tracking-wider",children:a(U.titleKey)}),e.jsx("div",{className:"space-y-1",children:U.items.map((R,P)=>{const V=R.icon,v=R.localOnly;return e.jsxs(k,{variant:d===R.id?"default":"ghost",disabled:v,title:v?a("nav.localOnly.tooltip"):void 0,className:D("w-full justify-start gap-4 h-10 text-sm nav-item-hover focus-ring spring-hover","animate-slide-in-up",v?"text-muted-foreground/60 cursor-not-allowed opacity-70":d===R.id?"bg-brand-500 text-white shadow-md hover:bg-brand-600":"text-foreground/80 dark:text-gray-400 hover:text-foreground dark:hover:text-gray-100 hover:bg-muted/50"),style:{animationDelay:`${(z*5+P)*20}ms`},onClick:()=>{v||(c("/"+R.id),m(!1))},children:[e.jsx(V,{className:"h-4 w-4"}),e.jsx("span",{className:"flex-1 text-left",children:a(R.labelKey)}),v&&e.jsxs("span",{className:"flex items-center gap-1 rounded bg-muted px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:[e.jsx(Ls,{className:"h-3 w-3"}),a("nav.localOnly.badge")]})]},R.id)})})]},U.titleKey))})]})]}),e.jsxs("div",{className:"flex",children:[e.jsx("aside",{className:D("hidden md:flex md:flex-col md:fixed md:inset-y-0 md:z-50 overflow-hidden transition-[width] duration-200",O?"md:w-16":"md:w-64"),children:e.jsxs("div",{className:"flex flex-col flex-grow overflow-hidden bg-bg-primary border-r border-border",children:[e.jsxs("div",{className:"flex items-center gap-3 px-4 py-4 border-b border-border flex-shrink-0",children:[e.jsx(zr,{variant:"icon",size:"md"}),!O&&e.jsx("span",{className:"font-semibold text-gray-900 dark:text-gray-100",children:a("app.brand")}),e.jsx(k,{variant:"ghost",size:"sm",className:"ml-auto h-7 w-7 p-0",onClick:()=>L({sidebarCollapsed:!O}),"aria-label":a(O?"a11y.expandSidebar":"a11y.collapseSidebar"),title:a(O?"a11y.expandSidebar":"a11y.collapseSidebar"),children:O?e.jsx(Xa,{className:"h-4 w-4"}):e.jsx(Ya,{className:"h-4 w-4"})})]}),e.jsx("nav",{id:"main-navigation",className:"flex-1 px-2 py-6 space-y-6 overflow-y-auto",role:"navigation","aria-label":a("a11y.mainNavigation"),children:vi.map(U=>e.jsxs("div",{className:"space-y-2",children:[!O&&e.jsx("h3",{className:"px-3 text-xs font-semibold text-muted-foreground uppercase tracking-wider",children:a(U.titleKey)}),e.jsx("div",{className:"space-y-1",children:U.items.map(z=>{const R=z.icon,P=z.localOnly,V=a(z.labelKey);return e.jsxs(k,{variant:d===z.id?"default":"ghost",disabled:P,title:P?a("nav.localOnly.tooltip"):O?V:void 0,"aria-label":O?V:void 0,className:D("w-full h-9 transition-all duration-200 nav-item-hover focus-ring spring-hover",O?"justify-center px-0":"justify-start gap-3",P?"text-muted-foreground/60 cursor-not-allowed opacity-70":d===z.id?"bg-brand-600 text-white shadow-lg ring-1 ring-brand-200/60 dark:ring-brand-600/70 hover:bg-brand-700":"text-foreground/80 dark:text-gray-200 hover:text-foreground dark:hover:text-white hover:bg-muted/50 dark:hover:bg-white/5"),onClick:()=>{P||c("/"+z.id)},children:[e.jsx(R,{className:"h-4 w-4"}),!O&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"flex-1 text-left",children:V}),P&&e.jsxs("span",{className:"flex items-center gap-1 rounded bg-muted px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:[e.jsx(Ls,{className:"h-3 w-3"}),a("nav.localOnly.badge")]})]})]},z.id)})})]},U.titleKey))})]})}),e.jsxs("div",{className:D("flex flex-col flex-1 min-h-screen",O?"md:pl-16":"md:pl-64"),children:[e.jsx("header",{className:"sticky top-0 z-40 flex h-16 shrink-0 items-center border-b border-border bg-bg-primary shadow-sm",children:e.jsxs("div",{className:"w-full max-w-[1400px] mx-auto flex items-center gap-x-4 px-4 sm:gap-x-6 sm:px-6 lg:px-8",children:[e.jsx(k,{variant:"ghost",size:"sm",className:"md:hidden",onClick:()=>m(!0),children:e.jsx(Qd,{className:"h-5 w-5"})}),e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:a("app.home")}),e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"/"}),e.jsx("span",{className:"text-sm font-medium text-gray-900 dark:text-gray-100 truncate capitalize",children:a(((ae=h0.find(U=>U.id===d))==null?void 0:ae.labelKey)??"",d)})]}),e.jsx("div",{className:"flex flex-1"}),e.jsxs("div",{className:"hidden sm:flex w-80 relative items-center gap-1",children:[e.jsxs("select",{value:b,onChange:U=>{const z=U.target.value;if(A(z),u){const R=z==="all"||z==="logs"||z==="current",P=z==="all"||z==="services"||z==="current";g({path_pattern:R?u:void 0}),y(P?u:void 0)}},"aria-label":a("a11y.searchScope"),className:"h-9 rounded-md border border-border bg-bg-primary px-1.5 text-xs text-foreground",children:[e.jsx("option",{value:"all",children:a("search.scope.all")}),e.jsx("option",{value:"current",children:a("search.scope.current")}),e.jsx("option",{value:"logs",children:a("search.scope.logs")}),e.jsx("option",{value:"services",children:a("search.scope.services")})]}),e.jsxs("div",{className:"relative flex-1",children:[e.jsx(B,{placeholder:a("app.searchPlaceholder"),id:"global-search-input",value:u,onChange:U=>{const z=U.target.value;p(z),_(z||void 0)},onKeyDown:U=>{var z;U.key==="Escape"&&(p(""),_(void 0),(z=document.getElementById("global-search-input"))==null||z.blur())}}),e.jsx("span",{className:"pointer-events-none absolute right-2.5 top-1/2 -translate-y-1/2 text-[10px] text-gray-600 dark:text-gray-400 border border-border rounded px-1 py-0.5 bg-bg-primary",children:f?"⌘K":"Ctrl K"})]})]}),e.jsxs("div",{className:"flex items-center gap-x-4 lg:gap-x-6",children:[e.jsx(d0,{className:"hidden sm:flex"}),n.length>1&&e.jsx("select",{value:r,onChange:U=>i(U.target.value),className:"hidden sm:block h-9 rounded-md border border-border bg-bg-primary px-2 text-xs","aria-label":"Language",children:n.map(U=>e.jsx("option",{value:U,children:U.toUpperCase()},U))}),e.jsx(lm,{}),e.jsxs(k,{variant:"outline",size:"sm",onClick:t,className:"flex items-center gap-2",children:[e.jsx(st,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:a("app.refresh")})]}),e.jsx(ym,{})]})]})}),e.jsx("main",{id:"main-content",className:"flex-1",role:"main","aria-label":a("a11y.mainContent"),children:e.jsx("div",{className:"w-full max-w-[1400px] mx-auto px-6 py-6",children:s})})]})]}),e.jsx(bm,{open:C,onOpenChange:N})]})}const _t=He.isCloud();function x0({onSuccess:s}){const[t,a]=h.useState("login"),[r,n]=h.useState({username:"",email:"",password:""}),[i,o]=h.useState(!1),[c,d]=h.useState(""),{login:l,setAuthenticated:m}=Ct(),g=async u=>{u.preventDefault(),o(!0),d("");try{if(t==="register"&&_t){const p=await He.register(r.username,r.email,r.password);m(p.user,p.token,p.refresh_token),s==null||s()}else{const p=_t?r.email:r.username;await l(p,r.password),s==null||s()}}catch(p){d(p instanceof Error?p.message:"Authentication failed")}finally{o(!1)}},y=u=>{n({...r,...{admin:{username:"admin",email:"",password:"admin123"},viewer:{username:"viewer",email:"",password:"viewer123"}}[u]})};return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsxs("div",{className:"w-full max-w-md space-y-8",children:[e.jsxs("div",{className:"text-center space-y-4",children:[e.jsx("div",{className:"flex justify-center",children:e.jsx(zr,{variant:"full",size:"xl"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-3xl font-bold",children:_t?"MockForge Cloud":"Admin Dashboard"}),e.jsx("p",{className:"mt-2 text-muted-foreground",children:_t?t==="register"?"Create your account to get started":"Sign in to manage your mock APIs":"Sign in to access the admin dashboard"})]})]}),e.jsxs("div",{className:"bg-card border rounded-lg p-6 space-y-6",children:[e.jsxs("form",{onSubmit:g,className:"space-y-4",children:[_t&&t==="register"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"username",className:"text-sm font-medium",children:"Username"}),e.jsx(B,{id:"username",type:"text",value:r.username,onChange:u=>n(p=>({...p,username:u.target.value})),placeholder:"Choose a username",required:!0,autoComplete:"username"})]}),_t?e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"email",className:"text-sm font-medium",children:"Email"}),e.jsx(B,{id:"email",type:"email",value:r.email,onChange:u=>n(p=>({...p,email:u.target.value})),placeholder:"Enter your email",required:!0,autoComplete:"email"})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"username",className:"text-sm font-medium",children:"Username"}),e.jsx(B,{id:"username",type:"text",value:r.username,onChange:u=>n(p=>({...p,username:u.target.value})),placeholder:"Enter your username",required:!0,autoComplete:"username"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"password",className:"text-sm font-medium",children:"Password"}),e.jsx(B,{id:"password",type:"password",value:r.password,onChange:u=>n(p=>({...p,password:u.target.value})),placeholder:"Enter your password",required:!0,autoComplete:t==="register"?"new-password":"current-password"})]}),c&&e.jsx("div",{className:"text-sm text-destructive bg-destructive/10 border border-destructive/20 rounded p-3",children:c}),e.jsx(k,{type:"submit",className:"w-full",disabled:i||(_t?!r.email:!r.username)||!r.password||t==="register"&&!r.username,children:i?t==="register"?"Creating account...":"Signing in...":t==="register"?"Create Account":"Sign In"})]}),_t&&e.jsx("div",{className:"text-center text-sm",children:t==="login"?e.jsxs("p",{className:"text-muted-foreground",children:["Don't have an account?"," ",e.jsx("button",{type:"button",onClick:()=>{a("register"),d("")},className:"text-primary hover:underline font-medium",children:"Sign up"})]}):e.jsxs("p",{className:"text-muted-foreground",children:["Already have an account?"," ",e.jsx("button",{type:"button",onClick:()=>{a("login"),d("")},className:"text-primary hover:underline font-medium",children:"Sign in"})]})}),!_t&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-card px-2 text-muted-foreground",children:"Demo Accounts"})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(k,{variant:"outline",onClick:()=>y("admin"),className:"w-full",children:"Demo Admin"}),e.jsx(k,{variant:"outline",onClick:()=>y("viewer"),className:"w-full",children:"Demo Viewer"})]}),e.jsxs("div",{className:"text-xs text-muted-foreground text-center space-y-2",children:[e.jsxs("div",{children:[e.jsx("strong",{children:"Admin:"})," admin / admin123 (Full access)"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Viewer:"})," viewer / viewer123 (Read-only)"]})]})]})]}),e.jsx("div",{className:"text-center text-xs text-muted-foreground",children:_t?"MockForge Cloud — Mock any API in seconds":"MockForge Admin UI v2.0 — Powered by React & Shadcn UI"})]})})}const p0=Yt()?[]:["/registry-login","/registry-admin"],f0=["/terms","/privacy","/dpa","/pricing","/faq","/support","/verify-email","/waitlist"];function y0({children:s,requiredRole:t}){const a=Li(),{isAuthenticated:r,user:n,isLoading:i,checkAuth:o}=Ct(),[c,d]=h.useState(!1),l=p0.some(g=>a.pathname.startsWith(g)),m=f0.some(g=>a.pathname.startsWith(g));return h.useEffect(()=>{!l&&!m?o().finally(()=>d(!0)):d(!0)},[o,l,m]),l||m?e.jsx(e.Fragment,{children:s}):!c||i?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsxs("div",{className:"text-center space-y-4",children:[e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto","data-testid":"loading-spinner"}),e.jsx("div",{className:"text-muted-foreground",children:"Checking authentication..."})]})}):!r||!n?e.jsx(x0,{}):t&&!(n.role==="admin"||n.role===t)?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsxs("div",{className:"text-center space-y-4",children:[e.jsx("div",{className:"text-6xl",children:"🔒"}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold",children:"Access Denied"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:"You don't have permission to access this resource."}),e.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:["Required role: ",t," • Your role: ",n.role]})]})]})}):e.jsx(e.Fragment,{children:s})}function hs({type:s,variant:t,title:a,message:r,className:n,children:i}){const o=s||t||"info",c={success:ua,warning:Dt,error:tt,info:ia,destructive:tt,default:ia},d={success:"bg-green-50 border-green-200 text-green-800 dark:bg-green-900/20 dark:border-green-800 dark:text-green-400",warning:"bg-yellow-50 border-yellow-200 text-yellow-800 dark:bg-yellow-900/20 dark:border-yellow-800 dark:text-yellow-400",error:"bg-red-50 border-red-200 text-red-800 dark:bg-red-900/20 dark:border-red-800 dark:text-red-400",info:"bg-blue-50 border-blue-200 text-blue-800 dark:bg-blue-900/20 dark:border-blue-800 dark:text-blue-400",destructive:"bg-red-50 border-red-200 text-red-800 dark:bg-red-900/20 dark:border-red-800 dark:text-red-400",default:"bg-gray-50 border-gray-200 text-gray-800 dark:bg-gray-900/20 dark:border-gray-800 dark:text-gray-400"},l=c[o];return e.jsxs("div",{className:D("flex items-start gap-3 p-4 border rounded-xl transition-all duration-200 spring-in",d[o],n),children:[e.jsx(l,{className:"h-5 w-5 mt-0.5 flex-shrink-0 spring-hover"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[a&&e.jsx("h4",{className:"font-semibold text-sm",children:a}),r&&e.jsx("p",{className:"text-sm opacity-90 mt-1",children:r}),i]})]})}function pt({title:s,subtitle:t,icon:a,action:r,variant:n="default",padding:i="md",children:o,className:c,...d}){const l={default:"bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-800 shadow-sm",elevated:"bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-800 shadow-lg",outlined:"bg-white dark:bg-gray-900 border-2 border-gray-300 dark:border-gray-700"},m={none:"",sm:"p-4",md:"p-6",lg:"p-8"};return e.jsxs("div",{className:D("rounded-xl transition-all duration-200 hover:shadow-md animate-fade-in-scale","card-hover",l[n],c),...d,children:[(s||t||a||r)&&e.jsxs("div",{className:"flex items-center justify-between p-6 pb-0 mb-6",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[a&&e.jsx("div",{className:"p-2 rounded-lg bg-blue-50 dark:bg-blue-900/20 text-blue-600 dark:text-blue-400 flex-shrink-0",children:a}),e.jsxs("div",{className:"min-w-0",children:[s&&e.jsx("h3",{className:"font-semibold text-gray-900 dark:text-gray-100 truncate",children:s}),t&&e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 mt-1",children:t})]})]}),r&&e.jsx("div",{className:"flex-shrink-0",children:r})]}),e.jsx("div",{className:D(m[i],s?"":m[i]),children:o})]})}const Ny=pt;function _y({title:s,value:t,subtitle:a,icon:r,trend:n,className:i}){const o={up:"text-green-600 dark:text-green-400",down:"text-red-600 dark:text-red-400",neutral:"text-gray-600 dark:text-gray-400"};return e.jsx(pt,{className:i,children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-sm font-medium text-gray-600 dark:text-gray-400 truncate",children:s}),e.jsxs("div",{className:"flex items-baseline gap-2 mt-1",children:[e.jsx("p",{className:"text-3xl font-bold text-gray-900 dark:text-gray-100",children:typeof t=="number"?t.toLocaleString():t}),n&&e.jsx("span",{className:D("text-sm font-medium",o[n.direction]),children:n.value})]}),a&&e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mt-1",children:a})]}),r&&e.jsx("div",{className:"p-3 rounded-lg bg-blue-50 dark:bg-blue-900/20 text-blue-600 dark:text-blue-400 spring-hover",children:r})]})})}function Po({children:s,variant:t="default",size:a="md",className:r}){const n={default:"bg-gray-100 text-gray-800 dark:bg-gray-800 dark:text-gray-200",success:"bg-green-100 text-green-800 dark:bg-green-900/20 dark:text-green-400",warning:"bg-yellow-100 text-yellow-800 dark:bg-yellow-900/20 dark:text-yellow-400",error:"bg-red-100 text-red-800 dark:bg-red-900/20 dark:text-red-400",info:"bg-blue-100 text-blue-800 dark:bg-blue-900/20 dark:text-blue-400",outline:"border border-gray-300 text-gray-700 dark:border-gray-600 dark:text-gray-300",destructive:"bg-red-100 text-red-800 dark:bg-red-900/20 dark:text-red-400"},i={sm:"px-2 py-0.5 text-xs",md:"px-2.5 py-1 text-xs",lg:"px-3 py-1.5 text-sm"};return e.jsx("span",{className:D("inline-flex items-center font-medium rounded-full transition-colors duration-200",n[t],i[a],r),children:s})}const jr=Po;function Ga({title:s,subtitle:t,action:a,className:r}){return e.jsxs("div",{className:D("flex items-center justify-between py-6 border-b border-gray-200 dark:border-gray-800",r),children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"text-3xl font-bold text-gray-900 dark:text-gray-100 truncate",children:s}),t&&e.jsx("p",{className:"text-lg text-gray-600 dark:text-gray-400 mt-2",children:t})]}),a&&e.jsx("div",{className:"flex-shrink-0 ml-4",children:a})]})}function Lt({title:s,subtitle:t,action:a,className:r,children:n}){return e.jsxs("section",{className:D("py-8",r),children:[(s||t||a)&&e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsxs("div",{className:"min-w-0",children:[s&&e.jsx("h2",{className:"text-2xl font-bold text-gray-900 dark:text-gray-100",children:s}),t&&e.jsx("p",{className:"text-base text-gray-600 dark:text-gray-400 mt-1",children:t})]}),a&&e.jsx("div",{className:"flex-shrink-0",children:a})]}),n]})}function Sy({icon:s,title:t,description:a,action:r,className:n}){return e.jsxs("div",{className:D("flex flex-col items-center justify-center py-12 px-4 text-center",n),children:[s&&e.jsx("div",{className:"p-4 rounded-full bg-gray-100 dark:bg-gray-800 text-gray-400 dark:text-gray-500 mb-4",children:s}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 mb-2",children:t}),a&&e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 mb-6 max-w-md",children:a}),r&&e.jsx("div",{children:r})]})}function Gr({children:s,variant:t="primary",size:a="md",className:r,loading:n,disabled:i,...o}){const c={primary:"bg-blue-600 hover:bg-blue-700 text-white shadow-sm hover:shadow-lg hover:-translate-y-0.5 active:translate-y-0 active:shadow-sm",secondary:"bg-gray-100 hover:bg-gray-200 text-gray-900 dark:bg-gray-800 dark:hover:bg-gray-700 dark:text-gray-100 hover:shadow-md hover:-translate-y-0.5 active:translate-y-0 active:shadow-sm",danger:"bg-red-600 hover:bg-red-700 text-white shadow-sm hover:shadow-lg hover:-translate-y-0.5 active:translate-y-0 active:shadow-sm",success:"bg-green-600 hover:bg-green-700 text-white shadow-sm hover:shadow-lg hover:-translate-y-0.5 active:translate-y-0 active:shadow-sm",outline:"border border-gray-300 dark:border-gray-700 bg-transparent hover:bg-gray-50 dark:hover:bg-gray-800 text-gray-700 dark:text-gray-300",ghost:"bg-transparent hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-700 dark:text-gray-300",destructive:"bg-red-600 hover:bg-red-700 text-white shadow-sm hover:shadow-lg hover:-translate-y-0.5 active:translate-y-0 active:shadow-sm"},d={sm:"px-3 py-1.5 text-sm",md:"px-4 py-2 text-base",lg:"px-6 py-3 text-lg"};return e.jsxs("button",{className:D("inline-flex items-center justify-center font-medium rounded-lg transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 disabled:opacity-50 disabled:cursor-not-allowed",c[t],d[a],r),disabled:i||n,...o,children:[n&&e.jsxs("svg",{className:"animate-spin -ml-1 mr-2 h-4 w-4",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.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"})]}),s]})}function kr({children:s,onClick:t,className:a}){return e.jsx("div",{onClick:t,className:a,children:s})}const b0={xs:"h-3 w-3",sm:"h-4 w-4",md:"h-5 w-5",lg:"h-6 w-6",xl:"h-8 w-8","2xl":"h-10 w-10","3xl":"h-12 w-12"},v0={default:"text-secondary",primary:"text-primary",brand:"text-brand",success:"text-success",warning:"text-warning",danger:"text-danger",muted:"text-tertiary"};function ir({icon:s,size:t="md",color:a="default",className:r,onClick:n,"aria-label":i,...o}){return e.jsx(s,{className:D(b0[t],v0[a],n&&"cursor-pointer hover:opacity-75 transition-opacity",r),onClick:n,"aria-label":i,...o})}function Eo({status:s,size:t="md",className:a}){const n={success:{icon:ua,color:"success"},error:{icon:xs,color:"danger"},warning:{icon:Dt,color:"warning"},info:{icon:ia,color:"brand"},pending:{icon:Vs,color:"muted"}}[s];return e.jsx(ir,{icon:n.icon,size:t,color:n.color,className:a})}function Cy({metric:s,size:t="lg",className:a}){const n={cpu:{icon:td,color:"primary"},memory:{icon:an,color:"primary"},activity:{icon:gs,color:"primary"},uptime:{icon:Vs,color:"primary"},performance:{icon:dt,color:"primary"}}[s];return e.jsx(ir,{icon:n.icon,size:t,color:n.color,className:a})}function ji({action:s,size:t="sm",onClick:a,className:r,"aria-label":n}){const o={add:{icon:kt,color:"success"},remove:{icon:su,color:"warning"},edit:{icon:Ks,color:"primary"},delete:{icon:Qe,color:"danger"},download:{icon:tn,color:"primary"},upload:{icon:$r,color:"primary"},copy:{icon:fs,color:"primary"},view:{icon:ma,color:"primary"},hide:{icon:sn,color:"muted"}}[s];return e.jsx(ir,{icon:o.icon,size:t,color:o.color,onClick:a,className:D("interactive-pulse",r),"aria-label":n||`${s} action`})}function Zr({direction:s,size:t="sm",onClick:a,className:r}){const n={up:Dc,down:Rc,left:Ya,right:Xa};return e.jsx(ir,{icon:n[s],size:t,color:"default",onClick:a,className:D("transition-transform duration-200",a&&"hover:scale-110",r)})}const ki={Close:ha,Search:sr};async function j0(){}class wi extends h.Component{constructor(a){super(a);Ws(this,"handleRetry",()=>{this.setState({hasError:!1,error:void 0,errorInfo:void 0})});Ws(this,"handleGoHome",()=>{window.location.href="proxy.php?url=https%3A%2F%2Fapp.mockforge.dev%2F"});this.state={hasError:!1}}static getDerivedStateFromError(a){return{hasError:!0,error:a}}componentDidCatch(a,r){Pe.error("ErrorBoundary caught an error",a,r),this.setState({error:a,errorInfo:r});try{}catch(n){Pe.error("Failed to report error",n)}}render(){return this.state.hasError?this.props.fallback?typeof this.props.fallback=="function"?this.props.fallback({error:this.state.error,resetError:this.handleRetry}):this.props.fallback:e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4","data-testid":"error-boundary-fallback",children:e.jsx("div",{className:"max-w-lg w-full bg-card border border-gray-200 dark:border-gray-800 rounded-xl shadow-xl p-8 spring-in",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"p-4 rounded-full bg-red-50 dark:bg-red-900/20 mb-6 inline-flex",children:e.jsx(Eo,{status:"error",size:"3xl"})}),e.jsx("h2",{className:"text-3xl font-bold text-gray-900 dark:text-gray-100 mb-3",children:"Something went wrong"}),e.jsx("p",{className:"text-lg text-gray-600 dark:text-gray-400 mb-8",children:"An unexpected error occurred in the application. Please try refreshing the page or contact support if the issue persists."}),!1,e.jsxs("div",{className:"flex gap-3 justify-center",children:[e.jsxs(Gr,{onClick:this.handleRetry,className:"flex items-center gap-2 spring-hover",variant:"primary",children:[e.jsx(ji,{action:"view"}),"Try Again"]}),e.jsxs(Gr,{onClick:this.handleGoHome,variant:"secondary",className:"flex items-center gap-2 spring-hover",children:[e.jsx(ji,{action:"view"}),"Go Home"]})]}),e.jsx("div",{className:"mt-6 text-sm text-gray-600 dark:text-gray-400",children:"If this problem persists, please contact support with the error details above."})]})})}):this.props.children}}let Ni=0;const k0=()=>(Ni+=1,`toast-${Ni}-${Date.now()}`);function w0(){try{const s=window.AudioContext||window.webkitAudioContext;if(!s)return;const t=new s,a=t.createOscillator(),r=t.createGain();a.type="sine",a.frequency.value=520,r.gain.value=.08,a.connect(r).connect(t.destination),a.start(),a.stop(t.currentTime+.18),a.onended=()=>void t.close()}catch{}}const ms=At()((s,t)=>({toasts:[],addToast:a=>{const r=et.getState().preferences.notifications;if(!r.showToasts||a.type==="success"&&!r.notifyOnSuccess||a.type==="error"&&!r.notifyOnErrors)return"";const n=k0(),i=Math.max(1,r.toastDuration)*1e3,o={id:n,duration:i,dismissible:!0,...a};return s(c=>({toasts:[...c.toasts,o]})),a.type==="error"&&r.enableSounds&&w0(),o.duration&&o.duration>0&&setTimeout(()=>{t().removeToast(n)},o.duration),n},removeToast:a=>{s(r=>({toasts:r.toasts.filter(n=>n.id!==a)}))},clearAllToasts:()=>{s({toasts:[]})},success:(a,r)=>t().addToast({type:"success",title:a,message:r}),error:(a,r)=>{const n=et.getState().preferences.notifications,i=Math.max(n.toastDuration*1e3,8e3);return t().addToast({type:"error",title:a,message:r,duration:i})},warning:(a,r)=>t().addToast({type:"warning",title:a,message:r}),info:(a,r)=>t().addToast({type:"info",title:a,message:r})}));function N0({type:s,title:t,message:a,duration:r=5e3,onClose:n}){const[i,o]=h.useState(!0),[c,d]=h.useState(!1);h.useEffect(()=>{if(r>0){const p=setTimeout(()=>{l()},r);return()=>clearTimeout(p)}},[r]);const l=()=>{d(!0),setTimeout(()=>{o(!1),n==null||n()},300)};if(!i)return null;const m={success:ua,error:xs,warning:tt,info:ia},g={success:"bg-green-50 border-green-200 text-green-800 dark:bg-green-950 dark:border-green-800 dark:text-green-200",error:"bg-red-50 border-red-200 text-red-800 dark:bg-red-950 dark:border-red-800 dark:text-red-200",warning:"bg-yellow-50 border-yellow-200 text-yellow-800 dark:bg-yellow-950 dark:border-yellow-800 dark:text-yellow-200",info:"bg-blue-50 border-blue-200 text-blue-800 dark:bg-blue-950 dark:border-blue-800 dark:text-blue-200"},y={success:"text-green-500",error:"text-red-500",warning:"text-yellow-500",info:"text-blue-500"},u=m[s];return e.jsxs("div",{className:D("flex items-start gap-3 p-4 border rounded-lg shadow-lg transition-all duration-300",g[s],c?"opacity-0 transform translate-x-full":"opacity-100 transform translate-x-0"),role:"alert","aria-live":s==="error"?"assertive":"polite",children:[e.jsx(u,{className:D("h-5 w-5 mt-0.5 flex-shrink-0",y[s])}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h4",{className:"text-sm font-medium",children:t}),a&&e.jsx("p",{className:"text-sm opacity-90 mt-1",children:a})]}),e.jsx("button",{onClick:l,className:"flex-shrink-0 p-1 rounded hover:bg-black/10 dark:hover:bg-white/10 transition-colors","aria-label":"Close notification",children:e.jsx(ha,{className:"h-4 w-4"})})]})}function _0(){const{toasts:s,removeToast:t}=ms();return s.length===0?null:e.jsx("div",{className:"fixed top-4 right-4 z-50 space-y-2 max-w-sm pointer-events-none","aria-label":"Notifications",children:s.map(a=>e.jsx("div",{className:"pointer-events-auto",children:e.jsx(N0,{type:a.type,title:a.title,message:a.message,duration:0,onClose:()=>t(a.id)})},a.id))})}const ot={success:(s,t)=>ms.getState().success(s,t),error:(s,t)=>ms.getState().error(s,t),warning:(s,t)=>ms.getState().warning(s,t),info:(s,t)=>ms.getState().info(s,t)},Ao=h.createContext(void 0);function S0({children:s}){const{addToast:t,removeToast:a,clearAllToasts:r}=ms(),n=h.useCallback((c,d,l,m)=>t({type:c,title:d,message:l,duration:m??(c==="error"?8e3:5e3)}),[t]),i=h.useCallback(c=>{a(c)},[a]),o=h.useCallback(()=>{r()},[r]);return e.jsxs(Ao.Provider,{value:{showToast:n,hideToast:i,clearAllToasts:o},children:[s,e.jsx(_0,{})]})}function ut(){const s=h.useContext(Ao);if(!s)throw new Error("useToast must be used within a ToastProvider");return s}function Ty(){const{showToast:s}=ut();return h.useCallback((t,a,r)=>s("error",t,a,r),[s])}const me={dashboard:["dashboard"],health:["health"],serverInfo:["serverInfo"],restartStatus:["restartStatus"],routes:["routes"],logs:["logs"],metrics:["metrics"],config:["config"],validation:["validation"],envVars:["envVars"],fixtures:["fixtures"],smokeTests:["smokeTests"],import:["import"],importHistory:["importHistory"],chaosConfig:["chaosConfig"],chaosStatus:["chaosStatus"],chaosLatencyMetrics:["chaosLatencyMetrics"],chaosLatencyStats:["chaosLatencyStats"],networkProfiles:["networkProfiles"],networkProfile:s=>["networkProfile",s],timeTravelStatus:["timeTravelStatus"],cronJobs:["cronJobs"],mutationRules:["mutationRules"],proxyRules:["proxyRules"],proxyInspect:["proxyInspect"],realityLevel:["realityLevel"],realityPresets:["realityPresets"],lifecyclePresets:["lifecyclePresets"],lifecyclePreset:s=>["lifecyclePreset",s],driftBudgets:["driftBudgets"],driftBudget:s=>["driftBudget",s],driftIncidents:s=>["driftIncidents",s],driftIncident:s=>["driftIncident",s],driftIncidentStats:["driftIncidentStats"]};function C0(){return he({queryKey:me.serverInfo,queryFn:pa.getServerInfo,staleTime:3e4})}function T0(){return he({queryKey:me.restartStatus,queryFn:pa.getRestartStatus,refetchInterval:5e3,enabled:!1})}function P0(){const s=oe();return Z({mutationFn:t=>pa.restartServer(t),onSuccess:()=>{s.invalidateQueries({queryKey:me.restartStatus}),s.invalidateQueries({queryKey:me.dashboard})}})}function E0(){return he({queryKey:me.validation,queryFn:hn.getValidation,staleTime:3e4})}function A0(){const s=oe();return Z({mutationFn:hn.updateValidation,onSuccess:()=>{s.invalidateQueries({queryKey:me.validation})}})}function O0(){return he({queryKey:me.config,queryFn:Js.getConfig,staleTime:3e4})}function I0(){const s=oe();return Z({mutationFn:Js.updateLatency,onSuccess:()=>{s.invalidateQueries({queryKey:me.config}),s.invalidateQueries({queryKey:me.dashboard})}})}function M0(){const s=oe();return Z({mutationFn:Js.updateFaults,onSuccess:()=>{s.invalidateQueries({queryKey:me.config}),s.invalidateQueries({queryKey:me.dashboard})}})}function R0(){const s=oe();return Z({mutationFn:Js.updateProxy,onSuccess:()=>{s.invalidateQueries({queryKey:me.config}),s.invalidateQueries({queryKey:me.dashboard})}})}function L0(){const s=oe();return Z({mutationFn:Js.updateProtocols,onSuccess:()=>{s.invalidateQueries({queryKey:me.config}),s.invalidateQueries({queryKey:me.dashboard})}})}function $0(s){return he({queryKey:["environments",s],queryFn:()=>lt.getEnvironments(s),enabled:!!s,staleTime:1e4})}function F0(s){const t=oe();return Z({mutationFn:a=>lt.createEnvironment(s,a),onSuccess:()=>{t.invalidateQueries({queryKey:["environments",s]})}})}function D0(s,t){const a=oe();return Z({mutationFn:r=>lt.updateEnvironment(s,t,r),onSuccess:()=>{a.invalidateQueries({queryKey:["environments",s]}),a.invalidateQueries({queryKey:["environment-variables",s,t]})}})}function z0(s){const t=oe();return Z({mutationFn:a=>lt.deleteEnvironment(s,a),onSuccess:()=>{t.invalidateQueries({queryKey:["environments",s]})}})}function q0(s){const t=oe();return Z({mutationFn:a=>lt.setActiveEnvironment(s,a),onSuccess:()=>{t.invalidateQueries({queryKey:["environments",s]}),t.invalidateQueries({queryKey:["workspaces"]})}})}function U0(s,t){return he({queryKey:["environment-variables",s,t],queryFn:()=>lt.getEnvironmentVariables(s,t),enabled:!!s&&!!t,staleTime:5e3})}function B0(s){return Z({mutationFn:t=>lt.getAutocompleteSuggestions(s,t)})}function Py(){const s=oe();return Z({mutationFn:t=>lt.updateWorkspacesOrder(t),onSuccess:()=>{s.invalidateQueries({queryKey:["workspaces"]})}})}function V0(s){const t=oe();return Z({mutationFn:a=>lt.updateEnvironmentsOrder(s,a),onSuccess:()=>{t.invalidateQueries({queryKey:["environments",s]})}})}function Oo(){return he({queryKey:me.timeTravelStatus,queryFn:()=>Ot.getStatus(),refetchInterval:2e3,staleTime:1e3})}function K0(){const s=oe();return Z({mutationFn:async(t="default")=>{const a=await fetch(`/api/v1/consistency/persona/update-lifecycles?workspace=${t}`,{method:"POST",headers:{"Content-Type":"application/json"}});if(a.status===405)return Pe.debug("[TimeTravel] Persona lifecycle update endpoint not available (405)"),null;if(!a.ok)throw new Error(`Failed to update persona lifecycles: ${a.status}`);return a.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["consistency","state"]}),s.invalidateQueries({queryKey:["consistency","persona"]})},onError:t=>{var a;(a=t.message)!=null&&a.includes("405")||Pe.warn("[TimeTravel] Failed to update persona lifecycles",t)}})}function Ey(s="default",t=!0){const{data:a}=Oo(),r=K0(),n=M.useRef();M.useEffect(()=>{if(!t||!(a!=null&&a.enabled))return;const i=a.current_time;i&&i!==n.current&&(n.current=i,r.mutate(s,{onSuccess:()=>{},onError:()=>{}}))},[a==null?void 0:a.current_time,a==null?void 0:a.enabled,t,s,r])}function J0(){const s=oe();return Z({mutationFn:({time:t,scale:a})=>Ot.enable(t,a),onSuccess:()=>{s.invalidateQueries({queryKey:me.timeTravelStatus})}})}function H0(){const s=oe();return Z({mutationFn:()=>Ot.disable(),onSuccess:()=>{s.invalidateQueries({queryKey:me.timeTravelStatus})}})}function W0(){const s=oe();return Z({mutationFn:t=>Ot.advance(t),onSuccess:()=>{s.invalidateQueries({queryKey:me.timeTravelStatus})}})}function Ay(){const s=oe();return Z({mutationFn:t=>Ot.setTime(t),onSuccess:()=>{s.invalidateQueries({queryKey:me.timeTravelStatus})}})}function G0(){const s=oe();return Z({mutationFn:t=>Ot.setScale(t),onSuccess:()=>{s.invalidateQueries({queryKey:me.timeTravelStatus})}})}function Z0(){const s=oe();return Z({mutationFn:()=>Ot.reset(),onSuccess:()=>{s.invalidateQueries({queryKey:me.timeTravelStatus})}})}function Q0(){return he({queryKey:me.cronJobs,queryFn:()=>Ot.listCronJobs(),refetchInterval:5e3,staleTime:2e3})}function Y0(){return he({queryKey:me.mutationRules,queryFn:()=>Ot.listMutationRules(),refetchInterval:5e3,staleTime:2e3})}function X0(){return he({queryKey:me.proxyRules,queryFn:()=>xa.getProxyRules(),staleTime:1e4,refetchInterval:5e3})}function eg(){const s=oe();return Z({mutationFn:t=>xa.createProxyRule(t),onSuccess:()=>{s.invalidateQueries({queryKey:me.proxyRules})}})}function tg(){const s=oe();return Z({mutationFn:({id:t,rule:a})=>xa.updateProxyRule(t,a),onSuccess:(t,a)=>{s.invalidateQueries({queryKey:me.proxyRules}),s.invalidateQueries({queryKey:[...me.proxyRules,a.id]})}})}function sg(){const s=oe();return Z({mutationFn:t=>xa.deleteProxyRule(t),onSuccess:()=>{s.invalidateQueries({queryKey:me.proxyRules})}})}function ag(s){return he({queryKey:[...me.proxyInspect,s],queryFn:()=>xa.getProxyInspect(s),staleTime:2e3,refetchInterval:2e3})}function Io(){return he({queryKey:me.realityLevel,queryFn:()=>fa.getRealityLevel(),staleTime:1e4,refetchInterval:3e4})}function Mo(){const s=oe();return Z({mutationFn:t=>fa.setRealityLevel(t),onSuccess:()=>{s.invalidateQueries({queryKey:me.realityLevel}),s.invalidateQueries({queryKey:me.dashboard})}})}function rg(){return he({queryKey:me.realityPresets,queryFn:()=>fa.listPresets(),staleTime:6e4})}function ng(){const s=oe();return Z({mutationFn:t=>fa.importPreset(t),onSuccess:()=>{s.invalidateQueries({queryKey:me.realityLevel}),s.invalidateQueries({queryKey:me.realityPresets}),s.invalidateQueries({queryKey:me.dashboard})}})}function ig(){const s=oe();return Z({mutationFn:({name:t,description:a})=>fa.exportPreset(t,a),onSuccess:()=>{s.invalidateQueries({queryKey:me.realityPresets})}})}function og(){const s=oe(),t=h.useCallback(()=>{s.prefetchQuery({queryKey:me.dashboard,staleTime:300*1e3})},[s]),a=h.useCallback(()=>{s.prefetchQuery({queryKey:me.metrics,staleTime:120*1e3})},[s]),r=h.useCallback(()=>{s.prefetchQuery({queryKey:[...me.logs],staleTime:60*1e3})},[s]),n=h.useCallback(()=>{s.prefetchQuery({queryKey:me.config,staleTime:600*1e3})},[s]),i=h.useCallback(()=>{t(),a(),r(),n()},[t,a,r,n]);return{prefetchDashboard:t,prefetchMetrics:a,prefetchLogs:r,prefetchConfig:n,prefetchAll:i}}function lg(){const{prefetchAll:s}=og();h.useEffect(()=>{const t=setTimeout(()=>{s()},1e3);return()=>clearTimeout(t)},[s])}const Ro=At()(da((s,t)=>({activeWorkspace:null,workspaces:[],loading:!1,error:null,setActiveWorkspace:a=>{s({activeWorkspace:a})},setWorkspaces:a=>{s({workspaces:a})},loadWorkspaces:async()=>{s({loading:!0,error:null});try{const a=await lt.listWorkspaces();s({workspaces:a,loading:!1});const r=a.find(n=>n.is_active);r&&s({activeWorkspace:r})}catch(a){s({error:a instanceof Error?a.message:"Failed to load workspaces",loading:!1,workspaces:[]})}},setActiveWorkspaceById:async a=>{s({loading:!0,error:null});try{await lt.setActiveWorkspace(a);const r=await lt.listWorkspaces();s({workspaces:r,loading:!1});const n=r.find(i=>i.is_active);s({activeWorkspace:n})}catch(r){s({error:r instanceof Error?r.message:"Failed to set active workspace",loading:!1,workspaces:[]})}},refreshWorkspaces:async()=>{await t().loadWorkspaces()}}),{name:"mockforge-workspace",partialize:s=>({activeWorkspace:s.activeWorkspace})})),_i={blue:{brand:"217 91% 60%",brand50:"217 100% 97%",brand100:"217 95% 92%",brand500:"217 91% 60%",brand600:"217 93% 55%"},green:{brand:"142 76% 36%",brand50:"142 100% 97%",brand100:"142 90% 92%",brand500:"142 76% 36%",brand600:"142 78% 32%"},purple:{brand:"271 76% 53%",brand50:"271 100% 97%",brand100:"271 90% 92%",brand500:"271 76% 53%",brand600:"271 78% 48%"},orange:{brand:"24 86% 42%",brand50:"24 100% 97%",brand100:"24 95% 92%",brand500:"24 86% 42%",brand600:"24 88% 36%"},red:{brand:"0 84% 50%",brand50:"0 100% 97%",brand100:"0 95% 92%",brand500:"0 84% 50%",brand600:"0 86% 45%"}},Si={small:"14px",medium:"16px",large:"18px"};function cg(){const s=et(r=>r.preferences.theme.accentColor),t=et(r=>r.preferences.theme.fontSize),a=et(r=>r.preferences.theme.highContrast);h.useEffect(()=>{const r=_i[s]??_i.orange,n=document.documentElement;n.style.setProperty("--primary",r.brand),n.style.setProperty("--brand",r.brand),n.style.setProperty("--brand-50",r.brand50),n.style.setProperty("--brand-100",r.brand100),n.style.setProperty("--brand-500",r.brand500),n.style.setProperty("--brand-600",r.brand600),n.style.setProperty("--ring",r.brand)},[s]),h.useEffect(()=>{const r=Si[t]??Si.medium;document.documentElement.style.fontSize=r},[t]),h.useEffect(()=>{document.documentElement.classList.toggle("high-contrast",a)},[a])}const dg=()=>{var A;const[s,t]=h.useState("entities"),[a,r]=h.useState(null),[n,i]=h.useState(""),[o,c]=h.useState(""),[d,l]=h.useState(""),[m,g]=h.useState(!1),y=oe(),{data:u,isLoading:p,error:f}=he({queryKey:["virtual-backend","entities"],queryFn:()=>Zh.listEntities()}),{data:j,isLoading:C,error:T}=he({queryKey:["virtual-backend","snapshots"],queryFn:()=>Ea.listSnapshots()}),N=Z({mutationFn:({name:_,description:$})=>Ea.saveSnapshot(_,"default",$),onSuccess:()=>{y.invalidateQueries({queryKey:["virtual-backend","snapshots"]}),c(""),l(""),g(!1)}}),w=Z({mutationFn:_=>Ea.loadSnapshot(_),onSuccess:()=>{y.invalidateQueries({queryKey:["virtual-backend"]})}}),O=Z({mutationFn:_=>Ea.deleteSnapshot(_),onSuccess:()=>{y.invalidateQueries({queryKey:["virtual-backend","snapshots"]})}}),L=M.useMemo(()=>{if(!(u!=null&&u.entities))return[];const _=new Map;for(const $ of u.entities){const ae=_.get($.entity_type)??[];ae.push($),_.set($.entity_type,ae)}return Array.from(_.entries()).map(([$,ae])=>{const U=new Set;let z="";for(const R of ae)R.data&&typeof R.data=="object"&&Object.keys(R.data).forEach(P=>U.add(P)),(!z||R.updated_at>z)&&(z=R.updated_at);return{entityType:$,count:ae.length,fields:U.size,lastModified:z}})},[u]),I=M.useMemo(()=>!(u!=null&&u.entities)||!a?[]:u.entities.filter(_=>_.entity_type===a).filter(_=>n?JSON.stringify(_.data).toLowerCase().includes(n.toLowerCase()):!0),[u,a,n]),b=h.useCallback(_=>{if(!_)return"N/A";const $=new Date(_),U=new Date().getTime()-$.getTime(),z=Math.floor(U/6e4);if(z<1)return"Just now";if(z<60)return`${z} min${z===1?"":"s"} ago`;const R=Math.floor(z/60);return R<24?`${R} hour${R===1?"":"s"} ago`:$.toLocaleDateString()},[]);return e.jsxs("div",{className:"p-6 max-w-7xl mx-auto h-full flex flex-col",children:[e.jsxs("div",{className:"flex justify-between items-start mb-6",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900 dark:text-gray-100",children:"Virtual Backend"}),e.jsx("span",{className:"px-2 py-0.5 rounded-full bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400 text-xs font-medium border border-green-200 dark:border-green-900/50",children:"Running"})]}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:"Manage your stateful mock database, entities, and time-travel snapshots."})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{className:"flex items-center px-3 py-2 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded-lg text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors",children:[e.jsx(Vs,{className:"w-4 h-4 mr-2"}),"Simulate Time"]}),e.jsxs("button",{onClick:()=>y.invalidateQueries({queryKey:["virtual-backend"]}),className:"flex items-center px-3 py-2 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded-lg text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors",children:[e.jsx(st,{className:"w-4 h-4 mr-2"}),"Refresh"]})]})]}),e.jsxs("div",{className:"flex border-b border-gray-200 dark:border-gray-700 mb-6",children:[e.jsxs("button",{onClick:()=>t("entities"),className:`px-4 py-2 font-medium text-sm flex items-center gap-2 border-b-2 transition-colors ${s==="entities"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-300"}`,children:[e.jsx(Ms,{className:"w-4 h-4"}),"Entities & Schema"]}),e.jsxs("button",{onClick:()=>t("data"),className:`px-4 py-2 font-medium text-sm flex items-center gap-2 border-b-2 transition-colors ${s==="data"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-300"}`,children:[e.jsx(Ca,{className:"w-4 h-4"}),"Data Explorer"]}),e.jsxs("button",{onClick:()=>t("snapshots"),className:`px-4 py-2 font-medium text-sm flex items-center gap-2 border-b-2 transition-colors ${s==="snapshots"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-300"}`,children:[e.jsx(La,{className:"w-4 h-4"}),"Snapshots & Time Travel"]}),e.jsxs("button",{onClick:()=>t("settings"),className:`px-4 py-2 font-medium text-sm flex items-center gap-2 border-b-2 transition-colors ${s==="settings"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-300"}`,children:[e.jsx(Tt,{className:"w-4 h-4"}),"Configuration"]})]}),e.jsxs("div",{className:"flex-1 bg-white dark:bg-gray-800 rounded-xl shadow-sm border border-gray-200 dark:border-gray-700 overflow-hidden",children:[s==="entities"&&e.jsx("div",{className:"p-0",children:p?e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsx(Is,{className:"w-8 h-8 animate-spin text-gray-400"})}):f?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-gray-500 dark:text-gray-400",children:[e.jsx(tt,{className:"w-12 h-12 mb-3 opacity-30"}),e.jsx("p",{children:"Failed to load entities"}),e.jsx("p",{className:"text-sm mt-1",children:f instanceof Error?f.message:"Unknown error"})]}):L.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-gray-500 dark:text-gray-400",children:[e.jsx(Ms,{className:"w-12 h-12 mb-3 opacity-20"}),e.jsx("p",{children:"No entities registered yet"}),e.jsx("p",{className:"text-sm mt-1",children:"Entities appear here as they are created through API interactions."})]}):e.jsxs("table",{className:"w-full text-left text-sm",children:[e.jsx("thead",{className:"bg-gray-50 dark:bg-gray-900/50 border-b border-gray-200 dark:border-gray-700",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-6 py-4 font-medium text-gray-500 dark:text-gray-400",children:"Entity Type"}),e.jsx("th",{className:"px-6 py-4 font-medium text-gray-500 dark:text-gray-400",children:"Records"}),e.jsx("th",{className:"px-6 py-4 font-medium text-gray-500 dark:text-gray-400",children:"Fields"}),e.jsx("th",{className:"px-6 py-4 font-medium text-gray-500 dark:text-gray-400",children:"Last Modified"}),e.jsx("th",{className:"px-6 py-4 font-medium text-gray-500 dark:text-gray-400 text-right",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:L.map(_=>e.jsxs("tr",{className:"hover:bg-gray-50 dark:hover:bg-gray-800/50 transition-colors",children:[e.jsx("td",{className:"px-6 py-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-blue-50 dark:bg-blue-900/20 rounded text-blue-600 dark:text-blue-400",children:e.jsx(Ca,{className:"w-4 h-4"})}),e.jsx("span",{className:"font-medium text-gray-900 dark:text-gray-100",children:_.entityType})]})}),e.jsx("td",{className:"px-6 py-4 text-gray-600 dark:text-gray-300",children:_.count.toLocaleString()}),e.jsx("td",{className:"px-6 py-4 text-gray-600 dark:text-gray-300",children:_.fields}),e.jsx("td",{className:"px-6 py-4 text-gray-500 dark:text-gray-400",children:b(_.lastModified)}),e.jsx("td",{className:"px-6 py-4 text-right",children:e.jsx("button",{onClick:()=>{r(_.entityType),t("data")},className:"text-blue-600 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300 font-medium text-sm",children:"View Data"})})]},_.entityType))})]})}),s==="data"&&e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"p-4 border-b border-gray-200 dark:border-gray-700 flex gap-4 items-center bg-gray-50 dark:bg-gray-900/30",children:[e.jsxs("select",{value:a??"",onChange:_=>r(_.target.value||null),className:"px-3 py-2 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded-lg text-sm",children:[e.jsx("option",{value:"",children:"Select entity type..."}),L.map(_=>e.jsxs("option",{value:_.entityType,children:[_.entityType," (",_.count,")"]},_.entityType))]}),e.jsxs("div",{className:"relative flex-1 max-w-md",children:[e.jsx(sr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),e.jsx("input",{type:"text",placeholder:"Search records...",value:n,onChange:_=>i(_.target.value),className:"w-full pl-9 pr-4 py-2 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded-lg text-sm focus:ring-2 focus:ring-blue-500 outline-none"})]})]}),a?p?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx(Is,{className:"w-8 h-8 animate-spin text-gray-400"})}):I.length===0?e.jsx("div",{className:"flex-1 flex items-center justify-center text-gray-500 dark:text-gray-400",children:e.jsxs("div",{className:"text-center",children:[e.jsx(Ca,{className:"w-12 h-12 mx-auto mb-3 opacity-20"}),e.jsxs("p",{children:['No records found for "',a,'"']})]})}):e.jsx("div",{className:"overflow-auto flex-1",children:e.jsxs("table",{className:"w-full text-left text-sm",children:[e.jsx("thead",{className:"bg-gray-50 dark:bg-gray-900/50 border-b border-gray-200 dark:border-gray-700 sticky top-0",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-6 py-3 font-medium text-gray-500 dark:text-gray-400",children:"ID"}),e.jsx("th",{className:"px-6 py-3 font-medium text-gray-500 dark:text-gray-400",children:"Data"}),e.jsx("th",{className:"px-6 py-3 font-medium text-gray-500 dark:text-gray-400",children:"Protocols"}),e.jsx("th",{className:"px-6 py-3 font-medium text-gray-500 dark:text-gray-400",children:"Updated"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:I.map(_=>e.jsxs("tr",{className:"hover:bg-gray-50 dark:hover:bg-gray-800/50",children:[e.jsx("td",{className:"px-6 py-3 font-mono text-xs text-gray-900 dark:text-gray-100",children:_.entity_id}),e.jsx("td",{className:"px-6 py-3",children:e.jsx("pre",{className:"text-xs text-gray-600 dark:text-gray-300 max-w-lg truncate",children:JSON.stringify(_.data,null,2).slice(0,200)})}),e.jsx("td",{className:"px-6 py-3",children:e.jsx("div",{className:"flex gap-1 flex-wrap",children:_.seen_in_protocols.map($=>e.jsx("span",{className:"px-1.5 py-0.5 bg-gray-100 dark:bg-gray-700 rounded text-xs text-gray-600 dark:text-gray-300",children:$},$))})}),e.jsx("td",{className:"px-6 py-3 text-gray-500 dark:text-gray-400 text-xs",children:b(_.updated_at)})]},`${_.entity_type}:${_.entity_id}`))})]})}):e.jsx("div",{className:"flex-1 flex items-center justify-center text-gray-500 dark:text-gray-400",children:e.jsxs("div",{className:"text-center",children:[e.jsx(Ca,{className:"w-12 h-12 mx-auto mb-3 opacity-20"}),e.jsx("p",{children:"Select an entity type to view records"})]})})]}),s==="snapshots"&&e.jsxs("div",{className:"p-6",children:[e.jsxs("div",{className:"flex justify-between items-center mb-6",children:[e.jsx("h3",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:"Database Snapshots"}),e.jsxs("button",{onClick:()=>g(!m),className:"flex items-center px-3 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg text-sm font-medium transition-colors",children:[e.jsx(Xt,{className:"w-4 h-4 mr-2"}),"Create Snapshot"]})]}),m&&e.jsx("div",{className:"mb-6 p-4 border border-blue-200 dark:border-blue-800 rounded-lg bg-blue-50 dark:bg-blue-900/20",children:e.jsxs("div",{className:"flex gap-3 items-end",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Name"}),e.jsx("input",{type:"text",value:o,onChange:_=>c(_.target.value),placeholder:"e.g., pre-migration-backup",className:"w-full px-3 py-2 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded-lg text-sm"})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Description"}),e.jsx("input",{type:"text",value:d,onChange:_=>l(_.target.value),placeholder:"Optional description...",className:"w-full px-3 py-2 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded-lg text-sm"})]}),e.jsx("button",{onClick:()=>{o.trim()&&N.mutate({name:o.trim(),description:d.trim()||void 0})},disabled:!o.trim()||N.isPending,className:"px-4 py-2 bg-blue-600 hover:bg-blue-700 disabled:opacity-50 text-white rounded-lg text-sm font-medium transition-colors",children:N.isPending?"Saving...":"Save"})]})}),C?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(Is,{className:"w-8 h-8 animate-spin text-gray-400"})}):T?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-gray-500 dark:text-gray-400",children:[e.jsx(tt,{className:"w-12 h-12 mb-3 opacity-30"}),e.jsx("p",{children:"Failed to load snapshots"})]}):(A=j==null?void 0:j.snapshots)!=null&&A.length?e.jsx("div",{className:"grid gap-4",children:j.snapshots.map(_=>e.jsxs("div",{className:"flex items-center justify-between p-4 border border-gray-200 dark:border-gray-700 rounded-lg hover:border-blue-300 dark:hover:border-blue-700 transition-colors bg-white dark:bg-gray-800",children:[e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"p-3 bg-purple-50 dark:bg-purple-900/20 rounded-lg text-purple-600 dark:text-purple-400",children:e.jsx(La,{className:"w-6 h-6"})}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-gray-100",children:_.name}),_.description&&e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 mt-1",children:_.description}),e.jsxs("div",{className:"flex items-center gap-4 mt-2 text-xs text-gray-400",children:[e.jsx("span",{children:b(_.created_at)}),e.jsx("span",{children:"•"}),e.jsxs("span",{children:["Workspace: ",_.workspace]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>w.mutate(_.name),disabled:w.isPending,className:"p-2 text-gray-500 hover:text-blue-600 hover:bg-blue-50 dark:hover:bg-blue-900/20 rounded-lg transition-colors",title:"Restore",children:e.jsx(nn,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>O.mutate(_.name),disabled:O.isPending,className:"p-2 text-gray-500 hover:text-red-600 hover:bg-red-50 dark:hover:bg-red-900/20 rounded-lg transition-colors",title:"Delete",children:e.jsx(Qe,{className:"w-5 h-5"})})]})]},_.name))}):e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-gray-500 dark:text-gray-400",children:[e.jsx(La,{className:"w-12 h-12 mb-3 opacity-20"}),e.jsx("p",{children:"No snapshots yet"}),e.jsx("p",{className:"text-sm mt-1",children:"Create a snapshot to save the current state."})]})]}),s==="settings"&&e.jsx("div",{className:"p-6",children:e.jsxs("div",{className:"max-w-2xl",children:[e.jsx("h3",{className:"text-lg font-medium text-gray-900 dark:text-gray-100 mb-4",children:"Engine Configuration"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"p-4 border border-gray-200 dark:border-gray-700 rounded-lg",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Storage Backend"}),e.jsxs("select",{className:"w-full p-2 bg-white dark:bg-gray-900 border border-gray-300 dark:border-gray-600 rounded-md",children:[e.jsx("option",{children:"SQLite (Persistent)"}),e.jsx("option",{children:"In-Memory (Fast)"}),e.jsx("option",{children:"JSON File (Portable)"})]})]}),e.jsxs("div",{className:"p-4 border border-gray-200 dark:border-gray-700 rounded-lg",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Auto-Snapshot Interval"}),e.jsxs("select",{className:"w-full p-2 bg-white dark:bg-gray-900 border border-gray-300 dark:border-gray-600 rounded-md",children:[e.jsx("option",{children:"Disabled"}),e.jsx("option",{children:"Every 1 hour"}),e.jsx("option",{children:"Every 24 hours"})]})]})]})]})})]})]})},ug=()=>{const[s,t]=h.useState([{id:"tun_123",name:"Payment Service Dev",local_port:8080,public_url:"https://payment-dev.mockforge.io",status:"active",created_at:new Date().toISOString(),region:"us-east-1"}]),[a,r]=h.useState(!1),[n,i]=h.useState({name:"",port:"8080"}),o=()=>{const l={id:`tun_${Math.random().toString(36).substr(2,9)}`,name:n.name,local_port:parseInt(n.port),public_url:`https://${n.name.toLowerCase().replace(/\s+/g,"-")}.mockforge.io`,status:"active",created_at:new Date().toISOString(),region:"us-east-1"};t([...s,l]),r(!1),i({name:"",port:"8080"})},c=l=>{t(s.filter(m=>m.id!==l))},d=l=>{navigator.clipboard.writeText(l)};return e.jsxs("div",{className:"p-6 max-w-7xl mx-auto",children:[e.jsxs("div",{className:"flex justify-between items-start mb-8",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900 dark:text-gray-100 mb-2",children:"Tunnels"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:"Expose your local mock servers to the internet via secure tunnels."})]}),e.jsxs("button",{onClick:()=>r(!0),className:"flex items-center px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg font-medium transition-colors",children:[e.jsx(kt,{className:"w-4 h-4 mr-2"}),"Start Tunnel"]})]}),s.length===0?e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-sm border border-gray-200 dark:border-gray-700 p-12 text-center",children:[e.jsx(lo,{className:"w-16 h-16 mx-auto text-gray-400 mb-4"}),e.jsx("h3",{className:"text-lg font-medium text-gray-900 dark:text-gray-100 mb-2",children:"No Active Tunnels"}),e.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-6",children:"Create a tunnel to share your local mocks with external services or teammates."}),e.jsx("button",{onClick:()=>r(!0),className:"px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors",children:"Create First Tunnel"})]}):e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-sm border border-gray-200 dark:border-gray-700 overflow-hidden",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-left text-sm",children:[e.jsx("thead",{className:"bg-gray-50 dark:bg-gray-900/50 border-b border-gray-200 dark:border-gray-700",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-6 py-4 font-medium text-gray-500 dark:text-gray-400",children:"Name"}),e.jsx("th",{className:"px-6 py-4 font-medium text-gray-500 dark:text-gray-400",children:"Status"}),e.jsx("th",{className:"px-6 py-4 font-medium text-gray-500 dark:text-gray-400",children:"Local Port"}),e.jsx("th",{className:"px-6 py-4 font-medium text-gray-500 dark:text-gray-400",children:"Public URL"}),e.jsx("th",{className:"px-6 py-4 font-medium text-gray-500 dark:text-gray-400",children:"Region"}),e.jsx("th",{className:"px-6 py-4 font-medium text-gray-500 dark:text-gray-400 text-right",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:s.map(l=>e.jsxs("tr",{className:"hover:bg-gray-50 dark:hover:bg-gray-800/50 transition-colors",children:[e.jsxs("td",{className:"px-6 py-4",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:l.name}),e.jsx("div",{className:"text-xs text-gray-500 font-mono mt-0.5",children:l.id})]}),e.jsx("td",{className:"px-6 py-4",children:e.jsxs("span",{className:`inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium border ${l.status==="active"?"bg-green-50 text-green-700 border-green-200 dark:bg-green-900/20 dark:text-green-400 dark:border-green-900/30":"bg-gray-100 text-gray-700 border-gray-200 dark:bg-gray-800 dark:text-gray-400 dark:border-gray-700"}`,children:[l.status==="active"?e.jsx(oa,{className:"w-3 h-3 mr-1"}):e.jsx(ln,{className:"w-3 h-3 mr-1"}),l.status]})}),e.jsx("td",{className:"px-6 py-4 text-gray-600 dark:text-gray-300 font-mono",children:l.local_port}),e.jsx("td",{className:"px-6 py-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-mono text-gray-600 dark:text-gray-300 truncate max-w-[200px]",children:l.public_url}),e.jsx("button",{onClick:()=>d(l.public_url),className:"p-1 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded transition-colors",title:"Copy URL",children:e.jsx(fs,{className:"w-3.5 h-3.5"})}),e.jsx("a",{href:l.public_url,target:"_blank",rel:"noopener noreferrer",className:"p-1 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded transition-colors",title:"Open URL",children:e.jsx(Os,{className:"w-3.5 h-3.5"})})]})}),e.jsx("td",{className:"px-6 py-4 text-gray-600 dark:text-gray-300",children:l.region}),e.jsx("td",{className:"px-6 py-4 text-right",children:e.jsx("button",{onClick:()=>c(l.id),className:"p-2 text-red-600 hover:bg-red-50 dark:hover:bg-red-900/20 rounded-lg transition-colors",title:"Stop Tunnel",children:e.jsx(Qe,{className:"w-4 h-4"})})})]},l.id))})]})})}),a&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-xl max-w-md w-full border border-gray-200 dark:border-gray-700",children:[e.jsx("div",{className:"p-6 border-b border-gray-200 dark:border-gray-700",children:e.jsx("h2",{className:"text-xl font-semibold text-gray-900 dark:text-gray-100",children:"Start New Tunnel"})}),e.jsxs("div",{className:"p-6 space-y-4",children:[e.jsx("div",{className:"bg-blue-50 dark:bg-blue-900/20 text-blue-700 dark:text-blue-300 p-4 rounded-lg text-sm",children:"This will create a secure tunnel from a public URL to your local machine."}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300",children:"Tunnel Name"}),e.jsx("input",{type:"text",value:n.name,onChange:l=>i({...n,name:l.target.value}),placeholder:"e.g., My Payment Mock",className:"w-full px-3 py-2 bg-white dark:bg-gray-900 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 outline-none transition-all"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300",children:"Local Port"}),e.jsx("input",{type:"number",value:n.port,onChange:l=>i({...n,port:l.target.value}),placeholder:"8080",className:"w-full px-3 py-2 bg-white dark:bg-gray-900 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 outline-none transition-all"}),e.jsx("p",{className:"text-xs text-gray-500",children:"The port your mock server is running on locally"})]})]}),e.jsxs("div",{className:"p-6 border-t border-gray-200 dark:border-gray-700 flex justify-end gap-3",children:[e.jsx("button",{onClick:()=>r(!1),className:"px-4 py-2 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",children:"Cancel"}),e.jsx("button",{onClick:o,disabled:!n.name||!n.port,className:"px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:"Start Tunnel"})]})]})})]})},zt="/api/v1/federation";function It(){const s=localStorage.getItem("auth_token");return{"Content-Type":"application/json",...s?{Authorization:`Bearer ${s}`}:{}}}const mg=s=>he({queryKey:["federations",s],queryFn:async()=>{const t=await fetch(`${zt}?org_id=${s}`,{headers:It()});if(!t.ok){const a=await t.json().catch(()=>({}));throw new Error(ct(t,a,"Failed to fetch federations"))}return t.json()},enabled:!!s,refetchInterval:3e4}),hg=s=>he({queryKey:["federation",s],queryFn:async()=>{const t=await fetch(`${zt}/${s}`,{headers:It()});if(!t.ok){const a=await t.json().catch(()=>({}));throw new Error(ct(t,a,"Failed to fetch federation"))}return t.json()},enabled:!!s}),gg=()=>{const s=oe();return Z({mutationFn:async t=>{const a=await fetch(zt,{method:"POST",headers:It(),body:JSON.stringify(t)});if(!a.ok){const r=await a.json().catch(()=>({}));throw new Error(ct(a,r,"Failed to create federation"))}return a.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["federations"]})}})},xg=()=>{const s=oe();return Z({mutationFn:async({id:t,data:a})=>{const r=await fetch(`${zt}/${t}`,{method:"PATCH",headers:It(),body:JSON.stringify(a)});if(!r.ok){const n=await r.json().catch(()=>({}));throw new Error(ct(r,n,"Failed to update federation"))}return r.json()},onSuccess:(t,a)=>{s.invalidateQueries({queryKey:["federations"]}),s.invalidateQueries({queryKey:["federation",a.id]})}})},pg=()=>{const s=oe();return Z({mutationFn:async t=>{const a=await fetch(`${zt}/${t}`,{method:"DELETE",headers:It()});if(!a.ok){const r=await a.json().catch(()=>({}));throw new Error(ct(a,r,"Failed to delete federation"))}},onSuccess:()=>{s.invalidateQueries({queryKey:["federations"]})}})},fg=()=>Z({mutationFn:async({federationId:s,request:t})=>{const a=await fetch(`${zt}/${s}/route`,{method:"POST",headers:It(),body:JSON.stringify(t)});if(!a.ok){const r=await a.json().catch(()=>({}));throw new Error(ct(a,r,"Failed to route request"))}return a.json()}}),yg=s=>he({queryKey:["federation-active-scenario",s],queryFn:async()=>{const t=await fetch(`${zt}/${s}/scenarios/active`,{headers:It()});if(!t.ok){const a=await t.json().catch(()=>({}));throw new Error(ct(t,a,"Failed to fetch active scenario"))}return t.json()},enabled:!!s,refetchInterval:1e4}),bg=()=>{const s=oe();return Z({mutationFn:async({federationId:t,request:a})=>{const r=await fetch(`${zt}/${t}/scenarios/activate`,{method:"POST",headers:It(),body:JSON.stringify(a)});if(!r.ok){const n=await r.json().catch(()=>({}));throw new Error(ct(r,n,"Failed to activate scenario"))}return r.json()},onSuccess:(t,a)=>{s.invalidateQueries({queryKey:["federation-active-scenario",a.federationId]})}})},vg=()=>he({queryKey:["org-scenarios"],queryFn:async()=>{const s=await fetch("/api/v1/scenarios",{headers:It()});if(!s.ok){const t=await s.json().catch(()=>({}));throw new Error(ct(s,t,"Failed to fetch scenarios"))}return s.json()}}),jg=()=>{const s=oe();return Z({mutationFn:async({federationId:t})=>{const a=await fetch(`${zt}/${t}/scenarios/active`,{method:"DELETE",headers:It()});if(!a.ok){const r=await a.json().catch(()=>({}));throw new Error(ct(a,r,"Failed to deactivate scenario"))}return a.json()},onSuccess:(t,a)=>{s.invalidateQueries({queryKey:["federation-active-scenario",a.federationId]})}})};function gn(){const s=et(t=>t.preferences.ui.confirmDelete);return h.useCallback(t=>s?typeof window>"u"?!0:window.confirm(t):!0,[s])}function X({title:s,icon:t,children:a,className:r,...n}){return e.jsxs("div",{className:D("bg-bg-primary border border-border rounded-xl shadow-sm","border-l-4 border-l-brand-200","hover:shadow-lg hover:border-brand-200 transition-all duration-200 ease-out","hover:-translate-y-0.5 group",r),...n,children:[s&&e.jsx("div",{className:"border-b border-border/50 px-6 py-4 bg-brand-50 dark:bg-brand-900/10 rounded-t-xl",children:e.jsxs("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 flex items-center gap-3",children:[t&&typeof s=="string"&&e.jsx("span",{className:"p-1.5 rounded-lg bg-brand-50 text-brand-600 group-hover:bg-brand-100 transition-colors duration-200 dark:bg-brand-900/20 dark:text-brand-400",children:t}),s]})}),e.jsx("div",{className:D("p-6",s?"":"pt-6"),children:a})]})}function Le({className:s,...t}){return e.jsx("div",{className:D("flex flex-col space-y-1.5 p-6",s),...t})}function ze({className:s,...t}){return e.jsx("h3",{className:D("text-2xl font-semibold leading-none tracking-tight",s),...t})}function We({className:s,...t}){return e.jsx("p",{className:D("text-sm text-muted-foreground",s),...t})}function _e({className:s,...t}){return e.jsx("div",{className:D("p-6 pt-0",s),...t})}const kg=({orgId:s,onSelect:t,onCreate:a})=>{const{data:r,isLoading:n,error:i}=mg(s),o=pg(),c=gn();if(n)return e.jsx("div",{className:"flex items-center justify-center p-8",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600"})});if(i)return e.jsx(X,{className:"p-6",children:e.jsxs("div",{className:"text-red-600 dark:text-red-400",children:["Error loading federations: ",i.message]})});const d=async(m,g)=>{if(c(`Are you sure you want to delete federation "${g}"?`))try{await o.mutateAsync(m)}catch(y){alert(`Failed to delete federation: ${y instanceof Error?y.message:"Unknown error"}`)}},l=m=>{switch(m){case"real":return"bg-blue-100 dark:bg-blue-900 text-blue-800 dark:text-blue-200";case"mock_v3":return"bg-green-100 dark:bg-green-900 text-green-800 dark:text-green-200";case"blended":return"bg-yellow-100 dark:bg-yellow-900 text-yellow-800 dark:text-yellow-200";case"chaos_driven":return"bg-red-100 dark:bg-red-900 text-red-800 dark:text-red-200";default:return"bg-gray-100 dark:bg-gray-800 text-gray-800 dark:text-gray-200"}};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:"Federations"}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mt-1",children:"Compose multiple workspaces into federated virtual systems"})]}),a&&e.jsxs("button",{onClick:a,className:"flex items-center gap-2 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors",children:[e.jsx(kt,{className:"h-4 w-4"}),"Create Federation"]})]}),!r||r.length===0?e.jsxs(X,{className:"p-8 text-center",children:[e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-4",children:"No federations found"}),a&&e.jsx("button",{onClick:a,className:"px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors",children:"Create Your First Federation"})]}):e.jsx("div",{className:"grid gap-4",children:r.map(m=>e.jsx(X,{className:"p-6 hover:shadow-lg transition-shadow",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx(rn,{className:"h-5 w-5 text-blue-600 dark:text-blue-400"}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:m.name})]}),m.description&&e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-3",children:m.description}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:[e.jsx("strong",{children:"Services:"})," ",m.services.length]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:m.services.map(g=>e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1 bg-gray-50 dark:bg-gray-800 rounded text-sm",children:[e.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:g.name}),e.jsx(ao,{className:"h-3 w-3 text-gray-400"}),e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:g.base_path}),e.jsx("span",{className:`px-2 py-0.5 rounded text-xs ${l(g.reality_level)}`,children:g.reality_level})]},g.name))}),e.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-500 mt-2",children:["Updated ",new Date(m.updated_at).toLocaleDateString()]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[t&&e.jsx("button",{onClick:()=>t(m),className:"p-2 text-gray-600 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 transition-colors",title:"View Details",children:e.jsx(Ks,{className:"h-4 w-4"})}),e.jsx("button",{onClick:()=>d(m.id,m.name),className:"p-2 text-gray-600 dark:text-gray-400 hover:text-red-600 dark:hover:text-red-400 transition-colors",title:"Delete Federation",children:e.jsx(Qe,{className:"h-4 w-4"})})]})]})},m.id))})]})},wg={pending:e.jsx(Vs,{className:"h-4 w-4 text-yellow-600 dark:text-yellow-400"}),applied:e.jsx(ua,{className:"h-4 w-4 text-green-600 dark:text-green-400"}),failed:e.jsx(tt,{className:"h-4 w-4 text-red-600 dark:text-red-400"})},Ng=({federation:s})=>{const{data:t,isLoading:a}=yg(s.id),r=bg(),n=jg(),[i,o]=h.useState(!1);if(a)return e.jsx(X,{className:"p-6",children:e.jsx("div",{className:"flex items-center justify-center",children:e.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-blue-600"})})});const c=async()=>{if(confirm("Deactivate the current scenario? Workspaces will revert to defaults."))try{await n.mutateAsync({federationId:s.id})}catch(d){alert(`Deactivate failed: ${d instanceof Error?d.message:"Unknown error"}`)}};return t?e.jsxs(X,{className:"p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white flex items-center gap-2",children:[e.jsx(dt,{className:"h-5 w-5 text-amber-500"}),"Active Scenario"]}),e.jsxs("button",{onClick:c,disabled:n.isPending,className:"flex items-center gap-2 px-3 py-1.5 bg-red-600 text-white rounded-lg hover:bg-red-700 transition-colors disabled:opacity-50 disabled:cursor-not-allowed text-sm",children:[e.jsx(Ru,{className:"h-4 w-4"}),"Deactivate"]})]}),e.jsxs("div",{className:"space-y-3 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Scenario:"}),e.jsx("span",{className:"ml-2 font-medium text-gray-900 dark:text-white",children:t.scenario_name})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Activated:"}),e.jsx("span",{className:"ml-2 text-gray-900 dark:text-white",children:new Date(t.activated_at).toLocaleString()})]}),e.jsxs("div",{className:"pt-2",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white mb-2",children:"Service status"}),e.jsx("div",{className:"space-y-2",children:t.per_service_state.map(d=>e.jsxs("div",{className:"flex items-center gap-3 p-2 bg-gray-50 dark:bg-gray-800 rounded",children:[wg[d.status],e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:d.service_name}),d.error&&e.jsx("div",{className:"text-xs text-red-600 dark:text-red-400",children:d.error}),d.last_observed_at&&e.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:["last seen ",new Date(d.last_observed_at).toLocaleTimeString()]})]}),e.jsx("span",{className:"text-xs uppercase text-gray-500 dark:text-gray-400",children:d.status})]},d.service_name))})]}),Object.keys(t.service_overrides||{}).length>0&&e.jsxs("div",{className:"pt-2",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white mb-2",children:"Per-service overrides"}),e.jsx("pre",{className:"p-3 bg-gray-50 dark:bg-gray-900 rounded text-xs overflow-x-auto text-gray-700 dark:text-gray-300",children:JSON.stringify(t.service_overrides,null,2)})]})]})]}):e.jsxs(X,{className:"p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white flex items-center gap-2",children:[e.jsx(dt,{className:"h-5 w-5 text-gray-400"}),"Active Scenario"]}),!i&&e.jsxs("button",{onClick:()=>o(!0),className:"flex items-center gap-2 px-3 py-1.5 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors text-sm",children:[e.jsx(er,{className:"h-4 w-4"}),"Activate Scenario"]})]}),i?e.jsx(Sg,{federation:s,onCancel:()=>o(!1),onActivate:async d=>{try{await r.mutateAsync({federationId:s.id,request:{scenario_id:d.scenario_id,scenario_name:d.scenario_name,manifest:d.manifest,service_overrides:d.service_overrides}}),o(!1)}catch(l){alert(`Activation failed: ${l instanceof Error?l.message:"Unknown error"}`)}},pending:r.isPending}):e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"No scenario is currently active on this federation."})]})},_g=()=>({manifest_version:"1.0",name:"inline-scenario",version:"0.1.0",title:"Inline scenario",description:"Activated via the federation UI",author:"ui",category:"Other",compatibility:{min_version:"0.3.0"},files:[]}),Sg=({federation:s,onActivate:t,onCancel:a,pending:r})=>{var C,T,N;const[n,i]=h.useState("inline-scenario"),[o,c]=h.useState(()=>JSON.stringify(_g(),null,2)),[d,l]=h.useState({}),[m,g]=h.useState(""),y=h.useMemo(()=>s.services||[],[s]),u=vg(),p=w=>{var L;if(g(w),!w)return;const O=(L=u.data)==null?void 0:L.find(I=>I.id===w);O&&(i(O.name),c(JSON.stringify(O.manifest_json,null,2)))},f=async()=>{let w;try{w=JSON.parse(o)}catch(O){alert(`Manifest is not valid JSON: ${O instanceof Error?O.message:"parse error"}`);return}await t({scenario_id:m||void 0,scenario_name:n,manifest:w,service_overrides:d})},j=(w,O,L)=>{l(I=>{const b={...I},A={...b[w]||{}};if(L==="")delete A[O];else if(O==="chaos_level"||O==="failure_rate"||O==="latency_ms"){const _=Number(L);if(Number.isNaN(_))return I;A[O]=_}else A[O]=L;return Object.keys(A).length===0?delete b[w]:b[w]=A,b})};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Pick a saved scenario"}),e.jsxs("select",{value:m,onChange:w=>p(w.target.value),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white",disabled:u.isLoading,children:[e.jsx("option",{value:"",children:u.isLoading?"Loading scenarios…":(C=u.data)!=null&&C.length?"— inline manifest —":"— no saved scenarios; edit manifest below —"}),(T=u.data)==null?void 0:T.map(w=>e.jsxs("option",{value:w.id,children:[w.name," (v",w.current_version,")"]},w.id))]}),u.isError&&e.jsxs("div",{className:"mt-1 text-xs text-red-600 dark:text-red-400",children:["Failed to load scenarios: ",(N=u.error)==null?void 0:N.message]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Scenario name"}),e.jsx("input",{type:"text",value:n,onChange:w=>i(w.target.value),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Manifest JSON"}),e.jsx("textarea",{value:o,onChange:w=>c(w.target.value),rows:10,className:"w-full px-3 py-2 font-mono text-xs border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Per-service overrides"}),y.length===0?e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"This federation has no services configured."}):e.jsx("div",{className:"space-y-3",children:y.map(w=>{var O,L,I,b;return e.jsxs("div",{className:"p-3 bg-gray-50 dark:bg-gray-800 rounded border border-gray-200 dark:border-gray-700",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white mb-2",children:w.name}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-2 text-xs",children:[e.jsxs("label",{className:"flex flex-col",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Reality level"}),e.jsxs("select",{value:((O=d[w.name])==null?void 0:O.reality_level)||"",onChange:A=>j(w.name,"reality_level",A.target.value),className:"mt-1 px-2 py-1 border border-gray-300 dark:border-gray-600 rounded bg-white dark:bg-gray-900 text-gray-900 dark:text-white",children:[e.jsx("option",{value:"",children:"(no change)"}),e.jsx("option",{value:"real",children:"real"}),e.jsx("option",{value:"mock_v3",children:"mock_v3"}),e.jsx("option",{value:"blended",children:"blended"}),e.jsx("option",{value:"chaos_driven",children:"chaos_driven"})]})]}),e.jsxs("label",{className:"flex flex-col",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Chaos level (0.0–1.0)"}),e.jsx("input",{type:"number",step:"0.1",min:"0",max:"1",value:((L=d[w.name])==null?void 0:L.chaos_level)??"",onChange:A=>j(w.name,"chaos_level",A.target.value),className:"mt-1 px-2 py-1 border border-gray-300 dark:border-gray-600 rounded bg-white dark:bg-gray-900 text-gray-900 dark:text-white"})]}),e.jsxs("label",{className:"flex flex-col",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Failure rate (0.0–1.0)"}),e.jsx("input",{type:"number",step:"0.1",min:"0",max:"1",value:((I=d[w.name])==null?void 0:I.failure_rate)??"",onChange:A=>j(w.name,"failure_rate",A.target.value),className:"mt-1 px-2 py-1 border border-gray-300 dark:border-gray-600 rounded bg-white dark:bg-gray-900 text-gray-900 dark:text-white"})]}),e.jsxs("label",{className:"flex flex-col",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Latency (ms)"}),e.jsx("input",{type:"number",step:"10",min:"0",value:((b=d[w.name])==null?void 0:b.latency_ms)??"",onChange:A=>j(w.name,"latency_ms",A.target.value),className:"mt-1 px-2 py-1 border border-gray-300 dark:border-gray-600 rounded bg-white dark:bg-gray-900 text-gray-900 dark:text-white"})]})]})]},w.name)})})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:a,className:"px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors",children:"Cancel"}),e.jsx("button",{type:"button",onClick:f,disabled:r||!n.trim(),className:"px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:r?"Activating…":"Activate"})]})]})},Cg=({federation:s,onEdit:t,onBack:a})=>{const{data:r,isLoading:n}=hg(s.id),i=fg(),[o,c]=h.useState(""),[d,l]=h.useState(null),m=r||s,g=async()=>{if(o)try{const u=await i.mutateAsync({federationId:m.id,request:{path:o,method:"GET"}});l(u)}catch(u){alert(`Failed to route request: ${u instanceof Error?u.message:"Unknown error"}`)}},y=u=>{switch(u){case"real":return"bg-blue-100 dark:bg-blue-900 text-blue-800 dark:text-blue-200";case"mock_v3":return"bg-green-100 dark:bg-green-900 text-green-800 dark:text-green-200";case"blended":return"bg-yellow-100 dark:bg-yellow-900 text-yellow-800 dark:text-yellow-200";case"chaos_driven":return"bg-red-100 dark:bg-red-900 text-red-800 dark:text-red-200";default:return"bg-gray-100 dark:bg-gray-800 text-gray-800 dark:text-gray-200"}};return n?e.jsx("div",{className:"flex items-center justify-center p-8",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600"})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[a&&e.jsx("button",{onClick:a,className:"p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white transition-colors",children:e.jsx(so,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsxs("h1",{className:"text-3xl font-bold text-gray-900 dark:text-white flex items-center gap-2",children:[e.jsx(rn,{className:"h-8 w-8 text-blue-600 dark:text-blue-400"}),m.name]}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mt-1",children:m.description||"Federation Details"})]})]}),t&&e.jsxs("button",{onClick:t,className:"flex items-center gap-2 px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors",children:[e.jsx(Ks,{className:"h-4 w-4"}),"Edit"]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs(X,{className:"p-6",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-4",children:"Basic Information"}),e.jsxs("div",{className:"space-y-3 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Federation ID:"}),e.jsx("span",{className:"ml-2 font-mono text-gray-900 dark:text-white",children:m.id})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Organization ID:"}),e.jsx("span",{className:"ml-2 font-mono text-gray-900 dark:text-white",children:m.org_id})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Created:"}),e.jsx("span",{className:"ml-2 text-gray-900 dark:text-white",children:new Date(m.created_at).toLocaleString()})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Updated:"}),e.jsx("span",{className:"ml-2 text-gray-900 dark:text-white",children:new Date(m.updated_at).toLocaleString()})]})]})]}),e.jsxs(X,{className:"p-6",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-4",children:"Services Summary"}),e.jsxs("div",{className:"space-y-2 text-sm",children:[e.jsxs("div",{children:[e.jsx("strong",{children:"Total Services:"})," ",m.services.length]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Reality Levels:"}),e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:["real","mock_v3","blended","chaos_driven"].map(u=>{const p=m.services.filter(f=>f.reality_level===u).length;return p===0?null:e.jsxs("span",{className:`px-2 py-1 rounded text-xs ${y(u)}`,children:[u,": ",p]},u)})})]})]})]})]}),e.jsxs(X,{className:"p-6",children:[e.jsxs("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-4",children:["Services (",m.services.length,")"]}),m.services.length===0?e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"No services configured"}):e.jsx("div",{className:"space-y-4",children:m.services.map((u,p)=>e.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-800 rounded border-l-4 border-blue-600",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:u.name}),e.jsx("span",{className:`px-2 py-1 rounded text-xs ${y(u.reality_level)}`,children:u.reality_level})]}),e.jsxs("div",{className:"space-y-1 text-sm text-gray-600 dark:text-gray-400",children:[e.jsxs("div",{children:[e.jsx("strong",{children:"Workspace ID:"})," ",e.jsx("span",{className:"font-mono",children:u.workspace_id})]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Base Path:"})," ",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-900 px-1 rounded",children:u.base_path})]}),u.dependencies&&u.dependencies.length>0&&e.jsxs("div",{children:[e.jsx("strong",{children:"Dependencies:"})," ",u.dependencies.join(", ")]})]})]},p))})]}),e.jsx(Ng,{federation:m}),e.jsxs(X,{className:"p-6",children:[e.jsxs("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-4 flex items-center gap-2",children:[e.jsx(er,{className:"h-5 w-5"}),"Test Routing"]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:o,onChange:u=>c(u.target.value),placeholder:"/auth/login",className:"flex-1 px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white"}),e.jsx("button",{onClick:g,disabled:!o||i.isPending,className:"px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:"Test Route"})]}),d&&e.jsxs("div",{className:"p-4 bg-green-50 dark:bg-green-900 rounded",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(ua,{className:"h-4 w-4 text-green-600 dark:text-green-400"}),e.jsx("span",{className:"font-medium text-green-900 dark:text-green-200",children:"Routing Successful"})]}),e.jsxs("div",{className:"text-sm text-green-800 dark:text-green-300 space-y-1",children:[e.jsxs("div",{children:[e.jsx("strong",{children:"Service:"})," ",d.service.name]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Workspace ID:"})," ",e.jsx("span",{className:"font-mono",children:d.workspace_id})]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Service Path:"})," ",e.jsx("code",{className:"bg-green-100 dark:bg-green-800 px-1 rounded",children:d.service_path})]})]})]})]})]})]})},Ci=({federation:s,orgId:t,onSave:a,onCancel:r})=>{const[n,i]=h.useState((s==null?void 0:s.name)||""),[o,c]=h.useState((s==null?void 0:s.description)||""),[d,l]=h.useState((s==null?void 0:s.services)||[]),m=gg(),g=xg(),y=()=>{l([...d,{name:"",workspace_id:"",base_path:"",reality_level:"mock_v3",config:{},dependencies:[]}])},u=j=>{l(d.filter((C,T)=>T!==j))},p=(j,C,T)=>{const N=[...d];N[j][C]=T,l(N)},f=async j=>{j.preventDefault();try{s?await g.mutateAsync({id:s.id,data:{name:n,description:o,services:d}}):await m.mutateAsync({name:n,description:o,org_id:t,services:d}),a==null||a()}catch(C){alert(`Failed to save federation: ${C instanceof Error?C.message:"Unknown error"}`)}};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[r&&e.jsx("button",{onClick:r,className:"p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white transition-colors",children:e.jsx(so,{className:"h-5 w-5"})}),e.jsx("h1",{className:"text-3xl font-bold text-gray-900 dark:text-white",children:s?"Edit Federation":"Create Federation"})]}),e.jsxs("form",{onSubmit:f,className:"space-y-6",children:[e.jsx(X,{className:"p-6",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Federation Name"}),e.jsx("input",{type:"text",value:n,onChange:j=>i(j.target.value),required:!0,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Description"}),e.jsx("textarea",{value:o,onChange:j=>c(j.target.value),rows:3,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white"})]})]})}),e.jsxs(X,{className:"p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:["Services (",d.length,")"]}),e.jsxs("button",{type:"button",onClick:y,className:"flex items-center gap-2 px-3 py-1 bg-blue-600 text-white rounded hover:bg-blue-700 transition-colors text-sm",children:[e.jsx(kt,{className:"h-4 w-4"}),"Add Service"]})]}),d.length===0?e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 text-center py-4",children:'No services configured. Click "Add Service" to add one.'}):e.jsx("div",{className:"space-y-4",children:d.map((j,C)=>{var T;return e.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-800 rounded border border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h4",{className:"font-medium text-gray-900 dark:text-white",children:["Service ",C+1]}),e.jsx("button",{type:"button",onClick:()=>u(C),className:"p-1 text-red-600 dark:text-red-400 hover:text-red-700 dark:hover:text-red-300",children:e.jsx(Qe,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Service Name"}),e.jsx("input",{type:"text",value:j.name,onChange:N=>p(C,"name",N.target.value),required:!0,placeholder:"auth",className:"w-full px-2 py-1 text-sm border border-gray-300 dark:border-gray-600 rounded bg-white dark:bg-gray-800 text-gray-900 dark:text-white"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Workspace ID"}),e.jsx("input",{type:"text",value:j.workspace_id,onChange:N=>p(C,"workspace_id",N.target.value),required:!0,placeholder:"550e8400-e29b-41d4-a716-446655440000",className:"w-full px-2 py-1 text-sm border border-gray-300 dark:border-gray-600 rounded bg-white dark:bg-gray-800 text-gray-900 dark:text-white font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Base Path"}),e.jsx("input",{type:"text",value:j.base_path,onChange:N=>p(C,"base_path",N.target.value),required:!0,placeholder:"/auth",className:"w-full px-2 py-1 text-sm border border-gray-300 dark:border-gray-600 rounded bg-white dark:bg-gray-800 text-gray-900 dark:text-white"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Reality Level"}),e.jsxs("select",{value:j.reality_level,onChange:N=>p(C,"reality_level",N.target.value),className:"w-full px-2 py-1 text-sm border border-gray-300 dark:border-gray-600 rounded bg-white dark:bg-gray-800 text-gray-900 dark:text-white",children:[e.jsx("option",{value:"real",children:"Real"}),e.jsx("option",{value:"mock_v3",children:"Mock V3"}),e.jsx("option",{value:"blended",children:"Blended"}),e.jsx("option",{value:"chaos_driven",children:"Chaos Driven"})]})]})]}),e.jsxs("div",{className:"mt-4",children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Dependencies (comma-separated service names)"}),e.jsx("input",{type:"text",value:((T=j.dependencies)==null?void 0:T.join(", "))||"",onChange:N=>p(C,"dependencies",N.target.value.split(",").map(w=>w.trim()).filter(Boolean)),placeholder:"auth, payments",className:"w-full px-2 py-1 text-sm border border-gray-300 dark:border-gray-600 rounded bg-white dark:bg-gray-800 text-gray-900 dark:text-white"})]})]},C)})})]}),e.jsxs("div",{className:"flex items-center justify-end gap-4",children:[r&&e.jsx("button",{type:"button",onClick:r,className:"px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors",children:"Cancel"}),e.jsxs("button",{type:"submit",className:"flex items-center gap-2 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors",children:[e.jsx(Xt,{className:"h-4 w-4"}),"Save Federation"]})]})]})]})},Tg=({orgId:s})=>{const[t,a]=h.useState("list"),[r,n]=h.useState(null),i=l=>{n(l),a("detail")},o=()=>{n(null),a("create")},c=l=>{n(l),a("edit")},d=()=>{n(null),a("list")};return e.jsxs("div",{className:"space-y-6 p-6",children:[t==="list"&&e.jsx(kg,{orgId:s,onSelect:i,onCreate:o}),t==="create"&&e.jsx(Ci,{orgId:s,onSave:()=>a("list"),onCancel:d}),t==="edit"&&r&&e.jsx(Ci,{orgId:s,federation:r,onSave:()=>a("detail"),onCancel:()=>a("detail")}),t==="detail"&&r&&e.jsx(Cg,{federation:r,onEdit:()=>c(r),onBack:d})]})};async function Pg(){const s=localStorage.getItem("auth_token"),t=await fetch("/api/v1/organizations",{headers:{Authorization:`Bearer ${s}`,"Content-Type":"application/json"}});if(!t.ok)throw new Error("Failed to fetch organizations");return t.json()}const Eg=()=>{var n;const{data:s,isLoading:t,error:a}=he({queryKey:["organizations"],queryFn:Pg});if(t)return e.jsx("div",{className:"flex items-center justify-center p-12",children:e.jsx(Is,{className:"w-8 h-8 animate-spin text-blue-600"})});if(a)return e.jsx("div",{className:"p-6 max-w-7xl mx-auto",children:e.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 text-red-700 dark:text-red-300 p-4 rounded-lg flex items-center gap-3",children:[e.jsx(tt,{className:"w-5 h-5 shrink-0"}),e.jsx("p",{children:"Failed to load organizations. Please try again later."})]})});const r=(n=s==null?void 0:s[0])==null?void 0:n.id;return r?e.jsx(Tg,{orgId:r}):e.jsx("div",{className:"p-6 max-w-7xl mx-auto",children:e.jsxs("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 text-yellow-700 dark:text-yellow-300 p-4 rounded-lg flex items-center gap-3",children:[e.jsx(tt,{className:"w-5 h-5 shrink-0"}),e.jsx("p",{children:"No organization found. Please create an organization first."})]})})};var Ag=s=>{switch(s){case"success":return Mg;case"info":return Lg;case"warning":return Rg;case"error":return $g;default:return null}},Og=Array(12).fill(0),Ig=({visible:s,className:t})=>M.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":s},M.createElement("div",{className:"sonner-spinner"},Og.map((a,r)=>M.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),Mg=M.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},M.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),Rg=M.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},M.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),Lg=M.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},M.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),$g=M.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},M.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),Fg=M.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},M.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),M.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),Dg=()=>{let[s,t]=M.useState(document.hidden);return M.useEffect(()=>{let a=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",a),()=>window.removeEventListener("visibilitychange",a)},[]),s},Qr=1,zg=class{constructor(){this.subscribe=s=>(this.subscribers.push(s),()=>{let t=this.subscribers.indexOf(s);this.subscribers.splice(t,1)}),this.publish=s=>{this.subscribers.forEach(t=>t(s))},this.addToast=s=>{this.publish(s),this.toasts=[...this.toasts,s]},this.create=s=>{var t;let{message:a,...r}=s,n=typeof(s==null?void 0:s.id)=="number"||((t=s.id)==null?void 0:t.length)>0?s.id:Qr++,i=this.toasts.find(c=>c.id===n),o=s.dismissible===void 0?!0:s.dismissible;return this.dismissedToasts.has(n)&&this.dismissedToasts.delete(n),i?this.toasts=this.toasts.map(c=>c.id===n?(this.publish({...c,...s,id:n,title:a}),{...c,...s,id:n,dismissible:o,title:a}):c):this.addToast({title:a,...r,dismissible:o,id:n}),n},this.dismiss=s=>(this.dismissedToasts.add(s),s||this.toasts.forEach(t=>{this.subscribers.forEach(a=>a({id:t.id,dismiss:!0}))}),this.subscribers.forEach(t=>t({id:s,dismiss:!0})),s),this.message=(s,t)=>this.create({...t,message:s}),this.error=(s,t)=>this.create({...t,message:s,type:"error"}),this.success=(s,t)=>this.create({...t,type:"success",message:s}),this.info=(s,t)=>this.create({...t,type:"info",message:s}),this.warning=(s,t)=>this.create({...t,type:"warning",message:s}),this.loading=(s,t)=>this.create({...t,type:"loading",message:s}),this.promise=(s,t)=>{if(!t)return;let a;t.loading!==void 0&&(a=this.create({...t,promise:s,type:"loading",message:t.loading,description:typeof t.description!="function"?t.description:void 0}));let r=s instanceof Promise?s:s(),n=a!==void 0,i,o=r.then(async d=>{if(i=["resolve",d],M.isValidElement(d))n=!1,this.create({id:a,type:"default",message:d});else if(Ug(d)&&!d.ok){n=!1;let l=typeof t.error=="function"?await t.error(`HTTP error! status: ${d.status}`):t.error,m=typeof t.description=="function"?await t.description(`HTTP error! status: ${d.status}`):t.description;this.create({id:a,type:"error",message:l,description:m})}else if(t.success!==void 0){n=!1;let l=typeof t.success=="function"?await t.success(d):t.success,m=typeof t.description=="function"?await t.description(d):t.description;this.create({id:a,type:"success",message:l,description:m})}}).catch(async d=>{if(i=["reject",d],t.error!==void 0){n=!1;let l=typeof t.error=="function"?await t.error(d):t.error,m=typeof t.description=="function"?await t.description(d):t.description;this.create({id:a,type:"error",message:l,description:m})}}).finally(()=>{var d;n&&(this.dismiss(a),a=void 0),(d=t.finally)==null||d.call(t)}),c=()=>new Promise((d,l)=>o.then(()=>i[0]==="reject"?l(i[1]):d(i[1])).catch(l));return typeof a!="string"&&typeof a!="number"?{unwrap:c}:Object.assign(a,{unwrap:c})},this.custom=(s,t)=>{let a=(t==null?void 0:t.id)||Qr++;return this.create({jsx:s(a),id:a,...t}),a},this.getActiveToasts=()=>this.toasts.filter(s=>!this.dismissedToasts.has(s.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},Xe=new zg,qg=(s,t)=>{let a=(t==null?void 0:t.id)||Qr++;return Xe.addToast({title:s,...t,id:a}),a},Ug=s=>s&&typeof s=="object"&&"ok"in s&&typeof s.ok=="boolean"&&"status"in s&&typeof s.status=="number",Bg=qg,Vg=()=>Xe.toasts,Kg=()=>Xe.getActiveToasts(),le=Object.assign(Bg,{success:Xe.success,info:Xe.info,warning:Xe.warning,error:Xe.error,custom:Xe.custom,message:Xe.message,promise:Xe.promise,dismiss:Xe.dismiss,loading:Xe.loading},{getHistory:Vg,getToasts:Kg});function Jg(s,{insertAt:t}={}){if(typeof document>"u")return;let a=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t==="top"&&a.firstChild?a.insertBefore(r,a.firstChild):a.appendChild(r),r.styleSheet?r.styleSheet.cssText=s:r.appendChild(document.createTextNode(s))}Jg(`:where(html[dir="ltr"]),:where([data-sonner-toaster][dir="ltr"]){--toast-icon-margin-start: -3px;--toast-icon-margin-end: 4px;--toast-svg-margin-start: -1px;--toast-svg-margin-end: 0px;--toast-button-margin-start: auto;--toast-button-margin-end: 0;--toast-close-button-start: 0;--toast-close-button-end: unset;--toast-close-button-transform: translate(-35%, -35%)}:where(html[dir="rtl"]),:where([data-sonner-toaster][dir="rtl"]){--toast-icon-margin-start: 4px;--toast-icon-margin-end: -3px;--toast-svg-margin-start: 0px;--toast-svg-margin-end: -1px;--toast-button-margin-start: 0;--toast-button-margin-end: auto;--toast-close-button-start: unset;--toast-close-button-end: 0;--toast-close-button-transform: translate(35%, -35%)}:where([data-sonner-toaster]){position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1: hsl(0, 0%, 99%);--gray2: hsl(0, 0%, 97.3%);--gray3: hsl(0, 0%, 95.1%);--gray4: hsl(0, 0%, 93%);--gray5: hsl(0, 0%, 90.9%);--gray6: hsl(0, 0%, 88.7%);--gray7: hsl(0, 0%, 85.8%);--gray8: hsl(0, 0%, 78%);--gray9: hsl(0, 0%, 56.1%);--gray10: hsl(0, 0%, 52.3%);--gray11: hsl(0, 0%, 43.5%);--gray12: hsl(0, 0%, 9%);--border-radius: 8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:none;z-index:999999999;transition:transform .4s ease}:where([data-sonner-toaster][data-lifted="true"]){transform:translateY(-10px)}@media (hover: none) and (pointer: coarse){:where([data-sonner-toaster][data-lifted="true"]){transform:none}}:where([data-sonner-toaster][data-x-position="right"]){right:var(--offset-right)}:where([data-sonner-toaster][data-x-position="left"]){left:var(--offset-left)}:where([data-sonner-toaster][data-x-position="center"]){left:50%;transform:translate(-50%)}:where([data-sonner-toaster][data-y-position="top"]){top:var(--offset-top)}:where([data-sonner-toaster][data-y-position="bottom"]){bottom:var(--offset-bottom)}:where([data-sonner-toast]){--y: translateY(100%);--lift-amount: calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);filter:blur(0);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none;overflow-wrap:anywhere}:where([data-sonner-toast][data-styled="true"]){padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}:where([data-sonner-toast]:focus-visible){box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast][data-y-position="top"]){top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}:where([data-sonner-toast][data-y-position="bottom"]){bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}:where([data-sonner-toast]) :where([data-description]){font-weight:400;line-height:1.4;color:inherit}:where([data-sonner-toast]) :where([data-title]){font-weight:500;line-height:1.5;color:inherit}:where([data-sonner-toast]) :where([data-icon]){display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}:where([data-sonner-toast][data-promise="true"]) :where([data-icon])>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}:where([data-sonner-toast]) :where([data-icon])>*{flex-shrink:0}:where([data-sonner-toast]) :where([data-icon]) svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}:where([data-sonner-toast]) :where([data-content]){display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;cursor:pointer;outline:none;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}:where([data-sonner-toast]) :where([data-button]):focus-visible{box-shadow:0 0 0 2px #0006}:where([data-sonner-toast]) :where([data-button]):first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}:where([data-sonner-toast]) :where([data-cancel]){color:var(--normal-text);background:rgba(0,0,0,.08)}:where([data-sonner-toast][data-theme="dark"]) :where([data-cancel]){background:rgba(255,255,255,.3)}:where([data-sonner-toast]) :where([data-close-button]){position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast] [data-close-button]{background:var(--gray1)}:where([data-sonner-toast]) :where([data-close-button]):focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast]) :where([data-disabled="true"]){cursor:not-allowed}:where([data-sonner-toast]):hover :where([data-close-button]):hover{background:var(--gray2);border-color:var(--gray5)}:where([data-sonner-toast][data-swiping="true"]):before{content:"";position:absolute;left:-50%;right:-50%;height:100%;z-index:-1}:where([data-sonner-toast][data-y-position="top"][data-swiping="true"]):before{bottom:50%;transform:scaleY(3) translateY(50%)}:where([data-sonner-toast][data-y-position="bottom"][data-swiping="true"]):before{top:50%;transform:scaleY(3) translateY(-50%)}:where([data-sonner-toast][data-swiping="false"][data-removed="true"]):before{content:"";position:absolute;inset:0;transform:scaleY(2)}:where([data-sonner-toast]):after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}:where([data-sonner-toast][data-mounted="true"]){--y: translateY(0);opacity:1}:where([data-sonner-toast][data-expanded="false"][data-front="false"]){--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}:where([data-sonner-toast])>*{transition:opacity .4s}:where([data-sonner-toast][data-expanded="false"][data-front="false"][data-styled="true"])>*{opacity:0}:where([data-sonner-toast][data-visible="false"]){opacity:0;pointer-events:none}:where([data-sonner-toast][data-mounted="true"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}:where([data-sonner-toast][data-removed="true"][data-front="true"][data-swipe-out="false"]){--y: translateY(calc(var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="false"]){--y: translateY(40%);opacity:0;transition:transform .5s,opacity .2s}:where([data-sonner-toast][data-removed="true"][data-front="false"]):before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y, 0px)) translate(var(--swipe-amount-x, 0px));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width: 600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--info-bg: hsl(208, 100%, 97%);--info-border: hsl(221, 91%, 91%);--info-text: hsl(210, 92%, 45%);--warning-bg: hsl(49, 100%, 97%);--warning-border: hsl(49, 91%, 91%);--warning-text: hsl(31, 92%, 45%);--error-bg: hsl(359, 100%, 97%);--error-border: hsl(359, 100%, 94%);--error-text: hsl(360, 100%, 45%)}[data-sonner-toaster][data-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-theme=dark]{--normal-bg: #000;--normal-bg-hover: hsl(0, 0%, 12%);--normal-border: hsl(0, 0%, 20%);--normal-border-hover: hsl(0, 0%, 25%);--normal-text: var(--gray1);--success-bg: hsl(150, 100%, 6%);--success-border: hsl(147, 100%, 12%);--success-text: hsl(150, 86%, 65%);--info-bg: hsl(215, 100%, 6%);--info-border: hsl(223, 100%, 12%);--info-text: hsl(216, 87%, 65%);--warning-bg: hsl(64, 100%, 6%);--warning-border: hsl(60, 100%, 12%);--warning-text: hsl(46, 87%, 65%);--error-bg: hsl(358, 76%, 10%);--error-border: hsl(357, 89%, 16%);--error-text: hsl(358, 100%, 81%)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success],[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info],[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning],[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error],[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size: 16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:nth-child(1){animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)} `);function Aa(s){return s.label!==void 0}var Hg=3,Wg="32px",Gg="16px",Ti=4e3,Zg=356,Qg=14,Yg=20,Xg=200;function jt(...s){return s.filter(Boolean).join(" ")}function ex(s){let[t,a]=s.split("-"),r=[];return t&&r.push(t),a&&r.push(a),r}var tx=s=>{var t,a,r,n,i,o,c,d,l,m,g;let{invert:y,toast:u,unstyled:p,interacting:f,setHeights:j,visibleToasts:C,heights:T,index:N,toasts:w,expanded:O,removeToast:L,defaultRichColors:I,closeButton:b,style:A,cancelButtonStyle:_,actionButtonStyle:$,className:ae="",descriptionClassName:U="",duration:z,position:R,gap:P,loadingIcon:V,expandByDefault:v,classNames:x,icons:K,closeButtonAriaLabel:de="Close toast",pauseWhenPageIsHidden:te}=s,[ee,se]=M.useState(null),[Oe,Ye]=M.useState(null),[ne,wt]=M.useState(!1),[nt,it]=M.useState(!1),[mt,ht]=M.useState(!1),[vs,ya]=M.useState(!1),[cr,ba]=M.useState(!1),[dr,Hs]=M.useState(0),[ur,va]=M.useState(0),es=M.useRef(u.duration||z||Ti),ja=M.useRef(null),Nt=M.useRef(null),ve=N===0,fe=N+1<=C,Re=u.type,gt=u.dismissible!==!1,ts=u.className||"",mr=u.descriptionClassName||"",ss=M.useMemo(()=>T.findIndex(ce=>ce.toastId===u.id)||0,[T,u.id]),Jo=M.useMemo(()=>{var ce;return(ce=u.closeButton)!=null?ce:b},[u.closeButton,b]),yn=M.useMemo(()=>u.duration||z||Ti,[u.duration,z]),hr=M.useRef(0),js=M.useRef(0),bn=M.useRef(0),ks=M.useRef(null),[Ho,Wo]=R.split("-"),vn=M.useMemo(()=>T.reduce((ce,Te,Ie)=>Ie>=ss?ce:ce+Te.height,0),[T,ss]),jn=Dg(),Go=u.invert||y,gr=Re==="loading";js.current=M.useMemo(()=>ss*P+vn,[ss,vn]),M.useEffect(()=>{es.current=yn},[yn]),M.useEffect(()=>{wt(!0)},[]),M.useEffect(()=>{let ce=Nt.current;if(ce){let Te=ce.getBoundingClientRect().height;return va(Te),j(Ie=>[{toastId:u.id,height:Te,position:u.position},...Ie]),()=>j(Ie=>Ie.filter(yt=>yt.toastId!==u.id))}},[j,u.id]),M.useLayoutEffect(()=>{if(!ne)return;let ce=Nt.current,Te=ce.style.height;ce.style.height="auto";let Ie=ce.getBoundingClientRect().height;ce.style.height=Te,va(Ie),j(yt=>yt.find(bt=>bt.toastId===u.id)?yt.map(bt=>bt.toastId===u.id?{...bt,height:Ie}:bt):[{toastId:u.id,height:Ie,position:u.position},...yt])},[ne,u.title,u.description,j,u.id]);let Bt=M.useCallback(()=>{it(!0),Hs(js.current),j(ce=>ce.filter(Te=>Te.toastId!==u.id)),setTimeout(()=>{L(u)},Xg)},[u,L,j,js]);M.useEffect(()=>{if(u.promise&&Re==="loading"||u.duration===1/0||u.type==="loading")return;let ce;return O||f||te&&jn?(()=>{if(bn.current{var Te;(Te=u.onAutoClose)==null||Te.call(u,u),Bt()},es.current)),()=>clearTimeout(ce)},[O,f,u,Re,te,jn,Bt]),M.useEffect(()=>{u.delete&&Bt()},[Bt,u.delete]);function Zo(){var ce,Te,Ie;return K!=null&&K.loading?M.createElement("div",{className:jt(x==null?void 0:x.loader,(ce=u==null?void 0:u.classNames)==null?void 0:ce.loader,"sonner-loader"),"data-visible":Re==="loading"},K.loading):V?M.createElement("div",{className:jt(x==null?void 0:x.loader,(Te=u==null?void 0:u.classNames)==null?void 0:Te.loader,"sonner-loader"),"data-visible":Re==="loading"},V):M.createElement(Ig,{className:jt(x==null?void 0:x.loader,(Ie=u==null?void 0:u.classNames)==null?void 0:Ie.loader),visible:Re==="loading"})}return M.createElement("li",{tabIndex:0,ref:Nt,className:jt(ae,ts,x==null?void 0:x.toast,(t=u==null?void 0:u.classNames)==null?void 0:t.toast,x==null?void 0:x.default,x==null?void 0:x[Re],(a=u==null?void 0:u.classNames)==null?void 0:a[Re]),"data-sonner-toast":"","data-rich-colors":(r=u.richColors)!=null?r:I,"data-styled":!(u.jsx||u.unstyled||p),"data-mounted":ne,"data-promise":!!u.promise,"data-swiped":cr,"data-removed":nt,"data-visible":fe,"data-y-position":Ho,"data-x-position":Wo,"data-index":N,"data-front":ve,"data-swiping":mt,"data-dismissible":gt,"data-type":Re,"data-invert":Go,"data-swipe-out":vs,"data-swipe-direction":Oe,"data-expanded":!!(O||v&&ne),style:{"--index":N,"--toasts-before":N,"--z-index":w.length-N,"--offset":`${nt?dr:js.current}px`,"--initial-height":v?"auto":`${ur}px`,...A,...u.style},onDragEnd:()=>{ht(!1),se(null),ks.current=null},onPointerDown:ce=>{gr||!gt||(ja.current=new Date,Hs(js.current),ce.target.setPointerCapture(ce.pointerId),ce.target.tagName!=="BUTTON"&&(ht(!0),ks.current={x:ce.clientX,y:ce.clientY}))},onPointerUp:()=>{var ce,Te,Ie,yt;if(vs||!gt)return;ks.current=null;let bt=Number(((ce=Nt.current)==null?void 0:ce.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Vt=Number(((Te=Nt.current)==null?void 0:Te.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),as=new Date().getTime()-((Ie=ja.current)==null?void 0:Ie.getTime()),vt=ee==="x"?bt:Vt,Kt=Math.abs(vt)/as;if(Math.abs(vt)>=Yg||Kt>.11){Hs(js.current),(yt=u.onDismiss)==null||yt.call(u,u),Ye(ee==="x"?bt>0?"right":"left":Vt>0?"down":"up"),Bt(),ya(!0),ba(!1);return}ht(!1),se(null)},onPointerMove:ce=>{var Te,Ie,yt,bt;if(!ks.current||!gt||((Te=window.getSelection())==null?void 0:Te.toString().length)>0)return;let Vt=ce.clientY-ks.current.y,as=ce.clientX-ks.current.x,vt=(Ie=s.swipeDirections)!=null?Ie:ex(R);!ee&&(Math.abs(as)>1||Math.abs(Vt)>1)&&se(Math.abs(as)>Math.abs(Vt)?"x":"y");let Kt={x:0,y:0};ee==="y"?(vt.includes("top")||vt.includes("bottom"))&&(vt.includes("top")&&Vt<0||vt.includes("bottom")&&Vt>0)&&(Kt.y=Vt):ee==="x"&&(vt.includes("left")||vt.includes("right"))&&(vt.includes("left")&&as<0||vt.includes("right")&&as>0)&&(Kt.x=as),(Math.abs(Kt.x)>0||Math.abs(Kt.y)>0)&&ba(!0),(yt=Nt.current)==null||yt.style.setProperty("--swipe-amount-x",`${Kt.x}px`),(bt=Nt.current)==null||bt.style.setProperty("--swipe-amount-y",`${Kt.y}px`)}},Jo&&!u.jsx?M.createElement("button",{"aria-label":de,"data-disabled":gr,"data-close-button":!0,onClick:gr||!gt?()=>{}:()=>{var ce;Bt(),(ce=u.onDismiss)==null||ce.call(u,u)},className:jt(x==null?void 0:x.closeButton,(n=u==null?void 0:u.classNames)==null?void 0:n.closeButton)},(i=K==null?void 0:K.close)!=null?i:Fg):null,u.jsx||h.isValidElement(u.title)?u.jsx?u.jsx:typeof u.title=="function"?u.title():u.title:M.createElement(M.Fragment,null,Re||u.icon||u.promise?M.createElement("div",{"data-icon":"",className:jt(x==null?void 0:x.icon,(o=u==null?void 0:u.classNames)==null?void 0:o.icon)},u.promise||u.type==="loading"&&!u.icon?u.icon||Zo():null,u.type!=="loading"?u.icon||(K==null?void 0:K[Re])||Ag(Re):null):null,M.createElement("div",{"data-content":"",className:jt(x==null?void 0:x.content,(c=u==null?void 0:u.classNames)==null?void 0:c.content)},M.createElement("div",{"data-title":"",className:jt(x==null?void 0:x.title,(d=u==null?void 0:u.classNames)==null?void 0:d.title)},typeof u.title=="function"?u.title():u.title),u.description?M.createElement("div",{"data-description":"",className:jt(U,mr,x==null?void 0:x.description,(l=u==null?void 0:u.classNames)==null?void 0:l.description)},typeof u.description=="function"?u.description():u.description):null),h.isValidElement(u.cancel)?u.cancel:u.cancel&&Aa(u.cancel)?M.createElement("button",{"data-button":!0,"data-cancel":!0,style:u.cancelButtonStyle||_,onClick:ce=>{var Te,Ie;Aa(u.cancel)&>&&((Ie=(Te=u.cancel).onClick)==null||Ie.call(Te,ce),Bt())},className:jt(x==null?void 0:x.cancelButton,(m=u==null?void 0:u.classNames)==null?void 0:m.cancelButton)},u.cancel.label):null,h.isValidElement(u.action)?u.action:u.action&&Aa(u.action)?M.createElement("button",{"data-button":!0,"data-action":!0,style:u.actionButtonStyle||$,onClick:ce=>{var Te,Ie;Aa(u.action)&&((Ie=(Te=u.action).onClick)==null||Ie.call(Te,ce),!ce.defaultPrevented&&Bt())},className:jt(x==null?void 0:x.actionButton,(g=u==null?void 0:u.classNames)==null?void 0:g.actionButton)},u.action.label):null))};function Pi(){if(typeof window>"u"||typeof document>"u")return"ltr";let s=document.documentElement.getAttribute("dir");return s==="auto"||!s?window.getComputedStyle(document.documentElement).direction:s}function sx(s,t){let a={};return[s,t].forEach((r,n)=>{let i=n===1,o=i?"--mobile-offset":"--offset",c=i?Gg:Wg;function d(l){["top","right","bottom","left"].forEach(m=>{a[`${o}-${m}`]=typeof l=="number"?`${l}px`:l})}typeof r=="number"||typeof r=="string"?d(r):typeof r=="object"?["top","right","bottom","left"].forEach(l=>{r[l]===void 0?a[`${o}-${l}`]=c:a[`${o}-${l}`]=typeof r[l]=="number"?`${r[l]}px`:r[l]}):d(c)}),a}h.forwardRef(function(s,t){let{invert:a,position:r="bottom-right",hotkey:n=["altKey","KeyT"],expand:i,closeButton:o,className:c,offset:d,mobileOffset:l,theme:m="light",richColors:g,duration:y,style:u,visibleToasts:p=Hg,toastOptions:f,dir:j=Pi(),gap:C=Qg,loadingIcon:T,icons:N,containerAriaLabel:w="Notifications",pauseWhenPageIsHidden:O}=s,[L,I]=M.useState([]),b=M.useMemo(()=>Array.from(new Set([r].concat(L.filter(te=>te.position).map(te=>te.position)))),[L,r]),[A,_]=M.useState([]),[$,ae]=M.useState(!1),[U,z]=M.useState(!1),[R,P]=M.useState(m!=="system"?m:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),V=M.useRef(null),v=n.join("+").replace(/Key/g,"").replace(/Digit/g,""),x=M.useRef(null),K=M.useRef(!1),de=M.useCallback(te=>{I(ee=>{var se;return(se=ee.find(Oe=>Oe.id===te.id))!=null&&se.delete||Xe.dismiss(te.id),ee.filter(({id:Oe})=>Oe!==te.id)})},[]);return M.useEffect(()=>Xe.subscribe(te=>{if(te.dismiss){I(ee=>ee.map(se=>se.id===te.id?{...se,delete:!0}:se));return}setTimeout(()=>{el.flushSync(()=>{I(ee=>{let se=ee.findIndex(Oe=>Oe.id===te.id);return se!==-1?[...ee.slice(0,se),{...ee[se],...te},...ee.slice(se+1)]:[te,...ee]})})})}),[]),M.useEffect(()=>{if(m!=="system"){P(m);return}if(m==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?P("dark"):P("light")),typeof window>"u")return;let te=window.matchMedia("(prefers-color-scheme: dark)");try{te.addEventListener("change",({matches:ee})=>{P(ee?"dark":"light")})}catch{te.addListener(({matches:se})=>{try{P(se?"dark":"light")}catch(Oe){console.error(Oe)}})}},[m]),M.useEffect(()=>{L.length<=1&&ae(!1)},[L]),M.useEffect(()=>{let te=ee=>{var se,Oe;n.every(Ye=>ee[Ye]||ee.code===Ye)&&(ae(!0),(se=V.current)==null||se.focus()),ee.code==="Escape"&&(document.activeElement===V.current||(Oe=V.current)!=null&&Oe.contains(document.activeElement))&&ae(!1)};return document.addEventListener("keydown",te),()=>document.removeEventListener("keydown",te)},[n]),M.useEffect(()=>{if(V.current)return()=>{x.current&&(x.current.focus({preventScroll:!0}),x.current=null,K.current=!1)}},[V.current]),M.createElement("section",{ref:t,"aria-label":`${w} ${v}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},b.map((te,ee)=>{var se;let[Oe,Ye]=te.split("-");return L.length?M.createElement("ol",{key:te,dir:j==="auto"?Pi():j,tabIndex:-1,ref:V,className:c,"data-sonner-toaster":!0,"data-theme":R,"data-y-position":Oe,"data-lifted":$&&L.length>1&&!i,"data-x-position":Ye,style:{"--front-toast-height":`${((se=A[0])==null?void 0:se.height)||0}px`,"--width":`${Zg}px`,"--gap":`${C}px`,...u,...sx(d,l)},onBlur:ne=>{K.current&&!ne.currentTarget.contains(ne.relatedTarget)&&(K.current=!1,x.current&&(x.current.focus({preventScroll:!0}),x.current=null))},onFocus:ne=>{ne.target instanceof HTMLElement&&ne.target.dataset.dismissible==="false"||K.current||(K.current=!0,x.current=ne.relatedTarget)},onMouseEnter:()=>ae(!0),onMouseMove:()=>ae(!0),onMouseLeave:()=>{U||ae(!1)},onDragEnd:()=>ae(!1),onPointerDown:ne=>{ne.target instanceof HTMLElement&&ne.target.dataset.dismissible==="false"||z(!0)},onPointerUp:()=>z(!1)},L.filter(ne=>!ne.position&&ee===0||ne.position===te).map((ne,wt)=>{var nt,it;return M.createElement(tx,{key:ne.id,icons:N,index:wt,toast:ne,defaultRichColors:g,duration:(nt=f==null?void 0:f.duration)!=null?nt:y,className:f==null?void 0:f.className,descriptionClassName:f==null?void 0:f.descriptionClassName,invert:a,visibleToasts:p,closeButton:(it=f==null?void 0:f.closeButton)!=null?it:o,interacting:U,position:te,style:f==null?void 0:f.style,unstyled:f==null?void 0:f.unstyled,classNames:f==null?void 0:f.classNames,cancelButtonStyle:f==null?void 0:f.cancelButtonStyle,actionButtonStyle:f==null?void 0:f.actionButtonStyle,removeToast:de,toasts:L.filter(mt=>mt.position==ne.position),heights:A.filter(mt=>mt.position==ne.position),setHeights:_,expandByDefault:i,gap:C,loadingIcon:T,expanded:$,pauseWhenPageIsHidden:O,swipeDirections:s.swipeDirections})})):null}))});const or=h.createContext(null),Lo=({children:s,value:t,onValueChange:a,defaultValue:r,id:n,error:i,errorId:o})=>{const[c,d]=h.useState(r||t||""),[l,m]=h.useState([]),g=t||c,y=!!i,u=f=>{d(f),a==null||a(f)},p=h.useCallback((f,j)=>{m(C=>C.some(T=>T.value===f)?C:[...C,{value:f,label:j}])},[]);return e.jsx(or.Provider,{value:{value:g,onValueChange:u,id:n,options:l,addOption:p,hasError:y,errorId:o},children:s})},$o=({placeholder:s,children:t})=>{const a=h.useContext(or);return e.jsx("span",{children:t||(a==null?void 0:a.value)||s})},xn=h.forwardRef(({className:s,children:t,"aria-describedby":a,...r},n)=>{const i=h.useContext(or),o=[a,i==null?void 0:i.errorId].filter(Boolean).join(" ")||void 0;return e.jsx("select",{ref:n,id:i==null?void 0:i.id,role:"combobox",value:i==null?void 0:i.value,onChange:c=>i==null?void 0:i.onValueChange(c.target.value),"aria-invalid":(i==null?void 0:i.hasError)||void 0,"aria-describedby":o,className:D("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",(i==null?void 0:i.hasError)&&"border-red-500 focus:ring-red-500",s),...r,children:i==null?void 0:i.options.map(c=>e.jsx("option",{value:c.value,children:c.label},c.value))})});xn.displayName="SelectTrigger";const pn=h.forwardRef(({className:s,children:t,position:a="popper",...r},n)=>e.jsx("div",{ref:n,"data-select-content":!0,className:D("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md p-1 hidden",s),...r,children:t}));pn.displayName="SelectContent";const ax=h.forwardRef(({className:s,...t},a)=>e.jsx("div",{ref:a,className:D("py-1.5 pl-8 pr-2 text-sm font-semibold",s),...t}));ax.displayName="SelectLabel";const Za=h.forwardRef(({className:s,children:t,value:a,...r},n)=>{const i=h.useContext(or);return h.useEffect(()=>{i&&typeof t=="string"&&i.addOption(a,t)},[i,a,t]),e.jsxs("div",{ref:n,className:D("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s),"data-value":a,...r,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(no,{className:"h-4 w-4"})}),t]})});Za.displayName="SelectItem";const rx=h.forwardRef(({className:s,...t},a)=>e.jsx("div",{ref:a,className:D("-mx-1 my-1 h-px bg-muted",s),...t}));rx.displayName="SelectSeparator";function Oy({items:s,position:t,onClose:a,className:r}){const n=h.useRef(null);h.useEffect(()=>{const o=d=>{n.current&&!n.current.contains(d.target)&&a()},c=d=>{d.key==="Escape"&&a()};return document.addEventListener("mousedown",o),document.addEventListener("keydown",c),()=>{document.removeEventListener("mousedown",o),document.removeEventListener("keydown",c)}},[a]);const i=M.useMemo(()=>{if(!n.current)return t;const o=n.current.getBoundingClientRect(),c=window.innerWidth,d=window.innerHeight;let l=t.x,m=t.y;return l+o.width>c&&(l=c-o.width-10),m+o.height>d&&(m=d-o.height-10),{x:l,y:m}},[t]);return e.jsx("div",{ref:n,className:D("fixed z-50 bg-popover border border-border rounded-md shadow-lg py-1 min-w-[200px]",r),style:{left:i.x,top:i.y},children:s.map((o,c)=>e.jsxs(M.Fragment,{children:[o.separator&&e.jsx("div",{className:"border-t border-border my-1"}),e.jsxs("button",{onClick:()=>{o.disabled||(o.onClick(),a())},disabled:o.disabled,className:D("w-full px-3 py-2 text-left text-sm hover:bg-accent hover:text-accent-foreground flex items-center gap-2","focus:outline-none focus:bg-accent focus:text-accent-foreground",o.disabled&&"opacity-50 cursor-not-allowed"),children:[o.icon&&e.jsx("span",{className:"w-4 h-4 flex items-center justify-center",children:o.icon}),e.jsx("span",{children:o.label})]})]},c))})}function nx({children:s}){return e.jsx(e.Fragment,{children:s})}function ix({children:s,onContextMenu:t}){return e.jsx("div",{onContextMenu:t,children:s})}function ox({children:s,className:t}){return e.jsx("div",{className:D("bg-white border border-gray-200 rounded-md shadow-lg py-1 min-w-[200px]",t),children:s})}const lx=[{hex:"#3B82F6",name:"Blue"},{hex:"#EF4444",name:"Red"},{hex:"#10B981",name:"Green"},{hex:"#F59E0B",name:"Yellow"},{hex:"#8B5CF6",name:"Purple"},{hex:"#F97316",name:"Orange"},{hex:"#06B6D4",name:"Cyan"},{hex:"#84CC16",name:"Lime"}];function cx({workspaceId:s,onEnvironmentSelect:t}){const a=gn(),[r,n]=h.useState(!1),[i,o]=h.useState(null),[c,d]=h.useState({name:"",description:""}),[l,m]=h.useState({}),[g,y]=h.useState(null),[u,p]=h.useState(null),{data:f,isLoading:j,error:C}=$0(s),T=F0(s),N=D0(s,(i==null?void 0:i.id)||""),w=z0(s),O=q0(s),L=V0(s),I=async()=>{if(!c.name.trim()){ot.error("Environment name is required");return}try{await T.mutateAsync({...c,name:c.name.trim()}),ot.success(`Environment "${c.name}" created successfully`),d({name:"",description:""}),n(!1)}catch{ot.error("Failed to create environment")}},b=async()=>{if(i)try{await N.mutateAsync(l),ot.success(`Environment "${i.name}" updated successfully`),o(null),m({}),y(null)}catch{ot.error("Failed to update environment")}},A=async P=>{if(P.is_global){ot.error("Cannot delete global environment");return}if(a(`Are you sure you want to delete "${P.name}"? This action cannot be undone.`))try{await w.mutateAsync(P.id),ot.success(`Environment "${P.name}" deleted successfully`)}catch{ot.error("Failed to delete environment")}},_=async P=>{try{const V=P.is_global?"global":P.id;await O.mutateAsync(V),ot.success(`Switched to "${P.name}" environment`),t==null||t(P.id)}catch{ot.error("Failed to switch environment")}},$=P=>{o(P),m({name:P.name,description:P.description}),y(P.color||null)},ae=(P,V)=>{p(V),P.dataTransfer.effectAllowed="move"},U=P=>{P.preventDefault(),P.dataTransfer.dropEffect="move"},z=async(P,V)=>{if(P.preventDefault(),!u||u===V){p(null);return}if(!(f!=null&&f.environments)){p(null);return}try{const v=f.environments.findIndex(ee=>ee.id===u),x=f.environments.findIndex(ee=>ee.id===V);if(v===-1||x===-1){p(null);return}const K=[...f.environments],[de]=K.splice(v,1);K.splice(x,0,de);const te=K.map(ee=>ee.id);try{await L.mutateAsync(te),ot.success("Environment order updated")}catch{throw ot.error("Failed to update environment order"),C}}catch{ot.error("Failed to update environment order")}finally{p(null)}},R=({environment:P})=>{const{data:V}=U0(s,P.id),v=u===P.id;return e.jsxs(nx,{children:[e.jsx(ix,{children:e.jsxs(pt,{draggable:!P.is_global,onDragStart:x=>ae(x,P.id),onDragOver:U,onDrop:x=>z(x,P.id),className:`cursor-pointer transition-all duration-200 hover:shadow-lg ${P.active?"ring-2 ring-blue-500 bg-blue-50 dark:bg-blue-900/20":"hover:bg-gray-50 dark:hover:bg-gray-800/50"} ${v?"opacity-50":""} ${P.is_global?"":"cursor-move"}`,onClick:()=>_(P),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[!P.is_global&&e.jsx("div",{className:"cursor-move p-1 hover:bg-gray-100 dark:hover:bg-gray-700 rounded",children:e.jsx(Td,{className:"w-4 h-4 text-gray-400"})}),P.color&&e.jsx("div",{className:"w-4 h-4 rounded-full border-2 border-white shadow-sm",style:{backgroundColor:P.color.hex}}),e.jsxs("div",{children:[e.jsxs("h3",{className:"font-medium text-gray-900 dark:text-gray-100",children:[P.name,P.is_global&&e.jsx("span",{className:"ml-2 text-xs text-gray-500 dark:text-gray-400",children:"(Global)"})]}),P.description&&e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:P.description})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:[P.variable_count," vars"]}),P.active&&e.jsx("div",{className:"w-2 h-2 bg-blue-500 rounded-full"})]})]}),V&&V.variables.length>0&&e.jsx("div",{className:"mt-3 pt-3 border-t border-gray-200 dark:border-gray-700",children:e.jsxs("div",{className:"flex flex-wrap gap-1",children:[V.variables.slice(0,3).map(x=>e.jsx("span",{className:"inline-flex items-center px-2 py-1 rounded-md text-xs font-medium bg-gray-100 dark:bg-gray-800 text-gray-800 dark:text-gray-200",children:x.name},x.name)),V.variables.length>3&&e.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:["+",V.variables.length-3," more"]})]})})]})}),e.jsxs(ox,{children:[e.jsxs(kr,{onClick:()=>_(P),children:[e.jsx(er,{className:"w-4 h-4 mr-2"}),"Set as Active"]}),e.jsxs(kr,{onClick:()=>$(P),children:[e.jsx(Tt,{className:"w-4 h-4 mr-2"}),"Edit Environment"]}),!P.is_global&&e.jsxs(kr,{onClick:()=>A(P),className:"text-red-600 dark:text-red-400",children:[e.jsx(Qe,{className:"w-4 h-4 mr-2"}),"Delete Environment"]})]})]})};return j?e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:"Environments"})}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[...Array(3)].map((P,V)=>e.jsx("div",{className:"animate-pulse",children:e.jsx("div",{className:"h-24 bg-gray-200 dark:bg-gray-700 rounded-lg"})},V))})]}):C?e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:"Environments"})}),e.jsx("div",{className:"text-center py-8 text-red-600 dark:text-red-400",children:"Failed to load environments"})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:"Environments"}),e.jsxs(qe,{open:r,onOpenChange:n,children:[e.jsx(Dr,{asChild:!0,children:e.jsxs(k,{className:"flex items-center gap-2",children:[e.jsx(kt,{className:"w-4 h-4"}),"New Environment"]})}),e.jsxs(Ue,{children:[e.jsx(Be,{children:e.jsx(Ve,{children:"Create New Environment"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Name"}),e.jsx(B,{value:c.name,onChange:P=>d(V=>({...V,name:P.target.value})),placeholder:"e.g., Development, Staging, Production"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Description (Optional)"}),e.jsx(B,{value:c.description||"",onChange:P=>d(V=>({...V,description:P.target.value})),placeholder:"Brief description of this environment"})]})]}),e.jsxs(Ke,{children:[e.jsx(k,{variant:"outline",onClick:()=>n(!1),children:"Cancel"}),e.jsx(k,{onClick:I,disabled:T.isPending,children:T.isPending?"Creating...":"Create Environment"})]})]})]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:((f==null?void 0:f.environments)||[]).sort((P,V)=>P.is_global&&!V.is_global?-1:!P.is_global&&V.is_global?1:(P.order||0)-(V.order||0)).map(P=>e.jsx(R,{environment:P},P.id))}),e.jsx(qe,{open:!!i,onOpenChange:P=>!P&&o(null),children:e.jsxs(Ue,{children:[e.jsx(Be,{children:e.jsx(Ve,{children:"Edit Environment"})}),i&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Name"}),e.jsx(B,{value:l.name||"",onChange:P=>m(V=>({...V,name:P.target.value}))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Description (Optional)"}),e.jsx(B,{value:l.description||"",onChange:P=>m(V=>({...V,description:P.target.value}))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Color (Optional)"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:lx.map(P=>e.jsx("button",{onClick:()=>y(P),className:`w-8 h-8 rounded-full border-2 ${(g==null?void 0:g.hex)===P.hex?"border-gray-900 dark:border-gray-100":"border-gray-300 dark:border-gray-600"}`,style:{backgroundColor:P.hex},title:P.name},P.hex))}),g&&e.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[e.jsx("div",{className:"w-4 h-4 rounded-full border border-gray-300",style:{backgroundColor:g.hex}}),e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:g.name})]})]})]}),e.jsxs(Ke,{children:[e.jsx(k,{variant:"outline",onClick:()=>o(null),children:"Cancel"}),e.jsx(k,{onClick:b,disabled:N.isPending,children:N.isPending?"Updating...":"Update Environment"})]})]})})]})}function dx({value:s,onChange:t,onSelect:a,placeholder:r,className:n,workspaceId:i,context:o,disabled:c=!1}){var N;const[d,l]=h.useState(!1),[m,g]=h.useState(-1),y=h.useRef(null),u=h.useRef(null),p=B0(i),f=h.useCallback(w=>{if(!p.data)return;const{start_position:O,end_position:L}=p.data,I=s.slice(0,O),b=s.slice(L),A=`${I}{{${w.text}}}}${b}`,_=I.length+w.text.length+4;t(A),a==null||a(w),setTimeout(()=>{var $,ae;($=y.current)==null||$.setSelectionRange(_,_),(ae=y.current)==null||ae.focus()},0),l(!1),g(-1)},[s,t,a,p.data]),j=h.useCallback(w=>{const O=w.target.value,L=w.target.selectionStart||0;t(O);const I=O.slice(0,L);if(I.includes("{{")){const A=I.lastIndexOf("{{");I.slice(A+2).length>0||I.endsWith("{{")?(p.mutate({input:O,cursor_position:L,context:o}),l(!0),g(-1)):l(!1)}else l(!1)},[t,o,p]),C=h.useCallback(w=>{var L,I,b;if(!d||!((L=p.data)!=null&&L.suggestions.length)){if(w.ctrlKey&&w.key===" "){w.preventDefault();const A=((I=y.current)==null?void 0:I.value)||"",_=((b=y.current)==null?void 0:b.selectionStart)||0;p.mutate({input:A,cursor_position:_,context:o}),l(!0),g(-1)}return}const O=p.data.suggestions;switch(w.key){case"ArrowDown":w.preventDefault(),g(A=>(A+1)%O.length);break;case"ArrowUp":w.preventDefault(),g(A=>A<=0?O.length-1:A-1);break;case"Enter":case"Tab":m>=0&&(w.preventDefault(),f(O[m]));break;case"Escape":l(!1),g(-1);break}},[d,m,p.data,o,p,f]);h.useEffect(()=>{const w=O=>{u.current&&!u.current.contains(O.target)&&y.current&&!y.current.contains(O.target)&&(l(!1),g(-1))};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[]);const T=((N=p.data)==null?void 0:N.suggestions)||[];return e.jsxs("div",{className:"relative",children:[e.jsx("input",{ref:y,type:"text",value:s,onChange:j,onKeyDown:C,placeholder:r,className:n,disabled:c,autoComplete:"off",spellCheck:!1}),d&&T.length>0&&e.jsx("div",{ref:u,className:"absolute z-50 w-full mt-1 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-md shadow-lg max-h-60 overflow-y-auto",children:T.map((w,O)=>e.jsxs("div",{className:`px-3 py-2 cursor-pointer border-b border-gray-100 dark:border-gray-700 last:border-b-0 ${O===m?"bg-blue-50 dark:bg-blue-900/20 text-blue-700 dark:text-blue-300":"hover:bg-gray-50 dark:hover:bg-gray-700"}`,onClick:()=>f(w),children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-gray-900 dark:text-gray-100",children:w.text}),e.jsx("span",{className:`text-xs px-2 py-1 rounded ${w.kind==="variable"?"bg-green-100 dark:bg-green-900/20 text-green-700 dark:text-green-300":"bg-blue-100 dark:bg-blue-900/20 text-blue-700 dark:text-blue-300"}`,children:w.kind})]})}),w.documentation&&e.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-400 mt-1",children:w.documentation})]},`${w.kind}-${w.text}`))}),p.isPending&&d&&e.jsx("div",{className:"absolute right-3 top-1/2 transform -translate-y-1/2",children:e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-blue-600"})}),e.jsx("div",{className:"absolute right-3 top-1/2 transform -translate-y-1/2 text-xs text-gray-400 dark:text-gray-500 opacity-0 group-hover:opacity-100 transition-opacity",children:"Ctrl+Space"})]})}function Fo({onOpenPresetManager:s,enabled:t=!0,defaultLevel:a=3}={}){const r=Mo(),n=h.useRef(s);n.current!==s&&(n.current=s);const i=h.useCallback(l=>{if(r.isPending)return;const m=["Static Stubs","Light Simulation","Moderate Realism","High Realism","Production Chaos"];r.mutate(l,{onSuccess:()=>{le.success(`Reality level set to ${l}: ${m[l-1]}`,{description:"Press Ctrl+Shift+R to reset to default"})},onError:g=>{le.error("Failed to set reality level",{description:g instanceof Error?g.message:"Unknown error"})}})},[r]),o=h.useCallback(()=>{r.isPending||i(a)},[a,i,r]),c=h.useCallback(()=>{n.current?n.current():le.info("Preset manager not available",{description:"Navigate to Configuration > Reality Slider to manage presets"})},[]),d=[{key:"1",ctrl:!0,shift:!0,handler:()=>i(1),description:"Set reality level to 1 (Static Stubs)",enabled:t},{key:"2",ctrl:!0,shift:!0,handler:()=>i(2),description:"Set reality level to 2 (Light Simulation)",enabled:t},{key:"3",ctrl:!0,shift:!0,handler:()=>i(3),description:"Set reality level to 3 (Moderate Realism)",enabled:t},{key:"4",ctrl:!0,shift:!0,handler:()=>i(4),description:"Set reality level to 4 (High Realism)",enabled:t},{key:"5",ctrl:!0,shift:!0,handler:()=>i(5),description:"Set reality level to 5 (Production Chaos)",enabled:t},{key:"r",ctrl:!0,shift:!0,handler:o,description:`Reset reality level to ${a} (default)`,enabled:t},{key:"p",ctrl:!0,shift:!0,handler:c,description:"Open preset manager",enabled:t&&!!s}];return So({shortcuts:d,enabled:t}),{shortcuts:d.map(l=>({key:l.key,modifiers:{ctrl:l.ctrl,shift:l.shift,alt:l.alt,meta:l.meta},description:l.description}))}}const Yr=h.forwardRef(({className:s,min:t=0,max:a=100,step:r=1,value:n,onChange:i,unit:o,label:c,showValue:d=!0,description:l,disabled:m,...g},y)=>{const[u,p]=h.useState(n??t);h.useEffect(()=>{n!==void 0&&p(n)},[n]);const f=T=>{const N=parseFloat(T.target.value);p(N),i==null||i(N)},j=n!==void 0?n:u,C=(j-t)/(a-t)*100;return e.jsxs("div",{className:"w-full space-y-2",children:[(c||d)&&e.jsxs("div",{className:"flex items-center justify-between",children:[c&&e.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:c}),d&&e.jsxs("span",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100 tabular-nums",children:[j.toLocaleString(),o&&e.jsx("span",{className:"ml-1 text-gray-500 dark:text-gray-400",children:o})]})]}),e.jsx("div",{className:"relative flex items-center",children:e.jsx("input",{type:"range",ref:y,min:t,max:a,step:r,value:j,onChange:f,disabled:m,className:D("h-2 w-full appearance-none rounded-lg bg-gray-200 dark:bg-gray-700 outline-none transition-all","disabled:opacity-50 disabled:cursor-not-allowed","[&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:h-4 [&::-webkit-slider-thumb]:w-4 [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-blue-600 dark:[&::-webkit-slider-thumb]:bg-blue-500 [&::-webkit-slider-thumb]:cursor-pointer [&::-webkit-slider-thumb]:shadow-sm [&::-webkit-slider-thumb]:transition-all [&::-webkit-slider-thumb]:hover:bg-blue-700 dark:[&::-webkit-slider-thumb]:hover:bg-blue-400 [&::-webkit-slider-thumb]:active:scale-110","[&::-moz-range-thumb]:h-4 [&::-moz-range-thumb]:w-4 [&::-moz-range-thumb]:rounded-full [&::-moz-range-thumb]:bg-blue-600 dark:[&::-moz-range-thumb]:bg-blue-500 [&::-moz-range-thumb]:border-0 [&::-moz-range-thumb]:cursor-pointer [&::-moz-range-thumb]:shadow-sm [&::-moz-range-thumb]:transition-all [&::-moz-range-thumb]:hover:bg-blue-700 dark:[&::-moz-range-thumb]:hover:bg-blue-400","before:absolute before:left-0 before:top-0 before:h-2 before:rounded-lg before:bg-blue-600 dark:before:bg-blue-500 before:pointer-events-none",s),style:{"--track-fill":`${C}%`,background:"linear-gradient(to right, rgb(37 99 235) 0%, rgb(37 99 235) var(--track-fill), rgb(229 231 235) var(--track-fill), rgb(229 231 235) 100%)"},...g})}),l&&e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:l}),e.jsxs("div",{className:"flex items-center justify-between text-xs text-gray-400 dark:text-gray-500",children:[e.jsxs("span",{children:[t,o&&` ${o}`]}),e.jsxs("span",{children:[a,o&&` ${o}`]})]})]})});Yr.displayName="Slider";function je({children:s,variant:t="default",className:a,...r}){const n={default:"bg-muted text-muted-foreground",secondary:"bg-secondary text-secondary-foreground",success:"bg-success/15 text-success",warning:"bg-warning/15 text-warning",danger:"bg-danger/15 text-danger",destructive:"bg-red-100 text-red-700 dark:bg-red-900/20 dark:text-red-400",error:"bg-danger/15 text-danger",brand:"bg-brand/15 text-brand",info:"bg-blue-100 text-blue-700 dark:bg-blue-900/20 dark:text-blue-400",outline:"border border-gray-300 dark:border-gray-700 text-gray-700 dark:text-gray-300"};return e.jsx("span",{className:D("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium transition-colors",n[t],a),...r,children:s})}function Do({content:s,children:t}){return e.jsxs("div",{className:"relative group inline-block",children:[t,e.jsxs("div",{className:"absolute bottom-full left-1/2 transform -translate-x-1/2 mb-2 px-2 py-1 text-xs text-white bg-gray-900 dark:bg-gray-700 rounded opacity-0 invisible group-hover:opacity-100 group-hover:visible transition-all duration-200 whitespace-nowrap z-50 pointer-events-none",children:[s,e.jsx("div",{className:"absolute top-full left-1/2 transform -translate-x-1/2 -mt-1 border-4 border-transparent border-t-gray-900 dark:border-t-gray-700"})]})]})}const cs=[{value:1,name:"Static Stubs",description:"Simple, instant responses with no chaos",icon:Zt,color:"text-gray-500",bgColor:"bg-gray-100 dark:bg-gray-800",borderColor:"border-gray-300 dark:border-gray-700",features:["No chaos","0ms latency","No AI"]},{value:2,name:"Light Simulation",description:"Minimal latency, basic intelligence",icon:gs,color:"text-blue-500",bgColor:"bg-blue-50 dark:bg-blue-900/20",borderColor:"border-blue-300 dark:border-blue-700",features:["No chaos","10-50ms latency","Basic AI"]},{value:3,name:"Moderate Realism",description:"Some chaos, moderate latency, full intelligence",icon:oo,color:"text-green-500",bgColor:"bg-green-50 dark:bg-green-900/20",borderColor:"border-green-300 dark:border-green-700",features:["5% errors, 10% delays","50-200ms latency","Full AI"]},{value:4,name:"High Realism",description:"Increased chaos, realistic latency, session state",icon:Dt,color:"text-orange-500",bgColor:"bg-orange-50 dark:bg-orange-900/20",borderColor:"border-orange-300 dark:border-orange-700",features:["10% errors, 20% delays","100-500ms latency","AI + Sessions"]},{value:5,name:"Production Chaos",description:"Maximum chaos, production-like latency, full features",icon:dt,color:"text-red-500",bgColor:"bg-red-50 dark:bg-red-900/20",borderColor:"border-red-300 dark:border-red-700",features:["15% errors, 30% delays","200-2000ms latency","Full AI + Mutations"]}];function ux({className:s,compact:t=!1}){const{data:a,isLoading:r}=Io(),n=Mo(),[i,o]=h.useState(3),[c,d]=h.useState(!1);Fo({enabled:!t}),h.useEffect(()=>{a!=null&&a.level&&o(a.level)},[a]);const l=(a==null?void 0:a.level)??i,m=cs.find(j=>j.value===l)||cs[2],g=m.icon,y=M.useRef(null),u=h.useCallback(j=>{o(j),d(!0),y.current&&clearTimeout(y.current),y.current=setTimeout(()=>{if(d(!1),j===l)return;const C=cs.find(T=>T.value===j)||cs[2];n.mutate(j,{onSuccess:()=>{le.success(`Reality level set to ${j}: ${C.name}`,{description:C.description})},onError:T=>{le.error("Failed to set reality level",{description:T instanceof Error?T.message:"Unknown error"}),o(l)}})},300)},[l,n]);h.useEffect(()=>()=>{y.current&&clearTimeout(y.current)},[]);const p=h.useCallback(j=>{if(y.current&&clearTimeout(y.current),d(!1),j===l)return;const C=cs.find(T=>T.value===j)||cs[2];n.mutate(j,{onSuccess:()=>{le.success(`Reality level set to ${j}: ${C.name}`,{description:C.description})},onError:T=>{le.error("Failed to set reality level",{description:T instanceof Error?T.message:"Unknown error"}),o(l)}})},[l,n]),f=h.useCallback(j=>{j!==l&&p(j)},[l,p]);return r&&!a?e.jsx(X,{className:D("p-6 animate-pulse",s),children:e.jsx("div",{className:"h-20 bg-gray-200 dark:bg-gray-700 rounded-lg"})}):t?e.jsxs("div",{className:D("flex items-center gap-3",s),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(g,{className:D("h-5 w-5",m.color)}),e.jsxs("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:["Level ",l]})]}),e.jsx(Yr,{min:1,max:5,step:1,value:i,onChange:u,className:"w-32",showValue:!1})]}):e.jsxs(X,{className:D("p-6 transition-all duration-300 ease-out","hover:shadow-lg hover:-translate-y-0.5",m.bgColor,`border-2 ${m.borderColor}`,s),children:[e.jsxs("div",{className:"flex items-start justify-between mb-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:D("p-3 rounded-xl transition-all duration-200",m.bgColor,m.color),children:e.jsx(g,{className:"h-6 w-6"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:"Reality Slider"}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:m.name})]})]}),e.jsxs(je,{variant:"default",className:D("text-sm font-semibold",m.color),children:["Level ",l]})]}),e.jsxs("div",{className:"mb-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Realism Level"}),e.jsxs("span",{className:"text-lg font-bold text-gray-900 dark:text-gray-100 tabular-nums",children:[i," / 5"]})]}),e.jsx(Yr,{min:1,max:5,step:1,value:i,onChange:u,disabled:n.isPending,description:m.description}),e.jsx("div",{className:"flex items-center justify-between mt-4 px-1",children:cs.map(j=>{const C=j.icon,T=j.value===l,N=j.value===i&&c;return e.jsx(Do,{content:e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold mb-1",children:j.name}),e.jsx("div",{className:"text-xs text-gray-300",children:j.description}),e.jsx("div",{className:"mt-2 text-xs",children:j.features.map((w,O)=>e.jsxs("div",{children:["• ",w]},O))})]}),children:e.jsxs("button",{type:"button",onClick:()=>f(j.value),disabled:n.isPending,className:D("flex flex-col items-center gap-1.5 p-2 rounded-lg transition-all duration-200","hover:bg-white/50 dark:hover:bg-gray-800/50","disabled:opacity-50 disabled:cursor-not-allowed",T&&"bg-white dark:bg-gray-800 shadow-sm",N&&!T&&"bg-white/30 dark:bg-gray-800/30"),children:[e.jsx(C,{className:D("h-5 w-5 transition-all duration-200",T?j.color:"text-gray-400 dark:text-gray-500",N&&!T&&"scale-110")}),e.jsx("span",{className:D("text-xs font-medium transition-all duration-200",T?"text-gray-900 dark:text-gray-100":"text-gray-500 dark:text-gray-400"),children:j.value})]})},j.value)})})]}),a&&e.jsx("div",{className:"mt-6 p-4 rounded-lg bg-white/50 dark:bg-gray-800/50 border border-gray-200 dark:border-gray-700",children:e.jsxs("div",{className:"grid grid-cols-3 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium text-gray-600 dark:text-gray-400 uppercase tracking-wide mb-1",children:"Chaos"}),e.jsx("p",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:a.chaos.enabled?e.jsxs(e.Fragment,{children:[Math.round(a.chaos.error_rate*100),"% errors",e.jsx("br",{}),Math.round(a.chaos.delay_rate*100),"% delays"]}):"Disabled"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium text-gray-600 dark:text-gray-400 uppercase tracking-wide mb-1",children:"Latency"}),e.jsxs("p",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:[a.latency.base_ms,"ms",a.latency.jitter_ms>0&&e.jsxs(e.Fragment,{children:[" ±",a.latency.jitter_ms,"ms"]})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium text-gray-600 dark:text-gray-400 uppercase tracking-wide mb-1",children:"MockAI"}),e.jsx("p",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:a.mockai.enabled?e.jsx("span",{className:"text-green-600 dark:text-green-400",children:"Enabled"}):e.jsx("span",{className:"text-gray-500",children:"Disabled"})})]})]})}),n.isPending&&e.jsxs("div",{className:"mt-4 flex items-center justify-center gap-2 text-sm text-gray-600 dark:text-gray-400",children:[e.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-gray-300 border-t-gray-600 dark:border-gray-600 dark:border-t-gray-300"}),e.jsx("span",{children:"Applying reality level..."})]})]})}const Ei=[{value:1,name:"Static Stubs",icon:Zt,color:"text-gray-500",bgColor:"bg-gray-100 dark:bg-gray-800",borderColor:"border-gray-300 dark:border-gray-700"},{value:2,name:"Light Simulation",icon:gs,color:"text-blue-500",bgColor:"bg-blue-50 dark:bg-blue-900/20",borderColor:"border-blue-300 dark:border-blue-700"},{value:3,name:"Moderate Realism",icon:oo,color:"text-green-500",bgColor:"bg-green-50 dark:bg-green-900/20",borderColor:"border-green-300 dark:border-green-700"},{value:4,name:"High Realism",icon:Dt,color:"text-orange-500",bgColor:"bg-orange-50 dark:bg-orange-900/20",borderColor:"border-orange-300 dark:border-orange-700"},{value:5,name:"Production Chaos",icon:dt,color:"text-red-500",bgColor:"bg-red-50 dark:bg-red-900/20",borderColor:"border-red-300 dark:border-red-700"}];function mx({className:s,showIcon:t=!0,showLabel:a=!1,variant:r="default"}){const{data:n,isLoading:i}=Io();if(i||!n)return e.jsx(je,{variant:"outline",className:D("animate-pulse",s),children:e.jsx("div",{className:"h-3 w-8 bg-gray-200 dark:bg-gray-700 rounded"})});const o=n.level,c=Ei.find(m=>m.value===o)||Ei[2],d=c.icon,l=e.jsxs(je,{variant:"outline",className:D("flex items-center gap-1.5 transition-all duration-200",c.bgColor,c.borderColor,s),children:[t&&e.jsx(d,{className:D("h-3.5 w-3.5",c.color)}),e.jsx("span",{className:D("font-semibold tabular-nums",c.color),children:r==="minimal"?o:`L${o}`}),a&&e.jsx("span",{className:D("text-xs",c.color),children:c.name})]});return r==="minimal"?l:e.jsx(Do,{content:e.jsxs("div",{children:[e.jsxs("div",{className:"font-semibold mb-1",children:["Reality Level ",o,": ",c.name]}),e.jsx("div",{className:"text-xs text-gray-300",children:n.description}),e.jsxs("div",{className:"mt-2 text-xs space-y-1",children:[e.jsxs("div",{children:[e.jsx("strong",{children:"Chaos:"})," ",n.chaos.enabled?`${Math.round(n.chaos.error_rate*100)}% errors, ${Math.round(n.chaos.delay_rate*100)}% delays`:"Disabled"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Latency:"})," ",n.latency.base_ms,"ms",n.latency.jitter_ms>0&&` ±${n.latency.jitter_ms}ms`]}),e.jsxs("div",{children:[e.jsx("strong",{children:"MockAI:"})," ",n.mockai.enabled?"Enabled":"Disabled"]})]})]}),children:l})}const pe=h.forwardRef(({className:s,children:t,required:a,...r},n)=>e.jsxs("label",{ref:n,className:D("text-sm font-medium leading-none text-gray-900 dark:text-gray-100 peer-disabled:cursor-not-allowed peer-disabled:opacity-70",s),...r,children:[t,a&&e.jsx("span",{className:"text-red-500 ml-0.5","aria-hidden":"true",children:"*"})]}));pe.displayName="Label";const zo=h.forwardRef(({className:s,error:t,errorId:a,"aria-invalid":r,"aria-describedby":n,...i},o)=>{const c=!!t||r===!0||r==="true",d=[n,a].filter(Boolean).join(" ")||void 0;return e.jsx("textarea",{className:D("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background 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",c&&"border-red-500 focus-visible:ring-red-500",s),ref:o,"aria-invalid":c||void 0,"aria-describedby":d,...i})});zo.displayName="Textarea";function hx({className:s}){const{data:t,isLoading:a}=rg(),r=ng(),n=ig(),[i,o]=h.useState(!1),[c,d]=h.useState(!1),[l,m]=h.useState(""),[g,y]=h.useState(""),[u,p]=h.useState(""),f=()=>{if(!l.trim()){le.error("Preset name is required");return}n.mutate({name:l.trim(),description:g.trim()||void 0},{onSuccess:C=>{le.success("Preset exported successfully",{description:`Saved to ${C.path}`}),o(!1),m(""),y("")},onError:C=>{le.error("Failed to export preset",{description:C instanceof Error?C.message:"Unknown error"})}})},j=C=>{r.mutate(C,{onSuccess:T=>{le.success("Preset imported successfully",{description:`Applied ${T.name} (Level ${T.level}: ${T.level_name})`}),d(!1),p("")},onError:T=>{le.error("Failed to import preset",{description:T instanceof Error?T.message:"Unknown error"})}})};return e.jsxs(X,{className:D("p-6",s),children:[e.jsxs(Le,{children:[e.jsx(ze,{className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:"Reality Presets"}),e.jsx(We,{className:"text-sm text-gray-600 dark:text-gray-400",children:"Save and load reality level configurations for different testing scenarios"})]}),e.jsxs(_e,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(qe,{open:i,onOpenChange:o,children:[e.jsx(Dr,{asChild:!0,children:e.jsxs(k,{variant:"default",className:"flex items-center gap-2",disabled:n.isPending,children:[e.jsx(tn,{className:"h-4 w-4"}),"Export Current"]})}),e.jsxs(Ue,{children:[e.jsxs(Be,{children:[e.jsx(Ve,{children:"Export Reality Preset"}),e.jsx(Ge,{children:"Save the current reality level configuration as a preset for later use"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{children:[e.jsx(pe,{htmlFor:"preset-name",children:"Preset Name *"}),e.jsx(B,{id:"preset-name",value:l,onChange:C=>m(C.target.value),placeholder:"e.g., production-chaos, staging-realistic",className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx(pe,{htmlFor:"preset-description",children:"Description (Optional)"}),e.jsx(zo,{id:"preset-description",value:g,onChange:C=>y(C.target.value),placeholder:"Describe when to use this preset...",className:"mt-1",rows:3})]})]}),e.jsxs(Ke,{children:[e.jsx(k,{variant:"outline",onClick:()=>{o(!1),m(""),y("")},children:"Cancel"}),e.jsx(k,{onClick:f,disabled:!l.trim()||n.isPending,children:n.isPending?"Exporting...":"Export Preset"})]})]})]}),e.jsxs(qe,{open:c,onOpenChange:d,children:[e.jsx(Dr,{asChild:!0,children:e.jsxs(k,{variant:"outline",className:"flex items-center gap-2",disabled:r.isPending,children:[e.jsx($r,{className:"h-4 w-4"}),"Import Preset"]})}),e.jsxs(Ue,{children:[e.jsxs(Be,{children:[e.jsx(Ve,{children:"Import Reality Preset"}),e.jsx(Ge,{children:"Load a previously saved reality level configuration"})]}),e.jsx("div",{className:"space-y-4 py-4",children:a?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-gray-300 border-t-gray-600 dark:border-gray-600 dark:border-t-gray-300"})}):t&&t.length>0?e.jsx("div",{className:"space-y-2 max-h-64 overflow-y-auto",children:t.map(C=>e.jsxs("button",{type:"button",onClick:()=>{p(C.path),j(C.path)},disabled:r.isPending,className:D("w-full text-left p-3 rounded-lg border transition-all duration-200","hover:bg-gray-50 dark:hover:bg-gray-800","hover:border-gray-300 dark:hover:border-gray-600","disabled:opacity-50 disabled:cursor-not-allowed",u===C.path?"border-blue-500 bg-blue-50 dark:bg-blue-900/20":"border-gray-200 dark:border-gray-700"),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Rs,{className:"h-4 w-4 text-gray-500 dark:text-gray-400"}),e.jsx("span",{className:"font-medium text-gray-900 dark:text-gray-100",children:C.name})]}),u===C.path&&r.isPending&&e.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-gray-300 border-t-gray-600 dark:border-gray-600 dark:border-t-gray-300"}),u===C.path&&!r.isPending&&e.jsx(no,{className:"h-4 w-4 text-green-500"})]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:C.path})]},C.id))}):e.jsx(hs,{variant:"info",className:"mt-4",children:e.jsx("p",{className:"text-sm",children:"No presets available. Export a preset to get started."})})}),e.jsx(Ke,{children:e.jsx(k,{variant:"outline",onClick:()=>{d(!1),p("")},children:"Close"})})]})]})]}),a?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-gray-300 border-t-gray-600 dark:border-gray-600 dark:border-t-gray-300"})}):t&&t.length>0?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h4",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:["Available Presets (",t.length,")"]}),e.jsx("div",{className:"space-y-2 max-h-64 overflow-y-auto",children:t.map(C=>e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[e.jsx(Rs,{className:"h-4 w-4 text-gray-500 dark:text-gray-400 flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-gray-100 truncate",children:C.name}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:C.path})]})]}),e.jsxs(k,{variant:"ghost",size:"sm",onClick:()=>j(C.path),disabled:r.isPending,className:"flex-shrink-0",children:[e.jsx($r,{className:"h-4 w-4 mr-1"}),"Load"]})]},C.id))})]}):e.jsx(hs,{variant:"info",children:e.jsx("p",{className:"text-sm",children:"No presets saved yet. Export your current configuration to create one."})}),(r.isPending||n.isPending)&&e.jsxs("div",{className:"flex items-center justify-center gap-2 text-sm text-gray-600 dark:text-gray-400 py-2",children:[e.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-gray-300 border-t-gray-600 dark:border-gray-600 dark:border-t-gray-300"}),e.jsx("span",{children:r.isPending?"Importing preset...":"Exporting preset..."})]})]})]})}function xt(s){if(!s)return"";const t=s.split(":");return t[t.length-1]||""}function wr(s){if(!s)return!0;try{const t=new URL(s);return t.protocol==="http:"||t.protocol==="https:"}catch{return!1}}function ea(s){return s>=1&&s<=65535}function gx(){const{t:s}=nr(),[t,a]=h.useState("general"),{activeWorkspace:r}=Ro(),n=(r==null?void 0:r.id)||"default-workspace",[i,o]=h.useState(!1),[c,d]=h.useState(!1),[l,m]=h.useState(()=>!!localStorage.getItem("mockforge_pending_port_config"));Fo({onOpenPresetManager:()=>{a("reality"),setTimeout(()=>{const v=document.querySelector('[data-section="reality"]');v&&v.scrollIntoView({behavior:"smooth",block:"start"})},100)}});const{data:g,isLoading:y}=O0(),{data:u,isLoading:p}=E0(),{data:f,isLoading:j}=C0(),C=I0(),T=M0(),N=R0(),w=L0(),O=A0(),L=P0(),{data:I}=T0(),[b,A]=h.useState({general:{http_port:3e3,ws_port:3001,grpc_port:50051,admin_port:9080,ai_mode:"live"},restartInProgress:!1,latency:{base_ms:0,jitter_ms:0},faults:{enabled:!1,failure_rate:0,status_codes:[]},trafficShaping:{enabled:!1,bandwidth:{enabled:!1,max_bytes_per_sec:1048576,burst_capacity_bytes:10485760},burstLoss:{enabled:!1,burst_probability:.1,burst_duration_ms:5e3,loss_rate_during_burst:.5,recovery_time_ms:3e4}},proxy:{enabled:!1,upstream_url:"",timeout_seconds:30},validation:{mode:"enforce",aggregate_errors:!0,validate_responses:!0,overrides:{}},protocols:{http:!0,graphql:!0,grpc:!0,websocket:!0,smtp:!1,mqtt:!1,ftp:!1,kafka:!1,rabbitmq:!1,amqp:!1},templateTest:""}),_=v=>{localStorage.setItem("mockforge_pending_port_config",JSON.stringify(v))};h.useEffect(()=>{const v=localStorage.getItem("mockforge_pending_port_config");if(v)try{const x=JSON.parse(v);A(K=>({...K,general:{...K.general,...x}})),m(!0)}catch(x){Pe.error("Failed to parse pending port config",x),localStorage.removeItem("mockforge_pending_port_config"),m(!1)}},[]),h.useEffect(()=>{I&&b.restartInProgress&&(I.restarting||(A(v=>({...v,restartInProgress:!1})),le.success("Server restarted successfully! Port configuration applied."),localStorage.removeItem("mockforge_pending_port_config"),m(!1)))},[I,b.restartInProgress]),h.useEffect(()=>{g!=null&&g.latency&&A(v=>({...v,latency:{base_ms:g.latency.base_ms,jitter_ms:g.latency.jitter_ms}})),g!=null&&g.faults&&A(v=>({...v,faults:{enabled:g.faults.enabled,failure_rate:g.faults.failure_rate,status_codes:g.faults.status_codes}})),g!=null&&g.proxy&&A(v=>({...v,proxy:{enabled:g.proxy.enabled,upstream_url:g.proxy.upstream_url||"",timeout_seconds:g.proxy.timeout_seconds}}))},[g]),h.useEffect(()=>{f&&!l&&A(v=>({...v,general:{http_port:parseInt(xt(f.http_server))||3e3,ws_port:parseInt(xt(f.ws_server))||3001,grpc_port:parseInt(xt(f.grpc_server))||50051,admin_port:f.admin_port||9080}}))},[f,l]),h.useEffect(()=>{u&&A(v=>({...v,validation:{mode:u.mode,aggregate_errors:u.aggregate_errors,validate_responses:u.validate_responses,overrides:u.overrides}}))},[u]),h.useEffect(()=>{let v=!1;if(f){const x=parseInt(xt(f.http_server))||3e3,K=parseInt(xt(f.ws_server))||3001,de=parseInt(xt(f.grpc_server))||50051,te=f.admin_port||9080;(b.general.http_port!==x||b.general.ws_port!==K||b.general.grpc_port!==de||b.general.admin_port!==te)&&(v=!0)}g!=null&&g.latency&&(b.latency.base_ms!==g.latency.base_ms||b.latency.jitter_ms!==g.latency.jitter_ms)&&(v=!0),g!=null&&g.faults&&(b.faults.enabled!==g.faults.enabled||b.faults.failure_rate!==g.faults.failure_rate||JSON.stringify(b.faults.status_codes)!==JSON.stringify(g.faults.status_codes))&&(v=!0),g!=null&&g.proxy&&(b.proxy.enabled!==g.proxy.enabled||b.proxy.upstream_url!==(g.proxy.upstream_url||"")||b.proxy.timeout_seconds!==g.proxy.timeout_seconds)&&(v=!0),u&&(b.validation.mode!==u.mode||b.validation.aggregate_errors!==u.aggregate_errors||b.validation.validate_responses!==u.validate_responses)&&(v=!0),o(v)},[b,g,u,f]),h.useEffect(()=>{const v=x=>{i&&(x.preventDefault(),x.returnValue="")};return window.addEventListener("beforeunload",v),()=>window.removeEventListener("beforeunload",v)},[i]);const $=async v=>{if(v==="proxy"&&b.proxy.enabled){if(!b.proxy.upstream_url){le.error("Upstream URL is required when proxy is enabled");return}if(!wr(b.proxy.upstream_url)){le.error("Invalid upstream URL. Must be a valid HTTP or HTTPS URL");return}if(!ea(b.proxy.timeout_seconds)){le.error("Invalid timeout. Must be between 1 and 300 seconds");return}}if(v==="general"){if(!ea(b.general.http_port)){le.error("Invalid HTTP port. Must be between 1 and 65535");return}if(!ea(b.general.ws_port)){le.error("Invalid WebSocket port. Must be between 1 and 65535");return}if(!ea(b.general.grpc_port)){le.error("Invalid gRPC port. Must be between 1 and 65535");return}if(!ea(b.general.admin_port)){le.error("Invalid Admin port. Must be between 1 and 65535");return}}try{switch(v){case"latency":await C.mutateAsync({name:"default",base_ms:b.latency.base_ms,jitter_ms:b.latency.jitter_ms,tag_overrides:{}}),le.success("Latency configuration saved successfully");break;case"faults":await T.mutateAsync({enabled:b.faults.enabled,failure_rate:b.faults.failure_rate,status_codes:b.faults.status_codes,active_failures:0}),le.success("Fault injection configuration saved successfully");break;case"proxy":await N.mutateAsync({enabled:b.proxy.enabled,upstream_url:b.proxy.upstream_url,timeout_seconds:b.proxy.timeout_seconds,requests_proxied:0}),le.success("Proxy configuration saved successfully");break;case"validation":await O.mutateAsync({mode:b.validation.mode,aggregate_errors:b.validation.aggregate_errors,validate_responses:b.validation.validate_responses,overrides:b.validation.overrides}),le.success("Validation settings saved successfully");break;case"general":{d(!0);break}case"protocols":await w.mutateAsync(b.protocols),le.success("Protocol configuration saved successfully");break;case"traffic-shaping":try{const x=await rt("/__mockforge/config/traffic-shaping",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b.trafficShaping)});if(!x.ok)throw new Error(`HTTP error! status: ${x.status}`);le.success("Traffic shaping configuration saved successfully")}catch(x){Pe.error("Error saving traffic shaping",x),le.error("Failed to save traffic shaping configuration")}break;default:le.error(`Unknown section: ${v}`)}}catch(x){Pe.error(`Error saving ${v} configuration:`,x),le.error(`Failed to save ${v} configuration`)}},ae=async()=>{d(!1);try{A(K=>({...K,restartInProgress:!0})),le.info("Saving configuration and restarting server..."),await L.mutateAsync("Port configuration updated");const v=b.general;let x=!1;for(let K=0;K<5;K++){await new Promise(de=>setTimeout(de,500));try{const de=await pa.getServerInfo(),te=xt(de.http_server),ee=xt(de.ws_server),se=xt(de.grpc_server),Oe=!de.http_server||te===String(v.http_port),Ye=!de.ws_server||ee===String(v.ws_port),ne=!de.grpc_server||se===String(v.grpc_port);if(Oe&&Ye&&ne){x=!0;break}}catch(de){Pe.error("server-info poll failed",de)}}A(K=>({...K,restartInProgress:!1})),x?(_(v),m(!0),le.success("Server restarted successfully! Port configuration applied.")):(localStorage.removeItem("mockforge_pending_port_config"),m(!1),le.error("Server restarted but ports could not be verified — please reload manually"))}catch(v){A(x=>({...x,restartInProgress:!1})),le.error("Failed to restart server. Please restart manually."),Pe.error("Server restart failed",v)}},U=()=>{d(!1),le.info("Configuration saved locally. Restart the server manually to apply changes.")},z=v=>{switch(v){case"general":f&&(A(x=>({...x,general:{http_port:parseInt(xt(f.http_server))||3e3,ws_port:parseInt(xt(f.ws_server))||3001,grpc_port:parseInt(xt(f.grpc_server))||50051,admin_port:f.admin_port||9080}})),le.info("General settings reset to server values"));break;case"latency":g!=null&&g.latency&&(A(x=>({...x,latency:{base_ms:g.latency.base_ms,jitter_ms:g.latency.jitter_ms}})),le.info("Latency configuration reset to server values"));break;case"faults":g!=null&&g.faults&&(A(x=>({...x,faults:{enabled:g.faults.enabled,failure_rate:g.faults.failure_rate,status_codes:g.faults.status_codes}})),le.info("Fault injection configuration reset to server values"));break;case"proxy":g!=null&&g.proxy&&(A(x=>({...x,proxy:{enabled:g.proxy.enabled,upstream_url:g.proxy.upstream_url||"",timeout_seconds:g.proxy.timeout_seconds}})),le.info("Proxy configuration reset to server values"));break;case"validation":u&&(A(x=>({...x,validation:{mode:u.mode,aggregate_errors:u.aggregate_errors,validate_responses:u.validate_responses,overrides:u.overrides}})),le.info("Validation settings reset to server values"));break;case"traffic-shaping":A(x=>({...x,trafficShaping:{enabled:!1,bandwidth:{enabled:!1,max_bytes_per_sec:1048576,burst_capacity_bytes:10485760},burstLoss:{enabled:!1,burst_probability:.1,burst_duration_ms:5e3,loss_rate_during_burst:.5,recovery_time_ms:3e4}}})),le.info("Traffic shaping configuration reset to defaults");break;default:le.error(`Unknown section: ${v}`)}},R=()=>{z("general"),z("latency"),z("faults"),z("traffic-shaping"),z("proxy"),z("validation"),le.success("All settings reset to server values")},P=async()=>{const v=["general","latency","faults","traffic-shaping","proxy","validation","protocols"];let x=0,K=0;for(const de of v)try{await $(de),x++}catch{K++}K===0?le.success("All settings saved successfully"):le.warning(`Saved ${x} sections, ${K} failed`)};if(y||p||j)return e.jsxs("div",{className:"space-y-8",children:[e.jsx(Ga,{title:s("page.config.title"),subtitle:s("page.config.subtitle")}),e.jsxs("div",{className:"flex items-center justify-center py-12",children:[e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600"}),e.jsx("span",{className:"ml-3 text-lg text-gray-600 dark:text-gray-400",children:"Loading configuration..."})]})]});const V=[{id:"reality",label:"Reality Slider",icon:dt,description:"Unified realism control"},{id:"general",label:"General",icon:Tt,description:"Basic MockForge settings"},{id:"protocols",label:"Protocols",icon:Rr,description:"Protocol enable/disable settings"},{id:"latency",label:"Latency",icon:dt,description:"Response delay and timing"},{id:"faults",label:"Fault Injection",icon:Zt,description:"Error simulation and failure modes"},{id:"traffic-shaping",label:"Traffic Shaping",icon:oa,description:"Bandwidth control and network simulation"},{id:"proxy",label:"Proxy",icon:Rr,description:"Upstream proxy configuration"},{id:"validation",label:"Validation",icon:Ms,description:"Request/response validation"},{id:"environment",label:"Environment",icon:Tt,description:"Environment variables"}];return e.jsxs("div",{className:"space-y-8",children:[e.jsx(Ga,{title:s("page.config.title"),subtitle:i?"⚠️ You have unsaved changes":s("page.config.subtitle"),action:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(mx,{}),e.jsxs(k,{variant:"outline",size:"sm",className:"flex items-center gap-2",onClick:R,children:[e.jsx(st,{className:"h-4 w-4"}),"Reset All"]}),e.jsxs(k,{variant:"default",size:"sm",className:"flex items-center gap-2",onClick:P,children:[e.jsx(Xt,{className:"h-4 w-4"}),"Save All Changes"]})]})}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-4 gap-8",children:[e.jsx("div",{className:"lg:col-span-1",children:e.jsx(pt,{children:e.jsx("nav",{className:"space-y-2",children:V.map(v=>{const x=v.icon;return e.jsxs("button",{onClick:()=>a(v.id),className:`w-full flex items-center gap-3 px-3 py-3 rounded-lg text-left transition-colors ${t===v.id?"bg-blue-50 dark:bg-blue-900/20 text-blue-700 dark:text-blue-300":"hover:bg-gray-50 dark:hover:bg-gray-800/50 text-gray-700 dark:text-gray-300"}`,children:[e.jsx(x,{className:"h-5 w-5"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:v.label}),e.jsx("div",{className:"text-xs opacity-75",children:v.description})]})]},v.id)})})})}),e.jsxs("div",{className:"lg:col-span-3",children:[t==="reality"&&e.jsx(Lt,{title:"Reality Slider",subtitle:"Unified control for chaos, latency, and MockAI","data-section":"reality",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(ux,{}),e.jsx(hx,{}),e.jsxs("div",{className:"mt-4 p-4 rounded-lg bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800",children:[e.jsx("h4",{className:"text-sm font-semibold text-blue-900 dark:text-blue-100 mb-2",children:"Keyboard Shortcuts"}),e.jsxs("div",{className:"text-xs text-blue-800 dark:text-blue-200 space-y-1",children:[e.jsxs("div",{children:[e.jsx("kbd",{className:"px-1.5 py-0.5 bg-white dark:bg-gray-800 rounded border border-blue-300 dark:border-blue-700",children:"Ctrl+Shift+1-5"})," Set reality level"]}),e.jsxs("div",{children:[e.jsx("kbd",{className:"px-1.5 py-0.5 bg-white dark:bg-gray-800 rounded border border-blue-300 dark:border-blue-700",children:"Ctrl+Shift+R"})," Reset to default (Level 3)"]}),e.jsxs("div",{children:[e.jsx("kbd",{className:"px-1.5 py-0.5 bg-white dark:bg-gray-800 rounded border border-blue-300 dark:border-blue-700",children:"Ctrl+Shift+P"})," Open preset manager"]})]})]})]})}),t==="general"&&e.jsx(Lt,{title:"General Settings",subtitle:"Basic MockForge configuration",children:e.jsx(pt,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Server Configuration"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-gray-500 dark:text-gray-400 mb-1",children:"HTTP Port"}),e.jsx(B,{type:"number",min:"1",max:"65535",value:b.general.http_port,onChange:v=>A(x=>({...x,general:{...x.general,http_port:parseInt(v.target.value)||3e3}}))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-gray-500 dark:text-gray-400 mb-1",children:"WebSocket Port"}),e.jsx(B,{type:"number",min:"1",max:"65535",value:b.general.ws_port,onChange:v=>A(x=>({...x,general:{...x.general,ws_port:parseInt(v.target.value)||3001}}))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-gray-500 dark:text-gray-400 mb-1",children:"gRPC Port"}),e.jsx(B,{type:"number",min:"1",max:"65535",value:b.general.grpc_port,onChange:v=>A(x=>({...x,general:{...x.general,grpc_port:parseInt(v.target.value)||50051}}))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Admin Port"}),e.jsx(B,{type:"number",min:"1",max:"65535",value:b.general.admin_port,onChange:v=>A(x=>({...x,general:{...x.general,admin_port:parseInt(v.target.value)||9080}}))})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"AI Mode"}),e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700",children:[e.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-4",children:["Control how AI-generated artifacts are used at runtime. In ",e.jsx("strong",{children:"Generate Once Freeze"})," mode, AI is only used to produce config/templates, and runtime mocks use frozen artifacts (no LLM calls). In ",e.jsx("strong",{children:"Live"})," mode, AI is used dynamically at runtime for each request."]}),e.jsxs(Lo,{value:b.general.ai_mode||"live",onValueChange:v=>{A(x=>({...x,general:{...x.general,ai_mode:v}})),o(!0)},children:[e.jsx(xn,{className:"w-full",children:e.jsx($o,{})}),e.jsxs(pn,{children:[e.jsx(Za,{value:"live",children:"Live - AI used dynamically at runtime"}),e.jsx(Za,{value:"generate_once_freeze",children:"Generate Once Freeze - Use frozen artifacts only"})]})]}),b.general.ai_mode==="generate_once_freeze"&&e.jsx("div",{className:"mt-3 p-3 bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded",children:e.jsxs("p",{className:"text-xs text-blue-800 dark:text-blue-200",children:[e.jsx("strong",{children:"Note:"})," In this mode, AI-generated scenarios and personas will use frozen artifacts. Make sure to freeze your AI-generated artifacts before using them in this mode."]})})]})})]}),b.restartInProgress&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg mb-4",children:[e.jsx(st,{className:"w-4 h-4 animate-spin text-blue-600"}),e.jsx("span",{className:"text-sm text-blue-700 dark:text-blue-300",children:"Server restart in progress... Configuration will be applied shortly."})]}),e.jsxs("div",{className:"flex items-center justify-between pt-4 border-t border-gray-200 dark:border-gray-700",children:[e.jsx(k,{variant:"outline",onClick:()=>z("general"),disabled:b.restartInProgress,children:"Reset"}),e.jsx(k,{onClick:()=>$("general"),disabled:b.restartInProgress,children:b.restartInProgress?e.jsxs(e.Fragment,{children:[e.jsx(st,{className:"w-4 h-4 mr-2 animate-spin"}),"Restarting..."]}):"Save & Restart Server"})]})]})})}),t==="protocols"&&e.jsx(Lt,{title:"Protocol Configuration",subtitle:"Enable or disable protocol support",children:e.jsx(pt,{children:e.jsx("div",{className:"space-y-6",children:e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:[{key:"http",label:"HTTP/REST",description:"RESTful API mocking"},{key:"graphql",label:"GraphQL",description:"GraphQL API mocking"},{key:"grpc",label:"gRPC",description:"gRPC service mocking"},{key:"websocket",label:"WebSocket",description:"WebSocket connection mocking"},{key:"smtp",label:"SMTP",description:"Email protocol mocking"},{key:"mqtt",label:"MQTT",description:"IoT messaging protocol"},{key:"ftp",label:"FTP",description:"File transfer protocol"},{key:"kafka",label:"Kafka",description:"Event streaming platform"},{key:"rabbitmq",label:"RabbitMQ",description:"Message queuing system"},{key:"amqp",label:"AMQP",description:"Advanced message queuing"}].map(v=>{var x;return e.jsxs("div",{className:"flex items-center justify-between p-4 border border-gray-200 dark:border-gray-700 rounded-lg",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:v.label}),e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:v.description})]}),e.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[e.jsx("input",{type:"checkbox",className:"sr-only peer",checked:((x=b.protocols)==null?void 0:x[v.key])??!1,onChange:K=>A(de=>({...de,protocols:{...de.protocols,[v.key]:K.target.checked}}))}),e.jsx("div",{className:"w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-blue-300 dark:peer-focus:ring-blue-800 rounded-full peer dark:bg-gray-700 peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-blue-600"})]})]},v.key)})})})})}),t==="latency"&&e.jsx(Lt,{title:"Latency Configuration",subtitle:"Control response timing and delays",children:e.jsx(pt,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Base Latency (ms)"}),e.jsx(B,{type:"number",placeholder:"0",value:b.latency.base_ms,onChange:v=>A(x=>({...x,latency:{...x.latency,base_ms:parseInt(v.target.value)||0}}))}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:"Minimum response time for all requests"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Jitter (ms)"}),e.jsx(B,{type:"number",placeholder:"0",value:b.latency.jitter_ms,onChange:v=>A(x=>({...x,latency:{...x.latency,jitter_ms:parseInt(v.target.value)||0}}))}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:"Random delay variation (± jitter)"})]})]}),e.jsxs("div",{className:"flex items-center justify-between pt-4 border-t border-gray-200 dark:border-gray-700",children:[e.jsx(k,{variant:"outline",onClick:()=>z("latency"),children:"Reset"}),e.jsx(k,{onClick:()=>$("latency"),children:"Save Changes"})]})]})})}),t==="faults"&&e.jsx(Lt,{title:"Fault Injection",subtitle:"Configure error simulation and failure scenarios",children:e.jsx(pt,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:"Enable Fault Injection"}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Simulate network failures and server errors"})]}),e.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[e.jsx("input",{type:"checkbox",className:"sr-only peer",checked:b.faults.enabled,onChange:v=>A(x=>({...x,faults:{...x.faults,enabled:v.target.checked}}))}),e.jsx("div",{className:"w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-blue-300 dark:peer-focus:ring-blue-800 rounded-full peer dark:bg-gray-700 peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-blue-600"})]})]}),b.faults.enabled&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Failure Rate (%)"}),e.jsx(B,{type:"number",min:"0",max:"100",placeholder:"5",value:b.faults.failure_rate,onChange:v=>A(x=>({...x,faults:{...x.faults,failure_rate:parseInt(v.target.value)||0}}))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Error Status Codes"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:[500,502,503,504,400,401,403,404].map(v=>e.jsx("button",{onClick:()=>{A(x=>({...x,faults:{...x.faults,status_codes:x.faults.status_codes.includes(v)?x.faults.status_codes.filter(K=>K!==v):[...x.faults.status_codes,v]}}))},className:"cursor-pointer",children:e.jsx(Po,{variant:b.faults.status_codes.includes(v)?"error":"outline",children:v})},v))})]})]}),e.jsxs("div",{className:"flex items-center justify-between pt-4 border-t border-gray-200 dark:border-gray-700",children:[e.jsx(k,{variant:"outline",onClick:()=>z("faults"),children:"Reset"}),e.jsx(k,{onClick:()=>$("faults"),children:"Save Changes"})]})]})})}),t==="traffic-shaping"&&e.jsx(Lt,{title:"Traffic Shaping",subtitle:"Control bandwidth and simulate network conditions",children:e.jsx(pt,{children:e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:"Enable Traffic Shaping"}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Simulate real network conditions with bandwidth control and connectivity issues"})]}),e.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[e.jsx("input",{type:"checkbox",className:"sr-only peer",checked:b.trafficShaping.enabled,onChange:v=>A(x=>({...x,trafficShaping:{...x.trafficShaping,enabled:v.target.checked}}))}),e.jsx("div",{className:"w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-blue-300 dark:peer-focus:ring-blue-800 rounded-full peer dark:bg-gray-700 peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-blue-600"})]})]}),b.trafficShaping.enabled&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"border-t border-gray-200 dark:border-gray-700 pt-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx(oa,{className:"h-5 w-5 text-blue-600"}),e.jsx("h3",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:"Bandwidth Control"})]}),e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:"Enable Bandwidth Throttling"}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Limit data transfer rates using token bucket algorithm"})]}),e.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[e.jsx("input",{type:"checkbox",className:"sr-only peer",checked:b.trafficShaping.bandwidth.enabled,onChange:v=>A(x=>({...x,trafficShaping:{...x.trafficShaping,bandwidth:{...x.trafficShaping.bandwidth,enabled:v.target.checked}}}))}),e.jsx("div",{className:"w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-blue-300 dark:peer-focus:ring-blue-800 rounded-full peer dark:bg-gray-700 peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-blue-600"})]})]}),b.trafficShaping.bandwidth.enabled&&e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Max Bandwidth (bytes/sec)"}),e.jsx(B,{type:"number",min:"1",placeholder:"1048576",value:b.trafficShaping.bandwidth.max_bytes_per_sec,onChange:v=>A(x=>({...x,trafficShaping:{...x.trafficShaping,bandwidth:{...x.trafficShaping.bandwidth,max_bytes_per_sec:parseInt(v.target.value)||1048576}}}))}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:"Maximum data transfer rate (1 MB/s = 1,048,576 bytes)"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Burst Capacity (bytes)"}),e.jsx(B,{type:"number",min:"1",placeholder:"10485760",value:b.trafficShaping.bandwidth.burst_capacity_bytes,onChange:v=>A(x=>({...x,trafficShaping:{...x.trafficShaping,bandwidth:{...x.trafficShaping.bandwidth,burst_capacity_bytes:parseInt(v.target.value)||10485760}}}))}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:"Token bucket capacity for burst traffic (10 MB = 10,485,760 bytes)"})]})]})]}),e.jsxs("div",{className:"border-t border-gray-200 dark:border-gray-700 pt-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx(ln,{className:"h-5 w-5 text-orange-600"}),e.jsx("h3",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:"Burst Loss Simulation"})]}),e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:"Enable Burst Loss"}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Simulate intermittent connectivity issues and packet loss"})]}),e.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[e.jsx("input",{type:"checkbox",className:"sr-only peer",checked:b.trafficShaping.burstLoss.enabled,onChange:v=>A(x=>({...x,trafficShaping:{...x.trafficShaping,burstLoss:{...x.trafficShaping.burstLoss,enabled:v.target.checked}}}))}),e.jsx("div",{className:"w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-blue-300 dark:peer-focus:ring-blue-800 rounded-full peer dark:bg-gray-700 peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-blue-600"})]})]}),b.trafficShaping.burstLoss.enabled&&e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Burst Probability (%)"}),e.jsx(B,{type:"number",min:"0",max:"100",step:"0.1",placeholder:"10",value:b.trafficShaping.burstLoss.burst_probability*100,onChange:v=>A(x=>({...x,trafficShaping:{...x.trafficShaping,burstLoss:{...x.trafficShaping.burstLoss,burst_probability:parseFloat(v.target.value)/100||.1}}}))}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:"Probability of entering a loss burst (0-100%)"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Burst Duration (ms)"}),e.jsx(B,{type:"number",min:"100",placeholder:"5000",value:b.trafficShaping.burstLoss.burst_duration_ms,onChange:v=>A(x=>({...x,trafficShaping:{...x.trafficShaping,burstLoss:{...x.trafficShaping.burstLoss,burst_duration_ms:parseInt(v.target.value)||5e3}}}))}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:"Duration of loss bursts in milliseconds"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Loss Rate During Burst (%)"}),e.jsx(B,{type:"number",min:"0",max:"100",step:"0.1",placeholder:"50",value:b.trafficShaping.burstLoss.loss_rate_during_burst*100,onChange:v=>A(x=>({...x,trafficShaping:{...x.trafficShaping,burstLoss:{...x.trafficShaping.burstLoss,loss_rate_during_burst:parseFloat(v.target.value)/100||.5}}}))}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:"Packet loss rate during burst periods (0-100%)"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Recovery Time (ms)"}),e.jsx(B,{type:"number",min:"1000",placeholder:"30000",value:b.trafficShaping.burstLoss.recovery_time_ms,onChange:v=>A(x=>({...x,trafficShaping:{...x.trafficShaping,burstLoss:{...x.trafficShaping.burstLoss,recovery_time_ms:parseInt(v.target.value)||3e4}}}))}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:"Recovery period between bursts in milliseconds"})]})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between pt-4 border-t border-gray-200 dark:border-gray-700",children:[e.jsx(k,{variant:"outline",onClick:()=>z("traffic-shaping"),children:"Reset"}),e.jsx(k,{onClick:()=>$("traffic-shaping"),children:"Save Changes"})]})]})})}),t==="proxy"&&e.jsx(Lt,{title:"Proxy Configuration",subtitle:"Configure upstream proxy settings",children:e.jsx(pt,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:"Enable Proxy Mode"}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Forward requests to upstream services"})]}),e.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[e.jsx("input",{type:"checkbox",className:"sr-only peer",checked:b.proxy.enabled,onChange:v=>A(x=>({...x,proxy:{...x.proxy,enabled:v.target.checked}}))}),e.jsx("div",{className:"w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-blue-300 dark:peer-focus:ring-blue-800 rounded-full peer dark:bg-gray-700 peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-blue-600"})]})]}),b.proxy.enabled&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Upstream URL"}),e.jsx(B,{type:"url",placeholder:"https://api.example.com",value:b.proxy.upstream_url,onChange:v=>A(x=>({...x,proxy:{...x.proxy,upstream_url:v.target.value}})),className:b.proxy.upstream_url&&!wr(b.proxy.upstream_url)?"border-red-500 dark:border-red-500":""}),b.proxy.upstream_url&&!wr(b.proxy.upstream_url)&&e.jsx("p",{className:"text-xs text-red-600 dark:text-red-400 mt-1",children:"Must be a valid HTTP or HTTPS URL"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Timeout (seconds)"}),e.jsx(B,{type:"number",min:"1",max:"300",placeholder:"30",value:b.proxy.timeout_seconds,onChange:v=>A(x=>({...x,proxy:{...x.proxy,timeout_seconds:parseInt(v.target.value)||30}}))})]})]}),e.jsxs("div",{className:"flex items-center justify-between pt-4 border-t border-gray-200 dark:border-gray-700",children:[e.jsx(k,{variant:"outline",onClick:()=>z("proxy"),children:"Reset"}),e.jsx(k,{onClick:()=>$("proxy"),children:"Save Changes"})]})]})})}),t==="validation"&&e.jsx(Lt,{title:"Validation Settings",subtitle:"Configure request and response validation",children:e.jsx(pt,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Validation Mode"}),e.jsxs("select",{value:b.validation.mode,onChange:v=>A(x=>({...x,validation:{...x.validation,mode:v.target.value}})),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100",children:[e.jsx("option",{value:"enforce",children:"Enforce (Strict)"}),e.jsx("option",{value:"warn",children:"Warn Only"}),e.jsx("option",{value:"off",children:"Disabled"})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:"Aggregate Errors"}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Collect all validation errors before responding"})]}),e.jsx("input",{type:"checkbox",checked:b.validation.aggregate_errors,onChange:v=>A(x=>({...x,validation:{...x.validation,aggregate_errors:v.target.checked}})),className:"w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:"Validate Responses"}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Check response format and content"})]}),e.jsx("input",{type:"checkbox",checked:b.validation.validate_responses,onChange:v=>A(x=>({...x,validation:{...x.validation,validate_responses:v.target.checked}})),className:"w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500"})]})]}),e.jsxs("div",{className:"flex items-center justify-between pt-4 border-t border-gray-200 dark:border-gray-700",children:[e.jsx(k,{variant:"outline",onClick:()=>z("validation"),children:"Reset"}),e.jsx(k,{onClick:()=>$("validation"),children:"Save Changes"})]})]})})}),t==="environment"&&e.jsxs(Lt,{title:"Environments & Variables",subtitle:"Manage environments and their variables",children:[e.jsx(cx,{workspaceId:n,onEnvironmentSelect:v=>{}}),e.jsx("div",{className:"mt-8",children:e.jsxs(pt,{children:[e.jsx("h3",{className:"text-lg font-medium text-gray-900 dark:text-gray-100 mb-4",children:"Template Testing"}),e.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-4",children:["Test variable substitution in templates. Type ","{{"," to see available variables."]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Template Input (with autocomplete)"}),e.jsx(dx,{value:b.templateTest||"",onChange:v=>A(x=>({...x,templateTest:v})),placeholder:"Type {{ to see available variables...",workspaceId:n,context:"template_test",className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Expected Output"}),e.jsx("div",{className:"p-3 bg-gray-50 dark:bg-gray-800 rounded-lg font-mono text-sm text-gray-600 dark:text-gray-400",children:b.templateTest||"Template output will appear here..."})]}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:"💡 Tip: Use Ctrl+Space anywhere in a text input to manually trigger autocomplete"})]})]})})]})]})]}),e.jsx(qe,{open:c,onOpenChange:d,children:e.jsxs(Ue,{children:[e.jsxs(Be,{children:[e.jsx(Ve,{children:"Restart Server Required"}),e.jsx(ga,{onClick:U})]}),e.jsx(Ge,{children:"Port configuration changes require a server restart to take effect."}),e.jsx("div",{className:"py-4",children:e.jsxs("div",{className:"space-y-2 text-sm",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"font-medium",children:"HTTP Port:"}),e.jsx("span",{children:b.general.http_port})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"font-medium",children:"WebSocket Port:"}),e.jsx("span",{children:b.general.ws_port})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"font-medium",children:"gRPC Port:"}),e.jsx("span",{children:b.general.grpc_port})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"font-medium",children:"Admin Port:"}),e.jsx("span",{children:b.general.admin_port})]})]})}),e.jsxs(Ke,{children:[e.jsx(k,{variant:"outline",onClick:U,children:"Cancel"}),e.jsx(k,{onClick:ae,children:"Restart Server"})]})]})})]})}const qt="/api/v1";function Ut(){return{Authorization:`Bearer ${localStorage.getItem("auth_token")}`,"Content-Type":"application/json"}}async function xx(){const s=await fetch(`${qt}/organizations`,{headers:Ut()});if(!s.ok)throw new Error("Failed to fetch organizations");return s.json()}async function px(s){const t=await fetch(`${qt}/settings/byok?reveal=${s}`,{headers:Ut()});if(!t.ok){if(t.status===404)return{provider:"openai",api_key:"",enabled:!1};throw new Error("Failed to fetch BYOK config")}return t.json()}async function fx(s){const t=await fetch(`${qt}/settings/byok`,{method:"PUT",headers:Ut(),body:JSON.stringify(s)});if(!t.ok){const a=await t.json();throw new Error(a.message||"Failed to save BYOK config")}}async function yx(){if(!(await fetch(`${qt}/settings/byok`,{method:"DELETE",headers:Ut()})).ok)throw new Error("Failed to delete BYOK config")}async function bx(s){const t=await fetch(`${qt}/settings/byok/test`,{method:"POST",headers:Ut(),body:JSON.stringify(s)});if(!t.ok)throw new Error("Failed to test connection");return t.json()}async function vx(s){const t=await fetch(`${qt}/organizations/${s}/settings/ai`,{headers:Ut()});if(!t.ok)throw new Error("Failed to fetch AI settings");return t.json()}async function jx(s,t){const a=await fetch(`${qt}/organizations/${s}/settings/ai`,{method:"PATCH",headers:Ut(),body:JSON.stringify(t)});if(!a.ok)throw new Error("Failed to save AI settings");return a.json()}async function kx(s){const t=await fetch(`${qt}/organizations/${s}/usage`,{headers:Ut()});if(!t.ok)throw new Error("Failed to fetch usage");return t.json()}async function wx(s){const t=await fetch(`${qt}/organizations/${s}/audit-logs?event_type=byok_config_updated,byok_config_deleted`,{headers:Ut()});if(!t.ok)throw new Error("Failed to fetch audit logs");return t.json()}const Ai=[{value:"openai",label:"OpenAI",description:"Use OpenAI API (GPT-4, GPT-3.5, etc.)",baseUrl:"https://api.openai.com/v1",docsUrl:"https://platform.openai.com/docs",models:[{value:"gpt-4o",label:"GPT-4o"},{value:"gpt-4o-mini",label:"GPT-4o Mini"},{value:"gpt-4-turbo",label:"GPT-4 Turbo"},{value:"gpt-3.5-turbo",label:"GPT-3.5 Turbo"},{value:"o3-mini",label:"o3-mini"}]},{value:"anthropic",label:"Anthropic",description:"Use Anthropic API (Claude)",baseUrl:"https://api.anthropic.com/v1",docsUrl:"https://docs.anthropic.com",models:[{value:"claude-sonnet-4-6",label:"Claude Sonnet 4.6"},{value:"claude-opus-4-6",label:"Claude Opus 4.6"},{value:"claude-haiku-4-5-20251001",label:"Claude Haiku 4.5"}]},{value:"together",label:"Together AI",description:"Use Together AI for open-source models",baseUrl:"https://api.together.xyz/v1",docsUrl:"https://docs.together.ai",models:[{value:"meta-llama/Llama-3.3-70B-Instruct-Turbo",label:"Llama 3.3 70B Instruct"},{value:"meta-llama/Llama-3.1-8B-Instruct-Turbo",label:"Llama 3.1 8B Instruct"},{value:"mistralai/Mixtral-8x7B-Instruct-v0.1",label:"Mixtral 8x7B"},{value:"Qwen/Qwen2.5-72B-Instruct-Turbo",label:"Qwen 2.5 72B"}]},{value:"fireworks",label:"Fireworks AI",description:"Use Fireworks AI for fast inference",baseUrl:"https://api.fireworks.ai/inference/v1",docsUrl:"https://docs.fireworks.ai",models:[{value:"accounts/fireworks/models/llama-v3p3-70b-instruct",label:"Llama 3.3 70B Instruct"},{value:"accounts/fireworks/models/mixtral-8x7b-instruct",label:"Mixtral 8x7B Instruct"},{value:"accounts/fireworks/models/qwen2p5-72b-instruct",label:"Qwen 2.5 72B Instruct"}]},{value:"custom",label:"Custom",description:"Use a custom OpenAI-compatible API",baseUrl:"",docsUrl:"",models:[]}],Nx=[{key:"ai_studio_enabled",label:"AI Studio",description:"AI-powered mock generation and editing"},{key:"ai_contract_diff_enabled",label:"AI Contract Diff",description:"Intelligent API contract comparison and change detection"},{key:"mockai_enabled",label:"MockAI",description:"AI-driven dynamic mock responses"},{key:"persona_generation_enabled",label:"Persona Generation",description:"Generate realistic test data personas"},{key:"generative_schema_enabled",label:"Generative Schema",description:"Auto-generate schemas from examples"},{key:"voice_interface_enabled",label:"Voice Interface",description:"Voice-controlled mock configuration"}];function _x(){const{showToast:s}=ut(),t=oe(),[a,r]=h.useState(!1),[n,i]=h.useState(!1),[o,c]=h.useState({provider:"openai",api_key:"",enabled:!1}),{data:d,isLoading:l}=he({queryKey:["byok-config",a],queryFn:()=>px(a)});h.useEffect(()=>{d&&c(d)},[d]);const m=Z({mutationFn:fx,onSuccess:()=>{t.invalidateQueries({queryKey:["byok-config"]}),s("success","Success","BYOK configuration saved successfully")},onError:j=>{s("error","Error",j.message||"Failed to save configuration")}}),g=Z({mutationFn:yx,onSuccess:()=>{t.invalidateQueries({queryKey:["byok-config"]}),c({provider:"openai",api_key:"",enabled:!1}),i(!1),s("success","Deleted","BYOK configuration removed")},onError:j=>{s("error","Error",j.message||"Failed to delete configuration")}}),y=Z({mutationFn:bx,onSuccess:j=>{j.success?s("success","Connected",j.message):s("error","Connection Failed",j.message)},onError:j=>{s("error","Error",j.message||"Failed to test connection")}}),u=()=>{var j;if(!o.api_key.trim()&&o.enabled){s("error","Error","API key is required when BYOK is enabled");return}if(o.provider==="custom"&&!((j=o.base_url)!=null&&j.trim())){s("error","Error","Base URL is required for custom provider");return}m.mutate(o)},p=()=>{if(!o.api_key.trim()){s("error","Error","Enter an API key to test");return}y.mutate({provider:o.provider,api_key:o.api_key,base_url:o.base_url,model:o.model})},f=Ai.find(j=>j.value===o.provider);return l?e.jsx("div",{className:"text-center py-12",children:"Loading configuration..."}):e.jsxs("div",{className:"grid gap-6 md:grid-cols-3",children:[e.jsxs(X,{className:"md:col-span-2",children:[e.jsxs(Le,{children:[e.jsxs(ze,{className:"flex items-center",children:[e.jsx(Gt,{className:"w-5 h-5 mr-2"}),"Configuration"]}),e.jsx(We,{children:"Set up your AI provider API key to use your own credits"})]}),e.jsxs(_e,{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx(pe,{children:"AI Provider"}),e.jsx("div",{className:"grid grid-cols-2 gap-3 mt-2",children:Ai.map(j=>e.jsxs("div",{className:`p-4 border rounded-lg cursor-pointer transition-colors ${o.provider===j.value?"border-primary bg-primary/5":"hover:bg-accent"}`,onClick:()=>c({...o,provider:j.value,base_url:j.baseUrl||o.base_url,model:void 0}),children:[e.jsx("div",{className:"font-medium",children:j.label}),e.jsx("div",{className:"text-sm text-muted-foreground mt-1",children:j.description})]},j.value))})]}),f&&f.models.length>0&&e.jsxs("div",{children:[e.jsx(pe,{children:"Model"}),e.jsxs(Lo,{value:o.model||"",onValueChange:j=>c({...o,model:j}),children:[e.jsx(xn,{className:"mt-2",children:e.jsx($o,{placeholder:"Select a model (optional)"})}),e.jsx(pn,{children:f.models.map(j=>e.jsx(Za,{value:j.value,children:j.label},j.value))})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Optional — defaults to provider's recommended model"})]}),o.provider==="custom"&&e.jsxs("div",{children:[e.jsx(pe,{htmlFor:"custom-model",children:"Model Name"}),e.jsx(B,{id:"custom-model",placeholder:"e.g., gpt-4o, llama-3-70b",value:o.model||"",onChange:j=>c({...o,model:j.target.value}),className:"mt-2"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Model identifier for your OpenAI-compatible API"})]}),e.jsxs("div",{children:[e.jsx(pe,{htmlFor:"api-key",children:"API Key"}),e.jsxs("div",{className:"relative mt-2",children:[e.jsx(B,{id:"api-key",type:a?"text":"password",placeholder:"sk-...",value:o.api_key,onChange:j=>c({...o,api_key:j.target.value}),className:"pr-10"}),e.jsx(k,{variant:"ghost",size:"sm",className:"absolute right-2 top-1/2 -translate-y-1/2",onClick:()=>r(!a),children:a?e.jsx(sn,{className:"w-4 h-4"}):e.jsx(ma,{className:"w-4 h-4"})})]}),(f==null?void 0:f.docsUrl)&&e.jsx("div",{className:"mt-1",children:e.jsxs("a",{href:f.docsUrl,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-primary hover:underline flex items-center",children:["View API documentation",e.jsx(Os,{className:"w-3 h-3 ml-1"})]})})]}),o.provider==="custom"&&e.jsxs("div",{children:[e.jsx(pe,{htmlFor:"base-url",children:"Base URL"}),e.jsx(B,{id:"base-url",type:"url",placeholder:"https://api.example.com/v1",value:o.base_url||"",onChange:j=>c({...o,base_url:j.target.value}),className:"mt-2"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Base URL for your OpenAI-compatible API"})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:"Enable BYOK"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Use your own API key for AI features"})]}),e.jsx(k,{variant:o.enabled?"default":"outline",onClick:()=>c({...o,enabled:!o.enabled}),children:o.enabled?e.jsxs(e.Fragment,{children:[e.jsx(Me,{className:"w-4 h-4 mr-2"}),"Enabled"]}):e.jsxs(e.Fragment,{children:[e.jsx(xs,{className:"w-4 h-4 mr-2"}),"Disabled"]})})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs(k,{onClick:u,disabled:m.isPending,className:"flex-1",children:[e.jsx(Xt,{className:"w-4 h-4 mr-2"}),m.isPending?"Saving...":"Save Configuration"]}),e.jsxs(k,{variant:"outline",onClick:p,disabled:y.isPending||!o.api_key.trim(),children:[y.isPending?e.jsx(Is,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(dt,{className:"w-4 h-4 mr-2"}),"Test"]})]}),(d==null?void 0:d.api_key)&&e.jsx("div",{className:"border-t pt-4",children:n?e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground flex-1",children:"This will permanently remove your stored API key."}),e.jsx(k,{variant:"destructive",size:"sm",onClick:()=>g.mutate(),disabled:g.isPending,children:g.isPending?"Deleting...":"Confirm Delete"}),e.jsx(k,{variant:"outline",size:"sm",onClick:()=>i(!1),children:"Cancel"})]}):e.jsxs(k,{variant:"ghost",className:"text-destructive hover:text-destructive",onClick:()=>i(!0),children:[e.jsx(Qe,{className:"w-4 h-4 mr-2"}),"Remove Configuration"]})})]})]}),e.jsxs(X,{children:[e.jsx(Le,{children:e.jsxs(ze,{className:"flex items-center",children:[e.jsx(ia,{className:"w-5 h-5 mr-2"}),"About BYOK"]})}),e.jsxs(_e,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold mb-2",children:"Free Tier"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"On the Free plan, BYOK is required to use AI features. Connect your own API key to get started."})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold mb-2",children:"Paid Plans"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Pro and Team plans include hosted AI credits, but you can still use BYOK for additional capacity or custom models."})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold mb-2",children:"Security"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Your API keys are encrypted with AES-256-GCM and stored securely. They are only used for AI requests you make."})]}),e.jsx("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg p-3",children:e.jsxs("div",{className:"flex items-start",children:[e.jsx(tt,{className:"w-4 h-4 mr-2 text-yellow-600 dark:text-yellow-400 mt-0.5"}),e.jsx("p",{className:"text-sm text-yellow-800 dark:text-yellow-200",children:"Keep your API keys secure. Never share them publicly or commit them to version control."})]})})]})]})]})}function Sx({orgId:s}){const{showToast:t}=ut(),a=oe(),[r,n]=h.useState(null),{data:i,isLoading:o}=he({queryKey:["org-ai-settings",s],queryFn:()=>vx(s),enabled:!!s});h.useEffect(()=>{i&&n(i)},[i]);const c=Z({mutationFn:l=>jx(s,l),onSuccess:()=>{a.invalidateQueries({queryKey:["org-ai-settings",s]}),t("success","Saved","AI settings updated")},onError:l=>{t("error","Error",l.message||"Failed to save AI settings")}});if(o||!r)return e.jsx("div",{className:"text-center py-12",children:"Loading AI settings..."});const d=l=>{n({...r,feature_flags:{...r.feature_flags,[l]:!r.feature_flags[l]}})};return e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsxs(X,{children:[e.jsxs(Le,{children:[e.jsxs(ze,{className:"flex items-center",children:[e.jsx(on,{className:"w-5 h-5 mr-2"}),"AI Feature Flags"]}),e.jsx(We,{children:"Enable or disable individual AI features"})]}),e.jsx(_e,{className:"space-y-4",children:Nx.map(l=>e.jsxs("div",{className:"flex items-center justify-between p-3 border rounded-lg",children:[e.jsxs("div",{className:"flex-1 mr-4",children:[e.jsx("div",{className:"font-medium text-sm",children:l.label}),e.jsx("div",{className:"text-xs text-muted-foreground",children:l.description})]}),e.jsx(Je,{checked:r.feature_flags[l.key],onCheckedChange:()=>d(l.key)})]},l.key))})]}),e.jsxs(X,{children:[e.jsxs(Le,{children:[e.jsx(ze,{children:"Rate Limits"}),e.jsx(We,{children:"Control AI usage limits per workspace"})]}),e.jsxs(_e,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(pe,{htmlFor:"daily-limit",children:"Max AI calls per workspace per day"}),e.jsx(B,{id:"daily-limit",type:"number",min:0,value:r.max_ai_calls_per_workspace_per_day,onChange:l=>n({...r,max_ai_calls_per_workspace_per_day:parseInt(l.target.value)||0}),className:"mt-2"})]}),e.jsxs("div",{children:[e.jsx(pe,{htmlFor:"monthly-limit",children:"Max AI calls per workspace per month"}),e.jsx(B,{id:"monthly-limit",type:"number",min:0,value:r.max_ai_calls_per_workspace_per_month,onChange:l=>n({...r,max_ai_calls_per_workspace_per_month:parseInt(l.target.value)||0}),className:"mt-2"})]}),e.jsxs(k,{onClick:()=>c.mutate(r),disabled:c.isPending,className:"w-full mt-4",children:[e.jsx(Xt,{className:"w-4 h-4 mr-2"}),c.isPending?"Saving...":"Save AI Settings"]})]})]})]})}function Cx({orgId:s}){const{data:t,isLoading:a}=he({queryKey:["org-usage",s],queryFn:()=>kx(s),enabled:!!s});if(a)return e.jsx("div",{className:"text-center py-12",children:"Loading usage data..."});if(!t)return e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"No usage data available"});const r=[{label:"AI Tokens Used",value:t.total_ai_tokens.toLocaleString(),icon:dt},{label:"Total Requests",value:t.total_requests.toLocaleString(),icon:As},{label:"Storage Used",value:`${t.total_storage_gb.toFixed(2)} GB`,icon:tr},{label:"Hosted Mocks",value:t.hosted_mocks_count.toString(),icon:on},{label:"Plugins Published",value:t.plugins_published.toString(),icon:Gt},{label:"API Tokens",value:t.api_tokens_count.toString(),icon:Gt}];return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"grid gap-4 md:grid-cols-3",children:r.map(n=>e.jsx(X,{children:e.jsx(_e,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:n.label}),e.jsx("p",{className:"text-2xl font-bold",children:n.value})]}),e.jsx(n.icon,{className:"w-8 h-8 text-muted-foreground/30"})]})})},n.label))}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:["For detailed usage breakdown, visit the"," ",e.jsx("a",{href:"/usage",className:"text-primary hover:underline",children:"Usage Dashboard"}),"."]})]})}const Nr=10;function Tx({orgId:s}){const[t,a]=h.useState(0),{data:r,isLoading:n}=he({queryKey:["byok-audit-logs",s],queryFn:()=>wx(s),enabled:!!s});if(n)return e.jsx("div",{className:"text-center py-12",children:"Loading audit logs..."});if(!r||r.length===0)return e.jsx(X,{children:e.jsx(_e,{className:"pt-6",children:e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No BYOK configuration changes recorded yet."})})});const i=Math.ceil(r.length/Nr),o=r.slice(t*Nr,(t+1)*Nr);return e.jsxs(X,{children:[e.jsxs(Le,{children:[e.jsxs(ze,{className:"flex items-center",children:[e.jsx(tr,{className:"w-5 h-5 mr-2"}),"BYOK Configuration History"]}),e.jsxs(We,{children:["Recent changes to your BYOK settings (",r.length," total)"]})]}),e.jsxs(_e,{children:[e.jsx("div",{className:"space-y-3",children:o.map(c=>e.jsxs("div",{className:"flex items-start gap-3 p-3 border rounded-lg",children:[e.jsx("div",{className:`mt-1 w-2 h-2 rounded-full shrink-0 ${c.event_type==="byok_config_deleted"?"bg-red-500":"bg-green-500"}`}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:c.description}),c.metadata&&e.jsxs("div",{className:"flex gap-2 mt-1 flex-wrap",children:[c.metadata.provider&&e.jsx(je,{variant:"secondary",children:String(c.metadata.provider)}),c.metadata.enabled!==void 0&&e.jsx(je,{variant:c.metadata.enabled?"default":"outline",children:c.metadata.enabled?"Enabled":"Disabled"})]}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[new Date(c.created_at).toLocaleString(),c.ip_address&&` · ${c.ip_address}`]})]})]},c.id))}),i>1&&e.jsxs("div",{className:"flex items-center justify-between mt-4 pt-4 border-t",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Page ",t+1," of ",i]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(k,{variant:"outline",size:"sm",onClick:()=>a(c=>Math.max(0,c-1)),disabled:t===0,children:"Previous"}),e.jsx(k,{variant:"outline",size:"sm",onClick:()=>a(c=>Math.min(i-1,c+1)),disabled:t>=i-1,children:"Next"})]})]})]})]})}function Px(){var r;const{data:s,isLoading:t}=he({queryKey:["organizations"],queryFn:xx}),a=(r=s==null?void 0:s[0])==null?void 0:r.id;return e.jsxs("div",{className:"container mx-auto p-6 space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold",children:"Bring Your Own Key (BYOK)"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:"Configure your own AI provider API keys, manage AI features, and monitor usage"})]}),e.jsxs(ys,{defaultValue:"configuration",children:[e.jsxs(bs,{children:[e.jsxs(Se,{value:"configuration",children:[e.jsx(Gt,{className:"w-4 h-4 mr-2"}),"Configuration"]}),e.jsxs(Se,{value:"ai-features",children:[e.jsx(on,{className:"w-4 h-4 mr-2"}),"AI Features"]}),e.jsxs(Se,{value:"usage",children:[e.jsx(As,{className:"w-4 h-4 mr-2"}),"Usage"]}),e.jsxs(Se,{value:"audit",children:[e.jsx(tr,{className:"w-4 h-4 mr-2"}),"Audit Log"]})]}),e.jsx(Ce,{value:"configuration",children:e.jsx(_x,{})}),e.jsx(Ce,{value:"ai-features",children:t?e.jsx("div",{className:"text-center py-12",children:"Loading..."}):a?e.jsx(Sx,{orgId:a}):e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"No organization found. Please create one first."})}),e.jsx(Ce,{value:"usage",children:t?e.jsx("div",{className:"text-center py-12",children:"Loading..."}):a?e.jsx(Cx,{orgId:a}):e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"No organization found."})}),e.jsx(Ce,{value:"audit",children:t?e.jsx("div",{className:"text-center py-12",children:"Loading..."}):a?e.jsx(Tx,{orgId:a}):e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"No organization found."})})]})]})}function Oi({status:s}){switch(s){case"operational":return e.jsx(Me,{className:"h-5 w-5 text-green-500"});case"degraded":return e.jsx(Dt,{className:"h-5 w-5 text-yellow-500"});case"down":return e.jsx(xs,{className:"h-5 w-5 text-red-500"});default:return e.jsx(Vs,{className:"h-5 w-5 text-gray-500"})}}function Oa({status:s}){const t={operational:"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200",degraded:"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-200",down:"bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200"};return e.jsx("span",{className:`px-2 py-1 rounded-full text-xs font-medium ${t[s]||"bg-gray-100 text-gray-800"}`,children:s.charAt(0).toUpperCase()+s.slice(1)})}function Ex(){const{data:s,isLoading:t,error:a}=he({queryKey:["status"],queryFn:async()=>{const i=await fetch("/api/v1/status");if(!i.ok)throw new Error("Failed to fetch status");return i.json()},refetchInterval:6e4});if(t)return e.jsx("div",{className:"container mx-auto px-4 py-8 max-w-4xl",children:e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})})});if(a)return e.jsx("div",{className:"container mx-auto px-4 py-8 max-w-4xl",children:e.jsx(hs,{className:"bg-red-50 dark:bg-red-900/20 border-red-200 dark:border-red-800",children:e.jsx("span",{className:"text-red-800 dark:text-red-200",children:"Failed to load status information. Please try again later."})})});if(!s)return e.jsxs("div",{className:"container mx-auto px-4 py-8 max-w-4xl",children:[e.jsxs("div",{className:"mb-8",children:[e.jsx("h1",{className:"text-3xl font-bold mb-2",children:"Service Status"}),e.jsx("p",{className:"text-muted-foreground",children:"Real-time status of MockForge Cloud services"})]}),e.jsx(hs,{children:e.jsx("span",{children:"No status information is available right now. Check back shortly."})})]});const r=Array.isArray(s.services)?s.services:[],n=Array.isArray(s.incidents)?s.incidents:[];return e.jsxs("div",{className:"container mx-auto px-4 py-8 max-w-4xl",children:[e.jsxs("div",{className:"mb-8",children:[e.jsx("h1",{className:"text-3xl font-bold mb-2",children:"Service Status"}),e.jsx("p",{className:"text-muted-foreground",children:"Real-time status of MockForge Cloud services"})]}),e.jsx(X,{className:"mb-6",children:e.jsxs(Le,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Oi,{status:s.status}),e.jsxs(ze,{children:["All Systems ",s.status==="operational"?"Operational":s.status==="degraded"?"Degraded":"Down"]})]}),e.jsx(Oa,{status:s.status})]}),e.jsxs(We,{children:["Last updated: ",new Date(s.timestamp).toLocaleString()]})]})}),e.jsxs(X,{className:"mb-6",children:[e.jsx(Le,{children:e.jsxs(ze,{className:"flex items-center gap-2",children:[e.jsx(gs,{className:"h-5 w-5"}),"Services"]})}),e.jsx(_e,{children:e.jsx("div",{className:"space-y-4",children:r.map(i=>e.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Oi,{status:i.status}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:i.name}),i.message&&e.jsx("div",{className:"text-sm text-muted-foreground",children:i.message})]})]}),e.jsx(Oa,{status:i.status})]},i.name))})})]}),e.jsxs(X,{children:[e.jsx(Le,{children:e.jsx(ze,{children:"Recent Incidents"})}),e.jsx(_e,{children:n.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Me,{className:"h-12 w-12 mx-auto mb-4 text-green-500"}),e.jsx("p",{children:"No incidents reported. All systems operational."})]}):e.jsx("div",{className:"space-y-4",children:n.map(i=>e.jsx("div",{className:"p-4 border rounded-lg",children:e.jsxs("div",{className:"flex items-start justify-between mb-2",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium",children:i.title}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Started: ",new Date(i.started_at).toLocaleString(),i.resolved_at&&e.jsxs(e.Fragment,{children:[" • Resolved: ",new Date(i.resolved_at).toLocaleString()]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Oa,{status:i.status}),e.jsx(Oa,{status:i.impact})]})]})},i.id))})})]}),e.jsx("div",{className:"mt-6 text-center text-sm text-muted-foreground",children:e.jsxs("p",{children:["Status page updates automatically every minute. For more information, visit"," ",e.jsx("a",{href:"https://docs.mockforge.dev",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"our documentation"})," ","or"," ",e.jsx("a",{href:"/support",className:"text-primary hover:underline",children:"contact support"}),"."]})})]})}const Ee="/api/v1";function Ax(){return{Authorization:`Bearer ${localStorage.getItem("auth_token")}`,"Content-Type":"application/json"}}async function Ae(s,t){const a=await fetch(s,{...t,headers:{...Ax(),...t==null?void 0:t.headers}});if(!a.ok){const r=await a.json().catch(()=>({}));throw new Error(r.message||r.error||`Request failed (${a.status})`)}return a.json()}const Ox=()=>Ae(`${Ee}/organizations`),Ix=s=>Ae(`${Ee}/organizations`,{method:"POST",body:JSON.stringify(s)}),Mx=(s,t)=>Ae(`${Ee}/organizations/${s}`,{method:"PATCH",body:JSON.stringify(t)}),Rx=s=>Ae(`${Ee}/organizations/${s}`,{method:"DELETE"}),Lx=s=>Ae(`${Ee}/organizations/${s}/members`),$x=(s,t)=>Ae(`${Ee}/organizations/${s}/members`,{method:"POST",body:JSON.stringify(t)}),Fx=(s,t,a)=>Ae(`${Ee}/organizations/${s}/members/${t}`,{method:"PATCH",body:JSON.stringify({role:a})}),Dx=(s,t)=>Ae(`${Ee}/organizations/${s}/members/${t}`,{method:"DELETE"}),qo=(s,t)=>Ae(`${Ee}/organizations/${s}/invitations`,{method:"POST",body:JSON.stringify(t)}),zx=(s,t)=>{const a=new URLSearchParams;return a.set("limit",String(t.limit)),t.offset&&a.set("offset",String(t.offset)),t.event_type&&a.set("event_type",t.event_type),Ae(`${Ee}/organizations/${s}/audit-logs?${a}`)},qx=()=>Ae(`${Ee}/sso/config`),Ux=s=>Ae(`${Ee}/sso/config`,{method:"POST",body:JSON.stringify(s)}),Bx=()=>Ae(`${Ee}/sso/config`,{method:"DELETE"}),Vx=()=>Ae(`${Ee}/sso/enable`,{method:"POST"}),Kx=()=>Ae(`${Ee}/sso/disable`,{method:"POST"}),Jx=s=>Ae(`${Ee}/organizations/${s}/templates`),Hx=(s,t)=>Ae(`${Ee}/organizations/${s}/templates`,{method:"POST",body:JSON.stringify(t)}),Wx=(s,t,a)=>Ae(`${Ee}/organizations/${s}/templates/${t}`,{method:"PATCH",body:JSON.stringify(a)}),Gx=(s,t)=>Ae(`${Ee}/organizations/${s}/templates/${t}`,{method:"DELETE"}),Zx=s=>Ae(`${Ee}/organizations/${s}/usage`),Qx=s=>Ae(`${Ee}/organizations/${s}/billing`),Yx=s=>Ae(`${Ee}/organizations/${s}/quota`),Xx=s=>Ae(`${Ee}/organizations/${s}/settings/ai`),ep=(s,t)=>Ae(`${Ee}/organizations/${s}/settings/ai`,{method:"PATCH",body:JSON.stringify(t)}),tp=(s,t={})=>{const a=new URLSearchParams;return t.severity&&a.set("severity",t.severity),t.limit&&a.set("limit",String(t.limit)),Ae(`${Ee}/security/suspicious-activities${a.toString()?`?${a}`:""}`,{headers:{"X-Organization-Id":s}})},sp=(s,t)=>Ae(`${Ee}/security/suspicious-activities/${t}/resolve`,{method:"POST",headers:{"X-Organization-Id":s}});function ap(s){switch(s){case"owner":return e.jsx(nd,{className:"w-4 h-4 text-yellow-500"});case"admin":return e.jsx(Zt,{className:"w-4 h-4 text-blue-500"});default:return e.jsx(Qu,{className:"w-4 h-4 text-gray-500"})}}function rp(s){switch(s){case"owner":return e.jsx(je,{className:"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-200",children:"Owner"});case"admin":return e.jsx(je,{className:"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200",children:"Admin"});default:return e.jsx(je,{variant:"secondary",children:"Member"})}}function Qa(s){switch(s){case"team":return e.jsx(je,{className:"bg-purple-100 text-purple-800 dark:bg-purple-900 dark:text-purple-200",children:"Team"});case"pro":return e.jsx(je,{className:"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200",children:"Pro"});default:return e.jsx(je,{variant:"secondary",children:"Free"})}}function np({org:s}){const{showToast:t}=ut(),a=oe(),[r,n]=h.useState(!1),[i,o]=h.useState(!1),[c,d]=h.useState(""),[l,m]=h.useState("member"),[g,y]=h.useState(""),[u,p]=h.useState("member"),[f,j]=h.useState(null),[C,T]=h.useState(null),[N,w]=h.useState(null),{data:O,isLoading:L}=he({queryKey:["org-members",s.id],queryFn:()=>Lx(s.id)}),I=Z({mutationFn:$=>$x(s.id,$),onSuccess:()=>{t("success","Member added",`Successfully added ${c}`),d(""),m("member"),n(!1),a.invalidateQueries({queryKey:["org-members",s.id]})},onError:$=>t("error","Failed to add member",$.message)}),b=Z({mutationFn:({userId:$,role:ae})=>Fx(s.id,$,ae),onSuccess:()=>{t("success","Role updated"),w(null),a.invalidateQueries({queryKey:["org-members",s.id]})},onError:$=>t("error","Failed to update role",$.message)}),A=Z({mutationFn:$=>Dx(s.id,$),onSuccess:()=>{t("success","Member removed"),T(null),a.invalidateQueries({queryKey:["org-members",s.id]})},onError:$=>t("error","Failed to remove member",$.message)}),_=Z({mutationFn:$=>qo(s.id,$),onSuccess:$=>{t("success","Invitation created"),j($)},onError:$=>t("error","Failed to create invitation",$.message)});return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsxs(k,{size:"sm",variant:"outline",onClick:()=>o(!0),children:[e.jsx(Jd,{className:"w-4 h-4 mr-2"}),"Invite Link"]}),e.jsxs(k,{size:"sm",onClick:()=>n(!0),children:[e.jsx(za,{className:"w-4 h-4 mr-2"}),"Add Member"]})]}),L?e.jsx("div",{className:"text-center py-4 text-muted-foreground",children:"Loading members..."}):O&&O.length>0?e.jsx("div",{className:"space-y-2",children:O.map($=>e.jsxs("div",{className:"flex items-center justify-between p-3 border rounded-lg",children:[e.jsxs("div",{className:"flex items-center space-x-3",children:[ap($.role),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:$.username}),e.jsx("div",{className:"text-sm text-muted-foreground",children:$.email})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[N===$.user_id&&$.role!=="owner"?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs("select",{className:"text-sm border rounded px-2 py-1 bg-background",defaultValue:$.role,onChange:ae=>b.mutate({userId:$.user_id,role:ae.target.value}),children:[e.jsx("option",{value:"admin",children:"Admin"}),e.jsx("option",{value:"member",children:"Member"})]}),e.jsx(k,{size:"sm",variant:"ghost",onClick:()=>w(null),children:e.jsx(ha,{className:"w-3 h-3"})})]}):e.jsx("button",{className:"cursor-pointer",onClick:()=>$.role!=="owner"&&w($.user_id),title:$.role==="owner"?"Owner role cannot be changed":"Click to change role",children:rp($.role)}),$.role!=="owner"&&(C===$.user_id?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(k,{size:"sm",variant:"destructive",onClick:()=>A.mutate($.user_id),disabled:A.isPending,children:A.isPending?"Removing...":"Confirm"}),e.jsx(k,{size:"sm",variant:"outline",onClick:()=>T(null),children:"Cancel"})]}):e.jsx(k,{size:"sm",variant:"ghost",className:"text-destructive hover:text-destructive",onClick:()=>T($.user_id),children:e.jsx(Qe,{className:"w-4 h-4"})}))]})]},$.id))}):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No members found"}),e.jsx(qe,{open:r,onOpenChange:n,children:e.jsxs(Ue,{className:"sm:max-w-md",children:[e.jsxs(Be,{children:[e.jsx(Ve,{children:"Add Member"}),e.jsx(Ge,{children:"Add an existing user to this organization by email"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(pe,{children:"Email"}),e.jsx(B,{type:"email",placeholder:"user@example.com",value:c,onChange:$=>d($.target.value)})]}),e.jsxs("div",{children:[e.jsx(pe,{children:"Role"}),e.jsxs("select",{className:"w-full border rounded px-3 py-2 bg-background mt-1",value:l,onChange:$=>m($.target.value),children:[e.jsx("option",{value:"member",children:"Member"}),e.jsx("option",{value:"admin",children:"Admin"})]})]})]}),e.jsxs(Ke,{children:[e.jsx(k,{variant:"outline",onClick:()=>n(!1),children:"Cancel"}),e.jsx(k,{onClick:()=>I.mutate({email:c,role:l}),disabled:!c.trim()||I.isPending,children:I.isPending?"Adding...":"Add Member"})]})]})}),e.jsx(qe,{open:i,onOpenChange:$=>{o($),$||j(null)},children:e.jsxs(Ue,{className:"sm:max-w-md",children:[e.jsxs(Be,{children:[e.jsx(Ve,{children:"Create Invitation Link"}),e.jsx(Ge,{children:"Generate a shareable invitation link for new members"})]}),f?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(pe,{children:"Invitation Link"}),e.jsxs("div",{className:"flex gap-2 mt-1",children:[e.jsx(B,{readOnly:!0,value:`${window.location.origin}/invite/${f.token}`}),e.jsx(k,{variant:"outline",onClick:()=>{navigator.clipboard.writeText(`${window.location.origin}/invite/${f.token}`),t("success","Copied to clipboard")},children:e.jsx(fs,{className:"w-4 h-4"})})]})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Share this link with the person you want to invite."})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(pe,{children:"Email"}),e.jsx(B,{type:"email",placeholder:"user@example.com",value:g,onChange:$=>y($.target.value)})]}),e.jsxs("div",{children:[e.jsx(pe,{children:"Role"}),e.jsxs("select",{className:"w-full border rounded px-3 py-2 bg-background mt-1",value:u,onChange:$=>p($.target.value),children:[e.jsx("option",{value:"member",children:"Member"}),e.jsx("option",{value:"admin",children:"Admin"})]})]})]}),e.jsx(Ke,{children:f?e.jsx(k,{onClick:()=>{o(!1),j(null),y("")},children:"Done"}):e.jsxs(e.Fragment,{children:[e.jsx(k,{variant:"outline",onClick:()=>o(!1),children:"Cancel"}),e.jsx(k,{onClick:()=>_.mutate({email:g,role:u}),disabled:!g.trim()||_.isPending,children:_.isPending?"Creating...":"Create Invitation"})]})})]})})]})}function ip({org:s}){const{showToast:t}=ut(),a=oe(),[r,n]=h.useState(!1),[i,o]=h.useState(s.name),[c,d]=h.useState(s.slug),[l,m]=h.useState(!1);h.useEffect(()=>{o(s.name),d(s.slug),n(!1)},[s.id,s.name,s.slug]);const g=Z({mutationFn:()=>Mx(s.id,{name:i,slug:c}),onSuccess:()=>{t("success","Organization updated"),n(!1),a.invalidateQueries({queryKey:["organizations"]})},onError:u=>t("error","Failed to update",u.message)}),y=Z({mutationFn:()=>Rx(s.id),onSuccess:()=>{t("success","Organization deleted"),a.invalidateQueries({queryKey:["organizations"]})},onError:u=>t("error","Failed to delete",u.message)});return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h4",{className:"text-sm font-semibold",children:"Organization Details"}),!r&&e.jsxs(k,{size:"sm",variant:"ghost",onClick:()=>n(!0),children:[e.jsx(Ks,{className:"w-4 h-4 mr-1"}),"Edit"]})]}),e.jsxs("div",{children:[e.jsx(pe,{children:"Organization Name"}),e.jsx(B,{value:i,disabled:!r,onChange:u=>o(u.target.value)})]}),e.jsxs("div",{children:[e.jsx(pe,{children:"Slug"}),e.jsx(B,{value:c,disabled:!r,onChange:u=>d(u.target.value)})]}),e.jsxs("div",{children:[e.jsx(pe,{children:"Plan"}),e.jsx("div",{className:"mt-2",children:Qa(s.plan)})]}),e.jsxs("div",{children:[e.jsx(pe,{children:"Created"}),e.jsx("div",{className:"text-sm text-muted-foreground mt-1",children:new Date(s.created_at).toLocaleDateString()})]}),r&&e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(k,{onClick:()=>g.mutate(),disabled:g.isPending,children:[e.jsx(Xt,{className:"w-4 h-4 mr-2"}),g.isPending?"Saving...":"Save"]}),e.jsx(k,{variant:"outline",onClick:()=>{n(!1),o(s.name),d(s.slug)},children:"Cancel"})]})]}),e.jsxs("div",{className:"border-t pt-6",children:[e.jsx("h4",{className:"text-sm font-semibold text-destructive mb-2",children:"Danger Zone"}),l?e.jsxs("div",{className:"flex items-center gap-3 p-3 border border-destructive rounded-lg",children:[e.jsxs("p",{className:"text-sm text-muted-foreground flex-1",children:["This will permanently delete ",e.jsx("strong",{children:s.name})," and all associated data. This cannot be undone."]}),e.jsx(k,{variant:"destructive",size:"sm",onClick:()=>y.mutate(),disabled:y.isPending,children:y.isPending?"Deleting...":"Confirm Delete"}),e.jsx(k,{variant:"outline",size:"sm",onClick:()=>m(!1),children:"Cancel"})]}):e.jsxs(k,{variant:"ghost",className:"text-destructive hover:text-destructive",onClick:()=>m(!0),children:[e.jsx(Qe,{className:"w-4 h-4 mr-2"}),"Delete Organization"]})]})]})}function op({org:s}){const[t,a]=h.useState(0),[r,n]=h.useState(""),i=20,{data:o,isLoading:c}=he({queryKey:["audit-logs",s.id,t,r],queryFn:()=>zx(s.id,{limit:i,offset:t,event_type:r||void 0})});return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(pe,{className:"text-sm",children:"Filter by event:"}),e.jsxs("select",{className:"border rounded px-2 py-1 text-sm bg-background",value:r,onChange:d=>{n(d.target.value),a(0)},children:[e.jsx("option",{value:"",children:"All events"}),e.jsx("option",{value:"org.updated",children:"Organization Updated"}),e.jsx("option",{value:"org.deleted",children:"Organization Deleted"}),e.jsx("option",{value:"member.added",children:"Member Added"}),e.jsx("option",{value:"member.removed",children:"Member Removed"}),e.jsx("option",{value:"member.role_changed",children:"Role Changed"}),e.jsx("option",{value:"settings.updated",children:"Settings Updated"}),e.jsx("option",{value:"sso.configured",children:"SSO Configured"}),e.jsx("option",{value:"plan.changed",children:"Plan Changed"})]})]}),c?e.jsx("div",{className:"text-center py-4 text-muted-foreground",children:"Loading audit logs..."}):o&&o.logs.length>0?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"space-y-2",children:o.logs.map(d=>e.jsxs("div",{className:"p-3 border rounded-lg text-sm",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx(je,{variant:"secondary",className:"text-xs",children:d.event_type}),e.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(d.created_at).toLocaleString()})]}),e.jsx("p",{className:"text-muted-foreground",children:d.description}),d.ip_address&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["IP: ",d.ip_address]})]},d.id))}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-sm text-muted-foreground",children:["Showing ",t+1,"-",Math.min(t+i,o.total)," of ",o.total]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(k,{size:"sm",variant:"outline",disabled:t===0,onClick:()=>a(Math.max(0,t-i)),children:e.jsx(Ya,{className:"w-4 h-4"})}),e.jsx(k,{size:"sm",variant:"outline",disabled:t+i>=o.total,onClick:()=>a(t+i),children:e.jsx(Xa,{className:"w-4 h-4"})})]})]})]}):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No audit logs found"})]})}function lp({org:s}){const{showToast:t}=ut(),a=oe(),[r,n]=h.useState(""),{data:i,isLoading:o}=he({queryKey:["suspicious-activities",s.id,r],queryFn:()=>tp(s.id,{severity:r||void 0,limit:100})}),c=Z({mutationFn:l=>sp(s.id,l),onSuccess:()=>{a.invalidateQueries({queryKey:["suspicious-activities",s.id]}),t("Marked as resolved","success")},onError:l=>t(l.message,"error")}),d=l=>{const m=l.toLowerCase();return m==="critical"||m==="high"?e.jsx(je,{className:"bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200",children:l}):m==="medium"?e.jsx(je,{className:"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-200",children:l}):e.jsx(je,{variant:"secondary",children:l})};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(pe,{className:"text-sm",children:"Severity:"}),e.jsxs("select",{className:"border rounded px-2 py-1 text-sm bg-background",value:r,onChange:l=>n(l.target.value),children:[e.jsx("option",{value:"",children:"All severities"}),e.jsx("option",{value:"critical",children:"Critical"}),e.jsx("option",{value:"high",children:"High"}),e.jsx("option",{value:"medium",children:"Medium"}),e.jsx("option",{value:"low",children:"Low"})]}),e.jsx("span",{className:"ml-auto text-xs text-muted-foreground",children:i?`${i.total} unresolved`:""})]}),o?e.jsx("div",{className:"text-center py-4 text-muted-foreground",children:"Loading security events…"}):i&&i.activities.length>0?e.jsx("div",{className:"space-y-2",children:i.activities.map(l=>e.jsxs("div",{className:"p-3 border rounded-lg text-sm",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Dt,{className:"w-4 h-4 text-yellow-600"}),e.jsx(je,{variant:"secondary",className:"text-xs",children:l.activity_type}),d(l.severity)]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(l.created_at).toLocaleString()})]}),e.jsx("p",{className:"text-muted-foreground",children:l.description}),e.jsxs("div",{className:"mt-2 flex flex-wrap gap-3 text-xs text-muted-foreground",children:[l.ip_address&&e.jsxs("span",{children:["IP: ",l.ip_address]}),l.user_agent&&e.jsxs("span",{className:"truncate max-w-md",title:l.user_agent,children:["UA: ",l.user_agent]})]}),e.jsx("div",{className:"mt-2 flex justify-end",children:e.jsxs(k,{size:"sm",variant:"outline",disabled:c.isPending,onClick:()=>c.mutate(l.id),children:[e.jsx(Me,{className:"w-4 h-4 mr-1"}),"Mark resolved"]})})]},l.id))}):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No unresolved suspicious activities."})]})}function cp({org:s}){const{showToast:t}=ut(),a=oe(),[r,n]=h.useState(!1),[i,o]=h.useState(null),[c,d]=h.useState(""),[l,m]=h.useState(""),[g,y]=h.useState(!1),[u,p]=h.useState(null),{data:f,isLoading:j}=he({queryKey:["org-templates",s.id],queryFn:()=>Jx(s.id)}),C=Z({mutationFn:()=>Hx(s.id,{name:c,description:l||void 0,is_default:g}),onSuccess:()=>{t("success","Template created"),n(!1),d(""),m(""),y(!1),a.invalidateQueries({queryKey:["org-templates",s.id]})},onError:I=>t("error","Failed to create template",I.message)}),T=Z({mutationFn:()=>{if(!i)throw new Error("No template selected");return Wx(s.id,i.id,{name:c,description:l||void 0,is_default:g})},onSuccess:()=>{t("success","Template updated"),o(null),a.invalidateQueries({queryKey:["org-templates",s.id]})},onError:I=>t("error","Failed to update template",I.message)}),N=Z({mutationFn:I=>Gx(s.id,I),onSuccess:()=>{t("success","Template deleted"),p(null),a.invalidateQueries({queryKey:["org-templates",s.id]})},onError:I=>t("error","Failed to delete template",I.message)}),w=I=>{d(I.name),m(I.description||""),y(I.is_default),o(I)},O=()=>{n(!1),o(null),d(""),m(""),y(!1)},L=e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(pe,{children:"Name"}),e.jsx(B,{value:c,onChange:I=>d(I.target.value),placeholder:"Template name"})]}),e.jsxs("div",{children:[e.jsx(pe,{children:"Description"}),e.jsx(B,{value:l,onChange:I=>m(I.target.value),placeholder:"Optional description"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",id:"template-default",checked:g,onChange:I=>y(I.target.checked),className:"rounded"}),e.jsx(pe,{htmlFor:"template-default",children:"Set as default template"})]})]});return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex justify-end",children:e.jsxs(k,{size:"sm",onClick:()=>n(!0),children:[e.jsx(kt,{className:"w-4 h-4 mr-2"}),"New Template"]})}),j?e.jsx("div",{className:"text-center py-4 text-muted-foreground",children:"Loading templates..."}):f&&f.templates.length>0?e.jsx("div",{className:"space-y-2",children:f.templates.map(I=>e.jsxs("div",{className:"flex items-center justify-between p-3 border rounded-lg",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"font-medium flex items-center gap-2",children:[e.jsx(Rs,{className:"w-4 h-4 text-muted-foreground"}),I.name,I.is_default&&e.jsx(je,{variant:"secondary",className:"text-xs",children:"Default"})]}),I.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:I.description})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(k,{size:"sm",variant:"ghost",onClick:()=>w(I),children:e.jsx(Ks,{className:"w-4 h-4"})}),u===I.id?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(k,{size:"sm",variant:"destructive",onClick:()=>N.mutate(I.id),disabled:N.isPending,children:N.isPending?"...":"Yes"}),e.jsx(k,{size:"sm",variant:"outline",onClick:()=>p(null),children:"No"})]}):e.jsx(k,{size:"sm",variant:"ghost",className:"text-destructive hover:text-destructive",onClick:()=>p(I.id),children:e.jsx(Qe,{className:"w-4 h-4"})})]})]},I.id))}):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No templates yet"}),e.jsx(qe,{open:r,onOpenChange:I=>{I?n(!0):O()},children:e.jsxs(Ue,{className:"sm:max-w-md",children:[e.jsxs(Be,{children:[e.jsx(Ve,{children:"Create Template"}),e.jsx(Ge,{children:"Create a new organization template"})]}),L,e.jsxs(Ke,{children:[e.jsx(k,{variant:"outline",onClick:O,children:"Cancel"}),e.jsx(k,{onClick:()=>C.mutate(),disabled:!c.trim()||C.isPending,children:C.isPending?"Creating...":"Create"})]})]})}),e.jsx(qe,{open:!!i,onOpenChange:I=>{I||O()},children:e.jsxs(Ue,{className:"sm:max-w-md",children:[e.jsxs(Be,{children:[e.jsx(Ve,{children:"Edit Template"}),e.jsx(Ge,{children:"Update template details"})]}),L,e.jsxs(Ke,{children:[e.jsx(k,{variant:"outline",onClick:O,children:"Cancel"}),e.jsx(k,{onClick:()=>T.mutate(),disabled:!c.trim()||T.isPending,children:T.isPending?"Saving...":"Save"})]})]})})]})}function dp({org:s}){const{showToast:t}=ut(),a=oe(),[r,n]=h.useState(""),[i,o]=h.useState(""),[c,d]=h.useState(""),[l,m]=h.useState(""),[g,y]=h.useState(!1),{data:u,isLoading:p}=he({queryKey:["sso-config",s.id],queryFn:qx,enabled:s.plan==="team"});h.useEffect(()=>{u&&(n(u.saml_entity_id||""),o(u.saml_sso_url||""),d(u.saml_slo_url||""))},[u]);const f=Z({mutationFn:()=>Ux({provider:"saml",saml_entity_id:r,saml_sso_url:i,saml_slo_url:c||void 0,saml_x509_cert:l||void 0}),onSuccess:()=>{t("success","SSO configuration saved"),m(""),a.invalidateQueries({queryKey:["sso-config",s.id]})},onError:T=>t("error","Failed to save SSO config",T.message)}),j=Z({mutationFn:()=>u!=null&&u.enabled?Kx():Vx(),onSuccess:()=>{t("success",`SSO ${u!=null&&u.enabled?"disabled":"enabled"}`),a.invalidateQueries({queryKey:["sso-config",s.id]})},onError:T=>t("error","Failed to toggle SSO",T.message)}),C=Z({mutationFn:Bx,onSuccess:()=>{t("success","SSO configuration deleted"),y(!1),n(""),o(""),d(""),a.invalidateQueries({queryKey:["sso-config",s.id]})},onError:T=>t("error","Failed to delete SSO config",T.message)});return s.plan!=="team"?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(Ls,{className:"w-8 h-8 mx-auto text-muted-foreground mb-3"}),e.jsx("h4",{className:"font-semibold mb-1",children:"SSO requires Team plan"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Upgrade to the Team plan to configure SAML-based Single Sign-On for your organization."})]}):p?e.jsx("div",{className:"text-center py-4 text-muted-foreground",children:"Loading SSO configuration..."}):e.jsxs("div",{className:"space-y-6",children:[u&&e.jsxs("div",{className:"flex items-center justify-between p-3 border rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-sm font-medium",children:"SSO Status"}),e.jsx(je,{className:u.enabled?"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200":"",children:u.enabled?"Enabled":"Disabled"})]}),e.jsxs(k,{size:"sm",variant:"outline",onClick:()=>j.mutate(),disabled:j.isPending,children:[u.enabled?e.jsx(xo,{className:"w-4 h-4 mr-2"}):e.jsx(go,{className:"w-4 h-4 mr-2"}),u.enabled?"Disable":"Enable"]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"text-sm font-semibold",children:"SAML 2.0 Configuration"}),e.jsxs("div",{children:[e.jsx(pe,{children:"Entity ID (Issuer)"}),e.jsx(B,{value:r,onChange:T=>n(T.target.value),placeholder:"https://idp.example.com/metadata"})]}),e.jsxs("div",{children:[e.jsx(pe,{children:"SSO URL (Login URL)"}),e.jsx(B,{value:i,onChange:T=>o(T.target.value),placeholder:"https://idp.example.com/sso"})]}),e.jsxs("div",{children:[e.jsx(pe,{children:"SLO URL (Logout URL, optional)"}),e.jsx(B,{value:c,onChange:T=>d(T.target.value),placeholder:"https://idp.example.com/slo"})]}),e.jsxs("div",{children:[e.jsx(pe,{children:"X.509 Certificate (paste new cert to update)"}),e.jsx("textarea",{className:"w-full border rounded px-3 py-2 text-sm bg-background font-mono min-h-[100px] mt-1",value:l,onChange:T=>m(T.target.value),placeholder:`-----BEGIN CERTIFICATE----- ... -----END CERTIFICATE-----`})]}),e.jsx("div",{className:"flex gap-2",children:e.jsxs(k,{onClick:()=>f.mutate(),disabled:!r.trim()||!i.trim()||f.isPending,children:[e.jsx(Xt,{className:"w-4 h-4 mr-2"}),f.isPending?"Saving...":"Save Configuration"]})})]}),u&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("h4",{className:"text-sm font-semibold",children:"Service Provider Details"}),e.jsxs("div",{className:"p-3 border rounded-lg bg-muted/50 text-sm space-y-2",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"SAML Metadata URL: "}),e.jsxs("code",{className:"text-xs",children:[window.location.origin,"/api/v1/sso/saml/metadata/",s.slug]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"ACS URL: "}),e.jsxs("code",{className:"text-xs",children:[window.location.origin,"/api/v1/sso/saml/acs/",s.slug]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"SLO URL: "}),e.jsxs("code",{className:"text-xs",children:[window.location.origin,"/api/v1/sso/saml/slo/",s.slug]})]})]})]}),u&&e.jsx("div",{className:"border-t pt-4",children:g?e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground flex-1",children:"Remove SSO configuration? Users will need to log in with email/password."}),e.jsx(k,{variant:"destructive",size:"sm",onClick:()=>C.mutate(),disabled:C.isPending,children:C.isPending?"Deleting...":"Confirm Delete"}),e.jsx(k,{variant:"outline",size:"sm",onClick:()=>y(!1),children:"Cancel"})]}):e.jsxs(k,{variant:"ghost",className:"text-destructive hover:text-destructive",onClick:()=>y(!0),children:[e.jsx(Qe,{className:"w-4 h-4 mr-2"}),"Remove SSO Configuration"]})})]})}function up({org:s}){const{showToast:t}=ut(),[a,r]=h.useState(!1),[n,i]=h.useState(""),[o,c]=h.useState("member"),[d,l]=h.useState(null),m=Z({mutationFn:g=>qo(s.id,g),onSuccess:g=>{t("success","Invitation created"),l(g)},onError:g=>t("error","Failed to create invitation",g.message)});return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex justify-end",children:e.jsxs(k,{size:"sm",onClick:()=>{r(!0),l(null),i("")},children:[e.jsx(za,{className:"w-4 h-4 mr-2"}),"Create Invitation"]})}),e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(za,{className:"w-8 h-8 mx-auto mb-3"}),e.jsx("p",{children:"Create invitation links to invite new members to your organization."}),e.jsx("p",{className:"text-sm mt-1",children:"Invitations are single-use and expire after acceptance."})]}),e.jsx(qe,{open:a,onOpenChange:g=>{r(g),g||l(null)},children:e.jsxs(Ue,{className:"sm:max-w-md",children:[e.jsxs(Be,{children:[e.jsx(Ve,{children:"Create Invitation"}),e.jsx(Ge,{children:"Generate a shareable invitation link for a new member"})]}),d?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(pe,{children:"Invitation Link"}),e.jsxs("div",{className:"flex gap-2 mt-1",children:[e.jsx(B,{readOnly:!0,value:`${window.location.origin}/invite/${d.token}`}),e.jsx(k,{variant:"outline",onClick:()=>{navigator.clipboard.writeText(`${window.location.origin}/invite/${d.token}`),t("success","Copied to clipboard")},children:e.jsx(fs,{className:"w-4 h-4"})})]})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Share this link with the person you want to invite."})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(pe,{children:"Email"}),e.jsx(B,{type:"email",placeholder:"user@example.com",value:n,onChange:g=>i(g.target.value)})]}),e.jsxs("div",{children:[e.jsx(pe,{children:"Role"}),e.jsxs("select",{className:"w-full border rounded px-3 py-2 bg-background mt-1",value:o,onChange:g=>c(g.target.value),children:[e.jsx("option",{value:"member",children:"Member"}),e.jsx("option",{value:"admin",children:"Admin"})]})]})]}),e.jsx(Ke,{children:d?e.jsx(k,{onClick:()=>{r(!1),l(null),i("")},children:"Done"}):e.jsxs(e.Fragment,{children:[e.jsx(k,{variant:"outline",onClick:()=>r(!1),children:"Cancel"}),e.jsx(k,{onClick:()=>m.mutate({email:n,role:o}),disabled:!n.trim()||m.isPending,children:m.isPending?"Creating...":"Create Invitation"})]})})]})})]})}function mp({org:s}){const{data:t,isLoading:a}=he({queryKey:["org-usage",s.id],queryFn:()=>Zx(s.id)}),{data:r,isLoading:n}=he({queryKey:["org-billing",s.id],queryFn:()=>Qx(s.id)}),{data:i,isLoading:o}=he({queryKey:["org-quota",s.id],queryFn:()=>Yx(s.id)});return a||n||o?e.jsx("div",{className:"text-center py-4 text-muted-foreground",children:"Loading usage data..."}):e.jsxs("div",{className:"space-y-6",children:[t&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-semibold mb-3",children:"Current Usage"}),e.jsxs("div",{className:"grid gap-3 grid-cols-2",children:[e.jsxs("div",{className:"p-3 border rounded-lg",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"Total Requests"}),e.jsx("div",{className:"text-2xl font-bold",children:t.total_requests.toLocaleString()})]}),e.jsxs("div",{className:"p-3 border rounded-lg",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"Storage"}),e.jsxs("div",{className:"text-2xl font-bold",children:[t.total_storage_gb.toFixed(2)," GB"]})]}),e.jsxs("div",{className:"p-3 border rounded-lg",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"AI Tokens"}),e.jsx("div",{className:"text-2xl font-bold",children:t.total_ai_tokens.toLocaleString()})]}),e.jsxs("div",{className:"p-3 border rounded-lg",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"Hosted Mocks"}),e.jsx("div",{className:"text-2xl font-bold",children:t.hosted_mocks_count})]}),e.jsxs("div",{className:"p-3 border rounded-lg",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"Plugins Published"}),e.jsx("div",{className:"text-2xl font-bold",children:t.plugins_published})]}),e.jsxs("div",{className:"p-3 border rounded-lg",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"API Tokens"}),e.jsx("div",{className:"text-2xl font-bold",children:t.api_tokens_count})]})]})]}),r&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-semibold mb-3",children:"Billing"}),e.jsxs("div",{className:"p-3 border rounded-lg space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm",children:"Plan"}),Qa(r.plan)]}),r.subscription&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm",children:"Status"}),e.jsx(je,{className:r.subscription.status==="active"?"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200":"",children:r.subscription.status})]}),r.subscription.current_period_end&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm",children:"Period Ends"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:new Date(r.subscription.current_period_end).toLocaleDateString()})]}),r.subscription.cancel_at_period_end&&e.jsx(je,{className:"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-200",children:"Cancels at period end"})]})]})]}),i&&Object.keys(i.quota).length>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-semibold mb-3",children:"Quota"}),e.jsx("div",{className:"p-3 border rounded-lg space-y-2",children:Object.entries(i.quota).map(([d,l])=>e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:d.replace(/_/g," ")}),e.jsx("span",{className:"font-medium",children:String(l)})]},d))})]})]})}function hp({org:s}){const{showToast:t}=ut(),a=oe(),{data:r,isLoading:n}=he({queryKey:["org-ai-settings",s.id],queryFn:()=>Xx(s.id)}),[i,o]=h.useState(0),[c,d]=h.useState(0),[l,m]=h.useState({ai_studio_enabled:!0,ai_contract_diff_enabled:!0,mockai_enabled:!0,persona_generation_enabled:!0});h.useEffect(()=>{r&&(o(r.max_ai_calls_per_workspace_per_day),d(r.max_ai_calls_per_workspace_per_month),m(r.feature_flags))},[r]);const g=Z({mutationFn:()=>ep(s.id,{max_ai_calls_per_workspace_per_day:i,max_ai_calls_per_workspace_per_month:c,feature_flags:l}),onSuccess:()=>{t("success","AI settings updated"),a.invalidateQueries({queryKey:["org-ai-settings",s.id]})},onError:y=>t("error","Failed to update AI settings",y.message)});return n?e.jsx("div",{className:"text-center py-4 text-muted-foreground",children:"Loading AI settings..."}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"text-sm font-semibold",children:"Rate Limits"}),e.jsxs("div",{children:[e.jsx(pe,{children:"Max AI calls per workspace per day"}),e.jsx(B,{type:"number",value:i,onChange:y=>o(Number(y.target.value))})]}),e.jsxs("div",{children:[e.jsx(pe,{children:"Max AI calls per workspace per month"}),e.jsx(B,{type:"number",value:c,onChange:y=>d(Number(y.target.value))})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h4",{className:"text-sm font-semibold",children:"Feature Flags"}),[["ai_studio_enabled","AI Studio"],["ai_contract_diff_enabled","AI Contract Diff"],["mockai_enabled","MockAI"],["persona_generation_enabled","Persona Generation"]].map(([y,u])=>e.jsxs("div",{className:"flex items-center justify-between p-2 border rounded-lg",children:[e.jsx("span",{className:"text-sm",children:u}),e.jsxs("button",{onClick:()=>m(p=>({...p,[y]:!p[y]})),className:"flex items-center gap-2 cursor-pointer",children:[l[y]?e.jsx(xo,{className:"w-6 h-6 text-primary"}):e.jsx(go,{className:"w-6 h-6 text-muted-foreground"}),e.jsx("span",{className:"text-sm",children:l[y]?"On":"Off"})]})]},y))]}),e.jsxs(k,{onClick:()=>g.mutate(),disabled:g.isPending,children:[e.jsx(Xt,{className:"w-4 h-4 mr-2"}),g.isPending?"Saving...":"Save AI Settings"]})]})}function gp(){const{showToast:s}=ut(),t=oe(),[a,r]=h.useState(null),[n,i]=h.useState(!1),[o,c]=h.useState(""),[d,l]=h.useState(""),{data:m,isLoading:g}=he({queryKey:["organizations"],queryFn:Ox}),y=Z({mutationFn:()=>Ix({name:o,slug:d}),onSuccess:f=>{s("success","Organization created",`${f.name} has been created`),i(!1),c(""),l(""),r(f.id),t.invalidateQueries({queryKey:["organizations"]})},onError:f=>s("error","Failed to create organization",f.message)}),u=f=>{c(f),l(f.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""))};if(g)return e.jsx("div",{className:"container mx-auto p-6",children:e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading organizations..."})});const p=m==null?void 0:m.find(f=>f.id===a);return e.jsxs("div",{className:"container mx-auto p-6 space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold",children:"Organizations"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:"Manage your organizations and team members"})]}),e.jsxs("div",{className:"grid gap-6 md:grid-cols-[1fr_2fr]",children:[e.jsxs(X,{children:[e.jsxs(Le,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(ze,{className:"flex items-center",children:[e.jsx(Vn,{className:"w-5 h-5 mr-2"}),"Your Organizations"]}),e.jsxs(k,{size:"sm",onClick:()=>i(!0),children:[e.jsx(kt,{className:"w-4 h-4 mr-1"}),"New"]})]}),e.jsx(We,{children:"Select an organization to manage"})]}),e.jsx(_e,{children:m&&m.length>0?e.jsx("div",{className:"space-y-2",children:m.map(f=>e.jsx("div",{className:`p-4 border rounded-lg cursor-pointer transition-colors ${a===f.id?"border-primary bg-primary/5":"hover:bg-accent"}`,onClick:()=>r(f.id),children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold",children:f.name}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:["@",f.slug]})]}),Qa(f.plan)]})},f.id))}):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No organizations found"})})]}),p?e.jsxs(X,{children:[e.jsxs(Le,{children:[e.jsxs(ze,{className:"flex items-center justify-between",children:[e.jsx("span",{children:p.name}),Qa(p.plan)]}),e.jsxs(We,{children:["@",p.slug]})]}),e.jsx(_e,{children:e.jsxs(ys,{defaultValue:"members",className:"w-full",children:[e.jsxs(bs,{className:"flex flex-wrap",children:[e.jsxs(Se,{value:"members",children:[e.jsx(Fr,{className:"w-4 h-4 mr-1"}),"Members"]}),e.jsxs(Se,{value:"settings",children:[e.jsx(Tt,{className:"w-4 h-4 mr-1"}),"Settings"]}),e.jsxs(Se,{value:"invitations",children:[e.jsx(za,{className:"w-4 h-4 mr-1"}),"Invitations"]}),e.jsxs(Se,{value:"audit",children:[e.jsx(tr,{className:"w-4 h-4 mr-1"}),"Audit Log"]}),e.jsxs(Se,{value:"templates",children:[e.jsx(Rs,{className:"w-4 h-4 mr-1"}),"Templates"]}),e.jsxs(Se,{value:"sso",children:[e.jsx(Ls,{className:"w-4 h-4 mr-1"}),"SSO"]}),e.jsxs(Se,{value:"usage",children:[e.jsx(As,{className:"w-4 h-4 mr-1"}),"Usage"]}),e.jsxs(Se,{value:"ai",children:[e.jsx(Or,{className:"w-4 h-4 mr-1"}),"AI"]}),e.jsxs(Se,{value:"security",children:[e.jsx(Dt,{className:"w-4 h-4 mr-1"}),"Security"]})]}),e.jsx(Ce,{value:"members",className:"mt-4",children:e.jsx(np,{org:p})}),e.jsx(Ce,{value:"settings",className:"mt-4",children:e.jsx(ip,{org:p})}),e.jsx(Ce,{value:"invitations",className:"mt-4",children:e.jsx(up,{org:p})}),e.jsx(Ce,{value:"audit",className:"mt-4",children:e.jsx(op,{org:p})}),e.jsx(Ce,{value:"templates",className:"mt-4",children:e.jsx(cp,{org:p})}),e.jsx(Ce,{value:"sso",className:"mt-4",children:e.jsx(dp,{org:p})}),e.jsx(Ce,{value:"usage",className:"mt-4",children:e.jsx(mp,{org:p})}),e.jsx(Ce,{value:"ai",className:"mt-4",children:e.jsx(hp,{org:p})}),e.jsx(Ce,{value:"security",className:"mt-4",children:e.jsx(lp,{org:p})})]})})]}):e.jsx(X,{children:e.jsxs(_e,{className:"p-12 text-center",children:[e.jsx(Vn,{className:"w-12 h-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Select an Organization"}),e.jsx("p",{className:"text-muted-foreground",children:"Choose an organization from the list to view details and manage members"})]})})]}),e.jsx(qe,{open:n,onOpenChange:i,children:e.jsxs(Ue,{className:"sm:max-w-md",children:[e.jsxs(Be,{children:[e.jsx(Ve,{children:"Create Organization"}),e.jsx(Ge,{children:"Create a new organization to collaborate with your team"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(pe,{children:"Organization Name"}),e.jsx(B,{value:o,onChange:f=>u(f.target.value),placeholder:"My Organization"})]}),e.jsxs("div",{children:[e.jsx(pe,{children:"Slug"}),e.jsx(B,{value:d,onChange:f=>l(f.target.value),placeholder:"my-organization"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"URL-friendly identifier. Auto-generated from name."})]})]}),e.jsxs(Ke,{children:[e.jsx(k,{variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(k,{onClick:()=>y.mutate(),disabled:!o.trim()||!d.trim()||y.isPending,children:y.isPending?"Creating...":"Create Organization"})]})]})})]})}const fn="/api/v1";async function xp(){const s=localStorage.getItem("auth_token"),t=await fetch(`${fn}/billing/subscription`,{headers:{Authorization:`Bearer ${s}`,"Content-Type":"application/json"}});if(!t.ok)throw new Error("Failed to fetch subscription");return t.json()}async function pp(s){const t=localStorage.getItem("auth_token"),a=await fetch(`${fn}/billing/checkout`,{method:"POST",headers:{Authorization:`Bearer ${t}`,"Content-Type":"application/json"},body:JSON.stringify(s)});if(!a.ok)throw new Error("Failed to create checkout session");return a.json()}async function fp(){const s=localStorage.getItem("auth_token"),t=await fetch(`${fn}/billing/portal`,{method:"POST",headers:{Authorization:`Bearer ${s}`,"Content-Type":"application/json"},body:JSON.stringify({return_url:window.location.href})});if(!t.ok)throw new Error("Failed to create portal session");return t.json()}function yp(){const{showToast:s}=ut(),t=oe(),[a,r]=h.useState(null),{data:n,isLoading:i}=he({queryKey:["subscription"],queryFn:xp}),o=Z({mutationFn:pp,onSuccess:p=>{window.location.href=p.checkout_url},onError:p=>{s("error","Error",p.message||"Failed to create checkout session")}}),c=Z({mutationFn:fp,onSuccess:p=>{window.location.href=p.portal_url},onError:p=>{s("error","Error",p.message||"Failed to open billing portal")}}),d=()=>{c.mutate()},l=p=>{r(p),o.mutate({plan:p,success_url:`${window.location.origin}/billing?success=true`,cancel_url:`${window.location.origin}/billing?canceled=true`})};h.useEffect(()=>{const p=new URLSearchParams(window.location.search);p.get("success")==="true"?(s("success","Subscription Updated","Your subscription has been updated successfully."),t.invalidateQueries({queryKey:["subscription"]}),window.history.replaceState({},"","/billing")):p.get("canceled")==="true"&&(s("info","Checkout Canceled","Your checkout session was canceled."),window.history.replaceState({},"","/billing"))},[]);const m=p=>{if(p===0)return"0 B";const f=1e3,j=["B","KB","MB","GB","TB"],C=Math.floor(Math.log(p)/Math.log(f));return`${parseFloat((p/Math.pow(f,C)).toFixed(2))} ${j[C]}`},g=p=>p>=1e6?`${(p/1e6).toFixed(1)}M`:p>=1e3?`${(p/1e3).toFixed(1)}K`:p.toString(),y=(p,f)=>f<=0?0:Math.min(p/f*100,100),u=p=>{switch(p){case"active":return e.jsxs(je,{className:"bg-green-500",children:[e.jsx(Me,{className:"w-3 h-3 mr-1"}),"Active"]});case"trialing":return e.jsxs(je,{className:"bg-blue-500",children:[e.jsx(na,{className:"w-3 h-3 mr-1"}),"Trialing"]});case"past_due":return e.jsxs(je,{className:"bg-yellow-500",children:[e.jsx(tt,{className:"w-3 h-3 mr-1"}),"Past Due"]});case"canceled":return e.jsxs(je,{className:"bg-gray-500",children:[e.jsx(xs,{className:"w-3 h-3 mr-1"}),"Canceled"]});default:return e.jsx(je,{children:p})}};return i?e.jsx("div",{className:"container mx-auto p-6",children:e.jsx("div",{className:"text-center py-12",children:"Loading subscription..."})}):n?e.jsxs("div",{className:"container mx-auto p-6 space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold",children:"Billing & Subscription"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:"Manage your subscription and view usage"})]}),n.cancel_at_period_end&&n.current_period_end&&e.jsx(X,{className:"border-yellow-500 bg-yellow-50 dark:bg-yellow-950/20",children:e.jsx(_e,{className:"p-4",children:e.jsxs("div",{className:"flex items-start space-x-3",children:[e.jsx(tt,{className:"w-5 h-5 text-yellow-600 mt-0.5"}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-yellow-800 dark:text-yellow-200",children:"Subscription Canceling"}),e.jsxs("p",{className:"text-sm text-yellow-700 dark:text-yellow-300",children:["Your subscription will be canceled at the end of the current billing period on"," ",new Date(n.current_period_end).toLocaleDateString(),". You will retain access to your current plan until then."]})]})]})})}),e.jsxs(ys,{defaultValue:"overview",className:"space-y-4",children:[e.jsxs(bs,{children:[e.jsx(Se,{value:"overview",children:"Overview"}),e.jsx(Se,{value:"usage",children:"Usage"}),e.jsx(Se,{value:"plans",children:"Plans"})]}),e.jsx(Ce,{value:"overview",className:"space-y-4",children:e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(X,{children:[e.jsxs(Le,{children:[e.jsxs(ze,{className:"flex items-center justify-between",children:[e.jsx("span",{children:"Current Plan"}),u(n.status)]}),e.jsx(We,{children:"Your active subscription details"})]}),e.jsxs(_e,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold capitalize",children:n.plan}),n.current_period_end&&e.jsxs("div",{className:"text-sm text-muted-foreground mt-1",children:["Renews on ",new Date(n.current_period_end).toLocaleDateString()]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:"Projects"}),e.jsx("span",{children:n.limits.max_projects===-1?"Unlimited":n.limits.max_projects})]}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:"Collaborators"}),e.jsx("span",{children:n.limits.max_collaborators})]}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:"Environments"}),e.jsx("span",{children:n.limits.max_environments})]}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:"Hosted Mocks"}),e.jsx("span",{children:n.limits.hosted_mocks?"Yes":"No"})]})]}),n.plan==="free"?e.jsxs(k,{onClick:()=>l("pro"),className:"w-full",disabled:o.isPending,children:[e.jsx(Uc,{className:"w-4 h-4 mr-2"}),"Upgrade to Pro"]}):e.jsxs(k,{variant:"outline",onClick:d,className:"w-full",disabled:c.isPending,children:[e.jsx(Os,{className:"w-4 h-4 mr-2"}),c.isPending?"Opening...":"Manage Subscription"]})]})]}),e.jsxs(X,{children:[e.jsxs(Le,{children:[e.jsx(ze,{children:"Usage This Month"}),e.jsx(We,{children:"Current usage against your plan limits"})]}),e.jsxs(_e,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[e.jsxs("span",{className:"flex items-center",children:[e.jsx(Lr,{className:"w-4 h-4 mr-1"}),"Requests"]}),e.jsxs("span",{children:[g(n.usage.requests)," /"," ",g(n.usage.requests_limit)]})]}),e.jsx("div",{className:"w-full bg-secondary rounded-full h-2",children:e.jsx("div",{className:"bg-primary h-2 rounded-full transition-all",style:{width:`${y(n.usage.requests,n.usage.requests_limit)}%`}})})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[e.jsxs("span",{className:"flex items-center",children:[e.jsx(an,{className:"w-4 h-4 mr-1"}),"Storage"]}),e.jsxs("span",{children:[m(n.usage.storage_bytes)," /"," ",m(n.usage.storage_limit_bytes)]})]}),e.jsx("div",{className:"w-full bg-secondary rounded-full h-2",children:e.jsx("div",{className:"bg-primary h-2 rounded-full transition-all",style:{width:`${y(n.usage.storage_bytes,n.usage.storage_limit_bytes)}%`}})})]}),n.usage.ai_tokens_limit>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[e.jsxs("span",{className:"flex items-center",children:[e.jsx(dt,{className:"w-4 h-4 mr-1"}),"AI Tokens"]}),e.jsxs("span",{children:[g(n.usage.ai_tokens_used)," /"," ",g(n.usage.ai_tokens_limit)]})]}),e.jsx("div",{className:"w-full bg-secondary rounded-full h-2",children:e.jsx("div",{className:"bg-primary h-2 rounded-full transition-all",style:{width:`${y(n.usage.ai_tokens_used,n.usage.ai_tokens_limit)}%`}})})]})]})]})]})}),e.jsx(Ce,{value:"usage",className:"space-y-4",children:e.jsxs(X,{children:[e.jsxs(Le,{children:[e.jsxs(ze,{className:"flex items-center",children:[e.jsx(Lr,{className:"w-5 h-5 mr-2"}),"Usage Dashboard"]}),e.jsx(We,{children:"View detailed usage statistics, history, and per-metric breakdowns"})]}),e.jsxs(_e,{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-3",children:[e.jsxs("div",{className:"rounded-lg border p-3",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"Requests"}),e.jsxs("div",{className:"text-lg font-semibold",children:[g(n.usage.requests)," / ",g(n.usage.requests_limit)]})]}),e.jsxs("div",{className:"rounded-lg border p-3",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"Storage"}),e.jsxs("div",{className:"text-lg font-semibold",children:[m(n.usage.storage_bytes)," / ",m(n.usage.storage_limit_bytes)]})]}),n.usage.ai_tokens_limit>0&&e.jsxs("div",{className:"rounded-lg border p-3",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"AI Tokens"}),e.jsxs("div",{className:"text-lg font-semibold",children:[g(n.usage.ai_tokens_used)," / ",g(n.usage.ai_tokens_limit)]})]})]}),e.jsxs("a",{href:"/usage",className:"inline-flex items-center text-sm font-medium text-blue-600 hover:text-blue-800 dark:text-blue-400 dark:hover:text-blue-300",children:["View full usage dashboard",e.jsx(Os,{className:"w-3 h-3 ml-1"})]})]})]})}),e.jsx(Ce,{value:"plans",className:"space-y-4",children:e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsxs(X,{className:n.plan==="free"?"border-primary":"",children:[e.jsxs(Le,{children:[e.jsx(ze,{children:"Free"}),e.jsx("div",{className:"text-3xl font-bold",children:"$0"}),e.jsx(We,{children:"per month"})]}),e.jsxs(_e,{className:"space-y-4",children:[e.jsxs("ul",{className:"space-y-2 text-sm",children:[e.jsxs("li",{className:"flex items-center",children:[e.jsx(Me,{className:"w-4 h-4 mr-2 text-green-500"}),"1 Project"]}),e.jsxs("li",{className:"flex items-center",children:[e.jsx(Me,{className:"w-4 h-4 mr-2 text-green-500"}),"1 Collaborator"]}),e.jsxs("li",{className:"flex items-center",children:[e.jsx(Me,{className:"w-4 h-4 mr-2 text-green-500"}),"10K requests/month"]}),e.jsxs("li",{className:"flex items-center",children:[e.jsx(Me,{className:"w-4 h-4 mr-2 text-green-500"}),"1GB storage"]}),e.jsxs("li",{className:"flex items-center",children:[e.jsx(xs,{className:"w-4 h-4 mr-2 text-gray-400"}),"BYOK only for AI"]})]}),n.plan==="free"?e.jsx(k,{disabled:!0,className:"w-full",children:"Current Plan"}):e.jsxs(k,{variant:"outline",className:"w-full",onClick:d,disabled:c.isPending,children:[e.jsx(Os,{className:"w-4 h-4 mr-2"}),c.isPending?"Opening...":"Manage via Stripe"]})]})]}),e.jsxs(X,{className:n.plan==="pro"?"border-primary":"",children:[e.jsxs(Le,{children:[e.jsx(ze,{children:"Pro"}),e.jsx("div",{className:"text-3xl font-bold",children:"$19"}),e.jsx(We,{children:"per month"})]}),e.jsxs(_e,{className:"space-y-4",children:[e.jsxs("ul",{className:"space-y-2 text-sm",children:[e.jsxs("li",{className:"flex items-center",children:[e.jsx(Me,{className:"w-4 h-4 mr-2 text-green-500"}),"10 Projects"]}),e.jsxs("li",{className:"flex items-center",children:[e.jsx(Me,{className:"w-4 h-4 mr-2 text-green-500"}),"5 Collaborators"]}),e.jsxs("li",{className:"flex items-center",children:[e.jsx(Me,{className:"w-4 h-4 mr-2 text-green-500"}),"250K requests/month"]}),e.jsxs("li",{className:"flex items-center",children:[e.jsx(Me,{className:"w-4 h-4 mr-2 text-green-500"}),"20GB storage"]}),e.jsxs("li",{className:"flex items-center",children:[e.jsx(Me,{className:"w-4 h-4 mr-2 text-green-500"}),"100K AI tokens/month"]}),e.jsxs("li",{className:"flex items-center",children:[e.jsx(Me,{className:"w-4 h-4 mr-2 text-green-500"}),"Hosted mocks"]})]}),n.plan==="pro"?e.jsx(k,{disabled:!0,className:"w-full",children:"Current Plan"}):e.jsx(k,{onClick:()=>l("pro"),className:"w-full",disabled:o.isPending,children:o.isPending&&a==="pro"?"Processing...":"Upgrade to Pro"})]})]}),e.jsxs(X,{className:n.plan==="team"?"border-primary":"",children:[e.jsxs(Le,{children:[e.jsx(ze,{children:"Team"}),e.jsx("div",{className:"text-3xl font-bold",children:"$79"}),e.jsx(We,{children:"per month"})]}),e.jsxs(_e,{className:"space-y-4",children:[e.jsxs("ul",{className:"space-y-2 text-sm",children:[e.jsxs("li",{className:"flex items-center",children:[e.jsx(Me,{className:"w-4 h-4 mr-2 text-green-500"}),"Unlimited Projects"]}),e.jsxs("li",{className:"flex items-center",children:[e.jsx(Me,{className:"w-4 h-4 mr-2 text-green-500"}),"20 Collaborators"]}),e.jsxs("li",{className:"flex items-center",children:[e.jsx(Me,{className:"w-4 h-4 mr-2 text-green-500"}),"1M requests/month"]}),e.jsxs("li",{className:"flex items-center",children:[e.jsx(Me,{className:"w-4 h-4 mr-2 text-green-500"}),"100GB storage"]}),e.jsxs("li",{className:"flex items-center",children:[e.jsx(Me,{className:"w-4 h-4 mr-2 text-green-500"}),"1M AI tokens/month"]}),e.jsxs("li",{className:"flex items-center",children:[e.jsx(Me,{className:"w-4 h-4 mr-2 text-green-500"}),"Hosted mocks"]})]}),n.plan==="team"?e.jsx(k,{disabled:!0,className:"w-full",children:"Current Plan"}):e.jsx(k,{onClick:()=>l("team"),className:"w-full",disabled:o.isPending,children:o.isPending&&a==="team"?"Processing...":"Upgrade to Team"})]})]})]})})]})]}):e.jsx("div",{className:"container mx-auto p-6",children:e.jsx("div",{className:"text-center py-12",children:"Failed to load subscription"})})}const lr="/api/v1";async function bp(){const s=localStorage.getItem("auth_token"),t=await fetch(`${lr}/tokens`,{headers:{Authorization:`Bearer ${s}`,"Content-Type":"application/json"}});if(!t.ok)throw new Error("Failed to fetch tokens");return t.json()}async function vp(s){const t=localStorage.getItem("auth_token"),a=await fetch(`${lr}/tokens`,{method:"POST",headers:{Authorization:`Bearer ${t}`,"Content-Type":"application/json"},body:JSON.stringify(s)});if(!a.ok){const r=await a.json();throw new Error(r.message||"Failed to create token")}return a.json()}async function jp(s){const t=localStorage.getItem("auth_token");if(!(await fetch(`${lr}/tokens/${s}`,{method:"DELETE",headers:{Authorization:`Bearer ${t}`,"Content-Type":"application/json"}})).ok)throw new Error("Failed to delete token")}async function kp(s,t,a){const r=localStorage.getItem("auth_token"),n=await fetch(`${lr}/tokens/${s}/rotate`,{method:"POST",headers:{Authorization:`Bearer ${r}`,"Content-Type":"application/json"},body:JSON.stringify({new_name:t||void 0,delete_old:a})});if(!n.ok){const i=await n.json();throw new Error(i.message||"Failed to rotate token")}return n.json()}const Ii=[{value:"read:packages",label:"Read Packages",description:"Read and search packages"},{value:"publish:packages",label:"Publish Packages",description:"Publish new package versions"},{value:"deploy:mocks",label:"Deploy Mocks",description:"Deploy hosted mock services"},{value:"admin:org",label:"Admin Organization",description:"Full organization administration"},{value:"read:usage",label:"Read Usage",description:"Read usage analytics and metrics"},{value:"manage:billing",label:"Manage Billing",description:"Manage billing and subscription"}];function wp(){const{showToast:s}=ut(),t=oe(),[a,r]=h.useState(!1),[n,i]=h.useState(""),[o,c]=h.useState([]),[d,l]=h.useState(void 0),[m,g]=h.useState(null),[y,u]=h.useState(!1),[p,f]=h.useState(null),[j,C]=h.useState(""),[T,N]=h.useState(!1),{data:w,isLoading:O}=he({queryKey:["api-tokens"],queryFn:bp}),L=Z({mutationFn:vp,onSuccess:R=>{g(R.token),t.invalidateQueries({queryKey:["api-tokens"]}),r(!1),i(""),c([]),l(void 0)},onError:R=>{s("error","Error",R.message||"Failed to create token")}}),I=Z({mutationFn:jp,onSuccess:()=>{t.invalidateQueries({queryKey:["api-tokens"]}),s("success","Success","Token deleted successfully")},onError:R=>{s("error","Error",R.message||"Failed to delete token")}}),b=Z({mutationFn:({tokenId:R,newName:P,deleteOld:V})=>kp(R,P,V),onSuccess:R=>{g(R.new_token),f(null),C(""),N(!1),t.invalidateQueries({queryKey:["api-tokens"]}),s("success","Success",R.message)},onError:R=>{s("error","Error",R.message||"Failed to rotate token")}}),A=()=>{p&&b.mutate({tokenId:p,newName:j.trim()||void 0,deleteOld:T})},_=()=>{if(!n.trim()){s("error","Error","Token name is required");return}if(o.length===0){s("error","Error","At least one scope is required");return}L.mutate({name:n,scopes:o,expires_days:d})},$=R=>{navigator.clipboard.writeText(R),s("success","Copied","Token copied to clipboard")},ae=R=>{c(P=>P.includes(R)?P.filter(V=>V!==R):[...P,R])},U=R=>R?new Date(R).toLocaleDateString():"Never",z=R=>R?new Date(R)r(!0),children:[e.jsx(kt,{className:"w-4 h-4 mr-2"}),"Create Token"]})]}),m&&e.jsx(qe,{open:!!m,onOpenChange:()=>g(null),children:e.jsxs(Ue,{className:"sm:max-w-md",children:[e.jsxs(Be,{children:[e.jsx(Ve,{children:"Token Created"}),e.jsx(Ge,{children:"Copy this token now. You won't be able to see it again!"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx(B,{type:y?"text":"password",value:m,readOnly:!0,className:"font-mono text-sm"}),e.jsx(k,{variant:"ghost",size:"sm",className:"absolute right-2 top-1/2 -translate-y-1/2",onClick:()=>u(!y),children:y?e.jsx(sn,{className:"w-4 h-4"}):e.jsx(ma,{className:"w-4 h-4"})})]}),e.jsx("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg p-3",children:e.jsxs("div",{className:"flex items-start",children:[e.jsx(Dt,{className:"w-4 h-4 mr-2 text-yellow-600 dark:text-yellow-400 mt-0.5"}),e.jsx("p",{className:"text-sm text-yellow-800 dark:text-yellow-200",children:"Make sure to copy this token. It will not be shown again."})]})})]}),e.jsxs(Ke,{children:[e.jsx(k,{variant:"outline",onClick:()=>{g(null),u(!1)},children:"Close"}),e.jsxs(k,{onClick:()=>$(m),children:[e.jsx(fs,{className:"w-4 h-4 mr-2"}),"Copy Token"]})]})]})}),e.jsx(qe,{open:a,onOpenChange:r,children:e.jsxs(Ue,{className:"sm:max-w-lg",children:[e.jsxs(Be,{children:[e.jsx(Ve,{children:"Create API Token"}),e.jsx(Ge,{children:"Create a personal access token for CLI and API access"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(pe,{htmlFor:"token-name",children:"Token Name"}),e.jsx(B,{id:"token-name",placeholder:"e.g., CLI Development",value:n,onChange:R=>i(R.target.value)})]}),e.jsxs("div",{children:[e.jsx(pe,{children:"Scopes"}),e.jsx("div",{className:"mt-2 space-y-2 max-h-64 overflow-y-auto",children:Ii.map(R=>e.jsxs("div",{className:"flex items-start space-x-3 p-3 border rounded-lg hover:bg-accent cursor-pointer",onClick:()=>ae(R.value),children:[e.jsx("input",{type:"checkbox",checked:o.includes(R.value),onChange:()=>ae(R.value),className:"mt-1"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium",children:R.label}),e.jsx("div",{className:"text-sm text-muted-foreground",children:R.description})]})]},R.value))})]}),e.jsxs("div",{children:[e.jsx(pe,{htmlFor:"expires-days",children:"Expires In (Days)"}),e.jsx(B,{id:"expires-days",type:"number",placeholder:"Leave empty for no expiration",value:d||"",onChange:R=>l(R.target.value?parseInt(R.target.value):void 0),min:"1"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Optional: Set expiration in days. Leave empty for no expiration."})]})]}),e.jsxs(Ke,{children:[e.jsx(k,{variant:"outline",onClick:()=>r(!1),children:"Cancel"}),e.jsx(k,{onClick:_,disabled:L.isPending||!n.trim()||o.length===0,children:L.isPending?"Creating...":"Create Token"})]})]})}),e.jsx(qe,{open:!!p,onOpenChange:()=>f(null),children:e.jsxs(Ue,{className:"sm:max-w-md",children:[e.jsxs(Be,{children:[e.jsx(Ve,{children:"Rotate Token"}),e.jsx(Ge,{children:"Create a new token with the same scopes. The old token remains active unless you choose to delete it."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(pe,{htmlFor:"rotate-new-name",children:"New Token Name (optional)"}),e.jsx(B,{id:"rotate-new-name",placeholder:"Leave empty to keep current name",value:j,onChange:R=>C(R.target.value)})]}),e.jsxs("div",{className:"flex items-start space-x-3 p-3 border rounded-lg hover:bg-accent cursor-pointer",onClick:()=>N(!T),children:[e.jsx("input",{type:"checkbox",checked:T,onChange:()=>N(!T),className:"mt-1"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium",children:"Delete old token"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Immediately revoke the old token after rotation"})]})]})]}),e.jsxs(Ke,{children:[e.jsx(k,{variant:"outline",onClick:()=>f(null),children:"Cancel"}),e.jsx(k,{onClick:A,disabled:b.isPending,children:b.isPending?"Rotating...":"Rotate Token"})]})]})}),O?e.jsx("div",{className:"text-center py-12",children:"Loading tokens..."}):w&&w.length>0?e.jsx("div",{className:"space-y-4",children:w.map(R=>e.jsx(X,{children:e.jsx(_e,{className:"p-6",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center space-x-2 mb-2",children:[e.jsx("h3",{className:"font-semibold",children:R.name}),z(R.expires_at)&&e.jsx(je,{variant:"destructive",children:"Expired"}),R.expires_at&&!z(R.expires_at)&&e.jsxs(je,{variant:"secondary",children:["Expires ",U(R.expires_at)]}),R.needs_rotation&&e.jsxs(je,{variant:"destructive",children:["Needs Rotation — ",R.age_days," days old"]})]}),e.jsxs("div",{className:"flex items-center space-x-4 text-sm text-muted-foreground mb-3",children:[e.jsxs("div",{className:"flex items-center",children:[e.jsx(Gt,{className:"w-4 h-4 mr-1"}),e.jsxs("span",{className:"font-mono",children:[R.token_prefix,"..."]})]}),e.jsxs("div",{className:"flex items-center",children:[e.jsx(na,{className:"w-4 h-4 mr-1"}),"Created: ",U(R.created_at)]}),R.last_used_at&&e.jsxs("div",{className:"flex items-center",children:["Last used: ",U(R.last_used_at)]})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:R.scopes.map(P=>{const V=Ii.find(v=>v.value===P);return e.jsx(je,{variant:"outline",children:(V==null?void 0:V.label)||P},P)})})]}),e.jsxs("div",{className:"flex items-center space-x-1",children:[e.jsx(k,{variant:"ghost",size:"sm",onClick:()=>f(R.id),title:"Rotate token",children:e.jsx(st,{className:"w-4 h-4"})}),e.jsx(k,{variant:"ghost",size:"sm",onClick:()=>{confirm("Are you sure you want to delete this token?")&&I.mutate(R.id)},disabled:I.isPending,children:e.jsx(Qe,{className:"w-4 h-4 text-destructive"})})]})]})})},R.id))}):e.jsx(X,{children:e.jsxs(_e,{className:"p-12 text-center",children:[e.jsx(Gt,{className:"w-12 h-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No API Tokens"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Create your first API token to get started with CLI and API access"}),e.jsxs(k,{onClick:()=>r(!0),children:[e.jsx(kt,{className:"w-4 h-4 mr-2"}),"Create Token"]})]})})]})}async function Np(){const s=await rt("/api/v1/users/me/public-keys");if(!s.ok){const a=await s.text().catch(()=>"");throw new Error(`Failed to load keys (${s.status}): ${a}`)}return(await s.json()).keys}async function _p(s){const t=await rt("/api/v1/users/me/public-keys",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!t.ok){const a=await t.text().catch(()=>"");throw new Error(`Failed to register key (${t.status}): ${a}`)}return t.json()}async function Sp(s){const t=await rt(`/api/v1/users/me/public-keys/${s}`,{method:"DELETE"});if(!t.ok){const a=await t.text().catch(()=>"");throw new Error(`Failed to revoke key (${t.status}): ${a}`)}}async function Cp(s){try{const t=Uint8Array.from(atob(Uo(s)),n=>n.charCodeAt(0)),a=await Tp(t);return Array.from(a.slice(0,8)).map(n=>n.toString(16).padStart(2,"0")).join("")}catch{return"—"}}function Uo(s){const t=s.replace(/-/g,"+").replace(/_/g,"/"),a=t.length%4;return a?t+"=".repeat(4-a):t}async function Tp(s){if(typeof crypto<"u"&&crypto.subtle&&crypto.subtle.digest)try{const t=await crypto.subtle.digest("SHA-256",s);return new Uint8Array(t)}catch{}return Pp(s)}function Pp(s){const t=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),a=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),r=s.length,n=r*8,i=r+9+63&-64,o=new Uint8Array(i);o.set(s),o[r]=128;const c=Math.floor(n/4294967296),d=n>>>0,l=new DataView(o.buffer);l.setUint32(i-8,c),l.setUint32(i-4,d);const m=new Uint32Array(64);for(let u=0;u>>7|m[L-15]<<25)^(m[L-15]>>>18|m[L-15]<<14)^m[L-15]>>>3,b=(m[L-2]>>>17|m[L-2]<<15)^(m[L-2]>>>19|m[L-2]<<13)^m[L-2]>>>10;m[L]=m[L-16]+I+m[L-7]+b>>>0}let[p,f,j,C,T,N,w,O]=[a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7]];for(let L=0;L<64;L++){const I=(T>>>6|T<<26)^(T>>>11|T<<21)^(T>>>25|T<<7),b=T&N^~T&w,A=O+I+b+t[L]+m[L]>>>0,_=(p>>>2|p<<30)^(p>>>13|p<<19)^(p>>>22|p<<10),$=p&f^p&j^f&j,ae=_+$>>>0;O=w,w=N,N=T,T=C+A>>>0,C=j,j=f,f=p,p=A+ae>>>0}a[0]=a[0]+p>>>0,a[1]=a[1]+f>>>0,a[2]=a[2]+j>>>0,a[3]=a[3]+C>>>0,a[4]=a[4]+T>>>0,a[5]=a[5]+N>>>0,a[6]=a[6]+w>>>0,a[7]=a[7]+O>>>0}const g=new Uint8Array(32),y=new DataView(g.buffer);for(let u=0;u<8;u++)y.setUint32(u*4,a[u]);return g}const Ep=()=>{const s=oe(),[t,a]=h.useState(!1),[r,n]=h.useState(""),[i,o]=h.useState(""),[c,d]=h.useState(null),[l,m]=h.useState(null),[g,y]=h.useState({}),{data:u,isLoading:p,isError:f,error:j}=he({queryKey:["publisher-public-keys"],queryFn:Np});M.useEffect(()=>{if(!u)return;let w=!1;return Promise.all(u.map(O=>Cp(O.publicKeyB64))).then(O=>{if(w)return;const L={};u.forEach((I,b)=>{L[I.id]=O[b]}),y(L)}),()=>{w=!0}},[u]);const C=Z({mutationFn:_p,onSuccess:()=>{s.invalidateQueries({queryKey:["publisher-public-keys"]}),a(!1),n(""),o(""),d(null)},onError:w=>d(w.message)}),T=Z({mutationFn:Sp,onSuccess:()=>{s.invalidateQueries({queryKey:["publisher-public-keys"]}),m(null)},onError:w=>d(w.message)}),N=()=>{d(null);const w=r.trim();if(!w){d("Label is required.");return}const O=i.trim();if(!O){d("Public key is required.");return}const L=Uo(O);if(L.length!==44){d(`Expected 44 base64 characters for an Ed25519 public key; got ${L.length}.`);return}C.mutate({algorithm:"ed25519",publicKeyB64:O,label:w})};return e.jsxs(tl,{sx:{p:3,m:2},children:[e.jsxs(ws,{direction:"row",alignItems:"center",justifyContent:"space-between",mb:2,children:[e.jsxs(ws,{direction:"row",alignItems:"center",spacing:1,children:[e.jsx(sl,{color:"primary"}),e.jsx(Mt,{variant:"h5",children:"Publisher Attestation Keys"})]}),e.jsx(Gs,{variant:"contained",startIcon:e.jsx(al,{}),onClick:()=>a(!0),disabled:C.isPending,children:"Add key"})]}),e.jsxs(Mt,{variant:"body2",color:"text.secondary",mb:3,children:["Register an Ed25519 public key to sign SBOMs at publish time. The registry verifies signatures against any of your active keys and surfaces a ",e.jsx("b",{children:"verified publisher attestation"})," finding on each accepted version. Generate a keypair locally with"," ",e.jsx("code",{children:"mockforge-plugin key gen"})," — the private half never leaves your machine."]}),p&&e.jsx(rl,{}),f&&e.jsx(Mt,{color:"error",variant:"body2",mb:2,children:(j==null?void 0:j.message)??"Failed to load keys."}),u&&u.length===0&&!p&&e.jsx(kn,{variant:"outlined",children:e.jsx(wn,{children:e.jsxs(Mt,{variant:"body2",color:"text.secondary",children:["No public keys registered yet. Click ",e.jsx("b",{children:"Add key"})," above to register one."]})})}),e.jsx(ws,{spacing:2,children:u==null?void 0:u.map(w=>e.jsx(kn,{variant:"outlined",children:e.jsx(wn,{children:e.jsxs(ws,{direction:"row",alignItems:"center",spacing:2,children:[e.jsx(nl,{color:w.revokedAt?"disabled":"success",fontSize:"large"}),e.jsxs("div",{style:{flexGrow:1},children:[e.jsxs(ws,{direction:"row",alignItems:"center",spacing:1,mb:.5,children:[e.jsx(Mt,{variant:"subtitle1",sx:{fontWeight:600},children:w.label}),e.jsx(Nn,{label:w.algorithm,size:"small",color:"primary",variant:"outlined"}),w.revokedAt&&e.jsx(Nn,{label:"Revoked",color:"default",size:"small"})]}),e.jsxs(Mt,{variant:"caption",color:"text.secondary",sx:{display:"block"},children:["id: ",e.jsx("code",{children:w.id})]}),e.jsxs(Mt,{variant:"caption",color:"text.secondary",sx:{display:"block"},children:["fingerprint:"," ",e.jsx("code",{children:g[w.id]??"computing…"})]}),e.jsxs(Mt,{variant:"caption",color:"text.secondary",sx:{display:"block"},children:["created: ",new Date(w.createdAt).toLocaleString(),w.revokedAt&&` • revoked ${new Date(w.revokedAt).toLocaleString()}`]})]}),e.jsx(_n,{title:"Copy public key",children:e.jsx(Sn,{onClick:()=>navigator.clipboard.writeText(w.publicKeyB64),children:e.jsx(il,{})})}),!w.revokedAt&&e.jsx(_n,{title:"Revoke key",children:e.jsx(Sn,{onClick:()=>m(w),disabled:T.isPending,children:e.jsx(ol,{})})})]})})},w.id))}),e.jsxs(Cn,{open:t,onClose:()=>a(!1),maxWidth:"sm",fullWidth:!0,children:[e.jsx(Tn,{children:"Register a public key"}),e.jsxs(Pn,{children:[e.jsxs(En,{sx:{mb:2},children:["Paste the base64-encoded Ed25519 public key produced by"," ",e.jsx("code",{children:"mockforge-plugin key gen"})," or"," ",e.jsx("code",{children:"openssl pkey -in key.pem -pubout"}),"."]}),e.jsxs(ws,{spacing:2,children:[e.jsx(An,{label:"Label",placeholder:"e.g. laptop, ci-2026",value:r,onChange:w=>n(w.target.value),inputProps:{maxLength:128},fullWidth:!0,autoFocus:!0}),e.jsx(An,{label:"Public key (base64)",value:i,onChange:w=>o(w.target.value),multiline:!0,minRows:2,fullWidth:!0,placeholder:"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="}),c&&e.jsx(Mt,{color:"error",variant:"body2",children:c})]})]}),e.jsxs(On,{children:[e.jsx(Gs,{onClick:()=>a(!1),disabled:C.isPending,children:"Cancel"}),e.jsx(Gs,{variant:"contained",onClick:N,disabled:C.isPending,children:C.isPending?"Registering…":"Register"})]})]}),e.jsxs(Cn,{open:!!l,onClose:()=>m(null),children:[e.jsx(Tn,{children:"Revoke key?"}),e.jsx(Pn,{children:e.jsxs(En,{children:["Revoking ",e.jsx("b",{children:l==null?void 0:l.label})," marks the key inactive immediately. New publish signatures made with this key will fail verification. Historical attestations remain intact."]})}),e.jsxs(On,{children:[e.jsx(Gs,{onClick:()=>m(null),disabled:T.isPending,children:"Cancel"}),e.jsx(Gs,{color:"error",variant:"contained",onClick:()=>l&&T.mutate(l.id),disabled:T.isPending,children:T.isPending?"Revoking…":"Revoke"})]})]})]})};function Ne({className:s,width:t,height:a,circle:r=!1,animation:n="shimmer",...i}){const o={pulse:"animate-pulse",shimmer:"loading-shimmer",none:""};return e.jsx("div",{className:D("bg-gray-200 dark:bg-gray-700",r?"rounded-full":"rounded-md",o[n],s),style:{width:typeof t=="number"?`${t}px`:t,height:typeof a=="number"?`${a}px`:a},...i})}function Iy({className:s,...t}){return e.jsxs("div",{className:D("p-6 border border-gray-200 dark:border-gray-800 rounded-xl space-y-4",s),...t,children:[e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(Ne,{circle:!0,width:48,height:48}),e.jsxs("div",{className:"space-y-2 flex-1",children:[e.jsx(Ne,{height:16,width:"60%"}),e.jsx(Ne,{height:12,width:"40%"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ne,{height:12,width:"100%"}),e.jsx(Ne,{height:12,width:"80%"}),e.jsx(Ne,{height:12,width:"90%"})]})]})}function Ap({rows:s=5,cols:t=4,className:a,...r}){return e.jsxs("div",{className:D("space-y-4",a),...r,children:[e.jsx("div",{className:"flex space-x-4",children:Array.from({length:t}).map((n,i)=>e.jsx(Ne,{height:16,className:"flex-1"},`header-${i}`))}),Array.from({length:s}).map((n,i)=>e.jsx("div",{className:"flex space-x-4",children:Array.from({length:t}).map((o,c)=>e.jsx(Ne,{height:12,className:"flex-1"},`cell-${i}-${c}`))},`row-${i}`))]})}function My({className:s,...t}){return e.jsx("div",{className:D("p-6 border border-gray-200 dark:border-gray-800 rounded-xl",s),...t,children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-2 flex-1",children:[e.jsx(Ne,{height:12,width:"60%"}),e.jsx(Ne,{height:20,width:"40%"}),e.jsx(Ne,{height:10,width:"50%"})]}),e.jsx(Ne,{circle:!0,width:40,height:40})]})})}function Ry({className:s,...t}){return e.jsxs("div",{className:D("p-6 border border-gray-200 dark:border-gray-800 rounded-xl space-y-4",s),...t,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Ne,{height:16,width:"30%"}),e.jsx(Ne,{height:12,width:"20%"})]}),e.jsx("div",{className:"h-64 flex items-end space-x-2",children:Array.from({length:12}).map((a,r)=>e.jsx(Ne,{className:"flex-1",height:Math.random()*200+40},`bar-${r}`))})]})}const Bo="/api/v1",ta=6;async function Op(){const s=await rt(`${Bo}/usage`);if(!s.ok)throw new Error("Failed to fetch usage");return s.json()}async function Ip(){const s=await rt(`${Bo}/usage/history`);if(!s.ok)throw new Error("Failed to fetch usage history");return s.json()}const Ia=s=>{if(s===0)return"0 B";const t=1e3,a=["B","KB","MB","GB","TB"],r=Math.floor(Math.log(s)/Math.log(t));return`${parseFloat((s/Math.pow(t,r)).toFixed(2))} ${a[r]}`},Ma=s=>s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toString(),Vo=(s,t)=>t<=0?0:Math.min(s/t*100,100),Mp=s=>s>90?"bg-red-500":s>75?"bg-yellow-500":"bg-green-500",Rp={requests:"API Requests",storage:"Storage",egress:"Data Egress",ai_tokens:"AI Tokens"};function Lp(s){return Object.entries(s).filter(([,t])=>t.limit>0&&Vo(t.used,t.limit)>75).map(([t])=>Rp[t]||t)}function _r(){return e.jsxs(X,{children:[e.jsxs(Le,{children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ne,{width:20,height:20}),e.jsx(Ne,{width:"40%",height:20})]}),e.jsx(Ne,{width:"60%",height:14,className:"mt-1"})]}),e.jsx(_e,{className:"space-y-4",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between mb-2",children:[e.jsx(Ne,{width:40,height:14}),e.jsx(Ne,{width:80,height:14})]}),e.jsx(Ne,{width:"100%",height:12,className:"rounded-full"}),e.jsx(Ne,{width:"50%",height:10,className:"mt-1"})]})})]})}function $p(){const[s,t]=h.useState(0),{data:a,isLoading:r,isError:n,error:i,refetch:o}=he({queryKey:["usage"],queryFn:Op,staleTime:6e4,refetchInterval:6e4}),{data:c,isLoading:d,isError:l,refetch:m}=he({queryKey:["usage-history"],queryFn:Ip,staleTime:6e4,refetchInterval:6e4});if(r)return e.jsxs("div",{className:"container mx-auto p-6 space-y-6",children:[e.jsxs("div",{children:[e.jsx(Ne,{width:"50%",height:32}),e.jsx(Ne,{width:"70%",height:16,className:"mt-2"})]}),e.jsx(X,{children:e.jsx(_e,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Ne,{width:"40%",height:16}),e.jsx(Ne,{width:80,height:24})]})})}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(_r,{}),e.jsx(_r,{}),e.jsx(_r,{})]})]});if(n||!a)return e.jsx("div",{className:"container mx-auto p-6",children:e.jsxs("div",{className:"text-center py-12 space-y-4",children:[e.jsx(tt,{className:"w-12 h-12 mx-auto text-red-500"}),e.jsx("h2",{className:"text-lg font-semibold",children:"Failed to load usage data"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:i instanceof Error?i.message:"An unexpected error occurred"}),e.jsxs(k,{variant:"outline",onClick:()=>o(),children:[e.jsx(st,{className:"w-4 h-4 mr-2"}),"Retry"]})]})});const g=Lp(a.usage),y=(c==null?void 0:c.history.length)??0,u=Math.max(1,Math.ceil(y/ta)),p=(c==null?void 0:c.history.slice(s*ta,(s+1)*ta))??[];return e.jsxs("div",{className:"container mx-auto p-6 space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold",children:"Usage Dashboard"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:"Monitor your organization's usage and limits"})]}),e.jsx(X,{children:e.jsx(_e,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(na,{className:"w-4 h-4 text-muted-foreground"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["Current Period: ",new Date(a.period_start).toLocaleDateString()," -"," ",new Date(a.period_end).toLocaleDateString()]})]}),e.jsxs(je,{className:"capitalize",children:[a.plan," Plan"]})]})})}),e.jsxs(ys,{defaultValue:"current",className:"space-y-4",children:[e.jsxs(bs,{children:[e.jsx(Se,{value:"current",children:"Current Usage"}),e.jsx(Se,{value:"history",children:"History"})]}),e.jsxs(Ce,{value:"current",className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(Ra,{icon:e.jsx(Lr,{className:"w-5 h-5 mr-2"}),title:"API Requests",description:"Monthly request usage",metric:a.usage.requests,formatValue:Ma,remainingLabel:"requests"}),e.jsx(Ra,{icon:e.jsx(an,{className:"w-5 h-5 mr-2"}),title:"Storage",description:"Storage usage",metric:a.usage.storage,formatValue:Ia}),e.jsx(Ra,{icon:e.jsx(gs,{className:"w-5 h-5 mr-2"}),title:"Data Egress",description:"Data transfer usage",metric:a.usage.egress,formatValue:Ia}),(a.usage.ai_tokens.limit>0||a.usage.ai_tokens.used>0)&&e.jsx(Ra,{icon:e.jsx(dt,{className:"w-5 h-5 mr-2"}),title:"AI Tokens",description:"AI token usage",metric:a.usage.ai_tokens,formatValue:Ma,remainingLabel:"tokens"})]}),g.length>0&&e.jsx(X,{className:"border-yellow-500",children:e.jsx(_e,{className:"p-4",children:e.jsxs("div",{className:"flex items-start space-x-3",children:[e.jsx(tt,{className:"w-5 h-5 text-yellow-500 mt-0.5"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"font-semibold mb-1",children:"Usage Warning"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[g.join(", ")," ",g.length===1?"is":"are"," approaching"," ",g.length===1?"its":"their"," plan limit."]}),e.jsxs("a",{href:"/billing",className:"inline-flex items-center mt-2 text-sm font-medium text-blue-600 hover:text-blue-800 dark:text-blue-400 dark:hover:text-blue-300",children:["Upgrade plan",e.jsx(jc,{className:"w-3 h-3 ml-1"})]})]})]})})})]}),e.jsx(Ce,{value:"history",className:"space-y-4",children:d?e.jsx("div",{className:"space-y-4",children:[0,1,2].map(f=>e.jsxs(X,{children:[e.jsxs(Le,{children:[e.jsx(Ne,{width:"30%",height:20}),e.jsx(Ne,{width:"50%",height:14,className:"mt-1"})]}),e.jsx(_e,{children:e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[0,1,2,3].map(j=>e.jsxs("div",{children:[e.jsx(Ne,{width:"60%",height:12}),e.jsx(Ne,{width:"40%",height:20,className:"mt-1"})]},j))})})]},f))}):l?e.jsxs("div",{className:"text-center py-12 space-y-4",children:[e.jsx(tt,{className:"w-12 h-12 mx-auto text-red-500"}),e.jsx("h2",{className:"text-lg font-semibold",children:"Failed to load usage history"}),e.jsxs(k,{variant:"outline",onClick:()=>m(),children:[e.jsx(st,{className:"w-4 h-4 mr-2"}),"Retry"]})]}):y>0?e.jsxs("div",{className:"space-y-4",children:[p.map((f,j)=>e.jsxs(X,{children:[e.jsxs(Le,{children:[e.jsx(ze,{className:"text-lg",children:new Date(f.period_start).toLocaleDateString("en-US",{month:"long",year:"numeric"})}),e.jsxs(We,{children:[new Date(f.period_start).toLocaleDateString()," -"," ",new Date(f.period_end).toLocaleDateString()]})]}),e.jsx(_e,{children:e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"Requests"}),e.jsx("div",{className:"text-lg font-semibold",children:Ma(f.requests)})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"Storage"}),e.jsx("div",{className:"text-lg font-semibold",children:Ia(f.storage_bytes)})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"Egress"}),e.jsx("div",{className:"text-lg font-semibold",children:Ia(f.egress_bytes)})]}),(f.ai_tokens_used>0||a.usage.ai_tokens.limit>0)&&e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"AI Tokens"}),e.jsx("div",{className:"text-lg font-semibold",children:Ma(f.ai_tokens_used)})]})]})})]},j)),u>1&&e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Showing ",s*ta+1,"–",Math.min((s+1)*ta,y)," of"," ",y," periods"]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(k,{variant:"outline",size:"sm",disabled:s===0,onClick:()=>t(f=>f-1),children:e.jsx(Ya,{className:"w-4 h-4"})}),e.jsxs("span",{className:"text-sm",children:[s+1," / ",u]}),e.jsx(k,{variant:"outline",size:"sm",disabled:s>=u-1,onClick:()=>t(f=>f+1),children:e.jsx(Xa,{className:"w-4 h-4"})})]})]})]}):e.jsx(X,{children:e.jsxs(_e,{className:"p-12 text-center",children:[e.jsx(na,{className:"w-12 h-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No History Available"}),e.jsx("p",{className:"text-muted-foreground",children:"Usage history will appear here as you use the service"})]})})})]})]})}function Ra({icon:s,title:t,description:a,metric:r,formatValue:n,remainingLabel:i}){const o=r.limit===-1,c=Vo(r.used,r.limit);return e.jsxs(X,{children:[e.jsxs(Le,{children:[e.jsxs(ze,{className:"flex items-center",children:[s,t]}),e.jsx(We,{children:a})]}),e.jsx(_e,{className:"space-y-4",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between text-sm mb-2",children:[e.jsx("span",{children:"Used"}),e.jsxs("span",{className:"font-semibold",children:[n(r.used),!o&&r.limit>0&&` / ${n(r.limit)}`]})]}),!o&&r.limit>0&&e.jsx("div",{className:"w-full bg-secondary rounded-full h-3",children:e.jsx("div",{className:`h-3 rounded-full transition-all ${Mp(c)}`,style:{width:`${c}%`}})}),e.jsx("div",{className:"text-xs text-muted-foreground mt-1",children:o?"Unlimited":r.limit>0?`${n(r.limit-r.used)} ${i??""} remaining`.trim():null})]})})]})}function Fp(){const{data:s,isLoading:t}=Oo(),{data:a,isLoading:r}=Q0(),{data:n,isLoading:i}=Y0(),o=J0(),c=H0(),d=W0(),l=G0(),m=Z0(),[g,y]=h.useState("1h"),[u,p]=h.useState("1.0"),[f,j]=h.useState(""),[C,T]=h.useState(null),N=_=>{if(!_)return"Real Time";try{return new Date(_).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{return _}},w=()=>{if(f){const _=new Date(f);if(isNaN(_.getTime())){T("Invalid ISO-8601 date (e.g., 2025-01-01T00:00:00Z)");return}}T(null),o.mutate({time:f||void 0,scale:u?parseFloat(u):void 0})},O=()=>{g&&d.mutate(g)},L=()=>{const _=parseFloat(u);!isNaN(_)&&_>0&&l.mutate(_)};if(t)return e.jsxs("div",{className:"content-width space-y-8",children:[e.jsx(Ga,{title:"Time Travel",subtitle:"Temporal simulation controls"}),e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-brand-600"}),e.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:"Loading..."})]})})]});const I=(s==null?void 0:s.enabled)??!1,b=s==null?void 0:s.current_time,A=(s==null?void 0:s.scale_factor)??1;return e.jsxs("div",{className:"content-width space-y-8",children:[e.jsx(Ga,{title:"Time Travel",subtitle:"Control virtual time for testing time-dependent applications",className:"space-section"}),e.jsxs(X,{className:"p-6",children:[e.jsxs("div",{className:"flex items-start justify-between mb-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:D("p-3 rounded-xl transition-all duration-200",I?"bg-brand-100 text-brand-600 dark:bg-brand-900/30 dark:text-brand-400":"bg-gray-100 text-gray-600 dark:bg-gray-800 dark:text-gray-400"),children:e.jsx(Vs,{className:"h-6 w-6"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-xl font-semibold text-gray-900 dark:text-gray-100",children:"Time Travel Status"}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:I?"Virtual time is active":"Using real time"})]})]}),I&&e.jsx(je,{variant:"success",className:"animate-fade-in",children:"Active"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 mb-6",children:[e.jsxs("div",{className:"p-4 rounded-lg bg-gray-50 dark:bg-gray-800/50 border border-gray-200 dark:border-gray-700",children:[e.jsx("p",{className:"text-xs font-medium text-gray-600 dark:text-gray-400 uppercase tracking-wide mb-1",children:I?"Virtual Time":"Real Time"}),e.jsx("p",{className:"text-2xl font-bold text-gray-900 dark:text-gray-100 tabular-nums",children:N(b||(s==null?void 0:s.real_time))})]}),I&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"p-4 rounded-lg bg-gray-50 dark:bg-gray-800/50 border border-gray-200 dark:border-gray-700",children:[e.jsx("p",{className:"text-xs font-medium text-gray-600 dark:text-gray-400 uppercase tracking-wide mb-1",children:"Time Scale"}),e.jsxs("p",{className:"text-2xl font-bold text-brand-600 dark:text-brand-400",children:[A.toFixed(1),"x"]})]}),e.jsxs("div",{className:"p-4 rounded-lg bg-gray-50 dark:bg-gray-800/50 border border-gray-200 dark:border-gray-700",children:[e.jsx("p",{className:"text-xs font-medium text-gray-600 dark:text-gray-400 uppercase tracking-wide mb-1",children:"Real Time"}),e.jsx("p",{className:"text-2xl font-bold text-gray-900 dark:text-gray-100 tabular-nums",children:N(s==null?void 0:s.real_time)})]})]})]}),e.jsx("div",{className:"space-y-4",children:I?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:'Advance Duration (e.g., "1h", "+1 week", "2d")'}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(B,{type:"text",placeholder:"1h",value:g,onChange:_=>y(_.target.value),className:"flex-1"}),e.jsxs(k,{onClick:O,disabled:d.isPending||!g,className:"bg-brand-600 hover:bg-brand-700 text-white",children:[e.jsx(md,{className:"h-4 w-4 mr-2"}),"Advance"]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Time Scale"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(B,{type:"number",step:"0.1",min:"0.1",placeholder:"1.0",value:u,onChange:_=>p(_.target.value),className:"flex-1"}),e.jsxs(k,{onClick:L,disabled:l.isPending||!u,className:"bg-brand-600 hover:bg-brand-700 text-white",children:[e.jsx(dt,{className:"h-4 w-4 mr-2"}),"Set Scale"]})]})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(k,{onClick:()=>c.mutate(),disabled:c.isPending,variant:"outline",className:"flex-1",children:[e.jsx(gu,{className:"h-4 w-4 mr-2"}),"Disable"]}),e.jsxs(k,{onClick:()=>m.mutate(),disabled:m.isPending,variant:"outline",className:"flex-1",children:[e.jsx(nn,{className:"h-4 w-4 mr-2"}),"Reset to Real Time"]})]})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Initial Time (ISO 8601, optional)"}),e.jsx(B,{type:"text",placeholder:"2025-01-01T00:00:00Z",value:f,onChange:_=>j(_.target.value),className:"w-full"}),C&&e.jsx("p",{className:"mt-1 text-sm text-red-600 dark:text-red-400",children:C})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Time Scale (1.0 = real time)"}),e.jsx(B,{type:"number",step:"0.1",min:"0.1",placeholder:"1.0",value:u,onChange:_=>p(_.target.value),className:"w-full"})]})]}),e.jsxs(k,{onClick:w,disabled:o.isPending,className:"w-full bg-brand-600 hover:bg-brand-700 text-white",children:[e.jsx(er,{className:"h-4 w-4 mr-2"}),"Enable Time Travel"]})]})})]}),e.jsxs(ys,{defaultValue:"cron",className:"space-y-6",children:[e.jsxs(bs,{className:"grid w-full grid-cols-3",children:[e.jsxs(Se,{value:"cron",children:[e.jsx(na,{className:"h-4 w-4 mr-2"}),"Cron Jobs"]}),e.jsxs(Se,{value:"mutations",children:[e.jsx(st,{className:"h-4 w-4 mr-2"}),"Mutation Rules"]}),e.jsxs(Se,{value:"scenarios",children:[e.jsx(Tt,{className:"h-4 w-4 mr-2"}),"Scenarios"]})]}),e.jsx(Ce,{value:"cron",className:"space-y-4",children:e.jsxs(X,{className:"p-6",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4",children:"Scheduled Cron Jobs"}),r?e.jsx("div",{className:"text-center py-8",children:e.jsx("div",{className:"inline-block animate-spin rounded-full h-6 w-6 border-b-2 border-brand-600"})}):a!=null&&a.jobs&&a.jobs.length>0?e.jsx("div",{className:"space-y-3",children:a.jobs.map(_=>e.jsx("div",{className:"p-4 rounded-lg border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold text-gray-900 dark:text-gray-100",children:_.name}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:_.schedule}),_.description&&e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-500 mt-1",children:_.description})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(je,{variant:_.enabled?"success":"default",children:_.enabled?"Enabled":"Disabled"}),e.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-500",children:[_.execution_count||0," executions"]})]})]})},_.id))}):e.jsx(hs,{type:"info",title:"No cron jobs",message:"Create cron jobs to schedule recurring events."})]})}),e.jsx(Ce,{value:"mutations",className:"space-y-4",children:e.jsxs(X,{className:"p-6",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4",children:"Data Mutation Rules"}),i?e.jsx("div",{className:"text-center py-8",children:e.jsx("div",{className:"inline-block animate-spin rounded-full h-6 w-6 border-b-2 border-brand-600"})}):n!=null&&n.rules&&n.rules.length>0?e.jsx("div",{className:"space-y-3",children:n.rules.map(_=>e.jsx("div",{className:"p-4 rounded-lg border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold text-gray-900 dark:text-gray-100",children:_.id}),e.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:["Entity: ",_.entity_name]}),_.description&&e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-500 mt-1",children:_.description})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(je,{variant:_.enabled?"success":"default",children:_.enabled?"Enabled":"Disabled"}),e.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-500",children:[_.execution_count||0," executions"]})]})]})},_.id))}):e.jsx(hs,{type:"info",title:"No mutation rules",message:"Create mutation rules to automatically modify data based on time triggers."})]})}),e.jsx(Ce,{value:"scenarios",className:"space-y-4",children:e.jsxs(X,{className:"p-6",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4",children:"Time Travel Scenarios"}),e.jsx(hs,{type:"info",title:"Scenario Management",message:"Save and load time travel scenarios to quickly restore specific time states. Use the CLI or API to manage scenarios."})]})})]})]})}function Dp({row:s,columns:t,onRowClick:a,showExpandButton:r=!0}){const[n,i]=h.useState(!1),o=t.filter(l=>!l.hideOnMobile).sort((l,m)=>{const g={high:0,medium:1,low:2},y=g[l.priority||"medium"],u=g[m.priority||"medium"];return y-u}),c=o.filter(l=>l.priority==="high"),d=o.filter(l=>l.priority!=="high");return e.jsxs("div",{className:D("bg-card border border-gray-200 dark:border-gray-800 rounded-lg p-4 space-y-3","table-row-hover spring-in animate-fade-in-up",a&&"cursor-pointer"),onClick:()=>a==null?void 0:a(s),children:[e.jsx("div",{className:"space-y-2",children:c.map(l=>{const m=s[l.key],g=l.render?l.render(m,s):m;return e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium text-gray-600 dark:text-gray-400",children:l.mobileLabel||l.label}),e.jsx("span",{className:"text-base text-gray-900 dark:text-gray-100 font-medium",children:g})]},l.key)})}),d.length>0&&r&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"divider-subtle"}),e.jsxs("button",{className:"flex items-center justify-between w-full text-sm text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-100 transition-colors",onClick:l=>{l.stopPropagation(),i(!n)},children:[e.jsx("span",{children:n?"Show less":`Show ${d.length} more details`}),e.jsx(Zr,{direction:n?"up":"down",size:"sm"})]}),n&&e.jsx("div",{className:"space-y-2 animate-fade-in-up",children:d.map(l=>{const m=s[l.key],g=l.render?l.render(m,s):m;return e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs font-medium text-gray-600 dark:text-gray-400",children:l.mobileLabel||l.label}),e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:g})]},l.key)})})]})]})}function zp({columns:s,data:t,onRowClick:a,sortable:r=!1}){const[n,i]=h.useState(null),[o,c]=h.useState("asc"),d=m=>{r&&(n===m?c(o==="asc"?"desc":"asc"):(i(m),c("asc")))},l=M.useMemo(()=>n?[...t].sort((m,g)=>{const y=m[n],u=g[n];return yu?o==="asc"?1:-1:0}):t,[t,n,o]);return e.jsx("div",{className:"overflow-x-auto custom-scrollbar",children:e.jsxs("table",{className:"min-w-full divide-y divide-gray-200 dark:divide-gray-700",children:[e.jsx("thead",{className:"bg-gray-50 dark:bg-gray-800",children:e.jsx("tr",{children:s.map(m=>e.jsx("th",{className:D("px-6 py-3 text-left text-xs font-medium text-tertiary uppercase tracking-wider",m.width&&`w-[${m.width}]`,m.minWidth&&`min-w-[${m.minWidth}]`,r&&m.sortable&&"cursor-pointer hover:text-primary transition-colors"),style:{width:m.width,minWidth:m.minWidth},onClick:()=>m.sortable&&d(m.key),children:e.jsxs("div",{className:"flex items-center gap-2",children:[m.label,r&&m.sortable&&e.jsxs("div",{className:"flex flex-col",children:[e.jsx(Zr,{direction:"up",size:"xs",className:D("transition-opacity",n===m.key&&o==="asc"?"opacity-100":"opacity-30")}),e.jsx(Zr,{direction:"down",size:"xs",className:D("transition-opacity -mt-1",n===m.key&&o==="desc"?"opacity-100":"opacity-30")})]})]})},m.key))})}),e.jsx("tbody",{className:"bg-background divide-y divide-gray-200 dark:divide-gray-700",children:l.map((m,g)=>e.jsx("tr",{className:D("table-row-hover animate-stagger-in",a&&"cursor-pointer"),style:{animationDelay:`${g*50}ms`},onClick:()=>a==null?void 0:a(m),children:s.map(y=>{const u=m[y.key],p=y.render?y.render(u,m):u;return e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-base text-gray-900 dark:text-gray-100",children:p},y.key)})},g))})]})})}function qp({columns:s,data:t,className:a,onRowClick:r,stackOnMobile:n=!0,showExpandButton:i=!0,sortable:o=!1,searchable:c=!1,searchPlaceholder:d="Search...",isLoading:l=!1,emptyMessage:m="No data available"}){const[g,y]=h.useState(""),u=M.useMemo(()=>!c||!g.trim()?t:t.filter(p=>s.some(f=>{const j=p[f.key];return String(j).toLowerCase().includes(g.toLowerCase())})),[t,g,s,c]);return l?e.jsx("div",{className:"space-y-4",children:[...Array(3)].map((p,f)=>e.jsx("div",{className:"animate-pulse",children:e.jsx("div",{className:"h-16 bg-gray-200 dark:bg-gray-700 rounded-lg"})},f))}):u.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"text-xl font-bold text-gray-600 dark:text-gray-400 mb-2",children:g?"No matching results":m}),g&&e.jsx("p",{className:"text-base text-gray-600 dark:text-gray-400",children:"Try adjusting your search terms"})]}):e.jsxs("div",{className:D("space-y-4",a),children:[c&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx("input",{type:"text",placeholder:d,value:g,onChange:p=>y(p.target.value),className:"w-full pl-10 pr-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg text-base bg-background focus:ring-2 focus:ring-brand/20 focus:border-brand transition-colors"}),e.jsx(ki.Search,{className:"absolute left-3 top-2.5 h-4 w-4 text-gray-600 dark:text-gray-400"})]}),g&&e.jsxs(Gr,{variant:"secondary",size:"sm",onClick:()=>y(""),className:"flex items-center gap-2",children:[e.jsx(ki.Close,{className:"h-4 w-4"}),"Clear"]})]}),e.jsx("div",{className:D(n?"md:hidden":"hidden","space-y-3"),children:u.map((p,f)=>e.jsx(Dp,{row:p,columns:s,onRowClick:r,showExpandButton:i},f))}),e.jsx("div",{className:D(n?"hidden md:block":"block"),children:e.jsx(zp,{columns:s,data:u,onRowClick:r,sortable:o})}),e.jsxs("div",{className:"flex items-center justify-between text-sm text-gray-600 dark:text-gray-400",children:[e.jsxs("span",{children:["Showing ",u.length," of ",t.length," ",t.length===1?"item":"items"]}),g&&e.jsxs("span",{children:['Filtered by "',g,'"']})]})]})}function Up({error:s,resetError:t,retry:a,title:r="Something went wrong",description:n="An unexpected error occurred. Please try again.",showDetails:i=!1,showHomeButton:o=!1,className:c=""}){return e.jsxs("div",{className:`flex flex-col items-center justify-center p-8 text-center ${c}`,children:[e.jsx("div",{className:"p-4 rounded-full bg-red-50 dark:bg-red-900/20 mb-4",children:e.jsx(Eo,{status:"error",size:"lg"})}),e.jsx("h3",{className:"text-xl font-bold text-gray-900 dark:text-gray-100 mb-2",children:r}),e.jsx("p",{className:"text-base text-gray-600 dark:text-gray-400 mb-6 max-w-md",children:n}),i&&s&&e.jsxs("details",{className:"mb-6 w-full max-w-md",children:[e.jsx("summary",{className:"cursor-pointer text-sm font-medium text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:text-gray-100 mb-2",children:"Show error details"}),e.jsx("div",{className:"p-3 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg text-left",children:e.jsx("div",{className:"text-sm font-mono text-red-700 dark:text-red-500 break-all",children:s.message})})]}),e.jsxs("div",{className:"flex gap-3",children:[a&&e.jsxs(k,{onClick:a,className:"flex items-center gap-2",variant:"default",children:[e.jsx(st,{className:"h-4 w-4"}),"Try again"]}),t&&e.jsxs(k,{onClick:t,variant:"outline",className:"flex items-center gap-2",children:[e.jsx(st,{className:"h-4 w-4"}),"Reset"]}),o&&e.jsxs(k,{onClick:()=>window.location.href="proxy.php?url=https%3A%2F%2Fapp.mockforge.dev%2F",variant:"outline",className:"flex items-center gap-2",children:[e.jsx(co,{className:"h-4 w-4"}),"Go home"]})]})]})}function Bp({retry:s,resetError:t}){return e.jsxs("div",{className:"flex flex-col items-center justify-center p-8 text-center",children:[e.jsx("div",{className:"p-4 rounded-full bg-orange-50 dark:bg-orange-900/20 mb-4",children:e.jsx(Ms,{className:"h-8 w-8 text-orange-600 dark:text-orange-400"})}),e.jsx("h3",{className:"text-xl font-bold text-gray-900 dark:text-gray-100 mb-2",children:"Data Loading Failed"}),e.jsx("p",{className:"text-base text-gray-600 dark:text-gray-400 mb-6 max-w-md",children:"There was a problem loading the data. This might be a temporary issue."}),e.jsxs("div",{className:"flex gap-3",children:[s&&e.jsxs(k,{onClick:s,className:"flex items-center gap-2",variant:"default",children:[e.jsx(st,{className:"h-4 w-4"}),"Reload data"]}),t&&e.jsxs(k,{onClick:t,variant:"outline",className:"flex items-center gap-2",children:[e.jsx(co,{className:"h-4 w-4"}),"Reset view"]})]})]})}class Ly extends M.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,a){Pe.error("Component error caught",t,a)}render(){if(this.state.hasError){const t=this.props.fallback||Up;return e.jsx(t,{error:this.state.error,resetError:()=>this.setState({hasError:!1,error:void 0})})}return this.props.children}}function Vp(s=3){var g;const[t,a]=h.useState({error:null,isRetrying:!1,retryCount:0}),r=oe(),{error:n}=ms(),i=h.useCallback((y,u)=>{const p=(u==null?void 0:u.showToast)??!0;if(a(f=>({...f,error:y,context:{operation:(u==null?void 0:u.operation)||"unknown",component:u==null?void 0:u.component,retryable:(u==null?void 0:u.retryable)??!0,timestamp:Date.now(),showToast:p}})),Pe.error("Error handled",{error:y.message,stack:y.stack,context:u}),p){const f=u!=null&&u.operation?`Failed to ${u.operation}`:"An error occurred";n(f,y.message)}},[n]),o=h.useCallback(async y=>{if(t.retryCount>=s){Pe.warn("Max retries reached, not retrying");return}a(u=>({...u,isRetrying:!0,retryCount:u.retryCount+1}));try{y?await y():await r.invalidateQueries(),a({error:null,isRetrying:!1,retryCount:0})}catch(u){a(p=>({...p,error:u instanceof Error?u:new Error("Retry failed"),isRetrying:!1}))}},[t.retryCount,s,r]),c=h.useCallback(()=>{a({error:null,isRetrying:!1,retryCount:0})},[]),d=h.useCallback(y=>y.message.includes("fetch")||y.message.includes("network")||y.message.includes("Failed to load"),[]),l=h.useCallback(y=>y.message.includes("timeout")||y.message.includes("Timeout"),[]),m=h.useCallback(y=>d(y)?"network":l(y)?"timeout":"generic",[d,l]);return{errorState:t,handleError:i,retry:o,clearError:c,isNetworkError:d,isTimeoutError:l,getErrorType:m,canRetry:t.retryCount{let m;d instanceof Error?m=d:typeof d=="string"?m=new Error(d):m=new Error("An unknown error occurred"),s(m,{operation:l,component:"API",retryable:!0})},[s]),c=h.useCallback(async d=>{try{const l=await d();return a(),l}catch(l){throw o(l,"retry"),l}},[a,o]);return{errorState:r,handleApiError:o,retry:t,retryApiCall:c,clearError:a,getErrorType:n,canRetry:i}}function Jp(){var P,V,v;const s=gn(),[t,a]=h.useState("rules"),[r,n]=h.useState(!1),[i,o]=h.useState(null),[c,d]=h.useState("all"),[l,m]=h.useState(""),{handleApiError:g,retry:y,clearError:u,errorState:p,canRetry:f}=Kp(),{data:j,isLoading:C,error:T,refetch:N}=X0(),{data:w,isLoading:O,error:L,refetch:I}=ag(50),b=eg(),A=tg(),_=sg();M.useEffect(()=>{T?g(T,"fetch_proxy_rules"):u()},[T,g,u]);const $=h.useMemo(()=>{if(!(j!=null&&j.rules))return[];let x=j.rules;if(c!=="all"&&(x=x.filter(K=>K.type===c)),l){const K=l.toLowerCase();x=x.filter(de=>de.pattern.toLowerCase().includes(K)||de.body_transforms.some(te=>te.path.toLowerCase().includes(K)||te.replace.toLowerCase().includes(K)))}return x},[j,c,l]),ae=async x=>{try{const K={pattern:x.pattern,type:x.type,status_codes:x.status_codes,body_transforms:x.body_transforms.map(de=>({path:de.path,replace:de.replace,operation:de.operation||"replace"})),enabled:x.enabled};await b.mutateAsync(K),n(!1)}catch(K){g(K,"create_proxy_rule")}},U=async(x,K)=>{try{const de={pattern:K.pattern,type:K.type,status_codes:K.status_codes,body_transforms:K.body_transforms.map(te=>({path:te.path,replace:te.replace,operation:te.operation||"replace"})),enabled:K.enabled};await A.mutateAsync({id:x,rule:de}),o(null)}catch(de){g(de,"update_proxy_rule")}},z=async x=>{if(s("Are you sure you want to delete this proxy replacement rule?"))try{await _.mutateAsync(x)}catch(K){g(K,"delete_proxy_rule")}},R=[{header:"Pattern",accessor:"pattern",cell:x=>e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("code",{className:"text-xs bg-gray-100 dark:bg-gray-800 px-2 py-1 rounded",children:x.pattern})})},{header:"Type",accessor:"type",cell:x=>e.jsx(jr,{variant:x.type==="request"?"info":"success",className:"text-xs",children:x.type})},{header:"Transforms",accessor:"body_transforms",cell:x=>e.jsx("div",{className:"flex flex-col gap-1",children:x.body_transforms.map((K,de)=>e.jsxs("div",{className:"text-xs text-gray-600 dark:text-gray-400",children:[e.jsx("code",{className:"text-xs",children:K.path}),e.jsx(ao,{className:"inline mx-1 h-3 w-3"}),e.jsxs("span",{className:"text-xs",children:[K.replace.substring(0,30),"..."]})]},de))})},{header:"Status",accessor:"enabled",cell:x=>e.jsxs("div",{className:"flex items-center gap-2",children:[x.enabled?e.jsx(Me,{className:"h-4 w-4 text-green-600"}):e.jsx(xs,{className:"h-4 w-4 text-gray-400"}),e.jsx("span",{className:"text-xs",children:x.enabled?"Enabled":"Disabled"})]})},{header:"Actions",accessor:"id",cell:x=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(k,{variant:"ghost",size:"sm",onClick:()=>o(x),className:"h-8 w-8 p-0",children:e.jsx(Ks,{className:"h-4 w-4"})}),e.jsx(k,{variant:"ghost",size:"sm",onClick:()=>z(x.id),className:"h-8 w-8 p-0 text-red-600 hover:text-red-700",children:e.jsx(Qe,{className:"h-4 w-4"})})]})}];return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold text-gray-900 dark:text-gray-100",children:"Proxy Inspector"}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mt-1",children:"Inspect and replace requests/responses from browser proxy mode"})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs(k,{variant:"outline",size:"sm",onClick:()=>{N(),I()},children:[e.jsx(st,{className:"h-4 w-4 mr-2"}),"Refresh"]})})]}),e.jsx("div",{className:"border-b border-gray-200 dark:border-gray-700",children:e.jsxs("nav",{className:"flex space-x-8",children:[e.jsxs("button",{onClick:()=>a("rules"),className:D("py-4 px-1 border-b-2 font-medium text-sm transition-colors",t==="rules"?"border-brand-500 text-brand-600 dark:text-brand-400":"border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300 dark:text-gray-400 dark:hover:text-gray-300"),children:[e.jsx(Tt,{className:"inline h-4 w-4 mr-2"}),"Replacement Rules"]}),e.jsxs("button",{onClick:()=>a("inspect"),className:D("py-4 px-1 border-b-2 font-medium text-sm transition-colors",t==="inspect"?"border-brand-500 text-brand-600 dark:text-brand-400":"border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300 dark:text-gray-400 dark:hover:text-gray-300"),children:[e.jsx(ma,{className:"inline h-4 w-4 mr-2"}),"Intercepted Traffic"]})]})}),p.hasError&&e.jsx(Bp,{error:p.error,retry:f?y:void 0,onDismiss:u}),t==="rules"&&e.jsxs("div",{className:"space-y-4",children:[e.jsx(X,{children:e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 items-start sm:items-center justify-between",children:[e.jsxs("div",{className:"flex flex-1 gap-2 items-center",children:[e.jsx(jd,{className:"h-4 w-4 text-gray-400"}),e.jsx(B,{placeholder:"Search patterns or transforms...",value:l,onChange:x=>m(x.target.value),className:"max-w-sm"}),e.jsxs("select",{value:c,onChange:x=>d(x.target.value),className:"px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-800 text-sm",children:[e.jsx("option",{value:"all",children:"All Types"}),e.jsx("option",{value:"request",children:"Request Rules"}),e.jsx("option",{value:"response",children:"Response Rules"})]})]}),e.jsxs(k,{onClick:()=>n(!0),children:[e.jsx(kt,{className:"h-4 w-4 mr-2"}),"Create Rule"]})]})}),e.jsx(X,{children:C?e.jsx(Ap,{columns:5,rows:5}):T?e.jsxs("div",{className:"p-8 text-center text-red-600",children:["Failed to load proxy rules. ",f&&e.jsx(k,{onClick:y,children:"Retry"})]}):$.length===0?e.jsx("div",{className:"p-8 text-center text-gray-500",children:(P=j==null?void 0:j.rules)!=null&&P.length?"No rules match your filters.":"No proxy replacement rules configured. Create one to get started."}):e.jsx(qp,{data:$,columns:R,keyExtractor:x=>x.id.toString()})}),(r||i)&&e.jsx(Hp,{rule:i,onSave:x=>{i?U(i.id,x):ae(x)},onCancel:()=>{n(!1),o(null)}})]}),t==="inspect"&&e.jsx("div",{className:"space-y-4",children:e.jsx(X,{children:e.jsx("div",{className:"space-y-4",children:O?e.jsxs("div",{className:"p-8 text-center",children:[e.jsx(st,{className:"h-6 w-6 animate-spin mx-auto mb-2 text-gray-400"}),e.jsx("p",{className:"text-sm text-gray-500",children:"Loading intercepted traffic..."})]}):L?e.jsxs("div",{className:"p-8 text-center text-red-600",children:["Failed to load intercepted traffic. ",f&&e.jsx(k,{onClick:y,children:"Retry"})]}):w!=null&&w.message?e.jsxs("div",{className:"p-8 text-center",children:[e.jsx(Yc,{className:"h-12 w-12 mx-auto mb-4 text-gray-400"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:w.message}),e.jsx("p",{className:"text-sm text-gray-500 mt-2",children:"Request/response inspection will be available in a future version."})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Intercepted Requests"}),(V=w==null?void 0:w.requests)!=null&&V.length?e.jsx("div",{className:"space-y-2",children:w.requests.map(x=>e.jsxs("div",{className:"p-4 border border-gray-200 dark:border-gray-700 rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(jr,{variant:"info",children:x.method}),e.jsx("code",{className:"text-sm",children:x.url}),e.jsx("span",{className:"text-xs text-gray-500",children:x.timestamp})]}),x.body&&e.jsx("pre",{className:"text-xs bg-gray-50 dark:bg-gray-900 p-2 rounded mt-2 overflow-x-auto",children:x.body})]},x.id))}):e.jsx("p",{className:"text-sm text-gray-500",children:"No requests intercepted yet."})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Intercepted Responses"}),(v=w==null?void 0:w.responses)!=null&&v.length?e.jsx("div",{className:"space-y-2",children:w.responses.map(x=>e.jsxs("div",{className:"p-4 border border-gray-200 dark:border-gray-700 rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(jr,{variant:x.status_code>=200&&x.status_code<300?"success":x.status_code>=400&&x.status_code<500?"warning":"danger",children:x.status_code}),e.jsx("span",{className:"text-xs text-gray-500",children:x.timestamp})]}),x.body&&e.jsx("pre",{className:"text-xs bg-gray-50 dark:bg-gray-900 p-2 rounded mt-2 overflow-x-auto",children:x.body})]},x.id))}):e.jsx("p",{className:"text-sm text-gray-500",children:"No responses intercepted yet."})]})]})})})})]})}function Hp({rule:s,onSave:t,onCancel:a}){const[r,n]=h.useState({pattern:(s==null?void 0:s.pattern)||"",type:(s==null?void 0:s.type)||"request",status_codes:(s==null?void 0:s.status_codes)||[],body_transforms:(s==null?void 0:s.body_transforms)||[{path:"",replace:"",operation:"replace"}],enabled:(s==null?void 0:s.enabled)??!0}),i=l=>{l.preventDefault(),t(r)},o=()=>{n({...r,body_transforms:[...r.body_transforms,{path:"",replace:"",operation:"replace"}]})},c=l=>{n({...r,body_transforms:r.body_transforms.filter((m,g)=>g!==l)})},d=(l,m,g)=>{const y=[...r.body_transforms];y[l]={...y[l],[m]:g},n({...r,body_transforms:y})};return e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsx(X,{className:"w-full max-w-2xl max-h-[90vh] overflow-y-auto m-4",children:e.jsxs("div",{className:"p-6",children:[e.jsx("h3",{className:"text-xl font-semibold mb-4",children:s?"Edit Proxy Rule":"Create Proxy Rule"}),e.jsxs("form",{onSubmit:i,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1",children:"URL Pattern"}),e.jsx(B,{value:r.pattern,onChange:l=>n({...r,pattern:l.target.value}),placeholder:"/api/users/*",required:!0}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Supports wildcards (e.g., /api/users/*)"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1",children:"Rule Type"}),e.jsxs("select",{value:r.type,onChange:l=>n({...r,type:l.target.value}),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-800",children:[e.jsx("option",{value:"request",children:"Request"}),e.jsx("option",{value:"response",children:"Response"})]})]}),r.type==="response"&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1",children:"Status Codes (comma-separated)"}),e.jsx(B,{value:r.status_codes.join(", "),onChange:l=>{const m=l.target.value.split(",").map(g=>parseInt(g.trim())).filter(g=>!isNaN(g));n({...r,status_codes:m})},placeholder:"200, 201, 404"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:"Body Transformations"}),e.jsxs("div",{className:"space-y-3",children:[r.body_transforms.map((l,m)=>e.jsxs("div",{className:"p-3 border border-gray-200 dark:border-gray-700 rounded-lg space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("span",{className:"text-sm font-medium",children:["Transform ",m+1]}),r.body_transforms.length>1&&e.jsx(k,{type:"button",variant:"ghost",size:"sm",onClick:()=>c(m),children:e.jsx(Qe,{className:"h-4 w-4"})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium mb-1",children:"JSONPath"}),e.jsx(B,{value:l.path,onChange:g=>d(m,"path",g.target.value),placeholder:"$.userId",required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium mb-1",children:"Replacement Value"}),e.jsx(B,{value:l.replace,onChange:g=>d(m,"replace",g.target.value),placeholder:"{{uuid}}",required:!0}),e.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:["Supports templates: ","{{","uuid","}}",", ","{{","faker.email","}}",", etc."]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium mb-1",children:"Operation"}),e.jsxs("select",{value:l.operation,onChange:g=>d(m,"operation",g.target.value),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-800 text-sm",children:[e.jsx("option",{value:"replace",children:"Replace"}),e.jsx("option",{value:"add",children:"Add"}),e.jsx("option",{value:"remove",children:"Remove"})]})]})]},m)),e.jsxs(k,{type:"button",variant:"outline",onClick:o,className:"w-full",children:[e.jsx(kt,{className:"h-4 w-4 mr-2"}),"Add Transformation"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",id:"enabled",checked:r.enabled,onChange:l=>n({...r,enabled:l.target.checked}),className:"h-4 w-4"}),e.jsx("label",{htmlFor:"enabled",className:"text-sm font-medium",children:"Enabled"})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[e.jsx(k,{type:"button",variant:"outline",onClick:a,children:"Cancel"}),e.jsxs(k,{type:"submit",children:[s?"Update":"Create"," Rule"]})]})]})]})})})}function Wp(){return e.jsx("div",{className:"container mx-auto px-4 py-6",children:e.jsx(Jp,{})})}const Gp=h.lazy(()=>G(()=>import("./DashboardPage.CdIQUb6l.js"),__vite__mapDeps([0,1,2,3,4,5,6])).then(s=>({default:s.DashboardPage}))),Zp=h.lazy(()=>G(()=>import("./ServicesPage.Dp4dNUy5.js"),__vite__mapDeps([7,1,6])).then(s=>({default:s.ServicesPage}))),Qp=h.lazy(()=>G(()=>import("./LogsPage._qJDRYPj.js"),__vite__mapDeps([8,1,2,9,10,11,6])).then(s=>({default:s.LogsPage}))),Yp=h.lazy(()=>G(()=>import("./MetricsPage.BiV4MKEw.js"),__vite__mapDeps([12,1,6])).then(s=>({default:s.MetricsPage}))),Xp=h.lazy(()=>G(()=>import("./VerificationPage.CpXiAA-n.js"),__vite__mapDeps([13,1,6])).then(s=>({default:s.VerificationPage}))),ef=h.lazy(()=>G(()=>import("./ContractDiffPage.D_5AHS5U.js"),__vite__mapDeps([14,1,15,11,6])).then(s=>({default:s.ContractDiffPage}))),Mi=h.lazy(()=>G(()=>import("./IncidentDashboardPage.WhmVZou5.js"),__vite__mapDeps([16,1,17,6])).then(s=>({default:s.IncidentDashboardPage}))),tf=h.lazy(()=>G(()=>import("./FitnessFunctionsPage.CCV7goA5.js"),__vite__mapDeps([18,1,17,19,20,6])).then(s=>({default:s.FitnessFunctionsPage}))),sf=h.lazy(()=>G(()=>import("./FixturesPage.CpOzLdOZ.js"),__vite__mapDeps([21,1,22,19,6])).then(s=>({default:s.FixturesPage}))),af=h.lazy(()=>G(()=>import("./TestingPage.DiPW8dou.js"),__vite__mapDeps([23,1,6])).then(s=>({default:s.TestingPage}))),rf=h.lazy(()=>G(()=>import("./ImportPage.C2ukTjau.js"),__vite__mapDeps([24,1,22,6])).then(s=>({default:s.ImportPage}))),nf=h.lazy(()=>G(()=>import("./WorkspacesPage.BrFPK6dn.js"),__vite__mapDeps([25,1,26,27,20,6]))),of=h.lazy(()=>G(()=>import("./PlaygroundPage.B0DtmhmM.js"),__vite__mapDeps([28,1,9,10,11,6])).then(s=>({default:s.PlaygroundPage}))),lf=h.lazy(()=>G(()=>import("./PluginsPage.BdsmE76_.js"),__vite__mapDeps([29,1,26,6])).then(s=>({default:s.PluginsPage}))),cf=h.lazy(()=>G(()=>import("./ChainsPage.8pczSHke.js"),__vite__mapDeps([30,1,6])).then(s=>({default:s.ChainsPage}))),df=h.lazy(()=>G(()=>import("./GraphPage.m1YDxmUu.js"),__vite__mapDeps([31,1,32,33,34,6])).then(s=>({default:s.GraphPage}))),uf=h.lazy(()=>G(()=>import("./WorldStatePage.D8JmVc-O.js"),__vite__mapDeps([35,1,32,34,4,5,6])).then(s=>({default:s.WorldStatePage}))),mf=h.lazy(()=>G(()=>import("./PerformancePage.Brrld2vw.js"),__vite__mapDeps([36,1,6])).then(s=>({default:s.default}))),hf=h.lazy(()=>G(()=>import("./ScenarioStateMachineEditor.CxgbCeWl.js"),__vite__mapDeps([37,1,32,4,38,6])).then(s=>({default:s.ScenarioStateMachineEditor}))),gf=h.lazy(()=>G(()=>import("./ScenarioStudioPage.BYOXjpZc.js"),__vite__mapDeps([39,1,32,38,4,6])).then(s=>({default:s.ScenarioStudioPage}))),xf=h.lazy(()=>G(()=>import("./AnalyticsPage.DZR8pmo2.js"),__vite__mapDeps([40,1,3,6]))),pf=h.lazy(()=>G(()=>import("./PillarAnalyticsPage.CgtLwiBR.js"),__vite__mapDeps([41,1,27,10,3,42,6])).then(s=>({default:s.PillarAnalyticsPage}))),ff=h.lazy(()=>G(()=>import("./HostedMocksPage.taCpBqZV.js"),__vite__mapDeps([43,1,4,6])).then(s=>({default:s.HostedMocksPage}))),yf=h.lazy(()=>G(()=>import("./ApiExplorerPage.MKc6DyZW.js").then(s=>s.b7),__vite__mapDeps([44,1,45,46])).then(s=>({default:s.ApiExplorerPage}))),bf=h.lazy(()=>G(()=>import("./ObservabilityPage.CWQkcngO.js"),__vite__mapDeps([47,1,4,6])).then(s=>({default:s.ObservabilityPage}))),vf=h.lazy(()=>G(()=>import("./TracesPage.BSj8MRlo.js"),__vite__mapDeps([48,1,6])).then(s=>({default:s.TracesPage}))),jf=h.lazy(()=>G(()=>import("./TestGeneratorPage.CAyeBzXW.js"),__vite__mapDeps([49,1]))),kf=h.lazy(()=>G(()=>import("./TestExecutionDashboard.j__yYtZw.js"),__vite__mapDeps([50,1,3]))),wf=h.lazy(()=>G(()=>import("./IntegrationTestBuilder.JwpKh1Na.js"),__vite__mapDeps([51,1]))),Nf=h.lazy(()=>G(()=>import("./ConformancePage.Cy5_aNVJ.js"),__vite__mapDeps([52,1,6])).then(s=>({default:s.ConformancePage}))),_f=h.lazy(()=>G(()=>import("./ChaosPage.C1VcGQjn.js"),__vite__mapDeps([53,1,5,3,6])).then(s=>({default:s.ChaosPage}))),Sf=h.lazy(()=>G(()=>import("./ResiliencePage.D0Kdpnnh.js"),__vite__mapDeps([54,1])).then(s=>({default:s.ResiliencePage}))),Cf=h.lazy(()=>G(()=>import("./RecorderPage.Da9YOgUd.js"),__vite__mapDeps([55,1,6])).then(s=>({default:s.RecorderPage}))),Tf=h.lazy(()=>G(()=>import("./BehavioralCloningPage.C1odslZv.js"),__vite__mapDeps([56,1,19,11,10,57,6])).then(s=>({default:s.BehavioralCloningPage}))),Pf=h.lazy(()=>G(()=>import("./OrchestrationBuilder.B1dub-eX.js"),__vite__mapDeps([58,1]))),Ef=h.lazy(()=>G(()=>import("./OrchestrationExecutionView.CvhwXldU.js"),__vite__mapDeps([59,1,4,6]))),Af=h.lazy(()=>G(()=>import("./PluginRegistryPage.BAOm3ZkE.js"),__vite__mapDeps([60,1,61,6]))),Of=h.lazy(()=>G(()=>import("./TemplateMarketplacePage.BqsEJ6d7.js"),__vite__mapDeps([62,1,61,6]))),If=h.lazy(()=>G(()=>import("./ScenarioMarketplacePage.B4g73bzV.js"),__vite__mapDeps([63,1,61,6]))),Mf=h.lazy(()=>G(()=>import("./ShowcasePage.Bl2HVOCZ.js"),__vite__mapDeps([64,1,65,6])).then(s=>({default:s.ShowcasePage}))),Rf=h.lazy(()=>G(()=>import("./LearningHubPage.U6XsQ5Gb.js"),__vite__mapDeps([66,1,65,6])).then(s=>({default:s.LearningHubPage}))),Lf=h.lazy(()=>G(()=>import("./UserManagementPage.C1zATZZD.js"),__vite__mapDeps([67,1,6])).then(s=>({default:s.UserManagementPage}))),$f=h.lazy(()=>G(()=>import("./RegistryLoginPage.Dh-tofzt.js"),__vite__mapDeps([68,1,69,6])).then(s=>({default:s.RegistryLoginPage}))),Ff=h.lazy(()=>G(()=>import("./RegistryAdminPage.1u3phRty.js"),__vite__mapDeps([70,1,69,6])).then(s=>({default:s.RegistryAdminPage}))),Df=h.lazy(()=>G(()=>import("./RegistryInvitePage.DZZ1YT-A.js"),__vite__mapDeps([71,1,69,6])).then(s=>({default:s.RegistryInvitePage}))),zf=h.lazy(()=>G(()=>import("./MockAIPage.aCyHOF9J.js"),__vite__mapDeps([72,1,15,10,6])).then(s=>({default:s.MockAIPage}))),qf=h.lazy(()=>G(()=>import("./MockAIOpenApiGeneratorPage.CRUF8UuZ.js"),__vite__mapDeps([73,1,6])).then(s=>({default:s.MockAIOpenApiGeneratorPage}))),Uf=h.lazy(()=>G(()=>import("./MockAIRulesPage.DNnss9-5.js"),__vite__mapDeps([74,1,10,6])).then(s=>({default:s.MockAIRulesPage}))),Bf=h.lazy(()=>G(()=>import("./VoicePage.sPkRUs-X.js"),__vite__mapDeps([75,1,15,11,10,6])).then(s=>({default:s.VoicePage}))),Vf=h.lazy(()=>G(()=>import("./AIStudioPage.BtcDJaxy.js"),__vite__mapDeps([76,1,15,33,42,10,57,6])).then(s=>({default:s.AIStudioPage}))),Kf=h.lazy(()=>G(()=>import("./SmtpMailboxPage.CYBCqxtN.js"),__vite__mapDeps([77,1,6])).then(s=>({default:s.SmtpMailboxPage}))),Jf=h.lazy(()=>G(()=>import("./MqttBrokerPage.txXXnlVl.js"),__vite__mapDeps([78,1,79,6])).then(s=>({default:s.MqttBrokerPage}))),Hf=h.lazy(()=>G(()=>import("./KafkaBrokerPage.CHsITh8I.js"),__vite__mapDeps([80,1,79,6])).then(s=>({default:s.KafkaBrokerPage}))),Wf=h.lazy(()=>G(()=>import("./TermsPage.Bs6ueNVO.js"),__vite__mapDeps([81,1,82,45,6])).then(s=>({default:s.TermsPage}))),Gf=h.lazy(()=>G(()=>import("./PrivacyPage.DHpIeKCg.js"),__vite__mapDeps([83,1,82,45,6])).then(s=>({default:s.PrivacyPage}))),Zf=h.lazy(()=>G(()=>import("./DPAPage.BQ4nFdp4.js"),__vite__mapDeps([84,1,82,45,6])).then(s=>({default:s.DPAPage}))),Qf=h.lazy(()=>G(()=>import("./FAQPage.KqT_4tJ7.js"),__vite__mapDeps([85,1,6])).then(s=>({default:s.FAQPage}))),Yf=h.lazy(()=>G(()=>import("./SupportPage.BslHrGHe.js"),__vite__mapDeps([86,1,33,79,6])).then(s=>({default:s.SupportPage}))),Xf=h.lazy(()=>G(()=>import("./PricingPage.DC8hUef5.js"),__vite__mapDeps([87,1,6])).then(s=>({default:s.PricingPage}))),ey=h.lazy(()=>G(()=>import("./EmailVerificationPage.CWI4y7Dt.js"),__vite__mapDeps([88,1,6])).then(s=>({default:s.EmailVerificationPage}))),ty=h.lazy(()=>G(()=>import("./WaitlistPage.DxQVqxA3.js"),__vite__mapDeps([89,1,10,6])).then(s=>({default:s.WaitlistPage})));function sy(){const s=window.__mockforge_explorer_deployment;return s?e.jsx(yf,{deployment:s,onBack:()=>{window.history.back()}}):e.jsx($i,{to:"/hosted-mocks",replace:!0})}const ay=[{path:"/dashboard",element:e.jsx(Gp,{})},{path:"/workspaces",element:e.jsx(nf,{})},{path:"/playground",element:e.jsx(of,{})},{path:"/federation",element:e.jsx(Eg,{})},{path:"/services",element:e.jsx(Zp,{})},{path:"/virtual-backends",element:e.jsx(dg,{})},{path:"/fixtures",element:e.jsx(sf,{})},{path:"/hosted-mocks",element:e.jsx(ff,{})},{path:"/api-explorer",element:e.jsx(sy,{})},{path:"/tunnels",element:e.jsx(ug,{})},{path:"/chains",element:e.jsx(cf,{})},{path:"/graph",element:e.jsx(df,{})},{path:"/world-state",element:e.jsx(uf,{})},{path:"/performance",element:e.jsx(mf,{})},{path:"/state-machine-editor",element:e.jsx(hf,{})},{path:"/scenario-studio",element:e.jsx(gf,{})},{path:"/orchestration-builder",element:e.jsx(Pf,{})},{path:"/orchestration-execution",element:e.jsx(Ef,{orchestrationId:"default"})},{path:"/observability",element:e.jsx(bf,{})},{path:"/status",element:e.jsx(Ex,{})},{path:"/logs",element:e.jsx(Qp,{})},{path:"/traces",element:e.jsx(vf,{})},{path:"/metrics",element:e.jsx(Yp,{})},{path:"/analytics",element:e.jsx(xf,{})},{path:"/pillar-analytics",element:e.jsx(pf,{})},{path:"/verification",element:e.jsx(Xp,{})},{path:"/contract-diff",element:e.jsx(ef,{})},{path:"/incidents",element:e.jsx(Mi,{})},{path:"/incident-dashboard",element:e.jsx(Mi,{})},{path:"/fitness-functions",element:e.jsx(tf,{})},{path:"/testing",element:e.jsx(af,{})},{path:"/test-generator",element:e.jsx(jf,{})},{path:"/test-execution",element:e.jsx(kf,{})},{path:"/integration-test-builder",element:e.jsx(wf,{})},{path:"/conformance",element:e.jsx(Nf,{})},{path:"/chaos",element:e.jsx(_f,{})},{path:"/resilience",element:e.jsx(Sf,{})},{path:"/recorder",element:e.jsx(Cf,{})},{path:"/behavioral-cloning",element:e.jsx(Tf,{})},{path:"/import",element:e.jsx(rf,{})},{path:"/template-marketplace",element:e.jsx(Of,{})},{path:"/scenario-marketplace",element:e.jsx(If,{})},{path:"/showcase",element:e.jsx(Mf,{})},{path:"/learning-hub",element:e.jsx(Rf,{})},{path:"/plugins",element:e.jsx(lf,{})},{path:"/plugin-registry",element:e.jsx(Af,{})},{path:"/user-management",element:e.jsx(Lf,{})},{path:"/registry-login",element:e.jsx($f,{})},{path:"/registry-admin",element:e.jsx(Ff,{})},{path:"/registry-admin/invite/:token",element:e.jsx(Df,{})},{path:"/mockai",element:e.jsx(zf,{})},{path:"/mockai-openapi-generator",element:e.jsx(qf,{})},{path:"/mockai-rules",element:e.jsx(Uf,{})},{path:"/voice",element:e.jsx(Bf,{})},{path:"/ai-studio",element:e.jsx(Vf,{})},{path:"/config",element:e.jsx(gx,{})},{path:"/organization",element:e.jsx(gp,{})},{path:"/billing",element:e.jsx(yp,{})},{path:"/api-tokens",element:e.jsx(wp,{})},{path:"/publisher-keys",element:e.jsx(Ep,{})},{path:"/byok",element:e.jsx(Px,{})},{path:"/usage",element:e.jsx($p,{})},{path:"/time-travel",element:e.jsx(Fp,{})},{path:"/proxy-inspector",element:e.jsx(Wp,{})},{path:"/smtp-mailbox",element:e.jsx(Kf,{})},{path:"/mqtt-broker",element:e.jsx(Jf,{})},{path:"/kafka-broker",element:e.jsx(Hf,{})},{path:"/terms",element:e.jsx(Wf,{})},{path:"/privacy",element:e.jsx(Gf,{})},{path:"/dpa",element:e.jsx(Zf,{})},{path:"/faq",element:e.jsx(Qf,{})},{path:"/support",element:e.jsx(Yf,{})},{path:"/pricing",element:e.jsx(Xf,{})},{path:"/verify-email",element:e.jsx(ey,{})},{path:"/waitlist",element:e.jsx(ty,{})}];function ry(){const{t:s}=nr(),t=Xr();return e.jsx("div",{className:"space-y-8",children:e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-6xl mb-4",children:"🚧"}),e.jsx("h2",{className:"text-2xl font-bold text-gray-900 dark:text-gray-100 mb-2",children:s("app.pageNotFoundTitle")}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-6",children:s("app.pageNotFoundBody")}),e.jsx("button",{onClick:()=>t("/dashboard"),className:"px-6 py-3 bg-blue-600 hover:bg-blue-700 text-white rounded-lg font-medium transition-colors",children:s("app.goToDashboard")})]})})})}function ny(){const{t:s}=nr(),t=Xr(),a=Ro(d=>d.loadWorkspaces),r=Ct(d=>d.isAuthenticated),n=et(d=>d.loadPreferences),i=et(d=>d.preferences.ui.defaultPage),o=i&&i!==""?`/${i}`:"/dashboard";cg(),lg(),h.useEffect(()=>{r&&(a(),n())},[r,a,n]),h.useEffect(()=>{const d=m=>{const{target:g}=m.detail;g==="chaos"?t("/chaos"):g==="scenario"?t("/scenario-studio"):g==="persona"&&t("/ai-studio")},l=m=>{const{tab:g}=m.detail;g&&t("/"+g)};return window.addEventListener("navigate",d),window.addEventListener("navigate-tab",l),()=>{window.removeEventListener("navigate",d),window.removeEventListener("navigate-tab",l)}},[t]),h.useEffect(()=>{G(async()=>{const{isTauri:d,listenToTauriEvent:l}=await import("./tauri.BOSGuS7D.js");return{isTauri:d,listenToTauriEvent:l}},__vite__mapDeps([90,1,6])).then(({isTauri:d,listenToTauriEvent:l})=>{if(d){const m=l("file-opened",u=>{G(async()=>{const{handleFileOpen:p}=await import("./tauri.BOSGuS7D.js");return{handleFileOpen:p}},__vite__mapDeps([90,1,6])).then(({handleFileOpen:p})=>{p(u).catch(f=>{console.error("Failed to handle file open:",f)})})}),g=l("file-dropped",u=>{G(async()=>{const{handleFileOpen:p}=await import("./tauri.BOSGuS7D.js");return{handleFileOpen:p}},__vite__mapDeps([90,1,6])).then(({handleFileOpen:p})=>{p(u).catch(f=>{console.error("Failed to handle file drop:",f)})})}),y=l("config-file-opened",u=>{});return()=>{m(),g(),y()}}})},[]);const c=()=>{};return e.jsx(wi,{children:e.jsx(S0,{children:e.jsx(y0,{children:e.jsx(g0,{onRefresh:c,children:e.jsx(wi,{children:e.jsx(h.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600"}),e.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:s("app.loading")})]})}),children:e.jsxs(ll,{children:[e.jsx(xr,{path:"/",element:e.jsx($i,{to:o,replace:!0})}),ay.map(d=>e.jsx(xr,{path:d.path,element:d.element},d.path)),e.jsx(xr,{path:"*",element:e.jsx(ry,{})})]})})})})})})})}const iy=!!(window.location.hostname==="localhost"||window.location.hostname==="[::1]"||window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/)),Sr="v4";function oy(s){if(!("serviceWorker"in navigator)||new URL("/",window.location.href).origin!==window.location.origin)return;const a=`/sw.js?version=${Sr}`,r=async()=>{const n=await navigator.serviceWorker.getRegistrations();await Promise.all(n.map(async o=>{var d,l,m;const c=((d=o.active)==null?void 0:d.scriptURL)||((l=o.installing)==null?void 0:l.scriptURL)||((m=o.waiting)==null?void 0:m.scriptURL);if(c&&!c.includes(`version=${Sr}`))try{await o.unregister()}catch(g){console.warn("[Service Worker] Failed to unregister stale registration",g)}}));const i=await caches.keys();await Promise.all(i.map(o=>o.includes(Sr)?Promise.resolve(!1):caches.delete(o)))};window.addEventListener("load",()=>{r().catch(n=>{console.warn("[Service Worker] Failed to clear stale registrations",n)}),iy?(ly(a,s),navigator.serviceWorker.ready.then(()=>{console.log("[Service Worker] Ready on localhost")})):Ko(a,s)})}function Ko(s,t){navigator.serviceWorker.register(s).then(a=>{a.onupdatefound=()=>{const r=a.installing;r!=null&&(r.onstatechange=()=>{var n;r.state==="installed"&&(navigator.serviceWorker.controller?(console.log("[Service Worker] New content available; please refresh."),t&&t.onUpdate?t.onUpdate(a):((n=a.waiting)==null||n.postMessage({type:"SKIP_WAITING"}),window.location.reload())):(console.log("[Service Worker] Content cached for offline use."),t&&t.onSuccess&&t.onSuccess(a)))})}}).catch(a=>{console.error("[Service Worker] Registration failed:",a)})}function ly(s,t){fetch(s,{headers:{"Service-Worker":"script"}}).then(a=>{const r=a.headers.get("content-type");a.status===404||r!=null&&r.indexOf("javascript")===-1?navigator.serviceWorker.ready.then(n=>{n.unregister()}):Ko(s,t)}).catch(()=>{console.log("[Service Worker] No internet connection found. App is running in offline mode.")})}const cy=null;qa.getState().init();j0();oy({onSuccess:s=>{Pe.info("PWA: Service worker registered",{registration:s})},onUpdate:s=>{var t;Pe.info("PWA: New service worker available",{registration:s}),window.confirm("New version available! Reload to update?")&&((t=s.waiting)==null||t.postMessage({type:"SKIP_WAITING"}),window.location.reload())}});const dy=new cl({defaultOptions:{queries:{retry:(s,t)=>t!=null&&t.status&&t.status>=400&&t.status<500?!1:s<3,retryDelay:s=>Math.min(1e3*2**s,3e4),staleTime:3e4,gcTime:600*1e3,refetchOnWindowFocus:!1,refetchOnReconnect:!0,refetchOnMount:!0,networkMode:"online"},mutations:{retry:(s,t)=>t!=null&&t.status&&t.status>=400&&t.status<500?!1:s<2,retryDelay:1e3,networkMode:"online"}}});dl.createRoot(document.getElementById("root")).render(e.jsx(h.StrictMode,{children:e.jsx(ul,{children:e.jsx(ml,{client:dy,children:e.jsxs(i0,{children:[e.jsx(ny,{}),cy]})})})}));export{_y as $,hs as A,k as B,X as C,Ms as D,Sy as E,jd as F,lo as G,nn as H,B as I,md as J,Tt as K,Yr as L,pt as M,na as N,c0 as O,er as P,Fo as Q,st as R,Iy as S,Dt as T,Qu as U,Ga as V,mx as W,Lt as X,ux as Y,dt as Z,G as _,Ty as a,zh as a$,Cy as a0,Eo as a1,oa as a2,ln as a3,E as a4,Je as a5,Qe as a6,Oy as a7,Xh as a8,Ro as a9,rt as aA,ha as aB,Xt as aC,rn as aD,ky as aE,Fr as aF,Os as aG,Xa as aH,lu as aI,Yc as aJ,Uu as aK,Ge as aL,Ks as aM,Yt as aN,ga as aO,le as aP,ua as aQ,Hh as aR,ys as aS,bs as aT,Se as aU,La as aV,Ce as aW,Gr as aX,Ny as aY,$r as aZ,Pa as a_,qe as aa,Ue as ab,Be as ac,Ve as ad,pe as ae,zo as af,Ke as ag,kt as ah,tt as ai,sr as aj,tn as ak,ma as al,Rc as am,Bh as an,Vh as ao,gs as ap,Lr as aq,As as ar,Lo as as,xn as at,$o as au,pn as av,Za as aw,Me as ax,xs as ay,jy as az,Rr as b,Le as b0,ze as b1,We as b2,_e as b3,lt as b4,Zt as b5,Ls as b6,Gt as b7,sn as b8,fs as b9,Hn as bA,io as bB,Or as bC,yy as bD,My as bE,Ry as bF,co as bG,eu as bH,_d as bI,Gh as bJ,so as bK,ct as bL,Ct as bM,ut as bN,za as bO,Nc as bP,Vn as bQ,Dc as bR,Dr as ba,Py as bb,bd as bc,Td as bd,fy as be,cx as bf,gy as bg,xy as bh,py as bi,Is as bj,ia as bk,gd as bl,no as bm,Jn as bn,Ir as bo,yr as bp,an as bq,Jd as br,nr as bs,Wh as bt,yu as bu,uo as bv,Wn as bw,mu as bx,Ru as by,ao as bz,D as c,qh as d,Po as e,Kp as f,Ap as g,Bp as h,qp as i,Rs as j,jr as k,Pe as l,Vs as m,Oo as n,J0 as o,H0 as p,me as q,W0 as r,Ay as s,G0 as t,et as u,Z0 as v,Ey as w,je as x,gu as y,Do as z}; //# sourceMappingURL=index.js.map