xedoc-cli 0.1.13 → 0.1.15

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.
Files changed (59) hide show
  1. package/README.md +2 -0
  2. package/build/client/assets/api-Bq1vju8d.js +1 -0
  3. package/build/client/assets/api.chats._chatId.messages-lfOVkPe8.js +0 -0
  4. package/build/client/assets/api.chats._chatId.queued._queueId.steer-Dob8lziy.js +0 -0
  5. package/build/client/assets/api.chats._chatId.server-requests._requestId.respond-CtGOWFXz.js +0 -0
  6. package/build/client/assets/api.workspaces.directories-_nGjLu4v.js +0 -0
  7. package/build/client/assets/app-layout-DcqaA3vs.js +1 -0
  8. package/build/client/assets/chat-DssIBrTY.js +1 -0
  9. package/build/client/assets/composer-controls-C-i2mGP0.js +2 -0
  10. package/build/client/assets/connect-BpTBAcLO.js +1 -0
  11. package/build/client/assets/document-title-CVCGo83t.js +1 -0
  12. package/build/client/assets/{entry.client-CYz-BGHO.js → entry.client-D7Yyv89q.js} +1 -1
  13. package/build/client/assets/folder-open-BGVSSdnS.js +1 -0
  14. package/build/client/assets/{ghostty-web-Bf0rFR1u.js → ghostty-web-C4aYPktj.js} +1 -1
  15. package/build/client/assets/header-menu-BZ8Qg4Vi.js +1 -0
  16. package/build/client/assets/home-bVxFnHUg.js +1 -0
  17. package/build/client/assets/input-DmJ6N0Sh.js +1 -0
  18. package/build/client/assets/label-PRFnRUMj.js +1 -0
  19. package/build/client/assets/manifest-62799e7e.js +1 -0
  20. package/build/client/assets/popover-DTbjnDSA.js +1 -0
  21. package/build/client/assets/{react-dom-CRV9fQsS.js → react-dom-Cmetac4J.js} +1 -1
  22. package/build/client/assets/root-BU4hb_em.js +1 -0
  23. package/build/client/assets/root-C6Tru0U5.css +2 -0
  24. package/build/client/assets/session-provider-Bxa1AL3n.js +1 -0
  25. package/build/client/assets/triangle-alert-CX-fS3B2.js +1 -0
  26. package/build/client/assets/usePositioner-DoPOYGgd.js +1 -0
  27. package/build/server/index.js +1 -1
  28. package/package.json +1 -2
  29. package/build/client/assets/app-layout-CN81j437.js +0 -1
  30. package/build/client/assets/app-shell-bZjdLund.js +0 -2
  31. package/build/client/assets/chat-B7RLVuco.js +0 -1
  32. package/build/client/assets/connect-CHSWDRRR.js +0 -1
  33. package/build/client/assets/document-title-nRpNLh53.js +0 -1
  34. package/build/client/assets/home-DtJ52lyi.js +0 -1
  35. package/build/client/assets/label-DBag4yRW.js +0 -1
  36. package/build/client/assets/manifest-3f1dd8c7.js +0 -1
  37. package/build/client/assets/root-BlJIezBz.js +0 -1
  38. package/build/client/assets/root-C6ZJNFQd.css +0 -2
  39. package/build/client/assets/session-provider-DZhkiIfn.js +0 -1
  40. /package/build/client/assets/{__vite-browser-external-2447137e-BK6zEOTY.js → __vite-browser-external-2447137e-BGy5hUdF.js} +0 -0
  41. /package/build/client/assets/{api.accounts._accountId-BixDYyx8.js → api.accounts._accountId-DbJR7wIK.js} +0 -0
  42. /package/build/client/assets/{api.accounts._accountId.authenticate-Cgza4mTm.js → api.accounts._accountId.authenticate-zJk1OPH-.js} +0 -0
  43. /package/build/client/assets/{api.accounts._accountId.authenticate.callback-jKtCcEgm.js → api.accounts._accountId.authenticate.callback-C3q2njBk.js} +0 -0
  44. /package/build/client/assets/{api.accounts._accountId.models-C3bayFCR.js → api.accounts._accountId.local-active-Lj56Skb8.js} +0 -0
  45. /package/build/client/assets/{api.accounts._accountId.personalization-Bd_x2nBr.js → api.accounts._accountId.models-BbNPhoBD.js} +0 -0
  46. /package/build/client/assets/{api.accounts._accountId.rate-limits-BrKCZxhm.js → api.accounts._accountId.personalization-DQAPMa-w.js} +0 -0
  47. /package/build/client/assets/{api.accounts._accountId.runtime-settings-6XNKTx--.js → api.accounts._accountId.rate-limits-C6Rs4m-7.js} +0 -0
  48. /package/build/client/assets/{api.accounts.login-callback-port-TLptuOkA.js → api.accounts._accountId.runtime-settings-DTZTQ21Z.js} +0 -0
  49. /package/build/client/assets/{api.chats-BUn9r-0x.js → api.accounts.import-local-active-D9cdi-v4.js} +0 -0
  50. /package/build/client/assets/{api.chats._chatId-BTgyeBLZ.js → api.accounts.login-callback-port-DQNbFsFb.js} +0 -0
  51. /package/build/client/assets/{api.chats._chatId.context-BgV2drn2.js → api.accounts.personalization-DH1AzvNF.js} +0 -0
  52. /package/build/client/assets/{api.chats._chatId.files-DGXv9z2x.js → api.chats-s886wBuI.js} +0 -0
  53. /package/build/client/assets/{api.chats._chatId.git._operation-DggKbqHL.js → api.chats._chatId-BdQ0D5mb.js} +0 -0
  54. /package/build/client/assets/{api.chats._chatId.interrupt-DkImed4M.js → api.chats._chatId.context-h_lwoA2q.js} +0 -0
  55. /package/build/client/assets/{api.chats._chatId.messages-kk2to-gt.js → api.chats._chatId.files-Cx0zOZBK.js} +0 -0
  56. /package/build/client/assets/{api.chats._chatId.server-requests._requestId.respond-BCMnFuvx.js → api.chats._chatId.git._operation-DogyaTuw.js} +0 -0
  57. /package/build/client/assets/{api.workspaces.directories-Bz0K1WZo.js → api.chats._chatId.interrupt-DFwcHue_.js} +0 -0
  58. /package/build/client/assets/{app-shell-DdKuH37F.css → header-menu-DdKuH37F.css} +0 -0
  59. /package/build/client/assets/{jsx-runtime-DhlB8LRe.js → jsx-runtime-BD6xVgfN.js} +0 -0
package/README.md CHANGED
@@ -112,6 +112,8 @@ directory, for example `/home/ubuntu`.
112
112
  - `GET /api/accounts/:accountId`
113
113
  - `PATCH /api/accounts/:accountId`
114
114
  - `DELETE /api/accounts/:accountId`
115
+ - `POST /api/accounts/import-local-active`
116
+ - `POST /api/accounts/:accountId/local-active`
115
117
  - `POST /api/accounts/:accountId/authenticate` with optional `{ "mode": "browser" | "device" }`
116
118
  - `POST /api/accounts/:accountId/authenticate/callback`
117
119
  - `GET /api/chats`
@@ -0,0 +1 @@
1
+ import{F as e,R as t}from"./jsx-runtime-BD6xVgfN.js";var r=t(e(),1),o=(...e)=>e.filter((e,t,r)=>Boolean(e)&&""!==e.trim()&&r.indexOf(e)===t).join(" ").trim(),n=e=>{const t=(e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,r)=>r?r.toUpperCase():t.toLowerCase()))(e);return t.charAt(0).toUpperCase()+t.slice(1)},s={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},a=e=>{for(const t in e)if(t.startsWith("aria-")||"role"===t||"title"===t)return!0;return!1},i=(0,r.createContext)({}),l=(0,r.forwardRef)(({color:e,size:t,strokeWidth:n,absoluteStrokeWidth:l,className:c="",children:d,iconNode:u,...f},p)=>{const{size:m=24,strokeWidth:b=2,absoluteStrokeWidth:h=!1,color:g="currentColor",className:k=""}=(0,r.useContext)(i)??{},y=l??h?24*Number(n??b)/Number(t??m):n??b;return(0,r.createElement)("svg",{ref:p,...s,width:t??m??s.width,height:t??m??s.height,stroke:e??g,strokeWidth:y,className:o("lucide",k,c),...!d&&!a(f)&&{"aria-hidden":"true"},...f},[...u.map(([e,t])=>(0,r.createElement)(e,t)),...Array.isArray(d)?d:[d]])}),c=(e,t)=>{const s=(0,r.forwardRef)(({className:s,...a},i)=>{return(0,r.createElement)(l,{ref:i,iconNode:t,className:o(`lucide-${c=n(e),c.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`,`lucide-${e}`,s),...a});var c});return s.displayName=n(e),s},d=c("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]),u={};function f(e,t){const o=r.useRef(u);return o.current===u&&(o.current=e(t)),o}var p="undefined"!=typeof document?r.useLayoutEffect:()=>{};var m,b,h=(m="https://base-ui.com/production-error",b="Base UI",function(e,...t){const r=new URL(m);return r.searchParams.set("code",e.toString()),t.forEach(e=>r.searchParams.append("args[]",e)),`${b} error #${e}; visit ${r} for the full message.`});function g(){}var k=Object.freeze([]),y=Object.freeze({}),v="none",w="trigger-press",x="trigger-hover",z="trigger-focus",$="outside-press",C="item-press",U="close-press",E="focus-out",j="escape-key",N="list-navigation",S="cancel-open",P="sibling-open",A="disabled",I="imperative-action";function L(e,t,r,o){let n=!1,s=!1;const a=o??y;return{reason:e,event:t??new Event("base-ui"),cancel(){n=!0},allowPropagation(){s=!0},get isCanceled(){return n},get isPropagationAllowed(){return s},trigger:r,...a}}function T(){return"undefined"!=typeof window}function G(e){return R(e)?(e.nodeName||"").toLowerCase():"#document"}function O(e){var t;return(null==e||null==(t=e.ownerDocument)?void 0:t.defaultView)||window}function M(e){var t;return null==(t=(R(e)?e.ownerDocument:e.document)||window.document)?void 0:t.documentElement}function R(e){return!!T()&&(e instanceof Node||e instanceof O(e).Node)}function W(e){return!!T()&&(e instanceof Element||e instanceof O(e).Element)}function H(e){return!!T()&&(e instanceof HTMLElement||e instanceof O(e).HTMLElement)}function q(e){return!(!T()||"undefined"==typeof ShadowRoot)&&(e instanceof ShadowRoot||e instanceof O(e).ShadowRoot)}function D(e){const{overflow:t,overflowX:r,overflowY:o,display:n}=ee(e);return/auto|scroll|overlay|hidden|clip/.test(t+o+r)&&"inline"!==n&&"contents"!==n}function B(e){return/^(table|td|th)$/.test(G(e))}function F(e){try{if(e.matches(":popover-open"))return!0}catch(t){}try{return e.matches(":modal")}catch(t){return!1}}var V,_=/transform|translate|scale|rotate|perspective|filter/,J=/paint|layout|strict|content/,X=e=>!!e&&"none"!==e;function Y(e){const t=W(e)?ee(e):e;return X(t.transform)||X(t.translate)||X(t.scale)||X(t.rotate)||X(t.perspective)||!K()&&(X(t.backdropFilter)||X(t.filter))||_.test(t.willChange||"")||J.test(t.contain||"")}function Z(e){let t=re(e);for(;H(t)&&!Q(t);){if(Y(t))return t;if(F(t))return null;t=re(t)}return null}function K(){return null==V&&(V="undefined"!=typeof CSS&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),V}function Q(e){return/^(html|body|#document)$/.test(G(e))}function ee(e){return O(e).getComputedStyle(e)}function te(e){return W(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function re(e){if("html"===G(e))return e;const t=e.assignedSlot||e.parentNode||q(e)&&e.host||M(e);return q(t)?t.host:t}function oe(e){const t=re(e);return Q(t)?e.ownerDocument?e.ownerDocument.body:e.body:H(t)&&D(t)?t:oe(t)}function ne(e,t,r){var o;void 0===t&&(t=[]),void 0===r&&(r=!0);const n=oe(e),s=n===(null==(o=e.ownerDocument)?void 0:o.body),a=O(n);if(s){const e=se(a);return t.concat(a,a.visualViewport||[],D(n)?n:[],e&&r?ne(e):[])}return t.concat(n,ne(n,[],r))}function se(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function ae(e,t,r,o){const n=f(ie).current;return function(e,t,r,o,n){return e.refs[0]!==t||e.refs[1]!==r||e.refs[2]!==o||e.refs[3]!==n}(n,e,t,r,o)&&le(n,[e,t,r,o]),n.callback}function ie(){return{callback:null,cleanup:null,refs:[]}}function le(e,t){e.refs=t,t.every(e=>null==e)?e.callback=null:e.callback=r=>{if(e.cleanup&&(e.cleanup(),e.cleanup=null),null!=r){const o=Array(t.length).fill(null);for(let e=0;e<t.length;e+=1){const n=t[e];if(null!=n)switch(typeof n){case"function":{const t=n(r);"function"==typeof t&&(o[e]=t);break}case"object":n.current=r}}e.cleanup=()=>{for(let e=0;e<t.length;e+=1){const r=t[e];if(null!=r)switch(typeof r){case"function":{const t=o[e];"function"==typeof t?t():r(null);break}case"object":r.current=null}}}}}}var ce=r[`useInsertionEffect${Math.random().toFixed(1)}`.slice(0,-3)],de=ce&&ce!==r.useLayoutEffect?ce:e=>e();function ue(e){const t=f(fe).current;return t.next=e,de(t.effect),t.trampoline}function fe(){const e={next:void 0,callback:pe,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function pe(){}function me(e){return e?.ownerDocument||document}function be(e){let t=e.activeElement;for(;null!=t?.shadowRoot?.activeElement;)t=t.shadowRoot.activeElement;return t}function he(e,t){if(!e||!t)return!1;const r=t.getRootNode?.();if(e.contains(t))return!0;if(r&&q(r)){let r=t;for(;r;){if(e===r)return!0;r=r.parentNode||r.host}}return!1}function ge(e){return"composedPath"in e?e.composedPath()[0]:e.target}var ke={...r},ye=0;var ve=ke.useId;function we(e,t){if(void 0!==ve){const r=ve();return e??(t?`${t}-${r}`:r)}return function(e,t="mui"){const[o,n]=r.useState(e),s=e||o;return r.useEffect(()=>{null==o&&n(`${t}-${ye+=1}`)},[o,t]),s}(e,t)}var xe=parseInt("19.2.6",10);function ze(e){return xe>=e}function $e(e){if(!r.isValidElement(e))return null;const t=e,o=t.props;return(ze(19)?o?.ref:t.ref)??null}function Ce(e,t){return e&&!t?e:!e&&t?t:e||t?{...e,...t}:void 0}var Ue={};function Ee(e,t,r,o,n){if(!(r||o||n||e))return je(t);let s=je(e);return t&&(s=Ne(s,t)),r&&(s=Ne(s,r)),o&&(s=Ne(s,o)),n&&(s=Ne(s,n)),s}function je(e){return Pe(e)?{...Ae(e,Ue)}:function(e){const t={...e};for(const r in t){const e=t[r];Se(r,e)&&(t[r]=Le(e))}return t}(e)}function Ne(e,t){return Pe(t)?Ae(t,e):function(e,t){if(!t)return e;for(const r in t){const o=t[r];switch(r){case"style":e[r]=Ce(e.style,o);break;case"className":e[r]=Ge(e.className,o);break;default:Se(r,o)?e[r]=Ie(e[r],o):e[r]=o}}return e}(e,t)}function Se(e,t){const r=e.charCodeAt(0),o=e.charCodeAt(1),n=e.charCodeAt(2);return 111===r&&110===o&&n>=65&&n<=90&&("function"==typeof t||void 0===t)}function Pe(e){return"function"==typeof e}function Ae(e,t){return Pe(e)?e(t):e??Ue}function Ie(e,t){return t?e?(...r)=>{const o=r[0];if(Oe(o)){const n=o;Te(n);const s=t(...r);return n.baseUIHandlerPrevented||e?.(...r),s}const n=t(...r);return e?.(...r),n}:Le(t):e}function Le(e){return e?(...t)=>{const r=t[0];return Oe(r)&&Te(r),e(...t)}:e}function Te(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function Ge(e,t){return t?e?t+" "+e:t:e}function Oe(e){return null!=e&&"object"==typeof e&&"nativeEvent"in e}function Me(e,t,o={}){const n=t.render,s=function(e,t={}){const{className:r,style:o,render:n}=e,{state:s=y,ref:a,props:i,stateAttributesMapping:l,enabled:c=!0}=t,d=c?function(e,t){return"function"==typeof e?e(t):e}(r,s):void 0,u=c?function(e,t){return"function"==typeof e?e(t):e}(o,s):void 0,p=c?function(e,t){const r={};for(const o in e){const n=e[o];if(t?.hasOwnProperty(o)){const e=t[o](n);null!=e&&Object.assign(r,e);continue}!0===n?r[`data-${o.toLowerCase()}`]="":n&&(r[`data-${o.toLowerCase()}`]=n.toString())}return r}(s,l):y,m=c&&i?function(e){return Array.isArray(e)?function(e){if(0===e.length)return Ue;if(1===e.length)return je(e[0]);let t=je(e[0]);for(let r=1;r<e.length;r+=1)t=Ne(t,e[r]);return t}(e):Ee(void 0,e)}(i):void 0,b=c?Ce(p,m)??{}:y;"undefined"!=typeof document&&(c?Array.isArray(a)?b.ref=function(e){const t=f(ie).current;return function(e,t){return e.refs.length!==t.length||e.refs.some((e,r)=>e!==t[r])}(t,e)&&le(t,e),t.callback}([b.ref,$e(n),...a]):b.ref=ae(b.ref,$e(n),a):ae(null,null));if(!c)return y;void 0!==d&&(b.className=Ge(b.className,d));void 0!==u&&(b.style=Ce(b.style,u));return b}(t,o);return!1===o.enabled?null:function(e,t,o,n){if(t){if("function"==typeof t)return t(o,n);const e=Ee(o,t.props);e.ref=o.ref;let s=t;return s?.$$typeof===Re&&(s=r.Children.toArray(t)[0]),r.cloneElement(s,e)}if(e&&"string"==typeof e)return function(e,t){return"button"===e?(0,r.createElement)("button",{type:"button",...t,key:t.key}):"img"===e?(0,r.createElement)("img",{alt:"",...t,key:t.key}):r.createElement(e,t)}(e,o);throw new Error(h(8))}(e,n,s,o.state??y)}var Re=Symbol.for("react.lazy");function We(e){return we(e,"base-ui")}function He(e){var t,r,o="";if("string"==typeof e||"number"==typeof e)o+=e;else if("object"==typeof e)if(Array.isArray(e)){var n=e.length;for(t=0;t<n;t++)e[t]&&(r=He(e[t]))&&(o&&(o+=" "),o+=r)}else for(r in e)e[r]&&(o&&(o+=" "),o+=r);return o}function qe(){for(var e,t,r=0,o="",n=arguments.length;r<n;r++)(e=arguments[r])&&(t=He(e))&&(o&&(o+=" "),o+=t);return o}var De=(e=new Map,t=null,r)=>({nextPart:e,validators:t,classGroupId:r}),Be="-",Fe=[],Ve=e=>{const t=Xe(e),{conflictingClassGroups:r,conflictingClassGroupModifiers:o}=e;return{getClassGroupId:e=>{if(e.startsWith("[")&&e.endsWith("]"))return Je(e);const r=e.split(Be);return _e(r,""===r[0]&&r.length>1?1:0,t)},getConflictingClassGroupIds:(e,t)=>{if(t){const t=o[e],n=r[e];return t?n?((e,t)=>{const r=new Array(e.length+t.length);for(let o=0;o<e.length;o++)r[o]=e[o];for(let o=0;o<t.length;o++)r[e.length+o]=t[o];return r})(n,t):t:n||Fe}return r[e]||Fe}}},_e=(e,t,r)=>{if(e.length-t===0)return r.classGroupId;const o=e[t],n=r.nextPart.get(o);if(n){const r=_e(e,t+1,n);if(r)return r}const s=r.validators;if(null===s)return;const a=0===t?e.join(Be):e.slice(t).join(Be),i=s.length;for(let l=0;l<i;l++){const e=s[l];if(e.validator(a))return e.classGroupId}},Je=e=>-1===e.slice(1,-1).indexOf(":")?void 0:(()=>{const t=e.slice(1,-1),r=t.indexOf(":"),o=t.slice(0,r);return o?"arbitrary.."+o:void 0})(),Xe=e=>{const{theme:t,classGroups:r}=e;return Ye(r,t)},Ye=(e,t)=>{const r=De();for(const o in e){const n=e[o];Ze(n,r,o,t)}return r},Ze=(e,t,r,o)=>{const n=e.length;for(let s=0;s<n;s++){const n=e[s];Ke(n,t,r,o)}},Ke=(e,t,r,o)=>{"string"!=typeof e?"function"!=typeof e?tt(e,t,r,o):et(e,t,r,o):Qe(e,t,r)},Qe=(e,t,r)=>{(""===e?t:rt(t,e)).classGroupId=r},et=(e,t,r,o)=>{ot(e)?Ze(e(o),t,r,o):(null===t.validators&&(t.validators=[]),t.validators.push(((e,t)=>({classGroupId:e,validator:t}))(r,e)))},tt=(e,t,r,o)=>{const n=Object.entries(e),s=n.length;for(let a=0;a<s;a++){const[e,s]=n[a];Ze(s,rt(t,e),r,o)}},rt=(e,t)=>{let r=e;const o=t.split(Be),n=o.length;for(let s=0;s<n;s++){const e=o[s];let t=r.nextPart.get(e);t||(t=De(),r.nextPart.set(e,t)),r=t}return r},ot=e=>"isThemeGetter"in e&&!0===e.isThemeGetter,nt=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,r=Object.create(null),o=Object.create(null);const n=(n,s)=>{r[n]=s,t++,t>e&&(t=0,o=r,r=Object.create(null))};return{get(e){let t=r[e];return void 0!==t?t:void 0!==(t=o[e])?(n(e,t),t):void 0},set(e,t){e in r?r[e]=t:n(e,t)}}},st=[],at=(e,t,r,o,n)=>({modifiers:e,hasImportantModifier:t,baseClassName:r,maybePostfixModifierPosition:o,isExternal:n}),it=e=>{const{prefix:t,experimentalParseClassName:r}=e;let o=e=>{const t=[];let r,o=0,n=0,s=0;const a=e.length;for(let d=0;d<a;d++){const a=e[d];if(0===o&&0===n){if(":"===a){t.push(e.slice(s,d)),s=d+1;continue}if("/"===a){r=d;continue}}"["===a?o++:"]"===a?o--:"("===a?n++:")"===a&&n--}const i=0===t.length?e:e.slice(s);let l=i,c=!1;i.endsWith("!")?(l=i.slice(0,-1),c=!0):i.startsWith("!")&&(l=i.slice(1),c=!0);return at(t,c,l,r&&r>s?r-s:void 0)};if(t){const e=t+":",r=o;o=t=>t.startsWith(e)?r(t.slice(e.length)):at(st,!1,t,void 0,!0)}if(r){const e=o;o=t=>r({className:t,parseClassName:e})}return o},lt=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((e,r)=>{t.set(e,1e6+r)}),e=>{const r=[];let o=[];for(let n=0;n<e.length;n++){const s=e[n],a="["===s[0],i=t.has(s);a||i?(o.length>0&&(o.sort(),r.push(...o),o=[]),r.push(s)):o.push(s)}return o.length>0&&(o.sort(),r.push(...o)),r}},ct=e=>{const t=Object.create(null),r=e.postfixLookupClassGroups;if(r)for(let o=0;o<r.length;o++)t[r[o]]=!0;return t},dt=/\s+/,ut=e=>{if("string"==typeof e)return e;let t,r="";for(let o=0;o<e.length;o++)e[o]&&(t=ut(e[o]))&&(r&&(r+=" "),r+=t);return r},ft=[],pt=e=>{const t=t=>t[e]||ft;return t.isThemeGetter=!0,t},mt=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,bt=/^\((?:(\w[\w-]*):)?(.+)\)$/i,ht=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,gt=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,kt=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,yt=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,vt=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,wt=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,xt=e=>ht.test(e),zt=e=>!!e&&!Number.isNaN(Number(e)),$t=e=>!!e&&Number.isInteger(Number(e)),Ct=e=>e.endsWith("%")&&zt(e.slice(0,-1)),Ut=e=>gt.test(e),Et=()=>!0,jt=e=>kt.test(e)&&!yt.test(e),Nt=()=>!1,St=e=>vt.test(e),Pt=e=>wt.test(e),At=e=>!Tt(e)&&!Dt(e),It=e=>e.startsWith("@container")&&("/"===e[10]&&void 0!==e[11]||"s"===e[11]&&void 0!==e[16]&&e.startsWith("-size/",10)||"n"===e[11]&&void 0!==e[18]&&e.startsWith("-normal/",10)),Lt=e=>Zt(e,tr,Nt),Tt=e=>mt.test(e),Gt=e=>Zt(e,rr,jt),Ot=e=>Zt(e,or,zt),Mt=e=>Zt(e,sr,Et),Rt=e=>Zt(e,nr,Nt),Wt=e=>Zt(e,Qt,Nt),Ht=e=>Zt(e,er,Pt),qt=e=>Zt(e,ar,St),Dt=e=>bt.test(e),Bt=e=>Kt(e,rr),Ft=e=>Kt(e,nr),Vt=e=>Kt(e,Qt),_t=e=>Kt(e,tr),Jt=e=>Kt(e,er),Xt=e=>Kt(e,ar,!0),Yt=e=>Kt(e,sr,!0),Zt=(e,t,r)=>{const o=mt.exec(e);return!!o&&(o[1]?t(o[1]):r(o[2]))},Kt=(e,t,r=!1)=>{const o=bt.exec(e);return!!o&&(o[1]?t(o[1]):r)},Qt=e=>"position"===e||"percentage"===e,er=e=>"image"===e||"url"===e,tr=e=>"length"===e||"size"===e||"bg-size"===e,rr=e=>"length"===e,or=e=>"number"===e,nr=e=>"family-name"===e,sr=e=>"number"===e||"weight"===e,ar=e=>"shadow"===e,ir=((e,...t)=>{let r,o,n,s;const a=e=>{const t=o(e);if(t)return t;const s=((e,t)=>{const{parseClassName:r,getClassGroupId:o,getConflictingClassGroupIds:n,sortModifiers:s,postfixLookupClassGroupIds:a}=t,i=[],l=e.trim().split(dt);let c="";for(let d=l.length-1;d>=0;d-=1){const e=l[d],{isExternal:t,modifiers:u,hasImportantModifier:f,baseClassName:p,maybePostfixModifierPosition:m}=r(e);if(t){c=e+(c.length>0?" "+c:c);continue}let b,h=!!m;if(h){b=o(p.substring(0,m));const e=b&&a[b]?o(p):void 0;e&&e!==b&&(b=e,h=!1)}else b=o(p);if(!b){if(!h){c=e+(c.length>0?" "+c:c);continue}if(b=o(p),!b){c=e+(c.length>0?" "+c:c);continue}h=!1}const g=0===u.length?"":1===u.length?u[0]:s(u).join(":"),k=f?g+"!":g,y=k+b;if(i.indexOf(y)>-1)continue;i.push(y);const v=n(b,h);for(let r=0;r<v.length;++r){const e=v[r];i.push(k+e)}c=e+(c.length>0?" "+c:c)}return c})(e,r);return n(e,s),s};return s=i=>{var l;return l=t.reduce((e,t)=>t(e),e()),r={cache:nt(l.cacheSize),parseClassName:it(l),sortModifiers:lt(l),postfixLookupClassGroupIds:ct(l),...Ve(l)},o=r.cache.get,n=r.cache.set,s=a,a(i)},(...e)=>s(((...e)=>{let t,r,o=0,n="";for(;o<e.length;)(t=e[o++])&&(r=ut(t))&&(n&&(n+=" "),n+=r);return n})(...e))})(()=>{const e=pt("color"),t=pt("font"),r=pt("text"),o=pt("font-weight"),n=pt("tracking"),s=pt("leading"),a=pt("breakpoint"),i=pt("container"),l=pt("spacing"),c=pt("radius"),d=pt("shadow"),u=pt("inset-shadow"),f=pt("text-shadow"),p=pt("drop-shadow"),m=pt("blur"),b=pt("perspective"),h=pt("aspect"),g=pt("ease"),k=pt("animate"),y=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom",Dt,Tt],v=()=>[Dt,Tt,l],w=()=>[xt,"full","auto",...v()],x=()=>[$t,"none","subgrid",Dt,Tt],z=()=>["auto",{span:["full",$t,Dt,Tt]},$t,Dt,Tt],$=()=>[$t,"auto",Dt,Tt],C=()=>["auto","min","max","fr",Dt,Tt],U=()=>["auto",...v()],E=()=>[xt,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...v()],j=()=>[xt,"screen","full","dvw","lvw","svw","min","max","fit",...v()],N=()=>[xt,"screen","full","lh","dvh","lvh","svh","min","max","fit",...v()],S=()=>[e,Dt,Tt],P=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom",Vt,Wt,{position:[Dt,Tt]}],A=()=>["auto","cover","contain",_t,Lt,{size:[Dt,Tt]}],I=()=>[Ct,Bt,Gt],L=()=>["","none","full",c,Dt,Tt],T=()=>["",zt,Bt,Gt],G=()=>[zt,Ct,Vt,Wt],O=()=>["","none",m,Dt,Tt],M=()=>["none",zt,Dt,Tt],R=()=>["none",zt,Dt,Tt],W=()=>[zt,Dt,Tt],H=()=>[xt,"full",...v()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Ut],breakpoint:[Ut],color:[Et],container:[Ut],"drop-shadow":[Ut],ease:["in","out","in-out"],font:[At],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Ut],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Ut],shadow:[Ut],spacing:["px",zt],text:[Ut],"text-shadow":[Ut],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",xt,Tt,Dt,h]}],container:["container"],"container-type":[{"@container":["","normal","size",Dt,Tt]}],"container-named":[It],columns:[{columns:[zt,Tt,Dt,i]}],"break-after":[{"break-after":["auto","avoid","all","avoid-page","page","left","right","column"]}],"break-before":[{"break-before":["auto","avoid","all","avoid-page","page","left","right","column"]}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:y()}],overflow:[{overflow:["auto","hidden","clip","visible","scroll"]}],"overflow-x":[{"overflow-x":["auto","hidden","clip","visible","scroll"]}],"overflow-y":[{"overflow-y":["auto","hidden","clip","visible","scroll"]}],overscroll:[{overscroll:["auto","contain","none"]}],"overscroll-x":[{"overscroll-x":["auto","contain","none"]}],"overscroll-y":[{"overscroll-y":["auto","contain","none"]}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:w()}],"inset-x":[{"inset-x":w()}],"inset-y":[{"inset-y":w()}],start:[{"inset-s":w(),start:w()}],end:[{"inset-e":w(),end:w()}],"inset-bs":[{"inset-bs":w()}],"inset-be":[{"inset-be":w()}],top:[{top:w()}],right:[{right:w()}],bottom:[{bottom:w()}],left:[{left:w()}],visibility:["visible","invisible","collapse"],z:[{z:[$t,"auto",Dt,Tt]}],basis:[{basis:[xt,"full","auto",i,...v()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[zt,xt,"auto","initial","none",Tt]}],grow:[{grow:["",zt,Dt,Tt]}],shrink:[{shrink:["",zt,Dt,Tt]}],order:[{order:[$t,"first","last","none",Dt,Tt]}],"grid-cols":[{"grid-cols":x()}],"col-start-end":[{col:z()}],"col-start":[{"col-start":$()}],"col-end":[{"col-end":$()}],"grid-rows":[{"grid-rows":x()}],"row-start-end":[{row:z()}],"row-start":[{"row-start":$()}],"row-end":[{"row-end":$()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":C()}],"auto-rows":[{"auto-rows":C()}],gap:[{gap:v()}],"gap-x":[{"gap-x":v()}],"gap-y":[{"gap-y":v()}],"justify-content":[{justify:["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe","normal"]}],"justify-items":[{"justify-items":["start","end","center","stretch","center-safe","end-safe","normal"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch","center-safe","end-safe"]}],"align-content":[{content:["normal","start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"]}],"align-items":[{items:["start","end","center","stretch","center-safe","end-safe",{baseline:["","last"]}]}],"align-self":[{self:["auto","start","end","center","stretch","center-safe","end-safe",{baseline:["","last"]}]}],"place-content":[{"place-content":["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"]}],"place-items":[{"place-items":["start","end","center","stretch","center-safe","end-safe","baseline"]}],"place-self":[{"place-self":["auto","start","end","center","stretch","center-safe","end-safe"]}],p:[{p:v()}],px:[{px:v()}],py:[{py:v()}],ps:[{ps:v()}],pe:[{pe:v()}],pbs:[{pbs:v()}],pbe:[{pbe:v()}],pt:[{pt:v()}],pr:[{pr:v()}],pb:[{pb:v()}],pl:[{pl:v()}],m:[{m:U()}],mx:[{mx:U()}],my:[{my:U()}],ms:[{ms:U()}],me:[{me:U()}],mbs:[{mbs:U()}],mbe:[{mbe:U()}],mt:[{mt:U()}],mr:[{mr:U()}],mb:[{mb:U()}],ml:[{ml:U()}],"space-x":[{"space-x":v()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":v()}],"space-y-reverse":["space-y-reverse"],size:[{size:E()}],"inline-size":[{inline:["auto",...j()]}],"min-inline-size":[{"min-inline":["auto",...j()]}],"max-inline-size":[{"max-inline":["none",...j()]}],"block-size":[{block:["auto",...N()]}],"min-block-size":[{"min-block":["auto",...N()]}],"max-block-size":[{"max-block":["none",...N()]}],w:[{w:[i,"screen",...E()]}],"min-w":[{"min-w":[i,"screen","none",...E()]}],"max-w":[{"max-w":[i,"screen","none","prose",{screen:[a]},...E()]}],h:[{h:["screen","lh",...E()]}],"min-h":[{"min-h":["screen","lh","none",...E()]}],"max-h":[{"max-h":["screen","lh",...E()]}],"font-size":[{text:["base",r,Bt,Gt]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[o,Yt,Mt]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Ct,Tt]}],"font-family":[{font:[Ft,Rt,t]}],"font-features":[{"font-features":[Tt]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[n,Dt,Tt]}],"line-clamp":[{"line-clamp":[zt,"none",Dt,Ot]}],leading:[{leading:[s,...v()]}],"list-image":[{"list-image":["none",Dt,Tt]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",Dt,Tt]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:S()}],"text-color":[{text:S()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:["solid","dashed","dotted","double","wavy"]}],"text-decoration-thickness":[{decoration:[zt,"from-font","auto",Dt,Gt]}],"text-decoration-color":[{decoration:S()}],"underline-offset":[{"underline-offset":[zt,"auto",Dt,Tt]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:v()}],"tab-size":[{tab:[$t,Dt,Tt]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Dt,Tt]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Dt,Tt]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:P()}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","space","round"]}]}],"bg-size":[{bg:A()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},$t,Dt,Tt],radial:["",Dt,Tt],conic:[$t,Dt,Tt]},Jt,Ht]}],"bg-color":[{bg:S()}],"gradient-from-pos":[{from:I()}],"gradient-via-pos":[{via:I()}],"gradient-to-pos":[{to:I()}],"gradient-from":[{from:S()}],"gradient-via":[{via:S()}],"gradient-to":[{to:S()}],rounded:[{rounded:L()}],"rounded-s":[{"rounded-s":L()}],"rounded-e":[{"rounded-e":L()}],"rounded-t":[{"rounded-t":L()}],"rounded-r":[{"rounded-r":L()}],"rounded-b":[{"rounded-b":L()}],"rounded-l":[{"rounded-l":L()}],"rounded-ss":[{"rounded-ss":L()}],"rounded-se":[{"rounded-se":L()}],"rounded-ee":[{"rounded-ee":L()}],"rounded-es":[{"rounded-es":L()}],"rounded-tl":[{"rounded-tl":L()}],"rounded-tr":[{"rounded-tr":L()}],"rounded-br":[{"rounded-br":L()}],"rounded-bl":[{"rounded-bl":L()}],"border-w":[{border:T()}],"border-w-x":[{"border-x":T()}],"border-w-y":[{"border-y":T()}],"border-w-s":[{"border-s":T()}],"border-w-e":[{"border-e":T()}],"border-w-bs":[{"border-bs":T()}],"border-w-be":[{"border-be":T()}],"border-w-t":[{"border-t":T()}],"border-w-r":[{"border-r":T()}],"border-w-b":[{"border-b":T()}],"border-w-l":[{"border-l":T()}],"divide-x":[{"divide-x":T()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":T()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:["solid","dashed","dotted","double","hidden","none"]}],"divide-style":[{divide:["solid","dashed","dotted","double","hidden","none"]}],"border-color":[{border:S()}],"border-color-x":[{"border-x":S()}],"border-color-y":[{"border-y":S()}],"border-color-s":[{"border-s":S()}],"border-color-e":[{"border-e":S()}],"border-color-bs":[{"border-bs":S()}],"border-color-be":[{"border-be":S()}],"border-color-t":[{"border-t":S()}],"border-color-r":[{"border-r":S()}],"border-color-b":[{"border-b":S()}],"border-color-l":[{"border-l":S()}],"divide-color":[{divide:S()}],"outline-style":[{outline:["solid","dashed","dotted","double","none","hidden"]}],"outline-offset":[{"outline-offset":[zt,Dt,Tt]}],"outline-w":[{outline:["",zt,Bt,Gt]}],"outline-color":[{outline:S()}],shadow:[{shadow:["","none",d,Xt,qt]}],"shadow-color":[{shadow:S()}],"inset-shadow":[{"inset-shadow":["none",u,Xt,qt]}],"inset-shadow-color":[{"inset-shadow":S()}],"ring-w":[{ring:T()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:S()}],"ring-offset-w":[{"ring-offset":[zt,Gt]}],"ring-offset-color":[{"ring-offset":S()}],"inset-ring-w":[{"inset-ring":T()}],"inset-ring-color":[{"inset-ring":S()}],"text-shadow":[{"text-shadow":["none",f,Xt,qt]}],"text-shadow-color":[{"text-shadow":S()}],opacity:[{opacity:[zt,Dt,Tt]}],"mix-blend":[{"mix-blend":["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity","plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"]}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[zt]}],"mask-image-linear-from-pos":[{"mask-linear-from":G()}],"mask-image-linear-to-pos":[{"mask-linear-to":G()}],"mask-image-linear-from-color":[{"mask-linear-from":S()}],"mask-image-linear-to-color":[{"mask-linear-to":S()}],"mask-image-t-from-pos":[{"mask-t-from":G()}],"mask-image-t-to-pos":[{"mask-t-to":G()}],"mask-image-t-from-color":[{"mask-t-from":S()}],"mask-image-t-to-color":[{"mask-t-to":S()}],"mask-image-r-from-pos":[{"mask-r-from":G()}],"mask-image-r-to-pos":[{"mask-r-to":G()}],"mask-image-r-from-color":[{"mask-r-from":S()}],"mask-image-r-to-color":[{"mask-r-to":S()}],"mask-image-b-from-pos":[{"mask-b-from":G()}],"mask-image-b-to-pos":[{"mask-b-to":G()}],"mask-image-b-from-color":[{"mask-b-from":S()}],"mask-image-b-to-color":[{"mask-b-to":S()}],"mask-image-l-from-pos":[{"mask-l-from":G()}],"mask-image-l-to-pos":[{"mask-l-to":G()}],"mask-image-l-from-color":[{"mask-l-from":S()}],"mask-image-l-to-color":[{"mask-l-to":S()}],"mask-image-x-from-pos":[{"mask-x-from":G()}],"mask-image-x-to-pos":[{"mask-x-to":G()}],"mask-image-x-from-color":[{"mask-x-from":S()}],"mask-image-x-to-color":[{"mask-x-to":S()}],"mask-image-y-from-pos":[{"mask-y-from":G()}],"mask-image-y-to-pos":[{"mask-y-to":G()}],"mask-image-y-from-color":[{"mask-y-from":S()}],"mask-image-y-to-color":[{"mask-y-to":S()}],"mask-image-radial":[{"mask-radial":[Dt,Tt]}],"mask-image-radial-from-pos":[{"mask-radial-from":G()}],"mask-image-radial-to-pos":[{"mask-radial-to":G()}],"mask-image-radial-from-color":[{"mask-radial-from":S()}],"mask-image-radial-to-color":[{"mask-radial-to":S()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"]}],"mask-image-conic-pos":[{"mask-conic":[zt]}],"mask-image-conic-from-pos":[{"mask-conic-from":G()}],"mask-image-conic-to-pos":[{"mask-conic-to":G()}],"mask-image-conic-from-color":[{"mask-conic-from":S()}],"mask-image-conic-to-color":[{"mask-conic-to":S()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:P()}],"mask-repeat":[{mask:["no-repeat",{repeat:["","x","y","space","round"]}]}],"mask-size":[{mask:A()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",Dt,Tt]}],filter:[{filter:["","none",Dt,Tt]}],blur:[{blur:O()}],brightness:[{brightness:[zt,Dt,Tt]}],contrast:[{contrast:[zt,Dt,Tt]}],"drop-shadow":[{"drop-shadow":["","none",p,Xt,qt]}],"drop-shadow-color":[{"drop-shadow":S()}],grayscale:[{grayscale:["",zt,Dt,Tt]}],"hue-rotate":[{"hue-rotate":[zt,Dt,Tt]}],invert:[{invert:["",zt,Dt,Tt]}],saturate:[{saturate:[zt,Dt,Tt]}],sepia:[{sepia:["",zt,Dt,Tt]}],"backdrop-filter":[{"backdrop-filter":["","none",Dt,Tt]}],"backdrop-blur":[{"backdrop-blur":O()}],"backdrop-brightness":[{"backdrop-brightness":[zt,Dt,Tt]}],"backdrop-contrast":[{"backdrop-contrast":[zt,Dt,Tt]}],"backdrop-grayscale":[{"backdrop-grayscale":["",zt,Dt,Tt]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[zt,Dt,Tt]}],"backdrop-invert":[{"backdrop-invert":["",zt,Dt,Tt]}],"backdrop-opacity":[{"backdrop-opacity":[zt,Dt,Tt]}],"backdrop-saturate":[{"backdrop-saturate":[zt,Dt,Tt]}],"backdrop-sepia":[{"backdrop-sepia":["",zt,Dt,Tt]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":v()}],"border-spacing-x":[{"border-spacing-x":v()}],"border-spacing-y":[{"border-spacing-y":v()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",Dt,Tt]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[zt,"initial",Dt,Tt]}],ease:[{ease:["linear","initial",g,Dt,Tt]}],delay:[{delay:[zt,Dt,Tt]}],animate:[{animate:["none",k,Dt,Tt]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[b,Dt,Tt]}],"perspective-origin":[{"perspective-origin":y()}],rotate:[{rotate:M()}],"rotate-x":[{"rotate-x":M()}],"rotate-y":[{"rotate-y":M()}],"rotate-z":[{"rotate-z":M()}],scale:[{scale:R()}],"scale-x":[{"scale-x":R()}],"scale-y":[{"scale-y":R()}],"scale-z":[{"scale-z":R()}],"scale-3d":["scale-3d"],skew:[{skew:W()}],"skew-x":[{"skew-x":W()}],"skew-y":[{"skew-y":W()}],transform:[{transform:[Dt,Tt,"","none","gpu","cpu"]}],"transform-origin":[{origin:y()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:H()}],"translate-x":[{"translate-x":H()}],"translate-y":[{"translate-y":H()}],"translate-z":[{"translate-z":H()}],"translate-none":["translate-none"],zoom:[{zoom:[$t,Dt,Tt]}],accent:[{accent:S()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:S()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Dt,Tt]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scrollbar-thumb-color":[{"scrollbar-thumb":S()}],"scrollbar-track-color":[{"scrollbar-track":S()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":v()}],"scroll-mx":[{"scroll-mx":v()}],"scroll-my":[{"scroll-my":v()}],"scroll-ms":[{"scroll-ms":v()}],"scroll-me":[{"scroll-me":v()}],"scroll-mbs":[{"scroll-mbs":v()}],"scroll-mbe":[{"scroll-mbe":v()}],"scroll-mt":[{"scroll-mt":v()}],"scroll-mr":[{"scroll-mr":v()}],"scroll-mb":[{"scroll-mb":v()}],"scroll-ml":[{"scroll-ml":v()}],"scroll-p":[{"scroll-p":v()}],"scroll-px":[{"scroll-px":v()}],"scroll-py":[{"scroll-py":v()}],"scroll-ps":[{"scroll-ps":v()}],"scroll-pe":[{"scroll-pe":v()}],"scroll-pbs":[{"scroll-pbs":v()}],"scroll-pbe":[{"scroll-pbe":v()}],"scroll-pt":[{"scroll-pt":v()}],"scroll-pr":[{"scroll-pr":v()}],"scroll-pb":[{"scroll-pb":v()}],"scroll-pl":[{"scroll-pl":v()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Dt,Tt]}],fill:[{fill:["none",...S()]}],"stroke-w":[{stroke:[zt,Bt,Gt,Ot]}],stroke:[{stroke:["none",...S()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{"container-named":["container-type"],overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},postfixLookupClassGroups:["container-type"],orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}});function lr(...e){return ir(qe(e))}var cr=class extends Error{status;url;constructor(e,t,r){super(e),this.status=t,this.url=r}},dr=class extends Error{request;constructor(e,t){super(function(e,t){const r=t instanceof Error?t.message:String(t);return["No HTTP response received.",`${e.method} ${e.url}`,r,"Check the server URL, CORS settings, network reachability, and whether the API is running."].filter(Boolean).join("\n")}(e,t)),this.request=e}};async function ur(e){return Zr(e,"/api/auth/status",{token:null})}async function fr(e,t){return Zr(e,"/api/auth/exchange",{body:{password:t},token:null})}async function pr(e){return Zr(e.serverUrl,"/api/auth/session",{token:e.token})}async function mr(e){return Zr(e.serverUrl,"/api/accounts",{token:e.token})}async function br(e){return Zr(e.serverUrl,"/api/accounts/export",{token:e.token})}async function hr(e,t){return Zr(e.serverUrl,"/api/accounts/import",{body:t,token:e.token})}async function gr(e){return Zr(e.serverUrl,"/api/accounts/import-local-active",{body:{},token:e.token})}async function kr(e){return Zr(e.serverUrl,"/api/accounts/login-callback-port",{token:e.token})}async function yr(e){return Zr(e.serverUrl,"/api/accounts/login-callback-port",{body:{},token:e.token})}async function vr(e,t){return Zr(e.serverUrl,"/api/accounts",{body:t,token:e.token})}async function wr(e,t,r){return Zr(e.serverUrl,`/api/accounts/${t}`,{body:r,method:"PATCH",token:e.token})}async function xr(e,t,r){return Zr(e.serverUrl,`/api/accounts/${t}/runtime-settings`,{body:r,method:"PATCH",token:e.token})}async function zr(e){return Zr(e.serverUrl,"/api/accounts/personalization",{token:e.token})}async function $r(e,t){return Zr(e.serverUrl,"/api/accounts/personalization",{body:t,method:"PATCH",token:e.token})}async function Cr(e,t){return Zr(e.serverUrl,`/api/accounts/${t}`,{method:"DELETE",token:e.token})}async function Ur(e,t){return Zr(e.serverUrl,`/api/accounts/${t}/local-active`,{body:{},token:e.token})}async function Er(e,t,r={}){return Zr(e.serverUrl,`/api/accounts/${t}/authenticate`,{body:r,token:e.token})}async function jr(e,t){return Zr(e.serverUrl,`/api/accounts/${t}/authenticate`,{method:"DELETE",token:e.token})}async function Nr(e,t){return Zr(e.serverUrl,`/api/accounts/${t}/models`,{token:e.token})}async function Sr(e,t){return Zr(e.serverUrl,`/api/accounts/${t}/rate-limits`,{token:e.token})}async function Pr(e,t,r){return Zr(e.serverUrl,`/api/accounts/${t}/authenticate/callback`,{body:r,token:e.token})}async function Ar(e,t){const r=t?`?path=${encodeURIComponent(t)}`:"";return Zr(e.serverUrl,`/api/workspaces/directories${r}`,{token:e.token})}async function Ir(e,t){return Zr(e.serverUrl,"/api/workspaces/directories",{body:t,token:e.token})}async function Lr(e){return Zr(e.serverUrl,"/api/chats",{token:e.token})}async function Tr(e,t){return Zr(e.serverUrl,`/api/chats/${t}`,{token:e.token})}async function Gr(e,t){return Zr(e.serverUrl,"/api/chats",{body:t,token:e.token})}async function Or(e,t,r){return Zr(e.serverUrl,`/api/chats/${t}`,{body:r,method:"PATCH",token:e.token})}async function Mr(e,t){return Zr(e.serverUrl,`/api/chats/${t}`,{method:"DELETE",token:e.token})}async function Rr(e,t,r=0){return Zr(e.serverUrl,`/api/chats/${t}/messages?afterSequence=${r}&limit=200`,{token:e.token})}async function Wr(e,t){return Zr(e.serverUrl,`/api/chats/${t}/context`,{token:e.token})}async function Hr(e,t,r){return Zr(e.serverUrl,`/api/chats/${t}/messages`,{body:r,token:e.token})}async function qr(e,t,r,o){const n=new URLSearchParams({path:r});return o&&o>0&&n.set("line",String(o)),Zr(e.serverUrl,`/api/chats/${t}/files?${n.toString()}`,{token:e.token})}async function Dr(e,t){return Zr(e.serverUrl,`/api/chats/${t}/git/status`,{token:e.token})}async function Br(e,t){return Zr(e.serverUrl,`/api/chats/${t}/git/branches`,{token:e.token})}async function Fr(e,t,r){const o=r?`?path=${encodeURIComponent(r)}`:"";return Zr(e.serverUrl,`/api/chats/${t}/git/diff${o}`,{token:e.token})}async function Vr(e,t){return Zr(e.serverUrl,`/api/chats/${t}/git/history`,{token:e.token})}async function _r(e,t,r){return Zr(e.serverUrl,`/api/chats/${t}/git/action`,{body:r,token:e.token})}async function Jr(e,t){return Zr(e.serverUrl,`/api/chats/${t}/interrupt`,{body:{},token:e.token})}async function Xr(e,t,r,o){return Zr(e.serverUrl,`/api/chats/${t}/server-requests/${encodeURIComponent(r)}/respond`,{body:o,token:e.token})}async function Yr(e,t,r){return Zr(e.serverUrl,`/api/chats/${t}/queued/${r}/steer`,{method:"POST",token:e.token})}async function Zr(e,t,r){const o=`${e}${t}`,n=r.method??(void 0===r.body?"GET":"POST");let s;try{s=await fetch(o,{method:n,headers:{Accept:"application/json",...void 0===r.body?{}:{"Content-Type":"application/json"},...r.token?{Authorization:`Bearer ${r.token}`}:{}},body:void 0===r.body?void 0:JSON.stringify(r.body)})}catch(l){throw new dr({method:n,url:o},l)}const a=await s.text(),i=function(e,t){if(!e)return null;try{return JSON.parse(e)}catch(l){throw new Error(["Server returned invalid JSON.",t,l instanceof Error?l.message:void 0,Kr(e)].filter(Boolean).join("\n"),{cause:l})}}(a,o);if(!s.ok)throw new cr([`HTTP ${s.status} ${s.statusText||"Request failed"}`,`${n} ${o}`,Qr(i)??Kr(a)].filter(Boolean).join("\n"),s.status,o);return i}function Kr(e){const t=e.trim();if(t)return t.length>500?`${t.slice(0,500)}...`:t}function Qr(e){if(!e||"object"!=typeof e)return;const t=e.message;return Array.isArray(t)?t.join("\n"):"string"==typeof t?t:void 0}function eo(e,t){return{data:[...(e?.data??[]).filter(e=>e.id!==t.id),t].sort((e,t)=>e.sequence-t.sequence),nextCursor:Math.max(t.sequence,e?.nextCursor??0)}}export{ge as $,Nr as A,N as At,xr as B,h as Bt,pr as C,S as Ct,yr as D,E as Dt,Jr as E,j as Et,Xr as F,x as Ft,We as G,$r as H,f as Ht,_r as I,w as It,Ee as J,Me as K,Ur as L,k as Lt,qr as M,$ as Mt,Sr as N,P as Nt,mr as O,I as Ot,kr as P,z as Pt,he as Q,Yr as R,y as Rt,zr as S,L as St,gr as T,A as Tt,lr as U,d as Ut,Or as V,p as Vt,qe as W,c as Wt,we as X,ze as Y,be as Z,Rr as _,D as _t,jr as a,M as at,Vr as b,F as bt,Gr as c,te as ct,fr as d,O as dt,me as et,Hr as f,Y as ft,Wr as g,R as gt,Tr as h,Q as ht,Er as i,Z as it,Ar as j,v as jt,Lr as k,C as kt,Ir as l,ne as lt,ur as m,H as mt,eo as n,ae as nt,Pr as o,se as ot,br as p,W as pt,Te as q,Mr as r,ee as rt,vr as s,G as st,cr as t,ue as tt,Cr as u,re as ut,Br as v,q as vt,hr as w,U as wt,Dr as x,K as xt,Fr as y,B as yt,wr as z,g as zt};
@@ -0,0 +1 @@
1
+ import{F as e,M as t,R as s,c as a,j as n,k as r,s as i,t as o}from"./jsx-runtime-BD6xVgfN.js";import{Ht as l,Wt as c,Xt as d,_n as u,an as m,cn as h,dn as x}from"./usePositioner-DoPOYGgd.js";import{At as p,B as g,Ct as f,Dt as b,E as j,Et as v,G as y,H as N,J as w,K as k,L as C,Mt as S,Nt as A,O as E,Ot as P,P as T,St as z,T as M,Tt as U,U as I,V as O,W as R,Z as F,bt as L,d as q,f as D,ft as $,g as H,gt as K,ht as _,jt as Q,kt as G,nt as V,p as B,pt as W,q as J,tt as Z,vt as X,wt as Y,xt as ee}from"./popover-DTbjnDSA.js";import{c as te,i as se,n as ae,o as ne,r as re,s as ie,u as oe}from"./document-title-CVCGo83t.js";import{D as le,H as ce,J as de,L as ue,N as me,O as he,P as xe,S as pe,T as ge,U as fe,Ut as be,V as je,Wt as ve,a as ye,i as Ne,j as we,k as ke,l as Ce,o as Se,p as Ae,r as Ee,s as Pe,u as Te,w as ze,z as Me}from"./api-Bq1vju8d.js";import{A as Ue,C as Ie,E as Oe,O as Re,S as Fe,T as Le,_ as qe,a as De,b as $e,c as He,d as Ke,g as _e,h as Qe,k as Ge,l as Ve,m as Be,n as We,o as Je,p as Ze,r as Xe,s as Ye,t as et,u as tt,v as st,w as at,x as nt,y as rt}from"./header-menu-BZ8Qg4Vi.js";import{t as it}from"./folder-open-BGVSSdnS.js";import{n as ot,t as lt}from"./label-PRFnRUMj.js";import{n as ct}from"./session-provider-Bxa1AL3n.js";import{c as dt,l as ut,t as mt}from"./input-DmJ6N0Sh.js";function ht(e,t){const s=new Set(t);return e.filter(e=>!s.has(e))}var xt=class extends u{#e;#t;#s;#a;#n;#r;#i;#o;#l;#c=[];constructor(e,t,s){super(),this.#e=e,this.#a=s,this.#s=[],this.#n=[],this.#t=[],this.setQueries(t)}onSubscribe(){1===this.listeners.size&&this.#n.forEach(e=>{e.subscribe(t=>{this.#d(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#n.forEach(e=>{e.destroy()})}setQueries(e,t){this.#s=e,this.#a=t,d.batch(()=>{const e=this.#n,t=this.#u(this.#s);t.forEach(e=>e.observer.setOptions(e.defaultedQueryOptions));const s=t.map(e=>e.observer),a=s.map(e=>e.getCurrentResult()),n=e.length!==s.length,r=s.some((t,s)=>t!==e[s]),i=n||r,o=!!i||a.some((e,t)=>{const s=this.#t[t];return!s||!x(e,s)});(i||o)&&(i&&(this.#c=t,this.#n=s),this.#t=a,this.hasListeners()&&(i&&(ht(e,s).forEach(e=>{e.destroy()}),ht(s,e).forEach(e=>{e.subscribe(t=>{this.#d(e,t)})})),this.#m()))})}getCurrentResult(){return this.#t}getQueries(){return this.#n.map(e=>e.getCurrentQuery())}getObservers(){return this.#n}getOptimisticResult(e,t){const s=this.#u(e),a=s.map(e=>e.observer.getOptimisticResult(e.defaultedQueryOptions)),n=s.map(e=>e.defaultedQueryOptions.queryHash);return[a,e=>this.#h(e??a,t,n),()=>this.#x(a,s)]}#x(e,t){return t.map((s,a)=>{const n=e[a];return s.defaultedQueryOptions.notifyOnChangeProps?n:s.observer.trackResult(n,e=>{t.forEach(t=>{t.observer.trackProp(e)})})})}#h(e,t,s){if(t){const a=this.#l,n=void 0!==s&&void 0!==a&&(a.length!==s.length||s.some((e,t)=>e!==a[t]));return this.#r&&this.#t===this.#o&&!n&&t===this.#i||(this.#i=t,this.#o=this.#t,void 0!==s&&(this.#l=s),this.#r=h(this.#r,t(e))),this.#r}return e}#p(){return void 0!==this.#a?.combine&&this.#n.some((e,t)=>e.options.suspense&&void 0===this.#t[t]?.data)}#u(e){const t=new Map;this.#n.forEach(e=>{const s=e.options.queryHash;if(!s)return;const a=t.get(s);a?a.push(e):t.set(s,[e])});const s=[];return e.forEach(e=>{const a=this.#e.defaultQueryOptions(e),n=t.get(a.queryHash)?.shift()??new A(this.#e,a);s.push({defaultedQueryOptions:a,observer:n})}),s}#d(e,t){const s=this.#n.indexOf(e);-1!==s&&(this.#t=function(e,t,s){const a=e.slice(0);return a[t]=s,a}(this.#t,s,t),this.#m())}#m(){if(this.hasListeners()){const e=this.#x(this.#t,this.#c),t=this.#p(),s=this.#r,a=t?s:this.#h(e,this.#a?.combine);(t||s!==a)&&d.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},pt=s(e(),1);var gt=ve("archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]),ft=ve("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]),bt=ve("copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]),jt=ve("ellipsis-vertical",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]]),vt=ve("ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]),yt=ve("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]),Nt=ve("eye-off",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]),wt=ve("folder-plus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]),kt=ve("folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]),Ct=ve("house",[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"r6nss1"}]]),St=ve("import",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m8 11 4 4 4-4",key:"1dohi6"}],["path",{d:"M8 5H4a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-4",key:"1ywtjm"}]]),At=ve("laptop",[["path",{d:"M18 5a2 2 0 0 1 2 2v8.526a2 2 0 0 0 .212.897l1.068 2.127a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45l1.068-2.127A2 2 0 0 0 4 15.526V7a2 2 0 0 1 2-2z",key:"1pdavp"}],["path",{d:"M20.054 15.987H3.946",key:"14rxg9"}]]),Et=ve("mail",[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]]),Pt=ve("menu",[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]]),Tt=ve("message-square",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]]),zt=ve("moon",[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]]),Mt=ve("panel-left",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]),Ut=ve("pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]),It=ve("power-off",[["path",{d:"M18.36 6.64A9 9 0 0 1 20.77 15",key:"dxknvb"}],["path",{d:"M6.16 6.16a9 9 0 1 0 12.68 12.68",key:"1x7qb5"}],["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]),Ot=ve("rotate-cw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]]),Rt=ve("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]),Ft=ve("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]),Lt=ve("settings",[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),qt=ve("sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]),Dt=ve("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]),$t=o();function Ht(e){const{children:t,open:s,defaultOpen:a=!1,onOpenChange:n,onOpenChangeComplete:r,actionsRef:i,handle:o,triggerId:l,defaultTriggerId:c=null}=e,d=Ie(!0),u=Boolean(d),m=nt.useStore(o?.store,{open:a,openProp:s,activeTriggerId:c,triggerIdProp:l,modal:!0,disablePointerDismissal:!0,nested:u,role:"alertdialog"});m.useControlledProp("openProp",s),m.useControlledProp("triggerIdProp",l),m.useSyncedValue("nested",u),m.useContextCallback("onOpenChange",n),m.useContextCallback("onOpenChangeComplete",r);const h=m.useState("payload");at({store:m,actionsRef:i,parentContext:d?.store.context,isDrawer:!1,onOpenChange:n,triggerIdProp:l});const x=pt.useMemo(()=>({store:m}),[m]);return(0,$t.jsx)($e.Provider,{value:!1,children:(0,$t.jsx)(Fe.Provider,{value:x,children:"function"==typeof t?t({payload:h}):t})})}function Kt({...e}){return(0,$t.jsx)(Ht,{"data-slot":"alert-dialog",...e})}function _t({...e}){return(0,$t.jsx)(Be,{"data-slot":"alert-dialog-portal",...e})}function Qt({className:e,...t}){return(0,$t.jsx)(st,{"data-slot":"alert-dialog-overlay",className:fe("fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",e),...t})}function Gt({className:e,size:t="default",...s}){return(0,$t.jsxs)(_t,{children:[(0,$t.jsx)(Qt,{}),(0,$t.jsx)(Qe,{"data-slot":"alert-dialog-content","data-size":t,className:fe("group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid w-full -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none data-[size=default]:max-w-xs data-[size=sm]:max-w-xs data-[size=default]:sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...s})]})}function Vt({className:e,...t}){return(0,$t.jsx)("div",{"data-slot":"alert-dialog-header",className:fe("grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-4 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]",e),...t})}function Bt({className:e,...t}){return(0,$t.jsx)("div",{"data-slot":"alert-dialog-footer",className:fe("-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end",e),...t})}function Wt({className:e,...t}){return(0,$t.jsx)(Ze,{"data-slot":"alert-dialog-title",className:fe("font-heading text-base font-medium sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2",e),...t})}function Jt({className:e,...t}){return(0,$t.jsx)(_e,{"data-slot":"alert-dialog-description",className:fe("text-sm text-balance text-muted-foreground md:text-pretty *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",e),...t})}function Zt({className:e,...t}){return(0,$t.jsx)(dt,{"data-slot":"alert-dialog-action",className:fe(e),...t})}function Xt({className:e,variant:t="outline",size:s="default",...a}){return(0,$t.jsx)(qe,{"data-slot":"alert-dialog-cancel",className:fe(e),render:(0,$t.jsx)(dt,{variant:t,size:s}),...a})}function Yt({callbackUrl:e,cancelPending:t,completePending:s,state:a,onCallbackUrlChange:n,onCancelAuthentication:r,onClose:i,onComplete:o,onCopyDeviceCode:l,onReopen:c}){const d="device"===a?.mode,u="CONNECTED"===a?.status;return(0,$t.jsx)(Je,{open:!!a,onOpenChange:e=>{e||i()},children:(0,$t.jsxs)(Ye,{className:"max-w-2xl",children:[(0,$t.jsxs)(tt,{children:[(0,$t.jsx)(Ke,{children:d?"Device authentication":"Normal authentication"}),(0,$t.jsx)(He,{children:a?.accountName??"Codex account"})]}),(0,$t.jsxs)("div",{className:"grid gap-4",children:[(0,$t.jsx)("div",{className:fe("rounded-md border px-3 py-2 text-sm",u?"border-emerald-300 bg-emerald-50 text-emerald-800 dark:border-emerald-900/70 dark:bg-emerald-950/35 dark:text-emerald-200":"bg-muted/35 text-muted-foreground"),children:u?"Codex reported this account as connected. xedoc will use the email from the authenticated account as its name.":d?"Open the verification link, enter the device code, then use the response URL field if Codex does not finish automatically.":"Complete the browser login. If the browser lands on a localhost callback page, paste that full URL below."}),a?.authUrl?(0,$t.jsxs)("div",{className:"grid gap-2",children:[(0,$t.jsx)(lt,{htmlFor:"account-auth-url",children:d?"Verification link":"Authentication link"}),(0,$t.jsxs)("div",{className:"grid gap-2 sm:grid-cols-[minmax(0,1fr)_auto]",children:[(0,$t.jsx)(mt,{className:"font-mono text-xs",id:"account-auth-url",readOnly:!0,value:a.authUrl}),(0,$t.jsxs)(dt,{variant:"outline",onClick:c,children:[(0,$t.jsx)(yt,{}),"Reopen"]})]})]}):null,d&&a?.userCode?(0,$t.jsxs)("div",{className:"grid gap-2",children:[(0,$t.jsx)(lt,{htmlFor:"account-device-code",children:"Device code"}),(0,$t.jsxs)("div",{className:"grid gap-2 sm:grid-cols-[minmax(0,1fr)_auto]",children:[(0,$t.jsx)(mt,{className:"font-mono text-sm tracking-wider",id:"account-device-code",readOnly:!0,value:a.userCode}),(0,$t.jsxs)(dt,{variant:"outline",onClick:l,children:[(0,$t.jsx)(bt,{}),"Copy"]})]})]}):null,(0,$t.jsxs)("div",{className:"grid gap-2",children:[(0,$t.jsx)(lt,{htmlFor:"account-callback-url",children:"Response URL"}),(0,$t.jsx)(y,{className:"min-h-24 font-mono text-xs",id:"account-callback-url",placeholder:"http://localhost:1455/auth/callback?code=...",value:e,onChange:e=>n(e.target.value)}),(0,$t.jsx)("p",{className:"text-xs text-muted-foreground",children:"Paste the complete localhost callback URL from the Codex browser tab when automatic completion is blocked."})]}),a?.message?(0,$t.jsx)("p",{className:"rounded-md border bg-background px-3 py-2 text-sm text-muted-foreground",children:a.message}):null]}),(0,$t.jsxs)(Ve,{children:[(0,$t.jsxs)(dt,{variant:"outline",onClick:i,children:[(0,$t.jsx)($,{}),"Close"]}),"AUTHENTICATING"===a?.status?(0,$t.jsxs)(dt,{disabled:!a.accountId||t,variant:"destructive",onClick:r,children:[t?(0,$t.jsx)(be,{className:"animate-spin"}):(0,$t.jsx)($,{}),"Cancel Auth"]}):null,(0,$t.jsxs)(dt,{disabled:!a?.authUrl,variant:"secondary",onClick:c,children:[(0,$t.jsx)(yt,{}),"Reopen Link"]}),(0,$t.jsxs)(dt,{disabled:!a?.accountId||!e.trim()||s,onClick:o,children:[s?(0,$t.jsx)(be,{className:"animate-spin"}):(0,$t.jsx)(te,{}),"Submit Response URL"]})]})]})})}function es(e){return"browser"===e||"device"===e?e:null}function ts(e,t){return{accountId:e?.id??"",accountName:e?.displayName??"Codex account",authUrl:e?.lastAuthUrl??null,message:"AUTHENTICATING"===e?.status?"Authentication is in progress.":"Starting Codex authentication.",mode:t,status:e?.status??"AUTHENTICATING",userCode:e?.lastAuthUserCode??null}}function ss({account:e,authPending:t,authPendingMode:s,cancelPending:a,localActivePending:n,quotaLabel:r,quotaPending:i,quotaSnapshot:o,onAuthenticate:l,onCancelAuthentication:c,onDelete:d,onEdit:u,onSetLocalActive:m,onShowAuthentication:h}){const x=es(e.lastAuthMode)??"browser",p=t&&"browser"===s,g=t&&"device"===s,f="AUTHENTICATING"===e.status?x:"browser",b="AUTHENTICATING"===e.status?"Check":"CONNECTED"===e.status?"Re-authenticate":"Authenticate",j="CONNECTED"===e.status&&!e.isLocalCodexActive,v="device"===x?"Device login pending":"Browser login pending";return(0,$t.jsx)("div",{className:fe("rounded-md border bg-background px-3 py-3 text-sm",e.isLocalCodexActive&&"border-primary/40 bg-primary/5 dark:bg-primary/10"),children:(0,$t.jsxs)("div",{className:"grid gap-3",children:[(0,$t.jsxs)("div",{className:"flex min-w-0 items-start justify-between gap-3",children:[(0,$t.jsxs)("div",{className:"grid min-w-0 gap-1.5",children:[(0,$t.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,$t.jsx)("div",{className:"min-w-0 max-w-full truncate font-medium",children:e.displayName}),(0,$t.jsx)(as,{planType:o?.planType}),e.isLocalCodexActive?(0,$t.jsx)(ns,{}):null]}),(0,$t.jsx)("div",{className:"truncate text-xs text-muted-foreground",children:os(e)})]}),(0,$t.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:[(0,$t.jsx)(rs,{account:e}),(0,$t.jsxs)(k,{children:[(0,$t.jsxs)(Z,{render:(0,$t.jsx)(dt,{size:"icon-sm",variant:"ghost"}),children:[t||a||n?(0,$t.jsx)(be,{className:"animate-spin"}):(0,$t.jsx)(jt,{}),(0,$t.jsx)("span",{className:"sr-only",children:"Account actions"})]}),(0,$t.jsxs)(J,{align:"end",className:"w-48",children:[(0,$t.jsxs)(w,{disabled:t,onClick:()=>l(f),children:[p?(0,$t.jsx)(be,{className:"animate-spin"}):"AUTHENTICATING"===e.status?(0,$t.jsx)(Ot,{}):(0,$t.jsx)(yt,{}),"AUTHENTICATING"===e.status?b:"Normal Auth"]}),(0,$t.jsxs)(w,{disabled:t,onClick:()=>l("device"),children:[g?(0,$t.jsx)(be,{className:"animate-spin"}):(0,$t.jsx)(ot,{}),"Device Auth"]}),(0,$t.jsxs)(w,{disabled:!j||n,onClick:m,children:[n?(0,$t.jsx)(be,{className:"animate-spin"}):(0,$t.jsx)(At,{}),e.isLocalCodexActive?"Local Active":"Make Local Active"]}),"AUTHENTICATING"===e.status?(0,$t.jsxs)(w,{disabled:a,variant:"destructive",onClick:c,children:[a?(0,$t.jsx)(be,{className:"animate-spin"}):(0,$t.jsx)($,{}),"Cancel Auth"]}):null,"AUTHENTICATING"===e.status||e.lastAuthUrl?(0,$t.jsxs)(w,{onClick:h,children:[(0,$t.jsx)(yt,{}),"Authentication Details"]}):null,(0,$t.jsx)(F,{}),(0,$t.jsxs)(w,{onClick:u,children:[(0,$t.jsx)(Ut,{}),"Edit"]}),(0,$t.jsxs)(w,{variant:"destructive",onClick:d,children:[(0,$t.jsx)(Dt,{}),"Delete"]})]})]})]})]}),(0,$t.jsxs)("div",{className:"grid gap-2 sm:grid-cols-[minmax(0,1fr)_auto] sm:items-end",children:[(0,$t.jsxs)("div",{className:"grid min-w-0 gap-1.5",children:[(0,$t.jsx)(is,{accountStatus:e.status,label:r,pending:i,snapshot:o}),"AUTHENTICATING"===e.status?(0,$t.jsx)("span",{className:"text-xs text-muted-foreground",children:v}):null]}),"AUTHENTICATING"===e.status?(0,$t.jsxs)(dt,{className:"min-w-0 sm:w-auto",disabled:a,size:"sm",variant:"destructive",onClick:c,children:[a?(0,$t.jsx)(be,{className:"animate-spin"}):(0,$t.jsx)($,{}),"Cancel"]}):null]})]})})}function as({planType:e}){return e?(0,$t.jsx)(I,{className:"border-emerald-300 bg-emerald-50 text-emerald-700 dark:border-emerald-900/70 dark:bg-emerald-950/35 dark:text-emerald-300",variant:"outline",children:(t=e,t.split("_").filter(Boolean).map(e=>e.slice(0,1).toUpperCase()+e.slice(1)).join(" "))}):null;var t}function ns(){return(0,$t.jsxs)(I,{className:"border-sky-300 bg-sky-50 text-sky-700 dark:border-sky-900/70 dark:bg-sky-950/35 dark:text-sky-300",variant:"outline",children:[(0,$t.jsx)(At,{}),"local active"]})}function rs({account:e}){const t=e.lastError?.trim();return t?(0,$t.jsxs)(re,{children:[(0,$t.jsx)(ne,{render:(0,$t.jsx)("span",{className:"inline-flex cursor-help"}),children:(0,$t.jsx)(De,{status:e.status})}),(0,$t.jsx)(se,{align:"start",className:"max-w-96 whitespace-pre-wrap break-words text-left leading-relaxed",side:"right",children:t})]}):(0,$t.jsx)(De,{status:e.status})}function is({accountStatus:e,label:t,pending:s,snapshot:a}){if("CONNECTED"!==e)return(0,$t.jsx)("div",{className:"text-xs text-muted-foreground",children:"INVALIDATED"===e?"Re-authenticate account to load quota.":"Connect account to load quota."});const n=t??O(a),r=N(a);return(0,$t.jsx)("div",{className:"grid gap-1.5",children:(0,$t.jsxs)("div",{className:fe("inline-flex w-fit items-center gap-1.5 rounded-md border px-2 py-1 text-xs","fiveHour"===r&&"border-orange-300 bg-orange-50 text-orange-700 dark:border-orange-900/70 dark:bg-orange-950/35 dark:text-orange-300","weekly"===r&&"border-red-300 bg-red-50 text-red-700 dark:border-red-900/70 dark:bg-red-950/35 dark:text-red-300"),children:[s?(0,$t.jsx)(be,{className:"size-3 animate-spin"}):null,(0,$t.jsx)("span",{children:n})]})})}function os(e){return[e.command,...e.args??[]].filter(Boolean).join(" ")}var ls={args:"",command:"",displayName:"",environment:""};function cs({accounts:e,accountRateLimitFetching:t,accountRateLimitSnapshots:s,accountUsageSummaries:a,createFocusKey:n=0,session:r}){const[i,o]=(0,pt.useState)(!1),[d,u]=(0,pt.useState)(null),[m,h]=(0,pt.useState)(""),[x,p]=(0,pt.useState)(""),[g,b]=(0,pt.useState)(null),[j,v]=(0,pt.useState)(ls),[y,N]=(0,pt.useState)(null),C=(0,pt.useRef)(null),S=(0,pt.useRef)(null),A=c(),E=(0,pt.useMemo)(()=>["login-callback-port",r.serverUrl],[r.serverUrl]),P=Y({queryKey:E,queryFn:()=>xe(r),refetchInterval:e=>e.state.data?.inUse?5e3:15e3,retry:1,staleTime:3e3});(0,pt.useEffect)(()=>{if(n<=0)return;const e=window.setTimeout(()=>{o(!0)},80);return()=>window.clearTimeout(e)},[n]),(0,pt.useEffect)(()=>{u(t=>{if(!t?.accountId)return t;const s=e.find(e=>e.id===t.accountId);if(!s)return t;const a=es(s.lastAuthMode)??t.mode,n="AUTHENTICATING"===s.status?s.lastAuthUrl??t.authUrl:s.lastAuthUrl,r="AUTHENTICATING"===s.status?s.lastAuthUserCode??t.userCode:s.lastAuthUserCode,i={...t,accountName:s.displayName,authUrl:n??null,mode:a,status:s.status,userCode:r??null};return l=i,(o=t).accountId===l.accountId&&o.accountName===l.accountName&&o.authUrl===l.authUrl&&o.message===l.message&&o.mode===l.mode&&o.status===l.status&&o.userCode===l.userCode?t:i;var o,l})},[e]),(0,pt.useEffect)(()=>{d?.accountId&&"CONNECTED"!==d.status&&"CONNECTED"===e.find(e=>e.id===d.accountId)?.status&&(X(),u(null),h(""),l.success("Account connected."))},[e,d?.accountId,d?.status]);const T=()=>A.invalidateQueries({queryKey:["accounts"]}),z=(0,pt.useMemo)(()=>function(e,t){const s=t.trim().toLocaleLowerCase();return s?e.filter(e=>[e.displayName,e.status,e.command,e.args.join(" "),e.defaultModel,e.defaultPermissionMode,e.defaultReasoningEffort,e.defaultServiceTier,e.lastError,e.environment?JSON.stringify(e.environment):null].filter(Boolean).some(e=>String(e).toLocaleLowerCase().includes(s))):e}(e,x),[e,x]),M=(0,pt.useMemo)(()=>e.some(e=>"AUTHENTICATING"===e.status&&"device"!==es(e.lastAuthMode)),[e]),U=f({mutationFn:async e=>{const t=await Pe(r,{});return{account:t,auth:await Ne(r,t.id,{mode:e.authMode}),popup:e.popup}},onError:(e,t)=>{X(t?.popup??null),u(t=>t?{...t,message:ps(e),status:"ERROR"}:t),l.error(ps(e))},onSuccess:({account:e,auth:t,popup:s})=>{T(),W(t,s,e)}}),I=f({mutationFn:()=>{if(!g)throw new Error("Select an account to edit.");return Me(r,g.id,{...ms(j),displayName:j.displayName.trim()})},onError:e=>l.error(ps(e)),onSuccess:()=>{b(null),v(ls),l.success("Account updated."),T()}}),O=f({mutationFn:({accountId:e,mode:t})=>Ne(r,e,{mode:t}),onError:(e,t)=>{X(t?.popup??null),u(t=>t?{...t,message:ps(e),status:"ERROR"}:t),l.error(ps(e))},onSuccess:(t,s)=>{T();const a=e.find(e=>e.id===s.accountId);W(t,s.popup,a)}}),R=f({mutationFn:e=>ye(r,e),onError:e=>l.error(ps(e)),onSuccess:e=>{X(),u(null),h(""),l.success(`Canceled authentication for ${e.displayName}.`),T()}}),L=f({mutationFn:({accountId:e,redirectUrl:t})=>Se(r,e,{redirectUrl:t.trim()}),onError:e=>{u(t=>t?{...t,message:ps(e),status:"ERROR"}:t),l.error(ps(e))},onSuccess:e=>{h(""),T(),W(e)}}),q=f({mutationFn:e=>Te(r,e),onError:e=>l.error(ps(e)),onSuccess:()=>{N(null),l.success("Account deleted."),T(),A.invalidateQueries({queryKey:["chats"]})}}),D=f({mutationFn:()=>Ae(r),onError:e=>l.error(ps(e)),onSuccess:e=>{!function(e){const t=new Blob([`${JSON.stringify(e,null,2)}\n`],{type:"application/json"}),s=URL.createObjectURL(t),a=window.document.createElement("a");a.href=s,a.download=`xedoc-accounts-${(new Date).toISOString().slice(0,10)}.json`,window.document.body.append(a),a.click(),a.remove(),URL.revokeObjectURL(s)}(e),l.success(`Exported ${e.accounts.length} ${xs(e.accounts.length)}. Keep the file private; it may include Codex auth tokens.`)}}),H=f({mutationFn:()=>le(r),onError:e=>l.error(ps(e)),onSuccess:e=>{A.setQueryData(E,e),e.inUse?l.warning(`${e.host}:${e.port} is still in use. The process may need more time to exit.`):l.success(function(e){const t=e.killedProcessIds??[];return t.length?`Killed ${1===t.length?"process":"processes"} ${t.join(", ")}.`:"Login callback port is available."}(e))}}),_=f({mutationFn:e=>ze(r,{accounts:e.accounts}),onError:(e,t)=>{t?.popup?.close(),l.error(ps(e))},onSuccess:(e,t)=>{l.success(`Imported ${e.imported} ${xs(e.imported)}.`),T(),A.invalidateQueries({queryKey:["chats"]}),function(e,t){const s=e.find(e=>e.authUrl);if(s){W(s,t);const a=e.filter(e=>e.authUrl&&e!==s).length;return void(a&&l.info(`${a} more ${xs(a)} need authentication.`))}t?.close();const a=e.filter(e=>"CONNECTED"===e.status).length;a&&l.success(`Connected ${a} imported ${xs(a)}.`)}(e.authentications,t.popup)}}),Q=f({mutationFn:()=>ge(r),onError:e=>l.error(ps(e)),onSuccess:e=>{l.success(`Imported ${e.imported} local ${xs(e.imported)}.`),T(),A.invalidateQueries({queryKey:["chats"]})}}),G=f({mutationFn:e=>ue(r,e),onError:e=>l.error(ps(e)),onSuccess:e=>{l.success(`${e.displayName} is now active in local Codex.`),T()}});async function V(){const e=P.data?.inUse?P.data:(await P.refetch()).data;return!e?.inUse||(l.error(`${e.host}:${e.port} is already in use. Kill the process or use Device Auth.`),!1)}async function B(e){if("browser"===e&&!(await V()))return void o(!1);const t=gs();C.current=t,o(!1),h(""),u({accountId:"",accountName:"Codex account",authUrl:null,message:"Creating account and starting Codex authentication.",mode:e,status:"AUTHENTICATING",userCode:null}),U.mutate({authMode:e,popup:t})}function W(e,t,s){if(u(function(e,t){return{accountId:e.accountId,accountName:t?.displayName??"Codex account",authUrl:e.authUrl??t?.lastAuthUrl??null,message:e.message??null,mode:e.authMode??es(t?.lastAuthMode)??"browser",status:e.status,userCode:e.userCode??t?.lastAuthUserCode??null}}(e,s)),e.authUrl)return C.current=t??C.current,fs(e.authUrl,t),void l.info("device"===e.authMode?"Device login page opened.":"Authentication page opened. xedoc is listening for the Codex callback.");X(t),"AUTHENTICATING"!==e.status?l.success(e.message??"Account is connected."):l.info(e.message??"Authentication is still in progress.")}function X(e=C.current){e&&!e.closed&&e.close(),e&&e!==C.current||(C.current=null)}return(0,$t.jsxs)($t.Fragment,{children:[(0,$t.jsx)("div",{className:"grid gap-5",children:(0,$t.jsxs)("section",{className:"grid gap-4",children:[(0,$t.jsx)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:(0,$t.jsxs)("div",{children:[(0,$t.jsx)("h3",{className:"text-sm font-semibold",children:"Accounts"}),(0,$t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Search, authenticate, and inspect current Codex quota."})]})}),(0,$t.jsx)(us,{browserAuthenticationInProgress:M,checking:P.isFetching,killing:H.isPending,status:P.data,onKill:()=>H.mutate(),onRefresh:()=>{P.refetch()}}),(0,$t.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,$t.jsxs)("div",{className:"relative min-w-0 flex-1 sm:min-w-64",children:[(0,$t.jsx)(Ft,{className:"pointer-events-none absolute top-1/2 left-2.5 size-4 -translate-y-1/2 text-muted-foreground"}),(0,$t.jsx)(mt,{className:"pl-8",placeholder:"Search accounts",value:x,onChange:e=>p(e.target.value)})]}),(0,$t.jsxs)("div",{className:"grid w-full grid-cols-2 gap-2 sm:flex sm:w-auto sm:flex-wrap sm:justify-end",children:[(0,$t.jsx)("input",{ref:S,accept:"application/json,.json",className:"hidden",type:"file",onChange:async function(e){const t=e.currentTarget.files?.[0];if(e.currentTarget.value="",!t)return;const s=gs();try{const e=JSON.parse(await t.text());_.mutate({accounts:hs(e),popup:s})}catch(a){s?.close(),l.error(ps(a))}}}),(0,$t.jsxs)(dt,{className:"w-full sm:w-auto",disabled:_.isPending,variant:"outline",onClick:()=>S.current?.click(),children:[_.isPending?(0,$t.jsx)(be,{className:"animate-spin"}):(0,$t.jsx)(Le,{}),"Import"]}),(0,$t.jsxs)(dt,{className:"w-full sm:w-auto",disabled:D.isPending,variant:"outline",onClick:()=>D.mutate(),children:[D.isPending?(0,$t.jsx)(be,{className:"animate-spin"}):(0,$t.jsx)(Ge,{}),"Export"]}),(0,$t.jsxs)(k,{open:i,onOpenChange:o,children:[(0,$t.jsxs)(Z,{render:(0,$t.jsx)(dt,{className:"w-full sm:w-auto"}),children:[U.isPending||Q.isPending?(0,$t.jsx)(be,{className:"animate-spin"}):(0,$t.jsx)(K,{}),"Add",(0,$t.jsx)(Ue,{"data-icon":"inline-end"})]}),(0,$t.jsxs)(J,{align:"end",className:"w-56",children:[(0,$t.jsxs)(w,{disabled:U.isPending,onClick:()=>B("browser"),children:[(0,$t.jsx)(yt,{}),"Normal Auth"]}),(0,$t.jsxs)(w,{disabled:U.isPending,onClick:()=>B("device"),children:[(0,$t.jsx)(ot,{}),"Device Auth"]}),(0,$t.jsx)(F,{}),(0,$t.jsxs)(w,{disabled:Q.isPending,onClick:()=>{o(!1),Q.mutate()},children:[Q.isPending?(0,$t.jsx)(be,{className:"animate-spin"}):(0,$t.jsx)(St,{}),"Import Local"]})]})]})]})]}),(0,$t.jsx)("div",{className:"grid gap-2",children:z.length?z.map(n=>(0,$t.jsx)(ss,{account:n,authPending:O.isPending&&O.variables?.accountId===n.id,authPendingMode:O.variables?.mode??"browser",cancelPending:R.isPending&&R.variables===n.id,localActivePending:G.isPending&&G.variables===n.id,quotaLabel:a[n.id],quotaPending:!!t[n.id],quotaSnapshot:s[n.id],onDelete:()=>N(n),onEdit:()=>function(e){var t;b(e),v({args:e.args.join(" "),command:e.command,displayName:e.displayName,environment:(t=e.environment,t?JSON.stringify(t,null,2):"")})}(n),onAuthenticate:t=>async function(t,s="browser"){if("browser"===s&&!(await V()))return;const a=e.find(e=>e.id===t),n=gs();C.current=n,h(""),u(ts(a,s)),O.mutate({accountId:t,mode:s,popup:n})}(n.id,t),onCancelAuthentication:()=>R.mutate(n.id),onSetLocalActive:()=>G.mutate(n.id),onShowAuthentication:()=>function(e){h(""),u(ts(e,es(e.lastAuthMode)??"browser"))}(n)},n.id)):(0,$t.jsx)("div",{className:"rounded-md border bg-background px-3 py-8 text-center text-sm text-muted-foreground",children:e.length?"No accounts match the current search.":"No accounts yet. Add an account or import account records."})})]})}),(0,$t.jsx)(Yt,{callbackUrl:m,cancelPending:R.isPending&&R.variables===d?.accountId,completePending:L.isPending,state:d,onCallbackUrlChange:h,onClose:()=>{u(null),h("")},onCancelAuthentication:()=>{d?.accountId&&R.mutate(d.accountId)},onComplete:()=>{d?.accountId&&L.mutate({accountId:d.accountId,redirectUrl:m})},onCopyDeviceCode:()=>{!async function(e){if(!e)return;try{await navigator.clipboard.writeText(e),l.success("Device code copied.")}catch{l.error("Could not copy device code.")}}(d?.userCode??"")},onReopen:()=>fs(d?.authUrl)}),(0,$t.jsx)(Je,{open:!!g,onOpenChange:e=>{e||I.isPending||(b(null),v(ls))},children:(0,$t.jsxs)(Ye,{className:"max-w-2xl",children:[(0,$t.jsxs)(tt,{children:[(0,$t.jsxs)(Ke,{children:["Edit ",g?.displayName??"account"]}),(0,$t.jsx)(He,{children:"Saving runtime settings disconnects the account until it is authenticated again."})]}),(0,$t.jsx)(ds,{form:j,onChange:v,prefix:`edit-account-${g?.id??"selected"}`}),(0,$t.jsxs)(Ve,{children:[(0,$t.jsxs)(dt,{variant:"outline",onClick:()=>{b(null),v(ls)},children:[(0,$t.jsx)($,{}),"Cancel"]}),(0,$t.jsxs)(dt,{disabled:!j.displayName.trim()||I.isPending,onClick:()=>I.mutate(),children:[I.isPending?(0,$t.jsx)(be,{className:"animate-spin"}):(0,$t.jsx)(te,{}),"Save account"]})]})]})}),(0,$t.jsx)(Kt,{open:!!y,onOpenChange:e=>{e||N(null)},children:(0,$t.jsxs)(Gt,{children:[(0,$t.jsxs)(Vt,{children:[(0,$t.jsx)(Wt,{children:"Delete account?"}),(0,$t.jsxs)(Jt,{children:["This removes ",y?.displayName??"the account"," from xedoc. Chats that reference it may no longer run."]})]}),(0,$t.jsxs)(Bt,{children:[(0,$t.jsx)(Xt,{children:"Cancel"}),(0,$t.jsxs)(Zt,{disabled:q.isPending,variant:"destructive",onClick:()=>{y&&q.mutate(y.id)},children:[q.isPending?(0,$t.jsx)(be,{className:"animate-spin"}):(0,$t.jsx)(Dt,{}),"Delete"]})]})]})})]})}function ds({form:e,onChange:t,prefix:s}){return(0,$t.jsxs)("div",{className:"grid gap-3",children:[(0,$t.jsxs)("div",{className:"grid gap-2",children:[(0,$t.jsx)(lt,{htmlFor:`${s}-name`,children:"Display name"}),(0,$t.jsx)(mt,{id:`${s}-name`,placeholder:"Work Codex",value:e.displayName,onChange:s=>t({...e,displayName:s.target.value})})]}),(0,$t.jsxs)("div",{className:"grid gap-3 md:grid-cols-2",children:[(0,$t.jsxs)("div",{className:"grid gap-2",children:[(0,$t.jsx)(lt,{htmlFor:`${s}-command`,children:"Command"}),(0,$t.jsx)(mt,{id:`${s}-command`,placeholder:"codex",value:e.command,onChange:s=>t({...e,command:s.target.value})})]}),(0,$t.jsxs)("div",{className:"grid gap-2",children:[(0,$t.jsx)(lt,{htmlFor:`${s}-args`,children:"Arguments"}),(0,$t.jsx)(mt,{id:`${s}-args`,placeholder:"app-server",value:e.args,onChange:s=>t({...e,args:s.target.value})})]})]}),(0,$t.jsxs)("div",{className:"grid gap-2",children:[(0,$t.jsx)(lt,{htmlFor:`${s}-environment`,children:"Environment JSON"}),(0,$t.jsx)(y,{className:"min-h-20 font-mono text-xs",id:`${s}-environment`,placeholder:'{"OPENAI_BASE_URL":"https://..."}',value:e.environment,onChange:s=>t({...e,environment:s.target.value})})]})]})}function us({browserAuthenticationInProgress:e,checking:t,killing:s,status:a,onKill:n,onRefresh:r}){if(!a?.inUse)return null;const i=function(e){return e.processes.length?e.processes.map(e=>[e.command??"process",`PID ${e.pid}`,e.user?`user ${e.user}`:null].filter(Boolean).join(" ")).join(", "):null}(a),o=1===a.processes.length?"Kill Process":"Kill Processes";return(0,$t.jsxs)("div",{className:"flex flex-col gap-3 rounded-md border border-amber-300 bg-amber-50 px-3 py-3 text-amber-950 dark:border-amber-900/70 dark:bg-amber-950/35 dark:text-amber-100 sm:flex-row sm:items-start sm:justify-between",children:[(0,$t.jsxs)("div",{className:"flex min-w-0 gap-2",children:[(0,$t.jsx)(ft,{className:"mt-0.5 size-4 shrink-0 text-amber-600 dark:text-amber-300"}),(0,$t.jsxs)("div",{className:"grid min-w-0 gap-1",children:[(0,$t.jsx)("div",{className:"text-sm font-medium",children:"Login callback port is busy"}),(0,$t.jsx)("p",{className:"text-sm leading-relaxed",children:e?`${a.host}:${a.port} is already listening for a browser login. Starting another Normal Auth can fail while this listener is active.`:`${a.host}:${a.port} is already listening. Normal Auth can fail until this process is stopped.`}),(0,$t.jsx)("p",{className:"break-words text-xs text-amber-800 dark:text-amber-200/80",children:i??"Process details are unavailable."})]})]}),(0,$t.jsxs)("div",{className:"flex shrink-0 flex-wrap gap-2 sm:justify-end",children:[(0,$t.jsxs)(dt,{disabled:t||s,size:"sm",variant:"outline",onClick:r,children:[t?(0,$t.jsx)(be,{className:"animate-spin"}):(0,$t.jsx)(Ot,{}),"Refresh"]}),(0,$t.jsxs)(dt,{disabled:!a.killable||s,size:"sm",variant:"destructive",onClick:n,children:[s?(0,$t.jsx)(be,{className:"animate-spin"}):(0,$t.jsx)(It,{}),o]})]})]})}function ms(e){const t={};if(e.command.trim()&&(t.command=e.command.trim()),e.args.trim()&&(t.args=e.args.split(/\s+/).map(e=>e.trim()).filter(Boolean)),e.environment.trim()){const s=JSON.parse(e.environment);if(!s||"object"!=typeof s||Array.isArray(s))throw new Error("Environment must be a JSON object.");t.environment=s}return t}function hs(e){if(Array.isArray(e))return e;if(e&&"object"==typeof e){const t=e.accounts;if(Array.isArray(t))return t}throw new Error("Import file must contain an accounts array.")}function xs(e){return 1===e?"account":"accounts"}function ps(e){return e instanceof Error?e.message:"Request failed."}function gs(){const e=window.open("about:blank","_blank");return e&&(e.opener=null),e}function fs(e,t){e?!t||t.closed?window.open(e,"_blank","noopener,noreferrer"):t.location.href=e:t?.close()}function bs({className:e,orientation:t="horizontal",...s}){return(0,$t.jsx)(V,{"data-slot":"separator",orientation:t,className:fe("shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch",e),...s})}function js({accounts:e,accountRateLimitFetching:t,accountRateLimitSnapshots:s,accountUsageSummaries:a,activeTab:n,createFocusKey:r,onOpenChange:i,onTabChange:o,open:l,session:c}){return(0,$t.jsx)(Je,{open:l,onOpenChange:i,children:(0,$t.jsxs)(Ye,{className:"max-h-[92vh] max-w-5xl gap-0 overflow-hidden p-0",children:[(0,$t.jsxs)(tt,{className:"px-5 py-4",children:[(0,$t.jsx)(Ke,{children:"Settings"}),(0,$t.jsx)(He,{children:"Manage accounts, personalization, and project details."})]}),(0,$t.jsx)(bs,{}),(0,$t.jsxs)("div",{className:"grid min-h-0 md:grid-cols-[11rem_minmax(0,1fr)]",children:[(0,$t.jsxs)("nav",{className:"flex gap-2 overflow-x-auto border-b p-3 md:flex-col md:border-r md:border-b-0",children:[(0,$t.jsx)(vs,{active:"accounts"===n,icon:(0,$t.jsx)(W,{}),label:"Accounts",onClick:()=>o("accounts")}),(0,$t.jsx)(vs,{active:"personalization"===n,icon:(0,$t.jsx)(z,{}),label:"Personalization",onClick:()=>o("personalization")}),(0,$t.jsx)(vs,{active:"info"===n,icon:(0,$t.jsx)(ie,{}),label:"Info",onClick:()=>o("info")})]}),(0,$t.jsx)(C,{className:"h-[74vh]",children:(0,$t.jsxs)("div",{className:"p-5",children:["personalization"===n?(0,$t.jsx)(ys,{session:c}):null,"accounts"===n?(0,$t.jsx)(cs,{accounts:e,accountRateLimitFetching:t,accountRateLimitSnapshots:s,accountUsageSummaries:a,createFocusKey:r,session:c}):null,"info"===n?(0,$t.jsx)(Ns,{}):null]})})]})]})})}function vs({active:e,icon:t,label:s,onClick:a}){return(0,$t.jsxs)(dt,{"aria-pressed":e,className:fe("justify-start",e&&"bg-muted text-foreground hover:bg-muted"),variant:"ghost",onClick:a,children:[t,s]})}function ys({session:e}){const[t,s]=(0,pt.useState)(""),a=c(),n=Y({queryKey:["account-personalization"],queryFn:()=>pe(e)});(0,pt.useEffect)(()=>{n.data&&s(n.data.instructions)},[n.data]);const r=f({mutationFn:()=>ce(e,{instructions:t}),onError:e=>l.error(ws(e)),onSuccess:e=>{a.setQueryData(["account-personalization"],e),a.invalidateQueries({queryKey:["account-personalization"]}),l.success("Personalization saved.")}}),i=(0,pt.useMemo)(()=>(new TextEncoder).encode(t).length,[t]),o=n.data?.maxBytes??32768,d=!!n.data&&t!==n.data.instructions,u=i>o;return(0,$t.jsxs)("div",{className:"grid gap-5",children:[(0,$t.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,$t.jsxs)("div",{children:[(0,$t.jsx)("h3",{className:"flex items-center text-sm font-semibold",children:"Custom instructions"}),(0,$t.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:"Saved to the shared Codex personalization file."})]}),(0,$t.jsxs)("div",{className:fe("text-xs text-muted-foreground",u&&"text-destructive"),children:[i.toLocaleString()," / ",o.toLocaleString()," bytes"]})]}),(0,$t.jsxs)("div",{className:"grid gap-2",children:[(0,$t.jsx)(lt,{htmlFor:"personalization-instructions",children:"AGENTS.md"}),(0,$t.jsx)(y,{className:"min-h-72 font-mono text-xs leading-relaxed",disabled:n.isLoading||r.isPending,id:"personalization-instructions",placeholder:"## Working agreements\n\n- Prefer concise answers.\n- Run relevant tests after code changes.",value:t,onChange:e=>s(e.target.value)})]}),n.error?(0,$t.jsx)("p",{className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:ws(n.error)}):null,(0,$t.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,$t.jsx)("div",{}),(0,$t.jsxs)("div",{className:"flex flex-wrap justify-end gap-2",children:[(0,$t.jsxs)(dt,{disabled:n.isFetching,variant:"outline",onClick:()=>{n.refetch()},children:[n.isFetching?(0,$t.jsx)(be,{className:"animate-spin"}):(0,$t.jsx)(_,{}),"Reload"]}),(0,$t.jsxs)(dt,{disabled:!d||r.isPending,variant:"secondary",onClick:()=>s(n.data?.instructions??""),children:[(0,$t.jsx)(_,{}),"Reset"]}),(0,$t.jsxs)(dt,{disabled:!d||u||n.isLoading||r.isPending,onClick:()=>r.mutate(),children:[r.isPending?(0,$t.jsx)(be,{className:"animate-spin"}):(0,$t.jsx)(Rt,{}),"Save"]})]})]})]})}function Ns(){return(0,$t.jsxs)("div",{className:"grid gap-4",children:[(0,$t.jsxs)("section",{className:"rounded-md border bg-muted/30 p-4",children:[(0,$t.jsxs)("div",{className:"flex items-center gap-2 text-sm font-medium",children:[(0,$t.jsx)(ie,{}),"Project"]}),(0,$t.jsx)("div",{className:"mt-2 text-sm text-muted-foreground",children:"xedoc"})]}),(0,$t.jsxs)("section",{className:"grid gap-3 rounded-md border bg-muted/30 p-4",children:[(0,$t.jsx)("h3",{className:"text-sm font-semibold",children:"Contact"}),(0,$t.jsxs)("a",{className:"inline-flex w-fit items-center gap-2 text-sm text-primary underline-offset-4 hover:underline",href:"https://github.com/monokaijs/xedoc",rel:"noreferrer",target:"_blank",children:[(0,$t.jsx)(yt,{className:"size-4"}),"GitHub: monokaijs/xedoc"]}),(0,$t.jsxs)("a",{className:"inline-flex w-fit items-center gap-2 text-sm text-primary underline-offset-4 hover:underline",href:"mailto:monokaijs@gmail.com",children:[(0,$t.jsx)(Et,{className:"size-4"}),"Email: monokaijs@gmail.com"]})]})]})}function ws(e){return e instanceof Error?e.message:"Request failed."}function ks(){const{setTheme:e,theme:t}=oe(),s=t??"system";return(0,$t.jsxs)(k,{children:[(0,$t.jsxs)(Z,{render:(0,$t.jsx)(dt,{size:"icon",variant:"ghost"}),children:[(0,$t.jsx)(qt,{className:"size-4 dark:hidden"}),(0,$t.jsx)(zt,{className:"hidden size-4 dark:block"}),(0,$t.jsx)("span",{className:"sr-only",children:"Theme"})]}),(0,$t.jsxs)(J,{align:"end",className:"w-40",children:[(0,$t.jsxs)(w,{onClick:()=>e("light"),children:[(0,$t.jsx)(qt,{}),"Light","light"===s?(0,$t.jsx)(ee,{className:"ml-auto"}):null]}),(0,$t.jsxs)(w,{onClick:()=>e("dark"),children:[(0,$t.jsx)(zt,{}),"Dark","dark"===s?(0,$t.jsx)(ee,{className:"ml-auto"}):null]}),(0,$t.jsxs)(w,{onClick:()=>e("system"),children:[(0,$t.jsx)(At,{}),"System","system"===s?(0,$t.jsx)(ee,{className:"ml-auto"}):null]})]})]})}function Cs({...e}){return(0,$t.jsx)(rt,{"data-slot":"sheet",...e})}function Ss({...e}){return(0,$t.jsx)(Be,{"data-slot":"sheet-portal",...e})}function As({className:e,...t}){return(0,$t.jsx)(st,{"data-slot":"sheet-overlay",className:fe("fixed inset-0 z-50 bg-black/10 transition-opacity duration-150 data-ending-style:opacity-0 data-starting-style:opacity-0 supports-backdrop-filter:backdrop-blur-xs",e),...t})}function Es({className:e,children:t,side:s="right",showCloseButton:a=!0,...n}){return(0,$t.jsxs)(Ss,{children:[(0,$t.jsx)(As,{}),(0,$t.jsxs)(Qe,{"data-slot":"sheet-content","data-side":s,className:fe("fixed z-50 flex flex-col gap-4 bg-popover bg-clip-padding text-sm text-popover-foreground shadow-lg transition duration-200 ease-in-out data-ending-style:opacity-0 data-starting-style:opacity-0 data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=bottom]:data-ending-style:translate-y-[2.5rem] data-[side=bottom]:data-starting-style:translate-y-[2.5rem] data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-3/4 data-[side=left]:border-r data-[side=left]:data-ending-style:translate-x-[-2.5rem] data-[side=left]:data-starting-style:translate-x-[-2.5rem] data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-3/4 data-[side=right]:border-l data-[side=right]:data-ending-style:translate-x-[2.5rem] data-[side=right]:data-starting-style:translate-x-[2.5rem] data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-[side=top]:data-ending-style:translate-y-[-2.5rem] data-[side=top]:data-starting-style:translate-y-[-2.5rem] data-[side=left]:sm:max-w-sm data-[side=right]:sm:max-w-sm",e),...n,children:[t,a&&(0,$t.jsxs)(qe,{"data-slot":"sheet-close",render:(0,$t.jsx)(dt,{variant:"ghost",className:"absolute top-3 right-3",size:"icon-sm"}),children:[(0,$t.jsx)($,{}),(0,$t.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})}function Ps({className:e,...t}){return(0,$t.jsx)("div",{"data-slot":"sheet-header",className:fe("flex flex-col gap-0.5 p-4",e),...t})}function Ts({className:e,...t}){return(0,$t.jsx)(Ze,{"data-slot":"sheet-title",className:fe("font-heading text-base font-medium text-foreground",e),...t})}function zs({className:e,...t}){return(0,$t.jsx)(_e,{"data-slot":"sheet-description",className:fe("text-sm text-muted-foreground",e),...t})}var Ms=pt.createContext(null);function Us(){const e=pt.useContext(Ms);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}function Is({defaultOpen:e=!0,open:t,onOpenChange:s,className:a,style:n,children:r,...i}){const o=function(){const[e,t]=pt.useState(()=>"undefined"!=typeof window&&window.innerWidth<768);return pt.useEffect(()=>{const e=window.matchMedia("(max-width: 767px)"),s=()=>{t(window.innerWidth<768)};return e.addEventListener("change",s),()=>e.removeEventListener("change",s)},[]),e}(),[l,c]=pt.useState(!1),[d,u]=pt.useState(e),m=t??d,h=pt.useCallback(e=>{const t="function"==typeof e?e(m):e;s?s(t):u(t),document.cookie=`sidebar_state=${t}; path=/; max-age=604800`},[s,m]),x=pt.useCallback(()=>o?c(e=>!e):h(e=>!e),[o,h,c]);pt.useEffect(()=>{const e=e=>{"b"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),x())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[x]);const p=m?"expanded":"collapsed",g=pt.useMemo(()=>({state:p,open:m,setOpen:h,isMobile:o,openMobile:l,setOpenMobile:c,toggleSidebar:x}),[p,m,h,o,l,c,x]);return(0,$t.jsx)(Ms.Provider,{value:g,children:(0,$t.jsx)("div",{"data-slot":"sidebar-wrapper",style:{"--sidebar-width":"16rem","--sidebar-width-icon":"3rem",...n},className:fe("group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar",a),...i,children:r})})}function Os({side:e="left",variant:t="sidebar",collapsible:s="offcanvas",className:a,children:n,dir:r,...i}){const{isMobile:o,state:l,openMobile:c,setOpenMobile:d}=Us();return"none"===s?(0,$t.jsx)("div",{"data-slot":"sidebar",className:fe("flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground",a),...i,children:n}):o?(0,$t.jsx)(Cs,{open:c,onOpenChange:d,...i,children:(0,$t.jsxs)(Es,{dir:r,"data-sidebar":"sidebar","data-slot":"sidebar","data-mobile":"true",className:"w-(--sidebar-width) bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden",style:{"--sidebar-width":"18rem"},side:e,children:[(0,$t.jsxs)(Ps,{className:"sr-only",children:[(0,$t.jsx)(Ts,{children:"Sidebar"}),(0,$t.jsx)(zs,{children:"Displays the mobile sidebar."})]}),(0,$t.jsx)("div",{className:"flex h-full w-full flex-col",children:n})]})}):(0,$t.jsxs)("div",{className:"group peer hidden text-sidebar-foreground md:block","data-state":l,"data-collapsible":"collapsed"===l?s:"","data-variant":t,"data-side":e,"data-slot":"sidebar",children:[(0,$t.jsx)("div",{"data-slot":"sidebar-gap",className:fe("relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear","group-data-[collapsible=offcanvas]:w-0","group-data-[side=right]:rotate-180","floating"===t||"inset"===t?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]":"group-data-[collapsible=icon]:w-(--sidebar-width-icon)")}),(0,$t.jsx)("div",{"data-slot":"sidebar-container","data-side":e,className:fe("fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear data-[side=left]:left-0 data-[side=left]:group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)] data-[side=right]:right-0 data-[side=right]:group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)] md:flex","floating"===t||"inset"===t?"p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]":"group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l",a),...i,children:(0,$t.jsx)("div",{"data-sidebar":"sidebar","data-slot":"sidebar-inner",className:"flex size-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:shadow-sm group-data-[variant=floating]:ring-1 group-data-[variant=floating]:ring-sidebar-border",children:n})})]})}function Rs({className:e,onClick:t,...s}){const{toggleSidebar:a}=Us();return(0,$t.jsxs)(dt,{"data-sidebar":"trigger","data-slot":"sidebar-trigger",variant:"ghost",size:"icon-sm",className:fe(e),onClick:e=>{t?.(e),a()},...s,children:[(0,$t.jsx)(Mt,{}),(0,$t.jsx)("span",{className:"sr-only",children:"Toggle Sidebar"})]})}function Fs({className:e,...t}){return(0,$t.jsx)("main",{"data-slot":"sidebar-inset",className:fe("relative flex w-full flex-1 flex-col bg-background md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2",e),...t})}function Ls({className:e,...t}){return(0,$t.jsx)("div",{"data-slot":"sidebar-header","data-sidebar":"header",className:fe("flex flex-col gap-2 p-2",e),...t})}function qs({className:e,...t}){return(0,$t.jsx)("div",{"data-slot":"sidebar-footer","data-sidebar":"footer",className:fe("flex flex-col gap-2 p-2",e),...t})}function Ds({className:e,...t}){return(0,$t.jsx)("div",{"data-slot":"sidebar-content","data-sidebar":"content",className:fe("no-scrollbar flex min-h-0 flex-1 flex-col gap-0 overflow-auto group-data-[collapsible=icon]:overflow-hidden",e),...t})}function $s({className:e,...t}){return(0,$t.jsx)("div",{"data-slot":"sidebar-group","data-sidebar":"group",className:fe("relative flex w-full min-w-0 flex-col p-2",e),...t})}function Hs({className:e,render:t,...s}){return R({defaultTagName:"div",props:de({className:fe("flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 ring-sidebar-ring outline-hidden transition-[margin,opacity] duration-200 ease-linear group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0 focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",e)},s),render:t,state:{slot:"sidebar-group-label",sidebar:"group-label"}})}function Ks({className:e,...t}){return(0,$t.jsx)("div",{"data-slot":"sidebar-group-content","data-sidebar":"group-content",className:fe("w-full text-sm",e),...t})}function _s({className:e,...t}){return(0,$t.jsx)("ul",{"data-slot":"sidebar-menu","data-sidebar":"menu",className:fe("flex w-full min-w-0 flex-col gap-0",e),...t})}function Qs({className:e,...t}){return(0,$t.jsx)("li",{"data-slot":"sidebar-menu-item","data-sidebar":"menu-item",className:fe("group/menu-item relative",e),...t})}var Gs=ut("peer/menu-button group/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm ring-sidebar-ring outline-hidden transition-[width,height,padding] group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-open:hover:bg-sidebar-accent data-open:hover:text-sidebar-accent-foreground data-active:bg-sidebar-accent data-active:font-medium data-active:text-sidebar-accent-foreground [&_svg]:size-4 [&_svg]:shrink-0 [&>span:last-child]:truncate",{variants:{variant:{default:"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",outline:"bg-background shadow-[0_0_0_1px_var(--sidebar-border)] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_var(--sidebar-accent)]"},size:{default:"h-8 text-sm",sm:"h-7 text-xs",lg:"h-12 text-sm group-data-[collapsible=icon]:p-0!"}},defaultVariants:{variant:"default",size:"default"}});function Vs({render:e,isActive:t=!1,variant:s="default",size:a="default",tooltip:n,className:r,...i}){const{isMobile:o,state:l}=Us(),c=R({defaultTagName:"button",props:de({className:fe(Gs({variant:s,size:a}),r)},i),render:n?(0,$t.jsx)(ne,{render:e}):e,state:{slot:"sidebar-menu-button",sidebar:"menu-button",size:a,active:t}});return n?("string"==typeof n&&(n={children:n}),(0,$t.jsxs)(re,{children:[c,(0,$t.jsx)(se,{side:"right",align:"center",hidden:"collapsed"!==l||o,...n})]})):c}function Bs({initialPath:e,mode:t="directory",onOpenChange:s,onSelect:a,open:n,session:r}){const i=c(),[o,d]=(0,pt.useState)(new Set),[u,m]=(0,pt.useState)(e??""),[h,x]=(0,pt.useState)("directory"),[p,g]=(0,pt.useState)(e??""),[b,j]=(0,pt.useState)(""),[v,y]=(0,pt.useState)(!0),[N,w]=(0,pt.useState)(!1),[k,S]=(0,pt.useState)(""),[A,E]=(0,pt.useState)(""),P=Y({enabled:n,queryKey:ta(r,void 0),queryFn:()=>we(r,void 0)}),T=P.data,z=T?.root??T?.path??"",M=u||T?.path||"",U=f({mutationFn:()=>{const e=k||M||T?.path,t=A.trim();if(!e)throw new Error("Select a folder first.");if(!t)throw new Error("Enter a folder name.");return Ce(r,{parentPath:e,name:t})},onError:e=>l.error(function(e){return e instanceof Error?e.message:"Request failed."}(e)),onSuccess:e=>{w(!1),S(""),E(""),l.success("Folder created."),i.invalidateQueries({queryKey:["workspace-directory",r.serverUrl]}),O(e.path)}});function I(e,t="directory"){m(e),x(t),g(e),z&&d(t=>{const s=new Set(t);for(const a of sa(e,z))s.add(a);return s})}function O(e){m(e),x("directory"),g(e),d(t=>new Set(t).add(e))}function R(){const e=p.trim()||T?.path;e&&I(e)}return(0,pt.useEffect)(()=>{n&&(d(new Set),m(e??""),x("directory"),g(e??""),j(""),y(!0),w(!1),S(""),E(""))},[e,n]),(0,pt.useEffect)(()=>{if(!T)return;const t=e||T.path;m(e=>e||t),g(e=>e||t),d(e=>{const s=new Set(e);for(const a of sa(t,T.root))s.add(a);return s})},[e,T]),(0,$t.jsx)(Je,{open:n,onOpenChange:s,children:(0,$t.jsxs)(Ye,{className:"flex max-h-[88vh] max-w-2xl flex-col gap-0 overflow-hidden rounded-xl bg-background p-0 ring-border sm:max-w-2xl",children:[(0,$t.jsxs)(tt,{className:"gap-1 px-4 pb-2 pt-3",children:[(0,$t.jsx)(Ke,{children:"file"===t?"Choose Workspace File":"Choose Working Directory"}),(0,$t.jsx)(He,{className:"truncate",children:T?.root?`Workspace root: ${T.root}`:"file"===t?"Pick a file from the workspace.":"Pick a project folder for Codex."})]}),(0,$t.jsxs)("div",{className:"grid min-h-0 flex-1 grid-rows-[auto_minmax(0,1fr)]",children:[(0,$t.jsxs)("div",{className:"grid gap-1.5 px-3 pb-2 pt-1",children:[(0,$t.jsxs)("div",{className:"flex min-w-0 items-center gap-1",children:[(0,$t.jsx)(ea,{label:"Home",onClick:function(){T?.path&&O(T.path)},children:(0,$t.jsx)(Ct,{})}),(0,$t.jsx)(ea,{disabled:!M||U.isPending,label:"New folder",onClick:function(){const e=M||T?.path;e&&(m(e),x("directory"),g(e),j(""),w(!0),S(e),E(""),d(t=>{const s=new Set(t);if(z)for(const a of sa(e,z))s.add(a);return s.add(e),s}))},children:(0,$t.jsx)(wt,{})}),(0,$t.jsx)(ea,{label:"Refresh",onClick:function(){i.invalidateQueries({queryKey:["workspace-directory",r.serverUrl]})},children:(0,$t.jsx)(_,{className:fe(P.isFetching&&"animate-spin")})}),(0,$t.jsxs)("div",{className:"ml-auto flex min-w-0 items-center gap-2",children:[(0,$t.jsx)(Ys,{showPath:v,onClick:()=>y(e=>!e)}),(0,$t.jsxs)("div",{className:"relative hidden min-w-0 sm:block",children:[(0,$t.jsx)(Ft,{className:"pointer-events-none absolute left-2 top-1.5 size-4 text-muted-foreground"}),(0,$t.jsx)(mt,{className:"h-7 w-44 border-border/70 bg-muted/40 pl-7 text-xs",placeholder:"Filter",value:b,onChange:e=>j(e.target.value)})]})]})]}),v?(0,$t.jsxs)("div",{className:"flex min-w-0 items-center gap-1",children:[(0,$t.jsx)(mt,{autoCapitalize:"none",className:"h-8 min-w-0 border-border/70 bg-muted/40 font-mono text-xs",spellCheck:!1,value:p,onChange:e=>g(e.target.value),onKeyDown:e=>{"Enter"===e.key&&R()}}),(0,$t.jsx)(ea,{label:"Open path",onClick:R,children:(0,$t.jsx)(L,{})})]}):null,(0,$t.jsxs)("div",{className:"flex min-w-0 items-center gap-2 sm:hidden",children:[(0,$t.jsx)(Ys,{showPath:v,onClick:()=>y(e=>!e)}),(0,$t.jsxs)("div",{className:"relative min-w-0 flex-1",children:[(0,$t.jsx)(Ft,{className:"pointer-events-none absolute left-2 top-1.5 size-4 text-muted-foreground"}),(0,$t.jsx)(mt,{className:"h-7 border-border/70 bg-muted/40 pl-7 text-xs",placeholder:"Filter",value:b,onChange:e=>j(e.target.value)})]})]})]}),(0,$t.jsx)("div",{className:"min-h-0 bg-background",children:P.error?(0,$t.jsx)("div",{className:"m-3 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:P.error.message||"Unable to browse workspace."}):(0,$t.jsx)(C,{className:"h-[46vh] min-h-72",children:(0,$t.jsxs)("div",{className:"p-1",children:[P.isLoading?(0,$t.jsx)("div",{className:"px-3 py-8 text-center text-sm text-muted-foreground",children:"Loading directories..."}):null,T?(0,$t.jsx)(Ws,{directory:T,entry:{name:(F=T.path,F.replace(/[\\/]+$/,"").split(/[\\/]/).filter(Boolean).at(-1)||F),path:T.path,type:"directory"},expandedPaths:o,filter:b,level:0,createFolderName:A,createFolderParentPath:k,createFolderPending:U.isPending,selectedPath:M,selectedType:h,session:r,showCreateFolder:N,onCancelCreateFolder:()=>{w(!1),S(""),E("")},onCreateFolderNameChange:E,onCreateFolderSubmit:()=>U.mutate(),onOpen:O,onSelect:I,onToggle:function(e){m(e),x("directory"),g(e),d(t=>{const s=new Set(t);return s.has(e)?s.delete(e):s.add(e),s})}}):null]})})})]}),(0,$t.jsxs)(Ve,{className:"mx-0 mb-0 rounded-none border-t bg-muted/35 px-3 py-2 sm:items-center sm:justify-between",children:[(0,$t.jsxs)("div",{className:"min-w-0 flex-1 truncate text-xs text-muted-foreground",children:[(0,$t.jsx)("span",{className:"mr-1 font-medium text-foreground",children:"Selected:"}),(0,$t.jsx)("span",{className:"font-mono",children:"file"===t&&"file"!==h?"Choose a file":M||z||"None"})]}),(0,$t.jsxs)("div",{className:"flex shrink-0 justify-end gap-2",children:[(0,$t.jsxs)(dt,{disabled:!M||"file"===t&&"file"!==h,size:"sm",type:"button",onClick:function(){!M||"file"===t&&"file"!==h||(a(M),s(!1))},children:[(0,$t.jsx)(ee,{}),"file"===t?"Attach":"OK"]}),(0,$t.jsx)(dt,{size:"sm",type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"})]})]})]})});var F}function Ws({createFolderName:e,createFolderParentPath:t,createFolderPending:s,directory:a,entry:n,expandedPaths:r,filter:i,level:o,onCancelCreateFolder:l,onCreateFolderNameChange:c,onCreateFolderSubmit:d,onOpen:u,onSelect:m,onToggle:h,selectedPath:x,selectedType:p,session:g,showCreateFolder:f}){const b=r.has(n.path),j=ra(x)===ra(n.path),v=f&&ra(t)===ra(n.path),y=Y({enabled:b&&!a,queryKey:ta(g,n.path),queryFn:()=>we(g,n.path)}),N=a??y.data,w=(0,pt.useMemo)(()=>function(e,t){const s=t.trim().toLocaleLowerCase();return(s?e.filter(e=>e.name.toLocaleLowerCase().includes(s)):e).slice(0,400)}(N?.entries??[],i),[N?.entries,i]),k=w.filter(e=>"directory"===e.type),C=w.filter(e=>"directory"!==e.type);return(0,$t.jsxs)("div",{className:"min-w-0",children:[(0,$t.jsx)(Zs,{entry:n,expanded:b,level:o,loading:y.isFetching,selected:j,onOpen:u,onSelect:m,onToggle:h}),b?(0,$t.jsxs)("div",{className:"min-w-0",children:[y.error?(0,$t.jsx)("div",{className:"h-7 truncate px-2 text-xs leading-7 text-destructive",style:{paddingLeft:34+18*(o+1)+"px"},children:y.error.message||"Unable to load folder."}):null,y.isLoading?(0,$t.jsx)("div",{className:"h-7 truncate px-2 text-xs leading-7 text-muted-foreground",style:{paddingLeft:34+18*(o+1)+"px"},children:"Loading..."}):null,v?(0,$t.jsx)(Js,{level:o+1,name:e,pending:s,onCancel:l,onNameChange:c,onSubmit:d}):null,k.map(a=>(0,$t.jsx)(Ws,{createFolderName:e,createFolderParentPath:t,createFolderPending:s,entry:a,expandedPaths:r,filter:i,level:o+1,showCreateFolder:f,selectedPath:x,selectedType:p,session:g,onCancelCreateFolder:l,onCreateFolderNameChange:c,onCreateFolderSubmit:d,onOpen:u,onSelect:m,onToggle:h},a.path)),C.map(e=>(0,$t.jsx)(Xs,{entry:e,level:o+1,selected:"file"===p&&ra(x)===ra(e.path),onSelect:m},e.path)),!N||w.length||v?null:(0,$t.jsx)("div",{className:"h-7 truncate px-2 text-xs leading-7 text-muted-foreground",style:{paddingLeft:34+18*(o+1)+"px"},children:"No matching entries."})]}):null]})}function Js({level:e,name:t,onCancel:s,onNameChange:a,onSubmit:n,pending:r}){return(0,$t.jsxs)("form",{className:"grid h-8 min-w-0 grid-cols-[1.5rem_1rem_minmax(0,1fr)_auto_auto] items-center gap-1 rounded-sm px-1 text-sm",style:{paddingLeft:4+18*e+"px"},onSubmit:e=>{e.preventDefault(),n()},children:[(0,$t.jsx)("span",{}),(0,$t.jsx)(wt,{className:"size-4 shrink-0 text-muted-foreground"}),(0,$t.jsx)(mt,{autoCapitalize:"none",autoFocus:!0,className:"h-7 min-w-0 border-border/70 bg-muted/40 text-xs",disabled:r,placeholder:"Folder name",spellCheck:!1,value:t,onChange:e=>a(e.target.value)}),(0,$t.jsx)(ea,{disabled:!t.trim()||r,label:"Create folder",onClick:n,children:(0,$t.jsx)(ee,{})}),(0,$t.jsx)(ea,{disabled:r,label:"Cancel new folder",onClick:s,children:(0,$t.jsx)($,{})})]})}function Zs({entry:e,expanded:t,level:s,loading:a,onOpen:n,onSelect:r,onToggle:i,selected:o}){return(0,$t.jsxs)("div",{className:fe("group grid h-7 min-w-0 grid-cols-[1.5rem_1rem_minmax(0,1fr)] items-center gap-1 rounded-sm px-1 text-sm",o?"bg-accent text-accent-foreground":"text-foreground hover:bg-accent/55"),style:{paddingLeft:4+18*s+"px"},children:[(0,$t.jsx)("button",{className:"flex size-6 items-center justify-center rounded-sm text-muted-foreground hover:bg-muted hover:text-foreground",title:t?"Collapse":"Expand",type:"button",onClick:()=>i(e.path),children:(0,$t.jsx)(L,{className:fe("size-4 transition-transform",t&&"rotate-90",a&&"opacity-50")})}),t?(0,$t.jsx)(it,{className:"size-4 shrink-0 text-muted-foreground"}):(0,$t.jsx)(kt,{className:"size-4 shrink-0 text-muted-foreground"}),(0,$t.jsx)("button",{className:"min-w-0 truncate text-left",title:e.path,type:"button",onClick:()=>r(e.path),onDoubleClick:()=>n(e.path),children:e.name})]})}function Xs({entry:e,level:t,onSelect:s,selected:a}){return(0,$t.jsxs)("button",{className:fe("grid h-7 min-w-0 w-full grid-cols-[1.5rem_1rem_minmax(0,1fr)] items-center gap-1 rounded-sm px-1 text-left text-sm",a?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-accent/55 hover:text-foreground"),style:{paddingLeft:4+18*t+"px"},title:e.path,type:"button",onClick:()=>s(e.path,"file"),children:[(0,$t.jsx)("span",{}),(0,$t.jsx)(X,{className:"size-4 shrink-0"}),(0,$t.jsx)("span",{className:"min-w-0 truncate",children:e.name})]})}function Ys({onClick:e,showPath:t}){return(0,$t.jsx)(ea,{label:t?"Hide path":"Show path",pressed:t,onClick:e,children:t?(0,$t.jsx)(Re,{}):(0,$t.jsx)(Nt,{})})}function ea({children:e,disabled:t,label:s,onClick:a,pressed:n}){return(0,$t.jsxs)(dt,{"aria-pressed":n,className:fe("size-7 p-0",n&&"bg-muted text-foreground"),disabled:t,size:"icon",title:s,type:"button",variant:"ghost",onClick:a,children:[e,(0,$t.jsx)("span",{className:"sr-only",children:s})]})}function ta(e,t){return["workspace-directory",e.serverUrl,t]}function sa(e,t){const s=na(t),a=na(e);if(!s||!a.startsWith(s))return s?[s]:[];const n=[s],r=a.slice(s.length).replace(/^[\\/]+/,"");let i=s;for(const o of r.split(/[\\/]/).filter(Boolean))i=aa(i,o),n.push(i);return n}function aa(e,t){const s=e.includes("\\")?"\\":"/";return`${na(e)}${s}${t}`}function na(e){return"/"===e||/^[A-Za-z]:[\\/]?$/.test(e)?e.replace(/[\\/]+$/,"")||e:e.replace(/[\\/]+$/,"")}function ra(e){return na(e).toLocaleLowerCase()}function ia({chats:e,session:t}){const s=r(),{chatId:a}=n(),i=c(),[o,d]=(0,pt.useState)(null),[u,m]=(0,pt.useState)(""),[h,x]=(0,pt.useState)(null),[p,g]=(0,pt.useState)(()=>new Set),[b,v]=(0,pt.useState)(()=>new Set),y=(0,pt.useMemo)(()=>e.map(e=>({chat:e,dateLabel:H(e.lastActivityAt),folderKey:q(e.workingDirectory),folderName:D(e.workingDirectory),folderPath:B(e.workingDirectory)})),[e]),N=(0,pt.useMemo)(()=>{const e=new Map;for(const t of y){const s=new Date(t.chat.lastActivityAt).getTime(),a=e.get(t.folderKey);a?(a.items.push(t),a.latestActivityAt=Math.max(a.latestActivityAt,s)):e.set(t.folderKey,{items:[t],key:t.folderKey,latestActivityAt:s,name:t.folderName,path:t.folderPath})}return Array.from(e.values()).map(e=>({...e,items:e.items.sort((e,t)=>new Date(t.chat.lastActivityAt).getTime()-new Date(e.chat.lastActivityAt).getTime()||e.chat.title.localeCompare(t.chat.title,void 0,{sensitivity:"base"}))})).sort((e,t)=>t.latestActivityAt-e.latestActivityAt||e.name.localeCompare(t.name,void 0,{sensitivity:"base"}))},[y]),C=f({mutationFn:()=>{if(!o)throw new Error("Select a chat to rename.");return je(t,o.id,{title:u.trim()||"Untitled chat"})},onError:e=>l.error(E(e)),onSuccess:()=>{d(null),m(""),i.invalidateQueries({queryKey:["chats"]})}}),S=f({mutationFn:e=>Ee(t,e.id),onError:e=>l.error(E(e)),onSuccess:(e,t)=>{x(null),i.invalidateQueries({queryKey:["chats"]}),a===t.id&&s("/")}});return(0,$t.jsxs)($t.Fragment,{children:[(0,$t.jsx)(_s,{className:"gap-1",children:N.length?N.map(e=>{const t=p.has(e.key),n=b.has(e.key),r=n?e.items:e.items.slice(0,4),i=e.items.length-r.length,o=j(e.path);return(0,$t.jsxs)(Qs,{children:[(0,$t.jsxs)("div",{className:"flex min-w-0 items-center gap-1 pr-1",children:[(0,$t.jsxs)("button",{className:"flex h-8 min-w-0 flex-1 items-center gap-2 rounded-md px-2 text-left text-xs font-medium text-sidebar-foreground/75 outline-none hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:bg-sidebar-accent",title:e.path,type:"button",onClick:()=>g(t=>{const s=new Set(t);return s.has(e.key)?s.delete(e.key):s.add(e.key),s}),children:[(0,$t.jsx)(kt,{className:"size-3.5 shrink-0 text-cyan-500"}),(0,$t.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e.name}),(0,$t.jsx)("span",{className:"shrink-0 text-[0.68rem] font-normal text-muted-foreground",children:e.items.length}),(0,$t.jsx)(Ue,{className:fe("size-3 shrink-0 text-muted-foreground transition-transform",t&&"-rotate-90")})]}),o?(0,$t.jsx)(dt,{"aria-label":`New chat in ${e.name}`,className:"size-7 shrink-0",size:"icon-sm",title:`New chat in ${e.path}`,type:"button",variant:"ghost",onClick:()=>s("/",{state:{workingDirectory:e.path}}),children:(0,$t.jsx)(K,{className:"size-3.5"})}):null]}),t?null:(0,$t.jsxs)(_s,{className:"gap-0.5 pl-4",children:[r.map(({chat:e,dateLabel:t,folderName:n})=>(0,$t.jsxs)(Qs,{className:"flex min-w-0 items-center",children:[(0,$t.jsxs)(Vs,{className:"h-7 min-w-0 flex-1 px-2 pr-2! text-xs",isActive:e.id===a,size:"sm",tooltip:`${e.title} · ${t} · ${n}`,onClick:()=>s(`/chat/${e.id}`),children:[(0,$t.jsx)(Tt,{className:"size-3.5 text-muted-foreground"}),(0,$t.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e.title})]}),(0,$t.jsxs)(k,{children:[(0,$t.jsxs)(Z,{render:(0,$t.jsx)(dt,{"aria-label":"Chat actions",className:"pointer-events-none h-7 w-0 shrink-0 overflow-hidden opacity-0 transition-[width,opacity] group-hover/menu-item:pointer-events-auto group-hover/menu-item:ml-1 group-hover/menu-item:w-7 group-hover/menu-item:opacity-100 group-focus-within/menu-item:pointer-events-auto group-focus-within/menu-item:ml-1 group-focus-within/menu-item:w-7 group-focus-within/menu-item:opacity-100 aria-expanded:pointer-events-auto aria-expanded:ml-1 aria-expanded:w-7 aria-expanded:opacity-100",size:"icon-sm",variant:"ghost"}),children:[(0,$t.jsx)(vt,{className:"size-4"}),(0,$t.jsx)("span",{className:"sr-only",children:"Chat actions"})]}),(0,$t.jsxs)(J,{align:"end",className:"w-40",children:[(0,$t.jsxs)(w,{onClick:()=>{d(e),m(e.title)},children:[(0,$t.jsx)(Ut,{}),"Rename"]}),(0,$t.jsxs)(w,{onClick:()=>x(e),children:[(0,$t.jsx)(gt,{}),"Archive"]})]})]})]},e.id)),i>0?(0,$t.jsx)("li",{children:(0,$t.jsxs)("button",{className:"flex h-7 w-full items-center gap-2 rounded-md px-2 text-left text-xs text-muted-foreground outline-none hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:bg-sidebar-accent",type:"button",onClick:()=>v(t=>new Set(t).add(e.key)),children:[(0,$t.jsx)(Ue,{className:"size-3.5 shrink-0"}),(0,$t.jsxs)("span",{className:"min-w-0 truncate",children:["Show ",i," more"]})]})}):n&&e.items.length>4?(0,$t.jsx)("li",{children:(0,$t.jsxs)("button",{className:"flex h-7 w-full items-center gap-2 rounded-md px-2 text-left text-xs text-muted-foreground outline-none hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:bg-sidebar-accent",type:"button",onClick:()=>v(t=>{const s=new Set(t);return s.delete(e.key),s}),children:[(0,$t.jsx)(Ue,{className:"size-3.5 shrink-0 rotate-180"}),(0,$t.jsx)("span",{className:"min-w-0 truncate",children:"Show less"})]})}):null]})]},e.key)}):(0,$t.jsx)("div",{className:"px-2 py-3 text-sm text-muted-foreground",children:"No chats yet."})}),(0,$t.jsx)(Je,{open:!!o,onOpenChange:e=>{e||(d(null),m(""))},children:(0,$t.jsxs)(Ye,{children:[(0,$t.jsxs)(tt,{children:[(0,$t.jsx)(Ke,{children:"Rename chat"}),(0,$t.jsx)(He,{children:"Choose a short title for the sidebar."})]}),(0,$t.jsx)(mt,{value:u,onChange:e=>m(e.target.value),onKeyDown:e=>{"Enter"===e.key&&C.mutate()}}),(0,$t.jsx)(Ve,{children:(0,$t.jsx)(dt,{disabled:C.isPending,onClick:()=>C.mutate(),children:"Save"})})]})}),(0,$t.jsx)(Je,{open:!!h,onOpenChange:e=>{e||x(null)},children:(0,$t.jsxs)(Ye,{children:[(0,$t.jsxs)(tt,{children:[(0,$t.jsx)(Ke,{children:"Archive chat?"}),(0,$t.jsxs)(He,{children:["This removes ",h?.title??"the chat"," from the active chat list. Message history stays on the server."]})]}),(0,$t.jsxs)(Ve,{children:[(0,$t.jsx)(dt,{variant:"outline",onClick:()=>x(null),children:"Cancel"}),(0,$t.jsxs)(dt,{disabled:S.isPending||!h,variant:"destructive",onClick:()=>{h&&S.mutate(h)},children:[(0,$t.jsx)(gt,{}),"Archive"]})]})]})})]})}function oa(){const{loading:e,session:t}=ct(),{chatId:s}=n(),o=function(e){const[t,s]=(0,pt.useState)(!1),[a,n]=(0,pt.useState)(0),[r,i]=(0,pt.useState)(null);return(0,pt.useEffect)(()=>{if(!e)return s(!1),n(0),void i(null);const t=T(e,{onClose:()=>s(!1),onCount:e=>n(Math.max(0,e.count)),onError:()=>s(!1),onOpen:()=>s(!0)});return i(t.socket),()=>{t.disconnect(),s(!1),i(null)}},[e?.serverUrl,e?.token]),{connected:t,count:a,socket:r}}(t),[l,u]=(0,pt.useState)(""),[h,x]=(0,pt.useState)(null),[f,j]=(0,pt.useState)(0),[y,N]=(0,pt.useState)(!1),[w,k]=(0,pt.useState)("accounts"),[C,E]=(0,pt.useState)(!1),[z,I]=(0,pt.useState)(null),R=r(),F=c(),L=(0,pt.useCallback)(e=>{j(e?.focusCreate?e=>e+1:0),k("accounts"),N(!0)},[]),q=(0,pt.useCallback)(e=>{"accounts"===e&&j(0),k(e)},[]),D=(0,pt.useCallback)((e="accounts")=>{k(e),N(!0)},[]),$=Y({enabled:!!t,queryKey:["accounts"],queryFn:()=>he(t),refetchInterval:e=>!!e.state.data?.some(e=>"AUTHENTICATING"===e.status)&&1500}),H=Y({enabled:!!t,queryKey:["chats"],queryFn:()=>ke(t)}),K=(0,pt.useMemo)(()=>$.data??[],[$.data]),_=(0,pt.useMemo)(()=>H.data??[],[H.data]),V=(0,pt.useMemo)(()=>s?_.find(e=>e.id===s)??null:null,[s,_]),B=V?.title??null;(0,pt.useEffect)(()=>{s&&x(s)},[s]);const W=(0,pt.useMemo)(()=>{if(s){const e=_.find(e=>e.id===s);if(e)return e}if(h){const e=_.find(e=>e.id===h);if(e)return e}return _[0]??null},[s,_,h]),J=(0,pt.useMemo)(()=>K.filter(e=>"CONNECTED"===e.status),[K]);ae(B);const Z=function({queries:e,...t},s){const a=c(s),n=S(),r=Q(),i=pt.useMemo(()=>e.map(e=>{const t=a.defaultQueryOptions(e);return t._optimisticResults=n?"isRestoring":"optimistic",t}),[e,a,n]);i.forEach(e=>{U(e),P(e,r,a.getQueryCache().get(e.queryHash))}),p(r);const[o]=pt.useState(()=>new xt(a,i,t)),[l,u,h]=o.getOptimisticResult(i,t.combine),x=!n&&!1!==t.subscribed;pt.useSyncExternalStore(pt.useCallback(e=>x?o.subscribe(d.batchCalls(e)):m,[o,x]),()=>o.getCurrentResult(),()=>o.getCurrentResult()),pt.useEffect(()=>{o.setQueries(i,t)},[i,t,o]);const g=l.some((e,t)=>b(i[t],e))?l.flatMap((e,t)=>{const s=i[t];return s&&b(s,e)?v(s,new A(a,s),r):[]}):[];if(g.length>0)throw Promise.all(g);const f=l.find((e,t)=>{const s=i[t];return s&&G({result:e,errorResetBoundary:r,throwOnError:s.throwOnError,query:a.getQueryCache().get(s.queryHash),suspense:s.suspense})});if(f?.error)throw f.error;return u(h())}({queries:J.map(e=>({enabled:!!t,queryKey:["rate-limits",e.id],queryFn:()=>me(t,e.id),refetchInterval:6e4,retry:!1,staleTime:3e4}))}),X=(0,pt.useMemo)(()=>Object.fromEntries(J.map((e,t)=>{const s=g(Z[t]?.data);return s?[e.id,s]:null}).filter(e=>!!e)),[Z,J]),ee=(0,pt.useMemo)(()=>Object.fromEntries(J.map(e=>{const t=X[e.id];return t?[e.id,O(t)]:null}).filter(e=>!!e)),[X,J]),te=(0,pt.useMemo)(()=>Object.fromEntries(J.map((e,t)=>[e.id,Z[t]?.isFetching??!1])),[Z,J]),se=Z.some(e=>M(e.error));if((0,pt.useEffect)(()=>{se&&F.invalidateQueries({queryKey:["accounts"]})},[se,F]),(0,pt.useEffect)(()=>{l.trim()||E(!1)},[l]),e)return(0,$t.jsx)(la,{});if(!t)return(0,$t.jsx)(i,{replace:!0,to:"/connect"});const ne={accounts:K,accountRateLimitFetching:te,accountRateLimitSnapshots:X,accountUsageSummaries:ee,activeProjectPath:l,chats:_,connectedAccounts:J,lastOpenedChat:W,openAccountManagement:L,openWorkspacePicker:I,session:t,setActiveProjectPath:u,setTerminalOpen:E,terminalCount:o.count,terminalOpen:C,terminalSocket:o.socket,terminalSocketConnected:o.connected};return(0,$t.jsxs)($t.Fragment,{children:[(0,$t.jsxs)(Is,{className:"h-svh min-h-0 overflow-hidden",children:[(0,$t.jsxs)(Os,{collapsible:"offcanvas",variant:"inset",children:[(0,$t.jsx)(Ls,{children:(0,$t.jsxs)(dt,{className:"w-full justify-start",variant:"ghost",onClick:()=>R("/"),children:[(0,$t.jsx)(Oe,{}),(0,$t.jsx)("span",{children:"New chat"})]})}),(0,$t.jsx)(Ds,{children:(0,$t.jsxs)($s,{className:"p-0",children:[(0,$t.jsx)(Hs,{children:"Chats"}),(0,$t.jsx)(Ks,{children:(0,$t.jsx)(ia,{chats:_,session:t})})]})}),(0,$t.jsx)(qs,{children:(0,$t.jsxs)(dt,{className:"justify-start",variant:"ghost",onClick:()=>D(),children:[(0,$t.jsx)(Lt,{}),(0,$t.jsx)("span",{children:"Settings"})]})})]}),(0,$t.jsxs)(Fs,{className:"min-h-0 min-w-0 overflow-hidden",children:[(0,$t.jsxs)("header",{className:"flex h-12 shrink-0 items-center justify-between gap-2 border-b px-2",children:[(0,$t.jsxs)("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[(0,$t.jsx)(Rs,{variant:"ghost",children:(0,$t.jsx)(Pt,{})}),(0,$t.jsx)("h1",{className:"min-w-0 flex-1 truncate text-sm font-semibold tracking-normal",children:B??(s?"Chat":"New chat")})]}),(0,$t.jsxs)("div",{className:"flex shrink-0 items-center gap-1",children:[V?(0,$t.jsxs)($t.Fragment,{children:[(0,$t.jsx)(We,{active:C,className:fe("md:hidden",C&&"text-foreground"),compact:!0,count:o.count,disabled:!l.trim(),onToggle:()=>E(!C)}),(0,$t.jsx)(Xe,{chatId:V.id,className:"md:hidden",compact:!0,disabled:"RUNNING"===V.status,session:t})]}):null,(0,$t.jsx)(et,{onAddAccount:()=>L({focusCreate:!0}),onNewChat:()=>R("/")}),(0,$t.jsx)(ks,{})]})]}),$.error||H.error?(0,$t.jsx)("div",{className:"border-b border-destructive/30 bg-destructive/10 px-4 py-2 text-sm text-destructive",children:$.error?.message??H.error?.message??"Unable to load workspace data."}):null,(0,$t.jsx)("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden",children:(0,$t.jsx)(a,{context:ne})})]})]}),(0,$t.jsx)(js,{accounts:K,accountRateLimitFetching:te,accountRateLimitSnapshots:X,accountUsageSummaries:ee,activeTab:w,createFocusKey:f,open:y,session:t,onTabChange:q,onOpenChange:N}),z?(0,$t.jsx)(Bs,{initialPath:z.initialPath,mode:z.mode,open:!!z,session:t,onOpenChange:e=>{e||I(null)},onSelect:z.onSelect}):null]})}function la(){return(0,$t.jsx)("div",{className:"flex min-h-svh items-center justify-center bg-background",children:(0,$t.jsx)(be,{className:"size-5 animate-spin text-muted-foreground"})})}var ca=t(function(){return(0,$t.jsx)(oa,{})});export{ca as default};