citadel_cli 1.0.0

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 (61) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +337 -0
  3. package/dist/.vite/manifest.json +12 -0
  4. package/dist/citadel.css +1 -0
  5. package/dist/citadel.es.js +3039 -0
  6. package/dist/citadel.umd.js +1015 -0
  7. package/dist/command_examples/basic-commands.d.ts +83 -0
  8. package/dist/dist/styles.css +789 -0
  9. package/dist/index.d.ts +2 -0
  10. package/dist/src/App.d.ts +4 -0
  11. package/dist/src/__test-utils__/factories.d.ts +21 -0
  12. package/dist/src/components/Citadel/Citadel.d.ts +11 -0
  13. package/dist/src/components/Citadel/Cursor.d.ts +9 -0
  14. package/dist/src/components/Citadel/__tests__/Citadel.test.d.ts +1 -0
  15. package/dist/src/components/Citadel/commands/history-commands.d.ts +2 -0
  16. package/dist/src/components/Citadel/components/AvailableCommands.d.ts +9 -0
  17. package/dist/src/components/Citadel/components/CommandInput.d.ts +10 -0
  18. package/dist/src/components/Citadel/components/CommandOutput.d.ts +8 -0
  19. package/dist/src/components/Citadel/components/CommandOutputLine.d.ts +9 -0
  20. package/dist/src/components/Citadel/components/Spinner.d.ts +2 -0
  21. package/dist/src/components/Citadel/components/__tests__/AvailableCommands.test.d.ts +1 -0
  22. package/dist/src/components/Citadel/components/__tests__/CommandInput.test.d.ts +1 -0
  23. package/dist/src/components/Citadel/components/__tests__/CommandOutput.test.d.ts +1 -0
  24. package/dist/src/components/Citadel/components/__tests__/CommandOutputLine.test.d.ts +1 -0
  25. package/dist/src/components/Citadel/components/__tests__/Spinner.test.d.ts +1 -0
  26. package/dist/src/components/Citadel/config/CitadelConfigContext.d.ts +11 -0
  27. package/dist/src/components/Citadel/config/__tests__/CitadelConfigContext.test.d.ts +1 -0
  28. package/dist/src/components/Citadel/config/defaults.d.ts +26 -0
  29. package/dist/src/components/Citadel/config/types.d.ts +56 -0
  30. package/dist/src/components/Citadel/hooks/__tests__/useCitadelState.test.d.ts +1 -0
  31. package/dist/src/components/Citadel/hooks/__tests__/useCommandHistory.test.d.ts +1 -0
  32. package/dist/src/components/Citadel/hooks/__tests__/useCommandParser.test.d.ts +1 -0
  33. package/dist/src/components/Citadel/hooks/__tests__/useCommandTrie.test.d.ts +1 -0
  34. package/dist/src/components/Citadel/hooks/useCitadelState.d.ts +6 -0
  35. package/dist/src/components/Citadel/hooks/useCommandHistory.d.ts +17 -0
  36. package/dist/src/components/Citadel/hooks/useCommandParser.d.ts +19 -0
  37. package/dist/src/components/Citadel/hooks/useCommandTrie.d.ts +2 -0
  38. package/dist/src/components/Citadel/hooks/useGlobalShortcut.d.ts +8 -0
  39. package/dist/src/components/Citadel/hooks/useSlideAnimation.d.ts +14 -0
  40. package/dist/src/components/Citadel/index.d.ts +2 -0
  41. package/dist/src/components/Citadel/services/HistoryService.d.ts +15 -0
  42. package/dist/src/components/Citadel/storage/BaseStorage.d.ts +25 -0
  43. package/dist/src/components/Citadel/storage/LocalStorage.d.ts +12 -0
  44. package/dist/src/components/Citadel/storage/MemoryStorage.d.ts +12 -0
  45. package/dist/src/components/Citadel/storage/StorageFactory.d.ts +9 -0
  46. package/dist/src/components/Citadel/storage/__tests__/LocalStorage.test.d.ts +1 -0
  47. package/dist/src/components/Citadel/storage/__tests__/MemoryStorage.test.d.ts +1 -0
  48. package/dist/src/components/Citadel/types/__tests__/command-trie.test.d.ts +1 -0
  49. package/dist/src/components/Citadel/types/command-context.d.ts +4 -0
  50. package/dist/src/components/Citadel/types/command-results.d.ts +41 -0
  51. package/dist/src/components/Citadel/types/command-trie.d.ts +238 -0
  52. package/dist/src/components/Citadel/types/cursor.d.ts +26 -0
  53. package/dist/src/components/Citadel/types/help-command.d.ts +3 -0
  54. package/dist/src/components/Citadel/types/index.d.ts +3 -0
  55. package/dist/src/components/Citadel/types/state.d.ts +40 -0
  56. package/dist/src/components/Citadel/types/storage.d.ts +44 -0
  57. package/dist/src/components/Citadel/utils/keySimulation.d.ts +2 -0
  58. package/dist/src/index.d.ts +4 -0
  59. package/dist/src/main.d.ts +1 -0
  60. package/dist/src/test/setup.d.ts +1 -0
  61. package/package.json +73 -0
@@ -0,0 +1,1015 @@
1
+ (function(P,l){typeof exports=="object"&&typeof module<"u"?l(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],l):(P=typeof globalThis<"u"?globalThis:P||self,l(P.Citadel={},P.React,P.ReactDOM))})(this,function(P,l,J){"use strict";var ht=Object.defineProperty;var pt=(P,l,J)=>l in P?ht(P,l,{enumerable:!0,configurable:!0,writable:!0,value:J}):P[l]=J;var A=(P,l,J)=>pt(P,typeof l!="symbol"?l+"":l,J);var fn={exports:{}},q={};/**
2
+ * @license React
3
+ * react-jsx-runtime.production.min.js
4
+ *
5
+ * Copyright (c) Facebook, Inc. and its affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */var Rn;function pe(){if(Rn)return q;Rn=1;var r=l,e=Symbol.for("react.element"),t=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,i=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};function c(u,p,w){var f,b={},m=null,x=null;w!==void 0&&(m=""+w),p.key!==void 0&&(m=""+p.key),p.ref!==void 0&&(x=p.ref);for(f in p)o.call(p,f)&&!a.hasOwnProperty(f)&&(b[f]=p[f]);if(u&&u.defaultProps)for(f in p=u.defaultProps,p)b[f]===void 0&&(b[f]=p[f]);return{$$typeof:e,type:u,key:m,ref:x,props:b,_owner:i.current}}return q.Fragment=t,q.jsx=c,q.jsxs=c,q}var $={};/**
10
+ * @license React
11
+ * react-jsx-runtime.development.js
12
+ *
13
+ * Copyright (c) Facebook, Inc. and its affiliates.
14
+ *
15
+ * This source code is licensed under the MIT license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ */var jn;function ge(){return jn||(jn=1,process.env.NODE_ENV!=="production"&&function(){var r=l,e=Symbol.for("react.element"),t=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),c=Symbol.for("react.provider"),u=Symbol.for("react.context"),p=Symbol.for("react.forward_ref"),w=Symbol.for("react.suspense"),f=Symbol.for("react.suspense_list"),b=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),x=Symbol.for("react.offscreen"),y=Symbol.iterator,v="@@iterator";function k(n){if(n===null||typeof n!="object")return null;var s=y&&n[y]||n[v];return typeof s=="function"?s:null}var h=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function _(n){{for(var s=arguments.length,d=new Array(s>1?s-1:0),C=1;C<s;C++)d[C-1]=arguments[C];S("error",n,d)}}function S(n,s,d){{var C=h.ReactDebugCurrentFrame,j=C.getStackAddendum();j!==""&&(s+="%s",d=d.concat([j]));var N=d.map(function(R){return String(R)});N.unshift("Warning: "+s),Function.prototype.apply.call(console[n],console,N)}}var I=!1,T=!1,z=!1,U=!1,nn=!1,en;en=Symbol.for("react.module.reference");function Me(n){return!!(typeof n=="string"||typeof n=="function"||n===o||n===a||nn||n===i||n===w||n===f||U||n===x||I||T||z||typeof n=="object"&&n!==null&&(n.$$typeof===m||n.$$typeof===b||n.$$typeof===c||n.$$typeof===u||n.$$typeof===p||n.$$typeof===en||n.getModuleId!==void 0))}function Ue(n,s,d){var C=n.displayName;if(C)return C;var j=s.displayName||s.name||"";return j!==""?d+"("+j+")":d}function Bn(n){return n.displayName||"Context"}function Y(n){if(n==null)return null;if(typeof n.tag=="number"&&_("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n;switch(n){case o:return"Fragment";case t:return"Portal";case a:return"Profiler";case i:return"StrictMode";case w:return"Suspense";case f:return"SuspenseList"}if(typeof n=="object")switch(n.$$typeof){case u:var s=n;return Bn(s)+".Consumer";case c:var d=n;return Bn(d._context)+".Provider";case p:return Ue(n,n.render,"ForwardRef");case b:var C=n.displayName||null;return C!==null?C:Y(n.type)||"Memo";case m:{var j=n,N=j._payload,R=j._init;try{return Y(R(N))}catch{return null}}}return null}var K=Object.assign,tn=0,Jn,Gn,Xn,Zn,Qn,qn,$n;function ne(){}ne.__reactDisabledLog=!0;function He(){{if(tn===0){Jn=console.log,Gn=console.info,Xn=console.warn,Zn=console.error,Qn=console.group,qn=console.groupCollapsed,$n=console.groupEnd;var n={configurable:!0,enumerable:!0,value:ne,writable:!0};Object.defineProperties(console,{info:n,log:n,warn:n,error:n,group:n,groupCollapsed:n,groupEnd:n})}tn++}}function Ye(){{if(tn--,tn===0){var n={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:K({},n,{value:Jn}),info:K({},n,{value:Gn}),warn:K({},n,{value:Xn}),error:K({},n,{value:Zn}),group:K({},n,{value:Qn}),groupCollapsed:K({},n,{value:qn}),groupEnd:K({},n,{value:$n})})}tn<0&&_("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var wn=h.ReactCurrentDispatcher,vn;function cn(n,s,d){{if(vn===void 0)try{throw Error()}catch(j){var C=j.stack.trim().match(/\n( *(at )?)/);vn=C&&C[1]||""}return`
18
+ `+vn+n}}var yn=!1,dn;{var We=typeof WeakMap=="function"?WeakMap:Map;dn=new We}function ee(n,s){if(!n||yn)return"";{var d=dn.get(n);if(d!==void 0)return d}var C;yn=!0;var j=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var N;N=wn.current,wn.current=null,He();try{if(s){var R=function(){throw Error()};if(Object.defineProperty(R.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(R,[])}catch(F){C=F}Reflect.construct(n,[],R)}else{try{R.call()}catch(F){C=F}n.call(R.prototype)}}else{try{throw Error()}catch(F){C=F}n()}}catch(F){if(F&&C&&typeof F.stack=="string"){for(var E=F.stack.split(`
19
+ `),L=C.stack.split(`
20
+ `),O=E.length-1,D=L.length-1;O>=1&&D>=0&&E[O]!==L[D];)D--;for(;O>=1&&D>=0;O--,D--)if(E[O]!==L[D]){if(O!==1||D!==1)do if(O--,D--,D<0||E[O]!==L[D]){var H=`
21
+ `+E[O].replace(" at new "," at ");return n.displayName&&H.includes("<anonymous>")&&(H=H.replace("<anonymous>",n.displayName)),typeof n=="function"&&dn.set(n,H),H}while(O>=1&&D>=0);break}}}finally{yn=!1,wn.current=N,Ye(),Error.prepareStackTrace=j}var Q=n?n.displayName||n.name:"",B=Q?cn(Q):"";return typeof n=="function"&&dn.set(n,B),B}function Ve(n,s,d){return ee(n,!1)}function Ke(n){var s=n.prototype;return!!(s&&s.isReactComponent)}function un(n,s,d){if(n==null)return"";if(typeof n=="function")return ee(n,Ke(n));if(typeof n=="string")return cn(n);switch(n){case w:return cn("Suspense");case f:return cn("SuspenseList")}if(typeof n=="object")switch(n.$$typeof){case p:return Ve(n.render);case b:return un(n.type,s,d);case m:{var C=n,j=C._payload,N=C._init;try{return un(N(j),s,d)}catch{}}}return""}var rn=Object.prototype.hasOwnProperty,te={},re=h.ReactDebugCurrentFrame;function mn(n){if(n){var s=n._owner,d=un(n.type,n._source,s?s.type:null);re.setExtraStackFrame(d)}else re.setExtraStackFrame(null)}function Be(n,s,d,C,j){{var N=Function.call.bind(rn);for(var R in n)if(N(n,R)){var E=void 0;try{if(typeof n[R]!="function"){var L=Error((C||"React class")+": "+d+" type `"+R+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof n[R]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw L.name="Invariant Violation",L}E=n[R](s,R,C,d,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(O){E=O}E&&!(E instanceof Error)&&(mn(j),_("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",C||"React class",d,R,typeof E),mn(null)),E instanceof Error&&!(E.message in te)&&(te[E.message]=!0,mn(j),_("Failed %s type: %s",d,E.message),mn(null))}}}var Je=Array.isArray;function xn(n){return Je(n)}function Ge(n){{var s=typeof Symbol=="function"&&Symbol.toStringTag,d=s&&n[Symbol.toStringTag]||n.constructor.name||"Object";return d}}function Xe(n){try{return oe(n),!1}catch{return!0}}function oe(n){return""+n}function ae(n){if(Xe(n))return _("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Ge(n)),oe(n)}var on=h.ReactCurrentOwner,Ze={key:!0,ref:!0,__self:!0,__source:!0},ie,se,Cn;Cn={};function Qe(n){if(rn.call(n,"ref")){var s=Object.getOwnPropertyDescriptor(n,"ref").get;if(s&&s.isReactWarning)return!1}return n.ref!==void 0}function qe(n){if(rn.call(n,"key")){var s=Object.getOwnPropertyDescriptor(n,"key").get;if(s&&s.isReactWarning)return!1}return n.key!==void 0}function $e(n,s){if(typeof n.ref=="string"&&on.current&&s&&on.current.stateNode!==s){var d=Y(on.current.type);Cn[d]||(_('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',Y(on.current.type),n.ref),Cn[d]=!0)}}function nt(n,s){{var d=function(){ie||(ie=!0,_("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",s))};d.isReactWarning=!0,Object.defineProperty(n,"key",{get:d,configurable:!0})}}function et(n,s){{var d=function(){se||(se=!0,_("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",s))};d.isReactWarning=!0,Object.defineProperty(n,"ref",{get:d,configurable:!0})}}var tt=function(n,s,d,C,j,N,R){var E={$$typeof:e,type:n,key:s,ref:d,props:R,_owner:N};return E._store={},Object.defineProperty(E._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(E,"_self",{configurable:!1,enumerable:!1,writable:!1,value:C}),Object.defineProperty(E,"_source",{configurable:!1,enumerable:!1,writable:!1,value:j}),Object.freeze&&(Object.freeze(E.props),Object.freeze(E)),E};function rt(n,s,d,C,j){{var N,R={},E=null,L=null;d!==void 0&&(ae(d),E=""+d),qe(s)&&(ae(s.key),E=""+s.key),Qe(s)&&(L=s.ref,$e(s,j));for(N in s)rn.call(s,N)&&!Ze.hasOwnProperty(N)&&(R[N]=s[N]);if(n&&n.defaultProps){var O=n.defaultProps;for(N in O)R[N]===void 0&&(R[N]=O[N])}if(E||L){var D=typeof n=="function"?n.displayName||n.name||"Unknown":n;E&&nt(R,D),L&&et(R,D)}return tt(n,E,L,j,C,on.current,R)}}var kn=h.ReactCurrentOwner,le=h.ReactDebugCurrentFrame;function Z(n){if(n){var s=n._owner,d=un(n.type,n._source,s?s.type:null);le.setExtraStackFrame(d)}else le.setExtraStackFrame(null)}var _n;_n=!1;function Sn(n){return typeof n=="object"&&n!==null&&n.$$typeof===e}function ce(){{if(kn.current){var n=Y(kn.current.type);if(n)return`
22
+
23
+ Check the render method of \``+n+"`."}return""}}function ot(n){return""}var de={};function at(n){{var s=ce();if(!s){var d=typeof n=="string"?n:n.displayName||n.name;d&&(s=`
24
+
25
+ Check the top-level render call using <`+d+">.")}return s}}function ue(n,s){{if(!n._store||n._store.validated||n.key!=null)return;n._store.validated=!0;var d=at(s);if(de[d])return;de[d]=!0;var C="";n&&n._owner&&n._owner!==kn.current&&(C=" It was passed a child from "+Y(n._owner.type)+"."),Z(n),_('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',d,C),Z(null)}}function me(n,s){{if(typeof n!="object")return;if(xn(n))for(var d=0;d<n.length;d++){var C=n[d];Sn(C)&&ue(C,s)}else if(Sn(n))n._store&&(n._store.validated=!0);else if(n){var j=k(n);if(typeof j=="function"&&j!==n.entries)for(var N=j.call(n),R;!(R=N.next()).done;)Sn(R.value)&&ue(R.value,s)}}}function it(n){{var s=n.type;if(s==null||typeof s=="string")return;var d;if(typeof s=="function")d=s.propTypes;else if(typeof s=="object"&&(s.$$typeof===p||s.$$typeof===b))d=s.propTypes;else return;if(d){var C=Y(s);Be(d,n.props,"prop",C,n)}else if(s.PropTypes!==void 0&&!_n){_n=!0;var j=Y(s);_("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",j||"Unknown")}typeof s.getDefaultProps=="function"&&!s.getDefaultProps.isReactClassApproved&&_("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function st(n){{for(var s=Object.keys(n.props),d=0;d<s.length;d++){var C=s[d];if(C!=="children"&&C!=="key"){Z(n),_("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",C),Z(null);break}}n.ref!==null&&(Z(n),_("Invalid attribute `ref` supplied to `React.Fragment`."),Z(null))}}var fe={};function he(n,s,d,C,j,N){{var R=Me(n);if(!R){var E="";(n===void 0||typeof n=="object"&&n!==null&&Object.keys(n).length===0)&&(E+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var L=ot();L?E+=L:E+=ce();var O;n===null?O="null":xn(n)?O="array":n!==void 0&&n.$$typeof===e?(O="<"+(Y(n.type)||"Unknown")+" />",E=" Did you accidentally export a JSX literal instead of a component?"):O=typeof n,_("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",O,E)}var D=rt(n,s,d,j,N);if(D==null)return D;if(R){var H=s.children;if(H!==void 0)if(C)if(xn(H)){for(var Q=0;Q<H.length;Q++)me(H[Q],n);Object.freeze&&Object.freeze(H)}else _("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else me(H,n)}if(rn.call(s,"key")){var B=Y(n),F=Object.keys(s).filter(function(ft){return ft!=="key"}),En=F.length>0?"{key: someKey, "+F.join(": ..., ")+": ...}":"{key: someKey}";if(!fe[B+En]){var mt=F.length>0?"{"+F.join(": ..., ")+": ...}":"{}";_(`A props object containing a "key" prop is being spread into JSX:
26
+ let props = %s;
27
+ <%s {...props} />
28
+ React keys must be passed directly to JSX without using spread:
29
+ let props = %s;
30
+ <%s key={someKey} {...props} />`,En,B,mt,B),fe[B+En]=!0}}return n===o?st(D):it(D),D}}function lt(n,s,d){return he(n,s,d,!0)}function ct(n,s,d){return he(n,s,d,!1)}var dt=ct,ut=lt;$.Fragment=o,$.jsx=dt,$.jsxs=ut}()),$}process.env.NODE_ENV==="production"?fn.exports=pe():fn.exports=ge();var g=fn.exports,hn,an=J;if(process.env.NODE_ENV==="production")hn=an.createRoot,an.hydrateRoot;else{var Tn=an.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;hn=function(r,e){Tn.usingClientEntryPoint=!0;try{return an.createRoot(r,e)}finally{Tn.usingClientEntryPoint=!1}}}const be=({onOpen:r,onClose:e,isVisible:t,showCitadelKey:o})=>{l.useEffect(()=>{const i=a=>{var c,u;!t&&a.key===o&&!["input","textarea"].includes(((u=(c=a.target)==null?void 0:c.tagName)==null?void 0:u.toLowerCase())||"")&&(a.preventDefault(),r()),t&&a.key==="Escape"&&(a.preventDefault(),e())};return document.addEventListener("keydown",i),()=>document.removeEventListener("keydown",i)},[r,e,t,o])},Nn={container:"_container_141sr_3",innerContainer:"_innerContainer_141sr_19",inputSection:"_inputSection_141sr_28",resizeHandle:"_resizeHandle_141sr_35",citadel_slideUp:"_citadel_slideUp_141sr_64",citadel_slideDown:"_citadel_slideDown_141sr_68"},we=r=>{const{isVisible:e,isClosing:t,onAnimationComplete:o}=r,i=l.useMemo(()=>e?t?Nn.slideDown:Nn.slideUp:"",[e,t]);return l.useEffect(()=>{if(o){const c=setTimeout(()=>{o()},200);return()=>clearTimeout(c)}},[t,o]),{style:l.useMemo(()=>({opacity:e?1:0,transform:e?"translateY(0)":t?"translateY(100%)":"translateY(-100%)",transition:"opacity 200ms ease-in-out, transform 200ms ease-in-out"}),[e,t]),animationClass:i}},M={commandTimeoutMs:1e4,includeHelpCommand:!0,maxHeight:"80vh",minHeight:"200",outputFontSize:"text-xs",resetStateOnHide:!1,showCitadelKey:".",cursorType:"bbs",cursorColor:"var(--cursor-color, #fff)",cursorSpeed:530,storage:{type:"localStorage",maxCommands:100}};class In{constructor(e){A(this,"config");this.config={type:"localStorage",maxCommands:100,...e}}async addCommand(e){const t=await this.getCommands();for(t.push(e);t.length>this.config.maxCommands;)t.shift();await this.saveCommands(t)}}class ve extends In{constructor(t){super(t);A(this,"storageKey","citadel_command_history")}async getCommands(){try{const t=window.localStorage.getItem(this.storageKey);return t?JSON.parse(t):[]}catch(t){return console.warn("Failed to load commands from localStorage:",t),[]}}async clear(){try{window.localStorage.removeItem(this.storageKey)}catch(t){console.warn("Failed to clear localStorage:",t)}}async saveCommands(t){try{const o=t.map(i=>({inputs:Array.isArray(i.inputs)?[...i.inputs]:[],timestamp:i.timestamp}));window.localStorage.setItem(this.storageKey,JSON.stringify(o))}catch(o){throw console.warn("Failed to save commands to localStorage:",o),o}}}class ye extends In{constructor(t){super(t);A(this,"commands",[])}async getCommands(){return this.commands.map(t=>({inputs:Array.isArray(t.inputs)?[...t.inputs]:[],timestamp:t.timestamp}))}async clear(){this.commands=[]}async saveCommands(t){this.commands=t.map(o=>({inputs:Array.isArray(o.inputs)?[...o.inputs]:[],timestamp:o.timestamp}))}}const V=class V{constructor(){A(this,"currentStorage")}static getInstance(){return V.instance||(V.instance=new V),V.instance}initializeStorage(e){if(!this.currentStorage)try{this.currentStorage=new ve(e)}catch(t){console.warn("Failed to create storage, falling back to memory storage:",t),this.currentStorage=new ye(e)}}getStorage(){if(!this.currentStorage)throw new Error("Storage not initialized. Call initializeStorage first.");return this.currentStorage}};A(V,"instance");let sn=V;function Pn(r,e=[]){const t={};for(const[o,i]of Object.entries(r)){const a=[...e,o],c=a.join("."),u={description:i.description,handler:i.handler,argument:i.argument};(u.handler||u.argument||u.description)&&(t[c]={description:u.description||`${c} command`,...u.handler&&{handler:u.handler},...u.argument&&{argument:u.argument}});const p=Object.keys(i).filter(w=>typeof i[w]=="object"&&w!=="argument"&&!["description","handler"].includes(w));if(p.length>0){const w=p.reduce((f,b)=>(f[b]=i[b],f),{});Object.assign(t,Pn(w,a))}}return t}const ln=l.createContext({config:M}),xe=({config:r=M,commands:e,children:t})=>{const[o,i]=l.useState(),a={...M,...r,storage:{...M.storage,...r.storage},cursorType:r.cursorType??M.cursorType,cursorColor:r.cursorColor??M.cursorColor,cursorSpeed:r.cursorSpeed??M.cursorSpeed,showCitadelKey:r.showCitadelKey||"."};l.useEffect(()=>{sn.getInstance().initializeStorage(a.storage??M.storage),i(sn.getInstance().getStorage())},[]);const c=e?Pn(e):void 0,u={config:a,commands:c,storage:o};return g.jsx(ln.Provider,{value:u,children:t})},G=()=>{const r=l.useContext(ln);if(r===void 0)throw new Error("useCitadelConfig must be used within a CitadelConfigProvider");return r.config},Ce=()=>{const r=l.useContext(ln);if(r===void 0)throw new Error("useCitadelCommands must be used within a CitadelConfigProvider");return r.commands},An=()=>{const r=l.useContext(ln);if(r===void 0)throw new Error("useCitadelStorage must be used within a CitadelConfigProvider");return r.storage};var X=(r=>(r.Pending="pending",r.Success="success",r.Failure="failure",r.Timeout="timeout",r))(X||{});class W{constructor(e=Date.now()){A(this,"_status","pending");this.timestamp=e}get status(){return this._status}markSuccess(){this._status="success"}markFailure(){this._status="failure"}markTimeout(){this._status="timeout"}}class ke extends W{constructor(e,t){super(t),this.data=e}render(){return g.jsx("pre",{className:"text-gray-200",children:JSON.stringify(this.data,null,2)})}}class pn extends W{constructor(e,t){super(t),this.text=e}render(){return g.jsx("div",{className:"text-gray-200 whitespace-pre font-mono",children:this.text})}}class On extends W{constructor(e,t){super(t),this.error=e,this.markFailure()}render(){return g.jsx("div",{className:"mt-1 text-red-400",children:this.error})}}class Dn extends W{render(){return g.jsx("div",{className:"text-gray-400",children:"..."})}}class _e extends W{constructor(e,t="",o){super(o),this.imageUrl=e,this.altText=t}render(){return g.jsx("div",{className:"my-2",children:g.jsx("img",{src:this.imageUrl,alt:this.altText,className:"max-w-[400px] max-h-[300px] h-auto rounded-lg object-contain"})})}}class zn{constructor(e,t){A(this,"timestamp");A(this,"command");A(this,"result");this.command=e,this.timestamp=Date.now(),this.result=t??new Dn}}const gn=async r=>new pn("");class bn{constructor(e){A(this,"_fullPath");A(this,"_description");A(this,"_children");A(this,"_argument");A(this,"_handler");A(this,"_parent");A(this,"_signature");if(!e.fullPath||e.fullPath.length===0)throw new Error("Command path cannot be empty");this._fullPath=e.fullPath,this._description=e.description,this._children=new Map,this._argument=e.argument,this._handler=e.handler||gn,this._parent=e.parent}get name(){return this._fullPath[this._fullPath.length-1]}get isLeaf(){return this._children.size===0}get hasHandler(){return this._handler!==void 0}get requiresArgument(){return this._argument!==void 0}get parent(){return this._parent}get signature(){return this._signature}setSignature(e){const t=e.buildSignatureForCommand(this);this._signature=t.signature.join("")}get children(){return this._children}get hasChildren(){return this._children.size>0}addChild(e,t){this._children.set(e,t)}getChild(e){return this._children.get(e)}get fullPath(){return this._fullPath}get description(){return this._description}get argument(){return this._argument}set argument(e){this._argument=e}get handler(){return this._handler}set handler(e){this._handler=e}}class Se{constructor(){A(this,"_root");this._root=new bn({fullPath:["ROOT"],description:"Root command node"})}addCommand(e){const{path:t,description:o,handler:i,argument:a}=e;if(!(t!=null&&t.length))throw new Error("Command path cannot be empty");let c=this._root;const u=t.length-1;for(let p=0;p<t.length;p++){const w=t[p],f=p===u,b=t.slice(0,p+1),m=c.children;if(m.has(w)){const x=m.get(w);if(f&&x.isLeaf)throw new Error(`Duplicate command: ${t.join(" ")}`);if(!f&&x.isLeaf)throw new Error(`Cannot add subcommand to leaf command: ${t.slice(0,p+1).join(" ")}`);c=x}else{const x=new bn({description:f?o:`${w} commands`,fullPath:b,parent:c,handler:f?i:void 0,argument:f?a:void 0});c.addChild(w,x),c=x,this.setSignatures()}}}getCommand(e){let t=this._root;for(const o of e){const a=t.children.get(o);if(!a)return;t=a}return t}getCompletions(e){let t=this._root;for(const c of e.slice(0,-1)){const p=t.children.get(c);if(!p)return[];t=p}const o=e[e.length-1]||"",i=[],a=t.children;if(e.length>0){const c=a.get(o);if(c)return c.children.forEach((u,p)=>{i.push(p)}),i}return a.forEach((c,u)=>{u.startsWith(o)&&i.push(u)}),i}async executeCommand(e,t=[]){var a;const o=this.getCommand(e);if(!o)return;if(!o.hasHandler)throw new Error(`Command '${e.join(" ")}' is not executable`);if(o.requiresArgument&&t.length===0)throw new Error(`Command '${e.join(" ")}' requires argument: ${(a=o.argument)==null?void 0:a.name}`);const i=o.handler;if(!i)throw new Error(`Command '${e.join(" ")}' has no handler`);return await i(t)}getRootCommands(){return Array.from(this._root.children.values())}getLeafCommands(){const e=[],t=o=>{o.isLeaf?e.push(o):o.children.forEach(i=>{t(i)})};return this._root.children.forEach(o=>{t(o)}),e}getCommandBySignature(e){if(!e.signature.length)return;let t=this._root;for(const o of e.signature){if(!o)return;const i=Array.from(t.children.entries()).filter(([a])=>a.toLowerCase().startsWith(o.toLowerCase()));if(i.length===0)return;if(i.length>1){const a=i.find(([c])=>c.toLowerCase()===o.toLowerCase());if(!a)return;t=a[1]}else t=i[0][1]}return t===this._root?void 0:t}buildSignatureForCommand(e){if(!e||e===this._root)return{signature:[]};const t=[];let o=e;const i=[];for(;o&&o!==this._root;)i.unshift(o),o=o.parent;o=this._root;for(const a of i){const c=a.name,u=Array.from(o.children.keys());let p=1,w=!1;for(;p<=c.length;){const f=c.slice(0,p),b=f.toLowerCase(),m=u.filter(x=>x.toLowerCase().startsWith(b));if(m.length===1&&m[0].toLowerCase()===c.toLowerCase()){t.push(f),w=!0;break}p++}w||t.push(c),o=a}return{signature:t}}setSignatures(){const e=t=>{t!==this._root&&t.setSignature(this),t.children.forEach(o=>e(o))};e(this._root)}validate(){const e=[],t=new Set,o=i=>{if(i===this._root)return;const a=i.fullPath.join(" ");t.has(a)&&e.push(`Duplicate command path: ${a}`),t.add(a),i.handler||e.push(`Command missing handler: ${a}`);const c=i.children;c.size>0&&(i.handler!==gn&&e.push(`Non-leaf command should use NoopHandler: ${a}`),i.argument&&e.push(`Non-leaf command cannot have argument: ${a}`),c.forEach(u=>{o(u)}))};return this._root.children.forEach(i=>{o(i)}),{isValid:e.length===0,errors:e}}}const Ee=(r,e)=>{const t=async function(o){const i=r.getLeafCommands().filter(a=>a.name!=="help").map(a=>{var u;return`${a.fullPath.join(" ")+(a.requiresArgument?` <${(u=a.argument)==null?void 0:u.name}>`:"")} - ${a.description}`}).sort();return e.includeHelpCommand&&i.push("help - Show available commands"),new pn(i.length>0?`Available Commands:
31
+ `+i.join(`
32
+ `):"No commands available yet. Add some commands to get started!")};return["help",new bn({fullPath:["help"],description:"Show available commands",handler:t})]},Ln=()=>{const r=G(),e=Ce();return l.useMemo(()=>{const o=new Se;if(r.includeHelpCommand){const[i,a]=Ee(o,r);o.addCommand({path:[i],description:a.description,handler:a.handler,argument:a.argument})}return e&&Object.entries(e).forEach(([i,a])=>{o.addCommand({path:i.split("."),...a})}),o},[r.includeHelpCommand,e])};function Re(){const r=An(),[e,t]=l.useState({commands:[],position:null,savedInput:null});l.useEffect(()=>{if(!r)return;(async()=>{try{const f=await r.getCommands();t(b=>({...b,commands:f}))}catch(f){console.warn("Failed to load command history:",f)}})()},[r]);const o=l.useCallback(async w=>{if(r)try{await r.addCommand(w),t(f=>({...f,commands:[...f.commands,w],position:null,savedInput:null}))}catch(f){console.warn("Failed to save command to history:",f)}},[r]),i=l.useCallback(()=>e.commands,[e.commands]),a=l.useCallback((w,f)=>{if(e.commands.length===0)return{command:null,position:null};e.position===null&&w==="up"&&t(m=>({...m,savedInput:f}));let b=null;if(w==="up"?e.position===null?b=e.commands.length-1:e.position>0?b=e.position-1:b=0:e.position===null||e.position>=e.commands.length-1?b=null:b=e.position+1,t(m=>({...m,position:b})),b===null&&e.savedInput){const m={inputs:e.savedInput.split(" ").filter(Boolean),timestamp:Date.now()};return t(x=>({...x,savedInput:null})),{command:m,position:null}}return{command:b!==null?e.commands[b]:null,position:b}},[e]),c=l.useCallback(w=>{t(f=>({...f,savedInput:w}))},[]),u=l.useCallback(async()=>{try{if(!r)return;await r.clear(),t({commands:[],position:null,savedInput:null})}catch(w){console.warn("Failed to clear command history:",w)}},[r]);return[e,{addCommand:o,getCommands:i,navigateHistory:a,saveInput:c,clear:u}]}function Fn({commandTrie:r}={}){const[e,t]=l.useState("idle"),o=Ln(),i=r||o,a=l.useCallback((v,k)=>v?k.filter(h=>h.name.toLowerCase().startsWith(v.toLowerCase())):k,[]),c=l.useCallback((v,k)=>{const h=a(v,k);return h.length===1?h[0].name:null},[a]),u=l.useCallback(v=>v!=null&&v.hasChildren?Array.from(v.children.values()):i.getRootCommands(),[i]),p=l.useCallback((v,k)=>a(v,k).length>0,[a]),w=l.useCallback((v,k,h)=>{i.getCommand(v)&&(k.executeCommand(v,h||void 0),k.setCurrentInput(""),k.setIsEnteringArg(!1),t("idle"))},[i]),f=l.useCallback((v,k,h)=>{if(h.setCurrentInput(v),!k.isEnteringArg){const _=u(k.currentNode),S=c(v,_);if(S&&S!==v){const I=[...k.commandStack,S],T=i.getCommand(I);T&&(h.setCommandStack(I),h.setCurrentInput(""),h.setCurrentNode(T),!T.hasChildren&&T.argument?(h.setIsEnteringArg(!0),t("entering_argument")):(h.setIsEnteringArg(!1),t("idle")))}}},[u,c,i]),b=l.useCallback((v,k,h)=>{const{commandStack:_,currentInput:S,isEnteringArg:I,currentNode:T}=k;switch(v.key){case"Tab":if(v.preventDefault(),!I&&S){const z=u(T),U=c(S,z);U&&h.setCurrentInput(U)}return;case"Backspace":if(S===""&&(v.preventDefault(),_.length>0)){const z=_.slice(0,-1),U=z.length>0?i.getCommand(z):void 0;h.setCommandStack(z),h.setCurrentNode(U),h.setIsEnteringArg(!1),t("entering_command")}return;case"Enter":if(v.preventDefault(),I&&(T!=null&&T.handler))S.trim()&&w(_,h,[S.trim()]);else if(!I&&S){const z=u(T),U=a(S,z);if(U.length===1){const nn=U[0],en=[..._,nn.name];nn.argument?(h.setCommandStack(en),h.setCurrentNode(nn),h.setCurrentInput(""),h.setIsEnteringArg(!0),t("entering_argument")):w(en,h,void 0)}}else T&&!T.argument&&w(_,h,void 0);return}if(!I&&!(T!=null&&T.argument)){const z=u(T);if(!p(S+v.key,z)){v.preventDefault();return}}},[u,c,a,w,i,p]),m=l.useCallback(async(v,k,h)=>{x(h);let _=[],S;for(const I of v.inputs){const T={...k,commandStack:_,currentNode:S};if(S!=null&&S.argument)h.setIsEnteringArg(!0),h.setCurrentInput(I);else{const z=y(I,T);z&&(_=[..._,z],h.setCommandStack(_),S=i.getCommand(_),h.setCurrentNode(S))}}},[f]),x=l.useCallback(v=>{v.setCurrentInput(""),v.setCommandStack([]),v.setCurrentNode(void 0),v.setIsEnteringArg(!1)},[]),y=(v,k)=>{const h=u(k.currentNode);return c(v,h)||""};return{handleInputChange:f,handleKeyDown:b,executeCommand:w,inputState:e,replayCommand:m,findMatchingCommands:a,getAutocompleteSuggestion:c,getAvailableNodes:u,isValidCommandInput:p}}const je=()=>{const r=Ln(),e=G(),[t,o]=Re(),{replayCommand:i}=Fn(),[a,c]=l.useState({commandStack:[],currentInput:"",isEnteringArg:!1,currentNode:void 0,output:[],validation:{isValid:!0},history:t}),u=An();l.useEffect(()=>{},[u]),l.useEffect(()=>{c(m=>({...m,history:t}))},[t]);const p=l.useCallback(async(m,x)=>{const y=r.getCommand(m);if(!y||!y.isLeaf)return;const v=new zn([...m,...x||[]]);c(k=>({...k,output:[...k.output,v]})),c(k=>({...k,commandStack:[],currentInput:"",isEnteringArg:!1,currentNode:void 0,validation:{isValid:!0}}));try{const k=new Promise((S,I)=>{setTimeout(()=>{I(new Error("Request timed out"))},e.commandTimeoutMs)}),h=await Promise.race([y.handler(x||[]),k]);if(!(h instanceof W))throw new Error(`The ${y.fullPath.join(".")} command returned an invalid result type. Commands must return an instance of a CommandResult.
33
+ For example:
34
+ return new JsonCommandResult({ text: "Hello World" });
35
+ Check the definition of the ${y.fullPath.join(".")} command and update the return type.`);h.markSuccess();const _={inputs:[...y.fullPath,...x||[]],timestamp:Date.now()};try{await o.addCommand(_),c(S=>({...S,output:S.output.map(I=>I.timestamp===v.timestamp?{...I,result:h}:I)}))}catch(S){console.warn("Failed to save command to history:",S),c(I=>({...I,output:I.output.map(T=>T.timestamp===v.timestamp?{...T,result:h}:T)}))}}catch(k){const h=new On(k instanceof Error?k.message:"Unknown error");h.markSuccess(),c(_=>({..._,output:_.output.map(S=>S.timestamp===v.timestamp?{...S,result:h}:S)}))}},[r,e.commandTimeoutMs,o,a]),w=l.useCallback(m=>{const{key:x}=m;switch(x){case"ArrowUp":m.preventDefault();const{command:y}=o.navigateHistory("up",a.currentInput);y&&i(y,a,f);break;case"ArrowDown":m.preventDefault();const{command:v}=o.navigateHistory("down",a.currentInput);v&&i(v,a,f);break;case"Enter":if(m.preventDefault(),a.history.position!==null){const k=a.history.commands[a.history.position];p([...k.inputs]),c(h=>({...h,history:{...h.history,position:null,savedInput:null}}))}break;case"Escape":if(m.preventDefault(),a.history.position!==null){const k=a.history.savedInput||"";c(h=>({...h,currentInput:k,history:{...h.history,position:null,savedInput:null}}))}break}},[a.currentInput,a.history,o,p]);l.useEffect(()=>(window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)),[w]);const f={setCommandStack:l.useCallback(m=>{c(x=>({...x,commandStack:m,currentNode:r.getCommand(m)}))},[r]),setCurrentInput:l.useCallback(m=>{c(x=>({...x,currentInput:m}))},[]),setIsEnteringArg:l.useCallback(m=>{c(x=>({...x,isEnteringArg:m}))},[]),setCurrentNode:l.useCallback(m=>{c(x=>({...x,currentNode:m}))},[]),addOutput:l.useCallback(m=>{c(x=>({...x,output:[...x.output,m]}))},[]),setValidation:l.useCallback(m=>{c(x=>({...x,validation:m}))},[]),executeCommand:p,executeHistoryCommand:l.useCallback(async m=>{const y=a.history.commands[m];if(!y){console.warn(`No command found at history index ${m}`);return}await i(y,a,f)},[a.history.commands,p]),clearHistory:l.useCallback(async()=>{try{await o.clear()}catch(m){console.warn("Failed to clear history:",m)}},[o])},b=l.useCallback(()=>a.currentNode&&a.currentNode.children?Array.from(a.currentNode.children.values()):r.getRootCommands(),[a.currentNode,r]);return{state:a,actions:f,getAvailableCommands:b}},Mn={blink:{character:"▋",speed:530,color:"#fff"},spin:{character:"⠋",speed:120,color:"#fff"},solid:{character:"▋",speed:0,color:"#fff"},bbs:{character:"|",speed:120,color:"#fff"}},Un=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"],Hn=["|","/","-","\\"],Te=({style:r={type:"blink"},isValid:e=!0,errorMessage:t})=>{const o=l.useMemo(()=>({...Mn[r.type],...r}),[r]),[i,a]=l.useState(!0),[c,u]=l.useState(0);l.useEffect(()=>{if(o.speed===0)return;const f=setInterval(()=>{o.type==="blink"?a(b=>!b):["spin","bbs"].includes(o.type)&&u(b=>(b+1)%(o.type==="bbs"?Hn.length:Un.length))},o.speed);return()=>clearInterval(f)},[o.type,o.speed]);const p=l.useMemo(()=>({color:e?o.color:"#ff4444",transition:"color 0.15s ease-in-out"}),[e,o.color]),w=()=>!e&&t?"✗":["spin","bbs"].includes(o.type)?(o.type==="bbs"?Hn:Un)[c]:o.type==="solid"||i?o.character:" ";return g.jsx("div",{className:"relative inline-block",children:g.jsx("span",{className:`command-cursor ${e?"":"animate-shake"}`,style:p,title:t,children:w()})})},Ne={invalidInput:"_invalidInput_e9b9w_12",shake:"_shake_e9b9w_1",flashBorder:"_flashBorder_e9b9w_1"},Ie=({state:r,actions:e,availableCommands:t})=>{var m,x;const o=l.useRef(null),{handleKeyDown:i,handleInputChange:a}=Fn(),[c,u]=l.useState(!1),p=G(),w=y=>{var k,h;const v=y.key==="Backspace"||y.key==="Escape"||y.key==="Tab"||y.key==="Shift"||y.key==="Control"||y.key==="Alt"||y.key==="Meta"||y.key==="ArrowLeft"||y.key==="ArrowRight"||y.key==="ArrowUp"||y.key==="ArrowDown"||y.key==="Enter";if(!v&&!r.isEnteringArg&&!((k=r.currentNode)!=null&&k.hasChildren)&&r.currentNode&&!r.currentNode.requiresArgument&&!r.currentNode.handler){y.preventDefault();return}if(!v&&!r.isEnteringArg&&!((h=r.currentNode)!=null&&h.requiresArgument)){const _=r.currentNode?Array.from(r.currentNode.children.values()):t,S=(r.currentInput+y.key).toLowerCase();if(!_.some(T=>T.name.toLowerCase().startsWith(S))){u(!0),setTimeout(()=>u(!1),300),y.preventDefault();return}}i(y.nativeEvent,r,e)},f=y=>{a(y.target.value,r,e)},b=y=>{y.preventDefault();const v=y.clipboardData.getData("text");a(v,r,e)};return l.useEffect(()=>{o.current&&o.current.focus()},[]),l.useEffect(()=>{o.current&&o.current.focus()},[r.commandStack]),g.jsxs("div",{className:"flex flex-col w-full bg-gray-900 rounded-lg p-4",children:[g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx("div",{className:"text-gray-400 font-mono",children:">"}),g.jsxs("div",{className:"flex-1 font-mono flex items-center",children:[g.jsxs("span",{className:"text-blue-400 whitespace-pre","data-testid":"user-input-area",children:[r.commandStack.join(" "),r.commandStack.length>0&&" "]}),g.jsxs("div",{className:"relative flex-1",children:[g.jsx("input",{ref:o,type:"text",role:"textbox",value:r.currentInput,onChange:f,onKeyDown:w,onPaste:b,"data-testid":"citadel-command-input",className:`w-full bg-transparent outline-none text-gray-200 caret-transparent ${c?Ne.invalidInput:""}`,spellCheck:!1,autoComplete:"off",placeholder:r.isEnteringArg?(x=(m=r.currentNode)==null?void 0:m.argument)==null?void 0:x.name:""}),g.jsx("div",{className:"absolute top-0 pointer-events-none",style:{left:`${r.currentInput.length}ch`,transition:"left 0.05s ease-out"},children:g.jsx(Te,{style:{type:p.cursorType??M.cursorType,color:p.cursorColor||M.cursorColor,speed:p.cursorSpeed||M.cursorSpeed},isValid:!c&&r.validation.isValid,errorMessage:r.validation.message})})]})]})]}),r.validation.message&&g.jsx("div",{className:`mt-2 text-sm ${r.validation.isValid?"text-green-500":"text-red-500"}`,children:r.validation.message})]})},Pe=()=>g.jsx("div",{"data-testid":"spinner",className:"animate-spin rounded-full h-4 w-4 border-2 border-gray-300 border-t-gray-600"}),Ae=({command:r,timestamp:e,status:t})=>g.jsxs("div",{className:"flex items-center gap-2 font-mono text-sm",children:[g.jsxs("span",{className:"text-gray-200",children:["> ",r]}),g.jsx("span",{className:"text-gray-400",children:"·"}),g.jsx("span",{className:"text-gray-500",children:e}),t===X.Pending&&g.jsx(Pe,{}),t===X.Success&&g.jsx("div",{"data-testid":"success-indicator",className:"w-4 h-4 rounded-full bg-green-500"}),(t===X.Timeout||t===X.Failure)&&g.jsx("div",{"data-testid":"error-indicator",className:"w-4 h-4 rounded-full bg-red-500"})]}),Oe=({output:r,outputRef:e})=>{const t=G(),o=l.useCallback(()=>{if(e.current){const i=e.current;requestAnimationFrame(()=>{i.scrollTop=i.scrollHeight})}},[e]);return l.useEffect(()=>{if(o(),e.current){const i=e.current.getElementsByTagName("img"),a=i[i.length-1];if(a&&!a.complete)return a.addEventListener("load",o),()=>a.removeEventListener("load",o)}},[r,o]),g.jsx("div",{ref:e,className:"h-full overflow-y-auto border border-gray-700 rounded-lg p-3 text-left",children:r.map((i,a)=>g.jsxs("div",{className:"mb-4 last:mb-0",children:[g.jsx(Ae,{command:i.command.join(" "),timestamp:new Date(i.timestamp).toLocaleTimeString(),status:i.result.status}),g.jsx("pre",{className:`text-gray-200 whitespace-pre font-mono ${t.outputFontSize}`,children:i.result.render()})]},a))})},De=({state:r,availableCommands:e})=>{var p,w;const t=G(),o=!r.isEnteringArg&&e.length>0,i="h-12 mt-2 border-t border-gray-700 px-4",a="text-gray-300 pt-2",c=((p=r.currentNode)==null?void 0:p.isLeaf)&&r.currentNode.handler===gn&&!r.currentNode.requiresArgument,u=l.useMemo(()=>{if(!r.commandStack.length&&t.includeHelpCommand){const f=e.filter(m=>m.name!=="help"),b=e.find(m=>m.name==="help");return[...f,...b?[b]:[]]}return e},[e,r.commandStack,t.includeHelpCommand]);return g.jsx("div",{className:i,"data-testid":"available-commands",children:c?g.jsx("div",{className:a,children:r.currentNode?g.jsxs(g.Fragment,{children:[g.jsx("span",{className:"text-blue-400",children:r.currentNode.name}),g.jsxs("span",{className:"text-gray-400 ml-2",children:["- ",r.currentNode.description]})]}):null}):o?g.jsx("div",{className:a,children:g.jsx("div",{className:"flex flex-wrap gap-2",children:u.map(f=>{const b=u.reduce((m,x)=>{if(x.name===f.name)return m;let y=0;for(;y<f.name.length&&y<x.name.length&&f.name[y].toLowerCase()===x.name[y].toLowerCase();)y++;return Math.max(m,y+1)},1);return g.jsx("div",{className:"px-2 py-1 rounded bg-gray-800 mr-2 last:mr-0",children:g.jsxs("span",{className:"font-mono text-white",children:[g.jsx("strong",{className:"underline",children:f.name.slice(0,b)}),f.name.slice(b)]})},f.fullPath.join("."))})})}):g.jsx("div",{className:a,children:(w=r.currentNode)==null?void 0:w.description})})},Yn=`:host {
36
+ --citadel-bg: rgb(17, 24, 39);
37
+ --citadel-text: rgba(255, 255, 255, 0.87);
38
+ --citadel-border: rgb(55, 65, 81);
39
+ --citadel-accent: #646cff;
40
+ --citadel-accent-hover: #535bf2;
41
+ --citadel-min-height: 200px;
42
+ --citadel-max-height: 80vh;
43
+ --citadel-default-height: 33vh;
44
+ --citadel-error: rgb(239, 68, 68);
45
+
46
+ height: var(--citadel-default-height);
47
+ max-height: var(--citadel-max-height);
48
+ min-height: var(--citadel-min-height);
49
+ width: 100%;
50
+
51
+ position: fixed;
52
+ bottom: 0;
53
+ left: 0;
54
+ right: 0;
55
+ overflow: hidden;
56
+
57
+ pointer-events: auto;
58
+ font-synthesis: none;
59
+ text-rendering: optimizeLegibility;
60
+ -webkit-font-smoothing: antialiased;
61
+ -moz-osx-font-smoothing: grayscale;
62
+ }
63
+
64
+ button {
65
+ border-radius: 8px;
66
+ border: 1px solid transparent;
67
+ padding: 0.6em 1.2em;
68
+ font-size: 1em;
69
+ font-weight: 500;
70
+ font-family: inherit;
71
+ background-color: #1a1a1a;
72
+ cursor: pointer;
73
+ transition: border-color 0.25s;
74
+ }
75
+
76
+ button:hover {
77
+ border-color: var(--citadel-accent);
78
+ }
79
+
80
+ button:focus,
81
+ button:focus-visible {
82
+ outline: 4px auto -webkit-focus-ring-color;
83
+ }
84
+
85
+ a {
86
+ font-weight: 500;
87
+ color: var(--citadel-accent);
88
+ text-decoration: inherit;
89
+ }
90
+
91
+ a:hover {
92
+ color: var(--citadel-accent-hover);
93
+ }
94
+
95
+ .flex-1 { flex: 1 1 0%; }
96
+ .flex-shrink-0 { flex-shrink: 0; }
97
+ .min-h-0 { min-height: 0px; }
98
+ .pt-3 { padding-top: 0.75rem; }
99
+ .px-4 { padding-left: 1rem; padding-right: 1rem; }
100
+
101
+ .h-full {
102
+ height: 100%;
103
+ }
104
+ .overflow-y-auto {
105
+ overflow-y: auto;
106
+ }
107
+ .border {
108
+ border-width: 1px;
109
+ }
110
+ .border-gray-700 {
111
+ --tw-border-opacity: 1;
112
+ border-color: rgb(55 65 81 / var(--tw-border-opacity, 1));
113
+ }
114
+ .rounded-lg {
115
+ border-radius: 0.5rem;
116
+ }
117
+ .p-3 {
118
+ padding: 0.75rem;
119
+ }
120
+ .text-left {
121
+ text-align: left;
122
+ }
123
+
124
+ `,Wn=`/* Keep only component-specific styles here */
125
+
126
+ .container {
127
+ position: fixed;
128
+ height: var(--citadel-default-height);
129
+ min-height: var(--citadel-min-height);
130
+ max-height: var(--citadel-max-height);
131
+ background-color: var(--citadel-bg);
132
+ overflow: hidden;
133
+ width: 100%;
134
+ box-sizing: border-box;
135
+ margin: 0;
136
+ padding: 0;
137
+ bottom: 0;
138
+ left: 0;
139
+ right: 0;
140
+ }
141
+
142
+ .innerContainer {
143
+ height: 100%;
144
+ width: 100%;
145
+ display: flex;
146
+ flex-direction: column;
147
+ margin: 0;
148
+ padding: 0;
149
+ }
150
+
151
+ .inputSection {
152
+ border-top: 1px solid var(--citadel-border);
153
+ padding: 1rem;
154
+ margin: 0;
155
+ box-sizing: border-box;
156
+ }
157
+
158
+ .resizeHandle {
159
+ width: 100%;
160
+ height: 6px;
161
+ background: transparent;
162
+ cursor: ns-resize;
163
+ position: absolute;
164
+ top: -3px;
165
+ left: 0;
166
+ right: 0;
167
+ z-index: 10;
168
+ user-select: none;
169
+ -webkit-user-select: none;
170
+ pointer-events: all;
171
+ }
172
+
173
+ .resizeHandle:hover {
174
+ background: rgba(255, 255, 255, 0.1);
175
+ }
176
+
177
+ @keyframes citadel_slideUp {
178
+ from { transform: translateY(100%); }
179
+ to { transform: translateY(0); }
180
+ }
181
+
182
+ @keyframes citadel_slideDown {
183
+ from { transform: translateY(0); }
184
+ to { transform: translateY(100%); }
185
+ }
186
+
187
+ .citadel_slideUp {
188
+ animation: citadel_slideUp 0.2s ease-out forwards;
189
+ }
190
+
191
+ .citadel_slideDown {
192
+ animation: citadel_slideDown 0.2s ease-out forwards;
193
+ }
194
+ `,Vn=`@tailwind base;
195
+ @tailwind components;
196
+ @tailwind utilities;
197
+ `,ze=`*, ::before, ::after {
198
+ --tw-border-spacing-x: 0;
199
+ --tw-border-spacing-y: 0;
200
+ --tw-translate-x: 0;
201
+ --tw-translate-y: 0;
202
+ --tw-rotate: 0;
203
+ --tw-skew-x: 0;
204
+ --tw-skew-y: 0;
205
+ --tw-scale-x: 1;
206
+ --tw-scale-y: 1;
207
+ --tw-pan-x: ;
208
+ --tw-pan-y: ;
209
+ --tw-pinch-zoom: ;
210
+ --tw-scroll-snap-strictness: proximity;
211
+ --tw-gradient-from-position: ;
212
+ --tw-gradient-via-position: ;
213
+ --tw-gradient-to-position: ;
214
+ --tw-ordinal: ;
215
+ --tw-slashed-zero: ;
216
+ --tw-numeric-figure: ;
217
+ --tw-numeric-spacing: ;
218
+ --tw-numeric-fraction: ;
219
+ --tw-ring-inset: ;
220
+ --tw-ring-offset-width: 0px;
221
+ --tw-ring-offset-color: #fff;
222
+ --tw-ring-color: rgb(59 130 246 / 0.5);
223
+ --tw-ring-offset-shadow: 0 0 #0000;
224
+ --tw-ring-shadow: 0 0 #0000;
225
+ --tw-shadow: 0 0 #0000;
226
+ --tw-shadow-colored: 0 0 #0000;
227
+ --tw-blur: ;
228
+ --tw-brightness: ;
229
+ --tw-contrast: ;
230
+ --tw-grayscale: ;
231
+ --tw-hue-rotate: ;
232
+ --tw-invert: ;
233
+ --tw-saturate: ;
234
+ --tw-sepia: ;
235
+ --tw-drop-shadow: ;
236
+ --tw-backdrop-blur: ;
237
+ --tw-backdrop-brightness: ;
238
+ --tw-backdrop-contrast: ;
239
+ --tw-backdrop-grayscale: ;
240
+ --tw-backdrop-hue-rotate: ;
241
+ --tw-backdrop-invert: ;
242
+ --tw-backdrop-opacity: ;
243
+ --tw-backdrop-saturate: ;
244
+ --tw-backdrop-sepia: ;
245
+ --tw-contain-size: ;
246
+ --tw-contain-layout: ;
247
+ --tw-contain-paint: ;
248
+ --tw-contain-style: ;
249
+ }
250
+
251
+ ::backdrop {
252
+ --tw-border-spacing-x: 0;
253
+ --tw-border-spacing-y: 0;
254
+ --tw-translate-x: 0;
255
+ --tw-translate-y: 0;
256
+ --tw-rotate: 0;
257
+ --tw-skew-x: 0;
258
+ --tw-skew-y: 0;
259
+ --tw-scale-x: 1;
260
+ --tw-scale-y: 1;
261
+ --tw-pan-x: ;
262
+ --tw-pan-y: ;
263
+ --tw-pinch-zoom: ;
264
+ --tw-scroll-snap-strictness: proximity;
265
+ --tw-gradient-from-position: ;
266
+ --tw-gradient-via-position: ;
267
+ --tw-gradient-to-position: ;
268
+ --tw-ordinal: ;
269
+ --tw-slashed-zero: ;
270
+ --tw-numeric-figure: ;
271
+ --tw-numeric-spacing: ;
272
+ --tw-numeric-fraction: ;
273
+ --tw-ring-inset: ;
274
+ --tw-ring-offset-width: 0px;
275
+ --tw-ring-offset-color: #fff;
276
+ --tw-ring-color: rgb(59 130 246 / 0.5);
277
+ --tw-ring-offset-shadow: 0 0 #0000;
278
+ --tw-ring-shadow: 0 0 #0000;
279
+ --tw-shadow: 0 0 #0000;
280
+ --tw-shadow-colored: 0 0 #0000;
281
+ --tw-blur: ;
282
+ --tw-brightness: ;
283
+ --tw-contrast: ;
284
+ --tw-grayscale: ;
285
+ --tw-hue-rotate: ;
286
+ --tw-invert: ;
287
+ --tw-saturate: ;
288
+ --tw-sepia: ;
289
+ --tw-drop-shadow: ;
290
+ --tw-backdrop-blur: ;
291
+ --tw-backdrop-brightness: ;
292
+ --tw-backdrop-contrast: ;
293
+ --tw-backdrop-grayscale: ;
294
+ --tw-backdrop-hue-rotate: ;
295
+ --tw-backdrop-invert: ;
296
+ --tw-backdrop-opacity: ;
297
+ --tw-backdrop-saturate: ;
298
+ --tw-backdrop-sepia: ;
299
+ --tw-contain-size: ;
300
+ --tw-contain-layout: ;
301
+ --tw-contain-paint: ;
302
+ --tw-contain-style: ;
303
+ }/*
304
+ ! tailwindcss v3.4.15 | MIT License | https://tailwindcss.com
305
+ *//*
306
+ 1. Prevent padding and border from affecting element width. (https://github.com/mozdevs/cssremedy/issues/4)
307
+ 2. Allow adding a border to an element by just adding a border-width. (https://github.com/tailwindcss/tailwindcss/pull/116)
308
+ */
309
+
310
+ *,
311
+ ::before,
312
+ ::after {
313
+ box-sizing: border-box; /* 1 */
314
+ border-width: 0; /* 2 */
315
+ border-style: solid; /* 2 */
316
+ border-color: #e5e7eb; /* 2 */
317
+ }
318
+
319
+ ::before,
320
+ ::after {
321
+ --tw-content: '';
322
+ }
323
+
324
+ /*
325
+ 1. Use a consistent sensible line-height in all browsers.
326
+ 2. Prevent adjustments of font size after orientation changes in iOS.
327
+ 3. Use a more readable tab size.
328
+ 4. Use the user's configured \`sans\` font-family by default.
329
+ 5. Use the user's configured \`sans\` font-feature-settings by default.
330
+ 6. Use the user's configured \`sans\` font-variation-settings by default.
331
+ 7. Disable tap highlights on iOS
332
+ */
333
+
334
+ html,
335
+ :host {
336
+ line-height: 1.5; /* 1 */
337
+ -webkit-text-size-adjust: 100%; /* 2 */
338
+ -moz-tab-size: 4; /* 3 */
339
+ -o-tab-size: 4;
340
+ tab-size: 4; /* 3 */
341
+ font-family: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; /* 4 */
342
+ font-feature-settings: normal; /* 5 */
343
+ font-variation-settings: normal; /* 6 */
344
+ -webkit-tap-highlight-color: transparent; /* 7 */
345
+ }
346
+
347
+ /*
348
+ 1. Remove the margin in all browsers.
349
+ 2. Inherit line-height from \`html\` so users can set them as a class directly on the \`html\` element.
350
+ */
351
+
352
+ body {
353
+ margin: 0; /* 1 */
354
+ line-height: inherit; /* 2 */
355
+ }
356
+
357
+ /*
358
+ 1. Add the correct height in Firefox.
359
+ 2. Correct the inheritance of border color in Firefox. (https://bugzilla.mozilla.org/show_bug.cgi?id=190655)
360
+ 3. Ensure horizontal rules are visible by default.
361
+ */
362
+
363
+ hr {
364
+ height: 0; /* 1 */
365
+ color: inherit; /* 2 */
366
+ border-top-width: 1px; /* 3 */
367
+ }
368
+
369
+ /*
370
+ Add the correct text decoration in Chrome, Edge, and Safari.
371
+ */
372
+
373
+ abbr:where([title]) {
374
+ -webkit-text-decoration: underline dotted;
375
+ text-decoration: underline dotted;
376
+ }
377
+
378
+ /*
379
+ Remove the default font size and weight for headings.
380
+ */
381
+
382
+ h1,
383
+ h2,
384
+ h3,
385
+ h4,
386
+ h5,
387
+ h6 {
388
+ font-size: inherit;
389
+ font-weight: inherit;
390
+ }
391
+
392
+ /*
393
+ Reset links to optimize for opt-in styling instead of opt-out.
394
+ */
395
+
396
+ a {
397
+ color: inherit;
398
+ text-decoration: inherit;
399
+ }
400
+
401
+ /*
402
+ Add the correct font weight in Edge and Safari.
403
+ */
404
+
405
+ b,
406
+ strong {
407
+ font-weight: bolder;
408
+ }
409
+
410
+ /*
411
+ 1. Use the user's configured \`mono\` font-family by default.
412
+ 2. Use the user's configured \`mono\` font-feature-settings by default.
413
+ 3. Use the user's configured \`mono\` font-variation-settings by default.
414
+ 4. Correct the odd \`em\` font sizing in all browsers.
415
+ */
416
+
417
+ code,
418
+ kbd,
419
+ samp,
420
+ pre {
421
+ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; /* 1 */
422
+ font-feature-settings: normal; /* 2 */
423
+ font-variation-settings: normal; /* 3 */
424
+ font-size: 1em; /* 4 */
425
+ }
426
+
427
+ /*
428
+ Add the correct font size in all browsers.
429
+ */
430
+
431
+ small {
432
+ font-size: 80%;
433
+ }
434
+
435
+ /*
436
+ Prevent \`sub\` and \`sup\` elements from affecting the line height in all browsers.
437
+ */
438
+
439
+ sub,
440
+ sup {
441
+ font-size: 75%;
442
+ line-height: 0;
443
+ position: relative;
444
+ vertical-align: baseline;
445
+ }
446
+
447
+ sub {
448
+ bottom: -0.25em;
449
+ }
450
+
451
+ sup {
452
+ top: -0.5em;
453
+ }
454
+
455
+ /*
456
+ 1. Remove text indentation from table contents in Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=999088, https://bugs.webkit.org/show_bug.cgi?id=201297)
457
+ 2. Correct table border color inheritance in all Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=935729, https://bugs.webkit.org/show_bug.cgi?id=195016)
458
+ 3. Remove gaps between table borders by default.
459
+ */
460
+
461
+ table {
462
+ text-indent: 0; /* 1 */
463
+ border-color: inherit; /* 2 */
464
+ border-collapse: collapse; /* 3 */
465
+ }
466
+
467
+ /*
468
+ 1. Change the font styles in all browsers.
469
+ 2. Remove the margin in Firefox and Safari.
470
+ 3. Remove default padding in all browsers.
471
+ */
472
+
473
+ button,
474
+ input,
475
+ optgroup,
476
+ select,
477
+ textarea {
478
+ font-family: inherit; /* 1 */
479
+ font-feature-settings: inherit; /* 1 */
480
+ font-variation-settings: inherit; /* 1 */
481
+ font-size: 100%; /* 1 */
482
+ font-weight: inherit; /* 1 */
483
+ line-height: inherit; /* 1 */
484
+ letter-spacing: inherit; /* 1 */
485
+ color: inherit; /* 1 */
486
+ margin: 0; /* 2 */
487
+ padding: 0; /* 3 */
488
+ }
489
+
490
+ /*
491
+ Remove the inheritance of text transform in Edge and Firefox.
492
+ */
493
+
494
+ button,
495
+ select {
496
+ text-transform: none;
497
+ }
498
+
499
+ /*
500
+ 1. Correct the inability to style clickable types in iOS and Safari.
501
+ 2. Remove default button styles.
502
+ */
503
+
504
+ button,
505
+ input:where([type='button']),
506
+ input:where([type='reset']),
507
+ input:where([type='submit']) {
508
+ -webkit-appearance: button; /* 1 */
509
+ background-color: transparent; /* 2 */
510
+ background-image: none; /* 2 */
511
+ }
512
+
513
+ /*
514
+ Use the modern Firefox focus style for all focusable elements.
515
+ */
516
+
517
+ :-moz-focusring {
518
+ outline: auto;
519
+ }
520
+
521
+ /*
522
+ Remove the additional \`:invalid\` styles in Firefox. (https://github.com/mozilla/gecko-dev/blob/2f9eacd9d3d995c937b4251a5557d95d494c9be1/layout/style/res/forms.css#L728-L737)
523
+ */
524
+
525
+ :-moz-ui-invalid {
526
+ box-shadow: none;
527
+ }
528
+
529
+ /*
530
+ Add the correct vertical alignment in Chrome and Firefox.
531
+ */
532
+
533
+ progress {
534
+ vertical-align: baseline;
535
+ }
536
+
537
+ /*
538
+ Correct the cursor style of increment and decrement buttons in Safari.
539
+ */
540
+
541
+ ::-webkit-inner-spin-button,
542
+ ::-webkit-outer-spin-button {
543
+ height: auto;
544
+ }
545
+
546
+ /*
547
+ 1. Correct the odd appearance in Chrome and Safari.
548
+ 2. Correct the outline style in Safari.
549
+ */
550
+
551
+ [type='search'] {
552
+ -webkit-appearance: textfield; /* 1 */
553
+ outline-offset: -2px; /* 2 */
554
+ }
555
+
556
+ /*
557
+ Remove the inner padding in Chrome and Safari on macOS.
558
+ */
559
+
560
+ ::-webkit-search-decoration {
561
+ -webkit-appearance: none;
562
+ }
563
+
564
+ /*
565
+ 1. Correct the inability to style clickable types in iOS and Safari.
566
+ 2. Change font properties to \`inherit\` in Safari.
567
+ */
568
+
569
+ ::-webkit-file-upload-button {
570
+ -webkit-appearance: button; /* 1 */
571
+ font: inherit; /* 2 */
572
+ }
573
+
574
+ /*
575
+ Add the correct display in Chrome and Safari.
576
+ */
577
+
578
+ summary {
579
+ display: list-item;
580
+ }
581
+
582
+ /*
583
+ Removes the default spacing and border for appropriate elements.
584
+ */
585
+
586
+ blockquote,
587
+ dl,
588
+ dd,
589
+ h1,
590
+ h2,
591
+ h3,
592
+ h4,
593
+ h5,
594
+ h6,
595
+ hr,
596
+ figure,
597
+ p,
598
+ pre {
599
+ margin: 0;
600
+ }
601
+
602
+ fieldset {
603
+ margin: 0;
604
+ padding: 0;
605
+ }
606
+
607
+ legend {
608
+ padding: 0;
609
+ }
610
+
611
+ ol,
612
+ ul,
613
+ menu {
614
+ list-style: none;
615
+ margin: 0;
616
+ padding: 0;
617
+ }
618
+
619
+ /*
620
+ Reset default styling for dialogs.
621
+ */
622
+ dialog {
623
+ padding: 0;
624
+ }
625
+
626
+ /*
627
+ Prevent resizing textareas horizontally by default.
628
+ */
629
+
630
+ textarea {
631
+ resize: vertical;
632
+ }
633
+
634
+ /*
635
+ 1. Reset the default placeholder opacity in Firefox. (https://github.com/tailwindlabs/tailwindcss/issues/3300)
636
+ 2. Set the default placeholder color to the user's configured gray 400 color.
637
+ */
638
+
639
+ input::-moz-placeholder, textarea::-moz-placeholder {
640
+ opacity: 1; /* 1 */
641
+ color: #9ca3af; /* 2 */
642
+ }
643
+
644
+ input::placeholder,
645
+ textarea::placeholder {
646
+ opacity: 1; /* 1 */
647
+ color: #9ca3af; /* 2 */
648
+ }
649
+
650
+ /*
651
+ Set the default cursor for buttons.
652
+ */
653
+
654
+ button,
655
+ [role="button"] {
656
+ cursor: pointer;
657
+ }
658
+
659
+ /*
660
+ Make sure disabled buttons don't get the pointer cursor.
661
+ */
662
+ :disabled {
663
+ cursor: default;
664
+ }
665
+
666
+ /*
667
+ 1. Make replaced elements \`display: block\` by default. (https://github.com/mozdevs/cssremedy/issues/14)
668
+ 2. Add \`vertical-align: middle\` to align replaced elements more sensibly by default. (https://github.com/jensimmons/cssremedy/issues/14#issuecomment-634934210)
669
+ This can trigger a poorly considered lint error in some tools but is included by design.
670
+ */
671
+
672
+ img,
673
+ svg,
674
+ video,
675
+ canvas,
676
+ audio,
677
+ iframe,
678
+ embed,
679
+ object {
680
+ display: block; /* 1 */
681
+ vertical-align: middle; /* 2 */
682
+ }
683
+
684
+ /*
685
+ Constrain images and videos to the parent width and preserve their intrinsic aspect ratio. (https://github.com/mozdevs/cssremedy/issues/14)
686
+ */
687
+
688
+ img,
689
+ video {
690
+ max-width: 100%;
691
+ height: auto;
692
+ }
693
+
694
+ /* Make elements with the HTML hidden attribute stay hidden by default */
695
+ [hidden]:where(:not([hidden="until-found"])) {
696
+ display: none;
697
+ }
698
+ .container {
699
+ width: 100%;
700
+ }
701
+ .pointer-events-none {
702
+ pointer-events: none;
703
+ }
704
+ .visible {
705
+ visibility: visible;
706
+ }
707
+ .static {
708
+ position: static;
709
+ }
710
+ .fixed {
711
+ position: fixed;
712
+ }
713
+ .absolute {
714
+ position: absolute;
715
+ }
716
+ .relative {
717
+ position: relative;
718
+ }
719
+ .top-0 {
720
+ top: 0px;
721
+ }
722
+ .my-2 {
723
+ margin-top: 0.5rem;
724
+ margin-bottom: 0.5rem;
725
+ }
726
+ .mb-4 {
727
+ margin-bottom: 1rem;
728
+ }
729
+ .ml-2 {
730
+ margin-left: 0.5rem;
731
+ }
732
+ .mr-2 {
733
+ margin-right: 0.5rem;
734
+ }
735
+ .mt-1 {
736
+ margin-top: 0.25rem;
737
+ }
738
+ .mt-2 {
739
+ margin-top: 0.5rem;
740
+ }
741
+ .block {
742
+ display: block;
743
+ }
744
+ .inline-block {
745
+ display: inline-block;
746
+ }
747
+ .flex {
748
+ display: flex;
749
+ }
750
+ .hidden {
751
+ display: none;
752
+ }
753
+ .h-12 {
754
+ height: 3rem;
755
+ }
756
+ .h-4 {
757
+ height: 1rem;
758
+ }
759
+ .h-auto {
760
+ height: auto;
761
+ }
762
+ .h-full {
763
+ height: 100%;
764
+ }
765
+ .max-h-\\[300px\\] {
766
+ max-height: 300px;
767
+ }
768
+ .min-h-0 {
769
+ min-height: 0px;
770
+ }
771
+ .min-h-screen {
772
+ min-height: 100vh;
773
+ }
774
+ .w-4 {
775
+ width: 1rem;
776
+ }
777
+ .w-full {
778
+ width: 100%;
779
+ }
780
+ .max-w-\\[400px\\] {
781
+ max-width: 400px;
782
+ }
783
+ .flex-1 {
784
+ flex: 1 1 0%;
785
+ }
786
+ .flex-shrink-0 {
787
+ flex-shrink: 0;
788
+ }
789
+ .transform {
790
+ transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
791
+ }
792
+ @keyframes spin {
793
+
794
+ to {
795
+ transform: rotate(360deg);
796
+ }
797
+ }
798
+ .animate-spin {
799
+ animation: spin 1s linear infinite;
800
+ }
801
+ .flex-col {
802
+ flex-direction: column;
803
+ }
804
+ .flex-wrap {
805
+ flex-wrap: wrap;
806
+ }
807
+ .items-center {
808
+ align-items: center;
809
+ }
810
+ .justify-center {
811
+ justify-content: center;
812
+ }
813
+ .gap-2 {
814
+ gap: 0.5rem;
815
+ }
816
+ .overflow-y-auto {
817
+ overflow-y: auto;
818
+ }
819
+ .whitespace-pre {
820
+ white-space: pre;
821
+ }
822
+ .rounded {
823
+ border-radius: 0.25rem;
824
+ }
825
+ .rounded-full {
826
+ border-radius: 9999px;
827
+ }
828
+ .rounded-lg {
829
+ border-radius: 0.5rem;
830
+ }
831
+ .border {
832
+ border-width: 1px;
833
+ }
834
+ .border-2 {
835
+ border-width: 2px;
836
+ }
837
+ .border-t {
838
+ border-top-width: 1px;
839
+ }
840
+ .border-gray-300 {
841
+ --tw-border-opacity: 1;
842
+ border-color: rgb(209 213 219 / var(--tw-border-opacity, 1));
843
+ }
844
+ .border-gray-700 {
845
+ --tw-border-opacity: 1;
846
+ border-color: rgb(55 65 81 / var(--tw-border-opacity, 1));
847
+ }
848
+ .border-t-gray-600 {
849
+ --tw-border-opacity: 1;
850
+ border-top-color: rgb(75 85 99 / var(--tw-border-opacity, 1));
851
+ }
852
+ .bg-gray-100 {
853
+ --tw-bg-opacity: 1;
854
+ background-color: rgb(243 244 246 / var(--tw-bg-opacity, 1));
855
+ }
856
+ .bg-gray-800 {
857
+ --tw-bg-opacity: 1;
858
+ background-color: rgb(31 41 55 / var(--tw-bg-opacity, 1));
859
+ }
860
+ .bg-gray-900 {
861
+ --tw-bg-opacity: 1;
862
+ background-color: rgb(17 24 39 / var(--tw-bg-opacity, 1));
863
+ }
864
+ .bg-green-500 {
865
+ --tw-bg-opacity: 1;
866
+ background-color: rgb(34 197 94 / var(--tw-bg-opacity, 1));
867
+ }
868
+ .bg-red-500 {
869
+ --tw-bg-opacity: 1;
870
+ background-color: rgb(239 68 68 / var(--tw-bg-opacity, 1));
871
+ }
872
+ .bg-transparent {
873
+ background-color: transparent;
874
+ }
875
+ .bg-white {
876
+ --tw-bg-opacity: 1;
877
+ background-color: rgb(255 255 255 / var(--tw-bg-opacity, 1));
878
+ }
879
+ .object-contain {
880
+ -o-object-fit: contain;
881
+ object-fit: contain;
882
+ }
883
+ .p-3 {
884
+ padding: 0.75rem;
885
+ }
886
+ .p-4 {
887
+ padding: 1rem;
888
+ }
889
+ .p-6 {
890
+ padding: 1.5rem;
891
+ }
892
+ .px-2 {
893
+ padding-left: 0.5rem;
894
+ padding-right: 0.5rem;
895
+ }
896
+ .px-4 {
897
+ padding-left: 1rem;
898
+ padding-right: 1rem;
899
+ }
900
+ .py-1 {
901
+ padding-top: 0.25rem;
902
+ padding-bottom: 0.25rem;
903
+ }
904
+ .pt-2 {
905
+ padding-top: 0.5rem;
906
+ }
907
+ .pt-3 {
908
+ padding-top: 0.75rem;
909
+ }
910
+ .text-left {
911
+ text-align: left;
912
+ }
913
+ .font-mono {
914
+ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
915
+ }
916
+ .text-base {
917
+ font-size: 1rem;
918
+ line-height: 1.5rem;
919
+ }
920
+ .text-lg {
921
+ font-size: 1.125rem;
922
+ line-height: 1.75rem;
923
+ }
924
+ .text-sm {
925
+ font-size: 0.875rem;
926
+ line-height: 1.25rem;
927
+ }
928
+ .text-xs {
929
+ font-size: 0.75rem;
930
+ line-height: 1rem;
931
+ }
932
+ .text-blue-400 {
933
+ --tw-text-opacity: 1;
934
+ color: rgb(96 165 250 / var(--tw-text-opacity, 1));
935
+ }
936
+ .text-gray-200 {
937
+ --tw-text-opacity: 1;
938
+ color: rgb(229 231 235 / var(--tw-text-opacity, 1));
939
+ }
940
+ .text-gray-300 {
941
+ --tw-text-opacity: 1;
942
+ color: rgb(209 213 219 / var(--tw-text-opacity, 1));
943
+ }
944
+ .text-gray-400 {
945
+ --tw-text-opacity: 1;
946
+ color: rgb(156 163 175 / var(--tw-text-opacity, 1));
947
+ }
948
+ .text-gray-500 {
949
+ --tw-text-opacity: 1;
950
+ color: rgb(107 114 128 / var(--tw-text-opacity, 1));
951
+ }
952
+ .text-gray-700 {
953
+ --tw-text-opacity: 1;
954
+ color: rgb(55 65 81 / var(--tw-text-opacity, 1));
955
+ }
956
+ .text-green-500 {
957
+ --tw-text-opacity: 1;
958
+ color: rgb(34 197 94 / var(--tw-text-opacity, 1));
959
+ }
960
+ .text-red-400 {
961
+ --tw-text-opacity: 1;
962
+ color: rgb(248 113 113 / var(--tw-text-opacity, 1));
963
+ }
964
+ .text-red-500 {
965
+ --tw-text-opacity: 1;
966
+ color: rgb(239 68 68 / var(--tw-text-opacity, 1));
967
+ }
968
+ .text-white {
969
+ --tw-text-opacity: 1;
970
+ color: rgb(255 255 255 / var(--tw-text-opacity, 1));
971
+ }
972
+ .underline {
973
+ text-decoration-line: underline;
974
+ }
975
+ .caret-transparent {
976
+ caret-color: transparent;
977
+ }
978
+ .shadow {
979
+ --tw-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
980
+ --tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);
981
+ box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);
982
+ }
983
+ .shadow-lg {
984
+ --tw-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
985
+ --tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);
986
+ box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);
987
+ }
988
+ .outline-none {
989
+ outline: 2px solid transparent;
990
+ outline-offset: 2px;
991
+ }
992
+ .filter {
993
+ filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);
994
+ }
995
+ .transition {
996
+ transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, -webkit-backdrop-filter;
997
+ transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter;
998
+ transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter, -webkit-backdrop-filter;
999
+ transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
1000
+ transition-duration: 150ms;
1001
+ }
1002
+ .ease-in-out {
1003
+ transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
1004
+ }
1005
+ .ease-out {
1006
+ transition-timing-function: cubic-bezier(0, 0, 0.2, 1);
1007
+ }
1008
+ .last\\:mb-0:last-child {
1009
+ margin-bottom: 0px;
1010
+ }
1011
+ .last\\:mr-0:last-child {
1012
+ margin-right: 0px;
1013
+ }
1014
+ `,Le=({config:r=M,commands:e={},containerId:t=null})=>(l.useEffect(()=>{const o=new Kn(e,r),i=t?document.getElementById(t):document.body;return i?i.appendChild(o):(console.warn(`Container with id "${t}" not found, falling back to body`),document.body.appendChild(o)),()=>{var a;(a=o.parentElement)==null||a.removeChild(o)}},[e,t]),null);class Kn extends HTMLElement{constructor(t,o){super();A(this,"shadow");A(this,"root",null);A(this,"commands");A(this,"config");this.shadow=this.attachShadow({mode:"open"}),this.commands=t,this.config=o}connectedCallback(){try{const o=[Yn,Wn,Vn,ze].map(i=>{const a=new CSSStyleSheet;return a.replaceSync(i),a});this.shadow.adoptedStyleSheets=[...o]}catch{const i=[Yn,Wn,Vn].join(`
1015
+ `),a=document.createElement("style");a.textContent=i,this.shadow.appendChild(a)}const t=document.createElement("div");t.id="citadel-root",this.shadow.appendChild(t),this.root=hn(t),this.root.render(g.jsx(xe,{config:this.config||M,commands:this.commands,children:g.jsx(Fe,{})}))}}customElements.define("citadel-element",Kn);const Fe=()=>{const[r,e]=l.useState(!1),[t,o]=l.useState(!1),[i,a]=l.useState(null),c=l.useRef(null),u=l.useRef(null),p=l.useRef(!1),w=l.useRef(0),f=l.useRef(0),b=G(),{state:m,actions:x,getAvailableCommands:y}=je(),v=l.useCallback(S=>{u.current&&(p.current=!0,w.current=S.clientY,f.current=u.current.offsetHeight,document.documentElement.style.userSelect="none",document.documentElement.style.webkitUserSelect="none",document.documentElement.style.mozUserSelect="none",document.documentElement.style.msUserSelect="none",document.addEventListener("mousemove",k),document.addEventListener("mouseup",h))},[]),k=l.useCallback(S=>{var U;if(!p.current)return;const I=S.clientY-w.current,T=(U=b.maxHeight)!=null&&U.endsWith("vh")?window.innerHeight*parseInt(b.maxHeight,10)/100:parseInt(b.maxHeight||"80vh",10),z=Math.min(Math.max(f.current-I,parseInt(b.minHeight||"200",10)),T);u.current&&(u.current.style.height=`${z}px`,u.current.style.bottom="0",a(z))},[b.maxHeight]),h=l.useCallback(()=>{p.current=!1,document.documentElement.style.userSelect="",document.documentElement.style.webkitUserSelect="",document.documentElement.style.mozUserSelect="",document.documentElement.style.msUserSelect="",document.removeEventListener("mousemove",k),document.removeEventListener("mouseup",h)},[]);l.useEffect(()=>()=>{document.removeEventListener("mousemove",k),document.removeEventListener("mouseup",h)},[k,h]),be({onOpen:()=>e(!0),onClose:()=>o(!0),isVisible:r,showCitadelKey:b.showCitadelKey||"."});const _=l.useCallback(()=>{t&&(e(!1),o(!1))},[t]);return we({isVisible:r,isClosing:t,onAnimationComplete:_}),r?g.jsxs("div",{ref:u,className:`container ${r?"citadel_slideUp":""} ${t?"citadel_slideDown":""}`,style:{...i?{height:`${i}px`}:void 0,maxHeight:b.maxHeight},children:[g.jsx("div",{className:"resizeHandle",onMouseDown:v}),g.jsxs("div",{className:"innerContainer",children:[g.jsx("div",{className:"flex-1 min-h-0 pt-3 px-4",children:g.jsx(Oe,{output:m.output,outputRef:c})}),g.jsxs("div",{children:[g.jsx(Ie,{state:m,actions:x,availableCommands:y()}),g.jsx(De,{state:m,availableCommands:y()})]})]})]}):null};P.Citadel=Le,P.CommandResult=W,P.CommandStatus=X,P.DEFAULT_CURSOR_CONFIGS=Mn,P.ErrorCommandResult=On,P.ImageCommandResult=_e,P.JsonCommandResult=ke,P.OutputItem=zn,P.PendingCommandResult=Dn,P.TextCommandResult=pn,Object.defineProperty(P,Symbol.toStringTag,{value:"Module"})});