@astrale-os/cli 1.0.0-beta.22 → 1.0.0-beta.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/astrale.js +650 -620
- package/dist/public/connect-core.js +4 -4
- package/dist/types/admin/contract.d.ts +2 -2
- package/package.json +4 -4
- package/src/admin/contract.ts +3 -2
- package/src/commands/__tests__/read-commands.test.ts +56 -0
- package/src/commands/__tests__/view.test.ts +1 -2
- package/src/commands/introspect.ts +8 -9
- package/src/ui/.spec/architecture.md +8 -7
- package/src/ui/.spec/laws.ts +7 -0
- package/src/ui/__tests__/ui.test.ts +147 -2
- package/src/ui/operations.ts +73 -12
- package/src/ui/release.ts +9 -2
- package/studio/client/dist/assets/{index-7YHdeCxp.js → index-OeJK1TjG.js} +2 -2
- package/studio/client/dist/assets/{schema-studio-CABpTfvH.js → schema-studio-DRdfu_cQ.js} +2 -2
- package/studio/client/dist/index.html +1 -1
- package/studio/package.json +3 -3
- package/studio/server/cli-consumers.test.ts +0 -1
- package/studio/server/introspect/anatomy/views.ts +1 -2
- package/studio/server/introspect/anatomy-extras.test.ts +3 -14
- package/studio/server/introspect/canonical-schema.test.ts +1 -1
- package/studio/server/introspect/canonical-schema.ts +0 -4
- package/studio/server/introspect/diff.test.ts +10 -2
- package/studio/server/introspect/diff.ts +1 -9
- package/studio/server/introspect/runtime.test.ts +1 -1
- package/studio/server/introspect/schema-ir-json.test.ts +12 -1
- package/studio/server/introspect/schema-ir-json.ts +1 -1
- package/studio/server/views/target.test.ts +1 -2
- package/studio/shared/contracts/schema.ts +1 -3
- package/studio/tsconfig.json +2 -1
- package/viewer/dist/main.js +13 -13
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/schema-studio-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/schema-studio-DRdfu_cQ.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/schema-studio-BilUNb6Z.css"])))=>i.map(i=>d[i]);
|
|
2
2
|
import{i as e,n as t,t as n}from"./rolldown-runtime-Dd_uD5pT.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var r=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},i=new class extends r{#e;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(e=>{typeof e==`boolean`?this.setFocused(e):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e==`boolean`?this.#e:globalThis.document?.visibilityState!==`hidden`}},a={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},o=new class{#e=a;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};function s(e){setTimeout(e,0)}var c=typeof window>`u`||`Deno`in globalThis;function l(){}function u(e,t){return typeof e==`function`?e(t):e}function d(e){return typeof e==`number`&&e>=0&&e!==1/0}function f(e,t){return Math.max(e+(t||0)-Date.now(),0)}function p(e,t){return typeof e==`function`?e(t):e}function m(e,t){return typeof e==`function`?e(t):e}function h(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==_(o,t.options))return!1}else if(!y(t.queryKey,o))return!1}if(n!==`all`){let e=t.isActive();if(n===`active`&&!e||n===`inactive`&&e)return!1}return!(typeof s==`boolean`&&t.isStale()!==s||i&&i!==t.state.fetchStatus||a&&!a(t))}function g(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(v(t.options.mutationKey)!==v(a))return!1}else if(!y(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function _(e,t){return(t?.queryKeyHashFn||v)(e)}function v(e){return JSON.stringify(e,(e,t)=>w(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function y(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(e&&t&&typeof e==`object`&&typeof t==`object`){if(Array.isArray(e)&&Array.isArray(t)){for(let n=0;n<t.length;n++)if(!y(e[n],t[n]))return!1;return!0}let n=Object.keys(t);for(let r of n)if(!y(e[r],t[r]))return!1;return!0}return!1}var b=Object.prototype.hasOwnProperty;function x(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=C(e)&&C(t);if(!r&&!(w(e)&&w(t)))return t;let i=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),o=a.length,s=r?Array(o):{},c=0;for(let l=0;l<o;l++){let o=r?l:a[l],u=e[o],d=t[o];if(u===d){s[o]=u,(r?l<i:b.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=x(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function S(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function C(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function w(e){if(!T(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!T(n)||!n.hasOwnProperty(`isPrototypeOf`)||Object.getPrototypeOf(e)!==Object.prototype)}function T(e){return Object.prototype.toString.call(e)===`[object Object]`}function E(e){return new Promise(t=>{o.setTimeout(t,e)})}function ee(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:x(e,t)}function D(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function O(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var te=Symbol();function ne(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===te?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function k(e,t){return typeof e==`function`?e(...t):!!e}function A(e,t,n){let r=!1,i;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(i??=t(),r?i:(r=!0,i.aborted?n():i.addEventListener(`abort`,n,{once:!0}),i))}),e}var j=(()=>{let e=()=>c;return{isServer(){return e()},setIsServer(t){e=t}}})();function re(){let e,t,n=new Promise((n,r)=>{e=n,t=r});n.status=`pending`,n.catch(()=>{});function r(e){Object.assign(n,e),delete n.resolve,delete n.reject}return n.resolve=t=>{r({status:`fulfilled`,value:t}),e(t)},n.reject=e=>{r({status:`rejected`,reason:e}),t(e)},n}var M=s;function ie(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=M,a=r=>{t?e.push(r):i(()=>{n(r)})},o=()=>{let t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})};return{batch:e=>{let n;t++;try{n=e()}finally{t--,t||o()}return n},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}var N=ie(),ae=new class extends r{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e(!0),n=()=>e(!1);return window.addEventListener(`online`,t,!1),window.addEventListener(`offline`,n,!1),()=>{window.removeEventListener(`online`,t),window.removeEventListener(`offline`,n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#e}};function oe(e){return Math.min(1e3*2**e,3e4)}function se(e){return(e??`online`)!==`online`||ae.isOnline()}var ce=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function le(e){let t=!1,n=0,r,a=re(),o=()=>a.status!==`pending`,s=t=>{if(!o()){let n=new ce(t);p(n),e.onCancel?.(n)}},c=()=>{t=!0},l=()=>{t=!1},u=()=>i.isFocused()&&(e.networkMode===`always`||ae.isOnline())&&e.canRun(),d=()=>se(e.networkMode)&&e.canRun(),f=e=>{o()||(r?.(),a.resolve(e))},p=e=>{o()||(r?.(),a.reject(e))},m=()=>new Promise(t=>{r=e=>{(o()||u())&&t(e)},e.onPause?.()}).then(()=>{r=void 0,o()||e.onContinue?.()}),h=()=>{if(o())return;let r,i=n===0?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(f).catch(r=>{if(o())return;let i=e.retry??(j.isServer()?0:3),a=e.retryDelay??oe,s=typeof a==`function`?a(n,r):a,c=i===!0||typeof i==`number`&&n<i||typeof i==`function`&&i(n,r);if(t||!c){p(r);return}n++,e.onFail?.(n,r),E(s).then(()=>u()?void 0:m()).then(()=>{t?p(r):h()})})};return{promise:a,status:()=>a.status,cancel:s,continue:()=>(r?.(),a),cancelRetry:c,continueRetry:l,canStart:d,start:()=>(d()?h():m().then(h),a)}}var ue=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),d(this.gcTime)&&(this.#e=o.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(j.isServer()?1/0:3e5))}clearGcTimeout(){this.#e!==void 0&&(o.clearTimeout(this.#e),this.#e=void 0)}};function de(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=e=>{A(e,()=>t.signal,()=>n=!0)},u=ne(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject(t.signal.reason);if(r==null&&e.pages.length)return Promise.resolve(e);let a=(()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})(),o=await u(a),{maxPages:s}=t.options,c=i?O:D;return{pages:c(e.pages,o,s),pageParams:c(e.pageParams,r,s)}};if(i&&a.length){let e=i===`backward`,t=e?pe:fe,n={pages:a,pageParams:o};s=await d(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]??r.initialPageParam:fe(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(c<t)}return s};t.fetchFn=t.options.persister?()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):l}}}function fe(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function pe(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}var me=class extends ue{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e){super(),this.#s=!1,this.#o=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#i=e.client,this.#r=this.#i.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#t=_e(this.options),this.state=e.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#e}get promise(){return this.#a?.promise}setOptions(e){if(this.options={...this.#o,...e},e?._type&&(this.#e=e._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=_e(this.options);e.data!==void 0&&(this.setState(ge(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#r.remove(this)}setData(e,t){let n=ee(this.state.data,e,this.options);return this.#l({data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e){this.#l({type:`setState`,state:e})}cancel(e){let t=this.#a?.promise;return this.#a?.cancel(e),t?t.then(l).catch(l):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#t}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>m(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===te||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>p(e.options.staleTime,this)===`static`)}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e===`static`?!1:this.state.isInvalidated?!0:!f(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#a?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#a?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#r.notify({type:`observerAdded`,query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#a&&(this.#s||this.#c()?this.#a.cancel({revert:!0}):this.#a.cancelRetry()),this.scheduleGc()),this.#r.notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}#c(){return this.state.fetchStatus===`paused`&&this.state.status===`pending`}invalidate(){this.state.isInvalidated||this.#l({type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&this.#a?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#a)return this.#a.continueRetry(),this.#a.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,r=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(this.#s=!0,n.signal)})},i=()=>{let e=ne(this.options,t),n=(()=>{let e={client:this.#i,queryKey:this.queryKey,meta:this.meta};return r(e),e})();return this.#s=!1,this.options.persister?this.options.persister(e,n,this):e(n)},a=(()=>{let e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:i};return r(e),e})();(this.#e===`infinite`?de(this.options.pages):this.options.behavior)?.onFetch(a,this),this.#n=this.state,(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#l({type:`fetch`,meta:a.fetchOptions?.meta}),this.#a=le({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof ce&&e.revert&&this.setState({...this.#n,fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{this.#l({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#l({type:`pause`})},onContinue:()=>{this.#l({type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{let e=await this.#a.start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#r.config.onSuccess?.(e,this),this.#r.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof ce){if(e.silent)return this.#a.promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw this.#l({type:`error`,error:e}),this.#r.config.onError?.(e,this),this.#r.config.onSettled?.(this.state.data,e,this),e}finally{this.scheduleGc()}}#l(e){let t=t=>{switch(e.type){case`failed`:return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case`pause`:return{...t,fetchStatus:`paused`};case`continue`:return{...t,fetchStatus:`fetching`};case`fetch`:return{...t,...he(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...ge(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return this.#n=e.manual?n:void 0,n;case`error`:let r=e.error;return{...t,error:r,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:`idle`,status:`error`,isInvalidated:!0};case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}};this.state=t(this.state),N.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),this.#r.notify({query:this,type:`updated`,action:e})})}};function he(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:se(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function ge(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function _e(e){let t=typeof e.initialData==`function`?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt==`function`?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?`success`:`pending`,fetchStatus:`idle`}}var ve=class extends r{constructor(e,t){super(),this.options=t,this.#e=e,this.#s=null,this.#o=re(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),be(this.#t,this.options)?this.#h():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return xe(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return xe(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof m(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!S(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&Se(this.#t,n,this.options,t)&&this.#h(),this.updateResult(),r&&(this.#t!==n||m(this.options.enabled,this.#t)!==m(t.enabled,this.#t)||p(this.options.staleTime,this.#t)!==p(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||m(this.options.enabled,this.#t)!==m(t.enabled,this.#t)||i!==this.#p)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return we(this,n)&&(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),n===`promise`&&(this.trackProp(`data`),!this.options.experimental_prefetchInRender&&this.#o.status===`pending`&&this.#o.reject(Error(`experimental_prefetchInRender feature flag is not enabled`))),Reflect.get(e,n))})}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#h({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#h(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(l)),t}#g(){this.#b();let e=p(this.options.staleTime,this.#t);if(j.isServer()||this.#r.isStale||!d(e))return;let t=f(this.#r.dataUpdatedAt,e)+1;this.#d=o.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return(typeof this.options.refetchInterval==`function`?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#x(),this.#p=e,!(j.isServer()||m(this.options.enabled,this.#t)===!1||!d(this.#p)||this.#p===0)&&(this.#f=o.setInterval(()=>{(this.options.refetchIntervalInBackground||i.isFocused())&&this.#h()},this.#p))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#d!==void 0&&(o.clearTimeout(this.#d),this.#d=void 0)}#x(){this.#f!==void 0&&(o.clearInterval(this.#f),this.#f=void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,s=e===n?this.#n:e.state,{state:c}=e,l={...c},u=!1,d;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&be(e,t),o=i&&Se(e,n,t,r);(a||o)&&(l={...l,...he(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:f,errorUpdatedAt:p,status:h}=l;d=l.data;let g=!1;if(t.placeholderData!==void 0&&d===void 0&&h===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,g=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#u?.state.data,this.#u):t.placeholderData,e!==void 0&&(h=`success`,d=ee(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!g){if(i&&d===a?.data&&t.select===this.#c)d=this.#l;else try{this.#c=t.select,d=t.select(d),d=ee(i?.data,d,t),this.#l=d,this.#s=null}catch(e){this.#s=e}}this.#s&&(f=this.#s,d=this.#l,p=Date.now(),h=`error`);let _=l.fetchStatus===`fetching`,v=h===`pending`,y=h===`error`,b=v&&_,x=d!==void 0,S={status:h,fetchStatus:l.fetchStatus,isPending:v,isSuccess:h===`success`,isError:y,isInitialLoading:b,isLoading:b,data:d,dataUpdatedAt:l.dataUpdatedAt,error:f,errorUpdatedAt:p,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:l.dataUpdateCount>s.dataUpdateCount||l.errorUpdateCount>s.errorUpdateCount,isFetching:_,isRefetching:_&&!v,isLoadingError:y&&!x,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:y&&x,isStale:Ce(e,t),refetch:this.refetch,promise:this.#o,isEnabled:m(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){let t=S.data!==void 0,r=S.status===`error`&&!t,i=e=>{r?e.reject(S.error):t&&e.resolve(S.data)},a=()=>{let e=this.#o=S.promise=re();i(e)},o=this.#o;switch(o.status){case`pending`:e.queryHash===n.queryHash&&i(o);break;case`fulfilled`:(r||S.data!==o.value)&&a();break;case`rejected`:(!r||S.error!==o.reason)&&a()}}return S}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#u=this.#t),!S(t,e)&&(this.#r=t,this.#C({listeners:(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#m.size)return!0;let r=new Set(n??this.#m);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})()}))}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#C(e){N.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}};function ye(e,t){return m(t.enabled,e)!==!1&&e.state.data===void 0&&(e.state.status!==`error`||m(t.retryOnMount,e)!==!1)}function be(e,t){return ye(e,t)||e.state.data!==void 0&&xe(e,t,t.refetchOnMount)}function xe(e,t,n){if(m(t.enabled,e)!==!1&&p(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&Ce(e,t)}return!1}function Se(e,t,n,r){return(e!==t||m(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&Ce(e,n)}function Ce(e,t){return m(t.enabled,e)!==!1&&e.isStaleByTime(p(t.staleTime,e))}function we(e,t){return!S(e.getCurrentResult(),t)}var Te=class extends ue{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||Ee(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#r=le({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});let r=this.state.status===`pending`,i=!this.#r.canStart();try{if(r)t();else{this.#i({type:`pending`,variables:e,isPaused:i}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:i})}let a=await this.#r.start();return await this.#n.config.onSuccess?.(a,e,this.state.context,this,n),await this.options.onSuccess?.(a,e,this.state.context,n),await this.#n.config.onSettled?.(a,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(a,null,e,this.state.context,n),this.#i({type:`success`,data:a}),a}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#n.runNext(this)}}#i(e){let t=t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}};this.state=t(this.state),N.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function Ee(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var De=class extends r{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(e,t,n){let r=new Te({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=Oe(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=Oe(e);if(typeof t==`string`){let n=this.#t.get(t);if(n){if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=Oe(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}return!0}runNext(e){let t=Oe(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){N.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>g(t,e))}findAll(e={}){return this.getAll().filter(t=>g(e,t))}notify(e){N.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return N.batch(()=>Promise.all(e.map(e=>e.continue().catch(l))))}};function Oe(e){return e.options.scope?.id}var ke=class extends r{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),S(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&v(t.mutationKey)!==v(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??Ee();this.#t={...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset}}#a(e){N.batch(()=>{if(this.#r&&this.hasListeners()){let t=this.#t.variables,n=this.#t.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type===`success`){try{this.#r.onSuccess?.(e.data,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(e.data,null,t,n,r)}catch(e){Promise.reject(e)}}else if(e?.type===`error`){try{this.#r.onError?.(e.error,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(void 0,e.error,t,n,r)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(this.#t)})})}},Ae=class extends r{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??_(r,t),a=this.get(i);return a||(a=new me({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){N.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>h(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>h(e,t)):t}notify(e){N.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){N.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){N.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},je=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new Ae,this.#t=e.mutationCache||new De,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=i.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=ae.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(p(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=u(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return N.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;N.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return N.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=N.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(l).catch(l)}invalidateQueries(e,t={}){return N.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=N.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(l)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(l)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(p(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(l).catch(l)}fetchInfiniteQuery(e){return e._type=`infinite`,this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(l).catch(l)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return ae.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(v(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{y(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(v(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{y(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=_(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===te&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},Me=n((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.iterator;function m(e){return typeof e!=`object`||!e?null:(e=p&&e[p]||e[`@@iterator`],typeof e==`function`?e:null)}var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},g=Object.assign,_={};function v(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}v.prototype.isReactComponent={},v.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},v.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function y(){}y.prototype=v.prototype;function b(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}var x=b.prototype=new y;x.constructor=b,g(x,v.prototype),x.isPureReactComponent=!0;var S=Array.isArray;function C(){}var w={H:null,A:null,T:null,S:null},T=Object.prototype.hasOwnProperty;function E(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function ee(e,t){return E(e.type,t,e.props)}function D(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function O(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var te=/\/+/g;function ne(e,t){return typeof e==`object`&&e&&e.key!=null?O(``+e.key):t.toString(36)}function k(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(C,C):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function A(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,A(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+ne(e,0):a,S(o)?(i=``,c!=null&&(i=c.replace(te,`$&/`)+`/`),A(o,r,i,``,function(e){return e})):o!=null&&(D(o)&&(o=ee(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(te,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(S(e))for(var u=0;u<e.length;u++)a=e[u],s=l+ne(a,u),c+=A(a,r,i,s,o);else if(u=m(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+ne(a,u++),c+=A(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return A(k(e),r,i,a,o);throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`)}return c}function j(e,t,n){if(e==null)return e;var r=[],i=0;return A(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function re(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t)},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var M=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},ie={map:j,forEach:function(e,t,n){j(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return j(e,function(){t++}),t},toArray:function(e){return j(e,function(e){return e})||[]},only:function(e){if(!D(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=ie,e.Component=v,e.Fragment=r,e.Profiler=a,e.PureComponent=b,e.StrictMode=i,e.Suspense=l,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=w,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return w.H.useMemoCache(e)}},e.cache=function(e){return function(){return e.apply(null,arguments)}},e.cacheSignal=function(){return null},e.cloneElement=function(e,t,n){if(e==null)throw Error(`The argument must be a React element, but you passed `+e+`.`);var r=g({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!T.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return E(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)T.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return E(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=D,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:re}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=function(e){var t=w.T,n={};w.T=n;try{var r=e(),i=w.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(C,M)}catch(e){M(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),w.T=t}},e.unstable_useCacheRefresh=function(){return w.H.useCacheRefresh()},e.use=function(e){return w.H.use(e)},e.useActionState=function(e,t,n){return w.H.useActionState(e,t,n)},e.useCallback=function(e,t){return w.H.useCallback(e,t)},e.useContext=function(e){return w.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return w.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return w.H.useEffect(e,t)},e.useEffectEvent=function(e){return w.H.useEffectEvent(e)},e.useId=function(){return w.H.useId()},e.useImperativeHandle=function(e,t,n){return w.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return w.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return w.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return w.H.useMemo(e,t)},e.useOptimistic=function(e,t){return w.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return w.H.useReducer(e,t,n)},e.useRef=function(e){return w.H.useRef(e)},e.useState=function(e){return w.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return w.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return w.H.useTransition()},e.version=`19.2.8`})),Ne=n(((e,t)=>{t.exports=Me()})),Pe=n((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),Fe=n(((e,t)=>{t.exports=Pe()})),P=e(Ne(),1),F=Fe(),Ie=P.createContext(void 0),Le=e=>{let t=P.useContext(Ie);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},Re=({client:e,children:t})=>(P.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,F.jsx)(Ie.Provider,{value:e,children:t})),ze=P.createContext(!1),Be=()=>P.useContext(ze);ze.Provider;function Ve(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var He=P.createContext(Ve()),Ue=()=>P.useContext(He),We=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?k(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},Ge=e=>{P.useEffect(()=>{e.clearReset()},[e])},Ke=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||k(n,[e.error,r])),qe=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},Je=(e,t)=>e.isLoading&&e.isFetching&&!t,Ye=(e,t)=>e?.suspense&&t.isPending,Xe=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Ze(e,t,n){let r=Be(),i=Ue(),a=Le(n),o=a.defaultQueryOptions(e);a.getDefaultOptions().queries?._experimental_beforeQuery?.(o);let s=a.getQueryCache().get(o.queryHash),c=e.subscribed!==!1;o._optimisticResults=r?`isRestoring`:c?`optimistic`:void 0,qe(o),We(o,i,s),Ge(i);let u=!a.getQueryCache().get(o.queryHash),[d]=P.useState(()=>new t(a,o)),f=d.getOptimisticResult(o),p=!r&&c;if(P.useSyncExternalStore(P.useCallback(e=>{let t=p?d.subscribe(N.batchCalls(e)):l;return d.updateResult(),t},[d,p]),()=>d.getCurrentResult(),()=>d.getCurrentResult()),P.useEffect(()=>{d.setOptions(o)},[o,d]),Ye(o,f))throw Xe(o,d,i);if(Ke({result:f,errorResetBoundary:i,throwOnError:o.throwOnError,query:s,suspense:o.suspense}))throw f.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(o,f),o.experimental_prefetchInRender&&!j.isServer()&&Je(f,r)&&(u?Xe(o,d,i):s?.promise)?.catch(l).finally(()=>{d.updateResult()}),o.notifyOnChangeProps?f:d.trackResult(f)}function Qe(e,t){return Ze(e,ve,t)}function $e(e,t){let n=Le(t),[r]=P.useState(()=>new ke(n,e));P.useEffect(()=>{r.setOptions(e)},[r,e]);let i=P.useSyncExternalStore(P.useCallback(e=>r.subscribe(N.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=P.useCallback((e,t)=>{r.mutate(e,t).catch(l)},[r]);if(i.error&&k(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}var et=n((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,D());else{var t=n(l);t!==null&&ne(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function ee(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&ne(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}}}finally{i?D():S=!1}}}var D;if(typeof y==`function`)D=function(){y(ee)};else if(typeof MessageChannel<`u`){var O=new MessageChannel,te=O.port2;O.port1.onmessage=ee,D=function(){te.postMessage(null)}}else D=function(){_(ee,0)};function ne(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,ne(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,D()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),tt=n(((e,t)=>{t.exports=et()})),nt=n((e=>{var t=Ne();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function r(){}var i={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},a=Symbol.for(`react.portal`);function o(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}var s=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function c(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return o(e,t,null,r)},e.flushSync=function(e){var t=s.T,n=i.p;try{if(s.T=null,i.p=2,e)return e()}finally{s.T=t,i.p=n,i.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,i.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&i.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin),a=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?i.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):n===`script`&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`){if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=c(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0})}}else t??i.d.M(e)}},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`){if(t){var n=c(t.as,t.crossOrigin);i.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0})}else i.d.m(e)}},e.requestFormReset=function(e){i.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return s.H.useFormState(e,t,n)},e.useFormStatus=function(){return s.H.useHostTransitionStatus()},e.version=`19.2.8`})),rt=n(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=nt()})),it=n((e=>{var t=tt(),n=Ne(),r=rt();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function d(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=d(e),t!==null)return t;e=e.sibling}return null}var f=Object.assign,p=Symbol.for(`react.element`),m=Symbol.for(`react.transitional.element`),h=Symbol.for(`react.portal`),g=Symbol.for(`react.fragment`),_=Symbol.for(`react.strict_mode`),v=Symbol.for(`react.profiler`),y=Symbol.for(`react.consumer`),b=Symbol.for(`react.context`),x=Symbol.for(`react.forward_ref`),S=Symbol.for(`react.suspense`),C=Symbol.for(`react.suspense_list`),w=Symbol.for(`react.memo`),T=Symbol.for(`react.lazy`),E=Symbol.for(`react.activity`),ee=Symbol.for(`react.memo_cache_sentinel`),D=Symbol.iterator;function O(e){return typeof e!=`object`||!e?null:(e=D&&e[D]||e[`@@iterator`],typeof e==`function`?e:null)}var te=Symbol.for(`react.client.reference`);function ne(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===te?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case g:return`Fragment`;case v:return`Profiler`;case _:return`StrictMode`;case S:return`Suspense`;case C:return`SuspenseList`;case E:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case h:return`Portal`;case b:return e.displayName||`Context`;case y:return(e._context.displayName||`Context`)+`.Consumer`;case x:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case w:return t=e.displayName||null,t===null?ne(e.type)||`Memo`:t;case T:t=e._payload,e=e._init;try{return ne(e(t))}catch{}}return null}var k=Array.isArray,A=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,j=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,re={pending:!1,data:null,method:null,action:null},M=[],ie=-1;function N(e){return{current:e}}function ae(e){0>ie||(e.current=M[ie],M[ie]=null,ie--)}function oe(e,t){ie++,M[ie]=e.current,e.current=t}var se=N(null),ce=N(null),le=N(null),ue=N(null);function de(e,t){switch(oe(le,t),oe(ce,e),oe(se,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Vd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Vd(t),e=Hd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}ae(se),oe(se,e)}function fe(){ae(se),ae(ce),ae(le)}function pe(e){e.memoizedState!==null&&oe(ue,e);var t=se.current,n=Hd(t,e.type);t!==n&&(oe(ce,e),oe(se,n))}function me(e){ce.current===e&&(ae(se),ae(ce)),ue.current===e&&(ae(ue),Qf._currentValue=re)}var he,ge;function _e(e){if(he===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);he=t&&t[1]||``,ge=-1<e.stack.indexOf(`
|
|
3
3
|
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
4
4
|
`+he+e+ge}var ve=!1;function ye(e,t){if(!e||ve)return``;ve=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
|
|
@@ -78,4 +78,4 @@ Error generating stack: `+e.message+`
|
|
|
78
78
|
`},Mv=0,Nv=[];function Pv(e){var t=P.useRef([]),n=P.useRef([0,0]),r=P.useRef(),i=P.useState(Mv++)[0],a=P.useState(nv)[0],o=P.useRef(e);P.useEffect(function(){o.current=e},[e]),P.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=j_([e.lockRef.current],(e.shards||[]).map(kv),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add(`allow-interactivity-${i}`)}),function(){document.body.classList.remove(`block-interactivity-${i}`),t.forEach(function(e){return e.classList.remove(`allow-interactivity-${i}`)})}}},[e.inert,e.lockRef.current,e.shards]);var s=P.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=Dv(e),a=n.current,s=`deltaX`in e?e.deltaX:a[0]-i[0],c=`deltaY`in e?e.deltaY:a[1]-i[1],l,u=e.target,d=Math.abs(s)>Math.abs(c)?`h`:`v`;if(`touches`in e&&d===`h`&&u.type===`range`)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=bv(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=bv(d,u)),!m)return!1;if(!r.current&&`changedTouches`in e&&(s||c)&&(r.current=l),!l)return!0;var h=r.current||l;return Ev(h,t,e,h===`h`?s:c,!0)},[]),c=P.useCallback(function(e){var n=e;if(!(!Nv.length||Nv[Nv.length-1]!==a)){var r=`deltaY`in n?Ov(n):Dv(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&Av(e.delta,r)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var c=(o.current.shards||[]).map(kv).filter(Boolean).filter(function(e){return e.contains(n.target)});(c.length>0?s(n,c[0]):!o.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),l=P.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:Fv(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),u=P.useCallback(function(e){n.current=Dv(e),r.current=void 0},[]),d=P.useCallback(function(t){l(t.type,Ov(t),t.target,s(t,e.lockRef.current))},[]),f=P.useCallback(function(t){l(t.type,Dv(t),t.target,s(t,e.lockRef.current))},[]);P.useEffect(function(){return Nv.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,hv),document.addEventListener(`touchmove`,c,hv),document.addEventListener(`touchstart`,u,hv),function(){Nv=Nv.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,hv),document.removeEventListener(`touchmove`,c,hv),document.removeEventListener(`touchstart`,u,hv)}},[]);var p=e.removeScrollBar,m=e.inert;return P.createElement(P.Fragment,null,m?P.createElement(a,{styles:jv(i)}):null,p?P.createElement(fv,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Fv(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var Iv=G_(K_,Pv),Lv=P.forwardRef(function(e,t){return P.createElement(J_,k_({},e,{ref:t,sideCar:Iv}))});Lv.classNames=J_.classNames;var Rv=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},zv=new WeakMap,Bv=new WeakMap,Vv={},Hv=0,Uv=function(e){return e&&(e.host||Uv(e.parentNode))},Wv=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=Uv(t);return n&&e.contains(n)?n:(console.error(`aria-hidden`,t,`in not contained inside`,e,`. Doing nothing`),null)}).filter(function(e){return!!e})},Gv=function(e,t,n,r){var i=Wv(t,Array.isArray(e)?e:[e]);Vv[n]||(Vv[n]=new WeakMap);var a=Vv[n],o=[],s=new Set,c=new Set(i),l=function(e){!e||s.has(e)||(s.add(e),l(e.parentNode))};i.forEach(l);var u=function(e){!e||c.has(e)||Array.prototype.forEach.call(e.children,function(e){if(s.has(e))u(e);else try{var t=e.getAttribute(r),i=t!==null&&t!==`false`,c=(zv.get(e)||0)+1,l=(a.get(e)||0)+1;zv.set(e,c),a.set(e,l),o.push(e),c===1&&i&&Bv.set(e,!0),l===1&&e.setAttribute(n,`true`),i||e.setAttribute(r,`true`)}catch(t){console.error(`aria-hidden: cannot operate on `,e,t)}})};return u(t),s.clear(),Hv++,function(){o.forEach(function(e){var t=zv.get(e)-1,i=a.get(e)-1;zv.set(e,t),a.set(e,i),t||(Bv.has(e)||e.removeAttribute(r),Bv.delete(e)),i||e.removeAttribute(n)}),Hv--,Hv||(zv=new WeakMap,zv=new WeakMap,Bv=new WeakMap,Vv={})}},Kv=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||Rv(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),Gv(r,i,n,`aria-hidden`)):function(){return null}},qv=Object.defineProperty,Jv=(e,t)=>qv(e,`name`,{value:t,configurable:!0}),Yv=`Dialog`,[Xv,Zv]=og(Yv),[Qv,$v]=Xv(Yv),ey=Jv(e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=P.useRef(null),c=P.useRef(null),[l,u]=Sg({prop:r,defaultProp:i??!1,onChange:a,caller:Yv}),[d,f]=P.useState(0),[p,m]=P.useState(0);return(0,F.jsx)(Qv,{scope:t,triggerRef:s,contentRef:c,contentId:pg(),titleId:pg(),descriptionId:pg(),titlePresent:d>0,descriptionPresent:p>0,setTitleCount:f,setDescriptionCount:m,open:l,onOpenChange:u,onOpenToggle:P.useCallback(()=>u(e=>!e),[u]),modal:o,children:n})},`Dialog`),ty=`DialogPortal`,[ny,ry]=Xv(ty,{forceMount:void 0}),iy=Jv(e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=$v(ty,t);return(0,F.jsx)(ny,{scope:t,forceMount:n,children:P.Children.map(r,e=>(0,F.jsx)(g_,{present:n||a.open,children:(0,F.jsx)(f_,{asChild:!0,container:i,children:e})}))})},`DialogPortal`),ay=`DialogOverlay`,oy=P.forwardRef(Jv(function(e,t){let n=ry(ay,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=$v(ay,e.__scopeDialog);return a.modal?(0,F.jsx)(g_,{present:r||a.open,children:(0,F.jsx)(cy,{...i,ref:t})}):null},`DialogOverlay`)),sy=Nh(`DialogOverlay.RemoveScroll`),cy=P.forwardRef(Jv(function(e,t){let{__scopeDialog:n,...r}=e,i=$v(ay,n),a=Ah(t,Hg());return(0,F.jsx)(Lv,{as:sy,allowPinchZoom:!0,shards:[i.contentRef],children:(0,F.jsx)(kg.div,{"data-state":by(i.open),...r,ref:a,style:{pointerEvents:`auto`,...r.style}})})},`DialogOverlayImpl`)),ly=`DialogContent`,uy=P.forwardRef(Jv(function(e,t){let n=ry(ly,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=$v(ly,e.__scopeDialog);return(0,F.jsx)(g_,{present:r||a.open,children:a.modal?(0,F.jsx)(dy,{...i,ref:t}):(0,F.jsx)(fy,{...i,ref:t})})},`DialogContent`)),dy=P.forwardRef(Jv(function(e,t){let n=$v(ly,e.__scopeDialog),r=P.useRef(null),i=Ah(t,n.contentRef,r);return P.useEffect(()=>{let e=r.current;if(e)return Kv(e)},[]),(0,F.jsx)(py,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:Qh(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:Qh(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:Qh(e.onFocusOutside,e=>e.preventDefault())})},`DialogContentModal`)),fy=P.forwardRef(Jv(function(e,t){let n=$v(ly,e.__scopeDialog),r=P.useRef(!1),i=P.useRef(!1);return(0,F.jsx)(py,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})},`DialogContentNonModal`)),py=P.forwardRef(Jv(function(e,t){let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=$v(ly,n);return D_(),(0,F.jsx)(F.Fragment,{children:(0,F.jsx)($g,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,F.jsx)(Vg,{role:`dialog`,id:s.contentId,"aria-describedby":s.descriptionPresent?s.descriptionId:void 0,"aria-labelledby":s.titlePresent?s.titleId:void 0,"data-state":by(s.open),...o,ref:t,deferPointerDownOutside:!0,onDismiss:()=>s.onOpenChange(!1)})})})},`DialogContentImpl`)),my=`DialogTitle`,hy=P.forwardRef(Jv(function(e,t){let{__scopeDialog:n,...r}=e,i=$v(my,n),{setTitleCount:a}=i;return cg(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,F.jsx)(kg.h2,{id:i.titleId,...r,ref:t})},`DialogTitle`)),gy=`DialogDescription`,_y=P.forwardRef(Jv(function(e,t){let{__scopeDialog:n,...r}=e,i=$v(gy,n),{setDescriptionCount:a}=i;return cg(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,F.jsx)(kg.p,{id:i.descriptionId,...r,ref:t})},`DialogDescription`)),vy=`DialogClose`,yy=P.forwardRef(Jv(function(e,t){let{__scopeDialog:n,...r}=e,i=$v(vy,n);return(0,F.jsx)(kg.button,{type:`button`,...r,ref:t,onClick:Qh(e.onClick,()=>i.onOpenChange(!1))})},`DialogClose`));function by(e){return e?`open`:`closed`}Jv(by,`getState`);var xy=ey,Sy=iy,Cy=P.forwardRef(({className:e,...t},n)=>(0,F.jsx)(oy,{ref:n,className:K(`fixed inset-0 z-50 bg-black/60 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out`,e),...t}));Cy.displayName=`DialogOverlay`;var wy=P.forwardRef(({className:e,children:t,hideClose:n,...r},i)=>(0,F.jsxs)(Sy,{children:[(0,F.jsx)(Cy,{}),(0,F.jsxs)(uy,{ref:i,className:K(`fixed left-1/2 top-1/2 z-50 grid w-full max-w-lg -translate-x-1/2 -translate-y-1/2 gap-4 border bg-card p-5 shadow-lg rounded-xl`,e),...r,children:[t,!n&&(0,F.jsxs)(yy,{className:`absolute right-4 top-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:outline-none cursor-pointer`,children:[(0,F.jsx)(fr,{className:`h-4 w-4`}),(0,F.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]}));wy.displayName=`DialogContent`;function Ty({className:e,...t}){return(0,F.jsx)(`div`,{className:K(`flex flex-col gap-1.5`,e),...t})}function Ey({className:e,...t}){return(0,F.jsx)(`div`,{className:K(`flex justify-end gap-2`,e),...t})}var Dy=P.forwardRef(({className:e,...t},n)=>(0,F.jsx)(hy,{ref:n,className:K(`text-lg font-semibold`,e),...t}));Dy.displayName=`DialogTitle`;var Oy=P.forwardRef(({className:e,...t},n)=>(0,F.jsx)(_y,{ref:n,className:K(`text-sm text-muted-foreground`,e),...t}));Oy.displayName=`DialogDescription`;var ky=Object.defineProperty,Ay=(e,t)=>ky(e,`name`,{value:t,configurable:!0}),jy=P.createContext(void 0);function My(e){let t=P.useContext(jy);return e||t||`ltr`}Ay(My,`useDirection`);var Ny=Object.defineProperty,Py=(e,t)=>Ny(e,`name`,{value:t,configurable:!0});function Fy(e,[t,n]){return Math.min(n,Math.max(t,e))}Py(Fy,`clamp`);var Iy=Object.defineProperty,Ly=(e,t)=>Iy(e,`name`,{value:t,configurable:!0});function Ry(e,t){return P.useReducer((e,n)=>t[e][n]??e,e)}Ly(Ry,`useStateMachine`);var zy=`ScrollArea`,[By,Vy]=og(zy),[Hy,Uy]=By(zy),Wy=P.forwardRef(Ly(function(e,t){let{__scopeScrollArea:n,type:r=`hover`,dir:i,scrollHideDelay:a=600,...o}=e,[s,c]=P.useState(null),[l,u]=P.useState(null),[d,f]=P.useState(null),[p,m]=P.useState(null),[h,g]=P.useState(null),[_,v]=P.useState(0),[y,b]=P.useState(0),[x,S]=P.useState(!1),[C,w]=P.useState(!1),T=Ah(t,c),E=My(i);return(0,F.jsx)(Hy,{scope:n,type:r,dir:E,scrollHideDelay:a,scrollArea:s,viewport:l,onViewportChange:u,content:d,onContentChange:f,scrollbarX:p,onScrollbarXChange:m,scrollbarXEnabled:x,onScrollbarXEnabledChange:S,scrollbarY:h,onScrollbarYChange:g,scrollbarYEnabled:C,onScrollbarYEnabledChange:w,onCornerWidthChange:v,onCornerHeightChange:b,children:(0,F.jsx)(kg.div,{dir:E,...o,ref:T,style:{position:`relative`,"--radix-scroll-area-corner-width":_+`px`,"--radix-scroll-area-corner-height":y+`px`,...e.style}})})},`ScrollArea`)),Gy=`ScrollAreaViewport`,Ky=P.forwardRef(Ly(function(e,t){let{__scopeScrollArea:n,children:r,nonce:i,...a}=e,o=Uy(Gy,n),s=Ah(t,P.useRef(null),o.onViewportChange);return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(qy,{nonce:i}),(0,F.jsx)(kg.div,{"data-radix-scroll-area-viewport":``,...a,ref:s,style:{overflowX:o.scrollbarXEnabled?`scroll`:`hidden`,overflowY:o.scrollbarYEnabled?`scroll`:`hidden`,...e.style},children:(0,F.jsx)(`div`,{ref:o.onContentChange,style:{minWidth:`100%`,display:`table`},children:r})})]})},`ScrollAreaViewport`)),qy=P.memo(Ly(function({nonce:e}){return(0,F.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}`},nonce:e})},`ScrollAreaViewportStyle`),(e,t)=>e.nonce===t.nonce),Jy=`ScrollAreaScrollbar`,Yy=P.forwardRef(Ly(function(e,t){let{forceMount:n,...r}=e,i=Uy(Jy,e.__scopeScrollArea),{onScrollbarXEnabledChange:a,onScrollbarYEnabledChange:o}=i,s=e.orientation===`horizontal`;return P.useEffect(()=>(s?a(!0):o(!0),()=>{s?a(!1):o(!1)}),[s,a,o]),i.type===`hover`?(0,F.jsx)(Xy,{...r,ref:t,forceMount:n}):i.type===`scroll`?(0,F.jsx)(Zy,{...r,ref:t,forceMount:n}):i.type===`auto`?(0,F.jsx)(Qy,{...r,ref:t,forceMount:n}):i.type===`always`?(0,F.jsx)($y,{...r,ref:t,"data-state":`visible`}):null},`ScrollAreaScrollbar`)),Xy=P.forwardRef(Ly(function(e,t){let{forceMount:n,...r}=e,i=Uy(Jy,e.__scopeScrollArea),[a,o]=P.useState(!1);return P.useEffect(()=>{let e=i.scrollArea,t=0;if(e){let n=Ly(()=>{window.clearTimeout(t),o(!0)},`handlePointerEnter`),r=Ly(()=>{t=window.setTimeout(()=>o(!1),i.scrollHideDelay)},`handlePointerLeave`);return e.addEventListener(`pointerenter`,n),e.addEventListener(`pointerleave`,r),()=>{window.clearTimeout(t),e.removeEventListener(`pointerenter`,n),e.removeEventListener(`pointerleave`,r)}}},[i.scrollArea,i.scrollHideDelay]),(0,F.jsx)(g_,{present:n||a,children:(0,F.jsx)(Qy,{"data-state":a?`visible`:`hidden`,...r,ref:t})})},`ScrollAreaScrollbarHover`)),Zy=P.forwardRef(Ly(function(e,t){let{forceMount:n,...r}=e,i=Uy(Jy,e.__scopeScrollArea),a=e.orientation===`horizontal`,o=yb(()=>c(`SCROLL_END`),100),[s,c]=Ry(`hidden`,{hidden:{SCROLL:`scrolling`},scrolling:{SCROLL_END:`idle`,POINTER_ENTER:`interacting`},interacting:{SCROLL:`interacting`,POINTER_LEAVE:`idle`},idle:{HIDE:`hidden`,SCROLL:`scrolling`,POINTER_ENTER:`interacting`}});return P.useEffect(()=>{if(s===`idle`){let e=window.setTimeout(()=>c(`HIDE`),i.scrollHideDelay);return()=>window.clearTimeout(e)}},[s,i.scrollHideDelay,c]),P.useEffect(()=>{let e=i.viewport,t=a?`scrollLeft`:`scrollTop`;if(e){let n=e[t],r=Ly(()=>{let r=e[t];n!==r&&(c(`SCROLL`),o()),n=r},`handleScroll`);return e.addEventListener(`scroll`,r),()=>e.removeEventListener(`scroll`,r)}},[i.viewport,a,c,o]),(0,F.jsx)(g_,{present:n||s!==`hidden`,children:(0,F.jsx)($y,{"data-state":s===`hidden`?`hidden`:`visible`,...r,ref:t,onPointerEnter:Qh(e.onPointerEnter,()=>c(`POINTER_ENTER`)),onPointerLeave:Qh(e.onPointerLeave,()=>c(`POINTER_LEAVE`))})})},`ScrollAreaScrollbarScroll`)),Qy=P.forwardRef(Ly(function(e,t){let n=Uy(Jy,e.__scopeScrollArea),{forceMount:r,...i}=e,[a,o]=P.useState(!1),s=e.orientation===`horizontal`,c=yb(()=>{if(n.viewport){let e=n.viewport.offsetWidth<n.viewport.scrollWidth,t=n.viewport.offsetHeight<n.viewport.scrollHeight;o(s?e:t)}},10);return bb(n.viewport,c),bb(n.content,c),(0,F.jsx)(g_,{present:r||a,children:(0,F.jsx)($y,{"data-state":a?`visible`:`hidden`,...i,ref:t})})},`ScrollAreaScrollbarAuto`)),$y=P.forwardRef(Ly(function(e,t){let{orientation:n=`vertical`,...r}=e,i=Uy(Jy,e.__scopeScrollArea),a=P.useRef(null),o=P.useRef(0),[s,c]=P.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),l=fb(s.viewport,s.content),u={...r,sizes:s,onSizesChange:c,hasThumb:l>0&&l<1,onThumbChange:Ly(e=>a.current=e,`onThumbChange`),onThumbPointerUp:Ly(()=>o.current=0,`onThumbPointerUp`),onThumbPointerDown:Ly(e=>o.current=e,`onThumbPointerDown`)};function d(e,t){return mb(e,o.current,s,t)}return Ly(d,`getScrollPosition`),n===`horizontal`?(0,F.jsx)(eb,{...u,ref:t,onThumbPositionChange:()=>{if(i.viewport&&a.current){let e=i.viewport.scrollLeft,t=hb(e,s,i.dir);a.current.style.transform=`translate3d(${t}px, 0, 0)`}},onWheelScroll:e=>{i.viewport&&(i.viewport.scrollLeft=e)},onDragScroll:e=>{i.viewport&&(i.viewport.scrollLeft=d(e,i.dir))}}):n===`vertical`?(0,F.jsx)(tb,{...u,ref:t,onThumbPositionChange:()=>{if(i.viewport&&a.current){let e=i.viewport.scrollTop,t=hb(e,s);a.current.style.transform=`translate3d(0, ${t}px, 0)`}},onWheelScroll:e=>{i.viewport&&(i.viewport.scrollTop=e)},onDragScroll:e=>{i.viewport&&(i.viewport.scrollTop=d(e))}}):null},`ScrollAreaScrollbarVisible`)),eb=P.forwardRef(Ly(function(e,t){let{sizes:n,onSizesChange:r,...i}=e,a=Uy(Jy,e.__scopeScrollArea),[o,s]=P.useState(),c=P.useRef(null),l=Ah(t,c,a.onScrollbarXChange);return P.useEffect(()=>{c.current&&s(getComputedStyle(c.current))},[c]),(0,F.jsx)(ib,{"data-orientation":`horizontal`,...i,ref:l,sizes:n,style:{bottom:0,left:a.dir===`rtl`?`var(--radix-scroll-area-corner-width)`:0,right:a.dir===`ltr`?`var(--radix-scroll-area-corner-width)`:0,"--radix-scroll-area-thumb-width":pb(n)+`px`,...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.x),onDragScroll:t=>e.onDragScroll(t.x),onWheelScroll:(t,n)=>{if(a.viewport){let r=a.viewport.scrollLeft+t.deltaX;e.onWheelScroll(r),_b(r,n)&&t.preventDefault()}},onResize:()=>{c.current&&a.viewport&&o&&r({content:a.viewport.scrollWidth,viewport:a.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:db(o.paddingLeft),paddingEnd:db(o.paddingRight)}})}})},`ScrollAreaScrollbarX`)),tb=P.forwardRef(Ly(function(e,t){let{sizes:n,onSizesChange:r,...i}=e,a=Uy(Jy,e.__scopeScrollArea),[o,s]=P.useState(),c=P.useRef(null),l=Ah(t,c,a.onScrollbarYChange);return P.useEffect(()=>{c.current&&s(getComputedStyle(c.current))},[c]),(0,F.jsx)(ib,{"data-orientation":`vertical`,...i,ref:l,sizes:n,style:{top:0,right:a.dir===`ltr`?0:void 0,left:a.dir===`rtl`?0:void 0,bottom:`var(--radix-scroll-area-corner-height)`,"--radix-scroll-area-thumb-height":pb(n)+`px`,...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.y),onDragScroll:t=>e.onDragScroll(t.y),onWheelScroll:(t,n)=>{if(a.viewport){let r=a.viewport.scrollTop+t.deltaY;e.onWheelScroll(r),_b(r,n)&&t.preventDefault()}},onResize:()=>{c.current&&a.viewport&&o&&r({content:a.viewport.scrollHeight,viewport:a.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:db(o.paddingTop),paddingEnd:db(o.paddingBottom)}})}})},`ScrollAreaScrollbarY`)),[nb,rb]=By(Jy),ib=P.forwardRef(Ly(function(e,t){let{__scopeScrollArea:n,sizes:r,hasThumb:i,onThumbChange:a,onThumbPointerUp:o,onThumbPointerDown:s,onThumbPositionChange:c,onDragScroll:l,onWheelScroll:u,onResize:d,...f}=e,p=Uy(Jy,n),[m,h]=P.useState(null),g=Ah(t,h),_=P.useRef(null),v=P.useRef(``),y=p.viewport,b=r.content-r.viewport,x=Ng(u),S=Ng(c),C=yb(d,10);function w(e){if(_.current){let t=e.clientX-_.current.left,n=e.clientY-_.current.top;l({x:t,y:n})}}return Ly(w,`handleDragScroll`),P.useEffect(()=>{let e=Ly(e=>{let t=e.target;m?.contains(t)&&x(e,b)},`handleWheel`);return document.addEventListener(`wheel`,e,{passive:!1}),()=>document.removeEventListener(`wheel`,e,{passive:!1})},[y,m,b,x]),P.useEffect(S,[r,S]),bb(m,C),bb(p.content,C),(0,F.jsx)(nb,{scope:n,scrollbar:m,hasThumb:i,onThumbChange:Ng(a),onThumbPointerUp:Ng(o),onThumbPositionChange:S,onThumbPointerDown:Ng(s),children:(0,F.jsx)(kg.div,{...f,ref:g,style:{position:`absolute`,...f.style},onPointerDown:Qh(e.onPointerDown,e=>{e.button===0&&(e.target.setPointerCapture(e.pointerId),_.current=m.getBoundingClientRect(),v.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect=`none`,p.viewport&&(p.viewport.style.scrollBehavior=`auto`),w(e))}),onPointerMove:Qh(e.onPointerMove,w),onPointerUp:Qh(e.onPointerUp,e=>{let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),document.body.style.webkitUserSelect=v.current,p.viewport&&(p.viewport.style.scrollBehavior=``),_.current=null})})})},`ScrollAreaScrollbarImpl`)),ab=`ScrollAreaThumb`,ob=P.forwardRef(Ly(function(e,t){let{forceMount:n,...r}=e,i=rb(ab,e.__scopeScrollArea);return(0,F.jsx)(g_,{present:n||i.hasThumb,children:(0,F.jsx)(sb,{ref:t,...r})})},`ScrollAreaThumb`)),sb=P.forwardRef(Ly(function(e,t){let{__scopeScrollArea:n,style:r,...i}=e,a=Uy(ab,n),o=rb(ab,n),{onThumbPositionChange:s}=o,c=Ah(t,o.onThumbChange),l=P.useRef(void 0),u=yb(()=>{l.current&&=(l.current(),void 0)},100);return P.useEffect(()=>{let e=a.viewport;if(e){let t=Ly(()=>{if(u(),!l.current){let t=vb(e,s);l.current=t,s()}},`handleScroll`);return s(),e.addEventListener(`scroll`,t),()=>e.removeEventListener(`scroll`,t)}},[a.viewport,u,s]),(0,F.jsx)(kg.div,{"data-state":o.hasThumb?`visible`:`hidden`,...i,ref:c,style:{width:`var(--radix-scroll-area-thumb-width)`,height:`var(--radix-scroll-area-thumb-height)`,...r},onPointerDownCapture:Qh(e.onPointerDownCapture,e=>{let t=e.target.getBoundingClientRect(),n=e.clientX-t.left,r=e.clientY-t.top;o.onThumbPointerDown({x:n,y:r})}),onPointerUp:Qh(e.onPointerUp,o.onThumbPointerUp)})},`ScrollAreaThumbImpl`)),cb=`ScrollAreaCorner`,lb=P.forwardRef(Ly(function(e,t){let n=Uy(cb,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!==`scroll`&&r?(0,F.jsx)(ub,{...e,ref:t}):null},`ScrollAreaCorner`)),ub=P.forwardRef(Ly(function(e,t){let{__scopeScrollArea:n,...r}=e,i=Uy(cb,n),[a,o]=P.useState(0),[s,c]=P.useState(0),l=!!(a&&s),{onCornerWidthChange:u,onCornerHeightChange:d}=i;return bb(i.scrollbarX,()=>{let e=i.scrollbarX?.offsetHeight||0;i.onCornerHeightChange(e),c(e)}),bb(i.scrollbarY,()=>{let e=i.scrollbarY?.offsetWidth||0;i.onCornerWidthChange(e),o(e)}),P.useEffect(()=>()=>{u(0),d(0)},[u,d]),l?(0,F.jsx)(kg.div,{...r,ref:t,style:{width:a,height:s,position:`absolute`,right:i.dir===`ltr`?0:void 0,left:i.dir===`rtl`?0:void 0,bottom:0,...e.style}}):null},`ScrollAreaCornerImpl`));function db(e){return e?parseInt(e,10):0}Ly(db,`toInt`);function fb(e,t){let n=e/t;return isNaN(n)?0:n}Ly(fb,`getThumbRatio`);function pb(e){let t=fb(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}Ly(pb,`getThumbSize`);function mb(e,t,n,r=`ltr`){let i=pb(n),a=i/2,o=t||a,s=i-o,c=n.scrollbar.paddingStart+o,l=n.scrollbar.size-n.scrollbar.paddingEnd-s,u=n.content-n.viewport,d=r===`ltr`?[0,u]:[u*-1,0];return gb([c,l],d)(e)}Ly(mb,`getScrollPositionFromPointer`);function hb(e,t,n=`ltr`){let r=pb(t),i=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,a=t.scrollbar.size-i,o=t.content-t.viewport,s=a-r,c=Fy(e,n===`ltr`?[0,o]:[o*-1,0]);return gb([0,o],[0,s])(c)}Ly(hb,`getThumbOffsetFromScroll`);function gb(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];let r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}Ly(gb,`linearScale`);function _b(e,t){return e>0&&e<t}Ly(_b,`isScrollingWithinScrollbarBounds`);var vb=Ly((e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return Ly((function i(){let a={left:e.scrollLeft,top:e.scrollTop},o=n.left!==a.left,s=n.top!==a.top;(o||s)&&t(),n=a,r=window.requestAnimationFrame(i)}),`loop`)(),()=>window.cancelAnimationFrame(r)},`addUnlinkedScrollListener`);function yb(e,t){let n=Ng(e),r=P.useRef(0);return P.useEffect(()=>()=>window.clearTimeout(r.current),[]),P.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}Ly(yb,`useDebounceCallback`);function bb(e,t){let n=Ng(t);cg(()=>{let t=0;if(e){let r=new ResizeObserver(()=>{cancelAnimationFrame(t),t=window.requestAnimationFrame(n)});return r.observe(e),()=>{window.cancelAnimationFrame(t),r.unobserve(e)}}},[e,n])}Ly(bb,`useResizeObserver`);var xb=Wy,Sb=Ky,Cb=Yy,wb=ob,Tb=lb,Eb=Object.defineProperty,Db=(e,t)=>Eb(e,`name`,{value:t,configurable:!0}),Ob=`horizontal`,kb=[`horizontal`,`vertical`],Ab=P.forwardRef(Db(function(e,t){let{decorative:n,orientation:r=Ob,...i}=e,a=jb(r)?r:Ob,o=n?{role:`none`}:{"aria-orientation":a===`vertical`?a:void 0,role:`separator`};return(0,F.jsx)(kg.div,{"data-orientation":a,...o,...i,ref:t})},`Separator`));function jb(e){return kb.includes(e)}Db(jb,`isValidOrientation`);var Mb=Ab,Nb=[`top`,`right`,`bottom`,`left`],Pb=Math.min,Fb=Math.max,Ib=Math.round,Lb=Math.floor,Rb=e=>({x:e,y:e}),zb={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function Bb(e,t,n){return Fb(e,Pb(t,n))}function Vb(e,t){return typeof e==`function`?e(t):e}function Hb(e){return e.split(`-`)[0]}function Ub(e){return e.split(`-`)[1]}function Wb(e){return e===`x`?`y`:`x`}function Gb(e){return e===`y`?`height`:`width`}function Kb(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function qb(e){return Wb(Kb(e))}function Jb(e,t,n){n===void 0&&(n=!1);let r=Ub(e),i=qb(e),a=Gb(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=rx(o)),[o,rx(o)]}function Yb(e){let t=rx(e);return[Xb(e),t,Xb(t)]}function Xb(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var Zb=[`left`,`right`],Qb=[`right`,`left`],$b=[`top`,`bottom`],ex=[`bottom`,`top`];function tx(e,t,n){switch(e){case`top`:case`bottom`:return n?t?Qb:Zb:t?Zb:Qb;case`left`:case`right`:return t?$b:ex;default:return[]}}function nx(e,t,n,r){let i=Ub(e),a=tx(Hb(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(Xb)))),a}function rx(e){let t=Hb(e);return zb[t]+e.slice(t.length)}function ix(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function ax(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:ix(e)}function ox(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function sx(e,t,n){let{reference:r,floating:i}=e,a=Kb(t),o=qb(t),s=Gb(o),c=Hb(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}let m=Ub(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function cx(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=Vb(t,e),p=ax(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=ox(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=ox(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var lx=50,ux=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:cx},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=sx(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<lx&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=sx(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},dx=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=Vb(e,t)||{};if(l==null)return{};let d=ax(u),f={x:n,y:r},p=qb(i),m=Gb(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),C=S?S[y]:0;(!C||!await(o.isElement==null?void 0:o.isElement(S)))&&(C=s.floating[y]||a.floating[m]);let w=b/2-x/2,T=C/2-h[m]/2-1,E=Pb(d[_],T),ee=Pb(d[v],T),D=C-h[m]-ee,O=C/2-h[m]/2+w,te=Bb(E,O,D),ne=!c.arrow&&Ub(i)!=null&&O!==te&&a.reference[m]/2-(O<E?E:ee)-h[m]/2<0,k=ne?O<E?O-E:O-D:0;return{[p]:f[p]+k,data:{[p]:te,centerOffset:O-te-k,...ne&&{alignmentOffset:k}},reset:ne}}}),fx=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=Vb(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=Hb(r),_=Kb(o),v=Hb(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[rx(o)]:Yb(o)),x=p!==`none`;!d&&x&&b.push(...nx(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=Jb(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(u!==`alignment`||_===Kb(t)||T.every(e=>Kb(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=Kb(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o}if(r!==n)return{reset:{placement:n}}}return{}}}};function px(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function mx(e){return Nb.some(t=>e[t]>=0)}var hx=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=Vb(e,t);switch(i){case`referenceHidden`:{let e=px(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:mx(e)}}}case`escaped`:{let e=px(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:mx(e)}}}default:return{}}}}},gx=new Set([`left`,`top`]);async function _x(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=Hb(n),s=Ub(n),c=Kb(n)===`y`,l=gx.has(o)?-1:1,u=a&&c?-1:1,d=Vb(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var vx=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await _x(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},yx=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=Vb(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=Kb(i),p=Wb(f),m=u[p],h=u[f],g=(e,t)=>Bb(t+d[e===`y`?`top`:`left`],t,t-d[e===`y`?`bottom`:`right`]);o&&(m=g(p,m)),s&&(h=g(f,h));let _=c.fn({...t,[p]:m,[f]:h});return{..._,data:{x:_.x-n,y:_.y-r,enabled:{[p]:o,[f]:s}}}}}},bx=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=Vb(e,t),u={x:n,y:r},d=Kb(i),f=Wb(d),p=u[f],m=u[d],h=Vb(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:h.mainAxis??0,crossAxis:h.crossAxis??0};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=gx.has(Hb(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},xx=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){let{placement:n,rects:r,platform:i,elements:a}=t,{apply:o=()=>{},...s}=Vb(e,t),c=await i.detectOverflow(t,s),l=Hb(n),u=Ub(n),d=Kb(n)===`y`,{width:f,height:p}=r.floating,m,h;l===`top`||l===`bottom`?(m=l,h=u===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?`start`:`end`)?`left`:`right`):(h=l,m=u===`end`?`top`:`bottom`);let g=p-c.top-c.bottom,_=f-c.left-c.right,v=Pb(p-c[m],g),y=Pb(f-c[h],_),b=t.middlewareData.shift,x=!b,S=v,C=y;b!=null&&b.enabled.x&&(C=_),b!=null&&b.enabled.y&&(S=g),x&&!u&&(d?C=f-2*Fb(c.left,c.right):S=p-2*Fb(c.top,c.bottom)),await o({...t,availableWidth:C,availableHeight:S});let w=await i.getDimensions(a.floating);return f!==w.width||p!==w.height?{reset:{rects:!0}}:{}}}};function Sx(){return typeof window<`u`}function Cx(e){return Ex(e)?(e.nodeName||``).toLowerCase():`#document`}function wx(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Tx(e){return((Ex(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function Ex(e){return Sx()?e instanceof Node||e instanceof wx(e).Node:!1}function Dx(e){return Sx()?e instanceof Element||e instanceof wx(e).Element:!1}function Ox(e){return Sx()?e instanceof HTMLElement||e instanceof wx(e).HTMLElement:!1}function kx(e){return!Sx()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof wx(e).ShadowRoot}function Ax(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=Vx(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function jx(e){return/^(table|td|th)$/.test(Cx(e))}function Mx(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var Nx=/transform|translate|scale|rotate|perspective|filter/,Px=/paint|layout|strict|content/,Fx=e=>!!e&&e!==`none`,Ix;function Lx(e){let t=Dx(e)?Vx(e):e;return Fx(t.transform)||Fx(t.translate)||Fx(t.scale)||Fx(t.rotate)||Fx(t.perspective)||!zx()&&(Fx(t.backdropFilter)||Fx(t.filter))||Nx.test(t.willChange||``)||Px.test(t.contain||``)}function Rx(e){let t=Ux(e);for(;Ox(t)&&!Bx(t);){if(Lx(t))return t;if(Mx(t))return null;t=Ux(t)}return null}function zx(){return Ix??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),Ix}function Bx(e){return/^(html|body|#document)$/.test(Cx(e))}function Vx(e){return wx(e).getComputedStyle(e)}function Hx(e){return Dx(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Ux(e){if(Cx(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||kx(e)&&e.host||Tx(e);return kx(t)?t.host:t}function Wx(e){let t=Ux(e);return Bx(t)?(e.ownerDocument||e).body:Ox(t)&&Ax(t)?t:Wx(t)}function Gx(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=Wx(e),i=r===e.ownerDocument?.body,a=wx(r);if(i){let e=Kx(a);return t.concat(a,a.visualViewport||[],Ax(r)?r:[],e&&n?Gx(e):[])}return t.concat(r,Gx(r,[],n))}function Kx(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function qx(e){let t=Vx(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=Ox(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=Ib(n)!==a||Ib(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function Jx(e){return Dx(e)?e:e.contextElement}function Yx(e){let t=Jx(e);if(!Ox(t))return Rb(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=qx(t),o=(a?Ib(n.width):n.width)/r,s=(a?Ib(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var Xx=Rb(0);function Zx(e){let t=wx(e);return!zx()||!t.visualViewport?Xx:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Qx(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===wx(e)}function $x(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=Jx(e),o=Rb(1);t&&(r?Dx(r)&&(o=Yx(r)):o=Yx(e));let s=Qx(a,n,r)?Zx(a):Rb(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a&&r){let e=wx(a),t=Dx(r)?wx(r):r,n=e,i=Kx(n);for(;i&&t!==n;){let e=Yx(i),t=i.getBoundingClientRect(),r=Vx(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=wx(i),i=Kx(n)}}return ox({width:u,height:d,x:c,y:l})}function eS(e,t){let n=Hx(e).scrollLeft;return t?t.left+n:$x(Tx(e)).left+n}function tS(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-eS(e,n),y:n.top+t.scrollTop}}function nS(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=Tx(r),s=t?Mx(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=Rb(1),u=Rb(0),d=Ox(r);if((d||!a)&&((Cx(r)!==`body`||Ax(o))&&(c=Hx(r)),d)){let e=$x(r);l=Yx(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?tS(o,c):Rb(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function rS(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function iS(e){let t=Hx(e),n=e.ownerDocument.body,r=Fb(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=Fb(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+eS(e),o=-t.scrollTop;return Vx(n).direction===`rtl`&&(a+=Fb(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var aS=25;function oS(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=wx(e),a=Tx(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!zx()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(eS(a)<=0){let e=a.ownerDocument,t=e.body,n=getComputedStyle(t),r=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,i=Math.abs(a.clientWidth-t.clientWidth-r),o=getComputedStyle(a).scrollbarGutter===`stable both-edges`?i/2:i;o<=aS&&(s-=o)}return{width:s,height:c,x:l,y:u}}function sS(e,t){let n=$x(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=Yx(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function cS(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=oS(e,n,t);else if(t===`document`)r=iS(Tx(e));else if(Dx(t))r=sS(t,n);else{let n=Zx(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return ox(r)}function lS(e,t){let n=t.get(e);if(n)return n;let r=Gx(e,[],!1).filter(e=>Dx(e)&&Cx(e)!==`body`),i=null,a=Vx(e).position===`fixed`,o=a?Ux(e):e;for(;Dx(o)&&!Bx(o);){let e=Vx(o),t=Lx(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=Ux(o)}return t.set(e,r),r}function uS(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?Mx(t)?[]:lS(t,this._c):[].concat(n),r],o=cS(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=cS(t,a[e],i);s=Fb(n.top,s),c=Pb(n.right,c),l=Pb(n.bottom,l),u=Fb(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function dS(e){let{width:t,height:n}=qx(e);return{width:t,height:n}}function fS(e,t,n){let r=Ox(t),i=Tx(t),a=n===`fixed`,o=$x(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=Rb(0);if((r||!a)&&((Cx(t)!==`body`||Ax(i))&&(s=Hx(t)),r)){let e=$x(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=eS(i));let l=i&&!r&&!a?tS(i,s):Rb(0);return{x:o.left+s.scrollLeft-c.x-l.x,y:o.top+s.scrollTop-c.y-l.y,width:o.width,height:o.height}}function pS(e){return Vx(e).position===`static`}function mS(e,t){if(!Ox(e)||Vx(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return Tx(e)===n&&(n=n.ownerDocument.body),n}function hS(e,t){let n=wx(e);if(Mx(e))return n;if(!Ox(e)){let t=Ux(e);for(;t&&!Bx(t);){if(Dx(t)&&!pS(t))return t;t=Ux(t)}return n}let r=mS(e,t);for(;r&&jx(r)&&pS(r);)r=mS(r,t);return r&&Bx(r)&&pS(r)&&!Lx(r)?n:r||Rx(e)||n}var gS=async function(e){let t=this.getOffsetParent||hS,n=this.getDimensions,r=await n(e.floating);return{reference:fS(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function _S(e){return Vx(e).direction===`rtl`}var vS={convertOffsetParentRelativeRectToViewportRelativeRect:nS,getDocumentElement:Tx,getClippingRect:uS,getOffsetParent:hS,getElementRects:gS,getClientRects:rS,getDimensions:dS,getScale:Yx,isElement:Dx,isRTL:_S};function yS(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function bS(e,t,n){let r=null,i,a=Tx(e);function o(){var e;clearTimeout(i),(e=r)==null||e.disconnect(),r=null}function s(n,c){n===void 0&&(n=!1),c===void 0&&(c=1),o();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(n||t(),!f||!p)return;let m=Lb(d),h=Lb(a.clientWidth-(u+f)),g=Lb(a.clientHeight-(d+p)),_=Lb(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:Fb(0,Pb(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(!yS(l,e.getBoundingClientRect()))return s();if(n!==c){if(!y)return s();n?s(!1,n):i=setTimeout(()=>{s(!1,1e-7)},1e3)}y=!1}try{r=new IntersectionObserver(b,{...v,root:a.ownerDocument})}catch{r=new IntersectionObserver(b,v)}r.observe(e)}let c=wx(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function xS(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=Jx(e),u=i||a?[...l?Gx(l):[],...t?Gx(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?bS(l,n,a):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?$x(e):null;c&&g();function g(){let t=$x(e);h&&!yS(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var SS=vx,CS=yx,wS=fx,TS=xx,ES=hx,DS=dx,OS=bx,kS=(e,t,n)=>{let r=new Map,i=n??{},a={...vS,...i.platform,_c:r};return ux(e,t,{...i,platform:a})},AS=typeof document<`u`?P.useLayoutEffect:function(){};function jS(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!jS(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!jS(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function MS(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function NS(e,t){let n=MS(e);return Math.round(t*n)/n}function PS(e){let t=P.useRef(e);return AS(()=>{t.current=e}),t}function FS(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=P.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=P.useState(r);jS(f,r)||p(r);let[m,h]=P.useState(null),[g,_]=P.useState(null),v=P.useCallback(e=>{e!==S.current&&(S.current=e,h(e))},[]),y=P.useCallback(e=>{e!==C.current&&(C.current=e,_(e))},[]),b=a||m,x=o||g,S=P.useRef(null),C=P.useRef(null),w=P.useRef(u),T=c!=null,E=PS(c),ee=PS(i),D=PS(l),O=P.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};ee.current&&(e.platform=ee.current),kS(S.current,C.current,e).then(e=>{let t={...e,isPositioned:D.current!==!1};te.current&&!jS(w.current,t)&&(w.current=t,ot.flushSync(()=>{d(t)}))})},[f,t,n,ee,D]);AS(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let te=P.useRef(!1);AS(()=>(te.current=!0,()=>{te.current=!1}),[]),AS(()=>{if(b&&(S.current=b),x&&(C.current=x),b&&x){if(E.current)return E.current(b,x,O);O()}},[b,x,O,E,T]);let ne=P.useMemo(()=>({reference:S,floating:C,setReference:v,setFloating:y}),[v,y]),k=P.useMemo(()=>({reference:b,floating:x}),[b,x]),A=P.useMemo(()=>{let e={position:n,left:0,top:0};if(!k.floating)return e;let t=NS(k.floating,u.x),r=NS(k.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...MS(k.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,k.floating,u.x,u.y]);return P.useMemo(()=>({...u,update:O,refs:ne,elements:k,floatingStyles:A}),[u,O,ne,k,A])}var IS=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:DS({element:r.current,padding:i}).fn(n):r?DS({element:r,padding:i}).fn(n):{}}}},LS=(e,t)=>{let n=SS(e);return{name:n.name,fn:n.fn,options:[e,t]}},RS=(e,t)=>{let n=CS(e);return{name:n.name,fn:n.fn,options:[e,t]}},zS=(e,t)=>({fn:OS(e).fn,options:[e,t]}),BS=(e,t)=>{let n=wS(e);return{name:n.name,fn:n.fn,options:[e,t]}},VS=(e,t)=>{let n=TS(e);return{name:n.name,fn:n.fn,options:[e,t]}},HS=(e,t)=>{let n=ES(e);return{name:n.name,fn:n.fn,options:[e,t]}},US=(e,t)=>{let n=IS(e);return{name:n.name,fn:n.fn,options:[e,t]}},WS=Object.defineProperty,GS=(e,t)=>WS(e,`name`,{value:t,configurable:!0});function KS(e){let[t,n]=P.useState(void 0);return cg(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}n(void 0)},[e]),t}GS(KS,`useSize`);var qS=Object.defineProperty,JS=(e,t)=>qS(e,`name`,{value:t,configurable:!0}),YS=`Popper`,[XS,ZS]=og(YS),[QS,$S]=XS(YS),eC=JS(e=>{let{__scopePopper:t,children:n}=e,[r,i]=P.useState(null),[a,o]=P.useState(void 0);return(0,F.jsx)(QS,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})},`Popper`),tC=`PopperAnchor`,nC=P.forwardRef(JS(function(e,t){let{__scopePopper:n,virtualRef:r,...i}=e,a=$S(tC,n),o=P.useRef(null),s=a.onAnchorChange,c=Ah(t,P.useCallback(e=>{o.current=e,e&&s(e)},[s])),l=P.useRef(null);P.useEffect(()=>{if(!r)return;let e=l.current;l.current=r.current,e!==l.current&&s(l.current)});let u=a.placementState&&lC(a.placementState),d=u?.[0],f=u?.[1];return r?null:(0,F.jsx)(kg.div,{"data-radix-popper-side":d,"data-radix-popper-align":f,...i,ref:c})},`PopperAnchor`)),rC=`PopperContent`,[iC,aC]=XS(rC),oC=P.forwardRef(JS(function(e,t){let{__scopePopper:n,side:r=`bottom`,sideOffset:i=0,align:a=`center`,alignOffset:o=0,arrowPadding:s=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:u=0,sticky:d=`partial`,hideWhenDetached:f=!1,updatePositionStrategy:p=`optimized`,onPlaced:m,...h}=e,g=$S(rC,n),[_,v]=P.useState(null),y=Ah(t,v),[b,x]=P.useState(null),S=KS(b),C=S?.width??0,w=S?.height??0,T=r+(a===`center`?``:`-`+a),E=typeof u==`number`?u:{top:0,right:0,bottom:0,left:0,...u},ee=Array.isArray(l)?l:[l],D=ee.length>0,O={padding:E,boundary:ee.filter(sC),altBoundary:D},{refs:te,floatingStyles:ne,placement:k,isPositioned:A,middlewareData:j}=FS({strategy:`fixed`,placement:T,whileElementsMounted:JS((...e)=>xS(...e,{animationFrame:p===`always`}),`whileElementsMounted`),elements:{reference:g.anchor},middleware:[LS({mainAxis:i+w,alignmentAxis:o}),c&&RS({mainAxis:!0,crossAxis:!1,limiter:d===`partial`?zS():void 0,...O}),c&&BS({...O}),VS({...O,apply:JS(({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)},`apply`)}),b&&US({element:b,padding:s}),cC({arrowWidth:C,arrowHeight:w}),f&&HS({strategy:`referenceHidden`,...O,boundary:D?O.boundary:void 0})]}),re=g.setPlacementState;cg(()=>(re(k),()=>{re(void 0)}),[k,re]);let[M,ie]=lC(k),N=Ng(m);cg(()=>{A&&N?.()},[A,N]);let ae=j.arrow?.x,oe=j.arrow?.y,se=j.arrow?.centerOffset!==0,[ce,le]=P.useState();return cg(()=>{_&&le(window.getComputedStyle(_).zIndex)},[_]),(0,F.jsx)(`div`,{ref:te.setFloating,"data-radix-popper-content-wrapper":``,style:{...ne,transform:A?ne.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:ce,"--radix-popper-transform-origin":[j.transformOrigin?.x,j.transformOrigin?.y].join(` `),...j.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,F.jsx)(iC,{scope:n,placedSide:M,placedAlign:ie,onArrowChange:x,arrowX:ae,arrowY:oe,shouldHideArrow:se,children:(0,F.jsx)(kg.div,{"data-side":M,"data-align":ie,...h,ref:y,style:{...h.style,animation:A?h.style?.animation:`none`}})})})},`PopperContent`));function sC(e){return e!==null}JS(sC,`isNotNull`);var cC=JS(e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=lC(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}}),`transformOrigin`);function lC(e){let[t,n=`center`]=e.split(`-`);return[t,n]}JS(lC,`getSideAndAlignFromPlacement`);var uC=eC,dC=nC,fC=oC,pC=Object.defineProperty,mC=(e,t)=>pC(e,`name`,{value:t,configurable:!0}),hC=Object.freeze({position:`absolute`,border:0,width:1,height:1,padding:0,margin:-1,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,wordWrap:`normal`}),gC=P.forwardRef(mC(function(e,t){return(0,F.jsx)(kg.span,{...e,ref:t,style:{...hC,...e.style}})},`VisuallyHidden`)),_C=Object.defineProperty,vC=(e,t)=>_C(e,`name`,{value:t,configurable:!0}),[yC,bC]=og(`Tooltip`,[ZS]),xC=ZS(),SC=`TooltipProvider`,CC=700,wC=`tooltip.open`,[TC,EC]=yC(SC),DC=vC(e=>{let{__scopeTooltip:t,delayDuration:n=CC,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=P.useRef(!0),s=P.useRef(!1),c=P.useRef(0);return P.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,F.jsx)(TC,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:P.useCallback(()=>{r<=0||(window.clearTimeout(c.current),o.current=!1)},[r]),onClose:P.useCallback(()=>{r<=0||(window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r))},[r]),isPointerInTransitRef:s,onPointerInTransitChange:P.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})},`TooltipProvider`),OC=`Tooltip`,[kC,AC]=yC(OC),jC=vC(e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=EC(OC,e.__scopeTooltip),l=xC(t),[u,d]=P.useState(null),[f,p]=P.useState(void 0),m=pg(),h=P.useRef(0),g=o??c.disableHoverableContent,_=s??c.delayDuration,v=P.useRef(!1),[y,b]=Sg({prop:r,defaultProp:i??!1,onChange:vC(e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(wC))):c.onClose(),a?.(e)},`onChange`),caller:OC}),x=P.useMemo(()=>y?v.current?`delayed-open`:`instant-open`:`closed`,[y]),S=P.useCallback(()=>{window.clearTimeout(h.current),h.current=0,v.current=!1,b(!0)},[b]),C=P.useCallback(()=>{window.clearTimeout(h.current),h.current=0,b(!1)},[b]),w=P.useCallback(()=>{window.clearTimeout(h.current),h.current=window.setTimeout(()=>{v.current=!0,b(!0),h.current=0},_)},[_,b]);P.useEffect(()=>()=>{h.current&&=(window.clearTimeout(h.current),0)},[]);let T=f??m;return(0,F.jsx)(uC,{...l,children:(0,F.jsx)(kC,{scope:t,contentId:T,setContentId:p,open:y,stateAttribute:x,trigger:u,onTriggerChange:d,onTriggerEnter:P.useCallback(()=>{c.isOpenDelayedRef.current?w():S()},[c.isOpenDelayedRef,w,S]),onTriggerLeave:P.useCallback(()=>{g?C():(window.clearTimeout(h.current),h.current=0)},[C,g]),onOpen:S,onClose:C,disableHoverableContent:g,children:n})})},`Tooltip`),MC=`TooltipTrigger`,NC=P.forwardRef(vC(function(e,t){let{__scopeTooltip:n,...r}=e,i=AC(MC,n),a=EC(MC,n),o=xC(n),s=Ah(t,P.useRef(null),i.onTriggerChange),c=P.useRef(!1),l=P.useRef(!1),u=P.useCallback(()=>c.current=!1,[]);return P.useEffect(()=>()=>document.removeEventListener(`pointerup`,u),[u]),(0,F.jsx)(dC,{asChild:!0,...o,children:(0,F.jsx)(kg.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:Qh(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:Qh(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:Qh(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:Qh(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:Qh(e.onBlur,i.onClose),onClick:Qh(e.onClick,i.onClose)})})},`TooltipTrigger`)),PC=`TooltipPortal`,[FC,IC]=yC(PC,{forceMount:void 0}),LC=vC(e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=AC(PC,t);return(0,F.jsx)(FC,{scope:t,forceMount:n,children:(0,F.jsx)(g_,{present:n||a.open,children:(0,F.jsx)(f_,{asChild:!0,container:i,children:r})})})},`TooltipPortal`),RC=`TooltipContent`,zC=P.forwardRef(vC(function(e,t){let n=IC(RC,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=AC(RC,e.__scopeTooltip);return(0,F.jsx)(g_,{present:r||o.open,children:o.disableHoverableContent?(0,F.jsx)(HC,{side:i,...a,ref:t}):(0,F.jsx)(BC,{side:i,...a,ref:t})})},`TooltipContent`)),BC=P.forwardRef(vC(function(e,t){let n=AC(RC,e.__scopeTooltip),r=EC(RC,e.__scopeTooltip),i=P.useRef(null),a=Ah(t,i),[o,s]=P.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:d}=r,f=P.useCallback(()=>{s(null),d(!1)},[d]),p=P.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=WC(r,UC(r,n.getBoundingClientRect())),a=GC(t.getBoundingClientRect()),o=qC([...i,...a]);s(o),d(!0)},[d]);return P.useEffect(()=>()=>f(),[f]),P.useEffect(()=>{if(c&&u){let e=vC(e=>p(e,u),`handleTriggerLeave`),t=vC(e=>p(e,c),`handleContentLeave`);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,p,f]),P.useEffect(()=>{if(o){let e=vC(e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!KC(n,o);r?f():i&&(f(),l())},`handleTrackPointerGrace`);return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,F.jsx)(HC,{...e,ref:a})},`TooltipContentHoverable`)),VC=Ih(`TooltipContent`),HC=P.forwardRef(vC(function(e,t){let{__scopeTooltip:n,children:r,"aria-label":i,id:a,onEscapeKeyDown:o,onPointerDownOutside:s,...c}=e,l=AC(RC,n),u=xC(n),{onClose:d}=l;P.useEffect(()=>(document.addEventListener(wC,d),()=>document.removeEventListener(wC,d)),[d]),P.useEffect(()=>{if(l.trigger){let e=vC(e=>{e.target instanceof Node&&e.target.contains(l.trigger)&&d()},`handleScroll`);return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[l.trigger,d]);let{setContentId:f}=l;return cg(()=>(f(a),()=>{f(void 0)}),[a,f]),(0,F.jsx)(Vg,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:s,onFocusOutside:e=>e.preventDefault(),onDismiss:d,children:(0,F.jsxs)(fC,{"data-state":l.stateAttribute,role:i?void 0:`tooltip`,id:i?void 0:l.contentId,...u,...c,ref:t,style:{...c.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[(0,F.jsx)(VC,{children:r}),i?(0,F.jsx)(gC,{id:l.contentId,role:`tooltip`,children:i}):null]})})},`TooltipContentImpl`));function UC(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}vC(UC,`getExitSideFromRect`);function WC(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n})}return r}vC(WC,`getPaddedExitPoints`);function GC(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}vC(GC,`getPointsFromRect`);function KC(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}vC(KC,`isPointInPolygon`);function qC(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:+(e.y>t.y)),JC(t)}vC(qC,`getHull`);function JC(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}vC(JC,`getHullPresorted`);var YC=DC,XC=jC,ZC=NC,QC=LC,$C=zC,ew=P.forwardRef(({className:e,children:t,...n},r)=>(0,F.jsxs)(xb,{ref:r,className:K(`relative overflow-hidden`,e),...n,children:[(0,F.jsx)(Sb,{className:`h-full w-full rounded-[inherit]`,children:t}),(0,F.jsx)(Cb,{orientation:`vertical`,className:`flex touch-none select-none transition-colors p-0.5 w-2.5`,children:(0,F.jsx)(wb,{className:`relative flex-1 rounded-full bg-border`})}),(0,F.jsx)(Tb,{})]}));ew.displayName=`ScrollArea`;var tw=P.forwardRef(({className:e,orientation:t=`horizontal`,decorative:n=!0,...r},i)=>(0,F.jsx)(Mb,{ref:i,decorative:n,orientation:t,className:K(`shrink-0 bg-border`,t===`horizontal`?`h-px w-full`:`h-full w-px`,e),...r}));tw.displayName=`Separator`;var nw=YC,rw=XC,iw=ZC,aw=P.forwardRef(({className:e,sideOffset:t=4,...n},r)=>(0,F.jsx)(QC,{children:(0,F.jsx)($C,{ref:r,sideOffset:t,className:K(`z-50 overflow-hidden rounded-md border bg-popover px-2.5 py-1 text-xs text-popover-foreground shadow-md max-w-xs`,e),...n})}));aw.displayName=`TooltipContent`;function ow(e){let{data:t}=ni(e);return(t?.comments??[]).filter(e=>e.status===`open`&&e.thread.at(-1)?.role!==`author`).length}function sw(e){let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);return n<60?`${n}m ${String(t%60).padStart(2,`0`)}s`:`${Math.floor(n/60)}h ${String(n%60).padStart(2,`0`)}m`}function cw(e,t,n){let[r,i]=(0,P.useState)(()=>Date.now());if((0,P.useEffect)(()=>{if(!n)return;i(Date.now());let e=setInterval(()=>i(Date.now()),1e3);return()=>clearInterval(e)},[n]),!e)return null;let a=Date.parse(e);return Number.isNaN(a)?null:Math.max(0,(n?r:t?Date.parse(t):r)-a)}function lw({run:e,className:t}){let n=Dr(e),r=cw(e?.createdAt,e?.finishedAt,n);return r==null?null:(0,F.jsx)(`span`,{className:K(`tabular-nums`,t),title:n?`Working time so far`:`Total run time`,children:sw(r)})}function uw(){let e=V(e=>e.domainId),t=Tr(e),n=Er(e),r=wr(e=>e.setRun),i=wr(e=>e.setDrawer),a=ow(e),[o,s]=(0,P.useState)(!1),c=Le(),l=Dr(n),u=t.data?.available??!1,d=async()=>{if(e){s(!0);try{let t=await z.agentSubmit(e);t.error?I.error(t.error):(r(t),I.success(`Sent to the agent`))}catch(e){I.error(String(e))}finally{s(!1),c.invalidateQueries({queryKey:B.agent(e)})}}};if(l)return(0,F.jsxs)(Jh,{size:`sm`,variant:`secondary`,onClick:()=>i(!0),title:`Show agent activity — running time so far`,children:[(0,F.jsx)(Pn,{className:`h-4 w-4 animate-spin`}),` Agent working…`,(0,F.jsx)(lw,{run:n,className:`ml-0.5 text-[11px] font-normal text-muted-foreground`})]});let f=o||!u,p=u?a===0?`No open threads awaiting a reply yet`:`Send ${a} open thread${a===1?``:`s`} to the agent`:`${t.data?.harness??`agent`} not available — set DOMAIN_STUDIO_HARNESS or install the CLI`;return(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,F.jsxs)(Jh,{size:`sm`,onClick:d,disabled:f,title:p,children:[o?(0,F.jsx)(Pn,{className:`h-4 w-4 animate-spin`}):(0,F.jsx)(Zn,{className:`h-4 w-4`}),` Submit to agent`,a>0&&(0,F.jsx)(`span`,{className:`rounded-full bg-primary-foreground/20 px-1.5 text-[10px] font-semibold`,children:a})]}),n&&(0,F.jsx)(Jh,{size:`icon`,variant:`ghost`,onClick:()=>i(!0),title:`Agent activity`,children:(0,F.jsx)(er,{className:`h-4 w-4`})})]})}function dw(e){switch(e.kind){case`message`:return{icon:(0,F.jsx)(Ln,{className:`h-3.5 w-3.5`}),tone:`text-primary`};case`thinking`:return{icon:(0,F.jsx)(er,{className:`h-3.5 w-3.5`}),tone:`text-muted-foreground`};case`reply`:return{icon:(0,F.jsx)(un,{className:`h-3.5 w-3.5`}),tone:`text-success`};case`error`:return{icon:(0,F.jsx)(sr,{className:`h-3.5 w-3.5`}),tone:`text-destructive`};case`tool`:{let t=e.tool??``;return t===`Edit`||t===`Write`||t===`MultiEdit`?{icon:(0,F.jsx)(_n,{className:`h-3.5 w-3.5`}),tone:`text-warning`}:t===`Bash`?{icon:(0,F.jsx)(ir,{className:`h-3.5 w-3.5`}),tone:`text-foreground/70`}:{icon:(0,F.jsx)(dr,{className:`h-3.5 w-3.5`}),tone:`text-foreground/60`}}default:return{icon:(0,F.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-muted-foreground/50`}),tone:`text-muted-foreground`}}}function fw(e){return e<1e3?String(e):e<1e6?`${(e/1e3).toFixed(+(e<1e4))}k`:`${(e/1e6).toFixed(1)}M`}var pw=(0,P.memo)(function({e}){let{icon:t,tone:n}=dw(e),r=e.kind===`thinking`;return(0,F.jsxs)(`div`,{className:`flex gap-2.5 px-4 py-2`,children:[(0,F.jsx)(`div`,{className:K(`mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center`,n),children:t}),(0,F.jsx)(`div`,{className:`min-w-0 flex-1`,children:e.kind===`tool`?(0,F.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2 gap-y-0.5 text-[13px]`,children:[(0,F.jsx)(`span`,{className:`font-medium text-foreground/90`,children:e.tool}),e.target&&(0,F.jsx)(`span`,{className:`truncate font-mono text-xs text-muted-foreground`,children:e.target})]}):e.kind===`message`||e.kind===`reply`?(0,F.jsx)(bh,{text:e.text}):(0,F.jsx)(`p`,{className:K(`whitespace-pre-wrap break-words text-[13px] leading-relaxed`,r?`italic text-muted-foreground`:`text-foreground/90`),children:e.text})})]})}),mw={queued:`warning`,running:`warning`,succeeded:`success`,failed:`destructive`,canceled:`muted`,interrupted:`warning`};function hw({title:e,text:t}){return(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsx)(`div`,{className:`text-[11px] font-semibold uppercase tracking-wide text-muted-foreground/70`,children:e}),(0,F.jsx)(`pre`,{className:`max-h-[36vh] overflow-auto whitespace-pre-wrap break-words rounded-md border bg-muted/35 p-3 font-mono text-[11px] leading-relaxed`,children:t})]})}function gw({prompt:e,onClose:t}){return(0,F.jsx)(xy,{open:!0,onOpenChange:e=>!e&&t(),children:(0,F.jsxs)(wy,{className:`max-w-4xl`,children:[(0,F.jsx)(Ty,{children:(0,F.jsx)(Dy,{children:`Prompt sent to agent`})}),(0,F.jsxs)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-1 text-[11px] text-muted-foreground`,children:[(0,F.jsx)(`span`,{children:e.firstTurn?`new session`:`follow-up turn`}),(0,F.jsx)(`span`,{children:e.resumed?`resumed`:`fresh`}),e.model&&(0,F.jsxs)(`span`,{className:`font-mono`,children:[`model `,e.model]}),e.effort&&(0,F.jsxs)(`span`,{children:[`effort `,e.effort]}),(0,F.jsx)(`span`,{children:new Date(e.createdAt).toLocaleString()}),e.sessionId&&(0,F.jsxs)(`span`,{className:`font-mono`,children:[`session `,e.sessionId]}),e.mcpTools.length>0&&(0,F.jsxs)(`span`,{children:[`bridge tools: `,e.mcpTools.join(`, `)]})]}),(0,F.jsxs)(`div`,{className:`max-h-[72vh] space-y-4 overflow-y-auto pr-1`,children:[(0,F.jsx)(hw,{title:`Turn prompt (stdin)`,text:e.turnPrompt}),(0,F.jsx)(hw,{title:`System appendix (--append-system-prompt)`,text:e.systemPrompt})]})]})})}function _w(){let e=wr(e=>e.drawerOpen),t=wr(e=>e.setDrawer),n=V(e=>e.domainId),r=V(e=>e.setSection),i=Er(n),a=Tr(n),o=wr(e=>e.setRun),s=Le(),[c,l]=(0,P.useState)(!1),[u,d]=(0,P.useState)(!1),[f,p]=(0,P.useState)(!1),[m,h]=(0,P.useState)(!1),g=(0,P.useRef)(null),_=Dr(i),v=i?.events??[],y=a.data?.conversation,b=y?.turns??0;return(0,P.useEffect)(()=>{e&&g.current&&(g.current.scrollTop=g.current.scrollHeight)},[v.length,e]),(0,P.useEffect)(()=>l(!1),[i?.id]),(0,P.useEffect)(()=>{if(!e)return;let n=e=>{e.key===`Escape`&&t(!1)};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e,t]),e?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`aside`,{className:`fixed inset-y-0 right-0 z-50 flex w-[440px] max-w-[92vw] flex-col border-l bg-card shadow-2xl`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2.5 border-b px-4 h-14 shrink-0`,children:[(0,F.jsx)(`div`,{className:K(`flex h-7 w-7 items-center justify-center rounded-lg`,_?`bg-warning/15 text-warning`:`bg-primary/15 text-primary`),children:_?(0,F.jsx)(Pn,{className:`h-4 w-4 animate-spin`}):(0,F.jsx)(Yt,{className:`h-4 w-4`})}),(0,F.jsx)(`div`,{className:`min-w-0`,children:(0,F.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold`,children:[`Agent`,(0,F.jsx)(`span`,{className:`text-xs font-normal text-muted-foreground`,children:a.data?.harness??i?.harness})]})}),i&&(0,F.jsx)(Th,{variant:mw[i.status],className:`ml-1 capitalize`,children:i.status}),i&&(0,F.jsx)(lw,{run:i,className:`text-[11px] text-muted-foreground/70`}),i?.prompt&&(0,F.jsx)(`button`,{type:`button`,onClick:()=>h(!0),className:`ml-1 rounded-md px-1.5 py-0.5 text-[11px] text-muted-foreground/60 transition-colors hover:bg-accent hover:text-foreground`,title:`Show the exact prompt sent to the local agent`,children:`Sent prompt`}),(0,F.jsx)(`button`,{type:`button`,onClick:()=>t(!1),className:`ml-auto inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground/60 hover:bg-accent hover:text-foreground`,children:(0,F.jsx)(fr,{className:`h-4 w-4`})})]}),y?.active&&(0,F.jsxs)(`div`,{className:`flex items-center gap-2 border-b bg-muted/30 px-4 py-1.5 text-xs text-muted-foreground shrink-0`,children:[(0,F.jsx)(Jn,{className:`h-3.5 w-3.5 shrink-0 opacity-70`}),(0,F.jsxs)(`span`,{className:`min-w-0 truncate`,children:[`Conversation · `,b,` turn`,b===1?``:`s`,(0,F.jsx)(`span`,{className:`opacity-60`,children:` · the agent remembers earlier turns`})]}),(0,F.jsxs)(`button`,{type:`button`,onClick:async()=>{if(!(!n||u||_)){d(!0);try{(await z.agentReset(n)).ok?I.success(`Started a fresh conversation — the next submit won’t remember earlier turns`):I.error(`Could not reset — a run may be in progress`)}catch(e){I.error(String(e))}finally{d(!1),s.invalidateQueries({queryKey:B.agent(n)})}}},disabled:_||u,className:`ml-auto inline-flex shrink-0 items-center gap-1 rounded-md px-1.5 py-0.5 hover:bg-accent hover:text-foreground disabled:opacity-40`,title:`Start a fresh conversation — the next submit won't remember earlier turns`,children:[u?(0,F.jsx)(Pn,{className:`h-3 w-3 animate-spin`}):(0,F.jsx)(Yn,{className:`h-3 w-3`}),` `,`Start fresh`]})]}),(0,F.jsx)(ew,{className:`flex-1 min-h-0`,children:(0,F.jsx)(`div`,{ref:g,className:`h-full overflow-y-auto overflow-x-hidden py-1.5`,children:i?v.length===0?(0,F.jsx)(`div`,{className:`px-4 py-16 text-center text-sm text-muted-foreground`,children:`Starting the agent…`}):(0,F.jsx)(`div`,{className:`divide-y divide-border/40`,children:v.map(e=>(0,F.jsx)(pw,{e},e.id))}):(0,F.jsxs)(`div`,{className:`px-4 py-16 text-center text-sm text-muted-foreground`,children:[`No agent run yet. Add a comment and press`,` `,(0,F.jsx)(`span`,{className:`font-medium text-foreground`,children:`Submit to agent`}),`.`]})})}),(0,F.jsx)(`div`,{className:`border-t px-4 py-3 shrink-0`,children:_?(0,F.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,F.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Editing your domain…`}),(0,F.jsxs)(Jh,{size:`sm`,variant:`outline`,onClick:async()=>{if(!(!n||c)){l(!0);try{await z.agentCancel(n),I.message(`Cancelling the agent…`)}catch{l(!1)}}},disabled:c,children:[c?(0,F.jsx)(Pn,{className:`h-3.5 w-3.5 animate-spin`}):(0,F.jsx)(fr,{className:`h-3.5 w-3.5`}),` `,`Cancel`]})]}):i?(0,F.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,F.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5 text-xs text-muted-foreground`,children:[i.status===`canceled`?(0,F.jsx)(`span`,{className:`text-muted-foreground`,children:`canceled — stopped before finishing`}):i.status===`interrupted`?(0,F.jsx)(`span`,{className:`text-warning`,children:`Interrupted by a studio restart — conversation intact.`}):i.status===`failed`?(0,F.jsx)(`span`,{className:`text-destructive`,children:i.error??`failed`}):(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)($t,{className:`h-3.5 w-3.5 text-success`}),[i.liveReplies?`${i.liveReplies} live`:``,i.merge&&(i.merge.merged||i.merge.closed)?`merged ${i.merge.merged}, closed ${i.merge.closed}`:``].filter(Boolean).join(` · `)||`done`]}),i.merge?.schemaMismatch&&(0,F.jsx)(`span`,{className:`text-warning`,children:`⚠ replied against an older schema`}),i.merge&&i.merge.unknownIds.length>0&&(0,F.jsxs)(`span`,{className:`text-warning`,children:[`⚠ `,i.merge.unknownIds.length,` unknown id(s)`]}),typeof i.tokens==`number`&&i.tokens>0&&(0,F.jsxs)(`span`,{className:`opacity-60`,children:[`· `,fw(i.tokens),` tokens`]})]}),i.status===`interrupted`?(0,F.jsxs)(Jh,{size:`sm`,onClick:async()=>{if(!(!n||f||_)){p(!0);try{let e=await z.agentResume(n);e.error?I.error(e.error):(o(e),I.success(`Resuming where the agent left off`))}catch(e){I.error(String(e))}finally{p(!1),s.invalidateQueries({queryKey:B.agent(n)})}}},disabled:f,title:`Continue the agent from where it was interrupted`,children:[f?(0,F.jsx)(Pn,{className:`h-3.5 w-3.5 animate-spin`}):(0,F.jsx)(Wn,{className:`h-3.5 w-3.5`}),` `,`Resume`]}):(0,F.jsxs)(Jh,{size:`sm`,variant:`outline`,onClick:()=>{t(!1),r(`comments`)},children:[(0,F.jsx)(Ln,{className:`h-3.5 w-3.5`}),` View replies`]})]}):null})]}),m&&i?.prompt&&(0,F.jsx)(gw,{prompt:i.prompt,onClose:()=>h(!1)})]}):null}async function vw(e,t,n,r){let i=await fetch(`/api/domain/${encodeURIComponent(e)}/agent/ask`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(t),signal:r});if(!i.ok||!i.body){let e=await i.text().catch(()=>i.statusText);return{text:``,error:`${i.status} ${e}`.trim()}}let a=i.body.getReader(),o=new TextDecoder,s=``,c=``,l;for(;;){let{value:e,done:t}=await a.read();if(t)break;s+=o.decode(e,{stream:!0});let r;for(;(r=s.indexOf(`
|
|
79
79
|
`))>=0;){let e=s.slice(0,r).trim();if(s=s.slice(r+1),e)try{let t=JSON.parse(e);typeof t.delta==`string`?n(t.delta):typeof t.done==`string`?c=t.done:t.error&&(l=String(t.error))}catch{}}}return{text:c,error:l}}var yw=(e,t)=>`${e}::${t}`,bw=new Map,xw=yr((e,t)=>({entries:{},openKey:null,start:(t,n,r,i,a)=>{let o=yw(t,n.ref);e(e=>{let s=e.entries[o],c=s?{...s,x:i,y:a,seen:!0}:{key:o,ref:n.ref,domainId:t,anchor:n,excerpt:r,x:i,y:a,question:``,answer:``,status:`composing`,seen:!0};return{entries:{...e.entries,[o]:c},openKey:o}})},submit:(n,r)=>{let i=t().entries[n];if(!i)return;bw.get(n)?.abort();let a=new AbortController;bw.set(n,a),e(e=>({entries:{...e.entries,[n]:{...i,question:r,answer:``,status:`streaming`,error:void 0,seen:!0}}}));let o=t=>e(e=>{let r=e.entries[n];return r?{entries:{...e.entries,[n]:t(r)}}:e});vw(i.domainId,{anchor:i.anchor,excerpt:i.excerpt,question:r},e=>{a.signal.aborted||o(t=>({...t,answer:t.answer+e}))},a.signal).then(e=>{a.signal.aborted||o(r=>({...r,status:e.error?`error`:`done`,error:e.error,answer:r.answer||e.text,seen:t().openKey===n}))}).catch(e=>{a.signal.aborted||o(r=>({...r,status:`error`,error:String(e),seen:t().openKey===n}))})},recompose:t=>{bw.get(t)?.abort(),e(e=>{let n=e.entries[t];return n?{entries:{...e.entries,[t]:{...n,question:``,answer:``,status:`composing`,error:void 0,seen:!0}}}:e})},open:t=>e(e=>({openKey:t,entries:e.entries[t]?{...e.entries,[t]:{...e.entries[t],seen:!0}}:e.entries})),collapse:()=>e({openKey:null}),remove:t=>{bw.get(t)?.abort(),bw.delete(t),e(e=>{let{[t]:n,...r}=e.entries;return{entries:r,openKey:e.openKey===t?null:e.openKey}})},keepOnly:t=>e(e=>{let n={};for(let[r,i]of Object.entries(e.entries))i.domainId===t?n[r]=i:(bw.get(r)?.abort(),bw.delete(r));return{entries:n,openKey:e.openKey&&n[e.openKey]?e.openKey:null}})})),Sw=Object.defineProperty,Cw=(e,t)=>Sw(e,`name`,{value:t,configurable:!0}),ww=`Popover`,[Tw,Ew]=og(ww,[ZS]),Dw=ZS(),[Ow,kw]=Tw(ww),Aw=Cw(e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=Dw(t),c=P.useRef(null),[l,u]=P.useState(!1),[d,f]=Sg({prop:r,defaultProp:i??!1,onChange:a,caller:ww});return(0,F.jsx)(uC,{...s,children:(0,F.jsx)(Ow,{scope:t,contentId:pg(),triggerRef:c,open:d,onOpenChange:f,onOpenToggle:P.useCallback(()=>f(e=>!e),[f]),hasCustomAnchor:l,onCustomAnchorAdd:P.useCallback(()=>u(!0),[]),onCustomAnchorRemove:P.useCallback(()=>u(!1),[]),modal:o,children:n})})},`Popover`),jw=`PopoverAnchor`,Mw=P.forwardRef(Cw(function(e,t){let{__scopePopover:n,...r}=e,i=kw(jw,n),a=Dw(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:s}=i;return P.useEffect(()=>(o(),()=>s()),[o,s]),(0,F.jsx)(dC,{...a,...r,ref:t})},`PopoverAnchor`)),Nw=`PopoverTrigger`,Pw=P.forwardRef(Cw(function(e,t){let{__scopePopover:n,...r}=e,i=kw(Nw,n),a=Dw(n),o=Ah(t,i.triggerRef),s=(0,F.jsx)(kg.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":Gw(i.open),...r,ref:o,onClick:Qh(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?s:(0,F.jsx)(dC,{asChild:!0,...a,children:s})},`PopoverTrigger`)),Fw=`PopoverPortal`,[Iw,Lw]=Tw(Fw,{forceMount:void 0}),Rw=Cw(e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=kw(Fw,t);return(0,F.jsx)(Iw,{scope:t,forceMount:n,children:(0,F.jsx)(g_,{present:n||a.open,children:(0,F.jsx)(f_,{asChild:!0,container:i,children:r})})})},`PopoverPortal`),zw=`PopoverContent`,Bw=P.forwardRef(Cw(function(e,t){let n=Lw(zw,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=kw(zw,e.__scopePopover);return(0,F.jsx)(g_,{present:r||a.open,children:a.modal?(0,F.jsx)(Hw,{...i,ref:t}):(0,F.jsx)(Uw,{...i,ref:t})})},`PopoverContent`)),Vw=Nh(`PopoverContent.RemoveScroll`),Hw=P.forwardRef(Cw(function(e,t){let n=kw(zw,e.__scopePopover),r=P.useRef(null),i=Ah(t,r),a=P.useRef(!1);return P.useEffect(()=>{let e=r.current;if(e)return Kv(e)},[]),(0,F.jsx)(Lv,{as:Vw,allowPinchZoom:!0,children:(0,F.jsx)(Ww,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Qh(e.onCloseAutoFocus,e=>{e.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:Qh(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;a.current=r},{checkForDefaultPrevented:!1}),onFocusOutside:Qh(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})},`PopoverContentModal`)),Uw=P.forwardRef(Cw(function(e,t){let n=kw(zw,e.__scopePopover),r=P.useRef(!1),i=P.useRef(!1);return(0,F.jsx)(Ww,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})},`PopoverContentNonModal`)),Ww=P.forwardRef(Cw(function(e,t){let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:u,...d}=e,f=kw(zw,n),p=Dw(n);return D_(),(0,F.jsx)($g,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,F.jsx)(Vg,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>f.onOpenChange(!1),deferPointerDownOutside:!0,children:(0,F.jsx)(fC,{"data-state":Gw(f.open),role:`dialog`,id:f.contentId,...p,...d,ref:t,style:{...d.style,"--radix-popover-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-popover-content-available-width":`var(--radix-popper-available-width)`,"--radix-popover-content-available-height":`var(--radix-popper-available-height)`,"--radix-popover-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-popover-trigger-height":`var(--radix-popper-anchor-height)`}})})})},`PopoverContentImpl`));function Gw(e){return e?`open`:`closed`}Cw(Gw,`getState`);var Kw=Aw,qw=Mw,Jw=Pw,Yw=Rw,Xw=Bw,Zw=Kw,Qw=Jw,$w=qw,eT=P.forwardRef(({className:e,align:t=`start`,side:n=`right`,sideOffset:r=8,...i},a)=>(0,F.jsx)(Yw,{children:(0,F.jsx)(Xw,{ref:a,align:t,side:n,sideOffset:r,collisionPadding:12,avoidCollisions:!0,sticky:`partial`,onOpenAutoFocus:e=>e.preventDefault(),className:K(`z-50 w-80 max-h-[var(--radix-popover-content-available-height)] overflow-hidden rounded-xl border bg-card p-3 shadow-lg outline-none`,`data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0`,e),...i})}));eT.displayName=`PopoverContent`;var tT=P.forwardRef(({className:e,...t},n)=>(0,F.jsx)(`textarea`,{ref:n,className:K(`flex min-h-20 w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 font-mono`,e),...t}));tT.displayName=`Textarea`;function nT(e){let t=e.ref,n=null;try{n=t.startsWith(`module.`)?document.querySelector(`.react-flow__node[data-id="grp-${t.slice(7)}"]`):t.startsWith(`edge.`)?document.querySelector(`.react-flow__edge[data-id="edge-${t.slice(5)}"]`):document.querySelector(`.react-flow__node[data-id="${t}"]`)||document.querySelector(`[data-anchor-ref="${t}"]`)}catch{n=null}if(n){let e=n.getBoundingClientRect();if((e.width||e.height)&&e.bottom>0&&e.top<window.innerHeight)return{x:e.right-10,y:e.top+10}}return{x:e.x,y:e.y}}function rT({entry:e}){let t=xw(e=>e.submit),n=xw(e=>e.recompose),r=xw(e=>e.remove),i=xw(e=>e.collapse),[a,o]=(0,P.useState)(``),s=e.status===`composing`,c=e.status===`done`||e.status===`error`,l=()=>{let n=a.trim();n&&t(e.key,n)};return(0,F.jsxs)(`div`,{className:`flex flex-col gap-2 text-sm`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-medium`,children:[(0,F.jsx)(er,{className:`h-3.5 w-3.5 text-violet-400`}),(0,F.jsx)(`span`,{className:`text-muted-foreground`,children:`Ask`}),(0,F.jsx)(`span`,{className:`truncate font-mono text-[11px] text-muted-foreground/70`,children:e.ref}),(0,F.jsx)(`span`,{className:`ml-auto shrink-0 text-[10px] text-muted-foreground/60`,children:`ephemeral`}),c&&(0,F.jsx)(`button`,{type:`button`,title:`Minimize`,onClick:i,className:`inline-flex h-5 w-5 shrink-0 items-center justify-center rounded text-muted-foreground/50 hover:bg-accent hover:text-foreground`,children:(0,F.jsx)(Bn,{className:`h-3.5 w-3.5`})}),(s||c)&&(0,F.jsx)(`button`,{type:`button`,title:s?`Cancel`:`Close`,onClick:()=>r(e.key),className:`-mr-1 inline-flex h-5 w-5 shrink-0 items-center justify-center rounded text-muted-foreground/50 hover:bg-accent hover:text-foreground`,children:(0,F.jsx)(fr,{className:`h-3.5 w-3.5`})})]}),!s&&(0,F.jsxs)(`div`,{className:`space-y-1.5 rounded-md border bg-background/40 p-2`,children:[(0,F.jsxs)(`div`,{className:`text-[13px] leading-snug`,children:[(0,F.jsx)(`span`,{className:`mr-1.5 text-[10px] font-medium uppercase text-muted-foreground`,children:`you`}),e.question]}),(0,F.jsxs)(`div`,{className:`text-[13px] leading-snug`,children:[(0,F.jsx)(`span`,{className:`mr-1.5 text-[10px] font-medium uppercase text-violet-400`,children:`agent`}),e.status===`streaming`&&!e.answer?(0,F.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-muted-foreground`,children:[(0,F.jsx)(Pn,{className:`h-3 w-3 animate-spin`}),` thinking…`]}):e.status===`error`?(0,F.jsx)(`span`,{className:`text-destructive`,children:e.error}):(0,F.jsxs)(`span`,{className:`whitespace-pre-wrap break-words`,children:[e.answer,e.status===`streaming`&&(0,F.jsx)(`span`,{className:`ml-0.5 inline-block h-3 w-[3px] animate-pulse bg-foreground/50 align-middle`})]})]})]}),s?(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(tT,{autoFocus:!0,className:`min-h-16 text-[13px]`,placeholder:`Ask about ${e.excerpt}…`,value:a,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),l())}}),(0,F.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,F.jsx)(`span`,{className:`mr-auto text-[10px] text-muted-foreground`,children:`⌘↵ to ask · forked aside`}),(0,F.jsxs)(Jh,{size:`sm`,onClick:l,disabled:!a.trim(),children:[(0,F.jsx)(Zn,{className:`h-3.5 w-3.5`}),` Ask`]})]})]}):c?(0,F.jsx)(`div`,{className:`flex items-center justify-end`,children:(0,F.jsx)(Jh,{size:`xs`,variant:`secondary`,onClick:()=>{n(e.key),o(``)},children:`Ask another`})}):null]})}function iT({entry:e,pos:t}){let n=xw(e=>e.openKey),r=xw(e=>e.open),i=xw(e=>e.collapse),a=xw(e=>e.remove),o=n===e.key,s=e.status===`streaming`?`streaming`:e.status===`error`?`error`:e.status===`done`&&!e.seen?`ready`:`idle`;return(0,F.jsxs)(Zw,{open:o,modal:!1,onOpenChange:t=>{t?r(e.key):e.status===`composing`?a(e.key):i()},children:[(0,F.jsx)($w,{asChild:!0,children:(0,F.jsxs)(`button`,{type:`button`,title:e.status===`streaming`?`Ask — answering…`:e.status===`done`?`Ask — answer ready`:e.status===`error`?`Ask — error`:`Ask`,onClick:()=>o?i():r(e.key),style:{position:`fixed`,left:t.x,top:t.y,transform:`translate(-50%, -50%)`},className:K(`z-40 inline-flex h-5 w-5 items-center justify-center rounded-full text-white shadow-md ring-2 ring-card transition-colors`,s===`streaming`&&`bg-violet-500`,s===`ready`&&`bg-emerald-500`,s===`error`&&`bg-destructive`,s===`idle`&&`bg-violet-500/80 hover:bg-violet-500`),children:[e.status===`streaming`?(0,F.jsx)(Pn,{className:`h-3 w-3 animate-spin`}):(0,F.jsx)(er,{className:`h-3 w-3`}),s===`ready`&&(0,F.jsx)(`span`,{className:`absolute -right-0.5 -top-0.5 h-2 w-2 animate-pulse rounded-full bg-emerald-300 ring-2 ring-card`})]})}),(0,F.jsx)(eT,{side:`bottom`,align:`start`,sideOffset:8,className:`w-96`,onInteractOutside:t=>{e.status===`composing`&&t.preventDefault()},children:(0,F.jsx)(rT,{entry:e})})]})}function aT(){let e=V(e=>e.domainId),t=xw(e=>e.entries),n=xw(e=>e.keepOnly),r=Object.values(t).filter(t=>t.domainId===e),[i,a]=(0,P.useState)({});(0,P.useEffect)(()=>{e&&n(e)},[e,n]);let o=r.map(e=>e.key).join(`|`);return(0,P.useEffect)(()=>{if(!o){a({});return}let e=0,t=()=>{let n=xw.getState().entries;a(e=>{let t={},r=!1;for(let i of o.split(`|`)){let a=n[i];if(!a)continue;let o=nT(a);t[i]=o;let s=e[i];(!s||s.x!==o.x||s.y!==o.y)&&(r=!0)}return!r&&Object.keys(e).length===Object.keys(t).length?e:t}),e=requestAnimationFrame(t)};return e=requestAnimationFrame(t),()=>cancelAnimationFrame(e)},[o]),(0,F.jsx)(F.Fragment,{children:r.map(e=>i[e.key]?(0,F.jsx)(iT,{entry:e,pos:i[e.key]},e.key):null)})}var oT=1,sT=.9,cT=.8,lT=.17,uT=.1,dT=.999,fT=.9999,pT=.99,mT=/[\\\/_+.#"@\[\(\{&]/,hT=/[\\\/_+.#"@\[\(\{&]/g,gT=/[\s-]/,_T=/[\s-]/g;function vT(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?oT:pT;var s=`${i},${a}`;if(o[s]!==void 0)return o[s];for(var c=r.charAt(a),l=n.indexOf(c,i),u=0,d,f,p,m;l>=0;)d=vT(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=oT:mT.test(e.charAt(l-1))?(d*=cT,p=e.slice(i,l-1).match(hT),p&&i>0&&(d*=dT**+p.length)):gT.test(e.charAt(l-1))?(d*=sT,m=e.slice(i,l-1).match(_T),m&&i>0&&(d*=dT**+m.length)):(d*=lT,i>0&&(d*=dT**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=fT)),(d<uT&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=vT(e,t,n,r,l+1,a+2,o),f*uT>d&&(d=f*uT)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function yT(e){return e.toLowerCase().replace(_T,` `)}function bT(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,vT(e,t,yT(e),yT(t),0,0,{})}var xT=`[cmdk-group=""]`,ST=`[cmdk-group-items=""]`,CT=`[cmdk-group-heading=""]`,wT=`[cmdk-item=""]`,TT=`${wT}:not([aria-disabled="true"])`,ET=`cmdk-item-select`,DT=`data-value`,OT=(e,t,n)=>bT(e,t,n),kT=P.createContext(void 0),AT=()=>P.useContext(kT),jT=P.createContext(void 0),MT=()=>P.useContext(jT),NT=P.createContext(void 0),PT=P.forwardRef((e,t)=>{let n=JT(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=JT(()=>new Set),i=JT(()=>new Map),a=JT(()=>new Map),o=JT(()=>new Set),s=KT(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:m,disablePointerSelection:h=!1,vimBindings:g=!0,..._}=e,v=pg(),y=pg(),b=pg(),x=P.useRef(null),S=ZT();qT(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,C.emit()}},[u]),qT(()=>{S(6,O)},[]);let C=P.useMemo(()=>({subscribe:e=>(o.current.add(e),()=>o.current.delete(e)),snapshot:()=>n.current,setState:(e,t,r)=>{var i,a,o;if(!Object.is(n.current[e],t)){if(n.current[e]=t,e===`search`)D(),E(),S(1,ee);else if(e===`value`){if(document.activeElement.hasAttribute(`cmdk-input`)||document.activeElement.hasAttribute(`cmdk-root`)){let e=document.getElementById(b);e?e.focus():(i=document.getElementById(v))==null||i.focus()}if(S(7,()=>{n.current.selectedItemId=te()?.id,C.emit()}),r||S(5,O),s.current?.value!==void 0){let e=t??``;(o=(a=s.current).onValueChange)==null||o.call(a,e);return}}C.emit()}},emit:()=>{o.current.forEach(e=>e())}}),[]),w=P.useMemo(()=>({value:(e,t,r)=>{t!==a.current.get(e)?.value&&(a.current.set(e,{value:t,keywords:r}),n.current.filtered.items.set(e,T(t,r)),S(2,()=>{E(),C.emit()}))},item:(e,t)=>(r.current.add(e),t&&(i.current.has(t)?i.current.get(t).add(e):i.current.set(t,new Set([e]))),S(3,()=>{D(),E(),n.current.value||ee(),C.emit()}),()=>{a.current.delete(e),r.current.delete(e),n.current.filtered.items.delete(e);let t=te();S(4,()=>{D(),t?.getAttribute(`id`)===e&&ee(),C.emit()})}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{a.current.delete(e),i.current.delete(e)}),filter:()=>s.current.shouldFilter,label:c||e[`aria-label`],getDisablePointerSelection:()=>s.current.disablePointerSelection,listId:v,inputId:b,labelId:y,listInnerRef:x}),[]);function T(e,t){let r=s.current?.filter??OT;return e?r(e,n.current.search,t):0}function E(){if(!n.current.search||s.current.shouldFilter===!1)return;let e=n.current.filtered.items,t=[];n.current.filtered.groups.forEach(n=>{let r=i.current.get(n),a=0;r.forEach(t=>{let n=e.get(t);a=Math.max(n,a)}),t.push([n,a])});let r=x.current;ne().sort((t,n)=>{let r=t.getAttribute(`id`),i=n.getAttribute(`id`);return(e.get(i)??0)-(e.get(r)??0)}).forEach(e=>{let t=e.closest(ST);t?t.appendChild(e.parentElement===t?e:e.closest(`${ST} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${ST} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=x.current?.querySelector(`${xT}[${DT}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function ee(){let e=ne().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(DT);C.setState(`value`,e||void 0)}function D(){if(!n.current.search||s.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let e=0;for(let t of r.current){let r=T(a.current.get(t)?.value??``,a.current.get(t)?.keywords??[]);n.current.filtered.items.set(t,r),r>0&&e++}for(let[e,t]of i.current)for(let r of t)if(n.current.filtered.items.get(r)>0){n.current.filtered.groups.add(e);break}n.current.filtered.count=e}function O(){var e;let t=te();t&&(t.parentElement?.firstChild===t&&((e=t.closest(xT)?.querySelector(CT))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function te(){return x.current?.querySelector(`${wT}[aria-selected="true"]`)}function ne(){return Array.from(x.current?.querySelectorAll(TT)||[])}function k(e){let t=ne()[e];t&&C.setState(`value`,t.getAttribute(DT))}function A(e){var t;let n=te(),r=ne(),i=r.findIndex(e=>e===n),a=r[i+e];(t=s.current)!=null&&t.loop&&(a=i+e<0?r[r.length-1]:i+e===r.length?r[0]:r[i+e]),a&&C.setState(`value`,a.getAttribute(DT))}function j(e){let t=te()?.closest(xT),n;for(;t&&!n;)t=e>0?WT(t,xT):GT(t,xT),n=t?.querySelector(TT);n?C.setState(`value`,n.getAttribute(DT)):A(e)}let re=()=>k(ne().length-1),M=e=>{e.preventDefault(),e.metaKey?re():e.altKey?j(1):A(1)},ie=e=>{e.preventDefault(),e.metaKey?k(0):e.altKey?j(-1):A(-1)};return P.createElement(kg.div,{ref:t,tabIndex:-1,..._,"cmdk-root":``,onKeyDown:e=>{var t;(t=_.onKeyDown)==null||t.call(_,e);let n=e.nativeEvent.isComposing||e.keyCode===229;if(!(e.defaultPrevented||n))switch(e.key){case`n`:case`j`:g&&e.ctrlKey&&M(e);break;case`ArrowDown`:M(e);break;case`p`:case`k`:g&&e.ctrlKey&&ie(e);break;case`ArrowUp`:ie(e);break;case`Home`:e.preventDefault(),k(0);break;case`End`:e.preventDefault(),re();break;case`Enter`:{e.preventDefault();let t=te();if(t){let e=new Event(ET);t.dispatchEvent(e)}}}}},P.createElement(`label`,{"cmdk-label":``,htmlFor:w.inputId,id:w.labelId,style:eE},c),$T(e,e=>P.createElement(jT.Provider,{value:C},P.createElement(kT.Provider,{value:w},e))))}),FT=P.forwardRef((e,t)=>{let n=pg(),r=P.useRef(null),i=P.useContext(NT),a=AT(),o=KT(e),s=o.current?.forceMount??i?.forceMount;qT(()=>{if(!s)return a.item(n,i?.id)},[s]);let c=XT(n,r,[e.value,e.children,r],e.keywords),l=MT(),u=YT(e=>e.value&&e.value===c.current),d=YT(e=>s||a.filter()===!1?!0:!e.search||e.filtered.items.get(n)>0);P.useEffect(()=>{let t=r.current;if(!(!t||e.disabled))return t.addEventListener(ET,f),()=>t.removeEventListener(ET,f)},[d,e.onSelect,e.disabled]);function f(){var e,t;p(),(t=(e=o.current).onSelect)==null||t.call(e,c.current)}function p(){l.setState(`value`,c.current,!0)}if(!d)return null;let{disabled:m,value:h,onSelect:g,forceMount:_,keywords:v,...y}=e;return P.createElement(kg.div,{ref:kh(r,t),...y,id:n,"cmdk-item":``,role:`option`,"aria-disabled":!!m,"aria-selected":!!u,"data-disabled":!!m,"data-selected":!!u,onPointerMove:m||a.getDisablePointerSelection()?void 0:p,onClick:m?void 0:f},e.children)}),IT=P.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=pg(),s=P.useRef(null),c=P.useRef(null),l=pg(),u=AT(),d=YT(e=>i||u.filter()===!1?!0:!e.search||e.filtered.groups.has(o));qT(()=>u.group(o),[]),XT(o,s,[e.value,e.heading,c]);let f=P.useMemo(()=>({id:o,forceMount:i}),[i]);return P.createElement(kg.div,{ref:kh(s,t),...a,"cmdk-group":``,role:`presentation`,hidden:!d||void 0},n&&P.createElement(`div`,{ref:c,"cmdk-group-heading":``,"aria-hidden":!0,id:l},n),$T(e,e=>P.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?l:void 0},P.createElement(NT.Provider,{value:f},e))))}),LT=P.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=P.useRef(null),a=YT(e=>!e.search);return!n&&!a?null:P.createElement(kg.div,{ref:kh(i,t),...r,"cmdk-separator":``,role:`separator`})}),RT=P.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=MT(),o=YT(e=>e.search),s=YT(e=>e.selectedItemId),c=AT();return P.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),P.createElement(kg.input,{ref:t,...r,"cmdk-input":``,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,"aria-autocomplete":`list`,role:`combobox`,"aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":s,id:c.inputId,type:`text`,value:i?e.value:o,onChange:e=>{i||a.setState(`search`,e.target.value),n?.(e.target.value)}})}),zT=P.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=P.useRef(null),o=P.useRef(null),s=YT(e=>e.selectedItemId),c=AT();return P.useEffect(()=>{if(o.current&&a.current){let e=o.current,t=a.current,n,r=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let n=e.offsetHeight;t.style.setProperty(`--cmdk-list-height`,n.toFixed(1)+`px`)})});return r.observe(e),()=>{cancelAnimationFrame(n),r.unobserve(e)}}},[]),P.createElement(kg.div,{ref:kh(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:c.listId},$T(e,e=>P.createElement(`div`,{ref:kh(o,c.listInnerRef),"cmdk-list-sizer":``},e)))}),BT=P.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return P.createElement(ey,{open:n,onOpenChange:r},P.createElement(iy,{container:o},P.createElement(oy,{"cmdk-overlay":``,className:i}),P.createElement(uy,{"aria-label":e.label,"cmdk-dialog":``,className:a},P.createElement(PT,{ref:t,...s}))))}),VT=P.forwardRef((e,t)=>YT(e=>e.filtered.count===0)?P.createElement(kg.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),HT=P.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return P.createElement(kg.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},$T(e,e=>P.createElement(`div`,{"aria-hidden":!0},e)))}),UT=Object.assign(PT,{List:zT,Item:FT,Input:RT,Group:IT,Separator:LT,Dialog:BT,Empty:VT,Loading:HT});function WT(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function GT(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function KT(e){let t=P.useRef(e);return qT(()=>{t.current=e}),t}var qT=typeof window>`u`?P.useEffect:P.useLayoutEffect;function JT(e){let t=P.useRef();return t.current===void 0&&(t.current=e()),t}function YT(e){let t=MT(),n=()=>e(t.snapshot());return P.useSyncExternalStore(t.subscribe,n,n)}function XT(e,t,n,r=[]){let i=P.useRef(),a=AT();return qT(()=>{var o;let s=(()=>{for(let e of n){if(typeof e==`string`)return e.trim();if(typeof e==`object`&&`current`in e)return e.current?e.current.textContent?.trim():i.current}})(),c=r.map(e=>e.trim());a.value(e,s,c),(o=t.current)==null||o.setAttribute(DT,s),i.current=s}),i}var ZT=()=>{let[e,t]=P.useState(),n=JT(()=>new Map);return qT(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function QT(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function $T({asChild:e,children:t},n){return e&&P.isValidElement(t)?P.cloneElement(QT(t),{ref:t.ref},n(t.props.children)):n(t)}var eE={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`},tE=[264,190,150,90,30,320,220,55,0,170,120,290];function nE(e){return tE[e%tE.length]}function rE(e,t){return`${e}.${t}`}function iE(e,t){if(!e)return{sourcePath:`root`,modulePath:`root`};let n=e.split(`/`).filter(Boolean),r=t.split(`/`).filter(Boolean),i=-1;for(let e=0;e<=n.length-r.length;e+=1)r.every((t,r)=>n[e+r]===t)&&(i=e+r.length);let a=i>=0?n.slice(i):n;return a.length===0?{sourcePath:`root`,modulePath:`root`}:(a[a.length-1]=a[a.length-1].replace(/\.tsx?$/u,``),{sourcePath:a.join(`/`),modulePath:a.length>1?a.slice(0,-1).join(`/`):`root`})}function aE(e,t){return e.ir?Object.entries(e.ir.classes).map(([n,r])=>{let i=r.type===`edge`?`edge`:`class`;return{name:n,kind:i,...iE(e.overlay.sourceSpans[`${i}.${n}`]?.file,t),icon:r.icon}}):[]}function oE(e){let t=[...new Set(e.map(e=>e.modulePath.split(`/`)[0]))].sort();return new Map(t.map((e,t)=>[e,nE(t)]))}function sE(e){return{name:e.name,kind:e.kind,selectId:`class.${e.name}`,ref:rE(e.kind,e.name),icon:e.icon}}function cE(e,t=`schema`){let n=aE(e,t),r=oE(n),i={name:t,path:``,hue:0,children:[],members:[]};for(let e of n){let n=e.modulePath===`root`?[]:e.modulePath.split(`/`),a=r.get(n[0]??`root`)??264,o=i;if(n.length===0){let e=i.children.find(e=>e.path===`root`);e||(e={name:t,path:`root`,hue:a,children:[],members:[]},i.children.push(e)),o=e}for(let e=0;e<n.length;e+=1){let t=n.slice(0,e+1).join(`/`),r=o.children.find(e=>e.path===t);r||(r={name:n[e],path:t,hue:a,children:[],members:[]},o.children.push(r)),o=r}o.members.push(sE(e))}return lE(i),i}function lE(e){e.children.sort((e,t)=>e.name.localeCompare(t.name)),e.members.sort((e,t)=>Number(e.kind===`edge`)-Number(t.kind===`edge`)||e.name.localeCompare(t.name)),e.children.forEach(lE)}function uE(e,t=`schema`){let n=aE(e,t),r=oE(n),i=new Map;for(let e of n){let n=e.modulePath.split(`/`)[0],a=i.get(e.modulePath)??{path:e.modulePath,label:e.modulePath===`root`?t:e.modulePath,hue:r.get(n)??264,classes:[],edges:[]};a[e.kind===`edge`?`edges`:`classes`].push(e.name),i.set(e.modulePath,a)}for(let e of i.values())e.classes.sort(),e.edges.sort();return[...i.values()].sort((e,t)=>e.path.localeCompare(t.path))}function dE(e,t,n=`schema`){return iE(e.overlay.sourceSpans[`class.${t}`]?.file,n).modulePath}function fE(e,t,n=`schema`){let r=aE(e,n),i=oE(r),a=r.filter(e=>e.modulePath===t||t!==`root`&&e.modulePath.startsWith(`${t}/`));return{path:t,label:t===`root`?n:t,hue:i.get(t.split(`/`)[0])??264,classes:a.filter(e=>e.kind===`class`).map(sE).sort(pE),edges:a.filter(e=>e.kind===`edge`).map(sE).sort(pE),files:[...new Set(a.map(e=>e.sourcePath))].sort()}}function pE(e,t){return e.name.localeCompare(t.name)}var mE=[{key:`context`,label:`Context`},{key:`schema`,label:`Schema`},{key:`process`,label:`Process`},{key:`comments`,label:`Comments`}];function hE(e,t){if(!e)return`unknown`;if(Array.isArray(e.enum)&&e.enum.length)return t?`enum?`:`enum`;let n=e.type;if(Array.isArray(n)){let e=n.filter(e=>e!==`null`),r=t??n.includes(`null`),i=e.length===1?e[0]:e.join(` | `)||`unknown`;return r?`${i}?`:i}let r=n===`array`?`${e.items?.type??`unknown`}[]`:n??`unknown`;return t?`${r}?`:r}function gE({icon:e,label:t,meta:n}){return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(e,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,F.jsx)(`span`,{className:`flex-1 truncate`,children:t}),n?(0,F.jsx)(`span`,{className:`ml-2 shrink-0 truncate text-xs text-muted-foreground`,children:n}):null]})}var _E=`flex cursor-pointer items-center gap-2 rounded-md px-2 py-2 text-sm text-foreground outline-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground`;function vE(){let e=V(e=>e.paletteOpen),t=V(e=>e.setPaletteOpen),n=V(e=>e.domainId),r=V(e=>e.setSection),i=V(e=>e.selectClass),a=V(e=>e.focusClass),o=V(e=>e.setSettingsOpen),{data:s}=Hr(n);(0,P.useEffect)(()=>{function e(e){e.key.toLowerCase()===`k`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),t(!V.getState().paletteOpen))}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]);let c=()=>t(!1),l=(0,P.useMemo)(()=>{let e=s?.ir;if(!e||!s)return{classes:[],edges:[],properties:[],modules:[]};let t=Object.values(e.classes).filter(e=>e.type===`node`).map(e=>{let t=Object.keys(e.properties).length,n=Object.keys(e.methods).length,r=dE(s,e.name),i=`${t}p · ${n}m`;return{name:e.name,value:`class ${e.name} ${r} ${i}`,meta:r===`root`?i:`${r} · ${i}`}}).sort((e,t)=>e.name.localeCompare(t.name)),n=Object.values(e.classes).filter(e=>e.type===`edge`).map(e=>{let[t,n]=e.endpoints??[],r=t?.types.join(`|`)??`?`,i=n?.types.join(`|`)??`?`;return{name:e.name,value:`edge ${e.name} ${r} ${i} relationship`,meta:`${r} → ${i}`}}).sort((e,t)=>e.name.localeCompare(t.name)),r=[];for(let t of Object.values(e.classes))if(t.type===`node`)for(let[e,n]of Object.entries(t.properties)){let i=t.required?!t.required.includes(e):void 0;r.push({id:`class.${t.name}.property.${e}`,owner:t.name,prop:e,value:`${t.name}.${e} property ${hE(n,i)}`,meta:hE(n,i)})}return r.sort((e,t)=>e.value.localeCompare(t.value)),{classes:t,edges:n,properties:r,modules:uE(s).map(e=>{let t=e.classes.length+e.edges.length;return{path:e.path,firstClass:e.classes[0],value:`module ${e.path} ${e.classes.join(` `)} ${e.edges.join(` `)}`,meta:`${t} member${t===1?``:`s`}`}})}},[s]);return(0,F.jsxs)(UT.Dialog,{open:e,onOpenChange:t,label:`Command palette`,shouldFilter:!0,overlayClassName:`fixed inset-0 z-50 bg-black/60 backdrop-blur-sm`,contentClassName:K(`fixed left-1/2 top-[15%] z-50 w-full max-w-[640px] -translate-x-1/2`,`overflow-hidden rounded-xl border bg-card text-card-foreground shadow-2xl`,`[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5`,`[&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium`,`[&_[cmdk-group-heading]]:text-muted-foreground`),children:[(0,F.jsx)(`div`,{className:`flex items-center border-b px-3`,children:(0,F.jsx)(UT.Input,{autoFocus:!0,placeholder:`Search classes, interfaces, edges, properties, modules…`,className:`h-12 w-full bg-transparent text-sm text-foreground outline-none placeholder:text-muted-foreground`})}),(0,F.jsxs)(UT.List,{className:`max-h-[60vh] overflow-y-auto overflow-x-hidden p-2`,children:[(0,F.jsx)(UT.Empty,{className:`py-8 text-center text-sm text-muted-foreground`,children:`No results`}),(0,F.jsx)(UT.Group,{heading:`Studio`,children:(0,F.jsxs)(UT.Item,{value:`settings power-user options integrations folder configuration`,className:_E,onSelect:()=>{o(!0),c()},children:[(0,F.jsx)(Qn,{className:`h-4 w-4 text-muted-foreground`}),`Settings…`]})}),l.classes.length>0&&(0,F.jsx)(UT.Group,{heading:`Classes`,children:l.classes.map(e=>(0,F.jsx)(UT.Item,{value:e.value,className:_E,onSelect:()=>{r(`schema`),a(`class.${e.name}`),c()},children:(0,F.jsx)(gE,{icon:Xt,label:e.name,meta:e.meta})},`class.${e.name}`))}),l.edges.length>0&&(0,F.jsx)(UT.Group,{heading:`Relationships`,children:l.edges.map(e=>(0,F.jsx)(UT.Item,{value:e.value,className:_E,onSelect:()=>{r(`schema`),i(`class.${e.name}`),c()},children:(0,F.jsx)(gE,{icon:tr,label:(0,F.jsxs)(F.Fragment,{children:[e.name,` `,(0,F.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`(`,e.meta,`)`]})]})})},`edge.${e.name}`))}),l.properties.length>0&&(0,F.jsx)(UT.Group,{heading:`Properties`,children:l.properties.map(e=>(0,F.jsx)(UT.Item,{value:e.value,className:_E,onSelect:()=>{r(`schema`),a(`class.${e.owner}`),c()},children:(0,F.jsx)(gE,{icon:rr,label:(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`span`,{className:`text-muted-foreground`,children:[e.owner,`.`]}),e.prop]}),meta:e.meta})},e.id))}),l.modules.length>0&&(0,F.jsx)(UT.Group,{heading:`Modules`,children:l.modules.map(e=>(0,F.jsx)(UT.Item,{value:e.value,className:_E,onSelect:()=>{r(`schema`),e.firstClass&&a(`class.${e.firstClass}`),c()},children:(0,F.jsx)(gE,{icon:Cn,label:e.path,meta:e.meta})},`module.${e.path}`))}),(0,F.jsx)(UT.Group,{heading:`Go to`,children:mE.map(e=>(0,F.jsx)(UT.Item,{value:`go to ${e.label} ${e.key} section`,className:_E,onSelect:()=>{r(e.key),c()},children:(0,F.jsx)(gE,{icon:qt,label:e.label,meta:`section`})},`section.${e.key}`))})]}),(0,F.jsxs)(`div`,{className:`flex items-center justify-end gap-3 border-t px-3 py-2 text-[11px] text-muted-foreground`,children:[(0,F.jsx)(`span`,{children:`↑↓ navigate`}),(0,F.jsx)(`span`,{children:`·`}),(0,F.jsx)(`span`,{children:`↵ select`}),(0,F.jsx)(`span`,{children:`·`}),(0,F.jsx)(`span`,{children:`esc close`})]})]})}function yE({count:e,status:t,orphaned:n,onClick:r,className:i}){return(0,F.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),r?.(e)},title:`${e} ${e===1?`thread`:`threads`}${n?` · orphaned`:t===`resolved`?` · resolved`:``}`,className:K(`inline-flex h-4 min-w-4 items-center justify-center rounded-full px-1 text-[10px] font-semibold leading-none tabular-nums shadow-sm transition-colors`,`ring-1 ring-inset cursor-pointer select-none`,t===`open`?`bg-primary text-primary-foreground ring-primary/40 hover:bg-primary/90`:`bg-muted text-muted-foreground ring-border hover:bg-muted/80`,n&&`ring-2 ring-destructive text-destructive bg-destructive/15`,i),children:e})}var bE=Object.defineProperty,xE=(e,t)=>bE(e,`name`,{value:t,configurable:!0}),SE=`Collapsible`,[CE,wE]=og(SE),[TE,EE]=CE(SE),DE=P.forwardRef(xE(function(e,t){let{__scopeCollapsible:n,open:r,defaultOpen:i,disabled:a,onOpenChange:o,...s}=e,[c,l]=Sg({prop:r,defaultProp:i??!1,onChange:o,caller:SE});return(0,F.jsx)(TE,{scope:n,disabled:a,contentId:pg(),open:c,onOpenToggle:P.useCallback(()=>l(e=>!e),[l]),children:(0,F.jsx)(kg.div,{"data-state":NE(c),"data-disabled":a?``:void 0,...s,ref:t})})},`Collapsible`)),OE=`CollapsibleTrigger`,kE=P.forwardRef(xE(function(e,t){let{__scopeCollapsible:n,...r}=e,i=EE(OE,n);return(0,F.jsx)(kg.button,{type:`button`,"aria-controls":i.open?i.contentId:void 0,"aria-expanded":i.open||!1,"data-state":NE(i.open),"data-disabled":i.disabled?``:void 0,disabled:i.disabled,...r,ref:t,onClick:Qh(e.onClick,i.onOpenToggle)})},`CollapsibleTrigger`)),AE=`CollapsibleContent`,jE=P.forwardRef(xE(function(e,t){let{forceMount:n,...r}=e,i=EE(AE,e.__scopeCollapsible);return(0,F.jsx)(g_,{present:n||i.open,children:({present:e})=>(0,F.jsx)(ME,{...r,ref:t,present:e})})},`CollapsibleContent`)),ME=P.forwardRef(xE(function(e,t){let{__scopeCollapsible:n,present:r,children:i,...a}=e,o=EE(AE,n),[s,c]=P.useState(r),l=P.useRef(null),u=Ah(t,l),d=P.useRef(0),f=d.current,p=P.useRef(0),m=p.current,h=o.open||s,g=P.useRef(h),_=P.useRef(void 0);return P.useEffect(()=>{let e=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(e)},[]),cg(()=>{let e=l.current;if(e){_.current=_.current||{transitionDuration:e.style.transitionDuration,animationName:e.style.animationName},e.style.transitionDuration=`0s`,e.style.animationName=`none`;let t=e.getBoundingClientRect();d.current=t.height,p.current=t.width,g.current||(e.style.transitionDuration=_.current.transitionDuration,e.style.animationName=_.current.animationName),c(r)}},[o.open,r]),(0,F.jsx)(kg.div,{"data-state":NE(o.open),"data-disabled":o.disabled?``:void 0,id:o.contentId,hidden:!h,...a,ref:u,style:{"--radix-collapsible-content-height":f?`${f}px`:void 0,"--radix-collapsible-content-width":m?`${m}px`:void 0,...e.style},children:h&&i})},`CollapsibleContentImpl`));function NE(e){return e?`open`:`closed`}xE(NE,`getState`);var PE=DE,FE=kE,IE=jE,LE=PE,RE=FE,zE=IE;function BE({title:e,subtitle:t,icon:n,actions:r,children:i,wide:a,className:o}){return(0,F.jsx)(`div`,{className:`h-full overflow-y-auto`,children:(0,F.jsxs)(`div`,{className:K(`mx-auto px-8 pt-8 pb-28`,a?`max-w-6xl`:`max-w-3xl`,o),children:[(0,F.jsxs)(`header`,{className:`flex items-start gap-3 mb-7`,children:[n&&(0,F.jsx)(`div`,{className:`text-muted-foreground mt-0.5`,children:n}),(0,F.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,F.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight`,children:e}),t&&(0,F.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1 leading-relaxed`,children:t})]}),r&&(0,F.jsx)(`div`,{className:`flex items-center gap-2 shrink-0`,children:r})]}),i]})})}function VE({label:e,hint:t,children:n,className:r}){return(0,F.jsxs)(`section`,{className:K(`mb-8`,r),children:[e&&(0,F.jsxs)(`div`,{className:`flex items-baseline justify-between mb-2.5 px-1`,children:[(0,F.jsx)(`h2`,{className:`text-[11px] font-semibold uppercase tracking-wider text-muted-foreground`,children:e}),t!=null&&(0,F.jsx)(`span`,{className:`text-xs text-muted-foreground/70`,children:t})]}),n]})}function HE({className:e,...t}){return(0,F.jsx)(`div`,{className:K(`rounded-xl border bg-card`,e),...t})}var UE={violet:`bg-primary/12 text-primary`,sky:`bg-sky-500/12 text-sky-400`,emerald:`bg-emerald-500/12 text-emerald-400`,amber:`bg-amber-500/12 text-amber-400`,rose:`bg-rose-500/12 text-rose-400`,fuchsia:`bg-fuchsia-500/12 text-fuchsia-400`,muted:`bg-muted text-muted-foreground`};function WE({children:e,tone:t=`muted`,size:n=`md`,className:r,style:i}){let a=n===`lg`?`h-10 w-10 [&_svg]:h-5 [&_svg]:w-5`:n===`sm`?`h-7 w-7 [&_svg]:h-3.5 [&_svg]:w-3.5`:`h-9 w-9 [&_svg]:h-[18px] [&_svg]:w-[18px]`;return(0,F.jsx)(`div`,{className:K(`inline-flex items-center justify-center rounded-lg shrink-0`,UE[t]??t,a,r),style:i,children:e})}function GE({leading:e,title:t,subtitle:n,trailing:r,onClick:i,active:a,className:o,children:s,anchorRef:c,anchorExcerpt:l}){return(0,F.jsxs)(i?`button`:`div`,{onClick:i,"data-anchor-ref":c,"data-anchor-excerpt":l,"data-commentable":c?``:void 0,className:K(`group/row w-full flex items-center gap-3 px-3 py-2.5 rounded-lg text-left transition-colors`,i&&`hover:bg-accent/60 cursor-pointer`,a&&`bg-accent`,o),children:[e,(t||n)&&(0,F.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[t&&(0,F.jsx)(`div`,{className:`text-sm font-extrabold truncate`,children:t}),n&&(0,F.jsx)(`div`,{className:`text-[13px] text-muted-foreground truncate leading-snug`,children:n})]}),s,r&&(0,F.jsx)(`div`,{className:`shrink-0 flex items-center gap-1.5`,children:r})]})}var KE={default:`bg-muted text-muted-foreground`,primary:`bg-primary/12 text-primary`,success:`bg-success/12 text-success`,warning:`bg-warning/15 text-warning`,danger:`bg-destructive/12 text-destructive`,fuchsia:`bg-fuchsia-500/12 text-fuchsia-300`,outline:`border border-border text-muted-foreground`};function qE({children:e,tone:t=`default`,className:n,...r}){return(0,F.jsx)(`span`,{className:K(`inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[11px] font-medium whitespace-nowrap`,KE[t],n),...r,children:e})}function JE({label:e=`Details`,children:t,className:n}){return(0,F.jsxs)(LE,{className:n,children:[(0,F.jsxs)(RE,{className:`group/disc inline-flex items-center gap-1 text-xs text-muted-foreground/80 hover:text-foreground transition-colors`,children:[(0,F.jsx)(tn,{className:`h-3 w-3 transition-transform group-data-[state=open]/disc:rotate-90`}),e]}),(0,F.jsx)(zE,{className:`overflow-hidden data-[state=open]:animate-in data-[state=closed]:animate-out`,children:(0,F.jsx)(`div`,{className:`pt-2`,children:t})})]})}function YE({items:e,className:t}){return(0,F.jsx)(`dl`,{className:K(`grid grid-cols-[auto_1fr] gap-x-4 gap-y-1.5 text-xs`,t),children:e.map((e,t)=>(0,F.jsxs)(P.Fragment,{children:[(0,F.jsx)(`dt`,{className:`text-muted-foreground/70 whitespace-nowrap`,children:e.label}),(0,F.jsx)(`dd`,{className:`font-mono text-muted-foreground break-all`,children:e.value})]},t))})}function XE({icon:e,title:t,hint:n}){return(0,F.jsxs)(`div`,{className:`flex flex-col items-center justify-center text-center py-12 px-6`,children:[e&&(0,F.jsx)(`div`,{className:`text-muted-foreground/40 mb-3 [&_svg]:h-8 [&_svg]:w-8`,children:e}),(0,F.jsx)(`p`,{className:`text-sm font-medium text-muted-foreground`,children:t}),n&&(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground/60 mt-1 max-w-xs`,children:n})]})}var ZE=Object.defineProperty,QE=(e,t)=>ZE(e,`name`,{value:t,configurable:!0}),$E,eD=`HoverCard`,[tD,nD]=og(eD,[ZS]),rD=ZS(),[iD,aD]=tD(eD),oD=QE(e=>{let{__scopeHoverCard:t,children:n,open:r,defaultOpen:i,onOpenChange:a,openDelay:o=700,closeDelay:s=300}=e,c=rD(t),l=P.useRef(0),u=P.useRef(0),d=P.useRef(!1),f=P.useRef(!1),[p,m]=Sg({prop:r,defaultProp:i??!1,onChange:a,caller:eD}),h=P.useCallback(()=>{clearTimeout(u.current),l.current=window.setTimeout(()=>m(!0),o)},[o,m]),g=P.useCallback(()=>{clearTimeout(l.current),!d.current&&!f.current&&(u.current=window.setTimeout(()=>m(!1),s))},[s,m]),_=P.useCallback(()=>m(!1),[m]);return P.useEffect(()=>()=>{clearTimeout(l.current),clearTimeout(u.current)},[]),(0,F.jsx)(iD,{scope:t,open:p,onOpenChange:m,onOpen:h,onClose:g,onDismiss:_,hasSelectionRef:d,isPointerDownOnContentRef:f,children:(0,F.jsx)(uC,{...c,children:n})})},`HoverCard`),sD=`HoverCardTrigger`,cD=P.forwardRef(QE(function(e,t){let{__scopeHoverCard:n,...r}=e,i=aD(sD,n),a=rD(n);return(0,F.jsx)(dC,{asChild:!0,...a,children:(0,F.jsx)(kg.a,{"data-state":i.open?`open`:`closed`,...r,ref:t,onPointerEnter:Qh(e.onPointerEnter,gD(i.onOpen)),onPointerLeave:Qh(e.onPointerLeave,gD(i.onClose)),onFocus:Qh(e.onFocus,i.onOpen),onBlur:Qh(e.onBlur,i.onClose),onTouchStart:Qh(e.onTouchStart,e=>e.preventDefault())})})},`HoverCardTrigger`)),lD=`HoverCardPortal`,[uD,dD]=tD(lD,{forceMount:void 0}),fD=QE(e=>{let{__scopeHoverCard:t,forceMount:n,children:r,container:i}=e,a=aD(lD,t);return(0,F.jsx)(uD,{scope:t,forceMount:n,children:(0,F.jsx)(g_,{present:n||a.open,children:(0,F.jsx)(f_,{asChild:!0,container:i,children:r})})})},`HoverCardPortal`),pD=`HoverCardContent`,mD=P.forwardRef(QE(function(e,t){let n=dD(pD,e.__scopeHoverCard),{forceMount:r=n.forceMount,...i}=e,a=aD(pD,e.__scopeHoverCard);return(0,F.jsx)(g_,{present:r||a.open,children:(0,F.jsx)(hD,{"data-state":a.open?`open`:`closed`,...i,onPointerEnter:Qh(e.onPointerEnter,gD(a.onOpen)),onPointerLeave:Qh(e.onPointerLeave,gD(a.onClose)),ref:t})})},`HoverCardContent`)),hD=P.forwardRef(QE(function(e,t){let{__scopeHoverCard:n,onEscapeKeyDown:r,onPointerDownOutside:i,onFocusOutside:a,onInteractOutside:o,...s}=e,c=aD(pD,n),l=rD(n),u=P.useRef(null),d=Ah(t,u),[f,p]=P.useState(!1);return P.useEffect(()=>{if(f){let e=document.body;return $E=e.style.userSelect||e.style.webkitUserSelect,e.style.userSelect=`none`,e.style.webkitUserSelect=`none`,()=>{e.style.userSelect=$E,e.style.webkitUserSelect=$E}}},[f]),P.useEffect(()=>{if(u.current){let e=QE(()=>{p(!1),c.isPointerDownOnContentRef.current=!1,setTimeout(()=>{document.getSelection()?.toString()!==``&&(c.hasSelectionRef.current=!0)})},`handlePointerUp`);return document.addEventListener(`pointerup`,e),()=>{document.removeEventListener(`pointerup`,e),c.hasSelectionRef.current=!1,c.isPointerDownOnContentRef.current=!1}}},[c.isPointerDownOnContentRef,c.hasSelectionRef]),P.useEffect(()=>{u.current&&_D(u.current).forEach(e=>e.setAttribute(`tabindex`,`-1`))}),(0,F.jsx)(Vg,{asChild:!0,disableOutsidePointerEvents:!1,onInteractOutside:o,onEscapeKeyDown:r,onPointerDownOutside:i,onFocusOutside:Qh(a,e=>{e.preventDefault()}),onDismiss:c.onDismiss,children:(0,F.jsx)(fC,{...l,...s,onPointerDown:Qh(s.onPointerDown,e=>{e.currentTarget.contains(e.target)&&p(!0),c.hasSelectionRef.current=!1,c.isPointerDownOnContentRef.current=!0}),ref:d,style:{...s.style,userSelect:f?`text`:void 0,WebkitUserSelect:f?`text`:void 0,"--radix-hover-card-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-hover-card-content-available-width":`var(--radix-popper-available-width)`,"--radix-hover-card-content-available-height":`var(--radix-popper-available-height)`,"--radix-hover-card-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-hover-card-trigger-height":`var(--radix-popper-anchor-height)`}})})},`HoverCardContentImpl`));function gD(e){return t=>t.pointerType===`touch`?void 0:e()}QE(gD,`excludeTouch`);function _D(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:QE(e=>e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP,`acceptNode`)});for(;n.nextNode();)t.push(n.currentNode);return t}QE(_D,`getTabbableNodes`);var vD=oD,yD=cD,bD=fD,xD=mD,SD=vD,CD=yD,wD=P.forwardRef(({className:e,align:t=`start`,sideOffset:n=8,...r},i)=>(0,F.jsx)(bD,{children:(0,F.jsx)(xD,{ref:i,align:t,sideOffset:n,className:K(`z-50 w-72 rounded-xl border bg-popover p-3 text-popover-foreground shadow-lg outline-none`,`data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=closed]:animate-out data-[state=closed]:fade-out-0`,e),...r})}));wD.displayName=`HoverCardContent`;function TD({domainId:e,anchor:t,excerpt:n,threads:r,onClose:i}){let a=V(e=>e.domainId),o=e??a??``;return(0,F.jsxs)(`div`,{className:`flex max-h-[calc(var(--radix-popover-content-available-height)-1.5rem)] min-h-0 flex-col gap-2 text-sm`,children:[(0,F.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between`,children:[(0,F.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:r.length>0?`${r.length} comment${r.length===1?``:`s`}`:`New comment`}),(0,F.jsxs)(SD,{openDelay:120,children:[(0,F.jsx)(CD,{asChild:!0,children:(0,F.jsx)(`button`,{type:`button`,title:`Target`,className:`text-muted-foreground/40 transition-colors hover:text-muted-foreground`,children:(0,F.jsx)(dn,{className:`h-3.5 w-3.5`})})}),(0,F.jsx)(wD,{className:`w-auto max-w-xs`,children:(0,F.jsx)(YE,{items:[{label:`target`,value:t.ref},...n&&n!==t.ref?[{label:`on`,value:n}]:[],...t.file?[{label:`file`,value:t.file}]:[]]})})]})]}),r.length>0&&(0,F.jsx)(`div`,{className:`min-h-0 flex-1 space-y-2 overflow-y-auto pr-1`,children:r.map(e=>(0,F.jsx)(DD,{domainId:o,comment:e},e.id))}),(0,F.jsx)(kD,{domainId:o,anchor:t,excerpt:n,hasThreads:r.length>0,onClose:i})]})}function ED({domainId:e,commentId:t,entryId:n,text:r}){let i=V(e=>e.domainId),{edit:a}=li(e??i??``),[o,s]=(0,P.useState)(!1),[c,l]=(0,P.useState)(r),u=()=>{let e=c.trim();!e||a.isPending||a.mutate({commentId:t,entryId:n,text:e},{onSuccess:()=>{s(!1),I.success(`Edited`)},onError:e=>I.error(String(e))})};return o?(0,F.jsxs)(`span`,{className:`mt-1 flex items-end gap-1.5`,children:[(0,F.jsx)(tT,{autoFocus:!0,className:`min-h-8 flex-1 text-[13px]`,value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)?(e.preventDefault(),u()):e.key===`Escape`&&(l(r),s(!1))}}),(0,F.jsx)(Jh,{size:`xs`,variant:`secondary`,disabled:!c.trim()||a.isPending,onClick:u,children:`Save`})]}):(0,F.jsxs)(`div`,{className:`group/e relative`,children:[(0,F.jsx)(bh,{text:r}),(0,F.jsx)(`button`,{type:`button`,title:`Edit`,onClick:()=>{l(r),s(!0)},className:`absolute right-0 top-0 inline-flex h-5 w-5 items-center justify-center rounded bg-background/80 text-transparent backdrop-blur-sm transition-colors group-hover/e:text-muted-foreground/50 hover:!text-foreground`,children:(0,F.jsx)(Un,{className:`h-3 w-3`})})]})}function DD({domainId:e,comment:t}){let{reply:n,setStatus:r,remove:i}=li(e),[a,o]=(0,P.useState)(``),s=t.status===`closed`,[c,l]=(0,P.useState)(!s),u=(t.thread.at(-1)?.text??t.thread[0]?.text??``).trim();return(0,P.useEffect)(()=>{l(t.status!==`closed`)},[t.status]),(0,F.jsxs)(`div`,{className:K(`rounded-md border bg-background/40 p-2 space-y-1.5`,s&&`bg-muted/20`),children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(Th,{variant:t.status===`open`?`secondary`:`muted`,children:s?`resolved`:`open`}),t.orphaned&&(0,F.jsx)(Th,{variant:`destructive`,children:`orphaned`}),s&&(0,F.jsxs)(`button`,{type:`button`,onClick:()=>l(e=>!e),className:`ml-auto inline-flex h-6 items-center gap-1 rounded-md px-1.5 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,children:[c?(0,F.jsx)(en,{className:`h-3.5 w-3.5`}):(0,F.jsx)(tn,{className:`h-3.5 w-3.5`}),c?`Hide`:`Show`]}),(0,F.jsx)(`button`,{type:`button`,title:`Delete comment`,disabled:i.isPending,onClick:()=>i.mutate(t.id,{onSuccess:()=>I.success(`Deleted`)}),className:K(`inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground/50 transition-colors hover:bg-destructive/10 hover:text-destructive disabled:opacity-50`,!s&&`ml-auto`),children:(0,F.jsx)(or,{className:`h-3.5 w-3.5`})})]}),s&&!c&&u&&(0,F.jsx)(`button`,{type:`button`,onClick:()=>l(!0),className:`block w-full truncate rounded-sm px-0.5 py-0.5 text-left text-[12px] leading-snug text-muted-foreground/75 hover:text-foreground`,children:u}),(!s||c)&&(0,F.jsx)(`div`,{className:K(`space-y-1`,s&&`opacity-75`),children:t.thread.map((n,r)=>{let i=n.type===`choice`&&!!n.options&&n.role===`author`&&t.status===`open`&&r===t.thread.length-1;return(0,F.jsxs)(`div`,{className:`text-[13px] leading-snug`,children:[(0,F.jsx)(`span`,{className:K(`mb-0.5 block text-[10px] font-medium uppercase`,n.role===`author`?`text-primary`:`text-muted-foreground`),children:n.role===`author`?`agent`:`you`}),(0,F.jsx)(ED,{domainId:e,commentId:t.id,entryId:n.id,text:n.text}),n.type===`choice`&&n.options&&(i?(0,F.jsx)(OD,{commentId:t.id,options:n.options,domainId:e}):(0,F.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1`,children:n.options.map(e=>(0,F.jsx)(Th,{variant:n.answer===e?`default`:`outline`,children:e},e))}))]},n.id)})}),t.status===`open`&&(0,F.jsxs)(`div`,{className:`flex items-end gap-1.5 pt-0.5`,children:[(0,F.jsx)(tT,{className:`min-h-8 flex-1 text-[13px]`,placeholder:`Reply…`,value:a,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&a.trim()&&n.mutate({commentId:t.id,entry:{role:`user`,type:`text`,text:a.trim()}},{onSuccess:()=>o(``)})}}),(0,F.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,F.jsx)(Jh,{size:`xs`,variant:`secondary`,disabled:!a.trim()||n.isPending,onClick:()=>n.mutate({commentId:t.id,entry:{role:`user`,type:`text`,text:a.trim()}},{onSuccess:()=>o(``)}),children:`Reply`}),(0,F.jsxs)(Jh,{size:`xs`,onClick:()=>r.mutate({commentId:t.id,status:`closed`},{onSuccess:()=>I.success(`Resolved`)}),children:[(0,F.jsx)($t,{className:`h-3 w-3`}),` Resolve`]})]})]})]})}function OD({commentId:e,options:t,domainId:n}){let{reply:r}=li(n),[i,a]=(0,P.useState)(``),[o,s]=(0,P.useState)(!1),c=t=>{let n=t.trim();!n||r.isPending||r.mutate({commentId:e,entry:{role:`user`,type:`text`,text:n}},{onSuccess:()=>{a(``),s(!1)}})};return(0,F.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-1.5`,children:[t.map(e=>(0,F.jsx)(`button`,{type:`button`,disabled:r.isPending,onClick:()=>c(e),className:`rounded-full border border-primary/35 bg-primary/5 px-2.5 py-1 text-[12px] font-medium transition-colors hover:border-primary hover:bg-primary/15 disabled:opacity-50`,children:e},e)),o?(0,F.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,F.jsx)(`input`,{autoFocus:!0,value:i,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),c(i))},placeholder:`Your answer…`,className:`h-7 w-36 rounded-md border bg-background px-2 text-[12px] outline-none focus:border-primary`}),(0,F.jsx)(Jh,{size:`xs`,variant:`secondary`,disabled:!i.trim()||r.isPending,onClick:()=>c(i),children:`Send`})]}):(0,F.jsx)(`button`,{type:`button`,onClick:()=>s(!0),className:`rounded-full border border-dashed px-2.5 py-1 text-[12px] text-muted-foreground transition-colors hover:border-foreground/40 hover:text-foreground`,children:`Other…`})]})}function kD({domainId:e,anchor:t,excerpt:n,hasThreads:r,onClose:i}){let{create:a}=li(e),[o,s]=(0,P.useState)(``),c=()=>{o.trim()&&a.mutate({anchors:[n],anchorRefs:[t],text:o.trim(),firstRole:`user`,type:`text`},{onSuccess:()=>{I.success(`Comment added`),i()},onError:e=>I.error(String(e))})};return(0,F.jsxs)(`div`,{className:`shrink-0 space-y-2 border-t pt-2`,children:[(0,F.jsx)(tT,{autoFocus:!r,className:`min-h-16 text-[13px]`,placeholder:r?`Add another comment…`:`Note for the agent…`,value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),c())}}),(0,F.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,F.jsx)(`span`,{className:`mr-auto text-[10px] text-muted-foreground`,children:`⌘↵ to submit`}),(0,F.jsx)(Jh,{size:`sm`,onClick:c,disabled:!o.trim()||a.isPending,children:`Add comment`})]})]})}function AD(e,t){let n=V(e=>e.domainId),{data:r}=ni(t??n),i=(r?.comments??[]).filter(t=>t.anchorRefs.some(t=>t.ref===e));return{threads:i,status:i.some(e=>e.status===`open`)?`open`:`resolved`,orphaned:i.some(e=>e.orphaned)}}function jD({anchorRef:e,excerpt:t,className:n,domainId:r}){let i=(0,P.useId)(),a=V(e=>e.openAnchorRef),o=V(e=>e.openAnchorId),s=r?`${r}::${e.ref}`:e.ref,c=a===s&&(o===null||o===i),l=V(e=>e.setOpenAnchor),{threads:u,status:d,orphaned:f}=AD(e.ref,r);return u.length===0?null:(0,F.jsxs)(Zw,{modal:!1,open:c,onOpenChange:e=>l(e?s:null,e?i:null),children:[(0,F.jsx)($w,{asChild:!0,children:(0,F.jsx)(`button`,{type:`button`,"data-anchor-ref":e.ref,"data-domain-id":r,"aria-label":`Comments on ${e.ref}`,onClick:e=>{e.stopPropagation(),l(c?null:s,i)},className:K(`inline-flex shrink-0 align-middle`,n),children:(0,F.jsx)(yE,{count:u.length,status:d,orphaned:f})})}),(0,F.jsx)(eT,{onInteractOutside:e=>e.preventDefault(),className:`max-h-[var(--radix-popover-content-available-height)] overflow-y-auto`,children:(0,F.jsx)(TD,{domainId:r,anchor:e,excerpt:t,threads:u,onClose:()=>l(null)})})]})}function MD(){let e=V(e=>e.commentDraft),t=V(e=>e.setCommentDraft),{threads:n}=AD(e?.anchor.ref??`__none__`,e?.domainId);return e?(0,F.jsxs)(Zw,{modal:!1,open:!0,onOpenChange:e=>{e||t(null)},children:[(0,F.jsx)($w,{asChild:!0,children:(0,F.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none fixed`,style:{left:e.x,top:e.y,width:1,height:1}})}),(0,F.jsx)(eT,{side:`bottom`,align:`start`,sideOffset:6,className:`w-80`,onInteractOutside:e=>e.preventDefault(),children:(0,F.jsx)(TD,{domainId:e.domainId,anchor:e.anchor,excerpt:e.excerpt,threads:n,onClose:()=>t(null)})})]},`${e.anchor.ref}:${e.x}:${e.y}`):null}function ND(e){return/^(class|edge)\./.test(e)?`schema`:/^(module|section|view)\./.test(e)?`section`:e.startsWith(`file.`)?`file`:`free`}function PD(e,t){return`${e}.${t}`}function FD(e){let t=(e.startsWith(`workspace-edge:`)?`edge-${e.split(`:`)[2]??``}`:e.startsWith(`workspace:`)?e.split(`:`).slice(2).join(`:`):e).replace(/^edge-/,``).split(`__`)[0]?.trim();return t?`edge.${t}`:null}function ID(e,t){return{"data-anchor-ref":e,"data-anchor-excerpt":t,"data-commentable":``}}function LD(e,t,n){let r=e.closest(`.react-flow`),i=r?.querySelector(`.react-flow__viewport`);if(!r||!i)return null;let a=r.getBoundingClientRect(),o=getComputedStyle(i).transform,s=0,c=0,l=1;if(o&&o!==`none`)try{let e=new DOMMatrixReadOnly(o);s=e.e,c=e.f,l=e.a||1}catch{return null}let u=(t-a.left-s)/l,d=(n-a.top-c)/l;return!Number.isFinite(u)||!Number.isFinite(d)?null:{x:Math.round(u),y:Math.round(d)}}function RD(e,t,n,r,i){if(!e)return null;let a=e.closest(`[data-domain-id]`)?.dataset.domainId,o=e.closest(`[data-anchor-ref]`);if(o?.dataset.anchorRef){let e=o.dataset.anchorRef,t=(o.dataset.anchorExcerpt||o.textContent||e).trim().slice(0,80);return{mode:n,domainId:o.dataset.domainId??a,anchor:{ref:e,kind:ND(e)},excerpt:t,x:r,y:i}}let s=e.closest(`.react-flow__node`);if(s){let e=s.getAttribute(`data-id`)??``,t=e.startsWith(`workspace:`)?e.split(`:`).slice(2).join(`:`):e;if(t.startsWith(`class.`))return{mode:n,domainId:a,anchor:{ref:t,kind:`schema`},excerpt:t.slice(6),x:r,y:i};if(t.startsWith(`grp-`)){let e=t.slice(4);return{mode:n,domainId:a,anchor:{ref:`module.${e}`,kind:`section`},excerpt:e,x:r,y:i}}}let c=e.closest(`.react-flow__edge`);if(c){let e=c.getAttribute(`data-id`)??``,t=FD(e),o=e.startsWith(`workspace-edge:`)?e.split(`:`)[1]:void 0;if(t)return{mode:n,domainId:o?decodeURIComponent(o):a,anchor:{ref:t,kind:`schema`},excerpt:t.slice(5),x:r,y:i}}if(e.closest(`main`)){let o=LD(e,r,i);return{mode:n,domainId:a,anchor:{ref:`section.${t}`,kind:`section`,...o},excerpt:t,x:r,y:i}}return null}function zD(){let e=V(e=>e.commentMode),t=V(e=>e.askMode),n=V(e=>e.toggleCommentMode),r=V(e=>e.toggleAskMode),i=V(e=>e.setCommentDraft),a=e||t,o=t?`ask`:`comment`;if((0,P.useEffect)(()=>{if(!a)return;let e=document.body.style.cursor;document.body.style.cursor=`crosshair`;let t=()=>V.getState().askMode?r(!1):n(!1),o=e=>{e.preventDefault(),e.stopPropagation();let n=V.getState(),r=n.askMode?`ask`:`comment`,a=RD(e.target,n.section,r,e.clientX,e.clientY);if(t(),a){if(a.mode===`ask`){let e=a.domainId??n.domainId;e&&requestAnimationFrame(()=>xw.getState().start(e,a.anchor,a.excerpt,a.x,a.y))}else requestAnimationFrame(()=>i(a))}},s=e=>{e.key===`Escape`&&(e.preventDefault(),t())};return document.addEventListener(`click`,o,!0),document.addEventListener(`keydown`,s,!0),()=>{document.body.style.cursor=e,document.removeEventListener(`click`,o,!0),document.removeEventListener(`keydown`,s,!0)}},[a,n,r,i]),!a)return null;let s=o===`ask`;return(0,F.jsx)(`div`,{className:`pointer-events-none fixed inset-x-0 top-3 z-50 flex justify-center`,children:(0,F.jsxs)(`div`,{className:K(`flex items-center gap-2 rounded-full border bg-card/95 px-4 py-1.5 text-xs font-medium text-foreground shadow-lg backdrop-blur`,s?`border-violet-400/50`:`border-primary/40`),children:[s?(0,F.jsx)(er,{className:`h-3.5 w-3.5 text-violet-400`}):(0,F.jsx)(Vn,{className:`h-3.5 w-3.5 text-primary`}),(0,F.jsxs)(`span`,{children:[s?`Ask mode — click anything to ask a quick question`:`Comment mode — click anything to comment`,` `,(0,F.jsx)(`kbd`,{className:`ml-1 rounded border bg-muted px-1 py-0.5 text-[10px] text-muted-foreground`,children:`Esc`}),` `,`to exit`]})]})})}var BD=`studio.schemaWorkspace.v1`,VD={selectedDomainIds:[],domainPositions:{},externalPositions:{},domainSizes:{},domainContentOffsets:{},collapsedModules:{}};function HD(e){return[...new Set(e.filter(Boolean))]}function UD(e,t,n){let r=HD(e);return t&&!r.includes(t)&&r.unshift(t),r.length<=1?[n]:(r.includes(n)||r.push(n),r)}function WD(){try{let e=JSON.parse(localStorage.getItem(BD)??`null`);return e?{selectedDomainIds:HD(e.selectedDomainIds??[]),domainPositions:e.domainPositions??{},externalPositions:e.externalPositions??{},domainSizes:e.domainSizes??{},domainContentOffsets:e.domainContentOffsets??{},collapsedModules:e.collapsedModules??{}}:VD}catch{return VD}}function GD(e){try{localStorage.setItem(BD,JSON.stringify(e))}catch{}}function KD(e){return{selectedDomainIds:e.selectedDomainIds,domainPositions:e.domainPositions,externalPositions:e.externalPositions,domainSizes:e.domainSizes,domainContentOffsets:e.domainContentOffsets,collapsedModules:e.collapsedModules}}var qD=WD(),JD=yr(e=>({...qD,replaceDomains:t=>e(e=>{let n=HD(t);return GD({...KD(e),selectedDomainIds:n}),{selectedDomainIds:n}}),toggleDomain:(t,n)=>e(e=>{let r=new Set(e.selectedDomainIds);r.has(t)&&t!==n?r.delete(t):r.add(t),r.add(n);let i=[...r];return GD({...KD(e),selectedDomainIds:i}),{selectedDomainIds:i}}),setDomainPosition:(t,n)=>e(e=>{let r={...e.domainPositions,[t]:n};return GD({...KD(e),domainPositions:r}),{domainPositions:r}}),setDomainSize:(t,n)=>e(e=>{let r={...e.domainSizes,[t]:n};return GD({...KD(e),domainSizes:r}),{domainSizes:r}}),ensureDomainPositions:t=>e(e=>{let n={...e.domainPositions},r=!1;for(let[e,i]of Object.entries(t))n[e]||(n[e]=i,r=!0);return r?(GD({...KD(e),domainPositions:n}),{domainPositions:n}):e}),ensureExternalPositions:t=>e(e=>{let n={...e.externalPositions},r=!1;for(let[e,i]of Object.entries(t))n[e]||(n[e]=i,r=!0);return r?(GD({...KD(e),externalPositions:n}),{externalPositions:n}):e}),ensureDomainContentOffsets:t=>e(e=>{let n={...e.domainContentOffsets},r=!1;for(let[e,i]of Object.entries(t))n[e]||(n[e]=i,r=!0);return r?(GD({...KD(e),domainContentOffsets:n}),{domainContentOffsets:n}):e}),resetWorkspaceFrames:()=>e(e=>(GD({...KD(e),domainPositions:{},externalPositions:{},domainSizes:{}}),{domainPositions:{},externalPositions:{},domainSizes:{}})),toggleModule:(t,n)=>e(e=>{let r=new Set(e.collapsedModules[t]??[]);r.has(n)?r.delete(n):r.add(n);let i={...e.collapsedModules,[t]:[...r]};return GD({...KD(e),collapsedModules:i}),{collapsedModules:i}})})),YD=P.forwardRef(({className:e,type:t,...n},r)=>(0,F.jsx)(`input`,{ref:r,type:t,className:K(`flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50`,e),...n}));YD.displayName=`Input`;var XD=/^[a-z0-9](?:[a-z0-9.-]*[a-z0-9])?$/;function ZD(){let{data:e}=zr(),t=V(e=>e.domainId),n=V(e=>e.setDomain),r=V(e=>e.setSection),i=JD(e=>e.selectedDomainIds),a=JD(e=>e.replaceDomains),o=JD(e=>e.toggleDomain),[s,c]=(0,P.useState)(!1),[l,u]=(0,P.useState)(!1),d=e?.find(e=>e.id===t),f=(0,P.useMemo)(()=>new Set((e??[]).map(e=>e.id)),[e]);(0,P.useEffect)(()=>{if(!t||!e)return;let n=i.filter(e=>f.has(e));n.includes(t)||n.unshift(t),(n.length!==i.length||n.some((e,t)=>e!==i[t]))&&a(n)},[t,e,a,i,f]);let p=new Set(i);t&&p.add(t);let m=p.size,h=e=>{a(t?UD([...p],t,e):[e]),n(e),c(!1)};return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(Zw,{open:s,onOpenChange:c,children:[(0,F.jsx)(Qw,{asChild:!0,children:(0,F.jsxs)(`button`,{type:`button`,"data-testid":`domain-selector`,title:`Domain canvas — choose the active domain and optional companions`,className:K(`inline-flex h-8 items-center gap-2 rounded-lg border pl-1.5 pr-2 text-sm font-medium outline-none transition-colors`,m>1?`border-sky-400/35 bg-sky-400/10 text-sky-100 hover:bg-sky-400/15`:`bg-card hover:bg-accent/50`),children:[(0,F.jsx)(`span`,{className:`grid h-5 w-5 place-items-center rounded-md bg-primary/10 text-primary`,children:(0,F.jsx)(Zt,{className:`h-3.5 w-3.5`})}),(0,F.jsx)(`span`,{className:`max-w-[15rem] truncate`,children:d?.origin??`select domain`}),(0,F.jsxs)(`span`,{className:K(`inline-flex h-5 items-center gap-1 rounded-full px-1.5 text-[10px] tabular-nums`,m>1?`bg-sky-300/15 text-sky-100`:`bg-muted text-muted-foreground`),children:[(0,F.jsx)(On,{className:`h-3 w-3`}),` `,m]}),(0,F.jsx)(nn,{className:`h-3.5 w-3.5 text-muted-foreground`})]})}),(0,F.jsxs)(eT,{align:`start`,className:`w-80 p-1.5`,children:[(0,F.jsxs)(`div`,{className:`flex items-start justify-between gap-3 px-2 pb-2 pt-1`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`div`,{className:`text-[11px] font-semibold uppercase tracking-wider text-muted-foreground`,children:`Domain canvas`}),(0,F.jsx)(`p`,{className:`mt-0.5 text-[11px] leading-snug text-muted-foreground/70`,children:`Open one domain, then check companions to compose their schemas.`})]}),!!e?.length&&(0,F.jsx)(`button`,{type:`button`,onClick:()=>a(e.map(e=>e.id)),className:`shrink-0 rounded-md px-1.5 py-1 text-[10px] font-medium text-sky-300 hover:bg-sky-400/10`,children:`Select all`})]}),(0,F.jsxs)(`div`,{className:`max-h-[50vh] space-y-0.5 overflow-y-auto`,children:[(e??[]).map(e=>{let n=p.has(e.id),r=e.id===t;return(0,F.jsxs)(`div`,{className:K(`flex items-center gap-1 rounded-md transition-colors`,n?`bg-accent/55`:`hover:bg-accent/35`),children:[(0,F.jsx)(`button`,{type:`button`,role:`checkbox`,"aria-label":r?`${e.origin} is the active domain on canvas`:`${n?`Remove`:`Add`} ${e.origin} ${n?`from`:`to`} canvas`,"aria-checked":n,disabled:r,title:r?`The active domain is always on the canvas`:void 0,onClick:()=>t&&o(e.id,t),className:`group ml-2 grid h-5 w-5 shrink-0 place-items-center rounded border border-border text-transparent transition-colors enabled:hover:border-sky-400/60 disabled:cursor-default`,children:n&&(0,F.jsx)(`span`,{className:`grid h-full w-full place-items-center rounded bg-sky-400/15 text-sky-200`,children:(0,F.jsx)($t,{className:`h-3 w-3`})})}),(0,F.jsxs)(`button`,{type:`button`,"aria-current":r?`true`:void 0,onClick:()=>h(e.id),className:`flex min-w-0 flex-1 items-center gap-2 px-1.5 py-2 text-left`,children:[(0,F.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,F.jsx)(`span`,{className:`block truncate text-[13px] font-semibold`,children:e.origin}),(0,F.jsxs)(`span`,{className:`block truncate text-[10px] text-muted-foreground/65`,children:[e.path.split(`/`).pop(),!e.depsInstalled&&` · deps missing`]})]}),r&&(0,F.jsx)(`span`,{className:`rounded-full border border-primary/25 bg-primary/10 px-1.5 py-0.5 text-[9px] font-semibold uppercase tracking-wide text-primary`,children:`active`})]})]},e.id)}),!e?.length&&(0,F.jsx)(`div`,{className:`px-2 py-3 text-center text-[12px] text-muted-foreground`,children:`No domains found`})]}),(0,F.jsx)(`div`,{className:`my-1 h-px bg-border/60`}),t&&m>1&&(0,F.jsxs)(`button`,{type:`button`,onClick:()=>a([t]),className:`flex w-full items-center rounded-md px-2 py-1.5 text-left text-[11px] font-medium text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground`,children:[`Show only `,d?.origin??`active domain`]}),(0,F.jsxs)(`button`,{type:`button`,onClick:()=>{c(!1),u(!0)},className:`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm font-medium text-primary transition-colors hover:bg-primary/10`,children:[(0,F.jsx)(`span`,{className:`flex h-4 w-4 shrink-0 items-center justify-center`,children:(0,F.jsx)(Sn,{className:`h-3.5 w-3.5`})}),`Create new domain`]})]})]}),(0,F.jsx)(QD,{open:l,onOpenChange:u,onCreated:e=>{a([e]),n(e),r(`context`)}})]})}function QD({open:e,onOpenChange:t,onCreated:n}){let r=Le(),[i,a]=(0,P.useState)(``),[o,s]=(0,P.useState)(!1),[c,l]=(0,P.useState)(null),u=i.trim().toLowerCase(),d=!!u&&u.length<=64&&XD.test(u),f=u?u.includes(`.`)?u:`${u}.example.dev`:``,p=()=>{a(``),l(null),s(!1)},m=e=>{o||(e||p(),t(e))},h=async()=>{if(!(!d||o)){s(!0),l(null);try{let e=await z.createDomain(u);e.ok&&e.id?(await r.invalidateQueries({queryKey:B.workspace}),n(e.id),I.success(`Created ${e.origin??u}`),p(),t(!1)):l(e.error||`Could not create the domain — check the studio logs.`)}catch(e){l(e?.message??String(e))}finally{s(!1)}}};return(0,F.jsx)(xy,{open:e,onOpenChange:m,children:(0,F.jsxs)(wy,{className:`max-w-md`,children:[(0,F.jsxs)(Ty,{children:[(0,F.jsx)(Dy,{children:`Create a new domain`}),(0,F.jsxs)(Oy,{children:[`Scaffolds a fresh Astrale domain with`,` `,(0,F.jsx)(`span`,{className:`font-mono text-[12px]`,children:`create-astrale-domain`}),` and installs its dependencies.`]})]}),(0,F.jsxs)(`div`,{className:`space-y-3 py-1`,children:[(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsx)(`label`,{htmlFor:`new-domain-name`,className:`text-[12px] font-medium text-muted-foreground`,children:`Domain name`}),(0,F.jsx)(YD,{id:`new-domain-name`,autoFocus:!0,value:i,disabled:o,placeholder:`crm`,spellCheck:!1,autoComplete:`off`,className:`font-mono`,onChange:e=>{a(e.target.value),l(null)},onKeyDown:e=>{e.key===`Enter`&&h()}})]}),u&&d&&(0,F.jsxs)(`div`,{className:`space-y-0.5 rounded-lg border bg-muted/30 px-3 py-2 text-[12px] leading-relaxed text-muted-foreground`,children:[(0,F.jsxs)(`div`,{children:[`origin `,(0,F.jsx)(`span`,{className:`font-mono text-foreground`,children:f}),!u.includes(`.`)&&(0,F.jsx)(`span`,{className:`text-muted-foreground/70`,children:` · placeholder, edit later`})]}),(0,F.jsxs)(`div`,{children:[`folder `,(0,F.jsxs)(`span`,{className:`font-mono text-foreground`,children:[u,`/`]}),` · managed (astrale) adapter`]})]}),u&&!d&&(0,F.jsx)(`p`,{className:`text-[12px] text-destructive`,children:`Use lowercase letters, digits, dots and dashes.`}),c&&(0,F.jsx)(`div`,{className:`rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-[12px] leading-relaxed text-destructive`,children:c}),o&&(0,F.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-muted-foreground`,children:[(0,F.jsx)(Pn,{className:`h-3.5 w-3.5 animate-spin`}),` Scaffolding and installing dependencies — this can take a moment…`]})]}),(0,F.jsxs)(Ey,{children:[(0,F.jsx)(Jh,{variant:`ghost`,onClick:()=>m(!1),disabled:o,children:`Cancel`}),(0,F.jsx)(Jh,{onClick:h,disabled:!d||o,children:o?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(Pn,{className:`h-4 w-4 animate-spin`}),` Creating…`]}):`Create domain`})]})]})})}function $D({domainId:e}){let{data:t}=ei(e,`dev`),n=V(e=>e.setSettingsOpen),r=t?.requiredMissing??0;return r===0?null:(0,F.jsxs)(`button`,{type:`button`,onClick:()=>n(!0),title:`${r} required env var${r===1?``:`s`} need a value — open Settings → Environment`,className:`inline-flex h-7 items-center gap-1.5 rounded-md border border-destructive/40 bg-destructive/10 px-2 text-xs font-medium text-destructive transition-colors hover:bg-destructive/20`,children:[(0,F.jsx)(Dn,{className:`h-3.5 w-3.5`}),(0,F.jsxs)(`span`,{children:[r,` env`]}),(0,F.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-destructive`})]})}function eO(e,t){return e.declared?!e.optional&&t===``?{dot:`bg-destructive`,label:`required`,tone:`text-destructive`}:t===``?{dot:`bg-muted-foreground/40`,label:`optional`,tone:`text-muted-foreground/60`}:{dot:`bg-emerald-500`,label:`set`,tone:`text-muted-foreground/60`}:{dot:`bg-amber-500`,label:`orphan`,tone:`text-amber-600 dark:text-amber-500`}}var tO=[`dev`,`prod`];function nO({domainId:e}){let[t,n]=(0,P.useState)(`dev`),{data:r,isLoading:i}=ei(e,t),a=Le(),[o,s]=(0,P.useState)({}),[c,l]=(0,P.useState)(()=>new Set);(0,P.useEffect)(()=>{s({}),l(new Set)},[t,e]);let u=$e({mutationFn:()=>z.setEnv(e,t,o),onSuccess:n=>{a.setQueryData(B.env(e,t),n),s({}),I.success(`Saved ${n.file}`)},onError:e=>I.error(String(e))}),d=(r?.rows??[]).filter(e=>o[e.name]!==null),f=Object.keys(o).length>0,p=e=>e.name in o?o[e.name]??``:e.value,m=e=>l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});return(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between px-1`,children:[(0,F.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wider text-muted-foreground/70`,children:`Environment`}),(0,F.jsx)(`div`,{className:`flex items-center gap-0.5 rounded-md border bg-card/40 p-0.5`,children:tO.map(e=>(0,F.jsx)(`button`,{type:`button`,onClick:()=>n(e),className:K(`rounded px-2 py-0.5 text-[11px] font-medium transition-colors`,t===e?`bg-primary text-primary-foreground`:`text-muted-foreground hover:text-foreground`),children:e},e))})]}),r&&(0,F.jsxs)(`div`,{className:`mb-1.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 px-1 text-[10px] text-muted-foreground/60`,children:[(0,F.jsx)(`span`,{className:`font-mono`,children:r.file}),!r.exists&&(0,F.jsx)(`span`,{children:`· new on save`}),!r.configured&&(0,F.jsx)(`span`,{className:`text-amber-600 dark:text-amber-500`,children:`· not wired in astrale.config`}),t===`prod`&&r.adapter===`astrale`&&(0,F.jsx)(`span`,{children:"· managed prod → platform store on `pnpm prod`"}),r.requiredMissing>0&&(0,F.jsxs)(`span`,{className:`font-medium text-destructive`,children:[`· `,r.requiredMissing,` required missing`]})]}),(0,F.jsx)(`div`,{className:`divide-y divide-border/50 rounded-lg border bg-card/40`,children:i&&!r?(0,F.jsxs)(`div`,{className:`px-3 py-2.5 text-[12px] text-muted-foreground/70`,children:[`Loading `,t,` env…`]}):d.length===0?(0,F.jsxs)(`div`,{className:`px-3 py-2.5 text-[12px] text-muted-foreground/70`,children:[`No variables declared in env.ts and none set in `,r?.file,`.`]}):d.map(e=>{let t=p(e),n=eO(e,t),r=c.has(e.name);return(0,F.jsxs)(`div`,{className:`space-y-1 px-3 py-2`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(`span`,{className:K(`h-1.5 w-1.5 shrink-0 rounded-full`,n.dot),title:n.label}),(0,F.jsx)(`span`,{className:`truncate font-mono text-[12px]`,children:e.name}),(0,F.jsx)(`span`,{className:K(`shrink-0 text-[10px]`,n.tone),children:n.label}),(0,F.jsxs)(`div`,{className:`ml-auto flex min-w-0 flex-1 items-center gap-1`,children:[(0,F.jsx)(`input`,{type:r?`text`:`password`,value:t,onChange:t=>s(n=>({...n,[e.name]:t.target.value})),placeholder:!e.optional&&e.declared?`required — set a value`:`unset`,spellCheck:!1,autoComplete:`off`,className:`w-full min-w-0 rounded-md border bg-background px-2 py-1 font-mono text-[12px] outline-none placeholder:text-muted-foreground/40 focus:border-primary`}),(0,F.jsx)(`button`,{type:`button`,onClick:()=>m(e.name),title:r?`Hide`:`Reveal`,className:`shrink-0 rounded p-1 text-muted-foreground/50 hover:text-foreground`,children:r?(0,F.jsx)(pn,{className:`h-3.5 w-3.5`}):(0,F.jsx)(mn,{className:`h-3.5 w-3.5`})}),!e.declared&&(0,F.jsx)(`button`,{type:`button`,onClick:()=>s(t=>({...t,[e.name]:null})),title:`Remove this variable from the file`,className:`shrink-0 rounded p-1 text-muted-foreground/50 hover:text-destructive`,children:(0,F.jsx)(or,{className:`h-3.5 w-3.5`})})]})]}),e.doc&&(0,F.jsx)(`p`,{className:`pl-3.5 text-[11px] leading-snug text-muted-foreground/70`,children:e.doc})]},e.name)})}),(0,F.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-2 px-1`,children:[(0,F.jsxs)(`p`,{className:`flex items-center gap-1 text-[10px] text-muted-foreground/50`,children:[(0,F.jsx)(sr,{className:`h-3 w-3`}),` Plaintext in `,r?.file??`.env.${t}`,` `,`(gitignored) · edits the file, not a deploy`]}),f&&(0,F.jsxs)(`button`,{type:`button`,onClick:()=>u.mutate(),disabled:u.isPending,className:`ml-auto inline-flex items-center gap-1 rounded-md bg-primary px-2.5 py-1 text-[12px] font-medium text-primary-foreground transition-opacity hover:opacity-90 disabled:opacity-50`,children:[u.isPending&&(0,F.jsx)(Pn,{className:`h-3 w-3 animate-spin`}),` Save `,t]})]})]})}function rO(e){if(!e)return{kind:`unknown`,optional:!1};let t=e.type,n=Array.isArray(t)?t.includes(`null`):!1,r=Array.isArray(t)?t.find(e=>e!==`null`):t;if(e.enum)return{kind:`enum`,values:e.enum,optional:n};if(e.$nodeRef)return{kind:`ref`,target:`node`,refKind:`node`,optional:n};if(e.$dataRef)return{kind:`ref`,target:`data`,refKind:`data`,optional:n};if(r===`array`)return{kind:`array`,items:rO(e.items),optional:n};if(r===`object`){let t={};for(let[n,r]of Object.entries(e.properties??{}))t[n]=rO(r);return{kind:`object`,fields:t,required:e.required??[],optional:n}}return r===`string`||r===`number`||r===`integer`||r===`boolean`||r===`null`?{kind:r,optional:n}:{kind:`unknown`,optional:n}}function iO(e){switch(e.kind){case`enum`:return`enum(${e.values.map(String).join(` | `)})`;case`array`:return`${iO(e.items)}[]`;case`object`:return`{ ${Object.keys(e.fields).join(`, `)} }`;case`ref`:return`→${e.target}`;default:return e.kind}}function aO({schema:e,className:t}){let n=rO(e);return(0,F.jsxs)(`span`,{className:K(`font-mono text-xs`,{string:`text-emerald-400`,integer:`text-sky-400`,number:`text-sky-400`,boolean:`text-amber-400`,enum:`text-fuchsia-400`,object:`text-violet-400`,array:`text-violet-400`,ref:`text-rose-400`,unknown:`text-muted-foreground`,null:`text-muted-foreground`}[n.kind]??`text-muted-foreground`,t),children:[iO(n),n.optional&&(0,F.jsx)(`span`,{className:`text-muted-foreground`,children:`?`})]})}function oO(e){return e?e.replace(/^sha256:/,``).replace(/^sha-?/,``).slice(0,8):`—`}function sO(e){return e.deployable?e.install===`unknown`?{word:`unreachable`,tone:`text-muted-foreground`,dot:`bg-muted-foreground/40`}:e.install===`not-installed`?{word:`not installed`,tone:`text-warning`,dot:`bg-warning`}:e.drift===`drifted`?{word:`drifted`,tone:`text-warning`,dot:`bg-warning`}:{word:`installed`,tone:`text-success`,dot:`bg-success`}:{word:`local only`,tone:`text-muted-foreground`,dot:`bg-muted-foreground/40`}}function cO({domainId:e}){let{data:t}=ti(e),{data:n}=Hr(e),{data:r}=Vr(),i=Le(),[a,o]=(0,P.useState)(`idle`),[s,c]=(0,P.useState)(null);if(!t)return null;let l=sO(t),u=n?!n.depsInstalled:!1,d=r?.active??null,f=!!t.deployTarget&&!!d&&t.deployTarget!==d;return(0,F.jsxs)(Zw,{onOpenChange:e=>{!e&&a!==`deploying`&&(o(`idle`),c(null))},children:[(0,F.jsx)(Qw,{asChild:!0,children:(0,F.jsxs)(`button`,{type:`button`,title:`Deploy — ${l.word}`,className:`inline-flex h-7 items-center gap-1.5 rounded-md border bg-card px-2 text-xs font-medium text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground`,children:[(0,F.jsx)(cn,{className:`h-3.5 w-3.5`}),(0,F.jsx)(`span`,{children:`Deploy`}),(0,F.jsx)(`span`,{className:K(`h-1.5 w-1.5 rounded-full`,u?`bg-warning`:l.dot)})]})}),(0,F.jsxs)(eT,{align:`end`,className:`w-64 space-y-2.5 p-3`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-muted-foreground/70`,children:`Deploy target instance`}),(0,F.jsxs)(`div`,{className:`mt-0.5 flex items-center justify-between gap-2`,children:[(0,F.jsx)(`span`,{className:`truncate text-sm font-semibold`,children:t.deployTarget??`no target`}),(0,F.jsxs)(`span`,{className:K(`inline-flex shrink-0 items-center gap-1 text-xs font-medium`,l.tone),children:[(0,F.jsx)(`span`,{className:K(`h-1.5 w-1.5 rounded-full`,l.dot)}),` `,l.word]})]}),t.deployTarget&&(0,F.jsxs)(`div`,{className:`mt-0.5 text-[10px] text-muted-foreground/60`,children:[`from `,(0,F.jsx)(`code`,{className:`font-mono`,children:`astrale.config.ts`})]})]}),t.drift===`drifted`?(0,F.jsxs)(`div`,{className:`space-y-0.5 font-mono text-[11px]`,children:[(0,F.jsxs)(`div`,{className:`text-warning`,children:[`local `,oO(t.localRevision??``)]}),(0,F.jsxs)(`div`,{className:`text-muted-foreground`,children:[`on instance `,oO(t.installedRevision??``)]})]}):(0,F.jsx)(`div`,{className:`font-mono text-[11px] text-muted-foreground`,children:t.localRevision?oO(t.localRevision):`revision unavailable`}),t.install===`unknown`&&t.deployTarget&&(0,F.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:`Can’t reach it to check status — deploy still works.`}),u&&(0,F.jsx)(`div`,{className:`text-[11px] text-warning`,children:`Dependencies not installed`}),f&&(0,F.jsxs)(`div`,{className:`text-[11px] leading-snug text-muted-foreground`,children:[`Independent of your active instance (`,(0,F.jsx)(`b`,{children:d}),`).`]}),t.deployable?a===`idle`?(0,F.jsxs)(Jh,{size:`sm`,className:`w-full`,onClick:async()=>{o(`deploying`),c(null);try{let t=await z.deployInstance(e);c(t),o(`done`),i.invalidateQueries({queryKey:B.instance(e)}),t.ok?I.success(`Deployed & installed`):I.error(`Deploy failed`)}catch(e){c({ok:!1,url:null,output:String(e)}),o(`done`)}},children:[(0,F.jsx)(cn,{className:`h-3.5 w-3.5`}),` `,t.install===`installed`?`Re-deploy`:`Deploy & install`]}):a===`deploying`?(0,F.jsxs)(Jh,{size:`sm`,className:`w-full`,disabled:!0,children:[(0,F.jsx)(Pn,{className:`h-3.5 w-3.5 animate-spin`}),` Deploying…`]}):(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsxs)(`div`,{className:K(`flex items-center gap-1.5 text-xs font-medium`,s?.ok?`text-success`:`text-destructive`),children:[s?.ok?(0,F.jsx)($t,{className:`h-3.5 w-3.5`}):(0,F.jsx)(sr,{className:`h-3.5 w-3.5`}),s?.ok?`Deployed`:`Failed`]}),s?.output&&(0,F.jsx)(`pre`,{className:`max-h-28 overflow-auto whitespace-pre-wrap break-all rounded bg-muted/50 p-1.5 text-[10px] leading-tight text-muted-foreground`,children:s.output.slice(-1200)}),(0,F.jsx)(Jh,{size:`xs`,variant:`outline`,className:`w-full`,onClick:()=>o(`idle`),children:`Done`})]}):null]})]})}function lO(e){let t=e?.trim();if(!t)return null;try{let e=new URL(t);return(e.pathname===`/api`||e.pathname===`/api/`)&&(e.pathname=`/`),e.href.replace(/\/$/,``)}catch{return t.replace(/\/api\/?$/,``)}}function uO(){let{data:e}=Vr(),t=Le(),[n,r]=(0,P.useState)(!1),[i,a]=(0,P.useState)(null),o=e?.active??null,s=e?.instances??[],c=async e=>{if(!(e===o||i)){a(e);try{let n=await z.switchInstance(e);n.ok?(await t.invalidateQueries({queryKey:B.instances}),I.success(`Switched to ${n.active??e}`),r(!1)):I.error(`Couldn't switch: ${n.output.split(`
|
|
80
80
|
`).filter(Boolean).pop()??`failed`}`)}finally{a(null)}}};return(0,F.jsxs)(Zw,{open:n,onOpenChange:r,children:[(0,F.jsx)(`div`,{className:`-ml-1 inline-flex items-center gap-0.5`,children:(0,F.jsx)(Qw,{asChild:!0,children:(0,F.jsxs)(`button`,{type:`button`,title:`Active instance — click to switch`,className:`inline-flex items-center gap-2 rounded-lg px-2 py-1 transition-colors hover:bg-accent/50`,children:[(0,F.jsx)(`span`,{className:`grid h-7 w-7 place-items-center rounded-lg bg-primary/15 text-primary`,children:(0,F.jsx)(Hn,{className:`h-4 w-4`})}),(0,F.jsx)(`span`,{className:`font-semibold tracking-tight`,children:o??`no instance`}),(0,F.jsx)(nn,{className:`h-3.5 w-3.5 text-muted-foreground`})]})})}),(0,F.jsxs)(eT,{align:`start`,className:`w-64 p-1.5`,children:[(0,F.jsx)(`div`,{className:`px-2 py-1 text-[11px] font-semibold uppercase tracking-wider text-muted-foreground`,children:`Active instance`}),(0,F.jsxs)(`div`,{className:`space-y-0.5`,children:[s.map(e=>{let t=lO(e.url);return(0,F.jsxs)(`div`,{className:K(`flex w-full items-center gap-1 rounded-md transition-colors hover:bg-accent`,e.active&&`bg-accent/40`),children:[(0,F.jsxs)(`button`,{type:`button`,onClick:()=>c(e.name),className:`flex min-w-0 flex-1 items-center gap-2 px-2 py-1.5 text-left`,children:[(0,F.jsx)(`span`,{className:`flex h-4 w-4 shrink-0 items-center justify-center`,children:i===e.name?(0,F.jsx)(Pn,{className:`h-3.5 w-3.5 animate-spin text-primary`}):e.active?(0,F.jsx)($t,{className:`h-3.5 w-3.5 text-primary`}):null}),(0,F.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,F.jsx)(`span`,{className:`block truncate text-sm font-medium`,children:e.name}),(0,F.jsx)(`span`,{className:`block truncate text-[11px] text-muted-foreground`,children:t?t.replace(/^https?:\/\//,``):`no URL`})]}),e.kind===`managed`&&(0,F.jsx)(`span`,{className:`shrink-0 text-[9px] uppercase tracking-wide text-muted-foreground/50`,children:`managed`})]}),t&&(0,F.jsx)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,title:`Open ${e.name} in a new tab`,className:`mr-1 inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-background/60 hover:text-foreground`,children:(0,F.jsx)(fn,{className:`h-3.5 w-3.5`})})]},e.name)}),s.length===0&&(0,F.jsx)(`div`,{className:`px-2 py-3 text-center text-[12px] text-muted-foreground`,children:`No instances found`})]})]})]})}function dO(e,t){if(t)return e.includes(t)?t:t===`max`&&e.includes(`xhigh`)||t===`ultracode`&&e.includes(`xhigh`)?`xhigh`:t===`minimal`&&e.includes(`low`)?`low`:e.includes(`high`)?`high`:e[0]}var fO=[`minimal`,`low`,`medium`,`high`,`xhigh`,`max`,`ultracode`],pO=[`workspace`,`full`];function mO(e,t,n){let r=t.trim().toLowerCase();if(!r)return e;let i={...e},a=n.trim();return a?i[r]=a:delete i[r],i}function hO({text:e}){return(0,F.jsxs)(SD,{openDelay:80,children:[(0,F.jsx)(CD,{asChild:!0,children:(0,F.jsx)(`button`,{type:`button`,"aria-label":`What's this?`,className:`text-muted-foreground/40 transition-colors hover:text-foreground`,children:(0,F.jsx)(an,{className:`h-3.5 w-3.5`})})}),(0,F.jsx)(wD,{className:`w-auto max-w-xs text-[13px] leading-relaxed text-muted-foreground`,children:e})]})}function gO({selected:e,loadout:t,modelOptions:n,onChange:r}){let i=t?.models??n??[],a=e||t?.model||`harness default`;return(0,F.jsxs)(`div`,{className:`space-y-1.5 px-3 py-2.5`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[13px]`,children:[(0,F.jsx)(`span`,{children:`Model`}),(0,F.jsx)(hO,{text:`Leave this on Default to preserve the selected harness's own config and account default. An explicit choice is remembered independently for this domain and harness, then passed as --model to normal turns, resumed turns, and Ask forks.`}),(0,F.jsx)(`span`,{className:`ml-auto max-w-[55%] truncate font-mono text-[11px] text-muted-foreground/70`,children:a})]}),(0,F.jsx)(`input`,{"aria-label":`Agent model`,list:i.length>0?`agent-model-options`:void 0,value:e,onChange:e=>r(e.target.value),placeholder:t?.nativeModel?`Default — ${t.nativeModel}`:`Default — choose an alias or type a full model id`,spellCheck:!1,className:`w-full rounded-md border bg-background px-2 py-1 font-mono text-[12px] outline-none focus:border-primary`}),i.length>0&&(0,F.jsx)(`datalist`,{id:`agent-model-options`,children:i.map(e=>(0,F.jsx)(`option`,{value:e.id,label:`${e.label}${e.isDefault?` — catalog default`:``}`},e.id))}),(0,F.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50`,children:e?`Studio override · saved when you press Save`:t?.modelSource===`config`?`Codex effective config`:t?.modelSource==="default"?`Harness catalog default`:t?.modelSource===`runtime`?`Harness runtime default`:`Harness-native selection`})]})}var _O={minimal:`Minimal`,low:`Low`,medium:`Medium`,high:`High`,xhigh:`X-high`,max:`Max`,ultracode:`Ultracode`},vO={workspace:`Workspace`,full:`Full automation`};function yO({value:e,levels:t,onChange:n}){let r=dO(t,e);return(0,F.jsx)(`div`,{className:`grid grid-cols-3 gap-1 rounded-md bg-muted/45 p-1 sm:grid-cols-6`,role:`radiogroup`,"aria-label":`Agent effort`,children:t.map(e=>(0,F.jsx)(`button`,{type:`button`,value:e,title:e===`ultracode`?`Claude: X-high effort plus dynamic workflow orchestration`:void 0,role:`radio`,"aria-checked":r===e,onClick:()=>n(e),className:K(`min-w-0 rounded px-1.5 py-1 text-center text-[11px] font-medium transition-colors`,r===e?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:bg-background/60 hover:text-foreground`),children:_O[e]},e))})}function bO({value:e,levels:t,onChange:n}){let r=pO.includes(e)&&t.includes(e)?e:t.includes(`full`)?`full`:t[0];return(0,F.jsx)(`div`,{className:`grid grid-cols-2 gap-1 rounded-md bg-muted/45 p-1`,role:`radiogroup`,children:t.map(e=>(0,F.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":r===e,onClick:()=>n(e),className:K(`rounded px-2 py-1 text-center text-[11px] font-medium transition-colors`,r===e?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:bg-background/60 hover:text-foreground`),children:vO[e]},e))})}function xO({domainId:e,harness:t}){let{data:n,isFetching:r}=qr(e),i=Le(),[a,o]=(0,P.useState)(``),s=!n?.harness||n.harness===t?.id;(0,P.useEffect)(()=>{if(!e||!t||r||!s){o(``);return}o(n?.sessionId??``)},[e,t?.id,r,s,n?.harness,n?.sessionId]);let c=$e({mutationFn:e=>z.setAgentSession(e.domainId,e.harness,e.sessionId),onSuccess:(e,t)=>{i.setQueryData(B.agentSession(t.domainId),e),i.invalidateQueries({queryKey:B.agent(t.domainId)}),I.success(e.sessionId?`Agent session changed`:`Agent session cleared`)},onError:e=>I.error(String(e))});return(0,F.jsxs)(`div`,{className:`space-y-1.5 px-3 py-2.5`,children:[(0,F.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[13px]`,children:[(0,F.jsx)(`span`,{children:`Session ID`}),(0,F.jsx)(hO,{text:`The agent's resumable conversation id. Paste another to resume that conversation; clear it to start fresh on the next turn. Cannot be changed while a turn is running.`}),n&&(0,F.jsx)(`span`,{className:`ml-auto text-[11px] text-muted-foreground/60`,children:n.sessionId?`${n.turns} turn${n.turns===1?``:`s`}${n.harness?` · ${n.harness}`:``}`:`no active conversation`})]}),(0,F.jsx)(`input`,{value:a,onChange:e=>o(e.target.value),placeholder:`(none — a fresh conversation starts next turn)`,spellCheck:!1,className:`w-full rounded-md border bg-background px-2 py-1 font-mono text-[12px] outline-none focus:border-primary`}),(0,F.jsx)(`div`,{className:`flex justify-end`,children:(0,F.jsx)(`button`,{type:`button`,disabled:!e||!t||r||!s||a.trim()===(n?.sessionId??``)||c.isPending,onClick:()=>c.mutate({domainId:e,harness:t.id,sessionId:a.trim()}),className:`rounded-md px-2.5 py-1 text-[12px] font-medium text-primary transition-colors hover:bg-primary/10 disabled:opacity-40`,children:c.isPending?`Applying…`:`Apply session`})})]})}var SO=[`astrale-cli`,`astrale-domain`,`agent-browser`],CO={"astrale-cli":[`npx skills add astrale-os/cli -g`],"astrale-domain":[`npx skills add astrale-os/cli -g`],"agent-browser":[`npm install -g agent-browser && agent-browser install`,`npx skills add vercel-labs/agent-browser -g`]};function wO({skill:e,domainId:t,expanded:n,onToggle:r}){let{data:i,isLoading:a}=$r(n?t:void 0,n?e.command:void 0),o=e.source===`plugin`?e.plugin??`plugin`:e.source;return(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`button`,{type:`button`,onClick:r,className:`flex w-full items-center gap-2 px-2.5 py-1.5 text-left transition-colors hover:bg-muted/40`,title:e.description??e.command,children:[(0,F.jsx)(`span`,{className:K(`h-1.5 w-1.5 shrink-0 rounded-full`,e.loaded?`bg-emerald-500`:`bg-amber-500`),title:e.loaded?`available to the selected harness here`:`installed but disabled here`}),(0,F.jsx)(`span`,{className:`truncate font-mono text-[12px]`,children:e.command}),(0,F.jsx)(`span`,{className:`ml-auto shrink-0 rounded bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground/80`,children:o}),(0,F.jsx)(tn,{className:K(`h-3 w-3 shrink-0 text-muted-foreground/50 transition-transform`,n&&`rotate-90`)})]}),n&&(0,F.jsx)(`div`,{className:`border-t bg-background/60 px-2.5 py-2`,children:a?(0,F.jsx)(`p`,{className:`text-[11px] text-muted-foreground/60`,children:`Loading…`}):i?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`pre`,{className:`max-h-64 overflow-auto whitespace-pre-wrap break-words rounded bg-muted/40 p-2 text-[11px] leading-relaxed`,children:i.content}),(0,F.jsx)(`p`,{className:`mt-1 truncate font-mono text-[10px] text-muted-foreground/50`,title:i.path,children:i.path})]}):(0,F.jsx)(`p`,{className:`text-[11px] text-muted-foreground/60`,children:`Couldn't read this skill's SKILL.md.`})})]})}function TO({command:e}){let[t,n]=(0,P.useState)(!1);return(0,F.jsxs)(`button`,{type:`button`,onClick:async()=>{try{await navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),1500)}catch{I.error(`Copy failed — select the command and copy it manually.`)}},className:`group flex w-full items-center gap-2 rounded bg-muted/40 px-2 py-1 text-left font-mono text-[11px] transition-colors hover:bg-muted`,title:`Copy to clipboard`,children:[(0,F.jsx)(`span`,{className:`truncate`,children:e}),t?(0,F.jsx)($t,{className:`ml-auto h-3 w-3 shrink-0 text-emerald-500`}):(0,F.jsx)(ln,{className:`ml-auto h-3 w-3 shrink-0 text-muted-foreground/50 transition-colors group-hover:text-foreground`})]})}function EO({command:e}){let[t,n]=(0,P.useState)(!1),r=CO[e];return(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`button`,{type:`button`,onClick:()=>r&&n(e=>!e),className:`flex w-full items-center gap-2 px-2.5 py-1.5 text-left transition-colors hover:bg-muted/40`,title:`not installed on disk in this workspace — click to see how`,children:[(0,F.jsx)(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full bg-destructive`,title:`not installed`}),(0,F.jsx)(`span`,{className:`truncate font-mono text-[12px] text-muted-foreground/60 line-through`,children:e}),(0,F.jsx)(`span`,{className:`ml-auto shrink-0 rounded bg-destructive/15 px-1.5 py-0.5 text-[10px] font-medium text-destructive`,children:`not installed`}),r&&(0,F.jsx)(tn,{className:K(`h-3 w-3 shrink-0 text-muted-foreground/50 transition-transform`,t&&`rotate-90`)})]}),t&&r&&(0,F.jsxs)(`div`,{className:`space-y-1.5 border-t bg-background/60 px-2.5 py-2`,children:[(0,F.jsx)(`p`,{className:`text-[11px] text-muted-foreground/70`,children:`Run, then hit re-probe above:`}),r.map(e=>(0,F.jsx)(TO,{command:e},e)),(0,F.jsxs)(`p`,{className:`text-[10px] text-muted-foreground/50`,children:[`Or run `,(0,F.jsx)(`span`,{className:`font-mono`,children:`astrale setup`}),` to equip everything at once.`]})]})]})}function DO({skills:e,domainId:t}){let[n,r]=(0,P.useState)(!1),[i,a]=(0,P.useState)(null),o=new Map(e.map(e=>[e.command,e])),s=new Set(SO),c=e.filter(e=>!s.has(e.command)).sort((e,t)=>Number(e.loaded)-Number(t.loaded)||e.command.localeCompare(t.command));return(0,F.jsxs)(`div`,{className:`space-y-1`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,F.jsx)(`span`,{children:`Skills`}),(0,F.jsxs)(`span`,{className:`ml-auto font-mono text-[11px] text-muted-foreground/80`,children:[e.filter(e=>e.loaded).length,` loaded / `,e.length]})]}),(0,F.jsxs)(`div`,{className:K(`divide-y divide-border/50 overflow-hidden rounded-md border bg-background/40`,n&&`max-h-64 overflow-y-auto`),children:[SO.map(e=>{let n=o.get(e);return n?(0,F.jsx)(wO,{skill:n,domainId:t,expanded:i===e,onToggle:()=>a(t=>t===e?null:e)},e):(0,F.jsx)(EO,{command:e},e)}),n&&c.map(e=>(0,F.jsx)(wO,{skill:e,domainId:t,expanded:i===e.command,onToggle:()=>a(t=>t===e.command?null:e.command)},e.command))]}),c.length>0&&(0,F.jsx)(`button`,{type:`button`,onClick:()=>r(e=>!e),className:`px-1 text-[11px] text-muted-foreground/60 transition-colors hover:text-foreground`,children:n?`Hide others`:`Show all (${c.length} more)`})]})}function OO({label:e,value:t,title:n,hint:r}){return(0,F.jsxs)(`div`,{className:`flex items-center gap-3`,title:n,children:[(0,F.jsxs)(`span`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[e,r&&(0,F.jsx)(hO,{text:r})]}),(0,F.jsx)(`span`,{className:`ml-auto truncate font-mono text-[11px]`,children:t})]})}var kO=e=>e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e);function AO({domainId:e}){let[t,n]=(0,P.useState)(!1),{data:r,isLoading:i,error:a}=Jr(t?e:void 0);return(0,F.jsxs)(`div`,{className:`space-y-2 px-3 py-2.5 text-[12px]`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[13px]`,children:[(0,F.jsx)(`span`,{children:`Injected system prompt`}),(0,F.jsx)(hO,{text:`The exact developer/system appendix passed to the selected local harness. It is hidden by default because it is long and mostly protocol.`})]}),(0,F.jsx)(`button`,{type:`button`,onClick:()=>n(e=>!e),className:`ml-auto rounded-md px-1.5 py-0.5 text-[11px] text-muted-foreground/70 transition-colors hover:bg-accent hover:text-foreground`,children:t?`Hide`:`Show`})]}),t&&(0,F.jsx)(`div`,{children:i?(0,F.jsx)(`p`,{className:`text-[11px] text-muted-foreground/70`,children:`Loading…`}):a?(0,F.jsx)(`p`,{className:`text-[11px] text-destructive`,children:String(a?.message??a)}):(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`pre`,{className:`max-h-64 overflow-auto whitespace-pre-wrap break-words rounded bg-muted/40 p-2 font-mono text-[11px] leading-relaxed`,children:r?.systemPrompt??``}),(0,F.jsxs)(`p`,{className:`mt-1 text-[10px] text-muted-foreground/50`,children:[`bridge tools: `,r?.bridge?`enabled`:`disabled`]})]})})]})}function jO({loadout:e,loading:t,errorMessage:n,usage:r,domainId:i,onRefresh:a}){let o=e?.source===`configured`?`What the selected harness has configured or installed for this folder. Codex discovers runtime tools when a turn starts.`:`What the selected harness actually loaded for this folder, probed from its runtime initialization event.`;return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(AO,{domainId:i}),(0,F.jsxs)(`div`,{className:`space-y-2 px-3 py-2.5 text-[12px]`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[13px]`,children:[(0,F.jsx)(`span`,{children:`Loaded by the harness`}),(0,F.jsx)(hO,{text:o}),(0,F.jsxs)(`button`,{type:`button`,disabled:t,onClick:a,className:`ml-auto inline-flex items-center gap-1 text-[11px] text-muted-foreground/60 transition-colors hover:text-foreground disabled:opacity-50`,title:`Re-probe`,children:[(0,F.jsx)(qn,{className:K(`h-3 w-3`,t&&`animate-spin`)}),` re-probe`]})]}),n?(0,F.jsx)(`p`,{className:`text-[11px] leading-relaxed text-destructive`,children:n.includes(`404`)?`The studio server predates this feature (no /agent/loadout route). Restart it — bun server/index.ts … — to pick it up.`:n}):t&&!e?(0,F.jsx)(`p`,{className:`text-[11px] text-muted-foreground/70`,children:`Probing the harness…`}):e?.ok?(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(OO,{label:`Model`,value:e.model??`—`}),(0,F.jsx)(OO,{label:`Source`,value:e.source===`configured`?`configured`:`runtime`,title:e.detail}),(0,F.jsx)(OO,{label:`Tools`,value:e.tools.length,title:e.tools.join(`, `)}),(0,F.jsx)(OO,{label:`Subagents`,value:e.agents.length,title:e.agents.join(`, `)}),(0,F.jsx)(DO,{skills:e.skills,domainId:i})]}):(0,F.jsx)(`p`,{className:`text-[11px] text-muted-foreground/70`,children:e?.detail??`Loadout unavailable.`})]}),(0,F.jsxs)(`div`,{className:`space-y-1.5 px-3 py-2.5 text-[12px]`,children:[(0,F.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[13px]`,children:[(0,F.jsx)(`span`,{children:`Usage`}),(0,F.jsx)(hO,{text:`This Studio's agent turns on this domain (succeeded or not). Machine-wide harness totals are out of scope.`}),(0,F.jsx)(`span`,{className:`ml-auto text-[11px] text-muted-foreground/60`,children:`this domain`})]}),(0,F.jsx)(OO,{label:`Turns`,value:r?.runs??0}),(0,F.jsx)(OO,{label:`Tokens`,value:kO(r?.tokens??0)}),(0,F.jsx)(OO,{label:`Cost`,value:`$${(r?.costUsd??0).toFixed(4)}`}),r?.lastTokens!=null&&(0,F.jsx)(OO,{label:`Last turn`,value:`${kO(r.lastTokens)} tok · $${(r.lastCostUsd??0).toFixed(4)}`})]})]})}function MO({domainId:e,settings:t,harness:n,values:r,setValues:i,agentModels:a,setAgentModels:o}){let{data:s,isFetching:c,error:l}=Zr(e),{data:u}=Qr(e),d=Le(),f=n?.capabilities.effortLevels??[...fO],p=n?.capabilities.accessLevels??[...pO],m=dO(f,r.agentEffort??t?.agentEffort),h=$e({mutationFn:e=>z.selectHarness(e.domainId,e.harness),onSuccess:(e,t)=>{d.setQueryData(B.harness(t.domainId),e),d.setQueryData(B.agentSession(t.domainId),void 0),d.setQueryData(B.loadout(t.domainId),void 0),d.invalidateQueries({queryKey:B.harness(t.domainId)}),d.invalidateQueries({queryKey:B.agentSession(t.domainId)}),d.invalidateQueries({queryKey:B.agent(t.domainId)}),d.invalidateQueries({queryKey:B.loadout(t.domainId)}),I.success(`Using ${e.label}`)},onError:e=>I.error(String(e))}),g=$e({mutationFn:e=>z.loadout(e,!0),onSuccess:(e,t)=>d.setQueryData(B.loadout(t),e),onError:e=>I.error(String(e))}),_=n?.options??[{id:`claude`,label:`Claude Code (local)`}],v=n?.id??`claude`,y=a[v]??``;return(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`div`,{className:`mb-1.5 px-1 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground/70`,children:`Agent`}),(0,F.jsxs)(`div`,{className:`divide-y divide-border/50 rounded-lg border bg-card/40`,children:[(0,F.jsxs)(`div`,{className:`space-y-2 px-3 py-2.5`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,F.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-1.5 text-[13px]`,children:[(0,F.jsx)(`span`,{className:`truncate`,children:`Harness`}),(0,F.jsx)(hO,{text:`Which installed local coding agent handles Studio turns. Conversations are preserved independently per harness.`})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[n?.locked&&(0,F.jsx)(Fn,{className:`h-3 w-3 shrink-0 text-muted-foreground/40`}),(0,F.jsx)(`select`,{disabled:!e||!n||n.locked||h.isPending,value:n?.id??`claude`,onChange:t=>h.mutate({domainId:e,harness:t.target.value}),className:`w-40 shrink-0 rounded-md border bg-background px-2 py-1 text-[13px] outline-none disabled:cursor-not-allowed disabled:text-muted-foreground`,children:_.map(e=>(0,F.jsx)(`option`,{value:e.id,children:e.label},e.id))})]})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px]`,children:[(0,F.jsx)(`span`,{className:K(`h-2 w-2 shrink-0 rounded-full`,n?n.ok?`bg-emerald-500`:`bg-destructive`:`bg-muted-foreground/30`)}),(0,F.jsx)(`span`,{className:K(`truncate`,n&&!n.ok?`font-medium text-destructive`:`text-muted-foreground/70`),children:n?n.message:`Checking…`}),n?.locked&&(0,F.jsx)(`span`,{className:`ml-auto shrink-0 text-muted-foreground/50`,children:`locked by --harness`})]})]}),(0,F.jsx)(gO,{selected:y,loadout:s,modelOptions:n?.capabilities.modelOptions,onChange:e=>o(t=>mO(t,v,e))}),(0,F.jsxs)(`div`,{className:`space-y-1.5 px-3 py-2.5`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[13px]`,children:[(0,F.jsx)(`span`,{children:`Effort`}),(0,F.jsx)(hO,{text:`Passed using the selected harness's native reasoning-effort setting. Only values supported by that harness are shown.`}),(0,F.jsx)(`span`,{className:`ml-auto font-mono text-[11px] text-muted-foreground/70`,children:m??`high`})]}),(0,F.jsx)(yO,{value:r.agentEffort??t?.agentEffort,levels:f,onChange:e=>i(t=>({...t,agentEffort:e}))})]}),(0,F.jsxs)(`div`,{className:`space-y-1.5 px-3 py-2.5`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[13px]`,children:[(0,F.jsx)(`span`,{children:`Access`}),(0,F.jsx)(hO,{text:`Workspace keeps the agent sandboxed to local edits. Full automation preserves Studio's deploy/install capability and grants unrestricted local command access.`}),(0,F.jsx)(`span`,{className:`ml-auto font-mono text-[11px] text-muted-foreground/70`,children:r.agentAccess??t?.agentAccess??`full`})]}),(0,F.jsx)(bO,{value:r.agentAccess??t?.agentAccess,levels:p,onChange:e=>i(t=>({...t,agentAccess:e}))})]}),(0,F.jsx)(xO,{domainId:e,harness:n}),(0,F.jsx)(jO,{loadout:s,loading:c||g.isPending,errorMessage:l?String(l?.message??l):void 0,usage:u,domainId:e,onRefresh:()=>g.mutate(e)})]})]})}var NO={introspectTimeoutMs:{min:250,max:3e5},instancePollMs:{min:1e3,max:36e5},updatesPollMs:{min:1e4,max:864e5},viewProbeTimeoutMs:{min:250,max:12e4}};function PO(e,t){if(typeof t!=`number`&&typeof t!=`string`||typeof t==`string`&&!t.trim())return null;let n=typeof t==`number`?t:Number(t),{min:r,max:i}=NO[e];return Number.isInteger(n)&&n>=r&&n<=i?n:null}var FO=[{title:`Detection`,fields:[{key:`integrationsDir`,label:`Integrations folder`,hint:`Folder under the domain root scanned for integrations.`,type:`text`,placeholder:`integrations`}]},{title:`Performance`,fields:[{key:`introspectTimeoutMs`,label:`Schema extraction timeout`,hint:`How long the Bun introspector may run before it is killed (ms). Raise for very large domains.`,type:`number`,placeholder:`20000`},{key:`instancePollMs`,label:`Instance status poll`,hint:`How often the deploy / instance status refreshes (ms). Raise to make fewer CLI calls.`,type:`number`,placeholder:`30000`},{key:`updatesPollMs`,label:`Updates check interval`,hint:`How often the studio re-checks for stale schema / available updates (ms).`,type:`number`,placeholder:`600000`},{key:`viewProbeTimeoutMs`,label:`View URL probe timeout`,hint:`How long to wait when resolving a live view URL from the instance (ms).`,type:`number`,placeholder:`8000`}]}];function IO(e,t){let n={};for(let r of FO)for(let i of r.fields){let r=e[i.key]??``;if(i.type===`number`){let e=PO(i.key,r);if(e===null)throw Error(`${i.label} must be a whole number from ${NO[i.key].min} to ${NO[i.key].max} ms`);n[i.key]=e}else n[i.key]=r.trim()||t[i.key]}return n}function LO({values:e,onChange:t}){return FO.map(n=>(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`div`,{className:`mb-1.5 px-1 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground/70`,children:n.title}),(0,F.jsx)(`div`,{className:`divide-y divide-border/50 rounded-lg border bg-card/40`,children:n.fields.map(n=>(0,F.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-2`,children:[(0,F.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-1.5 text-[13px]`,children:[(0,F.jsx)(`span`,{className:`truncate`,children:n.label}),(0,F.jsx)(hO,{text:n.hint})]}),(0,F.jsx)(`input`,{type:n.type,min:n.type===`number`?NO[n.key].min:void 0,max:n.type===`number`?NO[n.key].max:void 0,step:n.type===`number`?1:void 0,value:e[n.key]??``,onChange:e=>t(n.key,e.target.value),placeholder:n.placeholder,className:`w-32 shrink-0 rounded-md border bg-background px-2 py-1 text-right font-mono text-[13px] outline-none focus:border-primary`})]},n.key))})]},n.title))}var RO=typeof window<`u`&&window.self!==window.top,zO={mint:`Auto-mint`,token:`Static token`,host:`Host-managed`},BO=[`mint`,`token`,`host`];function VO({mode:e,setMode:t,instance:n,setInstance:r,token:i,setToken:a,reveal:o,setReveal:s}){return(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[12px] text-muted-foreground`,children:[`Authentication`,(0,F.jsx)(hO,{text:"How the harness gets its bearer token. Auto-mint: the studio mints a short-lived delegation token per run via `astrale token` (no secret stored) — best for Astrale gateways. Static token: a bearer you paste. Host-managed: the embedding Astrale app supplies it via the shell (used when the studio runs inside the Astrale GUI)."})]}),(0,F.jsx)(`div`,{className:`grid grid-cols-3 gap-1 rounded-md bg-muted/45 p-1`,role:`radiogroup`,"aria-label":`Auth mode`,children:BO.map(n=>(0,F.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":e===n,onClick:()=>t(n),className:K(`rounded px-1.5 py-1 text-center text-[11px] font-medium transition-colors`,e===n?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:bg-background/60 hover:text-foreground`),children:zO[n]},n))}),e===`mint`&&(0,F.jsxs)(`div`,{className:`space-y-1 pt-0.5`,children:[(0,F.jsx)(`input`,{value:n,onChange:e=>r(e.target.value),placeholder:`instance to mint on (blank = active instance)`,spellCheck:!1,autoComplete:`off`,className:`w-full rounded-md border bg-background px-2 py-1 font-mono text-[12px] outline-none placeholder:text-muted-foreground/40 focus:border-primary`}),(0,F.jsx)(`p`,{className:`text-[10px] leading-relaxed text-muted-foreground/60`,children:`A fresh delegation token is minted per run (no secret stored). You must be signed in to the instance and have USE on the model node.`})]}),e===`token`&&(0,F.jsxs)(`div`,{className:`space-y-1 pt-0.5`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,F.jsx)(`input`,{type:o?`text`:`password`,value:i,onChange:e=>a(e.target.value),placeholder:`bearer token (e.g. astrale token --audience <gateway-origin>)`,spellCheck:!1,autoComplete:`off`,className:`w-full min-w-0 rounded-md border bg-background px-2 py-1 font-mono text-[12px] outline-none placeholder:text-muted-foreground/40 focus:border-primary`}),(0,F.jsx)(`button`,{type:`button`,onClick:()=>s(!o),title:o?`Hide`:`Reveal`,className:`shrink-0 rounded-md p-1 text-muted-foreground/60 transition-colors hover:text-foreground`,children:o?(0,F.jsx)(pn,{className:`h-3.5 w-3.5`}):(0,F.jsx)(mn,{className:`h-3.5 w-3.5`})})]}),(0,F.jsx)(`p`,{className:`text-[10px] leading-relaxed text-muted-foreground/60`,children:`Stored locally in .domain-studio. It will stop working when the token expires.`})]}),e===`host`&&(0,F.jsx)(`p`,{className:`pt-0.5 text-[10px] leading-relaxed text-muted-foreground/60`,children:RO?`The embedding Astrale app supplies (and refreshes) the token via the shell.`:`For when the studio runs embedded in the Astrale GUI — the host then supplies the token via the shell. No effect standalone.`})]})}function HO({status:e,help:t=!1}){return(0,F.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-1.5 px-1`,children:[(0,F.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wider text-muted-foreground/70`,children:`Model gateway`}),t&&(0,F.jsx)(hO,{text:"Route the local Claude Code harness through a custom Anthropic-compatible endpoint (e.g. an Astrale ai-gateway model node) instead of its built-in auth. The URL + token are set as ANTHROPIC_BASE_URL / ANTHROPIC_AUTH_TOKEN on the spawned `claude` child ONLY — never your shell or a `claude` you run outside the studio."}),(0,F.jsx)(`span`,{className:`ml-auto text-[10px] text-muted-foreground/60`,children:e})]})}function UO({label:e,hint:t,value:n,onChange:r,placeholder:i}){return(0,F.jsxs)(`div`,{className:`space-y-1`,children:[(0,F.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[12px] text-muted-foreground`,children:[e,(0,F.jsx)(hO,{text:t})]}),(0,F.jsx)(`input`,{value:n,onChange:e=>r(e.target.value),placeholder:i,spellCheck:!1,autoComplete:`off`,className:`w-full rounded-md border bg-background px-2 py-1 font-mono text-[12px] outline-none placeholder:text-muted-foreground/40 focus:border-primary`})]})}function WO(e,t,n,r){if(!e)return null;let i=t.trim();if(!i)return`Base URL is required while the custom gateway is enabled.`;try{let e=new URL(i);if(e.protocol!==`http:`&&e.protocol!==`https:`)return`Base URL must use http:// or https://.`}catch{return`Base URL must be a valid URL.`}return n===`token`&&!r.trim()?`A static bearer token is required in token mode.`:null}function GO({domainId:e,harness:t}){let n=t?.capabilities.gateway===`anthropic`,{data:r,isFetching:i}=Xr(n?e:void 0),a=Le(),[o,s]=(0,P.useState)(!1),[c,l]=(0,P.useState)(``),[u,d]=(0,P.useState)(``),[f,p]=(0,P.useState)(RO?`host`:`mint`),[m,h]=(0,P.useState)(``),[g,_]=(0,P.useState)(``),[v,y]=(0,P.useState)(!1),[b,x]=(0,P.useState)(!1);(0,P.useEffect)(()=>{let e=r?.local??r?.global??null;s(e?.enabled??!1),l(e?.baseUrl??``),d(e?.model??``),p(e?.auth.mode??(RO?`host`:`mint`)),h(e?.auth.mode===`mint`?e.auth.instance??``:``),_(e?.auth.mode===`token`?e.auth.token:``),y(r?.local==null&&r?.global!=null),x(!1)},[e,r]);let S=()=>f===`token`?{mode:`token`,token:g.trim()}:f===`host`?{mode:`host`}:{mode:`mint`,...m.trim()?{instance:m.trim()}:{}},C=WO(o,c,f,g),w=$e({mutationFn:e=>z.setHarnessGateway(e.domainId,e.scope,e.config),onSuccess:(e,t)=>{a.invalidateQueries({queryKey:B.harnessGateway(t.domainId)}),a.invalidateQueries({queryKey:B.loadout(t.domainId)}),I.success(t.scope===`global`?`Saved for all domains`:`Saved for this domain`)},onError:e=>I.error(String(e))}),T=$e({mutationFn:e=>z.clearHarnessGateway(e,`domain`),onSuccess:(e,t)=>{a.invalidateQueries({queryKey:B.harnessGateway(t)}),a.invalidateQueries({queryKey:B.loadout(t)}),I.success(`Override removed — inheriting the default`)},onError:e=>I.error(String(e))});if(t&&!n)return(0,F.jsxs)(`div`,{children:[(0,F.jsx)(HO,{status:`not applicable`}),(0,F.jsx)(`div`,{className:`rounded-lg border bg-card/40 px-3 py-2.5 text-[12px] leading-relaxed text-muted-foreground`,children:t.id===`codex`?`Codex uses its own local login. The Astrale gateway currently exposes Chat Completions and Anthropic Messages, while Codex custom providers require the Responses API.`:`${t.label} does not expose a Studio model-gateway adapter.`})]});let E=r?.source??`none`;return(0,F.jsxs)(`div`,{children:[(0,F.jsx)(HO,{status:E===`domain`?`active for this domain`:E===`global`?`inherited from the studio-wide default`:`off — the harness uses its own Claude Code auth`,help:!0}),(0,F.jsxs)(`div`,{className:`space-y-2.5 rounded-lg border bg-card/40 px-3 py-2.5`,children:[(0,F.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-[13px]`,children:[(0,F.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked),className:`h-3.5 w-3.5 accent-primary`}),(0,F.jsx)(`span`,{children:`Use a custom model gateway`})]}),o&&(0,F.jsxs)(`div`,{className:`space-y-2.5 border-t pt-2.5`,children:[(0,F.jsx)(UO,{label:`Base URL`,hint:"ANTHROPIC_BASE_URL. Claude Code POSTs to `${baseUrl}/v1/messages`. For an Astrale model node: https://<gateway-host>/v1/models/<modelNodeId>. The token audience is derived from this URL's origin.",value:c,onChange:l,placeholder:`https://ai-gateway.astrale.ai/v1/models/<modelNodeId>`}),(0,F.jsx)(UO,{label:`Model label`,hint:"ANTHROPIC_MODEL — shown in the loadout and sent as the request `model`. Cosmetic: an Astrale gateway pins the real model by URL, so this is just a name (e.g. glm-5.2).",value:u,onChange:d,placeholder:`glm-5.2 (optional)`}),(0,F.jsx)(VO,{mode:f,setMode:p,instance:m,setInstance:h,token:g,setToken:_,reveal:b,setReveal:x})]}),(0,F.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 border-t pt-2.5 text-[12px]`,children:[(0,F.jsx)(`input`,{type:`checkbox`,checked:v,onChange:e=>y(e.target.checked),className:`h-3.5 w-3.5 accent-primary`}),(0,F.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[`Apply to all domains`,(0,F.jsx)(hO,{text:`Save as the studio-wide default for every domain (and clear this domain's own override so it inherits it). Off ⇒ this setting applies to THIS domain only. Either way it never leaks outside the studio.`})]})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2 pt-0.5`,children:[(0,F.jsx)(`button`,{type:`button`,disabled:!e||!r||i||!!C||w.isPending,onClick:()=>w.mutate({domainId:e,scope:v?`global`:`domain`,config:{enabled:o,baseUrl:c.trim(),model:u.trim()||void 0,auth:S()}}),className:`rounded-md bg-primary px-2.5 py-1 text-[12px] font-medium text-primary-foreground transition-opacity hover:opacity-90 disabled:opacity-50`,children:w.isPending?`Saving…`:v?`Save for all domains`:`Save for this domain`}),r?.local!=null&&(0,F.jsx)(`button`,{type:`button`,disabled:i||T.isPending,onClick:()=>T.mutate(e),className:`rounded-md px-2.5 py-1 text-[12px] text-muted-foreground transition-colors hover:text-foreground disabled:opacity-50`,title:`Remove this domain's override and inherit the studio-wide default (or default auth)`,children:`Reset to default`})]}),C&&(0,F.jsx)(`p`,{className:`text-[11px] text-destructive`,children:C})]})]})}function KO(){let e=V(e=>e.settingsOpen),t=V(e=>e.setSettingsOpen),n=V(e=>e.domainId),{data:r}=ri(e?n:void 0),{data:i}=Yr(e?n:void 0),a=Le(),[o,s]=(0,P.useState)({}),[c,l]=(0,P.useState)({});(0,P.useEffect)(()=>{r&&(s(Object.fromEntries(Object.entries(r).filter(([,e])=>typeof e!=`object`).map(([e,t])=>[e,String(t)]))),l({...r.agentModels}))},[r]);let u=$e({mutationFn:async e=>{let t=IO(e.values,e.settings),n=e.harness?.capabilities.effortLevels??[...fO],r=e.harness?.capabilities.accessLevels??[...pO],i=dO(n,e.values.agentEffort);i&&(t.agentEffort=i);let a=r.includes(e.values.agentAccess)?e.values.agentAccess:r.includes(`full`)?`full`:r[0];return a&&(t.agentAccess=a),t.agentModels=e.agentModels,z.updateSettings(e.domainId,t)},onSuccess:(e,n)=>{a.invalidateQueries({queryKey:B.settings(n.domainId)}),a.invalidateQueries({queryKey:B.anatomy(n.domainId)}),a.invalidateQueries({queryKey:B.agent(n.domainId)}),a.invalidateQueries({queryKey:B.loadout(n.domainId)}),I.success(`Settings saved`),t(!1)},onError:e=>I.error(String(e))});return(0,F.jsx)(xy,{open:e,onOpenChange:t,children:(0,F.jsxs)(wy,{className:`w-[calc(100%-2rem)] max-w-xl`,children:[(0,F.jsxs)(Ty,{children:[(0,F.jsx)(Dy,{children:`Settings`}),(0,F.jsx)(Oy,{children:`Power-user overrides for this domain — stored in .domain-studio/settings.json.`})]}),(0,F.jsxs)(`div`,{className:`-mx-1 max-h-[60vh] space-y-5 overflow-y-auto px-1`,children:[(0,F.jsx)(MO,{domainId:e?n:void 0,settings:r,harness:i,values:o,setValues:s,agentModels:c,setAgentModels:l}),(0,F.jsx)(GO,{domainId:n,harness:i}),(0,F.jsx)(nO,{domainId:n}),(0,F.jsx)(LO,{values:o,onChange:(e,t)=>s(n=>({...n,[e]:t}))})]}),(0,F.jsxs)(`div`,{className:`flex justify-end gap-2 pt-1`,children:[(0,F.jsx)(`button`,{type:`button`,onClick:()=>t(!1),className:`rounded-md px-3 py-1.5 text-[13px] text-muted-foreground transition-colors hover:text-foreground`,children:`Cancel`}),(0,F.jsx)(`button`,{type:`button`,disabled:!n||!r||u.isPending,onClick:()=>u.mutate({domainId:n,settings:r,harness:i,values:{...o},agentModels:{...c}}),className:`rounded-md bg-primary px-3 py-1.5 text-[13px] font-medium text-primary-foreground transition-opacity hover:opacity-90 disabled:opacity-50`,children:`Save`})]})]})})}function qO({domainId:e}){let{data:t}=Kr(e),n=Le(),[r,i]=(0,P.useState)(`idle`),[a,o]=(0,P.useState)(null);if(!t?.stale&&r===`idle`)return null;let{cli:s,sdk:c}=t??{cli:{stale:!1},sdk:{stale:!1,outdated:[]}};return(0,F.jsxs)(Zw,{onOpenChange:e=>{e||(i(`idle`),o(null))},children:[(0,F.jsx)(Qw,{asChild:!0,children:(0,F.jsxs)(`button`,{type:`button`,title:`Update available`,className:`inline-flex h-7 items-center gap-1.5 rounded-md border border-warning/40 bg-warning/10 px-2 text-xs font-medium text-warning transition-colors hover:bg-warning/20`,children:[(0,F.jsx)(rn,{className:`h-3.5 w-3.5`}),(0,F.jsx)(`span`,{children:`Update`}),(0,F.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-warning`})]})}),(0,F.jsxs)(eT,{align:`end`,className:`w-72 space-y-2.5 p-3`,children:[(0,F.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-muted-foreground/70`,children:`Update available`}),s.stale&&(0,F.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-[11px]`,children:[(0,F.jsx)(`span`,{className:`font-medium text-foreground`,children:`Astrale CLI`}),(0,F.jsxs)(`span`,{className:`shrink-0 font-mono text-muted-foreground`,children:[s.current,` → `,s.latest,s.channel?(0,F.jsxs)(`span`,{className:`text-muted-foreground/60`,children:[` (`,s.channel,`)`]}):null]})]}),c.stale&&(0,F.jsxs)(`div`,{className:`space-y-0.5 text-[11px]`,children:[(0,F.jsx)(`div`,{className:`font-medium text-foreground`,children:`SDK packages`}),c.outdated.map(e=>(0,F.jsxs)(`div`,{className:`flex items-center justify-between gap-2 font-mono text-muted-foreground`,children:[(0,F.jsx)(`span`,{className:`truncate`,children:e.pkg}),(0,F.jsxs)(`span`,{className:`shrink-0`,children:[e.current,` → `,e.latest]})]},e.pkg))]}),r===`idle`?(0,F.jsxs)(Jh,{size:`sm`,className:`w-full`,onClick:async()=>{i(`running`),o(null);try{let t=await z.applyUpdate(e);o(t),i(`done`),t.ok?(I.success(`Updated`),n.invalidateQueries({queryKey:B.updates(e)})):I.error(`Update failed`)}catch(e){o({ok:!1,output:String(e)}),i(`done`)}},children:[(0,F.jsx)(rn,{className:`h-3.5 w-3.5`}),` Update now`]}):r===`running`?(0,F.jsxs)(Jh,{size:`sm`,className:`w-full`,disabled:!0,children:[(0,F.jsx)(Pn,{className:`h-3.5 w-3.5 animate-spin`}),` Updating…`]}):(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsxs)(`div`,{className:K(`flex items-center gap-1.5 text-xs font-medium`,a?.ok?`text-success`:`text-destructive`),children:[a?.ok?(0,F.jsx)($t,{className:`h-3.5 w-3.5`}):(0,F.jsx)(sr,{className:`h-3.5 w-3.5`}),a?.ok?`Updated`:`Failed`]}),a?.output&&(0,F.jsx)(`pre`,{className:`max-h-32 overflow-auto whitespace-pre-wrap break-all rounded bg-muted/50 p-1.5 text-[10px] leading-tight text-muted-foreground`,children:a.output.slice(-1600)}),(0,F.jsx)(Jh,{size:`xs`,variant:`outline`,className:`w-full`,onClick:()=>i(`idle`),children:`Done`})]})]})]})}function JO(e){let t=(0,P.useRef)(e);(0,P.useEffect)(()=>{t.current=e}),(0,P.useEffect)(()=>{let e=null,n,r=!1,i=1e3,a=()=>{e=new EventSource(`/api/events`),e.onmessage=e=>{i=1e3;try{t.current(JSON.parse(e.data))}catch{}},e.onerror=()=>{e&&e.readyState===EventSource.CLOSED&&!r&&(e.close(),n=setTimeout(a,i),i=Math.min(i*2,15e3))}};return a(),()=>{r=!0,clearTimeout(n),e?.close()}},[])}function YO(){let e=V(e=>e.copyOpen),t=V(e=>e.setCopyOpen),n=V(e=>e.domainId),[r,i]=(0,P.useState)(!1),[a,o]=(0,P.useState)(``),[s,c]=(0,P.useState)(0),[l,u]=(0,P.useState)(!1),[d,f]=(0,P.useState)(!1);return(0,P.useEffect)(()=>{!e||!n||(u(!0),z.copyPayload(n,r).then(e=>{o(e.markdown),c(e.openComments)}).catch(e=>I.error(String(e))).finally(()=>u(!1)))},[e,n,r]),(0,F.jsx)(xy,{open:e,onOpenChange:t,children:(0,F.jsxs)(wy,{className:`max-w-3xl`,children:[(0,F.jsxs)(Ty,{children:[(0,F.jsx)(Dy,{children:`Copy handoff for the agent`}),(0,F.jsxs)(Oy,{children:[s,` open thread`,s===1?``:`s`,` + embedded context and document paths. Paste into Claude Code / Codex.`]})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(Jh,{size:`sm`,variant:r?`default`:`outline`,onClick:()=>i(e=>!e),children:r?`Including auto-context`:`Include auto-context`}),(0,F.jsx)(Th,{variant:`muted`,children:`read-only handoff`})]}),(0,F.jsx)(ew,{className:`h-[50vh] rounded-md border bg-muted/40`,children:(0,F.jsx)(`pre`,{className:`p-3 text-xs font-mono whitespace-pre-wrap`,children:l?`Building payload…`:a})}),(0,F.jsx)(Ey,{children:(0,F.jsxs)(Jh,{onClick:async()=>{await navigator.clipboard.writeText(a),f(!0),I.success(`Copied — paste into your terminal agent`),setTimeout(()=>f(!1),1500)},disabled:l||!a,children:[d?(0,F.jsx)($t,{className:`h-4 w-4`}):(0,F.jsx)(sn,{className:`h-4 w-4`}),d?`Copied`:`Copy to clipboard`]})})]})})}function XO(){let e=V(e=>e.mergeOpen),t=V(e=>e.setMergeOpen),n=V(e=>e.domainId),r=Le(),[i,a]=(0,P.useState)(``),[o,s]=(0,P.useState)(!1);return(0,F.jsx)(xy,{open:e,onOpenChange:t,children:(0,F.jsxs)(wy,{className:`max-w-2xl`,children:[(0,F.jsxs)(Ty,{children:[(0,F.jsx)(Dy,{children:`Paste the agent's reply`}),(0,F.jsxs)(Oy,{children:[`Paste the agent's response (prose + its trailing`,` `,(0,F.jsx)(`code`,{className:`font-mono`,children:"```json"}),` block). Threads merge by id.`]})]}),(0,F.jsx)(tT,{className:`min-h-[40vh] text-xs`,placeholder:`Paste the agent reply here…`,value:i,onChange:e=>a(e.target.value)}),(0,F.jsxs)(Ey,{children:[(0,F.jsx)(Jh,{variant:`ghost`,onClick:()=>t(!1),children:`Cancel`}),(0,F.jsxs)(Jh,{onClick:async()=>{if(!(!n||!i.trim())){s(!0);try{let e=await z.mergeReply(n,i);r.invalidateQueries({queryKey:B.comments(n)});let o=[`merged ${e.merged}`,`closed ${e.closed}`];e.unknownIds.length&&o.push(`${e.unknownIds.length} unknown id(s)`),e.schemaMismatch&&o.push(`⚠ authored against an older schema`),I.success(`Reply merged — ${o.join(`, `)}`),a(``),t(!1)}catch(e){I.error(String(e))}finally{s(!1)}}},disabled:o||!i.trim(),children:[(0,F.jsx)(wn,{className:`h-4 w-4`}),` Merge reply`]})]})]})})}function ZO(e){return e===`section.schema`?`Schema canvas`:e.startsWith(`view.`)?`View · ${e.slice(5)}`:e.startsWith(`module.`)?`Module · ${e.slice(7)}`:e.startsWith(`class.`)?`Class · ${e.slice(6)}`:e.startsWith(`edge.`)?`Edge · ${e.slice(5)}`:e.startsWith(`section.`)?e.slice(8).replace(/\./g,` · `):e}function QO({domainId:e}){let{data:t,isLoading:n}=ni(e),[r,i]=(0,P.useState)(`open`),a=V(e=>e.setCopyOpen),o=V(e=>e.setMergeOpen),s=`Pin notes to any element, then Submit to the agent — it edits the code and replies here.`;if(n)return(0,F.jsx)(BE,{title:`Comments`,subtitle:s,icon:(0,F.jsx)(Ln,{className:`h-5 w-5`}),children:(0,F.jsx)(`div`,{className:`flex items-center justify-center py-12 text-sm text-muted-foreground`,children:`Loading comments…`})});let c=t?.comments??[],l=c.filter(e=>e.status===`open`),u=c.filter(e=>e.status===`closed`),d=r===`open`?l:u,f=[{key:`open`,label:`Open`,count:l.length},{key:`closed`,label:`Resolved`,count:u.length}];return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(BE,{title:`Comments`,subtitle:s,icon:(0,F.jsx)(Ln,{className:`h-5 w-5`}),actions:(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsxs)(Jh,{variant:`outline`,size:`sm`,onClick:()=>a(!0),children:[(0,F.jsx)(sn,{className:`h-3.5 w-3.5`}),`Copy for agent`]}),(0,F.jsxs)(Jh,{variant:`outline`,size:`sm`,onClick:()=>o(!0),children:[(0,F.jsx)(wn,{className:`h-3.5 w-3.5`}),`Merge reply`]}),(0,F.jsx)(`div`,{className:`inline-flex items-center gap-0.5 rounded-lg bg-muted/60 p-0.5`,children:f.map(e=>(0,F.jsxs)(`button`,{type:`button`,onClick:()=>i(e.key),className:K(`inline-flex items-center gap-1.5 rounded-md px-3 py-1 text-[13px] font-medium transition-colors`,r===e.key?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground`),children:[e.label,(0,F.jsx)(`span`,{className:K(`text-xs`,r===e.key?`text-muted-foreground`:`text-muted-foreground/60`),children:e.count})]},e.key))})]}),children:d.length===0?(0,F.jsx)(HE,{children:(0,F.jsx)(XE,{icon:(0,F.jsx)(Ln,{}),title:r===`open`?`No open threads`:`No resolved threads yet`,hint:r===`open`?`Hover any element and click the comment icon to start one.`:void 0})}):(0,F.jsx)(`div`,{className:`flex flex-col gap-3`,children:d.map(t=>(0,F.jsx)(ek,{domainId:e,comment:t},t.id))})}),(0,F.jsx)(YO,{}),(0,F.jsx)(XO,{})]})}function $O({entry:e,commentId:t,open:n,isLast:r,domainId:i}){let a=e.role===`author`,o=e.type===`choice`&&!!e.options&&a&&n&&r;return(0,F.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,F.jsxs)(`div`,{className:`flex flex-col gap-0.5 text-[13px] leading-relaxed`,children:[(0,F.jsx)(`span`,{className:K(`text-[11px] font-semibold uppercase tracking-wider`,a?`text-primary`:`text-muted-foreground`),children:a?`agent`:`you`}),(0,F.jsx)(ED,{commentId:t,entryId:e.id,text:e.text})]}),e.type===`choice`&&e.options&&(o?(0,F.jsx)(OD,{commentId:t,options:e.options,domainId:i}):(0,F.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.options.map(t=>(0,F.jsx)(qE,{tone:e.answer===t?`primary`:`outline`,children:t},t))}))]})}function ek({domainId:e,comment:t}){let{reply:n,setStatus:r,remove:i}=li(e),[a,o]=(0,P.useState)(``),s=t.anchorRefs[0];return(0,F.jsxs)(HE,{className:K(`overflow-hidden`,t.status===`closed`&&`opacity-70`),children:[(0,F.jsx)(GE,{className:`border-b py-3`,leading:(0,F.jsx)(Ln,{className:`h-4 w-4 text-muted-foreground/70`}),trailing:(0,F.jsx)(`button`,{type:`button`,title:`Remove thread`,onClick:()=>i.mutate(t.id,{onSuccess:()=>I.success(`Deleted`)}),className:`inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground/50 opacity-0 transition-all hover:bg-destructive/10 hover:text-destructive group-hover/row:opacity-100`,children:(0,F.jsx)(or,{className:`h-3.5 w-3.5`})}),children:(0,F.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center gap-2`,children:[(0,F.jsx)(qE,{tone:t.status===`open`?`primary`:`default`,children:t.status}),t.orphaned&&(0,F.jsx)(qE,{tone:`danger`,children:`orphaned`}),s&&(0,F.jsx)(`span`,{className:`truncate text-xs text-muted-foreground/70`,title:s.ref,children:ZO(s.ref)})]})}),(0,F.jsx)(`div`,{className:`flex flex-col gap-3 px-4 py-3.5`,children:t.thread.map((n,r)=>(0,F.jsx)($O,{entry:n,commentId:t.id,open:t.status===`open`,isLast:r===t.thread.length-1,domainId:e},n.id))}),t.status===`open`&&(0,F.jsxs)(`div`,{className:`flex flex-col gap-2.5 border-t px-4 py-3`,children:[(0,F.jsx)(tT,{className:`min-h-16 resize-none font-sans text-[13px]`,placeholder:`Reply…`,value:a,onChange:e=>o(e.target.value)}),(0,F.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,F.jsxs)(`button`,{type:`button`,onClick:()=>r.mutate({commentId:t.id,status:`closed`},{onSuccess:()=>I.success(`Resolved`)}),className:`inline-flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-[13px] font-medium text-muted-foreground transition-colors hover:bg-accent/60 hover:text-foreground`,children:[(0,F.jsx)($t,{className:`h-3.5 w-3.5`}),`Resolve`]}),(0,F.jsx)(`button`,{type:`button`,disabled:!a.trim()||n.isPending,onClick:()=>n.mutate({commentId:t.id,entry:{role:`user`,type:`text`,text:a.trim()}},{onSuccess:()=>o(``)}),className:`inline-flex items-center gap-1.5 rounded-lg bg-primary/12 px-3 py-1.5 text-[13px] font-medium text-primary transition-colors hover:bg-primary/20 disabled:opacity-50`,children:`Reply`})]})]})]})}function tk(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(0)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function nk(e){let t=e.name.toLowerCase(),n=e.type;return/\.pdf$/.test(t)||n===`application/pdf`?{Icon:yn,tint:`bg-red-400/10 text-red-400`,label:`PDF`}:/\.(xlsx?|csv|tsv)$/.test(t)||n.includes(`sheet`)||n===`text/csv`?{Icon:vn,tint:`bg-emerald-400/10 text-emerald-400`,label:/\.csv$/.test(t)?`CSV`:`XLS`}:/\.(md|mdx|markdown)$/.test(t)||n===`text/markdown`?{Icon:En,tint:`bg-sky-400/10 text-sky-400`,label:`MD`}:/\.(docx?|rtf)$/.test(t)||n.includes(`word`)?{Icon:bn,tint:`bg-blue-400/10 text-blue-400`,label:`DOC`}:n.startsWith(`image/`)||/\.(png|jpe?g|gif|webp|svg|avif)$/.test(t)?{Icon:gn,tint:`bg-fuchsia-400/10 text-fuchsia-400`,label:`IMG`}:/\.(json|ya?ml|toml|ts|tsx|js|jsx|py|go|rs|sh|html|css)$/.test(t)||n.includes(`json`)?{Icon:hn,tint:`bg-amber-400/10 text-amber-400`,label:`CODE`}:n.startsWith(`text/`)||/\.(txt|log|env)$/.test(t)?{Icon:yn,tint:`bg-slate-400/10 text-slate-400`,label:`TXT`}:{Icon:xn,tint:`bg-muted text-muted-foreground`,label:(t.split(`.`).pop()??`file`).slice(0,4).toUpperCase()}}var rk=e=>e.type===`text/markdown`||/\.(md|mdx|markdown)$/i.test(e.name),ik=e=>e.type.startsWith(`text/`)||e.type.includes(`json`)||rk(e)||/\.(txt|json|ya?ml|csv|tsv|ts|tsx|js|jsx|html|css|toml|env|log)$/i.test(e.name);function ak(e){return`${e.trim().toLowerCase().replace(/[^a-z0-9\s-]/g,``).replace(/\s+/g,`-`).replace(/-+/g,`-`).replace(/^-+|-+$/g,``).slice(0,60)||`note`}.md`}var ok=e=>ak((e.split(`
|
|
81
|
-
`).map(e=>e.replace(/^#+\s*/,``).trim()).find(Boolean)??``).slice(0,60));function sk({domainId:e}){let{data:t}=si(e),n=Le(),r=()=>n.invalidateQueries({queryKey:B.documents(e)}),[i,a]=(0,P.useState)(!1),[o,s]=(0,P.useState)(null),c=$e({mutationFn:t=>z.uploadDocuments(e,t),onSuccess:e=>{r(),I.success(`Added ${e.length} document${e.length===1?``:`s`}`)},onError:e=>I.error(String(e))}),l=$e({mutationFn:t=>z.deleteDocument(e,t),onSuccess:r}),u=e=>{let t=e?[...e]:[];t.length&&c.mutate(t)},d=(e,t)=>c.mutate([new File([e],t?ak(t):ok(e),{type:`text/markdown`})]),f=e=>{let t=e.dataTransfer.files;if(t?.length){e.preventDefault(),a(!1),u(t);return}if(a(!1),e.target.closest(`textarea, input`))return;let n=e.dataTransfer.getData(`text/plain`);n.trim()&&(e.preventDefault(),d(n))};if(!t)return(0,F.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:`Loading…`});let p=t.length;return(0,F.jsxs)(`div`,{className:`relative h-full`,onDragOver:e=>{Array.from(e.dataTransfer.types).includes(`Files`)&&(e.preventDefault(),a(!0))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||a(!1)},onDrop:f,children:[(0,F.jsx)(`div`,{className:`h-full overflow-y-auto`,children:(0,F.jsxs)(`div`,{className:`mx-auto w-full max-w-3xl space-y-6 px-6 pb-28 pt-10`,children:[(0,F.jsx)(lk,{domainId:e}),p===0?(0,F.jsxs)(`div`,{className:`space-y-4`,children:[(0,F.jsx)(uk,{busy:c.isPending,onText:d,onFiles:u}),(0,F.jsx)(dk,{busy:c.isPending,onFiles:u})]}):(0,F.jsxs)(`div`,{className:`space-y-6`,children:[(0,F.jsx)(uk,{busy:c.isPending,onText:d,onFiles:u}),(0,F.jsx)(`div`,{className:`grid grid-cols-2 gap-2.5 sm:grid-cols-3`,children:t.map(t=>(0,F.jsx)(fk,{domainId:e,doc:t,onEdit:()=>s(t),onDelete:()=>l.mutate(t.id)},t.id))})]})]})}),i&&(0,F.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-30 flex items-center justify-center bg-background/80 backdrop-blur-sm`,children:(0,F.jsxs)(`div`,{className:`flex flex-col items-center gap-3 rounded-2xl border-2 border-dashed border-primary/60 px-16 py-12 text-primary`,children:[(0,F.jsx)(lr,{className:`h-8 w-8`}),(0,F.jsx)(`p`,{className:`text-sm font-medium`,children:`Drop to add`})]})}),o&&(0,F.jsx)(mk,{domainId:e,doc:o,onClose:()=>s(null),onSaved:r})]})}function ck({expanded:e,onClick:t}){let n=e?zn:In,r=e?`Collapse editor`:`Expand editor`;return(0,F.jsx)(`button`,{type:`button`,title:r,"aria-label":r,onClick:t,className:`absolute right-2 top-2 z-10 flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground/60 transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:(0,F.jsx)(n,{className:`h-3.5 w-3.5`})})}function lk({domainId:e}){let[t,n]=(0,P.useState)(``),[r,i]=(0,P.useState)(!1),[a,o]=(0,P.useState)(!1),s=Tr(e),c=Er(e),l=wr(e=>e.setRun),u=Le(),d=Dr(c),f=s.data?.available??!1,p=t.trim().length>0&&!a&&!d&&f,m=async()=>{if(p){o(!0);try{let r=await z.agentSubmit(e,t.trim());if(r.error){I.error(r.error);return}l(r),n(``),I.success(`Sent to the agent`)}catch(e){I.error(String(e))}finally{o(!1),u.invalidateQueries({queryKey:B.agent(e)})}}};return(0,F.jsxs)(`div`,{className:`rounded-2xl border bg-card/50 shadow-sm transition-colors focus-within:border-primary/50`,children:[(0,F.jsxs)(`div`,{className:`relative`,children:[(0,F.jsx)(tT,{autoFocus:!0,value:t,onChange:e=>n(e.target.value),onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),m())},placeholder:`Tell me what you want to do?`,className:K(`max-h-[65vh] min-h-[120px] resize-y border-0 bg-transparent pr-10 text-[15px] leading-relaxed shadow-none focus-visible:ring-0`,r&&`min-h-[45vh]`)}),(0,F.jsx)(ck,{expanded:r,onClick:()=>i(e=>!e)})]}),(0,F.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-t px-3 py-2`,children:[(0,F.jsx)(`span`,{className:`text-[11px] text-muted-foreground/50`,children:d?`Agent working…`:f?`⌘↵ to send`:`agent unavailable`}),(0,F.jsxs)(Jh,{size:`sm`,onClick:m,disabled:!p,children:[a||d?(0,F.jsx)(Pn,{className:`h-3.5 w-3.5 animate-spin`}):(0,F.jsx)(Zn,{className:`h-3.5 w-3.5`}),` `,`Send to agent`]})]})]})}function uk({hero:e,busy:t,onText:n,onFiles:r}){let[i,a]=(0,P.useState)(``),[o,s]=(0,P.useState)(!1),c=(0,P.useRef)(null),l=()=>{!i.trim()||t||(n(i),a(``))};return(0,F.jsxs)(`div`,{className:`rounded-2xl border bg-card/50 shadow-sm transition-colors focus-within:border-primary/50`,children:[(0,F.jsxs)(`div`,{className:`relative`,children:[(0,F.jsx)(tT,{autoFocus:e,value:i,onChange:e=>a(e.target.value),onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),l())},placeholder:e?`Paste anything — notes, specs, decisions…`:`Paste text to save as markdown…`,className:K(`max-h-[65vh] resize-y border-0 bg-transparent pr-10 leading-relaxed shadow-none focus-visible:ring-0`,o?e?`min-h-[45vh] text-[15px]`:`min-h-[32vh]`:e?`min-h-[180px] text-[15px]`:`min-h-[80px]`)}),(0,F.jsx)(ck,{expanded:o,onClick:()=>s(e=>!e)})]}),(0,F.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-t px-3 py-2`,children:[e?(0,F.jsx)(`span`,{className:`text-[11px] text-muted-foreground/50`,children:`⌘↵ to save`}):(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`button`,{type:`button`,onClick:()=>c.current?.click(),className:`inline-flex items-center gap-1.5 rounded-md px-2 py-1 text-[13px] text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,children:[(0,F.jsx)(lr,{className:`h-4 w-4`}),` `,t?`Uploading…`:`Upload`]}),(0,F.jsx)(`input`,{ref:c,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{r(e.target.files),e.target.value=``}})]}),i.trim()&&(0,F.jsxs)(Jh,{size:`sm`,onClick:l,disabled:t,children:[(0,F.jsx)(un,{className:`h-3.5 w-3.5`}),` Save`]})]})]})}function dk({busy:e,onFiles:t}){let n=(0,P.useRef)(null);return(0,F.jsxs)(`button`,{type:`button`,onClick:()=>n.current?.click(),className:`flex w-full flex-col items-center justify-center gap-2 rounded-2xl border border-dashed py-10 text-muted-foreground transition-colors hover:border-muted-foreground/40 hover:bg-accent/20`,children:[(0,F.jsx)(lr,{className:`h-6 w-6`}),(0,F.jsx)(`p`,{className:`text-[13px]`,children:e?`Uploading…`:`Drop files or browse`}),(0,F.jsx)(`input`,{ref:n,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{t(e.target.files),e.target.value=``}})]})}function fk({domainId:e,doc:t,onEdit:n,onDelete:r}){let i=nk(t);return(0,F.jsxs)(`div`,{className:`group flex flex-col gap-2.5 rounded-xl border bg-card/50 p-3 transition-colors hover:border-muted-foreground/30 hover:bg-accent/30`,children:[(0,F.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,F.jsx)(`div`,{className:K(`flex h-9 w-9 items-center justify-center rounded-lg`,i.tint),children:(0,F.jsx)(i.Icon,{className:`h-[18px] w-[18px]`})}),(0,F.jsxs)(`div`,{className:`flex items-center gap-0.5 opacity-0 transition-opacity group-hover:opacity-100`,children:[ik(t)&&(0,F.jsx)(pk,{title:`Copy`,onClick:async()=>{try{await navigator.clipboard.writeText(await z.docContent(e,t.id)),I.success(`Copied`)}catch{I.error(`Copy failed`)}},children:(0,F.jsx)(ln,{className:`h-3.5 w-3.5`})}),rk(t)&&(0,F.jsx)(pk,{title:`Edit`,onClick:n,children:(0,F.jsx)(Un,{className:`h-3.5 w-3.5`})}),(0,F.jsx)(pk,{title:`Remove`,danger:!0,onClick:r,children:(0,F.jsx)(fr,{className:`h-3.5 w-3.5`})})]})]}),(0,F.jsxs)(`a`,{href:z.docUrl(e,t.id),target:`_blank`,rel:`noreferrer`,className:`min-w-0`,children:[(0,F.jsx)(`div`,{className:`truncate text-[13px] font-medium leading-snug`,title:t.name,children:t.name}),(0,F.jsxs)(`div`,{className:`mt-0.5 text-[11px] text-muted-foreground`,children:[i.label,` · `,tk(t.size)]})]})]})}function pk({title:e,onClick:t,danger:n,children:r}){return(0,F.jsx)(`button`,{type:`button`,title:e,onClick:t,className:K(`flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground/60 transition-colors`,n?`hover:bg-destructive/10 hover:text-destructive`:`hover:bg-accent hover:text-foreground`),children:r})}function mk({domainId:e,doc:t,onClose:n,onSaved:r}){let[i,a]=(0,P.useState)(null),[o,s]=(0,P.useState)(!1);(0,P.useEffect)(()=>{let n=!0;return a(null),z.docContent(e,t.id).then(e=>n&&a(e)).catch(()=>{n&&(I.error(`Could not load document`),a(``))}),()=>{n=!1}},[e,t.id]);let c=async()=>{if(i!=null){s(!0);try{await z.updateDocument(e,t.id,i),I.success(`Saved`),r(),n()}catch(e){I.error(String(e))}finally{s(!1)}}};return(0,F.jsx)(xy,{open:!0,onOpenChange:e=>!e&&n(),children:(0,F.jsxs)(wy,{className:`max-w-2xl`,children:[(0,F.jsx)(Ty,{children:(0,F.jsx)(Dy,{className:`truncate text-sm`,children:t.name})}),(0,F.jsx)(tT,{autoFocus:!0,value:i??``,disabled:i==null,onChange:e=>a(e.target.value),onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),c())},placeholder:i==null?`Loading…`:``,className:`min-h-[50vh] resize-none font-mono text-[12px] leading-relaxed`}),(0,F.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,F.jsx)(`span`,{className:`mr-auto text-[11px] text-muted-foreground/60`,children:`⌘↵ to save`}),(0,F.jsx)(Jh,{variant:`ghost`,size:`sm`,onClick:n,children:`Cancel`}),(0,F.jsx)(Jh,{size:`sm`,onClick:c,disabled:o||i==null,children:o?`Saving…`:`Save`})]})]})})}function hk(e,t,n,r){return e.find(e=>e.owner===t&&e.method===n&&e.ownerKind===r)}function gk(e){let t=e?.auth;return t?t===`anonymous`?{level:`public`,icon:Tn,tone:`sky`,label:`Anonymous`,auth:t,blurb:`The callable contract permits anonymous callers.`}:{level:`secured`,icon:$n,tone:`emerald`,label:t===`authorized`?`Authorized`:`Authenticated`,auth:t,blurb:t===`authorized`?`The callable contract requires authorization.`:`The callable contract requires an authenticated principal.`}:null}var _k={emerald:`text-emerald-400 hover:text-emerald-300`,sky:`text-sky-400 hover:text-sky-300`,amber:`text-amber-400 hover:text-amber-300`,rose:`text-rose-400 hover:text-rose-300`};function vk({method:e,interactive:t=!0}){let n=gk(e);if(!n)return null;let r=n.icon,i=K(`inline-flex items-center justify-center rounded-md transition-colors`,_k[n.tone]);return(0,F.jsxs)(SD,{openDelay:80,children:[(0,F.jsx)(CD,{asChild:!0,children:t?(0,F.jsx)(`button`,{type:`button`,"aria-label":`Authorization: ${n.label}`,className:i,children:(0,F.jsx)(r,{className:`h-3.5 w-3.5`})}):(0,F.jsx)(`span`,{role:`img`,"aria-label":`Authorization: ${n.label}`,className:i,children:(0,F.jsx)(r,{className:`h-3.5 w-3.5`})})}),(0,F.jsx)(wD,{align:`start`,className:`w-96 p-0 overflow-hidden`,children:(0,F.jsx)(yk,{method:e})})]})}function yk({method:e}){let t=gk(e);if(!t)return null;let n=t.icon;return(0,F.jsxs)(`div`,{className:`text-[13px]`,children:[(0,F.jsxs)(`div`,{className:`flex items-start gap-2.5 p-3`,children:[(0,F.jsx)(WE,{tone:t.tone,size:`sm`,children:(0,F.jsx)(n,{})}),(0,F.jsxs)(`div`,{className:`min-w-0`,children:[(0,F.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,F.jsx)(`span`,{className:`font-semibold text-foreground`,children:t.label})}),(0,F.jsx)(`p`,{className:`mt-1 leading-relaxed text-muted-foreground`,children:t.blurb})]})]}),(0,F.jsx)(`div`,{className:`flex flex-wrap gap-1.5 border-t px-3 py-2`,children:(0,F.jsxs)(qE,{tone:`outline`,className:`font-mono`,children:[`auth: `,t.auth]})})]})}function bk(e,t){let n=rO(e),r=t??n.optional;switch(n.kind){case`string`:return{label:`Text`,icon:cr,optional:r};case`number`:case`integer`:return{label:`Number`,icon:En,optional:r};case`boolean`:return{label:`Yes / no`,icon:ar,optional:r};case`enum`:{let e=n.values.map(String);return{label:`One of: ${e.slice(0,3).join(`, `)}${e.length>3?`…`:``}`,icon:Mn,optional:r}}case`array`:return{label:`List`,icon:Nn,optional:r};case`object`:return{label:`Object`,icon:Qt,optional:r};case`ref`:return{label:`Reference`,icon:jn,optional:r};default:return{label:`Value`,icon:on,optional:r}}}function xk(e){return e.inheritance===`sealed`?{icon:Fn,tone:`amber`}:e.inheritance===`abstract`?{icon:Gn,tone:`fuchsia`}:{icon:pr,tone:`violet`}}function Sk(e){if(!e||typeof e!=`object`||Array.isArray(e))return 0;let t=e;return(t.nodes&&typeof t.nodes==`object`&&!Array.isArray(t.nodes)?Object.keys(t.nodes).length:0)+(Array.isArray(t.edges)?t.edges.length:0)}function Ck(e){let t=new Set,n=[];for(let r of e)for(let e of Array.isArray(r.viewFor)?r.viewFor:r.viewFor?[r.viewFor]:[])t.has(e)||(t.add(e),n.push(e));return n}function wk({domainId:e}){let t=Hr(e),n=Ur(e),r=V(e=>e.setSection),i=V(e=>e.focusClass),a=V(e=>e.setPanelOverlay),o=t.data,s=n.data,c=o?.ir??null,l=(0,P.useMemo)(()=>Sk(c?.core),[c?.core]),u=(0,P.useMemo)(()=>{if(!c||!o)return[];let e=[],t=Object.entries(c.functions);t.length>0&&e.push({owner:c.domain,label:`Domain callables`,className:null,fns:t.map(([e,t])=>({owner:c.domain,ownerKind:`function`,name:e,method:t,link:hk(o.overlay.handlerLinks,c.domain,e,`function`)}))});for(let t of Object.values(c.classes)){let n=Object.entries(t.methods??{});if(n.length===0)continue;let r=n.map(([e,n])=>({owner:t.name,ownerKind:`class`,name:e,method:n,link:hk(o.overlay.handlerLinks,t.name,e,`class`)}));e.push({owner:t.name,label:t.name,className:t.name,fns:r})}return e.sort((e,t)=>e.className===null&&t.className!==null?-1:+(e.className!==null&&t.className===null))},[c,o]),d=u.reduce((e,t)=>e+t.fns.length,0),f=s?.views??[],p=(0,P.useMemo)(()=>Ck(f),[f]),m=e=>{r(`schema`),i(`class.${e}`)};return t.isLoading||n.isLoading?(0,F.jsx)(`div`,{className:`flex items-center justify-center p-8 text-sm text-muted-foreground`,children:`Loading…`}):(0,F.jsx)(BE,{title:`Process`,subtitle:`Actions and workflows implementing callable contracts`,icon:(0,F.jsx)(ur,{className:`h-5 w-5`}),children:c?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(VE,{label:`Entrypoints`,children:(0,F.jsxs)(`div`,{className:`space-y-2`,children:[l>0?(0,F.jsxs)(HE,{className:`flex items-center gap-3 border-emerald-500/30 bg-emerald-500/[0.04] px-4 py-3`,children:[(0,F.jsx)(WE,{tone:`emerald`,children:(0,F.jsx)(nr,{})}),(0,F.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,F.jsx)(`div`,{className:`truncate text-sm font-semibold`,children:`Core genesis`}),(0,F.jsxs)(`div`,{className:`mt-0.5 text-[13px] text-muted-foreground`,children:[l,` portable element`,l===1?``:`s`,` installed with the schema`]})]})]}):(0,F.jsxs)(HE,{className:`flex items-center gap-3 px-4 py-3 text-muted-foreground`,children:[(0,F.jsx)(WE,{tone:`muted`,children:(0,F.jsx)(nr,{})}),(0,F.jsx)(`div`,{className:`min-w-0 flex-1 text-[13px]`,children:`No Core genesis data declared in this schema.`})]}),f.length>0&&(0,F.jsxs)(HE,{onClick:()=>{r(`schema`),a(`views`)},className:`flex cursor-pointer items-center gap-3 px-4 py-3 transition-colors hover:bg-accent/50`,children:[(0,F.jsx)(WE,{tone:`sky`,children:(0,F.jsx)(kn,{})}),(0,F.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,F.jsxs)(`div`,{className:`text-sm font-semibold`,children:[f.length,` view`,f.length===1?``:`s`,` `,(0,F.jsx)(`span`,{className:`font-normal text-muted-foreground`,children:`· UI entrypoints`})]}),p.length>0&&(0,F.jsxs)(`div`,{className:`mt-1 flex flex-wrap gap-1`,children:[p.slice(0,8).map(e=>(0,F.jsx)(qE,{tone:`outline`,children:e},e)),p.length>8&&(0,F.jsxs)(qE,{tone:`default`,children:[`+`,p.length-8]})]})]}),(0,F.jsx)(Jt,{className:`h-4 w-4 shrink-0 text-muted-foreground`})]}),(0,F.jsxs)(HE,{className:`flex items-center gap-3 border-dashed px-4 py-3 text-muted-foreground`,children:[(0,F.jsx)(WE,{tone:`muted`,children:(0,F.jsx)(Kn,{})}),(0,F.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,F.jsx)(`div`,{className:`text-sm font-medium text-muted-foreground`,children:`Triggers`}),(0,F.jsx)(`div`,{className:`mt-0.5 text-[13px] text-muted-foreground/70`,children:`On event · polling · cron — wired via the services domain. Not parsed yet.`})]})]})]})}),d===0?(0,F.jsx)(XE,{icon:(0,F.jsx)(ur,{}),title:`No callable contracts yet`,hint:`Add a standalone Function or class Method to the schema to see it here.`}):(0,F.jsx)(VE,{label:`Runtime`,hint:`${d}`,children:(0,F.jsx)(`div`,{className:`space-y-3`,children:u.map(e=>(0,F.jsxs)(HE,{className:`overflow-hidden`,children:[(0,F.jsxs)(`button`,{type:`button`,onClick:e.className?()=>m(e.className):void 0,className:K(`flex w-full items-center gap-2.5 px-3 py-2 text-left transition-colors`,e.className&&`hover:bg-accent/40`),children:[(0,F.jsx)(WE,{tone:`muted`,size:`sm`,children:e.className?(0,F.jsx)(Xt,{}):(0,F.jsx)(Qt,{})}),(0,F.jsx)(`span`,{className:`flex-1 truncate text-[13px] font-semibold`,children:e.label}),(0,F.jsxs)(`span`,{className:`shrink-0 text-[11px] text-muted-foreground`,children:[e.fns.length,` callable`]})]}),(0,F.jsx)(`div`,{className:`border-t`,children:e.fns.map(e=>(0,F.jsx)(Tk,{fn:e,onClick:e.ownerKind===`class`?()=>m(e.owner):void 0},e.name))})]},e.owner))})})]}):(0,F.jsx)(HE,{className:`px-4 py-3 text-sm text-muted-foreground`,children:`Schema unavailable — install dependencies to see this domain’s callable contracts.`})})}function Tk({fn:e,onClick:t}){let n=e.link?.kind===`workflow`?{icon:ur,tone:`fuchsia`}:e.link?.kind===`action`?{icon:pr,tone:`violet`}:`inheritance`in e.method?xk(e.method):{icon:pr,tone:`violet`},r=n.icon,i=e.link?.kernelCalls??[],a=e.link&&!e.link.implemented;return(0,F.jsx)(GE,{onClick:t,className:`px-3 py-2 border-t first:border-t-0 rounded-none`,leading:(0,F.jsx)(WE,{tone:n.tone,size:`sm`,children:(0,F.jsx)(r,{})}),title:(0,F.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(`span`,{className:`font-semibold`,children:e.name}),(0,F.jsx)(vk,{method:e.method,interactive:!t}),e.link&&(0,F.jsx)(qE,{tone:`primary`,children:e.link.kind}),`static`in e.method&&e.method.static&&(0,F.jsx)(qE,{tone:`default`,children:`static`}),`inheritance`in e.method&&e.method.inheritance===`abstract`&&(0,F.jsx)(qE,{tone:`fuchsia`,children:`contract`}),a&&(0,F.jsx)(qE,{tone:`warning`,children:`needs handler`}),e.link?.unlinked&&(0,F.jsx)(qE,{tone:`default`,children:`unlinked`})]}),trailing:i.length>0?(0,F.jsxs)(`div`,{className:`hidden items-center gap-1 sm:flex`,children:[i.slice(0,3).map(e=>(0,F.jsx)(qE,{tone:`outline`,className:`font-mono`,children:e},e)),i.length>3&&(0,F.jsxs)(qE,{tone:`default`,children:[`+`,i.length-3]})]}):void 0})}var Ek=`modulepreload`,Dk=function(e){return`/`+e},Ok={},kk=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=Dk(t,n),t=s(t),t in Ok)return;Ok[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:Ek,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},Ak=(0,P.lazy)(()=>kk(async()=>{let{SchemaSection:e}=await import(`./schema-studio-CABpTfvH.js`);return{SchemaSection:e}},__vite__mapDeps([0,1,2])).then(({SchemaSection:e})=>({default:e}))),jk=[{key:`context`,label:`Context`,icon:An},{key:`schema`,label:`Schema`,icon:Hn},{key:`process`,label:`Process`,icon:ur},{key:`comments`,label:`Comments`,icon:Ln}];function Mk({section:e,domainId:t}){switch(e){case`schema`:return(0,F.jsx)(P.Suspense,{fallback:(0,F.jsx)(`div`,{className:`h-full flex items-center justify-center text-muted-foreground`,children:`Loading schema studio…`}),children:(0,F.jsx)(Ak,{domainId:t})});case`context`:return(0,F.jsx)(sk,{domainId:t});case`process`:return(0,F.jsx)(wk,{domainId:t});case`comments`:return(0,F.jsx)(QO,{domainId:t})}}function Nk(){let{data:e}=zr(),t=V(e=>e.domainId),n=V(e=>e.section),r=V(e=>e.setDomain),i=V(e=>e.setSection),a=V(e=>e.setPaletteOpen),o=V(e=>e.setSettingsOpen),s=V(e=>e.commentMode),c=V(e=>e.toggleCommentMode),l=V(e=>e.toggleAskMode),u=ci(),d=wr(e=>e.setRun),f=wr(e=>e.appendEvent),p=Le();(0,P.useEffect)(()=>{if(!t&&e&&e.length){let t=null;try{t=localStorage.getItem(`studio.lastDomain`)}catch{}r(t&&e.some(e=>e.id===t)?t:e[0].id)}},[e,t,r]),JO((0,P.useCallback)(e=>{if(e.type===`hello`){let e=V.getState().domainId;e&&(u(e),p.invalidateQueries({queryKey:B.agent(e)}));return}if(e.type===`workspace`){p.invalidateQueries({queryKey:B.workspace});return}if(e.type===`agent-event`){f(e.domainId,e.runId,e.event);return}if(e.type===`agent-run`){d(e.run),p.invalidateQueries({queryKey:B.agent(e.domainId)});return}if(e.type===`schema-diff`){u(e.domainId),p.invalidateQueries({queryKey:B.workspace});return}`domainId`in e&&e.domainId&&u(e.domainId)},[u,d,f,p]));let{data:m}=Tr(t);(0,P.useEffect)(()=>{m?.run&&d(m.run)},[m,d]),(0,P.useEffect)(()=>{let e=e=>{let t=e.target;t&&(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.isContentEditable)||e.metaKey||e.ctrlKey||e.altKey||(e.key===`c`||e.key===`C`?(e.preventDefault(),c()):(e.key===`a`||e.key===`A`)&&(e.preventDefault(),l()))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[c,l]);let{data:h}=ni(t),g=h?.comments.filter(e=>e.status===`open`&&e.thread.at(-1)?.role===`author`).length??0;return e?(0,F.jsxs)(nw,{delayDuration:200,children:[(0,F.jsxs)(`div`,{className:`h-full flex flex-col`,children:[(0,F.jsxs)(`header`,{className:`flex items-center gap-3 px-5 h-14 border-b shrink-0`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(uO,{}),(0,F.jsx)(ZD,{}),t&&(0,F.jsx)(cO,{domainId:t}),t&&(0,F.jsx)(`button`,{type:`button`,"aria-label":`Settings`,title:`Settings`,onClick:()=>o(!0),className:`flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground/40 transition-colors hover:bg-accent/60 hover:text-foreground`,children:(0,F.jsx)(Qn,{className:`h-4 w-4`})}),t&&(0,F.jsx)(qO,{domainId:t}),t&&(0,F.jsx)($D,{domainId:t})]}),(0,F.jsxs)(`div`,{className:`ml-auto flex items-center gap-1.5`,children:[(0,F.jsxs)(Jh,{variant:`ghost`,size:`sm`,onClick:()=>a(!0),title:`Search (⌘K)`,children:[(0,F.jsx)(Xn,{className:`h-4 w-4`}),(0,F.jsx)(`kbd`,{className:`rounded bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground`,children:`⌘K`})]}),(0,F.jsxs)(Jh,{variant:s?`default`:`ghost`,size:`sm`,"aria-label":`Comment mode`,onClick:()=>c(),title:`Comment mode — click any element to comment (C)`,children:[(0,F.jsx)(Rn,{className:`h-4 w-4`}),(0,F.jsx)(`kbd`,{className:K(`rounded px-1.5 py-0.5 text-[10px]`,s?`bg-primary-foreground/20 text-primary-foreground`:`bg-muted text-muted-foreground`),children:`C`})]}),(0,F.jsx)(`div`,{className:`h-5 w-px bg-border mx-0.5`}),(0,F.jsx)(uw,{})]})]}),(0,F.jsxs)(`main`,{className:`flex-1 min-h-0 relative overflow-hidden`,children:[t?(0,F.jsx)(Mk,{section:n,domainId:t}):(0,F.jsx)(`div`,{className:`h-full flex items-center justify-center text-muted-foreground`,children:`No domain selected`}),(0,F.jsx)(`nav`,{className:`absolute bottom-5 left-1/2 -translate-x-1/2 z-40`,children:(0,F.jsx)(`div`,{className:`flex items-center gap-1 rounded-2xl border bg-card/70 px-2 py-2 shadow-2xl shadow-black/40 backdrop-blur-xl`,children:jk.map(e=>{let t=e.icon,r=n===e.key,a=e.key===`comments`?g:0;return(0,F.jsxs)(rw,{children:[(0,F.jsx)(iw,{asChild:!0,children:(0,F.jsxs)(`button`,{type:`button`,"aria-label":e.label,"aria-current":r?`page`:void 0,onClick:()=>i(e.key),className:K(`relative h-11 w-11 rounded-xl flex items-center justify-center transition-all duration-150`,r?`bg-primary/15 text-primary`:`text-muted-foreground hover:-translate-y-1 hover:bg-accent hover:text-foreground`),children:[(0,F.jsx)(t,{className:`h-[19px] w-[19px]`}),a>0&&(0,F.jsx)(`span`,{className:`absolute -right-0.5 -top-0.5 flex h-4 min-w-4 items-center justify-center rounded-full bg-primary px-1 text-[10px] font-semibold leading-none text-primary-foreground`,children:a>99?`99+`:a}),r&&(0,F.jsx)(`span`,{className:`absolute -bottom-0.5 left-1/2 h-1 w-1 -translate-x-1/2 rounded-full bg-primary`})]})}),(0,F.jsx)(aw,{side:`top`,sideOffset:10,children:e.label})]},e.key)})})})]})]}),(0,F.jsx)(vE,{}),(0,F.jsx)(zD,{}),(0,F.jsx)(MD,{}),(0,F.jsx)(aT,{}),(0,F.jsx)(_w,{}),(0,F.jsx)(KO,{})]}):(0,F.jsx)(`div`,{className:`h-full flex items-center justify-center text-muted-foreground`,children:`Connecting to studio…`})}var Pk=new je({defaultOptions:{queries:{staleTime:5e3,refetchOnWindowFocus:!1,retry:1}}});(0,at.createRoot)(document.getElementById(`root`)).render((0,F.jsx)(P.StrictMode,{children:(0,F.jsxs)(Re,{client:Pk,children:[(0,F.jsx)(Nk,{}),(0,F.jsx)(Lt,{theme:`dark`,position:`bottom-right`,richColors:!0,closeButton:!0})]})}));export{Gr as $,S as $t,nE as A,$t as At,wy as B,Ye as Bt,YE as C,mn as Ct,cE as D,nn as Dt,yE as E,an as Et,eT as F,L as Ft,Ur as G,Be as Gt,Jh as H,Ke as Ht,Qw as I,I as It,li as J,Ne as Jt,Hr as K,Le as Kt,ew as L,rt as Lt,dE as M,Xt as Mt,Zw as N,Jt as Nt,uE as O,tn as Ot,$w as P,qt as Pt,Wr as Q,x as Qt,tw as R,qe as Rt,WE as S,hn as St,HE as T,fn as Tt,K as U,Ge as Ut,Dy as V,We as Vt,V as W,Ue as Wt,ii as X,N as Xt,ni as Y,ve as Yt,ai as Z,l as Zt,CD as _,Vn as _t,hk as a,Mr as at,XE as b,On as bt,iO as c,z as ct,PD as d,sr as dt,r as en,oi as et,jD as f,tr as ft,wD as g,Hn as gt,SD as h,Wn as ht,vk as i,Lr as it,fE as j,Zt as jt,rE as k,en as kt,JD as l,B as lt,TD as m,qn as mt,bk as n,Ir as nt,aO as o,jr as ot,AD as p,Xn as pt,Br as q,Fe as qt,xk as r,Rr as rt,rO as s,Pr as st,kk as t,zr as tt,ID as u,fr as ut,qE as v,Ln as vt,GE as w,pn as wt,VE as x,Tn as xt,JE as y,Pn as yt,xy as z,Xe as zt};
|
|
81
|
+
`).map(e=>e.replace(/^#+\s*/,``).trim()).find(Boolean)??``).slice(0,60));function sk({domainId:e}){let{data:t}=si(e),n=Le(),r=()=>n.invalidateQueries({queryKey:B.documents(e)}),[i,a]=(0,P.useState)(!1),[o,s]=(0,P.useState)(null),c=$e({mutationFn:t=>z.uploadDocuments(e,t),onSuccess:e=>{r(),I.success(`Added ${e.length} document${e.length===1?``:`s`}`)},onError:e=>I.error(String(e))}),l=$e({mutationFn:t=>z.deleteDocument(e,t),onSuccess:r}),u=e=>{let t=e?[...e]:[];t.length&&c.mutate(t)},d=(e,t)=>c.mutate([new File([e],t?ak(t):ok(e),{type:`text/markdown`})]),f=e=>{let t=e.dataTransfer.files;if(t?.length){e.preventDefault(),a(!1),u(t);return}if(a(!1),e.target.closest(`textarea, input`))return;let n=e.dataTransfer.getData(`text/plain`);n.trim()&&(e.preventDefault(),d(n))};if(!t)return(0,F.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:`Loading…`});let p=t.length;return(0,F.jsxs)(`div`,{className:`relative h-full`,onDragOver:e=>{Array.from(e.dataTransfer.types).includes(`Files`)&&(e.preventDefault(),a(!0))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||a(!1)},onDrop:f,children:[(0,F.jsx)(`div`,{className:`h-full overflow-y-auto`,children:(0,F.jsxs)(`div`,{className:`mx-auto w-full max-w-3xl space-y-6 px-6 pb-28 pt-10`,children:[(0,F.jsx)(lk,{domainId:e}),p===0?(0,F.jsxs)(`div`,{className:`space-y-4`,children:[(0,F.jsx)(uk,{busy:c.isPending,onText:d,onFiles:u}),(0,F.jsx)(dk,{busy:c.isPending,onFiles:u})]}):(0,F.jsxs)(`div`,{className:`space-y-6`,children:[(0,F.jsx)(uk,{busy:c.isPending,onText:d,onFiles:u}),(0,F.jsx)(`div`,{className:`grid grid-cols-2 gap-2.5 sm:grid-cols-3`,children:t.map(t=>(0,F.jsx)(fk,{domainId:e,doc:t,onEdit:()=>s(t),onDelete:()=>l.mutate(t.id)},t.id))})]})]})}),i&&(0,F.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-30 flex items-center justify-center bg-background/80 backdrop-blur-sm`,children:(0,F.jsxs)(`div`,{className:`flex flex-col items-center gap-3 rounded-2xl border-2 border-dashed border-primary/60 px-16 py-12 text-primary`,children:[(0,F.jsx)(lr,{className:`h-8 w-8`}),(0,F.jsx)(`p`,{className:`text-sm font-medium`,children:`Drop to add`})]})}),o&&(0,F.jsx)(mk,{domainId:e,doc:o,onClose:()=>s(null),onSaved:r})]})}function ck({expanded:e,onClick:t}){let n=e?zn:In,r=e?`Collapse editor`:`Expand editor`;return(0,F.jsx)(`button`,{type:`button`,title:r,"aria-label":r,onClick:t,className:`absolute right-2 top-2 z-10 flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground/60 transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:(0,F.jsx)(n,{className:`h-3.5 w-3.5`})})}function lk({domainId:e}){let[t,n]=(0,P.useState)(``),[r,i]=(0,P.useState)(!1),[a,o]=(0,P.useState)(!1),s=Tr(e),c=Er(e),l=wr(e=>e.setRun),u=Le(),d=Dr(c),f=s.data?.available??!1,p=t.trim().length>0&&!a&&!d&&f,m=async()=>{if(p){o(!0);try{let r=await z.agentSubmit(e,t.trim());if(r.error){I.error(r.error);return}l(r),n(``),I.success(`Sent to the agent`)}catch(e){I.error(String(e))}finally{o(!1),u.invalidateQueries({queryKey:B.agent(e)})}}};return(0,F.jsxs)(`div`,{className:`rounded-2xl border bg-card/50 shadow-sm transition-colors focus-within:border-primary/50`,children:[(0,F.jsxs)(`div`,{className:`relative`,children:[(0,F.jsx)(tT,{autoFocus:!0,value:t,onChange:e=>n(e.target.value),onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),m())},placeholder:`Tell me what you want to do?`,className:K(`max-h-[65vh] min-h-[120px] resize-y border-0 bg-transparent pr-10 text-[15px] leading-relaxed shadow-none focus-visible:ring-0`,r&&`min-h-[45vh]`)}),(0,F.jsx)(ck,{expanded:r,onClick:()=>i(e=>!e)})]}),(0,F.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-t px-3 py-2`,children:[(0,F.jsx)(`span`,{className:`text-[11px] text-muted-foreground/50`,children:d?`Agent working…`:f?`⌘↵ to send`:`agent unavailable`}),(0,F.jsxs)(Jh,{size:`sm`,onClick:m,disabled:!p,children:[a||d?(0,F.jsx)(Pn,{className:`h-3.5 w-3.5 animate-spin`}):(0,F.jsx)(Zn,{className:`h-3.5 w-3.5`}),` `,`Send to agent`]})]})]})}function uk({hero:e,busy:t,onText:n,onFiles:r}){let[i,a]=(0,P.useState)(``),[o,s]=(0,P.useState)(!1),c=(0,P.useRef)(null),l=()=>{!i.trim()||t||(n(i),a(``))};return(0,F.jsxs)(`div`,{className:`rounded-2xl border bg-card/50 shadow-sm transition-colors focus-within:border-primary/50`,children:[(0,F.jsxs)(`div`,{className:`relative`,children:[(0,F.jsx)(tT,{autoFocus:e,value:i,onChange:e=>a(e.target.value),onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),l())},placeholder:e?`Paste anything — notes, specs, decisions…`:`Paste text to save as markdown…`,className:K(`max-h-[65vh] resize-y border-0 bg-transparent pr-10 leading-relaxed shadow-none focus-visible:ring-0`,o?e?`min-h-[45vh] text-[15px]`:`min-h-[32vh]`:e?`min-h-[180px] text-[15px]`:`min-h-[80px]`)}),(0,F.jsx)(ck,{expanded:o,onClick:()=>s(e=>!e)})]}),(0,F.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-t px-3 py-2`,children:[e?(0,F.jsx)(`span`,{className:`text-[11px] text-muted-foreground/50`,children:`⌘↵ to save`}):(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`button`,{type:`button`,onClick:()=>c.current?.click(),className:`inline-flex items-center gap-1.5 rounded-md px-2 py-1 text-[13px] text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,children:[(0,F.jsx)(lr,{className:`h-4 w-4`}),` `,t?`Uploading…`:`Upload`]}),(0,F.jsx)(`input`,{ref:c,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{r(e.target.files),e.target.value=``}})]}),i.trim()&&(0,F.jsxs)(Jh,{size:`sm`,onClick:l,disabled:t,children:[(0,F.jsx)(un,{className:`h-3.5 w-3.5`}),` Save`]})]})]})}function dk({busy:e,onFiles:t}){let n=(0,P.useRef)(null);return(0,F.jsxs)(`button`,{type:`button`,onClick:()=>n.current?.click(),className:`flex w-full flex-col items-center justify-center gap-2 rounded-2xl border border-dashed py-10 text-muted-foreground transition-colors hover:border-muted-foreground/40 hover:bg-accent/20`,children:[(0,F.jsx)(lr,{className:`h-6 w-6`}),(0,F.jsx)(`p`,{className:`text-[13px]`,children:e?`Uploading…`:`Drop files or browse`}),(0,F.jsx)(`input`,{ref:n,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{t(e.target.files),e.target.value=``}})]})}function fk({domainId:e,doc:t,onEdit:n,onDelete:r}){let i=nk(t);return(0,F.jsxs)(`div`,{className:`group flex flex-col gap-2.5 rounded-xl border bg-card/50 p-3 transition-colors hover:border-muted-foreground/30 hover:bg-accent/30`,children:[(0,F.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,F.jsx)(`div`,{className:K(`flex h-9 w-9 items-center justify-center rounded-lg`,i.tint),children:(0,F.jsx)(i.Icon,{className:`h-[18px] w-[18px]`})}),(0,F.jsxs)(`div`,{className:`flex items-center gap-0.5 opacity-0 transition-opacity group-hover:opacity-100`,children:[ik(t)&&(0,F.jsx)(pk,{title:`Copy`,onClick:async()=>{try{await navigator.clipboard.writeText(await z.docContent(e,t.id)),I.success(`Copied`)}catch{I.error(`Copy failed`)}},children:(0,F.jsx)(ln,{className:`h-3.5 w-3.5`})}),rk(t)&&(0,F.jsx)(pk,{title:`Edit`,onClick:n,children:(0,F.jsx)(Un,{className:`h-3.5 w-3.5`})}),(0,F.jsx)(pk,{title:`Remove`,danger:!0,onClick:r,children:(0,F.jsx)(fr,{className:`h-3.5 w-3.5`})})]})]}),(0,F.jsxs)(`a`,{href:z.docUrl(e,t.id),target:`_blank`,rel:`noreferrer`,className:`min-w-0`,children:[(0,F.jsx)(`div`,{className:`truncate text-[13px] font-medium leading-snug`,title:t.name,children:t.name}),(0,F.jsxs)(`div`,{className:`mt-0.5 text-[11px] text-muted-foreground`,children:[i.label,` · `,tk(t.size)]})]})]})}function pk({title:e,onClick:t,danger:n,children:r}){return(0,F.jsx)(`button`,{type:`button`,title:e,onClick:t,className:K(`flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground/60 transition-colors`,n?`hover:bg-destructive/10 hover:text-destructive`:`hover:bg-accent hover:text-foreground`),children:r})}function mk({domainId:e,doc:t,onClose:n,onSaved:r}){let[i,a]=(0,P.useState)(null),[o,s]=(0,P.useState)(!1);(0,P.useEffect)(()=>{let n=!0;return a(null),z.docContent(e,t.id).then(e=>n&&a(e)).catch(()=>{n&&(I.error(`Could not load document`),a(``))}),()=>{n=!1}},[e,t.id]);let c=async()=>{if(i!=null){s(!0);try{await z.updateDocument(e,t.id,i),I.success(`Saved`),r(),n()}catch(e){I.error(String(e))}finally{s(!1)}}};return(0,F.jsx)(xy,{open:!0,onOpenChange:e=>!e&&n(),children:(0,F.jsxs)(wy,{className:`max-w-2xl`,children:[(0,F.jsx)(Ty,{children:(0,F.jsx)(Dy,{className:`truncate text-sm`,children:t.name})}),(0,F.jsx)(tT,{autoFocus:!0,value:i??``,disabled:i==null,onChange:e=>a(e.target.value),onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),c())},placeholder:i==null?`Loading…`:``,className:`min-h-[50vh] resize-none font-mono text-[12px] leading-relaxed`}),(0,F.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,F.jsx)(`span`,{className:`mr-auto text-[11px] text-muted-foreground/60`,children:`⌘↵ to save`}),(0,F.jsx)(Jh,{variant:`ghost`,size:`sm`,onClick:n,children:`Cancel`}),(0,F.jsx)(Jh,{size:`sm`,onClick:c,disabled:o||i==null,children:o?`Saving…`:`Save`})]})]})})}function hk(e,t,n,r){return e.find(e=>e.owner===t&&e.method===n&&e.ownerKind===r)}function gk(e){let t=e?.auth;return t?t===`anonymous`?{level:`public`,icon:Tn,tone:`sky`,label:`Anonymous`,auth:t,blurb:`The callable contract permits anonymous callers.`}:{level:`secured`,icon:$n,tone:`emerald`,label:t===`authorized`?`Authorized`:`Authenticated`,auth:t,blurb:t===`authorized`?`The callable contract requires authorization.`:`The callable contract requires an authenticated principal.`}:null}var _k={emerald:`text-emerald-400 hover:text-emerald-300`,sky:`text-sky-400 hover:text-sky-300`,amber:`text-amber-400 hover:text-amber-300`,rose:`text-rose-400 hover:text-rose-300`};function vk({method:e,interactive:t=!0}){let n=gk(e);if(!n)return null;let r=n.icon,i=K(`inline-flex items-center justify-center rounded-md transition-colors`,_k[n.tone]);return(0,F.jsxs)(SD,{openDelay:80,children:[(0,F.jsx)(CD,{asChild:!0,children:t?(0,F.jsx)(`button`,{type:`button`,"aria-label":`Authorization: ${n.label}`,className:i,children:(0,F.jsx)(r,{className:`h-3.5 w-3.5`})}):(0,F.jsx)(`span`,{role:`img`,"aria-label":`Authorization: ${n.label}`,className:i,children:(0,F.jsx)(r,{className:`h-3.5 w-3.5`})})}),(0,F.jsx)(wD,{align:`start`,className:`w-96 p-0 overflow-hidden`,children:(0,F.jsx)(yk,{method:e})})]})}function yk({method:e}){let t=gk(e);if(!t)return null;let n=t.icon;return(0,F.jsxs)(`div`,{className:`text-[13px]`,children:[(0,F.jsxs)(`div`,{className:`flex items-start gap-2.5 p-3`,children:[(0,F.jsx)(WE,{tone:t.tone,size:`sm`,children:(0,F.jsx)(n,{})}),(0,F.jsxs)(`div`,{className:`min-w-0`,children:[(0,F.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,F.jsx)(`span`,{className:`font-semibold text-foreground`,children:t.label})}),(0,F.jsx)(`p`,{className:`mt-1 leading-relaxed text-muted-foreground`,children:t.blurb})]})]}),(0,F.jsx)(`div`,{className:`flex flex-wrap gap-1.5 border-t px-3 py-2`,children:(0,F.jsxs)(qE,{tone:`outline`,className:`font-mono`,children:[`auth: `,t.auth]})})]})}function bk(e,t){let n=rO(e),r=t??n.optional;switch(n.kind){case`string`:return{label:`Text`,icon:cr,optional:r};case`number`:case`integer`:return{label:`Number`,icon:En,optional:r};case`boolean`:return{label:`Yes / no`,icon:ar,optional:r};case`enum`:{let e=n.values.map(String);return{label:`One of: ${e.slice(0,3).join(`, `)}${e.length>3?`…`:``}`,icon:Mn,optional:r}}case`array`:return{label:`List`,icon:Nn,optional:r};case`object`:return{label:`Object`,icon:Qt,optional:r};case`ref`:return{label:`Reference`,icon:jn,optional:r};default:return{label:`Value`,icon:on,optional:r}}}function xk(e){return e.inheritance===`sealed`?{icon:Fn,tone:`amber`}:e.inheritance===`abstract`?{icon:Gn,tone:`fuchsia`}:{icon:pr,tone:`violet`}}function Sk(e){if(!e||typeof e!=`object`||Array.isArray(e))return 0;let t=e;return(t.nodes&&typeof t.nodes==`object`&&!Array.isArray(t.nodes)?Object.keys(t.nodes).length:0)+(Array.isArray(t.edges)?t.edges.length:0)}function Ck(e){let t=new Set,n=[];for(let r of e)for(let e of Array.isArray(r.viewFor)?r.viewFor:r.viewFor?[r.viewFor]:[])t.has(e)||(t.add(e),n.push(e));return n}function wk({domainId:e}){let t=Hr(e),n=Ur(e),r=V(e=>e.setSection),i=V(e=>e.focusClass),a=V(e=>e.setPanelOverlay),o=t.data,s=n.data,c=o?.ir??null,l=(0,P.useMemo)(()=>Sk(c?.core),[c?.core]),u=(0,P.useMemo)(()=>{if(!c||!o)return[];let e=[],t=Object.entries(c.functions);t.length>0&&e.push({owner:c.domain,label:`Domain callables`,className:null,fns:t.map(([e,t])=>({owner:c.domain,ownerKind:`function`,name:e,method:t,link:hk(o.overlay.handlerLinks,c.domain,e,`function`)}))});for(let t of Object.values(c.classes)){let n=Object.entries(t.methods??{});if(n.length===0)continue;let r=n.map(([e,n])=>({owner:t.name,ownerKind:`class`,name:e,method:n,link:hk(o.overlay.handlerLinks,t.name,e,`class`)}));e.push({owner:t.name,label:t.name,className:t.name,fns:r})}return e.sort((e,t)=>e.className===null&&t.className!==null?-1:+(e.className!==null&&t.className===null))},[c,o]),d=u.reduce((e,t)=>e+t.fns.length,0),f=s?.views??[],p=(0,P.useMemo)(()=>Ck(f),[f]),m=e=>{r(`schema`),i(`class.${e}`)};return t.isLoading||n.isLoading?(0,F.jsx)(`div`,{className:`flex items-center justify-center p-8 text-sm text-muted-foreground`,children:`Loading…`}):(0,F.jsx)(BE,{title:`Process`,subtitle:`Actions and workflows implementing callable contracts`,icon:(0,F.jsx)(ur,{className:`h-5 w-5`}),children:c?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(VE,{label:`Entrypoints`,children:(0,F.jsxs)(`div`,{className:`space-y-2`,children:[l>0?(0,F.jsxs)(HE,{className:`flex items-center gap-3 border-emerald-500/30 bg-emerald-500/[0.04] px-4 py-3`,children:[(0,F.jsx)(WE,{tone:`emerald`,children:(0,F.jsx)(nr,{})}),(0,F.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,F.jsx)(`div`,{className:`truncate text-sm font-semibold`,children:`Core genesis`}),(0,F.jsxs)(`div`,{className:`mt-0.5 text-[13px] text-muted-foreground`,children:[l,` portable element`,l===1?``:`s`,` installed with the schema`]})]})]}):(0,F.jsxs)(HE,{className:`flex items-center gap-3 px-4 py-3 text-muted-foreground`,children:[(0,F.jsx)(WE,{tone:`muted`,children:(0,F.jsx)(nr,{})}),(0,F.jsx)(`div`,{className:`min-w-0 flex-1 text-[13px]`,children:`No Core genesis data declared in this schema.`})]}),f.length>0&&(0,F.jsxs)(HE,{onClick:()=>{r(`schema`),a(`views`)},className:`flex cursor-pointer items-center gap-3 px-4 py-3 transition-colors hover:bg-accent/50`,children:[(0,F.jsx)(WE,{tone:`sky`,children:(0,F.jsx)(kn,{})}),(0,F.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,F.jsxs)(`div`,{className:`text-sm font-semibold`,children:[f.length,` view`,f.length===1?``:`s`,` `,(0,F.jsx)(`span`,{className:`font-normal text-muted-foreground`,children:`· UI entrypoints`})]}),p.length>0&&(0,F.jsxs)(`div`,{className:`mt-1 flex flex-wrap gap-1`,children:[p.slice(0,8).map(e=>(0,F.jsx)(qE,{tone:`outline`,children:e},e)),p.length>8&&(0,F.jsxs)(qE,{tone:`default`,children:[`+`,p.length-8]})]})]}),(0,F.jsx)(Jt,{className:`h-4 w-4 shrink-0 text-muted-foreground`})]}),(0,F.jsxs)(HE,{className:`flex items-center gap-3 border-dashed px-4 py-3 text-muted-foreground`,children:[(0,F.jsx)(WE,{tone:`muted`,children:(0,F.jsx)(Kn,{})}),(0,F.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,F.jsx)(`div`,{className:`text-sm font-medium text-muted-foreground`,children:`Triggers`}),(0,F.jsx)(`div`,{className:`mt-0.5 text-[13px] text-muted-foreground/70`,children:`On event · polling · cron — wired via the services domain. Not parsed yet.`})]})]})]})}),d===0?(0,F.jsx)(XE,{icon:(0,F.jsx)(ur,{}),title:`No callable contracts yet`,hint:`Add a standalone Function or class Method to the schema to see it here.`}):(0,F.jsx)(VE,{label:`Runtime`,hint:`${d}`,children:(0,F.jsx)(`div`,{className:`space-y-3`,children:u.map(e=>(0,F.jsxs)(HE,{className:`overflow-hidden`,children:[(0,F.jsxs)(`button`,{type:`button`,onClick:e.className?()=>m(e.className):void 0,className:K(`flex w-full items-center gap-2.5 px-3 py-2 text-left transition-colors`,e.className&&`hover:bg-accent/40`),children:[(0,F.jsx)(WE,{tone:`muted`,size:`sm`,children:e.className?(0,F.jsx)(Xt,{}):(0,F.jsx)(Qt,{})}),(0,F.jsx)(`span`,{className:`flex-1 truncate text-[13px] font-semibold`,children:e.label}),(0,F.jsxs)(`span`,{className:`shrink-0 text-[11px] text-muted-foreground`,children:[e.fns.length,` callable`]})]}),(0,F.jsx)(`div`,{className:`border-t`,children:e.fns.map(e=>(0,F.jsx)(Tk,{fn:e,onClick:e.ownerKind===`class`?()=>m(e.owner):void 0},e.name))})]},e.owner))})})]}):(0,F.jsx)(HE,{className:`px-4 py-3 text-sm text-muted-foreground`,children:`Schema unavailable — install dependencies to see this domain’s callable contracts.`})})}function Tk({fn:e,onClick:t}){let n=e.link?.kind===`workflow`?{icon:ur,tone:`fuchsia`}:e.link?.kind===`action`?{icon:pr,tone:`violet`}:`inheritance`in e.method?xk(e.method):{icon:pr,tone:`violet`},r=n.icon,i=e.link?.kernelCalls??[],a=e.link&&!e.link.implemented;return(0,F.jsx)(GE,{onClick:t,className:`px-3 py-2 border-t first:border-t-0 rounded-none`,leading:(0,F.jsx)(WE,{tone:n.tone,size:`sm`,children:(0,F.jsx)(r,{})}),title:(0,F.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(`span`,{className:`font-semibold`,children:e.name}),(0,F.jsx)(vk,{method:e.method,interactive:!t}),e.link&&(0,F.jsx)(qE,{tone:`primary`,children:e.link.kind}),`static`in e.method&&e.method.static&&(0,F.jsx)(qE,{tone:`default`,children:`static`}),`inheritance`in e.method&&e.method.inheritance===`abstract`&&(0,F.jsx)(qE,{tone:`fuchsia`,children:`contract`}),a&&(0,F.jsx)(qE,{tone:`warning`,children:`needs handler`}),e.link?.unlinked&&(0,F.jsx)(qE,{tone:`default`,children:`unlinked`})]}),trailing:i.length>0?(0,F.jsxs)(`div`,{className:`hidden items-center gap-1 sm:flex`,children:[i.slice(0,3).map(e=>(0,F.jsx)(qE,{tone:`outline`,className:`font-mono`,children:e},e)),i.length>3&&(0,F.jsxs)(qE,{tone:`default`,children:[`+`,i.length-3]})]}):void 0})}var Ek=`modulepreload`,Dk=function(e){return`/`+e},Ok={},kk=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=Dk(t,n),t=s(t),t in Ok)return;Ok[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:Ek,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},Ak=(0,P.lazy)(()=>kk(async()=>{let{SchemaSection:e}=await import(`./schema-studio-DRdfu_cQ.js`);return{SchemaSection:e}},__vite__mapDeps([0,1,2])).then(({SchemaSection:e})=>({default:e}))),jk=[{key:`context`,label:`Context`,icon:An},{key:`schema`,label:`Schema`,icon:Hn},{key:`process`,label:`Process`,icon:ur},{key:`comments`,label:`Comments`,icon:Ln}];function Mk({section:e,domainId:t}){switch(e){case`schema`:return(0,F.jsx)(P.Suspense,{fallback:(0,F.jsx)(`div`,{className:`h-full flex items-center justify-center text-muted-foreground`,children:`Loading schema studio…`}),children:(0,F.jsx)(Ak,{domainId:t})});case`context`:return(0,F.jsx)(sk,{domainId:t});case`process`:return(0,F.jsx)(wk,{domainId:t});case`comments`:return(0,F.jsx)(QO,{domainId:t})}}function Nk(){let{data:e}=zr(),t=V(e=>e.domainId),n=V(e=>e.section),r=V(e=>e.setDomain),i=V(e=>e.setSection),a=V(e=>e.setPaletteOpen),o=V(e=>e.setSettingsOpen),s=V(e=>e.commentMode),c=V(e=>e.toggleCommentMode),l=V(e=>e.toggleAskMode),u=ci(),d=wr(e=>e.setRun),f=wr(e=>e.appendEvent),p=Le();(0,P.useEffect)(()=>{if(!t&&e&&e.length){let t=null;try{t=localStorage.getItem(`studio.lastDomain`)}catch{}r(t&&e.some(e=>e.id===t)?t:e[0].id)}},[e,t,r]),JO((0,P.useCallback)(e=>{if(e.type===`hello`){let e=V.getState().domainId;e&&(u(e),p.invalidateQueries({queryKey:B.agent(e)}));return}if(e.type===`workspace`){p.invalidateQueries({queryKey:B.workspace});return}if(e.type===`agent-event`){f(e.domainId,e.runId,e.event);return}if(e.type===`agent-run`){d(e.run),p.invalidateQueries({queryKey:B.agent(e.domainId)});return}if(e.type===`schema-diff`){u(e.domainId),p.invalidateQueries({queryKey:B.workspace});return}`domainId`in e&&e.domainId&&u(e.domainId)},[u,d,f,p]));let{data:m}=Tr(t);(0,P.useEffect)(()=>{m?.run&&d(m.run)},[m,d]),(0,P.useEffect)(()=>{let e=e=>{let t=e.target;t&&(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.isContentEditable)||e.metaKey||e.ctrlKey||e.altKey||(e.key===`c`||e.key===`C`?(e.preventDefault(),c()):(e.key===`a`||e.key===`A`)&&(e.preventDefault(),l()))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[c,l]);let{data:h}=ni(t),g=h?.comments.filter(e=>e.status===`open`&&e.thread.at(-1)?.role===`author`).length??0;return e?(0,F.jsxs)(nw,{delayDuration:200,children:[(0,F.jsxs)(`div`,{className:`h-full flex flex-col`,children:[(0,F.jsxs)(`header`,{className:`flex items-center gap-3 px-5 h-14 border-b shrink-0`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(uO,{}),(0,F.jsx)(ZD,{}),t&&(0,F.jsx)(cO,{domainId:t}),t&&(0,F.jsx)(`button`,{type:`button`,"aria-label":`Settings`,title:`Settings`,onClick:()=>o(!0),className:`flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground/40 transition-colors hover:bg-accent/60 hover:text-foreground`,children:(0,F.jsx)(Qn,{className:`h-4 w-4`})}),t&&(0,F.jsx)(qO,{domainId:t}),t&&(0,F.jsx)($D,{domainId:t})]}),(0,F.jsxs)(`div`,{className:`ml-auto flex items-center gap-1.5`,children:[(0,F.jsxs)(Jh,{variant:`ghost`,size:`sm`,onClick:()=>a(!0),title:`Search (⌘K)`,children:[(0,F.jsx)(Xn,{className:`h-4 w-4`}),(0,F.jsx)(`kbd`,{className:`rounded bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground`,children:`⌘K`})]}),(0,F.jsxs)(Jh,{variant:s?`default`:`ghost`,size:`sm`,"aria-label":`Comment mode`,onClick:()=>c(),title:`Comment mode — click any element to comment (C)`,children:[(0,F.jsx)(Rn,{className:`h-4 w-4`}),(0,F.jsx)(`kbd`,{className:K(`rounded px-1.5 py-0.5 text-[10px]`,s?`bg-primary-foreground/20 text-primary-foreground`:`bg-muted text-muted-foreground`),children:`C`})]}),(0,F.jsx)(`div`,{className:`h-5 w-px bg-border mx-0.5`}),(0,F.jsx)(uw,{})]})]}),(0,F.jsxs)(`main`,{className:`flex-1 min-h-0 relative overflow-hidden`,children:[t?(0,F.jsx)(Mk,{section:n,domainId:t}):(0,F.jsx)(`div`,{className:`h-full flex items-center justify-center text-muted-foreground`,children:`No domain selected`}),(0,F.jsx)(`nav`,{className:`absolute bottom-5 left-1/2 -translate-x-1/2 z-40`,children:(0,F.jsx)(`div`,{className:`flex items-center gap-1 rounded-2xl border bg-card/70 px-2 py-2 shadow-2xl shadow-black/40 backdrop-blur-xl`,children:jk.map(e=>{let t=e.icon,r=n===e.key,a=e.key===`comments`?g:0;return(0,F.jsxs)(rw,{children:[(0,F.jsx)(iw,{asChild:!0,children:(0,F.jsxs)(`button`,{type:`button`,"aria-label":e.label,"aria-current":r?`page`:void 0,onClick:()=>i(e.key),className:K(`relative h-11 w-11 rounded-xl flex items-center justify-center transition-all duration-150`,r?`bg-primary/15 text-primary`:`text-muted-foreground hover:-translate-y-1 hover:bg-accent hover:text-foreground`),children:[(0,F.jsx)(t,{className:`h-[19px] w-[19px]`}),a>0&&(0,F.jsx)(`span`,{className:`absolute -right-0.5 -top-0.5 flex h-4 min-w-4 items-center justify-center rounded-full bg-primary px-1 text-[10px] font-semibold leading-none text-primary-foreground`,children:a>99?`99+`:a}),r&&(0,F.jsx)(`span`,{className:`absolute -bottom-0.5 left-1/2 h-1 w-1 -translate-x-1/2 rounded-full bg-primary`})]})}),(0,F.jsx)(aw,{side:`top`,sideOffset:10,children:e.label})]},e.key)})})})]})]}),(0,F.jsx)(vE,{}),(0,F.jsx)(zD,{}),(0,F.jsx)(MD,{}),(0,F.jsx)(aT,{}),(0,F.jsx)(_w,{}),(0,F.jsx)(KO,{})]}):(0,F.jsx)(`div`,{className:`h-full flex items-center justify-center text-muted-foreground`,children:`Connecting to studio…`})}var Pk=new je({defaultOptions:{queries:{staleTime:5e3,refetchOnWindowFocus:!1,retry:1}}});(0,at.createRoot)(document.getElementById(`root`)).render((0,F.jsx)(P.StrictMode,{children:(0,F.jsxs)(Re,{client:Pk,children:[(0,F.jsx)(Nk,{}),(0,F.jsx)(Lt,{theme:`dark`,position:`bottom-right`,richColors:!0,closeButton:!0})]})}));export{Gr as $,S as $t,nE as A,$t as At,wy as B,Ye as Bt,YE as C,mn as Ct,cE as D,nn as Dt,yE as E,an as Et,eT as F,L as Ft,Ur as G,Be as Gt,Jh as H,Ke as Ht,Qw as I,I as It,li as J,Ne as Jt,Hr as K,Le as Kt,ew as L,rt as Lt,dE as M,Xt as Mt,Zw as N,Jt as Nt,uE as O,tn as Ot,$w as P,qt as Pt,Wr as Q,x as Qt,tw as R,qe as Rt,WE as S,hn as St,HE as T,fn as Tt,K as U,Ge as Ut,Dy as V,We as Vt,V as W,Ue as Wt,ii as X,N as Xt,ni as Y,ve as Yt,ai as Z,l as Zt,CD as _,Vn as _t,hk as a,Mr as at,XE as b,On as bt,iO as c,z as ct,PD as d,sr as dt,r as en,oi as et,jD as f,tr as ft,wD as g,Hn as gt,SD as h,Wn as ht,vk as i,Lr as it,fE as j,Zt as jt,rE as k,en as kt,JD as l,B as lt,TD as m,qn as mt,bk as n,Ir as nt,aO as o,jr as ot,AD as p,Xn as pt,Br as q,Fe as qt,xk as r,Rr as rt,rO as s,Pr as st,kk as t,zr as tt,ID as u,fr as ut,qE as v,Ln as vt,GE as w,pn as wt,VE as x,Tn as xt,JE as y,Pn as yt,xy as z,Xe as zt};
|