@quixomatic/rpf 0.3.0 → 0.3.1
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/CHANGELOG.md +11 -0
- package/assets/forge-app/app/assets/{_forge-shiki-langs-BtmKnsX8.js → _forge-shiki-langs-DaJjT17w.js} +1 -1
- package/assets/forge-app/app/assets/{appendItems-D8y87kIw.js → appendItems-CWJJlOE7.js} +1 -1
- package/assets/forge-app/app/assets/{core-pm_tYnN8.js → core-Dl2d1S-D.js} +1 -1
- package/assets/forge-app/app/assets/{diff-view-KCzB8C4U.js → diff-view-Chujmqzi.js} +1 -1
- package/assets/forge-app/app/assets/{file-panel-BKKQ3JJL.js → file-panel-le_M5nHe.js} +1 -1
- package/assets/forge-app/app/assets/{highlights-dvwIMyOh.js → highlights-BxaWC1ve.js} +1 -1
- package/assets/forge-app/app/assets/{index-DgB2FK2g.js → index-UP3KtgHV.js} +6 -6
- package/assets/forge-app/app/assets/{loader-DUZOP7q_.js → loader-BMv9OYvr.js} +1 -1
- package/assets/forge-app/app/assets/{shiki-BghTRNDM.js → shiki-CoRI3zWj.js} +2 -2
- package/assets/forge-app/app/assets/{stream-tokenizer-BzA0VElt.js → stream-tokenizer-BMtK_3oz.js} +1 -1
- package/assets/forge-app/app/assets/{terminal-view-BdvNEDWd.js → terminal-view-D3CiLjfu.js} +1 -1
- package/assets/forge-app/app/assets/{themes-D3CUotbU.js → themes-CLX9vH7e.js} +2 -2
- package/assets/forge-app/app/assets/{useNextRenderData-BaDffqa5.js → useNextRenderData-dgMkjxGZ.js} +1 -1
- package/assets/forge-app/app/index.html +1 -1
- package/assets/forge-app/server.mjs +440 -125
- package/dist/cli.mjs +2 -2
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/core-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/core-Dl2d1S-D.js","assets/lib-BOh9Tw1y.js","assets/highlights-BxaWC1ve.js","assets/appendItems-CWJJlOE7.js","assets/stream-tokenizer-BMtK_3oz.js","assets/formatCSSVariablePrefix-KRh9vnZf.js","assets/shiki-CoRI3zWj.js","assets/utils-C9Glzetk.js","assets/diff-view-Chujmqzi.js","assets/useNextRenderData-dgMkjxGZ.js","assets/terminal-view-D3CiLjfu.js","assets/terminal-view-BrP-ENHg.css","assets/file-panel-le_M5nHe.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t,t.exports),e=null),t.exports),s=(e,n)=>{let r=Object.setPrototypeOf({},null);for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n&1||t(r,Symbol.toStringTag,{value:`Module`}),n&2?r:Object.preventExtensions(r)},c=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(let c of r(i))!a.call(e,c)&&c!==o&&(s=n(i,c),t(e,c,{get:s&&s.get&&!s.configurable?s.get:()=>i[c],enumerable:!s||s.enumerable}));return e},l=(n,r,o)=>(o=n==null?{}:e(i(n)),c(r||!n||!n.__esModule||!a.call(n,`default`)?t(o,`default`,{value:n,enumerable:!0}):o,n));(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 u=o((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.for(`react.view_transition`),m=Symbol.iterator;function h(e){return typeof e!=`object`||!e?null:(e=m&&e[m]||e[`@@iterator`],typeof e==`function`?e:null)}var g={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},_=Object.assign,v={};function y(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}y.prototype.isReactComponent={},y.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`)},y.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function b(){}b.prototype=y.prototype;function x(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}var S=x.prototype=new b;S.constructor=x,_(S,y.prototype),S.isPureReactComponent=!0;var C=Array.isArray;function w(){}var T={H:null,A:null,T:null,S:null},E=Object.prototype.hasOwnProperty;function D(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function O(e,t){return D(e.type,t,e.props)}function k(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function A(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var j=/\/+/g;function M(e,t){return typeof e==`object`&&e&&e.key!=null?A(``+e.key):t.toString(36)}function N(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(w,w):(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 P(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,P(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+M(e,0):a,C(o)?(i=``,c!=null&&(i=c.replace(j,`$&/`)+`/`),P(o,r,i,``,function(e){return e})):o!=null&&(k(o)&&(o=O(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(j,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(C(e))for(var u=0;u<e.length;u++)a=e[u],s=l+M(a,u),c+=P(a,r,i,s,o);else if(u=h(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+M(a,u++),c+=P(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return P(N(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 F(e,t,n){if(e==null)return e;var r=[],i=0;return P(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function I(e){if(e._status===-1){var t=(0,e._result)();t.then(function(n){(e._status===0||e._status===-1)&&(e._status=1,e._result=n,t.status===void 0&&(t.status=`fulfilled`,t.value=n))},function(n){(e._status===0||e._status===-1)&&(e._status=2,e._result=n,t.status===void 0&&(t.status=`rejected`,t.reason=n))}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var L=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)};function R(e){var t=T.T,n={};n.types=t===null?null:t.types,T.T=n;try{var r=e(),i=T.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(w,L)}catch(e){L(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),T.T=t}}function z(e){var t=T.T;if(t!==null){var n=t.types;n===null?t.types=[e]:n.indexOf(e)===-1&&n.push(e)}else R(z.bind(null,e))}var B={map:F,forEach:function(e,t,n){F(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return F(e,function(){t++}),t},toArray:function(e){return F(e,function(e){return e})||[]},only:function(e){if(!k(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=B,e.Component=y,e.Fragment=r,e.Profiler=a,e.PureComponent=x,e.StrictMode=i,e.Suspense=l,e.ViewTransition=p,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=T,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return T.H.useMemoCache(e)}},e.addTransitionType=z,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=_({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!E.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 D(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)E.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 D(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=k,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:I}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=R,e.unstable_useCacheRefresh=function(){return T.H.useCacheRefresh()},e.use=function(e){return T.H.use(e)},e.useActionState=function(e,t,n){return T.H.useActionState(e,t,n)},e.useCallback=function(e,t){return T.H.useCallback(e,t)},e.useContext=function(e){return T.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return T.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return T.H.useEffect(e,t)},e.useEffectEvent=function(e){return T.H.useEffectEvent(e)},e.useId=function(){return T.H.useId()},e.useImperativeHandle=function(e,t,n){return T.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return T.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return T.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return T.H.useMemo(e,t)},e.useOptimistic=function(e,t){return T.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return T.H.useReducer(e,t,n)},e.useRef=function(e){return T.H.useRef(e)},e.useState=function(e){return T.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return T.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return T.H.useTransition()},e.version=`19.3.1`})),d=o(((e,t)=>{t.exports=u()})),f=o((e=>{function t(e,t){var n=e.length;for(e.push(t);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}}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;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}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{e:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{t:{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 t}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&j(x,u.startTime-t),i=!1}}break e}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=0x3fffffff;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),p=o(((e,t)=>{t.exports=f()})),m=o((e=>{var t=d();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`),o=Symbol.for(`react.recoverable`),s=Symbol.for(`react.optimistic_key`);function c(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:r===s?s:``+r,children:e,containerInfo:t,implementation:n}}var l=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function u(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.browser=function(e){return{$$typeof:o,_reason:e}},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 c(e,t,null,r)},e.flushSync=function(e){var t=l.T,n=i.p;try{if(l.T=null,i.p=2,e)return e()}finally{l.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=u(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=u(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,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority: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=u(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=u(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,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority: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 l.H.useFormState(e,t,n)},e.useFormStatus=function(){return l.H.useHostTransitionStatus()},e.version=`19.3.1`})),h=o(((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=m()})),g=o((e=>{var t=p(),n=d(),r=h();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){for(var t=e,n=t;n&&!n.alternate;)t=n,t.flags&4098&&(e=t.return),n=t.return;for(;t.return;)t=t.return;return t.tag===3?e: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 f(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=f(e),t!==null)return t;e=e.sibling}return null}function m(e,t,n,r,i,a){for(;e!==null;){if((e.tag===5||e.tag===27||e.tag===6)&&n(e,r,i,a)||(e.tag!==22||e.memoizedState===null)&&(t||e.tag!==5&&e.tag!==27)&&m(e.child,t,n,r,i,a))return!0;e=e.sibling}return!1}function g(e){for(e=e.return;e!==null;){if(e.tag===3||e.tag===5||e.tag===27)return e;e=e.return}return null}function _(e){var t=!1;for(e=e.return;e!==null&&(e.tag===4&&(t=!0),e.tag!==3&&e.tag!==5&&e.tag!==27);)e=e.return;return t}function v(e){var t=[null,null],n=g(e);return n===null||y(t,e,n.child,{foundSelf:!1}),t}function y(e,t,n,r){for(;n!==null;){if(n===t)r.foundSelf=!0;else if(n.tag===5||n.tag===27||n.tag===6){if(r.foundSelf)return e[1]=n,!0;e[0]=n}else if((n.tag!==22||n.memoizedState===null)&&y(e,t,n.child,r))return!0;n=n.sibling}return!1}function b(e){switch(e.tag){case 5:case 27:case 6:return e.stateNode;case 3:return e.stateNode.containerInfo;default:throw Error(i(559))}}var x=null,S=null;function C(e,t,n){return e===n||e===t&&(x=e,!0)}function w(e,t,n){return e===n?(S=e,!1):e===t&&(S!==null&&(x=e),!0)}function T(e){if(e===null)return null;do e=e===null?null:e.return;while(e&&e.tag!==5&&e.tag!==27&&e.tag!==3);return e||null}function E(e,t,n){for(var r=0,i=e;i;i=n(i))r++;i=0;for(var a=t;a;a=n(a))i++;for(;0<r-i;)e=n(e),r--;for(;0<i-r;)t=n(t),i--;for(;r--;){if(e===t||t!==null&&e===t.alternate)return e;e=n(e),t=n(t)}return null}var D=Object.assign,O=Symbol.for(`react.element`),k=Symbol.for(`react.transitional.element`),A=Symbol.for(`react.portal`),j=Symbol.for(`react.fragment`),M=Symbol.for(`react.strict_mode`),N=Symbol.for(`react.profiler`),P=Symbol.for(`react.consumer`),F=Symbol.for(`react.context`),I=Symbol.for(`react.forward_ref`),L=Symbol.for(`react.suspense`),R=Symbol.for(`react.suspense_list`),z=Symbol.for(`react.memo`),B=Symbol.for(`react.lazy`),V=Symbol.for(`react.activity`),H=Symbol.for(`react.legacy_hidden`),ee=Symbol.for(`react.memo_cache_sentinel`),te=Symbol.for(`react.view_transition`),ne=Symbol.for(`react.recoverable`),re=Symbol.iterator;function ie(e){return typeof e!=`object`||!e?null:(e=re&&e[re]||e[`@@iterator`],typeof e==`function`?e:null)}var ae=Symbol.for(`react.client.reference`);function oe(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===ae?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case j:return`Fragment`;case N:return`Profiler`;case M:return`StrictMode`;case L:return`Suspense`;case R:return`SuspenseList`;case V:return`Activity`;case te:return`ViewTransition`}if(typeof e==`object`)switch(e.$$typeof){case A:return`Portal`;case F:return e.displayName||`Context`;case P:return(e._context.displayName||`Context`)+`.Consumer`;case I:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case z:return t=e.displayName||null,t===null?oe(e.type)||`Memo`:t;case B:t=e._payload,e=e._init;try{return oe(e(t))}catch{}}return null}var se=Array.isArray,ce=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,le=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ue={pending:!1,data:null,method:null,action:null},de=[],fe=-1;function pe(e){return{current:e}}function me(e){0>fe||(e.current=de[fe],de[fe]=null,fe--)}function he(e,t){fe++,de[fe]=e.current,e.current=t}var ge=pe(null),_e=pe(null),ve=pe(null),ye=pe(null);function be(e,t){switch(he(ve,t),he(_e,e),he(ge,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?_p(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=_p(t),e=vp(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}me(ge),he(ge,e)}function xe(){me(ge),me(_e),me(ve)}function Se(e){var t=e.memoizedState;t!==null&&(ph._currentValue=t.memoizedState,he(ye,e)),t=ge.current;var n=vp(t,e.type);t!==n&&(he(_e,e),he(ge,n))}function Ce(e){_e.current===e&&(me(ge),me(_e)),ye.current===e&&(me(ye),ph._currentValue=ue)}var we,Te;function Ee(e){if(we===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);we=t&&t[1]||``,Te=-1<e.stack.indexOf(`
|
|
3
3
|
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
4
4
|
`+we+e+Te}var De=!1;function Oe(e,t){if(!e||De)return``;De=!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}n=!1;try{var i=Object.getOwnPropertyDescriptor(e.prototype,`props`);Object.defineProperty(e.prototype,"props",{configurable:!0,set:function(){throw Error()}}),n=!0,new e}finally{n&&(i===void 0?delete e.prototype.props:Object.defineProperty(e.prototype,"props",i))}}}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(`
|
|
@@ -278,14 +278,14 @@ ${t}`,d++;break;case`id`:t.includes(`\0`)||(l=t);break;case`retry`:/^\d+$/.test(
|
|
|
278
278
|
`,...a.current()}),u=l.charCodeAt(0);return(u===9||u===32)&&(l=MG(u)+l.slice(1)),l=l?o+` `+l:o,n.options.closeAtx&&(l+=` `+o),c(),s(),l}$G.peek=eK;function $G(e){return e.value||``}function eK(){return`<`}tK.peek=nK;function tK(e,t,n,r){let i=DG(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`image`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`![`);return l+=c.move(n.safe(e.alt,{before:l,after:`]`,...c.current()})),l+=c.move(`](`),s(),!e.url&&e.title||/^<|[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),l+=c.move(`)`),o(),l}function nK(){return`!`}rK.peek=iK;function rK(e,t,n,r){let i=e.referenceType,a=n.enter(`imageReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`![`),l=n.safe(e.alt,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=u.filter(function(e){return e!==`phrasing`}),o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function iK(){return`!`}aK.peek=oK;function aK(e,t,n){let r=e.value||``,i="`",a=-1;for(;RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^\n\r ]/.test(r)&&(/^[\n\r ]/.test(r)&&/[\n\r ]$/.test(r)||/^`|`$/.test(r))&&(r=` `+r+` `);++a<n.unsafe.length;){let e=n.unsafe[a],t=n.compilePattern(e);if(!e.atBreak)continue;let i;for(;i=t.exec(r);){let e=i.index;r.charCodeAt(e)===10&&r.charCodeAt(e-1)===13&&e--,r=r.slice(0,e)+` `+r.slice(i.index+1)}}return i+r+i}function oK(){return"`"}function sK(e,t){let n=oz(e);return!(t.options.resourceLink||!e.url||e.title||!e.children||e.children.length!==1||e.children[0].type!==`text`||n!==e.url&&`mailto:`+n!==e.url||!/^[a-z][+\-.a-z]+:/i.test(e.url)||/[\0- <>\u007F]/.test(e.url))}cK.peek=lK;function cK(e,t,n,r){let i=DG(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.createTracker(r);if(sK(e,n)){let t=n.stack;n.stack=t.filter(function(e){return e!==`phrasing`});let r=n.enter(`autolink`),i=o.move(`<`);return i+=o.move(n.containerPhrasing(e,{before:i,after:`>`,...o.current()})),i+=o.move(`>`),r(),n.stack=t,i}let s=n.enter(`link`),c=n.enter(`label`),l=o.move(`[`),u=n.containerPhrasing(e,{before:l,after:`](`,...o.current()});l+=o.move(u),c(),l+=o.move(`](`);let d=/^<|[\0- \u007F]/.test(e.url),f=r.before.charAt(r.before.length-1),p=e.title||void 0;if(!p&&!d&&(f===`
|
|
279
279
|
`||f===`\r`)){let e=0;for(;e<u.length&&u.charCodeAt(e)!==93;)e+=u.charCodeAt(e)===92?2:1;u.charCodeAt(e+1)===58&&(p=``)}return!e.url&&typeof p==`string`||d?(c=n.enter(`destinationLiteral`),l+=o.move(`<`),l+=o.move(n.safe(e.url,{before:l,after:`>`,...o.current()})),l+=o.move(`>`)):(c=n.enter(`destinationRaw`),l+=o.move(n.safe(e.url,{before:l,after:typeof p==`string`?` `:`)`,...o.current()}))),c(),typeof p==`string`&&(c=n.enter(`title${a}`),l+=o.move(` `+i),l+=o.move(n.safe(p,{before:l,after:i,...o.current()})),l+=o.move(i),c()),l+=o.move(`)`),s(),l}function lK(e,t,n){return sK(e,n)?`<`:`[`}uK.peek=dK;function uK(e,t,n,r){let i=e.referenceType,a=n.enter(`linkReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`[`),l=n.containerPhrasing(e,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=u.filter(function(e){return e!==`phrasing`}),o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function dK(){return`[`}function fK(e){let t=e.options.bullet||`*`;if(t!==`*`&&t!==`+`&&t!==`-`)throw Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function pK(e){let t=fK(e),n=e.options.bulletOther;if(!n)return t===`*`?`-`:`*`;if(n!==`*`&&n!==`+`&&n!==`-`)throw Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function mK(e){let t=e.options.bulletOrdered||`.`;if(t!==`.`&&t!==`)`)throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function hK(e){let t=e.options.rule||`*`;if(t!==`*`&&t!==`-`&&t!==`_`)throw Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function gK(e,t,n,r){let i=n.enter(`list`),a=n.bulletCurrent,o=e.ordered?mK(n):fK(n),s=e.ordered?o===`.`?`)`:`.`:pK(n),c=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){let t=e.children?e.children[0]:void 0;if(o!==`*`&&o!==`-`||!t||t.children&&t.children[0]||n.stack[n.stack.length-1]!==`list`||n.stack[n.stack.length-2]!==`listItem`||n.stack[n.stack.length-3]!==`list`||n.stack[n.stack.length-4]!==`listItem`||n.indexStack[n.indexStack.length-1]!==0||n.indexStack[n.indexStack.length-2]!==0||n.indexStack[n.indexStack.length-3]!==0||(c=!0),hK(n)===o&&t){let t=-1;for(;++t<e.children.length;){let n=e.children[t];if(n&&n.type===`listItem`&&n.children&&n.children[0]&&n.children[0].type===`thematicBreak`){c=!0;break}}}}c&&(o=s),n.bulletCurrent=o;let l=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=a,i(),l}function _K(e){let t=e.options.listItemIndent||`one`;if(t!==`tab`&&t!==`one`&&t!==`mixed`)throw Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function vK(e,t,n,r){let i=_K(n),a=n.bulletCurrent||fK(n);t&&t.type===`list`&&t.ordered&&(a=(typeof t.start==`number`&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+a);let o=a.length+1;(i===`tab`||i===`mixed`&&(t&&t.type===`list`&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);let s=n.createTracker(r);s.move(a+` `.repeat(o-a.length)),s.shift(o);let c=n.enter(`listItem`),l=n.indentLines(n.containerFlow(e,s.current()),u);return c(),l;function u(e,t,n){return t?(n?``:` `.repeat(o))+e:(n?a:a+` `.repeat(o-a.length))+e}}function yK(e,t,n,r){let i=n.enter(`paragraph`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,r);return a(),i(),o}function bK(e,t,n,r){if(!e.children.some(function(e){return gG(e)}))return n.containerFlow(e,r);let i=n.enter(`phrasing`),a=n.containerPhrasing(e,r);return i(),a}function xK(e){let t=e.options.strong||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}SK.attention=CK,SK.peek=wK;function SK(e,t,n,r){let i=n.enter(`phrasing`),a=UG(e,CK,n,n.createTracker(r)),o=a?qG([a],r.before,r.after):``;return i(),o}function CK(e,t){return{construct:`strong`,markers:xK(t)===`*`?[`*`,`_`]:[`_`,`*`],sizes:[2]}}function wK(e,t,n){return n.options.strong||`*`}function TK(e,t,n,r){let i=t?t.children:[],a=n.indexStack[n.indexStack.length-1];return n.safe(e.value,{...r,afterNode:i[a+1],beforeNode:i[a-1]})}function EK(e){let t=e.options.ruleRepetition||3;if(t<3)throw Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function DK(e,t,n){let r=(hK(n)+(n.options.ruleSpaces?` `:``)).repeat(EK(n));return n.options.ruleSpaces?r.slice(0,-1):r}var OK={blockquote:_G,break:xG,code:TG,definition:OG,emphasis:JG,hardBreak:xG,heading:QG,html:$G,image:tK,imageReference:rK,inlineCode:aK,link:cK,linkReference:uK,list:gK,listItem:vK,paragraph:yK,root:bK,strong:SK,text:TK,thematicBreak:DK};function kK(){return{enter:{table:AK,tableData:PK,tableHeader:PK,tableRow:MK},exit:{codeText:FK,table:jK,tableData:NK,tableHeader:NK,tableRow:NK}}}function AK(e){let t=e._align;this.enter({type:`table`,align:t.map(function(e){return e===`none`?null:e}),children:[],position:void 0},e),this.data.inTable=!0}function jK(e){this.exit(e),this.data.inTable=void 0}function MK(e){this.enter({type:`tableRow`,children:[],position:void 0},e)}function NK(e){this.exit(e)}function PK(e){this.enter({type:`tableCell`,children:[],position:void 0},e)}function FK(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,IK));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function IK(e,t){return t===`|`?t:e}function LK(e){let{tableCellPadding:t,tablePipeAlign:n,stringLength:r}=e||{},i=t?` `:`|`;return{handlers:{inlineCode:d,table:a,tableCell:s,tableRow:o},join:[RK],unsafe:[{character:`\r`,inConstruct:`tableCell`},{character:`
|
|
280
280
|
`,inConstruct:`tableCell`},{atBreak:!0,character:`|`,after:`[ :-]`},{character:`|`,inConstruct:`tableCell`},{atBreak:!0,character:`:`,after:`-`},{atBreak:!0,character:`-`,after:`[:|-]`}]};function a(e,t,n,r){let i=l(e,n,r),a=i[0];if(a){let t=e.align?e.align.length:0,n=-1;if(!t)for(;++n<i.length;)i[n].length>t&&(t=i[n].length);for(;a.length<t;)a.push(``)}return c(i,e.align)}function o(e,t,n,r){let i=c([u(e,n,r)]);return i.slice(0,i.indexOf(`
|
|
281
|
-
`))}function s(e,t,n,r){let a=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:i,after:i});return o(),a(),s}function c(e,i){return pG(e,{align:i,alignDelimiters:n,fillRows:!1,padding:t,stringLength:r})}function l(e,t,n){let{children:r}=e,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=u(r[i],t,n);return o(),a}function u(e,t,n){let{children:r}=e,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=s(r[i],e,t,n);return o(),a}function d(e,t,n){let r=OK.inlineCode(e,t,n);if(!n.stack.includes(`tableCell`))return r;let i=[],a=0,o=r.indexOf(`|`);for(;o!==-1;){let e=o;for(;e>a&&r.charCodeAt(e-1)===92;)e--;i.push(r.slice(a,o)),(o-e)%2==0&&i.push(`\\`),a=o,o=r.indexOf(`|`,o+1)}return i.push(r.slice(a)),i.join(``)}}function RK(e,t,n,r){if(e.type===`table`&&n.type===`listItem`&&n.spread===!1&&(t.type===`definition`||t.type===`heading`&&zK(t,r)||t.type===`paragraph`||t.type===`table`))return 1}function zK(e,t){let n=!1;return hU(e,function(e){if(e.type===`break`||`value`in e&&/\r?\n|\r/.test(e.value))return n=!0,!1}),!!((!e.depth||e.depth<3)&&oz(e)&&(t.options.setext||n))}function BK(){return{exit:{taskListCheckValueChecked:HK,taskListCheckValueUnchecked:HK,paragraph:UK}}}function VK(){return{handlers:{paragraph:WK},join:[GK]}}function HK(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function UK(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start={...n.position.start}))}}this.exit(e)}function WK(e,t,n,r){if(!t||t.type!==`listItem`||KK(t)!==e)return OK.paragraph(e,t,n,r);let i=`[`+(t.checked?`x`:` `)+`] `,a=n.createTracker(r);return a.move(i),i+OK.paragraph(e.children.length>0?e:{type:`paragraph`,children:[{type:`text`,value:` `}]},t,n,{...r,...a.current()})}function GK(e,t,n){if(e.type!==`definition`||n.type!==`listItem`)return;let r=KK(n);if(r&&n.children.indexOf(e)<n.children.indexOf(r))return 0}function KK(e){if(typeof e.checked==`boolean`)for(let t of e.children){if(t.type===`paragraph`)return t;if(t.type!==`definition`)return}}function qK(){return[OW(),eG(),aG(),kK(),BK()]}function JK(e){return{extensions:[kW(),tG(e),oG(),LK(e),VK()]}}var YK={tokenize:lq,partial:!0},XK={tokenize:uq,partial:!0},ZK={tokenize:dq,partial:!0},QK={tokenize:fq,partial:!0},$K={tokenize:pq,partial:!0},eq={name:`wwwAutolink`,tokenize:sq,previous:mq},tq={name:`protocolAutolink`,tokenize:cq,previous:hq},nq={name:`emailAutolink`,tokenize:oq,previous:gq},rq={};function iq(){return{text:rq}}for(var aq=48;aq<123;)rq[aq]=nq,aq++,aq===58?aq=65:aq===91&&(aq=97);rq[43]=nq,rq[45]=nq,rq[46]=nq,rq[95]=nq,rq[72]=[nq,tq],rq[104]=[nq,tq],rq[87]=[nq,eq],rq[119]=[nq,eq];function oq(e,t,n){let r=this,i,a;return o;function o(t){return!_q(t)||!gq.call(r,r.previous)||vq(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return _q(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check($K,u,l)(t):t===45||t===95||xz(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&bz(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function sq(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!mq.call(r,r.previous)||vq(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(YK,e.attempt(XK,e.attempt(ZK,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function cq(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&hq.call(r,r.previous)&&!vq(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(bz(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||Cz(t)||Oz(t)||jz(t)||Az(t)?n(t):e.attempt(XK,e.attempt(ZK,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function lq(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function uq(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(QK,c,s)(t):t===null||Oz(t)||jz(t)||t!==45&&Az(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function dq(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(QK,t,a)(o):o===null||Oz(o)||jz(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function fq(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||Oz(o)||jz(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||Oz(e)||jz(e)?t(e):r(e)}function a(e){return bz(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):bz(t)?(e.consume(t),o):n(t)}}function pq(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return xz(e)?n(e):t(e)}}function mq(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Oz(e)}function hq(e){return!bz(e)}function gq(e){return!(e===47||_q(e))}function _q(e){return e===43||e===45||e===46||e===95||xz(e)}function vq(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var yq={tokenize:Dq,partial:!0};function bq(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:wq,continuation:{tokenize:Tq},exit:Eq}},text:{91:{name:`gfmFootnoteCall`,tokenize:Cq},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:xq,resolveTo:Sq}}}}function xq(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=yz(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function Sq(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function Cq(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||Oz(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(yz(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return Oz(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function wq(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||Oz(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=yz(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return Oz(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),Pz(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function Tq(e,t,n){return e.check(Qz,t,e.attempt(yq,t,n))}function Eq(e){e.exit(`gfmFootnoteDefinition`)}function Dq(e,t,n){let r=this;return Pz(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function Oq(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&fz(o,o.length,0,Gz(s,e.slice(r+1,n),t)),fz(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),fz(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=Wz(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=Wz(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var kq=class{constructor(){this.map=[],this.index=new Map}add(e,t,n){Aq(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0,this.index.clear()}};function Aq(e,t,n,r){if(n===0&&r.length===0)return;let i=e.index.get(t);if(i){i[1]+=n,i[2].push(...r);return}let a=[t,n,r];e.map.push(a),e.index.set(t,a)}function jq(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function Mq(){return{flow:{null:{name:`table`,tokenize:Nq,resolveAll:Pq}}}}function Nq(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let{type:e}=r.events[t][1];if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124||(o=!0,a+=1),u(e)}function u(t){return t===null?n(t):Dz(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):kz(t)?Pz(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||Oz(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,kz(t)?Pz(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return kz(t)?Pz(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||Dz(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return kz(t)?Pz(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||Dz(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||Dz(n)?(e.exit(`tableRow`),t(n)):kz(n)?Pz(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||Oz(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function Pq(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new kq;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(Iq(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=Fq(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=Fq(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=Fq(f,t,o,i,n,d)):(o[0]=o[1],d=Fq(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&Iq(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=jq(t.events,n))}return e}function Fq(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},Lq(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=Lq(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=Lq(t.events,n[2]),a=Lq(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},Lq(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function Iq(e,t,n,r,i){let a=[],o=Lq(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function Lq(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var Rq={name:`tasklistCheck`,tokenize:Bq};function zq(){return{text:{91:Rq}}}function Bq(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return Oz(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return Dz(r)?t(r):kz(r)?e.check({tokenize:Vq},t,n)(r):n(r)}}function Vq(e,t,n){return Pz(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function Hq(e){return hz([iq(),bq(),Oq(e),Mq(),zq()])}var Uq={};function Wq(e){let t=this,n=e||Uq,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(Hq(n)),a.push(qK()),o.push(JK(n))}var Gq=`diffs-container`,Kq=/(?=^diff --git)/gm,qq=/(?<=\n)/,Jq=/^(---|\+\+\+)\s+([^\t\r\n]+)/,Yq=/^index ([0-9a-f]+)\.\.([0-9a-f]+)(?: (\d+))?$/i,Xq=`header-prefix`,Zq=`header-filename-suffix`,Qq=`header-metadata`,$q=`header-custom`,eJ={dark:`pierre-dark`,light:`pierre-light`},tJ=`data-theme-css`,nJ=`data-unsafe-css`,rJ=`data-diffs-scrollbar-measure`,iJ=`--diffs-scrollbar-gutter-measured`,aJ=1e5,oJ={unmodifiedLines:`{count, plural, one {# unmodified line} other {# unmodified lines}}`,unknownUnmodifiedLines:`More unchanged context may be available`,expandAll:`Expand all`,expandLine:`Show full line`,noNewlineAtEndOfFile:`No newline at end of file`,acceptCurrentChange:`Accept current change`,acceptIncomingChange:`Accept incoming change`,acceptBoth:`Accept both`,searchPlaceholder:`Search`,replacePlaceholder:`Replace`,noSearchResults:`0/0`,searching:`Searching…`,searchResultCount:`{count, plural, one {# result} other {# results}}`,searchResultPosition:`{index}/{count}`,matchCase:`Match Case`,wholeWord:`Whole Word`,regularExpression:`Regexp`,replaceMatch:`Replace`,replaceAllMatches:`Replace All`,previousMatch:`Previous`,nextMatch:`Next`,closeSearch:`Close`,toggleReplace:`Toggle Replace`},sJ={hunkLineCount:50,lineHeight:20,diffHeaderHeight:44,spacing:8};({...sJ});var cJ=Object.freeze({fromStart:0,fromEnd:0}),lJ={startingLine:0,totalLines:1/0,bufferBefore:0,bufferAfter:0},uJ=Object.freeze([]),dJ,fJ=0,pJ=class extends Error{constructor(){super(`Highlighter is disposed`),this.name=`HighlighterDisposedError`}};function mJ(){return dJ}function hJ(e){return e??dJ??`shiki-js`}function gJ(e){if(dJ!=null&&dJ!==e)throw Error(`Cannot load the "${e}" highlighter while "${dJ}" is in use. Only one highlighter type can be active at a time; dispose every "${dJ}" instance (disposeHighlighter() disposes the shared one) before switching.`)}function _J(e){gJ(e),dJ=e,fJ++}function vJ(){fJ--,fJ===0&&(dJ=void 0)}function yJ(e=eJ){let t=[];return typeof e==`string`?t.push(e):(t.push(e.dark),t.push(e.light)),t}function bJ(){return typeof WorkerGlobalScope<`u`&&typeof self<`u`&&self instanceof WorkerGlobalScope}function xJ(e){let t;return()=>t??=e().then(e=>(t=e,e),e=>{throw t=void 0,e})}function SJ(e){return typeof e==`object`&&e&&`default`in e?e.default:e}var CJ=class extends Error{constructor(e){super(`Theme "${e}" is already registered`),this.name=`DuplicateThemeError`}},wJ=class extends Error{constructor(e){super(`No loader registered for theme "${e}"`),this.name=`UnregisteredThemeError`}},TJ=class extends Error{constructor(e){super(`Theme "${e}" has not been resolved`),this.name=`UnresolvedThemeError`}};function EJ(e={}){let t=new Map,n=new Map,r=new Map,i=0;function a(e,n){if(t.has(e))throw new CJ(e);t.set(e,n)}function o(e,n){return!t.has(e)&&(t.set(e,n),!0)}function s(e){return t.has(e)}function c(a){let o=n.get(a);if(o!==void 0)return Promise.resolve(o);let s=r.get(a);if(s!==void 0)return s;let c=t.get(a);if(c===void 0&&e.fallbackLoader===void 0)return Promise.reject(new wJ(a));let l=i,u=Promise.resolve().then(()=>c===void 0?e.fallbackLoader?.(a):c()).then(async t=>{if(t===void 0)throw new wJ(a);let o=SJ(t),s=e.normalizeTheme===void 0?o:await e.normalizeTheme(o,a);return l===i&&n.set(a,s),r.get(a)===u&&r.delete(a),s}).catch(e=>{throw r.get(a)===u&&r.delete(a),e});return r.set(a,u),u}function l(e){return Promise.all(e.map(e=>c(e)))}function u(e,t){n.set(e,t)}function d(e){for(let[t,n]of e)u(t,n)}function f(e){return n.get(e)}function p(e){let t=[];for(let r of e){let e=n.get(r);if(e===void 0)throw new TJ(r);t.push(e)}return t}function m(e){return n.has(e)}function h(e){for(let t of e)if(!n.has(t))return!1;return!0}function g(e){let t=n.get(e);return t===void 0?c(e):t}function _(){i++,n.clear(),r.clear()}return{clearResolvedThemes:_,getResolvedOrResolveTheme:g,getResolvedTheme:f,getResolvedThemes:p,hasRegisteredTheme:s,hasResolvedTheme:m,hasResolvedThemes:h,registerTheme:a,registerThemeIfAbsent:o,resolveTheme:c,resolveThemes:l,seedResolvedTheme:u,seedResolvedThemes:d}}var DJ=`modulepreload`,OJ=function(e){return`/`+e},kJ={},AJ={},jJ=function(e){return e.pathname.endsWith(`.css`)},MJ=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw delete e[t],n});return e[t]=i,i},NJ=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=function(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))},i=function(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)},a,o=document.querySelector(`meta[property=csp-nonce]`),s=o?.nonce||o?.getAttribute(`nonce`);r=e(t.map(e=>{e=OJ(e,n);let t=i(e),r=jJ(t);return MJ(kJ,t.href,()=>{if(a===void 0){a={all:new Set,styles:new Set};let e=document.getElementsByTagName(`link`);for(let t=e.length-1;t>=0;t--){let n=e[t];a.all.add(n.href),n.rel===`stylesheet`&&a.styles.add(n.href)}}let e=r?a.styles:a.all,n=r?AJ[t.href]:void 0;if(!n&&e.has(t.href))return;let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:DJ,r||(i.as=`script`),i.crossOrigin=``,i.href=t.href,s&&i.setAttribute(`nonce`,s),n&&delete AJ[t.href],n?.isConnected?n.replaceWith(i):document.head.appendChild(i),r)return new Promise((e,n)=>{let r=a=>{i.removeEventListener(`load`,r),i.removeEventListener(`error`,r),a.type===`error`?(AJ[t.href]=i,n(Error(`Unable to preload CSS for ${t}`))):e(a)};i.addEventListener(`load`,r),i.addEventListener(`error`,r)})})}).filter(e=>e!==void 0))}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)})},PJ=new Map,FJ=new Map,IJ=xJ(()=>NJ(()=>import(`./loader-DUZOP7q_.js`),[])),LJ=xJ(()=>NJ(()=>import(`./themes-D3CUotbU.js`),[])),RJ=xJ(()=>NJ(()=>import(`./core-pm_tYnN8.js`).then(e=>e.t),__vite__mapDeps([0,1]))),zJ=[[`editor.lineHighlightBackground`,`editor.active_line.background`],[`editor.selectionBackground`,`element.selected`],[`editor.findMatchHighlightBackground`,`search.match_background`],[`editorBracketMatch.background`,`editor.document_highlight.bracket_background`],[`editorError.foreground`,`error`],[`editorWarning.foreground`,`warning`],[`editorInfo.foreground`,`info`],[`editorHint.foreground`,`hint`],[`gitDecoration.addedResourceForeground`,`created`,`terminal.ansi.green`],[`gitDecoration.deletedResourceForeground`,`deleted`,`terminal.ansi.red`],[`gitDecoration.modifiedResourceForeground`,`modified`,`terminal.ansi.blue`]];function BJ(e,t){let n=`themes`in t?t.themes[0]:t;if(n==null)throw Error(`Theme "${e}" is an empty Zed theme family.`);let r={...n,name:e},i={};for(let[e,t]of Object.entries(r.style))typeof t==`string`&&(i[e]=t);let a=r.style.players?.[0];a?.cursor!=null&&(i[`editorCursor.foreground`]??=a.cursor),a?.selection!=null&&(i[`editor.selectionBackground`]??=a.selection);for(let[e,...t]of zJ){if(i[e]!=null)continue;let n=t.find(e=>i[e]!=null);n!=null&&(i[e]=i[n])}if(r.cssVariables===!0)i[`editor.foreground`]=`var(--hls-foreground)`,i[`editor.background`]=`var(--hls-background)`;else if(typeof r.cssVariables==`object`){i[`editor.foreground`]??=i.text??i.foreground??`foreground`,i[`editor.background`]??=i.background??`background`;let{prefix:e=`--hls-`,defaults:t}=r.cssVariables;for(let[n,r]of Object.entries(i)){let a=t?.[r];i[n]=`var(${e}${r}${a?`, ${a}`:``})`}}let o=r.appearance===`light`?`light`:`dark`;return{name:e,type:o,colors:i,zed:r,fg:i[`editor.foreground`]??i.text??i.foreground??(o===`light`?`#333333`:`#bbbbbb`),bg:i[`editor.background`]??i.background??(o===`light`?`#ffffff`:`#1e1e1e`)}}function VJ(e){let t=FJ.get(e);return t??(t=EJ({fallbackLoader:async t=>{if(typeof __DIFFS_WORKER__<`u`?__DIFFS_WORKER__:bJ())throw Error(`Theme "${t}" cannot be resolved from a worker context. Themes must be pre-resolved on the main thread and passed to the worker via the resolvedThemes parameter.`);let n=PJ.get(t);if(e===`highlights`){let e=n?.zed??n?.diffs;if(e!=null){let n=await e(),r=`default`in n?n.default:n;if(`zed`in r&&r.zed!=null)return r;if(`style`in r||`themes`in r)return BJ(t,r);throw Error(`Theme "${t}" is a TextMate theme; register a Zed theme with registerCustomTheme(name, loader, 'zed') for Highlights.`)}let r=IJ(),{themes:i}=r instanceof Promise?await r:r,a=i[t];if(a!=null)return BJ(t,(await a()).default);if(n?.textmate!=null)throw Error(`Theme "${t}" is only registered for TextMate; use registerCustomTheme(name, loader, 'zed') for Highlights.`)}else{let e=n?.textmate??n?.diffs,r;if(e!=null){let t=await e();r=`default`in t?t.default:t}else{let e=LJ(),{themes:i}=e instanceof Promise?await e:e,a=i.getTheme(t);if(a==null&&n?.zed!=null)throw Error(`Theme "${t}" is only registered for Zed; use registerCustomTheme(name, loader, 'textmate') for Shiki.`);if(a==null)throw Error(`No valid theme loader registered for "${t}"`);let o=await a.load();r=`default`in o?o.default:o}if(`style`in r||`themes`in r)throw Error(`Theme "${t}" is a Zed theme; use preferredHighlighter: 'highlights' or register a TextMate theme for Shiki.`);let i=RJ(),{normalizeTheme:a,createCssVariablesTheme:o}=i instanceof Promise?await i:i;if(`cssVariables`in r&&r.cssVariables!=null)return{...r,textmate:a(o(r.cssVariables))};if(`textmate`in r&&r.textmate!=null)return{...r,textmate:a(r.textmate)};let s=a(r);return{name:s.name,type:s.type,fg:s.fg,bg:s.bg,colors:s.colors,textmate:s}}throw Error(`No valid theme loader registered for "${t}"`)},normalizeTheme:(e,t)=>{if(e.name!==t)throw Error(`resolvedTheme: themeName: ${t} does not match theme.name: ${e.name}`);return e}}),FJ.set(e,t)),t}function HJ(e,t=hJ()){return typeof t!=`string`&&t.isDisposed?!1:(typeof t==`string`?VJ(t):t.themeResolver).hasResolvedThemes(yJ(e))}var UJ;async function WJ(e){let t=hJ(e);_J(t);try{if(t===`highlights`){let{HighlightsHighlighter:e}=await NJ(async()=>{let{HighlightsHighlighter:e}=await import(`./highlights-dvwIMyOh.js`);return{HighlightsHighlighter:e}},__vite__mapDeps([2,3,1,4,5]));return new e}let{ShikiHighlighter:e}=await NJ(async()=>{let{ShikiHighlighter:e}=await import(`./shiki-BghTRNDM.js`);return{ShikiHighlighter:e}},__vite__mapDeps([6,3,1,4,7,0]));return await e.create(t)}finally{vJ()}}async function GJ({themes:e,langs:t,preferredHighlighter:n}){KJ();let r=UJ??=WJ(mJ()??n),i;try{i=await r}catch(e){throw UJ===r&&(UJ=void 0),e}if(UJ===r&&(UJ=i),await Promise.all([i.themeResolver.resolveThemes(e),i.loadLanguages(t)]),i.isDisposed)throw new pJ;return i}function KJ(){UJ!=null&&!(`then`in UJ)&&UJ.isDisposed&&(UJ=void 0)}function qJ({theme:e,lang:t,langs:n}={}){KJ();let r=UJ;if(!(r==null||`then`in r||e!=null&&!HJ(e,r)||(t!=null||n!=null)&&!r.hasLoadedLanguages([...t==null?[]:[t],...n??[]])))return r}function JJ(e,t=hJ()){return VJ(t).getResolvedOrResolveTheme(e)}function YJ(e,t,n=`textmate`){let r=PJ.get(e)??{};r[n]==null?(r[n]=t,PJ.set(e,r)):console.error(`SharedHighlight.registerCustomTheme: theme name and type already registered`,e,n)}var XJ=`highlights`,ZJ=`forge-light`,QJ={light:ZJ,dark:`pierre-dark`};function $J(e){return e?QJ.dark:QJ.light}var eY=4.5;function tY(e){let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4}function nY(e){let t=/^#([0-9a-f]{6})([0-9a-f]{2})?$/i.exec(e);if(!t)return e;let n=[0,2,4].map(e=>parseInt(t[1].slice(e,e+2),16)),r=()=>{let[e,t,r]=n.map(tY);return .74/(.2126*e+.7152*t+.0722*r+.05)};if(r()>=eY)return e;for(;r()<eY;)n=n.map(e=>Math.floor(e*.95));return`#`+n.map(e=>e.toString(16).padStart(2,`0`)).join(``)+(t[2]||``)}function rY(e){let t={};for(let[n,r]of Object.entries(e.style.syntax??{}))t[n]=typeof r==`string`?nY(r):r&&typeof r==`object`&&`color`in r&&typeof r.color==`string`?{...r,color:nY(r.color)}:r;return{...e,name:ZJ,style:{...e.style,syntax:t}}}YJ(ZJ,async()=>{let e=await JJ(`pierre-light`,XJ);if(!e.zed)throw Error(`pierre-light has no palette for the highlights engine`);return rY(e.zed)},`zed`);var iY=new Map;function aY(e){let t=iY.get(e);if(t)return t;let n=GJ({themes:Object.values(QJ),langs:[e],preferredHighlighter:XJ}).catch(t=>{if(e===`text`)throw iY.delete(e),t;return aY(`text`)});return iY.set(e,n),n}var oY=b.memo(function({text:e}){return(0,x.jsx)(`div`,{className:`prose-forge`,children:(0,x.jsx)(hW,{remarkPlugins:[Wq],components:{a:({node:e,...t})=>(0,x.jsx)(`a`,{...t,target:`_blank`,rel:`noreferrer noopener`}),pre:({node:e,children:t})=>(0,x.jsx)(lY,{children:t})},children:e})})});function sY(e){let t=b.Children.toArray(e)[0];return/language-([\w+-]+)/.exec(t?.props?.className||``)?.[1]||``}function cY(e){let t=b.Children.toArray(e)[0]?.props?.children;return(Array.isArray(t)?t.join(``):String(t??``)).replace(/\n$/,``)}function lY({children:e}){let t=sY(e)||`text`,[n,r]=b.useState(!0),[i,a]=b.useState(!1);return(0,x.jsxs)(`div`,{dir:`ltr`,className:`code-block my-[0.65rem] overflow-hidden rounded-lg border border-border/70 bg-secondary leading-snug dark:border-transparent dark:bg-input/32`,"data-language":t,"data-wrap":n?`true`:`false`,children:[(0,x.jsxs)(`div`,{className:`code-block-header flex items-center justify-between gap-2 pt-1.5 pr-1.5 pb-0 pl-3 select-none`,children:[(0,x.jsx)(`span`,{className:`truncate font-mono text-2xs`,children:t}),(0,x.jsxs)(`span`,{className:`flex items-center gap-0.5`,role:`toolbar`,"aria-label":`Code block actions`,children:[(0,x.jsx)(Tb,{label:n?`Don’t wrap lines`:`Wrap lines`,children:(0,x.jsx)(q,{type:`button`,variant:n?`secondary`:`ghost-muted`,size:`icon-xs`,"aria-pressed":n,"aria-label":n?`Don’t wrap lines`:`Wrap lines`,onClick:()=>r(!n),children:(0,x.jsx)(Nm,{className:`size-3`})})}),(0,x.jsx)(Tb,{label:i?`Copied`:`Copy`,children:(0,x.jsx)(q,{type:`button`,variant:`ghost-muted`,size:`icon-xs`,"aria-label":`Copy`,onClick:()=>{navigator.clipboard.writeText(cY(e)).then(()=>{a(!0),setTimeout(()=>a(!1),1200)})},children:i?(0,x.jsx)(Md,{className:`size-3`}):(0,x.jsx)(ef,{className:`size-3`})})})]})]}),(0,x.jsx)(fY,{code:cY(e),language:t,fallback:(0,x.jsx)(`pre`,{children:e})})]})}var uY=new Map,dY=200;function fY({code:e,language:t,fallback:n}){let r=$J(Ju()),i=/^(text|txt|plain|plaintext)$/i.test(t),a=`${r}\u0000${t}\u0000${e}`,[o,s]=b.useState(()=>uY.get(a)??null);return b.useEffect(()=>{if(i)return;let n=uY.get(a);if(n)return s(n);let o=!0;return aY(t).then(n=>{let i;try{i=n.codeToHtml(e,{lang:t,theme:r})}catch{i=n.codeToHtml(e,{lang:`text`,theme:r})}uY.size>=dY&&uY.delete(uY.keys().next().value),uY.set(a,i),o&&s(i)}).catch(()=>{}),()=>{o=!1}},[a,i,e,t,r]),i||!o?(0,x.jsx)(x.Fragment,{children:n}):(0,x.jsx)(`div`,{className:`code-block-highlighted`,dangerouslySetInnerHTML:{__html:o}})}var pY=e=>e.type.replace(/^tool-/,``),mY=e=>e.state===`output-error`||!!e.output?.error||pY(e)===`shell`&&typeof e.output?.exitCode==`number`&&e.output.exitCode!==0;function hY(e,t){let n=-1;e.forEach((e,t)=>{e.kind===`text`&&(n=t)});let r=e.some(e=>e.kind===`tool`&&(e.part.state===`approval-requested`||pY(e.part)===`ask`&&e.part.state===`input-available`));if(t.streaming||r||!t.finished||n<0)return null;let i=new Set;return e.forEach((e,t)=>{t===n||e.kind===`tool`&&pY(e.part)===`ask`||t>n&&e.kind===`tool`&&mY(e.part)||t>n&&e.kind===`group`&&e.parts.some(mY)||i.add(t)}),i.size?i:null}var gY=2e3;function _Y({text:e,label:t=`Copy message`}){let[n,r]=b.useState(`idle`);return b.useEffect(()=>{if(n===`idle`)return;let e=setTimeout(()=>r(`idle`),gY);return()=>clearTimeout(e)},[n]),(0,x.jsx)(Tb,{label:n===`failed`?`Couldn’t copy to the clipboard`:t,children:(0,x.jsx)(q,{"aria-label":t,size:`xs`,variant:`ghost-muted`,disabled:n===`copied`,className:`disabled:opacity-100`,onClick:()=>navigator.clipboard.writeText(e).then(()=>r(`copied`),()=>r(`failed`)),children:n===`copied`?(0,x.jsx)(Md,{className:`size-3 text-primary`}):(0,x.jsx)(ef,{className:`size-3`})})})}function vY({at:e}){return e?(0,x.jsx)(Tb,{label:Tu(e),children:(0,x.jsx)(`p`,{tabIndex:0,className:`rounded-sm text-xs text-muted-foreground tabular-nums outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:Cu(e)})}):null}var yY=e=>G(`transition-opacity duration-200 pointer-coarse:opacity-100 focus-within:opacity-100`,e===`group`?`opacity-0 group-hover:opacity-100`:`opacity-0 group-hover/assistant:opacity-100`);function bY({at:e,text:t,onRevert:n,busy:r}){return(0,x.jsx)(`div`,{className:G(`flex w-full max-w-[80%] items-center justify-end pe-1 text-xs tabular-nums`,yY(`group`)),children:(0,x.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-x-2`,children:[(0,x.jsx)(vY,{at:e}),(0,x.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[n&&(0,x.jsx)(Tb,{label:`Edit from here`,children:(0,x.jsx)(q,{"aria-label":`Edit from here`,size:`xs`,variant:`ghost`,disabled:r,onClick:n,children:(0,x.jsx)(Lp,{className:`size-3`})})}),t&&(0,x.jsx)(_Y,{text:t})]})]})})}function xY({at:e,text:t,status:n,alwaysVisible:r,className:i}){return(0,x.jsxs)(`div`,{className:G(`flex items-center gap-2 text-xs tabular-nums`,r?`opacity-100`:yY(`assistant`),i),children:[n&&(0,x.jsx)(`span`,{className:`rounded-full border border-border/70 px-1.5 py-0.5 font-mono text-3xs text-muted-foreground`,children:n}),t.trim()&&(0,x.jsx)(_Y,{text:t}),(0,x.jsx)(vY,{at:e})]})}function SY(e){let t=e.parts.filter(e=>e.type===`text`&&typeof e.text==`string`).map(e=>e.text);return t.length?t.join(`
|
|
282
|
-
`):null}function CY(e){let t=[];return e.forEach((n,r)=>{if(n.role!==`user`)return;let i=null;for(let t=r+1;t<e.length&&e[t].role!==`user`;t++){let n=SY(e[t]);e[t].role===`assistant`&&n!==null&&(i=n)}t.push({id:n.id,rowIndex:r,userText:SY(n)??``,assistantText:i})}),t}var wY=new Set([`paragraph`,`heading`,`tableCell`,`emphasis`,`strong`,`delete`,`link`,`linkReference`]);function TY(e){switch(e.type){case`text`:case`inlineCode`:case`code`:return e.value;case`break`:return` `;case`image`:case`imageReference`:return String(e.alt||``);case`footnoteReference`:case`footnoteDefinition`:case`definition`:case`html`:return``}return Array.isArray(e.children)?e.children.map(TY).join(wY.has(e.type)?``:` `):``}function EY(e){return TY(tH(e,{extensions:[Hq()],mdastExtensions:[qK()]})).replace(/\s+/g,` `).trim()}function DY(e,t){if(t<=0||t>=e.length)return!1;let n=e.charCodeAt(t-1),r=e.charCodeAt(t);return n>=55296&&n<=56319&&r>=56320&&r<=57343}function OY(e){if(e===null)return null;let t=EY(e.slice(0,DY(e,1500)?1499:1500));return t.length?t:null}function kY(e){return e&&{...e,userText:OY(e.userText),assistantText:OY(e.assistantText)}}var AY=8,jY=5,MY=48,NY=32,PY=40,FY=14;function IY(e){return`min(${Math.max(1,(e-1)*AY)}px, max(4rem, calc(100% - 14.75rem)))`}function LY(e,t){return t<=1?0:Math.max(0,Math.min(e,t-1))/(t-1)*100}function RY(e,t){return t<=0?e:Math.min(e,Math.max(2,Math.floor(t/jY)+1))}function zY(e,t,n){return n>=t?e:Math.round(e/(t-1)*(n-1))}function BY(e){if(e.count<=0||e.railHeight<=0)return null;if(e.count===1)return 0;let t=Math.max(0,Math.min(1,(e.y-e.railTop)/e.railHeight));return Math.max(0,Math.min(e.count-1,Math.round(t*(e.count-1))))}function VY(e,t,n,r){return n!==null&&r!==null&&e<=r&&(t===void 0||t>n)}function HY(e){if(e.visibleStart===null||e.visibleEnd===null)return null;let t=null;for(let[n,r]of e.rowIndices.entries()){if(r>=e.visibleStart)return r<=e.visibleEnd?n:t;t=n}return t}function UY(e){return e>=MY}function WY(e){let t=Number.isFinite(e)?Math.max(0,Math.floor(e)):0;return t<46?{left:0,width:Math.min(8,t)}:{left:NY,width:Math.min(PY,t-NY)}}function GY(e){return e>=FY}var KY=150,qY=[1,3],JY=new WeakMap;function YY(e){let t=JY.get(e);if(t)return cancelAnimationFrame(t.frame),t.stop.abort(),JY.delete(e),t}function XY(e,t){let n=YY(e),r=e.scrollTop,i=n?n.to+r-n.written:r,a={from:r,to:Math.max(0,Math.min(e.scrollHeight-e.clientHeight,i+t)),start:performance.now(),written:r,frame:0,stop:new AbortController};for(let t of[`pointerdown`,`keydown`])window.addEventListener(t,()=>YY(e),{capture:!0,signal:a.stop.signal});let o=t=>{if(!e.isConnected)return void YY(e);let n=e.scrollTop-a.written;a.from+=n,a.to+=n;let r=Math.min(1,Math.max(0,(t-a.start)/KY));e.scrollTop=a.from+(a.to-a.from)*(1-(1-r)**3),a.written=e.scrollTop,r<1?a.frame=requestAnimationFrame(o):YY(e)};a.frame=requestAnimationFrame(o),JY.set(e,a)}function ZY(e,t){if(e.defaultPrevented||e.ctrlKey||e.deltaY===0)return;e.preventDefault();let n=e.deltaMode===WheelEvent.DOM_DELTA_LINE?16:e.deltaMode===WheelEvent.DOM_DELTA_PAGE?t.clientHeight:1,r=e.deltaY*n,i=e.wheelDeltaY;e.deltaMode===WheelEvent.DOM_DELTA_PIXEL&&(i===void 0||qY.some(t=>Math.abs(i+t*e.deltaY)<1))||window.matchMedia(`(prefers-reduced-motion: reduce)`).matches?(YY(t),t.scrollBy({top:r})):XY(t,r)}function QY(e){let t=n=>{n.buttons===0&&(window.removeEventListener(`mouseup`,t),window.removeEventListener(`mousemove`,t),e())};window.addEventListener(`mouseup`,t),window.addEventListener(`mousemove`,t)}function $Y({items:e,persistent:t,hitStrip:n,currentIndex:r,atEnd:i,stripMap:a,onWheel:o,onSelect:s}){let[c,l]=b.useState(null),[u,d]=b.useState(0),[f,p]=b.useState(!1),m=b.useRef(!1),h=b.useRef(null),g=b.useRef(null),_=b.useRef(o);if(_.current=o,b.useEffect(()=>{let e=h.current;if(!e)return;let t=e=>_.current(e);return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[e.length>=2]),b.useEffect(()=>{let e=g.current;if(!e)return;d(e.getBoundingClientRect().height);let t=new ResizeObserver(([e])=>e&&d(e.contentRect.height));return t.observe(e),()=>t.disconnect()},[e.length>=2]),e.length<2)return null;let v=c!==null&&c<e.length?c:null,y=kY(v===null?null:e[v]||null),S=r!==null&&r>=0&&r<e.length?r:null,C=S===null?null:e[S-1]||null,w=S===null||i?null:e[S+1]||null,T=GY(n.width)&&!f,E=RY(e.length,u),D=Array.from({length:E},()=>[]);e.forEach((t,n)=>D[zY(n,e.length,E)]?.push(t));let O=v===null?null:zY(v,e.length,E),k=t=>{let n=t.currentTarget.getBoundingClientRect();return BY({count:e.length,railTop:n.top,railHeight:n.height,y:t.clientY})},A=t=>l(n=>Math.max(0,Math.min(e.length-1,(n??0)+t)));return(0,x.jsx)(`div`,{ref:h,"data-testid":`timeline-minimap`,className:G(`group/minimap pointer-events-none absolute top-0 bottom-0 left-0 z-40 w-18`,t?`opacity-100`:`hidden opacity-0 transition-opacity duration-150 hover:opacity-100 focus-within:opacity-100 [@media(pointer:fine)]:block`),children:(0,x.jsx)(`div`,{className:`relative h-full w-full select-none`,children:(0,x.jsxs)(`div`,{ref:g,className:G(`absolute top-1/2 -translate-y-1/2`,n.width>0&&!f?`pointer-events-auto`:`pointer-events-none`),style:{height:IY(e.length),left:n.left,width:n.width},onMouseDown:()=>{m.current||(m.current=!0,QY(()=>m.current=!1))},onMouseMove:e=>{e.buttons===0||m.current||f||(p(!0),QY(()=>p(!1)))},children:[(0,x.jsx)(eX,{direction:`previous`,disabled:!C,interactive:T,onClick:()=>C&&s(C)}),(0,x.jsxs)(`button`,{type:`button`,"aria-label":`Jump to message: ${y?.userText??`User message`}`,className:`absolute inset-y-0 left-0 w-full cursor-pointer bg-transparent before:absolute before:inset-x-0 before:-inset-y-1 before:content-[''] focus-visible:ring-2 focus-visible:ring-ring/70 focus-visible:outline-none focus-visible:ring-inset`,onBlur:()=>l(null),onFocus:()=>l(e=>e??S??0),onMouseLeave:()=>l(null),onMouseMove:e=>{(e.buttons===0||m.current)&&l(k(e))},onMouseDown:e=>e.preventDefault(),onClick:t=>{let n=k(t),r=n===null?null:e[n];r&&s(r),t.currentTarget.blur()},onKeyDown:t=>{let n={ArrowDown:()=>A(1),ArrowUp:()=>A(-1),Home:()=>l(0),End:()=>l(e.length-1),Enter:()=>v!==null&&s(e[v])," ":()=>v!==null&&s(e[v])}[t.key];n&&(t.preventDefault(),n())},children:[D.map((e,t)=>{let n=O===null?null:Math.abs(t-O);return(0,x.jsx)(`span`,{"aria-hidden":!0,"data-minimap-strip":!0,"data-in-view":`false`,ref:t=>{if(t){for(let n of e)a.set(n.id,t);return()=>{for(let n of e)a.get(n.id)===t&&a.delete(n.id)}}},style:{top:`${LY(t,E)}%`},className:G(`pointer-events-none absolute left-0 h-0.5 w-6 origin-left -translate-y-1/2 rounded-full transition-transform duration-150 after:absolute after:inset-0 after:rounded-full after:bg-foreground/55 after:opacity-0 after:transition-opacity after:duration-150 data-[in-view=true]:after:opacity-100`,n===0?`bg-muted-foreground/60`:`bg-muted-foreground/25`,n===0?`scale-x-100`:n===1?`scale-x-[0.667]`:n===2?`scale-x-[0.417]`:`scale-x-[0.333]`)},e[0]?.id??t)}),y&&(0,x.jsx)(`span`,{className:`pointer-events-none absolute left-8 w-80 -translate-y-1/2`,style:{top:`${LY(v,e.length)}%`},children:(0,x.jsxs)(`span`,{className:`glass block rounded-xl p-3 text-left text-popover-foreground shadow-xl shadow-black/25`,children:[(0,x.jsx)(`span`,{className:`block max-w-full truncate text-sm leading-5 font-medium`,children:y.userText??`User message`}),y.assistantText&&(0,x.jsx)(`span`,{className:`mt-1 line-clamp-3 max-h-[3.75rem] overflow-hidden text-sm leading-5 text-muted-foreground`,children:y.assistantText})]})})]}),(0,x.jsx)(eX,{direction:`next`,disabled:!w,interactive:T,onClick:()=>w&&s(w)})]})})})}function eX({direction:e,disabled:t,interactive:n,onClick:r}){let i=e===`previous`,a=i?`Previous turn`:`Next turn`,o=i?Rd:Pd;return(0,x.jsx)(`span`,{className:G(`absolute left-1 z-10 inline-flex -translate-x-1/2 opacity-0 transition-opacity duration-150 focus-within:opacity-100 hover:opacity-100`,n?`pointer-events-auto`:`pointer-events-none`,i?`bottom-[calc(100%+6px)]`:`top-[calc(100%+6px)]`),children:(0,x.jsx)(Tb,{label:a,side:i?`top`:`bottom`,children:(0,x.jsx)(q,{"aria-label":a,disabled:t,onClick:r,variant:`ghost-muted`,className:`size-5 p-0`,children:(0,x.jsx)(o,{className:`size-4 text-foreground/90`})})})})}var tX=b.lazy(()=>NJ(()=>import(`./diff-view-KCzB8C4U.js`),__vite__mapDeps([8,9,3,1,5])));function nX(e){return e.state===`input-streaming`||e.state===`input-available`||e.state===`output-available`&&(e.preliminary===!0||e.output?.running===!0)}var rX=e=>e.type.replace(/^tool-/,``),iX=new Set([`read_file`,`list_dir`,`glob`,`grep`]),aX=e=>iX.has(rX(e));function oX(e){let t=e.input||{},n=e.output||{},r=nX(e),i=e=>(0,x.jsx)(`span`,{className:`font-mono text-[12.5px]`,children:String(e??``)});switch(rX(e)){case`read_file`:return{icon:hf,label:(0,x.jsxs)(x.Fragment,{children:[r?`Reading`:`Read`,` `,i(t.path)]}),meta:n.totalLines?`${n.totalLines} lines`:n.error};case`list_dir`:return{icon:xf,label:(0,x.jsxs)(x.Fragment,{children:[r?`Listing`:`Listed`,` `,i(t.path||`.`)]}),meta:n.entries?`${n.entries.length} entries`:n.error};case`glob`:return{icon:am,label:(0,x.jsxs)(x.Fragment,{children:[`Found files `,i(t.pattern)]}),meta:n.files?`${n.files.length} files`:void 0};case`grep`:return{icon:am,label:(0,x.jsxs)(x.Fragment,{children:[`Searched “`,t.pattern,`”`]}),meta:n.matches?`${n.matches.length} matches in ${n.files} files`:n.error};case`write_file`:return{icon:xm,label:(0,x.jsxs)(x.Fragment,{children:[r?`Writing`:n.created?`Created`:`Wrote`,` `,i(t.path)]}),stat:n.added===void 0?void 0:{added:n.added,removed:n.removed}};case`edit_file`:return{icon:xm,label:(0,x.jsxs)(x.Fragment,{children:[r?`Editing`:n.error?`Edit`:`Edited`,` `,i(t.path)]}),stat:n.added===void 0?void 0:{added:n.added,removed:n.removed},meta:n.error};case`rename_path`:return{icon:Fp,label:(0,x.jsxs)(x.Fragment,{children:[`Renamed `,i(t.from),` → `,i(t.to)]}),meta:n.error};case`delete_path`:return{icon:Fm,label:(0,x.jsxs)(x.Fragment,{children:[n.deleted?`Deleted`:`Delete`,` `,i(t.path)]}),stat:n.removed?{added:0,removed:n.removed}:void 0,meta:e.state===`output-denied`?`declined`:n.error};case`shell`:{let i=typeof n.durationMs==`number`?` · ${(n.durationMs/1e3).toFixed(+(n.durationMs<1e4))}s`:``;return{icon:jm,label:(0,x.jsxs)(x.Fragment,{children:[e.state===`approval-requested`?`Run`:r?`Running`:e.state===`output-denied`?`Not run:`:`Ran`,` `,(0,x.jsx)(`span`,{className:`font-mono text-[12.5px]`,children:String(t.command||``).slice(0,120)})]}),meta:e.state===`output-denied`?e.approval?.reason||`declined`:n.timedOut?`timed out`:typeof n.exitCode==`number`?`exit ${n.exitCode}${i}`:void 0}}default:return lX(e,r)}}var sX={dev_open:Ff,dev_act:xp,dev_screenshot:Ed,dev_inspect:rm,dev_eval:Qd,dev_wait_idle:Vf,dev_status:fd,search_docs:bd,read_doc:bd,lookup_api:bd,describe_table:nf,check_component:Lf,workspace_check:Lf,workspace_status:jf,workspace_diff:jf,workspace_push:zm},cX={click:`Clicked`,dblclick:`Double-clicked`,hover:`Hovered`,type:`Typed`,press:`Pressed`,scroll:`Scrolled`,select:`Selected`};function lX(e,t){let n=rX(e),r=e.input||{},i=e.output||{},a=sX[n]||(n.startsWith(`dev_`)?Ff:af),o=r.route||r.path||r.query||r.selector||r.component||r.table||r.portal||r.key||r.name||``,s={dev_open:[`Opening`,`Opened`],dev_act:[`Acting`,cX[r.action]||`Acted`],dev_screenshot:[`Taking a screenshot`,`Took a screenshot`],dev_inspect:[`Inspecting the page`,`Inspected the page`],search_docs:[`Searching the docs`,`Searched the docs`],workspace_push:[`Planning a push`,`Planned a push`]}[n],c=s?t?s[0]:s[1]:n.replace(/_/g,` `);return{icon:a,label:(0,x.jsxs)(x.Fragment,{children:[c,o&&(0,x.jsxs)(`span`,{className:`font-mono text-[12.5px]`,children:[` `,String(o).slice(0,80)]})]}),meta:i.refused?`refused`:i.error?String(i.error).split(`
|
|
281
|
+
`))}function s(e,t,n,r){let a=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:i,after:i});return o(),a(),s}function c(e,i){return pG(e,{align:i,alignDelimiters:n,fillRows:!1,padding:t,stringLength:r})}function l(e,t,n){let{children:r}=e,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=u(r[i],t,n);return o(),a}function u(e,t,n){let{children:r}=e,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=s(r[i],e,t,n);return o(),a}function d(e,t,n){let r=OK.inlineCode(e,t,n);if(!n.stack.includes(`tableCell`))return r;let i=[],a=0,o=r.indexOf(`|`);for(;o!==-1;){let e=o;for(;e>a&&r.charCodeAt(e-1)===92;)e--;i.push(r.slice(a,o)),(o-e)%2==0&&i.push(`\\`),a=o,o=r.indexOf(`|`,o+1)}return i.push(r.slice(a)),i.join(``)}}function RK(e,t,n,r){if(e.type===`table`&&n.type===`listItem`&&n.spread===!1&&(t.type===`definition`||t.type===`heading`&&zK(t,r)||t.type===`paragraph`||t.type===`table`))return 1}function zK(e,t){let n=!1;return hU(e,function(e){if(e.type===`break`||`value`in e&&/\r?\n|\r/.test(e.value))return n=!0,!1}),!!((!e.depth||e.depth<3)&&oz(e)&&(t.options.setext||n))}function BK(){return{exit:{taskListCheckValueChecked:HK,taskListCheckValueUnchecked:HK,paragraph:UK}}}function VK(){return{handlers:{paragraph:WK},join:[GK]}}function HK(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function UK(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start={...n.position.start}))}}this.exit(e)}function WK(e,t,n,r){if(!t||t.type!==`listItem`||KK(t)!==e)return OK.paragraph(e,t,n,r);let i=`[`+(t.checked?`x`:` `)+`] `,a=n.createTracker(r);return a.move(i),i+OK.paragraph(e.children.length>0?e:{type:`paragraph`,children:[{type:`text`,value:` `}]},t,n,{...r,...a.current()})}function GK(e,t,n){if(e.type!==`definition`||n.type!==`listItem`)return;let r=KK(n);if(r&&n.children.indexOf(e)<n.children.indexOf(r))return 0}function KK(e){if(typeof e.checked==`boolean`)for(let t of e.children){if(t.type===`paragraph`)return t;if(t.type!==`definition`)return}}function qK(){return[OW(),eG(),aG(),kK(),BK()]}function JK(e){return{extensions:[kW(),tG(e),oG(),LK(e),VK()]}}var YK={tokenize:lq,partial:!0},XK={tokenize:uq,partial:!0},ZK={tokenize:dq,partial:!0},QK={tokenize:fq,partial:!0},$K={tokenize:pq,partial:!0},eq={name:`wwwAutolink`,tokenize:sq,previous:mq},tq={name:`protocolAutolink`,tokenize:cq,previous:hq},nq={name:`emailAutolink`,tokenize:oq,previous:gq},rq={};function iq(){return{text:rq}}for(var aq=48;aq<123;)rq[aq]=nq,aq++,aq===58?aq=65:aq===91&&(aq=97);rq[43]=nq,rq[45]=nq,rq[46]=nq,rq[95]=nq,rq[72]=[nq,tq],rq[104]=[nq,tq],rq[87]=[nq,eq],rq[119]=[nq,eq];function oq(e,t,n){let r=this,i,a;return o;function o(t){return!_q(t)||!gq.call(r,r.previous)||vq(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return _q(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check($K,u,l)(t):t===45||t===95||xz(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&bz(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function sq(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!mq.call(r,r.previous)||vq(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(YK,e.attempt(XK,e.attempt(ZK,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function cq(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&hq.call(r,r.previous)&&!vq(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(bz(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||Cz(t)||Oz(t)||jz(t)||Az(t)?n(t):e.attempt(XK,e.attempt(ZK,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function lq(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function uq(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(QK,c,s)(t):t===null||Oz(t)||jz(t)||t!==45&&Az(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function dq(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(QK,t,a)(o):o===null||Oz(o)||jz(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function fq(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||Oz(o)||jz(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||Oz(e)||jz(e)?t(e):r(e)}function a(e){return bz(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):bz(t)?(e.consume(t),o):n(t)}}function pq(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return xz(e)?n(e):t(e)}}function mq(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Oz(e)}function hq(e){return!bz(e)}function gq(e){return!(e===47||_q(e))}function _q(e){return e===43||e===45||e===46||e===95||xz(e)}function vq(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var yq={tokenize:Dq,partial:!0};function bq(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:wq,continuation:{tokenize:Tq},exit:Eq}},text:{91:{name:`gfmFootnoteCall`,tokenize:Cq},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:xq,resolveTo:Sq}}}}function xq(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=yz(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function Sq(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function Cq(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||Oz(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(yz(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return Oz(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function wq(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||Oz(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=yz(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return Oz(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),Pz(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function Tq(e,t,n){return e.check(Qz,t,e.attempt(yq,t,n))}function Eq(e){e.exit(`gfmFootnoteDefinition`)}function Dq(e,t,n){let r=this;return Pz(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function Oq(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&fz(o,o.length,0,Gz(s,e.slice(r+1,n),t)),fz(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),fz(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=Wz(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=Wz(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var kq=class{constructor(){this.map=[],this.index=new Map}add(e,t,n){Aq(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0,this.index.clear()}};function Aq(e,t,n,r){if(n===0&&r.length===0)return;let i=e.index.get(t);if(i){i[1]+=n,i[2].push(...r);return}let a=[t,n,r];e.map.push(a),e.index.set(t,a)}function jq(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function Mq(){return{flow:{null:{name:`table`,tokenize:Nq,resolveAll:Pq}}}}function Nq(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let{type:e}=r.events[t][1];if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124||(o=!0,a+=1),u(e)}function u(t){return t===null?n(t):Dz(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):kz(t)?Pz(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||Oz(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,kz(t)?Pz(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return kz(t)?Pz(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||Dz(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return kz(t)?Pz(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||Dz(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||Dz(n)?(e.exit(`tableRow`),t(n)):kz(n)?Pz(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||Oz(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function Pq(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new kq;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(Iq(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=Fq(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=Fq(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=Fq(f,t,o,i,n,d)):(o[0]=o[1],d=Fq(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&Iq(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=jq(t.events,n))}return e}function Fq(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},Lq(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=Lq(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=Lq(t.events,n[2]),a=Lq(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},Lq(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function Iq(e,t,n,r,i){let a=[],o=Lq(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function Lq(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var Rq={name:`tasklistCheck`,tokenize:Bq};function zq(){return{text:{91:Rq}}}function Bq(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return Oz(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return Dz(r)?t(r):kz(r)?e.check({tokenize:Vq},t,n)(r):n(r)}}function Vq(e,t,n){return Pz(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function Hq(e){return hz([iq(),bq(),Oq(e),Mq(),zq()])}var Uq={};function Wq(e){let t=this,n=e||Uq,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(Hq(n)),a.push(qK()),o.push(JK(n))}var Gq=`diffs-container`,Kq=/(?=^diff --git)/gm,qq=/(?<=\n)/,Jq=/^(---|\+\+\+)\s+([^\t\r\n]+)/,Yq=/^index ([0-9a-f]+)\.\.([0-9a-f]+)(?: (\d+))?$/i,Xq=`header-prefix`,Zq=`header-filename-suffix`,Qq=`header-metadata`,$q=`header-custom`,eJ={dark:`pierre-dark`,light:`pierre-light`},tJ=`data-theme-css`,nJ=`data-unsafe-css`,rJ=`data-diffs-scrollbar-measure`,iJ=`--diffs-scrollbar-gutter-measured`,aJ=1e5,oJ={unmodifiedLines:`{count, plural, one {# unmodified line} other {# unmodified lines}}`,unknownUnmodifiedLines:`More unchanged context may be available`,expandAll:`Expand all`,expandLine:`Show full line`,noNewlineAtEndOfFile:`No newline at end of file`,acceptCurrentChange:`Accept current change`,acceptIncomingChange:`Accept incoming change`,acceptBoth:`Accept both`,searchPlaceholder:`Search`,replacePlaceholder:`Replace`,noSearchResults:`0/0`,searching:`Searching…`,searchResultCount:`{count, plural, one {# result} other {# results}}`,searchResultPosition:`{index}/{count}`,matchCase:`Match Case`,wholeWord:`Whole Word`,regularExpression:`Regexp`,replaceMatch:`Replace`,replaceAllMatches:`Replace All`,previousMatch:`Previous`,nextMatch:`Next`,closeSearch:`Close`,toggleReplace:`Toggle Replace`},sJ={hunkLineCount:50,lineHeight:20,diffHeaderHeight:44,spacing:8};({...sJ});var cJ=Object.freeze({fromStart:0,fromEnd:0}),lJ={startingLine:0,totalLines:1/0,bufferBefore:0,bufferAfter:0},uJ=Object.freeze([]),dJ,fJ=0,pJ=class extends Error{constructor(){super(`Highlighter is disposed`),this.name=`HighlighterDisposedError`}};function mJ(){return dJ}function hJ(e){return e??dJ??`shiki-js`}function gJ(e){if(dJ!=null&&dJ!==e)throw Error(`Cannot load the "${e}" highlighter while "${dJ}" is in use. Only one highlighter type can be active at a time; dispose every "${dJ}" instance (disposeHighlighter() disposes the shared one) before switching.`)}function _J(e){gJ(e),dJ=e,fJ++}function vJ(){fJ--,fJ===0&&(dJ=void 0)}function yJ(e=eJ){let t=[];return typeof e==`string`?t.push(e):(t.push(e.dark),t.push(e.light)),t}function bJ(){return typeof WorkerGlobalScope<`u`&&typeof self<`u`&&self instanceof WorkerGlobalScope}function xJ(e){let t;return()=>t??=e().then(e=>(t=e,e),e=>{throw t=void 0,e})}function SJ(e){return typeof e==`object`&&e&&`default`in e?e.default:e}var CJ=class extends Error{constructor(e){super(`Theme "${e}" is already registered`),this.name=`DuplicateThemeError`}},wJ=class extends Error{constructor(e){super(`No loader registered for theme "${e}"`),this.name=`UnregisteredThemeError`}},TJ=class extends Error{constructor(e){super(`Theme "${e}" has not been resolved`),this.name=`UnresolvedThemeError`}};function EJ(e={}){let t=new Map,n=new Map,r=new Map,i=0;function a(e,n){if(t.has(e))throw new CJ(e);t.set(e,n)}function o(e,n){return!t.has(e)&&(t.set(e,n),!0)}function s(e){return t.has(e)}function c(a){let o=n.get(a);if(o!==void 0)return Promise.resolve(o);let s=r.get(a);if(s!==void 0)return s;let c=t.get(a);if(c===void 0&&e.fallbackLoader===void 0)return Promise.reject(new wJ(a));let l=i,u=Promise.resolve().then(()=>c===void 0?e.fallbackLoader?.(a):c()).then(async t=>{if(t===void 0)throw new wJ(a);let o=SJ(t),s=e.normalizeTheme===void 0?o:await e.normalizeTheme(o,a);return l===i&&n.set(a,s),r.get(a)===u&&r.delete(a),s}).catch(e=>{throw r.get(a)===u&&r.delete(a),e});return r.set(a,u),u}function l(e){return Promise.all(e.map(e=>c(e)))}function u(e,t){n.set(e,t)}function d(e){for(let[t,n]of e)u(t,n)}function f(e){return n.get(e)}function p(e){let t=[];for(let r of e){let e=n.get(r);if(e===void 0)throw new TJ(r);t.push(e)}return t}function m(e){return n.has(e)}function h(e){for(let t of e)if(!n.has(t))return!1;return!0}function g(e){let t=n.get(e);return t===void 0?c(e):t}function _(){i++,n.clear(),r.clear()}return{clearResolvedThemes:_,getResolvedOrResolveTheme:g,getResolvedTheme:f,getResolvedThemes:p,hasRegisteredTheme:s,hasResolvedTheme:m,hasResolvedThemes:h,registerTheme:a,registerThemeIfAbsent:o,resolveTheme:c,resolveThemes:l,seedResolvedTheme:u,seedResolvedThemes:d}}var DJ=`modulepreload`,OJ=function(e){return`/`+e},kJ={},AJ={},jJ=function(e){return e.pathname.endsWith(`.css`)},MJ=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw delete e[t],n});return e[t]=i,i},NJ=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=function(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))},i=function(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)},a,o=document.querySelector(`meta[property=csp-nonce]`),s=o?.nonce||o?.getAttribute(`nonce`);r=e(t.map(e=>{e=OJ(e,n);let t=i(e),r=jJ(t);return MJ(kJ,t.href,()=>{if(a===void 0){a={all:new Set,styles:new Set};let e=document.getElementsByTagName(`link`);for(let t=e.length-1;t>=0;t--){let n=e[t];a.all.add(n.href),n.rel===`stylesheet`&&a.styles.add(n.href)}}let e=r?a.styles:a.all,n=r?AJ[t.href]:void 0;if(!n&&e.has(t.href))return;let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:DJ,r||(i.as=`script`),i.crossOrigin=``,i.href=t.href,s&&i.setAttribute(`nonce`,s),n&&delete AJ[t.href],n?.isConnected?n.replaceWith(i):document.head.appendChild(i),r)return new Promise((e,n)=>{let r=a=>{i.removeEventListener(`load`,r),i.removeEventListener(`error`,r),a.type===`error`?(AJ[t.href]=i,n(Error(`Unable to preload CSS for ${t}`))):e(a)};i.addEventListener(`load`,r),i.addEventListener(`error`,r)})})}).filter(e=>e!==void 0))}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)})},PJ=new Map,FJ=new Map,IJ=xJ(()=>NJ(()=>import(`./loader-BMv9OYvr.js`),[])),LJ=xJ(()=>NJ(()=>import(`./themes-CLX9vH7e.js`),[])),RJ=xJ(()=>NJ(()=>import(`./core-Dl2d1S-D.js`).then(e=>e.t),__vite__mapDeps([0,1]))),zJ=[[`editor.lineHighlightBackground`,`editor.active_line.background`],[`editor.selectionBackground`,`element.selected`],[`editor.findMatchHighlightBackground`,`search.match_background`],[`editorBracketMatch.background`,`editor.document_highlight.bracket_background`],[`editorError.foreground`,`error`],[`editorWarning.foreground`,`warning`],[`editorInfo.foreground`,`info`],[`editorHint.foreground`,`hint`],[`gitDecoration.addedResourceForeground`,`created`,`terminal.ansi.green`],[`gitDecoration.deletedResourceForeground`,`deleted`,`terminal.ansi.red`],[`gitDecoration.modifiedResourceForeground`,`modified`,`terminal.ansi.blue`]];function BJ(e,t){let n=`themes`in t?t.themes[0]:t;if(n==null)throw Error(`Theme "${e}" is an empty Zed theme family.`);let r={...n,name:e},i={};for(let[e,t]of Object.entries(r.style))typeof t==`string`&&(i[e]=t);let a=r.style.players?.[0];a?.cursor!=null&&(i[`editorCursor.foreground`]??=a.cursor),a?.selection!=null&&(i[`editor.selectionBackground`]??=a.selection);for(let[e,...t]of zJ){if(i[e]!=null)continue;let n=t.find(e=>i[e]!=null);n!=null&&(i[e]=i[n])}if(r.cssVariables===!0)i[`editor.foreground`]=`var(--hls-foreground)`,i[`editor.background`]=`var(--hls-background)`;else if(typeof r.cssVariables==`object`){i[`editor.foreground`]??=i.text??i.foreground??`foreground`,i[`editor.background`]??=i.background??`background`;let{prefix:e=`--hls-`,defaults:t}=r.cssVariables;for(let[n,r]of Object.entries(i)){let a=t?.[r];i[n]=`var(${e}${r}${a?`, ${a}`:``})`}}let o=r.appearance===`light`?`light`:`dark`;return{name:e,type:o,colors:i,zed:r,fg:i[`editor.foreground`]??i.text??i.foreground??(o===`light`?`#333333`:`#bbbbbb`),bg:i[`editor.background`]??i.background??(o===`light`?`#ffffff`:`#1e1e1e`)}}function VJ(e){let t=FJ.get(e);return t??(t=EJ({fallbackLoader:async t=>{if(typeof __DIFFS_WORKER__<`u`?__DIFFS_WORKER__:bJ())throw Error(`Theme "${t}" cannot be resolved from a worker context. Themes must be pre-resolved on the main thread and passed to the worker via the resolvedThemes parameter.`);let n=PJ.get(t);if(e===`highlights`){let e=n?.zed??n?.diffs;if(e!=null){let n=await e(),r=`default`in n?n.default:n;if(`zed`in r&&r.zed!=null)return r;if(`style`in r||`themes`in r)return BJ(t,r);throw Error(`Theme "${t}" is a TextMate theme; register a Zed theme with registerCustomTheme(name, loader, 'zed') for Highlights.`)}let r=IJ(),{themes:i}=r instanceof Promise?await r:r,a=i[t];if(a!=null)return BJ(t,(await a()).default);if(n?.textmate!=null)throw Error(`Theme "${t}" is only registered for TextMate; use registerCustomTheme(name, loader, 'zed') for Highlights.`)}else{let e=n?.textmate??n?.diffs,r;if(e!=null){let t=await e();r=`default`in t?t.default:t}else{let e=LJ(),{themes:i}=e instanceof Promise?await e:e,a=i.getTheme(t);if(a==null&&n?.zed!=null)throw Error(`Theme "${t}" is only registered for Zed; use registerCustomTheme(name, loader, 'textmate') for Shiki.`);if(a==null)throw Error(`No valid theme loader registered for "${t}"`);let o=await a.load();r=`default`in o?o.default:o}if(`style`in r||`themes`in r)throw Error(`Theme "${t}" is a Zed theme; use preferredHighlighter: 'highlights' or register a TextMate theme for Shiki.`);let i=RJ(),{normalizeTheme:a,createCssVariablesTheme:o}=i instanceof Promise?await i:i;if(`cssVariables`in r&&r.cssVariables!=null)return{...r,textmate:a(o(r.cssVariables))};if(`textmate`in r&&r.textmate!=null)return{...r,textmate:a(r.textmate)};let s=a(r);return{name:s.name,type:s.type,fg:s.fg,bg:s.bg,colors:s.colors,textmate:s}}throw Error(`No valid theme loader registered for "${t}"`)},normalizeTheme:(e,t)=>{if(e.name!==t)throw Error(`resolvedTheme: themeName: ${t} does not match theme.name: ${e.name}`);return e}}),FJ.set(e,t)),t}function HJ(e,t=hJ()){return typeof t!=`string`&&t.isDisposed?!1:(typeof t==`string`?VJ(t):t.themeResolver).hasResolvedThemes(yJ(e))}var UJ;async function WJ(e){let t=hJ(e);_J(t);try{if(t===`highlights`){let{HighlightsHighlighter:e}=await NJ(async()=>{let{HighlightsHighlighter:e}=await import(`./highlights-BxaWC1ve.js`);return{HighlightsHighlighter:e}},__vite__mapDeps([2,3,1,4,5]));return new e}let{ShikiHighlighter:e}=await NJ(async()=>{let{ShikiHighlighter:e}=await import(`./shiki-CoRI3zWj.js`);return{ShikiHighlighter:e}},__vite__mapDeps([6,3,1,4,7,0]));return await e.create(t)}finally{vJ()}}async function GJ({themes:e,langs:t,preferredHighlighter:n}){KJ();let r=UJ??=WJ(mJ()??n),i;try{i=await r}catch(e){throw UJ===r&&(UJ=void 0),e}if(UJ===r&&(UJ=i),await Promise.all([i.themeResolver.resolveThemes(e),i.loadLanguages(t)]),i.isDisposed)throw new pJ;return i}function KJ(){UJ!=null&&!(`then`in UJ)&&UJ.isDisposed&&(UJ=void 0)}function qJ({theme:e,lang:t,langs:n}={}){KJ();let r=UJ;if(!(r==null||`then`in r||e!=null&&!HJ(e,r)||(t!=null||n!=null)&&!r.hasLoadedLanguages([...t==null?[]:[t],...n??[]])))return r}function JJ(e,t=hJ()){return VJ(t).getResolvedOrResolveTheme(e)}function YJ(e,t,n=`textmate`){let r=PJ.get(e)??{};r[n]==null?(r[n]=t,PJ.set(e,r)):console.error(`SharedHighlight.registerCustomTheme: theme name and type already registered`,e,n)}var XJ=`highlights`,ZJ=`forge-light`,QJ={light:ZJ,dark:`pierre-dark`};function $J(e){return e?QJ.dark:QJ.light}var eY=4.5;function tY(e){let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4}function nY(e){let t=/^#([0-9a-f]{6})([0-9a-f]{2})?$/i.exec(e);if(!t)return e;let n=[0,2,4].map(e=>parseInt(t[1].slice(e,e+2),16)),r=()=>{let[e,t,r]=n.map(tY);return .74/(.2126*e+.7152*t+.0722*r+.05)};if(r()>=eY)return e;for(;r()<eY;)n=n.map(e=>Math.floor(e*.95));return`#`+n.map(e=>e.toString(16).padStart(2,`0`)).join(``)+(t[2]||``)}function rY(e){let t={};for(let[n,r]of Object.entries(e.style.syntax??{}))t[n]=typeof r==`string`?nY(r):r&&typeof r==`object`&&`color`in r&&typeof r.color==`string`?{...r,color:nY(r.color)}:r;return{...e,name:ZJ,style:{...e.style,syntax:t}}}YJ(ZJ,async()=>{let e=await JJ(`pierre-light`,XJ);if(!e.zed)throw Error(`pierre-light has no palette for the highlights engine`);return rY(e.zed)},`zed`);var iY=new Map;function aY(e){let t=iY.get(e);if(t)return t;let n=GJ({themes:Object.values(QJ),langs:[e],preferredHighlighter:XJ}).catch(t=>{if(e===`text`)throw iY.delete(e),t;return aY(`text`)});return iY.set(e,n),n}var oY=b.memo(function({text:e}){return(0,x.jsx)(`div`,{className:`prose-forge`,children:(0,x.jsx)(hW,{remarkPlugins:[Wq],components:{a:({node:e,...t})=>(0,x.jsx)(`a`,{...t,target:`_blank`,rel:`noreferrer noopener`}),pre:({node:e,children:t})=>(0,x.jsx)(lY,{children:t})},children:e})})});function sY(e){let t=b.Children.toArray(e)[0];return/language-([\w+-]+)/.exec(t?.props?.className||``)?.[1]||``}function cY(e){let t=b.Children.toArray(e)[0]?.props?.children;return(Array.isArray(t)?t.join(``):String(t??``)).replace(/\n$/,``)}function lY({children:e}){let t=sY(e)||`text`,[n,r]=b.useState(!0),[i,a]=b.useState(!1);return(0,x.jsxs)(`div`,{dir:`ltr`,className:`code-block my-[0.65rem] overflow-hidden rounded-lg border border-border/70 bg-secondary leading-snug dark:border-transparent dark:bg-input/32`,"data-language":t,"data-wrap":n?`true`:`false`,children:[(0,x.jsxs)(`div`,{className:`code-block-header flex items-center justify-between gap-2 pt-1.5 pr-1.5 pb-0 pl-3 select-none`,children:[(0,x.jsx)(`span`,{className:`truncate font-mono text-2xs`,children:t}),(0,x.jsxs)(`span`,{className:`flex items-center gap-0.5`,role:`toolbar`,"aria-label":`Code block actions`,children:[(0,x.jsx)(Tb,{label:n?`Don’t wrap lines`:`Wrap lines`,children:(0,x.jsx)(q,{type:`button`,variant:n?`secondary`:`ghost-muted`,size:`icon-xs`,"aria-pressed":n,"aria-label":n?`Don’t wrap lines`:`Wrap lines`,onClick:()=>r(!n),children:(0,x.jsx)(Nm,{className:`size-3`})})}),(0,x.jsx)(Tb,{label:i?`Copied`:`Copy`,children:(0,x.jsx)(q,{type:`button`,variant:`ghost-muted`,size:`icon-xs`,"aria-label":`Copy`,onClick:()=>{navigator.clipboard.writeText(cY(e)).then(()=>{a(!0),setTimeout(()=>a(!1),1200)})},children:i?(0,x.jsx)(Md,{className:`size-3`}):(0,x.jsx)(ef,{className:`size-3`})})})]})]}),(0,x.jsx)(fY,{code:cY(e),language:t,fallback:(0,x.jsx)(`pre`,{children:e})})]})}var uY=new Map,dY=200;function fY({code:e,language:t,fallback:n}){let r=$J(Ju()),i=/^(text|txt|plain|plaintext)$/i.test(t),a=`${r}\u0000${t}\u0000${e}`,[o,s]=b.useState(()=>uY.get(a)??null);return b.useEffect(()=>{if(i)return;let n=uY.get(a);if(n)return s(n);let o=!0;return aY(t).then(n=>{let i;try{i=n.codeToHtml(e,{lang:t,theme:r})}catch{i=n.codeToHtml(e,{lang:`text`,theme:r})}uY.size>=dY&&uY.delete(uY.keys().next().value),uY.set(a,i),o&&s(i)}).catch(()=>{}),()=>{o=!1}},[a,i,e,t,r]),i||!o?(0,x.jsx)(x.Fragment,{children:n}):(0,x.jsx)(`div`,{className:`code-block-highlighted`,dangerouslySetInnerHTML:{__html:o}})}var pY=e=>e.type.replace(/^tool-/,``),mY=e=>e.state===`output-error`||!!e.output?.error||pY(e)===`shell`&&typeof e.output?.exitCode==`number`&&e.output.exitCode!==0;function hY(e,t){let n=-1;e.forEach((e,t)=>{e.kind===`text`&&(n=t)});let r=e.some(e=>e.kind===`tool`&&(e.part.state===`approval-requested`||pY(e.part)===`ask`&&e.part.state===`input-available`));if(t.streaming||r||!t.finished||n<0)return null;let i=new Set;return e.forEach((e,t)=>{t===n||e.kind===`tool`&&pY(e.part)===`ask`||t>n&&e.kind===`tool`&&mY(e.part)||t>n&&e.kind===`group`&&e.parts.some(mY)||i.add(t)}),i.size?i:null}var gY=2e3;function _Y({text:e,label:t=`Copy message`}){let[n,r]=b.useState(`idle`);return b.useEffect(()=>{if(n===`idle`)return;let e=setTimeout(()=>r(`idle`),gY);return()=>clearTimeout(e)},[n]),(0,x.jsx)(Tb,{label:n===`failed`?`Couldn’t copy to the clipboard`:t,children:(0,x.jsx)(q,{"aria-label":t,size:`xs`,variant:`ghost-muted`,disabled:n===`copied`,className:`disabled:opacity-100`,onClick:()=>navigator.clipboard.writeText(e).then(()=>r(`copied`),()=>r(`failed`)),children:n===`copied`?(0,x.jsx)(Md,{className:`size-3 text-primary`}):(0,x.jsx)(ef,{className:`size-3`})})})}function vY({at:e}){return e?(0,x.jsx)(Tb,{label:Tu(e),children:(0,x.jsx)(`p`,{tabIndex:0,className:`rounded-sm text-xs text-muted-foreground tabular-nums outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:Cu(e)})}):null}var yY=e=>G(`transition-opacity duration-200 pointer-coarse:opacity-100 focus-within:opacity-100`,e===`group`?`opacity-0 group-hover:opacity-100`:`opacity-0 group-hover/assistant:opacity-100`);function bY({at:e,text:t,onRevert:n,busy:r}){return(0,x.jsx)(`div`,{className:G(`flex w-full max-w-[80%] items-center justify-end pe-1 text-xs tabular-nums`,yY(`group`)),children:(0,x.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-x-2`,children:[(0,x.jsx)(vY,{at:e}),(0,x.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[n&&(0,x.jsx)(Tb,{label:`Edit from here`,children:(0,x.jsx)(q,{"aria-label":`Edit from here`,size:`xs`,variant:`ghost`,disabled:r,onClick:n,children:(0,x.jsx)(Lp,{className:`size-3`})})}),t&&(0,x.jsx)(_Y,{text:t})]})]})})}function xY({at:e,text:t,status:n,alwaysVisible:r,className:i}){return(0,x.jsxs)(`div`,{className:G(`flex items-center gap-2 text-xs tabular-nums`,r?`opacity-100`:yY(`assistant`),i),children:[n&&(0,x.jsx)(`span`,{className:`rounded-full border border-border/70 px-1.5 py-0.5 font-mono text-3xs text-muted-foreground`,children:n}),t.trim()&&(0,x.jsx)(_Y,{text:t}),(0,x.jsx)(vY,{at:e})]})}function SY(e){let t=e.parts.filter(e=>e.type===`text`&&typeof e.text==`string`).map(e=>e.text);return t.length?t.join(`
|
|
282
|
+
`):null}function CY(e){let t=[];return e.forEach((n,r)=>{if(n.role!==`user`)return;let i=null;for(let t=r+1;t<e.length&&e[t].role!==`user`;t++){let n=SY(e[t]);e[t].role===`assistant`&&n!==null&&(i=n)}t.push({id:n.id,rowIndex:r,userText:SY(n)??``,assistantText:i})}),t}var wY=new Set([`paragraph`,`heading`,`tableCell`,`emphasis`,`strong`,`delete`,`link`,`linkReference`]);function TY(e){switch(e.type){case`text`:case`inlineCode`:case`code`:return e.value;case`break`:return` `;case`image`:case`imageReference`:return String(e.alt||``);case`footnoteReference`:case`footnoteDefinition`:case`definition`:case`html`:return``}return Array.isArray(e.children)?e.children.map(TY).join(wY.has(e.type)?``:` `):``}function EY(e){return TY(tH(e,{extensions:[Hq()],mdastExtensions:[qK()]})).replace(/\s+/g,` `).trim()}function DY(e,t){if(t<=0||t>=e.length)return!1;let n=e.charCodeAt(t-1),r=e.charCodeAt(t);return n>=55296&&n<=56319&&r>=56320&&r<=57343}function OY(e){if(e===null)return null;let t=EY(e.slice(0,DY(e,1500)?1499:1500));return t.length?t:null}function kY(e){return e&&{...e,userText:OY(e.userText),assistantText:OY(e.assistantText)}}var AY=8,jY=5,MY=48,NY=32,PY=40,FY=14;function IY(e){return`min(${Math.max(1,(e-1)*AY)}px, max(4rem, calc(100% - 14.75rem)))`}function LY(e,t){return t<=1?0:Math.max(0,Math.min(e,t-1))/(t-1)*100}function RY(e,t){return t<=0?e:Math.min(e,Math.max(2,Math.floor(t/jY)+1))}function zY(e,t,n){return n>=t?e:Math.round(e/(t-1)*(n-1))}function BY(e){if(e.count<=0||e.railHeight<=0)return null;if(e.count===1)return 0;let t=Math.max(0,Math.min(1,(e.y-e.railTop)/e.railHeight));return Math.max(0,Math.min(e.count-1,Math.round(t*(e.count-1))))}function VY(e,t,n,r){return n!==null&&r!==null&&e<=r&&(t===void 0||t>n)}function HY(e){if(e.visibleStart===null||e.visibleEnd===null)return null;let t=null;for(let[n,r]of e.rowIndices.entries()){if(r>=e.visibleStart)return r<=e.visibleEnd?n:t;t=n}return t}function UY(e){return e>=MY}function WY(e){let t=Number.isFinite(e)?Math.max(0,Math.floor(e)):0;return t<46?{left:0,width:Math.min(8,t)}:{left:NY,width:Math.min(PY,t-NY)}}function GY(e){return e>=FY}var KY=150,qY=[1,3],JY=new WeakMap;function YY(e){let t=JY.get(e);if(t)return cancelAnimationFrame(t.frame),t.stop.abort(),JY.delete(e),t}function XY(e,t){let n=YY(e),r=e.scrollTop,i=n?n.to+r-n.written:r,a={from:r,to:Math.max(0,Math.min(e.scrollHeight-e.clientHeight,i+t)),start:performance.now(),written:r,frame:0,stop:new AbortController};for(let t of[`pointerdown`,`keydown`])window.addEventListener(t,()=>YY(e),{capture:!0,signal:a.stop.signal});let o=t=>{if(!e.isConnected)return void YY(e);let n=e.scrollTop-a.written;a.from+=n,a.to+=n;let r=Math.min(1,Math.max(0,(t-a.start)/KY));e.scrollTop=a.from+(a.to-a.from)*(1-(1-r)**3),a.written=e.scrollTop,r<1?a.frame=requestAnimationFrame(o):YY(e)};a.frame=requestAnimationFrame(o),JY.set(e,a)}function ZY(e,t){if(e.defaultPrevented||e.ctrlKey||e.deltaY===0)return;e.preventDefault();let n=e.deltaMode===WheelEvent.DOM_DELTA_LINE?16:e.deltaMode===WheelEvent.DOM_DELTA_PAGE?t.clientHeight:1,r=e.deltaY*n,i=e.wheelDeltaY;e.deltaMode===WheelEvent.DOM_DELTA_PIXEL&&(i===void 0||qY.some(t=>Math.abs(i+t*e.deltaY)<1))||window.matchMedia(`(prefers-reduced-motion: reduce)`).matches?(YY(t),t.scrollBy({top:r})):XY(t,r)}function QY(e){let t=n=>{n.buttons===0&&(window.removeEventListener(`mouseup`,t),window.removeEventListener(`mousemove`,t),e())};window.addEventListener(`mouseup`,t),window.addEventListener(`mousemove`,t)}function $Y({items:e,persistent:t,hitStrip:n,currentIndex:r,atEnd:i,stripMap:a,onWheel:o,onSelect:s}){let[c,l]=b.useState(null),[u,d]=b.useState(0),[f,p]=b.useState(!1),m=b.useRef(!1),h=b.useRef(null),g=b.useRef(null),_=b.useRef(o);if(_.current=o,b.useEffect(()=>{let e=h.current;if(!e)return;let t=e=>_.current(e);return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[e.length>=2]),b.useEffect(()=>{let e=g.current;if(!e)return;d(e.getBoundingClientRect().height);let t=new ResizeObserver(([e])=>e&&d(e.contentRect.height));return t.observe(e),()=>t.disconnect()},[e.length>=2]),e.length<2)return null;let v=c!==null&&c<e.length?c:null,y=kY(v===null?null:e[v]||null),S=r!==null&&r>=0&&r<e.length?r:null,C=S===null?null:e[S-1]||null,w=S===null||i?null:e[S+1]||null,T=GY(n.width)&&!f,E=RY(e.length,u),D=Array.from({length:E},()=>[]);e.forEach((t,n)=>D[zY(n,e.length,E)]?.push(t));let O=v===null?null:zY(v,e.length,E),k=t=>{let n=t.currentTarget.getBoundingClientRect();return BY({count:e.length,railTop:n.top,railHeight:n.height,y:t.clientY})},A=t=>l(n=>Math.max(0,Math.min(e.length-1,(n??0)+t)));return(0,x.jsx)(`div`,{ref:h,"data-testid":`timeline-minimap`,className:G(`group/minimap pointer-events-none absolute top-0 bottom-0 left-0 z-40 w-18`,t?`opacity-100`:`hidden opacity-0 transition-opacity duration-150 hover:opacity-100 focus-within:opacity-100 [@media(pointer:fine)]:block`),children:(0,x.jsx)(`div`,{className:`relative h-full w-full select-none`,children:(0,x.jsxs)(`div`,{ref:g,className:G(`absolute top-1/2 -translate-y-1/2`,n.width>0&&!f?`pointer-events-auto`:`pointer-events-none`),style:{height:IY(e.length),left:n.left,width:n.width},onMouseDown:()=>{m.current||(m.current=!0,QY(()=>m.current=!1))},onMouseMove:e=>{e.buttons===0||m.current||f||(p(!0),QY(()=>p(!1)))},children:[(0,x.jsx)(eX,{direction:`previous`,disabled:!C,interactive:T,onClick:()=>C&&s(C)}),(0,x.jsxs)(`button`,{type:`button`,"aria-label":`Jump to message: ${y?.userText??`User message`}`,className:`absolute inset-y-0 left-0 w-full cursor-pointer bg-transparent before:absolute before:inset-x-0 before:-inset-y-1 before:content-[''] focus-visible:ring-2 focus-visible:ring-ring/70 focus-visible:outline-none focus-visible:ring-inset`,onBlur:()=>l(null),onFocus:()=>l(e=>e??S??0),onMouseLeave:()=>l(null),onMouseMove:e=>{(e.buttons===0||m.current)&&l(k(e))},onMouseDown:e=>e.preventDefault(),onClick:t=>{let n=k(t),r=n===null?null:e[n];r&&s(r),t.currentTarget.blur()},onKeyDown:t=>{let n={ArrowDown:()=>A(1),ArrowUp:()=>A(-1),Home:()=>l(0),End:()=>l(e.length-1),Enter:()=>v!==null&&s(e[v])," ":()=>v!==null&&s(e[v])}[t.key];n&&(t.preventDefault(),n())},children:[D.map((e,t)=>{let n=O===null?null:Math.abs(t-O);return(0,x.jsx)(`span`,{"aria-hidden":!0,"data-minimap-strip":!0,"data-in-view":`false`,ref:t=>{if(t){for(let n of e)a.set(n.id,t);return()=>{for(let n of e)a.get(n.id)===t&&a.delete(n.id)}}},style:{top:`${LY(t,E)}%`},className:G(`pointer-events-none absolute left-0 h-0.5 w-6 origin-left -translate-y-1/2 rounded-full transition-transform duration-150 after:absolute after:inset-0 after:rounded-full after:bg-foreground/55 after:opacity-0 after:transition-opacity after:duration-150 data-[in-view=true]:after:opacity-100`,n===0?`bg-muted-foreground/60`:`bg-muted-foreground/25`,n===0?`scale-x-100`:n===1?`scale-x-[0.667]`:n===2?`scale-x-[0.417]`:`scale-x-[0.333]`)},e[0]?.id??t)}),y&&(0,x.jsx)(`span`,{className:`pointer-events-none absolute left-8 w-80 -translate-y-1/2`,style:{top:`${LY(v,e.length)}%`},children:(0,x.jsxs)(`span`,{className:`glass block rounded-xl p-3 text-left text-popover-foreground shadow-xl shadow-black/25`,children:[(0,x.jsx)(`span`,{className:`block max-w-full truncate text-sm leading-5 font-medium`,children:y.userText??`User message`}),y.assistantText&&(0,x.jsx)(`span`,{className:`mt-1 line-clamp-3 max-h-[3.75rem] overflow-hidden text-sm leading-5 text-muted-foreground`,children:y.assistantText})]})})]}),(0,x.jsx)(eX,{direction:`next`,disabled:!w,interactive:T,onClick:()=>w&&s(w)})]})})})}function eX({direction:e,disabled:t,interactive:n,onClick:r}){let i=e===`previous`,a=i?`Previous turn`:`Next turn`,o=i?Rd:Pd;return(0,x.jsx)(`span`,{className:G(`absolute left-1 z-10 inline-flex -translate-x-1/2 opacity-0 transition-opacity duration-150 focus-within:opacity-100 hover:opacity-100`,n?`pointer-events-auto`:`pointer-events-none`,i?`bottom-[calc(100%+6px)]`:`top-[calc(100%+6px)]`),children:(0,x.jsx)(Tb,{label:a,side:i?`top`:`bottom`,children:(0,x.jsx)(q,{"aria-label":a,disabled:t,onClick:r,variant:`ghost-muted`,className:`size-5 p-0`,children:(0,x.jsx)(o,{className:`size-4 text-foreground/90`})})})})}var tX=b.lazy(()=>NJ(()=>import(`./diff-view-Chujmqzi.js`),__vite__mapDeps([8,9,3,1,5])));function nX(e){return e.state===`input-streaming`||e.state===`input-available`||e.state===`output-available`&&(e.preliminary===!0||e.output?.running===!0)}var rX=e=>e.type.replace(/^tool-/,``),iX=new Set([`read_file`,`list_dir`,`glob`,`grep`]),aX=e=>iX.has(rX(e));function oX(e){let t=e.input||{},n=e.output||{},r=nX(e),i=e=>(0,x.jsx)(`span`,{className:`font-mono text-[12.5px]`,children:String(e??``)});switch(rX(e)){case`read_file`:return{icon:hf,label:(0,x.jsxs)(x.Fragment,{children:[r?`Reading`:`Read`,` `,i(t.path)]}),meta:n.totalLines?`${n.totalLines} lines`:n.error};case`list_dir`:return{icon:xf,label:(0,x.jsxs)(x.Fragment,{children:[r?`Listing`:`Listed`,` `,i(t.path||`.`)]}),meta:n.entries?`${n.entries.length} entries`:n.error};case`glob`:return{icon:am,label:(0,x.jsxs)(x.Fragment,{children:[`Found files `,i(t.pattern)]}),meta:n.files?`${n.files.length} files`:void 0};case`grep`:return{icon:am,label:(0,x.jsxs)(x.Fragment,{children:[`Searched “`,t.pattern,`”`]}),meta:n.matches?`${n.matches.length} matches in ${n.files} files`:n.error};case`write_file`:return{icon:xm,label:(0,x.jsxs)(x.Fragment,{children:[r?`Writing`:n.created?`Created`:`Wrote`,` `,i(t.path)]}),stat:n.added===void 0?void 0:{added:n.added,removed:n.removed}};case`edit_file`:return{icon:xm,label:(0,x.jsxs)(x.Fragment,{children:[r?`Editing`:n.error?`Edit`:`Edited`,` `,i(t.path)]}),stat:n.added===void 0?void 0:{added:n.added,removed:n.removed},meta:n.error};case`rename_path`:return{icon:Fp,label:(0,x.jsxs)(x.Fragment,{children:[`Renamed `,i(t.from),` → `,i(t.to)]}),meta:n.error};case`delete_path`:return{icon:Fm,label:(0,x.jsxs)(x.Fragment,{children:[n.deleted?`Deleted`:`Delete`,` `,i(t.path)]}),stat:n.removed?{added:0,removed:n.removed}:void 0,meta:e.state===`output-denied`?`declined`:n.error};case`shell`:{let i=typeof n.durationMs==`number`?` · ${(n.durationMs/1e3).toFixed(+(n.durationMs<1e4))}s`:``;return{icon:jm,label:(0,x.jsxs)(x.Fragment,{children:[e.state===`approval-requested`?`Run`:r?`Running`:e.state===`output-denied`?`Not run:`:`Ran`,` `,(0,x.jsx)(`span`,{className:`font-mono text-[12.5px]`,children:String(t.command||``).slice(0,120)})]}),meta:e.state===`output-denied`?e.approval?.reason||`declined`:n.timedOut?`timed out`:typeof n.exitCode==`number`?`exit ${n.exitCode}${i}`:void 0}}default:return lX(e,r)}}var sX={dev_open:Ff,dev_act:xp,dev_screenshot:Ed,dev_inspect:rm,dev_eval:Qd,dev_wait_idle:Vf,dev_status:fd,search_docs:bd,read_doc:bd,lookup_api:bd,describe_table:nf,check_component:Lf,workspace_check:Lf,workspace_status:jf,workspace_diff:jf,workspace_push:zm},cX={click:`Clicked`,dblclick:`Double-clicked`,hover:`Hovered`,type:`Typed`,press:`Pressed`,scroll:`Scrolled`,select:`Selected`};function lX(e,t){let n=rX(e),r=e.input||{},i=e.output||{},a=sX[n]||(n.startsWith(`dev_`)?Ff:af),o=r.route||r.path||r.query||r.selector||r.component||r.table||r.portal||r.key||r.name||``,s={dev_open:[`Opening`,`Opened`],dev_act:[`Acting`,cX[r.action]||`Acted`],dev_screenshot:[`Taking a screenshot`,`Took a screenshot`],dev_inspect:[`Inspecting the page`,`Inspected the page`],search_docs:[`Searching the docs`,`Searched the docs`],workspace_push:[`Planning a push`,`Planned a push`]}[n],c=s?t?s[0]:s[1]:n.replace(/_/g,` `);return{icon:a,label:(0,x.jsxs)(x.Fragment,{children:[c,o&&(0,x.jsxs)(`span`,{className:`font-mono text-[12.5px]`,children:[` `,String(o).slice(0,80)]})]}),meta:i.refused?`refused`:i.error?String(i.error).split(`
|
|
283
283
|
`)[0].slice(0,80):e.state===`output-denied`?`declined`:void 0}}function uX({part:e}){let t=e.output||{},n=nX(e),r=b.useRef(null),i=b.useRef(!0),a=t.output?String(t.output).slice(-6e3):``;return b.useLayoutEffect(()=>{let e=r.current;e&&i.current&&(e.scrollTop=e.scrollHeight)},[a]),(0,x.jsxs)(`div`,{onClick:e=>e.stopPropagation(),className:`ms-7 mt-0.5 mb-1.5 flex cursor-auto flex-col gap-1.5`,children:[a?(0,x.jsxs)(`pre`,{ref:r,onScroll:e=>{let t=e.currentTarget;i.current=t.scrollHeight-t.scrollTop-t.clientHeight<=8},className:`max-h-80 overflow-auto rounded-lg border bg-muted px-3 py-2 font-mono text-2xs leading-relaxed whitespace-pre-wrap text-muted-foreground select-text`,children:[t.truncated||String(t.output).length>6e3?(0,x.jsx)(`span`,{className:`block italic`,children:`Earlier output not shown`}):null,a]}):n?null:e.state===`output-available`&&!t.error?(0,x.jsx)(`div`,{className:`text-xs text-muted-foreground italic`,children:`No output.`}):null,t.sessionId&&(0,x.jsx)(`button`,{className:`self-start text-xs text-muted-foreground hover:text-foreground hover:underline`,onClick:()=>Wu({drawerOpen:!0,activeTerminal:t.sessionId}),children:`Open in terminal`})]})}function dX({part:e}){let t=e.output?.result||{};if(e.output?.refused||e.output?.error)return null;let n=t.chunks||[],r=e=>n.reduce((t,n)=>t+(Array.isArray(n[e])?n[e].length:0),0),i=n.reduce((e,t)=>e+(t.compile?.components?.length||0),0),a=n.some(e=>e.compile?.finalize?.reprocess),o=[r(`creates`)&&`${r(`creates`)} create${r(`creates`)===1?``:`s`}`,r(`updates`)&&`${r(`updates`)} update${r(`updates`)===1?``:`s`}`,r(`deactivates`)&&`${r(`deactivates`)} deactivation${r(`deactivates`)===1?``:`s`}`,r(`deletes`)&&`${r(`deletes`)} file deletion${r(`deletes`)===1?``:`s`}`,i&&`${i} compile${i===1?``:`s`}`,a&&`1 reprocess`].filter(Boolean),s=n.flatMap(e=>[...e.creates||[],...e.updates||[]]).map(e=>e.display),c=[...new Set(n.flatMap(e=>e.warnings||[]))];return(0,x.jsxs)(`div`,{onClick:e=>e.stopPropagation(),className:`ms-7 mt-1 mb-2 cursor-auto rounded-2xl border border-border/80 bg-card/70 p-4 text-sm`,children:[(0,x.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,x.jsxs)(`span`,{className:`inline-flex h-[18px] shrink-0 items-center gap-1 rounded-sm bg-foreground/8 px-1.5 text-xs font-medium whitespace-nowrap`,children:[(0,x.jsx)(zm,{className:`size-3`}),` Push plan`]}),(0,x.jsxs)(`span`,{className:`truncate font-medium`,children:[[t.portal?.slug,t.app].filter(Boolean).join(` · `)||`Workspace`,t.updateSet?` · ${t.updateSet}`:``]}),t.planHash&&(0,x.jsx)(`span`,{className:`ms-auto shrink-0 font-mono text-xs text-muted-foreground`,children:t.planHash})]}),(0,x.jsx)(`div`,{className:`mt-2 text-xs text-muted-foreground`,children:t.refused?`Refused: ${t.reason}`:t.nothingToPush?`Nothing to push: the instance has everything.`:o.join(` · `)||`Planned changes`}),s.length>0&&(0,x.jsxs)(`div`,{className:`mt-1 truncate font-mono text-xs text-foreground/80`,children:[s.slice(0,4).join(`, `),s.length>4?` +${s.length-4}`:``]}),c.slice(0,2).map(e=>(0,x.jsxs)(`div`,{className:`mt-1 truncate text-xs text-warning-foreground`,children:[`⚠ `,e]},e)),!t.nothingToPush&&!t.refused&&(0,x.jsxs)(`div`,{className:`mt-3 flex items-center gap-1.5 text-xs`,children:[(0,x.jsx)(_m,{className:`size-3.5 text-warning-foreground`}),(0,x.jsx)(`span`,{className:`text-warning-foreground`,children:`Waiting for your review`}),(0,x.jsx)(`span`,{className:`text-icon-muted`,children:`·`}),(0,x.jsx)(`button`,{className:`font-medium text-foreground underline-offset-4 hover:underline`,onClick:()=>Wu({pushOpen:!0}),children:`Review and push…`})]})]})}function fX({ids:e}){let{projectId:t}=b.useContext(pX);return(0,x.jsx)(`div`,{className:`ms-7 flex gap-2 pt-1 pb-1.5`,children:e.slice(0,3).map(e=>(0,x.jsx)(`a`,{href:`/api/blob/${t}/${e}`,target:`_blank`,rel:`noreferrer`,onClick:e=>e.stopPropagation(),children:(0,x.jsx)(`img`,{src:`/api/blob/${t}/${e}`,alt:`Screenshot from the agent's browser`,className:`h-28 w-auto rounded-lg border bg-muted object-cover object-top shadow-xs/5`})},e))})}var pX=b.createContext({projectId:``,chatId:``,onAnswer:()=>{},onRewind:()=>{},onUndoTurn:()=>{}}),mX=new Set([`edit_file`,`write_file`,`delete_path`]);function hX(e){let{projectId:t,chatId:n}=b.useContext(pX),r=Au(),i=e.output?.editId,a=U({...r.edits.undone.queryOptions({projectId:t}),enabled:!!i&&!!t}),o=at(r.edits.undo.mutationOptions()),s=U({...r.chats.overlaps.queryOptions({projectId:t,chatId:n}),enabled:!!i&&!!t&&!!n}),[c,l]=b.useState(``);if(!i||!mX.has(rX(e)))return null;let u=!!a.data?.includes(i),d=(s.data||[]).filter(t=>t.path===e.output?.path),f=!u&&d.length>0&&(0,x.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 text-xs text-warning-foreground`,title:`Also changed by ${d.map(e=>`“${e.title}”`).join(`, `)}. Undo merges around their edits.`,children:[(0,x.jsx)(Um,{"aria-hidden":!0,className:`size-3`}),(0,x.jsx)(`span`,{className:`sr-only`,children:`Also changed by another chat`})]});return{editId:i,isUndone:u,actions:(0,x.jsxs)(x.Fragment,{children:[f,(0,x.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2 text-xs opacity-0 transition-opacity group-hover/timeline-row:opacity-100 group-focus-within/timeline-row:opacity-100`,children:[(0,x.jsx)(`button`,{className:`text-muted-foreground hover:text-foreground hover:underline`,onClick:t=>{t.stopPropagation(),Wu({panelOpen:!0,panelTab:`diff`,diffScope:`session`,diffPath:e.output?.path})},children:`View diff`}),!u&&(0,x.jsxs)(`button`,{className:`inline-flex items-center gap-1 text-muted-foreground hover:text-foreground`,title:`Undo this edit`,onClick:async e=>{e.stopPropagation();let r=await o.mutateAsync({projectId:t,chatId:n,editId:i});l(r.ok?``:r.message||`Undo failed`)},children:[(0,x.jsx)(Zp,{className:`size-3`}),` Undo`]})]})]}),msg:c}}function gX({editId:e}){let{projectId:t}=b.useContext(pX),n=U(Au().edits.diff.queryOptions({projectId:t,editId:e}));return n.data?(0,x.jsx)(`div`,{onClick:e=>e.stopPropagation(),className:`ms-7 mt-0.5 mb-1.5 max-h-96 cursor-auto overflow-auto rounded-lg border`,children:(0,x.jsx)(b.Suspense,{fallback:(0,x.jsx)(`div`,{className:`h-10`}),children:(0,x.jsx)(tX,{path:n.data.path,oldText:n.data.old,newText:n.data.new})})}):null}function _X({part:e}){let{onAnswer:t}=b.useContext(pX),[n,r]=b.useState(``),i=e.input||{},a=e.state===`output-available`?String(e.output?.answer??``):``;return e.state===`input-streaming`?null:(0,x.jsx)(`div`,{className:`my-1 rounded-xl border bg-card/60 p-3 text-sm`,children:(0,x.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,x.jsx)(sp,{className:`mt-0.5 size-4 shrink-0 text-indigo-600 dark:text-indigo-300`}),(0,x.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,x.jsx)(`div`,{className:`leading-relaxed`,children:i.question}),a?(0,x.jsxs)(`div`,{className:`mt-1.5 text-xs text-muted-foreground`,children:[`You answered: `,(0,x.jsx)(`span`,{className:`text-foreground`,children:a})]}):(0,x.jsxs)(`div`,{className:`mt-2 flex flex-col gap-2`,children:[Array.isArray(i.choices)&&i.choices.length>0&&(0,x.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:i.choices.map(n=>(0,x.jsx)(`button`,{onClick:()=>t(e.toolCallId,n),className:`h-7 rounded-[var(--control-radius)] border border-input bg-popover px-2.5 text-xs font-medium shadow-xs/5 hover:bg-accent/50`,children:n},n))}),(0,x.jsxs)(`form`,{onSubmit:r=>{r.preventDefault(),n.trim()&&t(e.toolCallId,n.trim())},className:`flex gap-1.5`,children:[(0,x.jsx)(`input`,{value:n,onChange:e=>r(e.target.value),placeholder:`Or type an answer`,className:`h-7 min-w-0 flex-1 rounded-[var(--control-radius)] border border-input bg-transparent px-2 text-xs outline-none focus:ring-2 focus:ring-ring/40`}),(0,x.jsx)(`button`,{type:`submit`,disabled:!n.trim(),className:`h-7 rounded-[var(--control-radius)] bg-primary px-2.5 text-xs font-medium text-primary-foreground disabled:opacity-50`,children:`Answer`})]})]})]})]})})}var vX=e=>e.state===`output-error`||!!e.output?.error||rX(e)===`shell`&&typeof e.output?.exitCode==`number`&&e.output.exitCode!==0;function yX({added:e,removed:t}){return(0,x.jsxs)(`span`,{className:`font-mono text-xs tabular-nums`,children:[(0,x.jsxs)(`span`,{className:`text-diff-addition-foreground`,children:[`+`,e]}),` `,(0,x.jsxs)(`span`,{className:`text-diff-deletion-foreground`,children:[`−`,t]})]})}var bX=`rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring/70`,xX=b.createContext(!1);function SX({at:e}){return e?(0,x.jsx)(`span`,{title:new Date(e).toLocaleString(),className:`pointer-events-none absolute me-1 shrink-0 rounded-md text-xs whitespace-nowrap text-muted-foreground tabular-nums opacity-0 group-focus-within/timeline-row:pointer-events-auto group-focus-within/timeline-row:static group-focus-within/timeline-row:opacity-100 group-hover/timeline-row:pointer-events-auto group-hover/timeline-row:static group-hover/timeline-row:opacity-100`,children:xu(e)}):null}function CX({icon:e,label:t,meta:n,stat:r,at:i,live:a,error:o,open:s,expandable:c,onToggle:l,actions:u,children:d}){let f=b.useContext(xX);return(0,x.jsxs)(`div`,{onClick:c?l:void 0,className:G(`group/timeline-row relative w-full min-w-0 rounded-md px-0.5 text-left transition-colors`,f?`py-0`:`py-0.5`,c&&`cursor-pointer`),children:[(0,x.jsxs)(`div`,{role:c?`button`:void 0,tabIndex:c?0:void 0,"aria-expanded":c?!!s:void 0,onKeyDown:e=>{c&&e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),l?.())},className:G(`flex min-h-6 min-w-0 items-center gap-1.5 text-sm leading-relaxed select-none`,c&&bX),children:[(0,x.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-baseline gap-1.5`,children:[(0,x.jsx)(`span`,{className:`relative w-6 shrink-0 leading-0`,children:(0,x.jsx)(`span`,{className:`inline-block size-6 overflow-hidden align-[calc(0.5cap_-_0.75rem)]`,children:(0,x.jsx)(`span`,{className:`flex size-full items-center justify-center`,children:(0,x.jsx)(`span`,{className:G(`flex size-4 items-center justify-center`,o?`text-tool-error-icon/40`:`text-icon-muted`),children:(0,x.jsx)(e,{className:G(`block size-4 shrink-0 stroke-2`,!o&&`opacity-70`)})})})})}),(0,x.jsx)(`div`,{className:`min-w-0 flex-1 truncate text-secondary-label [&_*]:whitespace-nowrap`,children:(0,x.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-1.5`,children:[(0,x.jsx)(`span`,{className:G(`min-w-0 truncate`,a&&`live-tool-shine`),children:t}),r&&(0,x.jsx)(yX,{...r}),n&&(0,x.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:n})]})})]}),u,(0,x.jsx)(SX,{at:i}),o&&(0,x.jsx)(Gm,{"aria-hidden":!0,className:`size-3 shrink-0 text-tool-error-icon/40`}),c&&(0,x.jsx)(`span`,{className:`flex size-4 shrink-0 items-center justify-center`,"aria-hidden":!0,children:(0,x.jsx)(Id,{className:G(`size-3 shrink-0 text-icon-muted opacity-70 transition-transform duration-200`,s&&`rotate-90`)})})]}),d]})}function wX({part:e}){let t=e.errorText||(e.output===void 0?``:JSON.stringify(e.output,null,2));return(0,x.jsxs)(`div`,{onClick:e=>e.stopPropagation(),className:`ms-7 flex max-h-96 cursor-auto flex-col gap-3 overflow-auto px-0.5 py-1 select-text`,children:[(0,x.jsx)(`pre`,{className:`font-mono text-2xs leading-relaxed whitespace-pre-wrap text-secondary-label`,children:JSON.stringify(e.input,null,2)}),t&&(0,x.jsx)(`pre`,{className:`max-h-64 overflow-auto font-mono text-2xs leading-relaxed whitespace-pre-wrap text-secondary-label`,children:t.length>6e3?t.slice(0,6e3)+`
|
|
284
284
|
…`:t})]})}function TX({part:e,at:t,onApprove:n}){let[r,i]=b.useState(!1),a=oX(e),o=rX(e)===`shell`&&/^command:/.test(e.approval?.requestReason||``),s=nX(e),c=hX(e);return(0,x.jsxs)(CX,{...a,meta:c?.isUndone?`undone`:c?.msg||a.meta,actions:c?.actions,at:t,live:s,error:vX(e),open:r,expandable:!0,onToggle:()=>i(!r),children:[e.state===`approval-requested`&&(0,x.jsx)(`div`,{className:`ms-7.5 flex flex-col gap-1 pb-1 text-xs`,children:(0,x.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,x.jsx)(_m,{className:`size-3 text-warning-foreground`}),(0,x.jsx)(`span`,{className:`text-warning-foreground`,children:`Waiting for approval`}),(0,x.jsx)(`span`,{className:`text-muted-foreground`,children:`·`}),(0,x.jsx)(`button`,{className:`text-muted-foreground hover:text-foreground`,onClick:()=>n?.(!1),children:`Decline`}),(0,x.jsx)(`span`,{className:`text-muted-foreground`,children:`·`}),(0,x.jsx)(`button`,{className:`font-medium text-foreground hover:underline`,onClick:()=>n?.(!0),children:`Approve`}),o&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`span`,{className:`text-muted-foreground`,children:`·`}),(0,x.jsxs)(mb,{children:[(0,x.jsx)(hb,{render:(0,x.jsx)(`button`,{className:`text-muted-foreground hover:text-foreground`,"aria-label":`More approval options`}),children:`More`}),(0,x.jsx)(gb,{align:`start`,children:(0,x.jsx)(_b,{onClick:()=>n?.(!0,!0),children:`Always allow this session`})})]})]})]})}),rX(e)===`shell`&&(r||nX(e))&&(0,x.jsx)(uX,{part:e}),rX(e)===`workspace_push`&&e.state===`output-available`&&(0,x.jsx)(dX,{part:e}),Array.isArray(e.output?.screenshots)&&e.output.screenshots.length>0&&(0,x.jsx)(fX,{ids:e.output.screenshots}),r&&c&&!c.isUndone&&(0,x.jsx)(gX,{editId:c.editId}),r&&rX(e)!==`shell`&&!c&&(0,x.jsx)(wX,{part:e})]})}function EX({parts:e,at:t}){let[n,r]=b.useState(!1),i=t=>e.filter(e=>t.includes(rX(e))).length,a=i([`read_file`]),o=i([`list_dir`]),s=i([`grep`,`glob`]),c=[a&&`Read ${a} file${a>1?`s`:``}`,o&&`listed ${o} folder${o>1?`s`:``}`,s&&`searched ${s} pattern${s>1?`s`:``}`].filter(Boolean).join(`, `).replace(/^./,e=>e.toUpperCase()),l=e.some(nX);return(0,x.jsx)(CX,{icon:hf,label:c,at:t,live:l,error:e.some(vX),open:n,expandable:!0,onToggle:()=>r(!n),children:n&&(0,x.jsx)(`div`,{className:`flex flex-col pb-1 ps-7`,onClick:e=>e.stopPropagation(),children:(0,x.jsx)(xX.Provider,{value:!0,children:e.map(e=>(0,x.jsx)(TX,{part:e},e.toolCallId))})})})}function DX({text:e,live:t,seconds:n}){let[r,i]=b.useState(!1),a=t?`Thinking`:n?`Thought for ${n}s`:`Thought`,o=e.trim().split(`
|
|
285
285
|
`).filter(Boolean).pop()?.slice(0,160)||``;return(0,x.jsx)(CX,{icon:wd,label:(0,x.jsxs)(x.Fragment,{children:[a,!r&&o&&(0,x.jsxs)(`span`,{className:`text-muted-foreground`,children:[` · `,o]})]}),live:t,expandable:!!e,open:r,onToggle:()=>i(!r),children:r&&(0,x.jsx)(`div`,{onClick:e=>e.stopPropagation(),className:`ms-7 flex max-h-96 cursor-auto flex-col overflow-auto px-0.5 py-1 text-sm leading-relaxed whitespace-pre-wrap text-secondary-label select-text`,children:e})})}function OX(e,t){let n=[],r=[],i=()=>{r.length&&(r.length===1?n.push({kind:`tool`,key:r[0].toolCallId,part:r[0]}):n.push({kind:`group`,key:r[0].toolCallId,parts:r}),r=[])};return e.parts.forEach((e,a)=>{if(typeof e.type==`string`&&e.type.startsWith(`tool-`)){let t=e;if(aX(t)&&t.state!==`approval-requested`){r.push(t);return}i(),n.push({kind:`tool`,key:t.toolCallId,part:t})}else if(e.type===`text`){if(!e.text.trim())return;i(),n.push({kind:`text`,key:`t${a}`,text:e.text})}else if(e.type===`reasoning`){if(!e.text.trim())return;i(),n.push({kind:`reasoning`,key:`r${a}`,text:e.text,live:t&&e.state===`streaming`})}}),i(),n}function kX({m:e,busy:t}){let{onRewind:n}=b.useContext(pX),r=e.parts.map(e=>e.type===`text`?e.text:``).join(`
|
|
286
286
|
`),{projectId:i}=qi({strict:!1}),a=w9(i),o=b.useMemo(()=>new Map((a.data||[]).map(e=>[e.name,e.description])),[a.data]);return(0,x.jsxs)(`div`,{className:`group flex flex-col items-end gap-1 pb-4`,"data-timeline-message":e.id,children:[(0,x.jsx)(`div`,{className:`max-w-[80%] rounded-2xl bg-message p-3 text-sm leading-relaxed break-words whitespace-pre-wrap text-message-foreground ring-1 ring-[var(--bubble-ring)] ring-inset`,children:(0,x.jsx)(y9,{text:r,skills:o})}),(0,x.jsx)(bY,{at:e.metadata?.createdAt,text:r,busy:t,onRevert:()=>n(e.id)})]})}function AX(e){let t=Math.max(1,Math.round(e/1e3));if(t<60)return`${t}s`;let n=Math.floor(t/60);return n<60?`${n}m ${t%60}s`:`${Math.floor(n/60)}h ${n%60}m`}function jX({label:e,at:t,open:n,onToggle:r,onUndo:i,usage:a}){return(0,x.jsx)(`div`,{className:`group/timeline-row border-b border-border/60 pt-1 pe-0.5 pb-2`,children:(0,x.jsxs)(`div`,{className:`relative flex items-center gap-1`,children:[(0,x.jsxs)(`button`,{type:`button`,"aria-expanded":n,onClick:r,className:`flex cursor-pointer items-center gap-1 rounded-md px-1 text-sm leading-relaxed text-muted-foreground tabular-nums transition-colors select-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/70 focus-visible:outline-none focus-visible:ring-inset`,children:[(0,x.jsx)(`span`,{children:e}),(0,x.jsx)(n?Pd:Id,{className:`size-3.5`})]}),i&&(0,x.jsxs)(`button`,{onClick:i,className:`ms-auto inline-flex items-center gap-1 rounded-md px-1 text-xs text-muted-foreground opacity-0 transition-opacity group-hover/timeline-row:opacity-100 hover:text-foreground`,children:[(0,x.jsx)(Zp,{className:`size-3`}),` Undo turn`]}),a&&(0,x.jsxs)(`span`,{className:G(`text-xs text-muted-foreground tabular-nums opacity-0 transition-opacity group-hover/timeline-row:opacity-100`,!i&&`ms-auto`),children:[PX(a.input),` in`,a.cachedInput?` (${PX(a.cachedInput)} cached)`:``,` ·`,` `,PX(a.output),` out`,typeof a.cost==`number`?` · ${FX(a.cost)}`:``]}),t&&(0,x.jsx)(`span`,{className:G(`text-xs text-muted-foreground tabular-nums opacity-0 transition-opacity group-hover/timeline-row:opacity-100`,!i&&!a&&`ms-auto`),children:xu(t)})]})})}function MX({m:e,streaming:t,onApprove:n,turnId:r,terminal:i}){let[a,o]=b.useState(!1),{onUndoTurn:s}=b.useContext(pX),c=OX(e,t),l=e.parts.some(e=>[`tool-edit_file`,`tool-write_file`,`tool-delete_path`].includes(e.type)&&e.output?.editId),u=e.metadata?.createdAt,d=hY(c,{streaming:t,finished:!!e.metadata?.finishedAt}),f=[...e.parts].reverse().find(e=>e.type===`tool-workspace_push`&&e.state===`output-available`),p=e.metadata?.createdAt,m=e.metadata?.finishedAt,h=p&&m?`Worked for ${AX(Date.parse(m)-Date.parse(p))}`:p?`You stopped this response`:`Worked`,g=e.metadata?.error?`failed`:p&&!m&&!t?`stopped`:null,_=c.filter(e=>e.kind===`text`).map(e=>e.text).join(`
|
|
287
287
|
|
|
288
|
-
`),v=d?c.filter((e,t)=>a||!d.has(t)):c,y=[...v].reverse().find(e=>e.kind===`text`),S=!!y&&v.indexOf(y)<v.length-1,C=i&&(_.trim()||g)?{at:m||p,text:_}:null,w=e=>{switch(e.kind){case`text`:return C&&e===y&&!S?(0,x.jsxs)(`div`,{className:`group/assistant relative min-w-0 px-1 py-0.5 pb-2`,children:[(0,x.jsx)(oY,{text:e.text}),(0,x.jsx)(xY,{className:`mt-1.5`,at:C.at,text:C.text,status:g})]},e.key):(0,x.jsx)(`div`,{className:`px-1 py-0.5 pb-2`,children:(0,x.jsx)(oY,{text:e.text})},e.key);case`reasoning`:return(0,x.jsx)(DX,{text:e.text,live:e.live},e.key);case`tool`:return rX(e.part)===`ask`?(0,x.jsx)(_X,{part:e.part},e.key):(0,x.jsx)(TX,{part:e.part,at:u,onApprove:(t,r)=>e.part.approval&&n(e.part.approval.id,t,r)},e.key);case`group`:return(0,x.jsx)(EX,{parts:e.parts,at:u},e.key)}},T=C&&(S||!y)?(0,x.jsx)(`div`,{className:`px-1`,children:(0,x.jsx)(xY,{className:`mt-0.5`,at:C.at,text:C.text,status:g,alwaysVisible:!0})}):null;return d?(0,x.jsxs)(`div`,{className:`flex flex-col pb-4`,"data-timeline-message":e.id,children:[(0,x.jsx)(jX,{label:h,at:u,open:a,onToggle:()=>o(!a),onUndo:l&&r?()=>s(r):void 0,usage:e.metadata?.usage}),(0,x.jsxs)(`div`,{className:`pt-2`,children:[c.filter((e,t)=>a||!d.has(t)).map(w),!a&&f&&(0,x.jsx)(dX,{part:f}),T]})]}):(0,x.jsxs)(`div`,{className:`flex flex-col pb-4`,"data-timeline-message":e.id,children:[c.map(w),T]})}function NX({since:e}){let[t,n]=b.useState(Date.now());return b.useEffect(()=>{let e=setInterval(()=>n(Date.now()),500);return()=>clearInterval(e)},[]),(0,x.jsx)(`div`,{className:`border-b border-border/60 pt-1 pb-2`,children:(0,x.jsx)(`div`,{className:`flex h-6 min-w-0 items-baseline gap-2 px-1 text-sm leading-relaxed text-muted-foreground tabular-nums`,children:(0,x.jsxs)(`span`,{className:`relative shrink-0 overflow-hidden whitespace-nowrap`,children:[`Working for `,Eu(t-e)]})})})}function PX(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e4?`${Math.round(e/1e3)}k`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function FX(e){return e===0?`$0.00`:e<.001?`<$0.001`:e<.1?`$${e.toFixed(3)}`:`$${e.toFixed(2)}`}function IX({c:e,active:t}){let[n,r]=b.useState(!1),i=(0,x.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,x.jsx)(pp,{"aria-hidden":!0,className:`size-3 shrink-0`}),e?(0,x.jsxs)(x.Fragment,{children:[`Compacted `,e.turns,` earlier turn`,e.turns===1?``:`s`,` `,PX(e.before),(0,x.jsx)(vd,{"aria-hidden":!0,className:`size-3`}),PX(e.after),` tokens`,(0,x.jsxs)(`span`,{className:`opacity-80`,children:[`· `,e.model.model,e.cost===null?``:` · ${FX(e.cost)}`]})]}):`Compacting earlier turns…`]});return(0,x.jsxs)(`div`,{className:`py-1`,children:[(0,x.jsxs)(`div`,{role:`separator`,"aria-label":e?`Compacted ${e.turns} earlier turns`:`Compacting`,className:`flex w-full items-center gap-3 py-1 text-xs text-muted-foreground`,children:[(0,x.jsx)(`span`,{className:`h-px flex-1 bg-border/70`}),(0,x.jsxs)(`span`,{className:`relative min-w-0 overflow-hidden`,children:[i,t&&(0,x.jsx)(qb,{children:i})]}),e&&(0,x.jsx)(`button`,{onClick:()=>r(!n),className:`shrink-0 text-xs text-muted-foreground underline-offset-4 hover:text-foreground hover:underline`,children:n?`Hide summary`:`Show summary`}),(0,x.jsx)(`span`,{className:`h-px flex-1 bg-border/70`})]}),n&&e&&(0,x.jsx)(`div`,{className:`mx-auto mt-1 mb-2 max-w-[40rem] rounded-lg border bg-muted/40 px-3 py-2`,children:(0,x.jsx)(oY,{text:e.summary})})]})}function LX({messages:e,running:t,runStarted:n,onApprove:r,error:i,compactions:a=[],compacting:o}){let s=b.useRef(null),c=b.useRef(!0),l=b.useRef(0);b.useLayoutEffect(()=>{let e=s.current;e&&c.current&&(e.scrollTop=e.scrollHeight)});let u=e[e.length-1],d=RX(s,e);return(0,x.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col`,children:[(0,x.jsx)(`div`,{ref:s,onScroll:e=>{let t=e.currentTarget;Date.now()>l.current&&(c.current=t.scrollHeight-t.scrollTop-t.clientHeight<40),d.schedule()},className:`fade-top min-h-0 flex-1 overflow-y-auto px-3 sm:px-12`,children:(0,x.jsxs)(`div`,{className:`mx-auto w-full max-w-[var(--chat-max)] pt-4 pb-6`,"data-timeline-root":!0,children:[e.map((n,i)=>(0,x.jsxs)(b.Fragment,{children:[n.role===`user`?(0,x.jsx)(kX,{m:n,busy:t}):(0,x.jsx)(MX,{m:n,streaming:t&&n===u,terminal:!(t&&n===u)&&(i===e.length-1||e[i+1]?.role===`user`),onApprove:r,turnId:[...e.slice(0,i)].reverse().find(e=>e.role===`user`)?.id}),a.filter(e=>e.upTo===n.id).map(e=>(0,x.jsx)(IX,{c:e},`c${e.upTo}`))]},n.id)),o&&(0,x.jsx)(IX,{active:!0}),t&&(0,x.jsx)(NX,{since:n}),i&&(0,x.jsx)(`div`,{className:G(`mt-2 rounded-lg border border-destructive/30 bg-destructive/8 px-3 py-2 text-sm text-destructive-foreground`),children:i})]})}),(0,x.jsx)($Y,{items:d.items,persistent:d.persistent,hitStrip:d.hitStrip,currentIndex:d.current,atEnd:d.atEnd,stripMap:d.stripMap,onWheel:e=>s.current&&ZY(e,s.current),onSelect:e=>{c.current=!1,l.current=Date.now()+1e3,d.select(e.id)}})]})}function RX(e,t){let n=b.useMemo(()=>CY(t),[t]),[r]=b.useState(()=>new Map),[i,a]=b.useState(null),[o,s]=b.useState(!1),[c,l]=b.useState(0),u=b.useRef(null),d=b.useRef(n);d.current=n;let f=b.useCallback(()=>{let t=e.current;if(!t)return;let n=t.querySelector(`[data-timeline-root]`),i=t.getBoundingClientRect();n&&l(Math.floor(n.getBoundingClientRect().left-i.left));let o=d.current;if(!o.length)return;let c=[...t.querySelectorAll(`[data-timeline-message]`)],u=e=>{let t=null,n=null;return c.forEach((r,a)=>{let o=r.getBoundingClientRect();o.top<i.bottom&&o.bottom>i.top+e&&(t??=a,n=a)}),{start:t,end:n}},f=new Map(c.map((e,t)=>[e.dataset.timelineMessage,t])),p=o.map(e=>f.get(e.id)??e.rowIndex),m=u(0),h=new Map;o.forEach((e,t)=>{let n=r.get(e.id);if(!n)return;let i=VY(p[t],p[t+1],m.start,m.end);h.set(n,i||h.get(n)===!0)});for(let[e,t]of h)e.dataset.inView!==String(t)&&(e.dataset.inView=String(t));let g=u(25),_=HY({visibleStart:g.start,visibleEnd:g.end,rowIndices:p});a(e=>e===_?e:_),s(t.scrollHeight-t.scrollTop-t.clientHeight<=1)},[e,r]),p=b.useCallback(()=>{u.current===null&&(u.current=requestAnimationFrame(()=>{u.current=null,f()}))},[f]);return b.useEffect(()=>{p()},[t,p]),b.useEffect(()=>{let t=e.current;if(!t)return;let n=new ResizeObserver(p);n.observe(t);let r=t.querySelector(`[data-timeline-root]`);return r&&n.observe(r),()=>{n.disconnect(),u.current!==null&&cancelAnimationFrame(u.current)}},[e,p]),{items:n,stripMap:r,current:i,atEnd:o,persistent:UY(c),hitStrip:WY(c),schedule:p,select:t=>{let n=e.current,r=n?.querySelector(`[data-timeline-message="${CSS.escape(t)}"]`);if(!n||!r)return;let i=r.getBoundingClientRect().top-n.getBoundingClientRect().top+n.scrollTop-24;n.scrollTo({top:i,behavior:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches?`auto`:`smooth`})}}}function zX({chatId:e}){let t=Au(),n=U(t.agent.writes.queryOptions({chatId:e})),r=at(t.agent.answerWrite.mutationOptions()),[i,a]=b.useState(Date.now()),o=n.data||[];return b.useEffect(()=>{if(!o.length)return;let e=setInterval(()=>a(Date.now()),1e3);return()=>clearInterval(e)},[o.length]),o.length?(0,x.jsx)(`div`,{className:`mx-auto mb-2 flex w-full max-w-[var(--chat-max)] flex-col gap-2`,children:o.map(e=>(0,x.jsxs)(`div`,{className:`rounded-lg border bg-background p-3 text-xs shadow-xs/5`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-1.5 font-medium`,children:[(0,x.jsx)(Ff,{className:`size-3.5 text-icon-muted`}),`The agent’s browser wants to write to the instance`,(0,x.jsxs)(`span`,{className:`ms-auto font-normal text-muted-foreground tabular-nums`,children:[`declines in `,Eu(Date.parse(e.expiresAt)-i)]})]}),(0,x.jsxs)(`div`,{className:`mt-1.5 font-mono text-[11.5px] text-foreground/85`,children:[e.method,` `,e.table?`${e.table}${e.sysId?`/${e.sysId}`:``}`:e.path,e.action?` · action ${e.action}`:``]}),e.fields&&e.fields.length>0&&(0,x.jsxs)(`div`,{className:`mt-1 text-muted-foreground`,children:[`Fields: `,e.fields.join(`, `)]}),(0,x.jsxs)(`div`,{className:`mt-2.5 flex items-center gap-2`,children:[(0,x.jsx)(_m,{className:`size-3 text-warning-foreground`}),(0,x.jsx)(`span`,{className:`text-warning-foreground`,children:`Waiting for approval`}),(0,x.jsx)(`span`,{className:`ms-auto`}),(0,x.jsx)(q,{size:`xs`,variant:`outline`,onClick:()=>r.mutate({id:e.id,approved:!1}),children:`Decline`}),(0,x.jsx)(q,{size:`xs`,onClick:()=>r.mutate({id:e.id,approved:!0}),children:`Approve`})]})]},e.id))}):null}var BX=new Map,VX=new Map,HX=(e,t,n)=>BX.set(e,{text:t,model:n});function UX(e){let t=rX(e),n=e.input||{};return t===`delete_path`?`delete ${n.path}`:t===`shell`?`run ${String(n.command||``).slice(0,80)}`:`${t.replace(/_/g,` `)} ${n.path||``}`.trim()}function WX({projectId:e,chatId:t}){let n=Au(),r=C(),i=U(n.chats.get.queryOptions({projectId:e,chatId:t})),a=U(n.projects.get.queryOptions({id:e})),o=at(n.chats.visit.mutationOptions()),s=b.useCallback(()=>{o.mutate({projectId:e,chatId:t},{onSuccess:()=>{r.invalidateQueries({queryKey:n.chats.list.queryKey({projectId:e})}),r.invalidateQueries({queryKey:n.chats.recent.pathKey()})}})},[e,t]);return b.useEffect(()=>s(),[s]),i.isLoading?(0,x.jsx)(`div`,{className:`flex-1`}):i.error?(0,x.jsx)(`div`,{className:`p-6 text-sm text-muted-foreground`,children:i.error.message}):(0,x.jsx)(GX,{projectId:e,chatId:t,title:i.data.title,projectName:a.data?.name||``,initial:i.data.messages,initialModel:i.data.model,initialSafety:i.data.safety,serverRunning:i.data.running,onDone:()=>{r.invalidateQueries({queryKey:n.chats.get.queryKey({projectId:e,chatId:t})}),s()}},t)}function GX({projectId:e,chatId:t,title:n,projectName:r,initial:i,initialModel:a,initialSafety:o,serverRunning:s,onDone:c}){let l=Au(),u=C(),[d,f]=b.useState(a),p=b.useRef(d);p.current=d;let m=at(l.chats.setModel.mutationOptions()),h=at(l.chats.stop.mutationOptions()),g=at(l.chats.rewind.mutationOptions()),_=at(l.edits.undoTurn.mutationOptions()),v=Yi(),[y]=b.useState(()=>{let e=VX.get(t)||``;return VX.delete(t),e}),[S,w]=b.useState(o),T=at(l.chats.setSafety.mutationOptions()),[E,D]=b.useState(Date.now()),[O,k]=b.useState(),A=mL({id:t,messages:i,transport:b.useMemo(()=>new tL({api:`/api/chat`,headers:()=>({"x-forge-token":vu()}),prepareSendMessagesRequest:({messages:t,id:n})=>({body:{projectId:e,chatId:n,message:t[t.length-1],model:p.current}}),fetch:(async(e,t)=>{let n=await fetch(e,t);if(!n.ok){let e=`Request failed (${n.status})`,t=``;try{let r=await n.clone().json();e=r.message||e,t=r.code||``}catch{}throw Object.assign(Error(e),{code:t})}return n})}),[e]),sendAutomaticallyWhen:rL,onError:e=>{k(e.message),e.code===`approval_expired`&&j()},onFinish:()=>c()}),j=async()=>{let n=await u.fetchQuery({...l.chats.get.queryOptions({projectId:e,chatId:t}),staleTime:0});A.setMessages(n.messages)},M=A.status===`submitted`||A.status===`streaming`;b.useEffect(()=>{let e=BX.get(t);e&&(BX.delete(t),e.model&&f(e.model),p.current=e.model,D(Date.now()),A.sendMessage({text:e.text}))},[t]);let N=b.useMemo(()=>{let e=A.messages[A.messages.length-1];return!e||e.role!==`assistant`?null:e.parts.find(e=>e.state===`approval-requested`)},[A.messages]),P=N?.approval?{id:N.approval.id,summary:UX(N),always:rX(N)===`shell`&&/^command:/.test(N.approval.requestReason||``)}:null,F=at(l.chats.answerSdk.mutationOptions({onError:e=>{k(e.message),j()}})),I=(n,r,i)=>{k(void 0),n.startsWith(`sdk:`)?F.mutate({chatId:t,projectId:e,approvalId:n,approved:r,always:!!i}):(D(Date.now()),A.addToolApprovalResponse({id:n,approved:r,...i?{reason:`always`}:{}}))},L=([...A.messages].reverse().find(e=>e.metadata?.usage)?.metadata)?.usage?.context||0,R=U(l.chats.get.queryOptions({projectId:e,chatId:t})),z=U(l.chats.usage.queryOptions({projectId:e,chatId:t})),B=U(l.chats.overlaps.queryOptions({projectId:e,chatId:t})),V=at(l.chats.compact.mutationOptions()),H=z.data?.totals,ee=!!H&&H.cost>0,te=!!H&&!ee&&(H.apiEquivalent||0)>0,ne=!H||!H.calls?``:ee?FX(H.cost):te?`~${FX(H.apiEquivalent)}`:`${PX(H.input+H.output)} tokens`,re=H?`This chat: ${PX(H.input)} in (${PX(H.cachedInput)} cached) · ${PX(H.output)} out`+(te?` · API estimate ${FX(H.apiEquivalent)} (subscription: no per-token charge)`:``)+(H.unpricedTokens?` · ${PX(H.unpricedTokens)} tokens without a price (set one in Settings)`:``):``,ie=(B.data||[]).length?(B.data||[]).slice(0,2).map(e=>`${e.path.split(`/`).pop()} is also being changed by “${e.title}”`).join(` · `):void 0,ae=U(l.models.queryOptions()).data?.some(e=>e.connectionId===d?.connectionId&&e.kind===`claude-subscription`),oe=U({...l.claude.status.queryOptions(),enabled:!!ae}),se=ae&&oe.data?.limit?oe.data.limit.message:void 0;return(0,x.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,x.jsx)(qX,{title:n,projectName:r,projectId:e,chatId:t}),(0,x.jsx)(pX.Provider,{value:{projectId:e,chatId:t,onRewind:async n=>{k(void 0);try{let r=await g.mutateAsync({projectId:e,chatId:t,messageId:n});VX.set(r.chatId,r.text),v({to:`/p/$projectId/c/$chatId`,params:{projectId:e,chatId:r.chatId}})}catch(e){k(e.message)}},onUndoTurn:async n=>{let r=await _.mutateAsync({projectId:e,chatId:t,turnId:n});!r.ok&&`conflictPath`in r&&k(`Undo stopped at ${r.conflictPath}: ${r.message}`)},onAnswer:(n,r)=>{k(void 0),A.messages[A.messages.length-1]?.metadata?.runner===`claude`?F.mutate({chatId:t,projectId:e,toolCallId:n,answer:r}):(D(Date.now()),Promise.resolve(A.addToolOutput({tool:`ask`,toolCallId:n,output:{answer:r}})).then(()=>A.sendMessage()))}},children:(0,x.jsx)(LX,{messages:A.messages,running:M,runStarted:E,onApprove:I,error:O,compactions:R.data?.compactions||[],compacting:V.isPending})}),(0,x.jsxs)(`div`,{className:`px-3 pt-1.5 pb-3 sm:px-12 sm:pt-2 sm:pb-4`,children:[(0,x.jsx)(zX,{chatId:t}),(0,x.jsx)(fS,{running:M||!!s,model:d,onModel:n=>{f(n),m.mutate({projectId:e,chatId:t,model:n})},onSend:e=>{k(void 0),D(Date.now()),A.sendMessage({text:e})},onStop:()=>{A.stop(),h.mutate({chatId:t})},initialText:y,safety:S,onSafety:n=>{w(n),T.mutate({projectId:e,chatId:t,safety:n})},pending:M&&!P?.id.startsWith(`sdk:`)?null:P,onAnswer:(e,t)=>P&&I(P.id,e,t),context:L?PX(L):``,onCompact:async()=>{k(void 0);try{await V.mutateAsync({projectId:e,chatId:t})}catch(e){k(e.message)}},compacting:V.isPending,cost:ne,costTip:re,banner:s&&!M?`This chat is still running from before a reload. It appears when it finishes, or Stop it.`:ie||se})]})]})}function KX({title:e,projectId:t,chatId:n}){let r=Au(),i=C(),a=Yi(),[o,s]=b.useState(!1),[c,l]=b.useState(!1),[u,d]=b.useState(!1),f=b.useRef(!1),p=b.useRef(null),m=at(r.chats.rename.mutationOptions({onSettled:()=>i.invalidateQueries({queryKey:r.chats.get.queryKey({projectId:t,chatId:n})})})),h=at(r.chats.delete.mutationOptions()),g=r=>{s(!1);let i=r.trim();i&&i!==e&&m.mutate({projectId:t,chatId:n,title:i})};if(o)return(0,x.jsx)(`input`,{autoFocus:!0,dir:`auto`,"aria-label":`Chat title`,defaultValue:e,onFocus:e=>e.currentTarget.select(),onBlur:e=>{f.current||g(e.currentTarget.value)},onKeyDown:e=>{e.nativeEvent.isComposing||(e.key===`Enter`?(f.current=!0,g(e.currentTarget.value)):e.key===`Escape`&&(e.preventDefault(),f.current=!0,s(!1)))},className:`w-72 max-w-full min-w-0 rounded-sm bg-transparent px-1 text-sm font-medium text-foreground ring-1 ring-ring/50 outline-none ring-inset focus:ring-ring`});let _=()=>{p.current&&clearTimeout(p.current),f.current=!1,d(!1),s(!0)};return(0,x.jsxs)(mb,{open:u,onOpenChange:e=>{e||(d(!1),l(!1))},children:[(0,x.jsxs)(hb,{render:(0,x.jsx)(`button`,{type:`button`,title:e,"aria-label":`Chat actions for ${e}`,onClick:e=>{if(!(e.detail>1)){if(p.current&&clearTimeout(p.current),e.detail===0)return d(!0);p.current=setTimeout(()=>d(!0),220)}},onDoubleClick:e=>{e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||_()},className:`group/title inline-flex max-w-full min-w-0 cursor-pointer items-center gap-1 rounded-sm text-left focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-hidden focus-visible:ring-inset`}),children:[(0,x.jsx)(`h2`,{className:`min-w-0 truncate text-foreground`,children:e}),(0,x.jsx)(Pd,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-muted-foreground opacity-0 transition-opacity group-hover/title:opacity-100 group-focus-visible/title:opacity-100`})]}),(0,x.jsxs)(gb,{align:`start`,sideOffset:4,children:[(0,x.jsxs)(_b,{onClick:_,children:[(0,x.jsx)(Lp,{}),` Rename`]}),(0,x.jsx)(yb,{}),(0,x.jsxs)(_b,{closeOnClick:c,onClick:()=>{if(!c)return l(!0);h.mutate({projectId:t,chatId:n},{onSuccess:()=>a({to:`/p/$projectId`,params:{projectId:t}})})},className:`text-destructive data-[highlighted]:text-destructive`,children:[(0,x.jsx)(Fm,{}),` `,c?`Click again to delete`:`Delete chat`]})]})]})}function qX({title:e,projectName:t,projectId:n,chatId:r}){let i=Gu();return(0,x.jsxs)(`header`,{className:`flex h-[var(--topbar-h)] shrink-0 items-center gap-2 px-3 sm:px-5`,children:[!i.sidebarOpen&&(0,x.jsx)(Tb,{label:`Show sidebar`,children:(0,x.jsx)(q,{variant:`ghost`,size:`icon-sm`,onClick:()=>Wu({sidebarOpen:!0}),children:(0,x.jsx)(kp,{})})}),(0,x.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-sm font-medium sm:gap-3`,children:[(0,x.jsx)(`span`,{className:`truncate text-muted-foreground`,children:t}),(0,x.jsx)(`span`,{className:`text-icon-muted`,children:`/`}),r?(0,x.jsx)(KX,{title:e,projectId:n,chatId:r}):(0,x.jsx)(`span`,{className:`truncate text-foreground`,children:e})]}),(0,x.jsx)(`div`,{className:`ms-2 min-w-0 flex-1`,children:(0,x.jsx)(l8,{projectId:n})}),(0,x.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,x.jsx)(Tb,{label:`Check the workspace (Push plan tab)`,children:(0,x.jsx)(q,{variant:`ghost`,size:`icon-sm`,"aria-label":`Check`,onClick:()=>Wu({panelOpen:!0,panelTab:`plan`}),children:(0,x.jsx)(Bd,{})})}),(0,x.jsx)(Tb,{label:`Push to the instance (review the plan first)`,children:(0,x.jsx)(q,{variant:`ghost`,size:`icon-sm`,"aria-label":`Push`,onClick:()=>Wu({pushOpen:!0}),children:(0,x.jsx)(zm,{})})}),(0,x.jsx)(`span`,{className:`mx-1 h-4 w-px bg-border`,"aria-hidden":!0}),(0,x.jsx)(Tb,{label:`Terminal (${Du?`⌘`:`Ctrl`}+\`)`,children:(0,x.jsx)(q,{variant:`ghost`,size:`icon-sm`,"aria-label":`Toggle terminal`,"aria-pressed":i.drawerOpen,onClick:()=>Wu({drawerOpen:!i.drawerOpen}),className:i.drawerOpen?`bg-accent [&_svg]:text-foreground`:``,children:(0,x.jsx)(Dp,{})})}),(0,x.jsx)(Tb,{label:`Toggle the right panel`,children:(0,x.jsx)(q,{variant:`ghost`,size:`icon-sm`,"aria-pressed":i.panelOpen,onClick:()=>Wu({panelOpen:!i.panelOpen}),className:i.panelOpen?`bg-accent [&_svg]:text-foreground`:``,children:(0,x.jsx)(jp,{})})})]})]})}function JX(e){let t=Au(),n=Yi(),r=at(t.chats.create.mutationOptions());return async(t,i)=>{let a=await r.mutateAsync({projectId:e});HX(a.id,t,i),n({to:`/p/$projectId/c/$chatId`,params:{projectId:e,chatId:a.id}})}}var YX=500,XX=new Map,ZX=new Set,QX=0,$X=(e,t)=>`${e}\u0000${t}`;function eZ(){QX+=1;for(let e of ZX)e()}async function tZ(e){if(e.saving||e.latest===null||e.problem)return;e.saving=!0;let t=e.latest;try{e.baseHash=(await Ou.files.write.mutate({projectId:e.projectId,path:e.path,content:t,baseHash:e.baseHash})).hash,e.latest===t&&(e.latest=null)}catch(t){let n=t;e.problem={kind:n.data?.code===`CONFLICT`?`conflict`:`failed`,message:n.message||`The file could not be saved`}}finally{e.saving=!1,eZ()}e.latest!==null&&!e.problem&&!e.timer&&tZ(e)}function nZ(e,t,n){let r=$X(e,t),i=XX.get(r);i?i.latest===null&&!i.saving&&(i.baseHash=n):XX.set(r,{projectId:e,path:t,baseHash:n,latest:null,timer:null,saving:!1,problem:null})}function rZ(e,t,n){let r=XX.get($X(e,t));r&&(r.latest=n,r.timer&&clearTimeout(r.timer),r.timer=setTimeout(()=>{r.timer=null,tZ(r)},YX),eZ())}function iZ(e,t){let n=XX.get($X(e,t));n&&(n.timer&&=(clearTimeout(n.timer),null),tZ(n))}function aZ(e,t,n,r){let i=XX.get($X(e,t));i&&(i.problem=null,n===`reload`?(i.latest=null,i.timer&&clearTimeout(i.timer),i.timer=null,XX.delete($X(e,t)),eZ()):(r!==void 0&&(i.baseHash=r),eZ(),tZ(i)))}function oZ(e,t){let n=XX.get($X(e,t));return!!n&&(n.latest!==null||n.saving)}function sZ(e,t){return XX.get($X(e,t))?.latest??null}function cZ(e){return ZX.add(e),()=>ZX.delete(e)}function lZ(){return(0,b.useSyncExternalStore)(cZ,()=>QX)}function uZ(e,t){return lZ(),XX.get($X(e,t))?.problem??null}typeof window<`u`&&window.addEventListener(`pagehide`,()=>{for(let e of XX.values())e.latest!==null&&iZ(e.projectId,e.path)});var dZ=700;function fZ(e){return e?1:.35}function pZ({frame:e,pointer:t}){let n=b.useRef(null),[r,i]=b.useState(0);b.useLayoutEffect(()=>{let e=n.current;if(!e)return;let t=new ResizeObserver(()=>i(e.clientWidth));return t.observe(e),i(e.clientWidth),()=>t.disconnect()},[]);let a=e.width?r/e.width:1;return(0,x.jsxs)(`div`,{className:`relative max-w-full`,children:[(0,x.jsx)(`img`,{ref:n,src:`data:image/jpeg;base64,${e.data}`,alt:`Live view of the agent’s browser`,className:`block max-w-full rounded-lg border bg-white shadow-xs/5`,style:{aspectRatio:`${e.width} / ${e.height}`}}),t&&r?(0,x.jsx)(mZ,{phase:t.phase,sequence:t.sequence,left:t.x*a+1,top:t.y*a+1}):null]})}function mZ({phase:e,sequence:t,left:n,top:r}){let[i,a]=b.useState(null);return b.useEffect(()=>{let e=window.setTimeout(()=>a(t),dZ);return()=>window.clearTimeout(e)},[t]),(0,x.jsxs)(`div`,{className:`pointer-events-none absolute top-0 left-0 z-40 transition-[opacity,transform] duration-150 ease-out motion-reduce:transition-none`,style:{opacity:fZ(i!==t),transform:`translate3d(${n}px, ${r}px, 0)`},"aria-hidden":`true`,"data-agent-cursor":!0,children:[e===`click`?(0,x.jsx)(`span`,{className:`absolute top-0.5 left-0.5 size-4 animate-status-ping rounded-full bg-primary/25 motion-reduce:animate-none`},t):null,(0,x.jsx)(yp,{className:`relative size-5 -translate-x-0.5 -translate-y-0.5 fill-background stroke-2 text-primary drop-shadow-sm`})]})}function hZ({projectId:e}){let t=Au(),n=U(t.agent.info.queryOptions({projectId:e})),r=at(t.agent.openWindow.mutationOptions()),[i,a]=b.useState(null),[o,s]=b.useState(null),c=!!n.data?.running;return Ic(t.agent.frames.subscriptionOptions({projectId:e},{enabled:c&&n.data?.headless!==!1,onData:e=>`pointer`in e?s(e.pointer):a(e)})),c?(0,x.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,x.jsxs)(`div`,{className:`flex h-9 shrink-0 items-center gap-2 border-b px-2`,children:[(0,x.jsx)(kb,{variant:`info`,children:`Read-only`}),(0,x.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-muted-foreground`,children:i?.url||``}),n.data?.headless===!1?(0,x.jsxs)(q,{size:`xs`,variant:`outline`,disabled:r.isPending,onClick:()=>r.mutate({projectId:e,headless:!0}),children:[(0,x.jsx)(pf,{}),` Back to headless`]}):(0,x.jsxs)(q,{size:`xs`,variant:`outline`,disabled:r.isPending,onClick:()=>r.mutate({projectId:e,headless:!1}),children:[(0,x.jsx)(md,{}),` Open window`]})]}),(0,x.jsx)(`div`,{className:`flex min-h-0 flex-1 items-start justify-center overflow-auto bg-muted p-3`,children:n.data?.headless===!1?(0,x.jsx)(b8,{icon:md,title:`Showing in a window`,children:`The agent’s browser is open as a window on your desktop. Switch back to headless to watch it here.`}):i?(0,x.jsx)(pZ,{frame:i,pointer:o}):(0,x.jsxs)(`div`,{className:`flex h-full items-center gap-2 text-xs text-muted-foreground`,children:[(0,x.jsx)(Yb,{size:`sm`,muted:!0}),` Waiting for the first frame…`]})})]}):(0,x.jsx)(b8,{icon:xp,title:`The agent’s browser`,children:`It starts the first time the agent opens a page of the preview. Here you watch it live: it looks and clicks, and it can’t change instance data unless you allow browser writes for the chat.`})}var gZ=b.lazy(()=>NJ(()=>import(`./terminal-view-BdvNEDWd.js`),__vite__mapDeps([10,11])));function _Z({projectId:e,autoCreate:t}){let n=Au(),r=C(),i=Gu(),a=U(n.terminals.list.queryOptions({projectId:e})),o=at(n.terminals.create.mutationOptions({onSuccess:t=>{r.invalidateQueries({queryKey:n.terminals.list.queryKey({projectId:e})}),Wu({activeTerminal:t.id})}})),s=at(n.terminals.close.mutationOptions({onSuccess:()=>r.invalidateQueries({queryKey:n.terminals.list.queryKey({projectId:e})})})),c=a.data||[],l=c.find(e=>e.id===i.activeTerminal)||c.filter(e=>e.kind===`shell`)[0]||c[0];return b.useEffect(()=>{t&&a.data&&!a.data.some(e=>e.kind===`shell`)&&!o.isPending&&o.mutate({projectId:e})},[t,a.data]),(0,x.jsxs)(`div`,{className:`flex h-full min-h-0`,children:[(0,x.jsx)(`div`,{className:`relative min-w-0 flex-1`,children:l?(0,x.jsx)(b.Suspense,{fallback:(0,x.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,x.jsx)(Yb,{size:`sm`,muted:!0})}),children:(0,x.jsx)(gZ,{sessionId:l.id},l.id)}):a.isLoading?null:(0,x.jsx)(b8,{icon:Cm,title:`No terminal yet`,children:`A shell in the project folder. The agent’s commands show here too, read-only, while they run.`})}),(0,x.jsxs)(`div`,{className:`flex w-36 shrink-0 flex-col border-l border-border/80 py-1`,children:[c.map(e=>(0,x.jsxs)(`div`,{className:G(`group mx-1 flex h-[22px] cursor-pointer items-center gap-1.5 rounded px-1.5 text-2xs`,e.id===l?.id?`bg-accent text-foreground`:`text-muted-foreground hover:bg-accent/60`),onClick:()=>Wu({activeTerminal:e.id}),title:e.title,children:[e.kind===`command`?(0,x.jsx)(hf,{className:`size-3 shrink-0`}):(0,x.jsx)(Cm,{className:`size-3 shrink-0`}),(0,x.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono`,children:e.title}),e.exitCode!==null&&(0,x.jsx)(`span`,{className:G(`tabular-nums`,e.exitCode?`text-destructive-foreground`:`text-success-foreground`),children:e.exitCode}),(0,x.jsx)(`button`,{"aria-label":`Close`,onClick:t=>{t.stopPropagation(),s.mutate({id:e.id})},className:`hidden size-4 items-center justify-center rounded text-muted-foreground group-hover:inline-flex hover:text-foreground`,children:(0,x.jsx)(Gm,{className:`size-3`})})]},e.id)),(0,x.jsx)(Tb,{label:`New terminal`,children:(0,x.jsxs)(`button`,{onClick:()=>o.mutate({projectId:e}),className:`mx-1 mt-0.5 flex h-[22px] items-center gap-1.5 rounded px-1.5 text-2xs text-muted-foreground hover:bg-accent/60 hover:text-foreground`,children:[(0,x.jsx)(qp,{className:`size-3`}),` New`]})})]})]})}function vZ({projectId:e}){let t=Gu();return t.drawerOpen?(0,x.jsxs)(`div`,{className:`relative shrink-0 border-t border-border/80 bg-background`,style:{height:t.drawerHeight},children:[(0,x.jsx)(`div`,{onPointerDown:e=>{e.preventDefault();let t=e=>{let t=window.innerHeight-e.clientY;Wu({drawerHeight:Math.min(window.innerHeight*.75,Math.max(180,t))})},n=()=>{window.removeEventListener(`pointermove`,t),window.removeEventListener(`pointerup`,n),document.body.style.cursor=``};document.body.style.cursor=`row-resize`,window.addEventListener(`pointermove`,t),window.addEventListener(`pointerup`,n)},className:`group absolute -top-2 left-0 z-10 flex h-4 w-full cursor-row-resize items-center`,children:(0,x.jsx)(`div`,{className:`h-0.5 w-full transition-colors group-hover:bg-border`})}),(0,x.jsx)(_Z,{projectId:e,autoCreate:!0})]}):null}var yZ={layout:`stacked`,ignoreWhitespace:!1,colors:`red-green`};function bZ(){let e=U(Au().settings.get.queryOptions());return{...yZ,...e.data?.diffs||{}}}var xZ=b.lazy(()=>NJ(()=>import(`./diff-view-KCzB8C4U.js`),__vite__mapDeps([8,9,3,1,5])));function SZ({projectId:e}){let t=Au(),n=Gu(),r=bZ().layout===`split`,i=at(t.settings.setDiffs.mutationOptions()),{chatId:a=``}=qi({strict:!1}),o=n.diffScope,s=U(t.diffs.files.queryOptions({projectId:e,chatId:a,scope:o})),c=s.data||[],l=c.find(e=>e.path===n.diffPath)||c[0],u=U({...t.diffs.file.queryOptions({projectId:e,chatId:a,scope:o,path:l?.path||``}),enabled:!!l}),d=at(t.diffs.accept.mutationOptions()),f=at(t.diffs.revert.mutationOptions());return(0,x.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,x.jsxs)(`div`,{className:`flex h-9 shrink-0 items-center gap-1 border-b px-2`,children:[(0,x.jsx)(`div`,{className:`inline-flex rounded-md bg-accent p-0.5`,children:[{id:`turn`,label:`This turn`},{id:`session`,label:`Session`},{id:`instance`,label:`vs instance`},{id:`head`,label:`vs git HEAD`}].map(e=>(0,x.jsx)(`button`,{onClick:()=>Wu({diffScope:e.id}),className:G(`h-5 rounded px-2 text-2xs`,o===e.id?`bg-background font-medium text-foreground shadow-xs/5`:`text-muted-foreground hover:text-foreground`),children:e.label},e.id))}),(0,x.jsx)(`span`,{className:`ms-auto`}),(0,x.jsx)(`div`,{className:`inline-flex rounded-md bg-accent p-0.5`,children:[`unified`,`split`].map(e=>(0,x.jsx)(`button`,{onClick:()=>i.mutate({layout:e===`split`?`split`:`stacked`}),className:G(`h-5 rounded px-2 text-2xs capitalize`,r===(e===`split`)?`bg-background font-medium text-foreground shadow-xs/5`:`text-muted-foreground hover:text-foreground`),children:e},e))})]}),s.isLoading?(0,x.jsx)(`div`,{className:`flex flex-1 items-center justify-center`,children:(0,x.jsx)(Yb,{size:`sm`,muted:!0})}):c.length?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`div`,{className:`max-h-[40%] shrink-0 overflow-y-auto border-b py-1`,children:c.map(t=>(0,x.jsxs)(`div`,{onClick:()=>Wu({diffPath:t.path}),className:G(`group mx-1 flex h-7 cursor-pointer items-center gap-2 rounded-md px-2 text-[13px]`,t.path===l?.path?`bg-accent`:`hover:bg-accent/60`),children:[(0,x.jsx)(Tb,{label:t.origin===`outside`?`Changed outside Forge`:t.origin===`git`?`git status`:`Edited by the agent`,children:(0,x.jsx)(`span`,{className:`flex size-4 items-center justify-center text-icon-muted`,children:t.origin===`outside`?(0,x.jsx)(zf,{className:`size-3.5`}):(0,x.jsx)(xm,{className:`size-3.5`})})}),(0,x.jsx)(`span`,{className:G(`min-w-0 flex-1 truncate font-mono text-xs`,t.status===`deleted`&&`line-through opacity-70`),children:t.path}),t.status!==`modified`&&(0,x.jsx)(`span`,{className:`text-2xs text-muted-foreground`,children:t.status}),(0,x.jsx)(yX,{added:t.added,removed:t.removed}),o===`session`&&a&&(0,x.jsxs)(`span`,{className:`hidden items-center gap-1 group-hover:flex`,children:[(0,x.jsx)(q,{size:`xs`,variant:`ghost-muted`,onClick:n=>{n.stopPropagation(),f.mutate({projectId:e,chatId:a,path:t.path})},children:`Revert`}),(0,x.jsx)(q,{size:`xs`,variant:`outline`,onClick:n=>{n.stopPropagation(),d.mutate({projectId:e,chatId:a,path:t.path})},children:`Accept`})]})]},t.path))}),(0,x.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:[l&&(0,x.jsxs)(`div`,{className:`flex h-8 items-center gap-2 border-b px-3 text-xs`,children:[(0,x.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono`,children:l.path}),l.status!==`deleted`&&(0,x.jsx)(q,{size:`xs`,variant:`ghost`,onClick:()=>Xu(l.path),children:`Edit`})]}),u.data?(0,x.jsx)(b.Suspense,{fallback:(0,x.jsx)(`div`,{className:`flex h-20 items-center justify-center`,children:(0,x.jsx)(Yb,{size:`sm`,muted:!0})}),children:(0,x.jsx)(xZ,{path:u.data.path,oldText:u.data.old,newText:u.data.new,split:r})}):null]})]}):(0,x.jsx)(b8,{icon:_f,title:`No changes`,children:o===`head`?`Nothing differs from git HEAD (or this folder isn’t a git repository).`:o===`instance`?`The files match the instance base (the last pull or push), or this folder has no base yet.`:a?`The agent’s edits in this chat show here, with undo.`:`Open a chat to see its changes.`})]})}var CZ=`flex h-10 min-h-10 shrink-0 items-center gap-2 border-b border-border/60 bg-background px-3`;function wZ({label:e,pressed:t,disabled:n,onPress:r,children:i}){return(0,x.jsx)(Tb,{label:e,children:(0,x.jsx)(`button`,{type:`button`,"aria-label":e,"aria-pressed":t,"data-pressed":t?``:void 0,disabled:n,onClick:r,className:G(`relative inline-flex size-7 shrink-0 cursor-pointer items-center justify-center rounded-md text-foreground outline-none transition-colors hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset disabled:pointer-events-none disabled:text-muted-foreground [&_svg]:size-3.5 [&_svg]:opacity-80`,t&&`bg-accent text-accent-foreground [&_svg]:opacity-100`),children:i})})}function TZ({className:e}){return(0,x.jsx)(`div`,{role:`status`,"aria-label":`Loading file`,className:G(`flex min-h-0 flex-1 items-center justify-center text-muted-foreground`,e),children:(0,x.jsx)(Yb,{size:`lg`})})}function EZ({message:e,onRetry:t}){return(0,x.jsxs)(`div`,{role:`alert`,className:`flex min-h-0 flex-1 flex-col items-center justify-center gap-3 px-6 text-center text-xs leading-relaxed`,children:[(0,x.jsx)(`p`,{className:`text-destructive-foreground`,children:e}),t&&(0,x.jsx)(`button`,{type:`button`,onClick:t,className:`cursor-pointer rounded-md border border-input px-2.5 py-1 text-xs text-foreground hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset`,children:`Try again`})]})}function DZ({tone:e=`warning`,children:t}){return(0,x.jsx)(`div`,{role:`status`,className:G(`flex shrink-0 items-center gap-2 border-b px-3 py-1.5 text-[11px]`,e===`warning`&&`border-warning/20 bg-warning/8 text-warning-foreground`,e===`error`&&`border-destructive/20 bg-destructive/8 text-destructive-foreground`,e===`muted`&&`text-muted-foreground`),children:t})}function OZ({at:e,items:t,onPick:n,onClose:r}){let i=b.useMemo(()=>e?{getBoundingClientRect:()=>DOMRect.fromRect({x:e.x,y:e.y,width:0,height:0})}:null,[e]);return(0,x.jsx)(I3,{open:!!e,onOpenChange:e=>!e&&r(),children:(0,x.jsx)(A4,{children:(0,x.jsx)(b3,{anchor:i,side:`bottom`,align:`start`,sideOffset:2,className:`z-50 outline-none`,children:(0,x.jsx)(D4,{className:`glass min-w-44 origin-[var(--transform-origin)] rounded-lg p-1 text-sm outline-none transition-[opacity,scale] duration-150 data-[ending-style]:scale-98 data-[ending-style]:opacity-0 data-[starting-style]:scale-98 data-[starting-style]:opacity-0`,children:t.map(e=>(0,x.jsxs)(b.Fragment,{children:[e.separated&&(0,x.jsx)(Y3,{className:`mx-2 my-1 h-px bg-border`}),(0,x.jsx)(i1,{disabled:e.disabled,onClick:()=>n(e.id),className:`flex min-h-7 cursor-default items-center gap-2 rounded-sm px-2 py-1 outline-none select-none data-[disabled]:opacity-50 data-[highlighted]:bg-accent`,children:e.label})]},e.id))})})})})}function kZ(e){return e.files&&Object.keys(e.files).length?Object.entries(e.files).map(([e,t])=>`${e} ${t}`).join(`, `):[e.change,e.renamedFrom&&`from ${e.renamedFrom}`,e.renamedTo&&`to ${e.renamedTo}`,e.note].filter(Boolean).join(` · `)}function AZ({projectId:e}){let t=Au(),n=U(t.push.state.queryOptions({projectId:e})),r=at(t.push.status.mutationOptions()),i=at(t.push.check.mutationOptions()),a=at(t.push.resolve.mutationOptions({onSuccess:()=>r.mutate({projectId:e})})),[o,s]=b.useState(``);b.useEffect(()=>{r.mutate({projectId:e})},[e]);let c=n.data?.push?.at;b.useEffect(()=>{c&&r.mutate({projectId:e})},[c]);let l=r.data,u=i.data,d=n.data?.plan,f=n.data?.push,p=a.isPending?a.variables?.keys[0]:``,m=(t,n,r,i)=>(0,x.jsx)(Tb,{label:i,children:(0,x.jsx)(q,{size:`xs`,variant:`ghost-muted`,disabled:!!p,onClick:r=>{r.stopPropagation(),a.mutate({projectId:e,keys:[t],action:n})},children:r})}),h=(t,n,r,i={})=>n&&n.length>0?(0,x.jsxs)(`section`,{children:[(0,x.jsxs)(`div`,{className:G(`mb-1 px-2 text-xs font-medium`,r),children:[t,` `,(0,x.jsx)(`span`,{className:`text-muted-foreground tabular-nums`,children:n.length})]}),(0,x.jsx)(`div`,{className:`flex flex-col`,children:n.slice(0,200).map(t=>(0,x.jsxs)(b.Fragment,{children:[(0,x.jsxs)(`div`,{onClick:i.expandable?()=>s(o===t.key?``:t.key):void 0,className:G(`group flex h-7 items-center gap-2 rounded-md px-2 text-[13px] hover:bg-accent/60`,i.expandable&&`cursor-pointer`),children:[i.expandable&&(0,x.jsx)(Id,{className:G(`size-3 shrink-0 text-icon-muted/70 transition-transform duration-200`,o===t.key&&`rotate-90`)}),(0,x.jsx)(`span`,{className:`min-w-0 shrink truncate font-mono text-xs`,children:t.key}),(0,x.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-muted-foreground`,children:kZ(t)}),t.updatedBy&&(0,x.jsx)(`span`,{className:`shrink-0 text-2xs text-muted-foreground group-hover:hidden`,children:t.updatedBy}),p===t.key&&(0,x.jsx)(Yb,{size:`xs`,muted:!0}),i.actions&&(0,x.jsx)(`span`,{className:`hidden gap-0.5 group-hover:flex`,children:i.actions(t.key)})]}),i.expandable&&o===t.key&&(0,x.jsx)(MZ,{projectId:e,entry:t})]},t.key))})]}):null;return(0,x.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,x.jsxs)(`div`,{className:`flex h-9 shrink-0 items-center gap-1.5 border-b px-2`,children:[(0,x.jsxs)(q,{size:`xs`,variant:`outline`,disabled:r.isPending,onClick:()=>r.mutate({projectId:e}),children:[r.isPending?(0,x.jsx)(Yb,{size:`xs`}):(0,x.jsx)(Yp,{}),` Status`]}),(0,x.jsxs)(q,{size:`xs`,variant:`outline`,disabled:i.isPending,onClick:()=>i.mutate({projectId:e}),children:[i.isPending?(0,x.jsx)(Yb,{size:`xs`}):(0,x.jsx)(Bd,{}),` Check`]}),(0,x.jsx)(Tb,{label:`Diff the files against the instance base (the last pull or push)`,children:(0,x.jsxs)(q,{size:`xs`,variant:`ghost-muted`,onClick:()=>Wu({panelTab:`diff`,diffScope:`instance`}),children:[(0,x.jsx)(_f,{}),` vs instance`]})}),(0,x.jsx)(`span`,{className:`ms-auto`}),(0,x.jsxs)(q,{size:`xs`,disabled:n.data?.running,onClick:()=>Wu({pushOpen:!0}),children:[n.data?.running?(0,x.jsx)(Yb,{size:`xs`}):(0,x.jsx)(zm,{}),` Plan push…`]})]}),(0,x.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-1 py-3 text-sm`,children:[r.error&&(0,x.jsx)(`div`,{className:`mx-2 mb-3 rounded-lg border border-destructive/30 bg-destructive/6 px-3 py-2 text-xs text-destructive-foreground`,children:r.error.message}),r.isPending&&!l&&(0,x.jsx)(`div`,{className:`flex items-center justify-center py-10`,children:(0,x.jsx)(Yb,{size:`sm`,muted:!0})}),l&&(0,x.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-1.5 px-2`,children:[l.clean?(0,x.jsx)(kb,{variant:`success`,children:`clean`}):(0,x.jsx)(kb,{variant:`warning`,children:`changes`}),[`local`,`instance`,`conflicts`].map(e=>l.counts?.[e]?(0,x.jsxs)(kb,{variant:e===`conflicts`?`error`:`outline`,children:[l.counts[e],` `,e===`conflicts`&&l.counts[e]===1?`conflict`:e]},e):null),(0,x.jsxs)(`span`,{className:`min-w-0 truncate text-xs text-muted-foreground`,children:[[l.on,l.app,l.updateSet].filter(Boolean).join(` · `),l.syncedAt?` · synced ${bu(l.syncedAt)}`:``]})]}),l&&l.clean&&!u&&(0,x.jsx)(b8,{icon:Bd,title:`In sync with the instance`,children:`The files match the instance base. Edits show here as local changes, ready to push.`}),(0,x.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[h(`Conflicts`,l?.conflicts,`text-destructive-foreground`,{expandable:!0,actions:e=>(0,x.jsxs)(x.Fragment,{children:[m(e,`take-local`,`Keep mine`,`Keep the files; the next push overwrites the instance`),m(e,`take-instance`,`Take instance`,`Replace the files with the instance’s version`),m(e,`merge`,`Merge`,`Three-way merge; leaves conflict markers where both changed`)]})}),h(`Local changes (to push)`,l?.local,`text-info-foreground`),h(`Instance changes (a pull takes them)`,l?.instance,`text-warning-foreground`,{actions:e=>m(e,`take-instance`,`Take instance`,`Bring this change into the files`)}),(l?.hints||[]).map(e=>(0,x.jsxs)(`div`,{className:`mx-2 text-xs text-muted-foreground`,children:[`· `,e]},e)),(l?.markers||[]).length>0&&(0,x.jsxs)(`div`,{className:`mx-2 text-xs text-warning-foreground`,children:[`Conflict markers left in: `,l.markers.join(`, `)]})]}),a.error&&(0,x.jsx)(`div`,{className:`mx-2 mt-2 text-xs text-destructive-foreground`,children:a.error.message}),i.error&&(0,x.jsx)(`div`,{className:`mx-2 mt-3 text-xs text-destructive-foreground`,children:i.error.message}),u&&(0,x.jsx)(jZ,{c:u}),(d||f)&&(0,x.jsxs)(`div`,{className:`mx-2 mt-4 flex flex-col gap-1 border-t pt-3 text-xs text-muted-foreground`,children:[d&&(0,x.jsxs)(`div`,{children:[`Latest dry run `,bu(d.at),`:`,` `,(0,x.jsx)(`span`,{className:`font-mono`,children:d.result?.planHash||`—`}),d.stale&&(0,x.jsx)(`span`,{className:`text-warning-foreground`,children:` · files changed since`})]}),f&&(0,x.jsxs)(`div`,{children:[`Last push `,bu(f.at),`:`,` `,f.result.failed?`failed in chunk ${f.result.failed.chunk} of ${f.result.failed.of}`:f.result.refused?`refused (${f.result.reason})`:`${f.result.pushed} written`,f.commit?` · git: ${f.commit.message}`:``]})]})]})]})}function jZ({c:e}){let t=e.local?.prettier?.unformatted||[],n=e.instance?.compiles||[],r=n.filter(e=>!e.ok);return(0,x.jsxs)(`div`,{className:`mx-2 mt-4 rounded-lg border p-3`,children:[(0,x.jsxs)(`div`,{className:G(`flex items-center gap-2 font-medium`,e.ok?`text-success-foreground`:`text-warning-foreground`),children:[e.ok?(0,x.jsx)(Bd,{className:`size-4`}):(0,x.jsx)(Wd,{className:`size-4`}),e.ok?`Check passed`:`Check found ${e.problems.length} problem${e.problems.length===1?``:`s`}`,e.ms?(0,x.jsxs)(`span`,{className:`ms-auto text-xs font-normal text-muted-foreground`,children:[(e.ms/1e3).toFixed(1),` s`]}):null]}),(e.problems||[]).map((e,t)=>(0,x.jsxs)(`div`,{className:`mt-1 text-xs`,children:[`· `,e]},t)),t.length>0&&(0,x.jsxs)(`div`,{className:`mt-2 text-xs text-muted-foreground`,children:[`Not Prettier-formatted: `,(0,x.jsx)(`span`,{className:`font-mono`,children:t.join(`, `)})]}),r.map((e,t)=>(0,x.jsxs)(`div`,{className:`mt-1 font-mono text-xs text-destructive-foreground`,children:[e.component||e.uid,`: `,e.error||e.message||`does not compile`]},t)),e.ok&&(0,x.jsxs)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:[`Prettier, lint, `,n.length,` compile`,n.length===1?``:`s`,` on the instance, the dry run`,e.updateSet?` and the update set`:``,`: all clear.`]})]})}function MZ({projectId:e,entry:t}){let n=U(Au().push.diff.queryOptions({projectId:e,keys:[t.key]})),r=n.data?.entries||[];return(0,x.jsxs)(`div`,{className:`ms-7 me-2 mb-2 rounded-lg border bg-muted/30 p-2 text-xs`,children:[n.isLoading&&(0,x.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,x.jsx)(Yb,{size:`xs`,muted:!0}),` Reading both sides…`]}),n.error&&(0,x.jsx)(`div`,{className:`text-destructive-foreground`,children:n.error.message}),!n.isLoading&&!r.length&&!n.error&&(0,x.jsx)(`div`,{className:`text-muted-foreground`,children:`No content difference to show (metadata only).`}),r.map(e=>(0,x.jsxs)(`div`,{className:`mb-2 last:mb-0`,children:[r.length>1&&(0,x.jsx)(`div`,{className:`mb-1 font-mono text-muted-foreground`,children:e.id}),e.note&&(0,x.jsx)(`div`,{className:`mb-1 text-warning-foreground`,children:e.note}),(0,x.jsx)(`div`,{className:`grid gap-2 md:grid-cols-2`,children:(e.diffs||[]).map((e,t)=>(0,x.jsxs)(`div`,{className:`min-w-0 rounded-md border bg-background`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b px-2 py-1 text-2xs font-medium text-muted-foreground`,children:[e.to===`instance`?(0,x.jsx)(Xd,{className:`size-3`}):(0,x.jsx)(Nf,{className:`size-3`}),e.from,` → `,e.to===`local`?`mine`:e.to]}),(0,x.jsx)(NZ,{d:e})]},t))})]},e.id))]})}function NZ({d:e}){return e.unavailable?(0,x.jsx)(`div`,{className:`px-2 py-1.5 text-muted-foreground`,children:e.unavailable}):e.binary?(0,x.jsx)(`div`,{className:`px-2 py-1.5 text-muted-foreground`,children:`binary file changed`}):e.created?(0,x.jsx)(`div`,{className:`px-2 py-1.5 text-success-foreground`,children:`created`}):e.removed?(0,x.jsx)(`div`,{className:`px-2 py-1.5 text-destructive-foreground`,children:`removed`}):Array.isArray(e.fields)?(0,x.jsx)(`div`,{className:`px-2 py-1.5 font-mono`,children:e.fields.map(t=>(0,x.jsxs)(`div`,{className:`truncate`,children:[(0,x.jsxs)(`span`,{className:`text-muted-foreground`,children:[t.path,`: `]}),(0,x.jsx)(`span`,{className:`text-destructive-foreground line-through decoration-destructive/40`,children:PZ(t[e.from])}),` `,(0,x.jsx)(`span`,{className:`text-success-foreground`,children:PZ(t[e.to])})]},t.path))}):typeof e.diff==`string`?(0,x.jsx)(`pre`,{className:`max-h-64 overflow-auto px-2 py-1.5 font-mono text-2xs leading-relaxed`,children:e.diff.split(`
|
|
288
|
+
`),v=d?c.filter((e,t)=>a||!d.has(t)):c,y=[...v].reverse().find(e=>e.kind===`text`),S=!!y&&v.indexOf(y)<v.length-1,C=i&&(_.trim()||g)?{at:m||p,text:_}:null,w=e=>{switch(e.kind){case`text`:return C&&e===y&&!S?(0,x.jsxs)(`div`,{className:`group/assistant relative min-w-0 px-1 py-0.5 pb-2`,children:[(0,x.jsx)(oY,{text:e.text}),(0,x.jsx)(xY,{className:`mt-1.5`,at:C.at,text:C.text,status:g})]},e.key):(0,x.jsx)(`div`,{className:`px-1 py-0.5 pb-2`,children:(0,x.jsx)(oY,{text:e.text})},e.key);case`reasoning`:return(0,x.jsx)(DX,{text:e.text,live:e.live},e.key);case`tool`:return rX(e.part)===`ask`?(0,x.jsx)(_X,{part:e.part},e.key):(0,x.jsx)(TX,{part:e.part,at:u,onApprove:(t,r)=>e.part.approval&&n(e.part.approval.id,t,r)},e.key);case`group`:return(0,x.jsx)(EX,{parts:e.parts,at:u},e.key)}},T=C&&(S||!y)?(0,x.jsx)(`div`,{className:`px-1`,children:(0,x.jsx)(xY,{className:`mt-0.5`,at:C.at,text:C.text,status:g,alwaysVisible:!0})}):null;return d?(0,x.jsxs)(`div`,{className:`flex flex-col pb-4`,"data-timeline-message":e.id,children:[(0,x.jsx)(jX,{label:h,at:u,open:a,onToggle:()=>o(!a),onUndo:l&&r?()=>s(r):void 0,usage:e.metadata?.usage}),(0,x.jsxs)(`div`,{className:`pt-2`,children:[c.filter((e,t)=>a||!d.has(t)).map(w),!a&&f&&(0,x.jsx)(dX,{part:f}),T]})]}):(0,x.jsxs)(`div`,{className:`flex flex-col pb-4`,"data-timeline-message":e.id,children:[c.map(w),T]})}function NX({since:e}){let[t,n]=b.useState(Date.now());return b.useEffect(()=>{let e=setInterval(()=>n(Date.now()),500);return()=>clearInterval(e)},[]),(0,x.jsx)(`div`,{className:`border-b border-border/60 pt-1 pb-2`,children:(0,x.jsx)(`div`,{className:`flex h-6 min-w-0 items-baseline gap-2 px-1 text-sm leading-relaxed text-muted-foreground tabular-nums`,children:(0,x.jsxs)(`span`,{className:`relative shrink-0 overflow-hidden whitespace-nowrap`,children:[`Working for `,Eu(t-e)]})})})}function PX(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e4?`${Math.round(e/1e3)}k`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function FX(e){return e===0?`$0.00`:e<.001?`<$0.001`:e<.1?`$${e.toFixed(3)}`:`$${e.toFixed(2)}`}function IX({c:e,active:t}){let[n,r]=b.useState(!1),i=(0,x.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,x.jsx)(pp,{"aria-hidden":!0,className:`size-3 shrink-0`}),e?(0,x.jsxs)(x.Fragment,{children:[`Compacted `,e.turns,` earlier turn`,e.turns===1?``:`s`,` `,PX(e.before),(0,x.jsx)(vd,{"aria-hidden":!0,className:`size-3`}),PX(e.after),` tokens`,(0,x.jsxs)(`span`,{className:`opacity-80`,children:[`· `,e.model.model,e.cost===null?``:` · ${FX(e.cost)}`]})]}):`Compacting earlier turns…`]});return(0,x.jsxs)(`div`,{className:`py-1`,children:[(0,x.jsxs)(`div`,{role:`separator`,"aria-label":e?`Compacted ${e.turns} earlier turns`:`Compacting`,className:`flex w-full items-center gap-3 py-1 text-xs text-muted-foreground`,children:[(0,x.jsx)(`span`,{className:`h-px flex-1 bg-border/70`}),(0,x.jsxs)(`span`,{className:`relative min-w-0 overflow-hidden`,children:[i,t&&(0,x.jsx)(qb,{children:i})]}),e&&(0,x.jsx)(`button`,{onClick:()=>r(!n),className:`shrink-0 text-xs text-muted-foreground underline-offset-4 hover:text-foreground hover:underline`,children:n?`Hide summary`:`Show summary`}),(0,x.jsx)(`span`,{className:`h-px flex-1 bg-border/70`})]}),n&&e&&(0,x.jsx)(`div`,{className:`mx-auto mt-1 mb-2 max-w-[40rem] rounded-lg border bg-muted/40 px-3 py-2`,children:(0,x.jsx)(oY,{text:e.summary})})]})}function LX({messages:e,running:t,runStarted:n,onApprove:r,error:i,compactions:a=[],compacting:o}){let s=b.useRef(null),c=b.useRef(!0),l=b.useRef(0);b.useLayoutEffect(()=>{let e=s.current;e&&c.current&&(e.scrollTop=e.scrollHeight)});let u=e[e.length-1],d=RX(s,e);return(0,x.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col`,children:[(0,x.jsx)(`div`,{ref:s,onScroll:e=>{let t=e.currentTarget;Date.now()>l.current&&(c.current=t.scrollHeight-t.scrollTop-t.clientHeight<40),d.schedule()},className:`fade-top min-h-0 flex-1 overflow-y-auto px-3 sm:px-12`,children:(0,x.jsxs)(`div`,{className:`mx-auto w-full max-w-[var(--chat-max)] pt-4 pb-6`,"data-timeline-root":!0,children:[e.map((n,i)=>(0,x.jsxs)(b.Fragment,{children:[n.role===`user`?(0,x.jsx)(kX,{m:n,busy:t}):(0,x.jsx)(MX,{m:n,streaming:t&&n===u,terminal:!(t&&n===u)&&(i===e.length-1||e[i+1]?.role===`user`),onApprove:r,turnId:[...e.slice(0,i)].reverse().find(e=>e.role===`user`)?.id}),a.filter(e=>e.upTo===n.id).map(e=>(0,x.jsx)(IX,{c:e},`c${e.upTo}`))]},n.id)),o&&(0,x.jsx)(IX,{active:!0}),t&&(0,x.jsx)(NX,{since:n}),i&&(0,x.jsx)(`div`,{className:G(`mt-2 rounded-lg border border-destructive/30 bg-destructive/8 px-3 py-2 text-sm text-destructive-foreground`),children:i})]})}),(0,x.jsx)($Y,{items:d.items,persistent:d.persistent,hitStrip:d.hitStrip,currentIndex:d.current,atEnd:d.atEnd,stripMap:d.stripMap,onWheel:e=>s.current&&ZY(e,s.current),onSelect:e=>{c.current=!1,l.current=Date.now()+1e3,d.select(e.id)}})]})}function RX(e,t){let n=b.useMemo(()=>CY(t),[t]),[r]=b.useState(()=>new Map),[i,a]=b.useState(null),[o,s]=b.useState(!1),[c,l]=b.useState(0),u=b.useRef(null),d=b.useRef(n);d.current=n;let f=b.useCallback(()=>{let t=e.current;if(!t)return;let n=t.querySelector(`[data-timeline-root]`),i=t.getBoundingClientRect();n&&l(Math.floor(n.getBoundingClientRect().left-i.left));let o=d.current;if(!o.length)return;let c=[...t.querySelectorAll(`[data-timeline-message]`)],u=e=>{let t=null,n=null;return c.forEach((r,a)=>{let o=r.getBoundingClientRect();o.top<i.bottom&&o.bottom>i.top+e&&(t??=a,n=a)}),{start:t,end:n}},f=new Map(c.map((e,t)=>[e.dataset.timelineMessage,t])),p=o.map(e=>f.get(e.id)??e.rowIndex),m=u(0),h=new Map;o.forEach((e,t)=>{let n=r.get(e.id);if(!n)return;let i=VY(p[t],p[t+1],m.start,m.end);h.set(n,i||h.get(n)===!0)});for(let[e,t]of h)e.dataset.inView!==String(t)&&(e.dataset.inView=String(t));let g=u(25),_=HY({visibleStart:g.start,visibleEnd:g.end,rowIndices:p});a(e=>e===_?e:_),s(t.scrollHeight-t.scrollTop-t.clientHeight<=1)},[e,r]),p=b.useCallback(()=>{u.current===null&&(u.current=requestAnimationFrame(()=>{u.current=null,f()}))},[f]);return b.useEffect(()=>{p()},[t,p]),b.useEffect(()=>{let t=e.current;if(!t)return;let n=new ResizeObserver(p);n.observe(t);let r=t.querySelector(`[data-timeline-root]`);return r&&n.observe(r),()=>{n.disconnect(),u.current!==null&&cancelAnimationFrame(u.current)}},[e,p]),{items:n,stripMap:r,current:i,atEnd:o,persistent:UY(c),hitStrip:WY(c),schedule:p,select:t=>{let n=e.current,r=n?.querySelector(`[data-timeline-message="${CSS.escape(t)}"]`);if(!n||!r)return;let i=r.getBoundingClientRect().top-n.getBoundingClientRect().top+n.scrollTop-24;n.scrollTo({top:i,behavior:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches?`auto`:`smooth`})}}}function zX({chatId:e}){let t=Au(),n=U(t.agent.writes.queryOptions({chatId:e})),r=at(t.agent.answerWrite.mutationOptions()),[i,a]=b.useState(Date.now()),o=n.data||[];return b.useEffect(()=>{if(!o.length)return;let e=setInterval(()=>a(Date.now()),1e3);return()=>clearInterval(e)},[o.length]),o.length?(0,x.jsx)(`div`,{className:`mx-auto mb-2 flex w-full max-w-[var(--chat-max)] flex-col gap-2`,children:o.map(e=>(0,x.jsxs)(`div`,{className:`rounded-lg border bg-background p-3 text-xs shadow-xs/5`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-1.5 font-medium`,children:[(0,x.jsx)(Ff,{className:`size-3.5 text-icon-muted`}),`The agent’s browser wants to write to the instance`,(0,x.jsxs)(`span`,{className:`ms-auto font-normal text-muted-foreground tabular-nums`,children:[`declines in `,Eu(Date.parse(e.expiresAt)-i)]})]}),(0,x.jsxs)(`div`,{className:`mt-1.5 font-mono text-[11.5px] text-foreground/85`,children:[e.method,` `,e.table?`${e.table}${e.sysId?`/${e.sysId}`:``}`:e.path,e.action?` · action ${e.action}`:``]}),e.fields&&e.fields.length>0&&(0,x.jsxs)(`div`,{className:`mt-1 text-muted-foreground`,children:[`Fields: `,e.fields.join(`, `)]}),(0,x.jsxs)(`div`,{className:`mt-2.5 flex items-center gap-2`,children:[(0,x.jsx)(_m,{className:`size-3 text-warning-foreground`}),(0,x.jsx)(`span`,{className:`text-warning-foreground`,children:`Waiting for approval`}),(0,x.jsx)(`span`,{className:`ms-auto`}),(0,x.jsx)(q,{size:`xs`,variant:`outline`,onClick:()=>r.mutate({id:e.id,approved:!1}),children:`Decline`}),(0,x.jsx)(q,{size:`xs`,onClick:()=>r.mutate({id:e.id,approved:!0}),children:`Approve`})]})]},e.id))}):null}var BX=new Map,VX=new Map,HX=(e,t,n)=>BX.set(e,{text:t,model:n});function UX(e){let t=rX(e),n=e.input||{};return t===`delete_path`?`delete ${n.path}`:t===`shell`?`run ${String(n.command||``).slice(0,80)}`:`${t.replace(/_/g,` `)} ${n.path||``}`.trim()}function WX({projectId:e,chatId:t}){let n=Au(),r=C(),i=U(n.chats.get.queryOptions({projectId:e,chatId:t})),a=U(n.projects.get.queryOptions({id:e})),o=at(n.chats.visit.mutationOptions()),s=b.useCallback(()=>{o.mutate({projectId:e,chatId:t},{onSuccess:()=>{r.invalidateQueries({queryKey:n.chats.list.queryKey({projectId:e})}),r.invalidateQueries({queryKey:n.chats.recent.pathKey()})}})},[e,t]);return b.useEffect(()=>s(),[s]),i.isLoading?(0,x.jsx)(`div`,{className:`flex-1`}):i.error?(0,x.jsx)(`div`,{className:`p-6 text-sm text-muted-foreground`,children:i.error.message}):(0,x.jsx)(GX,{projectId:e,chatId:t,title:i.data.title,projectName:a.data?.name||``,initial:i.data.messages,initialModel:i.data.model,initialSafety:i.data.safety,serverRunning:i.data.running,onDone:()=>{r.invalidateQueries({queryKey:n.chats.get.queryKey({projectId:e,chatId:t})}),s()}},t)}function GX({projectId:e,chatId:t,title:n,projectName:r,initial:i,initialModel:a,initialSafety:o,serverRunning:s,onDone:c}){let l=Au(),u=C(),[d,f]=b.useState(a),p=b.useRef(d);p.current=d;let m=at(l.chats.setModel.mutationOptions()),h=at(l.chats.stop.mutationOptions()),g=at(l.chats.rewind.mutationOptions()),_=at(l.edits.undoTurn.mutationOptions()),v=Yi(),[y]=b.useState(()=>{let e=VX.get(t)||``;return VX.delete(t),e}),[S,w]=b.useState(o),T=at(l.chats.setSafety.mutationOptions()),[E,D]=b.useState(Date.now()),[O,k]=b.useState(),A=mL({id:t,messages:i,transport:b.useMemo(()=>new tL({api:`/api/chat`,headers:()=>({"x-forge-token":vu()}),prepareSendMessagesRequest:({messages:t,id:n})=>({body:{projectId:e,chatId:n,message:t[t.length-1],model:p.current}}),fetch:(async(e,t)=>{let n=await fetch(e,t);if(!n.ok){let e=`Request failed (${n.status})`,t=``;try{let r=await n.clone().json();e=r.message||e,t=r.code||``}catch{}throw Object.assign(Error(e),{code:t})}return n})}),[e]),sendAutomaticallyWhen:rL,onError:e=>{k(e.message),e.code===`approval_expired`&&j()},onFinish:()=>c()}),j=async()=>{let n=await u.fetchQuery({...l.chats.get.queryOptions({projectId:e,chatId:t}),staleTime:0});A.setMessages(n.messages)},M=A.status===`submitted`||A.status===`streaming`;b.useEffect(()=>{let e=BX.get(t);e&&(BX.delete(t),e.model&&f(e.model),p.current=e.model,D(Date.now()),A.sendMessage({text:e.text}))},[t]);let N=b.useMemo(()=>{let e=A.messages[A.messages.length-1];return!e||e.role!==`assistant`?null:e.parts.find(e=>e.state===`approval-requested`)},[A.messages]),P=N?.approval?{id:N.approval.id,summary:UX(N),always:rX(N)===`shell`&&/^command:/.test(N.approval.requestReason||``)}:null,F=at(l.chats.answerSdk.mutationOptions({onError:e=>{k(e.message),j()}})),I=(n,r,i)=>{k(void 0),n.startsWith(`sdk:`)?F.mutate({chatId:t,projectId:e,approvalId:n,approved:r,always:!!i}):(D(Date.now()),A.addToolApprovalResponse({id:n,approved:r,...i?{reason:`always`}:{}}))},L=([...A.messages].reverse().find(e=>e.metadata?.usage)?.metadata)?.usage?.context||0,R=U(l.chats.get.queryOptions({projectId:e,chatId:t})),z=U(l.chats.usage.queryOptions({projectId:e,chatId:t})),B=U(l.chats.overlaps.queryOptions({projectId:e,chatId:t})),V=at(l.chats.compact.mutationOptions()),H=z.data?.totals,ee=!!H&&H.cost>0,te=!!H&&!ee&&(H.apiEquivalent||0)>0,ne=!H||!H.calls?``:ee?FX(H.cost):te?`~${FX(H.apiEquivalent)}`:`${PX(H.input+H.output)} tokens`,re=H?`This chat: ${PX(H.input)} in (${PX(H.cachedInput)} cached) · ${PX(H.output)} out`+(te?` · API estimate ${FX(H.apiEquivalent)} (subscription: no per-token charge)`:``)+(H.unpricedTokens?` · ${PX(H.unpricedTokens)} tokens without a price (set one in Settings)`:``):``,ie=(B.data||[]).length?(B.data||[]).slice(0,2).map(e=>`${e.path.split(`/`).pop()} is also being changed by “${e.title}”`).join(` · `):void 0,ae=U(l.models.queryOptions()).data?.some(e=>e.connectionId===d?.connectionId&&e.kind===`claude-subscription`),oe=U({...l.claude.status.queryOptions(),enabled:!!ae}),se=ae&&oe.data?.limit?oe.data.limit.message:void 0;return(0,x.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,x.jsx)(qX,{title:n,projectName:r,projectId:e,chatId:t}),(0,x.jsx)(pX.Provider,{value:{projectId:e,chatId:t,onRewind:async n=>{k(void 0);try{let r=await g.mutateAsync({projectId:e,chatId:t,messageId:n});VX.set(r.chatId,r.text),v({to:`/p/$projectId/c/$chatId`,params:{projectId:e,chatId:r.chatId}})}catch(e){k(e.message)}},onUndoTurn:async n=>{let r=await _.mutateAsync({projectId:e,chatId:t,turnId:n});!r.ok&&`conflictPath`in r&&k(`Undo stopped at ${r.conflictPath}: ${r.message}`)},onAnswer:(n,r)=>{k(void 0),A.messages[A.messages.length-1]?.metadata?.runner===`claude`?F.mutate({chatId:t,projectId:e,toolCallId:n,answer:r}):(D(Date.now()),Promise.resolve(A.addToolOutput({tool:`ask`,toolCallId:n,output:{answer:r}})).then(()=>A.sendMessage()))}},children:(0,x.jsx)(LX,{messages:A.messages,running:M,runStarted:E,onApprove:I,error:O,compactions:R.data?.compactions||[],compacting:V.isPending})}),(0,x.jsxs)(`div`,{className:`px-3 pt-1.5 pb-3 sm:px-12 sm:pt-2 sm:pb-4`,children:[(0,x.jsx)(zX,{chatId:t}),(0,x.jsx)(fS,{running:M||!!s,model:d,onModel:n=>{f(n),m.mutate({projectId:e,chatId:t,model:n})},onSend:e=>{k(void 0),D(Date.now()),A.sendMessage({text:e})},onStop:()=>{A.stop(),h.mutate({chatId:t})},initialText:y,safety:S,onSafety:n=>{w(n),T.mutate({projectId:e,chatId:t,safety:n})},pending:M&&!P?.id.startsWith(`sdk:`)?null:P,onAnswer:(e,t)=>P&&I(P.id,e,t),context:L?PX(L):``,onCompact:async()=>{k(void 0);try{await V.mutateAsync({projectId:e,chatId:t})}catch(e){k(e.message)}},compacting:V.isPending,cost:ne,costTip:re,banner:s&&!M?`This chat is still running from before a reload. It appears when it finishes, or Stop it.`:ie||se})]})]})}function KX({title:e,projectId:t,chatId:n}){let r=Au(),i=C(),a=Yi(),[o,s]=b.useState(!1),[c,l]=b.useState(!1),[u,d]=b.useState(!1),f=b.useRef(!1),p=b.useRef(null),m=at(r.chats.rename.mutationOptions({onSettled:()=>i.invalidateQueries({queryKey:r.chats.get.queryKey({projectId:t,chatId:n})})})),h=at(r.chats.delete.mutationOptions()),g=r=>{s(!1);let i=r.trim();i&&i!==e&&m.mutate({projectId:t,chatId:n,title:i})};if(o)return(0,x.jsx)(`input`,{autoFocus:!0,dir:`auto`,"aria-label":`Chat title`,defaultValue:e,onFocus:e=>e.currentTarget.select(),onBlur:e=>{f.current||g(e.currentTarget.value)},onKeyDown:e=>{e.nativeEvent.isComposing||(e.key===`Enter`?(f.current=!0,g(e.currentTarget.value)):e.key===`Escape`&&(e.preventDefault(),f.current=!0,s(!1)))},className:`w-72 max-w-full min-w-0 rounded-sm bg-transparent px-1 text-sm font-medium text-foreground ring-1 ring-ring/50 outline-none ring-inset focus:ring-ring`});let _=()=>{p.current&&clearTimeout(p.current),f.current=!1,d(!1),s(!0)};return(0,x.jsxs)(mb,{open:u,onOpenChange:e=>{e||(d(!1),l(!1))},children:[(0,x.jsxs)(hb,{render:(0,x.jsx)(`button`,{type:`button`,title:e,"aria-label":`Chat actions for ${e}`,onClick:e=>{if(!(e.detail>1)){if(p.current&&clearTimeout(p.current),e.detail===0)return d(!0);p.current=setTimeout(()=>d(!0),220)}},onDoubleClick:e=>{e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||_()},className:`group/title inline-flex max-w-full min-w-0 cursor-pointer items-center gap-1 rounded-sm text-left focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-hidden focus-visible:ring-inset`}),children:[(0,x.jsx)(`h2`,{className:`min-w-0 truncate text-foreground`,children:e}),(0,x.jsx)(Pd,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-muted-foreground opacity-0 transition-opacity group-hover/title:opacity-100 group-focus-visible/title:opacity-100`})]}),(0,x.jsxs)(gb,{align:`start`,sideOffset:4,children:[(0,x.jsxs)(_b,{onClick:_,children:[(0,x.jsx)(Lp,{}),` Rename`]}),(0,x.jsx)(yb,{}),(0,x.jsxs)(_b,{closeOnClick:c,onClick:()=>{if(!c)return l(!0);h.mutate({projectId:t,chatId:n},{onSuccess:()=>a({to:`/p/$projectId`,params:{projectId:t}})})},className:`text-destructive data-[highlighted]:text-destructive`,children:[(0,x.jsx)(Fm,{}),` `,c?`Click again to delete`:`Delete chat`]})]})]})}function qX({title:e,projectName:t,projectId:n,chatId:r}){let i=Gu();return(0,x.jsxs)(`header`,{className:`flex h-[var(--topbar-h)] shrink-0 items-center gap-2 px-3 sm:px-5`,children:[!i.sidebarOpen&&(0,x.jsx)(Tb,{label:`Show sidebar`,children:(0,x.jsx)(q,{variant:`ghost`,size:`icon-sm`,onClick:()=>Wu({sidebarOpen:!0}),children:(0,x.jsx)(kp,{})})}),(0,x.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-sm font-medium sm:gap-3`,children:[(0,x.jsx)(`span`,{className:`truncate text-muted-foreground`,children:t}),(0,x.jsx)(`span`,{className:`text-icon-muted`,children:`/`}),r?(0,x.jsx)(KX,{title:e,projectId:n,chatId:r}):(0,x.jsx)(`span`,{className:`truncate text-foreground`,children:e})]}),(0,x.jsx)(`div`,{className:`ms-2 min-w-0 flex-1`,children:(0,x.jsx)(l8,{projectId:n})}),(0,x.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,x.jsx)(Tb,{label:`Check the workspace (Push plan tab)`,children:(0,x.jsx)(q,{variant:`ghost`,size:`icon-sm`,"aria-label":`Check`,onClick:()=>Wu({panelOpen:!0,panelTab:`plan`}),children:(0,x.jsx)(Bd,{})})}),(0,x.jsx)(Tb,{label:`Push to the instance (review the plan first)`,children:(0,x.jsx)(q,{variant:`ghost`,size:`icon-sm`,"aria-label":`Push`,onClick:()=>Wu({pushOpen:!0}),children:(0,x.jsx)(zm,{})})}),(0,x.jsx)(`span`,{className:`mx-1 h-4 w-px bg-border`,"aria-hidden":!0}),(0,x.jsx)(Tb,{label:`Terminal (${Du?`⌘`:`Ctrl`}+\`)`,children:(0,x.jsx)(q,{variant:`ghost`,size:`icon-sm`,"aria-label":`Toggle terminal`,"aria-pressed":i.drawerOpen,onClick:()=>Wu({drawerOpen:!i.drawerOpen}),className:i.drawerOpen?`bg-accent [&_svg]:text-foreground`:``,children:(0,x.jsx)(Dp,{})})}),(0,x.jsx)(Tb,{label:`Toggle the right panel`,children:(0,x.jsx)(q,{variant:`ghost`,size:`icon-sm`,"aria-pressed":i.panelOpen,onClick:()=>Wu({panelOpen:!i.panelOpen}),className:i.panelOpen?`bg-accent [&_svg]:text-foreground`:``,children:(0,x.jsx)(jp,{})})})]})]})}function JX(e){let t=Au(),n=Yi(),r=at(t.chats.create.mutationOptions());return async(t,i)=>{let a=await r.mutateAsync({projectId:e});HX(a.id,t,i),n({to:`/p/$projectId/c/$chatId`,params:{projectId:e,chatId:a.id}})}}var YX=500,XX=new Map,ZX=new Set,QX=0,$X=(e,t)=>`${e}\u0000${t}`;function eZ(){QX+=1;for(let e of ZX)e()}async function tZ(e){if(e.saving||e.latest===null||e.problem)return;e.saving=!0;let t=e.latest;try{e.baseHash=(await Ou.files.write.mutate({projectId:e.projectId,path:e.path,content:t,baseHash:e.baseHash})).hash,e.latest===t&&(e.latest=null)}catch(t){let n=t;e.problem={kind:n.data?.code===`CONFLICT`?`conflict`:`failed`,message:n.message||`The file could not be saved`}}finally{e.saving=!1,eZ()}e.latest!==null&&!e.problem&&!e.timer&&tZ(e)}function nZ(e,t,n){let r=$X(e,t),i=XX.get(r);i?i.latest===null&&!i.saving&&(i.baseHash=n):XX.set(r,{projectId:e,path:t,baseHash:n,latest:null,timer:null,saving:!1,problem:null})}function rZ(e,t,n){let r=XX.get($X(e,t));r&&(r.latest=n,r.timer&&clearTimeout(r.timer),r.timer=setTimeout(()=>{r.timer=null,tZ(r)},YX),eZ())}function iZ(e,t){let n=XX.get($X(e,t));n&&(n.timer&&=(clearTimeout(n.timer),null),tZ(n))}function aZ(e,t,n,r){let i=XX.get($X(e,t));i&&(i.problem=null,n===`reload`?(i.latest=null,i.timer&&clearTimeout(i.timer),i.timer=null,XX.delete($X(e,t)),eZ()):(r!==void 0&&(i.baseHash=r),eZ(),tZ(i)))}function oZ(e,t){let n=XX.get($X(e,t));return!!n&&(n.latest!==null||n.saving)}function sZ(e,t){return XX.get($X(e,t))?.latest??null}function cZ(e){return ZX.add(e),()=>ZX.delete(e)}function lZ(){return(0,b.useSyncExternalStore)(cZ,()=>QX)}function uZ(e,t){return lZ(),XX.get($X(e,t))?.problem??null}typeof window<`u`&&window.addEventListener(`pagehide`,()=>{for(let e of XX.values())e.latest!==null&&iZ(e.projectId,e.path)});var dZ=700;function fZ(e){return e?1:.35}function pZ({frame:e,pointer:t}){let n=b.useRef(null),[r,i]=b.useState(0);b.useLayoutEffect(()=>{let e=n.current;if(!e)return;let t=new ResizeObserver(()=>i(e.clientWidth));return t.observe(e),i(e.clientWidth),()=>t.disconnect()},[]);let a=e.width?r/e.width:1;return(0,x.jsxs)(`div`,{className:`relative max-w-full`,children:[(0,x.jsx)(`img`,{ref:n,src:`data:image/jpeg;base64,${e.data}`,alt:`Live view of the agent’s browser`,className:`block max-w-full rounded-lg border bg-white shadow-xs/5`,style:{aspectRatio:`${e.width} / ${e.height}`}}),t&&r?(0,x.jsx)(mZ,{phase:t.phase,sequence:t.sequence,left:t.x*a+1,top:t.y*a+1}):null]})}function mZ({phase:e,sequence:t,left:n,top:r}){let[i,a]=b.useState(null);return b.useEffect(()=>{let e=window.setTimeout(()=>a(t),dZ);return()=>window.clearTimeout(e)},[t]),(0,x.jsxs)(`div`,{className:`pointer-events-none absolute top-0 left-0 z-40 transition-[opacity,transform] duration-150 ease-out motion-reduce:transition-none`,style:{opacity:fZ(i!==t),transform:`translate3d(${n}px, ${r}px, 0)`},"aria-hidden":`true`,"data-agent-cursor":!0,children:[e===`click`?(0,x.jsx)(`span`,{className:`absolute top-0.5 left-0.5 size-4 animate-status-ping rounded-full bg-primary/25 motion-reduce:animate-none`},t):null,(0,x.jsx)(yp,{className:`relative size-5 -translate-x-0.5 -translate-y-0.5 fill-background stroke-2 text-primary drop-shadow-sm`})]})}function hZ({projectId:e}){let t=Au(),n=U(t.agent.info.queryOptions({projectId:e})),r=at(t.agent.openWindow.mutationOptions()),[i,a]=b.useState(null),[o,s]=b.useState(null),c=!!n.data?.running;return Ic(t.agent.frames.subscriptionOptions({projectId:e},{enabled:c&&n.data?.headless!==!1,onData:e=>`pointer`in e?s(e.pointer):a(e)})),c?(0,x.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,x.jsxs)(`div`,{className:`flex h-9 shrink-0 items-center gap-2 border-b px-2`,children:[(0,x.jsx)(kb,{variant:`info`,children:`Read-only`}),(0,x.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-muted-foreground`,children:i?.url||``}),n.data?.headless===!1?(0,x.jsxs)(q,{size:`xs`,variant:`outline`,disabled:r.isPending,onClick:()=>r.mutate({projectId:e,headless:!0}),children:[(0,x.jsx)(pf,{}),` Back to headless`]}):(0,x.jsxs)(q,{size:`xs`,variant:`outline`,disabled:r.isPending,onClick:()=>r.mutate({projectId:e,headless:!1}),children:[(0,x.jsx)(md,{}),` Open window`]})]}),(0,x.jsx)(`div`,{className:`flex min-h-0 flex-1 items-start justify-center overflow-auto bg-muted p-3`,children:n.data?.headless===!1?(0,x.jsx)(b8,{icon:md,title:`Showing in a window`,children:`The agent’s browser is open as a window on your desktop. Switch back to headless to watch it here.`}):i?(0,x.jsx)(pZ,{frame:i,pointer:o}):(0,x.jsxs)(`div`,{className:`flex h-full items-center gap-2 text-xs text-muted-foreground`,children:[(0,x.jsx)(Yb,{size:`sm`,muted:!0}),` Waiting for the first frame…`]})})]}):(0,x.jsx)(b8,{icon:xp,title:`The agent’s browser`,children:`It starts the first time the agent opens a page of the preview. Here you watch it live: it looks and clicks, and it can’t change instance data unless you allow browser writes for the chat.`})}var gZ=b.lazy(()=>NJ(()=>import(`./terminal-view-D3CiLjfu.js`),__vite__mapDeps([10,11])));function _Z({projectId:e,autoCreate:t}){let n=Au(),r=C(),i=Gu(),a=U(n.terminals.list.queryOptions({projectId:e})),o=at(n.terminals.create.mutationOptions({onSuccess:t=>{r.invalidateQueries({queryKey:n.terminals.list.queryKey({projectId:e})}),Wu({activeTerminal:t.id})}})),s=at(n.terminals.close.mutationOptions({onSuccess:()=>r.invalidateQueries({queryKey:n.terminals.list.queryKey({projectId:e})})})),c=a.data||[],l=c.find(e=>e.id===i.activeTerminal)||c.filter(e=>e.kind===`shell`)[0]||c[0];return b.useEffect(()=>{t&&a.data&&!a.data.some(e=>e.kind===`shell`)&&!o.isPending&&o.mutate({projectId:e})},[t,a.data]),(0,x.jsxs)(`div`,{className:`flex h-full min-h-0`,children:[(0,x.jsx)(`div`,{className:`relative min-w-0 flex-1`,children:l?(0,x.jsx)(b.Suspense,{fallback:(0,x.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,x.jsx)(Yb,{size:`sm`,muted:!0})}),children:(0,x.jsx)(gZ,{sessionId:l.id},l.id)}):a.isLoading?null:(0,x.jsx)(b8,{icon:Cm,title:`No terminal yet`,children:`A shell in the project folder. The agent’s commands show here too, read-only, while they run.`})}),(0,x.jsxs)(`div`,{className:`flex w-36 shrink-0 flex-col border-l border-border/80 py-1`,children:[c.map(e=>(0,x.jsxs)(`div`,{className:G(`group mx-1 flex h-[22px] cursor-pointer items-center gap-1.5 rounded px-1.5 text-2xs`,e.id===l?.id?`bg-accent text-foreground`:`text-muted-foreground hover:bg-accent/60`),onClick:()=>Wu({activeTerminal:e.id}),title:e.title,children:[e.kind===`command`?(0,x.jsx)(hf,{className:`size-3 shrink-0`}):(0,x.jsx)(Cm,{className:`size-3 shrink-0`}),(0,x.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono`,children:e.title}),e.exitCode!==null&&(0,x.jsx)(`span`,{className:G(`tabular-nums`,e.exitCode?`text-destructive-foreground`:`text-success-foreground`),children:e.exitCode}),(0,x.jsx)(`button`,{"aria-label":`Close`,onClick:t=>{t.stopPropagation(),s.mutate({id:e.id})},className:`hidden size-4 items-center justify-center rounded text-muted-foreground group-hover:inline-flex hover:text-foreground`,children:(0,x.jsx)(Gm,{className:`size-3`})})]},e.id)),(0,x.jsx)(Tb,{label:`New terminal`,children:(0,x.jsxs)(`button`,{onClick:()=>o.mutate({projectId:e}),className:`mx-1 mt-0.5 flex h-[22px] items-center gap-1.5 rounded px-1.5 text-2xs text-muted-foreground hover:bg-accent/60 hover:text-foreground`,children:[(0,x.jsx)(qp,{className:`size-3`}),` New`]})})]})]})}function vZ({projectId:e}){let t=Gu();return t.drawerOpen?(0,x.jsxs)(`div`,{className:`relative shrink-0 border-t border-border/80 bg-background`,style:{height:t.drawerHeight},children:[(0,x.jsx)(`div`,{onPointerDown:e=>{e.preventDefault();let t=e=>{let t=window.innerHeight-e.clientY;Wu({drawerHeight:Math.min(window.innerHeight*.75,Math.max(180,t))})},n=()=>{window.removeEventListener(`pointermove`,t),window.removeEventListener(`pointerup`,n),document.body.style.cursor=``};document.body.style.cursor=`row-resize`,window.addEventListener(`pointermove`,t),window.addEventListener(`pointerup`,n)},className:`group absolute -top-2 left-0 z-10 flex h-4 w-full cursor-row-resize items-center`,children:(0,x.jsx)(`div`,{className:`h-0.5 w-full transition-colors group-hover:bg-border`})}),(0,x.jsx)(_Z,{projectId:e,autoCreate:!0})]}):null}var yZ={layout:`stacked`,ignoreWhitespace:!1,colors:`red-green`};function bZ(){let e=U(Au().settings.get.queryOptions());return{...yZ,...e.data?.diffs||{}}}var xZ=b.lazy(()=>NJ(()=>import(`./diff-view-Chujmqzi.js`),__vite__mapDeps([8,9,3,1,5])));function SZ({projectId:e}){let t=Au(),n=Gu(),r=bZ().layout===`split`,i=at(t.settings.setDiffs.mutationOptions()),{chatId:a=``}=qi({strict:!1}),o=n.diffScope,s=U(t.diffs.files.queryOptions({projectId:e,chatId:a,scope:o})),c=s.data||[],l=c.find(e=>e.path===n.diffPath)||c[0],u=U({...t.diffs.file.queryOptions({projectId:e,chatId:a,scope:o,path:l?.path||``}),enabled:!!l}),d=at(t.diffs.accept.mutationOptions()),f=at(t.diffs.revert.mutationOptions());return(0,x.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,x.jsxs)(`div`,{className:`flex h-9 shrink-0 items-center gap-1 border-b px-2`,children:[(0,x.jsx)(`div`,{className:`inline-flex rounded-md bg-accent p-0.5`,children:[{id:`turn`,label:`This turn`},{id:`session`,label:`Session`},{id:`instance`,label:`vs instance`},{id:`head`,label:`vs git HEAD`}].map(e=>(0,x.jsx)(`button`,{onClick:()=>Wu({diffScope:e.id}),className:G(`h-5 rounded px-2 text-2xs`,o===e.id?`bg-background font-medium text-foreground shadow-xs/5`:`text-muted-foreground hover:text-foreground`),children:e.label},e.id))}),(0,x.jsx)(`span`,{className:`ms-auto`}),(0,x.jsx)(`div`,{className:`inline-flex rounded-md bg-accent p-0.5`,children:[`unified`,`split`].map(e=>(0,x.jsx)(`button`,{onClick:()=>i.mutate({layout:e===`split`?`split`:`stacked`}),className:G(`h-5 rounded px-2 text-2xs capitalize`,r===(e===`split`)?`bg-background font-medium text-foreground shadow-xs/5`:`text-muted-foreground hover:text-foreground`),children:e},e))})]}),s.isLoading?(0,x.jsx)(`div`,{className:`flex flex-1 items-center justify-center`,children:(0,x.jsx)(Yb,{size:`sm`,muted:!0})}):c.length?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`div`,{className:`max-h-[40%] shrink-0 overflow-y-auto border-b py-1`,children:c.map(t=>(0,x.jsxs)(`div`,{onClick:()=>Wu({diffPath:t.path}),className:G(`group mx-1 flex h-7 cursor-pointer items-center gap-2 rounded-md px-2 text-[13px]`,t.path===l?.path?`bg-accent`:`hover:bg-accent/60`),children:[(0,x.jsx)(Tb,{label:t.origin===`outside`?`Changed outside Forge`:t.origin===`git`?`git status`:`Edited by the agent`,children:(0,x.jsx)(`span`,{className:`flex size-4 items-center justify-center text-icon-muted`,children:t.origin===`outside`?(0,x.jsx)(zf,{className:`size-3.5`}):(0,x.jsx)(xm,{className:`size-3.5`})})}),(0,x.jsx)(`span`,{className:G(`min-w-0 flex-1 truncate font-mono text-xs`,t.status===`deleted`&&`line-through opacity-70`),children:t.path}),t.status!==`modified`&&(0,x.jsx)(`span`,{className:`text-2xs text-muted-foreground`,children:t.status}),(0,x.jsx)(yX,{added:t.added,removed:t.removed}),o===`session`&&a&&(0,x.jsxs)(`span`,{className:`hidden items-center gap-1 group-hover:flex`,children:[(0,x.jsx)(q,{size:`xs`,variant:`ghost-muted`,onClick:n=>{n.stopPropagation(),f.mutate({projectId:e,chatId:a,path:t.path})},children:`Revert`}),(0,x.jsx)(q,{size:`xs`,variant:`outline`,onClick:n=>{n.stopPropagation(),d.mutate({projectId:e,chatId:a,path:t.path})},children:`Accept`})]})]},t.path))}),(0,x.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:[l&&(0,x.jsxs)(`div`,{className:`flex h-8 items-center gap-2 border-b px-3 text-xs`,children:[(0,x.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono`,children:l.path}),l.status!==`deleted`&&(0,x.jsx)(q,{size:`xs`,variant:`ghost`,onClick:()=>Xu(l.path),children:`Edit`})]}),u.data?(0,x.jsx)(b.Suspense,{fallback:(0,x.jsx)(`div`,{className:`flex h-20 items-center justify-center`,children:(0,x.jsx)(Yb,{size:`sm`,muted:!0})}),children:(0,x.jsx)(xZ,{path:u.data.path,oldText:u.data.old,newText:u.data.new,split:r})}):null]})]}):(0,x.jsx)(b8,{icon:_f,title:`No changes`,children:o===`head`?`Nothing differs from git HEAD (or this folder isn’t a git repository).`:o===`instance`?`The files match the instance base (the last pull or push), or this folder has no base yet.`:a?`The agent’s edits in this chat show here, with undo.`:`Open a chat to see its changes.`})]})}var CZ=`flex h-10 min-h-10 shrink-0 items-center gap-2 border-b border-border/60 bg-background px-3`;function wZ({label:e,pressed:t,disabled:n,onPress:r,children:i}){return(0,x.jsx)(Tb,{label:e,children:(0,x.jsx)(`button`,{type:`button`,"aria-label":e,"aria-pressed":t,"data-pressed":t?``:void 0,disabled:n,onClick:r,className:G(`relative inline-flex size-7 shrink-0 cursor-pointer items-center justify-center rounded-md text-foreground outline-none transition-colors hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset disabled:pointer-events-none disabled:text-muted-foreground [&_svg]:size-3.5 [&_svg]:opacity-80`,t&&`bg-accent text-accent-foreground [&_svg]:opacity-100`),children:i})})}function TZ({className:e}){return(0,x.jsx)(`div`,{role:`status`,"aria-label":`Loading file`,className:G(`flex min-h-0 flex-1 items-center justify-center text-muted-foreground`,e),children:(0,x.jsx)(Yb,{size:`lg`})})}function EZ({message:e,onRetry:t}){return(0,x.jsxs)(`div`,{role:`alert`,className:`flex min-h-0 flex-1 flex-col items-center justify-center gap-3 px-6 text-center text-xs leading-relaxed`,children:[(0,x.jsx)(`p`,{className:`text-destructive-foreground`,children:e}),t&&(0,x.jsx)(`button`,{type:`button`,onClick:t,className:`cursor-pointer rounded-md border border-input px-2.5 py-1 text-xs text-foreground hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset`,children:`Try again`})]})}function DZ({tone:e=`warning`,children:t}){return(0,x.jsx)(`div`,{role:`status`,className:G(`flex shrink-0 items-center gap-2 border-b px-3 py-1.5 text-[11px]`,e===`warning`&&`border-warning/20 bg-warning/8 text-warning-foreground`,e===`error`&&`border-destructive/20 bg-destructive/8 text-destructive-foreground`,e===`muted`&&`text-muted-foreground`),children:t})}function OZ({at:e,items:t,onPick:n,onClose:r}){let i=b.useMemo(()=>e?{getBoundingClientRect:()=>DOMRect.fromRect({x:e.x,y:e.y,width:0,height:0})}:null,[e]);return(0,x.jsx)(I3,{open:!!e,onOpenChange:e=>!e&&r(),children:(0,x.jsx)(A4,{children:(0,x.jsx)(b3,{anchor:i,side:`bottom`,align:`start`,sideOffset:2,className:`z-50 outline-none`,children:(0,x.jsx)(D4,{className:`glass min-w-44 origin-[var(--transform-origin)] rounded-lg p-1 text-sm outline-none transition-[opacity,scale] duration-150 data-[ending-style]:scale-98 data-[ending-style]:opacity-0 data-[starting-style]:scale-98 data-[starting-style]:opacity-0`,children:t.map(e=>(0,x.jsxs)(b.Fragment,{children:[e.separated&&(0,x.jsx)(Y3,{className:`mx-2 my-1 h-px bg-border`}),(0,x.jsx)(i1,{disabled:e.disabled,onClick:()=>n(e.id),className:`flex min-h-7 cursor-default items-center gap-2 rounded-sm px-2 py-1 outline-none select-none data-[disabled]:opacity-50 data-[highlighted]:bg-accent`,children:e.label})]},e.id))})})})})}function kZ(e){return e.files&&Object.keys(e.files).length?Object.entries(e.files).map(([e,t])=>`${e} ${t}`).join(`, `):[e.change,e.renamedFrom&&`from ${e.renamedFrom}`,e.renamedTo&&`to ${e.renamedTo}`,e.note].filter(Boolean).join(` · `)}function AZ({projectId:e}){let t=Au(),n=U(t.push.state.queryOptions({projectId:e})),r=at(t.push.status.mutationOptions()),i=at(t.push.check.mutationOptions()),a=at(t.push.resolve.mutationOptions({onSuccess:()=>r.mutate({projectId:e})})),[o,s]=b.useState(``);b.useEffect(()=>{r.mutate({projectId:e})},[e]);let c=n.data?.push?.at;b.useEffect(()=>{c&&r.mutate({projectId:e})},[c]);let l=r.data,u=i.data,d=n.data?.plan,f=n.data?.push,p=a.isPending?a.variables?.keys[0]:``,m=(t,n,r,i)=>(0,x.jsx)(Tb,{label:i,children:(0,x.jsx)(q,{size:`xs`,variant:`ghost-muted`,disabled:!!p,onClick:r=>{r.stopPropagation(),a.mutate({projectId:e,keys:[t],action:n})},children:r})}),h=(t,n,r,i={})=>n&&n.length>0?(0,x.jsxs)(`section`,{children:[(0,x.jsxs)(`div`,{className:G(`mb-1 px-2 text-xs font-medium`,r),children:[t,` `,(0,x.jsx)(`span`,{className:`text-muted-foreground tabular-nums`,children:n.length})]}),(0,x.jsx)(`div`,{className:`flex flex-col`,children:n.slice(0,200).map(t=>(0,x.jsxs)(b.Fragment,{children:[(0,x.jsxs)(`div`,{onClick:i.expandable?()=>s(o===t.key?``:t.key):void 0,className:G(`group flex h-7 items-center gap-2 rounded-md px-2 text-[13px] hover:bg-accent/60`,i.expandable&&`cursor-pointer`),children:[i.expandable&&(0,x.jsx)(Id,{className:G(`size-3 shrink-0 text-icon-muted/70 transition-transform duration-200`,o===t.key&&`rotate-90`)}),(0,x.jsx)(`span`,{className:`min-w-0 shrink truncate font-mono text-xs`,children:t.key}),(0,x.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-muted-foreground`,children:kZ(t)}),t.updatedBy&&(0,x.jsx)(`span`,{className:`shrink-0 text-2xs text-muted-foreground group-hover:hidden`,children:t.updatedBy}),p===t.key&&(0,x.jsx)(Yb,{size:`xs`,muted:!0}),i.actions&&(0,x.jsx)(`span`,{className:`hidden gap-0.5 group-hover:flex`,children:i.actions(t.key)})]}),i.expandable&&o===t.key&&(0,x.jsx)(MZ,{projectId:e,entry:t})]},t.key))})]}):null;return(0,x.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,x.jsxs)(`div`,{className:`flex h-9 shrink-0 items-center gap-1.5 border-b px-2`,children:[(0,x.jsxs)(q,{size:`xs`,variant:`outline`,disabled:r.isPending,onClick:()=>r.mutate({projectId:e}),children:[r.isPending?(0,x.jsx)(Yb,{size:`xs`}):(0,x.jsx)(Yp,{}),` Status`]}),(0,x.jsxs)(q,{size:`xs`,variant:`outline`,disabled:i.isPending,onClick:()=>i.mutate({projectId:e}),children:[i.isPending?(0,x.jsx)(Yb,{size:`xs`}):(0,x.jsx)(Bd,{}),` Check`]}),(0,x.jsx)(Tb,{label:`Diff the files against the instance base (the last pull or push)`,children:(0,x.jsxs)(q,{size:`xs`,variant:`ghost-muted`,onClick:()=>Wu({panelTab:`diff`,diffScope:`instance`}),children:[(0,x.jsx)(_f,{}),` vs instance`]})}),(0,x.jsx)(`span`,{className:`ms-auto`}),(0,x.jsxs)(q,{size:`xs`,disabled:n.data?.running,onClick:()=>Wu({pushOpen:!0}),children:[n.data?.running?(0,x.jsx)(Yb,{size:`xs`}):(0,x.jsx)(zm,{}),` Plan push…`]})]}),(0,x.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-1 py-3 text-sm`,children:[r.error&&(0,x.jsx)(`div`,{className:`mx-2 mb-3 rounded-lg border border-destructive/30 bg-destructive/6 px-3 py-2 text-xs text-destructive-foreground`,children:r.error.message}),r.isPending&&!l&&(0,x.jsx)(`div`,{className:`flex items-center justify-center py-10`,children:(0,x.jsx)(Yb,{size:`sm`,muted:!0})}),l&&(0,x.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-1.5 px-2`,children:[l.clean?(0,x.jsx)(kb,{variant:`success`,children:`clean`}):(0,x.jsx)(kb,{variant:`warning`,children:`changes`}),[`local`,`instance`,`conflicts`].map(e=>l.counts?.[e]?(0,x.jsxs)(kb,{variant:e===`conflicts`?`error`:`outline`,children:[l.counts[e],` `,e===`conflicts`&&l.counts[e]===1?`conflict`:e]},e):null),(0,x.jsxs)(`span`,{className:`min-w-0 truncate text-xs text-muted-foreground`,children:[[l.on,l.app,l.updateSet].filter(Boolean).join(` · `),l.syncedAt?` · synced ${bu(l.syncedAt)}`:``]})]}),l&&l.clean&&!u&&(0,x.jsx)(b8,{icon:Bd,title:`In sync with the instance`,children:`The files match the instance base. Edits show here as local changes, ready to push.`}),(0,x.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[h(`Conflicts`,l?.conflicts,`text-destructive-foreground`,{expandable:!0,actions:e=>(0,x.jsxs)(x.Fragment,{children:[m(e,`take-local`,`Keep mine`,`Keep the files; the next push overwrites the instance`),m(e,`take-instance`,`Take instance`,`Replace the files with the instance’s version`),m(e,`merge`,`Merge`,`Three-way merge; leaves conflict markers where both changed`)]})}),h(`Local changes (to push)`,l?.local,`text-info-foreground`),h(`Instance changes (a pull takes them)`,l?.instance,`text-warning-foreground`,{actions:e=>m(e,`take-instance`,`Take instance`,`Bring this change into the files`)}),(l?.hints||[]).map(e=>(0,x.jsxs)(`div`,{className:`mx-2 text-xs text-muted-foreground`,children:[`· `,e]},e)),(l?.markers||[]).length>0&&(0,x.jsxs)(`div`,{className:`mx-2 text-xs text-warning-foreground`,children:[`Conflict markers left in: `,l.markers.join(`, `)]})]}),a.error&&(0,x.jsx)(`div`,{className:`mx-2 mt-2 text-xs text-destructive-foreground`,children:a.error.message}),i.error&&(0,x.jsx)(`div`,{className:`mx-2 mt-3 text-xs text-destructive-foreground`,children:i.error.message}),u&&(0,x.jsx)(jZ,{c:u}),(d||f)&&(0,x.jsxs)(`div`,{className:`mx-2 mt-4 flex flex-col gap-1 border-t pt-3 text-xs text-muted-foreground`,children:[d&&(0,x.jsxs)(`div`,{children:[`Latest dry run `,bu(d.at),`:`,` `,(0,x.jsx)(`span`,{className:`font-mono`,children:d.result?.planHash||`—`}),d.stale&&(0,x.jsx)(`span`,{className:`text-warning-foreground`,children:` · files changed since`})]}),f&&(0,x.jsxs)(`div`,{children:[`Last push `,bu(f.at),`:`,` `,f.result.failed?`failed in chunk ${f.result.failed.chunk} of ${f.result.failed.of}`:f.result.refused?`refused (${f.result.reason})`:`${f.result.pushed} written`,f.commit?` · git: ${f.commit.message}`:``]})]})]})]})}function jZ({c:e}){let t=e.local?.prettier?.unformatted||[],n=e.instance?.compiles||[],r=n.filter(e=>!e.ok);return(0,x.jsxs)(`div`,{className:`mx-2 mt-4 rounded-lg border p-3`,children:[(0,x.jsxs)(`div`,{className:G(`flex items-center gap-2 font-medium`,e.ok?`text-success-foreground`:`text-warning-foreground`),children:[e.ok?(0,x.jsx)(Bd,{className:`size-4`}):(0,x.jsx)(Wd,{className:`size-4`}),e.ok?`Check passed`:`Check found ${e.problems.length} problem${e.problems.length===1?``:`s`}`,e.ms?(0,x.jsxs)(`span`,{className:`ms-auto text-xs font-normal text-muted-foreground`,children:[(e.ms/1e3).toFixed(1),` s`]}):null]}),(e.problems||[]).map((e,t)=>(0,x.jsxs)(`div`,{className:`mt-1 text-xs`,children:[`· `,e]},t)),t.length>0&&(0,x.jsxs)(`div`,{className:`mt-2 text-xs text-muted-foreground`,children:[`Not Prettier-formatted: `,(0,x.jsx)(`span`,{className:`font-mono`,children:t.join(`, `)})]}),r.map((e,t)=>(0,x.jsxs)(`div`,{className:`mt-1 font-mono text-xs text-destructive-foreground`,children:[e.component||e.uid,`: `,e.error||e.message||`does not compile`]},t)),e.ok&&(0,x.jsxs)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:[`Prettier, lint, `,n.length,` compile`,n.length===1?``:`s`,` on the instance, the dry run`,e.updateSet?` and the update set`:``,`: all clear.`]})]})}function MZ({projectId:e,entry:t}){let n=U(Au().push.diff.queryOptions({projectId:e,keys:[t.key]})),r=n.data?.entries||[];return(0,x.jsxs)(`div`,{className:`ms-7 me-2 mb-2 rounded-lg border bg-muted/30 p-2 text-xs`,children:[n.isLoading&&(0,x.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,x.jsx)(Yb,{size:`xs`,muted:!0}),` Reading both sides…`]}),n.error&&(0,x.jsx)(`div`,{className:`text-destructive-foreground`,children:n.error.message}),!n.isLoading&&!r.length&&!n.error&&(0,x.jsx)(`div`,{className:`text-muted-foreground`,children:`No content difference to show (metadata only).`}),r.map(e=>(0,x.jsxs)(`div`,{className:`mb-2 last:mb-0`,children:[r.length>1&&(0,x.jsx)(`div`,{className:`mb-1 font-mono text-muted-foreground`,children:e.id}),e.note&&(0,x.jsx)(`div`,{className:`mb-1 text-warning-foreground`,children:e.note}),(0,x.jsx)(`div`,{className:`grid gap-2 md:grid-cols-2`,children:(e.diffs||[]).map((e,t)=>(0,x.jsxs)(`div`,{className:`min-w-0 rounded-md border bg-background`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b px-2 py-1 text-2xs font-medium text-muted-foreground`,children:[e.to===`instance`?(0,x.jsx)(Xd,{className:`size-3`}):(0,x.jsx)(Nf,{className:`size-3`}),e.from,` → `,e.to===`local`?`mine`:e.to]}),(0,x.jsx)(NZ,{d:e})]},t))})]},e.id))]})}function NZ({d:e}){return e.unavailable?(0,x.jsx)(`div`,{className:`px-2 py-1.5 text-muted-foreground`,children:e.unavailable}):e.binary?(0,x.jsx)(`div`,{className:`px-2 py-1.5 text-muted-foreground`,children:`binary file changed`}):e.created?(0,x.jsx)(`div`,{className:`px-2 py-1.5 text-success-foreground`,children:`created`}):e.removed?(0,x.jsx)(`div`,{className:`px-2 py-1.5 text-destructive-foreground`,children:`removed`}):Array.isArray(e.fields)?(0,x.jsx)(`div`,{className:`px-2 py-1.5 font-mono`,children:e.fields.map(t=>(0,x.jsxs)(`div`,{className:`truncate`,children:[(0,x.jsxs)(`span`,{className:`text-muted-foreground`,children:[t.path,`: `]}),(0,x.jsx)(`span`,{className:`text-destructive-foreground line-through decoration-destructive/40`,children:PZ(t[e.from])}),` `,(0,x.jsx)(`span`,{className:`text-success-foreground`,children:PZ(t[e.to])})]},t.path))}):typeof e.diff==`string`?(0,x.jsx)(`pre`,{className:`max-h-64 overflow-auto px-2 py-1.5 font-mono text-2xs leading-relaxed`,children:e.diff.split(`
|
|
289
289
|
`).filter(e=>!/^(---|\+\+\+) /.test(e)).map((e,t)=>(0,x.jsx)(`div`,{className:G(e.startsWith(`+`)&&`bg-success/8 text-success-foreground`,e.startsWith(`-`)&&`bg-destructive/8 text-destructive-foreground`,e.startsWith(`@@`)&&`text-info-foreground`),children:e||` `},t))}):(0,x.jsx)(`div`,{className:`px-2 py-1.5 text-muted-foreground`,children:`changed`})}function PZ(e){let t=typeof e==`string`?e:JSON.stringify(e);return t===void 0?`—`:t.length>80?`${t.slice(0,77)}…`:t}function FZ(e,t){if(!e||!t)return null;let n,r;try{n=new URL(e),r=new URL(t)}catch{return null}if(n.port!==r.port||!/^(127\.0\.0\.1|localhost)$/.test(n.hostname)||!n.pathname.startsWith(`/x/`))return null;let i=/\/params\/(?:.*\/)?page-id\/([^/]+)/.exec(n.pathname)?.[1];return{path:n.pathname+n.search,label:i?`/${decodeURIComponent(i)}`:`Home`}}function IZ({projectId:e,dev:t,onRestart:n}){let r=Au(),[i,a]=b.useState(null),[o,s]=b.useState(0),[c,l]=b.useState(``),[u,d]=b.useState(``),f=t&&(t.state===`running`||t.state===`attached`)&&t.enterUrl,p=f?`${t.enterUrl}${c?`&to=${encodeURIComponent(c)}`:``}`:``,m=U(r.agent.info.queryOptions({projectId:e})),h=f?FZ(m.data?.url,t.url):null,[g,_]=b.useState(``),v=h&&h.path!==c&&h.path!==g&&(h.label!==`Home`||c)?h:null;return(0,x.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,x.jsxs)(`div`,{className:`flex h-9 shrink-0 items-center gap-1 border-b px-2`,children:[(0,x.jsx)(Tb,{label:`Reload`,children:(0,x.jsx)(`button`,{disabled:!f,onClick:()=>s(o+1),className:`inline-flex size-6 items-center justify-center rounded-md text-icon-muted hover:bg-accent hover:text-foreground disabled:opacity-50`,children:(0,x.jsx)($p,{className:`size-3.5`})})}),(0,x.jsx)(`form`,{className:`min-w-0 flex-1`,onSubmit:e=>{e.preventDefault(),l(u.startsWith(`/`)?u:u?`/`+u:``),s(o+1)},children:(0,x.jsx)(`input`,{value:u,onChange:e=>d(e.target.value),disabled:!f,placeholder:f?`portal home`:``,className:`h-6 w-full rounded-md bg-accent px-2 font-mono text-xs text-muted-foreground outline-none placeholder:text-muted-foreground/60 focus:text-foreground`})}),[390,768,1440].map(e=>(0,x.jsx)(`button`,{onClick:()=>a(i===e?null:e),className:G(`h-6 rounded-md px-1.5 text-2xs text-muted-foreground tabular-nums hover:bg-accent`,i===e&&`bg-accent text-foreground`),children:e},e)),(0,x.jsx)(Tb,{label:`Open in a tab`,children:(0,x.jsx)(`a`,{href:p||void 0,target:`_blank`,rel:`noreferrer`,className:`inline-flex size-6 items-center justify-center rounded-md text-icon-muted hover:bg-accent hover:text-foreground`,children:(0,x.jsx)(df,{className:`size-3.5`})})})]}),(0,x.jsxs)(`div`,{className:`relative min-h-0 flex-1 overflow-auto bg-muted`,children:[v&&(0,x.jsxs)(`div`,{className:`absolute top-2 left-1/2 z-10 flex -translate-x-1/2 items-center gap-0.5 rounded-full border bg-popover/90 py-0.5 pr-0.5 pl-2.5 text-xs shadow-md backdrop-blur-md`,children:[(0,x.jsx)(xp,{className:`size-3 text-icon-muted`}),(0,x.jsx)(`span`,{className:`ml-1 text-muted-foreground`,children:`Agent is on`}),(0,x.jsxs)(`button`,{onClick:()=>{l(v.path),d(v.path),s(o+1)},className:`ml-0.5 rounded-full px-1.5 py-0.5 font-medium text-foreground hover:bg-accent`,children:[`Open `,v.label]}),(0,x.jsx)(Tb,{label:`Dismiss`,children:(0,x.jsx)(`button`,{onClick:()=>_(v.path),"aria-label":`Dismiss`,className:`inline-flex size-5 items-center justify-center rounded-full text-icon-muted hover:bg-accent hover:text-foreground`,children:(0,x.jsx)(Gm,{className:`size-3`})})})]}),f?(0,x.jsx)(`iframe`,{src:p,title:`Preview`,className:`mx-auto h-full border-0 bg-white`,style:{width:i?`${i}px`:`100%`}},o):t?.state===`starting`?(0,x.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,x.jsx)(`div`,{className:`skeleton m-4 h-10 rounded-lg bg-foreground/6`}),(0,x.jsx)(`div`,{className:`skeleton mx-4 h-40 rounded-lg bg-foreground/6`}),(0,x.jsx)(`pre`,{className:`mt-auto max-h-40 overflow-hidden px-4 pb-3 font-mono text-2xs leading-relaxed whitespace-pre-wrap text-secondary-label`,children:t.log.slice(-8).join(`
|
|
290
|
-
`)||`Starting the dev server…`})]}):t?.state===`failed`?(0,x.jsx)(b8,{icon:Wd,title:t.code===`no_profile`?`No profile for this instance`:t.code===`no_portal`?`Nothing to preview`:`The dev server failed`,actions:t.code===`no_portal`?null:(0,x.jsxs)(x.Fragment,{children:[t.code===`no_profile`&&(0,x.jsx)(a8,{section:`instances`,children:(0,x.jsx)(q,{size:`sm`,variant:`outline`,children:`Add a profile`})}),(0,x.jsxs)(q,{size:`sm`,variant:`outline`,onClick:n,children:[(0,x.jsx)($p,{}),` Restart`]})]}),children:t.error}):(0,x.jsx)(b8,{icon:hp,title:`No preview yet`,children:`The project’s portal appears here, live, once its dev server is running.`})]}),f&&(0,x.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 border-t px-3 py-1 text-2xs text-muted-foreground`,children:[(0,x.jsx)(`span`,{className:`size-1.5 rounded-full bg-success`}),`your session · live data (not read-only)`,t.state===`attached`&&(0,x.jsx)(`span`,{className:`ml-auto`,children:`attached to your rpf dev`})]})]})}var LZ=[{id:`preview`,label:`Preview`,icon:md},{id:`agent`,label:`Agent`,icon:xp},{id:`diff`,label:`Diff`,icon:_f},{id:`files`,label:`Files`,icon:Tf},{id:`terminal`,label:`Terminal`,icon:Cm},{id:`problems`,label:`Problems`,icon:Wd},{id:`plan`,label:`Push plan`,icon:zm}],RZ={agent:{icon:xp,title:`The agent’s browser`,text:`A live view of the read-only browser the agent uses to look at and click through the portal.`},diff:{icon:_f,title:`No changes yet`,text:`Every edit the agent makes shows here, per turn or for the session, with undo.`},files:{icon:Tf,title:`Files`,text:`The project tree, with changed files marked.`},terminal:{icon:Cm,title:`Terminal`,text:`Your shell in the project folder, and live views of the agent’s commands.`},problems:{icon:Wd,title:`No problems`,text:`Compile errors, missing components and console errors from the preview show here.`},plan:{icon:zm,title:`No push plan`,text:`Check and plan a push to the instance; every push is reviewed in a dialog before it runs.`}};function zZ(e,t,n,r,i,a){let o=new Set(e);for(let t of e){let e=Zu(t);e&&iZ(a,e)}let s=t.filter(e=>!o.has(e)),c=e.filter(e=>!Zu(e)),l=i.filter(e=>!o.has(`file:${e}`));if(!s.length)return Wu({panelOpen:!1,openFiles:l,closedTabs:[...r,...c]});let u=n;if(o.has(n)){let e=t.indexOf(n);u=t.slice(e).find(e=>!o.has(e))??t.slice(0,e).reverse().find(e=>!o.has(e))}Wu({closedTabs:[...r,...c],openFiles:l,panelTab:u})}var BZ=b.lazy(()=>NJ(()=>import(`./file-panel-BKKQ3JJL.js`).then(e=>({default:e.FilePanel})),__vite__mapDeps([12,9,3,1,5,7]))),VZ=e=>e.slice(e.lastIndexOf(`/`)+1);function HZ({projectId:e,dev:t,onRestart:n}){let r=Gu(),i=RZ[r.panelTab],a=r.openFiles||[];lZ();let[o,s]=b.useState(null),c=r.closedTabs||[];b.useEffect(()=>{c.includes(r.panelTab)&&Wu({closedTabs:c.filter(e=>e!==r.panelTab)})},[r.panelTab,c]);let l=LZ.filter(e=>!c.includes(e.id)||e.id===r.panelTab),u=LZ.filter(e=>!l.includes(e)),d=[...l.map(e=>e.id),...a.map(e=>`file:${e}`)],f=t=>zZ(t,d,r.panelTab,c,a,e),p=e=>f([e]),m=[...l.map(e=>({id:e.id,label:e.label,icon:(0,x.jsx)(e.icon,{className:`size-3`})})),...a.map(t=>({id:`file:${t}`,label:VZ(t),title:t,icon:(0,x.jsx)(u9,{path:t,className:`size-3`}),pending:oZ(e,t)}))],h=o?d.indexOf(o.id):-1,g=o?[...Zu(o.id)?[{id:`copy-path`,label:`Copy path`}]:[],{id:`close`,label:`Close`},{id:`close-others`,label:`Close others`,disabled:d.length<=1},{id:`close-to-right`,label:`Close to the right`,disabled:h>=d.length-1},{id:`close-all`,label:`Close all`,disabled:d.length===0}]:[],_=e=>{if(!o)return;let t=o.id;s(null),e===`copy-path`?navigator.clipboard.writeText(Zu(t)||``):e===`close`?p(t):e===`close-others`?f(d.filter(e=>e!==t)):e===`close-to-right`?f(d.slice(d.indexOf(t)+1)):e===`close-all`&&f(d)},v=WZ(),y=(0,x.jsxs)(`section`,{className:G(`relative flex h-full shrink-0 flex-col bg-background`,v?`w-full bg-popover`:`border-l`),style:v?void 0:{width:r.panelWidth},children:[(0,x.jsxs)(`div`,{className:`flex h-[var(--topbar-h)] shrink-0 items-center gap-1 overflow-x-auto pl-2 [scrollbar-width:none]`,children:[m.map(e=>(0,x.jsxs)(`div`,{onClick:t=>{t.target===t.currentTarget&&Wu({panelTab:e.id})},onAuxClick:t=>{t.button===1&&p(e.id)},onContextMenu:t=>{t.preventDefault(),s({at:{x:t.clientX,y:t.clientY},id:e.id})},title:e.title,className:G(`group/tab flex h-6 max-w-36 shrink-0 cursor-pointer items-center gap-0.5 rounded-md pr-2 pl-1.5 text-xs`,r.panelTab===e.id?`bg-accent text-foreground`:`text-muted-foreground hover:bg-accent/60 hover:text-foreground`),children:[(0,x.jsxs)(`button`,{type:`button`,"aria-label":`Close ${e.label}`,onClick:()=>p(e.id),className:`group/close relative flex size-4 shrink-0 cursor-pointer items-center justify-center rounded-sm hover:bg-muted`,children:[(0,x.jsx)(`span`,{className:`flex group-hover/tab:hidden group-focus-visible/close:hidden`,children:e.icon}),e.pending&&(0,x.jsx)(`span`,{className:`absolute -right-0.5 -bottom-0.5 size-1.5 rounded-full bg-current group-hover/tab:hidden`,"aria-hidden":!0}),(0,x.jsx)(Gm,{className:`hidden size-3 group-hover/tab:block group-focus-visible/close:block`})]}),(0,x.jsx)(`button`,{type:`button`,"aria-pressed":r.panelTab===e.id,onClick:()=>Wu({panelTab:e.id}),className:`flex min-w-0 cursor-pointer items-center`,children:(0,x.jsx)(`span`,{className:`truncate`,children:e.label})})]},e.id)),u.length>0&&(0,x.jsxs)(mb,{children:[(0,x.jsx)(hb,{render:(0,x.jsx)(q,{"aria-label":`Open a tab`,title:`Open a tab`,className:`shrink-0`,size:`icon-xs`,variant:`ghost-muted`}),children:(0,x.jsx)(qp,{className:`size-3.5`})}),(0,x.jsx)(gb,{align:`start`,sideOffset:6,children:u.map(e=>(0,x.jsxs)(_b,{onClick:()=>Wu({panelTab:e.id}),children:[(0,x.jsx)(e.icon,{}),e.label]},e.id))})]})]}),(0,x.jsx)(`div`,{className:`min-h-0 flex-1 border-t`,children:r.panelTab===`preview`?(0,x.jsx)(IZ,{projectId:e,dev:t,onRestart:n}):r.panelTab===`agent`?(0,x.jsx)(hZ,{projectId:e}):r.panelTab===`terminal`?(0,x.jsx)(_Z,{projectId:e}):r.panelTab===`diff`?(0,x.jsx)(SZ,{projectId:e}):Zu(r.panelTab)?(0,x.jsx)(b.Suspense,{fallback:null,children:(0,x.jsx)(BZ,{projectId:e,path:Zu(r.panelTab)},r.panelTab)}):r.panelTab===`plan`?(0,x.jsx)(AZ,{projectId:e}):r.panelTab===`files`?(0,x.jsx)(b.Suspense,{fallback:null,children:(0,x.jsx)(BZ,{projectId:e,path:null})}):i?(0,x.jsx)(b8,{icon:i.icon,title:i.title,children:i.text}):null}),(0,x.jsx)(OZ,{at:o?.at??null,items:g,onPick:_,onClose:()=>s(null)}),!v&&(0,x.jsx)(KZ,{})]});return v?(0,x.jsx)(GZ,{children:y}):y}var UZ=`(max-width: 980px)`;function WZ(){let[e,t]=b.useState(()=>window.matchMedia(UZ).matches);return b.useEffect(()=>{let e=window.matchMedia(UZ),n=()=>t(e.matches);return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}function GZ({children:e}){return(0,x.jsx)(U6,{open:!0,onOpenChange:(e,t)=>{if(!e){if(t.reason===`escape-key`&&t.event?.repeat)return t.cancel();Wu({panelOpen:!1})}},children:(0,x.jsxs)(I6,{children:[(0,x.jsx)(D6,{className:`fixed inset-0 z-40 bg-background/60 backdrop-blur-xs transition-all duration-200 data-[ending-style]:opacity-0 data-[starting-style]:opacity-0`}),(0,x.jsx)(`div`,{className:`fixed inset-0 z-40 flex justify-end`,"data-slot":`sheet-viewport`,children:(0,x.jsx)(F6,{"aria-label":`Workspace panel`,className:`relative flex h-full max-h-full w-[min(42vw,28rem)] max-w-[28rem] min-w-80 flex-col border-s bg-popover text-popover-foreground shadow-lg/5 transition-[opacity,translate] duration-200 ease-in-out will-change-transform data-[ending-style]:translate-x-8 data-[ending-style]:opacity-0 data-[starting-style]:translate-x-8 data-[starting-style]:opacity-0 max-[760px]:w-[min(88vw,24rem)] max-[760px]:min-w-0`,children:e})})]})})}function KZ(){return(0,x.jsx)(`div`,{onPointerDown:e=>{e.preventDefault();let t=e=>{let t=window.innerWidth-e.clientX;Wu({panelWidth:Math.min(window.innerWidth*.7,Math.max(360,t))})},n=()=>{window.removeEventListener(`pointermove`,t),window.removeEventListener(`pointerup`,n),document.body.style.cursor=``};document.body.style.cursor=`col-resize`,window.addEventListener(`pointermove`,t),window.addEventListener(`pointerup`,n)},className:`group absolute top-0 -left-2 z-10 flex h-full w-4 cursor-col-resize justify-center`,children:(0,x.jsx)(`div`,{className:`h-full w-0.5 transition-colors group-hover:bg-border`})})}function qZ(e=``){return e.replace(/^x_\d+_portal_/,``).replace(/^sys_/,``)}var JZ=/^(server_script|script|server_js|server\.js)$/;function YZ({verb:e,tone:t,item:n}){let r=Object.keys(n.changes||n.fields||{}).filter(e=>e!==`sys_updated_on`),i=r.some(e=>JZ.test(e)),a=n.changes?.revision;return(0,x.jsxs)(`div`,{className:`grid grid-cols-[6.5rem_minmax(0,1fr)] gap-x-2 py-0.5`,children:[(0,x.jsx)(`span`,{className:G(`font-medium`,t),children:e}),(0,x.jsxs)(`div`,{className:`min-w-0`,children:[(0,x.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,x.jsx)(`span`,{className:`text-muted-foreground`,children:qZ(n.table)}),(0,x.jsx)(`span`,{className:`truncate text-foreground`,children:n.display||n.path||n.id}),a&&(0,x.jsxs)(`span`,{className:`ms-auto shrink-0 text-muted-foreground tabular-nums`,children:[`rev `,String(a.from),` → `,String(a.to)]})]}),r.length>0&&e!==`DEACTIVATE`&&(0,x.jsx)(`div`,{className:`truncate text-muted-foreground`,children:r.filter(e=>e!==`revision`).join(`, `)}),i&&(0,x.jsxs)(`div`,{className:`flex items-center gap-1 text-warning-foreground`,children:[(0,x.jsx)(Lm,{className:`size-3 shrink-0`}),` server script: runs on the instance as each visitor`]})]})]})}function XZ({chunks:e}){let t=t=>e.flatMap(e=>e[t]||[]),n=e.flatMap(e=>e.compile?.components||[]),r=e.map(e=>e.compile?.theme).filter(Boolean),i=e.some(e=>e.compile?.finalize?.reprocess),a=[];return t(`creates`).length||a.push(`nothing created`),t(`deactivates`).length||a.push(`nothing deactivated`),t(`deletes`).length||a.push(`no files removed`),(0,x.jsxs)(`div`,{className:`rounded-lg border bg-muted/40 px-3 py-2 font-mono text-xs`,children:[e.map((t,n)=>(0,x.jsxs)(`div`,{className:G(n>0&&`mt-2 border-t border-border/60 pt-2`),children:[e.length>1&&(0,x.jsxs)(`div`,{className:`mb-0.5 text-2xs tracking-wide text-muted-foreground uppercase`,children:[`chunk `,n+1,` of `,e.length]}),(t.creates||[]).map((e,t)=>(0,x.jsx)(YZ,{verb:`CREATE`,tone:`text-success-foreground`,item:e},`c${t}`)),(t.updates||[]).map((e,t)=>(0,x.jsx)(YZ,{verb:`UPDATE`,tone:`text-info-foreground`,item:e},`u${t}`)),(t.deactivates||[]).map((e,t)=>(0,x.jsx)(YZ,{verb:`DEACTIVATE`,tone:`text-warning-foreground`,item:e},`d${t}`)),(t.deletes||[]).map((e,t)=>(0,x.jsx)(YZ,{verb:`DELETE FILE`,tone:`text-destructive-foreground`,item:e},`x${t}`)),(t.compile?.components||[]).map(e=>(0,x.jsxs)(`div`,{className:`grid grid-cols-[6.5rem_minmax(0,1fr)] gap-x-2 py-0.5`,children:[(0,x.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:`COMPILE`}),(0,x.jsx)(`span`,{className:`truncate`,children:e})]},`k${e}`))]},n)),r.length>0&&(0,x.jsxs)(`div`,{className:`grid grid-cols-[6.5rem_minmax(0,1fr)] gap-x-2 py-0.5`,children:[(0,x.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:`THEME`}),(0,x.jsx)(`span`,{children:r.join(`, `)})]}),i&&(0,x.jsxs)(`div`,{className:`grid grid-cols-[6.5rem_minmax(0,1fr)] gap-x-2 py-0.5`,children:[(0,x.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:`REPROCESS`}),(0,x.jsx)(`span`,{children:`the portal (once, at the end)`})]}),!n.length&&!i&&!e.some(e=>(e.updates||[]).length)&&(0,x.jsx)(`div`,{className:`py-0.5 text-muted-foreground`,children:`No writes.`}),a.length>0&&(0,x.jsxs)(`div`,{className:`mt-1 text-muted-foreground`,children:[a.join(`, `),`.`]})]})}function ZZ({overwrites:e,slug:t,typed:n,onType:r}){return(0,x.jsxs)(`div`,{className:`rounded-lg border border-destructive/40 bg-destructive/6 px-3 py-2.5 dark:bg-destructive/12`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium text-destructive-foreground`,children:[(0,x.jsx)(Lm,{className:`size-4`}),` Force push: these instance changes are overwritten`]}),e.length===0?(0,x.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:`No instance-side changes to overwrite.`}):(0,x.jsx)(`div`,{className:`mt-1.5 max-h-44 overflow-auto font-mono text-xs`,children:e.map((e,t)=>(0,x.jsxs)(`div`,{className:`py-0.5`,children:[(0,x.jsxs)(`div`,{className:`flex gap-2`,children:[(0,x.jsx)(`span`,{className:`truncate text-foreground`,children:e.id}),(0,x.jsx)(`span`,{className:`ms-auto shrink-0 text-muted-foreground`,children:[e.updatedBy,e.updatedOn].filter(Boolean).join(` · `)})]}),(e.fields||[]).slice(0,6).map(e=>(0,x.jsxs)(`div`,{className:`truncate ps-3 text-muted-foreground`,children:[e.path,`: `,(0,x.jsx)(`span`,{className:`text-destructive-foreground`,children:$Z(e.instance)}),` → `,(0,x.jsx)(`span`,{className:`text-foreground`,children:$Z(e.file)})]},e.path)),e.diff&&(0,x.jsx)(`div`,{className:`ps-3 text-muted-foreground`,children:`file content differs`}),e.binary&&(0,x.jsx)(`div`,{className:`ps-3 text-muted-foreground`,children:`image replaced`})]},t))}),(0,x.jsxs)(`label`,{className:`mt-2.5 grid gap-1.5 text-xs`,children:[(0,x.jsxs)(`span`,{children:[`Type `,(0,x.jsx)(`span`,{className:`font-mono font-medium`,children:t||`(unknown portal)`}),` to confirm`]}),(0,x.jsx)(o5,{size:`compact`,mono:!0,value:n,onChange:e=>r(e.target.value),autoComplete:`off`})]})]})}function QZ(e){return/^Conflicts \(or records without a known base\)/.test(e)?`Conflicts are open (or records without a known base). Resolve them in the Push plan tab, or plan a force push to make the instance match the files.`:/merge conflict markers/i.test(e)?`Files still have merge conflict markers: finish the merge first.`:e.replace(/workspace_pull/g,`a pull`).replace(/workspace_push \{ dryRun: true \}/g,`a dry run`)}function $Z(e){let t=typeof e==`string`?e:JSON.stringify(e);return t===void 0?`—`:t.length>60?`${t.slice(0,57)}…`:t}function eQ({progress:e}){let t=e?e.phase===`finishing`?96:(e.chunk-1)/e.of*92+4:4;return(0,x.jsxs)(`div`,{className:`rounded-lg border px-3 py-2.5`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,x.jsx)(Yb,{size:`sm`}),e?e.phase===`finishing`?`Written. Moving the base to the instance…`:`Writing chunk ${e.chunk} of ${e.of}…`:`Checking the plan on the instance…`]}),(0,x.jsx)(`div`,{className:`mt-2 h-1 overflow-hidden rounded-full bg-foreground/8`,children:(0,x.jsx)(`div`,{className:`h-full rounded-full bg-primary transition-[width] duration-500`,style:{width:`${t}%`}})})]})}function tQ({projectId:e}){let t=Gu(),n=Au(),r=t.pushOpen,i=U(n.projects.info.queryOptions({id:e})),a=U({...n.push.state.queryOptions({projectId:e}),enabled:r}),o=at(n.push.plan.mutationOptions()),s=at(n.push.run.mutationOptions()),[c,l]=b.useState(!1),[u,d]=b.useState(``),[f,p]=b.useState(!1),[m,h]=b.useState(``),g=i.data?.facts;b.useEffect(()=>{r&&(s.reset(),o.mutate({projectId:e,force:c}))},[r,c]);let _=()=>{s.isPending||(Wu({pushOpen:!1}),l(!1),d(``),p(!1))},v=o.data?.result,y=v?.chunks||[],S=y.reduce((e,t)=>e+(t.creates?.length||0)+(t.updates?.length||0)+(t.deactivates?.length||0)+(t.deletes?.length||0),0),C=s.data?.result,w=a.data?.plan,T=!!w&&w.result?.planHash===v?.planHash&&!!w.stale||!!s.error&&/dry run again|changed since/i.test(s.error.message)||!!C?.refused&&/dry run again|changed since/i.test(C.reason||``),E=[...new Set(y.flatMap(e=>e.warnings||[]))].filter(e=>!/^Force push:/.test(e)),D=v?.instanceChangesLeftAlone||[],O=!!v?.planHash&&!v?.refused&&!v?.nothingToPush&&!s.isPending&&!C&&(!c||u===g?.portal),k=c?`Force push`:`Push`,A=S?`${S} ${S===1?`change`:`changes`}`:v?.pending?`and finish`:``;return(0,x.jsx)(Eb,{open:r,onOpenChange:e=>!e&&_(),children:(0,x.jsx)(Db,{className:`max-w-3xl`,title:`Push to ${g?.host||`the instance`}`,description:g?`${g.portal||`workspace`} → ${g.instance}${i.data?.profile?` · profile ${i.data.profile}`:``}`:void 0,footer:C&&!C.refused?C.failed?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(q,{variant:`outline`,onClick:_,children:`Close`}),(0,x.jsx)(q,{onClick:()=>{s.reset(),o.mutate({projectId:e,force:!1}),l(!1)},children:`Finish the push…`})]}):(0,x.jsx)(q,{onClick:_,children:`Done`}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(`label`,{className:`me-auto flex cursor-pointer items-center gap-2 text-xs text-muted-foreground select-none`,children:[(0,x.jsx)(c5,{checked:f,onCheckedChange:e=>p(!!e),disabled:s.isPending}),`Commit the files and forge.workspace.json after the push`]}),(0,x.jsx)(q,{variant:`outline`,onClick:_,disabled:s.isPending,children:`Cancel`}),T?(0,x.jsxs)(q,{disabled:o.isPending,onClick:()=>{s.reset(),o.mutate({projectId:e,force:c})},children:[o.isPending&&(0,x.jsx)(Yb,{size:`sm`}),`Re-run dry run`]}):(0,x.jsxs)(q,{variant:c?`destructive`:`default`,disabled:!O||f&&!m.trim(),onClick:()=>s.mutate({projectId:e,planHash:v.planHash,force:c,...c?{confirm:u}:{},...f?{commit:{message:m.trim()}}:{}}),children:[s.isPending?(0,x.jsx)(Yb,{size:`sm`}):(0,x.jsx)(zm,{}),k,` `,A]})]}),children:(0,x.jsxs)(`div`,{className:`flex flex-col gap-3 text-sm`,children:[g&&(0,x.jsxs)(`div`,{className:`grid grid-cols-[6.5rem_minmax(0,1fr)] gap-x-2 gap-y-1 text-xs`,children:[(0,x.jsx)(`span`,{className:`text-muted-foreground`,children:`App`}),(0,x.jsx)(`span`,{children:v?.app||g.scope}),(0,x.jsx)(`span`,{className:`text-muted-foreground`,children:`Update set`}),(0,x.jsxs)(`span`,{children:[v?.updateSet||g.updateSet||`—`,v?.planHash&&(0,x.jsx)(`span`,{className:`text-success-foreground`,children:` · in progress ✓`})]}),v?.planHash&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`span`,{className:`text-muted-foreground`,children:`planHash`}),(0,x.jsxs)(`span`,{children:[(0,x.jsx)(`span`,{className:`font-mono`,children:v.planHash}),(0,x.jsxs)(`span`,{className:`text-muted-foreground`,children:[` `,`· dry run `,bu(o.data?.at),` ·`,` `]}),T?(0,x.jsx)(`span`,{className:`text-warning-foreground`,children:`files changed since`}):(0,x.jsx)(`span`,{className:`text-success-foreground`,children:`files unchanged since ✓`})]})]})]}),o.isPending&&(0,x.jsxs)(`div`,{className:`flex items-center gap-2 py-6 text-muted-foreground`,children:[(0,x.jsx)(Yb,{size:`sm`}),` Running the dry run on the instance…`]}),o.error&&(0,x.jsx)(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/6 px-3 py-2 text-destructive-foreground`,children:o.error.message}),v?.refused&&!o.isPending&&(0,x.jsxs)(`div`,{className:`rounded-lg border border-warning/30 bg-warning/6 px-3 py-2.5`,children:[(0,x.jsxs)(`div`,{className:`font-medium text-warning-foreground`,children:[`Can’t push yet. `,QZ(v.reason)]}),Array.isArray(v.conflicts)&&v.conflicts.length>0&&(0,x.jsx)(`div`,{className:`mt-1.5 font-mono text-xs`,children:v.conflicts.slice(0,20).map(e=>(0,x.jsxs)(`div`,{className:`flex gap-2 py-0.5`,children:[(0,x.jsx)(`span`,{className:`truncate`,children:e.key}),(0,x.jsx)(`span`,{className:`ms-auto shrink-0 text-muted-foreground`,children:[e.updatedBy,e.updatedOn].filter(Boolean).join(` · `)})]},e.key))}),(0,x.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[(0,x.jsx)(q,{size:`xs`,variant:`outline`,onClick:()=>{_(),Wu({panelOpen:!0,panelTab:`plan`})},children:`Resolve in Push plan`}),!c&&Array.isArray(v.conflicts)&&(0,x.jsx)(q,{size:`xs`,variant:`destructive-outline`,onClick:()=>l(!0),children:`Plan a force push…`})]})]}),v?.nothingToPush&&!o.isPending&&(0,x.jsxs)(`div`,{className:`flex items-center gap-2 py-4 text-muted-foreground`,children:[(0,x.jsx)(Bd,{className:`size-4 text-success-foreground`}),` Nothing to push: the instance has everything.`]}),v?.planHash&&!o.isPending&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`div`,{className:`mb-1.5 text-xs font-medium text-muted-foreground`,children:`Planned writes`}),(0,x.jsx)(XZ,{chunks:y})]}),v.pending&&(0,x.jsxs)(`div`,{className:`flex items-start gap-2 text-xs text-info-foreground`,children:[(0,x.jsx)(qf,{className:`mt-0.5 size-3.5 shrink-0`}),`Also finishes the last push: the compiles and reprocess it still owed.`]}),E.map(e=>(0,x.jsxs)(`div`,{className:`flex items-start gap-2 text-xs text-warning-foreground`,children:[(0,x.jsx)(Lm,{className:`mt-0.5 size-3.5 shrink-0`}),` `,e]},e)),D.length>0&&(0,x.jsxs)(`div`,{className:`flex items-start gap-2 text-xs text-muted-foreground`,children:[(0,x.jsx)(qf,{className:`mt-0.5 size-3.5 shrink-0`}),D.length,` instance change`,D.length===1?``:`s`,` left alone (`,D.slice(0,3).map(e=>e.id).join(`, `),D.length>3?`, …`:``,`): a pull takes them.`]}),(v.problems||[]).map(e=>(0,x.jsxs)(`div`,{className:`flex items-start gap-2 text-xs text-warning-foreground`,children:[(0,x.jsx)(Lm,{className:`mt-0.5 size-3.5 shrink-0`}),` `,e]},e))]}),c&&v?.planHash&&!o.isPending&&(0,x.jsx)(ZZ,{overwrites:v.overwrites||[],slug:g?.portal||``,typed:u,onType:d}),f&&!C&&(0,x.jsx)(o5,{size:`compact`,value:m,onChange:e=>h(e.target.value),placeholder:`Commit message, e.g. feat: stalled deals KPI`,"aria-label":`Commit message`}),s.isPending&&(0,x.jsx)(eQ,{progress:a.data?.progress||null}),s.error&&!T&&(0,x.jsx)(`div`,{className:`text-destructive-foreground`,children:s.error.message}),T&&(s.error||C?.refused)&&(0,x.jsx)(`div`,{className:`text-warning-foreground`,children:s.error?.message||C?.reason}),C&&!C.refused&&(0,x.jsx)(nQ,{done:C,commit:s.data?.commit}),(0,x.jsxs)(`div`,{className:`flex items-start gap-2 text-xs text-muted-foreground`,children:[(0,x.jsx)(qf,{className:`mt-0.5 size-3.5 shrink-0`}),`Pushes aren’t undone by Forge. To roll back, revert the files and push again.`]})]})})})}function nQ({done:e,commit:t}){if(e.failed)return(0,x.jsxs)(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/6 px-3 py-2.5`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-1.5 font-medium text-destructive-foreground`,children:[(0,x.jsx)(Kd,{className:`size-4`}),` Chunk `,e.failed.chunk,` of `,e.failed.of,` failed:`,` `,e.failed.message]}),(0,x.jsxs)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:[e.failed.chunk>1?`Chunks 1–${e.failed.chunk-1} were written. `:``,e.note]}),e.rebased>0&&(0,x.jsxs)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:[e.rebased,` written record(s) now match the files: their base moved to the instance.`]})]});let n=e.status?.counts||{};return(0,x.jsxs)(`div`,{className:`rounded-lg border px-3 py-2.5`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-1.5 font-medium text-success-foreground`,children:[(0,x.jsx)(Bd,{className:`size-4`}),` Pushed `,e.pushed,` file`,e.pushed===1?``:`s`,` and record`,e.pushed===1?``:`s`,e.ms?(0,x.jsxs)(`span`,{className:`font-normal text-muted-foreground`,children:[` · `,(e.ms/1e3).toFixed(1),` s`]}):null]}),(0,x.jsxs)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:[e.status?.clean?`The workspace is clean: the new base is the instance.`:`The new base is the instance for what was pushed. Still open: ${n.local||0} local, ${n.instance||0} instance, ${n.conflicts||0} conflicts.`,e.rebased?` ${e.rebased} record(s) rebased.`:``]}),Array.isArray(e.notConverged)&&e.notConverged.length>0&&(0,x.jsxs)(`div`,{className:`mt-1 text-xs text-warning-foreground`,children:[`Not matching after the push: `,e.notConverged.map(e=>e.id).join(`, `)]}),e.overwritten&&(0,x.jsxs)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:[`The overwritten instance values are kept in `,(0,x.jsx)(`span`,{className:`font-mono`,children:e.overwritten}),`.`]}),t&&(0,x.jsxs)(`div`,{className:G(`mt-1 text-xs`,t.ok?`text-muted-foreground`:`text-warning-foreground`),children:[`git: `,t.message]})]})}function rQ({projectId:e,chatId:t}){let n=Gu(),r=U(Au().projects.get.queryOptions({id:e})),i=o8(e);return b.useEffect(()=>{r.data&&(document.title=`rpf forge · ${r.data.name}`)},[r.data]),(0,x.jsxs)(`div`,{className:`flex min-w-0 flex-1`,children:[(0,x.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[t?(0,x.jsx)(WX,{projectId:e,chatId:t}):(0,x.jsx)(iQ,{projectId:e,name:r.data?.name||``}),(0,x.jsx)(vZ,{projectId:e})]}),n.panelOpen&&(0,x.jsx)(HZ,{projectId:e,dev:i.status,onRestart:i.restart}),(0,x.jsx)(tQ,{projectId:e})]})}function iQ({projectId:e,name:t}){let n=U(Au().settings.get.queryOptions()),r=JX(e),[i,a]=b.useState(null),o=n.data?.projects[e]?.chat||n.data?.defaults.chat||null,s=i||o;return(0,x.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,x.jsx)(qX,{title:`New chat`,projectName:t,projectId:e}),(0,x.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col px-3 sm:px-12`,children:[(0,x.jsx)(`div`,{className:`shrink-0`,style:{flexBasis:`max(0px, calc(50% - 5rem))`}}),(0,x.jsxs)(`div`,{className:`mx-auto flex w-full max-w-5xl flex-col items-center pb-4`,children:[(0,x.jsx)(fC,{}),(0,x.jsxs)(`h1`,{className:`text-center text-2xl font-normal tracking-tight text-foreground sm:text-3xl`,children:[`What should we build in `,(0,x.jsx)(`span`,{className:`font-medium`,children:t||`…`}),`?`]})]}),(0,x.jsx)(fS,{autoFocus:!0,model:s,onModel:a,onSend:e=>r(e,s),placeholder:`Describe a change, ask about the portal, or paste an error`})]})]})}function aQ({label:e,onClose:t,children:n}){let[r,i]=b.useState(!0),a=b.useRef(!1),o=b.useRef(null);return(0,x.jsx)(U6,{open:r,disablePointerDismissal:!0,onOpenChange:(e,t)=>{if(!e){if(t.reason===`escape-key`&&t.event.repeat)return t.cancel();i(!1)}},onOpenChangeComplete:e=>{e||t()},children:(0,x.jsxs)(I6,{children:[(0,x.jsx)(D6,{className:`dialog-backdrop fixed inset-0 z-50 transition-all duration-200 data-[ending-style]:opacity-0 data-[starting-style]:opacity-0`}),(0,x.jsx)(W6,{className:`fixed inset-0 z-50 flex items-center justify-center sm:p-6 lg:p-10`,onPointerDown:e=>{a.current=e.target===e.currentTarget},onClick:e=>{a.current&&e.target===e.currentTarget&&i(!1),a.current=!1},children:(0,x.jsx)(F6,{ref:o,initialFocus:o,"aria-label":e,className:`relative flex size-full min-h-0 min-w-0 flex-col overflow-hidden bg-background text-foreground outline-none transition-[opacity,scale] duration-150 ease-out data-[ending-style]:scale-[0.985] data-[ending-style]:opacity-0 data-[starting-style]:scale-[0.985] data-[starting-style]:opacity-0 sm:max-h-[60rem] sm:max-w-[80rem] sm:rounded-2xl sm:border sm:shadow-2xl/40`,children:n})})]})})}function oQ(){return(0,x.jsx)(Tb,{label:`Close (Esc)`,children:(0,x.jsx)(O6,{"aria-label":`Close`,render:(0,x.jsx)(q,{size:`icon-sm`,variant:`ghost`}),children:(0,x.jsx)(Gm,{})})})}function sQ(){let e=Fa({select:e=>e.location.pathname});return/^\/p\/([^/]+)/.exec(e)?.[1]||``}function cQ({label:e,onClick:t}){return(0,x.jsx)(Tb,{label:e,children:(0,x.jsx)(q,{size:`icon-xs`,variant:`ghost-muted`,"aria-label":e,onClick:t,children:(0,x.jsx)(Zp,{className:`size-3`})})})}function lQ({value:e,options:t,onChange:n,label:r}){return(0,x.jsx)(`div`,{role:`radiogroup`,"aria-label":r,className:`inline-flex rounded-[var(--control-radius)] border border-input p-0.5`,children:t.map(t=>(0,x.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":e===t.id,onClick:()=>n(t.id),className:G(`inline-flex h-6 items-center gap-1.5 rounded-md px-2.5 text-xs`,e===t.id?`bg-accent font-medium`:`text-muted-foreground hover:text-foreground`),children:t.label},t.id))})}function uQ(){let e=sQ(),[t,n]=b.useState(null),r=t??e;return r?(0,x.jsx)(pQ,{id:r,onBack:()=>n(``)}):(0,x.jsx)(dQ,{onPick:n})}function dQ({onPick:e}){let t=U(Au().projects.list.queryOptions()),n=t.data||[];return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(NS,{title:`Projects`,children:[n.length===0&&!t.isLoading&&(0,x.jsx)(`p`,{className:`px-4 py-8 text-center text-sm text-muted-foreground`,children:`No projects yet. Create or open one from the sidebar.`}),n.length>0&&(0,x.jsx)(`p`,{className:`px-3 pt-3 pb-1 text-xs text-muted-foreground sm:px-4`,children:`Choose a project to manage its name, model defaults and place in Forge.`}),n.map(t=>(0,x.jsxs)(`button`,{type:`button`,onClick:()=>e(t.id),className:`flex w-full min-w-0 cursor-pointer items-center gap-3 px-3 py-3 text-left outline-none first:rounded-t-xl last:rounded-b-xl hover:bg-accent/50 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset sm:px-4`,children:[(0,x.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded bg-foreground/8 text-[10px] font-semibold text-muted-foreground uppercase`,children:t.name.slice(0,1)}),(0,x.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,x.jsx)(`span`,{className:`block truncate text-sm font-medium`,children:t.name}),(0,x.jsxs)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:[t.missing?`Folder missing · `:``,t.path]})]}),(0,x.jsx)(Id,{className:`size-4 shrink-0 text-muted-foreground`})]},t.id))]}),(0,x.jsx)(fQ,{})]})}function fQ(){let e=Au(),t=C(),n=U(e.meta.queryOptions()),r=U(e.settings.get.queryOptions()),i=at(e.settings.setProjectsHome.mutationOptions({onSuccess:()=>t.invalidateQueries({queryKey:e.meta.queryKey()})})),a=r.data?.projectsHome,[o,s]=b.useState(null),c=o??a??``;return(0,x.jsx)(NS,{title:`New projects`,children:(0,x.jsxs)(PS,{title:`Projects folder`,description:(0,x.jsxs)(x.Fragment,{children:[`New portals are pulled into a folder here. Now:`,` `,(0,x.jsx)(`code`,{className:`font-mono`,children:n.data?.projectsHome}),i.error&&(0,x.jsx)(`span`,{className:`block text-destructive-foreground`,children:i.error.message})]}),children:[a&&(0,x.jsx)(cQ,{label:`Use the default folder`,onClick:()=>i.mutate({path:``})}),(0,x.jsx)(o5,{size:`compact`,mono:!0,className:`w-64`,placeholder:`~/rpf-projects`,"aria-label":`Projects folder`,value:c,onChange:e=>s(e.target.value),onBlur:()=>{o!==null&&o!==(a??``)&&i.mutate({path:o}),s(null)}})]})})}function pQ({id:e,onBack:t}){let n=Au(),r=i8(),i=U(n.projects.list.queryOptions()),a=i.data?.find(t=>t.id===e),o=U({...n.projects.info.queryOptions({id:e}),enabled:!!a}),s=U({...n.chats.list.queryOptions({projectId:e}),enabled:!!a}),c=U(n.settings.get.queryOptions()),l=at(n.projects.rename.mutationOptions()),u=at(n.projects.remove.mutationOptions()),[d,f]=b.useState(null),[p,m]=b.useState(!1);if(!a)return(0,x.jsx)(NS,{title:`Projects`,action:(0,x.jsx)(mQ,{onClick:t}),children:(0,x.jsx)(`p`,{className:`px-4 py-8 text-center text-sm text-muted-foreground`,children:i.isLoading?`Loading…`:`This project is no longer in Forge.`})});let h=o.data?.facts,g=c.data?.projects?.[e],_=a.name!==a.folderName;return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(NS,{title:a.name,action:(0,x.jsx)(mQ,{onClick:t}),children:[(0,x.jsxs)(PS,{title:`Name`,description:`Shown in the sidebar and the projects list. The folder keeps its name.`,children:[_&&(0,x.jsx)(cQ,{label:`Use the folder name`,onClick:()=>l.mutate({id:e,name:``})}),(0,x.jsx)(o5,{size:`compact`,className:`w-56`,"aria-label":`Project name`,value:d??a.name,onChange:e=>f(e.target.value),onBlur:()=>{d!==null&&d.trim()&&d.trim()!==a.name&&l.mutate({id:e,name:d.trim()}),f(null)}})]}),(0,x.jsx)(PS,{title:`Folder`,description:a.missing?(0,x.jsx)(`span`,{className:`text-warning-foreground`,children:`The folder no longer exists.`}):`Forge reads and edits files here. Chats live in the rpf home, never in the folder.`,children:(0,x.jsxs)(`code`,{className:`flex min-w-0 items-center gap-1.5 self-center font-mono text-xs text-muted-foreground`,children:[(0,x.jsx)(Df,{className:`size-3.5 shrink-0`}),(0,x.jsx)(`span`,{className:`truncate`,title:a.path,children:a.path})]})}),(0,x.jsx)(PS,{title:`Instance`,description:h?[h.scope&&`App ${h.appName||h.scope}`,h.updateSet&&`update set “${h.updateSet}”`].filter(Boolean).join(` · `)||`From forge.workspace.json`:`Not a React Portal workspace (no forge.workspace.json).`,children:h?.instance?o.data?.profile?(0,x.jsxs)(`span`,{className:`self-center text-xs`,children:[o.data.profile,` · `,h.host]}):(0,x.jsxs)(q,{size:`xs`,variant:`outline`,onClick:()=>r(`instances`),children:[`No profile for `,h.host,` · Add`]}):null}),(0,x.jsxs)(PS,{title:`Models`,description:g?.chat||g?.helper?`Overridden for this project: new chats here start with its own model.`:`Uses your defaults from Providers and models.`,children:[!!(g?.chat||g?.helper)&&(0,x.jsx)(kb,{variant:`info`,children:`Overridden`}),(0,x.jsx)(q,{size:`xs`,variant:`outline`,onClick:()=>r(`providers`),children:`Change`})]}),(0,x.jsx)(PS,{title:`Chats`,description:`Kept in the rpf home, keyed by this folder.`,children:(0,x.jsxs)(`span`,{className:`self-center text-xs text-muted-foreground tabular-nums`,children:[s.data?.length??`…`,` `,s.data?.length===1?`chat`:`chats`,o.data?.lastActivity?` · active ${yu(o.data.lastActivity)} ago`:``]})})]}),(0,x.jsx)(NS,{title:`Danger`,children:(0,x.jsx)(PS,{title:`Remove project`,description:`Removes the project from Forge. Its chats stay in the rpf home and files on disk are not touched.`,children:p?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(q,{size:`xs`,variant:`ghost-muted`,onClick:()=>m(!1),children:`Cancel`}),(0,x.jsxs)(q,{size:`xs`,variant:`destructive`,onClick:()=>u.mutate({id:e},{onSuccess:t}),children:[`Remove `,a.name]})]}):(0,x.jsx)(q,{size:`xs`,variant:`destructive-outline`,onClick:()=>m(!0),children:`Remove project`})})})]})}function mQ({onClick:e}){return(0,x.jsxs)(q,{size:`xs`,variant:`ghost-muted`,onClick:e,children:[(0,x.jsx)(gd,{}),` All projects`]})}function hQ({value:e}){return(0,x.jsx)(`span`,{className:`inline-flex items-center gap-0.5`,children:Fu(e).map((e,t)=>(0,x.jsx)(Ab,{children:e},t))})}function gQ(){let e=Au(),t=U(e.settings.get.queryOptions()),n=at(e.settings.setKeybinding.mutationOptions()),r=t.data?.keybindings||[],[i,a]=b.useState(``),o=Lu(r),s=i.trim().toLowerCase(),c=ju.filter(e=>!s||e.label.toLowerCase().includes(s)||e.id.toLowerCase().includes(s)||Iu(Mu(e,r)).toLowerCase().includes(s)),l=[...new Set(c.map(e=>e.group))];return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(NS,{title:`Keybindings`,action:(0,x.jsx)(Tb,{label:`The browser may claim some shortcuts first (Ctrl+N, Ctrl+W, Ctrl+T).`,children:(0,x.jsx)(q,{size:`icon-xs`,variant:`ghost-muted`,"aria-label":`The browser may claim some shortcuts first`,children:(0,x.jsx)(Lm,{className:`size-3.5 text-warning-foreground`})})}),children:(0,x.jsx)(`div`,{className:`flex items-center gap-2 px-3 py-3 sm:px-4`,children:(0,x.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,x.jsx)(am,{className:`pointer-events-none absolute top-1/2 left-2.5 z-10 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,x.jsx)(o5,{size:`compact`,className:`[&_input]:ps-7.5`,placeholder:`Search keybindings`,"aria-label":`Search keybindings`,value:i,onChange:e=>a(e.target.value)})]})})}),l.length===0&&(0,x.jsx)(`div`,{className:`rounded-xl border border-border/60 bg-card/40 px-4 py-12 text-center text-sm text-muted-foreground`,children:`No keybindings match your search.`}),l.map(e=>(0,x.jsx)(NS,{title:e,children:c.filter(t=>t.group===e).map(e=>(0,x.jsx)(_Q,{cmd:e,value:Mu(e,r),custom:r.some(t=>t.command===e.id),clashes:(o.get(Mu(e,r))||[]).filter(t=>t!==e.id),onSave:t=>n.mutate({command:e.id,key:t===e.key?null:t}),onReset:()=>n.mutate({command:e.id,key:null})},e.id))},e))]})}function _Q({cmd:e,value:t,custom:n,clashes:r,onSave:i,onReset:a}){let[o,s]=b.useState(!1),[c,l]=b.useState(null),u=b.useRef(null),d=c!==null&&c!==t,f=e=>ju.find(t=>t.id===e)?.label||e;return(0,x.jsxs)(`div`,{className:`group/row grid items-center gap-x-8 gap-y-2 px-3 py-3 sm:grid-cols-[minmax(0,1fr)_auto] sm:px-4`,children:[(0,x.jsxs)(`div`,{className:`min-w-0`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,title:e.id,children:[e.label,n&&(0,x.jsx)(kb,{variant:`outline`,children:`Custom`})]}),(0,x.jsx)(`div`,{className:`mt-0.5 text-xs text-muted-foreground`,children:!t&&!d?`No keyboard shortcut assigned. Click Unassigned to set one.`:n&&e.key?`Default: ${Iu(e.key)}`:e.inFields?`Works while typing too`:`Not while typing in a field`})]}),(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-1.5`,children:[r.length>0&&!d&&(0,x.jsx)(Tb,{label:`Conflicts with ${r.map(f).join(`, `)}.`,children:(0,x.jsx)(`span`,{tabIndex:0,"aria-label":`Conflicts with ${r.map(f).join(`, `)}`,className:`inline-flex size-6 items-center justify-center text-warning-foreground`,children:(0,x.jsx)(Lm,{className:`size-3.5`})})}),(0,x.jsx)(`span`,{className:`flex items-center opacity-0 transition-opacity group-focus-within/row:opacity-100 group-hover/row:opacity-100 has-[[data-popup-open]]:opacity-100`,children:(0,x.jsxs)(mb,{children:[(0,x.jsx)(hb,{render:(0,x.jsx)(q,{size:`icon-xs`,variant:`ghost-muted`,"aria-label":`Actions for ${e.label}`}),children:(0,x.jsx)(lf,{})}),(0,x.jsxs)(gb,{align:`end`,children:[(0,x.jsx)(_b,{disabled:!n,onClick:a,children:`Reset to default`}),(0,x.jsx)(_b,{disabled:!t,onClick:()=>i(``),children:`Unassign`})]})]})}),d&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(q,{size:`sm`,variant:`ghost-muted`,onClick:()=>l(null),children:`Cancel`}),(0,x.jsx)(q,{size:`sm`,onClick:()=>{i(c),l(null)},children:`Save`})]}),!o&&!d?(0,x.jsx)(`button`,{ref:u,type:`button`,onClick:()=>s(!0),"aria-label":`Edit shortcut for ${e.label}: ${t?Iu(t):`Unassigned`}`,className:`-mr-1.5 inline-flex h-7 cursor-pointer items-center rounded-md border border-transparent px-1.5 outline-none transition-colors hover:border-border/70 hover:bg-accent focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/24 focus-visible:ring-inset`,children:t?(0,x.jsx)(hQ,{value:t}):(0,x.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`Unassigned`})}):d&&!o?(0,x.jsx)(`button`,{type:`button`,onClick:()=>s(!0),className:`inline-flex h-7 items-center rounded-md border border-border/70 px-1.5`,"aria-label":`Record again`,children:(0,x.jsx)(hQ,{value:c})}):(0,x.jsx)(`span`,{"data-keybinding-capture":``,children:(0,x.jsx)(o5,{autoFocus:!0,size:`compact`,mono:!0,className:`w-44`,readOnly:!0,"aria-label":`Keybinding for ${e.label}`,placeholder:`Press shortcut`,value:``,onBlur:()=>s(!1),onKeyDown:e=>{if(e.key===`Tab`&&!o)return;if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`&&!e.shiftKey&&!e.altKey&&!e.ctrlKey&&!e.metaKey){l(null),s(!1),requestAnimationFrame(()=>u.current?.focus());return}let t=Pu(e.nativeEvent);t&&(l(t),s(!1))}})})]})]})}var vQ={layout:`stacked`,ignoreWhitespace:!1,colors:`red-green`};function yQ(){let e=Au(),t=U(e.settings.get.queryOptions()),n=at(e.settings.setDiffs.mutationOptions()),r={...vQ,...t.data?.diffs||{}};return(0,x.jsxs)(NS,{title:`Diffs`,children:[(0,x.jsxs)(PS,{title:`Diff layout`,description:`Show diffs stacked or side by side. The toggle in the Diff tab changes this too.`,children:[r.layout!==vQ.layout&&(0,x.jsx)(cQ,{label:`Reset diff layout to default`,onClick:()=>n.mutate({layout:`stacked`})}),(0,x.jsx)(lQ,{label:`Diff layout`,value:r.layout,options:[{id:`stacked`,label:`Stacked`},{id:`split`,label:`Side by side`}],onChange:e=>n.mutate({layout:e})})]}),(0,x.jsxs)(PS,{title:`Hide whitespace changes`,description:`Set whether diffs ignore whitespace-only edits by default.`,children:[r.ignoreWhitespace!==vQ.ignoreWhitespace&&(0,x.jsx)(cQ,{label:`Reset whitespace changes to default`,onClick:()=>n.mutate({ignoreWhitespace:!1})}),(0,x.jsx)(l5,{checked:r.ignoreWhitespace,"aria-label":`Hide whitespace changes by default`,onCheckedChange:e=>n.mutate({ignoreWhitespace:!!e})})]}),(0,x.jsxs)(PS,{title:`Diff colors`,description:`Choose colors for additions and deletions, including change counts.`,children:[r.colors!==vQ.colors&&(0,x.jsx)(cQ,{label:`Reset diff colors to default`,onClick:()=>n.mutate({colors:`red-green`})}),(0,x.jsx)(lQ,{label:`Diff colors`,value:r.colors,options:[{id:`red-green`,label:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(bQ,{a:`var(--destructive)`,b:`var(--success)`}),` Red & green`]})},{id:`blue-orange`,label:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(bQ,{a:`oklch(0.646 0.222 41.116)`,b:`oklch(0.546 0.245 262.881)`}),` Blue & orange`]})}],onChange:e=>n.mutate({colors:e})})]})]})}function bQ({a:e,b:t}){return(0,x.jsxs)(`span`,{"aria-hidden":!0,className:`flex shrink-0 gap-1`,children:[(0,x.jsx)(`span`,{className:`size-2 rounded-full`,style:{backgroundColor:e}}),(0,x.jsx)(`span`,{className:`size-2 rounded-full`,style:{backgroundColor:t}})]})}function xQ(){let e=Au(),t=i8(),n=U(e.meta.queryOptions()),r=U(e.about.update.queryOptions()),i=at(e.about.checkUpdate.mutationOptions()),a=at(e.settings.setOnboarded.mutationOptions()),o=Yi(),[s,c]=b.useState(!1),l=n.data?.version||``,u=i.data||r.data,d=u?u.disabled?`Update checks are off: ${u.disabled}.`:u.newer?`rpf ${u.latest} is available.${u.command?` Update with: ${u.command}`:``}`:u.checkedAt?`Up to date · checked ${yu(u.checkedAt)===`now`?`just now`:`${yu(u.checkedAt)} ago`}.`:`Current version of rpf.`:`Current version of rpf.`;return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(NS,{title:`App`,children:[(0,x.jsx)(PS,{title:(0,x.jsxs)(`span`,{className:`inline-flex items-baseline gap-2`,children:[`Version`,(0,x.jsx)(Tb,{label:s?`Copied`:`Copy version`,children:(0,x.jsxs)(`button`,{type:`button`,"aria-label":`Copy version ${l}`,onClick:()=>{navigator.clipboard?.writeText(l),c(!0),setTimeout(()=>c(!1),1500)},className:`inline-flex items-center gap-1 rounded font-mono text-2xs font-medium text-muted-foreground hover:text-foreground`,children:[l,(0,x.jsx)(ef,{className:`size-3`})]})})]}),description:(0,x.jsxs)(x.Fragment,{children:[d,i.error&&(0,x.jsx)(`span`,{className:`block text-destructive-foreground`,children:i.error.message})]}),children:(0,x.jsx)(q,{size:`sm`,variant:`outline`,disabled:i.isPending||!r.data||!!u?.disabled,onClick:()=>i.mutate(),children:i.isPending?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(Yb,{size:`xs`}),` Checking…`]}):i.data&&!i.data.newer&&i.data.latest?`Up to date`:`Check for updates`})}),(0,x.jsx)(PS,{title:`Welcome page`,description:`See your instances and AI providers, and start a first project.`,children:(0,x.jsx)(q,{size:`sm`,variant:`outline`,onClick:()=>a.mutate({done:!1},{onSuccess:()=>o({to:`/welcome`,search:{}})}),children:`Open`})}),u?.newer&&(0,x.jsx)(EQ,{st:u})]}),(0,x.jsx)(NS,{title:`Legal`,children:(0,x.jsx)(PS,{title:`Open-source licenses`,description:`Notices for the libraries bundled in Forge.`,children:(0,x.jsx)(q,{size:`sm`,variant:`outline`,onClick:()=>t(`licenses`),children:`View licenses`})})})]})}function SQ(){let e=U({...Au().about.notices.queryOptions(),retry:!1,staleTime:1/0}),[t,n]=b.useState(``),[r,i]=b.useState(!1),[a,o]=b.useState(null),s=e.data?.entries||[],c=t.trim().toLowerCase(),l=s.filter(e=>!c||e.name.toLowerCase().includes(c)||e.license.toLowerCase().includes(c)),u=(0,x.jsx)(`p`,{className:`text-xs font-normal whitespace-nowrap text-muted-foreground tabular-nums`,children:l.length===s.length?`${s.length} notices`:`${l.length} of ${s.length}`});return(0,x.jsx)(NS,{title:`Third-party notices`,action:e.data&&(r?(0,x.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,x.jsx)(`span`,{className:`hidden sm:block`,children:u}),(0,x.jsxs)(`div`,{className:`relative w-44`,children:[(0,x.jsx)(am,{className:`pointer-events-none absolute top-1/2 left-2.5 z-10 size-3 -translate-y-1/2 text-muted-foreground`}),(0,x.jsx)(o5,{autoFocus:!0,size:`compact`,className:`[&_input]:ps-7`,type:`search`,placeholder:`Search licenses`,"aria-label":`Search open-source licenses`,value:t,onChange:e=>n(e.target.value),onBlur:()=>!t&&i(!1),onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),n(``),i(!1))}})]})]}):(0,x.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[u,(0,x.jsx)(Tb,{label:`Search licenses`,children:(0,x.jsx)(q,{size:`icon-xs`,variant:`ghost-muted`,"aria-label":`Search open-source licenses`,onClick:()=>i(!0),children:(0,x.jsx)(am,{className:`size-3`})})})]})),children:e.error?(0,x.jsxs)(`div`,{className:`flex flex-col items-start gap-3 px-3 py-5 sm:px-4`,children:[(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`h3`,{className:`text-sm font-medium`,children:`Open-source notices are unavailable`}),(0,x.jsx)(`p`,{className:`mt-1 max-w-[70ch] text-xs text-muted-foreground/80`,children:e.error.message})]}),(0,x.jsx)(q,{size:`xs`,variant:`outline`,onClick:()=>e.refetch(),children:`Try again`})]}):e.data?l.length===0?(0,x.jsx)(`p`,{className:`px-3 py-8 text-center text-sm text-muted-foreground sm:px-4`,children:`No licenses match that search.`}):l.map(e=>{let t=`${e.name}@${e.version}`,n=a===t;return(0,x.jsxs)(`article`,{children:[(0,x.jsxs)(`div`,{className:`flex min-h-9 items-center hover:bg-muted/35`,children:[(0,x.jsxs)(`button`,{type:`button`,"aria-expanded":n,onClick:()=>o(n?null:t),className:`group flex min-h-9 min-w-0 flex-1 items-center gap-2.5 px-3 text-left text-sm outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset sm:px-4`,children:[(0,x.jsx)(Id,{"aria-hidden":!0,className:G(`size-3.5 shrink-0 text-muted-foreground transition-transform duration-200`,n&&`rotate-90`)}),(0,x.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-baseline gap-2`,children:[(0,x.jsx)(`span`,{className:`truncate font-medium`,children:e.name}),(0,x.jsx)(`code`,{className:`shrink-0 text-xs text-muted-foreground`,children:e.version})]}),(0,x.jsx)(`span`,{className:`max-w-[42%] shrink-0 truncate text-xs text-muted-foreground`,children:e.license||`see notice`})]}),(0,x.jsx)(Tb,{label:`Project page`,children:(0,x.jsx)(`a`,{href:e.sourceUrl,target:`_blank`,rel:`noreferrer noopener`,"aria-label":`View the project page for ${e.name}`,className:`me-3 inline-flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-foreground sm:me-4`,children:(0,x.jsx)(df,{"aria-hidden":!0,className:`size-3`})})})]}),n&&(0,x.jsx)(`div`,{className:`px-9 pt-1 pb-4 sm:px-10`,children:(0,x.jsx)(`pre`,{className:`max-w-[76ch] font-mono text-xs/5 break-words whitespace-pre-wrap text-foreground/80`,children:e.text})})]},t)}):(0,x.jsx)(`p`,{className:`px-3 py-5 text-sm text-muted-foreground sm:px-4`,children:`Loading open-source notices…`})})}function CQ({level:e}){return e===`ok`?(0,x.jsx)(Bd,{className:`size-4 text-success-foreground`}):e===`warn`?(0,x.jsx)(Lm,{className:`size-4 text-warning-foreground`}):e===`fail`?(0,x.jsx)(Kd,{className:`size-4 text-destructive-foreground`}):(0,x.jsx)(qf,{className:`size-4 text-muted-foreground`})}function wQ(){let e=Au(),t=sQ(),n=U({...e.profiles.list.queryOptions(),retry:!1}),r=U({...e.projects.info.queryOptions({id:t}),enabled:!!t}),i=at(e.tools.doctor.mutationOptions()),[a,o]=b.useState(``),[s,c]=b.useState(!1),l=(n.data?.profiles||[]).map(e=>e.name),u=a||r.data?.profile||n.data?.default||``,d=i.data?.checks||[],f=[`fail`,`warn`,`ok`].map(e=>[e,d.filter(t=>t.level===e).length]);return(0,x.jsxs)(NS,{title:`Doctor`,action:i.data&&(0,x.jsxs)(q,{size:`xs`,variant:`ghost-muted`,onClick:()=>{navigator.clipboard?.writeText(JSON.stringify(i.data,null,2)),c(!0),setTimeout(()=>c(!1),1500)},children:[(0,x.jsx)(ef,{}),` `,s?`Copied`:`Copy as JSON`]}),children:[(0,x.jsxs)(PS,{title:`Check this computer and an instance`,description:`Node, rpf's toolchain, git, the credential store, the profile and its token, the workspace, and the instance (Forge on, roles, API level, React Portal and Global Helpers versions).`,children:[(0,x.jsxs)(`select`,{"aria-label":`Profile`,value:u,onChange:e=>o(e.target.value),className:`h-7 rounded-md border border-input bg-background px-2 text-xs dark:bg-input/32`,children:[!l.length&&(0,x.jsx)(`option`,{value:``,children:`No profiles`}),l.map(e=>(0,x.jsx)(`option`,{value:e,children:e},e))]}),(0,x.jsx)(q,{size:`sm`,variant:`outline`,disabled:i.isPending,onClick:()=>i.mutate({profile:u||void 0,projectId:t||void 0}),children:i.isPending?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(Yb,{size:`xs`}),` Checking…`]}):i.data?`Run again`:`Run checks`})]}),i.error&&(0,x.jsx)(`p`,{className:`px-4 py-3 text-xs text-destructive-foreground`,children:i.error.message}),d.length>0&&(0,x.jsxs)(`div`,{className:`px-3 py-2 sm:px-4`,children:[(0,x.jsx)(`p`,{className:`pb-1 text-xs text-muted-foreground`,children:f.map(([e,t])=>`${t} ${e===`ok`?`ok`:e===`warn`?`warning`+(t===1?``:`s`):`failed`}`).join(` · `)}),d.map((e,t)=>(0,x.jsxs)(`div`,{className:`flex min-h-8 items-start gap-2.5 py-1`,children:[(0,x.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:(0,x.jsx)(CQ,{level:e.level})}),(0,x.jsxs)(`span`,{className:`min-w-0 text-sm`,children:[e.message,e.fix&&(0,x.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[`→ `,e.fix]})]})]},`${e.id}-${t}`))]})]})}function TQ(){let e=Au(),t=C(),n=sQ(),r=U({...e.tools.skills.queryOptions({projectId:n||void 0}),retry:!1}),i=at(e.tools.syncSkills.mutationOptions({onSuccess:()=>t.invalidateQueries({queryKey:e.tools.skills.queryKey()})})),[a,o]=b.useState(``),s=r.data,c=(s?.installed||[]).filter(e=>n||e.where===`global`),l=i.data?.skills;return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(NS,{title:`Skills`,children:[r.isLoading&&(0,x.jsx)(`p`,{className:`px-4 py-3 text-sm text-muted-foreground`,children:`Reading skills…`}),r.error&&(0,x.jsx)(`p`,{className:`px-4 py-3 text-xs text-destructive-foreground`,children:r.error.message}),(s?.bundled||[]).map(e=>(0,x.jsx)(PS,{title:e.name,description:e.description,children:(0,x.jsxs)(`span`,{className:`self-center text-xs text-muted-foreground tabular-nums`,children:[e.files.length,` `,e.files.length===1?`file`:`files`,` · rpf `,s.version]})},e.name))]}),c.map(e=>{let t=e.where===`global`?`global`:`project`,r=e.skills.some(e=>e.state!==`not-installed`),s=e.skills.some(e=>e.state===`edited`);return(0,x.jsxs)(NS,{title:t===`global`?`Installed for every project`:`Installed in this project`,action:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(q,{size:`xs`,variant:`outline`,disabled:i.isPending,onClick:()=>i.mutate({projectId:n||void 0,mode:r?`update`:`install`,global:t===`global`,force:!1}),children:r?`Update`:`Install`}),s&&(a===t?(0,x.jsx)(q,{size:`xs`,variant:`destructive`,onClick:()=>{o(``),i.mutate({projectId:n||void 0,mode:`update`,global:t===`global`,force:!0})},children:`Overwrite my edits`}):(0,x.jsx)(q,{size:`xs`,variant:`ghost-muted`,onClick:()=>o(t),children:`Force…`}))]}),children:[(0,x.jsx)(`p`,{className:`px-3 pt-3 font-mono text-2xs break-all text-muted-foreground sm:px-4`,children:e.root}),e.skills.map(e=>(0,x.jsx)(PS,{title:e.name,description:e.state===`edited`?`Edited: ${e.edited.join(`, `)} (kept on update; Force saves yours as .orig)`:e.state===`outdated`?`An update is available${e.version?` (installed from rpf ${e.version})`:``}`:e.state===`up-to-date`?`Up to date${e.version?` · from rpf ${e.version}`:``}`:`Not installed`,children:(0,x.jsx)(kb,{variant:e.state===`up-to-date`?`success`:e.state===`not-installed`?`outline`:`warning`,children:e.state===`up-to-date`?`up to date`:e.state===`not-installed`?`not installed`:e.state})},e.name))]},e.where)}),i.error&&(0,x.jsx)(`p`,{className:`text-xs text-destructive-foreground`,children:i.error.message}),l&&(0,x.jsx)(`p`,{className:`px-1 text-xs text-muted-foreground`,children:l.map(e=>`${e.name}: ${e.action.replace(`-`,` `)}${e.edited?.length?` (kept ${e.edited.length} edited)`:``}${e.overwritten?.length?` (yours saved as .orig)`:``}`).join(` · `)})]})}function EQ({st:e}){let t=at(Au().about.runUpdate.mutationOptions()),[n,r]=b.useState([]);return b.useEffect(()=>{let e=e=>{let t=e.detail;t.line!==void 0&&r(e=>[...e,t.line].slice(-200))};return window.addEventListener(`forge:update`,e),()=>window.removeEventListener(`forge:update`,e)},[]),(0,x.jsx)(PS,{title:`Update to rpf ${e.latest}`,description:(0,x.jsxs)(x.Fragment,{children:[e.command?(0,x.jsxs)(x.Fragment,{children:[`Runs `,(0,x.jsx)(`code`,{className:`font-mono`,children:e.command}),` (`,e.installer,`).`]}):`Couldn't tell how rpf was installed: update it in a terminal.`,n.length>0&&(0,x.jsx)(`pre`,{className:`mt-2 max-h-48 overflow-auto rounded-md bg-muted p-2 font-mono text-2xs whitespace-pre-wrap text-foreground/80`,children:n.join(`
|
|
291
|
-
`)}),t.data&&(0,x.jsx)(`span`,{className:G(`mt-1 block`,t.data.code===0?`text-success-foreground`:`text-destructive-foreground`),children:t.data.code===0?`Updated. Restart Forge (Ctrl+C in its terminal, then rpf forge) to run the new version.`:`The update failed (exit ${t.data.code}).`})]}),children:(0,x.jsx)(q,{size:`sm`,disabled:!e.command||t.isPending||t.data?.code===0,onClick:()=>t.mutate(),children:t.isPending?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(Yb,{size:`xs`}),` Updating…`]}):`Update`})})}var DQ=[{id:`general`,label:`General`,icon:lm,group:`Forge`},{id:`appearance`,label:`Appearance`,icon:Tp,group:`Forge`},{id:`providers`,label:`Providers and models`,icon:Sd,group:`Agent`},{id:`usage`,label:`Usage`,icon:Ad,group:`Agent`},{id:`instances`,label:`Instances`,icon:sm,group:`rpf`},{id:`projects`,label:`Projects`,icon:Tf,group:`rpf`},{id:`doctor`,label:`Doctor`,icon:Dm,group:`rpf`},{id:`skills`,label:`Skills`,icon:ym,group:`rpf`},{id:`keybindings`,label:`Keybindings`,icon:Yf,group:`More`},{id:`diffs`,label:`Diffs`,icon:_f,group:`More`},{id:`about`,label:`About and updates`,icon:qf,group:`More`},{id:`licenses`,label:`Open-source licenses`,icon:tm,group:`More`}];function OQ({section:e,onSection:t}){let n=[...new Set(DQ.map(e=>e.group))],[r,i]=b.useState(``),a=b.useRef(null),o=DQ,s=b.useMemo(()=>Object.fromEntries(DQ.map(e=>[e.id,e.label])),[]),c=OS(r,s),[l,u]=b.useState(0),d=Math.min(l,Math.max(c.length-1,0)),[f,p]=b.useState(null);b.useEffect(()=>{if(!f)return;let e=0,t=setInterval(()=>{(kS(f)||++e>20)&&(clearInterval(t),p(null))},50);return()=>clearInterval(t)},[f,e]);let m=e=>{i(``),u(0),t(e.section),e.target&&p(e.target)},h=e=>{if(!e.nativeEvent.isComposing){if(e.key===`Escape`&&r)e.preventDefault(),e.stopPropagation(),i(``);else if(c.length){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=c.length;u((d+(e.key===`ArrowDown`?1:t-1))%t)}else e.key===`Enter`&&(e.preventDefault(),m(c[d]))}}};b.useEffect(()=>{let e=e=>{let t=e.target;e.key===`/`&&!/INPUT|TEXTAREA/.test(t.tagName)&&!t.isContentEditable&&(e.preventDefault(),a.current?.focus())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let g=DQ.find(t=>t.id===e)||DQ[0];return(0,x.jsxs)(`div`,{className:`relative flex min-h-0 flex-1`,children:[(0,x.jsx)(`nav`,{className:`flex w-60 shrink-0 flex-col border-e bg-sidebar text-sidebar-foreground`,children:(0,x.jsxs)(`div`,{className:`flex flex-col gap-2 p-2`,children:[(0,x.jsxs)(`div`,{className:`flex h-8 items-center gap-2 rounded-md px-2 py-1.5 text-sm font-medium text-sidebar-muted-foreground focus-within:bg-sidebar-row-hover hover:bg-sidebar-row-hover hover:text-sidebar-foreground`,children:[(0,x.jsx)(am,{className:`size-4 shrink-0 text-sidebar-muted-foreground/80`}),(0,x.jsx)(`input`,{ref:a,value:r,onChange:e=>{i(e.target.value),u(0)},onKeyDown:h,placeholder:`Search`,"aria-label":`Search settings`,role:`combobox`,"aria-expanded":!!r&&c.length>0,"aria-controls":c.length?`settings-search-results`:void 0,"aria-activedescendant":c[d]?`settings-result-${d}`:void 0,className:`min-w-0 flex-1 bg-transparent outline-none placeholder:text-sidebar-muted-foreground`}),r?(0,x.jsx)(`button`,{"aria-label":`Clear settings search`,onClick:()=>i(``),className:`inline-flex size-5 items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-foreground`,children:(0,x.jsx)(Gm,{className:`size-3`})}):(0,x.jsx)(Ab,{children:`/`})]}),r&&c.length===0&&(0,x.jsx)(`p`,{role:`status`,className:`px-2 py-6 text-center text-xs text-sidebar-muted-foreground`,children:`No settings found`}),r?(0,x.jsx)(`div`,{id:c.length?`settings-search-results`:void 0,role:c.length?`listbox`:void 0,"aria-label":`Settings search results`,className:`flex flex-col gap-px`,children:c.map((e,t)=>{let n=DQ.find(t=>t.id===e.section)?.icon||lm;return(0,x.jsxs)(`button`,{type:`button`,id:`settings-result-${t}`,role:`option`,"aria-selected":t===d,tabIndex:-1,onMouseMove:()=>u(t),onClick:()=>m(e),className:G(`flex min-h-10 w-full items-start gap-2 rounded-[var(--control-radius)] px-2.5 py-1.5 text-left outline-none hover:bg-sidebar-row-hover`,t===d&&`bg-sidebar-row-selected`),children:[(0,x.jsx)(n,{className:`mt-0.5 size-4 shrink-0 text-sidebar-icon`}),(0,x.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,x.jsx)(`span`,{className:`block truncate text-sm font-medium text-sidebar-foreground`,children:e.title}),(0,x.jsx)(`span`,{className:`block truncate text-2xs text-sidebar-muted-foreground/75`,children:s[e.section]})]})]},e.id)})}):null,(0,x.jsx)(`div`,{className:G(`flex flex-col gap-4`,r&&`hidden`),children:n.filter(e=>o.some(t=>t.group===e)).map(e=>(0,x.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,x.jsx)(`h3`,{className:`px-2 text-xs font-medium text-sidebar-muted-foreground/80`,children:e}),(0,x.jsx)(`div`,{className:`flex flex-col gap-px`,children:o.filter(t=>t.group===e).map(e=>(0,x.jsxs)(`button`,{type:`button`,onClick:()=>t(e.id),"aria-current":e.id===g.id?`page`:void 0,className:G(`flex h-8 w-full items-center gap-2 rounded-[var(--control-radius)] px-2.5 text-left text-sm outline-none hover:bg-sidebar-row-hover focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset`,e.id===g.id&&`bg-sidebar-row-selected font-medium text-sidebar-foreground`),children:[(0,x.jsx)(e.icon,{className:`size-4 shrink-0 text-sidebar-icon`}),(0,x.jsx)(`span`,{className:`truncate`,children:e.label})]},e.id))})]},e))})]})}),(0,x.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,x.jsxs)(`header`,{className:`flex h-12 shrink-0 items-center gap-3 border-b ps-5 pe-2`,children:[(0,x.jsxs)(`nav`,{"aria-label":`Breadcrumb`,className:`flex min-w-0 items-center gap-2 text-sm font-medium`,children:[(0,x.jsx)(`span`,{className:`text-muted-foreground`,children:`Settings`}),(0,x.jsx)(`span`,{className:`text-icon-muted`,children:`/`}),(0,x.jsx)(`span`,{className:`truncate`,children:g.label})]}),(0,x.jsx)(`div`,{className:`ms-auto flex shrink-0 items-center gap-1`,children:(0,x.jsx)(oQ,{})})]}),(0,x.jsx)(`div`,{className:`fade-top min-h-0 flex-1 overflow-y-auto`,children:(0,x.jsxs)(`div`,{className:`mx-auto flex max-w-4xl flex-col gap-8 px-5 pt-6 pb-12 sm:px-6`,children:[g.id===`general`&&(0,x.jsx)(jQ,{}),g.id===`appearance`&&(0,x.jsx)(MQ,{}),g.id===`providers`&&(0,x.jsx)(RS,{}),g.id===`instances`&&(0,x.jsx)(tC,{}),g.id===`projects`&&(0,x.jsx)(uQ,{}),g.id===`keybindings`&&(0,x.jsx)(gQ,{}),g.id===`diffs`&&(0,x.jsx)(yQ,{}),g.id===`about`&&(0,x.jsx)(xQ,{}),g.id===`licenses`&&(0,x.jsx)(SQ,{}),g.id===`doctor`&&(0,x.jsx)(wQ,{}),g.id===`skills`&&(0,x.jsx)(TQ,{})]})})]})]})}function kQ({title:e,children:t,action:n}){return(0,x.jsxs)(`section`,{className:`space-y-2.5`,children:[(0,x.jsxs)(`div`,{className:`flex items-center px-3 sm:px-4`,children:[(0,x.jsx)(`h2`,{className:`text-base font-semibold`,children:e}),(0,x.jsx)(`div`,{className:`ml-auto`,children:n})]}),(0,x.jsx)(`div`,{className:`overflow-hidden rounded-xl border border-border/60 bg-card/40 shadow-xs/5 [&>*+*]:border-t [&>*+*]:border-border/50`,children:t})]})}function AQ({title:e,description:t,children:n}){return(0,x.jsxs)(`div`,{id:typeof e==`string`?SS(e):void 0,className:`grid grid-cols-[minmax(0,1fr)_auto] items-center gap-8 px-3 py-3 sm:px-4`,children:[(0,x.jsxs)(`div`,{className:`min-w-0`,children:[(0,x.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:e}),t&&(0,x.jsx)(`div`,{className:`mt-0.5 max-w-2xl text-xs leading-normal text-muted-foreground`,children:t})]}),(0,x.jsx)(`div`,{className:`flex max-w-[28rem] min-w-0 justify-end`,children:n})]})}function jQ(){let e=U(Au().meta.queryOptions());return(0,x.jsxs)(kQ,{title:`General`,children:[(0,x.jsx)(AQ,{title:`rpf home`,description:`Profiles, keys, projects and chats live here (RPFORGE_HOME moves it).`,children:(0,x.jsx)(`code`,{className:`font-mono text-xs break-all text-muted-foreground`,children:e.data?.home})}),(0,x.jsx)(AQ,{title:`Key store`,description:`Model keys are encrypted in the same store as instance credentials.`,children:(0,x.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.data?.keyStore?e.data.keyStore.keySource:`unavailable (keys can’t be saved)`})}),(0,x.jsx)(AQ,{title:`Version`,children:(0,x.jsxs)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:[`rpf `,e.data?.version]})})]})}function MQ(){let e=Gu();return(0,x.jsx)(kQ,{title:`Appearance`,children:(0,x.jsx)(AQ,{title:`Theme`,description:`Follow the system, or always light or dark.`,children:(0,x.jsx)(`div`,{className:`inline-flex rounded-[var(--control-radius)] border border-input p-0.5`,children:[{id:`system`,label:`System`},{id:`light`,label:`Light`},{id:`dark`,label:`Dark`}].map(t=>(0,x.jsx)(`button`,{onClick:()=>Wu({theme:t.id}),className:G(`h-6 rounded-md px-2.5 text-xs`,e.theme===t.id?`bg-accent font-medium`:`text-muted-foreground hover:text-foreground`),children:t.label},t.id))})})})}function NQ({section:e,onSection:t,onClose:n}){return(0,x.jsx)(aQ,{label:`Settings`,onClose:n,children:(0,x.jsx)(OQ,{section:e,onSection:t})})}var PQ=[`var(--primary)`,`#d97757`,`#4d9f8a`,`#8c7bd1`,`#5b9bbd`,`#c2a14d`,`#8b8b8b`];function FQ({value:e,options:t,onChange:n}){return(0,x.jsx)(`div`,{className:`inline-flex rounded-md bg-accent p-0.5`,children:t.map(t=>(0,x.jsx)(`button`,{onClick:()=>n(t.id),className:G(`h-6 rounded px-2 text-xs`,e===t.id?`bg-background font-medium text-foreground shadow-xs/5`:`text-muted-foreground hover:text-foreground`),children:t.label},String(t.id)))})}function IQ({label:e,value:t}){return(0,x.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,x.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:e}),(0,x.jsx)(`dd`,{className:`text-base font-medium text-foreground tabular-nums`,children:t})]})}function LQ({label:e,segments:t,format:n}){let r=t.reduce((e,t)=>e+t.value,0)||1,i=t.filter(e=>e.value>0);return(0,x.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2.5`,children:[(0,x.jsx)(`h3`,{className:`text-sm font-medium text-foreground`,children:e}),(0,x.jsx)(`div`,{"aria-hidden":!0,className:`flex h-2 gap-0.5`,children:i.map(e=>(0,x.jsx)(`div`,{className:`h-full min-w-1 rounded-xs first:rounded-l-full last:rounded-r-full`,style:{width:`${e.value/r*100}%`,backgroundColor:e.color}},e.label))}),(0,x.jsx)(`ul`,{"aria-label":e,className:`flex flex-wrap gap-x-4 gap-y-1 text-xs`,children:i.map(e=>(0,x.jsxs)(`li`,{className:`flex items-center gap-1.5`,children:[(0,x.jsx)(`span`,{className:`size-2 rounded-xs`,style:{backgroundColor:e.color}}),(0,x.jsx)(`span`,{className:`text-muted-foreground`,children:e.label}),` `,(0,x.jsx)(`span`,{className:`text-foreground tabular-nums`,children:n(e.value)})]},e.label))})]})}function RQ({days:e,series:t,metric:n}){let[r,i]=b.useState(null),a=Math.max(1e-9,...t.flatMap(e=>e.values)),o=n===`cost`?FX:PX,s=t=>e.length<=1?300:t/(e.length-1)*600,c=e=>200-e/a*192;return(0,x.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,x.jsxs)(`div`,{className:`flex gap-2`,children:[(0,x.jsx)(`div`,{"aria-hidden":!0,className:`relative h-56 w-14 shrink-0`,children:[1,.5,0].map(e=>(0,x.jsx)(`span`,{className:`absolute right-0 -translate-y-1/2 text-2xs text-muted-foreground tabular-nums`,style:{top:`${(1-e)*100*.96+4*(1-e==0)}%`},children:o(a*e)},e))}),(0,x.jsxs)(`div`,{className:`relative h-56 flex-1`,onMouseLeave:()=>i(null),onMouseMove:t=>{let n=t.currentTarget.getBoundingClientRect(),r=Math.round((t.clientX-n.left)/n.width*(e.length-1));i(Math.max(0,Math.min(e.length-1,r)))},children:[(0,x.jsxs)(`svg`,{viewBox:`0 0 600 200`,preserveAspectRatio:`none`,className:`h-full w-full overflow-visible`,children:[[0,.5,1].map(e=>(0,x.jsx)(`line`,{x1:0,x2:600,y1:c(a*e),y2:c(a*e),className:`text-border`,stroke:`currentColor`,strokeDasharray:e?`3 3`:void 0,vectorEffect:`non-scaling-stroke`},e)),t.map(e=>{let t=e.values.map((e,t)=>`${s(t)},${c(e)}`).join(` `);return(0,x.jsxs)(`g`,{children:[(0,x.jsx)(`polygon`,{points:`0,200 ${t} 600,200`,fill:e.color,opacity:.12}),(0,x.jsx)(`polyline`,{points:t,fill:`none`,stroke:e.color,strokeWidth:1.5,vectorEffect:`non-scaling-stroke`})]},e.key)}),r!==null&&(0,x.jsx)(`line`,{x1:s(r),x2:s(r),y1:0,y2:200,stroke:`currentColor`,className:`text-foreground/40`,vectorEffect:`non-scaling-stroke`})]}),r!==null&&(0,x.jsxs)(`div`,{className:`glass pointer-events-none absolute top-2 z-10 min-w-36 rounded-xl border border-border/50 px-2.5 py-2 text-xs shadow-lg`,style:{left:`min(calc(${s(r)/600*100}% + 8px), calc(100% - 10rem))`},children:[(0,x.jsx)(`div`,{className:`mb-1 text-muted-foreground`,children:e[r]}),t.map(e=>(0,x.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,x.jsxs)(`span`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,x.jsx)(`span`,{className:`size-2 rounded-full`,style:{backgroundColor:e.color}}),e.label]}),(0,x.jsx)(`span`,{className:`text-foreground tabular-nums`,children:o(e.values[r]||0)})]},e.key))]})]})]}),(0,x.jsxs)(`div`,{className:`flex justify-between ps-16 text-2xs text-muted-foreground tabular-nums`,children:[(0,x.jsx)(`span`,{children:e[0]}),(0,x.jsx)(`span`,{children:e[e.length-1]})]})]})}function zQ(e,t){let n=new Date,r=e?new Date(Date.now()-(e-1)*864e5):new Date(t||n),i=[];for(let e=new Date(r.toISOString().slice(0,10));e<=n;e=new Date(e.getTime()+864e5))i.push(e.toISOString().slice(0,10));return i.length?i:[n.toISOString().slice(0,10)]}function BQ(){let e=Au(),[t,n]=b.useState(`cost`),[r,i]=b.useState(30),a=U(e.usage.report.queryOptions({days:r})),o=a.data,s=o?.totals,c=e=>t===`cost`?e.cost:e.input+e.output,l=t===`cost`?FX:PX,u=(o?.connections||[]).map((e,t)=>({...e,label:o?.connectionNames[e.key]||e.key,color:PQ[t%PQ.length]})),d=zQ(r,o?.days[0]?.key),f=u.map(e=>({key:e.key,label:e.label,color:e.color,values:d.map(t=>{let n=o?.connectionDays[`${e.key}|${t}`];return n?c(n):0})})),p=s?c(s):0,m=s?s.input-s.cachedInput:0;return(0,x.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,x.jsxs)(`header`,{className:`flex min-h-12 shrink-0 items-center gap-2 border-b ps-5 pe-2`,children:[(0,x.jsx)(`nav`,{"aria-label":`Usage breadcrumb`,className:`flex min-w-0 items-center gap-2 text-sm font-medium`,children:(0,x.jsx)(`span`,{className:`truncate`,children:`Usage`})}),(0,x.jsxs)(`div`,{className:`ms-auto flex shrink-0 items-center gap-2`,children:[(0,x.jsx)(FQ,{value:t,onChange:n,options:[{id:`cost`,label:`Cost`},{id:`tokens`,label:`Tokens`}]}),(0,x.jsx)(FQ,{value:r,onChange:i,options:[{id:7,label:`7 days`},{id:30,label:`30 days`},{id:90,label:`90 days`},{id:0,label:`All`}]}),(0,x.jsx)(oQ,{})]})]}),(0,x.jsx)(`div`,{className:`fade-top min-h-0 flex-1 overflow-y-auto`,children:(0,x.jsx)(`div`,{className:`mx-auto flex max-w-6xl flex-col gap-6 px-5 pt-6 pb-12 sm:px-6`,children:a.isLoading?(0,x.jsx)(`div`,{className:`flex justify-center py-16`,children:(0,x.jsx)(Yb,{size:`sm`,muted:!0})}):!s||!s.calls?(0,x.jsxs)(`div`,{className:`space-y-2 py-12 text-center text-sm text-muted-foreground`,children:[(0,x.jsx)(`p`,{children:`No usage in this range yet.`}),(0,x.jsx)(`p`,{children:`Each chat run, compaction and title is counted here, by project, model and connection.`})]}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(`section`,{className:`grid gap-6 lg:grid-cols-[minmax(0,18rem)_minmax(0,1fr)]`,children:[(0,x.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-5`,children:[(0,x.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,x.jsx)(`p`,{className:`text-4xl font-semibold text-foreground tabular-nums`,children:l(p)}),(0,x.jsxs)(`p`,{className:`inline-flex items-center gap-1 text-xs text-muted-foreground`,children:[(0,x.jsxs)(`span`,{children:[s.chats,` chat`,s.chats===1?``:`s`,` · `,s.calls,` call`,s.calls===1?``:`s`,t===`cost`&&` · API estimate`]}),t===`cost`&&s.unpricedTokens>0&&(0,x.jsx)(Tb,{label:`Excludes ${PX(s.unpricedTokens)} tokens of models without a price (set prices in Settings › Providers and models).`,children:(0,x.jsx)(qf,{className:`size-3`,"aria-label":`Unpriced usage details`})})]})]}),u.map(e=>{let t=p?c(e)/p:0;return(0,x.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,x.jsxs)(`dl`,{className:`flex items-baseline justify-between gap-4`,children:[(0,x.jsxs)(`dt`,{className:`flex min-w-0 items-center gap-2 text-sm text-foreground`,children:[(0,x.jsx)(`span`,{"aria-hidden":!0,className:`size-2 shrink-0 rounded-full`,style:{backgroundColor:e.color}}),(0,x.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-1.5`,children:[(0,x.jsx)(`span`,{className:`truncate`,children:e.label}),(0,x.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[e.chats,` chat`,e.chats===1?``:`s`]})]})]}),(0,x.jsx)(`dd`,{className:`text-sm text-foreground tabular-nums`,children:l(c(e))})]}),(0,x.jsx)(`div`,{className:`h-[3px] rounded-full bg-muted-foreground/20`,children:(0,x.jsx)(`div`,{className:`h-full rounded-full`,style:{width:`${t*100}%`,backgroundColor:e.color}})})]},e.key)})]}),(0,x.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[(0,x.jsx)(`h2`,{className:`text-sm font-medium text-foreground`,children:t===`tokens`?`Daily processed tokens`:`Daily cost`}),(0,x.jsx)(RQ,{days:d,series:f,metric:t})]})]}),(0,x.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,x.jsx)(`h2`,{className:`text-sm font-medium text-foreground`,children:`Totals`}),(0,x.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-6 gap-y-4 py-1 md:grid-cols-5`,children:[(0,x.jsx)(IQ,{label:`Processed tokens`,value:PX(s.input+s.output)}),(0,x.jsx)(IQ,{label:`Cached input`,value:PX(s.cachedInput)}),(0,x.jsx)(IQ,{label:`Uncached input`,value:PX(m)}),(0,x.jsx)(IQ,{label:`Output`,value:PX(s.output)}),(0,x.jsx)(IQ,{label:`Reasoning`,value:s.reasoning?PX(s.reasoning):`—`})]})]}),(0,x.jsxs)(`section`,{className:`grid gap-x-12 gap-y-8 lg:grid-cols-2`,children:[(0,x.jsx)(LQ,{label:`Tokens by type`,format:PX,segments:[{label:`Uncached input`,value:m,color:PQ[0]},{label:`Cached input`,value:s.cachedInput,color:PQ[2]},{label:`Output`,value:s.output,color:PQ[1]}]}),(0,x.jsx)(LQ,{label:t===`cost`?`Cost by kind`:`Tokens by kind`,format:l,segments:(o?.kinds||[]).map((e,t)=>({label:e.key===`run`?`Chat runs`:e.key===`compaction`?`Compactions`:`Titles`,value:c(e),color:PQ[(t+3)%PQ.length]}))})]}),(0,x.jsx)(VQ,{title:`Models`,rows:(o?.models||[]).map(e=>({...e,name:e.model,sub:o?.connectionNames[e.connectionId]||e.connectionId})),metric:t}),(0,x.jsx)(VQ,{title:`Projects`,rows:(o?.projects||[]).map(e=>({...e,sub:``})),metric:t})]})})})]})}function VQ({title:e,rows:t,metric:n}){let r=Math.max(1e-9,...t.map(e=>n===`cost`?e.cost:e.input+e.output));return(0,x.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,x.jsx)(`h2`,{className:`text-sm font-medium text-foreground`,children:e}),(0,x.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,x.jsx)(`thead`,{children:(0,x.jsxs)(`tr`,{className:`border-b border-border text-right text-xs text-muted-foreground`,children:[(0,x.jsx)(`th`,{className:`py-2 pr-3 pl-2 text-left font-normal`,children:`#`}),(0,x.jsx)(`th`,{className:`w-full py-2 text-left font-normal`,children:e===`Models`?`Model`:`Project`}),(0,x.jsx)(`th`,{className:`py-2 pl-6 font-normal`,children:`Tokens`}),(0,x.jsx)(`th`,{className:`hidden py-2 pl-6 font-normal sm:table-cell`,children:`Chats`}),(0,x.jsx)(`th`,{className:`py-2 pr-2 pl-6 font-normal`,children:`Cost`})]})}),(0,x.jsx)(`tbody`,{children:t.map((e,t)=>{let i=n===`cost`?e.cost:e.input+e.output;return(0,x.jsxs)(`tr`,{className:`border-b border-border/50 text-right whitespace-nowrap text-muted-foreground tabular-nums transition-colors hover:bg-muted/50`,children:[(0,x.jsx)(`td`,{className:`py-2.5 pr-3 pl-2 text-left text-xs`,children:t+1}),(0,x.jsxs)(`td`,{className:`py-2.5 text-left whitespace-normal`,children:[(0,x.jsxs)(`div`,{className:`flex items-baseline gap-1.5`,children:[(0,x.jsx)(`span`,{className:`text-foreground`,children:e.name}),e.sub&&(0,x.jsx)(`span`,{className:`text-xs`,children:e.sub})]}),(0,x.jsx)(`div`,{"aria-hidden":!0,className:`mt-1.5 h-0.5 max-w-48`,children:(0,x.jsx)(`div`,{className:`h-full rounded-full bg-primary/60`,style:{width:`${i/r*100}%`}})})]}),(0,x.jsx)(`td`,{className:`py-2.5 pl-6 text-foreground`,children:PX(e.input+e.output)}),(0,x.jsx)(`td`,{className:`hidden py-2.5 pl-6 sm:table-cell`,children:e.chats}),(0,x.jsx)(`td`,{className:`py-2.5 pr-2 pl-6 text-foreground`,children:e.cost>0?FX(e.cost):e.unpricedTokens?(0,x.jsx)(`span`,{className:`text-muted-foreground`,children:`no price`}):FX(0)})]},e.key)})})]})]})}function HQ({onClose:e}){return(0,x.jsx)(aQ,{label:`Usage`,onClose:e,children:(0,x.jsx)(BQ,{})})}var UQ={start:`new`,profile:``,app:``,setMode:`existing`,setId:``,setName:``,name:``,slug:``,slugTouched:!1,description:``,sourceKind:`template`,template:``,portal:``,copyPages:!1,layout:``,themeMode:`keep`,themeKey:``,themeCopy:!1,color:`#2563eb`,tint:`neutral`,contrast:`AA`,icon:``,folder:``,folderTouched:!1,extras:{prettierrc:!0,gitignore:!0,readme:!0,skills:!0,git:!0}},WQ={start:`Start from`,instance:`Instance`,app:`App and update set`,portal:`Portal`,look:`Look and navigation`,folder:`Folder and extras`,review:`Review plan`};function GQ(e){return e===`new`?[`start`,`instance`,`app`,`portal`,`look`,`folder`,`review`]:[`start`,`instance`,`app`,`portal`,`folder`,`review`]}function KQ(e){let t=e.normalize(`NFKD`).replace(/[̀-ͯ]/g,``).toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).substring(0,40).replace(/-+$/,``);return t.length===1&&(t+=`-portal`),t}function qQ(e){return`${e.trim()||`Portal`} (React Portal)`.substring(0,80)}function JQ(e){let t=/^([a-z_]+): ([\s\S]*)$/.exec(e||``);return t?[t[1],t[2]]:[``,e||``]}var YQ={no_profile:`Add or finish the instance profile in Settings › Instances.`,forge_mcp_disabled:`An admin turns Forge on in React Portal (x_312987_portal.forge.mcp.enabled).`,forbidden:`Ask for the React Portal designer or developer role.`,incompatible:`Upgrade React Portal on the instance.`,helper_missing:`Install or upgrade React Portal Global Helpers on the instance.`,no_apps:`You need author access to a scoped application.`};function XQ(e){let t={app:e.app,updateSet:e.setMode===`new`?{create:e.setName.trim()||qQ(e.name)}:e.setId,name:e.name.trim(),slug:e.slug};return e.description.trim()&&(t.description=e.description.trim()),t.source=e.start===`copy`?{kind:`portal`,portal:e.portal,pages:e.copyPages?`all`:`none`}:e.sourceKind===`empty`?{kind:`empty`}:{kind:`template`,...e.template?{portal:e.template}:{}},e.start===`new`&&(e.layout&&(t.layout=e.layout),e.themeMode===`pick`&&e.themeKey&&(t.theme={key:e.themeKey,...e.themeCopy?{copy:!0}:{}}),e.themeMode===`keep`&&e.themeCopy&&(t.theme={copy:!0}),e.themeMode===`color`&&(t.theme={color:e.color,tint:e.tint,contrast:e.contrast}),e.icon.trim()&&e.sourceKind!==`empty`&&(t.brand={icon:e.icon.trim()})),t}function ZQ(){let e=Gu(),t=!!e.newProject;return(0,x.jsx)(Eb,{open:t,onOpenChange:e=>!e&&Wu({newProject:``}),children:t&&(0,x.jsx)(QQ,{preset:e.newProject===`choose`||!e.newProject?void 0:e.newProject},e.newProject)})}function QQ({preset:e}){let t=Au(),n=C(),r=Yi(),i=i8(),a=U(t.wizard.context.queryOptions()),o=U({...t.profiles.list.queryOptions(),retry:!1}),[s,c]=b.useState({...UQ,start:e||`new`}),l=e=>c(t=>({...t,...e})),u=GQ(s.start),[d,f]=b.useState(e?`instance`:`start`),p=u.indexOf(d),[m,h]=b.useState(``),g=at(t.wizard.plan.mutationOptions()),_=at(t.wizard.run.mutationOptions()),v=at(t.wizard.pull.mutationOptions()),y=at(t.wizard.retryPull.mutationOptions()),S=b.useMemo(()=>crypto.randomUUID(),[]),w=o.data?.profiles||[];b.useEffect(()=>{!s.profile&&w.length&&l({profile:o.data?.default||w[0].name})},[w.length]);let T=!!s.profile&&a.data?.available!==!1,E=U({...t.wizard.preflight.queryOptions({profile:s.profile}),enabled:T,retry:!1,staleTime:6e4}),D=U({...t.wizard.updateSets.queryOptions({profile:s.profile,appId:E.data?.apps.find(e=>e.scope===s.app)?.id||``}),enabled:T&&!!s.app&&!!E.data}),O=U({...t.wizard.portals.queryOptions({profile:s.profile}),enabled:T&&!!E.data});b.useEffect(()=>{if(E.data&&!s.app){let e=E.data.apps.find(e=>e.current&&!e.reactPortal)||E.data.apps.find(e=>!e.reactPortal);e&&l({app:e.scope})}},[E.data]),b.useEffect(()=>{let e=D.data||[];if(e.length&&!e.some(e=>e.id===s.setId)){let t=e.find(e=>e.remembered)||e.find(e=>e.isDefault)||e[0];l({setId:t.id})}},[D.data]);let k=s.start===`pull`?s.portal:s.slug,A=U({...t.wizard.folder.queryOptions(s.folderTouched&&s.folder?{path:s.folder}:{slug:k||`portal`}),enabled:!!a.data});b.useEffect(()=>{!s.folderTouched&&A.data&&l({folder:A.data.folder})},[A.data?.folder]);let j=U({...t.wizard.job.queryOptions({id:m}),enabled:!!m});b.useEffect(()=>{if(j.data?.state===`done`&&j.data.projectId){n.invalidateQueries({queryKey:t.projects.list.queryKey()});let e=j.data.projectId,i=setTimeout(()=>{Wu({newProject:``}),r({to:`/p/$projectId`,params:{projectId:e}})},700);return()=>clearTimeout(i)}},[j.data?.state,j.data?.projectId,r,n,t]);let[M,N]=JQ(E.error?.message),P=U({...t.wizard.slug.queryOptions({profile:s.profile,slug:s.slug}),enabled:T&&!!E.data&&s.start!==`pull`&&/^[a-z0-9][a-z0-9-]{1,39}$/.test(s.slug),staleTime:3e4}),F=()=>{switch(d){case`instance`:return s.profile?E.data?``:E.isLoading?`Checking…`:`The instance refused`:`Pick an instance`;case`app`:return s.app?s.setMode===`existing`&&!s.setId?`Pick an update set`:``:`Pick an application`;case`portal`:return s.start===`pull`?s.portal?``:`Pick a portal`:s.start===`copy`&&!s.portal?`Pick a portal to copy`:s.name.trim()?/^[a-z0-9][a-z0-9-]{1,39}$/.test(s.slug)?P.data&&!P.data.available?`That slug is taken`:``:`The slug needs 2-40 lowercase letters, digits or dashes`:`Name the portal`;case`folder`:return s.folder?A.data&&!A.data.empty?`The folder is not empty`:``:`Pick a folder`;default:return``}},I=()=>{let e=u[p+1];e&&(e===`review`&&s.start!==`pull`&&g.mutate({profile:s.profile,answers:XQ(s),folder:s.folder,extras:s.extras}),f(e))},L=()=>p>0&&f(u[p-1]),R=async()=>{if(s.start===`pull`){let e=await v.mutateAsync({profile:s.profile,portal:s.portal,folder:s.folder,updateSet:s.setId,extras:s.extras});h(e.jobId);return}let e=g.data?.plan?.hash;if(!e)return;let t=await _.mutateAsync({profile:s.profile,answers:XQ(s),folder:s.folder,extras:s.extras,planHash:e,requestId:S});h(t.jobId)},z=F(),B=!!m,V=E.data?.apps.find(e=>e.scope===s.app)?.reactPortal;return(0,x.jsxs)(I6,{children:[(0,x.jsx)(D6,{className:`fixed inset-0 z-50 bg-background/60 backdrop-blur-[4px] transition-opacity duration-200 data-[ending-style]:opacity-0 data-[starting-style]:opacity-0`}),(0,x.jsxs)(F6,{className:`glass fixed top-1/2 left-1/2 z-50 flex h-[min(44rem,calc(100vh-2rem))] w-[calc(100vw-2rem)] max-w-5xl -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl shadow-[0_24px_64px_-24px_rgb(0_0_0/65%)] transition-[opacity,scale] duration-200 data-[ending-style]:scale-98 data-[ending-style]:opacity-0 data-[starting-style]:scale-98 data-[starting-style]:opacity-0`,children:[(0,x.jsxs)(`div`,{className:`flex h-12 shrink-0 items-center gap-2 border-b ps-5 pe-2`,children:[(0,x.jsx)(G6,{className:`text-sm font-medium`,children:`New project`}),(0,x.jsx)(O6,{"aria-label":`Close (Esc)`,className:`ms-auto inline-flex size-7 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground`,children:(0,x.jsx)(Gm,{className:`size-4`})})]}),(0,x.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,x.jsx)(`ol`,{className:`hidden w-56 shrink-0 flex-col gap-0.5 border-e bg-muted/20 p-3 sm:flex`,children:u.map((e,t)=>{let n=t<p||B&&t<=p,r=e===d&&!B;return(0,x.jsx)(`li`,{children:(0,x.jsxs)(`button`,{type:`button`,disabled:B||t>p,onClick:()=>f(e),className:G(`flex h-8 w-full items-center gap-2.5 rounded-md px-2 text-left text-sm`,r?`bg-accent font-medium`:`text-muted-foreground`,t<=p&&!B&&`hover:bg-accent/60`),children:[(0,x.jsx)(`span`,{className:G(`flex size-5 shrink-0 items-center justify-center rounded-full border text-2xs tabular-nums`,n&&`border-transparent bg-success/16 text-success-foreground`,r&&`border-primary bg-primary text-primary-foreground`),children:n?(0,x.jsx)(Md,{className:`size-3`}):t+1}),WQ[e]]})},e)})}),(0,x.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:B?(0,x.jsx)(l$,{job:j.data,onRetry:()=>y.mutate({jobId:m}),retrying:y.isPending,onBack:()=>{h(``),f(`review`)}}):a.data?.available===!1?(0,x.jsxs)($Q,{icon:qf,title:`This rpf build can't create projects`,children:[`Run `,(0,x.jsx)(`code`,{className:`font-mono`,children:`rpf init`}),` in a terminal, then open the folder.`]}):d===`start`?(0,x.jsx)(t$,{value:s.start,onPick:e=>{l({start:e,portal:``}),f(`instance`)}}):d===`instance`?(0,x.jsx)(n$,{profiles:w,profile:s.profile,onProfile:e=>l({profile:e,app:``,setId:``}),pre:E.data,loading:E.isLoading&&!!s.profile,code:M,message:N,onAddInstance:()=>i(`instances`),onRetry:()=>E.refetch()}):d===`app`?(0,x.jsx)(r$,{d:s,set:l,apps:E.data?.apps||[],sets:D.data||[],loadingSets:D.isLoading,canCreateSets:s.start!==`pull`&&!!E.data?.canCreateSets}):d===`portal`?(0,x.jsx)(i$,{d:s,set:l,portals:O.data||[],loading:O.isLoading,slugCheck:P.data,slugChecking:P.isFetching}):d===`look`?(0,x.jsx)(a$,{d:s,set:l,profile:s.profile}):d===`folder`?(0,x.jsx)(s$,{d:s,set:l,free:A.data}):(0,x.jsx)(c$,{d:s,plan:g.data,error:g.error?.message,planning:g.isPending,reactPortalApp:!!V,onReplan:()=>g.mutate({profile:s.profile,answers:XQ(s),folder:s.folder,extras:s.extras})})})]}),!B&&(0,x.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-t bg-muted/72 px-6 py-3`,children:[z&&d!==`start`&&d!==`review`&&(0,x.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:z}),(0,x.jsxs)(`div`,{className:`ms-auto flex gap-2`,children:[p>0&&(0,x.jsx)(q,{variant:`outline`,onClick:L,children:`Back`}),d===`review`?(0,x.jsx)(q,{disabled:s.start!==`pull`&&!g.data?.plan?.hash||g.isPending||_.isPending||v.isPending,onClick:R,children:s.start===`pull`?`Pull and open`:`Create and open`}):d!==`start`&&(0,x.jsx)(q,{disabled:!!z,onClick:I,children:`Next`})]})]}),(_.error||v.error)&&!B&&(0,x.jsx)(`div`,{className:`border-t px-6 py-2 text-xs text-destructive-foreground`,children:JQ((_.error||v.error)?.message)[1]})]})]})}function $Q({icon:e,title:t,children:n}){return(0,x.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-2 text-center`,children:[(0,x.jsx)(e,{className:`size-6 text-muted-foreground`}),(0,x.jsx)(`p`,{className:`text-sm font-medium`,children:t}),(0,x.jsx)(`div`,{className:`max-w-md text-xs text-muted-foreground`,children:n})]})}function e$({title:e,children:t}){return(0,x.jsxs)(`div`,{className:`mb-5`,children:[(0,x.jsx)(`h2`,{className:`text-base font-semibold`,children:e}),t&&(0,x.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:t})]})}function t$({value:e,onPick:t}){return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(e$,{title:`How do you want to start?`}),(0,x.jsx)(`div`,{className:`grid gap-3 md:grid-cols-3`,children:[{id:`new`,icon:ym,title:`New portal`,body:`A draft on the instance from a template or empty (rpf init).`},{id:`pull`,icon:sf,title:`Pull a portal`,body:`Work on an existing portal as files. Any portal, React Portal ones included.`},{id:`copy`,icon:ef,title:`Copy a portal`,body:`A new draft copied from any portal, then pulled. Pages are optional.`}].map(n=>(0,x.jsxs)(`button`,{type:`button`,onClick:()=>t(n.id),className:G(`flex flex-col items-start gap-2 rounded-xl border bg-card/40 p-4 text-left shadow-xs/5 outline-none transition-colors hover:bg-accent/50 focus-visible:ring-2 focus-visible:ring-ring`,e===n.id&&`border-primary/60`),children:[(0,x.jsx)(n.icon,{className:`size-5 text-icon-muted`}),(0,x.jsx)(`span`,{className:`text-sm font-medium`,children:n.title}),(0,x.jsx)(`span`,{className:`text-xs leading-relaxed text-muted-foreground`,children:n.body})]},n.id))})]})}function n$({profiles:e,profile:t,onProfile:n,pre:r,loading:i,code:a,message:o,onAddInstance:s,onRetry:c}){return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(e$,{title:`Instance`,children:`The rpf profile the portal lives on. The CLI uses the same profiles.`}),e.length===0?(0,x.jsxs)(`div`,{className:`rounded-xl border border-dashed p-6 text-center`,children:[(0,x.jsx)(`p`,{className:`text-sm font-medium`,children:`No instances yet`}),(0,x.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Add the ServiceNow instance your portals live on.`}),(0,x.jsx)(q,{size:`sm`,className:`mt-3`,onClick:s,children:`Add an instance`})]}):(0,x.jsx)(`div`,{className:`overflow-hidden rounded-xl border border-border/60 bg-card/40 shadow-xs/5`,children:e.map(e=>(0,x.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-3 border-border/50 px-4 py-2.5 not-first:border-t hover:bg-accent/40`,children:[(0,x.jsx)(`input`,{type:`radio`,name:`profile`,checked:t===e.name,onChange:()=>n(e.name),className:f5}),(0,x.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,x.jsx)(`span`,{className:`text-sm font-medium`,children:e.name}),e.default&&(0,x.jsx)(`span`,{className:`ms-2 text-xs text-muted-foreground`,children:`default`}),(0,x.jsx)(`span`,{className:`block truncate font-mono text-xs text-muted-foreground`,children:e.instance.replace(/^https?:\/\//,``)})]})]},e.name))}),t&&(0,x.jsx)(`div`,{className:`mt-4 rounded-lg border border-border/60 px-4 py-3 text-sm`,children:i?(0,x.jsxs)(`span`,{className:`inline-flex items-center gap-2 text-muted-foreground`,children:[(0,x.jsx)(Yb,{size:`sm`}),` Checking `,t,`…`]}):r?(0,x.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,x.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-success-foreground`,children:[(0,x.jsx)(Md,{className:`size-4`}),` Forge on`]}),(0,x.jsxs)(`span`,{className:`text-muted-foreground`,children:[`as `,r.user,` ·`,` `,Object.keys(r.capabilities||{}).filter(e=>r.capabilities[e]).join(`, `),r.reactPortal?` · React Portal ${r.reactPortal}`:``]}),r.warning&&(0,x.jsx)(`span`,{className:`basis-full text-xs text-warning-foreground`,children:r.warning})]}):o?(0,x.jsxs)(`div`,{className:`flex gap-2`,children:[(0,x.jsx)(Wd,{className:`mt-0.5 size-4 shrink-0 text-destructive-foreground`}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`p`,{className:`text-destructive-foreground`,children:o}),YQ[a]&&(0,x.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:YQ[a]}),(0,x.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[(0,x.jsx)(q,{size:`xs`,variant:`outline`,onClick:c,children:`Check again`}),a===`no_profile`&&(0,x.jsx)(q,{size:`xs`,variant:`outline`,onClick:s,children:`Open Instances`})]})]})]}):null})]})}function r$({d:e,set:t,apps:n,sets:r,loadingSets:i,canCreateSets:a}){let o=n.find(t=>t.scope===e.app);return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(e$,{title:`App and update set`,children:e.start===`pull`?`Pushes from the folder write into this update set.`:`The application that owns the portal, and the update set that captures it.`}),(0,x.jsxs)(`div`,{className:`grid gap-5`,children:[(0,x.jsx)(u5,{label:`Application`,children:(0,x.jsx)(d5,{"aria-label":`Application`,value:e.app,onChange:e=>t({app:e,setId:``}),options:n.map(e=>({value:e.scope,label:`${e.name} (${e.scope})${e.reactPortal?` · React Portal itself`:e.current?` · current`:``}`}))})}),o?.reactPortal&&(0,x.jsxs)(`p`,{className:`flex gap-2 text-xs text-warning-foreground`,children:[(0,x.jsx)(Lm,{className:`size-4 shrink-0`}),`React Portal itself owns these records: a React Portal upgrade may change them.`]}),(0,x.jsxs)(`div`,{className:`grid gap-2`,children:[(0,x.jsx)(`span`,{className:`text-xs font-medium`,children:`Update set`}),(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-sm`,children:[(0,x.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,x.jsx)(`input`,{type:`radio`,className:f5,checked:e.setMode===`existing`,onChange:()=>t({setMode:`existing`})}),`An in-progress set`]}),(0,x.jsx)(d5,{"aria-label":`Update set`,className:`w-auto min-w-64`,disabled:e.setMode!==`existing`,value:e.setId,onChange:e=>t({setId:e}),placeholder:i?`Loading…`:`Choose a set`,options:r.map(e=>({value:e.id,label:`${e.name}${e.isDefault?` (default)`:``}${e.remembered?` · yours`:``}`}))})]}),a&&(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-sm`,children:[(0,x.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,x.jsx)(`input`,{type:`radio`,className:`relative inline-flex size-4.5 shrink-0 cursor-pointer appearance-none items-center justify-center rounded-full border border-input bg-background shadow-xs/5 outline-none transition-shadow not-dark:bg-clip-padding checked:border-primary checked:bg-[radial-gradient(circle,var(--primary-foreground)_0_3px,var(--primary)_3.5px)] checked:shadow-none focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring disabled:opacity-64 sm:size-4 dark:not-checked:bg-input/32`,checked:e.setMode===`new`,onChange:()=>t({setMode:`new`})}),`A new set`]}),(0,x.jsx)(o5,{size:`compact`,className:`w-80`,disabled:e.setMode!==`new`,"aria-label":`New update set name`,placeholder:qQ(e.name||`Portal name`),value:e.setName,maxLength:80,onChange:e=>t({setName:e.target.value})})]})]})]})]})}function i$({d:e,set:t,portals:n,loading:r,slugCheck:i,slugChecking:a}){let[o,s]=b.useState(``),c=n.filter(e=>e.isTemplate),l=(e.start===`pull`?n.filter(e=>!e.isTemplate):n).filter(e=>!o||`${e.slug} ${e.name}`.toLowerCase().includes(o.toLowerCase())),u=e.start!==`pull`&&(0,x.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,x.jsx)(u5,{label:`Portal name`,children:(0,x.jsx)(o5,{autoFocus:!0,placeholder:`HR Portal`,value:e.name,maxLength:100,onChange:n=>t({name:n.target.value,...e.slugTouched?{}:{slug:KQ(n.target.value)}})})}),(0,x.jsx)(u5,{label:`Slug`,description:a?`Checking…`:i&&!i.available?(0,x.jsxs)(`span`,{className:`text-destructive-foreground`,children:[`Taken by `,i.takenBy?.name||`another portal`,i.suggestion&&(0,x.jsxs)(x.Fragment,{children:[` · `,(0,x.jsxs)(`button`,{type:`button`,className:`underline`,onClick:()=>t({slug:i.suggestion,slugTouched:!0}),children:[`use `,i.suggestion]})]})]}):i?.available?(0,x.jsxs)(`span`,{className:`text-success-foreground`,children:[`Available · /x/312987/portal/site/`,e.slug]}):`The URL: lowercase letters, digits and dashes`,children:(0,x.jsx)(o5,{mono:!0,value:e.slug,onChange:e=>t({slug:e.target.value.toLowerCase(),slugTouched:!0}),"aria-invalid":i&&!i.available||void 0})}),(0,x.jsx)(u5,{label:`Description (optional)`,className:`sm:col-span-2`,children:(0,x.jsx)(s5,{rows:2,value:e.description,maxLength:1e3,onChange:e=>t({description:e.target.value})})})]}),d=(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(`div`,{className:`relative mb-2`,children:[(0,x.jsx)(am,{className:`pointer-events-none absolute top-1/2 left-2.5 z-10 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,x.jsx)(o5,{size:`compact`,className:`[&_input]:ps-7.5`,placeholder:`Search portals`,"aria-label":`Search portals`,value:o,onChange:e=>s(e.target.value)})]}),(0,x.jsxs)(`div`,{className:`max-h-72 overflow-y-auto rounded-xl border border-border/60 bg-card/40 shadow-xs/5`,children:[r&&(0,x.jsx)(`p`,{className:`px-4 py-3 text-sm text-muted-foreground`,children:`Reading portals…`}),l.map(n=>(0,x.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-3 border-border/50 px-4 py-2 not-first:border-t hover:bg-accent/40`,children:[(0,x.jsx)(`input`,{type:`radio`,className:f5,name:`portal`,checked:e.portal===n.slug,onChange:()=>t({portal:n.slug})}),(0,x.jsx)(`span`,{className:`w-32 shrink-0 truncate font-mono text-xs`,children:n.slug}),(0,x.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm`,children:n.name}),(0,x.jsxs)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:[n.app,` · `,n.isTemplate?`template`:n.active?`live`:`draft`,` · `,n.pageCount,` pages`]}),n.reactPortal&&(0,x.jsx)(kb,{variant:`info`,children:`React Portal`})]},n.slug))]}),n.find(t=>t.slug===e.portal)?.reactPortal&&(0,x.jsxs)(`p`,{className:`mt-2 flex gap-2 text-xs text-info-foreground`,children:[(0,x.jsx)(qf,{className:`size-4 shrink-0`}),`React Portal owns `,e.portal,`: a React Portal upgrade may change these records.`]})]});return e.start===`pull`?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(e$,{title:`Portal`,children:`The portal to work on as files. Nothing on the instance changes until you push.`}),d]}):e.start===`copy`?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(e$,{title:`Portal`,children:`A new draft copied from another portal: its layout, theme, chrome, panels and menus.`}),d,(0,x.jsxs)(`label`,{className:`mt-3 flex items-center gap-2 text-sm`,children:[(0,x.jsx)(c5,{checked:e.copyPages,onCheckedChange:e=>t({copyPages:!!e})}),` Copy its pages too`]}),(0,x.jsx)(`div`,{className:`mt-5`,children:u})]}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(e$,{title:`Portal`,children:`The new draft's name, its URL slug, and what it starts from.`}),u,(0,x.jsxs)(`div`,{className:`mt-5 grid gap-2`,children:[(0,x.jsx)(`span`,{className:`text-xs font-medium`,children:`Start from`}),(0,x.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,x.jsx)(`input`,{type:`radio`,className:f5,checked:e.sourceKind===`template`,onChange:()=>t({sourceKind:`template`})}),`A template`,(0,x.jsx)(d5,{"aria-label":`Template`,className:`w-auto min-w-56`,disabled:e.sourceKind!==`template`,value:e.template,onChange:e=>t({template:e}),options:[{value:``,label:`The default template`},...c.map(e=>({value:e.slug,label:`${e.name} · ${e.pageCount} pages${e.isDefaultTemplate?` (default)`:``}`}))]})]}),(0,x.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,x.jsx)(`input`,{type:`radio`,className:f5,checked:e.sourceKind===`empty`,onChange:()=>t({sourceKind:`empty`})}),`Empty: a layout, one empty Home page, empty menus`]})]})]})}function a$({d:e,set:t,profile:n}){let r=Au(),i=U(r.wizard.layouts.queryOptions({profile:n})),a=U({...r.wizard.themes.queryOptions({profile:n}),enabled:e.themeMode===`pick`}),o=/^#[0-9a-f]{6}$/i.test(e.color),s=U({...r.wizard.brandTheme.queryOptions({color:e.color,tint:e.tint,contrast:e.contrast}),enabled:e.themeMode===`color`&&o}),c=(n,r)=>(0,x.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,x.jsx)(`input`,{type:`radio`,className:f5,checked:e.themeMode===n,onChange:()=>t({themeMode:n})}),r]});return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(e$,{title:`Look and navigation`,children:`Menus and panels come from the source as they are; change them in Studio later.`}),(0,x.jsxs)(`div`,{className:`grid gap-6`,children:[(0,x.jsx)(u5,{label:`Layout`,children:(0,x.jsx)(d5,{"aria-label":`Layout`,className:`max-w-sm`,value:e.layout,onChange:e=>t({layout:e}),options:[{value:``,label:`The source's layout`},...(i.data||[]).map(e=>({value:String(e.uniqueId),label:`${e.name} (${e.uniqueId})`}))]})}),(0,x.jsxs)(`div`,{className:`grid gap-2`,children:[(0,x.jsx)(`span`,{className:`text-xs font-medium`,children:`Theme`}),c(`keep`,e.sourceKind===`empty`?`Starter (the default)`:`Keep the source's theme`),c(`pick`,`A theme or preset`),e.themeMode===`pick`&&(0,x.jsx)(`div`,{className:`ms-6 flex flex-wrap gap-2`,children:(a.data||[]).map(n=>(0,x.jsxs)(`button`,{type:`button`,onClick:()=>t({themeKey:n.key}),className:G(`inline-flex h-8 items-center gap-2 rounded-lg border px-2.5 text-sm`,e.themeKey===n.key?`border-primary bg-accent`:`hover:bg-accent/50`),children:[(0,x.jsx)(`span`,{className:`size-3 rounded-full`,style:{backgroundColor:n.tokens?.light?.primary}}),n.name]},n.key))}),c(`color`,`From a brand color (contrast-safe light and dark tokens, made here)`),e.themeMode===`color`&&(0,x.jsxs)(`div`,{className:`ms-6 grid gap-3`,children:[(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,x.jsx)(`input`,{type:`color`,"aria-label":`Brand color`,value:o?e.color:`#2563eb`,onChange:e=>t({color:e.target.value}),className:`size-8 cursor-pointer rounded-md border border-input bg-transparent`}),(0,x.jsx)(o5,{size:`compact`,mono:!0,className:`w-28`,value:e.color,onChange:e=>t({color:e.target.value}),"aria-label":`Brand color hex`}),(0,x.jsx)(d5,{"aria-label":`Neutrals`,size:`xs`,className:`w-auto`,value:e.tint,onChange:e=>t({tint:e}),options:[{value:`neutral`,label:`Neutral grays`},{value:`tinted`,label:`Tinted with the brand color`}]}),(0,x.jsx)(d5,{"aria-label":`Contrast target`,size:`xs`,className:`w-auto`,value:e.contrast,onChange:e=>t({contrast:e}),options:[{value:`AA`,label:`AA (4.5:1 text)`},{value:`AAA`,label:`AAA (7:1 text)`}]})]}),(0,x.jsx)(o$,{tokens:s.data?.tokens,contrast:s.data?.contrast,error:s.error?.message,loading:s.isFetching})]}),e.themeMode!==`color`&&(0,x.jsxs)(`label`,{className:`mt-1 flex items-center gap-2 text-sm`,children:[(0,x.jsx)(c5,{checked:e.themeCopy,onCheckedChange:e=>t({themeCopy:!!e})}),` Make an editable copy of the theme for this portal`]})]}),e.sourceKind!==`empty`&&(0,x.jsx)(u5,{label:`Brand icon (optional)`,description:`A Lucide icon name for the sidebar, such as briefcase.`,children:(0,x.jsx)(o5,{size:`compact`,mono:!0,className:`w-56`,value:e.icon,onChange:e=>t({icon:e.target.value.toLowerCase()})})})]})]})}function o$({tokens:e,contrast:t,error:n,loading:r}){if(n)return(0,x.jsx)(`p`,{className:`text-xs text-destructive-foreground`,children:JQ(n)[1]});if(!e)return r?(0,x.jsx)(Yb,{size:`sm`,muted:!0}):null;let i=[`primary`,`secondary`,`accent`,`background`,`foreground`,`muted`];return(0,x.jsxs)(`div`,{className:`grid gap-2`,children:[[`light`,`dark`].map(t=>(0,x.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,x.jsx)(`span`,{className:`w-10 text-xs text-muted-foreground`,children:t}),i.filter(n=>e[t]?.[n]).map(n=>(0,x.jsx)(`span`,{title:`${n} ${e[t][n]}`,className:`size-6 rounded-md border border-border/60`,style:{backgroundColor:e[t][n]}},n))]},t)),t&&t.length>0?(0,x.jsx)(`ul`,{className:`text-xs text-warning-foreground`,children:t.map(e=>(0,x.jsxs)(`li`,{children:[`Below target: `,e]},e))}):(0,x.jsx)(`p`,{className:`text-xs text-success-foreground`,children:`Contrast ok`})]})}function s$({d:e,set:t,free:n}){let r=(n,r,i)=>(0,x.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,x.jsx)(c5,{checked:e.extras[n],onCheckedChange:r=>t({extras:{...e.extras,[n]:!!r}})}),r,` `,(0,x.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:i})]});return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(e$,{title:`Folder and extras`,children:`The portal is pulled into this folder; it must be empty or new.`}),(0,x.jsx)(u5,{label:`Folder`,description:n&&!n.empty?(0,x.jsx)(`span`,{className:`text-destructive-foreground`,children:`This folder has files: pick an empty or new one.`}):`The projects folder is set in Settings › Projects.`,children:(0,x.jsx)(o5,{mono:!0,value:e.folder,onChange:e=>t({folder:e.target.value,folderTouched:!0}),"aria-label":`Folder`})}),(0,x.jsxs)(`div`,{className:`mt-5 grid gap-2`,children:[(0,x.jsx)(`span`,{className:`text-xs font-medium`,children:`Also write`}),r(`prettierrc`,`.prettierrc.json`,`React Portal's code style`),r(`gitignore`,`.gitignore`,`.forge/ (the local base copy)`),r(`readme`,`README.md`,`the next commands`),r(`skills`,`Agent skills`,`.claude/skills`),!n?.inRepo&&r(`git`,`git init`,`not inside a repository`)]})]})}function c$({d:e,plan:t,error:n,planning:r,reactPortalApp:i,onReplan:a}){return e.start===`pull`?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(e$,{title:`Review`,children:`Read-only on the instance: nothing changes there until your first push.`}),(0,x.jsxs)(`dl`,{className:`grid grid-cols-[8rem_minmax(0,1fr)] gap-x-4 gap-y-2 text-sm`,children:[(0,x.jsx)(`dt`,{className:`text-muted-foreground`,children:`Portal`}),(0,x.jsx)(`dd`,{className:`font-mono`,children:e.portal}),(0,x.jsx)(`dt`,{className:`text-muted-foreground`,children:`App`}),(0,x.jsx)(`dd`,{children:e.app}),(0,x.jsx)(`dt`,{className:`text-muted-foreground`,children:`Pushes go to`}),(0,x.jsxs)(`dd`,{children:[`update set `,e.setId]}),(0,x.jsx)(`dt`,{className:`text-muted-foreground`,children:`Folder`}),(0,x.jsx)(`dd`,{className:`font-mono text-xs break-all`,children:e.folder}),(0,x.jsx)(`dt`,{className:`text-muted-foreground`,children:`Then`}),(0,x.jsx)(`dd`,{children:Object.entries(e.extras).filter(([,e])=>e).map(([e])=>e).join(`, `)||`nothing else`})]})]}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(e$,{title:`Plan`,children:`The instance's dry run. Create runs exactly this plan.`}),r?(0,x.jsxs)(`span`,{className:`inline-flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,x.jsx)(Yb,{size:`sm`}),` Planning on the instance…`]}):n?(0,x.jsxs)(`div`,{className:`flex gap-2 text-sm`,children:[(0,x.jsx)(Wd,{className:`mt-0.5 size-4 shrink-0 text-destructive-foreground`}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`p`,{className:`text-destructive-foreground`,children:JQ(n)[1]}),(0,x.jsx)(q,{size:`xs`,variant:`outline`,className:`mt-2`,onClick:a,children:`Plan again`})]})]}):t?(0,x.jsxs)(`div`,{className:`grid gap-4 text-sm`,children:[(0,x.jsx)(`p`,{className:`font-medium`,children:t.plan?.summary}),(0,x.jsxs)(`dl`,{className:`grid grid-cols-[8rem_minmax(0,1fr)] gap-x-4 gap-y-1.5`,children:[(0,x.jsx)(`dt`,{className:`text-muted-foreground`,children:`Application`}),(0,x.jsxs)(`dd`,{children:[t.app?.name,` (`,t.app?.scope,`)`]}),(0,x.jsx)(`dt`,{className:`text-muted-foreground`,children:`Update set`}),(0,x.jsxs)(`dd`,{children:[`“`,t.updateSet?.name,`” `,t.updateSet?.isNew&&(0,x.jsx)(kb,{variant:`warning`,children:`new`})]}),(0,x.jsx)(`dt`,{className:`text-muted-foreground`,children:`Creates`}),(0,x.jsx)(`dd`,{children:(t.counts||[]).map(([e,t])=>`${t} ${e}`).join(` · `)||`nothing`}),(0,x.jsx)(`dt`,{className:`text-muted-foreground`,children:`Then`}),(0,x.jsx)(`dd`,{children:(t.local||[]).join(` · `)}),(0,x.jsx)(`dt`,{className:`text-muted-foreground`,children:`planHash`}),(0,x.jsx)(`dd`,{className:`font-mono text-xs`,children:t.plan?.hash})]}),(t.plan?.warnings||[]).length>0&&(0,x.jsx)(`ul`,{className:`grid gap-1 text-xs text-warning-foreground`,children:t.plan.warnings.map(e=>(0,x.jsxs)(`li`,{className:`flex gap-1.5`,children:[(0,x.jsx)(Lm,{className:`size-3.5 shrink-0`}),` `,e]},e))}),i&&(0,x.jsx)(`p`,{className:`text-xs text-info-foreground`,children:`React Portal owns these records: a React Portal upgrade may change them.`}),(t.contrast||[]).length>0&&(0,x.jsxs)(`p`,{className:`text-xs text-warning-foreground`,children:[`Theme contrast: `,t.contrast.length,` pair(s) below target.`]}),(0,x.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`The portal is created as a draft. Publish it in Studio when it is ready; Forge never publishes.`})]}):null]})}function l$({job:e,onRetry:t,retrying:n,onBack:r}){let i=e?.state||`running`;return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(e$,{title:i===`done`?`Done`:i===`running`?`Working…`:i===`pull_failed`?`The draft exists; the pull failed`:`Stopped`}),(0,x.jsxs)(`ol`,{className:`grid gap-1.5 font-mono text-xs`,children:[(e?.log||[]).map((e,t,n)=>{let r=t===n.length-1&&(i===`failed`||i===`pull_failed`);return(0,x.jsxs)(`li`,{className:G(`flex gap-2`,r&&`text-destructive-foreground`),children:[r?(0,x.jsx)(Wd,{className:`mt-0.5 size-3 shrink-0`}):(0,x.jsx)(Md,{className:`mt-0.5 size-3 shrink-0 text-success-foreground`}),(0,x.jsx)(`span`,{className:`break-all`,children:e})]},t)}),i===`running`&&(0,x.jsxs)(`li`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,x.jsx)(Yb,{size:`xs`}),` working`]})]}),i===`done`&&(0,x.jsx)(`p`,{className:`mt-4 text-sm text-success-foreground`,children:`Opening the project…`}),i===`pull_failed`&&(0,x.jsxs)(`div`,{className:`mt-4 flex items-center gap-2`,children:[(0,x.jsx)(q,{size:`sm`,disabled:n,onClick:t,children:`Retry pull`}),e?.result?.studioUrl&&(0,x.jsx)(`a`,{className:`text-xs underline`,href:e.result.studioUrl,target:`_blank`,rel:`noreferrer noopener`,children:`Open the draft in Studio`})]}),i===`failed`&&(0,x.jsxs)(`div`,{className:`mt-4`,children:[(0,x.jsx)(`p`,{className:`text-sm text-destructive-foreground`,children:JQ(e?.error)[1]}),(0,x.jsx)(q,{size:`sm`,variant:`outline`,className:`mt-2`,onClick:r,children:`Back to the plan`})]})]})}var u$=[[`general`,`General`],[`appearance`,`Appearance`],[`providers`,`Providers and models`],[`usage`,`Usage`],[`instances`,`Instances`],[`projects`,`Projects`],[`doctor`,`Doctor`],[`skills`,`Skills`],[`keybindings`,`Keybindings`],[`diffs`,`Diffs`],[`about`,`About and updates`],[`licenses`,`Open-source licenses`]];function d$(){let[e,t]=b.useState(!1);return b.useEffect(()=>{let e=e=>e.detail===`commandPalette.toggle`&&t(e=>!e);return window.addEventListener(`forge:command`,e),()=>window.removeEventListener(`forge:command`,e)},[]),(0,x.jsx)(U6,{open:e,onOpenChange:t,children:e&&(0,x.jsx)(f$,{onClose:()=>t(!1)})})}function f$({onClose:e}){let t=Au(),n=Yi(),r=Gu(),i=i8(),a=Fa({select:e=>e.location.pathname}),o=/^\/p\/([^/]+)/.exec(a)?.[1],s=U(t.projects.list.queryOptions()),c=U(t.chats.recent.queryOptions({limit:60})),l=U(t.settings.get.queryOptions()).data?.keybindings||[],[u,d]=b.useState(``),[f,p]=b.useState(0),m=b.useRef(null),h=t=>()=>{e(),t()},g=[...o?[{id:`chat.new`,group:`Actions`,title:`New chat`,icon:xm,command:`chat.new`,run:h(()=>n({to:`/p/$projectId`,params:{projectId:o}}))},{id:`push`,group:`Actions`,title:`Plan a push…`,detail:`dry run, then review`,icon:zm,run:h(()=>Wu({pushOpen:!0}))}]:[],{id:`project.new`,group:`Actions`,title:`New project…`,detail:`new, pull or copy a portal`,icon:Cf,run:h(()=>Wu({newProject:`choose`}))},{id:`panel`,group:`Actions`,title:r.panelOpen?`Hide the right panel`:`Show the right panel`,icon:jp,command:`rightPanel.toggle`,run:h(()=>Wu({panelOpen:!r.panelOpen}))},{id:`terminal`,group:`Actions`,title:r.drawerOpen?`Hide the terminal`:`Show the terminal`,icon:Dp,command:`terminal.toggle`,run:h(()=>Wu({drawerOpen:!r.drawerOpen}))},{id:`theme`,group:`Actions`,title:document.documentElement.classList.contains(`dark`)?`Switch to light theme`:`Switch to dark theme`,icon:document.documentElement.classList.contains(`dark`)?km:_p,run:h(()=>Wu({theme:document.documentElement.classList.contains(`dark`)?`light`:`dark`}))},{id:`usage`,group:`Actions`,title:`Usage`,icon:Ad,command:`usage.open`,run:h(()=>i(`usage`))},{id:`doctor`,group:`Actions`,title:`Run doctor`,icon:Dm,run:h(()=>i(`doctor`))},...(s.data||[]).map(e=>({id:`p:${e.id}`,group:`Projects`,title:e.name,detail:e.path,icon:Df,run:h(()=>n({to:`/p/$projectId`,params:{projectId:e.id}}))})),...(c.data||[]).slice(0,30).map(e=>({id:`c:${e.id}`,group:`Chats`,title:e.title,detail:e.projectName,icon:dp,run:h(()=>n({to:`/p/$projectId/c/$chatId`,params:{projectId:e.projectId,chatId:e.id}}))})),...u$.map(([e,t])=>({id:`s:${e}`,group:`Settings`,title:t,detail:`Settings`,icon:dm,command:e===`general`?`settings.open`:void 0,run:h(()=>i(e))}))],_=u.toLowerCase().split(/\s+/).filter(Boolean),v=g.filter(e=>_.every(t=>`${e.title} ${e.detail||``} ${e.group}`.toLowerCase().includes(t))),y=u?v:v.filter(e=>e.group!==`Settings`).slice(0,14),S=Math.min(f,Math.max(0,y.length-1));b.useEffect(()=>p(0),[u]),b.useEffect(()=>{m.current?.querySelector(`[data-highlighted]`)?.scrollIntoView({block:`nearest`})},[S]);let C=e=>{e.key===`ArrowDown`?(e.preventDefault(),p((S+1)%Math.max(1,y.length))):e.key===`ArrowUp`?(e.preventDefault(),p((S-1+y.length)%Math.max(1,y.length))):e.key===`Enter`&&(e.preventDefault(),y[S]?.run())},w=e=>{let t=e&&ju.find(t=>t.id===e);return t?Iu(Mu(t,l)):``},T=``;return(0,x.jsxs)(I6,{children:[(0,x.jsx)(D6,{className:`fixed inset-0 z-50 bg-background/60 backdrop-blur-[4px] transition-opacity duration-200 data-[ending-style]:opacity-0 data-[starting-style]:opacity-0`}),(0,x.jsx)(`div`,{className:`pointer-events-none fixed inset-0 z-50 flex flex-col items-center px-4 pt-[max(1rem,4vh)] sm:pt-[10vh]`,children:(0,x.jsxs)(F6,{"aria-label":`Command palette`,className:`glass pointer-events-auto flex max-h-105 w-full max-w-xl flex-col overflow-hidden rounded-2xl text-foreground shadow-[0_24px_64px_-24px_rgb(0_0_0/65%)] transition-[opacity,scale] duration-150 data-[ending-style]:scale-98 data-[ending-style]:opacity-0 data-[starting-style]:scale-98 data-[starting-style]:opacity-0`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/60 px-4 py-2.5`,children:[(0,x.jsx)(am,{className:`size-4 shrink-0 text-icon-muted`}),(0,x.jsx)(`input`,{autoFocus:!0,value:u,onChange:e=>d(e.target.value),onKeyDown:C,placeholder:`Search projects, chats, actions and settings`,"aria-label":`Search commands`,className:`h-7 min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground`})]}),(0,x.jsxs)(`div`,{ref:m,role:`listbox`,className:`min-h-0 flex-1 overflow-y-auto p-2`,children:[y.length===0&&(0,x.jsx)(`p`,{className:`py-10 text-center text-sm text-muted-foreground`,children:`No matching commands`}),y.map((e,t)=>{let n=e.group!==T;return T=e.group,(0,x.jsxs)(b.Fragment,{children:[n&&(0,x.jsx)(`div`,{className:G(`px-2 pb-1 text-xs font-medium text-muted-foreground`,t>0&&`pt-2.5`),children:e.group}),(0,x.jsxs)(`div`,{role:`option`,"aria-selected":t===S,"data-highlighted":t===S||void 0,onMouseMove:()=>p(t),onClick:e.run,className:G(`flex min-h-7 cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-sm select-none`,t===S&&`bg-foreground/[0.09]`),children:[(0,x.jsx)(e.icon,{className:`size-4 shrink-0 text-icon-muted`}),(0,x.jsx)(`span`,{className:`truncate`,children:e.title}),e.detail&&(0,x.jsx)(`span`,{className:`max-w-[45%] shrink-0 truncate text-xs text-muted-foreground/70`,children:e.detail}),w(e.command)&&(0,x.jsx)(`kbd`,{className:`ms-auto font-sans text-xs font-medium tracking-widest text-secondary-label`,children:w(e.command)})]})]},e.id)})]}),(0,x.jsxs)(`div`,{className:`flex items-center gap-3 border-t border-border/60 px-4 py-2 text-xs text-muted-foreground`,children:[(0,x.jsx)(`span`,{children:`↑↓ move`}),(0,x.jsx)(`span`,{children:`↵ run`}),(0,x.jsx)(`span`,{children:`Esc close`})]})]})})]})}var p$=new Ue({defaultOptions:{queries:{staleTime:5e3,refetchOnWindowFocus:!1}}});function m$(e){let t=Gu(),n=Yi(),r=mi(),i=i8(),a=Fa({select:e=>e.location.pathname}),o=b.useRef({ui:t,overrides:e,path:a});o.current={ui:t,overrides:e,path:a},b.useEffect(()=>{let e=e=>{let{ui:t,path:a}=o.current,s=/^\/p\/([^/]+)/.exec(a)?.[1];switch(e){case`sidebar.toggle`:return Wu({sidebarOpen:!t.sidebarOpen});case`rightPanel.toggle`:return Wu({panelOpen:!t.panelOpen});case`terminal.toggle`:return Wu({drawerOpen:!t.drawerOpen});case`preview.toggle`:return Wu(t.panelOpen&&t.panelTab===`preview`?{panelOpen:!1}:{panelOpen:!0,panelTab:`preview`});case`diff.toggle`:return Wu(t.panelOpen&&t.panelTab===`diff`?{panelOpen:!1}:{panelOpen:!0,panelTab:`diff`});case`settings.open`:return i(`general`);case`usage.open`:return i(`usage`);case`navigation.back`:return r.history.back();case`navigation.forward`:return r.history.forward();case`chat.new`:s&&n({to:`/p/$projectId`,params:{projectId:s}});return;default:window.dispatchEvent(new CustomEvent(`forge:command`,{detail:e}))}},t=t=>{let n=t.target;if(n?.closest?.(`[data-keybinding-capture]`))return;let r=Pu(t);if(!r)return;let i=!!n&&(/INPUT|TEXTAREA|SELECT/.test(n.tagName)||n.isContentEditable),a=ju.find(e=>Mu(e,o.current.overrides)===r);!a||i&&!a.inFields||(t.preventDefault(),e(a.id))};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[n,r,i])}function h$(){let e=Au(),t=Yi(),n=Fa({select:e=>e.location.pathname}),r=U(e.wizard.context.queryOptions()),i=b.useRef(!1);b.useEffect(()=>{!i.current&&r.data?.firstRun&&n!==`/welcome`&&(i.current=!0,t({to:`/welcome`}))},[r.data?.firstRun,n,t])}function g$(){let e=Gu();Ru();let t=U(Au().settings.get.queryOptions()),n=Ji({strict:!1}),r=i8(),i=Fa({select:e=>e.location.pathname})===`/welcome`;m$(t.data?.keybindings||[]),h$();let a=t.data?.diffs?.colors||`red-green`;return b.useEffect(()=>{document.documentElement.dataset.diffColors=a},[a]),(0,x.jsxs)(`div`,{className:`flex h-full overflow-hidden`,children:[e.sidebarOpen&&!i&&(0,x.jsx)(u8,{}),(0,x.jsx)(`main`,{className:`flex min-w-0 flex-1 bg-background`,children:(0,x.jsx)(Ta,{})}),(0,x.jsx)(ZQ,{}),(0,x.jsx)(d$,{}),n.settings===`usage`?(0,x.jsx)(HQ,{onClose:()=>r(null)}):n.settings&&(0,x.jsx)(NQ,{section:n.settings,onSection:r,onClose:()=>r(null)})]})}var _$=ha({component:g$,validateSearch:e=>typeof e.settings==`string`?{settings:e.settings}:{}}),v$=pa({getParentRoute:()=>_$,path:`/`,component:x8}),y$=pa({getParentRoute:()=>_$,path:`/p/$projectId`,component:function(){let{projectId:e}=qi({from:`/p/$projectId`});return(0,x.jsx)(rQ,{projectId:e})}}),b$=pa({getParentRoute:()=>_$,path:`/p/$projectId/c/$chatId`,component:function(){let{projectId:e,chatId:t}=qi({from:`/p/$projectId/c/$chatId`});return(0,x.jsx)(rQ,{projectId:e,chatId:t})}}),x$=pa({getParentRoute:()=>_$,path:`/welcome`,component:uC}),S$=pa({getParentRoute:()=>_$,path:`/settings/$section`,beforeLoad:({params:e})=>{throw sn({to:`/`,search:{settings:e.section}})}}),C$=ja({routeTree:_$.addChildren([v$,x$,y$,b$,S$])});Ku(localStorage.getItem(`forge.theme`)||`system`),Ha(),(0,Ia.createRoot)(document.getElementById(`root`)).render((0,x.jsx)(b.StrictMode,{children:(0,x.jsx)(w,{client:p$,children:(0,x.jsx)(ku,{trpcClient:Ou,queryClient:p$,children:(0,x.jsx)(wb,{delay:400,children:(0,x.jsx)(Pa,{router:C$})})})})}));export{nR as $,Ye as $t,$q as A,lp as At,uJ as B,Xu as Bt,SJ as C,A4 as Ct,_J as D,Fm as Dt,pJ as E,q as Et,aJ as F,Qd as Ft,Xq as G,G as Gt,Kq as H,Ju as Ht,sJ as I,Id as It,tJ as J,tt as Jt,Yq as K,U as Kt,iJ as L,Md as Lt,oJ as M,hf as Mt,lJ as N,sf as Nt,vJ as O,Nm as Ot,eJ as P,ef as Pt,tR as Q,Ze as Qt,rJ as R,gd as Rt,NJ as S,b3 as St,yJ as T,i1 as Tt,Zq as U,Gu as Ut,Jq as V,Wu as Vt,Qq as W,Au as Wt,bW as X,Xe as Xt,nJ as Y,et as Yt,rR as Z,Qe as Zt,$J as _,Yb as _t,TZ as a,B as an,L9 as at,HJ as b,G3 as bt,rZ as c,y as cn,V9 as ct,nZ as d,o as dn,n9 as dt,Ke as en,QL as et,sZ as f,s as fn,Z7 as ft,XJ as g,s5 as gt,oY as h,x5 as ht,EZ as i,k as in,W9 as it,cJ as j,Tf as jt,hJ as k,Yp as kt,iZ as l,h as ln,r9 as lt,uZ as m,J7 as mt,CZ as n,_e as nn,hL as nt,DZ as o,V as on,R9 as ot,aZ as p,l as pn,K7 as pt,qq as q,$e as qt,wZ as r,pe as rn,G9 as rt,bZ as s,C as sn,z9 as st,OZ as t,je as tn,xL as tt,oZ as u,d as un,u9 as ut,qJ as v,Tb as vt,bJ as w,D4 as wt,VJ as x,I3 as xt,GJ as y,Y3 as yt,Gq as z,K as zt};
|
|
290
|
+
`)||`Starting the dev server…`})]}):t?.state===`failed`?(0,x.jsx)(b8,{icon:Wd,title:t.code===`no_profile`?`No profile for this instance`:t.code===`no_portal`?`Nothing to preview`:`The dev server failed`,actions:t.code===`no_portal`?null:(0,x.jsxs)(x.Fragment,{children:[t.code===`no_profile`&&(0,x.jsx)(a8,{section:`instances`,children:(0,x.jsx)(q,{size:`sm`,variant:`outline`,children:`Add a profile`})}),(0,x.jsxs)(q,{size:`sm`,variant:`outline`,onClick:n,children:[(0,x.jsx)($p,{}),` Restart`]})]}),children:t.error}):(0,x.jsx)(b8,{icon:hp,title:`No preview yet`,children:`The project’s portal appears here, live, once its dev server is running.`})]}),f&&(0,x.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 border-t px-3 py-1 text-2xs text-muted-foreground`,children:[(0,x.jsx)(`span`,{className:`size-1.5 rounded-full bg-success`}),`your session · live data (not read-only)`,t.state===`attached`&&(0,x.jsx)(`span`,{className:`ml-auto`,children:`attached to your rpf dev`})]})]})}var LZ=[{id:`preview`,label:`Preview`,icon:md},{id:`agent`,label:`Agent`,icon:xp},{id:`diff`,label:`Diff`,icon:_f},{id:`files`,label:`Files`,icon:Tf},{id:`terminal`,label:`Terminal`,icon:Cm},{id:`problems`,label:`Problems`,icon:Wd},{id:`plan`,label:`Push plan`,icon:zm}],RZ={agent:{icon:xp,title:`The agent’s browser`,text:`A live view of the read-only browser the agent uses to look at and click through the portal.`},diff:{icon:_f,title:`No changes yet`,text:`Every edit the agent makes shows here, per turn or for the session, with undo.`},files:{icon:Tf,title:`Files`,text:`The project tree, with changed files marked.`},terminal:{icon:Cm,title:`Terminal`,text:`Your shell in the project folder, and live views of the agent’s commands.`},problems:{icon:Wd,title:`No problems`,text:`Compile errors, missing components and console errors from the preview show here.`},plan:{icon:zm,title:`No push plan`,text:`Check and plan a push to the instance; every push is reviewed in a dialog before it runs.`}};function zZ(e,t,n,r,i,a){let o=new Set(e);for(let t of e){let e=Zu(t);e&&iZ(a,e)}let s=t.filter(e=>!o.has(e)),c=e.filter(e=>!Zu(e)),l=i.filter(e=>!o.has(`file:${e}`));if(!s.length)return Wu({panelOpen:!1,openFiles:l,closedTabs:[...r,...c]});let u=n;if(o.has(n)){let e=t.indexOf(n);u=t.slice(e).find(e=>!o.has(e))??t.slice(0,e).reverse().find(e=>!o.has(e))}Wu({closedTabs:[...r,...c],openFiles:l,panelTab:u})}var BZ=b.lazy(()=>NJ(()=>import(`./file-panel-le_M5nHe.js`).then(e=>({default:e.FilePanel})),__vite__mapDeps([12,9,3,1,5,7]))),VZ=e=>e.slice(e.lastIndexOf(`/`)+1);function HZ({projectId:e,dev:t,onRestart:n}){let r=Gu(),i=RZ[r.panelTab],a=r.openFiles||[];lZ();let[o,s]=b.useState(null),c=r.closedTabs||[];b.useEffect(()=>{c.includes(r.panelTab)&&Wu({closedTabs:c.filter(e=>e!==r.panelTab)})},[r.panelTab,c]);let l=LZ.filter(e=>!c.includes(e.id)||e.id===r.panelTab),u=LZ.filter(e=>!l.includes(e)),d=[...l.map(e=>e.id),...a.map(e=>`file:${e}`)],f=t=>zZ(t,d,r.panelTab,c,a,e),p=e=>f([e]),m=[...l.map(e=>({id:e.id,label:e.label,icon:(0,x.jsx)(e.icon,{className:`size-3`})})),...a.map(t=>({id:`file:${t}`,label:VZ(t),title:t,icon:(0,x.jsx)(u9,{path:t,className:`size-3`}),pending:oZ(e,t)}))],h=o?d.indexOf(o.id):-1,g=o?[...Zu(o.id)?[{id:`copy-path`,label:`Copy path`}]:[],{id:`close`,label:`Close`},{id:`close-others`,label:`Close others`,disabled:d.length<=1},{id:`close-to-right`,label:`Close to the right`,disabled:h>=d.length-1},{id:`close-all`,label:`Close all`,disabled:d.length===0}]:[],_=e=>{if(!o)return;let t=o.id;s(null),e===`copy-path`?navigator.clipboard.writeText(Zu(t)||``):e===`close`?p(t):e===`close-others`?f(d.filter(e=>e!==t)):e===`close-to-right`?f(d.slice(d.indexOf(t)+1)):e===`close-all`&&f(d)},v=WZ(),y=(0,x.jsxs)(`section`,{className:G(`relative flex h-full shrink-0 flex-col bg-background`,v?`w-full bg-popover`:`border-l`),style:v?void 0:{width:r.panelWidth},children:[(0,x.jsxs)(`div`,{className:`flex h-[var(--topbar-h)] shrink-0 items-center gap-1 overflow-x-auto pl-2 [scrollbar-width:none]`,children:[m.map(e=>(0,x.jsxs)(`div`,{onClick:t=>{t.target===t.currentTarget&&Wu({panelTab:e.id})},onAuxClick:t=>{t.button===1&&p(e.id)},onContextMenu:t=>{t.preventDefault(),s({at:{x:t.clientX,y:t.clientY},id:e.id})},title:e.title,className:G(`group/tab flex h-6 max-w-36 shrink-0 cursor-pointer items-center gap-0.5 rounded-md pr-2 pl-1.5 text-xs`,r.panelTab===e.id?`bg-accent text-foreground`:`text-muted-foreground hover:bg-accent/60 hover:text-foreground`),children:[(0,x.jsxs)(`button`,{type:`button`,"aria-label":`Close ${e.label}`,onClick:()=>p(e.id),className:`group/close relative flex size-4 shrink-0 cursor-pointer items-center justify-center rounded-sm hover:bg-muted`,children:[(0,x.jsx)(`span`,{className:`flex group-hover/tab:hidden group-focus-visible/close:hidden`,children:e.icon}),e.pending&&(0,x.jsx)(`span`,{className:`absolute -right-0.5 -bottom-0.5 size-1.5 rounded-full bg-current group-hover/tab:hidden`,"aria-hidden":!0}),(0,x.jsx)(Gm,{className:`hidden size-3 group-hover/tab:block group-focus-visible/close:block`})]}),(0,x.jsx)(`button`,{type:`button`,"aria-pressed":r.panelTab===e.id,onClick:()=>Wu({panelTab:e.id}),className:`flex min-w-0 cursor-pointer items-center`,children:(0,x.jsx)(`span`,{className:`truncate`,children:e.label})})]},e.id)),u.length>0&&(0,x.jsxs)(mb,{children:[(0,x.jsx)(hb,{render:(0,x.jsx)(q,{"aria-label":`Open a tab`,title:`Open a tab`,className:`shrink-0`,size:`icon-xs`,variant:`ghost-muted`}),children:(0,x.jsx)(qp,{className:`size-3.5`})}),(0,x.jsx)(gb,{align:`start`,sideOffset:6,children:u.map(e=>(0,x.jsxs)(_b,{onClick:()=>Wu({panelTab:e.id}),children:[(0,x.jsx)(e.icon,{}),e.label]},e.id))})]})]}),(0,x.jsx)(`div`,{className:`min-h-0 flex-1 border-t`,children:r.panelTab===`preview`?(0,x.jsx)(IZ,{projectId:e,dev:t,onRestart:n}):r.panelTab===`agent`?(0,x.jsx)(hZ,{projectId:e}):r.panelTab===`terminal`?(0,x.jsx)(_Z,{projectId:e}):r.panelTab===`diff`?(0,x.jsx)(SZ,{projectId:e}):Zu(r.panelTab)?(0,x.jsx)(b.Suspense,{fallback:null,children:(0,x.jsx)(BZ,{projectId:e,path:Zu(r.panelTab)},r.panelTab)}):r.panelTab===`plan`?(0,x.jsx)(AZ,{projectId:e}):r.panelTab===`files`?(0,x.jsx)(b.Suspense,{fallback:null,children:(0,x.jsx)(BZ,{projectId:e,path:null})}):i?(0,x.jsx)(b8,{icon:i.icon,title:i.title,children:i.text}):null}),(0,x.jsx)(OZ,{at:o?.at??null,items:g,onPick:_,onClose:()=>s(null)}),!v&&(0,x.jsx)(KZ,{})]});return v?(0,x.jsx)(GZ,{children:y}):y}var UZ=`(max-width: 980px)`;function WZ(){let[e,t]=b.useState(()=>window.matchMedia(UZ).matches);return b.useEffect(()=>{let e=window.matchMedia(UZ),n=()=>t(e.matches);return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}function GZ({children:e}){return(0,x.jsx)(U6,{open:!0,onOpenChange:(e,t)=>{if(!e){if(t.reason===`escape-key`&&t.event?.repeat)return t.cancel();Wu({panelOpen:!1})}},children:(0,x.jsxs)(I6,{children:[(0,x.jsx)(D6,{className:`fixed inset-0 z-40 bg-background/60 backdrop-blur-xs transition-all duration-200 data-[ending-style]:opacity-0 data-[starting-style]:opacity-0`}),(0,x.jsx)(`div`,{className:`fixed inset-0 z-40 flex justify-end`,"data-slot":`sheet-viewport`,children:(0,x.jsx)(F6,{"aria-label":`Workspace panel`,className:`relative flex h-full max-h-full w-[min(42vw,28rem)] max-w-[28rem] min-w-80 flex-col border-s bg-popover text-popover-foreground shadow-lg/5 transition-[opacity,translate] duration-200 ease-in-out will-change-transform data-[ending-style]:translate-x-8 data-[ending-style]:opacity-0 data-[starting-style]:translate-x-8 data-[starting-style]:opacity-0 max-[760px]:w-[min(88vw,24rem)] max-[760px]:min-w-0`,children:e})})]})})}function KZ(){return(0,x.jsx)(`div`,{onPointerDown:e=>{e.preventDefault();let t=e=>{let t=window.innerWidth-e.clientX;Wu({panelWidth:Math.min(window.innerWidth*.7,Math.max(360,t))})},n=()=>{window.removeEventListener(`pointermove`,t),window.removeEventListener(`pointerup`,n),document.body.style.cursor=``};document.body.style.cursor=`col-resize`,window.addEventListener(`pointermove`,t),window.addEventListener(`pointerup`,n)},className:`group absolute top-0 -left-2 z-10 flex h-full w-4 cursor-col-resize justify-center`,children:(0,x.jsx)(`div`,{className:`h-full w-0.5 transition-colors group-hover:bg-border`})})}function qZ(e=``){return e.replace(/^x_\d+_portal_/,``).replace(/^sys_/,``)}var JZ=/^(server_script|script|server_js|server\.js)$/;function YZ({verb:e,tone:t,item:n}){let r=Object.keys(n.changes||n.fields||{}).filter(e=>e!==`sys_updated_on`),i=r.some(e=>JZ.test(e)),a=n.changes?.revision;return(0,x.jsxs)(`div`,{className:`grid grid-cols-[6.5rem_minmax(0,1fr)] gap-x-2 py-0.5`,children:[(0,x.jsx)(`span`,{className:G(`font-medium`,t),children:e}),(0,x.jsxs)(`div`,{className:`min-w-0`,children:[(0,x.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,x.jsx)(`span`,{className:`text-muted-foreground`,children:qZ(n.table)}),(0,x.jsx)(`span`,{className:`truncate text-foreground`,children:n.display||n.path||n.id}),a&&(0,x.jsxs)(`span`,{className:`ms-auto shrink-0 text-muted-foreground tabular-nums`,children:[`rev `,String(a.from),` → `,String(a.to)]})]}),r.length>0&&e!==`DEACTIVATE`&&(0,x.jsx)(`div`,{className:`truncate text-muted-foreground`,children:r.filter(e=>e!==`revision`).join(`, `)}),i&&(0,x.jsxs)(`div`,{className:`flex items-center gap-1 text-warning-foreground`,children:[(0,x.jsx)(Lm,{className:`size-3 shrink-0`}),` server script: runs on the instance as each visitor`]})]})]})}function XZ({chunks:e}){let t=t=>e.flatMap(e=>e[t]||[]),n=e.flatMap(e=>e.compile?.components||[]),r=e.map(e=>e.compile?.theme).filter(Boolean),i=e.some(e=>e.compile?.finalize?.reprocess),a=[];return t(`creates`).length||a.push(`nothing created`),t(`deactivates`).length||a.push(`nothing deactivated`),t(`deletes`).length||a.push(`no files removed`),(0,x.jsxs)(`div`,{className:`rounded-lg border bg-muted/40 px-3 py-2 font-mono text-xs`,children:[e.map((t,n)=>(0,x.jsxs)(`div`,{className:G(n>0&&`mt-2 border-t border-border/60 pt-2`),children:[e.length>1&&(0,x.jsxs)(`div`,{className:`mb-0.5 text-2xs tracking-wide text-muted-foreground uppercase`,children:[`chunk `,n+1,` of `,e.length]}),(t.creates||[]).map((e,t)=>(0,x.jsx)(YZ,{verb:`CREATE`,tone:`text-success-foreground`,item:e},`c${t}`)),(t.updates||[]).map((e,t)=>(0,x.jsx)(YZ,{verb:`UPDATE`,tone:`text-info-foreground`,item:e},`u${t}`)),(t.deactivates||[]).map((e,t)=>(0,x.jsx)(YZ,{verb:`DEACTIVATE`,tone:`text-warning-foreground`,item:e},`d${t}`)),(t.deletes||[]).map((e,t)=>(0,x.jsx)(YZ,{verb:`DELETE FILE`,tone:`text-destructive-foreground`,item:e},`x${t}`)),(t.compile?.components||[]).map(e=>(0,x.jsxs)(`div`,{className:`grid grid-cols-[6.5rem_minmax(0,1fr)] gap-x-2 py-0.5`,children:[(0,x.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:`COMPILE`}),(0,x.jsx)(`span`,{className:`truncate`,children:e})]},`k${e}`))]},n)),r.length>0&&(0,x.jsxs)(`div`,{className:`grid grid-cols-[6.5rem_minmax(0,1fr)] gap-x-2 py-0.5`,children:[(0,x.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:`THEME`}),(0,x.jsx)(`span`,{children:r.join(`, `)})]}),i&&(0,x.jsxs)(`div`,{className:`grid grid-cols-[6.5rem_minmax(0,1fr)] gap-x-2 py-0.5`,children:[(0,x.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:`REPROCESS`}),(0,x.jsx)(`span`,{children:`the portal (once, at the end)`})]}),!n.length&&!i&&!e.some(e=>(e.updates||[]).length)&&(0,x.jsx)(`div`,{className:`py-0.5 text-muted-foreground`,children:`No writes.`}),a.length>0&&(0,x.jsxs)(`div`,{className:`mt-1 text-muted-foreground`,children:[a.join(`, `),`.`]})]})}function ZZ({overwrites:e,slug:t,typed:n,onType:r}){return(0,x.jsxs)(`div`,{className:`rounded-lg border border-destructive/40 bg-destructive/6 px-3 py-2.5 dark:bg-destructive/12`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium text-destructive-foreground`,children:[(0,x.jsx)(Lm,{className:`size-4`}),` Force push: these instance changes are overwritten`]}),e.length===0?(0,x.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:`No instance-side changes to overwrite.`}):(0,x.jsx)(`div`,{className:`mt-1.5 max-h-44 overflow-auto font-mono text-xs`,children:e.map((e,t)=>(0,x.jsxs)(`div`,{className:`py-0.5`,children:[(0,x.jsxs)(`div`,{className:`flex gap-2`,children:[(0,x.jsx)(`span`,{className:`truncate text-foreground`,children:e.id}),(0,x.jsx)(`span`,{className:`ms-auto shrink-0 text-muted-foreground`,children:[e.updatedBy,e.updatedOn].filter(Boolean).join(` · `)})]}),(e.fields||[]).slice(0,6).map(e=>(0,x.jsxs)(`div`,{className:`truncate ps-3 text-muted-foreground`,children:[e.path,`: `,(0,x.jsx)(`span`,{className:`text-destructive-foreground`,children:$Z(e.instance)}),` → `,(0,x.jsx)(`span`,{className:`text-foreground`,children:$Z(e.file)})]},e.path)),e.diff&&(0,x.jsx)(`div`,{className:`ps-3 text-muted-foreground`,children:`file content differs`}),e.binary&&(0,x.jsx)(`div`,{className:`ps-3 text-muted-foreground`,children:`image replaced`})]},t))}),(0,x.jsxs)(`label`,{className:`mt-2.5 grid gap-1.5 text-xs`,children:[(0,x.jsxs)(`span`,{children:[`Type `,(0,x.jsx)(`span`,{className:`font-mono font-medium`,children:t||`(unknown portal)`}),` to confirm`]}),(0,x.jsx)(o5,{size:`compact`,mono:!0,value:n,onChange:e=>r(e.target.value),autoComplete:`off`})]})]})}function QZ(e){return/^Conflicts \(or records without a known base\)/.test(e)?`Conflicts are open (or records without a known base). Resolve them in the Push plan tab, or plan a force push to make the instance match the files.`:/merge conflict markers/i.test(e)?`Files still have merge conflict markers: finish the merge first.`:e.replace(/workspace_pull/g,`a pull`).replace(/workspace_push \{ dryRun: true \}/g,`a dry run`)}function $Z(e){let t=typeof e==`string`?e:JSON.stringify(e);return t===void 0?`—`:t.length>60?`${t.slice(0,57)}…`:t}function eQ({progress:e}){let t=e?e.phase===`finishing`?96:(e.chunk-1)/e.of*92+4:4;return(0,x.jsxs)(`div`,{className:`rounded-lg border px-3 py-2.5`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,x.jsx)(Yb,{size:`sm`}),e?e.phase===`finishing`?`Written. Moving the base to the instance…`:`Writing chunk ${e.chunk} of ${e.of}…`:`Checking the plan on the instance…`]}),(0,x.jsx)(`div`,{className:`mt-2 h-1 overflow-hidden rounded-full bg-foreground/8`,children:(0,x.jsx)(`div`,{className:`h-full rounded-full bg-primary transition-[width] duration-500`,style:{width:`${t}%`}})})]})}function tQ({projectId:e}){let t=Gu(),n=Au(),r=t.pushOpen,i=U(n.projects.info.queryOptions({id:e})),a=U({...n.push.state.queryOptions({projectId:e}),enabled:r}),o=at(n.push.plan.mutationOptions()),s=at(n.push.run.mutationOptions()),[c,l]=b.useState(!1),[u,d]=b.useState(``),[f,p]=b.useState(!1),[m,h]=b.useState(``),g=i.data?.facts;b.useEffect(()=>{r&&(s.reset(),o.mutate({projectId:e,force:c}))},[r,c]);let _=()=>{s.isPending||(Wu({pushOpen:!1}),l(!1),d(``),p(!1))},v=o.data?.result,y=v?.chunks||[],S=y.reduce((e,t)=>e+(t.creates?.length||0)+(t.updates?.length||0)+(t.deactivates?.length||0)+(t.deletes?.length||0),0),C=s.data?.result,w=a.data?.plan,T=!!w&&w.result?.planHash===v?.planHash&&!!w.stale||!!s.error&&/dry run again|changed since/i.test(s.error.message)||!!C?.refused&&/dry run again|changed since/i.test(C.reason||``),E=[...new Set(y.flatMap(e=>e.warnings||[]))].filter(e=>!/^Force push:/.test(e)),D=v?.instanceChangesLeftAlone||[],O=!!v?.planHash&&!v?.refused&&!v?.nothingToPush&&!s.isPending&&!C&&(!c||u===g?.portal),k=c?`Force push`:`Push`,A=S?`${S} ${S===1?`change`:`changes`}`:v?.pending?`and finish`:``;return(0,x.jsx)(Eb,{open:r,onOpenChange:e=>!e&&_(),children:(0,x.jsx)(Db,{className:`max-w-3xl`,title:`Push to ${g?.host||`the instance`}`,description:g?`${g.portal||`workspace`} → ${g.instance}${i.data?.profile?` · profile ${i.data.profile}`:``}`:void 0,footer:C&&!C.refused?C.failed?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(q,{variant:`outline`,onClick:_,children:`Close`}),(0,x.jsx)(q,{onClick:()=>{s.reset(),o.mutate({projectId:e,force:!1}),l(!1)},children:`Finish the push…`})]}):(0,x.jsx)(q,{onClick:_,children:`Done`}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(`label`,{className:`me-auto flex cursor-pointer items-center gap-2 text-xs text-muted-foreground select-none`,children:[(0,x.jsx)(c5,{checked:f,onCheckedChange:e=>p(!!e),disabled:s.isPending}),`Commit the files and forge.workspace.json after the push`]}),(0,x.jsx)(q,{variant:`outline`,onClick:_,disabled:s.isPending,children:`Cancel`}),T?(0,x.jsxs)(q,{disabled:o.isPending,onClick:()=>{s.reset(),o.mutate({projectId:e,force:c})},children:[o.isPending&&(0,x.jsx)(Yb,{size:`sm`}),`Re-run dry run`]}):(0,x.jsxs)(q,{variant:c?`destructive`:`default`,disabled:!O||f&&!m.trim(),onClick:()=>s.mutate({projectId:e,planHash:v.planHash,force:c,...c?{confirm:u}:{},...f?{commit:{message:m.trim()}}:{}}),children:[s.isPending?(0,x.jsx)(Yb,{size:`sm`}):(0,x.jsx)(zm,{}),k,` `,A]})]}),children:(0,x.jsxs)(`div`,{className:`flex flex-col gap-3 text-sm`,children:[g&&(0,x.jsxs)(`div`,{className:`grid grid-cols-[6.5rem_minmax(0,1fr)] gap-x-2 gap-y-1 text-xs`,children:[(0,x.jsx)(`span`,{className:`text-muted-foreground`,children:`App`}),(0,x.jsx)(`span`,{children:v?.app||g.scope}),(0,x.jsx)(`span`,{className:`text-muted-foreground`,children:`Update set`}),(0,x.jsxs)(`span`,{children:[v?.updateSet||g.updateSet||`—`,v?.planHash&&(0,x.jsx)(`span`,{className:`text-success-foreground`,children:` · in progress ✓`})]}),v?.planHash&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`span`,{className:`text-muted-foreground`,children:`planHash`}),(0,x.jsxs)(`span`,{children:[(0,x.jsx)(`span`,{className:`font-mono`,children:v.planHash}),(0,x.jsxs)(`span`,{className:`text-muted-foreground`,children:[` `,`· dry run `,bu(o.data?.at),` ·`,` `]}),T?(0,x.jsx)(`span`,{className:`text-warning-foreground`,children:`files changed since`}):(0,x.jsx)(`span`,{className:`text-success-foreground`,children:`files unchanged since ✓`})]})]})]}),o.isPending&&(0,x.jsxs)(`div`,{className:`flex items-center gap-2 py-6 text-muted-foreground`,children:[(0,x.jsx)(Yb,{size:`sm`}),` Running the dry run on the instance…`]}),o.error&&(0,x.jsx)(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/6 px-3 py-2 text-destructive-foreground`,children:o.error.message}),v?.refused&&!o.isPending&&(0,x.jsxs)(`div`,{className:`rounded-lg border border-warning/30 bg-warning/6 px-3 py-2.5`,children:[(0,x.jsxs)(`div`,{className:`font-medium text-warning-foreground`,children:[`Can’t push yet. `,QZ(v.reason)]}),Array.isArray(v.conflicts)&&v.conflicts.length>0&&(0,x.jsx)(`div`,{className:`mt-1.5 font-mono text-xs`,children:v.conflicts.slice(0,20).map(e=>(0,x.jsxs)(`div`,{className:`flex gap-2 py-0.5`,children:[(0,x.jsx)(`span`,{className:`truncate`,children:e.key}),(0,x.jsx)(`span`,{className:`ms-auto shrink-0 text-muted-foreground`,children:[e.updatedBy,e.updatedOn].filter(Boolean).join(` · `)})]},e.key))}),(0,x.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[(0,x.jsx)(q,{size:`xs`,variant:`outline`,onClick:()=>{_(),Wu({panelOpen:!0,panelTab:`plan`})},children:`Resolve in Push plan`}),!c&&Array.isArray(v.conflicts)&&(0,x.jsx)(q,{size:`xs`,variant:`destructive-outline`,onClick:()=>l(!0),children:`Plan a force push…`})]})]}),v?.nothingToPush&&!o.isPending&&(0,x.jsxs)(`div`,{className:`flex items-center gap-2 py-4 text-muted-foreground`,children:[(0,x.jsx)(Bd,{className:`size-4 text-success-foreground`}),` Nothing to push: the instance has everything.`]}),v?.planHash&&!o.isPending&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`div`,{className:`mb-1.5 text-xs font-medium text-muted-foreground`,children:`Planned writes`}),(0,x.jsx)(XZ,{chunks:y})]}),v.pending&&(0,x.jsxs)(`div`,{className:`flex items-start gap-2 text-xs text-info-foreground`,children:[(0,x.jsx)(qf,{className:`mt-0.5 size-3.5 shrink-0`}),`Also finishes the last push: the compiles and reprocess it still owed.`]}),E.map(e=>(0,x.jsxs)(`div`,{className:`flex items-start gap-2 text-xs text-warning-foreground`,children:[(0,x.jsx)(Lm,{className:`mt-0.5 size-3.5 shrink-0`}),` `,e]},e)),D.length>0&&(0,x.jsxs)(`div`,{className:`flex items-start gap-2 text-xs text-muted-foreground`,children:[(0,x.jsx)(qf,{className:`mt-0.5 size-3.5 shrink-0`}),D.length,` instance change`,D.length===1?``:`s`,` left alone (`,D.slice(0,3).map(e=>e.id).join(`, `),D.length>3?`, …`:``,`): a pull takes them.`]}),(v.problems||[]).map(e=>(0,x.jsxs)(`div`,{className:`flex items-start gap-2 text-xs text-warning-foreground`,children:[(0,x.jsx)(Lm,{className:`mt-0.5 size-3.5 shrink-0`}),` `,e]},e))]}),c&&v?.planHash&&!o.isPending&&(0,x.jsx)(ZZ,{overwrites:v.overwrites||[],slug:g?.portal||``,typed:u,onType:d}),f&&!C&&(0,x.jsx)(o5,{size:`compact`,value:m,onChange:e=>h(e.target.value),placeholder:`Commit message, e.g. feat: stalled deals KPI`,"aria-label":`Commit message`}),s.isPending&&(0,x.jsx)(eQ,{progress:a.data?.progress||null}),s.error&&!T&&(0,x.jsx)(`div`,{className:`text-destructive-foreground`,children:s.error.message}),T&&(s.error||C?.refused)&&(0,x.jsx)(`div`,{className:`text-warning-foreground`,children:s.error?.message||C?.reason}),C&&!C.refused&&(0,x.jsx)(nQ,{done:C,commit:s.data?.commit}),(0,x.jsxs)(`div`,{className:`flex items-start gap-2 text-xs text-muted-foreground`,children:[(0,x.jsx)(qf,{className:`mt-0.5 size-3.5 shrink-0`}),`Pushes aren’t undone by Forge. To roll back, revert the files and push again.`]})]})})})}function nQ({done:e,commit:t}){if(e.failed)return(0,x.jsxs)(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/6 px-3 py-2.5`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-1.5 font-medium text-destructive-foreground`,children:[(0,x.jsx)(Kd,{className:`size-4`}),` Chunk `,e.failed.chunk,` of `,e.failed.of,` failed:`,` `,e.failed.message]}),(0,x.jsxs)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:[e.failed.chunk>1?`Chunks 1–${e.failed.chunk-1} were written. `:``,e.note]}),e.rebased>0&&(0,x.jsxs)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:[e.rebased,` written record(s) now match the files: their base moved to the instance.`]})]});let n=e.status?.counts||{};return(0,x.jsxs)(`div`,{className:`rounded-lg border px-3 py-2.5`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-1.5 font-medium text-success-foreground`,children:[(0,x.jsx)(Bd,{className:`size-4`}),` Pushed `,e.pushed,` file`,e.pushed===1?``:`s`,` and record`,e.pushed===1?``:`s`,e.ms?(0,x.jsxs)(`span`,{className:`font-normal text-muted-foreground`,children:[` · `,(e.ms/1e3).toFixed(1),` s`]}):null]}),(0,x.jsxs)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:[e.status?.clean?`The workspace is clean: the new base is the instance.`:`The new base is the instance for what was pushed. Still open: ${n.local||0} local, ${n.instance||0} instance, ${n.conflicts||0} conflicts.`,e.rebased?` ${e.rebased} record(s) rebased.`:``]}),Array.isArray(e.notConverged)&&e.notConverged.length>0&&(0,x.jsxs)(`div`,{className:`mt-1 text-xs text-warning-foreground`,children:[`Not matching after the push: `,e.notConverged.map(e=>e.id).join(`, `)]}),e.overwritten&&(0,x.jsxs)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:[`The overwritten instance values are kept in `,(0,x.jsx)(`span`,{className:`font-mono`,children:e.overwritten}),`.`]}),t&&(0,x.jsxs)(`div`,{className:G(`mt-1 text-xs`,t.ok?`text-muted-foreground`:`text-warning-foreground`),children:[`git: `,t.message]})]})}function rQ({projectId:e,chatId:t}){let n=Gu(),r=U(Au().projects.get.queryOptions({id:e})),i=o8(e);return b.useEffect(()=>{r.data&&(document.title=`rpf forge · ${r.data.name}`)},[r.data]),(0,x.jsxs)(`div`,{className:`flex min-w-0 flex-1`,children:[(0,x.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[t?(0,x.jsx)(WX,{projectId:e,chatId:t}):(0,x.jsx)(iQ,{projectId:e,name:r.data?.name||``}),(0,x.jsx)(vZ,{projectId:e})]}),n.panelOpen&&(0,x.jsx)(HZ,{projectId:e,dev:i.status,onRestart:i.restart}),(0,x.jsx)(tQ,{projectId:e})]})}function iQ({projectId:e,name:t}){let n=U(Au().settings.get.queryOptions()),r=JX(e),[i,a]=b.useState(null),o=n.data?.projects[e]?.chat||n.data?.defaults.chat||null,s=i||o;return(0,x.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,x.jsx)(qX,{title:`New chat`,projectName:t,projectId:e}),(0,x.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col px-3 sm:px-12`,children:[(0,x.jsx)(`div`,{className:`shrink-0`,style:{flexBasis:`max(0px, calc(50% - 5rem))`}}),(0,x.jsxs)(`div`,{className:`mx-auto flex w-full max-w-5xl flex-col items-center pb-4`,children:[(0,x.jsx)(fC,{}),(0,x.jsxs)(`h1`,{className:`text-center text-2xl font-normal tracking-tight text-foreground sm:text-3xl`,children:[`What should we build in `,(0,x.jsx)(`span`,{className:`font-medium`,children:t||`…`}),`?`]})]}),(0,x.jsx)(fS,{autoFocus:!0,model:s,onModel:a,onSend:e=>r(e,s),placeholder:`Describe a change, ask about the portal, or paste an error`})]})]})}function aQ({label:e,onClose:t,children:n}){let[r,i]=b.useState(!0),a=b.useRef(!1),o=b.useRef(null);return(0,x.jsx)(U6,{open:r,disablePointerDismissal:!0,onOpenChange:(e,t)=>{if(!e){if(t.reason===`escape-key`&&t.event.repeat)return t.cancel();i(!1)}},onOpenChangeComplete:e=>{e||t()},children:(0,x.jsxs)(I6,{children:[(0,x.jsx)(D6,{className:`dialog-backdrop fixed inset-0 z-50 transition-all duration-200 data-[ending-style]:opacity-0 data-[starting-style]:opacity-0`}),(0,x.jsx)(W6,{className:`fixed inset-0 z-50 flex items-center justify-center sm:p-6 lg:p-10`,onPointerDown:e=>{a.current=e.target===e.currentTarget},onClick:e=>{a.current&&e.target===e.currentTarget&&i(!1),a.current=!1},children:(0,x.jsx)(F6,{ref:o,initialFocus:o,"aria-label":e,className:`relative flex size-full min-h-0 min-w-0 flex-col overflow-hidden bg-background text-foreground outline-none transition-[opacity,scale] duration-150 ease-out data-[ending-style]:scale-[0.985] data-[ending-style]:opacity-0 data-[starting-style]:scale-[0.985] data-[starting-style]:opacity-0 sm:max-h-[60rem] sm:max-w-[80rem] sm:rounded-2xl sm:border sm:shadow-2xl/40`,children:n})})]})})}function oQ(){return(0,x.jsx)(Tb,{label:`Close (Esc)`,children:(0,x.jsx)(O6,{"aria-label":`Close`,render:(0,x.jsx)(q,{size:`icon-sm`,variant:`ghost`}),children:(0,x.jsx)(Gm,{})})})}function sQ(){let e=Fa({select:e=>e.location.pathname});return/^\/p\/([^/]+)/.exec(e)?.[1]||``}function cQ({label:e,onClick:t}){return(0,x.jsx)(Tb,{label:e,children:(0,x.jsx)(q,{size:`icon-xs`,variant:`ghost-muted`,"aria-label":e,onClick:t,children:(0,x.jsx)(Zp,{className:`size-3`})})})}function lQ({value:e,options:t,onChange:n,label:r}){return(0,x.jsx)(`div`,{role:`radiogroup`,"aria-label":r,className:`inline-flex rounded-[var(--control-radius)] border border-input p-0.5`,children:t.map(t=>(0,x.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":e===t.id,onClick:()=>n(t.id),className:G(`inline-flex h-6 items-center gap-1.5 rounded-md px-2.5 text-xs`,e===t.id?`bg-accent font-medium`:`text-muted-foreground hover:text-foreground`),children:t.label},t.id))})}function uQ(){let e=sQ(),[t,n]=b.useState(null),r=t??e;return r?(0,x.jsx)(pQ,{id:r,onBack:()=>n(``)}):(0,x.jsx)(dQ,{onPick:n})}function dQ({onPick:e}){let t=U(Au().projects.list.queryOptions()),n=t.data||[];return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(NS,{title:`Projects`,children:[n.length===0&&!t.isLoading&&(0,x.jsx)(`p`,{className:`px-4 py-8 text-center text-sm text-muted-foreground`,children:`No projects yet. Create or open one from the sidebar.`}),n.length>0&&(0,x.jsx)(`p`,{className:`px-3 pt-3 pb-1 text-xs text-muted-foreground sm:px-4`,children:`Choose a project to manage its name, model defaults and place in Forge.`}),n.map(t=>(0,x.jsxs)(`button`,{type:`button`,onClick:()=>e(t.id),className:`flex w-full min-w-0 cursor-pointer items-center gap-3 px-3 py-3 text-left outline-none first:rounded-t-xl last:rounded-b-xl hover:bg-accent/50 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset sm:px-4`,children:[(0,x.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded bg-foreground/8 text-[10px] font-semibold text-muted-foreground uppercase`,children:t.name.slice(0,1)}),(0,x.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,x.jsx)(`span`,{className:`block truncate text-sm font-medium`,children:t.name}),(0,x.jsxs)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:[t.missing?`Folder missing · `:``,t.path]})]}),(0,x.jsx)(Id,{className:`size-4 shrink-0 text-muted-foreground`})]},t.id))]}),(0,x.jsx)(fQ,{})]})}function fQ(){let e=Au(),t=C(),n=U(e.meta.queryOptions()),r=U(e.settings.get.queryOptions()),i=at(e.settings.setProjectsHome.mutationOptions({onSuccess:()=>t.invalidateQueries({queryKey:e.meta.queryKey()})})),a=r.data?.projectsHome,[o,s]=b.useState(null),c=o??a??``;return(0,x.jsx)(NS,{title:`New projects`,children:(0,x.jsxs)(PS,{title:`Projects folder`,description:(0,x.jsxs)(x.Fragment,{children:[`New portals are pulled into a folder here. Now:`,` `,(0,x.jsx)(`code`,{className:`font-mono`,children:n.data?.projectsHome}),i.error&&(0,x.jsx)(`span`,{className:`block text-destructive-foreground`,children:i.error.message})]}),children:[a&&(0,x.jsx)(cQ,{label:`Use the default folder`,onClick:()=>i.mutate({path:``})}),(0,x.jsx)(o5,{size:`compact`,mono:!0,className:`w-64`,placeholder:`~/rpf-projects`,"aria-label":`Projects folder`,value:c,onChange:e=>s(e.target.value),onBlur:()=>{o!==null&&o!==(a??``)&&i.mutate({path:o}),s(null)}})]})})}function pQ({id:e,onBack:t}){let n=Au(),r=i8(),i=U(n.projects.list.queryOptions()),a=i.data?.find(t=>t.id===e),o=U({...n.projects.info.queryOptions({id:e}),enabled:!!a}),s=U({...n.chats.list.queryOptions({projectId:e}),enabled:!!a}),c=U(n.settings.get.queryOptions()),l=at(n.projects.rename.mutationOptions()),u=at(n.projects.remove.mutationOptions()),[d,f]=b.useState(null),[p,m]=b.useState(!1);if(!a)return(0,x.jsx)(NS,{title:`Projects`,action:(0,x.jsx)(mQ,{onClick:t}),children:(0,x.jsx)(`p`,{className:`px-4 py-8 text-center text-sm text-muted-foreground`,children:i.isLoading?`Loading…`:`This project is no longer in Forge.`})});let h=o.data?.facts,g=c.data?.projects?.[e],_=a.name!==a.folderName;return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(NS,{title:a.name,action:(0,x.jsx)(mQ,{onClick:t}),children:[(0,x.jsxs)(PS,{title:`Name`,description:`Shown in the sidebar and the projects list. The folder keeps its name.`,children:[_&&(0,x.jsx)(cQ,{label:`Use the folder name`,onClick:()=>l.mutate({id:e,name:``})}),(0,x.jsx)(o5,{size:`compact`,className:`w-56`,"aria-label":`Project name`,value:d??a.name,onChange:e=>f(e.target.value),onBlur:()=>{d!==null&&d.trim()&&d.trim()!==a.name&&l.mutate({id:e,name:d.trim()}),f(null)}})]}),(0,x.jsx)(PS,{title:`Folder`,description:a.missing?(0,x.jsx)(`span`,{className:`text-warning-foreground`,children:`The folder no longer exists.`}):`Forge reads and edits files here. Chats live in the rpf home, never in the folder.`,children:(0,x.jsxs)(`code`,{className:`flex min-w-0 items-center gap-1.5 self-center font-mono text-xs text-muted-foreground`,children:[(0,x.jsx)(Df,{className:`size-3.5 shrink-0`}),(0,x.jsx)(`span`,{className:`truncate`,title:a.path,children:a.path})]})}),(0,x.jsx)(PS,{title:`Instance`,description:h?[h.scope&&`App ${h.appName||h.scope}`,h.updateSet&&`update set “${h.updateSet}”`].filter(Boolean).join(` · `)||`From forge.workspace.json`:`Not a React Portal workspace (no forge.workspace.json).`,children:h?.instance?o.data?.profile?(0,x.jsxs)(`span`,{className:`self-center text-xs`,children:[o.data.profile,` · `,h.host]}):(0,x.jsxs)(q,{size:`xs`,variant:`outline`,onClick:()=>r(`instances`),children:[`No profile for `,h.host,` · Add`]}):null}),(0,x.jsxs)(PS,{title:`Models`,description:g?.chat||g?.helper?`Overridden for this project: new chats here start with its own model.`:`Uses your defaults from Providers and models.`,children:[!!(g?.chat||g?.helper)&&(0,x.jsx)(kb,{variant:`info`,children:`Overridden`}),(0,x.jsx)(q,{size:`xs`,variant:`outline`,onClick:()=>r(`providers`),children:`Change`})]}),(0,x.jsx)(PS,{title:`Chats`,description:`Kept in the rpf home, keyed by this folder.`,children:(0,x.jsxs)(`span`,{className:`self-center text-xs text-muted-foreground tabular-nums`,children:[s.data?.length??`…`,` `,s.data?.length===1?`chat`:`chats`,o.data?.lastActivity?` · active ${yu(o.data.lastActivity)} ago`:``]})})]}),(0,x.jsx)(NS,{title:`Danger`,children:(0,x.jsx)(PS,{title:`Remove project`,description:`Removes the project from Forge. Its chats stay in the rpf home and files on disk are not touched.`,children:p?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(q,{size:`xs`,variant:`ghost-muted`,onClick:()=>m(!1),children:`Cancel`}),(0,x.jsxs)(q,{size:`xs`,variant:`destructive`,onClick:()=>u.mutate({id:e},{onSuccess:t}),children:[`Remove `,a.name]})]}):(0,x.jsx)(q,{size:`xs`,variant:`destructive-outline`,onClick:()=>m(!0),children:`Remove project`})})})]})}function mQ({onClick:e}){return(0,x.jsxs)(q,{size:`xs`,variant:`ghost-muted`,onClick:e,children:[(0,x.jsx)(gd,{}),` All projects`]})}function hQ({value:e}){return(0,x.jsx)(`span`,{className:`inline-flex items-center gap-0.5`,children:Fu(e).map((e,t)=>(0,x.jsx)(Ab,{children:e},t))})}function gQ(){let e=Au(),t=U(e.settings.get.queryOptions()),n=at(e.settings.setKeybinding.mutationOptions()),r=t.data?.keybindings||[],[i,a]=b.useState(``),o=Lu(r),s=i.trim().toLowerCase(),c=ju.filter(e=>!s||e.label.toLowerCase().includes(s)||e.id.toLowerCase().includes(s)||Iu(Mu(e,r)).toLowerCase().includes(s)),l=[...new Set(c.map(e=>e.group))];return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(NS,{title:`Keybindings`,action:(0,x.jsx)(Tb,{label:`The browser may claim some shortcuts first (Ctrl+N, Ctrl+W, Ctrl+T).`,children:(0,x.jsx)(q,{size:`icon-xs`,variant:`ghost-muted`,"aria-label":`The browser may claim some shortcuts first`,children:(0,x.jsx)(Lm,{className:`size-3.5 text-warning-foreground`})})}),children:(0,x.jsx)(`div`,{className:`flex items-center gap-2 px-3 py-3 sm:px-4`,children:(0,x.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,x.jsx)(am,{className:`pointer-events-none absolute top-1/2 left-2.5 z-10 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,x.jsx)(o5,{size:`compact`,className:`[&_input]:ps-7.5`,placeholder:`Search keybindings`,"aria-label":`Search keybindings`,value:i,onChange:e=>a(e.target.value)})]})})}),l.length===0&&(0,x.jsx)(`div`,{className:`rounded-xl border border-border/60 bg-card/40 px-4 py-12 text-center text-sm text-muted-foreground`,children:`No keybindings match your search.`}),l.map(e=>(0,x.jsx)(NS,{title:e,children:c.filter(t=>t.group===e).map(e=>(0,x.jsx)(_Q,{cmd:e,value:Mu(e,r),custom:r.some(t=>t.command===e.id),clashes:(o.get(Mu(e,r))||[]).filter(t=>t!==e.id),onSave:t=>n.mutate({command:e.id,key:t===e.key?null:t}),onReset:()=>n.mutate({command:e.id,key:null})},e.id))},e))]})}function _Q({cmd:e,value:t,custom:n,clashes:r,onSave:i,onReset:a}){let[o,s]=b.useState(!1),[c,l]=b.useState(null),u=b.useRef(null),d=c!==null&&c!==t,f=e=>ju.find(t=>t.id===e)?.label||e;return(0,x.jsxs)(`div`,{className:`group/row grid items-center gap-x-8 gap-y-2 px-3 py-3 sm:grid-cols-[minmax(0,1fr)_auto] sm:px-4`,children:[(0,x.jsxs)(`div`,{className:`min-w-0`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,title:e.id,children:[e.label,n&&(0,x.jsx)(kb,{variant:`outline`,children:`Custom`})]}),(0,x.jsx)(`div`,{className:`mt-0.5 text-xs text-muted-foreground`,children:!t&&!d?`No keyboard shortcut assigned. Click Unassigned to set one.`:n&&e.key?`Default: ${Iu(e.key)}`:e.inFields?`Works while typing too`:`Not while typing in a field`})]}),(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-1.5`,children:[r.length>0&&!d&&(0,x.jsx)(Tb,{label:`Conflicts with ${r.map(f).join(`, `)}.`,children:(0,x.jsx)(`span`,{tabIndex:0,"aria-label":`Conflicts with ${r.map(f).join(`, `)}`,className:`inline-flex size-6 items-center justify-center text-warning-foreground`,children:(0,x.jsx)(Lm,{className:`size-3.5`})})}),(0,x.jsx)(`span`,{className:`flex items-center opacity-0 transition-opacity group-focus-within/row:opacity-100 group-hover/row:opacity-100 has-[[data-popup-open]]:opacity-100`,children:(0,x.jsxs)(mb,{children:[(0,x.jsx)(hb,{render:(0,x.jsx)(q,{size:`icon-xs`,variant:`ghost-muted`,"aria-label":`Actions for ${e.label}`}),children:(0,x.jsx)(lf,{})}),(0,x.jsxs)(gb,{align:`end`,children:[(0,x.jsx)(_b,{disabled:!n,onClick:a,children:`Reset to default`}),(0,x.jsx)(_b,{disabled:!t,onClick:()=>i(``),children:`Unassign`})]})]})}),d&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(q,{size:`sm`,variant:`ghost-muted`,onClick:()=>l(null),children:`Cancel`}),(0,x.jsx)(q,{size:`sm`,onClick:()=>{i(c),l(null)},children:`Save`})]}),!o&&!d?(0,x.jsx)(`button`,{ref:u,type:`button`,onClick:()=>s(!0),"aria-label":`Edit shortcut for ${e.label}: ${t?Iu(t):`Unassigned`}`,className:`-mr-1.5 inline-flex h-7 cursor-pointer items-center rounded-md border border-transparent px-1.5 outline-none transition-colors hover:border-border/70 hover:bg-accent focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/24 focus-visible:ring-inset`,children:t?(0,x.jsx)(hQ,{value:t}):(0,x.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`Unassigned`})}):d&&!o?(0,x.jsx)(`button`,{type:`button`,onClick:()=>s(!0),className:`inline-flex h-7 items-center rounded-md border border-border/70 px-1.5`,"aria-label":`Record again`,children:(0,x.jsx)(hQ,{value:c})}):(0,x.jsx)(`span`,{"data-keybinding-capture":``,children:(0,x.jsx)(o5,{autoFocus:!0,size:`compact`,mono:!0,className:`w-44`,readOnly:!0,"aria-label":`Keybinding for ${e.label}`,placeholder:`Press shortcut`,value:``,onBlur:()=>s(!1),onKeyDown:e=>{if(e.key===`Tab`&&!o)return;if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`&&!e.shiftKey&&!e.altKey&&!e.ctrlKey&&!e.metaKey){l(null),s(!1),requestAnimationFrame(()=>u.current?.focus());return}let t=Pu(e.nativeEvent);t&&(l(t),s(!1))}})})]})]})}var vQ={layout:`stacked`,ignoreWhitespace:!1,colors:`red-green`};function yQ(){let e=Au(),t=U(e.settings.get.queryOptions()),n=at(e.settings.setDiffs.mutationOptions()),r={...vQ,...t.data?.diffs||{}};return(0,x.jsxs)(NS,{title:`Diffs`,children:[(0,x.jsxs)(PS,{title:`Diff layout`,description:`Show diffs stacked or side by side. The toggle in the Diff tab changes this too.`,children:[r.layout!==vQ.layout&&(0,x.jsx)(cQ,{label:`Reset diff layout to default`,onClick:()=>n.mutate({layout:`stacked`})}),(0,x.jsx)(lQ,{label:`Diff layout`,value:r.layout,options:[{id:`stacked`,label:`Stacked`},{id:`split`,label:`Side by side`}],onChange:e=>n.mutate({layout:e})})]}),(0,x.jsxs)(PS,{title:`Hide whitespace changes`,description:`Set whether diffs ignore whitespace-only edits by default.`,children:[r.ignoreWhitespace!==vQ.ignoreWhitespace&&(0,x.jsx)(cQ,{label:`Reset whitespace changes to default`,onClick:()=>n.mutate({ignoreWhitespace:!1})}),(0,x.jsx)(l5,{checked:r.ignoreWhitespace,"aria-label":`Hide whitespace changes by default`,onCheckedChange:e=>n.mutate({ignoreWhitespace:!!e})})]}),(0,x.jsxs)(PS,{title:`Diff colors`,description:`Choose colors for additions and deletions, including change counts.`,children:[r.colors!==vQ.colors&&(0,x.jsx)(cQ,{label:`Reset diff colors to default`,onClick:()=>n.mutate({colors:`red-green`})}),(0,x.jsx)(lQ,{label:`Diff colors`,value:r.colors,options:[{id:`red-green`,label:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(bQ,{a:`var(--destructive)`,b:`var(--success)`}),` Red & green`]})},{id:`blue-orange`,label:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(bQ,{a:`oklch(0.646 0.222 41.116)`,b:`oklch(0.546 0.245 262.881)`}),` Blue & orange`]})}],onChange:e=>n.mutate({colors:e})})]})]})}function bQ({a:e,b:t}){return(0,x.jsxs)(`span`,{"aria-hidden":!0,className:`flex shrink-0 gap-1`,children:[(0,x.jsx)(`span`,{className:`size-2 rounded-full`,style:{backgroundColor:e}}),(0,x.jsx)(`span`,{className:`size-2 rounded-full`,style:{backgroundColor:t}})]})}function xQ(){let e=Au(),t=i8(),n=U(e.meta.queryOptions()),r=U(e.about.update.queryOptions()),i=at(e.about.checkUpdate.mutationOptions()),a=at(e.settings.setOnboarded.mutationOptions()),o=Yi(),[s,c]=b.useState(!1),l=n.data?.version||``,u=i.data||r.data,d=u?u.disabled?`Update checks are off: ${u.disabled}.`:u.newer?`rpf ${u.latest} is available.${u.command?` Update with: ${u.command}`:``}`:u.checkedAt?`Up to date · checked ${yu(u.checkedAt)===`now`?`just now`:`${yu(u.checkedAt)} ago`}.`:`Current version of rpf.`:`Current version of rpf.`;return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(NS,{title:`App`,children:[(0,x.jsx)(PS,{title:(0,x.jsxs)(`span`,{className:`inline-flex items-baseline gap-2`,children:[`Version`,(0,x.jsx)(Tb,{label:s?`Copied`:`Copy version`,children:(0,x.jsxs)(`button`,{type:`button`,"aria-label":`Copy version ${l}`,onClick:()=>{navigator.clipboard?.writeText(l),c(!0),setTimeout(()=>c(!1),1500)},className:`inline-flex items-center gap-1 rounded font-mono text-2xs font-medium text-muted-foreground hover:text-foreground`,children:[l,(0,x.jsx)(ef,{className:`size-3`})]})})]}),description:(0,x.jsxs)(x.Fragment,{children:[d,i.error&&(0,x.jsx)(`span`,{className:`block text-destructive-foreground`,children:i.error.message})]}),children:(0,x.jsx)(q,{size:`sm`,variant:`outline`,disabled:i.isPending||!r.data||!!u?.disabled,onClick:()=>i.mutate(),children:i.isPending?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(Yb,{size:`xs`}),` Checking…`]}):i.data&&!i.data.newer&&i.data.latest?`Up to date`:`Check for updates`})}),(0,x.jsx)(PS,{title:`Welcome page`,description:`See your instances and AI providers, and start a first project.`,children:(0,x.jsx)(q,{size:`sm`,variant:`outline`,onClick:()=>a.mutate({done:!1},{onSuccess:()=>o({to:`/welcome`,search:{}})}),children:`Open`})}),u?.newer&&(0,x.jsx)(EQ,{st:u})]}),(0,x.jsx)(NS,{title:`Legal`,children:(0,x.jsx)(PS,{title:`Open-source licenses`,description:`Notices for the libraries bundled in Forge.`,children:(0,x.jsx)(q,{size:`sm`,variant:`outline`,onClick:()=>t(`licenses`),children:`View licenses`})})})]})}function SQ(){let e=U({...Au().about.notices.queryOptions(),retry:!1,staleTime:1/0}),[t,n]=b.useState(``),[r,i]=b.useState(!1),[a,o]=b.useState(null),s=e.data?.entries||[],c=t.trim().toLowerCase(),l=s.filter(e=>!c||e.name.toLowerCase().includes(c)||e.license.toLowerCase().includes(c)),u=(0,x.jsx)(`p`,{className:`text-xs font-normal whitespace-nowrap text-muted-foreground tabular-nums`,children:l.length===s.length?`${s.length} notices`:`${l.length} of ${s.length}`});return(0,x.jsx)(NS,{title:`Third-party notices`,action:e.data&&(r?(0,x.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,x.jsx)(`span`,{className:`hidden sm:block`,children:u}),(0,x.jsxs)(`div`,{className:`relative w-44`,children:[(0,x.jsx)(am,{className:`pointer-events-none absolute top-1/2 left-2.5 z-10 size-3 -translate-y-1/2 text-muted-foreground`}),(0,x.jsx)(o5,{autoFocus:!0,size:`compact`,className:`[&_input]:ps-7`,type:`search`,placeholder:`Search licenses`,"aria-label":`Search open-source licenses`,value:t,onChange:e=>n(e.target.value),onBlur:()=>!t&&i(!1),onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),n(``),i(!1))}})]})]}):(0,x.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[u,(0,x.jsx)(Tb,{label:`Search licenses`,children:(0,x.jsx)(q,{size:`icon-xs`,variant:`ghost-muted`,"aria-label":`Search open-source licenses`,onClick:()=>i(!0),children:(0,x.jsx)(am,{className:`size-3`})})})]})),children:e.error?(0,x.jsxs)(`div`,{className:`flex flex-col items-start gap-3 px-3 py-5 sm:px-4`,children:[(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`h3`,{className:`text-sm font-medium`,children:`Open-source notices are unavailable`}),(0,x.jsx)(`p`,{className:`mt-1 max-w-[70ch] text-xs text-muted-foreground/80`,children:e.error.message})]}),(0,x.jsx)(q,{size:`xs`,variant:`outline`,onClick:()=>e.refetch(),children:`Try again`})]}):e.data?l.length===0?(0,x.jsx)(`p`,{className:`px-3 py-8 text-center text-sm text-muted-foreground sm:px-4`,children:`No licenses match that search.`}):l.map(e=>{let t=`${e.name}@${e.version}`,n=a===t;return(0,x.jsxs)(`article`,{children:[(0,x.jsxs)(`div`,{className:`flex min-h-9 items-center hover:bg-muted/35`,children:[(0,x.jsxs)(`button`,{type:`button`,"aria-expanded":n,onClick:()=>o(n?null:t),className:`group flex min-h-9 min-w-0 flex-1 items-center gap-2.5 px-3 text-left text-sm outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset sm:px-4`,children:[(0,x.jsx)(Id,{"aria-hidden":!0,className:G(`size-3.5 shrink-0 text-muted-foreground transition-transform duration-200`,n&&`rotate-90`)}),(0,x.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-baseline gap-2`,children:[(0,x.jsx)(`span`,{className:`truncate font-medium`,children:e.name}),(0,x.jsx)(`code`,{className:`shrink-0 text-xs text-muted-foreground`,children:e.version})]}),(0,x.jsx)(`span`,{className:`max-w-[42%] shrink-0 truncate text-xs text-muted-foreground`,children:e.license||`see notice`})]}),(0,x.jsx)(Tb,{label:`Project page`,children:(0,x.jsx)(`a`,{href:e.sourceUrl,target:`_blank`,rel:`noreferrer noopener`,"aria-label":`View the project page for ${e.name}`,className:`me-3 inline-flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-foreground sm:me-4`,children:(0,x.jsx)(df,{"aria-hidden":!0,className:`size-3`})})})]}),n&&(0,x.jsx)(`div`,{className:`px-9 pt-1 pb-4 sm:px-10`,children:(0,x.jsx)(`pre`,{className:`max-w-[76ch] font-mono text-xs/5 break-words whitespace-pre-wrap text-foreground/80`,children:e.text})})]},t)}):(0,x.jsx)(`p`,{className:`px-3 py-5 text-sm text-muted-foreground sm:px-4`,children:`Loading open-source notices…`})})}function CQ({level:e}){return e===`ok`?(0,x.jsx)(Bd,{className:`size-4 text-success-foreground`}):e===`warn`?(0,x.jsx)(Lm,{className:`size-4 text-warning-foreground`}):e===`fail`?(0,x.jsx)(Kd,{className:`size-4 text-destructive-foreground`}):(0,x.jsx)(qf,{className:`size-4 text-muted-foreground`})}function wQ(){let e=Au(),t=sQ(),n=U({...e.profiles.list.queryOptions(),retry:!1}),r=U({...e.projects.info.queryOptions({id:t}),enabled:!!t}),i=at(e.tools.doctor.mutationOptions()),[a,o]=b.useState(``),[s,c]=b.useState(!1),l=(n.data?.profiles||[]).map(e=>e.name),u=a||r.data?.profile||n.data?.default||``,d=i.data?.checks||[],f=[`fail`,`warn`,`ok`].map(e=>[e,d.filter(t=>t.level===e).length]);return(0,x.jsxs)(NS,{title:`Doctor`,action:i.data&&(0,x.jsxs)(q,{size:`xs`,variant:`ghost-muted`,onClick:()=>{navigator.clipboard?.writeText(JSON.stringify(i.data,null,2)),c(!0),setTimeout(()=>c(!1),1500)},children:[(0,x.jsx)(ef,{}),` `,s?`Copied`:`Copy as JSON`]}),children:[(0,x.jsxs)(PS,{title:`Check this computer and an instance`,description:`Node, rpf's toolchain, git, the credential store, the profile and its token, the workspace, and the instance (Forge on, roles, API level, React Portal and Global Helpers versions).`,children:[(0,x.jsxs)(`select`,{"aria-label":`Profile`,value:u,onChange:e=>o(e.target.value),className:`h-7 rounded-md border border-input bg-background px-2 text-xs dark:bg-input/32`,children:[!l.length&&(0,x.jsx)(`option`,{value:``,children:`No profiles`}),l.map(e=>(0,x.jsx)(`option`,{value:e,children:e},e))]}),(0,x.jsx)(q,{size:`sm`,variant:`outline`,disabled:i.isPending,onClick:()=>i.mutate({profile:u||void 0,projectId:t||void 0}),children:i.isPending?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(Yb,{size:`xs`}),` Checking…`]}):i.data?`Run again`:`Run checks`})]}),i.error&&(0,x.jsx)(`p`,{className:`px-4 py-3 text-xs text-destructive-foreground`,children:i.error.message}),d.length>0&&(0,x.jsxs)(`div`,{className:`px-3 py-2 sm:px-4`,children:[(0,x.jsx)(`p`,{className:`pb-1 text-xs text-muted-foreground`,children:f.map(([e,t])=>`${t} ${e===`ok`?`ok`:e===`warn`?`warning`+(t===1?``:`s`):`failed`}`).join(` · `)}),d.map((e,t)=>(0,x.jsxs)(`div`,{className:`flex min-h-8 items-start gap-2.5 py-1`,children:[(0,x.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:(0,x.jsx)(CQ,{level:e.level})}),(0,x.jsxs)(`span`,{className:`min-w-0 text-sm`,children:[e.message,e.fix&&(0,x.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[`→ `,e.fix]})]})]},`${e.id}-${t}`))]})]})}function TQ(){let e=Au(),t=C(),n=sQ(),r=U({...e.tools.skills.queryOptions({projectId:n||void 0}),retry:!1}),i=at(e.tools.syncSkills.mutationOptions({onSuccess:()=>t.invalidateQueries({queryKey:e.tools.skills.queryKey()})})),[a,o]=b.useState(``),s=r.data,c=(s?.installed||[]).filter(e=>n||e.where===`global`),l=i.data?.skills;return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(NS,{title:`Skills`,children:[r.isLoading&&(0,x.jsx)(`p`,{className:`px-4 py-3 text-sm text-muted-foreground`,children:`Reading skills…`}),r.error&&(0,x.jsx)(`p`,{className:`px-4 py-3 text-xs text-destructive-foreground`,children:r.error.message}),(s?.bundled||[]).map(e=>(0,x.jsx)(PS,{title:e.name,description:e.description,children:(0,x.jsxs)(`span`,{className:`self-center text-xs text-muted-foreground tabular-nums`,children:[e.files.length,` `,e.files.length===1?`file`:`files`,` · rpf `,s.version]})},e.name))]}),c.map(e=>{let t=e.where===`global`?`global`:`project`,r=e.skills.some(e=>e.state!==`not-installed`),s=e.skills.some(e=>e.state===`edited`);return(0,x.jsxs)(NS,{title:t===`global`?`Installed for every project`:`Installed in this project`,action:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(q,{size:`xs`,variant:`outline`,disabled:i.isPending,onClick:()=>i.mutate({projectId:n||void 0,mode:r?`update`:`install`,global:t===`global`,force:!1}),children:r?`Update`:`Install`}),s&&(a===t?(0,x.jsx)(q,{size:`xs`,variant:`destructive`,onClick:()=>{o(``),i.mutate({projectId:n||void 0,mode:`update`,global:t===`global`,force:!0})},children:`Overwrite my edits`}):(0,x.jsx)(q,{size:`xs`,variant:`ghost-muted`,onClick:()=>o(t),children:`Force…`}))]}),children:[(0,x.jsx)(`p`,{className:`px-3 pt-3 font-mono text-2xs break-all text-muted-foreground sm:px-4`,children:e.root}),e.skills.map(e=>(0,x.jsx)(PS,{title:e.name,description:e.state===`edited`?`Edited: ${e.edited.join(`, `)} (kept on update; Force saves yours as .orig)`:e.state===`outdated`?`An update is available${e.version?` (installed from rpf ${e.version})`:``}`:e.state===`up-to-date`?`Up to date${e.version?` · from rpf ${e.version}`:``}`:`Not installed`,children:(0,x.jsx)(kb,{variant:e.state===`up-to-date`?`success`:e.state===`not-installed`?`outline`:`warning`,children:e.state===`up-to-date`?`up to date`:e.state===`not-installed`?`not installed`:e.state})},e.name))]},e.where)}),i.error&&(0,x.jsx)(`p`,{className:`text-xs text-destructive-foreground`,children:i.error.message}),l&&(0,x.jsx)(`p`,{className:`px-1 text-xs text-muted-foreground`,children:l.map(e=>`${e.name}: ${e.action.replace(`-`,` `)}${e.edited?.length?` (kept ${e.edited.length} edited)`:``}${e.overwritten?.length?` (yours saved as .orig)`:``}`).join(` · `)})]})}function EQ({st:e}){let t=at(Au().about.runUpdate.mutationOptions()),[n,r]=b.useState([]);return b.useEffect(()=>{let e=e=>{let t=e.detail;t.line!==void 0&&r(e=>[...e,t.line].slice(-200))};return window.addEventListener(`forge:update`,e),()=>window.removeEventListener(`forge:update`,e)},[]),(0,x.jsx)(PS,{title:`Update to rpf ${e.latest}`,description:(0,x.jsxs)(x.Fragment,{children:[e.command?(0,x.jsxs)(x.Fragment,{children:[`Runs `,(0,x.jsx)(`code`,{className:`font-mono`,children:e.command}),` (`,e.installer,`).`]}):`Couldn't tell how rpf was installed: update it in a terminal.`,n.length>0&&(0,x.jsx)(`pre`,{className:`mt-2 max-h-48 overflow-auto rounded-md bg-muted p-2 font-mono text-2xs whitespace-pre-wrap text-foreground/80`,children:n.join(`
|
|
291
|
+
`)}),t.data&&(0,x.jsx)(`span`,{className:G(`mt-1 block`,t.data.code===0?`text-success-foreground`:`text-destructive-foreground`),children:t.data.code===0?`Updated. Restart Forge (Ctrl+C in its terminal, then rpf forge) to run the new version.`:`The update failed (exit ${t.data.code}).`})]}),children:(0,x.jsx)(q,{size:`sm`,disabled:!e.command||t.isPending||t.data?.code===0,onClick:()=>t.mutate(),children:t.isPending?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(Yb,{size:`xs`}),` Updating…`]}):`Update`})})}var DQ=[{id:`general`,label:`General`,icon:lm,group:`Forge`},{id:`appearance`,label:`Appearance`,icon:Tp,group:`Forge`},{id:`providers`,label:`Providers and models`,icon:Sd,group:`Agent`},{id:`usage`,label:`Usage`,icon:Ad,group:`Agent`},{id:`instances`,label:`Instances`,icon:sm,group:`rpf`},{id:`projects`,label:`Projects`,icon:Tf,group:`rpf`},{id:`doctor`,label:`Doctor`,icon:Dm,group:`rpf`},{id:`skills`,label:`Skills`,icon:ym,group:`rpf`},{id:`keybindings`,label:`Keybindings`,icon:Yf,group:`More`},{id:`diffs`,label:`Diffs`,icon:_f,group:`More`},{id:`about`,label:`About and updates`,icon:qf,group:`More`},{id:`licenses`,label:`Open-source licenses`,icon:tm,group:`More`}];function OQ({section:e,onSection:t}){let n=[...new Set(DQ.map(e=>e.group))],[r,i]=b.useState(``),a=b.useRef(null),o=DQ,s=b.useMemo(()=>Object.fromEntries(DQ.map(e=>[e.id,e.label])),[]),c=OS(r,s),[l,u]=b.useState(0),d=Math.min(l,Math.max(c.length-1,0)),[f,p]=b.useState(null);b.useEffect(()=>{if(!f)return;let e=0,t=setInterval(()=>{(kS(f)||++e>20)&&(clearInterval(t),p(null))},50);return()=>clearInterval(t)},[f,e]);let m=e=>{i(``),u(0),t(e.section),e.target&&p(e.target)},h=e=>{if(!e.nativeEvent.isComposing){if(e.key===`Escape`&&r)e.preventDefault(),e.stopPropagation(),i(``);else if(c.length){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=c.length;u((d+(e.key===`ArrowDown`?1:t-1))%t)}else e.key===`Enter`&&(e.preventDefault(),m(c[d]))}}};b.useEffect(()=>{let e=e=>{let t=e.target;e.key===`/`&&!/INPUT|TEXTAREA/.test(t.tagName)&&!t.isContentEditable&&(e.preventDefault(),a.current?.focus())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let g=DQ.find(t=>t.id===e)||DQ[0];return(0,x.jsxs)(`div`,{className:`relative flex min-h-0 flex-1`,children:[(0,x.jsx)(`nav`,{className:`flex w-60 shrink-0 flex-col border-e bg-sidebar text-sidebar-foreground`,children:(0,x.jsxs)(`div`,{className:`flex flex-col gap-2 p-2`,children:[(0,x.jsxs)(`div`,{className:`flex h-8 items-center gap-2 rounded-md px-2 py-1.5 text-sm font-medium text-sidebar-muted-foreground focus-within:bg-sidebar-row-hover hover:bg-sidebar-row-hover hover:text-sidebar-foreground`,children:[(0,x.jsx)(am,{className:`size-4 shrink-0 text-sidebar-muted-foreground/80`}),(0,x.jsx)(`input`,{ref:a,value:r,onChange:e=>{i(e.target.value),u(0)},onKeyDown:h,placeholder:`Search`,"aria-label":`Search settings`,role:`combobox`,"aria-expanded":!!r&&c.length>0,"aria-controls":c.length?`settings-search-results`:void 0,"aria-activedescendant":c[d]?`settings-result-${d}`:void 0,className:`min-w-0 flex-1 bg-transparent outline-none placeholder:text-sidebar-muted-foreground`}),r?(0,x.jsx)(`button`,{"aria-label":`Clear settings search`,onClick:()=>i(``),className:`inline-flex size-5 items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-foreground`,children:(0,x.jsx)(Gm,{className:`size-3`})}):(0,x.jsx)(Ab,{children:`/`})]}),r&&c.length===0&&(0,x.jsx)(`p`,{role:`status`,className:`px-2 py-6 text-center text-xs text-sidebar-muted-foreground`,children:`No settings found`}),r?(0,x.jsx)(`div`,{id:c.length?`settings-search-results`:void 0,role:c.length?`listbox`:void 0,"aria-label":`Settings search results`,className:`flex flex-col gap-px`,children:c.map((e,t)=>{let n=DQ.find(t=>t.id===e.section)?.icon||lm;return(0,x.jsxs)(`button`,{type:`button`,id:`settings-result-${t}`,role:`option`,"aria-selected":t===d,tabIndex:-1,onMouseMove:()=>u(t),onClick:()=>m(e),className:G(`flex min-h-10 w-full items-start gap-2 rounded-[var(--control-radius)] px-2.5 py-1.5 text-left outline-none hover:bg-sidebar-row-hover`,t===d&&`bg-sidebar-row-selected`),children:[(0,x.jsx)(n,{className:`mt-0.5 size-4 shrink-0 text-sidebar-icon`}),(0,x.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,x.jsx)(`span`,{className:`block truncate text-sm font-medium text-sidebar-foreground`,children:e.title}),(0,x.jsx)(`span`,{className:`block truncate text-2xs text-sidebar-muted-foreground/75`,children:s[e.section]})]})]},e.id)})}):null,(0,x.jsx)(`div`,{className:G(`flex flex-col gap-4`,r&&`hidden`),children:n.filter(e=>o.some(t=>t.group===e)).map(e=>(0,x.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,x.jsx)(`h3`,{className:`px-2 text-xs font-medium text-sidebar-muted-foreground/80`,children:e}),(0,x.jsx)(`div`,{className:`flex flex-col gap-px`,children:o.filter(t=>t.group===e).map(e=>(0,x.jsxs)(`button`,{type:`button`,onClick:()=>t(e.id),"aria-current":e.id===g.id?`page`:void 0,className:G(`flex h-8 w-full items-center gap-2 rounded-[var(--control-radius)] px-2.5 text-left text-sm outline-none hover:bg-sidebar-row-hover focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset`,e.id===g.id&&`bg-sidebar-row-selected font-medium text-sidebar-foreground`),children:[(0,x.jsx)(e.icon,{className:`size-4 shrink-0 text-sidebar-icon`}),(0,x.jsx)(`span`,{className:`truncate`,children:e.label})]},e.id))})]},e))})]})}),(0,x.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,x.jsxs)(`header`,{className:`flex h-12 shrink-0 items-center gap-3 border-b ps-5 pe-2`,children:[(0,x.jsxs)(`nav`,{"aria-label":`Breadcrumb`,className:`flex min-w-0 items-center gap-2 text-sm font-medium`,children:[(0,x.jsx)(`span`,{className:`text-muted-foreground`,children:`Settings`}),(0,x.jsx)(`span`,{className:`text-icon-muted`,children:`/`}),(0,x.jsx)(`span`,{className:`truncate`,children:g.label})]}),(0,x.jsx)(`div`,{className:`ms-auto flex shrink-0 items-center gap-1`,children:(0,x.jsx)(oQ,{})})]}),(0,x.jsx)(`div`,{className:`fade-top min-h-0 flex-1 overflow-y-auto`,children:(0,x.jsxs)(`div`,{className:`mx-auto flex max-w-4xl flex-col gap-8 px-5 pt-6 pb-12 sm:px-6`,children:[g.id===`general`&&(0,x.jsx)(jQ,{}),g.id===`appearance`&&(0,x.jsx)(MQ,{}),g.id===`providers`&&(0,x.jsx)(RS,{}),g.id===`instances`&&(0,x.jsx)(tC,{}),g.id===`projects`&&(0,x.jsx)(uQ,{}),g.id===`keybindings`&&(0,x.jsx)(gQ,{}),g.id===`diffs`&&(0,x.jsx)(yQ,{}),g.id===`about`&&(0,x.jsx)(xQ,{}),g.id===`licenses`&&(0,x.jsx)(SQ,{}),g.id===`doctor`&&(0,x.jsx)(wQ,{}),g.id===`skills`&&(0,x.jsx)(TQ,{})]})})]})]})}function kQ({title:e,children:t,action:n}){return(0,x.jsxs)(`section`,{className:`space-y-2.5`,children:[(0,x.jsxs)(`div`,{className:`flex items-center px-3 sm:px-4`,children:[(0,x.jsx)(`h2`,{className:`text-base font-semibold`,children:e}),(0,x.jsx)(`div`,{className:`ml-auto`,children:n})]}),(0,x.jsx)(`div`,{className:`overflow-hidden rounded-xl border border-border/60 bg-card/40 shadow-xs/5 [&>*+*]:border-t [&>*+*]:border-border/50`,children:t})]})}function AQ({title:e,description:t,children:n}){return(0,x.jsxs)(`div`,{id:typeof e==`string`?SS(e):void 0,className:`grid grid-cols-[minmax(0,1fr)_auto] items-center gap-8 px-3 py-3 sm:px-4`,children:[(0,x.jsxs)(`div`,{className:`min-w-0`,children:[(0,x.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:e}),t&&(0,x.jsx)(`div`,{className:`mt-0.5 max-w-2xl text-xs leading-normal text-muted-foreground`,children:t})]}),(0,x.jsx)(`div`,{className:`flex max-w-[28rem] min-w-0 justify-end`,children:n})]})}function jQ(){let e=U(Au().meta.queryOptions());return(0,x.jsxs)(kQ,{title:`General`,children:[(0,x.jsx)(AQ,{title:`rpf home`,description:`Profiles, keys, projects and chats live here (RPFORGE_HOME moves it).`,children:(0,x.jsx)(`code`,{className:`font-mono text-xs break-all text-muted-foreground`,children:e.data?.home})}),(0,x.jsx)(AQ,{title:`Key store`,description:`Model keys are encrypted in the same store as instance credentials.`,children:(0,x.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.data?.keyStore?e.data.keyStore.keySource:`unavailable (keys can’t be saved)`})}),(0,x.jsx)(AQ,{title:`Version`,children:(0,x.jsxs)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:[`rpf `,e.data?.version]})})]})}function MQ(){let e=Gu();return(0,x.jsx)(kQ,{title:`Appearance`,children:(0,x.jsx)(AQ,{title:`Theme`,description:`Follow the system, or always light or dark.`,children:(0,x.jsx)(`div`,{className:`inline-flex rounded-[var(--control-radius)] border border-input p-0.5`,children:[{id:`system`,label:`System`},{id:`light`,label:`Light`},{id:`dark`,label:`Dark`}].map(t=>(0,x.jsx)(`button`,{onClick:()=>Wu({theme:t.id}),className:G(`h-6 rounded-md px-2.5 text-xs`,e.theme===t.id?`bg-accent font-medium`:`text-muted-foreground hover:text-foreground`),children:t.label},t.id))})})})}function NQ({section:e,onSection:t,onClose:n}){return(0,x.jsx)(aQ,{label:`Settings`,onClose:n,children:(0,x.jsx)(OQ,{section:e,onSection:t})})}var PQ=[`var(--primary)`,`#d97757`,`#4d9f8a`,`#8c7bd1`,`#5b9bbd`,`#c2a14d`,`#8b8b8b`];function FQ({value:e,options:t,onChange:n}){return(0,x.jsx)(`div`,{className:`inline-flex rounded-md bg-accent p-0.5`,children:t.map(t=>(0,x.jsx)(`button`,{onClick:()=>n(t.id),className:G(`h-6 rounded px-2 text-xs`,e===t.id?`bg-background font-medium text-foreground shadow-xs/5`:`text-muted-foreground hover:text-foreground`),children:t.label},String(t.id)))})}function IQ({label:e,value:t}){return(0,x.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,x.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:e}),(0,x.jsx)(`dd`,{className:`text-base font-medium text-foreground tabular-nums`,children:t})]})}function LQ({label:e,segments:t,format:n}){let r=t.reduce((e,t)=>e+t.value,0)||1,i=t.filter(e=>e.value>0);return(0,x.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2.5`,children:[(0,x.jsx)(`h3`,{className:`text-sm font-medium text-foreground`,children:e}),(0,x.jsx)(`div`,{"aria-hidden":!0,className:`flex h-2 gap-0.5`,children:i.map(e=>(0,x.jsx)(`div`,{className:`h-full min-w-1 rounded-xs first:rounded-l-full last:rounded-r-full`,style:{width:`${e.value/r*100}%`,backgroundColor:e.color}},e.label))}),(0,x.jsx)(`ul`,{"aria-label":e,className:`flex flex-wrap gap-x-4 gap-y-1 text-xs`,children:i.map(e=>(0,x.jsxs)(`li`,{className:`flex items-center gap-1.5`,children:[(0,x.jsx)(`span`,{className:`size-2 rounded-xs`,style:{backgroundColor:e.color}}),(0,x.jsx)(`span`,{className:`text-muted-foreground`,children:e.label}),` `,(0,x.jsx)(`span`,{className:`text-foreground tabular-nums`,children:n(e.value)})]},e.label))})]})}function RQ({days:e,series:t,metric:n}){let[r,i]=b.useState(null),a=Math.max(1e-9,...t.flatMap(e=>e.values)),o=n===`cost`?FX:PX,s=t=>e.length<=1?300:t/(e.length-1)*600,c=e=>200-e/a*192;return(0,x.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,x.jsxs)(`div`,{className:`flex gap-2`,children:[(0,x.jsx)(`div`,{"aria-hidden":!0,className:`relative h-56 w-14 shrink-0`,children:[1,.5,0].map(e=>(0,x.jsx)(`span`,{className:`absolute right-0 -translate-y-1/2 text-2xs text-muted-foreground tabular-nums`,style:{top:`${(1-e)*100*.96+4*(1-e==0)}%`},children:o(a*e)},e))}),(0,x.jsxs)(`div`,{className:`relative h-56 flex-1`,onMouseLeave:()=>i(null),onMouseMove:t=>{let n=t.currentTarget.getBoundingClientRect(),r=Math.round((t.clientX-n.left)/n.width*(e.length-1));i(Math.max(0,Math.min(e.length-1,r)))},children:[(0,x.jsxs)(`svg`,{viewBox:`0 0 600 200`,preserveAspectRatio:`none`,className:`h-full w-full overflow-visible`,children:[[0,.5,1].map(e=>(0,x.jsx)(`line`,{x1:0,x2:600,y1:c(a*e),y2:c(a*e),className:`text-border`,stroke:`currentColor`,strokeDasharray:e?`3 3`:void 0,vectorEffect:`non-scaling-stroke`},e)),t.map(e=>{let t=e.values.map((e,t)=>`${s(t)},${c(e)}`).join(` `);return(0,x.jsxs)(`g`,{children:[(0,x.jsx)(`polygon`,{points:`0,200 ${t} 600,200`,fill:e.color,opacity:.12}),(0,x.jsx)(`polyline`,{points:t,fill:`none`,stroke:e.color,strokeWidth:1.5,vectorEffect:`non-scaling-stroke`})]},e.key)}),r!==null&&(0,x.jsx)(`line`,{x1:s(r),x2:s(r),y1:0,y2:200,stroke:`currentColor`,className:`text-foreground/40`,vectorEffect:`non-scaling-stroke`})]}),r!==null&&(0,x.jsxs)(`div`,{className:`glass pointer-events-none absolute top-2 z-10 min-w-36 rounded-xl border border-border/50 px-2.5 py-2 text-xs shadow-lg`,style:{left:`min(calc(${s(r)/600*100}% + 8px), calc(100% - 10rem))`},children:[(0,x.jsx)(`div`,{className:`mb-1 text-muted-foreground`,children:e[r]}),t.map(e=>(0,x.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,x.jsxs)(`span`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,x.jsx)(`span`,{className:`size-2 rounded-full`,style:{backgroundColor:e.color}}),e.label]}),(0,x.jsx)(`span`,{className:`text-foreground tabular-nums`,children:o(e.values[r]||0)})]},e.key))]})]})]}),(0,x.jsxs)(`div`,{className:`flex justify-between ps-16 text-2xs text-muted-foreground tabular-nums`,children:[(0,x.jsx)(`span`,{children:e[0]}),(0,x.jsx)(`span`,{children:e[e.length-1]})]})]})}function zQ(e,t){let n=new Date,r=e?new Date(Date.now()-(e-1)*864e5):new Date(t||n),i=[];for(let e=new Date(r.toISOString().slice(0,10));e<=n;e=new Date(e.getTime()+864e5))i.push(e.toISOString().slice(0,10));return i.length?i:[n.toISOString().slice(0,10)]}function BQ(){let e=Au(),[t,n]=b.useState(`cost`),[r,i]=b.useState(30),a=U(e.usage.report.queryOptions({days:r})),o=a.data,s=o?.totals,c=e=>t===`cost`?e.cost:e.input+e.output,l=t===`cost`?FX:PX,u=(o?.connections||[]).map((e,t)=>({...e,label:o?.connectionNames[e.key]||e.key,color:PQ[t%PQ.length]})),d=zQ(r,o?.days[0]?.key),f=u.map(e=>({key:e.key,label:e.label,color:e.color,values:d.map(t=>{let n=o?.connectionDays[`${e.key}|${t}`];return n?c(n):0})})),p=s?c(s):0,m=s?s.input-s.cachedInput:0;return(0,x.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,x.jsxs)(`header`,{className:`flex min-h-12 shrink-0 items-center gap-2 border-b ps-5 pe-2`,children:[(0,x.jsx)(`nav`,{"aria-label":`Usage breadcrumb`,className:`flex min-w-0 items-center gap-2 text-sm font-medium`,children:(0,x.jsx)(`span`,{className:`truncate`,children:`Usage`})}),(0,x.jsxs)(`div`,{className:`ms-auto flex shrink-0 items-center gap-2`,children:[(0,x.jsx)(FQ,{value:t,onChange:n,options:[{id:`cost`,label:`Cost`},{id:`tokens`,label:`Tokens`}]}),(0,x.jsx)(FQ,{value:r,onChange:i,options:[{id:7,label:`7 days`},{id:30,label:`30 days`},{id:90,label:`90 days`},{id:0,label:`All`}]}),(0,x.jsx)(oQ,{})]})]}),(0,x.jsx)(`div`,{className:`fade-top min-h-0 flex-1 overflow-y-auto`,children:(0,x.jsx)(`div`,{className:`mx-auto flex max-w-6xl flex-col gap-6 px-5 pt-6 pb-12 sm:px-6`,children:a.isLoading?(0,x.jsx)(`div`,{className:`flex justify-center py-16`,children:(0,x.jsx)(Yb,{size:`sm`,muted:!0})}):!s||!s.calls?(0,x.jsxs)(`div`,{className:`space-y-2 py-12 text-center text-sm text-muted-foreground`,children:[(0,x.jsx)(`p`,{children:`No usage in this range yet.`}),(0,x.jsx)(`p`,{children:`Each chat run, compaction and title is counted here, by project, model and connection.`})]}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(`section`,{className:`grid gap-6 lg:grid-cols-[minmax(0,18rem)_minmax(0,1fr)]`,children:[(0,x.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-5`,children:[(0,x.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,x.jsx)(`p`,{className:`text-4xl font-semibold text-foreground tabular-nums`,children:l(p)}),(0,x.jsxs)(`p`,{className:`inline-flex items-center gap-1 text-xs text-muted-foreground`,children:[(0,x.jsxs)(`span`,{children:[s.chats,` chat`,s.chats===1?``:`s`,` · `,s.calls,` call`,s.calls===1?``:`s`,t===`cost`&&` · API estimate`]}),t===`cost`&&s.unpricedTokens>0&&(0,x.jsx)(Tb,{label:`Excludes ${PX(s.unpricedTokens)} tokens of models without a price (set prices in Settings › Providers and models).`,children:(0,x.jsx)(qf,{className:`size-3`,"aria-label":`Unpriced usage details`})})]})]}),u.map(e=>{let t=p?c(e)/p:0;return(0,x.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,x.jsxs)(`dl`,{className:`flex items-baseline justify-between gap-4`,children:[(0,x.jsxs)(`dt`,{className:`flex min-w-0 items-center gap-2 text-sm text-foreground`,children:[(0,x.jsx)(`span`,{"aria-hidden":!0,className:`size-2 shrink-0 rounded-full`,style:{backgroundColor:e.color}}),(0,x.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-1.5`,children:[(0,x.jsx)(`span`,{className:`truncate`,children:e.label}),(0,x.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[e.chats,` chat`,e.chats===1?``:`s`]})]})]}),(0,x.jsx)(`dd`,{className:`text-sm text-foreground tabular-nums`,children:l(c(e))})]}),(0,x.jsx)(`div`,{className:`h-[3px] rounded-full bg-muted-foreground/20`,children:(0,x.jsx)(`div`,{className:`h-full rounded-full`,style:{width:`${t*100}%`,backgroundColor:e.color}})})]},e.key)})]}),(0,x.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[(0,x.jsx)(`h2`,{className:`text-sm font-medium text-foreground`,children:t===`tokens`?`Daily processed tokens`:`Daily cost`}),(0,x.jsx)(RQ,{days:d,series:f,metric:t})]})]}),(0,x.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,x.jsx)(`h2`,{className:`text-sm font-medium text-foreground`,children:`Totals`}),(0,x.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-6 gap-y-4 py-1 md:grid-cols-5`,children:[(0,x.jsx)(IQ,{label:`Processed tokens`,value:PX(s.input+s.output)}),(0,x.jsx)(IQ,{label:`Cached input`,value:PX(s.cachedInput)}),(0,x.jsx)(IQ,{label:`Uncached input`,value:PX(m)}),(0,x.jsx)(IQ,{label:`Output`,value:PX(s.output)}),(0,x.jsx)(IQ,{label:`Reasoning`,value:s.reasoning?PX(s.reasoning):`—`})]})]}),(0,x.jsxs)(`section`,{className:`grid gap-x-12 gap-y-8 lg:grid-cols-2`,children:[(0,x.jsx)(LQ,{label:`Tokens by type`,format:PX,segments:[{label:`Uncached input`,value:m,color:PQ[0]},{label:`Cached input`,value:s.cachedInput,color:PQ[2]},{label:`Output`,value:s.output,color:PQ[1]}]}),(0,x.jsx)(LQ,{label:t===`cost`?`Cost by kind`:`Tokens by kind`,format:l,segments:(o?.kinds||[]).map((e,t)=>({label:e.key===`run`?`Chat runs`:e.key===`compaction`?`Compactions`:`Titles`,value:c(e),color:PQ[(t+3)%PQ.length]}))})]}),(0,x.jsx)(VQ,{title:`Models`,rows:(o?.models||[]).map(e=>({...e,name:e.model,sub:o?.connectionNames[e.connectionId]||e.connectionId})),metric:t}),(0,x.jsx)(VQ,{title:`Projects`,rows:(o?.projects||[]).map(e=>({...e,sub:``})),metric:t})]})})})]})}function VQ({title:e,rows:t,metric:n}){let r=Math.max(1e-9,...t.map(e=>n===`cost`?e.cost:e.input+e.output));return(0,x.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,x.jsx)(`h2`,{className:`text-sm font-medium text-foreground`,children:e}),(0,x.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,x.jsx)(`thead`,{children:(0,x.jsxs)(`tr`,{className:`border-b border-border text-right text-xs text-muted-foreground`,children:[(0,x.jsx)(`th`,{className:`py-2 pr-3 pl-2 text-left font-normal`,children:`#`}),(0,x.jsx)(`th`,{className:`w-full py-2 text-left font-normal`,children:e===`Models`?`Model`:`Project`}),(0,x.jsx)(`th`,{className:`py-2 pl-6 font-normal`,children:`Tokens`}),(0,x.jsx)(`th`,{className:`hidden py-2 pl-6 font-normal sm:table-cell`,children:`Chats`}),(0,x.jsx)(`th`,{className:`py-2 pr-2 pl-6 font-normal`,children:`Cost`})]})}),(0,x.jsx)(`tbody`,{children:t.map((e,t)=>{let i=n===`cost`?e.cost:e.input+e.output;return(0,x.jsxs)(`tr`,{className:`border-b border-border/50 text-right whitespace-nowrap text-muted-foreground tabular-nums transition-colors hover:bg-muted/50`,children:[(0,x.jsx)(`td`,{className:`py-2.5 pr-3 pl-2 text-left text-xs`,children:t+1}),(0,x.jsxs)(`td`,{className:`py-2.5 text-left whitespace-normal`,children:[(0,x.jsxs)(`div`,{className:`flex items-baseline gap-1.5`,children:[(0,x.jsx)(`span`,{className:`text-foreground`,children:e.name}),e.sub&&(0,x.jsx)(`span`,{className:`text-xs`,children:e.sub})]}),(0,x.jsx)(`div`,{"aria-hidden":!0,className:`mt-1.5 h-0.5 max-w-48`,children:(0,x.jsx)(`div`,{className:`h-full rounded-full bg-primary/60`,style:{width:`${i/r*100}%`}})})]}),(0,x.jsx)(`td`,{className:`py-2.5 pl-6 text-foreground`,children:PX(e.input+e.output)}),(0,x.jsx)(`td`,{className:`hidden py-2.5 pl-6 sm:table-cell`,children:e.chats}),(0,x.jsx)(`td`,{className:`py-2.5 pr-2 pl-6 text-foreground`,children:e.cost>0?FX(e.cost):e.unpricedTokens?(0,x.jsx)(`span`,{className:`text-muted-foreground`,children:`no price`}):FX(0)})]},e.key)})})]})]})}function HQ({onClose:e}){return(0,x.jsx)(aQ,{label:`Usage`,onClose:e,children:(0,x.jsx)(BQ,{})})}var UQ={start:`new`,profile:``,app:``,setMode:`existing`,setId:``,setName:``,name:``,slug:``,slugTouched:!1,description:``,sourceKind:`template`,template:``,portal:``,copyPages:!1,layout:``,themeMode:`keep`,themeKey:``,themeCopy:!1,color:`#2563eb`,tint:`neutral`,contrast:`AA`,icon:``,folder:``,folderTouched:!1,extras:{prettierrc:!0,gitignore:!0,readme:!0,skills:!0,git:!0}},WQ={start:`Start from`,instance:`Instance`,app:`App and update set`,portal:`Portal`,look:`Look and navigation`,folder:`Folder and extras`,review:`Review plan`};function GQ(e){return e===`new`?[`start`,`instance`,`app`,`portal`,`look`,`folder`,`review`]:[`start`,`instance`,`app`,`portal`,`folder`,`review`]}function KQ(e){let t=e.normalize(`NFKD`).replace(/[̀-ͯ]/g,``).toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).substring(0,40).replace(/-+$/,``);return t.length===1&&(t+=`-portal`),t}function qQ(e){return`${e.trim()||`Portal`} (React Portal)`.substring(0,80)}function JQ(e){let t=/^([a-z_]+): ([\s\S]*)$/.exec(e||``);return t?[t[1],t[2]]:[``,e||``]}var YQ={no_profile:`Add or finish the instance profile in Settings › Instances.`,forge_mcp_disabled:`An admin turns Forge on in React Portal (x_312987_portal.forge.mcp.enabled).`,forbidden:`Ask for the React Portal designer or developer role.`,incompatible:`Upgrade React Portal on the instance.`,helper_missing:`Install or upgrade React Portal Global Helpers on the instance.`,no_apps:`You need author access to a scoped application.`};function XQ(e){let t={app:e.app,updateSet:e.setMode===`new`?{create:e.setName.trim()||qQ(e.name)}:e.setId,name:e.name.trim(),slug:e.slug};return e.description.trim()&&(t.description=e.description.trim()),t.source=e.start===`copy`?{kind:`portal`,portal:e.portal,pages:e.copyPages?`all`:`none`}:e.sourceKind===`empty`?{kind:`empty`}:{kind:`template`,...e.template?{portal:e.template}:{}},e.start===`new`&&(e.layout&&(t.layout=e.layout),e.themeMode===`pick`&&e.themeKey&&(t.theme={key:e.themeKey,...e.themeCopy?{copy:!0}:{}}),e.themeMode===`keep`&&e.themeCopy&&(t.theme={copy:!0}),e.themeMode===`color`&&(t.theme={color:e.color,tint:e.tint,contrast:e.contrast}),e.icon.trim()&&e.sourceKind!==`empty`&&(t.brand={icon:e.icon.trim()})),t}function ZQ(){let e=Gu(),t=!!e.newProject;return(0,x.jsx)(Eb,{open:t,onOpenChange:e=>!e&&Wu({newProject:``}),children:t&&(0,x.jsx)(QQ,{preset:e.newProject===`choose`||!e.newProject?void 0:e.newProject},e.newProject)})}function QQ({preset:e}){let t=Au(),n=C(),r=Yi(),i=i8(),a=U(t.wizard.context.queryOptions()),o=U({...t.profiles.list.queryOptions(),retry:!1}),[s,c]=b.useState({...UQ,start:e||`new`}),l=e=>c(t=>({...t,...e})),u=GQ(s.start),[d,f]=b.useState(e?`instance`:`start`),p=u.indexOf(d),[m,h]=b.useState(``),g=at(t.wizard.plan.mutationOptions()),_=at(t.wizard.run.mutationOptions()),v=at(t.wizard.pull.mutationOptions()),y=at(t.wizard.retryPull.mutationOptions()),S=b.useMemo(()=>crypto.randomUUID(),[]),w=o.data?.profiles||[];b.useEffect(()=>{!s.profile&&w.length&&l({profile:o.data?.default||w[0].name})},[w.length]);let T=!!s.profile&&a.data?.available!==!1,E=U({...t.wizard.preflight.queryOptions({profile:s.profile}),enabled:T,retry:!1,staleTime:6e4}),D=U({...t.wizard.updateSets.queryOptions({profile:s.profile,appId:E.data?.apps.find(e=>e.scope===s.app)?.id||``}),enabled:T&&!!s.app&&!!E.data}),O=U({...t.wizard.portals.queryOptions({profile:s.profile}),enabled:T&&!!E.data});b.useEffect(()=>{if(E.data&&!s.app){let e=E.data.apps.find(e=>e.current&&!e.reactPortal)||E.data.apps.find(e=>!e.reactPortal);e&&l({app:e.scope})}},[E.data]),b.useEffect(()=>{let e=D.data||[];if(e.length&&!e.some(e=>e.id===s.setId)){let t=e.find(e=>e.remembered)||e.find(e=>e.isDefault)||e[0];l({setId:t.id})}},[D.data]);let k=s.start===`pull`?s.portal:s.slug,A=U({...t.wizard.folder.queryOptions(s.folderTouched&&s.folder?{path:s.folder}:{slug:k||`portal`}),enabled:!!a.data});b.useEffect(()=>{!s.folderTouched&&A.data&&l({folder:A.data.folder})},[A.data?.folder]);let j=U({...t.wizard.job.queryOptions({id:m}),enabled:!!m});b.useEffect(()=>{if(j.data?.state===`done`&&j.data.projectId){n.invalidateQueries({queryKey:t.projects.list.queryKey()});let e=j.data.projectId,i=setTimeout(()=>{Wu({newProject:``}),r({to:`/p/$projectId`,params:{projectId:e}})},700);return()=>clearTimeout(i)}},[j.data?.state,j.data?.projectId,r,n,t]);let[M,N]=JQ(E.error?.message),P=U({...t.wizard.slug.queryOptions({profile:s.profile,slug:s.slug}),enabled:T&&!!E.data&&s.start!==`pull`&&/^[a-z0-9][a-z0-9-]{1,39}$/.test(s.slug),staleTime:3e4}),F=()=>{switch(d){case`instance`:return s.profile?E.data?``:E.isLoading?`Checking…`:`The instance refused`:`Pick an instance`;case`app`:return s.app?s.setMode===`existing`&&!s.setId?`Pick an update set`:``:`Pick an application`;case`portal`:return s.start===`pull`?s.portal?``:`Pick a portal`:s.start===`copy`&&!s.portal?`Pick a portal to copy`:s.name.trim()?/^[a-z0-9][a-z0-9-]{1,39}$/.test(s.slug)?P.data&&!P.data.available?`That slug is taken`:``:`The slug needs 2-40 lowercase letters, digits or dashes`:`Name the portal`;case`folder`:return s.folder?A.data&&!A.data.empty?`The folder is not empty`:``:`Pick a folder`;default:return``}},I=()=>{let e=u[p+1];e&&(e===`review`&&s.start!==`pull`&&g.mutate({profile:s.profile,answers:XQ(s),folder:s.folder,extras:s.extras}),f(e))},L=()=>p>0&&f(u[p-1]),R=async()=>{if(s.start===`pull`){let e=await v.mutateAsync({profile:s.profile,portal:s.portal,folder:s.folder,updateSet:s.setId,extras:s.extras});h(e.jobId);return}let e=g.data?.plan?.hash;if(!e)return;let t=await _.mutateAsync({profile:s.profile,answers:XQ(s),folder:s.folder,extras:s.extras,planHash:e,requestId:S});h(t.jobId)},z=F(),B=!!m,V=E.data?.apps.find(e=>e.scope===s.app)?.reactPortal;return(0,x.jsxs)(I6,{children:[(0,x.jsx)(D6,{className:`fixed inset-0 z-50 bg-background/60 backdrop-blur-[4px] transition-opacity duration-200 data-[ending-style]:opacity-0 data-[starting-style]:opacity-0`}),(0,x.jsxs)(F6,{className:`glass fixed top-1/2 left-1/2 z-50 flex h-[min(44rem,calc(100vh-2rem))] w-[calc(100vw-2rem)] max-w-5xl -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl shadow-[0_24px_64px_-24px_rgb(0_0_0/65%)] transition-[opacity,scale] duration-200 data-[ending-style]:scale-98 data-[ending-style]:opacity-0 data-[starting-style]:scale-98 data-[starting-style]:opacity-0`,children:[(0,x.jsxs)(`div`,{className:`flex h-12 shrink-0 items-center gap-2 border-b ps-5 pe-2`,children:[(0,x.jsx)(G6,{className:`text-sm font-medium`,children:`New project`}),(0,x.jsx)(O6,{"aria-label":`Close (Esc)`,className:`ms-auto inline-flex size-7 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground`,children:(0,x.jsx)(Gm,{className:`size-4`})})]}),(0,x.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,x.jsx)(`ol`,{className:`hidden w-56 shrink-0 flex-col gap-0.5 border-e bg-muted/20 p-3 sm:flex`,children:u.map((e,t)=>{let n=t<p||B&&t<=p,r=e===d&&!B;return(0,x.jsx)(`li`,{children:(0,x.jsxs)(`button`,{type:`button`,disabled:B||t>p,onClick:()=>f(e),className:G(`flex h-8 w-full items-center gap-2.5 rounded-md px-2 text-left text-sm`,r?`bg-accent font-medium`:`text-muted-foreground`,t<=p&&!B&&`hover:bg-accent/60`),children:[(0,x.jsx)(`span`,{className:G(`flex size-5 shrink-0 items-center justify-center rounded-full border text-2xs tabular-nums`,n&&`border-transparent bg-success/16 text-success-foreground`,r&&`border-primary bg-primary text-primary-foreground`),children:n?(0,x.jsx)(Md,{className:`size-3`}):t+1}),WQ[e]]})},e)})}),(0,x.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:B?(0,x.jsx)(l$,{job:j.data,onRetry:()=>y.mutate({jobId:m}),retrying:y.isPending,onBack:()=>{h(``),f(`review`)}}):a.data?.available===!1?(0,x.jsxs)($Q,{icon:qf,title:`This rpf build can't create projects`,children:[`Run `,(0,x.jsx)(`code`,{className:`font-mono`,children:`rpf init`}),` in a terminal, then open the folder.`]}):d===`start`?(0,x.jsx)(t$,{value:s.start,onPick:e=>{l({start:e,portal:``}),f(`instance`)}}):d===`instance`?(0,x.jsx)(n$,{profiles:w,profile:s.profile,onProfile:e=>l({profile:e,app:``,setId:``}),pre:E.data,loading:E.isLoading&&!!s.profile,code:M,message:N,onAddInstance:()=>i(`instances`),onRetry:()=>E.refetch()}):d===`app`?(0,x.jsx)(r$,{d:s,set:l,apps:E.data?.apps||[],sets:D.data||[],loadingSets:D.isLoading,canCreateSets:s.start!==`pull`&&!!E.data?.canCreateSets}):d===`portal`?(0,x.jsx)(i$,{d:s,set:l,portals:O.data||[],loading:O.isLoading,slugCheck:P.data,slugChecking:P.isFetching}):d===`look`?(0,x.jsx)(a$,{d:s,set:l,profile:s.profile}):d===`folder`?(0,x.jsx)(s$,{d:s,set:l,free:A.data}):(0,x.jsx)(c$,{d:s,sets:D.data||[],plan:g.data,error:g.error?.message,planning:g.isPending,reactPortalApp:!!V,onReplan:()=>g.mutate({profile:s.profile,answers:XQ(s),folder:s.folder,extras:s.extras})})})]}),!B&&(0,x.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-t bg-muted/72 px-6 py-3`,children:[z&&d!==`start`&&d!==`review`&&(0,x.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:z}),(0,x.jsxs)(`div`,{className:`ms-auto flex gap-2`,children:[p>0&&(0,x.jsx)(q,{variant:`outline`,onClick:L,children:`Back`}),d===`review`?(0,x.jsx)(q,{disabled:s.start!==`pull`&&!g.data?.plan?.hash||g.isPending||_.isPending||v.isPending,onClick:R,children:s.start===`pull`?`Pull and open`:`Create and open`}):d!==`start`&&(0,x.jsx)(q,{disabled:!!z,onClick:I,children:`Next`})]})]}),(_.error||v.error)&&!B&&(0,x.jsx)(`div`,{className:`border-t px-6 py-2 text-xs text-destructive-foreground`,children:JQ((_.error||v.error)?.message)[1]})]})]})}function $Q({icon:e,title:t,children:n}){return(0,x.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-2 text-center`,children:[(0,x.jsx)(e,{className:`size-6 text-muted-foreground`}),(0,x.jsx)(`p`,{className:`text-sm font-medium`,children:t}),(0,x.jsx)(`div`,{className:`max-w-md text-xs text-muted-foreground`,children:n})]})}function e$({title:e,children:t}){return(0,x.jsxs)(`div`,{className:`mb-5`,children:[(0,x.jsx)(`h2`,{className:`text-base font-semibold`,children:e}),t&&(0,x.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:t})]})}function t$({value:e,onPick:t}){return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(e$,{title:`How do you want to start?`}),(0,x.jsx)(`div`,{className:`grid gap-3 md:grid-cols-3`,children:[{id:`new`,icon:ym,title:`New portal`,body:`A draft on the instance from a template or empty (rpf init).`},{id:`pull`,icon:sf,title:`Pull a portal`,body:`Work on an existing portal as files. Any portal, React Portal ones included.`},{id:`copy`,icon:ef,title:`Copy a portal`,body:`A new draft copied from any portal, then pulled. Pages are optional.`}].map(n=>(0,x.jsxs)(`button`,{type:`button`,onClick:()=>t(n.id),className:G(`flex flex-col items-start gap-2 rounded-xl border bg-card/40 p-4 text-left shadow-xs/5 outline-none transition-colors hover:bg-accent/50 focus-visible:ring-2 focus-visible:ring-ring`,e===n.id&&`border-primary/60`),children:[(0,x.jsx)(n.icon,{className:`size-5 text-icon-muted`}),(0,x.jsx)(`span`,{className:`text-sm font-medium`,children:n.title}),(0,x.jsx)(`span`,{className:`text-xs leading-relaxed text-muted-foreground`,children:n.body})]},n.id))})]})}function n$({profiles:e,profile:t,onProfile:n,pre:r,loading:i,code:a,message:o,onAddInstance:s,onRetry:c}){return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(e$,{title:`Instance`,children:`The rpf profile the portal lives on. The CLI uses the same profiles.`}),e.length===0?(0,x.jsxs)(`div`,{className:`rounded-xl border border-dashed p-6 text-center`,children:[(0,x.jsx)(`p`,{className:`text-sm font-medium`,children:`No instances yet`}),(0,x.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Add the ServiceNow instance your portals live on.`}),(0,x.jsx)(q,{size:`sm`,className:`mt-3`,onClick:s,children:`Add an instance`})]}):(0,x.jsx)(`div`,{className:`overflow-hidden rounded-xl border border-border/60 bg-card/40 shadow-xs/5`,children:e.map(e=>(0,x.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-3 border-border/50 px-4 py-2.5 not-first:border-t hover:bg-accent/40`,children:[(0,x.jsx)(`input`,{type:`radio`,name:`profile`,checked:t===e.name,onChange:()=>n(e.name),className:f5}),(0,x.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,x.jsx)(`span`,{className:`text-sm font-medium`,children:e.name}),e.default&&(0,x.jsx)(`span`,{className:`ms-2 text-xs text-muted-foreground`,children:`default`}),(0,x.jsx)(`span`,{className:`block truncate font-mono text-xs text-muted-foreground`,children:e.instance.replace(/^https?:\/\//,``)})]})]},e.name))}),t&&(0,x.jsx)(`div`,{className:`mt-4 rounded-lg border border-border/60 px-4 py-3 text-sm`,children:i?(0,x.jsxs)(`span`,{className:`inline-flex items-center gap-2 text-muted-foreground`,children:[(0,x.jsx)(Yb,{size:`sm`}),` Checking `,t,`…`]}):r?(0,x.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,x.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-success-foreground`,children:[(0,x.jsx)(Md,{className:`size-4`}),` Forge on`]}),(0,x.jsxs)(`span`,{className:`text-muted-foreground`,children:[`as `,r.user,` ·`,` `,Object.keys(r.capabilities||{}).filter(e=>r.capabilities[e]).join(`, `),r.reactPortal?` · React Portal ${r.reactPortal}`:``]}),r.warning&&(0,x.jsx)(`span`,{className:`basis-full text-xs text-warning-foreground`,children:r.warning})]}):o?(0,x.jsxs)(`div`,{className:`flex gap-2`,children:[(0,x.jsx)(Wd,{className:`mt-0.5 size-4 shrink-0 text-destructive-foreground`}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`p`,{className:`text-destructive-foreground`,children:o}),YQ[a]&&(0,x.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:YQ[a]}),(0,x.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[(0,x.jsx)(q,{size:`xs`,variant:`outline`,onClick:c,children:`Check again`}),a===`no_profile`&&(0,x.jsx)(q,{size:`xs`,variant:`outline`,onClick:s,children:`Open Instances`})]})]})]}):null})]})}function r$({d:e,set:t,apps:n,sets:r,loadingSets:i,canCreateSets:a}){let o=n.find(t=>t.scope===e.app),s=a&&!o?.reactPortal;return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(e$,{title:`App and update set`,children:e.start===`pull`?`Pushes from the folder write into this update set.`:`The application that owns the portal, and the update set that captures it.`}),(0,x.jsxs)(`div`,{className:`grid gap-5`,children:[(0,x.jsx)(u5,{label:`Application`,children:(0,x.jsx)(d5,{"aria-label":`Application`,value:e.app,onChange:e=>t({app:e,setId:``,...n.find(t=>t.scope===e)?.reactPortal?{setMode:`existing`}:{}}),options:n.map(e=>({value:e.scope,label:`${e.name} (${e.scope})${e.reactPortal?` · React Portal itself`:e.current?` · current`:``}`}))})}),o?.reactPortal&&(0,x.jsxs)(`p`,{className:`flex gap-2 text-xs text-warning-foreground`,children:[(0,x.jsx)(Lm,{className:`size-4 shrink-0`}),`React Portal itself owns these records: a React Portal upgrade may change them.`]}),(0,x.jsxs)(`div`,{className:`grid gap-2`,children:[(0,x.jsx)(`span`,{className:`text-xs font-medium`,children:`Update set`}),(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-sm`,children:[(0,x.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,x.jsx)(`input`,{type:`radio`,className:f5,checked:e.setMode===`existing`,onChange:()=>t({setMode:`existing`})}),`An in-progress set`]}),(0,x.jsx)(d5,{"aria-label":`Update set`,className:`w-auto min-w-64`,disabled:e.setMode!==`existing`,value:e.setId,onChange:e=>t({setId:e}),placeholder:i?`Loading…`:`Choose a set`,options:r.map(e=>({value:e.id,label:`${e.name}${e.isDefault?` (default)`:``}${e.remembered?` · yours`:``}`}))})]}),s&&(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-sm`,children:[(0,x.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,x.jsx)(`input`,{type:`radio`,className:`relative inline-flex size-4.5 shrink-0 cursor-pointer appearance-none items-center justify-center rounded-full border border-input bg-background shadow-xs/5 outline-none transition-shadow not-dark:bg-clip-padding checked:border-primary checked:bg-[radial-gradient(circle,var(--primary-foreground)_0_3px,var(--primary)_3.5px)] checked:shadow-none focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring disabled:opacity-64 sm:size-4 dark:not-checked:bg-input/32`,checked:e.setMode===`new`,onChange:()=>t({setMode:`new`})}),`A new set`]}),(0,x.jsx)(o5,{size:`compact`,className:`w-80`,disabled:e.setMode!==`new`,"aria-label":`New update set name`,placeholder:qQ(e.name||`Portal name`),value:e.setName,maxLength:80,onChange:e=>t({setName:e.target.value})})]})]})]})]})}function i$({d:e,set:t,portals:n,loading:r,slugCheck:i,slugChecking:a}){let[o,s]=b.useState(``),c=n.filter(e=>e.isTemplate),l=(e.start===`pull`?n.filter(e=>!e.isTemplate):n).filter(e=>!o||`${e.slug} ${e.name}`.toLowerCase().includes(o.toLowerCase())),u=e.start!==`pull`&&(0,x.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,x.jsx)(u5,{label:`Portal name`,children:(0,x.jsx)(o5,{autoFocus:!0,placeholder:`HR Portal`,value:e.name,maxLength:100,onChange:n=>t({name:n.target.value,...e.slugTouched?{}:{slug:KQ(n.target.value)}})})}),(0,x.jsx)(u5,{label:`Slug`,description:a?`Checking…`:i&&!i.available?(0,x.jsxs)(`span`,{className:`text-destructive-foreground`,children:[`Taken by `,i.takenBy?.name||`another portal`,i.suggestion&&(0,x.jsxs)(x.Fragment,{children:[` · `,(0,x.jsxs)(`button`,{type:`button`,className:`underline`,onClick:()=>t({slug:i.suggestion,slugTouched:!0}),children:[`use `,i.suggestion]})]})]}):i?.available?(0,x.jsxs)(`span`,{className:`text-success-foreground`,children:[`Available · /x/312987/portal/site/`,e.slug]}):`The URL: lowercase letters, digits and dashes`,children:(0,x.jsx)(o5,{mono:!0,value:e.slug,onChange:e=>t({slug:e.target.value.toLowerCase(),slugTouched:!0}),"aria-invalid":i&&!i.available||void 0})}),(0,x.jsx)(u5,{label:`Description (optional)`,className:`sm:col-span-2`,children:(0,x.jsx)(s5,{rows:2,value:e.description,maxLength:1e3,onChange:e=>t({description:e.target.value})})})]}),d=(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(`div`,{className:`relative mb-2`,children:[(0,x.jsx)(am,{className:`pointer-events-none absolute top-1/2 left-2.5 z-10 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,x.jsx)(o5,{size:`compact`,className:`[&_input]:ps-7.5`,placeholder:`Search portals`,"aria-label":`Search portals`,value:o,onChange:e=>s(e.target.value)})]}),(0,x.jsxs)(`div`,{className:`max-h-72 overflow-y-auto rounded-xl border border-border/60 bg-card/40 shadow-xs/5`,children:[r&&(0,x.jsx)(`p`,{className:`px-4 py-3 text-sm text-muted-foreground`,children:`Reading portals…`}),l.map(n=>(0,x.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-3 border-border/50 px-4 py-2 not-first:border-t hover:bg-accent/40`,children:[(0,x.jsx)(`input`,{type:`radio`,className:f5,name:`portal`,checked:e.portal===n.slug,onChange:()=>t({portal:n.slug})}),(0,x.jsx)(`span`,{className:`w-32 shrink-0 truncate font-mono text-xs`,children:n.slug}),(0,x.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm`,children:n.name}),(0,x.jsxs)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,title:n.appName||void 0,children:[n.app||`no application`,` · `,n.isTemplate?`template`:n.active?`live`:`draft`,` ·`,` `,n.pageCount,` pages`]}),n.reactPortal&&(0,x.jsx)(kb,{variant:`info`,children:`React Portal`})]},n.slug))]}),n.find(t=>t.slug===e.portal)?.reactPortal&&(0,x.jsxs)(`p`,{className:`mt-2 flex gap-2 text-xs text-info-foreground`,children:[(0,x.jsx)(qf,{className:`size-4 shrink-0`}),`React Portal owns `,e.portal,`: a React Portal upgrade may change these records.`]})]});return e.start===`pull`?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(e$,{title:`Portal`,children:`The portal to work on as files. Nothing on the instance changes until you push.`}),d]}):e.start===`copy`?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(e$,{title:`Portal`,children:`A new draft copied from another portal: its layout, theme, chrome, panels and menus.`}),d,(0,x.jsxs)(`label`,{className:`mt-3 flex items-center gap-2 text-sm`,children:[(0,x.jsx)(c5,{checked:e.copyPages,onCheckedChange:e=>t({copyPages:!!e})}),` Copy its pages too`]}),(0,x.jsx)(`div`,{className:`mt-5`,children:u})]}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(e$,{title:`Portal`,children:`The new draft's name, its URL slug, and what it starts from.`}),u,(0,x.jsxs)(`div`,{className:`mt-5 grid gap-2`,children:[(0,x.jsx)(`span`,{className:`text-xs font-medium`,children:`Start from`}),(0,x.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,x.jsx)(`input`,{type:`radio`,className:f5,checked:e.sourceKind===`template`,onChange:()=>t({sourceKind:`template`})}),`A template`,(0,x.jsx)(d5,{"aria-label":`Template`,className:`w-auto min-w-56`,disabled:e.sourceKind!==`template`,value:e.template,onChange:e=>t({template:e}),options:[{value:``,label:`The default template`},...c.map(e=>({value:e.slug,label:`${e.name} · ${e.pageCount} pages${e.isDefaultTemplate?` (default)`:``}`}))]})]}),(0,x.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,x.jsx)(`input`,{type:`radio`,className:f5,checked:e.sourceKind===`empty`,onChange:()=>t({sourceKind:`empty`})}),`Empty: a layout, one empty Home page, empty menus`]})]})]})}function a$({d:e,set:t,profile:n}){let r=Au(),i=U(r.wizard.layouts.queryOptions({profile:n})),a=U({...r.wizard.themes.queryOptions({profile:n}),enabled:e.themeMode===`pick`}),o=/^#[0-9a-f]{6}$/i.test(e.color),s=U({...r.wizard.brandTheme.queryOptions({color:e.color,tint:e.tint,contrast:e.contrast}),enabled:e.themeMode===`color`&&o}),c=(n,r)=>(0,x.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,x.jsx)(`input`,{type:`radio`,className:f5,checked:e.themeMode===n,onChange:()=>t({themeMode:n})}),r]});return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(e$,{title:`Look and navigation`,children:`Menus and panels come from the source as they are; change them in Studio later.`}),(0,x.jsxs)(`div`,{className:`grid gap-6`,children:[(0,x.jsx)(u5,{label:`Layout`,children:(0,x.jsx)(d5,{"aria-label":`Layout`,className:`max-w-sm`,value:e.layout,onChange:e=>t({layout:e}),options:[{value:``,label:`The source's layout`},...(i.data||[]).map(e=>({value:String(e.uniqueId),label:`${e.name} (${e.uniqueId})`}))]})}),(0,x.jsxs)(`div`,{className:`grid gap-2`,children:[(0,x.jsx)(`span`,{className:`text-xs font-medium`,children:`Theme`}),c(`keep`,e.sourceKind===`empty`?`Starter (the default)`:`Keep the source's theme`),c(`pick`,`A theme or preset`),e.themeMode===`pick`&&(0,x.jsx)(`div`,{className:`ms-6 flex flex-wrap gap-2`,children:(a.data||[]).map(n=>(0,x.jsxs)(`button`,{type:`button`,onClick:()=>t({themeKey:n.key}),className:G(`inline-flex h-8 items-center gap-2 rounded-lg border px-2.5 text-sm`,e.themeKey===n.key?`border-primary bg-accent`:`hover:bg-accent/50`),children:[(0,x.jsx)(`span`,{className:`size-3 rounded-full`,style:{backgroundColor:n.tokens?.light?.primary}}),n.name]},n.key))}),c(`color`,`From a brand color (contrast-safe light and dark tokens, made here)`),e.themeMode===`color`&&(0,x.jsxs)(`div`,{className:`ms-6 grid gap-3`,children:[(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,x.jsx)(`input`,{type:`color`,"aria-label":`Brand color`,value:o?e.color:`#2563eb`,onChange:e=>t({color:e.target.value}),className:`size-8 cursor-pointer rounded-md border border-input bg-transparent`}),(0,x.jsx)(o5,{size:`compact`,mono:!0,className:`w-28`,value:e.color,onChange:e=>t({color:e.target.value}),"aria-label":`Brand color hex`}),(0,x.jsx)(d5,{"aria-label":`Neutrals`,size:`xs`,className:`w-auto`,value:e.tint,onChange:e=>t({tint:e}),options:[{value:`neutral`,label:`Neutral grays`},{value:`tinted`,label:`Tinted with the brand color`}]}),(0,x.jsx)(d5,{"aria-label":`Contrast target`,size:`xs`,className:`w-auto`,value:e.contrast,onChange:e=>t({contrast:e}),options:[{value:`AA`,label:`AA (4.5:1 text)`},{value:`AAA`,label:`AAA (7:1 text)`}]})]}),(0,x.jsx)(o$,{tokens:s.data?.tokens,contrast:s.data?.contrast,error:s.error?.message,loading:s.isFetching})]}),e.themeMode!==`color`&&(0,x.jsxs)(`label`,{className:`mt-1 flex items-center gap-2 text-sm`,children:[(0,x.jsx)(c5,{checked:e.themeCopy,onCheckedChange:e=>t({themeCopy:!!e})}),` Make an editable copy of the theme for this portal`]})]}),e.sourceKind!==`empty`&&(0,x.jsx)(u5,{label:`Brand icon (optional)`,description:`A Lucide icon name for the sidebar, such as briefcase.`,children:(0,x.jsx)(o5,{size:`compact`,mono:!0,className:`w-56`,value:e.icon,onChange:e=>t({icon:e.target.value.toLowerCase()})})})]})]})}function o$({tokens:e,contrast:t,error:n,loading:r}){if(n)return(0,x.jsx)(`p`,{className:`text-xs text-destructive-foreground`,children:JQ(n)[1]});if(!e)return r?(0,x.jsx)(Yb,{size:`sm`,muted:!0}):null;let i=[`primary`,`secondary`,`accent`,`background`,`foreground`,`muted`];return(0,x.jsxs)(`div`,{className:`grid gap-2`,children:[[`light`,`dark`].map(t=>(0,x.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,x.jsx)(`span`,{className:`w-10 text-xs text-muted-foreground`,children:t}),i.filter(n=>e[t]?.[n]).map(n=>(0,x.jsx)(`span`,{title:`${n} ${e[t][n]}`,className:`size-6 rounded-md border border-border/60`,style:{backgroundColor:e[t][n]}},n))]},t)),t&&t.length>0?(0,x.jsx)(`ul`,{className:`text-xs text-warning-foreground`,children:t.map(e=>(0,x.jsxs)(`li`,{children:[`Below target: `,e]},e))}):(0,x.jsx)(`p`,{className:`text-xs text-success-foreground`,children:`Contrast ok`})]})}function s$({d:e,set:t,free:n}){let r=(n,r,i)=>(0,x.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,x.jsx)(c5,{checked:e.extras[n],onCheckedChange:r=>t({extras:{...e.extras,[n]:!!r}})}),r,` `,(0,x.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:i})]});return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(e$,{title:`Folder and extras`,children:`The portal is pulled into this folder; it must be empty or new.`}),(0,x.jsx)(u5,{label:`Folder`,description:n&&!n.empty?(0,x.jsx)(`span`,{className:`text-destructive-foreground`,children:`This folder has files: pick an empty or new one.`}):`The projects folder is set in Settings › Projects.`,children:(0,x.jsx)(o5,{mono:!0,value:e.folder,onChange:e=>t({folder:e.target.value,folderTouched:!0}),"aria-label":`Folder`})}),(0,x.jsxs)(`div`,{className:`mt-5 grid gap-2`,children:[(0,x.jsx)(`span`,{className:`text-xs font-medium`,children:`Also write`}),r(`prettierrc`,`.prettierrc.json`,`React Portal's code style`),r(`gitignore`,`.gitignore`,`.forge/ (the local base copy)`),r(`readme`,`README.md`,`the next commands`),r(`skills`,`Agent skills`,`.claude/skills`),!n?.inRepo&&r(`git`,`git init`,`not inside a repository`)]})]})}function c$({d:e,sets:t,plan:n,error:r,planning:i,reactPortalApp:a,onReplan:o}){return e.start===`pull`?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(e$,{title:`Review`,children:`Read-only on the instance: nothing changes there until your first push.`}),(0,x.jsxs)(`dl`,{className:`grid grid-cols-[8rem_minmax(0,1fr)] gap-x-4 gap-y-2 text-sm`,children:[(0,x.jsx)(`dt`,{className:`text-muted-foreground`,children:`Portal`}),(0,x.jsx)(`dd`,{className:`font-mono`,children:e.portal}),(0,x.jsx)(`dt`,{className:`text-muted-foreground`,children:`App`}),(0,x.jsx)(`dd`,{children:e.app}),(0,x.jsx)(`dt`,{className:`text-muted-foreground`,children:`Pushes go to`}),(0,x.jsxs)(`dd`,{children:[`update set “`,t.find(t=>t.id===e.setId)?.name||e.setId,`”`]}),(0,x.jsx)(`dt`,{className:`text-muted-foreground`,children:`Folder`}),(0,x.jsx)(`dd`,{className:`font-mono text-xs break-all`,children:e.folder}),(0,x.jsx)(`dt`,{className:`text-muted-foreground`,children:`Then`}),(0,x.jsx)(`dd`,{children:Object.entries(e.extras).filter(([,e])=>e).map(([e])=>e).join(`, `)||`nothing else`})]})]}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(e$,{title:`Plan`,children:`The instance's dry run. Create runs exactly this plan.`}),i?(0,x.jsxs)(`span`,{className:`inline-flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,x.jsx)(Yb,{size:`sm`}),` Planning on the instance…`]}):r?(0,x.jsxs)(`div`,{className:`flex gap-2 text-sm`,children:[(0,x.jsx)(Wd,{className:`mt-0.5 size-4 shrink-0 text-destructive-foreground`}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`p`,{className:`text-destructive-foreground`,children:JQ(r)[1]}),(0,x.jsx)(q,{size:`xs`,variant:`outline`,className:`mt-2`,onClick:o,children:`Plan again`})]})]}):n?(0,x.jsxs)(`div`,{className:`grid gap-4 text-sm`,children:[(0,x.jsx)(`p`,{className:`font-medium`,children:n.plan?.summary}),(0,x.jsxs)(`dl`,{className:`grid grid-cols-[8rem_minmax(0,1fr)] gap-x-4 gap-y-1.5`,children:[(0,x.jsx)(`dt`,{className:`text-muted-foreground`,children:`Application`}),(0,x.jsxs)(`dd`,{children:[n.app?.name,` (`,n.app?.scope,`)`]}),(0,x.jsx)(`dt`,{className:`text-muted-foreground`,children:`Update set`}),(0,x.jsxs)(`dd`,{children:[`“`,n.updateSet?.name,`” `,n.updateSet?.isNew&&(0,x.jsx)(kb,{variant:`warning`,children:`new`})]}),(0,x.jsx)(`dt`,{className:`text-muted-foreground`,children:`Creates`}),(0,x.jsx)(`dd`,{children:(n.counts||[]).map(([e,t])=>`${t} ${e}`).join(` · `)||`nothing`}),(0,x.jsx)(`dt`,{className:`text-muted-foreground`,children:`Then`}),(0,x.jsx)(`dd`,{children:(n.local||[]).join(` · `)}),(0,x.jsx)(`dt`,{className:`text-muted-foreground`,children:`planHash`}),(0,x.jsx)(`dd`,{className:`font-mono text-xs`,children:n.plan?.hash})]}),(n.plan?.warnings||[]).length>0&&(0,x.jsx)(`ul`,{className:`grid gap-1 text-xs text-warning-foreground`,children:n.plan.warnings.map(e=>(0,x.jsxs)(`li`,{className:`flex gap-1.5`,children:[(0,x.jsx)(Lm,{className:`size-3.5 shrink-0`}),` `,e]},e))}),a&&!(n.plan?.warnings||[]).some(e=>/React Portal itself owns/.test(e))&&(0,x.jsx)(`p`,{className:`text-xs text-info-foreground`,children:`React Portal owns these records: a React Portal upgrade may change them.`}),(n.contrast||[]).length>0&&(0,x.jsxs)(`p`,{className:`text-xs text-warning-foreground`,children:[`Theme contrast: `,n.contrast.length,` pair(s) below target.`]}),(0,x.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`The portal is created as a draft. Publish it in Studio when it is ready; Forge never publishes.`})]}):null]})}function l$({job:e,onRetry:t,retrying:n,onBack:r}){let i=e?.state||`running`;return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(e$,{title:i===`done`?`Done`:i===`running`?`Working…`:i===`pull_failed`?`The draft exists; the pull failed`:`Stopped`}),(0,x.jsxs)(`ol`,{className:`grid gap-1.5 font-mono text-xs`,children:[(e?.log||[]).map((e,t,n)=>{let r=t===n.length-1&&(i===`failed`||i===`pull_failed`);return(0,x.jsxs)(`li`,{className:G(`flex gap-2`,r&&`text-destructive-foreground`),children:[r?(0,x.jsx)(Wd,{className:`mt-0.5 size-3 shrink-0`}):(0,x.jsx)(Md,{className:`mt-0.5 size-3 shrink-0 text-success-foreground`}),(0,x.jsx)(`span`,{className:`break-all`,children:e})]},t)}),i===`running`&&(0,x.jsxs)(`li`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,x.jsx)(Yb,{size:`xs`}),` working`]})]}),i===`done`&&(0,x.jsx)(`p`,{className:`mt-4 text-sm text-success-foreground`,children:`Opening the project…`}),i===`pull_failed`&&(0,x.jsxs)(`div`,{className:`mt-4 flex items-center gap-2`,children:[(0,x.jsx)(q,{size:`sm`,disabled:n,onClick:t,children:`Retry pull`}),e?.result?.studioUrl&&(0,x.jsx)(`a`,{className:`text-xs underline`,href:e.result.studioUrl,target:`_blank`,rel:`noreferrer noopener`,children:`Open the draft in Studio`})]}),i===`failed`&&(0,x.jsxs)(`div`,{className:`mt-4`,children:[(0,x.jsx)(`p`,{className:`text-sm text-destructive-foreground`,children:JQ(e?.error)[1]}),(0,x.jsx)(q,{size:`sm`,variant:`outline`,className:`mt-2`,onClick:r,children:`Back to the plan`})]})]})}var u$=[[`general`,`General`],[`appearance`,`Appearance`],[`providers`,`Providers and models`],[`usage`,`Usage`],[`instances`,`Instances`],[`projects`,`Projects`],[`doctor`,`Doctor`],[`skills`,`Skills`],[`keybindings`,`Keybindings`],[`diffs`,`Diffs`],[`about`,`About and updates`],[`licenses`,`Open-source licenses`]];function d$(){let[e,t]=b.useState(!1);return b.useEffect(()=>{let e=e=>e.detail===`commandPalette.toggle`&&t(e=>!e);return window.addEventListener(`forge:command`,e),()=>window.removeEventListener(`forge:command`,e)},[]),(0,x.jsx)(U6,{open:e,onOpenChange:t,children:e&&(0,x.jsx)(f$,{onClose:()=>t(!1)})})}function f$({onClose:e}){let t=Au(),n=Yi(),r=Gu(),i=i8(),a=Fa({select:e=>e.location.pathname}),o=/^\/p\/([^/]+)/.exec(a)?.[1],s=U(t.projects.list.queryOptions()),c=U(t.chats.recent.queryOptions({limit:60})),l=U(t.settings.get.queryOptions()).data?.keybindings||[],[u,d]=b.useState(``),[f,p]=b.useState(0),m=b.useRef(null),h=t=>()=>{e(),t()},g=[...o?[{id:`chat.new`,group:`Actions`,title:`New chat`,icon:xm,command:`chat.new`,run:h(()=>n({to:`/p/$projectId`,params:{projectId:o}}))},{id:`push`,group:`Actions`,title:`Plan a push…`,detail:`dry run, then review`,icon:zm,run:h(()=>Wu({pushOpen:!0}))}]:[],{id:`project.new`,group:`Actions`,title:`New project…`,detail:`new, pull or copy a portal`,icon:Cf,run:h(()=>Wu({newProject:`choose`}))},{id:`panel`,group:`Actions`,title:r.panelOpen?`Hide the right panel`:`Show the right panel`,icon:jp,command:`rightPanel.toggle`,run:h(()=>Wu({panelOpen:!r.panelOpen}))},{id:`terminal`,group:`Actions`,title:r.drawerOpen?`Hide the terminal`:`Show the terminal`,icon:Dp,command:`terminal.toggle`,run:h(()=>Wu({drawerOpen:!r.drawerOpen}))},{id:`theme`,group:`Actions`,title:document.documentElement.classList.contains(`dark`)?`Switch to light theme`:`Switch to dark theme`,icon:document.documentElement.classList.contains(`dark`)?km:_p,run:h(()=>Wu({theme:document.documentElement.classList.contains(`dark`)?`light`:`dark`}))},{id:`usage`,group:`Actions`,title:`Usage`,icon:Ad,command:`usage.open`,run:h(()=>i(`usage`))},{id:`doctor`,group:`Actions`,title:`Run doctor`,icon:Dm,run:h(()=>i(`doctor`))},...(s.data||[]).map(e=>({id:`p:${e.id}`,group:`Projects`,title:e.name,detail:e.path,icon:Df,run:h(()=>n({to:`/p/$projectId`,params:{projectId:e.id}}))})),...(c.data||[]).slice(0,30).map(e=>({id:`c:${e.id}`,group:`Chats`,title:e.title,detail:e.projectName,icon:dp,run:h(()=>n({to:`/p/$projectId/c/$chatId`,params:{projectId:e.projectId,chatId:e.id}}))})),...u$.map(([e,t])=>({id:`s:${e}`,group:`Settings`,title:t,detail:`Settings`,icon:dm,command:e===`general`?`settings.open`:void 0,run:h(()=>i(e))}))],_=u.toLowerCase().split(/\s+/).filter(Boolean),v=g.filter(e=>_.every(t=>`${e.title} ${e.detail||``} ${e.group}`.toLowerCase().includes(t))),y=u?v:v.filter(e=>e.group!==`Settings`).slice(0,14),S=Math.min(f,Math.max(0,y.length-1));b.useEffect(()=>p(0),[u]),b.useEffect(()=>{m.current?.querySelector(`[data-highlighted]`)?.scrollIntoView({block:`nearest`})},[S]);let C=e=>{e.key===`ArrowDown`?(e.preventDefault(),p((S+1)%Math.max(1,y.length))):e.key===`ArrowUp`?(e.preventDefault(),p((S-1+y.length)%Math.max(1,y.length))):e.key===`Enter`&&(e.preventDefault(),y[S]?.run())},w=e=>{let t=e&&ju.find(t=>t.id===e);return t?Iu(Mu(t,l)):``},T=``;return(0,x.jsxs)(I6,{children:[(0,x.jsx)(D6,{className:`fixed inset-0 z-50 bg-background/60 backdrop-blur-[4px] transition-opacity duration-200 data-[ending-style]:opacity-0 data-[starting-style]:opacity-0`}),(0,x.jsx)(`div`,{className:`pointer-events-none fixed inset-0 z-50 flex flex-col items-center px-4 pt-[max(1rem,4vh)] sm:pt-[10vh]`,children:(0,x.jsxs)(F6,{"aria-label":`Command palette`,className:`glass pointer-events-auto flex max-h-105 w-full max-w-xl flex-col overflow-hidden rounded-2xl text-foreground shadow-[0_24px_64px_-24px_rgb(0_0_0/65%)] transition-[opacity,scale] duration-150 data-[ending-style]:scale-98 data-[ending-style]:opacity-0 data-[starting-style]:scale-98 data-[starting-style]:opacity-0`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/60 px-4 py-2.5`,children:[(0,x.jsx)(am,{className:`size-4 shrink-0 text-icon-muted`}),(0,x.jsx)(`input`,{autoFocus:!0,value:u,onChange:e=>d(e.target.value),onKeyDown:C,placeholder:`Search projects, chats, actions and settings`,"aria-label":`Search commands`,className:`h-7 min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground`})]}),(0,x.jsxs)(`div`,{ref:m,role:`listbox`,className:`min-h-0 flex-1 overflow-y-auto p-2`,children:[y.length===0&&(0,x.jsx)(`p`,{className:`py-10 text-center text-sm text-muted-foreground`,children:`No matching commands`}),y.map((e,t)=>{let n=e.group!==T;return T=e.group,(0,x.jsxs)(b.Fragment,{children:[n&&(0,x.jsx)(`div`,{className:G(`px-2 pb-1 text-xs font-medium text-muted-foreground`,t>0&&`pt-2.5`),children:e.group}),(0,x.jsxs)(`div`,{role:`option`,"aria-selected":t===S,"data-highlighted":t===S||void 0,onMouseMove:()=>p(t),onClick:e.run,className:G(`flex min-h-7 cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-sm select-none`,t===S&&`bg-foreground/[0.09]`),children:[(0,x.jsx)(e.icon,{className:`size-4 shrink-0 text-icon-muted`}),(0,x.jsx)(`span`,{className:`truncate`,children:e.title}),e.detail&&(0,x.jsx)(`span`,{className:`max-w-[45%] shrink-0 truncate text-xs text-muted-foreground/70`,children:e.detail}),w(e.command)&&(0,x.jsx)(`kbd`,{className:`ms-auto font-sans text-xs font-medium tracking-widest text-secondary-label`,children:w(e.command)})]})]},e.id)})]}),(0,x.jsxs)(`div`,{className:`flex items-center gap-3 border-t border-border/60 px-4 py-2 text-xs text-muted-foreground`,children:[(0,x.jsx)(`span`,{children:`↑↓ move`}),(0,x.jsx)(`span`,{children:`↵ run`}),(0,x.jsx)(`span`,{children:`Esc close`})]})]})})]})}var p$=new Ue({defaultOptions:{queries:{staleTime:5e3,refetchOnWindowFocus:!1}}});function m$(e){let t=Gu(),n=Yi(),r=mi(),i=i8(),a=Fa({select:e=>e.location.pathname}),o=b.useRef({ui:t,overrides:e,path:a});o.current={ui:t,overrides:e,path:a},b.useEffect(()=>{let e=e=>{let{ui:t,path:a}=o.current,s=/^\/p\/([^/]+)/.exec(a)?.[1];switch(e){case`sidebar.toggle`:return Wu({sidebarOpen:!t.sidebarOpen});case`rightPanel.toggle`:return Wu({panelOpen:!t.panelOpen});case`terminal.toggle`:return Wu({drawerOpen:!t.drawerOpen});case`preview.toggle`:return Wu(t.panelOpen&&t.panelTab===`preview`?{panelOpen:!1}:{panelOpen:!0,panelTab:`preview`});case`diff.toggle`:return Wu(t.panelOpen&&t.panelTab===`diff`?{panelOpen:!1}:{panelOpen:!0,panelTab:`diff`});case`settings.open`:return i(`general`);case`usage.open`:return i(`usage`);case`navigation.back`:return r.history.back();case`navigation.forward`:return r.history.forward();case`chat.new`:s&&n({to:`/p/$projectId`,params:{projectId:s}});return;default:window.dispatchEvent(new CustomEvent(`forge:command`,{detail:e}))}},t=t=>{let n=t.target;if(n?.closest?.(`[data-keybinding-capture]`))return;let r=Pu(t);if(!r)return;let i=!!n&&(/INPUT|TEXTAREA|SELECT/.test(n.tagName)||n.isContentEditable),a=ju.find(e=>Mu(e,o.current.overrides)===r);!a||i&&!a.inFields||(t.preventDefault(),e(a.id))};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[n,r,i])}function h$(){let e=Au(),t=Yi(),n=Fa({select:e=>e.location.pathname}),r=U(e.wizard.context.queryOptions()),i=b.useRef(!1);b.useEffect(()=>{!i.current&&r.data?.firstRun&&n!==`/welcome`&&(i.current=!0,t({to:`/welcome`}))},[r.data?.firstRun,n,t])}function g$(){let e=Gu();Ru();let t=U(Au().settings.get.queryOptions()),n=Ji({strict:!1}),r=i8(),i=Fa({select:e=>e.location.pathname})===`/welcome`;m$(t.data?.keybindings||[]),h$();let a=t.data?.diffs?.colors||`red-green`;return b.useEffect(()=>{document.documentElement.dataset.diffColors=a},[a]),(0,x.jsxs)(`div`,{className:`flex h-full overflow-hidden`,children:[e.sidebarOpen&&!i&&(0,x.jsx)(u8,{}),(0,x.jsx)(`main`,{className:`flex min-w-0 flex-1 bg-background`,children:(0,x.jsx)(Ta,{})}),(0,x.jsx)(ZQ,{}),(0,x.jsx)(d$,{}),n.settings===`usage`?(0,x.jsx)(HQ,{onClose:()=>r(null)}):n.settings&&(0,x.jsx)(NQ,{section:n.settings,onSection:r,onClose:()=>r(null)})]})}var _$=ha({component:g$,validateSearch:e=>typeof e.settings==`string`?{settings:e.settings}:{}}),v$=pa({getParentRoute:()=>_$,path:`/`,component:x8}),y$=pa({getParentRoute:()=>_$,path:`/p/$projectId`,component:function(){let{projectId:e}=qi({from:`/p/$projectId`});return(0,x.jsx)(rQ,{projectId:e})}}),b$=pa({getParentRoute:()=>_$,path:`/p/$projectId/c/$chatId`,component:function(){let{projectId:e,chatId:t}=qi({from:`/p/$projectId/c/$chatId`});return(0,x.jsx)(rQ,{projectId:e,chatId:t})}}),x$=pa({getParentRoute:()=>_$,path:`/welcome`,component:uC}),S$=pa({getParentRoute:()=>_$,path:`/settings/$section`,beforeLoad:({params:e})=>{throw sn({to:`/`,search:{settings:e.section}})}}),C$=ja({routeTree:_$.addChildren([v$,x$,y$,b$,S$])});Ku(localStorage.getItem(`forge.theme`)||`system`),Ha(),(0,Ia.createRoot)(document.getElementById(`root`)).render((0,x.jsx)(b.StrictMode,{children:(0,x.jsx)(w,{client:p$,children:(0,x.jsx)(ku,{trpcClient:Ou,queryClient:p$,children:(0,x.jsx)(wb,{delay:400,children:(0,x.jsx)(Pa,{router:C$})})})})}));export{nR as $,Ye as $t,$q as A,lp as At,uJ as B,Xu as Bt,SJ as C,A4 as Ct,_J as D,Fm as Dt,pJ as E,q as Et,aJ as F,Qd as Ft,Xq as G,G as Gt,Kq as H,Ju as Ht,sJ as I,Id as It,tJ as J,tt as Jt,Yq as K,U as Kt,iJ as L,Md as Lt,oJ as M,hf as Mt,lJ as N,sf as Nt,vJ as O,Nm as Ot,eJ as P,ef as Pt,tR as Q,Ze as Qt,rJ as R,gd as Rt,NJ as S,b3 as St,yJ as T,i1 as Tt,Zq as U,Gu as Ut,Jq as V,Wu as Vt,Qq as W,Au as Wt,bW as X,Xe as Xt,nJ as Y,et as Yt,rR as Z,Qe as Zt,$J as _,Yb as _t,TZ as a,B as an,L9 as at,HJ as b,G3 as bt,rZ as c,y as cn,V9 as ct,nZ as d,o as dn,n9 as dt,Ke as en,QL as et,sZ as f,s as fn,Z7 as ft,XJ as g,s5 as gt,oY as h,x5 as ht,EZ as i,k as in,W9 as it,cJ as j,Tf as jt,hJ as k,Yp as kt,iZ as l,h as ln,r9 as lt,uZ as m,J7 as mt,CZ as n,_e as nn,hL as nt,DZ as o,V as on,R9 as ot,aZ as p,l as pn,K7 as pt,qq as q,$e as qt,wZ as r,pe as rn,G9 as rt,bZ as s,C as sn,z9 as st,OZ as t,je as tn,xL as tt,oZ as u,d as un,u9 as ut,qJ as v,Tb as vt,bJ as w,D4 as wt,VJ as x,I3 as xt,GJ as y,Y3 as yt,Gq as z,K as zt};
|