@cryptiklemur/lattice 5.8.3 → 5.9.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 (78) hide show
  1. package/dist/client/assets/{angular-html-BpO2Tp5w.js → angular-html-8JKlj5ad.js} +1 -1
  2. package/dist/client/assets/{angular-ts-DgHuzSgH.js → angular-ts-DM4EAst9.js} +1 -1
  3. package/dist/client/assets/{apl-DN-3g-kA.js → apl-udROknSk.js} +1 -1
  4. package/dist/client/assets/{astro-DC7TkZXH.js → astro-CJikhv_r.js} +1 -1
  5. package/dist/client/assets/{blade-DJeBezn7.js → blade-CClbyOec.js} +1 -1
  6. package/dist/client/assets/{c-CWPHtG_V.js → c-COT7AWn_.js} +1 -1
  7. package/dist/client/assets/{cobol-TtN3pbhH.js → cobol-CPRu8Rmc.js} +1 -1
  8. package/dist/client/assets/{coffee-DR36C-Bj.js → coffee-BAPMJD1x.js} +1 -1
  9. package/dist/client/assets/{cpp-C9XaUQ0i.js → cpp-D17pC1A2.js} +1 -1
  10. package/dist/client/assets/{crystal-T-sTBJEW.js → crystal-Wm3u_0fs.js} +1 -1
  11. package/dist/client/assets/{css-BX5yO7SA.js → css-DdsIUVB9.js} +1 -1
  12. package/dist/client/assets/{dist-VJaucYqW.js → dist-Czy4uBIU.js} +2 -2
  13. package/dist/client/assets/{edge-B6UK8iH4.js → edge-Ba2zKZ07.js} +1 -1
  14. package/dist/client/assets/{elixir-CgftVsub.js → elixir-CjkAxj6n.js} +1 -1
  15. package/dist/client/assets/{elm-Bm5ehGFJ.js → elm-eK84qhmU.js} +1 -1
  16. package/dist/client/assets/{erb-BGdFwtqx.js → erb-DaOSeBfZ.js} +1 -1
  17. package/dist/client/assets/{git-rebase-Dgch70i-.js → git-rebase-Bs_LvrD9.js} +1 -1
  18. package/dist/client/assets/{glimmer-js-CO2m7K3o.js → glimmer-js-BTQEYtLP.js} +1 -1
  19. package/dist/client/assets/{glimmer-ts-Rh9OBnOT.js → glimmer-ts-8knr0l2i.js} +1 -1
  20. package/dist/client/assets/{glsl-DKLX4cjW.js → glsl-BYHK68lX.js} +1 -1
  21. package/dist/client/assets/{graphql-CirzzkU1.js → graphql-DDj1OtPF.js} +1 -1
  22. package/dist/client/assets/{hack-CQC9znUp.js → hack-CcKIyJY8.js} +1 -1
  23. package/dist/client/assets/{haml-ze151Tzg.js → haml-Ckvp9ZDE.js} +1 -1
  24. package/dist/client/assets/{handlebars-CxjP8Lo0.js → handlebars-BmkOrZAU.js} +1 -1
  25. package/dist/client/assets/{html-CqXIaUHF.js → html-BNeILzYX.js} +1 -1
  26. package/dist/client/assets/{html-derivative-BzQtEeTI.js → html-derivative-DXYTWJdT.js} +1 -1
  27. package/dist/client/assets/{http-DuZ92gpQ.js → http-Bm6thhnK.js} +1 -1
  28. package/dist/client/assets/{hurl-CAbh6Y6a.js → hurl-C1VtDM6O.js} +1 -1
  29. package/dist/client/assets/{index-etW8QK5W.css → index-B5VoMd15.css} +1 -1
  30. package/dist/client/assets/{index-E8YNABWy.js → index-BtD8qQe3.js} +7 -7
  31. package/dist/client/assets/{java-DzcsTbJs.js → java-B6K9sIL3.js} +1 -1
  32. package/dist/client/assets/{javascript-DClRq2ts.js → javascript-CVnObVni.js} +1 -1
  33. package/dist/client/assets/{jinja-B5sT9_-9.js → jinja-DIl2wopt.js} +1 -1
  34. package/dist/client/assets/{jison-CU3zhnCb.js → jison-Bzd-FxY3.js} +1 -1
  35. package/dist/client/assets/{json-CQp0L0ej.js → json-DGk6UGY4.js} +1 -1
  36. package/dist/client/assets/{jsx-Bf-5FvbF.js → jsx-gCV-fD9Z.js} +1 -1
  37. package/dist/client/assets/{julia-CydtGy78.js → julia-BrGr__9m.js} +1 -1
  38. package/dist/client/assets/{just-DdklfRff.js → just-Di9h03x3.js} +1 -1
  39. package/dist/client/assets/{latex-Br5dIruj.js → latex-DsZVz_IO.js} +1 -1
  40. package/dist/client/assets/{liquid-BzrfNGvH.js → liquid-zepQwhaf.js} +1 -1
  41. package/dist/client/assets/{lua-Cj4dlLGr.js → lua-C0SGvxRb.js} +1 -1
  42. package/dist/client/assets/{marko-BSCcyzMZ.js → marko-DmPgKAzL.js} +1 -1
  43. package/dist/client/assets/{mdc-BPOjCacH.js → mdc-1KJwlAmt.js} +1 -1
  44. package/dist/client/assets/{nginx-DbzWTwI6.js → nginx-_-_z2Bjm.js} +1 -1
  45. package/dist/client/assets/{nim-CRdChtbV.js → nim-C9QfMb2o.js} +1 -1
  46. package/dist/client/assets/{perl-C3QVEeKS.js → perl-DnP404vu.js} +1 -1
  47. package/dist/client/assets/{php-C1EdFiJm.js → php-DyGyvtbP.js} +1 -1
  48. package/dist/client/assets/{pug-CO6P9E1X.js → pug-C0v501gI.js} +1 -1
  49. package/dist/client/assets/{qml-iW4zlehx.js → qml-Dn6-iA6b.js} +1 -1
  50. package/dist/client/assets/{r-C6XBkrUL.js → r-96JXyyfm.js} +1 -1
  51. package/dist/client/assets/{razor-CeQnxDgb.js → razor-CyBZxn9W.js} +1 -1
  52. package/dist/client/assets/{regexp-Dy8aAKap.js → regexp-WC_YlMIa.js} +1 -1
  53. package/dist/client/assets/{rst-OwTtwL0i.js → rst-BByyhlEZ.js} +1 -1
  54. package/dist/client/assets/{ruby-D7JWM2N5.js → ruby-BvQy3HKZ.js} +1 -1
  55. package/dist/client/assets/{sas-DiK66SDU.js → sas-BtW-j5ov.js} +1 -1
  56. package/dist/client/assets/{scss-qrlTvxMb.js → scss-DhqQMrFB.js} +1 -1
  57. package/dist/client/assets/{shellscript-D7AOrbZb.js → shellscript-D16b1-i2.js} +1 -1
  58. package/dist/client/assets/{shellsession-DjQiM7TM.js → shellsession-Bw15k9FH.js} +1 -1
  59. package/dist/client/assets/{soy-BL7E9JSD.js → soy-Cs-U7QL1.js} +1 -1
  60. package/dist/client/assets/{sql-CteFkLc2.js → sql-BWtytU08.js} +1 -1
  61. package/dist/client/assets/{stata-B3MgNvuI.js → stata-CnuYfC8x.js} +1 -1
  62. package/dist/client/assets/{surrealql-COKgmBsN.js → surrealql-DKSkaRaH.js} +1 -1
  63. package/dist/client/assets/{svelte-Gjt4fCGF.js → svelte-Cyv2obHJ.js} +1 -1
  64. package/dist/client/assets/{templ-Bj518YFy.js → templ-C0EIvZlo.js} +1 -1
  65. package/dist/client/assets/{tex-DRQn3t1e.js → tex-CuZaUPAe.js} +1 -1
  66. package/dist/client/assets/{ts-tags-Ca2ut20u.js → ts-tags-DwkkHusB.js} +1 -1
  67. package/dist/client/assets/{tsx-q8zyOWFk.js → tsx-Dtf-SzhM.js} +1 -1
  68. package/dist/client/assets/{twig-TjCAErzr.js → twig-CeA0HG91.js} +1 -1
  69. package/dist/client/assets/{typescript-p7KFNEGW.js → typescript-KIqRWyll.js} +1 -1
  70. package/dist/client/assets/{vue-BPqqN4qD.js → vue-DhTR6Wxc.js} +1 -1
  71. package/dist/client/assets/{vue-html-DWzvGKv5.js → vue-html-3oU4yV-b.js} +1 -1
  72. package/dist/client/assets/{vue-vine-ooxqXIjP.js → vue-vine-DTbyNCqF.js} +1 -1
  73. package/dist/client/assets/{xml-B8jNsjt9.js → xml-e4PNboGe.js} +1 -1
  74. package/dist/client/assets/{xsl-B6pyn4Tp.js → xsl-B0MOV4pk.js} +1 -1
  75. package/dist/client/assets/{yaml-BN6nvuC4.js → yaml-Cymug6w8.js} +1 -1
  76. package/dist/client/index.html +2 -2
  77. package/dist/client/sw.js +1 -1
  78. package/package.json +1 -1
@@ -112,7 +112,7 @@ ${s.join(`
112
112
  `).slice(2,3).join(`
113
113
  `).trim(),t=/(file:|vscode-file:\/\/vscode-app)?(\/[^:]*:\d+:\d+)/.exec(e);mN.register(a,t?.[2]??e,a)}return a},this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let t=this._listeners,n=t.indexOf(e);if(n===-1)throw console.log(`disposed?`,this._disposed),console.log(`size?`,this._size),console.log(`arr?`,JSON.stringify(this._listeners)),Error(`Attempted to dispose unknown listener`);this._size--,t[n]=void 0;let r=this._deliveryQueue.current===this;if(this._size*fN<=t.length){let e=0;for(let n=0;n<t.length;n++)t[n]?t[e++]=t[n]:r&&(this._deliveryQueue.end--,e<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=e}}_deliver(e,t){if(!e)return;let n=this._options?.onListenerError||yM;if(!n){e.value(t);return}try{e.value(t)}catch(e){n(e)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof dN)this._deliver(this._listeners,e);else{let t=this._deliveryQueue;t.enqueue(this,e,this._listeners.length),this._deliverQueue(t)}this._perfMon?.stop()}hasListeners(){return this._size>0}},gN=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,n){this.i=0,this.end=n,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},_N=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),vN;(e=>{function t(t){return t===e.None||t===e.Cancelled||t instanceof yN?!0:!t||typeof t!=`object`?!1:typeof t.isCancellationRequested==`boolean`&&typeof t.onCancellationRequested==`function`}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:tN.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:_N})})(vN||={});var yN=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?_N:(this._emitter||=new hN,this._emitter.event)}dispose(){this._emitter&&=(this._emitter.dispose(),null)}},bN=`en`,xN=!1,SN=!1,CN=bN,wN,TN=globalThis,EN;typeof TN.vscode<`u`&&typeof TN.vscode.process<`u`?EN=TN.vscode.process:typeof process<`u`&&typeof process?.versions?.node==`string`&&(EN=process);var DN=typeof EN?.versions?.electron==`string`&&EN?.type===`renderer`;if(typeof EN==`object`){EN.platform,EN.platform,xN=EN.platform===`linux`,xN&&EN.env.SNAP&&EN.env.SNAP_REVISION,EN.env.CI||EN.env.BUILD_ARTIFACTSTAGINGDIRECTORY,CN=bN;let e=EN.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,CN=t.resolvedLanguage||bN,t.languagePack?.translationsConfigFile}catch{}}else typeof navigator==`object`&&!DN?(wN=navigator.userAgent,wN.indexOf(`Windows`),wN.indexOf(`Macintosh`),(wN.indexOf(`Macintosh`)>=0||wN.indexOf(`iPad`)>=0||wN.indexOf(`iPhone`)>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints,xN=wN.indexOf(`Linux`)>=0,wN?.indexOf(`Mobi`),SN=!0,CN=globalThis._VSCODE_NLS_LANGUAGE||bN,navigator.language.toLowerCase()):console.error(`Unable to resolve platform.`);SN&&typeof TN.importScripts==`function`&&TN.origin;var ON=wN,kN=CN,AN;(e=>{function t(){return kN}e.value=t;function n(){return kN.length===2?kN===`en`:kN.length>=3?kN[0]===`e`&&kN[1]===`n`&&kN[2]===`-`:!1}e.isDefaultVariant=n;function r(){return kN===`en`}e.isDefault=r})(AN||={});var jN=typeof TN.postMessage==`function`&&!TN.importScripts;(()=>{if(jN){let e=[];TN.addEventListener(`message`,t=>{if(t.data&&t.data.vscodeScheduleAsyncWork)for(let n=0,r=e.length;n<r;n++){let r=e[n];if(r.id===t.data.vscodeScheduleAsyncWork){e.splice(n,1),r.callback();return}}});let t=0;return n=>{let r=++t;e.push({id:r,callback:n}),TN.postMessage({vscodeScheduleAsyncWork:r},`*`)}}return e=>setTimeout(e)})();var MN=!!(ON&&ON.indexOf(`Chrome`)>=0);ON&&ON.indexOf(`Firefox`),!MN&&ON&&ON.indexOf(`Safari`),ON&&ON.indexOf(`Edg/`),ON&&ON.indexOf(`Android`);function NN(e,t=0,n){let r=setTimeout(()=>{e(),n&&i.dispose()},t),i=WM(()=>{clearTimeout(r),n?.deleteAndLeak(i)});return n?.add(i),i}(function(){typeof globalThis.requestIdleCallback!=`function`||globalThis.cancelIdleCallback})();var PN;(e=>{async function t(e){let t,n=await Promise.all(e.map(e=>e.then(e=>e,e=>{t||=e})));if(typeof t<`u`)throw t;return n}e.settled=t;function n(e){return new Promise(async(t,n)=>{try{await e(t,n)}catch(e){n(e)}})}e.withAsyncBody=n})(PN||={});var FN=class e{static fromArray(t){return new e(e=>{e.emitMany(t)})}static fromPromise(t){return new e(async e=>{e.emitMany(await t)})}static fromPromises(t){return new e(async e=>{await Promise.all(t.map(async t=>e.emitOne(await t)))})}static merge(t){return new e(async e=>{await Promise.all(t.map(async t=>{for await(let n of t)e.emitOne(n)}))})}constructor(e,t){this._state=0,this._results=[],this._error=null,this._onReturn=t,this._onStateChanged=new hN,queueMicrotask(async()=>{let t={emitOne:e=>this.emitOne(e),emitMany:e=>this.emitMany(e),reject:e=>this.reject(e)};try{await Promise.resolve(e(t)),this.resolve()}catch(e){this.reject(e)}finally{t.emitOne=void 0,t.emitMany=void 0,t.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(this._state===1)return{done:!0,value:void 0};await tN.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,n){return new e(async e=>{for await(let r of t)e.emitOne(n(r))})}map(t){return e.map(this,t)}static filter(t,n){return new e(async e=>{for await(let r of t)n(r)&&e.emitOne(r)})}filter(t){return e.filter(this,t)}static coalesce(t){return e.filter(t,e=>!!e)}coalesce(){return e.coalesce(this)}static async toPromise(e){let t=[];for await(let n of e)t.push(n);return t}toPromise(){return e.toPromise(this)}emitOne(e){this._state===0&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){this._state===0&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(e){this._state===0&&(this._state=2,this._error=e,this._onStateChanged.fire())}};FN.EMPTY=FN.fromArray([]);var IN=class extends qM{constructor(e){super(),this._terminal=e,this._linesCacheTimeout=this._register(new JM),this._linesCacheDisposables=this._register(new JM),this._register(WM(()=>this._destroyLinesCache()))}initLinesCache(){this._linesCache||(this._linesCache=Array(this._terminal.buffer.active.length),this._linesCacheDisposables.value=UM(this._terminal.onLineFeed(()=>this._destroyLinesCache()),this._terminal.onCursorMove(()=>this._destroyLinesCache()),this._terminal.onResize(()=>this._destroyLinesCache()))),this._linesCacheTimeout.value=NN(()=>this._destroyLinesCache(),15e3)}_destroyLinesCache(){this._linesCache=void 0,this._linesCacheDisposables.clear(),this._linesCacheTimeout.clear()}getLineFromCache(e){return this._linesCache?.[e]}setLineInCache(e,t){this._linesCache&&(this._linesCache[e]=t)}translateBufferLineToStringWithWrap(e,t){let n=[],r=[0],i=this._terminal.buffer.active.getLine(e);for(;i;){let a=this._terminal.buffer.active.getLine(e+1),o=a?a.isWrapped:!1,s=i.translateToString(!o&&t);if(o&&a){let e=i.getCell(i.length-1);e&&e.getCode()===0&&e.getWidth()===1&&a.getCell(0)?.getWidth()===2&&(s=s.slice(0,-1))}if(n.push(s),o)r.push(r[r.length-1]+s.length);else break;e++,i=a}return[n.join(``),r]}},LN=class{get cachedSearchTerm(){return this._cachedSearchTerm}set cachedSearchTerm(e){this._cachedSearchTerm=e}get lastSearchOptions(){return this._lastSearchOptions}set lastSearchOptions(e){this._lastSearchOptions=e}isValidSearchTerm(e){return!!(e&&e.length>0)}didOptionsChange(e){return this._lastSearchOptions?e?this._lastSearchOptions.caseSensitive!==e.caseSensitive||this._lastSearchOptions.regex!==e.regex||this._lastSearchOptions.wholeWord!==e.wholeWord:!1:!0}shouldUpdateHighlighting(e,t){return t?.decorations?this._cachedSearchTerm===void 0||e!==this._cachedSearchTerm||this.didOptionsChange(t):!1}clearCachedTerm(){this._cachedSearchTerm=void 0}reset(){this._cachedSearchTerm=void 0,this._lastSearchOptions=void 0}},RN=class{constructor(e,t){this._terminal=e,this._lineCache=t}find(e,t,n,r){if(!e||e.length===0){this._terminal.clearSelection();return}if(n>this._terminal.cols)throw Error(`Invalid col: ${n} to search in terminal of ${this._terminal.cols} cols`);this._lineCache.initLinesCache();let i={startRow:t,startCol:n},a=this._findInLine(e,i,r);if(!a)for(let n=t+1;n<this._terminal.buffer.active.baseY+this._terminal.rows&&(i.startRow=n,i.startCol=0,a=this._findInLine(e,i,r),!a);n++);return a}findNextWithSelection(e,t,n){if(!e||e.length===0){this._terminal.clearSelection();return}let r=this._terminal.getSelectionPosition();this._terminal.clearSelection();let i=0,a=0;r&&(n===e?(i=r.end.x,a=r.end.y):(i=r.start.x,a=r.start.y)),this._lineCache.initLinesCache();let o={startRow:a,startCol:i},s=this._findInLine(e,o,t);if(!s)for(let n=a+1;n<this._terminal.buffer.active.baseY+this._terminal.rows&&(o.startRow=n,o.startCol=0,s=this._findInLine(e,o,t),!s);n++);if(!s&&a!==0)for(let n=0;n<a&&(o.startRow=n,o.startCol=0,s=this._findInLine(e,o,t),!s);n++);return!s&&r&&(o.startRow=r.start.y,o.startCol=0,s=this._findInLine(e,o,t)),s}findPreviousWithSelection(e,t,n){if(!e||e.length===0){this._terminal.clearSelection();return}let r=this._terminal.getSelectionPosition();this._terminal.clearSelection();let i=this._terminal.buffer.active.baseY+this._terminal.rows-1,a=this._terminal.cols;this._lineCache.initLinesCache();let o={startRow:i,startCol:a},s;if(r&&(o.startRow=i=r.start.y,o.startCol=a=r.start.x,n!==e&&(s=this._findInLine(e,o,t,!1),s||(o.startRow=i=r.end.y,o.startCol=a=r.end.x))),s||=this._findInLine(e,o,t,!0),!s){o.startCol=Math.max(o.startCol,this._terminal.cols);for(let n=i-1;n>=0&&(o.startRow=n,s=this._findInLine(e,o,t,!0),!s);n--);}if(!s&&i!==this._terminal.buffer.active.baseY+this._terminal.rows-1)for(let n=this._terminal.buffer.active.baseY+this._terminal.rows-1;n>=i&&(o.startRow=n,s=this._findInLine(e,o,t,!0),!s);n--);return s}_isWholeWord(e,t,n){return(e===0||` ~!@#$%^&*()+\`-=[]{}|\\;:"',./<>?`.includes(t[e-1]))&&(e+n.length===t.length||` ~!@#$%^&*()+\`-=[]{}|\\;:"',./<>?`.includes(t[e+n.length]))}_findInLine(e,t,n={},r=!1){let i=t.startRow,a=t.startCol;if(this._terminal.buffer.active.getLine(i)?.isWrapped){if(r){t.startCol+=this._terminal.cols;return}return t.startRow--,t.startCol+=this._terminal.cols,this._findInLine(e,t,n)}let o=this._lineCache.getLineFromCache(i);o||(o=this._lineCache.translateBufferLineToStringWithWrap(i,!0),this._lineCache.setLineInCache(i,o));let[s,c]=o,l=this._bufferColsToStringOffset(i,a),u=e,d=s;n.regex||(u=n.caseSensitive?e:e.toLowerCase(),d=n.caseSensitive?s:s.toLowerCase());let f=-1;if(n.regex){let t=RegExp(u,n.caseSensitive?`g`:`gi`),i;if(r)for(;i=t.exec(d.slice(0,l));)f=t.lastIndex-i[0].length,e=i[0],t.lastIndex-=e.length-1;else i=t.exec(d.slice(l)),i&&i[0].length>0&&(f=l+(t.lastIndex-i[0].length),e=i[0])}else r?l-u.length>=0&&(f=d.lastIndexOf(u,l-u.length)):f=d.indexOf(u,l);if(f>=0){if(n.wholeWord&&!this._isWholeWord(f,d,e))return;let t=0;for(;t<c.length-1&&f>=c[t+1];)t++;let r=t;for(;r<c.length-1&&f+e.length>=c[r+1];)r++;let a=f-c[t],o=f+e.length-c[r],s=this._stringLengthToBufferSize(i+t,a),l=this._stringLengthToBufferSize(i+r,o)-s+this._terminal.cols*(r-t);return{term:e,col:s,row:i+t,size:l}}}_stringLengthToBufferSize(e,t){let n=this._terminal.buffer.active.getLine(e);if(!n)return 0;for(let e=0;e<t;e++){let r=n.getCell(e);if(!r)break;let i=r.getChars();i.length>1&&(t-=i.length-1);let a=n.getCell(e+1);a&&a.getWidth()===0&&t++}return t}_bufferColsToStringOffset(e,t){let n=e,r=0,i=this._terminal.buffer.active.getLine(n);for(;t>0&&i;){for(let e=0;e<t&&e<this._terminal.cols;e++){let t=i.getCell(e);if(!t)break;t.getWidth()&&(r+=t.getCode()===0?1:t.getChars().length)}if(n++,i=this._terminal.buffer.active.getLine(n),i&&!i.isWrapped)break;t-=this._terminal.cols}return r}},zN=class extends qM{constructor(e){super(),this._terminal=e,this._highlightDecorations=[],this._highlightedLines=new Set,this._register(WM(()=>this.clearHighlightDecorations()))}createHighlightDecorations(e,t){this.clearHighlightDecorations();for(let n of e){let e=this._createResultDecorations(n,t,!1);if(e)for(let t of e)this._storeDecoration(t,n)}}createActiveDecoration(e,t){let n=this._createResultDecorations(e,t,!0);if(n)return{decorations:n,match:e,dispose(){HM(n)}}}clearHighlightDecorations(){HM(this._highlightDecorations),this._highlightDecorations=[],this._highlightedLines.clear()}_storeDecoration(e,t){this._highlightedLines.add(e.marker.line),this._highlightDecorations.push({decoration:e,match:t,dispose(){e.dispose()}})}_applyStyles(e,t,n){e.classList.contains(`xterm-find-result-decoration`)||(e.classList.add(`xterm-find-result-decoration`),t&&(e.style.outline=`1px solid ${t}`)),n&&e.classList.add(`xterm-find-active-result-decoration`)}_createResultDecorations(e,t,n){let r=[],i=e.col,a=e.size,o=-this._terminal.buffer.active.baseY-this._terminal.buffer.active.cursorY+e.row;for(;a>0;){let e=Math.min(this._terminal.cols-i,a);r.push([o,i,e]),i=0,a-=e,o++}let s=[];for(let e of r){let r=this._terminal.registerMarker(e[0]),i=this._terminal.registerDecoration({marker:r,x:e[1],width:e[2],backgroundColor:n?t.activeMatchBackground:t.matchBackground,overviewRulerOptions:this._highlightedLines.has(r.line)?void 0:{color:n?t.activeMatchColorOverviewRuler:t.matchOverviewRuler,position:`center`}});if(i){let e=[];e.push(r),e.push(i.onRender(e=>this._applyStyles(e,n?t.activeMatchBorder:t.matchBorder,!1))),e.push(i.onDispose(()=>HM(e))),s.push(i)}}return s.length===0?void 0:s}},BN=class extends qM{constructor(){super(...arguments),this._searchResults=[],this._onDidChangeResults=this._register(new hN)}get onDidChangeResults(){return this._onDidChangeResults.event}get searchResults(){return this._searchResults}get selectedDecoration(){return this._selectedDecoration}set selectedDecoration(e){this._selectedDecoration=e}updateResults(e,t){this._searchResults=e.slice(0,t)}clearResults(){this._searchResults=[]}clearSelectedDecoration(){this._selectedDecoration&&=(this._selectedDecoration.dispose(),void 0)}findResultIndex(e){for(let t=0;t<this._searchResults.length;t++){let n=this._searchResults[t];if(n.row===e.row&&n.col===e.col&&n.size===e.size)return t}return-1}fireResultsChanged(e){if(!e)return;let t=-1;this._selectedDecoration&&(t=this.findResultIndex(this._selectedDecoration.match)),this._onDidChangeResults.fire({resultIndex:t,resultCount:this._searchResults.length})}reset(){this.clearSelectedDecoration(),this.clearResults()}},VN=class extends qM{constructor(e){super(),this._highlightTimeout=this._register(new JM),this._lineCache=this._register(new JM),this._state=new LN,this._resultTracker=this._register(new BN),this._highlightLimit=e?.highlightLimit??1e3}get onDidChangeResults(){return this._resultTracker.onDidChangeResults}activate(e){this._terminal=e,this._lineCache.value=new IN(e),this._engine=new RN(e,this._lineCache.value),this._decorationManager=new zN(e),this._register(this._terminal.onWriteParsed(()=>this._updateMatches())),this._register(this._terminal.onResize(()=>this._updateMatches())),this._register(WM(()=>this.clearDecorations()))}_updateMatches(){this._highlightTimeout.clear(),this._state.cachedSearchTerm&&this._state.lastSearchOptions?.decorations&&(this._highlightTimeout.value=NN(()=>{let e=this._state.cachedSearchTerm;this._state.clearCachedTerm(),this.findPrevious(e,{...this._state.lastSearchOptions,incremental:!0},{noScroll:!0})},200))}clearDecorations(e){this._resultTracker.clearSelectedDecoration(),this._decorationManager?.clearHighlightDecorations(),this._resultTracker.clearResults(),e||this._state.clearCachedTerm()}clearActiveDecoration(){this._resultTracker.clearSelectedDecoration()}findNext(e,t,n){if(!this._terminal||!this._engine)throw Error(`Cannot use addon until it has been loaded`);this._state.lastSearchOptions=t,this._state.shouldUpdateHighlighting(e,t)&&this._highlightAllMatches(e,t);let r=this._findNextAndSelect(e,t,n);return this._fireResults(t),this._state.cachedSearchTerm=e,r}_highlightAllMatches(e,t){if(!this._terminal||!this._engine||!this._decorationManager)throw Error(`Cannot use addon until it has been loaded`);if(!this._state.isValidSearchTerm(e)){this.clearDecorations();return}this.clearDecorations(!0);let n=[],r,i=this._engine.find(e,0,0,t);for(;i&&(r?.row!==i.row||r?.col!==i.col)&&!(n.length>=this._highlightLimit);)r=i,n.push(r),i=this._engine.find(e,r.col+r.term.length>=this._terminal.cols?r.row+1:r.row,r.col+r.term.length>=this._terminal.cols?0:r.col+1,t);this._resultTracker.updateResults(n,this._highlightLimit),t.decorations&&this._decorationManager.createHighlightDecorations(n,t.decorations)}_findNextAndSelect(e,t,n){if(!this._terminal||!this._engine)return!1;if(!this._state.isValidSearchTerm(e))return this._terminal.clearSelection(),this.clearDecorations(),!1;let r=this._engine.findNextWithSelection(e,t,this._state.cachedSearchTerm);return this._selectResult(r,t?.decorations,n?.noScroll)}findPrevious(e,t,n){if(!this._terminal||!this._engine)throw Error(`Cannot use addon until it has been loaded`);this._state.lastSearchOptions=t,this._state.shouldUpdateHighlighting(e,t)&&this._highlightAllMatches(e,t);let r=this._findPreviousAndSelect(e,t,n);return this._fireResults(t),this._state.cachedSearchTerm=e,r}_fireResults(e){this._resultTracker.fireResultsChanged(!!e?.decorations)}_findPreviousAndSelect(e,t,n){if(!this._terminal||!this._engine)return!1;if(!this._state.isValidSearchTerm(e))return this._terminal.clearSelection(),this.clearDecorations(),!1;let r=this._engine.findPreviousWithSelection(e,t,this._state.cachedSearchTerm);return this._selectResult(r,t?.decorations,n?.noScroll)}_selectResult(e,t,n){if(!this._terminal||!this._decorationManager)return!1;if(this._resultTracker.clearSelectedDecoration(),!e)return this._terminal.clearSelection(),!1;if(this._terminal.select(e.col,e.row,e.size),t){let n=this._decorationManager.createActiveDecoration(e,t);n&&(this._resultTracker.selectedDecoration=n)}if(!n&&(e.row>=this._terminal.buffer.active.viewportY+this._terminal.rows||e.row<this._terminal.buffer.active.viewportY)){let t=e.row-this._terminal.buffer.active.viewportY;t-=Math.floor(this._terminal.rows/2),this._terminal.scrollLines(t)}return!0}};function HN(){var e=document.documentElement,t=getComputedStyle(e);function n(e,n){return t.getPropertyValue(e).trim()||n}return{background:n(`--base00`,`#0d0d0d`),foreground:n(`--base05`,`#d4d4d4`),cursor:n(`--base05`,`#d4d4d4`),selectionBackground:n(`--base02`,`#264f78`),black:n(`--base00`,`#1e1e1e`),red:n(`--base08`,`#f44747`),green:n(`--base0B`,`#4ec9b0`),yellow:n(`--base0A`,`#dcdcaa`),blue:n(`--base0D`,`#569cd6`),magenta:n(`--base0E`,`#c586c0`),cyan:n(`--base0C`,`#9cdcfe`),white:n(`--base05`,`#d4d4d4`),brightBlack:n(`--base03`,`#808080`),brightRed:n(`--base08`,`#f44747`),brightGreen:n(`--base0B`,`#4ec9b0`),brightYellow:n(`--base0A`,`#dcdcaa`),brightBlue:n(`--base0D`,`#569cd6`),brightMagenta:n(`--base0E`,`#c586c0`),brightCyan:n(`--base0C`,`#9cdcfe`),brightWhite:n(`--base07`,`#ffffff`)}}function UN({instanceId:e,visible:t}){var n=(0,x.useRef)(null),r=(0,x.useRef)(null),i=(0,x.useRef)(null),a=(0,x.useRef)(null),o=(0,x.useRef)(null),{activeProjectSlug:s}=jy(),{send:c,subscribe:l,unsubscribe:u}=R();return(0,x.useEffect)(function(){if(!n.current)return;var e=new cM({cursorBlink:!0,fontFamily:getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||`JetBrains Mono, monospace`,fontSize:13,theme:HN()}),t=new dM,d=new _M,f=new VN;e.loadAddon(t),e.loadAddon(d),e.loadAddon(f),e.open(n.current),t.fit(),r.current=e,i.current=t,a.current=f;var p=!0;function m(e){p&&(p=!1,o.current=e.termId)}function h(e){var t=e;r.current&&t.termId===o.current&&r.current.write(t.data)}function g(e){var t=e;r.current&&t.termId===o.current&&r.current.write(`\r
114
114
  \x1B[31m[process exited]\x1B[0m\r
115
- `)}l(`terminal:created`,m),l(`terminal:output`,h),l(`terminal:exited`,g),c({type:`terminal:create`,projectSlug:s||void 0}),e.onData(function(e){var t=o.current;t&&c({type:`terminal:input`,termId:t,data:e})});var _=new ResizeObserver(function(){if(i.current){i.current.fit();var e=o.current,t=i.current.proposeDimensions();e&&t&&c({type:`terminal:resize`,termId:e,cols:t.cols,rows:t.rows})}});return n.current&&_.observe(n.current),function(){u(`terminal:created`,m),u(`terminal:output`,h),u(`terminal:exited`,g),_.disconnect(),e.dispose(),r.current=null,i.current=null,a.current=null}},[]),(0,x.useEffect)(function(){if(t&&i.current){var e=setTimeout(function(){if(i.current){i.current.fit();var e=o.current,t=i.current.proposeDimensions();e&&t&&c({type:`terminal:resize`,termId:e,cols:t.cols,rows:t.rows})}},50);return function(){clearTimeout(e)}}},[t]),(0,b.jsx)(`div`,{ref:n,className:`w-full h-full overflow-hidden bg-base-100`,style:{display:t?`block`:`none`},"data-instance-id":e})}var WN=1;function GN(){var e=WN++;return{id:`term-${e}-${Date.now()}`,label:`Terminal ${e}`}}function KN(){var e=GN(),[t,n]=(0,x.useState)([e]),[r,i]=(0,x.useState)(e.id);function a(){var e=GN();n(function(t){return[...t,e]}),i(e.id)}function o(e){n(function(t){if(t.length===1){var n=GN();return i(n.id),[n]}var a=t.filter(function(t){return t.id!==e});if(e===r){var o=t.findIndex(function(t){return t.id===e}),s=a[Math.min(o,a.length-1)];i(s.id)}return a})}return(0,b.jsxs)(`div`,{className:`flex flex-col h-full w-full overflow-hidden`,children:[(0,b.jsxs)(`div`,{role:`tablist`,className:`flex items-center h-8 bg-base-200 border-b border-base-content/15 flex-shrink-0 overflow-x-auto`,children:[t.map(function(e){var n=e.id===r;return(0,b.jsxs)(`div`,{tabIndex:0,role:`tab`,"aria-selected":n,className:[`flex items-center gap-1 px-3 h-full text-[12px] cursor-pointer select-none border-r border-base-content/15 flex-shrink-0 outline-none focus-visible:ring-2 focus-visible:ring-primary/50 focus-visible:ring-offset-1 focus-visible:ring-offset-base-200`,n?`bg-base-100 text-base-content`:`text-base-content/50 hover:text-base-content hover:bg-base-100/50`].join(` `),onClick:function(){i(e.id)},onKeyDown:function(t){(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),i(e.id))},children:[(0,b.jsx)(`span`,{children:e.label}),t.length>1&&(0,b.jsx)(`button`,{className:`ml-1 rounded hover:bg-base-300 p-1 sm:p-0.5 outline-none focus-visible:ring-2 focus-visible:ring-primary/50 focus-visible:ring-offset-1 focus-visible:ring-offset-base-200`,"aria-label":`Close `+e.label,onClick:function(t){t.stopPropagation(),o(e.id)},children:(0,b.jsx)(Nv,{className:`!size-3`})})]},e.id)}),(0,b.jsx)(`button`,{className:`flex items-center justify-center w-10 sm:w-8 h-full text-base-content/50 hover:text-base-content hover:bg-base-100/50 flex-shrink-0 outline-none focus-visible:ring-2 focus-visible:ring-primary/50 focus-visible:ring-offset-1 focus-visible:ring-offset-base-200`,"aria-label":`New terminal`,onClick:a,title:`New terminal`,children:(0,b.jsx)(tv,{className:`!size-4`})})]}),(0,b.jsx)(`div`,{className:`flex-1 min-h-0 relative`,children:t.map(function(e){return(0,b.jsx)(`div`,{className:`absolute inset-0`,style:{display:e.id===r?`block`:`none`},children:(0,b.jsx)(UN,{instanceId:e.id,visible:e.id===r})},e.id)})})]})}function qN(e){return e.map(function(e){return{entry:e,children:null,expanded:!1}})}function JN(e){var{node:t,depth:n,selectedPath:r,onToggle:i,onSelect:a}=e,o=r===t.entry.path,s=t.entry.isDirectory;function c(){s?i(t.entry.path):a(t.entry.path)}function l(e){(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),c())}return(0,b.jsxs)(`div`,{role:`treeitem`,"aria-expanded":s?t.expanded:void 0,"aria-selected":o,children:[(0,b.jsxs)(`div`,{tabIndex:0,onClick:c,onKeyDown:l,className:`flex items-center gap-1.5 py-[3px] pr-2 cursor-pointer text-[13px] rounded select-none outline-none focus-visible:ring-2 focus-visible:ring-primary/50 focus-visible:ring-offset-1 focus-visible:ring-offset-base-200 `+(o?`bg-base-300 text-primary`:`text-base-content hover:bg-base-200`),style:{paddingLeft:8+n*16+`px`},children:[s?(0,b.jsx)(cu,{size:12,className:`flex-shrink-0 text-base-content/40 transition-transform duration-[120ms]`,style:{transform:t.expanded?`rotate(90deg)`:`none`}}):(0,b.jsx)(Um,{size:12,className:`flex-shrink-0 text-base-content/40`}),(0,b.jsx)(`span`,{className:`truncate `+(s?`text-info`:`text-base-content`),children:t.entry.name})]}),s&&t.expanded&&t.children&&(0,b.jsx)(`div`,{role:`group`,children:t.children.map(function(e){return(0,b.jsx)(JN,{node:e,depth:n+1,selectedPath:r,onToggle:i,onSelect:a},e.entry.path)})})]})}function YN(e){var{nodes:t,selectedPath:n,onToggle:r,onSelect:i}=e;return(0,b.jsx)(`div`,{role:`tree`,"aria-label":`File tree`,children:t.length===0?(0,b.jsx)(`div`,{className:`px-2 py-3 text-[12px] text-base-content/40`,children:`Loading...`}):t.map(function(e){return(0,b.jsx)(JN,{node:e,depth:0,selectedPath:n,onToggle:r,onSelect:i},e.entry.path)})})}var XN=`modulepreload`,ZN=function(e){return`/`+e},QN={},$N=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=ZN(t,n),t in QN)return;QN[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:XN,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},eP=null,tP=new Set;function nP(){return eP||=$N(()=>import(`./dist-VJaucYqW.js`).then(function(e){return e.createHighlighter({themes:[`css-variables`],langs:[]})}),[]),eP}async function rP(e,t){var n=await nP(),r=t===`text`?`text`:t;if(r!==`text`&&!tP.has(r))try{await n.loadLanguage(r),tP.add(r)}catch{r=`text`}return n.codeToHtml(e,{lang:r,theme:`css-variables`})}var iP={ts:`typescript`,tsx:`tsx`,js:`javascript`,jsx:`jsx`,json:`json`,md:`markdown`,css:`css`,scss:`scss`,html:`html`,xml:`xml`,yaml:`yaml`,yml:`yaml`,toml:`toml`,py:`python`,rs:`rust`,go:`go`,sh:`bash`,bash:`bash`,zsh:`bash`,sql:`sql`,graphql:`graphql`,dockerfile:`dockerfile`,makefile:`makefile`,vue:`vue`,svelte:`svelte`,lua:`lua`,rb:`ruby`,java:`java`,kt:`kotlin`,swift:`swift`,c:`c`,cpp:`cpp`,h:`c`,hpp:`cpp`,cs:`csharp`};function aP(e){var t=e.split(`/`).pop()||``,n=t.toLowerCase();return n===`dockerfile`?`dockerfile`:n===`makefile`?`makefile`:iP[t.split(`.`).pop()?.toLowerCase()||``]||`text`}function oP(e){return e.toLowerCase().endsWith(`.md`)}function sP(e){var{path:t,content:n,editorUrl:r}=e,[i,a]=(0,x.useState)(null),[o,s]=(0,x.useState)(!1),[c,l]=(0,x.useState)(!0),u=(0,x.useRef)(null),d=aP(t),f=n.split(`
115
+ `)}l(`terminal:created`,m),l(`terminal:output`,h),l(`terminal:exited`,g),c({type:`terminal:create`,projectSlug:s||void 0}),e.onData(function(e){var t=o.current;t&&c({type:`terminal:input`,termId:t,data:e})});var _=new ResizeObserver(function(){if(i.current){i.current.fit();var e=o.current,t=i.current.proposeDimensions();e&&t&&c({type:`terminal:resize`,termId:e,cols:t.cols,rows:t.rows})}});return n.current&&_.observe(n.current),function(){u(`terminal:created`,m),u(`terminal:output`,h),u(`terminal:exited`,g),_.disconnect(),e.dispose(),r.current=null,i.current=null,a.current=null}},[]),(0,x.useEffect)(function(){if(t&&i.current){var e=setTimeout(function(){if(i.current){i.current.fit();var e=o.current,t=i.current.proposeDimensions();e&&t&&c({type:`terminal:resize`,termId:e,cols:t.cols,rows:t.rows})}},50);return function(){clearTimeout(e)}}},[t]),(0,b.jsx)(`div`,{ref:n,className:`w-full h-full overflow-hidden bg-base-100`,style:{display:t?`block`:`none`},"data-instance-id":e})}var WN=1;function GN(){var e=WN++;return{id:`term-${e}-${Date.now()}`,label:`Terminal ${e}`}}function KN(){var e=GN(),[t,n]=(0,x.useState)([e]),[r,i]=(0,x.useState)(e.id);function a(){var e=GN();n(function(t){return[...t,e]}),i(e.id)}function o(e){n(function(t){if(t.length===1){var n=GN();return i(n.id),[n]}var a=t.filter(function(t){return t.id!==e});if(e===r){var o=t.findIndex(function(t){return t.id===e}),s=a[Math.min(o,a.length-1)];i(s.id)}return a})}return(0,b.jsxs)(`div`,{className:`flex flex-col h-full w-full overflow-hidden`,children:[(0,b.jsxs)(`div`,{role:`tablist`,className:`flex items-center h-8 bg-base-200 border-b border-base-content/15 flex-shrink-0 overflow-x-auto`,children:[t.map(function(e){var n=e.id===r;return(0,b.jsxs)(`div`,{tabIndex:0,role:`tab`,"aria-selected":n,className:[`flex items-center gap-1 px-3 h-full text-[12px] cursor-pointer select-none border-r border-base-content/15 flex-shrink-0 outline-none focus-visible:ring-2 focus-visible:ring-primary/50 focus-visible:ring-offset-1 focus-visible:ring-offset-base-200`,n?`bg-base-100 text-base-content`:`text-base-content/50 hover:text-base-content hover:bg-base-100/50`].join(` `),onClick:function(){i(e.id)},onKeyDown:function(t){(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),i(e.id))},children:[(0,b.jsx)(`span`,{children:e.label}),t.length>1&&(0,b.jsx)(`button`,{className:`ml-1 rounded hover:bg-base-300 p-1 sm:p-0.5 outline-none focus-visible:ring-2 focus-visible:ring-primary/50 focus-visible:ring-offset-1 focus-visible:ring-offset-base-200`,"aria-label":`Close `+e.label,onClick:function(t){t.stopPropagation(),o(e.id)},children:(0,b.jsx)(Nv,{className:`!size-3`})})]},e.id)}),(0,b.jsx)(`button`,{className:`flex items-center justify-center w-10 sm:w-8 h-full text-base-content/50 hover:text-base-content hover:bg-base-100/50 flex-shrink-0 outline-none focus-visible:ring-2 focus-visible:ring-primary/50 focus-visible:ring-offset-1 focus-visible:ring-offset-base-200`,"aria-label":`New terminal`,onClick:a,title:`New terminal`,children:(0,b.jsx)(tv,{className:`!size-4`})})]}),(0,b.jsx)(`div`,{className:`flex-1 min-h-0 relative`,children:t.map(function(e){return(0,b.jsx)(`div`,{className:`absolute inset-0`,style:{display:e.id===r?`block`:`none`},children:(0,b.jsx)(UN,{instanceId:e.id,visible:e.id===r})},e.id)})})]})}function qN(e){return e.map(function(e){return{entry:e,children:null,expanded:!1}})}function JN(e){var{node:t,depth:n,selectedPath:r,onToggle:i,onSelect:a}=e,o=r===t.entry.path,s=t.entry.isDirectory;function c(){s?i(t.entry.path):a(t.entry.path)}function l(e){(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),c())}return(0,b.jsxs)(`div`,{role:`treeitem`,"aria-expanded":s?t.expanded:void 0,"aria-selected":o,children:[(0,b.jsxs)(`div`,{tabIndex:0,onClick:c,onKeyDown:l,className:`flex items-center gap-1.5 py-[3px] pr-2 cursor-pointer text-[13px] rounded select-none outline-none focus-visible:ring-2 focus-visible:ring-primary/50 focus-visible:ring-offset-1 focus-visible:ring-offset-base-200 `+(o?`bg-base-300 text-primary`:`text-base-content hover:bg-base-200`),style:{paddingLeft:8+n*16+`px`},children:[s?(0,b.jsx)(cu,{size:12,className:`flex-shrink-0 text-base-content/40 transition-transform duration-[120ms]`,style:{transform:t.expanded?`rotate(90deg)`:`none`}}):(0,b.jsx)(Um,{size:12,className:`flex-shrink-0 text-base-content/40`}),(0,b.jsx)(`span`,{className:`truncate `+(s?`text-info`:`text-base-content`),children:t.entry.name})]}),s&&t.expanded&&t.children&&(0,b.jsx)(`div`,{role:`group`,children:t.children.map(function(e){return(0,b.jsx)(JN,{node:e,depth:n+1,selectedPath:r,onToggle:i,onSelect:a},e.entry.path)})})]})}function YN(e){var{nodes:t,selectedPath:n,onToggle:r,onSelect:i}=e;return(0,b.jsx)(`div`,{role:`tree`,"aria-label":`File tree`,children:t.length===0?(0,b.jsx)(`div`,{className:`px-2 py-3 text-[12px] text-base-content/40`,children:`Loading...`}):t.map(function(e){return(0,b.jsx)(JN,{node:e,depth:0,selectedPath:n,onToggle:r,onSelect:i},e.entry.path)})})}var XN=`modulepreload`,ZN=function(e){return`/`+e},QN={},$N=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=ZN(t,n),t in QN)return;QN[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:XN,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},eP=null,tP=new Set;function nP(){return eP||=$N(()=>import(`./dist-Czy4uBIU.js`).then(function(e){return e.createHighlighter({themes:[`css-variables`],langs:[]})}),[]),eP}async function rP(e,t){var n=await nP(),r=t===`text`?`text`:t;if(r!==`text`&&!tP.has(r))try{await n.loadLanguage(r),tP.add(r)}catch{r=`text`}return n.codeToHtml(e,{lang:r,theme:`css-variables`})}var iP={ts:`typescript`,tsx:`tsx`,js:`javascript`,jsx:`jsx`,json:`json`,md:`markdown`,css:`css`,scss:`scss`,html:`html`,xml:`xml`,yaml:`yaml`,yml:`yaml`,toml:`toml`,py:`python`,rs:`rust`,go:`go`,sh:`bash`,bash:`bash`,zsh:`bash`,sql:`sql`,graphql:`graphql`,dockerfile:`dockerfile`,makefile:`makefile`,vue:`vue`,svelte:`svelte`,lua:`lua`,rb:`ruby`,java:`java`,kt:`kotlin`,swift:`swift`,c:`c`,cpp:`cpp`,h:`c`,hpp:`cpp`,cs:`csharp`};function aP(e){var t=e.split(`/`).pop()||``,n=t.toLowerCase();return n===`dockerfile`?`dockerfile`:n===`makefile`?`makefile`:iP[t.split(`.`).pop()?.toLowerCase()||``]||`text`}function oP(e){return e.toLowerCase().endsWith(`.md`)}function sP(e){var{path:t,content:n,editorUrl:r}=e,[i,a]=(0,x.useState)(null),[o,s]=(0,x.useState)(!1),[c,l]=(0,x.useState)(!0),u=(0,x.useRef)(null),d=aP(t),f=n.split(`
116
116
  `).length,p=oP(t),m=t.split(`/`).pop()||t;(0,x.useEffect)(function(){if(a(null),!(p&&c)){var e=!1;return rP(n,d).then(function(t){e||a(t)}).catch(function(){}),function(){e=!0}}},[n,d,p,c]);function h(){navigator.clipboard.writeText(n),s(!0),u.current&&clearTimeout(u.current),u.current=setTimeout(function(){s(!1)},2e3)}return(0,b.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[(0,b.jsxs)(`div`,{className:`h-9 flex-shrink-0 flex items-center gap-2 px-4 border-b border-base-content/15 bg-base-200`,children:[(0,b.jsx)(Sm,{size:13,className:`text-base-content/40 flex-shrink-0`}),(0,b.jsx)(`span`,{className:`text-[12px] font-mono text-base-content/60 truncate`,children:m}),(0,b.jsx)(`span`,{className:`text-[10px] font-mono px-1.5 py-0.5 rounded bg-base-300 text-base-content/40 uppercase flex-shrink-0`,children:d}),(0,b.jsxs)(`span`,{className:`text-[10px] font-mono text-base-content/30 flex-shrink-0`,children:[f,` lines`]}),(0,b.jsx)(`div`,{className:`flex-1`}),p&&(0,b.jsxs)(`button`,{onClick:function(){l(!c)},className:`btn btn-ghost btn-xs gap-1 text-[11px] `+(c?`text-primary`:`text-base-content/50`),title:c?`Show source`:`Show rendered`,children:[(0,b.jsx)(fm,{size:13}),c?`Source`:`Rendered`]}),(0,b.jsx)(`button`,{onClick:h,className:`btn btn-ghost btn-xs text-base-content/50 hover:text-base-content`,title:`Copy to clipboard`,children:o?(0,b.jsx)(L,{size:13,className:`text-success`}):(0,b.jsx)(Yf,{size:13})}),r&&(0,b.jsx)(`a`,{href:r,className:`btn btn-ghost btn-xs text-base-content/50 hover:text-base-content`,title:`Open in editor`,children:(0,b.jsx)(um,{size:13})})]}),(0,b.jsx)(`div`,{className:`flex-1 overflow-auto`,children:p&&c?(0,b.jsx)(`div`,{className:`prose prose-sm max-w-none p-4`,children:(0,b.jsx)(Cw,{children:n})}):i?(0,b.jsx)(`div`,{className:`p-4 text-[13px] leading-relaxed [&_pre]:!bg-transparent [&_pre]:!m-0 [&_pre]:!p-0 [&_code]:!bg-transparent`,style:{"--shiki-foreground":`var(--base05)`,"--shiki-background":`transparent`,"--shiki-token-constant":`var(--base09)`,"--shiki-token-string":`var(--base0B)`,"--shiki-token-comment":`var(--base03)`,"--shiki-token-keyword":`var(--base0E)`,"--shiki-token-parameter":`var(--base08)`,"--shiki-token-function":`var(--base0D)`,"--shiki-token-string-expression":`var(--base0B)`,"--shiki-token-punctuation":`var(--base05)`,"--shiki-token-link":`var(--base0D)`},dangerouslySetInnerHTML:{__html:i}}):(0,b.jsx)(`pre`,{className:`m-0 p-4 text-[13px] font-mono text-base-content leading-relaxed whitespace-pre-wrap break-words`,children:n})})]})}function cP(){var{send:e,subscribe:t,unsubscribe:n}=R(),{activeProjectSlug:r}=jy(),{activeProject:i}=Dy(),{editorType:a,wslDistro:o}=Nb(),s=(0,x.useRef)(null);s.current=r;var[c,l]=(0,x.useState)([]),[u,d]=(0,x.useState)(null),[f,p]=(0,x.useState)(null),[m,h]=(0,x.useState)(!1),[g,_]=(0,x.useState)(!1),v=(0,x.useRef)([]);v.current=c;var y=(0,x.useCallback)(function(e){var t=e,n=qN(t.entries);if(t.path===``||t.path===`.`){l(n);return}function r(e){return e.map(function(e){return e.entry.path===t.path?Object.assign({},e,{children:n,expanded:!0}):e.children?Object.assign({},e,{children:r(e.children)}):e})}l(function(e){return r(e)})},[]),S=(0,x.useCallback)(function(e){p(e.content),h(!1)},[]),C=(0,x.useRef)(null);C.current=u;var w=(0,x.useCallback)(function(t){var n=t.path;n===C.current&&e({type:`fs:read`,path:n,projectSlug:s.current||void 0})},[e]);(0,x.useEffect)(function(){return t(`fs:list_result`,y),t(`fs:read_result`,S),t(`fs:changed`,w),e({type:`fs:list`,path:`.`,projectSlug:s.current||void 0}),function(){n(`fs:list_result`,y),n(`fs:read_result`,S),n(`fs:changed`,w)}},[y,S,w,e,t,n]);function T(t){function n(r){return r.map(function(r){return r.entry.path===t?!r.expanded&&!r.children?(e({type:`fs:list`,path:t,projectSlug:s.current||void 0}),Object.assign({},r,{expanded:!0})):Object.assign({},r,{expanded:!r.expanded}):r.children?Object.assign({},r,{children:n(r.children)}):r})}l(function(e){return n(e)})}function E(t){d(t),p(null),h(!0),_(!0),e({type:`fs:read`,path:t,projectSlug:r||void 0})}var D=u&&i?Fb(a,i.path,u,void 0,o,i.ideProjectName):null;return(0,b.jsxs)(`div`,{className:`flex h-full w-full overflow-hidden bg-base-100`,children:[(0,b.jsxs)(`div`,{className:`w-full sm:w-[220px] sm:flex-shrink-0 sm:border-r sm:border-base-content/15 overflow-y-auto p-2`+(g?` hidden sm:block`:` block`),children:[(0,b.jsx)(`div`,{className:`text-[11px] font-semibold tracking-[0.06em] uppercase text-base-content/40 px-2 pb-2 pt-1`,children:`Files`}),(0,b.jsx)(YN,{nodes:c,selectedPath:u,onToggle:T,onSelect:E})]}),(0,b.jsxs)(`div`,{className:`flex-1 flex-col overflow-hidden`+(g?` flex`:` hidden sm:flex`),children:[u&&(0,b.jsxs)(`button`,{className:`sm:hidden flex items-center gap-1 px-2 py-1.5 text-[12px] text-base-content/60 hover:text-base-content border-b border-base-content/15`,onClick:function(){_(!1)},children:[(0,b.jsx)(ba,{size:14}),(0,b.jsx)(`span`,{children:`Back to files`})]}),!u&&(0,b.jsxs)(`div`,{className:`h-full flex flex-col items-center justify-center gap-3`,children:[(0,b.jsx)(Sm,{size:28,className:`text-base-content/15`}),(0,b.jsx)(`div`,{className:`text-base-content/40 text-[13px]`,children:`Select a file from the tree to view its contents`})]}),u&&m&&(0,b.jsx)(`div`,{className:`h-full flex items-center justify-center text-base-content/40 text-[13px]`,children:`Loading...`}),u&&!m&&f!==null&&(0,b.jsx)(sP,{path:u,content:f,editorUrl:D}),u&&!m&&f===null&&(0,b.jsxs)(`div`,{className:`h-full flex flex-col items-center justify-center gap-3`,children:[(0,b.jsx)(Hm,{size:28,className:`text-base-content/15`}),(0,b.jsx)(`div`,{className:`text-base-content/40 text-[13px]`,children:`Cannot display this file`}),(0,b.jsx)(`div`,{className:`text-base-content/30 text-[11px]`,children:`Binary files and files over 512KB are not shown`})]})]})]})}function lP(e){var{note:t,onUpdate:n,onDelete:r,disabled:i}=e,[a,o]=(0,x.useState)(!t.content),[s,c]=(0,x.useState)(t.content),[l,u]=(0,x.useState)(!1),d=(0,x.useRef)(t.content);function f(){i||a||(d.current=t.content,c(t.content),o(!0))}function p(){a&&(s.trim()&&s.trim()!==d.current&&n(t.id,s.trim()),o(!1))}function m(e){e.key===`Escape`&&(c(d.current),o(!1)),e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),p())}var h=new Date(t.updatedAt).toLocaleDateString(void 0,{month:`short`,day:`numeric`,year:`numeric`});return(0,b.jsx)(`div`,{className:`card bg-base-200 border border-base-content/15 outline-none focus-visible:ring-2 focus-visible:ring-primary/50 focus-visible:ring-offset-1 focus-visible:ring-offset-base-200`,tabIndex:a?void 0:0,role:a?void 0:`button`,onClick:a?void 0:f,onKeyDown:a?void 0:function(e){(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),f())},style:{cursor:a?`default`:`pointer`},children:(0,b.jsxs)(`div`,{className:`card-body p-3`,children:[a?(0,b.jsx)(`textarea`,{autoFocus:!0,value:s,onChange:function(e){c(e.target.value)},onBlur:p,onKeyDown:m,placeholder:`Type your note...`,"aria-label":`Note content`,className:`textarea textarea-bordered w-full min-h-[80px] bg-base-300 text-base-content text-[13px] resize-y leading-relaxed`}):(0,b.jsx)(`div`,{className:`text-[13px] whitespace-pre-wrap break-words leading-relaxed min-h-12`,children:t.content?(0,b.jsx)(`span`,{className:`text-base-content`,children:t.content}):(0,b.jsx)(`span`,{className:`text-base-content/30 italic`,children:`Click to add a note...`})}),(0,b.jsxs)(`div`,{className:`flex items-center justify-between mt-2`,children:[(0,b.jsx)(`span`,{className:`text-[11px] text-base-content/40`,children:h}),l?(0,b.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,b.jsx)(`button`,{onClick:function(e){e.stopPropagation(),r(t.id)},className:`btn btn-error btn-xs outline-none focus-visible:ring-2 focus-visible:ring-primary/50 focus-visible:ring-offset-1 focus-visible:ring-offset-base-200`,children:`Delete`}),(0,b.jsx)(`button`,{onClick:function(e){e.stopPropagation(),u(!1)},className:`btn btn-ghost btn-xs border border-base-content/15 outline-none focus-visible:ring-2 focus-visible:ring-primary/50 focus-visible:ring-offset-1 focus-visible:ring-offset-base-200`,children:`Cancel`})]}):(0,b.jsx)(`button`,{onClick:function(e){e.stopPropagation(),u(!0)},disabled:i,className:`btn btn-ghost btn-xs border border-base-content/15 text-base-content/50 outline-none focus-visible:ring-2 focus-visible:ring-primary/50 focus-visible:ring-offset-1 focus-visible:ring-offset-base-200`,"aria-label":`Delete note`,children:(0,b.jsx)(Tv,{className:`!size-3`})})]})]})})}function uP(){var{send:e,subscribe:t,unsubscribe:n}=R(),{activeProjectSlug:r}=gb(),i=_b(),[a,o]=(0,x.useState)([]),s=(0,x.useCallback)(function(e){if(e.type===`notes:list_result`){o(e.notes);return}if(e.type===`notes:created`){o(function(t){return[...t,e.note]});return}if(e.type===`notes:updated`){o(function(t){return t.map(function(t){return t.id===e.note.id?e.note:t})});return}if(e.type===`notes:deleted`){o(function(t){return t.filter(function(t){return t.id!==e.id})});return}},[]);(0,x.useEffect)(function(){return t(`notes:list_result`,s),t(`notes:created`,s),t(`notes:updated`,s),t(`notes:deleted`,s),e({type:`notes:list`,projectSlug:r??void 0}),function(){n(`notes:list_result`,s),n(`notes:created`,s),n(`notes:updated`,s),n(`notes:deleted`,s)}},[e,t,n,s,r]);function c(){e({type:`notes:create`,content:``,projectSlug:r??void 0})}function l(t,n){e({type:`notes:update`,id:t,content:n})}function u(t){e({type:`notes:delete`,id:t})}return(0,b.jsxs)(`div`,{className:`flex flex-col h-full bg-base-100`,children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b border-base-content/15`,children:[(0,b.jsx)(`span`,{className:`text-[13px] font-semibold text-base-content`,children:`Notes`}),(0,b.jsx)(`button`,{onClick:c,disabled:!i,className:`btn btn-primary btn-xs`,children:`New Note`})]}),(0,b.jsx)(`div`,{className:`flex-1 overflow-auto p-3`,children:a.length===0?(0,b.jsxs)(`div`,{className:`flex flex-col items-center justify-center text-center mt-16 gap-3`,children:[(0,b.jsx)(bv,{size:28,className:`text-base-content/15`}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-[13px] text-base-content/40`,children:`No notes for this project`}),(0,b.jsx)(`div`,{className:`text-[11px] text-base-content/30 mt-1`,children:`Quick-capture ideas, reminders, or context. Click "New Note" to start.`})]})]}):(0,b.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-2.5`,children:a.map(function(e){return(0,b.jsx)(lP,{note:e,onUpdate:l,onDelete:u,disabled:!i},e.id)})})})]})}var dP=l(o(((e,t)=>{(function(n,r){typeof e==`object`&&typeof t==`object`?t.exports=r():typeof define==`function`&&define.amd?define(`cronstrue`,[],r):typeof e==`object`?e.cronstrue=r():n.cronstrue=r()})(globalThis,()=>(()=>{var e={949(e,t,n){Object.defineProperty(t,`__esModule`,{value:!0}),t.CronParser=void 0;var r=n(515);t.CronParser=function(){function e(e,t,n){t===void 0&&(t=!0),n===void 0&&(n=!1),this.expression=e,this.dayOfWeekStartIndexZero=t,this.monthStartIndexZero=n}return e.prototype.parse=function(){var e,t=this.expression??``;if(t===`@reboot`)return e=[`@reboot`,``,``,``,``,``,``],e;if(t.startsWith(`@`)){var n=this.parseSpecial(this.expression);e=this.extractParts(n)}else e=this.extractParts(this.expression);return this.normalize(e),this.validate(e),e},e.prototype.parseSpecial=function(e){var t={"@yearly":`0 0 1 1 *`,"@annually":`0 0 1 1 *`,"@monthly":`0 0 1 * *`,"@weekly":`0 0 * * 0`,"@daily":`0 0 * * *`,"@midnight":`0 0 * * *`,"@hourly":`0 * * * *`,"@reboot":`@reboot`}[e];if(!t)throw Error(`Unknown special expression.`);return t},e.prototype.extractParts=function(e){if(!this.expression)throw Error(`cron expression is empty`);for(var t=e.trim().split(/[ ]+/),n=0;n<t.length;n++)if(t[n].includes(`,`)){var r=t[n].split(`,`).map(function(e){return e.trim()}).filter(function(e){return e!==``}).map(function(e){return isNaN(Number(e))?e:Number(e)}).filter(function(e){return e!==null&&e!==``});r.length===0&&r.push(`*`),r.sort(function(e,t){return e!==null&&t!==null?e-t:0}),t[n]=r.map(function(e){return e===null?``:e.toString()}).join(`,`)}if(t.length<5)throw Error(`Expression has only ${t.length} part${t.length==1?``:`s`}. At least 5 parts are required.`);if(t.length==5)t.unshift(``),t.push(``);else if(t.length==6)/\d{4}$/.test(t[5])||t[4]==`?`||t[2]==`?`?t.unshift(``):t.push(``);else if(t.length>7)throw Error(`Expression has ${t.length} parts; too many!`);return t},e.prototype.normalize=function(e){var t=this;if(e[3]=e[3].replace(`?`,`*`),e[5]=e[5].replace(`?`,`*`),e[2]=e[2].replace(`?`,`*`),e[0].indexOf(`0/`)==0&&(e[0]=e[0].replace(`0/`,`*/`)),e[1].indexOf(`0/`)==0&&(e[1]=e[1].replace(`0/`,`*/`)),e[2].indexOf(`0/`)==0&&(e[2]=e[2].replace(`0/`,`*/`)),e[3].indexOf(`1/`)==0&&(e[3]=e[3].replace(`1/`,`*/`)),e[4].indexOf(`1/`)==0&&(e[4]=e[4].replace(`1/`,`*/`)),e[6].indexOf(`1/`)==0&&(e[6]=e[6].replace(`1/`,`*/`)),e[5]=e[5].replace(/(^\d)|([^#/\s]\d)/g,function(e){var n=e.replace(/\D/,``),r=n;return t.dayOfWeekStartIndexZero?n==`7`&&(r=`0`):r=(parseInt(n)-1).toString(),e.replace(n,r)}),e[5]==`L`&&(e[5]=`6`),e[3]==`?`&&(e[3]=`*`),e[3].indexOf(`W`)>-1&&(e[3].indexOf(`,`)>-1||e[3].indexOf(`-`)>-1))throw Error(`The 'W' character can be specified only when the day-of-month is a single day, not a range or list of days.`);var n={SUN:0,MON:1,TUE:2,WED:3,THU:4,FRI:5,SAT:6};for(var r in n)e[5]=e[5].replace(new RegExp(r,`gi`),n[r].toString());e[4]=e[4].replace(/(^\d{1,2})|([^#/\s]\d{1,2})/g,function(e){var n=e.replace(/\D/,``),r=n;return t.monthStartIndexZero&&(r=(parseInt(n)+1).toString()),e.replace(n,r)});var i={JAN:1,FEB:2,MAR:3,APR:4,MAY:5,JUN:6,JUL:7,AUG:8,SEP:9,OCT:10,NOV:11,DEC:12};for(var a in i)e[4]=e[4].replace(new RegExp(a,`gi`),i[a].toString());e[0]==`0`&&(e[0]=``),!/\*|\-|\,|\//.test(e[2])&&(/\*|\//.test(e[1])||/\*|\//.test(e[0]))&&(e[2]+=`-${e[2]}`);for(var o=0;o<e.length;o++)if(e[o].indexOf(`,`)!=-1&&(e[o]=e[o].split(`,`).filter(function(e){return e!==``}).join(`,`)||`*`),e[o]==`*/1`&&(e[o]=`*`),e[o].indexOf(`/`)>-1&&!/^\*|\-|\,/.test(e[o])){var s=null;switch(o){case 4:s=`12`;break;case 5:s=`6`;break;case 6:s=`9999`;break;default:s=null;break}if(s!==null){var c=e[o].split(`/`);e[o]=`${c[0]}-${s}/${c[1]}`}}},e.prototype.validate=function(e){var t=`0-9,\\-*/`;this.validateOnlyExpectedCharactersFound(e[0],t),this.validateOnlyExpectedCharactersFound(e[1],t),this.validateOnlyExpectedCharactersFound(e[2],t),this.validateOnlyExpectedCharactersFound(e[3],`0-9,\\-*/LW`),this.validateOnlyExpectedCharactersFound(e[4],t),this.validateOnlyExpectedCharactersFound(e[5],`0-9,\\-*/L#`),this.validateOnlyExpectedCharactersFound(e[6],t),this.validateAnyRanges(e)},e.prototype.validateAnyRanges=function(e){r.default.secondRange(e[0]),r.default.minuteRange(e[1]),r.default.hourRange(e[2]),r.default.dayOfMonthRange(e[3]),r.default.monthRange(e[4],this.monthStartIndexZero),r.default.dayOfWeekRange(e[5],this.dayOfWeekStartIndexZero)},e.prototype.validateOnlyExpectedCharactersFound=function(e,t){var n=e.match(RegExp(`[^${t}]+`,`gi`));if(n&&n.length)throw Error(`Expression contains invalid values: '${n.toString()}'`)},e}()},333(e,t,n){Object.defineProperty(t,`__esModule`,{value:!0}),t.ExpressionDescriptor=void 0;var r=n(823),i=n(949);t.ExpressionDescriptor=function(){function e(t,n){if(this.expression=t,this.options=n,this.expressionParts=[,,,,,],!this.options.locale&&e.defaultLocale&&(this.options.locale=e.defaultLocale),!e.locales[this.options.locale]){var r=Object.keys(e.locales)[0];console.warn(`Locale '${this.options.locale}' could not be found; falling back to '${r}'.`),this.options.locale=r}this.i18n=e.locales[this.options.locale],n.use24HourTimeFormat===void 0&&(n.use24HourTimeFormat=this.i18n.use24HourTimeFormatByDefault())}return e.toString=function(t,n){var r=n===void 0?{}:n,i=r.throwExceptionOnParseError,a=i===void 0?!0:i,o=r.verbose,s=o===void 0?!1:o,c=r.dayOfWeekStartIndexZero,l=c===void 0?!0:c,u=r.monthStartIndexZero,d=u===void 0?!1:u,f=r.use24HourTimeFormat,p=r.trimHoursLeadingZero,m=p===void 0?!1:p,h=r.locale,g=h===void 0?null:h,_=r.logicalAndDayFields,v={throwExceptionOnParseError:a,verbose:s,dayOfWeekStartIndexZero:l,monthStartIndexZero:d,use24HourTimeFormat:f,trimHoursLeadingZero:m,locale:g,logicalAndDayFields:_===void 0?!1:_};return v.tzOffset&&console.warn(`'tzOffset' option has been deprecated and is no longer supported.`),new e(t,v).getFullDescription()},e.initialize=function(t,n){n===void 0&&(n=`en`),e.specialCharacters=[`/`,`-`,`,`,`*`],e.defaultLocale=n,t.load(e.locales)},e.prototype.getFullDescription=function(){var e,t=``;try{if(this.expressionParts=new i.CronParser(this.expression,this.options.dayOfWeekStartIndexZero,this.options.monthStartIndexZero).parse(),this.expressionParts[0]===`@reboot`)return(e=this.i18n).atReboot?.call(e)||`Run once, at startup`;var n=this.getTimeOfDayDescription(),r=this.getDayOfMonthDescription(),a=this.getMonthDescription(),o=this.getDayOfWeekDescription(),s=this.getYearDescription();t+=n+r+o+a+s,t=this.transformVerbosity(t,!!this.options.verbose),t=t.charAt(0).toLocaleUpperCase()+t.substr(1)}catch(e){if(!this.options.throwExceptionOnParseError)t=this.i18n.anErrorOccuredWhenGeneratingTheExpressionD();else throw`${e}`}return t},e.prototype.getTimeOfDayDescription=function(){var t=this.expressionParts[0],n=this.expressionParts[1],i=this.expressionParts[2],a=``;if(!r.StringUtilities.containsAny(n,e.specialCharacters)&&!r.StringUtilities.containsAny(i,e.specialCharacters)&&!r.StringUtilities.containsAny(t,e.specialCharacters))a+=this.i18n.atSpace()+this.formatTime(i,n,t);else if(!t&&n.indexOf(`-`)>-1&&!(n.indexOf(`,`)>-1)&&!(n.indexOf(`/`)>-1)&&!r.StringUtilities.containsAny(i,e.specialCharacters)){var o=n.split(`-`);a+=r.StringUtilities.format(this.i18n.everyMinuteBetweenX0AndX1(),this.formatTime(i,o[0],``),this.formatTime(i,o[1],``))}else if(!t&&i.indexOf(`,`)>-1&&i.indexOf(`-`)==-1&&i.indexOf(`/`)==-1&&!r.StringUtilities.containsAny(n,e.specialCharacters)){var s=i.split(`,`);a+=this.i18n.at();for(var c=0;c<s.length;c++)a+=` `,a+=this.formatTime(s[c],n,``),c<s.length-2&&(a+=`,`),c==s.length-2&&(a+=this.i18n.spaceAnd())}else{var l=this.getSecondsDescription(),u=this.getMinutesDescription(),d=this.getHoursDescription();if(a+=l,a&&u&&(a+=`, `),a+=u,u===d)return a;a&&d&&(a+=`, `),a+=d}return a},e.prototype.getSecondsDescription=function(){var e=this;return this.getSegmentDescription(this.expressionParts[0],this.i18n.everySecond(),function(e){return e},function(t){return r.StringUtilities.format(e.i18n.everyX0Seconds(t),t)},function(t){return e.i18n.secondsX0ThroughX1PastTheMinute()},function(t){return t==`0`?``:parseInt(t)<20?e.i18n.atX0SecondsPastTheMinute(t):e.i18n.atX0SecondsPastTheMinuteGt20()||e.i18n.atX0SecondsPastTheMinute(t)})},e.prototype.getMinutesDescription=function(){var e=this,t=this.expressionParts[0],n=this.expressionParts[2];return this.getSegmentDescription(this.expressionParts[1],this.i18n.everyMinute(),function(e){return e},function(t){return r.StringUtilities.format(e.i18n.everyX0Minutes(t),t)},function(t){return e.i18n.minutesX0ThroughX1PastTheHour()},function(r){var i;try{return r==`0`&&n.indexOf(`/`)==-1&&t==``?e.i18n.everyHour():r==`0`?(i=e.i18n).onTheHour?.call(i)||e.i18n.atX0MinutesPastTheHour(r):parseInt(r)<20?e.i18n.atX0MinutesPastTheHour(r):e.i18n.atX0MinutesPastTheHourGt20()||e.i18n.atX0MinutesPastTheHour(r)}catch{return e.i18n.atX0MinutesPastTheHour(r)}})},e.prototype.getHoursDescription=function(){var e=this,t=this.expressionParts[2],n=0,i=[];t.split(`/`)[0].split(`,`).forEach(function(e){var t=e.split(`-`);t.length===2&&i.push({value:t[1],index:n+1}),n+=t.length});var a=0;return this.getSegmentDescription(t,this.i18n.everyHour(),function(t){var n=i.find(function(e){return e.value===t&&e.index===a})&&e.expressionParts[1]!==`0`;return a++,n?e.formatTime(t,`59`,``):e.formatTime(t,`0`,``)},function(t){return r.StringUtilities.format(e.i18n.everyX0Hours(t),t)},function(t){return e.i18n.betweenX0AndX1()},function(t){return e.i18n.atX0()})},e.prototype.getDayOfWeekDescription=function(){var e=this,t=this.i18n.daysOfTheWeek(),n=null;return n=this.expressionParts[5]==`*`?``:this.getSegmentDescription(this.expressionParts[5],this.i18n.commaEveryDay(),function(n,r){var i=n;n.indexOf(`#`)>-1?i=n.substring(0,n.indexOf(`#`)):n.indexOf(`L`)>-1&&(i=i.replace(`L`,``));var a=parseInt(i),o=e.i18n.daysOfTheWeekInCase?e.i18n.daysOfTheWeekInCase(r)[a]:t[a];if(n.indexOf(`#`)>-1){var s=null,c=n.substring(n.indexOf(`#`)+1),l=n.substring(0,n.indexOf(`#`));switch(c){case`1`:s=e.i18n.first(l);break;case`2`:s=e.i18n.second(l);break;case`3`:s=e.i18n.third(l);break;case`4`:s=e.i18n.fourth(l);break;case`5`:s=e.i18n.fifth(l);break}o=s+` `+o}return o},function(t){return parseInt(t)==1?``:r.StringUtilities.format(e.i18n.commaEveryX0DaysOfTheWeek(t),t)},function(t){var n=t.substring(0,t.indexOf(`-`));return e.expressionParts[3]==`*`?e.i18n.commaX0ThroughX1(n):e.i18n.commaAndX0ThroughX1(n)},function(t){var n=null;if(t.indexOf(`#`)>-1){var r=t.substring(t.indexOf(`#`)+1),i=t.substring(0,t.indexOf(`#`));n=e.i18n.commaOnThe(r,i).trim()+e.i18n.spaceX0OfTheMonth()}else n=t.indexOf(`L`)>-1?e.i18n.commaOnTheLastX0OfTheMonth(t.replace(`L`,``)):e.expressionParts[3]==`*`||e.options.logicalAndDayFields?e.i18n.commaOnlyOnX0(t):e.i18n.commaAndOnX0();return n}),n},e.prototype.getMonthDescription=function(){var e=this,t=this.i18n.monthsOfTheYear();return this.getSegmentDescription(this.expressionParts[4],``,function(n,r){return r&&e.i18n.monthsOfTheYearInCase?e.i18n.monthsOfTheYearInCase(r)[parseInt(n)-1]:t[parseInt(n)-1]},function(t){return parseInt(t)==1?``:r.StringUtilities.format(e.i18n.commaEveryX0Months(t),t)},function(t){return e.i18n.commaMonthX0ThroughMonthX1()||e.i18n.commaX0ThroughX1()},function(t){return e.i18n.commaOnlyInMonthX0?e.i18n.commaOnlyInMonthX0():e.i18n.commaOnlyInX0()})},e.prototype.getDayOfMonthDescription=function(){var e=this,t=null,n=this.expressionParts[3];switch(n){case`L`:t=this.i18n.commaOnTheLastDayOfTheMonth();break;case`WL`:case`LW`:t=this.i18n.commaOnTheLastWeekdayOfTheMonth();break;default:var i=n.match(/(\d{1,2}W)|(W\d{1,2})/);if(i){var a=parseInt(i[0].replace(`W`,``)),o=a==1?this.i18n.firstWeekday():r.StringUtilities.format(this.i18n.weekdayNearestDayX0(),a.toString());t=r.StringUtilities.format(this.i18n.commaOnTheX0OfTheMonth(),o);break}else{var s=n.match(/L-(\d{1,2})/);if(s){var c=s[1];t=r.StringUtilities.format(this.i18n.commaDaysBeforeTheLastDayOfTheMonth(c),c);break}else if(n==`*`&&this.expressionParts[5]!=`*`)return``;else t=this.getSegmentDescription(n,this.i18n.commaEveryDay(),function(t){return t==`L`?e.i18n.lastDay():e.i18n.dayX0?r.StringUtilities.format(e.i18n.dayX0(),t):t},function(t){return t==`1`?e.i18n.commaEveryDay():e.i18n.commaEveryX0Days(t)},function(t){return e.i18n.commaBetweenDayX0AndX1OfTheMonth(t)},function(t){return e.i18n.commaOnDayX0OfTheMonth(t)});break}}return t},e.prototype.getYearDescription=function(){var e=this;return this.getSegmentDescription(this.expressionParts[6],``,function(e){return/^\d+$/.test(e)?new Date(parseInt(e),1).getFullYear().toString():e},function(t){return r.StringUtilities.format(e.i18n.commaEveryX0Years(t),t)},function(t){return e.i18n.commaYearX0ThroughYearX1()||e.i18n.commaX0ThroughX1()},function(t){return e.i18n.commaOnlyInYearX0?e.i18n.commaOnlyInYearX0():e.i18n.commaOnlyInX0()})},e.prototype.getSegmentDescription=function(e,t,n,i,a,o){var s=null,c=e.indexOf(`/`)>-1,l=e.indexOf(`-`)>-1,u=e.indexOf(`,`)>-1;if(!e)s=``;else if(e===`*`)s=t;else if(!c&&!l&&!u)s=r.StringUtilities.format(o(e),n(e));else if(u){for(var d=e.split(`,`),f=``,p=0;p<d.length;p++)if(p>0&&d.length>2&&(f+=`,`,p<d.length-1&&(f+=` `)),p>0&&d.length>1&&(p==d.length-1||d.length==2)&&(f+=`${this.i18n.spaceAnd()} `),d[p].indexOf(`/`)>-1||d[p].indexOf(`-`)>-1){var m=d[p].indexOf(`-`)>-1&&d[p].indexOf(`/`)==-1,h=this.getSegmentDescription(d[p],t,n,i,m?this.i18n.commaX0ThroughX1:a,o);m&&(h=h.replace(`, `,``)),f+=h}else if(!c)f+=n(d[p]);else{var g=this.getSegmentDescription(d[p],t,n,i,a,o);g&&g.startsWith(`, `)&&(g=g.substring(2)),f+=g}s=c?f:r.StringUtilities.format(o(e),f)}else if(c){var d=e.split(`/`);if(s=r.StringUtilities.format(i(d[1]),d[1]),d[0].indexOf(`-`)>-1){var _=this.generateRangeSegmentDescription(d[0],a,n);_.indexOf(`, `)!=0&&(s+=`, `),s+=_}else if(d[0].indexOf(`*`)==-1){var v=r.StringUtilities.format(o(d[0]),n(d[0]));v=v.replace(`, `,``),s+=r.StringUtilities.format(this.i18n.commaStartingX0(),v)}}else l&&(s=this.generateRangeSegmentDescription(e,a,n));return s},e.prototype.generateRangeSegmentDescription=function(e,t,n){var i=``,a=e.split(`-`),o=n(a[0],1),s=n(a[1],2),c=t(e);return i+=r.StringUtilities.format(c,o,s),i},e.prototype.formatTime=function(e,t,n){var r=0,i=0,a=parseInt(e)+r,o=parseInt(t)+i;o>=60?(o-=60,a+=1):o<0&&(o+=60,--a),a>=24?a-=24:a<0&&(a=24+a);var s=``,c=!1;this.options.use24HourTimeFormat||(c=!!(this.i18n.setPeriodBeforeTime&&this.i18n.setPeriodBeforeTime()),s=c?`${this.getPeriod(a)} `:` ${this.getPeriod(a)}`,a>12&&(a-=12),a===0&&(a=12));var l=``;n&&(l=`:${(`00`+n).substring(n.length)}`);var u=a.toString(),d=(`00`+u).substring(u.length),f=o.toString(),p=(`00`+f).substring(f.length),m=this.options.trimHoursLeadingZero?u:d;return`${c?s:``}${m}:${p}${l}${c?``:s}`},e.prototype.transformVerbosity=function(e,t){if(!t&&(e=e.replace(RegExp(`, ${this.i18n.everyMinute()}`,`g`),``),e=e.replace(RegExp(`, ${this.i18n.everyHour()}`,`g`),``),e=e.replace(new RegExp(this.i18n.commaEveryDay(),`g`),``),e=e.replace(/\, ?$/,``),this.i18n.conciseVerbosityReplacements))for(var n=0,r=Object.entries(this.i18n.conciseVerbosityReplacements());n<r.length;n++){var i=r[n],a=i[0],o=i[1];e=e.replace(new RegExp(a,`g`),o)}return e},e.prototype.getPeriod=function(e){return e>=12?this.i18n.pm&&this.i18n.pm()||`PM`:this.i18n.am&&this.i18n.am()||`AM`},e.locales={},e}()},747(e,t,n){Object.defineProperty(t,`__esModule`,{value:!0}),t.enLocaleLoader=void 0;var r=n(486);t.enLocaleLoader=function(){function e(){}return e.prototype.load=function(e){e.en=new r.en},e}()},486(e,t){Object.defineProperty(t,`__esModule`,{value:!0}),t.en=void 0,t.en=function(){function e(){}return e.prototype.atX0SecondsPastTheMinuteGt20=function(){return null},e.prototype.atX0MinutesPastTheHourGt20=function(){return null},e.prototype.commaMonthX0ThroughMonthX1=function(){return null},e.prototype.commaYearX0ThroughYearX1=function(){return null},e.prototype.use24HourTimeFormatByDefault=function(){return!1},e.prototype.anErrorOccuredWhenGeneratingTheExpressionD=function(){return`An error occurred when generating the expression description. Check the cron expression syntax.`},e.prototype.everyMinute=function(){return`every minute`},e.prototype.everyHour=function(){return`every hour`},e.prototype.atSpace=function(){return`At `},e.prototype.everyMinuteBetweenX0AndX1=function(){return`Every minute between %s and %s`},e.prototype.at=function(){return`At`},e.prototype.spaceAnd=function(){return` and`},e.prototype.everySecond=function(){return`every second`},e.prototype.everyX0Seconds=function(){return`every %s seconds`},e.prototype.secondsX0ThroughX1PastTheMinute=function(){return`seconds %s through %s past the minute`},e.prototype.atX0SecondsPastTheMinute=function(){return`at %s seconds past the minute`},e.prototype.everyX0Minutes=function(){return`every %s minutes`},e.prototype.minutesX0ThroughX1PastTheHour=function(){return`minutes %s through %s past the hour`},e.prototype.atX0MinutesPastTheHour=function(){return`at %s minutes past the hour`},e.prototype.everyX0Hours=function(){return`every %s hours`},e.prototype.betweenX0AndX1=function(){return`between %s and %s`},e.prototype.atX0=function(){return`at %s`},e.prototype.commaEveryDay=function(){return`, every day`},e.prototype.commaEveryX0DaysOfTheWeek=function(){return`, every %s days of the week`},e.prototype.commaX0ThroughX1=function(){return`, %s through %s`},e.prototype.commaAndX0ThroughX1=function(){return`, %s through %s`},e.prototype.first=function(){return`first`},e.prototype.second=function(){return`second`},e.prototype.third=function(){return`third`},e.prototype.fourth=function(){return`fourth`},e.prototype.fifth=function(){return`fifth`},e.prototype.commaOnThe=function(){return`, on the `},e.prototype.spaceX0OfTheMonth=function(){return` %s of the month`},e.prototype.lastDay=function(){return`the last day`},e.prototype.commaOnTheLastX0OfTheMonth=function(){return`, on the last %s of the month`},e.prototype.commaOnlyOnX0=function(){return`, only on %s`},e.prototype.commaAndOnX0=function(){return`, and on %s`},e.prototype.commaEveryX0Months=function(){return`, every %s months`},e.prototype.commaOnlyInX0=function(){return`, only in %s`},e.prototype.commaOnTheLastDayOfTheMonth=function(){return`, on the last day of the month`},e.prototype.commaOnTheLastWeekdayOfTheMonth=function(){return`, on the last weekday of the month`},e.prototype.commaDaysBeforeTheLastDayOfTheMonth=function(){return`, %s days before the last day of the month`},e.prototype.firstWeekday=function(){return`first weekday`},e.prototype.weekdayNearestDayX0=function(){return`weekday nearest day %s`},e.prototype.commaOnTheX0OfTheMonth=function(){return`, on the %s of the month`},e.prototype.commaEveryX0Days=function(){return`, every %s days in a month`},e.prototype.commaBetweenDayX0AndX1OfTheMonth=function(){return`, between day %s and %s of the month`},e.prototype.commaOnDayX0OfTheMonth=function(){return`, on day %s of the month`},e.prototype.commaEveryHour=function(){return`, every hour`},e.prototype.commaEveryX0Years=function(){return`, every %s years`},e.prototype.commaStartingX0=function(){return`, starting %s`},e.prototype.daysOfTheWeek=function(){return[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`]},e.prototype.monthsOfTheYear=function(){return[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`]},e.prototype.atReboot=function(){return`Run once, at startup`},e.prototype.onTheHour=function(){return`on the hour`},e}()},515(e,t){Object.defineProperty(t,`__esModule`,{value:!0});function n(e,t){if(!e)throw Error(t)}t.default=function(){function e(){}return e.secondRange=function(e){for(var t=e.split(`,`),r=0;r<t.length;r++)if(!isNaN(parseInt(t[r],10))){var i=parseInt(t[r],10);n(i>=0&&i<=59,`seconds part must be >= 0 and <= 59`)}},e.minuteRange=function(e){for(var t=e.split(`,`),r=0;r<t.length;r++)if(!isNaN(parseInt(t[r],10))){var i=parseInt(t[r],10);n(i>=0&&i<=59,`minutes part must be >= 0 and <= 59`)}},e.hourRange=function(e){for(var t=e.split(`,`),r=0;r<t.length;r++)if(!isNaN(parseInt(t[r],10))){var i=parseInt(t[r],10);n(i>=0&&i<=23,`hours part must be >= 0 and <= 23`)}},e.dayOfMonthRange=function(e){for(var t=e.split(`,`),r=0;r<t.length;r++)if(!isNaN(parseInt(t[r],10))){var i=parseInt(t[r],10);n(i>=1&&i<=31,`DOM part must be >= 1 and <= 31`)}},e.monthRange=function(e,t){for(var r=e.split(`,`),i=0;i<r.length;i++)if(!isNaN(parseInt(r[i],10))){var a=parseInt(r[i],10);n(a>=1&&a<=12,t?`month part must be >= 0 and <= 11`:`month part must be >= 1 and <= 12`)}},e.dayOfWeekRange=function(e,t){for(var r=e.split(`,`),i=0;i<r.length;i++)if(!isNaN(parseInt(r[i],10))){var a=parseInt(r[i],10);n(a>=0&&a<=6,t?`DOW part must be >= 0 and <= 6`:`DOW part must be >= 1 and <= 7`)}},e}()},823(e,t){Object.defineProperty(t,`__esModule`,{value:!0}),t.StringUtilities=void 0,t.StringUtilities=function(){function e(){}return e.format=function(e){var t=[...arguments].slice(1);return e.replace(/%s/g,function(e){return t.shift()})},e.containsAny=function(e,t){return t.some(function(t){return e.indexOf(t)>-1})},e}()}},t={};function n(r){var i=t[r];if(i!==void 0)return i.exports;var a=t[r]={exports:{}};return e[r](a,a.exports,n),a.exports}var r={};return(()=>{var e=r;Object.defineProperty(e,`__esModule`,{value:!0}),e.toString=void 0;var t=n(333),i=n(747);t.ExpressionDescriptor.initialize(new i.enLocaleLoader),e.default=t.ExpressionDescriptor,e.toString=t.ExpressionDescriptor.toString})(),r})())}))(),1);function fP(e){return e?new Date(e).toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}):`—`}function pP(e){try{return dP.default.toString(e,{use24HourTimeFormat:!0})}catch{return e}}function mP(e){var{task:t,onToggle:n,onEdit:r,onDelete:i,disabled:a}=e,[o,s]=(0,x.useState)(!1),[c,l]=(0,x.useState)(!1);function u(e){e.stopPropagation(),s(function(e){return!e})}function d(e){e.stopPropagation(),c?i(t.id):l(!0)}function f(e){e.stopPropagation(),l(!1)}function p(e){e.stopPropagation(),r(t)}function m(e){e.stopPropagation(),n(t.id)}return(0,b.jsxs)(`div`,{className:`bg-base-200 border border-base-content/15 rounded-lg overflow-hidden`,children:[(0,b.jsxs)(`div`,{tabIndex:0,role:`button`,className:`flex items-center gap-2.5 px-3 py-2.5 cursor-pointer hover:bg-base-300/50 transition-colors outline-none focus-visible:ring-2 focus-visible:ring-primary/50 focus-visible:ring-offset-1 focus-visible:ring-offset-base-200`,onClick:u,onKeyDown:function(e){(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),s(function(e){return!e}))},"aria-expanded":o,children:[(0,b.jsx)(`span`,{className:`text-base-content/40 flex-shrink-0`,children:o?(0,b.jsx)(iu,{className:`!size-3.5`}):(0,b.jsx)(cu,{className:`!size-3.5`})}),(0,b.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,b.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,b.jsx)(`span`,{className:`text-[13px] font-medium truncate ${t.enabled?`text-base-content`:`text-base-content/40`}`,children:t.name})}),(0,b.jsx)(`div`,{className:`text-[11px] text-base-content/40 truncate mt-0.5`,children:pP(t.cron)})]}),(0,b.jsx)(`label`,{className:`swap flex-shrink-0`,onClick:a?void 0:m,children:(0,b.jsx)(`input`,{type:`checkbox`,className:`toggle toggle-primary toggle-xs`,checked:t.enabled,disabled:a,"aria-label":`Toggle `+t.name,onChange:function(){}})})]}),o&&(0,b.jsx)(`div`,{className:`px-3 pb-3 border-t border-base-content/15 bg-base-100/50`,children:(0,b.jsxs)(`div`,{className:`pt-2.5 space-y-2`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`span`,{className:`text-[11px] text-base-content/40 uppercase tracking-wider`,children:`Prompt`}),(0,b.jsx)(`p`,{className:`text-[12px] text-base-content/80 mt-0.5 whitespace-pre-wrap break-words leading-relaxed`,children:t.prompt})]}),(0,b.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`span`,{className:`text-[11px] text-base-content/40 uppercase tracking-wider`,children:`Last Run`}),(0,b.jsx)(`p`,{className:`text-[12px] text-base-content/70 mt-0.5`,children:fP(t.lastRunAt)})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`span`,{className:`text-[11px] text-base-content/40 uppercase tracking-wider`,children:`Next Run`}),(0,b.jsx)(`p`,{className:`text-[12px] text-base-content/70 mt-0.5`,children:fP(t.nextRunAt)})]})]}),!a&&(0,b.jsxs)(`div`,{className:`flex items-center gap-1.5 pt-1`,children:[(0,b.jsxs)(`button`,{onClick:p,className:`btn btn-ghost btn-xs border border-base-content/15 text-base-content/70 gap-1 outline-none focus-visible:ring-2 focus-visible:ring-primary/50 focus-visible:ring-offset-1 focus-visible:ring-offset-base-200`,children:[(0,b.jsx)($_,{className:`!size-3`}),`Edit`]}),c?(0,b.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,b.jsx)(`button`,{onClick:d,className:`btn btn-error btn-xs outline-none focus-visible:ring-2 focus-visible:ring-primary/50 focus-visible:ring-offset-1 focus-visible:ring-offset-base-200`,children:`Confirm Delete`}),(0,b.jsx)(`button`,{onClick:f,className:`btn btn-ghost btn-xs border border-base-content/15 outline-none focus-visible:ring-2 focus-visible:ring-primary/50 focus-visible:ring-offset-1 focus-visible:ring-offset-base-200`,children:`Cancel`})]}):(0,b.jsx)(`button`,{onClick:d,className:`btn btn-ghost btn-xs border border-base-content/15 text-base-content/50 outline-none focus-visible:ring-2 focus-visible:ring-primary/50 focus-visible:ring-offset-1 focus-visible:ring-offset-base-200`,"aria-label":`Delete task`,children:(0,b.jsx)(Tv,{className:`!size-3`})})]})]})})]})}function hP(e){if(!e.trim())return``;try{return dP.default.toString(e.trim(),{use24HourTimeFormat:!0})}catch{return`Invalid cron expression`}}function gP(e){var{task:t,onSave:n,onClose:r}=e,[i,a]=(0,x.useState)(t?t.name:``),[o,s]=(0,x.useState)(t?t.prompt:``),[c,l]=(0,x.useState)(t?t.cron:`0 9 * * 1-5`),u=(0,x.useRef)(null);Wr(u,(0,x.useCallback)(function(){r()},[r]));var d=hP(c),f=d!==`Invalid cron expression`&&d!==``;function p(e){e.preventDefault(),!(!i.trim()||!o.trim()||!f)&&n({name:i.trim(),prompt:o.trim(),cron:c.trim()})}function m(e){e.target===e.currentTarget&&r()}return(0,b.jsx)(`div`,{ref:u,className:`fixed inset-0 z-[9999] flex items-center justify-center bg-base-content/50 backdrop-blur-sm`,onClick:m,role:`dialog`,"aria-modal":`true`,"aria-label":t?`Edit Task`:`New Scheduled Task`,children:(0,b.jsxs)(`div`,{className:`bg-base-200 border border-base-content/15 rounded-2xl shadow-2xl w-full max-w-md mx-4`,children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between px-5 py-4 border-b border-base-content/15`,children:[(0,b.jsx)(`h2`,{className:`text-[14px] font-semibold text-base-content`,children:t?`Edit Task`:`New Scheduled Task`}),(0,b.jsx)(`button`,{onClick:r,"aria-label":`Close`,className:`btn btn-ghost btn-xs btn-square text-base-content/50`,children:(0,b.jsx)(Nv,{size:14})})]}),(0,b.jsxs)(`form`,{onSubmit:p,className:`p-5 space-y-4`,children:[(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(`label`,{htmlFor:`task-name`,className:`text-[12px] font-semibold text-base-content/40 uppercase tracking-wider`,children:`Name`}),(0,b.jsx)(`input`,{id:`task-name`,type:`text`,className:`w-full h-9 px-3 bg-base-300 border border-base-content/15 rounded-xl text-base-content text-[13px] focus:border-primary focus-visible:outline-none transition-colors duration-[120ms]`,placeholder:`Daily standup summary`,value:i,onChange:function(e){a(e.target.value)},autoFocus:!0})]}),(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(`label`,{htmlFor:`task-prompt`,className:`text-[12px] font-semibold text-base-content/40 uppercase tracking-wider`,children:`Prompt`}),(0,b.jsx)(`textarea`,{id:`task-prompt`,className:`w-full px-3 py-2.5 bg-base-300 border border-base-content/15 rounded-xl text-base-content text-[13px] min-h-[96px] resize-y leading-relaxed focus:border-primary focus-visible:outline-none transition-colors duration-[120ms]`,placeholder:`Summarize yesterday's work and create a plan for today...`,value:o,onChange:function(e){s(e.target.value)}})]}),(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(`label`,{htmlFor:`task-cron`,className:`text-[12px] font-semibold text-base-content/40 uppercase tracking-wider`,children:`Cron Expression`}),(0,b.jsx)(`input`,{id:`task-cron`,type:`text`,className:`w-full h-9 px-3 bg-base-300 border rounded-xl text-base-content text-[13px] font-mono focus:border-primary focus-visible:outline-none transition-colors duration-[120ms] ${c.trim()&&!f?`border-error`:`border-base-content/15`}`,placeholder:`0 9 * * 1-5`,value:c,onChange:function(e){l(e.target.value)},"aria-invalid":c.trim()&&!f?`true`:void 0,"aria-describedby":c.trim()?`cron-preview`:void 0}),c.trim()&&(0,b.jsx)(`p`,{id:`cron-preview`,className:`text-[11px] mt-1 ${f?`text-primary/80`:`text-error`}`,children:d})]}),(0,b.jsxs)(`div`,{className:`flex gap-2 pt-1`,children:[(0,b.jsx)(`button`,{type:`submit`,className:`btn btn-primary btn-sm flex-1`,disabled:!i.trim()||!o.trim()||!f,children:t?`Save Changes`:`Create Task`}),(0,b.jsx)(`button`,{type:`button`,onClick:r,className:`btn btn-ghost btn-sm border border-base-content/15`,children:`Cancel`})]})]})]})})}function _P(){var{send:e,subscribe:t,unsubscribe:n}=R(),{activeProjectSlug:r}=gb(),i=_b(),[a,o]=(0,x.useState)([]),[s,c]=(0,x.useState)(void 0),l=(0,x.useCallback)(function(e){if(e.type===`scheduler:tasks`){o(e.tasks);return}if(e.type===`scheduler:task_created`){o(function(t){return[...t,e.task]});return}if(e.type===`scheduler:task_updated`){o(function(t){return t.map(function(t){return t.id===e.task.id?e.task:t})});return}},[]);(0,x.useEffect)(function(){return t(`scheduler:tasks`,l),t(`scheduler:task_created`,l),t(`scheduler:task_updated`,l),e({type:`scheduler:list`}),function(){n(`scheduler:tasks`,l),n(`scheduler:task_created`,l),n(`scheduler:task_updated`,l)}},[e,t,n,l]);var u=a.filter(function(e){return e.projectSlug===r});function d(t){e({type:`scheduler:toggle`,taskId:t})}function f(t){e({type:`scheduler:delete`,taskId:t}),o(function(e){return e.filter(function(e){return e.id!==t})})}function p(t){if(s===null){if(!r)return;e({type:`scheduler:create`,name:t.name,prompt:t.prompt,cron:t.cron,projectSlug:r})}else s&&e({type:`scheduler:update`,taskId:s.id,name:t.name,prompt:t.prompt,cron:t.cron});c(void 0)}return(0,b.jsxs)(`div`,{className:`flex flex-col h-full bg-base-100`,children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b border-base-content/15`,children:[(0,b.jsx)(`span`,{className:`text-[13px] font-semibold text-base-content`,children:`Scheduled Tasks`}),(0,b.jsx)(`button`,{onClick:function(){c(null)},disabled:!i,className:`btn btn-primary btn-xs`,children:`New Task`})]}),(0,b.jsx)(`div`,{className:`flex-1 overflow-auto p-3`,children:u.length===0?(0,b.jsxs)(`div`,{className:`flex flex-col items-center justify-center text-center mt-16 gap-3`,children:[(0,b.jsx)(el,{size:28,className:`text-base-content/15`}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-[13px] text-base-content/40`,children:`No scheduled tasks for this project`}),(0,b.jsx)(`div`,{className:`text-[11px] text-base-content/30 mt-1`,children:`Automate Claude prompts on a cron schedule. Click "New Task" to create one.`})]})]}):(0,b.jsx)(`div`,{className:`space-y-2`,children:u.map(function(e){return(0,b.jsx)(mP,{task:e,onToggle:d,onEdit:function(e){c(e)},onDelete:f,disabled:!i},e.id)})})}),s!==void 0&&(0,b.jsx)(gP,{task:s,projectSlug:r??``,onSave:p,onClose:function(){c(void 0)}})]})}function vP(e){var t=Date.now()-e,n=Math.floor(t/1e3);if(n<60)return n+`s ago`;var r=Math.floor(n/60);if(r<60)return r+`m ago`;var i=Math.floor(r/60);return i<24?i+`h ago`:Math.floor(i/24)+`d ago`}function yP(){var{allBookmarks:e,requestAllBookmarks:t}=zT(),{activateSession:n}=gb(),{projects:r}=Dy();(0,x.useEffect)(function(){t()},[]);var i=(0,x.useMemo)(function(){for(var t=new Map,n=0;n<e.length;n++){var r=e[n];t.has(r.projectSlug)||t.set(r.projectSlug,new Map);var i=t.get(r.projectSlug);i.has(r.sessionId)||i.set(r.sessionId,[]),i.get(r.sessionId).push(r)}var a=[];return t.forEach(function(e,t){var n=[];e.forEach(function(e,t){n.push({sessionId:t,bookmarks:e})}),n.sort(function(e,t){return t.bookmarks[0].createdAt-e.bookmarks[0].createdAt}),a.push({projectSlug:t,sessions:n})}),a.sort(function(e,t){var n=e.sessions[0]?.bookmarks[0]?.createdAt??0;return(t.sessions[0]?.bookmarks[0]?.createdAt??0)-n}),a},[e]);function a(e){for(var t=0;t<r.length;t++)if(r[t].slug===e)return r[t].title;return e}function o(e){n(e.projectSlug,e.sessionId),Wv(`chat`),setTimeout(function(){var t=document.getElementById(`msg-`+e.messageUuid);t&&(t.scrollIntoView({behavior:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches?`auto`:`smooth`,block:`center`}),t.classList.add(`ring-2`,`ring-warning/40`),setTimeout(function(){t.classList.remove(`ring-2`,`ring-warning/40`)},2e3))},500)}return(0,b.jsxs)(`div`,{className:`flex flex-col h-full w-full overflow-hidden`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-3 border-b border-base-content/10 bg-base-100 flex-shrink-0`,children:[(0,b.jsx)(Zs,{size:16,className:`text-warning`}),(0,b.jsx)(`span`,{className:`text-sm font-semibold text-base-content`,children:`Bookmarks`}),(0,b.jsxs)(`span`,{className:`text-[10px] font-mono text-base-content/30 ml-auto`,children:[e.length,` total`]})]}),(0,b.jsx)(`div`,{className:`flex-1 overflow-y-auto p-4`,children:e.length===0?(0,b.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full text-base-content/30 gap-3`,children:[(0,b.jsx)(Zs,{size:32,className:`text-base-content/15`}),(0,b.jsx)(`div`,{className:`text-[13px] font-mono`,children:`No bookmarks yet`}),(0,b.jsx)(`div`,{className:`text-[11px] text-base-content/20 max-w-[260px] text-center`,children:`Bookmark messages in chat to quickly find them later.`})]}):(0,b.jsx)(`div`,{className:`flex flex-col gap-4`,children:i.map(function(e){return(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-[10px] uppercase tracking-widest text-base-content/40 font-mono font-bold mb-2`,children:a(e.projectSlug)}),(0,b.jsx)(`div`,{className:`flex flex-col gap-2`,children:e.sessions.map(function(e){return(0,b.jsxs)(`div`,{className:`bg-base-200/50 border border-base-content/8 rounded-lg overflow-hidden`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 border-b border-base-content/5`,children:[(0,b.jsx)(U_,{size:11,className:`text-base-content/30`}),(0,b.jsxs)(`span`,{className:`text-[11px] font-mono text-base-content/40 truncate`,children:[e.sessionId.slice(0,12),`...`]})]}),(0,b.jsx)(`div`,{className:`flex flex-col`,children:e.bookmarks.map(function(e){return(0,b.jsxs)(`button`,{type:`button`,onClick:function(){o(e)},className:`flex items-start gap-2 px-3 py-2 hover:bg-base-content/5 transition-colors text-left w-full`,children:[(0,b.jsx)(Zs,{size:10,className:`text-warning/60 mt-0.5 flex-shrink-0`}),(0,b.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,b.jsx)(`div`,{className:`text-[12px] text-base-content/70 line-clamp-2`,children:e.messageText}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5`,children:[(0,b.jsx)(`span`,{className:`text-[9px] text-base-content/25 font-mono`,children:e.messageType}),(0,b.jsx)(`span`,{className:`text-[9px] text-base-content/20 font-mono`,children:vP(e.createdAt)})]})]}),(0,b.jsx)(um,{size:10,className:`text-base-content/20 mt-1 flex-shrink-0`})]},e.id)})})]},e.sessionId)})})]},e.projectSlug)})})})]})}function bP(){var e=getComputedStyle(document.documentElement),t=e.getPropertyValue(`--color-base-100`).trim(),n=e.getPropertyValue(`--color-base-200`).trim(),r=e.getPropertyValue(`--color-base-300`).trim(),i=e.getPropertyValue(`--color-base-content`).trim(),a=e.getPropertyValue(`--color-primary`).trim(),o=e.getPropertyValue(`--color-primary-content`).trim();function s(e){return e.replace(/^oklch\(/,``).replace(/\)$/,``)}var c=s(i);return`
117
117
  :root {
118
118
  --bg-primary: ${t};
@@ -555,7 +555,7 @@ ${t.slice(l+2)}`,d+=1;else break}t.push({indent:l,number:parseInt(s,10),content:
555
555
  `):``,markdownTokenizer:{name:`orderedList`,level:`block`,start:e=>{let t=e.match(/^(\s*)(\d+)\.\s+/)?.index;return t===void 0?-1:t},tokenize:(e,t,n)=>{let r=e.split(`
556
556
  `),[i,a]=VZe(r);if(i.length===0)return;let o=Z5(i,0,n);if(o.length!==0)return{type:`list`,ordered:!0,start:i[0]?.number||1,items:o,raw:r.slice(0,a).join(`
557
557
  `)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(UZe,this.editor.getAttributes(Q5)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let e=k6({find:$5,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(e=k6({find:$5,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Q5)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[e]}}),WZe=/^\s*(\[([( |x])?\])\s$/,t7=P6.create({name:`taskItem`,addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:`taskList`,a11y:void 0}},content(){return this.options.nested?`paragraph block*`:`paragraph+`},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:e=>{let t=e.getAttribute(`data-checked`);return t===``||t===`true`},renderHTML:e=>({"data-checked":e.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:e,HTMLAttributes:t}){return[`li`,R3(this.options.HTMLAttributes,t,{"data-type":this.name}),[`label`,[`input`,{type:`checkbox`,checked:e.attrs.checked?`checked`:null}],[`span`]],[`div`,0]]},parseMarkdown:(e,t)=>{let n=[];if(e.tokens&&e.tokens.length>0?n.push(t.createNode(`paragraph`,{},t.parseInline(e.tokens))):e.text?n.push(t.createNode(`paragraph`,{},[t.createNode(`text`,{text:e.text})])):n.push(t.createNode(`paragraph`,{},[])),e.nestedTokens&&e.nestedTokens.length>0){let r=t.parseChildren(e.nestedTokens);n.push(...r)}return t.createNode(`taskItem`,{checked:e.checked||!1},n)},renderMarkdown:(e,t)=>N6(e,t,`- [${e.attrs?.checked?`x`:` `}] `),addKeyboardShortcuts(){let e={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...e,Tab:()=>this.editor.commands.sinkListItem(this.name)}:e},addNodeView(){return({node:e,HTMLAttributes:t,getPos:n,editor:r})=>{let i=document.createElement(`li`),a=document.createElement(`label`),o=document.createElement(`span`),s=document.createElement(`input`),c=document.createElement(`div`),l=e=>{var t;s.ariaLabel=((t=this.options.a11y)?.checkboxLabel)?.call(t,e,s.checked)||`Task item checkbox for ${e.textContent||`empty task item`}`};l(e),a.contentEditable=`false`,s.type=`checkbox`,s.addEventListener(`mousedown`,e=>e.preventDefault()),s.addEventListener(`change`,t=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){s.checked=!s.checked;return}let{checked:i}=t.target;r.isEditable&&typeof n==`function`&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:e})=>{let t=n();if(typeof t!=`number`)return!1;let r=e.doc.nodeAt(t);return e.setNodeMarkup(t,void 0,{...r?.attrs,checked:i}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(e,i)||(s.checked=!s.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([e,t])=>{i.setAttribute(e,t)}),i.dataset.checked=e.attrs.checked,s.checked=e.attrs.checked,a.append(s,o),i.append(a,c),Object.entries(t).forEach(([e,t])=>{i.setAttribute(e,t)});let u=new Set(Object.keys(t));return{dom:i,contentDOM:c,update:e=>{if(e.type!==this.type)return!1;i.dataset.checked=e.attrs.checked,s.checked=e.attrs.checked,l(e);let t=r.extensionManager.attributes,n=z3(e,t),a=new Set(Object.keys(n)),o=this.options.HTMLAttributes;return u.forEach(e=>{a.has(e)||(e in o?i.setAttribute(e,o[e]):i.removeAttribute(e))}),Object.entries(n).forEach(([e,t])=>{t==null?e in o?i.setAttribute(e,o[e]):i.removeAttribute(e):i.setAttribute(e,t)}),u=a,!0}}}},addInputRules(){return[k6({find:WZe,type:this.type,getAttributes:e=>({checked:e[e.length-1]===`x`})})]}}),n7=P6.create({name:`taskList`,addOptions(){return{itemTypeName:`taskItem`,HTMLAttributes:{}}},group:`block list`,content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:e}){return[`ul`,R3(this.options.HTMLAttributes,e,{"data-type":this.name}),0]},parseMarkdown:(e,t)=>t.createNode(`taskList`,{},t.parseChildren(e.items||[])),renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,`
558
- `):``,markdownTokenizer:{name:`taskList`,level:`block`,start(e){let t=e.match(/^\s*[-+*]\s+\[([ xX])\]\s+/)?.index;return t===void 0?-1:t},tokenize(e,t,n){let r=e=>{let t=M6(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:e[3].toLowerCase()===`x`}),createToken:(e,t)=>({type:`taskItem`,raw:``,mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);return t?[{type:`taskList`,raw:t.raw,items:t.items}]:n.blockTokens(e)},i=M6(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:e[3].toLowerCase()===`x`}),createToken:(e,t)=>({type:`taskItem`,raw:``,mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);if(i)return{type:`taskList`,raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:e})=>e.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});h6.create({name:`listKit`,addExtensions(){let e=[];return this.options.bulletList!==!1&&e.push(R5.configure(this.options.bulletList)),this.options.listItem!==!1&&e.push(z5.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(Y5.configure(this.options.listKeymap)),this.options.orderedList!==!1&&e.push(e7.configure(this.options.orderedList)),this.options.taskItem!==!1&&e.push(t7.configure(this.options.taskItem)),this.options.taskList!==!1&&e.push(n7.configure(this.options.taskList)),e}});var r7=`&nbsp;`,i7=`\xA0`,GZe=P6.create({name:`paragraph`,priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:`block`,content:`inline*`,parseHTML(){return[{tag:`p`}]},renderHTML({HTMLAttributes:e}){return[`p`,R3(this.options.HTMLAttributes,e),0]},parseMarkdown:(e,t)=>{let n=e.tokens||[];if(n.length===1&&n[0].type===`image`)return t.parseChildren([n[0]]);let r=t.parseInline(n);return n.length===1&&n[0].type===`text`&&(n[0].raw===r7||n[0].text===r7||n[0].raw===i7||n[0].text===i7)&&r.length===1&&r[0].type===`text`&&(r[0].text===r7||r[0].text===i7)?t.createNode(`paragraph`,void 0,[]):t.createNode(`paragraph`,void 0,r)},renderMarkdown:(e,t,n)=>{if(!e)return``;let r=Array.isArray(e.content)?e.content:[];if(r.length===0){let e=Array.isArray(n?.previousNode?.content)?n.previousNode.content:[];return n?.previousNode?.type===`paragraph`&&e.length===0?r7:``}return t.renderChildren(r)},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),KZe=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,qZe=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,JZe=f6.create({name:`strike`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`s`},{tag:`del`},{tag:`strike`},{style:`text-decoration`,consuming:!1,getAttrs:e=>e.includes(`line-through`)?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`s`,R3(this.options.HTMLAttributes,e),0]},markdownTokenName:`del`,parseMarkdown:(e,t)=>t.applyMark(`strike`,t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>`~~${t.renderChildren(e)}~~`,addCommands(){return{setStrike:()=>({commands:e})=>e.setMark(this.name),toggleStrike:()=>({commands:e})=>e.toggleMark(this.name),unsetStrike:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[D6({find:KZe,type:this.type})]},addPasteRules(){return[F6({find:qZe,type:this.type})]}}),YZe=P6.create({name:`text`,group:`inline`,parseMarkdown:e=>({type:`text`,text:e.text||``}),renderMarkdown:e=>e.text||``}),XZe=f6.create({name:`underline`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`u`},{style:`text-decoration`,consuming:!1,getAttrs:e=>e.includes(`underline`)?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`u`,R3(this.options.HTMLAttributes,e),0]},parseMarkdown(e,t){return t.applyMark(this.name||`underline`,t.parseInline(e.tokens||[]))},renderMarkdown(e,t){return`++${t.renderChildren(e)}++`},markdownTokenizer:{name:`underline`,level:`inline`,start(e){return e.indexOf(`++`)},tokenize(e,t,n){let r=/^(\+\+)([\s\S]+?)(\+\+)/.exec(e);if(!r)return;let i=r[2].trim();return{type:`underline`,raw:r[0],text:i,tokens:n.inlineTokens(i)}}},addCommands(){return{setUnderline:()=>({commands:e})=>e.setMark(this.name),toggleUnderline:()=>({commands:e})=>e.toggleMark(this.name),unsetUnderline:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function ZZe(e={}){return new R1({view(t){return new QZe(t,e)}})}var QZe=class{constructor(e,t){this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=t.width??1,this.color=t.color===!1?void 0:t.color||`black`,this.class=t.class,this.handlers=[`dragover`,`dragend`,`drop`,`dragleave`].map(t=>{let n=e=>{this[t](e)};return e.dom.addEventListener(t,n),{name:t,handler:n}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,n,r=this.editorView.dom,i=r.getBoundingClientRect(),a=i.width/r.offsetWidth,o=i.height/r.offsetHeight;if(t){let t=e.nodeBefore,r=e.nodeAfter;if(t||r){let e=this.editorView.nodeDOM(this.cursorPos-(t?t.nodeSize:0));if(e){let i=e.getBoundingClientRect(),a=t?i.bottom:i.top;t&&r&&(a=(a+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let s=this.width/2*o;n={left:i.left,right:i.right,top:a-s,bottom:a+s}}}}if(!n){let e=this.editorView.coordsAtPos(this.cursorPos),t=this.width/2*a;n={left:e.left-t,right:e.left+t,top:e.top,bottom:e.bottom}}let s=this.editorView.dom.offsetParent;this.element||(this.element=s.appendChild(document.createElement(`div`)),this.class&&(this.element.className=this.class),this.element.style.cssText=`position: absolute; z-index: 50; pointer-events: none;`,this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle(`prosemirror-dropcursor-block`,t),this.element.classList.toggle(`prosemirror-dropcursor-inline`,!t);let c,l;if(!s||s==document.body&&getComputedStyle(s).position==`static`)c=-pageXOffset,l=-pageYOffset;else{let e=s.getBoundingClientRect(),t=e.width/s.offsetWidth,n=e.height/s.offsetHeight;c=e.left-s.scrollLeft*t,l=e.top-s.scrollTop*n}this.element.style.left=(n.left-c)/a+`px`,this.element.style.top=(n.top-l)/o+`px`,this.element.style.width=(n.right-n.left)/a+`px`,this.element.style.height=(n.bottom-n.top)/o+`px`}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),r=n&&n.type.spec.disableDropCursor,i=typeof r==`function`?r(this.editorView,t,e):r;if(t&&!i){let e=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let t=s1(this.editorView.state.doc,e,this.editorView.dragging.slice);t!=null&&(e=t)}this.setCursor(e),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}},a7=class e extends S1{constructor(e){super(e,e)}map(t,n){let r=t.resolve(n.map(this.head));return e.valid(r)?new e(r):S1.near(r)}content(){return Z.empty}eq(t){return t instanceof e&&t.head==this.head}toJSON(){return{type:`gapcursor`,pos:this.head}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for GapCursor.fromJSON`);return new e(t.resolve(n.pos))}getBookmark(){return new $Ze(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!eQe(e)||!tQe(e))return!1;let n=t.type.spec.allowGapCursor;if(n!=null)return n;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(t,n,r=!1){search:for(;;){if(!r&&e.valid(t))return t;let i=t.pos,a=null;for(let r=t.depth;;r--){let o=t.node(r);if(n>0?t.indexAfter(r)<o.childCount:t.index(r)>0){a=o.child(n>0?t.indexAfter(r):t.index(r)-1);break}else if(r==0)return null;i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}for(;;){let o=n>0?a.firstChild:a.lastChild;if(!o){if(a.isAtom&&!a.isText&&!D1.isSelectable(a)){t=t.doc.resolve(i+a.nodeSize*n),r=!1;continue search}break}a=o,i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}return null}}};a7.prototype.visible=!1,a7.findFrom=a7.findGapCursorFrom,S1.jsonID(`gapcursor`,a7);var $Ze=class e{constructor(e){this.pos=e}map(t){return new e(t.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return a7.valid(t)?new a7(t):S1.near(t)}};function o7(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function eQe(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n-1);;e=e.lastChild){if(e.childCount==0&&!e.inlineContent||o7(e.type))return!0;if(e.inlineContent)return!1}}return!0}function tQe(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n);;e=e.firstChild){if(e.childCount==0&&!e.inlineContent||o7(e.type))return!0;if(e.inlineContent)return!1}}return!0}function nQe(){return new R1({props:{decorations:oQe,createSelectionBetween(e,t,n){return t.pos==n.pos&&a7.valid(n)?new a7(n):null},handleClick:iQe,handleKeyDown:rQe,handleDOMEvents:{beforeinput:aQe}}})}var rQe=r3({ArrowLeft:s7(`horiz`,-1),ArrowRight:s7(`horiz`,1),ArrowUp:s7(`vert`,-1),ArrowDown:s7(`vert`,1)});function s7(e,t){let n=e==`vert`?t>0?`down`:`up`:t>0?`right`:`left`;return function(e,r,i){let a=e.selection,o=t>0?a.$to:a.$from,s=a.empty;if(a instanceof T1){if(!i.endOfTextblock(n)||o.depth==0)return!1;s=!1,o=e.doc.resolve(t>0?o.after():o.before())}let c=a7.findGapCursorFrom(o,t,s);return c?(r&&r(e.tr.setSelection(new a7(c))),!0):!1}}function iQe(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!a7.valid(r))return!1;let i=e.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&D1.isSelectable(e.state.doc.nodeAt(i.inside))?!1:(e.dispatch(e.state.tr.setSelection(new a7(r))),!0)}function aQe(e,t){if(t.inputType!=`insertCompositionText`||!(e.state.selection instanceof a7))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let i=X.empty;for(let e=r.length-1;e>=0;e--)i=X.from(r[e].createAndFill(null,i));let a=e.state.tr.replace(n.pos,n.pos,new Z(i,0,0));return a.setSelection(T1.near(a.doc.resolve(n.pos+1))),e.dispatch(a),!1}function oQe(e){if(!(e.selection instanceof a7))return null;let t=document.createElement(`div`);return t.className=`ProseMirror-gapcursor`,k4.create(e.doc,[E4.widget(e.selection.head,t,{key:`gapcursor`})])}var c7=200,l7=function(){};l7.prototype.append=function(e){return e.length?(e=l7.from(e),!this.length&&e||e.length<c7&&this.leafAppend(e)||this.length<c7&&e.leafPrepend(this)||this.appendInner(e)):this},l7.prototype.prepend=function(e){return e.length?l7.from(e).append(this):this},l7.prototype.appendInner=function(e){return new sQe(this,e)},l7.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?l7.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},l7.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},l7.prototype.forEach=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},l7.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var r=[];return this.forEach(function(t,n){return r.push(e(t,n))},t,n),r},l7.from=function(e){return e instanceof l7?e:e&&e.length?new u7(e):l7.empty};var u7=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return e==0&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,r){for(var i=t;i<n;i++)if(e(this.values[i],r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){for(var i=t-1;i>=n;i--)if(e(this.values[i],r+i)===!1)return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=c7)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=c7)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(l7);l7.empty=new u7([]);var sQe=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,n,r){var i=this.left.length;if(t<i&&this.left.forEachInner(e,t,Math.min(n,i),r)===!1||n>i&&this.right.forEachInner(e,Math.max(t-i,0),Math.min(this.length,n)-i,r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){var i=this.left.length;if(t>i&&this.right.forEachInvertedInner(e,t-i,Math.max(n,i)-i,r+i)===!1||n<i&&this.left.forEachInvertedInner(e,Math.min(t,i),n,r)===!1)return!1},t.prototype.sliceInner=function(e,t){if(e==0&&t==this.length)return this;var n=this.left.length;return t<=n?this.left.slice(e,t):e>=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(l7),cQe=500,d7=class e{constructor(e,t){this.items=e,this.eventCount=t}popEvent(t,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,a;n&&(i=this.remapping(r,this.items.length),a=i.maps.length);let o=t.tr,s,c,l=[],u=[];return this.items.forEach((t,n)=>{if(!t.step){i||(i=this.remapping(r,n+1),a=i.maps.length),a--,u.push(t);return}if(i){u.push(new f7(t.map));let e=t.step.map(i.slice(a)),n;e&&o.maybeStep(e).doc&&(n=o.mapping.maps[o.mapping.maps.length-1],l.push(new f7(n,void 0,void 0,l.length+u.length))),a--,n&&i.appendMap(n,a)}else o.maybeStep(t.step);if(t.selection)return s=i?t.selection.map(i.slice(a)):t.selection,c=new e(this.items.slice(0,r).append(u.reverse().concat(l)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:o,selection:s}}addTransform(t,n,r,i){let a=[],o=this.eventCount,s=this.items,c=!i&&s.length?s.get(s.length-1):null;for(let e=0;e<t.steps.length;e++){let r=t.steps[e].invert(t.docs[e]),l=new f7(t.mapping.maps[e],r,n),u;(u=c&&c.merge(l))&&(l=u,e?a.pop():s=s.slice(0,s.length-1)),a.push(l),n&&=(o++,void 0),i||(c=l)}let l=o-r.depth;return l>uQe&&(s=lQe(s,l),o-=l),new e(s.append(a),o)}remapping(e,t){let n=new z$;return this.items.forEach((t,r)=>{let i=t.mirrorOffset!=null&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,i)},e,t),n}addMaps(t){return this.eventCount==0?this:new e(this.items.append(t.map(e=>new f7(e))),this.eventCount)}rebased(t,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),a=t.mapping,o=t.steps.length,s=this.eventCount;this.items.forEach(e=>{e.selection&&s--},i);let c=n;this.items.forEach(e=>{let n=a.getMirror(--c);if(n==null)return;o=Math.min(o,n);let i=a.maps[n];if(e.step){let o=t.steps[n].invert(t.docs[n]),l=e.selection&&e.selection.map(a.slice(c+1,n));l&&s++,r.push(new f7(i,o,l))}else r.push(new f7(i))},i);let l=[];for(let e=n;e<o;e++)l.push(new f7(a.maps[e]));let u=new e(this.items.slice(0,i).append(l).append(r),s);return u.emptyItemCount()>cQe&&(u=u.compress(this.items.length-r.length)),u}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(t=this.items.length){let n=this.remapping(0,t),r=n.maps.length,i=[],a=0;return this.items.forEach((e,o)=>{if(o>=t)i.push(e),e.selection&&a++;else if(e.step){let t=e.step.map(n.slice(r)),o=t&&t.getMap();if(r--,o&&n.appendMap(o,r),t){let s=e.selection&&e.selection.map(n.slice(r));s&&a++;let c=new f7(o.invert(),t,s),l,u=i.length-1;(l=i.length&&i[u].merge(c))?i[u]=l:i.push(c)}}else e.map&&r--},this.items.length,0),new e(l7.from(i.reverse()),a)}};d7.empty=new d7(l7.empty,0);function lQe(e,t){let n;return e.forEach((e,r)=>{if(e.selection&&t--==0)return n=r,!1}),e.slice(n)}var f7=class e{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(t){if(this.step&&t.step&&!t.selection){let n=t.step.merge(this.step);if(n)return new e(n.getMap().invert(),n,this.selection)}}},p7=class{constructor(e,t,n,r,i){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=i}},uQe=20;function dQe(e,t,n,r){let i=n.getMeta(y7),a;if(i)return i.historyState;n.getMeta(mQe)&&(e=new p7(e.done,e.undone,null,0,-1));let o=n.getMeta(`appendedTransaction`);if(n.steps.length==0)return e;if(o&&o.getMeta(y7))return o.getMeta(y7).redo?new p7(e.done.addTransform(n,void 0,r,v7(t)),e.undone,m7(n.mapping.maps),e.prevTime,e.prevComposition):new p7(e.done,e.undone.addTransform(n,void 0,r,v7(t)),null,e.prevTime,e.prevComposition);if(n.getMeta(`addToHistory`)!==!1&&!(o&&o.getMeta(`addToHistory`)===!1)){let i=n.getMeta(`composition`),a=e.prevTime==0||!o&&e.prevComposition!=i&&(e.prevTime<(n.time||0)-r.newGroupDelay||!fQe(n,e.prevRanges)),s=o?h7(e.prevRanges,n.mapping):m7(n.mapping.maps);return new p7(e.done.addTransform(n,a?t.selection.getBookmark():void 0,r,v7(t)),d7.empty,s,n.time,i??e.prevComposition)}else if(a=n.getMeta(`rebased`))return new p7(e.done.rebased(n,a),e.undone.rebased(n,a),h7(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);else return new p7(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),h7(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function fQe(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((e,r)=>{for(let i=0;i<t.length;i+=2)e<=t[i+1]&&r>=t[i]&&(n=!0)}),n}function m7(e){let t=[];for(let n=e.length-1;n>=0&&t.length==0;n--)e[n].forEach((e,n,r,i)=>t.push(r,i));return t}function h7(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let i=t.map(e[r],1),a=t.map(e[r+1],-1);i<=a&&n.push(i,a)}return n}function pQe(e,t,n){let r=v7(t),i=y7.get(t).spec.config,a=(n?e.undone:e.done).popEvent(t,r);if(!a)return null;let o=a.selection.resolve(a.transform.doc),s=(n?e.done:e.undone).addTransform(a.transform,t.selection.getBookmark(),i,r),c=new p7(n?s:a.remaining,n?a.remaining:s,null,0,-1);return a.transform.setSelection(o).setMeta(y7,{redo:n,historyState:c})}var g7=!1,_7=null;function v7(e){let t=e.plugins;if(_7!=t){g7=!1,_7=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){g7=!0;break}}return g7}var y7=new V1(`history`),mQe=new V1(`closeHistory`);function hQe(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new R1({key:y7,state:{init(){return new p7(d7.empty,d7.empty,null,0,-1)},apply(t,n,r){return dQe(n,r,t,e)}},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,r=n==`historyUndo`?x7:n==`historyRedo`?S7:null;return!r||!e.editable?!1:(t.preventDefault(),r(e.state,e.dispatch))}}}})}function b7(e,t){return(n,r)=>{let i=y7.getState(n);if(!i||(e?i.undone:i.done).eventCount==0)return!1;if(r){let a=pQe(i,n,e);a&&r(t?a.scrollIntoView():a)}return!0}}var x7=b7(!1,!0),S7=b7(!0,!0);h6.create({name:`characterCount`,addOptions(){return{limit:null,mode:`textSize`,textCounter:e=>e.length,wordCounter:e=>e.split(` `).filter(e=>e!==``).length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=e=>{let t=e?.node||this.editor.state.doc;if((e?.mode||this.options.mode)===`textSize`){let e=t.textBetween(0,t.content.size,void 0,` `);return this.options.textCounter(e)}return t.nodeSize},this.storage.words=e=>{let t=e?.node||this.editor.state.doc,n=t.textBetween(0,t.content.size,` `,` `);return this.options.wordCounter(n)}},addProseMirrorPlugins(){let e=!1;return[new R1({key:new V1(`characterCount`),appendTransaction:(t,n,r)=>{if(e)return;let i=this.options.limit;if(i==null||i===0){e=!0;return}let a=this.storage.characters({node:r.doc});if(a>i){let t=a-i;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);let n=r.tr.deleteRange(0,t);return e=!0,n}e=!0},filterTransaction:(e,t)=>{let n=this.options.limit;if(!e.docChanged||n===0||n==null)return!0;let r=this.storage.characters({node:t.doc}),i=this.storage.characters({node:e.doc});if(i<=n||r>n&&i>n&&i<=r)return!0;if(r>n&&i>n&&i>r||!e.getMeta(`paste`))return!1;let a=e.selection.$head.pos,o=a-(i-n),s=a;return e.deleteRange(o,s),!(this.storage.characters({node:e.doc})>n)}})]}});var gQe=h6.create({name:`dropCursor`,addOptions(){return{color:`currentColor`,width:1,class:void 0}},addProseMirrorPlugins(){return[ZZe(this.options)]}});h6.create({name:`focus`,addOptions(){return{className:`has-focus`,mode:`all`}},addProseMirrorPlugins(){return[new R1({key:new V1(`focus`),props:{decorations:({doc:e,selection:t})=>{let{isEditable:n,isFocused:r}=this.editor,{anchor:i}=t,a=[];if(!n||!r)return k4.create(e,[]);let o=0;this.options.mode===`deepest`&&e.descendants((e,t)=>{if(!e.isText){if(!(i>=t&&i<=t+e.nodeSize-1))return!1;o+=1}});let s=0;return e.descendants((e,t)=>{if(e.isText||!(i>=t&&i<=t+e.nodeSize-1))return!1;if(s+=1,this.options.mode===`deepest`&&o-s>0||this.options.mode===`shallowest`&&s>1)return this.options.mode===`deepest`;a.push(E4.node(t,t+e.nodeSize,{class:this.options.className}))}),k4.create(e,a)}}})]}});var _Qe=h6.create({name:`gapCursor`,addProseMirrorPlugins(){return[nQe()]},extendNodeSchema(e){return{allowGapCursor:P3(Q(e,`allowGapCursor`,{name:e.name,options:e.options,storage:e.storage}))??null}}}),C7=`placeholder`;function vQe(e){return e.replace(/\s+/g,`-`).replace(/[^a-zA-Z0-9-]/g,``).replace(/^[0-9-]+/,``).replace(/^-+/,``).toLowerCase()}var yQe=h6.create({name:`placeholder`,addOptions(){return{emptyEditorClass:`is-editor-empty`,emptyNodeClass:`is-empty`,dataAttribute:C7,placeholder:`Write something …`,showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){let e=this.options.dataAttribute?`data-${vQe(this.options.dataAttribute)}`:`data-${C7}`;return[new R1({key:new V1(`placeholder`),props:{decorations:({doc:t,selection:n})=>{let r=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:i}=n,a=[];if(!r)return null;let o=this.editor.isEmpty;return t.descendants((t,n)=>{let r=i>=n&&i<=n+t.nodeSize,s=!t.isLeaf&&t6(t);if(!t.type.isTextblock)return this.options.includeChildren;if((r||!this.options.showOnlyCurrent)&&s){let i=[this.options.emptyNodeClass];o&&i.push(this.options.emptyEditorClass);let s=E4.node(n,n+t.nodeSize,{class:i.join(` `),[e]:typeof this.options.placeholder==`function`?this.options.placeholder({editor:this.editor,node:t,pos:n,hasAnchor:r}):this.options.placeholder});a.push(s)}return this.options.includeChildren}),k4.create(t,a)}}})]}});h6.create({name:`selection`,addOptions(){return{className:`selection`}},addProseMirrorPlugins(){let{editor:e,options:t}=this;return[new R1({key:new V1(`selection`),props:{decorations(n){return n.selection.empty||e.isFocused||!e.isEditable||n6(n.selection)||e.view.dragging?null:k4.create(n.doc,[E4.inline(n.selection.from,n.selection.to,{class:t.className})])}}})]}});function w7({types:e,node:t}){return t&&Array.isArray(e)&&e.includes(t.type)||t?.type===e}var bQe=h6.create({name:`trailingNode`,addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){let e=new V1(this.name),t=this.options.node||this.editor.schema.topNodeType.contentMatch.defaultType?.name||`paragraph`,n=Object.entries(this.editor.schema.nodes).map(([,e])=>e).filter(e=>(this.options.notAfter||[]).concat(t).includes(e.name));return[new R1({key:e,appendTransaction:(n,r,i)=>{let{doc:a,tr:o,schema:s}=i,c=e.getState(i),l=a.content.size,u=s.nodes[t];if(!n.some(e=>e.getMeta(`skipTrailingNode`))&&c)return o.insert(l,u.create())},state:{init:(e,t)=>{let r=t.tr.doc.lastChild;return!w7({node:r,types:n})},apply:(e,t)=>{if(!e.docChanged||e.getMeta(`__uniqueIDTransaction`))return t;let r=e.doc.lastChild;return!w7({node:r,types:n})}}})]}}),xQe=h6.create({name:`undoRedo`,addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>x7(e,t),redo:()=>({state:e,dispatch:t})=>S7(e,t)}},addProseMirrorPlugins(){return[hQe(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),SQe=h6.create({name:`starterKit`,addExtensions(){let e=[];return this.options.bold!==!1&&e.push(YXe.configure(this.options.bold)),this.options.blockquote!==!1&&e.push(WXe.configure(this.options.blockquote)),this.options.bulletList!==!1&&e.push(R5.configure(this.options.bulletList)),this.options.code!==!1&&e.push(QXe.configure(this.options.code)),this.options.codeBlock!==!1&&e.push(tZe.configure(this.options.codeBlock)),this.options.document!==!1&&e.push(nZe.configure(this.options.document)),this.options.dropcursor!==!1&&e.push(gQe.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&e.push(_Qe.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&e.push(rZe.configure(this.options.hardBreak)),this.options.heading!==!1&&e.push(iZe.configure(this.options.heading)),this.options.undoRedo!==!1&&e.push(xQe.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&e.push(aZe.configure(this.options.horizontalRule)),this.options.italic!==!1&&e.push(uZe.configure(this.options.italic)),this.options.listItem!==!1&&e.push(z5.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(Y5.configure(this.options?.listKeymap)),this.options.link!==!1&&e.push(F5.configure(this.options?.link)),this.options.orderedList!==!1&&e.push(e7.configure(this.options.orderedList)),this.options.paragraph!==!1&&e.push(GZe.configure(this.options.paragraph)),this.options.strike!==!1&&e.push(JZe.configure(this.options.strike)),this.options.text!==!1&&e.push(YZe.configure(this.options.text)),this.options.underline!==!1&&e.push(XZe.configure(this.options?.underline)),this.options.trailingNode!==!1&&e.push(bQe.configure(this.options?.trailingNode)),e}}),CQe=n7,wQe=t7,TQe=yQe;function T7(e){if(!e)return null;try{var t=JSON.parse(e);if(typeof t==`object`&&t)return t}catch{}return null}function E7({active:e,onClick:t,disabled:n,label:r,children:i}){return(0,b.jsx)(`button`,{type:`button`,onClick:t,disabled:n,"aria-label":r,"aria-pressed":e,className:`p-1 rounded transition-colors `+(e?`bg-primary/20 text-primary`:`text-base-content/40 hover:text-base-content/70 hover:bg-base-content/5`)+(n?` opacity-30 cursor-not-allowed`:``),children:i})}function EQe({content:e,onChange:t,placeholder:n,disabled:r}){var i=(0,x.useRef)(e);i.current=e;var a=zXe({extensions:[SQe.configure({heading:{levels:[1,2]}}),FZe.configure({openOnClick:!0}),CQe,wQe.configure({nested:!0}),TQe.configure({placeholder:n??`Write something...`})],editable:!r,content:T7(e)??(e||``),onUpdate:function({editor:e}){t(JSON.stringify(e.getJSON()))}});if((0,x.useEffect)(function(){a&&a.setEditable(!r)},[a,r]),(0,x.useEffect)(function(){if(!(!a||a.isFocused)){var t=T7(e),n=JSON.stringify(a.getJSON());t&&JSON.stringify(t)!==n?a.commands.setContent(t):!t&&e!==n&&a.commands.setContent(e||``)}},[e,a]),!a)return null;function o(){if(a){var e=window.prompt(`URL:`);e&&a.chain().focus().setLink({href:e}).run()}}return(0,b.jsxs)(`div`,{className:`flex flex-col gap-0 border border-base-content/10 rounded-lg overflow-hidden bg-base-100`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-0.5 px-2 py-1.5 border-b border-base-content/10 bg-base-200/50 flex-wrap`,children:[(0,b.jsx)(E7,{active:a.isActive(`bold`),onClick:function(){a.chain().focus().toggleBold().run()},disabled:r,label:`Bold`,children:(0,b.jsx)(vs,{size:14})}),(0,b.jsx)(E7,{active:a.isActive(`italic`),onClick:function(){a.chain().focus().toggleItalic().run()},disabled:r,label:`Italic`,children:(0,b.jsx)(eg,{size:14})}),(0,b.jsx)(E7,{active:a.isActive(`strike`),onClick:function(){a.chain().focus().toggleStrike().run()},disabled:r,label:`Strikethrough`,children:(0,b.jsx)(xv,{size:14})}),(0,b.jsx)(`div`,{className:`w-px h-4 bg-base-content/10 mx-1`}),(0,b.jsx)(E7,{active:a.isActive(`heading`,{level:1}),onClick:function(){a.chain().focus().toggleHeading({level:1}).run()},disabled:r,label:`Heading 1`,children:(0,b.jsx)(rh,{size:14})}),(0,b.jsx)(E7,{active:a.isActive(`heading`,{level:2}),onClick:function(){a.chain().focus().toggleHeading({level:2}).run()},disabled:r,label:`Heading 2`,children:(0,b.jsx)(ih,{size:14})}),(0,b.jsx)(`div`,{className:`w-px h-4 bg-base-content/10 mx-1`}),(0,b.jsx)(E7,{active:a.isActive(`bulletList`),onClick:function(){a.chain().focus().toggleBulletList().run()},disabled:r,label:`Bullet List`,children:(0,b.jsx)(x_,{size:14})}),(0,b.jsx)(E7,{active:a.isActive(`orderedList`),onClick:function(){a.chain().focus().toggleOrderedList().run()},disabled:r,label:`Numbered List`,children:(0,b.jsx)(p_,{size:14})}),(0,b.jsx)(E7,{active:a.isActive(`taskList`),onClick:function(){a.chain().focus().toggleTaskList().run()},disabled:r,label:`Task List`,children:(0,b.jsx)(n_,{size:14})}),(0,b.jsx)(`div`,{className:`w-px h-4 bg-base-content/10 mx-1`}),(0,b.jsx)(E7,{active:a.isActive(`codeBlock`),onClick:function(){a.chain().focus().toggleCodeBlock().run()},disabled:r,label:`Code Block`,children:(0,b.jsx)(bf,{size:14})}),(0,b.jsx)(E7,{active:a.isActive(`link`),onClick:o,disabled:r,label:`Link`,children:(0,b.jsx)($g,{size:14})})]}),(0,b.jsx)(I6,{editor:a,className:`prose prose-sm max-w-none px-3 py-2 min-h-[200px] text-base-content [&_.tiptap]:outline-none [&_.tiptap]:min-h-[180px] [&_.tiptap_p.is-editor-empty:first-child::before]:text-base-content/30 [&_.tiptap_p.is-editor-empty:first-child::before]:content-[attr(data-placeholder)] [&_.tiptap_p.is-editor-empty:first-child::before]:float-left [&_.tiptap_p.is-editor-empty:first-child::before]:h-0 [&_.tiptap_p.is-editor-empty:first-child::before]:pointer-events-none [&_.tiptap_h1]:text-lg [&_.tiptap_h1]:font-mono [&_.tiptap_h1]:font-bold [&_.tiptap_h2]:text-base [&_.tiptap_h2]:font-mono [&_.tiptap_h2]:font-semibold [&_.tiptap_a]:text-primary [&_.tiptap_a]:underline [&_.tiptap_code]:bg-base-300 [&_.tiptap_code]:px-1 [&_.tiptap_code]:rounded [&_.tiptap_pre]:bg-base-300 [&_.tiptap_pre]:p-3 [&_.tiptap_pre]:rounded-lg [&_.tiptap_ul[data-type=taskList]]:list-none [&_.tiptap_ul[data-type=taskList]]:pl-0`})]})}var DQe={created:`bg-info/20 text-info`,"status-change":`bg-warning/20 text-warning`,"session-linked":`bg-accent/20 text-accent`,edited:`bg-base-content/10 text-base-content/60`,"ai-note":`bg-secondary/20 text-secondary`},OQe={created:`Created`,"status-change":`Status`,"session-linked":`Session`,edited:`Edited`,"ai-note":`AI Note`};function kQe(e){var t=Date.now()-e,n=Math.floor(t/1e3);if(n<60)return n+`s ago`;var r=Math.floor(n/60);if(r<60)return r+`m ago`;var i=Math.floor(r/60);return i<24?i+`h ago`:Math.floor(i/24)+`d ago`}function AQe({activity:e}){var t=[...e].reverse();return t.length===0?(0,b.jsx)(`div`,{className:`flex items-center justify-center py-12 text-[13px] text-base-content/30 font-mono`,children:`No activity yet`}):(0,b.jsx)(`div`,{className:`flex flex-col gap-1 py-2`,children:t.map(function(e,t){return(0,b.jsxs)(`div`,{className:`flex items-start gap-3 px-1 py-1.5`,children:[(0,b.jsx)(`span`,{className:`text-[10px] text-base-content/30 font-mono w-14 flex-shrink-0 pt-0.5 text-right`,children:kQe(e.timestamp)}),(0,b.jsx)(`span`,{className:`text-[10px] font-mono px-1.5 py-0.5 rounded flex-shrink-0 `+DQe[e.type],children:OQe[e.type]}),(0,b.jsx)(`span`,{className:`text-[12px] text-base-content/70 min-w-0`,children:e.detail})]},t)})})}function jQe(e){var t=Date.now()-e,n=Math.floor(t/1e3);if(n<60)return n+`s ago`;var r=Math.floor(n/60);if(r<60)return r+`m ago`;var i=Math.floor(r/60);return i<24?i+`h ago`:Math.floor(i/24)+`d ago`}function MQe({linkedSessions:e,onUnlink:t,disabled:n}){return e.length===0?(0,b.jsx)(`div`,{className:`flex items-center justify-center py-12 text-[13px] text-base-content/30 font-mono`,children:`No linked sessions`}):(0,b.jsx)(`div`,{className:`flex flex-col gap-1 py-2`,children:e.map(function(e){return(0,b.jsxs)(`div`,{className:`flex items-center gap-3 px-1 py-1.5 rounded hover:bg-base-content/5 transition-colors`,children:[(0,b.jsx)(`span`,{className:`text-[12px] font-mono text-base-content/70 flex-shrink-0`,children:e.sessionId.slice(0,8)}),e.note&&(0,b.jsx)(`span`,{className:`text-[11px] text-base-content/40 truncate min-w-0 flex-1`,children:e.note}),(0,b.jsx)(`span`,{className:`text-[10px] text-base-content/30 font-mono flex-shrink-0 ml-auto`,children:jQe(e.linkedAt)}),(0,b.jsx)(`button`,{type:`button`,onClick:function(){t(e.sessionId)},disabled:n,className:`p-1 rounded text-base-content/30 hover:text-error hover:bg-error/10 transition-colors disabled:opacity-30 disabled:cursor-not-allowed`,"aria-label":`Unlink session `+e.sessionId.slice(0,8),children:(0,b.jsx)(Zg,{size:13})})]},e.sessionId)})})}var NQe=[{key:`summary`,label:`Summary`},{key:`currentState`,label:`Current State`},{key:`requirements`,label:`Requirements`},{key:`implementationPlan`,label:`Implementation`},{key:`migrationMap`,label:`Migration`},{key:`testing`,label:`Testing`},{key:`activity`,label:`Activity`},{key:`sessions`,label:`Sessions`}],PQe=[`draft`,`in-progress`,`on-hold`,`completed`],FQe=[`high`,`medium`,`low`],IQe=[`small`,`medium`,`large`,`xl`];function LQe({spec:e,onBack:t}){var{send:n}=R(),r=_b(),[i,a]=(0,x.useState)(e.title),[o,s]=(0,x.useState)(e.tagline),[c,l]=(0,x.useState)(e.status),[u,d]=(0,x.useState)(e.priority),[f,p]=(0,x.useState)(e.estimatedEffort),[m,h]=(0,x.useState)(e.author),[g,_]=(0,x.useState)(e.tags),[v,y]=(0,x.useState)(e.sections),[S,C]=(0,x.useState)(`summary`),[w,T]=(0,x.useState)(`idle`),[E,D]=(0,x.useState)(!1),[O,k]=(0,x.useState)(``),A=(0,x.useRef)(null),j=(0,x.useRef)(null),M=(0,x.useRef)(e.id);M.current=e.id,(0,x.useEffect)(function(){a(e.title),s(e.tagline),l(e.status),d(e.priority),p(e.estimatedEffort),h(e.author),_(e.tags),y(e.sections)},[e.id]);var N=(0,x.useCallback)(function(){A.current&&=(clearTimeout(A.current),null),j.current&&=(n({type:`specs:update`,id:M.current,sections:j.current}),null)},[n]);(0,x.useEffect)(function(){return function(){N()}},[N]);function ee(e,t){var r={...v,[e]:t};y(r),j.current=r,T(`saving`),A.current&&clearTimeout(A.current),A.current=setTimeout(function(){n({type:`specs:update`,id:M.current,sections:j.current}),j.current=null,T(`saved`),setTimeout(function(){T(`idle`)},1500)},800)}function te(t){n({type:`specs:update`,id:e.id,...t}),T(`saved`),setTimeout(function(){T(`idle`)},1500)}function P(){i!==e.title&&te({title:i})}function F(){o!==e.tagline&&te({tagline:o})}function ne(e){l(e),te({status:e})}function re(e){d(e),te({priority:e})}function ie(e){p(e),te({estimatedEffort:e})}function ae(){m!==e.author&&te({author:m})}function oe(e){if(e.key===`Enter`&&O.trim()){var t=[...g,O.trim()];_(t),k(``),te({tags:t})}}function se(e){var t=g.filter(function(t,n){return n!==e});_(t),te({tags:t})}function ce(){N(),t()}function le(){n({type:`specs:delete`,id:e.id}),t()}function ue(t){n({type:`specs:unlink-session`,id:e.id,sessionId:t})}var de=S!==`activity`&&S!==`sessions`;return(0,b.jsxs)(`div`,{className:`flex flex-col h-full bg-base-100`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-2.5 border-b border-base-content/15 flex-shrink-0`,children:[(0,b.jsx)(`button`,{type:`button`,onClick:ce,className:`p-1 rounded text-base-content/40 hover:text-base-content hover:bg-base-content/5 transition-colors`,"aria-label":`Back to specs`,children:(0,b.jsx)(ba,{size:16})}),(0,b.jsxs)(`div`,{className:`flex items-center gap-1.5 ml-auto text-[11px] text-base-content/30 font-mono`,children:[w===`saving`&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(C_,{size:12,className:`animate-spin`}),(0,b.jsx)(`span`,{children:`Saving...`})]}),w===`saved`&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(L,{size:12,className:`text-success`}),(0,b.jsx)(`span`,{children:`Saved`})]})]}),(0,b.jsx)(`button`,{type:`button`,onClick:function(){D(!0)},disabled:!r,className:`p-1 rounded text-base-content/30 hover:text-error hover:bg-error/10 transition-colors disabled:opacity-30`,"aria-label":`Delete spec`,children:(0,b.jsx)(Tv,{size:14})})]}),(0,b.jsxs)(`div`,{className:`flex-1 overflow-y-auto`,children:[(0,b.jsxs)(`div`,{className:`px-4 pt-4 pb-2`,children:[(0,b.jsx)(`input`,{type:`text`,value:i,onChange:function(e){a(e.target.value)},onBlur:P,disabled:!r,placeholder:`Untitled spec`,className:`w-full bg-transparent text-[17px] font-mono font-bold text-base-content placeholder:text-base-content/20 outline-none border-none`}),(0,b.jsx)(`input`,{type:`text`,value:o,onChange:function(e){s(e.target.value)},onBlur:F,disabled:!r,placeholder:`Add a tagline...`,className:`w-full bg-transparent text-[13px] text-base-content/40 placeholder:text-base-content/20 outline-none border-none mt-0.5`})]}),(0,b.jsxs)(`div`,{className:`grid grid-cols-2 lg:grid-cols-4 gap-2 px-4 py-2`,children:[(0,b.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,b.jsx)(`label`,{className:`text-[10px] text-base-content/30 font-mono uppercase tracking-wider`,children:`Status`}),(0,b.jsx)(`select`,{value:c,onChange:function(e){ne(e.target.value)},disabled:!r,className:`h-7 px-2 bg-base-200 border border-base-content/10 rounded text-[12px] text-base-content font-mono focus:border-primary focus-visible:outline-none transition-colors`,children:PQe.map(function(e){return(0,b.jsx)(`option`,{value:e,children:e},e)})})]}),(0,b.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,b.jsx)(`label`,{className:`text-[10px] text-base-content/30 font-mono uppercase tracking-wider`,children:`Priority`}),(0,b.jsx)(`select`,{value:u,onChange:function(e){re(e.target.value)},disabled:!r,className:`h-7 px-2 bg-base-200 border border-base-content/10 rounded text-[12px] text-base-content font-mono focus:border-primary focus-visible:outline-none transition-colors`,children:FQe.map(function(e){return(0,b.jsx)(`option`,{value:e,children:e},e)})})]}),(0,b.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,b.jsx)(`label`,{className:`text-[10px] text-base-content/30 font-mono uppercase tracking-wider`,children:`Effort`}),(0,b.jsx)(`select`,{value:f,onChange:function(e){ie(e.target.value)},disabled:!r,className:`h-7 px-2 bg-base-200 border border-base-content/10 rounded text-[12px] text-base-content font-mono focus:border-primary focus-visible:outline-none transition-colors`,children:IQe.map(function(e){return(0,b.jsx)(`option`,{value:e,children:e},e)})})]}),(0,b.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,b.jsx)(`label`,{className:`text-[10px] text-base-content/30 font-mono uppercase tracking-wider`,children:`Author`}),(0,b.jsx)(`input`,{type:`text`,value:m,onChange:function(e){h(e.target.value)},onBlur:ae,disabled:!r,placeholder:`Author`,className:`h-7 px-2 bg-base-200 border border-base-content/10 rounded text-[12px] text-base-content font-mono focus:border-primary focus-visible:outline-none transition-colors`})]})]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-1.5 px-4 py-2 flex-wrap`,children:[g.map(function(e,t){return(0,b.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-base-content/10 text-[11px] font-mono text-base-content/60`,children:[e,(0,b.jsx)(`button`,{type:`button`,onClick:function(){se(t)},disabled:!r,className:`text-base-content/30 hover:text-base-content transition-colors`,"aria-label":`Remove tag `+e,children:(0,b.jsx)(Nv,{size:10})})]},t)}),(0,b.jsx)(`input`,{type:`text`,value:O,onChange:function(e){k(e.target.value)},onKeyDown:oe,disabled:!r,placeholder:`Add tag...`,className:`bg-transparent text-[11px] text-base-content/60 placeholder:text-base-content/20 outline-none border-none w-20`})]}),(0,b.jsx)(`div`,{className:`border-b border-base-content/10 overflow-x-auto flex-shrink-0`,role:`tablist`,children:(0,b.jsx)(`div`,{className:`flex px-4 gap-0`,children:NQe.map(function(e){var t=S===e.key;return(0,b.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":t,onClick:function(){C(e.key)},className:`px-3 py-2 text-[11px] font-mono whitespace-nowrap border-b-2 transition-colors `+(t?`border-primary text-primary`:`border-transparent text-base-content/40 hover:text-base-content/70`),children:e.label},e.key)})})}),(0,b.jsxs)(`div`,{className:`px-4 py-3`,children:[de&&(0,b.jsx)(EQe,{content:v[S],onChange:function(e){ee(S,e)},placeholder:`Write `+S+` details...`,disabled:!r}),S===`activity`&&(0,b.jsx)(AQe,{activity:e.activity}),S===`sessions`&&(0,b.jsx)(MQe,{linkedSessions:e.linkedSessions,onUnlink:ue,disabled:!r})]})]}),E&&(0,b.jsx)(`div`,{className:`fixed inset-0 z-[9999] flex items-center justify-center bg-black/50`,children:(0,b.jsxs)(`div`,{className:`bg-base-300 border border-base-content/15 rounded-xl shadow-2xl p-6 max-w-sm w-full mx-4`,children:[(0,b.jsx)(`h3`,{className:`text-[15px] font-mono font-bold text-base-content mb-2`,children:`Delete spec?`}),(0,b.jsxs)(`p`,{className:`text-[13px] text-base-content/60 mb-4`,children:[`This will permanently delete "`,e.title||`Untitled`,`". This action cannot be undone.`]}),(0,b.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,b.jsx)(`button`,{type:`button`,onClick:function(){D(!1)},className:`btn btn-ghost btn-sm`,children:`Cancel`}),(0,b.jsx)(`button`,{type:`button`,onClick:le,className:`btn btn-error btn-sm`,children:`Delete`})]})]})})]})}var RQe={draft:`Draft`,"in-progress":`In Progress`,"on-hold":`On Hold`,completed:`Completed`},zQe=[{value:`all`,label:`All`},{value:`draft`,label:`Draft`},{value:`in-progress`,label:`In Progress`},{value:`on-hold`,label:`On Hold`},{value:`completed`,label:`Completed`}],D7={high:0,medium:1,low:2},O7={xl:0,large:1,medium:2,small:3},k7={"in-progress":0,draft:1,"on-hold":2,completed:3};function BQe(e){var t=Date.now()-e,n=Math.floor(t/1e3);if(n<60)return n+`s ago`;var r=Math.floor(n/60);if(r<60)return r+`m ago`;var i=Math.floor(r/60);return i<24?i+`h ago`:Math.floor(i/24)+`d ago`}function VQe({specs:e,onSelectSpec:t,filter:n,onFilterChange:r}){var[i,a]=(0,x.useState)(`updatedAt`),[o,s]=(0,x.useState)(`desc`);function c(e){i===e?s(function(e){return e===`asc`?`desc`:`asc`}):(a(e),s(`desc`))}var l=(0,x.useMemo)(function(){var t=[...n===`all`?e:e.filter(function(e){return e.status===n})];return t.sort(function(e,t){var n=0;return n=i===`title`?e.title.localeCompare(t.title):i===`status`?(k7[e.status]??99)-(k7[t.status]??99):i===`priority`?(D7[e.priority]??99)-(D7[t.priority]??99):i===`estimatedEffort`?(O7[e.estimatedEffort]??99)-(O7[t.estimatedEffort]??99):e.updatedAt-t.updatedAt,o===`desc`?-n:n}),t},[e,n,i,o]);function u(e,n){(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),t(n))}return(0,b.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,b.jsx)(`div`,{className:`flex items-center gap-1 flex-wrap`,children:zQe.map(function(e){return(0,b.jsx)(`button`,{type:`button`,onClick:function(){r(e.value)},className:`px-2.5 py-1 rounded-full text-[11px] font-mono transition-colors `+(n===e.value?`bg-primary/20 text-primary`:`text-base-content/40 hover:text-base-content/70 hover:bg-base-content/5`),children:e.label},e.value)})}),(0,b.jsx)(`div`,{className:`overflow-x-auto`,children:(0,b.jsxs)(`table`,{className:`w-full text-left`,children:[(0,b.jsx)(`thead`,{children:(0,b.jsx)(`tr`,{className:`border-b border-base-content/10`,children:[{field:`title`,label:`Title`},{field:`status`,label:`Status`},{field:`priority`,label:`Priority`},{field:`estimatedEffort`,label:`Effort`},{field:`updatedAt`,label:`Updated`}].map(function(e){return(0,b.jsx)(`th`,{className:`pb-2 pr-3`,children:(0,b.jsxs)(`button`,{type:`button`,onClick:function(){c(e.field)},className:`flex items-center gap-1 text-[10px] font-mono uppercase tracking-wider transition-colors `+(i===e.field?`text-primary`:`text-base-content/30 hover:text-base-content/60`),children:[e.label,(0,b.jsx)(ka,{size:10})]})},e.field)})})}),(0,b.jsx)(`tbody`,{children:l.map(function(e){return(0,b.jsxs)(`tr`,{tabIndex:0,role:`button`,onClick:function(){t(e)},onKeyDown:function(t){u(t,e)},className:`border-b border-base-content/5 hover:bg-base-content/5 cursor-pointer transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/40`+(e.status===`completed`?` opacity-60`:``),children:[(0,b.jsx)(`td`,{className:`py-2 pr-3`,children:(0,b.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,b.jsx)(`span`,{className:`text-[12px] font-mono font-semibold text-base-content truncate max-w-[300px]`,children:e.title||`Untitled`}),e.tagline&&(0,b.jsx)(`span`,{className:`text-[10px] text-base-content/30 truncate max-w-[300px]`,children:e.tagline})]})}),(0,b.jsx)(`td`,{className:`py-2 pr-3`,children:(0,b.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,b.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full `+Ib[e.status]}),(0,b.jsx)(`span`,{className:`text-[11px] font-mono text-base-content/60`,children:RQe[e.status]})]})}),(0,b.jsx)(`td`,{className:`py-2 pr-3`,children:(0,b.jsx)(`span`,{className:`text-[11px] font-mono `+Lb[e.priority],children:e.priority})}),(0,b.jsx)(`td`,{className:`py-2 pr-3`,children:(0,b.jsx)(`span`,{className:`text-[11px] font-mono text-base-content/40`,children:e.estimatedEffort})}),(0,b.jsx)(`td`,{className:`py-2`,children:(0,b.jsx)(`span`,{className:`text-[10px] font-mono text-base-content/30`,children:BQe(e.updatedAt)})})]},e.id)})})]})})]})}var HQe=[{status:`draft`,label:`Draft`,color:`text-info`,borderColor:`border-info/40`},{status:`in-progress`,label:`In Progress`,color:`text-warning`,borderColor:`border-warning/40`},{status:`on-hold`,label:`On Hold`,color:`text-base-content/50`,borderColor:`border-base-content/20`},{status:`completed`,label:`Completed`,color:`text-success`,borderColor:`border-success/40`}];function UQe({specs:e,onSelectSpec:t}){var n=(0,x.useMemo)(function(){for(var t={draft:[],"in-progress":[],"on-hold":[],completed:[]},n=0;n<e.length;n++){var r=e[n];t[r.status]&&t[r.status].push(r)}return t},[e]);return(0,b.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 xl:grid-cols-4 gap-4 h-full`,children:HQe.map(function(e){var r=n[e.status];return(0,b.jsxs)(`div`,{className:`flex flex-col min-h-0`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2 pb-2 mb-2 border-b-2 `+e.borderColor,children:[(0,b.jsx)(`span`,{className:`text-[12px] font-mono font-bold `+e.color,children:e.label}),(0,b.jsx)(`span`,{className:`text-[10px] font-mono text-base-content/30 bg-base-content/5 px-1.5 rounded-full`,children:r.length})]}),(0,b.jsx)(`div`,{className:`flex flex-col gap-2 overflow-y-auto flex-1`,children:r.map(function(e){return(0,b.jsx)(Ive,{spec:e,onClick:function(){t(e)}},e.id)})})]},e.status)})})}function WQe(){try{var e=localStorage.getItem(`lattice:specs:viewMode`);if(e===`list`||e===`board`)return e}catch{}return`list`}function GQe(){var{send:e,subscribe:t,unsubscribe:n}=R(),{activeProjectSlug:r}=jy(),i=_b(),[a,o]=(0,x.useState)([]),[s,c]=(0,x.useState)(!0),[l,u]=(0,x.useState)(WQe),[d,f]=(0,x.useState)(`in-progress`),[p,m]=(0,x.useState)(null),h=(0,x.useCallback)(function(e){if(e.type===`specs:list_result`){o(e.specs),c(!1);return}if(e.type===`specs:created`){o(function(t){return[...t,e.spec]});return}if(e.type===`specs:updated`||e.type===`specs:session_linked`||e.type===`specs:session_unlinked`||e.type===`specs:activity_added`){o(function(t){return t.map(function(t){return t.id===e.spec.id?e.spec:t})});return}if(e.type===`specs:deleted`){o(function(t){return t.filter(function(t){return t.id!==e.id})}),p===e.id&&m(null);return}},[p]);(0,x.useEffect)(function(){return c(!0),t(`specs:list_result`,h),t(`specs:created`,h),t(`specs:updated`,h),t(`specs:deleted`,h),t(`specs:session_linked`,h),t(`specs:session_unlinked`,h),t(`specs:activity_added`,h),e({type:`specs:list`,projectSlug:r??void 0}),function(){n(`specs:list_result`,h),n(`specs:created`,h),n(`specs:updated`,h),n(`specs:deleted`,h),n(`specs:session_linked`,h),n(`specs:session_unlinked`,h),n(`specs:activity_added`,h)}},[e,t,n,h,r]);function g(e){u(e);try{localStorage.setItem(`lattice:specs:viewMode`,e)}catch{}}function _(){e({type:`specs:create`,projectSlug:r??``,title:`Untitled Spec`})}function v(e){m(e.id)}var y=p?a.find(function(e){return e.id===p}):null;return y?(0,b.jsx)(LQe,{spec:y,onBack:function(){m(null)}}):(0,b.jsxs)(`div`,{className:`flex flex-col h-full bg-base-100`,children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b border-base-content/15 flex-shrink-0`,children:[(0,b.jsx)(`span`,{className:`text-[13px] font-semibold text-base-content`,children:`Specs`}),(0,b.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,b.jsxs)(`div`,{className:`flex items-center bg-base-200 rounded-lg p-0.5`,children:[(0,b.jsx)(`button`,{type:`button`,onClick:function(){g(`list`)},className:`p-1 rounded transition-colors `+(l===`list`?`bg-base-300 text-base-content`:`text-base-content/30 hover:text-base-content/60`),"aria-label":`List view`,children:(0,b.jsx)(x_,{size:14})}),(0,b.jsx)(`button`,{type:`button`,onClick:function(){g(`board`)},className:`p-1 rounded transition-colors `+(l===`board`?`bg-base-300 text-base-content`:`text-base-content/30 hover:text-base-content/60`),"aria-label":`Board view`,children:(0,b.jsx)(Mg,{size:14})})]}),(0,b.jsxs)(`button`,{type:`button`,onClick:_,disabled:!i,className:`btn btn-primary btn-xs gap-1`,children:[(0,b.jsx)(tv,{size:12}),`New Spec`]})]})]}),(0,b.jsx)(`div`,{className:`flex-1 overflow-auto p-4`,children:s?(0,b.jsxs)(`div`,{className:`flex flex-col gap-3 mt-2`,children:[(0,b.jsx)(`div`,{className:`h-12 bg-base-content/10 animate-pulse rounded`}),(0,b.jsx)(`div`,{className:`h-12 bg-base-content/10 animate-pulse rounded`}),(0,b.jsx)(`div`,{className:`h-12 bg-base-content/10 animate-pulse rounded`})]}):a.length===0?(0,b.jsxs)(`div`,{className:`flex flex-col items-center justify-center text-center mt-16 gap-3`,children:[(0,b.jsx)(bd,{size:28,className:`text-base-content/15`}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-[13px] text-base-content/40`,children:`No specs yet`}),(0,b.jsx)(`div`,{className:`text-[11px] text-base-content/30 mt-1`,children:`Track features, bugs, and tasks with detailed specs.`})]}),(0,b.jsx)(`button`,{type:`button`,onClick:_,disabled:!i,className:`btn btn-primary btn-sm mt-2`,children:`Create your first spec`})]}):l===`list`?(0,b.jsx)(VQe,{specs:a,onSelectSpec:v,filter:d,onFilterChange:f}):(0,b.jsx)(UQe,{specs:a,onSelectSpec:v})})]})}function A7({paneId:e}){var t=Ub(),n=Vb(),[r,i]=(0,x.useState)(null);if(!t.isDragging)return null;if(t.sourcePaneId===e&&n.panes.length<2){var a=n.panes.find(function(t){return t.id===e});if(a&&a.tabIds.length<2)return null}var o=n.panes.length>=2,s=t.sourcePaneId===e,c,l;if(o?(c=!1,l=!s):(c=!0,l=!1),s&&!o){var u=n.panes.find(function(e){return e.id===t.sourcePaneId});u&&u.tabIds.length<2&&(c=!1)}if(!c&&!l)return null;function d(e,t){e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect=`move`,i(t)}function f(e){var t=e.relatedTarget;t&&e.currentTarget.contains(t)||i(null)}function p(r,a){r.preventDefault(),r.stopPropagation(),!(!t.draggedTabId||!t.sourcePaneId)&&(a===`center`&&!s?n.moveTabToPane(t.draggedTabId,t.sourcePaneId,e):a===`left`?n.splitPane(t.draggedTabId,`horizontal`,`before`):a===`right`?n.splitPane(t.draggedTabId,`horizontal`,`after`):a===`top`?n.splitPane(t.draggedTabId,`vertical`,`before`):a===`bottom`&&n.splitPane(t.draggedTabId,`vertical`,`after`),i(null),t.endDrag())}var m=`flex items-center justify-center rounded-lg border-2 border-dashed transition-colors duration-150 text-xs font-semibold font-mono pointer-events-auto`,h=`border-primary/30 bg-primary/5 text-primary/40`,g=`border-primary/60 bg-primary/20 text-primary/80`;return(0,b.jsx)(`div`,{className:`absolute inset-0 z-50 pointer-events-none`,onDragLeave:f,children:(0,b.jsxs)(`div`,{className:`w-full h-full grid gap-1 p-2`,style:{gridTemplateColumns:c?`48px 1fr 48px`:`1fr`,gridTemplateRows:c?`40px 1fr 40px`:`1fr`},children:[c&&(0,b.jsx)(`div`,{className:m+` col-span-3 `+(r===`top`?g:h),onDragOver:function(e){d(e,`top`)},onDrop:function(e){p(e,`top`)},children:`Split Up`}),c&&(0,b.jsx)(`div`,{className:m+` `+(r===`left`?g:h),style:{writingMode:`vertical-lr`},onDragOver:function(e){d(e,`left`)},onDrop:function(e){p(e,`left`)},children:`Split Left`}),(c||l)&&(0,b.jsx)(`div`,{className:m+` `+(r===`center`?`border-info/60 bg-info/20 text-info/80`:`border-info/30 bg-info/5 text-info/40`),onDragOver:function(e){d(e,`center`)},onDrop:function(e){p(e,`center`)},children:l?`Move Here`:``}),c&&(0,b.jsx)(`div`,{className:m+` `+(r===`right`?g:h),style:{writingMode:`vertical-lr`},onDragOver:function(e){d(e,`right`)},onDrop:function(e){p(e,`right`)},children:`Split Right`}),c&&(0,b.jsx)(`div`,{className:m+` col-span-3 `+(r===`bottom`?g:h),onDragOver:function(e){d(e,`bottom`)},onDrop:function(e){p(e,`bottom`)},children:`Split Down`})]})})}var j7={files:cP,terminal:KN,notes:uP,tasks:_P,bookmarks:yP,brainstorm:CP,analytics:jQ,specs:GQe},KQe=[{type:`chat`,icon:U_,label:`Chat`,hint:`New session`},{type:`files`,icon:Wm,label:`Files`,hint:`Browse project`},{type:`terminal`,icon:vv,label:`Terminal`,hint:`Shell access`},{type:`notes`,icon:bv,label:`Notes`,hint:`Project notes`},{type:`specs`,icon:bd,label:`Specs`,hint:`Design specs`},{type:`analytics`,icon:Il,label:`Analytics`,hint:`Usage data`}];function qQe(){return(0,b.jsx)(`div`,{className:`flex-1 flex items-center justify-center min-h-0`,children:(0,b.jsxs)(`div`,{className:`flex flex-col items-center gap-8 max-w-md px-6`,children:[(0,b.jsxs)(`div`,{className:`flex flex-col items-center gap-2`,children:[(0,b.jsx)(`span`,{className:`font-mono text-[11px] font-bold tracking-widest uppercase text-base-content/30`,children:`No open tabs`}),(0,b.jsx)(`span`,{className:`text-[13px] text-base-content/40`,children:`Select a session from the sidebar or open a workspace tool.`})]}),(0,b.jsx)(`div`,{className:`grid grid-cols-3 gap-1.5 w-full max-w-xs`,children:KQe.map(function(e){return(0,b.jsxs)(`button`,{onClick:function(){Wv(e.type)},className:`group flex flex-col items-center gap-1 px-3 py-3 rounded-lg border border-base-content/10 hover:border-base-content/20 hover:bg-base-200/50 transition-colors cursor-pointer`,children:[(0,b.jsx)(e.icon,{size:16,className:`text-base-content/30 group-hover:text-base-content/60 transition-colors`}),(0,b.jsx)(`span`,{className:`font-mono text-[11px] font-medium text-base-content/50 group-hover:text-base-content/70 transition-colors`,children:e.label}),(0,b.jsx)(`span`,{className:`text-[10px] text-base-content/25 group-hover:text-base-content/40 transition-colors`,children:e.hint})]},e.type)})})]})})}function M7({pane:e,tabs:t,isActive:n,onFocus:r}){var i=_b(),a=e.tabIds.map(function(e){return t.find(function(t){return t.id===e})}).filter(function(e){return e!=null});return(0,b.jsxs)(`div`,{className:`flex flex-col h-full w-full overflow-hidden`,onClick:r,children:[(0,b.jsx)(Wb,{paneId:e.id,isActivePane:n}),!i&&(0,b.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 bg-warning/10 border-b border-warning/20 flex-shrink-0`,children:[(0,b.jsx)(Av,{size:13,className:`text-warning flex-shrink-0`}),(0,b.jsx)(`span`,{className:`text-[12px] text-warning`,children:`Disconnected — viewing only`})]}),(0,b.jsxs)(`div`,{className:`flex-1 min-h-0 relative`,children:[(0,b.jsx)(A7,{paneId:e.id}),a.map(function(t){var n=t.id===e.activeTabId;if(t.type===`chat`)return(0,b.jsx)(`div`,{className:`absolute inset-0`,style:{display:n?`flex`:`none`,flexDirection:`column`},children:(0,b.jsx)(BT,{sessionId:t.sessionId,projectSlug:t.projectSlug})},t.id);var r=j7[t.type];return r?(0,b.jsx)(`div`,{className:`absolute inset-0`,style:{display:n?`flex`:`none`,flexDirection:`column`},children:(0,b.jsx)(r,{})},t.id):null})]})]})}function JQe(){var{tabs:e,panes:t,activePaneId:n,splitDirection:r,splitRatio:i,setSplitRatio:a,setActivePaneId:o}=Vb(),s=_b();if(!r||t.length<2){var c=t[0],l=e.length>0&&c&&c.tabIds.length>0;return(0,b.jsxs)(`div`,{className:`flex flex-col h-full w-full overflow-hidden`,children:[l&&(0,b.jsx)(Wb,{paneId:c?.id}),!s&&(0,b.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 bg-warning/10 border-b border-warning/20 flex-shrink-0 order-0 sm:order-none`,children:[(0,b.jsx)(Av,{size:13,className:`text-warning flex-shrink-0`}),(0,b.jsx)(`span`,{className:`text-[12px] text-warning`,children:`Disconnected — viewing only`})]}),l?(0,b.jsxs)(`div`,{className:`flex-1 min-h-0 relative order-0 sm:order-none`,children:[(0,b.jsx)(A7,{paneId:c?.id||`pane-1`}),e.map(function(e){var t=c?e.id===c.activeTabId:e.id===`chat`;if(e.type===`chat`)return(0,b.jsx)(`div`,{className:`absolute inset-0`,style:{display:t?`flex`:`none`,flexDirection:`column`},children:(0,b.jsx)(BT,{sessionId:e.sessionId,projectSlug:e.projectSlug})},e.id);var n=j7[e.type];return n?(0,b.jsx)(`div`,{className:`absolute inset-0`,style:{display:t?`flex`:`none`,flexDirection:`column`},children:(0,b.jsx)(n,{})},e.id):null})]}):(0,b.jsx)(qQe,{})]})}return(0,b.jsxs)(Uve,{direction:r,ratio:i,onRatioChange:a,children:[(0,b.jsx)(M7,{pane:t[0],tabs:e,isActive:n===t[0].id,onFocus:function(){o(t[0].id)}}),(0,b.jsx)(M7,{pane:t[1],tabs:e,isActive:n===t[1].id,onFocus:function(){o(t[1].id)}})]})}function YQe(){return(0,b.jsx)(Vve,{children:(0,b.jsx)(JQe,{})})}var XQe=[`dracula`,`catppuccin-mocha`,`tokyo-night`,`one-dark`,`amoled`],ZQe=[`ayu-light`,`catppuccin-latte`,`github-light`,`one-light`,`rose-pine-dawn`],N7=6;function QQe(e){var[t,n]=(0,x.useState)(1),[r,i]=(0,x.useState)(1),[a,o]=(0,x.useState)(!1),[s,c]=(0,x.useState)(``),[l,u]=(0,x.useState)(``),[d,f]=(0,x.useState)(``),[p,m]=(0,x.useState)(``),[h,g]=(0,x.useState)(``),[_,v]=(0,x.useState)(``),[y,S]=(0,x.useState)([]),C=Mb(),w=R();function T(e){a||(i(t),o(!0),setTimeout(function(){n(e),o(!1)},180))}function E(){T(Math.min(t+1,N7))}function D(){T(Math.max(t-1,1))}function O(){E()}function k(){var e=s.trim();e.length>0&&(w.send({type:`settings:update`,settings:{name:e}}),S(function(t){return[...t.filter(function(e){return e!==`name`}),`name: `+e]})),E()}function A(){S(function(e){var t=`theme: `+C.currentThemeId+` (`+C.mode+`)`;return[...e.filter(function(e){return!e.startsWith(`theme:`)}),t]}),E()}function j(){if(l.length===0){E();return}if(l!==d){m(`Passphrases do not match`);return}w.send({type:`settings:update`,settings:{passphraseHash:l}}),S(function(e){return[...e.filter(function(e){return e!==`security`}),`security: passphrase set`]}),E()}function M(){var e=h.trim();if(e.length>0){var t=e.replace(/\/+$/,``).split(`/`).pop()||e,n=_.trim()||t;w.send({type:`settings:update`,settings:{projects:[{path:e,slug:``,title:n,env:{}}]}}),S(function(e){return[...e.filter(function(e){return!e.startsWith(`project:`)}),`project: `+n]})}E()}function N(){w.send({type:`settings:update`,settings:{setupComplete:!0}}),e.onComplete()}var ee=kb.filter(function(e){return XQe.includes(e.id)}),te=kb.filter(function(e){return ZQe.includes(e.id)}),P=t>r;return(0,b.jsxs)(`div`,{className:`fixed inset-0 z-[9999] flex items-center justify-center bg-base-100 transition-colors duration-300`,children:[(0,b.jsx)(`style`,{children:o$e}),t===1?(0,b.jsxs)(`div`,{className:`relative w-full max-w-[520px] px-6 py-12 flex flex-col items-center text-center`,children:[(0,b.jsx)(`div`,{className:`fixed inset-0 pointer-events-none z-0`,"aria-hidden":`true`,style:{backgroundImage:`linear-gradient(oklch(from var(--color-primary) l c h / 0.07) 1px, transparent 1px), linear-gradient(90deg, oklch(from var(--color-primary) l c h / 0.07) 1px, transparent 1px)`,backgroundSize:`40px 40px`,animation:`wizard-grid-shift 8s linear infinite`}}),(0,b.jsxs)(`div`,{className:`relative z-[1] flex flex-col items-center gap-0`,children:[(0,b.jsx)(`div`,{className:`wizard-fade-in text-primary`,style:{animationDelay:`0ms`},children:(0,b.jsx)(Iv,{size:64})}),(0,b.jsx)(`h1`,{className:`wizard-fade-in font-mono font-bold text-base-content leading-none mt-5 mb-0`,style:{fontSize:`clamp(48px, 10vw, 72px)`,letterSpacing:`-0.04em`,animationDelay:`80ms`},children:`Lattice`}),(0,b.jsx)(`p`,{className:`wizard-fade-in text-[17px] text-base-content/60 mt-3 mb-8 tracking-[0.01em]`,style:{animationDelay:`160ms`},children:`One dashboard. Every machine.`}),(0,b.jsx)(`div`,{className:`wizard-fade-in`,style:{animationDelay:`240ms`},children:(0,b.jsx)($Qe,{})}),(0,b.jsx)(`div`,{className:`wizard-fade-in`,style:{animationDelay:`320ms`},children:(0,b.jsxs)(`button`,{onClick:E,className:`wizard-btn-primary btn btn-primary inline-flex items-center gap-2 mt-7 h-[52px] px-8 text-[15px] font-semibold cursor-pointer`,children:[`Get Started`,(0,b.jsx)(Ta,{size:16})]})}),(0,b.jsx)(`p`,{className:`wizard-fade-in text-[12px] text-base-content/30 mt-4`,style:{animationDelay:`380ms`},children:`Takes about 2 minutes`})]})]}):(0,b.jsxs)(`div`,{className:`w-[480px] max-w-[calc(100vw-24px)] bg-base-200 border border-base-300 rounded-xl flex flex-col overflow-hidden shadow-2xl`,children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between px-6 py-4 border-b border-base-300 bg-base-100`,children:[(0,b.jsx)(`div`,{className:`flex items-center gap-1.5`,children:Array.from({length:N7-1},function(e,n){var r=n+2,i=t>r,a=t===r;return(0,b.jsx)(`div`,{className:`h-1.5 rounded-full transition-all duration-[250ms]`,style:{background:i||a?`var(--color-primary)`:`var(--color-base-300)`,opacity:a?1:i?.7:.35,width:a?`24px`:`8px`}},n)})}),(0,b.jsxs)(`span`,{className:`text-[11px] text-base-content/40 font-mono tracking-[0.06em]`,children:[t-1,` / `,N7-1]})]}),(0,b.jsxs)(`div`,{className:`px-7 pt-7 pb-2 flex-1 min-h-[320px] `+(a?P?`wizard-slide-out-left`:`wizard-slide-out-right`:P?`wizard-slide-in-right`:`wizard-slide-in-left`),children:[t===2&&(0,b.jsx)(e$e,{value:s,onChange:c}),t===3&&(0,b.jsx)(t$e,{theme:C,darkQuickPicks:ee,lightQuickPicks:te}),t===4&&(0,b.jsx)(n$e,{passphrase:l,passphraseConfirm:d,error:p,onPassphraseChange:function(e){u(e),m(``)},onConfirmChange:function(e){f(e),m(``)}}),t===5&&(0,b.jsx)(i$e,{path:h,title:_,onPathChange:g,onTitleChange:v}),t===6&&(0,b.jsx)(a$e,{configured:y})]},t),(0,b.jsxs)(`div`,{className:`flex items-center gap-2 px-6 py-4 border-t border-base-300 bg-base-100`,children:[t>=2&&t<N7&&(0,b.jsxs)(`button`,{onClick:D,className:`wizard-btn-back btn btn-ghost btn-sm gap-1 text-base-content/40`,children:[(0,b.jsx)(su,{size:14}),`Back`]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2 ml-auto`,children:[t===2&&(0,b.jsx)(`button`,{onClick:O,className:`wizard-btn-skip btn btn-ghost btn-sm text-base-content/40`,children:`Skip`}),t===3&&(0,b.jsxs)(`button`,{onClick:A,className:`wizard-btn-primary btn btn-primary btn-sm gap-1`,children:[`Continue`,(0,b.jsx)(cu,{size:14})]}),t===4&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`button`,{onClick:O,className:`wizard-btn-skip btn btn-ghost btn-sm text-base-content/40`,children:`Skip`}),(0,b.jsxs)(`button`,{onClick:j,className:`wizard-btn-primary btn btn-primary btn-sm gap-1`,children:[`Continue`,(0,b.jsx)(cu,{size:14})]})]}),t===5&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`button`,{onClick:O,className:`wizard-btn-skip btn btn-ghost btn-sm text-base-content/40`,children:`Skip`}),(0,b.jsxs)(`button`,{onClick:M,className:`wizard-btn-primary btn btn-primary btn-sm gap-1`,children:[`Add & Continue`,(0,b.jsx)(cu,{size:14})]})]}),t===6&&(0,b.jsxs)(`button`,{onClick:N,className:`wizard-btn-done btn btn-success btn-sm gap-2 font-bold`,children:[`Open Dashboard`,(0,b.jsx)(Ta,{size:16})]}),t===2&&(0,b.jsxs)(`button`,{onClick:k,className:`wizard-btn-primary btn btn-primary btn-sm gap-1`,children:[`Continue`,(0,b.jsx)(cu,{size:14})]})]})]})]})]})}function $Qe(){var[e,t]=(0,x.useState)(0),n=[{prefix:`$ `,text:`lattice`,color:`var(--color-base-content)`},{prefix:``,text:` [lattice] Daemon started (PID 4821)`,color:`oklch(from var(--color-base-content) l c h / 0.5)`},{prefix:``,text:` [lattice] Listening on https://0.0.0.0:7654`,color:`var(--color-success)`},{prefix:``,text:` [discovery] Found 2 nodes on mesh`,color:`var(--color-primary)`}];return(0,x.useEffect)(function(){var e=[];return n.forEach(function(n,r){e.push(setTimeout(function(){t(r+1)},600+r*600))}),function(){e.forEach(clearTimeout)}},[]),(0,b.jsxs)(`div`,{className:`w-[380px] max-w-[calc(100vw-48px)] bg-base-200 border border-base-300 rounded-xl overflow-hidden shadow-2xl`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-1.5 px-3.5 py-2.5 bg-base-300 border-b border-base-300`,children:[(0,b.jsx)(`span`,{className:`w-2.5 h-2.5 rounded-full bg-error opacity-80 flex-shrink-0`}),(0,b.jsx)(`span`,{className:`w-2.5 h-2.5 rounded-full bg-warning opacity-80 flex-shrink-0`}),(0,b.jsx)(`span`,{className:`w-2.5 h-2.5 rounded-full bg-success opacity-80 flex-shrink-0`}),(0,b.jsx)(`span`,{className:`text-[11px] text-base-content/40 font-mono mx-auto tracking-[0.02em]`,children:`lattice — zsh`})]}),(0,b.jsxs)(`div`,{className:`px-4 py-3.5 flex flex-col gap-1 min-h-[96px]`,children:[n.map(function(t,n){return(0,b.jsxs)(`div`,{className:`text-[12px] font-mono leading-relaxed whitespace-pre transition-all duration-200`,style:{opacity:n<e?1:0,transform:n<e?`translateY(0)`:`translateY(4px)`,color:t.color},children:[t.prefix&&(0,b.jsx)(`span`,{style:{color:`var(--color-primary)`},children:t.prefix}),(0,b.jsx)(`span`,{children:t.text})]},n)}),(0,b.jsxs)(`div`,{className:`flex items-center gap-0.5 text-[12px] font-mono mt-0.5`,children:[(0,b.jsx)(`span`,{style:{color:`var(--color-primary)`},children:`$ `}),(0,b.jsx)(`span`,{className:`inline-block w-2 h-3.5 rounded-[1px] align-middle opacity-90`,style:{background:`var(--color-primary)`,animation:`wizard-cursor-blink 1s step-end infinite`}})]})]})]})}function e$e(e){var t=e.value.trim()||`this-machine`;return(0,b.jsxs)(`div`,{className:`flex flex-col`,children:[(0,b.jsx)(`div`,{className:`flex items-center mb-3.5`,children:(0,b.jsx)(mv,{size:22,className:`text-primary`})}),(0,b.jsx)(`h2`,{className:`font-mono text-[22px] font-bold text-base-content tracking-tight mb-2 leading-tight`,children:`Name this machine`}),(0,b.jsx)(`p`,{className:`text-[13px] text-base-content/60 leading-relaxed mb-5`,children:`Give this node a recognizable name. It appears in your mesh when you connect multiple computers.`}),(0,b.jsxs)(`fieldset`,{className:`fieldset mb-3.5`,children:[(0,b.jsx)(`legend`,{className:`fieldset-legend text-[11px] font-semibold text-base-content/40 uppercase tracking-[0.08em]`,children:`Machine name`}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2 bg-base-300 border border-base-content/20 rounded-md px-3 h-[44px] focus-within:border-primary transition-colors duration-[120ms]`,children:[(0,b.jsx)(`span`,{className:`text-primary font-mono font-bold text-[16px]`,children:`>`}),(0,b.jsx)(`input`,{type:`text`,value:e.value,onChange:function(t){e.onChange(t.target.value)},placeholder:`my-laptop`,"aria-label":`Machine name`,className:`flex-1 bg-transparent text-base-content font-mono text-[14px] outline-none`,autoFocus:!0,spellCheck:!1})]})]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 bg-base-300 border border-base-content/10 rounded-md`,children:[(0,b.jsx)(`span`,{className:`text-[10px] uppercase tracking-[0.08em] text-base-content/40 font-semibold`,children:`Preview`}),(0,b.jsx)(`span`,{className:`font-mono text-[13px] font-semibold text-base-content`,children:t}),(0,b.jsx)(`span`,{className:`text-base-content/30 text-[12px]`,children:`will appear on your mesh`})]})]})}function t$e(e){var{theme:t,darkQuickPicks:n,lightQuickPicks:r}=e,i=t.mode===`dark`?n:r;return(0,b.jsxs)(`div`,{className:`flex flex-col`,children:[(0,b.jsx)(`div`,{className:`flex items-center mb-3.5`,children:(0,b.jsx)(X_,{size:22,className:`text-primary`})}),(0,b.jsx)(`h2`,{className:`font-mono text-[22px] font-bold text-base-content tracking-tight mb-2 leading-tight`,children:`Choose appearance`}),(0,b.jsx)(`p`,{className:`text-[13px] text-base-content/60 leading-relaxed mb-4`,children:`Pick a color theme. You can always change this in settings.`}),(0,b.jsxs)(`div`,{className:`flex gap-1.5 mb-4 p-1 bg-base-300 rounded-lg w-fit`,children:[(0,b.jsxs)(`button`,{onClick:function(){t.mode!==`dark`&&t.toggleMode()},className:`flex items-center gap-1.5 px-3 py-1.5 rounded-md text-[13px] font-medium transition-all duration-[120ms] cursor-pointer `+(t.mode===`dark`?`bg-primary text-primary-content`:`text-base-content/60 hover:text-base-content`),children:[(0,b.jsx)(q_,{size:13}),`Dark`]}),(0,b.jsxs)(`button`,{onClick:function(){t.mode!==`light`&&t.toggleMode()},className:`flex items-center gap-1.5 px-3 py-1.5 rounded-md text-[13px] font-medium transition-all duration-[120ms] cursor-pointer `+(t.mode===`light`?`bg-primary text-primary-content`:`text-base-content/60 hover:text-base-content`),children:[(0,b.jsx)(Sv,{size:13}),`Light`]})]}),(0,b.jsx)(`div`,{className:`grid gap-2 mb-4`,style:{gridTemplateColumns:`repeat(auto-fill, minmax(80px, 1fr))`},children:i.map(function(e){var n=e.id===t.currentThemeId,r=`#`+e.theme.base00,i=`#`+e.theme.base0D,a=`#`+e.theme.base05,o=`#`+e.theme.base08,s=`#`+e.theme.base0B;return(0,b.jsxs)(`button`,{onClick:function(){t.setTheme(e.id)},title:e.theme.name,className:`relative flex flex-col gap-1.5 p-0 rounded-md overflow-hidden cursor-pointer border-2 transition-all duration-[120ms] `+(n?`border-primary`:`border-transparent hover:border-base-content/20`),children:[(0,b.jsxs)(`div`,{className:`w-full h-[48px] flex flex-col`,style:{background:r},children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-1 px-1.5 py-1`,style:{background:`#`+e.theme.base01},children:[(0,b.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full`,style:{background:o}}),(0,b.jsx)(`span`,{className:`w-6 h-1 rounded`,style:{background:i,opacity:.7}})]}),(0,b.jsxs)(`div`,{className:`flex flex-col gap-[3px] px-1.5 py-1`,children:[(0,b.jsx)(`div`,{className:`h-[3px] rounded w-[80%]`,style:{background:i,opacity:.8}}),(0,b.jsx)(`div`,{className:`h-[3px] rounded w-[60%]`,style:{background:a,opacity:.4}}),(0,b.jsx)(`div`,{className:`h-[3px] rounded w-[70%]`,style:{background:s,opacity:.6}})]})]}),(0,b.jsx)(`span`,{className:`text-[10px] text-base-content/60 truncate px-1.5 pb-1`,children:e.theme.name}),n&&(0,b.jsx)(`div`,{className:`absolute top-1 right-1 w-3.5 h-3.5 rounded-full bg-primary flex items-center justify-center`,children:(0,b.jsx)(L,{size:8,className:`text-primary-content`})})]},e.id)})}),(0,b.jsxs)(`div`,{className:`rounded-lg border border-base-300 overflow-hidden transition-all duration-300`,children:[(0,b.jsx)(`div`,{className:`text-[9px] font-mono tracking-[0.05em] uppercase text-base-content/40 px-2.5 py-1.5 bg-base-300 border-b border-base-300 transition-all duration-300`,children:`Preview`}),(0,b.jsxs)(`div`,{className:`flex h-[100px] bg-base-100 transition-all duration-300`,children:[(0,b.jsxs)(`div`,{className:`w-[72px] flex-shrink-0 border-r border-base-300 p-2 flex flex-col gap-1`,children:[(0,b.jsx)(`div`,{className:`text-[8px] font-mono text-base-content/30 uppercase tracking-[0.05em] mb-0.5`,children:`Projects`}),(0,b.jsx)(`div`,{className:`h-1.5 w-[90%] rounded bg-primary opacity-80`}),(0,b.jsx)(`div`,{className:`h-1.5 w-[70%] rounded bg-base-300`}),(0,b.jsx)(`div`,{className:`h-1.5 w-[80%] rounded bg-base-300`})]}),(0,b.jsxs)(`div`,{className:`flex-1 p-2.5 flex flex-col gap-1.5`,children:[(0,b.jsx)(`div`,{className:`text-[9px] font-mono font-semibold text-base-content`,children:`New Session`}),(0,b.jsx)(`div`,{className:`flex-1 flex flex-col gap-[3px] justify-center`,children:(0,b.jsxs)(`div`,{className:`flex gap-1 items-start`,children:[(0,b.jsx)(`div`,{className:`w-3 h-3 rounded-full bg-primary flex-shrink-0 opacity-60`}),(0,b.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,b.jsx)(`div`,{className:`h-1 w-[120px] rounded bg-base-content/20`}),(0,b.jsx)(`div`,{className:`h-1 w-[80px] rounded bg-base-content/15`})]})]})}),(0,b.jsx)(`div`,{className:`h-[18px] rounded bg-base-200 border border-base-300`})]})]})]})]})}function n$e(e){var t=r$e(e.passphrase);return(0,b.jsxs)(`div`,{className:`flex flex-col`,children:[(0,b.jsx)(`div`,{className:`flex items-center mb-3.5`,children:(0,b.jsx)(M_,{size:22,className:`text-primary`})}),(0,b.jsx)(`h2`,{className:`font-mono text-[22px] font-bold text-base-content tracking-tight mb-2 leading-tight`,children:`Set a passphrase`}),(0,b.jsxs)(`div`,{className:`flex gap-2 p-3 bg-base-300 border border-base-300 rounded-md mb-4`,children:[(0,b.jsx)(Zh,{size:16,className:`text-base-content/40 flex-shrink-0 mt-[1px]`}),(0,b.jsx)(`p`,{className:`text-[12px] text-base-content/50 leading-relaxed`,children:`Optional. Protects your dashboard on shared networks. Node-to-node connections use separate key-based auth.`})]}),(0,b.jsxs)(`fieldset`,{className:`fieldset mb-3.5`,children:[(0,b.jsx)(`legend`,{className:`fieldset-legend text-[11px] font-semibold text-base-content/40 uppercase tracking-[0.08em]`,children:`Passphrase`}),(0,b.jsx)(`input`,{type:`password`,value:e.passphrase,onChange:function(t){e.onPassphraseChange(t.target.value)},placeholder:`Leave blank to skip`,"aria-label":`Passphrase`,className:`input input-bordered w-full bg-base-300 text-base-content text-[14px] focus:border-primary`,autoFocus:!0}),e.passphrase.length>0&&(0,b.jsxs)(`div`,{className:`flex items-center gap-2 mt-1.5`,children:[(0,b.jsx)(`div`,{className:`flex-1 h-1 bg-base-300 rounded-full overflow-hidden`,children:(0,b.jsx)(`div`,{className:`h-full rounded-full transition-all duration-200`,style:{width:t.pct+`%`,background:t.color}})}),(0,b.jsx)(`span`,{className:`text-[11px] font-semibold`,style:{color:t.color},children:t.label})]})]}),e.passphrase.length>0&&(0,b.jsxs)(`fieldset`,{className:`fieldset mb-3.5`,children:[(0,b.jsx)(`legend`,{className:`fieldset-legend text-[11px] font-semibold text-base-content/40 uppercase tracking-[0.08em]`,children:`Confirm passphrase`}),(0,b.jsx)(`input`,{type:`password`,value:e.passphraseConfirm,onChange:function(t){e.onConfirmChange(t.target.value)},placeholder:`Repeat passphrase`,"aria-label":`Confirm passphrase`,className:`input input-bordered w-full bg-base-300 text-base-content text-[14px] focus:border-primary `+(e.error?`border-error`:``)})]}),e.error&&(0,b.jsx)(`p`,{className:`text-[12px] text-error mt-1`,children:e.error})]})}function r$e(e){return e.length===0?{pct:0,label:``,color:`oklch(from var(--color-base-content) l c h / 0.5)`}:e.length<8?{pct:25,label:`Weak`,color:`var(--color-error)`}:e.length<14?{pct:55,label:`Fair`,color:`var(--color-warning)`}:e.length<20?{pct:80,label:`Good`,color:`var(--color-primary)`}:{pct:100,label:`Strong`,color:`var(--color-success)`}}function i$e(e){return(0,b.jsxs)(`div`,{className:`flex flex-col`,children:[(0,b.jsx)(`div`,{className:`flex items-center mb-3.5`,children:(0,b.jsx)(Gm,{size:22,className:`text-primary`})}),(0,b.jsx)(`h2`,{className:`font-mono text-[22px] font-bold text-base-content tracking-tight mb-2 leading-tight`,children:`Add your first project`}),(0,b.jsx)(`p`,{className:`text-[13px] text-base-content/60 leading-relaxed mb-5`,children:`Point Lattice at a local directory. Claude runs inside that workspace. Add more projects from the sidebar anytime.`}),(0,b.jsxs)(`fieldset`,{className:`fieldset mb-3.5`,children:[(0,b.jsx)(`legend`,{className:`fieldset-legend text-[11px] font-semibold text-base-content/40 uppercase tracking-[0.08em]`,children:`Project path`}),(0,b.jsx)(`input`,{type:`text`,value:e.path,onChange:function(t){e.onPathChange(t.target.value)},placeholder:`/home/you/projects/my-app`,"aria-label":`Project path`,className:`input input-bordered w-full bg-base-300 text-base-content font-mono text-[14px] focus:border-primary`,autoFocus:!0,spellCheck:!1}),(0,b.jsx)(`p`,{className:`fieldset-label text-[11px] text-base-content/30 mt-1`,children:`Absolute path to a local directory on this machine.`})]}),(0,b.jsxs)(`fieldset`,{className:`fieldset mb-3.5`,children:[(0,b.jsxs)(`legend`,{className:`fieldset-legend text-[11px] font-semibold text-base-content/40 uppercase tracking-[0.08em]`,children:[`Display name `,(0,b.jsx)(`span`,{className:`font-normal normal-case tracking-normal`,children:`(optional)`})]}),(0,b.jsx)(`input`,{type:`text`,value:e.title,onChange:function(t){e.onTitleChange(t.target.value)},placeholder:e.path&&e.path.replace(/\/+$/,``).split(`/`).pop()||`My App`,"aria-label":`Display name`,className:`input input-bordered w-full bg-base-300 text-base-content text-[14px] focus:border-primary`})]})]})}function a$e(e){return(0,b.jsxs)(`div`,{className:`flex flex-col items-center text-center`,children:[(0,b.jsx)(`div`,{className:`wizard-check-pop mb-4`,children:(0,b.jsx)(ju,{size:36,className:`text-success`,strokeWidth:1.5,"aria-hidden":`true`})}),(0,b.jsx)(`h2`,{className:`font-mono text-[26px] font-bold text-base-content tracking-tight mb-2`,children:`You're all set`}),(0,b.jsx)(`p`,{className:`text-[13px] text-base-content/60 leading-relaxed mb-5`,children:`Lattice is configured and ready to go.`}),e.configured.length>0?(0,b.jsx)(`ul`,{className:`list-none p-0 m-0 flex flex-col gap-1.5 text-left w-full`,children:e.configured.map(function(e,t){return(0,b.jsxs)(`li`,{className:`wizard-fade-in flex items-center gap-2 bg-base-300 px-3 py-2 rounded-md`,"data-delay":t*60,children:[(0,b.jsx)(`span`,{className:`w-4 h-4 rounded-full bg-success/20 text-success flex items-center justify-center flex-shrink-0`,children:(0,b.jsx)(L,{size:10})}),(0,b.jsx)(`span`,{className:`font-mono text-[12px] text-base-content/60`,children:e})]},t)})}):(0,b.jsx)(`p`,{className:`text-[11px] text-base-content/30`,children:`Everything was skipped — configure it from settings anytime.`})]})}var o$e=`
558
+ `):``,markdownTokenizer:{name:`taskList`,level:`block`,start(e){let t=e.match(/^\s*[-+*]\s+\[([ xX])\]\s+/)?.index;return t===void 0?-1:t},tokenize(e,t,n){let r=e=>{let t=M6(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:e[3].toLowerCase()===`x`}),createToken:(e,t)=>({type:`taskItem`,raw:``,mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);return t?[{type:`taskList`,raw:t.raw,items:t.items}]:n.blockTokens(e)},i=M6(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:e[3].toLowerCase()===`x`}),createToken:(e,t)=>({type:`taskItem`,raw:``,mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);if(i)return{type:`taskList`,raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:e})=>e.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});h6.create({name:`listKit`,addExtensions(){let e=[];return this.options.bulletList!==!1&&e.push(R5.configure(this.options.bulletList)),this.options.listItem!==!1&&e.push(z5.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(Y5.configure(this.options.listKeymap)),this.options.orderedList!==!1&&e.push(e7.configure(this.options.orderedList)),this.options.taskItem!==!1&&e.push(t7.configure(this.options.taskItem)),this.options.taskList!==!1&&e.push(n7.configure(this.options.taskList)),e}});var r7=`&nbsp;`,i7=`\xA0`,GZe=P6.create({name:`paragraph`,priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:`block`,content:`inline*`,parseHTML(){return[{tag:`p`}]},renderHTML({HTMLAttributes:e}){return[`p`,R3(this.options.HTMLAttributes,e),0]},parseMarkdown:(e,t)=>{let n=e.tokens||[];if(n.length===1&&n[0].type===`image`)return t.parseChildren([n[0]]);let r=t.parseInline(n);return n.length===1&&n[0].type===`text`&&(n[0].raw===r7||n[0].text===r7||n[0].raw===i7||n[0].text===i7)&&r.length===1&&r[0].type===`text`&&(r[0].text===r7||r[0].text===i7)?t.createNode(`paragraph`,void 0,[]):t.createNode(`paragraph`,void 0,r)},renderMarkdown:(e,t,n)=>{if(!e)return``;let r=Array.isArray(e.content)?e.content:[];if(r.length===0){let e=Array.isArray(n?.previousNode?.content)?n.previousNode.content:[];return n?.previousNode?.type===`paragraph`&&e.length===0?r7:``}return t.renderChildren(r)},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),KZe=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,qZe=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,JZe=f6.create({name:`strike`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`s`},{tag:`del`},{tag:`strike`},{style:`text-decoration`,consuming:!1,getAttrs:e=>e.includes(`line-through`)?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`s`,R3(this.options.HTMLAttributes,e),0]},markdownTokenName:`del`,parseMarkdown:(e,t)=>t.applyMark(`strike`,t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>`~~${t.renderChildren(e)}~~`,addCommands(){return{setStrike:()=>({commands:e})=>e.setMark(this.name),toggleStrike:()=>({commands:e})=>e.toggleMark(this.name),unsetStrike:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[D6({find:KZe,type:this.type})]},addPasteRules(){return[F6({find:qZe,type:this.type})]}}),YZe=P6.create({name:`text`,group:`inline`,parseMarkdown:e=>({type:`text`,text:e.text||``}),renderMarkdown:e=>e.text||``}),XZe=f6.create({name:`underline`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`u`},{style:`text-decoration`,consuming:!1,getAttrs:e=>e.includes(`underline`)?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`u`,R3(this.options.HTMLAttributes,e),0]},parseMarkdown(e,t){return t.applyMark(this.name||`underline`,t.parseInline(e.tokens||[]))},renderMarkdown(e,t){return`++${t.renderChildren(e)}++`},markdownTokenizer:{name:`underline`,level:`inline`,start(e){return e.indexOf(`++`)},tokenize(e,t,n){let r=/^(\+\+)([\s\S]+?)(\+\+)/.exec(e);if(!r)return;let i=r[2].trim();return{type:`underline`,raw:r[0],text:i,tokens:n.inlineTokens(i)}}},addCommands(){return{setUnderline:()=>({commands:e})=>e.setMark(this.name),toggleUnderline:()=>({commands:e})=>e.toggleMark(this.name),unsetUnderline:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function ZZe(e={}){return new R1({view(t){return new QZe(t,e)}})}var QZe=class{constructor(e,t){this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=t.width??1,this.color=t.color===!1?void 0:t.color||`black`,this.class=t.class,this.handlers=[`dragover`,`dragend`,`drop`,`dragleave`].map(t=>{let n=e=>{this[t](e)};return e.dom.addEventListener(t,n),{name:t,handler:n}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,n,r=this.editorView.dom,i=r.getBoundingClientRect(),a=i.width/r.offsetWidth,o=i.height/r.offsetHeight;if(t){let t=e.nodeBefore,r=e.nodeAfter;if(t||r){let e=this.editorView.nodeDOM(this.cursorPos-(t?t.nodeSize:0));if(e){let i=e.getBoundingClientRect(),a=t?i.bottom:i.top;t&&r&&(a=(a+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let s=this.width/2*o;n={left:i.left,right:i.right,top:a-s,bottom:a+s}}}}if(!n){let e=this.editorView.coordsAtPos(this.cursorPos),t=this.width/2*a;n={left:e.left-t,right:e.left+t,top:e.top,bottom:e.bottom}}let s=this.editorView.dom.offsetParent;this.element||(this.element=s.appendChild(document.createElement(`div`)),this.class&&(this.element.className=this.class),this.element.style.cssText=`position: absolute; z-index: 50; pointer-events: none;`,this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle(`prosemirror-dropcursor-block`,t),this.element.classList.toggle(`prosemirror-dropcursor-inline`,!t);let c,l;if(!s||s==document.body&&getComputedStyle(s).position==`static`)c=-pageXOffset,l=-pageYOffset;else{let e=s.getBoundingClientRect(),t=e.width/s.offsetWidth,n=e.height/s.offsetHeight;c=e.left-s.scrollLeft*t,l=e.top-s.scrollTop*n}this.element.style.left=(n.left-c)/a+`px`,this.element.style.top=(n.top-l)/o+`px`,this.element.style.width=(n.right-n.left)/a+`px`,this.element.style.height=(n.bottom-n.top)/o+`px`}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),r=n&&n.type.spec.disableDropCursor,i=typeof r==`function`?r(this.editorView,t,e):r;if(t&&!i){let e=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let t=s1(this.editorView.state.doc,e,this.editorView.dragging.slice);t!=null&&(e=t)}this.setCursor(e),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}},a7=class e extends S1{constructor(e){super(e,e)}map(t,n){let r=t.resolve(n.map(this.head));return e.valid(r)?new e(r):S1.near(r)}content(){return Z.empty}eq(t){return t instanceof e&&t.head==this.head}toJSON(){return{type:`gapcursor`,pos:this.head}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for GapCursor.fromJSON`);return new e(t.resolve(n.pos))}getBookmark(){return new $Ze(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!eQe(e)||!tQe(e))return!1;let n=t.type.spec.allowGapCursor;if(n!=null)return n;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(t,n,r=!1){search:for(;;){if(!r&&e.valid(t))return t;let i=t.pos,a=null;for(let r=t.depth;;r--){let o=t.node(r);if(n>0?t.indexAfter(r)<o.childCount:t.index(r)>0){a=o.child(n>0?t.indexAfter(r):t.index(r)-1);break}else if(r==0)return null;i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}for(;;){let o=n>0?a.firstChild:a.lastChild;if(!o){if(a.isAtom&&!a.isText&&!D1.isSelectable(a)){t=t.doc.resolve(i+a.nodeSize*n),r=!1;continue search}break}a=o,i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}return null}}};a7.prototype.visible=!1,a7.findFrom=a7.findGapCursorFrom,S1.jsonID(`gapcursor`,a7);var $Ze=class e{constructor(e){this.pos=e}map(t){return new e(t.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return a7.valid(t)?new a7(t):S1.near(t)}};function o7(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function eQe(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n-1);;e=e.lastChild){if(e.childCount==0&&!e.inlineContent||o7(e.type))return!0;if(e.inlineContent)return!1}}return!0}function tQe(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n);;e=e.firstChild){if(e.childCount==0&&!e.inlineContent||o7(e.type))return!0;if(e.inlineContent)return!1}}return!0}function nQe(){return new R1({props:{decorations:oQe,createSelectionBetween(e,t,n){return t.pos==n.pos&&a7.valid(n)?new a7(n):null},handleClick:iQe,handleKeyDown:rQe,handleDOMEvents:{beforeinput:aQe}}})}var rQe=r3({ArrowLeft:s7(`horiz`,-1),ArrowRight:s7(`horiz`,1),ArrowUp:s7(`vert`,-1),ArrowDown:s7(`vert`,1)});function s7(e,t){let n=e==`vert`?t>0?`down`:`up`:t>0?`right`:`left`;return function(e,r,i){let a=e.selection,o=t>0?a.$to:a.$from,s=a.empty;if(a instanceof T1){if(!i.endOfTextblock(n)||o.depth==0)return!1;s=!1,o=e.doc.resolve(t>0?o.after():o.before())}let c=a7.findGapCursorFrom(o,t,s);return c?(r&&r(e.tr.setSelection(new a7(c))),!0):!1}}function iQe(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!a7.valid(r))return!1;let i=e.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&D1.isSelectable(e.state.doc.nodeAt(i.inside))?!1:(e.dispatch(e.state.tr.setSelection(new a7(r))),!0)}function aQe(e,t){if(t.inputType!=`insertCompositionText`||!(e.state.selection instanceof a7))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let i=X.empty;for(let e=r.length-1;e>=0;e--)i=X.from(r[e].createAndFill(null,i));let a=e.state.tr.replace(n.pos,n.pos,new Z(i,0,0));return a.setSelection(T1.near(a.doc.resolve(n.pos+1))),e.dispatch(a),!1}function oQe(e){if(!(e.selection instanceof a7))return null;let t=document.createElement(`div`);return t.className=`ProseMirror-gapcursor`,k4.create(e.doc,[E4.widget(e.selection.head,t,{key:`gapcursor`})])}var c7=200,l7=function(){};l7.prototype.append=function(e){return e.length?(e=l7.from(e),!this.length&&e||e.length<c7&&this.leafAppend(e)||this.length<c7&&e.leafPrepend(this)||this.appendInner(e)):this},l7.prototype.prepend=function(e){return e.length?l7.from(e).append(this):this},l7.prototype.appendInner=function(e){return new sQe(this,e)},l7.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?l7.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},l7.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},l7.prototype.forEach=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},l7.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var r=[];return this.forEach(function(t,n){return r.push(e(t,n))},t,n),r},l7.from=function(e){return e instanceof l7?e:e&&e.length?new u7(e):l7.empty};var u7=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return e==0&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,r){for(var i=t;i<n;i++)if(e(this.values[i],r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){for(var i=t-1;i>=n;i--)if(e(this.values[i],r+i)===!1)return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=c7)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=c7)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(l7);l7.empty=new u7([]);var sQe=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,n,r){var i=this.left.length;if(t<i&&this.left.forEachInner(e,t,Math.min(n,i),r)===!1||n>i&&this.right.forEachInner(e,Math.max(t-i,0),Math.min(this.length,n)-i,r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){var i=this.left.length;if(t>i&&this.right.forEachInvertedInner(e,t-i,Math.max(n,i)-i,r+i)===!1||n<i&&this.left.forEachInvertedInner(e,Math.min(t,i),n,r)===!1)return!1},t.prototype.sliceInner=function(e,t){if(e==0&&t==this.length)return this;var n=this.left.length;return t<=n?this.left.slice(e,t):e>=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(l7),cQe=500,d7=class e{constructor(e,t){this.items=e,this.eventCount=t}popEvent(t,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,a;n&&(i=this.remapping(r,this.items.length),a=i.maps.length);let o=t.tr,s,c,l=[],u=[];return this.items.forEach((t,n)=>{if(!t.step){i||(i=this.remapping(r,n+1),a=i.maps.length),a--,u.push(t);return}if(i){u.push(new f7(t.map));let e=t.step.map(i.slice(a)),n;e&&o.maybeStep(e).doc&&(n=o.mapping.maps[o.mapping.maps.length-1],l.push(new f7(n,void 0,void 0,l.length+u.length))),a--,n&&i.appendMap(n,a)}else o.maybeStep(t.step);if(t.selection)return s=i?t.selection.map(i.slice(a)):t.selection,c=new e(this.items.slice(0,r).append(u.reverse().concat(l)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:o,selection:s}}addTransform(t,n,r,i){let a=[],o=this.eventCount,s=this.items,c=!i&&s.length?s.get(s.length-1):null;for(let e=0;e<t.steps.length;e++){let r=t.steps[e].invert(t.docs[e]),l=new f7(t.mapping.maps[e],r,n),u;(u=c&&c.merge(l))&&(l=u,e?a.pop():s=s.slice(0,s.length-1)),a.push(l),n&&=(o++,void 0),i||(c=l)}let l=o-r.depth;return l>uQe&&(s=lQe(s,l),o-=l),new e(s.append(a),o)}remapping(e,t){let n=new z$;return this.items.forEach((t,r)=>{let i=t.mirrorOffset!=null&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,i)},e,t),n}addMaps(t){return this.eventCount==0?this:new e(this.items.append(t.map(e=>new f7(e))),this.eventCount)}rebased(t,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),a=t.mapping,o=t.steps.length,s=this.eventCount;this.items.forEach(e=>{e.selection&&s--},i);let c=n;this.items.forEach(e=>{let n=a.getMirror(--c);if(n==null)return;o=Math.min(o,n);let i=a.maps[n];if(e.step){let o=t.steps[n].invert(t.docs[n]),l=e.selection&&e.selection.map(a.slice(c+1,n));l&&s++,r.push(new f7(i,o,l))}else r.push(new f7(i))},i);let l=[];for(let e=n;e<o;e++)l.push(new f7(a.maps[e]));let u=new e(this.items.slice(0,i).append(l).append(r),s);return u.emptyItemCount()>cQe&&(u=u.compress(this.items.length-r.length)),u}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(t=this.items.length){let n=this.remapping(0,t),r=n.maps.length,i=[],a=0;return this.items.forEach((e,o)=>{if(o>=t)i.push(e),e.selection&&a++;else if(e.step){let t=e.step.map(n.slice(r)),o=t&&t.getMap();if(r--,o&&n.appendMap(o,r),t){let s=e.selection&&e.selection.map(n.slice(r));s&&a++;let c=new f7(o.invert(),t,s),l,u=i.length-1;(l=i.length&&i[u].merge(c))?i[u]=l:i.push(c)}}else e.map&&r--},this.items.length,0),new e(l7.from(i.reverse()),a)}};d7.empty=new d7(l7.empty,0);function lQe(e,t){let n;return e.forEach((e,r)=>{if(e.selection&&t--==0)return n=r,!1}),e.slice(n)}var f7=class e{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(t){if(this.step&&t.step&&!t.selection){let n=t.step.merge(this.step);if(n)return new e(n.getMap().invert(),n,this.selection)}}},p7=class{constructor(e,t,n,r,i){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=i}},uQe=20;function dQe(e,t,n,r){let i=n.getMeta(y7),a;if(i)return i.historyState;n.getMeta(mQe)&&(e=new p7(e.done,e.undone,null,0,-1));let o=n.getMeta(`appendedTransaction`);if(n.steps.length==0)return e;if(o&&o.getMeta(y7))return o.getMeta(y7).redo?new p7(e.done.addTransform(n,void 0,r,v7(t)),e.undone,m7(n.mapping.maps),e.prevTime,e.prevComposition):new p7(e.done,e.undone.addTransform(n,void 0,r,v7(t)),null,e.prevTime,e.prevComposition);if(n.getMeta(`addToHistory`)!==!1&&!(o&&o.getMeta(`addToHistory`)===!1)){let i=n.getMeta(`composition`),a=e.prevTime==0||!o&&e.prevComposition!=i&&(e.prevTime<(n.time||0)-r.newGroupDelay||!fQe(n,e.prevRanges)),s=o?h7(e.prevRanges,n.mapping):m7(n.mapping.maps);return new p7(e.done.addTransform(n,a?t.selection.getBookmark():void 0,r,v7(t)),d7.empty,s,n.time,i??e.prevComposition)}else if(a=n.getMeta(`rebased`))return new p7(e.done.rebased(n,a),e.undone.rebased(n,a),h7(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);else return new p7(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),h7(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function fQe(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((e,r)=>{for(let i=0;i<t.length;i+=2)e<=t[i+1]&&r>=t[i]&&(n=!0)}),n}function m7(e){let t=[];for(let n=e.length-1;n>=0&&t.length==0;n--)e[n].forEach((e,n,r,i)=>t.push(r,i));return t}function h7(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let i=t.map(e[r],1),a=t.map(e[r+1],-1);i<=a&&n.push(i,a)}return n}function pQe(e,t,n){let r=v7(t),i=y7.get(t).spec.config,a=(n?e.undone:e.done).popEvent(t,r);if(!a)return null;let o=a.selection.resolve(a.transform.doc),s=(n?e.done:e.undone).addTransform(a.transform,t.selection.getBookmark(),i,r),c=new p7(n?s:a.remaining,n?a.remaining:s,null,0,-1);return a.transform.setSelection(o).setMeta(y7,{redo:n,historyState:c})}var g7=!1,_7=null;function v7(e){let t=e.plugins;if(_7!=t){g7=!1,_7=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){g7=!0;break}}return g7}var y7=new V1(`history`),mQe=new V1(`closeHistory`);function hQe(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new R1({key:y7,state:{init(){return new p7(d7.empty,d7.empty,null,0,-1)},apply(t,n,r){return dQe(n,r,t,e)}},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,r=n==`historyUndo`?x7:n==`historyRedo`?S7:null;return!r||!e.editable?!1:(t.preventDefault(),r(e.state,e.dispatch))}}}})}function b7(e,t){return(n,r)=>{let i=y7.getState(n);if(!i||(e?i.undone:i.done).eventCount==0)return!1;if(r){let a=pQe(i,n,e);a&&r(t?a.scrollIntoView():a)}return!0}}var x7=b7(!1,!0),S7=b7(!0,!0);h6.create({name:`characterCount`,addOptions(){return{limit:null,mode:`textSize`,textCounter:e=>e.length,wordCounter:e=>e.split(` `).filter(e=>e!==``).length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=e=>{let t=e?.node||this.editor.state.doc;if((e?.mode||this.options.mode)===`textSize`){let e=t.textBetween(0,t.content.size,void 0,` `);return this.options.textCounter(e)}return t.nodeSize},this.storage.words=e=>{let t=e?.node||this.editor.state.doc,n=t.textBetween(0,t.content.size,` `,` `);return this.options.wordCounter(n)}},addProseMirrorPlugins(){let e=!1;return[new R1({key:new V1(`characterCount`),appendTransaction:(t,n,r)=>{if(e)return;let i=this.options.limit;if(i==null||i===0){e=!0;return}let a=this.storage.characters({node:r.doc});if(a>i){let t=a-i;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);let n=r.tr.deleteRange(0,t);return e=!0,n}e=!0},filterTransaction:(e,t)=>{let n=this.options.limit;if(!e.docChanged||n===0||n==null)return!0;let r=this.storage.characters({node:t.doc}),i=this.storage.characters({node:e.doc});if(i<=n||r>n&&i>n&&i<=r)return!0;if(r>n&&i>n&&i>r||!e.getMeta(`paste`))return!1;let a=e.selection.$head.pos,o=a-(i-n),s=a;return e.deleteRange(o,s),!(this.storage.characters({node:e.doc})>n)}})]}});var gQe=h6.create({name:`dropCursor`,addOptions(){return{color:`currentColor`,width:1,class:void 0}},addProseMirrorPlugins(){return[ZZe(this.options)]}});h6.create({name:`focus`,addOptions(){return{className:`has-focus`,mode:`all`}},addProseMirrorPlugins(){return[new R1({key:new V1(`focus`),props:{decorations:({doc:e,selection:t})=>{let{isEditable:n,isFocused:r}=this.editor,{anchor:i}=t,a=[];if(!n||!r)return k4.create(e,[]);let o=0;this.options.mode===`deepest`&&e.descendants((e,t)=>{if(!e.isText){if(!(i>=t&&i<=t+e.nodeSize-1))return!1;o+=1}});let s=0;return e.descendants((e,t)=>{if(e.isText||!(i>=t&&i<=t+e.nodeSize-1))return!1;if(s+=1,this.options.mode===`deepest`&&o-s>0||this.options.mode===`shallowest`&&s>1)return this.options.mode===`deepest`;a.push(E4.node(t,t+e.nodeSize,{class:this.options.className}))}),k4.create(e,a)}}})]}});var _Qe=h6.create({name:`gapCursor`,addProseMirrorPlugins(){return[nQe()]},extendNodeSchema(e){return{allowGapCursor:P3(Q(e,`allowGapCursor`,{name:e.name,options:e.options,storage:e.storage}))??null}}}),C7=`placeholder`;function vQe(e){return e.replace(/\s+/g,`-`).replace(/[^a-zA-Z0-9-]/g,``).replace(/^[0-9-]+/,``).replace(/^-+/,``).toLowerCase()}var yQe=h6.create({name:`placeholder`,addOptions(){return{emptyEditorClass:`is-editor-empty`,emptyNodeClass:`is-empty`,dataAttribute:C7,placeholder:`Write something …`,showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){let e=this.options.dataAttribute?`data-${vQe(this.options.dataAttribute)}`:`data-${C7}`;return[new R1({key:new V1(`placeholder`),props:{decorations:({doc:t,selection:n})=>{let r=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:i}=n,a=[];if(!r)return null;let o=this.editor.isEmpty;return t.descendants((t,n)=>{let r=i>=n&&i<=n+t.nodeSize,s=!t.isLeaf&&t6(t);if(!t.type.isTextblock)return this.options.includeChildren;if((r||!this.options.showOnlyCurrent)&&s){let i=[this.options.emptyNodeClass];o&&i.push(this.options.emptyEditorClass);let s=E4.node(n,n+t.nodeSize,{class:i.join(` `),[e]:typeof this.options.placeholder==`function`?this.options.placeholder({editor:this.editor,node:t,pos:n,hasAnchor:r}):this.options.placeholder});a.push(s)}return this.options.includeChildren}),k4.create(t,a)}}})]}});h6.create({name:`selection`,addOptions(){return{className:`selection`}},addProseMirrorPlugins(){let{editor:e,options:t}=this;return[new R1({key:new V1(`selection`),props:{decorations(n){return n.selection.empty||e.isFocused||!e.isEditable||n6(n.selection)||e.view.dragging?null:k4.create(n.doc,[E4.inline(n.selection.from,n.selection.to,{class:t.className})])}}})]}});function w7({types:e,node:t}){return t&&Array.isArray(e)&&e.includes(t.type)||t?.type===e}var bQe=h6.create({name:`trailingNode`,addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){let e=new V1(this.name),t=this.options.node||this.editor.schema.topNodeType.contentMatch.defaultType?.name||`paragraph`,n=Object.entries(this.editor.schema.nodes).map(([,e])=>e).filter(e=>(this.options.notAfter||[]).concat(t).includes(e.name));return[new R1({key:e,appendTransaction:(n,r,i)=>{let{doc:a,tr:o,schema:s}=i,c=e.getState(i),l=a.content.size,u=s.nodes[t];if(!n.some(e=>e.getMeta(`skipTrailingNode`))&&c)return o.insert(l,u.create())},state:{init:(e,t)=>{let r=t.tr.doc.lastChild;return!w7({node:r,types:n})},apply:(e,t)=>{if(!e.docChanged||e.getMeta(`__uniqueIDTransaction`))return t;let r=e.doc.lastChild;return!w7({node:r,types:n})}}})]}}),xQe=h6.create({name:`undoRedo`,addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>x7(e,t),redo:()=>({state:e,dispatch:t})=>S7(e,t)}},addProseMirrorPlugins(){return[hQe(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),SQe=h6.create({name:`starterKit`,addExtensions(){let e=[];return this.options.bold!==!1&&e.push(YXe.configure(this.options.bold)),this.options.blockquote!==!1&&e.push(WXe.configure(this.options.blockquote)),this.options.bulletList!==!1&&e.push(R5.configure(this.options.bulletList)),this.options.code!==!1&&e.push(QXe.configure(this.options.code)),this.options.codeBlock!==!1&&e.push(tZe.configure(this.options.codeBlock)),this.options.document!==!1&&e.push(nZe.configure(this.options.document)),this.options.dropcursor!==!1&&e.push(gQe.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&e.push(_Qe.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&e.push(rZe.configure(this.options.hardBreak)),this.options.heading!==!1&&e.push(iZe.configure(this.options.heading)),this.options.undoRedo!==!1&&e.push(xQe.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&e.push(aZe.configure(this.options.horizontalRule)),this.options.italic!==!1&&e.push(uZe.configure(this.options.italic)),this.options.listItem!==!1&&e.push(z5.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(Y5.configure(this.options?.listKeymap)),this.options.link!==!1&&e.push(F5.configure(this.options?.link)),this.options.orderedList!==!1&&e.push(e7.configure(this.options.orderedList)),this.options.paragraph!==!1&&e.push(GZe.configure(this.options.paragraph)),this.options.strike!==!1&&e.push(JZe.configure(this.options.strike)),this.options.text!==!1&&e.push(YZe.configure(this.options.text)),this.options.underline!==!1&&e.push(XZe.configure(this.options?.underline)),this.options.trailingNode!==!1&&e.push(bQe.configure(this.options?.trailingNode)),e}}),CQe=n7,wQe=t7,TQe=yQe;function T7(e){if(!e)return null;try{var t=JSON.parse(e);if(typeof t==`object`&&t)return t}catch{}return null}function E7({active:e,onClick:t,disabled:n,label:r,children:i}){return(0,b.jsx)(`button`,{type:`button`,onClick:t,disabled:n,"aria-label":r,"aria-pressed":e,className:`p-1 rounded transition-colors `+(e?`bg-primary/20 text-primary`:`text-base-content/40 hover:text-base-content/70 hover:bg-base-content/5`)+(n?` opacity-30 cursor-not-allowed`:``),children:i})}function EQe({content:e,onChange:t,placeholder:n,disabled:r}){var i=(0,x.useRef)(e);i.current=e;var a=zXe({extensions:[SQe.configure({heading:{levels:[1,2]}}),FZe.configure({openOnClick:!0}),CQe,wQe.configure({nested:!0}),TQe.configure({placeholder:n??`Write something...`})],editable:!r,content:T7(e)??(e||``),onUpdate:function({editor:e}){t(JSON.stringify(e.getJSON()))}});if((0,x.useEffect)(function(){a&&a.setEditable(!r)},[a,r]),(0,x.useEffect)(function(){if(!(!a||a.isFocused)){var t=T7(e),n=JSON.stringify(a.getJSON());t&&JSON.stringify(t)!==n?a.commands.setContent(t):!t&&e!==n&&a.commands.setContent(e||``)}},[e,a]),!a)return null;function o(){if(a){var e=window.prompt(`URL:`);e&&a.chain().focus().setLink({href:e}).run()}}return(0,b.jsxs)(`div`,{className:`flex flex-col gap-0 border border-base-content/10 rounded-lg overflow-hidden bg-base-100`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-0.5 px-2 py-1.5 border-b border-base-content/10 bg-base-200/50 flex-wrap`,children:[(0,b.jsx)(E7,{active:a.isActive(`bold`),onClick:function(){a.chain().focus().toggleBold().run()},disabled:r,label:`Bold`,children:(0,b.jsx)(vs,{size:14})}),(0,b.jsx)(E7,{active:a.isActive(`italic`),onClick:function(){a.chain().focus().toggleItalic().run()},disabled:r,label:`Italic`,children:(0,b.jsx)(eg,{size:14})}),(0,b.jsx)(E7,{active:a.isActive(`strike`),onClick:function(){a.chain().focus().toggleStrike().run()},disabled:r,label:`Strikethrough`,children:(0,b.jsx)(xv,{size:14})}),(0,b.jsx)(`div`,{className:`w-px h-4 bg-base-content/10 mx-1`}),(0,b.jsx)(E7,{active:a.isActive(`heading`,{level:1}),onClick:function(){a.chain().focus().toggleHeading({level:1}).run()},disabled:r,label:`Heading 1`,children:(0,b.jsx)(rh,{size:14})}),(0,b.jsx)(E7,{active:a.isActive(`heading`,{level:2}),onClick:function(){a.chain().focus().toggleHeading({level:2}).run()},disabled:r,label:`Heading 2`,children:(0,b.jsx)(ih,{size:14})}),(0,b.jsx)(`div`,{className:`w-px h-4 bg-base-content/10 mx-1`}),(0,b.jsx)(E7,{active:a.isActive(`bulletList`),onClick:function(){a.chain().focus().toggleBulletList().run()},disabled:r,label:`Bullet List`,children:(0,b.jsx)(x_,{size:14})}),(0,b.jsx)(E7,{active:a.isActive(`orderedList`),onClick:function(){a.chain().focus().toggleOrderedList().run()},disabled:r,label:`Numbered List`,children:(0,b.jsx)(p_,{size:14})}),(0,b.jsx)(E7,{active:a.isActive(`taskList`),onClick:function(){a.chain().focus().toggleTaskList().run()},disabled:r,label:`Task List`,children:(0,b.jsx)(n_,{size:14})}),(0,b.jsx)(`div`,{className:`w-px h-4 bg-base-content/10 mx-1`}),(0,b.jsx)(E7,{active:a.isActive(`codeBlock`),onClick:function(){a.chain().focus().toggleCodeBlock().run()},disabled:r,label:`Code Block`,children:(0,b.jsx)(bf,{size:14})}),(0,b.jsx)(E7,{active:a.isActive(`link`),onClick:o,disabled:r,label:`Link`,children:(0,b.jsx)($g,{size:14})})]}),(0,b.jsx)(I6,{editor:a,className:`prose prose-sm max-w-none px-3 py-2 min-h-[200px] text-base-content [&_.tiptap]:outline-none [&_.tiptap]:min-h-[180px] [&_.tiptap_p.is-editor-empty:first-child::before]:text-base-content/30 [&_.tiptap_p.is-editor-empty:first-child::before]:content-[attr(data-placeholder)] [&_.tiptap_p.is-editor-empty:first-child::before]:float-left [&_.tiptap_p.is-editor-empty:first-child::before]:h-0 [&_.tiptap_p.is-editor-empty:first-child::before]:pointer-events-none [&_.tiptap_h1]:text-lg [&_.tiptap_h1]:font-mono [&_.tiptap_h1]:font-bold [&_.tiptap_h2]:text-base [&_.tiptap_h2]:font-mono [&_.tiptap_h2]:font-semibold [&_.tiptap_a]:text-primary [&_.tiptap_a]:underline [&_.tiptap_code]:bg-base-300 [&_.tiptap_code]:px-1 [&_.tiptap_code]:rounded [&_.tiptap_pre]:bg-base-300 [&_.tiptap_pre]:p-3 [&_.tiptap_pre]:rounded-lg [&_.tiptap_ul[data-type=taskList]]:list-none [&_.tiptap_ul[data-type=taskList]]:pl-0`})]})}var DQe={created:`bg-info/20 text-info`,"status-change":`bg-warning/20 text-warning`,"session-linked":`bg-accent/20 text-accent`,edited:`bg-base-content/10 text-base-content/60`,"ai-note":`bg-secondary/20 text-secondary`},OQe={created:`Created`,"status-change":`Status`,"session-linked":`Session`,edited:`Edited`,"ai-note":`AI Note`};function kQe(e){var t=Date.now()-e,n=Math.floor(t/1e3);if(n<60)return n+`s ago`;var r=Math.floor(n/60);if(r<60)return r+`m ago`;var i=Math.floor(r/60);return i<24?i+`h ago`:Math.floor(i/24)+`d ago`}function AQe({activity:e}){var t=[...e].reverse();return t.length===0?(0,b.jsx)(`div`,{className:`flex items-center justify-center py-12 text-[13px] text-base-content/30 font-mono`,children:`No activity yet`}):(0,b.jsx)(`div`,{className:`flex flex-col gap-1 py-2`,children:t.map(function(e,t){return(0,b.jsxs)(`div`,{className:`flex items-start gap-3 px-1 py-1.5`,children:[(0,b.jsx)(`span`,{className:`text-[10px] text-base-content/30 font-mono w-14 flex-shrink-0 pt-0.5 text-right`,children:kQe(e.timestamp)}),(0,b.jsx)(`span`,{className:`text-[10px] font-mono px-1.5 py-0.5 rounded flex-shrink-0 `+DQe[e.type],children:OQe[e.type]}),(0,b.jsx)(`span`,{className:`text-[12px] text-base-content/70 min-w-0`,children:e.detail})]},t)})})}function jQe(e){var t=Date.now()-e,n=Math.floor(t/1e3);if(n<60)return n+`s ago`;var r=Math.floor(n/60);if(r<60)return r+`m ago`;var i=Math.floor(r/60);return i<24?i+`h ago`:Math.floor(i/24)+`d ago`}function MQe({linkedSessions:e,onUnlink:t,disabled:n}){return e.length===0?(0,b.jsx)(`div`,{className:`flex items-center justify-center py-12 text-[13px] text-base-content/30 font-mono`,children:`No linked sessions`}):(0,b.jsx)(`div`,{className:`flex flex-col gap-1 py-2`,children:e.map(function(e){return(0,b.jsxs)(`div`,{className:`flex items-center gap-3 px-1 py-1.5 rounded hover:bg-base-content/5 transition-colors`,children:[(0,b.jsx)(`span`,{className:`text-[12px] font-mono text-base-content/70 flex-shrink-0`,children:e.sessionId.slice(0,8)}),e.note&&(0,b.jsx)(`span`,{className:`text-[11px] text-base-content/40 truncate min-w-0 flex-1`,children:e.note}),(0,b.jsx)(`span`,{className:`text-[10px] text-base-content/30 font-mono flex-shrink-0 ml-auto`,children:jQe(e.linkedAt)}),(0,b.jsx)(`button`,{type:`button`,onClick:function(){t(e.sessionId)},disabled:n,className:`p-1 rounded text-base-content/30 hover:text-error hover:bg-error/10 transition-colors disabled:opacity-30 disabled:cursor-not-allowed`,"aria-label":`Unlink session `+e.sessionId.slice(0,8),children:(0,b.jsx)(Zg,{size:13})})]},e.sessionId)})})}var NQe=[{key:`summary`,label:`Summary`},{key:`currentState`,label:`Current State`},{key:`requirements`,label:`Requirements`},{key:`implementationPlan`,label:`Implementation`},{key:`migrationMap`,label:`Migration`},{key:`testing`,label:`Testing`},{key:`activity`,label:`Activity`},{key:`sessions`,label:`Sessions`}],PQe=[`draft`,`in-progress`,`on-hold`,`completed`],FQe=[`high`,`medium`,`low`],IQe=[`small`,`medium`,`large`,`xl`];function LQe({spec:e,onBack:t}){var{send:n}=R(),r=_b(),[i,a]=(0,x.useState)(e.title),[o,s]=(0,x.useState)(e.tagline),[c,l]=(0,x.useState)(e.status),[u,d]=(0,x.useState)(e.priority),[f,p]=(0,x.useState)(e.estimatedEffort),[m,h]=(0,x.useState)(e.author),[g,_]=(0,x.useState)(e.tags),[v,y]=(0,x.useState)(e.sections),[S,C]=(0,x.useState)(`summary`),[w,T]=(0,x.useState)(`idle`),[E,D]=(0,x.useState)(!1),[O,k]=(0,x.useState)(``),A=(0,x.useRef)(null),j=(0,x.useRef)(null),M=(0,x.useRef)(e.id);M.current=e.id,(0,x.useEffect)(function(){a(e.title),s(e.tagline),l(e.status),d(e.priority),p(e.estimatedEffort),h(e.author),_(e.tags),y(e.sections)},[e.id]);var N=(0,x.useCallback)(function(){A.current&&=(clearTimeout(A.current),null),j.current&&=(n({type:`specs:update`,id:M.current,sections:j.current}),null)},[n]);(0,x.useEffect)(function(){return function(){N()}},[N]);function ee(e,t){var r={...v,[e]:t};y(r),j.current=r,T(`saving`),A.current&&clearTimeout(A.current),A.current=setTimeout(function(){n({type:`specs:update`,id:M.current,sections:j.current}),j.current=null,T(`saved`),setTimeout(function(){T(`idle`)},1500)},800)}function te(t){n({type:`specs:update`,id:e.id,...t}),T(`saved`),setTimeout(function(){T(`idle`)},1500)}function P(){i!==e.title&&te({title:i})}function F(){o!==e.tagline&&te({tagline:o})}function ne(e){l(e),te({status:e})}function re(e){d(e),te({priority:e})}function ie(e){p(e),te({estimatedEffort:e})}function ae(){m!==e.author&&te({author:m})}function oe(e){if(e.key===`Enter`&&O.trim()){var t=[...g,O.trim()];_(t),k(``),te({tags:t})}}function se(e){var t=g.filter(function(t,n){return n!==e});_(t),te({tags:t})}function ce(){N(),t()}function le(){n({type:`specs:delete`,id:e.id}),t()}function ue(t){n({type:`specs:unlink-session`,id:e.id,sessionId:t})}var de=S!==`activity`&&S!==`sessions`;return(0,b.jsxs)(`div`,{className:`flex flex-col h-full bg-base-100`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-2.5 border-b border-base-content/15 flex-shrink-0`,children:[(0,b.jsx)(`button`,{type:`button`,onClick:ce,className:`p-1 rounded text-base-content/40 hover:text-base-content hover:bg-base-content/5 transition-colors`,"aria-label":`Back to specs`,children:(0,b.jsx)(ba,{size:16})}),(0,b.jsxs)(`div`,{className:`flex items-center gap-1.5 ml-auto text-[11px] text-base-content/30 font-mono`,children:[w===`saving`&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(C_,{size:12,className:`animate-spin`}),(0,b.jsx)(`span`,{children:`Saving...`})]}),w===`saved`&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(L,{size:12,className:`text-success`}),(0,b.jsx)(`span`,{children:`Saved`})]})]}),(0,b.jsx)(`button`,{type:`button`,onClick:function(){D(!0)},disabled:!r,className:`p-1 rounded text-base-content/30 hover:text-error hover:bg-error/10 transition-colors disabled:opacity-30`,"aria-label":`Delete spec`,children:(0,b.jsx)(Tv,{size:14})})]}),(0,b.jsxs)(`div`,{className:`flex-1 overflow-y-auto`,children:[(0,b.jsxs)(`div`,{className:`px-4 pt-4 pb-2`,children:[(0,b.jsx)(`input`,{type:`text`,value:i,onChange:function(e){a(e.target.value)},onBlur:P,disabled:!r,placeholder:`Untitled spec`,className:`w-full bg-transparent text-[17px] font-mono font-bold text-base-content placeholder:text-base-content/20 outline-none border-none`}),(0,b.jsx)(`input`,{type:`text`,value:o,onChange:function(e){s(e.target.value)},onBlur:F,disabled:!r,placeholder:`Add a tagline...`,className:`w-full bg-transparent text-[13px] text-base-content/40 placeholder:text-base-content/20 outline-none border-none mt-0.5`})]}),(0,b.jsxs)(`div`,{className:`grid grid-cols-2 lg:grid-cols-4 gap-2 px-4 py-2`,children:[(0,b.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,b.jsx)(`label`,{className:`text-[10px] text-base-content/30 font-mono uppercase tracking-wider`,children:`Status`}),(0,b.jsx)(`select`,{value:c,onChange:function(e){ne(e.target.value)},disabled:!r,className:`h-7 px-2 bg-base-200 border border-base-content/10 rounded text-[12px] text-base-content font-mono focus:border-primary focus-visible:outline-none transition-colors`,children:PQe.map(function(e){return(0,b.jsx)(`option`,{value:e,children:e},e)})})]}),(0,b.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,b.jsx)(`label`,{className:`text-[10px] text-base-content/30 font-mono uppercase tracking-wider`,children:`Priority`}),(0,b.jsx)(`select`,{value:u,onChange:function(e){re(e.target.value)},disabled:!r,className:`h-7 px-2 bg-base-200 border border-base-content/10 rounded text-[12px] text-base-content font-mono focus:border-primary focus-visible:outline-none transition-colors`,children:FQe.map(function(e){return(0,b.jsx)(`option`,{value:e,children:e},e)})})]}),(0,b.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,b.jsx)(`label`,{className:`text-[10px] text-base-content/30 font-mono uppercase tracking-wider`,children:`Effort`}),(0,b.jsx)(`select`,{value:f,onChange:function(e){ie(e.target.value)},disabled:!r,className:`h-7 px-2 bg-base-200 border border-base-content/10 rounded text-[12px] text-base-content font-mono focus:border-primary focus-visible:outline-none transition-colors`,children:IQe.map(function(e){return(0,b.jsx)(`option`,{value:e,children:e},e)})})]}),(0,b.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,b.jsx)(`label`,{className:`text-[10px] text-base-content/30 font-mono uppercase tracking-wider`,children:`Author`}),(0,b.jsx)(`input`,{type:`text`,value:m,onChange:function(e){h(e.target.value)},onBlur:ae,disabled:!r,placeholder:`Author`,className:`h-7 px-2 bg-base-200 border border-base-content/10 rounded text-[12px] text-base-content font-mono focus:border-primary focus-visible:outline-none transition-colors`})]})]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-1.5 px-4 py-2 flex-wrap`,children:[g.map(function(e,t){return(0,b.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-base-content/10 text-[11px] font-mono text-base-content/60`,children:[e,(0,b.jsx)(`button`,{type:`button`,onClick:function(){se(t)},disabled:!r,className:`text-base-content/30 hover:text-base-content transition-colors`,"aria-label":`Remove tag `+e,children:(0,b.jsx)(Nv,{size:10})})]},t)}),(0,b.jsx)(`input`,{type:`text`,value:O,onChange:function(e){k(e.target.value)},onKeyDown:oe,disabled:!r,placeholder:`Add tag...`,className:`bg-transparent text-[11px] text-base-content/60 placeholder:text-base-content/20 outline-none border-none w-20`})]}),(0,b.jsx)(`div`,{className:`border-b border-base-content/10 overflow-x-auto flex-shrink-0`,role:`tablist`,children:(0,b.jsx)(`div`,{className:`flex px-4 gap-0`,children:NQe.map(function(e){var t=S===e.key;return(0,b.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":t,onClick:function(){C(e.key)},className:`px-3 py-2 text-[11px] font-mono whitespace-nowrap border-b-2 transition-colors `+(t?`border-primary text-primary`:`border-transparent text-base-content/40 hover:text-base-content/70`),children:e.label},e.key)})})}),(0,b.jsxs)(`div`,{className:`px-4 py-3`,children:[de&&(0,b.jsx)(EQe,{content:v[S],onChange:function(e){ee(S,e)},placeholder:`Write `+S+` details...`,disabled:!r}),S===`activity`&&(0,b.jsx)(AQe,{activity:e.activity}),S===`sessions`&&(0,b.jsx)(MQe,{linkedSessions:e.linkedSessions,onUnlink:ue,disabled:!r})]})]}),E&&(0,b.jsx)(`div`,{className:`fixed inset-0 z-[9999] flex items-center justify-center bg-black/50`,children:(0,b.jsxs)(`div`,{className:`bg-base-300 border border-base-content/15 rounded-xl shadow-2xl p-6 max-w-sm w-full mx-4`,children:[(0,b.jsx)(`h3`,{className:`text-[15px] font-mono font-bold text-base-content mb-2`,children:`Delete spec?`}),(0,b.jsxs)(`p`,{className:`text-[13px] text-base-content/60 mb-4`,children:[`This will permanently delete "`,e.title||`Untitled`,`". This action cannot be undone.`]}),(0,b.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,b.jsx)(`button`,{type:`button`,onClick:function(){D(!1)},className:`btn btn-ghost btn-sm`,children:`Cancel`}),(0,b.jsx)(`button`,{type:`button`,onClick:le,className:`btn btn-error btn-sm`,children:`Delete`})]})]})})]})}var RQe={draft:`Draft`,"in-progress":`In Progress`,"on-hold":`On Hold`,completed:`Completed`},zQe=[{value:`all`,label:`All`},{value:`draft`,label:`Draft`},{value:`in-progress`,label:`In Progress`},{value:`on-hold`,label:`On Hold`},{value:`completed`,label:`Completed`}],D7={high:0,medium:1,low:2},O7={xl:0,large:1,medium:2,small:3},k7={"in-progress":0,draft:1,"on-hold":2,completed:3};function BQe(e){var t=Date.now()-e,n=Math.floor(t/1e3);if(n<60)return n+`s ago`;var r=Math.floor(n/60);if(r<60)return r+`m ago`;var i=Math.floor(r/60);return i<24?i+`h ago`:Math.floor(i/24)+`d ago`}function VQe({specs:e,onSelectSpec:t,filter:n,onFilterChange:r}){var[i,a]=(0,x.useState)(`updatedAt`),[o,s]=(0,x.useState)(`desc`);function c(e){i===e?s(function(e){return e===`asc`?`desc`:`asc`}):(a(e),s(`desc`))}var l=(0,x.useMemo)(function(){var t=[...n===`all`?e:e.filter(function(e){return e.status===n})];return t.sort(function(e,t){var n=0;return n=i===`title`?e.title.localeCompare(t.title):i===`status`?(k7[e.status]??99)-(k7[t.status]??99):i===`priority`?(D7[e.priority]??99)-(D7[t.priority]??99):i===`estimatedEffort`?(O7[e.estimatedEffort]??99)-(O7[t.estimatedEffort]??99):e.updatedAt-t.updatedAt,o===`desc`?-n:n}),t},[e,n,i,o]);function u(e,n){(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),t(n))}return(0,b.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,b.jsx)(`div`,{className:`flex items-center gap-1 flex-wrap`,children:zQe.map(function(e){return(0,b.jsx)(`button`,{type:`button`,onClick:function(){r(e.value)},className:`px-2.5 py-1 rounded-full text-[11px] font-mono transition-colors `+(n===e.value?`bg-primary/20 text-primary`:`text-base-content/40 hover:text-base-content/70 hover:bg-base-content/5`),children:e.label},e.value)})}),(0,b.jsx)(`div`,{className:`overflow-x-auto`,children:(0,b.jsxs)(`table`,{className:`w-full text-left`,children:[(0,b.jsx)(`thead`,{children:(0,b.jsx)(`tr`,{className:`border-b border-base-content/10`,children:[{field:`title`,label:`Title`},{field:`status`,label:`Status`},{field:`priority`,label:`Priority`},{field:`estimatedEffort`,label:`Effort`},{field:`updatedAt`,label:`Updated`}].map(function(e){return(0,b.jsx)(`th`,{className:`pb-2 pr-3`,children:(0,b.jsxs)(`button`,{type:`button`,onClick:function(){c(e.field)},className:`flex items-center gap-1 text-[10px] font-mono uppercase tracking-wider transition-colors `+(i===e.field?`text-primary`:`text-base-content/30 hover:text-base-content/60`),children:[e.label,(0,b.jsx)(ka,{size:10})]})},e.field)})})}),(0,b.jsx)(`tbody`,{children:l.map(function(e){return(0,b.jsxs)(`tr`,{tabIndex:0,role:`button`,onClick:function(){t(e)},onKeyDown:function(t){u(t,e)},className:`border-b border-base-content/5 hover:bg-base-content/5 cursor-pointer transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/40`+(e.status===`completed`?` opacity-60`:``),children:[(0,b.jsx)(`td`,{className:`py-2 pr-3`,children:(0,b.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,b.jsx)(`span`,{className:`text-[12px] font-mono font-semibold text-base-content truncate max-w-[300px]`,children:e.title||`Untitled`}),e.tagline&&(0,b.jsx)(`span`,{className:`text-[10px] text-base-content/30 truncate max-w-[300px]`,children:e.tagline})]})}),(0,b.jsx)(`td`,{className:`py-2 pr-3`,children:(0,b.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,b.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full `+Ib[e.status]}),(0,b.jsx)(`span`,{className:`text-[11px] font-mono text-base-content/60`,children:RQe[e.status]})]})}),(0,b.jsx)(`td`,{className:`py-2 pr-3`,children:(0,b.jsx)(`span`,{className:`text-[11px] font-mono `+Lb[e.priority],children:e.priority})}),(0,b.jsx)(`td`,{className:`py-2 pr-3`,children:(0,b.jsx)(`span`,{className:`text-[11px] font-mono text-base-content/40`,children:e.estimatedEffort})}),(0,b.jsx)(`td`,{className:`py-2`,children:(0,b.jsx)(`span`,{className:`text-[10px] font-mono text-base-content/30`,children:BQe(e.updatedAt)})})]},e.id)})})]})})]})}var HQe=[{status:`draft`,label:`Draft`,color:`text-info`,borderColor:`border-info/40`},{status:`in-progress`,label:`In Progress`,color:`text-warning`,borderColor:`border-warning/40`},{status:`on-hold`,label:`On Hold`,color:`text-base-content/50`,borderColor:`border-base-content/20`},{status:`completed`,label:`Completed`,color:`text-success`,borderColor:`border-success/40`}],UQe={draft:`bg-info/5`,"in-progress":`bg-warning/5`,"on-hold":`bg-base-content/5`,completed:`bg-success/5`};function WQe({specs:e,onSelectSpec:t,onStatusChange:n}){var[r,i]=(0,x.useState)(null),[a,o]=(0,x.useState)(null),s=(0,x.useMemo)(function(){for(var t={draft:[],"in-progress":[],"on-hold":[],completed:[]},n=0;n<e.length;n++){var r=e[n];t[r.status]&&t[r.status].push(r)}return t},[e]);function c(e,t){e.dataTransfer.setData(`text/plain`,t),e.dataTransfer.effectAllowed=`move`,i(t)}function l(e,t){e.preventDefault(),e.dataTransfer.dropEffect=`move`,o(t)}function u(e,t){t.contains(e.relatedTarget)||o(null)}function d(t,a){if(t.preventDefault(),r){var s=e.find(function(e){return e.id===r});s&&s.status!==a&&n(r,a)}i(null),o(null)}function f(){i(null),o(null)}return(0,b.jsx)(`div`,{className:`flex gap-4 h-full overflow-x-auto pb-2`,children:HQe.map(function(e){var n=s[e.status];return(0,b.jsxs)(`div`,{className:`flex flex-col min-h-0 min-w-[240px] w-[280px] flex-shrink-0 rounded-lg transition-colors `+(a===e.status?UQe[e.status]:``),onDragOver:function(t){l(t,e.status)},onDragLeave:function(e){u(e,e.currentTarget)},onDrop:function(t){d(t,e.status)},children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2 pb-2 mb-2 border-b-2 px-1 `+e.borderColor,children:[(0,b.jsx)(`span`,{className:`text-[12px] font-mono font-bold `+e.color,children:e.label}),(0,b.jsx)(`span`,{className:`text-[10px] font-mono text-base-content/30 bg-base-content/5 px-1.5 rounded-full`,children:n.length})]}),(0,b.jsx)(`div`,{className:`flex flex-col gap-2 overflow-y-auto flex-1 px-1`,children:n.map(function(e){return(0,b.jsx)(`div`,{draggable:!0,onDragStart:function(t){c(t,e.id)},onDragEnd:f,className:r===e.id?`opacity-30`:``,children:(0,b.jsx)(Ive,{spec:e,onClick:function(){t(e)}})},e.id)})})]},e.status)})})}function GQe(){try{var e=localStorage.getItem(`lattice:specs:viewMode`);if(e===`list`||e===`board`)return e}catch{}return`list`}function KQe(){var{send:e,subscribe:t,unsubscribe:n}=R(),{activeProjectSlug:r}=jy(),i=_b(),[a,o]=(0,x.useState)([]),[s,c]=(0,x.useState)(!0),[l,u]=(0,x.useState)(GQe),[d,f]=(0,x.useState)(`in-progress`),[p,m]=(0,x.useState)(null),h=(0,x.useCallback)(function(e){if(e.type===`specs:list_result`){o(e.specs),c(!1);return}if(e.type===`specs:created`){o(function(t){return[...t,e.spec]});return}if(e.type===`specs:updated`||e.type===`specs:session_linked`||e.type===`specs:session_unlinked`||e.type===`specs:activity_added`){o(function(t){return t.map(function(t){return t.id===e.spec.id?e.spec:t})});return}if(e.type===`specs:deleted`){o(function(t){return t.filter(function(t){return t.id!==e.id})}),p===e.id&&m(null);return}},[p]);(0,x.useEffect)(function(){return c(!0),t(`specs:list_result`,h),t(`specs:created`,h),t(`specs:updated`,h),t(`specs:deleted`,h),t(`specs:session_linked`,h),t(`specs:session_unlinked`,h),t(`specs:activity_added`,h),e({type:`specs:list`,projectSlug:r??void 0}),function(){n(`specs:list_result`,h),n(`specs:created`,h),n(`specs:updated`,h),n(`specs:deleted`,h),n(`specs:session_linked`,h),n(`specs:session_unlinked`,h),n(`specs:activity_added`,h)}},[e,t,n,h,r]);function g(e){u(e);try{localStorage.setItem(`lattice:specs:viewMode`,e)}catch{}}function _(){e({type:`specs:create`,projectSlug:r??``,title:`Untitled Spec`})}function v(e){m(e.id)}var y=p?a.find(function(e){return e.id===p}):null;return y?(0,b.jsx)(LQe,{spec:y,onBack:function(){m(null)}}):(0,b.jsxs)(`div`,{className:`flex flex-col h-full bg-base-100`,children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b border-base-content/15 flex-shrink-0`,children:[(0,b.jsx)(`span`,{className:`text-[13px] font-semibold text-base-content`,children:`Specs`}),(0,b.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,b.jsxs)(`div`,{className:`flex items-center bg-base-200 rounded-lg p-0.5`,children:[(0,b.jsx)(`button`,{type:`button`,onClick:function(){g(`list`)},className:`p-1 rounded transition-colors `+(l===`list`?`bg-base-300 text-base-content`:`text-base-content/30 hover:text-base-content/60`),"aria-label":`List view`,children:(0,b.jsx)(x_,{size:14})}),(0,b.jsx)(`button`,{type:`button`,onClick:function(){g(`board`)},className:`p-1 rounded transition-colors `+(l===`board`?`bg-base-300 text-base-content`:`text-base-content/30 hover:text-base-content/60`),"aria-label":`Board view`,children:(0,b.jsx)(Mg,{size:14})})]}),(0,b.jsxs)(`button`,{type:`button`,onClick:_,disabled:!i,className:`btn btn-primary btn-xs gap-1`,children:[(0,b.jsx)(tv,{size:12}),`New Spec`]})]})]}),(0,b.jsx)(`div`,{className:`flex-1 overflow-auto p-4`,children:s?(0,b.jsxs)(`div`,{className:`flex flex-col gap-3 mt-2`,children:[(0,b.jsx)(`div`,{className:`h-12 bg-base-content/10 animate-pulse rounded`}),(0,b.jsx)(`div`,{className:`h-12 bg-base-content/10 animate-pulse rounded`}),(0,b.jsx)(`div`,{className:`h-12 bg-base-content/10 animate-pulse rounded`})]}):a.length===0?(0,b.jsxs)(`div`,{className:`flex flex-col items-center justify-center text-center mt-16 gap-3`,children:[(0,b.jsx)(bd,{size:28,className:`text-base-content/15`}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-[13px] text-base-content/40`,children:`No specs yet`}),(0,b.jsx)(`div`,{className:`text-[11px] text-base-content/30 mt-1`,children:`Track features, bugs, and tasks with detailed specs.`})]}),(0,b.jsx)(`button`,{type:`button`,onClick:_,disabled:!i,className:`btn btn-primary btn-sm mt-2`,children:`Create your first spec`})]}):l===`list`?(0,b.jsx)(VQe,{specs:a,onSelectSpec:v,filter:d,onFilterChange:f}):(0,b.jsx)(WQe,{specs:a,onSelectSpec:v,onStatusChange:function(t,n){e({type:`specs:update`,id:t,status:n})}})})]})}function A7({paneId:e}){var t=Ub(),n=Vb(),[r,i]=(0,x.useState)(null);if(!t.isDragging)return null;if(t.sourcePaneId===e&&n.panes.length<2){var a=n.panes.find(function(t){return t.id===e});if(a&&a.tabIds.length<2)return null}var o=n.panes.length>=2,s=t.sourcePaneId===e,c,l;if(o?(c=!1,l=!s):(c=!0,l=!1),s&&!o){var u=n.panes.find(function(e){return e.id===t.sourcePaneId});u&&u.tabIds.length<2&&(c=!1)}if(!c&&!l)return null;function d(e,t){e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect=`move`,i(t)}function f(e){var t=e.relatedTarget;t&&e.currentTarget.contains(t)||i(null)}function p(r,a){r.preventDefault(),r.stopPropagation(),!(!t.draggedTabId||!t.sourcePaneId)&&(a===`center`&&!s?n.moveTabToPane(t.draggedTabId,t.sourcePaneId,e):a===`left`?n.splitPane(t.draggedTabId,`horizontal`,`before`):a===`right`?n.splitPane(t.draggedTabId,`horizontal`,`after`):a===`top`?n.splitPane(t.draggedTabId,`vertical`,`before`):a===`bottom`&&n.splitPane(t.draggedTabId,`vertical`,`after`),i(null),t.endDrag())}var m=`flex items-center justify-center rounded-lg border-2 border-dashed transition-colors duration-150 text-xs font-semibold font-mono pointer-events-auto`,h=`border-primary/30 bg-primary/5 text-primary/40`,g=`border-primary/60 bg-primary/20 text-primary/80`;return(0,b.jsx)(`div`,{className:`absolute inset-0 z-50 pointer-events-none`,onDragLeave:f,children:(0,b.jsxs)(`div`,{className:`w-full h-full grid gap-1 p-2`,style:{gridTemplateColumns:c?`48px 1fr 48px`:`1fr`,gridTemplateRows:c?`40px 1fr 40px`:`1fr`},children:[c&&(0,b.jsx)(`div`,{className:m+` col-span-3 `+(r===`top`?g:h),onDragOver:function(e){d(e,`top`)},onDrop:function(e){p(e,`top`)},children:`Split Up`}),c&&(0,b.jsx)(`div`,{className:m+` `+(r===`left`?g:h),style:{writingMode:`vertical-lr`},onDragOver:function(e){d(e,`left`)},onDrop:function(e){p(e,`left`)},children:`Split Left`}),(c||l)&&(0,b.jsx)(`div`,{className:m+` `+(r===`center`?`border-info/60 bg-info/20 text-info/80`:`border-info/30 bg-info/5 text-info/40`),onDragOver:function(e){d(e,`center`)},onDrop:function(e){p(e,`center`)},children:l?`Move Here`:``}),c&&(0,b.jsx)(`div`,{className:m+` `+(r===`right`?g:h),style:{writingMode:`vertical-lr`},onDragOver:function(e){d(e,`right`)},onDrop:function(e){p(e,`right`)},children:`Split Right`}),c&&(0,b.jsx)(`div`,{className:m+` col-span-3 `+(r===`bottom`?g:h),onDragOver:function(e){d(e,`bottom`)},onDrop:function(e){p(e,`bottom`)},children:`Split Down`})]})})}var j7={files:cP,terminal:KN,notes:uP,tasks:_P,bookmarks:yP,brainstorm:CP,analytics:jQ,specs:KQe},qQe=[{type:`chat`,icon:U_,label:`Chat`,hint:`New session`},{type:`files`,icon:Wm,label:`Files`,hint:`Browse project`},{type:`terminal`,icon:vv,label:`Terminal`,hint:`Shell access`},{type:`notes`,icon:bv,label:`Notes`,hint:`Project notes`},{type:`specs`,icon:bd,label:`Specs`,hint:`Design specs`},{type:`analytics`,icon:Il,label:`Analytics`,hint:`Usage data`}];function JQe(){return(0,b.jsx)(`div`,{className:`flex-1 flex items-center justify-center min-h-0`,children:(0,b.jsxs)(`div`,{className:`flex flex-col items-center gap-8 max-w-md px-6`,children:[(0,b.jsxs)(`div`,{className:`flex flex-col items-center gap-2`,children:[(0,b.jsx)(`span`,{className:`font-mono text-[11px] font-bold tracking-widest uppercase text-base-content/30`,children:`No open tabs`}),(0,b.jsx)(`span`,{className:`text-[13px] text-base-content/40`,children:`Select a session from the sidebar or open a workspace tool.`})]}),(0,b.jsx)(`div`,{className:`grid grid-cols-3 gap-1.5 w-full max-w-xs`,children:qQe.map(function(e){return(0,b.jsxs)(`button`,{onClick:function(){Wv(e.type)},className:`group flex flex-col items-center gap-1 px-3 py-3 rounded-lg border border-base-content/10 hover:border-base-content/20 hover:bg-base-200/50 transition-colors cursor-pointer`,children:[(0,b.jsx)(e.icon,{size:16,className:`text-base-content/30 group-hover:text-base-content/60 transition-colors`}),(0,b.jsx)(`span`,{className:`font-mono text-[11px] font-medium text-base-content/50 group-hover:text-base-content/70 transition-colors`,children:e.label}),(0,b.jsx)(`span`,{className:`text-[10px] text-base-content/25 group-hover:text-base-content/40 transition-colors`,children:e.hint})]},e.type)})})]})})}function M7({pane:e,tabs:t,isActive:n,onFocus:r}){var i=_b(),a=e.tabIds.map(function(e){return t.find(function(t){return t.id===e})}).filter(function(e){return e!=null});return(0,b.jsxs)(`div`,{className:`flex flex-col h-full w-full overflow-hidden`,onClick:r,children:[(0,b.jsx)(Wb,{paneId:e.id,isActivePane:n}),!i&&(0,b.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 bg-warning/10 border-b border-warning/20 flex-shrink-0`,children:[(0,b.jsx)(Av,{size:13,className:`text-warning flex-shrink-0`}),(0,b.jsx)(`span`,{className:`text-[12px] text-warning`,children:`Disconnected — viewing only`})]}),(0,b.jsxs)(`div`,{className:`flex-1 min-h-0 relative`,children:[(0,b.jsx)(A7,{paneId:e.id}),a.map(function(t){var n=t.id===e.activeTabId;if(t.type===`chat`)return(0,b.jsx)(`div`,{className:`absolute inset-0`,style:{display:n?`flex`:`none`,flexDirection:`column`},children:(0,b.jsx)(BT,{sessionId:t.sessionId,projectSlug:t.projectSlug})},t.id);var r=j7[t.type];return r?(0,b.jsx)(`div`,{className:`absolute inset-0`,style:{display:n?`flex`:`none`,flexDirection:`column`},children:(0,b.jsx)(r,{})},t.id):null})]})]})}function YQe(){var{tabs:e,panes:t,activePaneId:n,splitDirection:r,splitRatio:i,setSplitRatio:a,setActivePaneId:o}=Vb(),s=_b();if(!r||t.length<2){var c=t[0],l=e.length>0&&c&&c.tabIds.length>0;return(0,b.jsxs)(`div`,{className:`flex flex-col h-full w-full overflow-hidden`,children:[l&&(0,b.jsx)(Wb,{paneId:c?.id}),!s&&(0,b.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 bg-warning/10 border-b border-warning/20 flex-shrink-0 order-0 sm:order-none`,children:[(0,b.jsx)(Av,{size:13,className:`text-warning flex-shrink-0`}),(0,b.jsx)(`span`,{className:`text-[12px] text-warning`,children:`Disconnected — viewing only`})]}),l?(0,b.jsxs)(`div`,{className:`flex-1 min-h-0 relative order-0 sm:order-none`,children:[(0,b.jsx)(A7,{paneId:c?.id||`pane-1`}),e.map(function(e){var t=c?e.id===c.activeTabId:e.id===`chat`;if(e.type===`chat`)return(0,b.jsx)(`div`,{className:`absolute inset-0`,style:{display:t?`flex`:`none`,flexDirection:`column`},children:(0,b.jsx)(BT,{sessionId:e.sessionId,projectSlug:e.projectSlug})},e.id);var n=j7[e.type];return n?(0,b.jsx)(`div`,{className:`absolute inset-0`,style:{display:t?`flex`:`none`,flexDirection:`column`},children:(0,b.jsx)(n,{})},e.id):null})]}):(0,b.jsx)(JQe,{})]})}return(0,b.jsxs)(Uve,{direction:r,ratio:i,onRatioChange:a,children:[(0,b.jsx)(M7,{pane:t[0],tabs:e,isActive:n===t[0].id,onFocus:function(){o(t[0].id)}}),(0,b.jsx)(M7,{pane:t[1],tabs:e,isActive:n===t[1].id,onFocus:function(){o(t[1].id)}})]})}function XQe(){return(0,b.jsx)(Vve,{children:(0,b.jsx)(YQe,{})})}var ZQe=[`dracula`,`catppuccin-mocha`,`tokyo-night`,`one-dark`,`amoled`],QQe=[`ayu-light`,`catppuccin-latte`,`github-light`,`one-light`,`rose-pine-dawn`],N7=6;function $Qe(e){var[t,n]=(0,x.useState)(1),[r,i]=(0,x.useState)(1),[a,o]=(0,x.useState)(!1),[s,c]=(0,x.useState)(``),[l,u]=(0,x.useState)(``),[d,f]=(0,x.useState)(``),[p,m]=(0,x.useState)(``),[h,g]=(0,x.useState)(``),[_,v]=(0,x.useState)(``),[y,S]=(0,x.useState)([]),C=Mb(),w=R();function T(e){a||(i(t),o(!0),setTimeout(function(){n(e),o(!1)},180))}function E(){T(Math.min(t+1,N7))}function D(){T(Math.max(t-1,1))}function O(){E()}function k(){var e=s.trim();e.length>0&&(w.send({type:`settings:update`,settings:{name:e}}),S(function(t){return[...t.filter(function(e){return e!==`name`}),`name: `+e]})),E()}function A(){S(function(e){var t=`theme: `+C.currentThemeId+` (`+C.mode+`)`;return[...e.filter(function(e){return!e.startsWith(`theme:`)}),t]}),E()}function j(){if(l.length===0){E();return}if(l!==d){m(`Passphrases do not match`);return}w.send({type:`settings:update`,settings:{passphraseHash:l}}),S(function(e){return[...e.filter(function(e){return e!==`security`}),`security: passphrase set`]}),E()}function M(){var e=h.trim();if(e.length>0){var t=e.replace(/\/+$/,``).split(`/`).pop()||e,n=_.trim()||t;w.send({type:`settings:update`,settings:{projects:[{path:e,slug:``,title:n,env:{}}]}}),S(function(e){return[...e.filter(function(e){return!e.startsWith(`project:`)}),`project: `+n]})}E()}function N(){w.send({type:`settings:update`,settings:{setupComplete:!0}}),e.onComplete()}var ee=kb.filter(function(e){return ZQe.includes(e.id)}),te=kb.filter(function(e){return QQe.includes(e.id)}),P=t>r;return(0,b.jsxs)(`div`,{className:`fixed inset-0 z-[9999] flex items-center justify-center bg-base-100 transition-colors duration-300`,children:[(0,b.jsx)(`style`,{children:s$e}),t===1?(0,b.jsxs)(`div`,{className:`relative w-full max-w-[520px] px-6 py-12 flex flex-col items-center text-center`,children:[(0,b.jsx)(`div`,{className:`fixed inset-0 pointer-events-none z-0`,"aria-hidden":`true`,style:{backgroundImage:`linear-gradient(oklch(from var(--color-primary) l c h / 0.07) 1px, transparent 1px), linear-gradient(90deg, oklch(from var(--color-primary) l c h / 0.07) 1px, transparent 1px)`,backgroundSize:`40px 40px`,animation:`wizard-grid-shift 8s linear infinite`}}),(0,b.jsxs)(`div`,{className:`relative z-[1] flex flex-col items-center gap-0`,children:[(0,b.jsx)(`div`,{className:`wizard-fade-in text-primary`,style:{animationDelay:`0ms`},children:(0,b.jsx)(Iv,{size:64})}),(0,b.jsx)(`h1`,{className:`wizard-fade-in font-mono font-bold text-base-content leading-none mt-5 mb-0`,style:{fontSize:`clamp(48px, 10vw, 72px)`,letterSpacing:`-0.04em`,animationDelay:`80ms`},children:`Lattice`}),(0,b.jsx)(`p`,{className:`wizard-fade-in text-[17px] text-base-content/60 mt-3 mb-8 tracking-[0.01em]`,style:{animationDelay:`160ms`},children:`One dashboard. Every machine.`}),(0,b.jsx)(`div`,{className:`wizard-fade-in`,style:{animationDelay:`240ms`},children:(0,b.jsx)(e$e,{})}),(0,b.jsx)(`div`,{className:`wizard-fade-in`,style:{animationDelay:`320ms`},children:(0,b.jsxs)(`button`,{onClick:E,className:`wizard-btn-primary btn btn-primary inline-flex items-center gap-2 mt-7 h-[52px] px-8 text-[15px] font-semibold cursor-pointer`,children:[`Get Started`,(0,b.jsx)(Ta,{size:16})]})}),(0,b.jsx)(`p`,{className:`wizard-fade-in text-[12px] text-base-content/30 mt-4`,style:{animationDelay:`380ms`},children:`Takes about 2 minutes`})]})]}):(0,b.jsxs)(`div`,{className:`w-[480px] max-w-[calc(100vw-24px)] bg-base-200 border border-base-300 rounded-xl flex flex-col overflow-hidden shadow-2xl`,children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between px-6 py-4 border-b border-base-300 bg-base-100`,children:[(0,b.jsx)(`div`,{className:`flex items-center gap-1.5`,children:Array.from({length:N7-1},function(e,n){var r=n+2,i=t>r,a=t===r;return(0,b.jsx)(`div`,{className:`h-1.5 rounded-full transition-all duration-[250ms]`,style:{background:i||a?`var(--color-primary)`:`var(--color-base-300)`,opacity:a?1:i?.7:.35,width:a?`24px`:`8px`}},n)})}),(0,b.jsxs)(`span`,{className:`text-[11px] text-base-content/40 font-mono tracking-[0.06em]`,children:[t-1,` / `,N7-1]})]}),(0,b.jsxs)(`div`,{className:`px-7 pt-7 pb-2 flex-1 min-h-[320px] `+(a?P?`wizard-slide-out-left`:`wizard-slide-out-right`:P?`wizard-slide-in-right`:`wizard-slide-in-left`),children:[t===2&&(0,b.jsx)(t$e,{value:s,onChange:c}),t===3&&(0,b.jsx)(n$e,{theme:C,darkQuickPicks:ee,lightQuickPicks:te}),t===4&&(0,b.jsx)(r$e,{passphrase:l,passphraseConfirm:d,error:p,onPassphraseChange:function(e){u(e),m(``)},onConfirmChange:function(e){f(e),m(``)}}),t===5&&(0,b.jsx)(a$e,{path:h,title:_,onPathChange:g,onTitleChange:v}),t===6&&(0,b.jsx)(o$e,{configured:y})]},t),(0,b.jsxs)(`div`,{className:`flex items-center gap-2 px-6 py-4 border-t border-base-300 bg-base-100`,children:[t>=2&&t<N7&&(0,b.jsxs)(`button`,{onClick:D,className:`wizard-btn-back btn btn-ghost btn-sm gap-1 text-base-content/40`,children:[(0,b.jsx)(su,{size:14}),`Back`]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2 ml-auto`,children:[t===2&&(0,b.jsx)(`button`,{onClick:O,className:`wizard-btn-skip btn btn-ghost btn-sm text-base-content/40`,children:`Skip`}),t===3&&(0,b.jsxs)(`button`,{onClick:A,className:`wizard-btn-primary btn btn-primary btn-sm gap-1`,children:[`Continue`,(0,b.jsx)(cu,{size:14})]}),t===4&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`button`,{onClick:O,className:`wizard-btn-skip btn btn-ghost btn-sm text-base-content/40`,children:`Skip`}),(0,b.jsxs)(`button`,{onClick:j,className:`wizard-btn-primary btn btn-primary btn-sm gap-1`,children:[`Continue`,(0,b.jsx)(cu,{size:14})]})]}),t===5&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`button`,{onClick:O,className:`wizard-btn-skip btn btn-ghost btn-sm text-base-content/40`,children:`Skip`}),(0,b.jsxs)(`button`,{onClick:M,className:`wizard-btn-primary btn btn-primary btn-sm gap-1`,children:[`Add & Continue`,(0,b.jsx)(cu,{size:14})]})]}),t===6&&(0,b.jsxs)(`button`,{onClick:N,className:`wizard-btn-done btn btn-success btn-sm gap-2 font-bold`,children:[`Open Dashboard`,(0,b.jsx)(Ta,{size:16})]}),t===2&&(0,b.jsxs)(`button`,{onClick:k,className:`wizard-btn-primary btn btn-primary btn-sm gap-1`,children:[`Continue`,(0,b.jsx)(cu,{size:14})]})]})]})]})]})}function e$e(){var[e,t]=(0,x.useState)(0),n=[{prefix:`$ `,text:`lattice`,color:`var(--color-base-content)`},{prefix:``,text:` [lattice] Daemon started (PID 4821)`,color:`oklch(from var(--color-base-content) l c h / 0.5)`},{prefix:``,text:` [lattice] Listening on https://0.0.0.0:7654`,color:`var(--color-success)`},{prefix:``,text:` [discovery] Found 2 nodes on mesh`,color:`var(--color-primary)`}];return(0,x.useEffect)(function(){var e=[];return n.forEach(function(n,r){e.push(setTimeout(function(){t(r+1)},600+r*600))}),function(){e.forEach(clearTimeout)}},[]),(0,b.jsxs)(`div`,{className:`w-[380px] max-w-[calc(100vw-48px)] bg-base-200 border border-base-300 rounded-xl overflow-hidden shadow-2xl`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-1.5 px-3.5 py-2.5 bg-base-300 border-b border-base-300`,children:[(0,b.jsx)(`span`,{className:`w-2.5 h-2.5 rounded-full bg-error opacity-80 flex-shrink-0`}),(0,b.jsx)(`span`,{className:`w-2.5 h-2.5 rounded-full bg-warning opacity-80 flex-shrink-0`}),(0,b.jsx)(`span`,{className:`w-2.5 h-2.5 rounded-full bg-success opacity-80 flex-shrink-0`}),(0,b.jsx)(`span`,{className:`text-[11px] text-base-content/40 font-mono mx-auto tracking-[0.02em]`,children:`lattice — zsh`})]}),(0,b.jsxs)(`div`,{className:`px-4 py-3.5 flex flex-col gap-1 min-h-[96px]`,children:[n.map(function(t,n){return(0,b.jsxs)(`div`,{className:`text-[12px] font-mono leading-relaxed whitespace-pre transition-all duration-200`,style:{opacity:n<e?1:0,transform:n<e?`translateY(0)`:`translateY(4px)`,color:t.color},children:[t.prefix&&(0,b.jsx)(`span`,{style:{color:`var(--color-primary)`},children:t.prefix}),(0,b.jsx)(`span`,{children:t.text})]},n)}),(0,b.jsxs)(`div`,{className:`flex items-center gap-0.5 text-[12px] font-mono mt-0.5`,children:[(0,b.jsx)(`span`,{style:{color:`var(--color-primary)`},children:`$ `}),(0,b.jsx)(`span`,{className:`inline-block w-2 h-3.5 rounded-[1px] align-middle opacity-90`,style:{background:`var(--color-primary)`,animation:`wizard-cursor-blink 1s step-end infinite`}})]})]})]})}function t$e(e){var t=e.value.trim()||`this-machine`;return(0,b.jsxs)(`div`,{className:`flex flex-col`,children:[(0,b.jsx)(`div`,{className:`flex items-center mb-3.5`,children:(0,b.jsx)(mv,{size:22,className:`text-primary`})}),(0,b.jsx)(`h2`,{className:`font-mono text-[22px] font-bold text-base-content tracking-tight mb-2 leading-tight`,children:`Name this machine`}),(0,b.jsx)(`p`,{className:`text-[13px] text-base-content/60 leading-relaxed mb-5`,children:`Give this node a recognizable name. It appears in your mesh when you connect multiple computers.`}),(0,b.jsxs)(`fieldset`,{className:`fieldset mb-3.5`,children:[(0,b.jsx)(`legend`,{className:`fieldset-legend text-[11px] font-semibold text-base-content/40 uppercase tracking-[0.08em]`,children:`Machine name`}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2 bg-base-300 border border-base-content/20 rounded-md px-3 h-[44px] focus-within:border-primary transition-colors duration-[120ms]`,children:[(0,b.jsx)(`span`,{className:`text-primary font-mono font-bold text-[16px]`,children:`>`}),(0,b.jsx)(`input`,{type:`text`,value:e.value,onChange:function(t){e.onChange(t.target.value)},placeholder:`my-laptop`,"aria-label":`Machine name`,className:`flex-1 bg-transparent text-base-content font-mono text-[14px] outline-none`,autoFocus:!0,spellCheck:!1})]})]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 bg-base-300 border border-base-content/10 rounded-md`,children:[(0,b.jsx)(`span`,{className:`text-[10px] uppercase tracking-[0.08em] text-base-content/40 font-semibold`,children:`Preview`}),(0,b.jsx)(`span`,{className:`font-mono text-[13px] font-semibold text-base-content`,children:t}),(0,b.jsx)(`span`,{className:`text-base-content/30 text-[12px]`,children:`will appear on your mesh`})]})]})}function n$e(e){var{theme:t,darkQuickPicks:n,lightQuickPicks:r}=e,i=t.mode===`dark`?n:r;return(0,b.jsxs)(`div`,{className:`flex flex-col`,children:[(0,b.jsx)(`div`,{className:`flex items-center mb-3.5`,children:(0,b.jsx)(X_,{size:22,className:`text-primary`})}),(0,b.jsx)(`h2`,{className:`font-mono text-[22px] font-bold text-base-content tracking-tight mb-2 leading-tight`,children:`Choose appearance`}),(0,b.jsx)(`p`,{className:`text-[13px] text-base-content/60 leading-relaxed mb-4`,children:`Pick a color theme. You can always change this in settings.`}),(0,b.jsxs)(`div`,{className:`flex gap-1.5 mb-4 p-1 bg-base-300 rounded-lg w-fit`,children:[(0,b.jsxs)(`button`,{onClick:function(){t.mode!==`dark`&&t.toggleMode()},className:`flex items-center gap-1.5 px-3 py-1.5 rounded-md text-[13px] font-medium transition-all duration-[120ms] cursor-pointer `+(t.mode===`dark`?`bg-primary text-primary-content`:`text-base-content/60 hover:text-base-content`),children:[(0,b.jsx)(q_,{size:13}),`Dark`]}),(0,b.jsxs)(`button`,{onClick:function(){t.mode!==`light`&&t.toggleMode()},className:`flex items-center gap-1.5 px-3 py-1.5 rounded-md text-[13px] font-medium transition-all duration-[120ms] cursor-pointer `+(t.mode===`light`?`bg-primary text-primary-content`:`text-base-content/60 hover:text-base-content`),children:[(0,b.jsx)(Sv,{size:13}),`Light`]})]}),(0,b.jsx)(`div`,{className:`grid gap-2 mb-4`,style:{gridTemplateColumns:`repeat(auto-fill, minmax(80px, 1fr))`},children:i.map(function(e){var n=e.id===t.currentThemeId,r=`#`+e.theme.base00,i=`#`+e.theme.base0D,a=`#`+e.theme.base05,o=`#`+e.theme.base08,s=`#`+e.theme.base0B;return(0,b.jsxs)(`button`,{onClick:function(){t.setTheme(e.id)},title:e.theme.name,className:`relative flex flex-col gap-1.5 p-0 rounded-md overflow-hidden cursor-pointer border-2 transition-all duration-[120ms] `+(n?`border-primary`:`border-transparent hover:border-base-content/20`),children:[(0,b.jsxs)(`div`,{className:`w-full h-[48px] flex flex-col`,style:{background:r},children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-1 px-1.5 py-1`,style:{background:`#`+e.theme.base01},children:[(0,b.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full`,style:{background:o}}),(0,b.jsx)(`span`,{className:`w-6 h-1 rounded`,style:{background:i,opacity:.7}})]}),(0,b.jsxs)(`div`,{className:`flex flex-col gap-[3px] px-1.5 py-1`,children:[(0,b.jsx)(`div`,{className:`h-[3px] rounded w-[80%]`,style:{background:i,opacity:.8}}),(0,b.jsx)(`div`,{className:`h-[3px] rounded w-[60%]`,style:{background:a,opacity:.4}}),(0,b.jsx)(`div`,{className:`h-[3px] rounded w-[70%]`,style:{background:s,opacity:.6}})]})]}),(0,b.jsx)(`span`,{className:`text-[10px] text-base-content/60 truncate px-1.5 pb-1`,children:e.theme.name}),n&&(0,b.jsx)(`div`,{className:`absolute top-1 right-1 w-3.5 h-3.5 rounded-full bg-primary flex items-center justify-center`,children:(0,b.jsx)(L,{size:8,className:`text-primary-content`})})]},e.id)})}),(0,b.jsxs)(`div`,{className:`rounded-lg border border-base-300 overflow-hidden transition-all duration-300`,children:[(0,b.jsx)(`div`,{className:`text-[9px] font-mono tracking-[0.05em] uppercase text-base-content/40 px-2.5 py-1.5 bg-base-300 border-b border-base-300 transition-all duration-300`,children:`Preview`}),(0,b.jsxs)(`div`,{className:`flex h-[100px] bg-base-100 transition-all duration-300`,children:[(0,b.jsxs)(`div`,{className:`w-[72px] flex-shrink-0 border-r border-base-300 p-2 flex flex-col gap-1`,children:[(0,b.jsx)(`div`,{className:`text-[8px] font-mono text-base-content/30 uppercase tracking-[0.05em] mb-0.5`,children:`Projects`}),(0,b.jsx)(`div`,{className:`h-1.5 w-[90%] rounded bg-primary opacity-80`}),(0,b.jsx)(`div`,{className:`h-1.5 w-[70%] rounded bg-base-300`}),(0,b.jsx)(`div`,{className:`h-1.5 w-[80%] rounded bg-base-300`})]}),(0,b.jsxs)(`div`,{className:`flex-1 p-2.5 flex flex-col gap-1.5`,children:[(0,b.jsx)(`div`,{className:`text-[9px] font-mono font-semibold text-base-content`,children:`New Session`}),(0,b.jsx)(`div`,{className:`flex-1 flex flex-col gap-[3px] justify-center`,children:(0,b.jsxs)(`div`,{className:`flex gap-1 items-start`,children:[(0,b.jsx)(`div`,{className:`w-3 h-3 rounded-full bg-primary flex-shrink-0 opacity-60`}),(0,b.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,b.jsx)(`div`,{className:`h-1 w-[120px] rounded bg-base-content/20`}),(0,b.jsx)(`div`,{className:`h-1 w-[80px] rounded bg-base-content/15`})]})]})}),(0,b.jsx)(`div`,{className:`h-[18px] rounded bg-base-200 border border-base-300`})]})]})]})]})}function r$e(e){var t=i$e(e.passphrase);return(0,b.jsxs)(`div`,{className:`flex flex-col`,children:[(0,b.jsx)(`div`,{className:`flex items-center mb-3.5`,children:(0,b.jsx)(M_,{size:22,className:`text-primary`})}),(0,b.jsx)(`h2`,{className:`font-mono text-[22px] font-bold text-base-content tracking-tight mb-2 leading-tight`,children:`Set a passphrase`}),(0,b.jsxs)(`div`,{className:`flex gap-2 p-3 bg-base-300 border border-base-300 rounded-md mb-4`,children:[(0,b.jsx)(Zh,{size:16,className:`text-base-content/40 flex-shrink-0 mt-[1px]`}),(0,b.jsx)(`p`,{className:`text-[12px] text-base-content/50 leading-relaxed`,children:`Optional. Protects your dashboard on shared networks. Node-to-node connections use separate key-based auth.`})]}),(0,b.jsxs)(`fieldset`,{className:`fieldset mb-3.5`,children:[(0,b.jsx)(`legend`,{className:`fieldset-legend text-[11px] font-semibold text-base-content/40 uppercase tracking-[0.08em]`,children:`Passphrase`}),(0,b.jsx)(`input`,{type:`password`,value:e.passphrase,onChange:function(t){e.onPassphraseChange(t.target.value)},placeholder:`Leave blank to skip`,"aria-label":`Passphrase`,className:`input input-bordered w-full bg-base-300 text-base-content text-[14px] focus:border-primary`,autoFocus:!0}),e.passphrase.length>0&&(0,b.jsxs)(`div`,{className:`flex items-center gap-2 mt-1.5`,children:[(0,b.jsx)(`div`,{className:`flex-1 h-1 bg-base-300 rounded-full overflow-hidden`,children:(0,b.jsx)(`div`,{className:`h-full rounded-full transition-all duration-200`,style:{width:t.pct+`%`,background:t.color}})}),(0,b.jsx)(`span`,{className:`text-[11px] font-semibold`,style:{color:t.color},children:t.label})]})]}),e.passphrase.length>0&&(0,b.jsxs)(`fieldset`,{className:`fieldset mb-3.5`,children:[(0,b.jsx)(`legend`,{className:`fieldset-legend text-[11px] font-semibold text-base-content/40 uppercase tracking-[0.08em]`,children:`Confirm passphrase`}),(0,b.jsx)(`input`,{type:`password`,value:e.passphraseConfirm,onChange:function(t){e.onConfirmChange(t.target.value)},placeholder:`Repeat passphrase`,"aria-label":`Confirm passphrase`,className:`input input-bordered w-full bg-base-300 text-base-content text-[14px] focus:border-primary `+(e.error?`border-error`:``)})]}),e.error&&(0,b.jsx)(`p`,{className:`text-[12px] text-error mt-1`,children:e.error})]})}function i$e(e){return e.length===0?{pct:0,label:``,color:`oklch(from var(--color-base-content) l c h / 0.5)`}:e.length<8?{pct:25,label:`Weak`,color:`var(--color-error)`}:e.length<14?{pct:55,label:`Fair`,color:`var(--color-warning)`}:e.length<20?{pct:80,label:`Good`,color:`var(--color-primary)`}:{pct:100,label:`Strong`,color:`var(--color-success)`}}function a$e(e){return(0,b.jsxs)(`div`,{className:`flex flex-col`,children:[(0,b.jsx)(`div`,{className:`flex items-center mb-3.5`,children:(0,b.jsx)(Gm,{size:22,className:`text-primary`})}),(0,b.jsx)(`h2`,{className:`font-mono text-[22px] font-bold text-base-content tracking-tight mb-2 leading-tight`,children:`Add your first project`}),(0,b.jsx)(`p`,{className:`text-[13px] text-base-content/60 leading-relaxed mb-5`,children:`Point Lattice at a local directory. Claude runs inside that workspace. Add more projects from the sidebar anytime.`}),(0,b.jsxs)(`fieldset`,{className:`fieldset mb-3.5`,children:[(0,b.jsx)(`legend`,{className:`fieldset-legend text-[11px] font-semibold text-base-content/40 uppercase tracking-[0.08em]`,children:`Project path`}),(0,b.jsx)(`input`,{type:`text`,value:e.path,onChange:function(t){e.onPathChange(t.target.value)},placeholder:`/home/you/projects/my-app`,"aria-label":`Project path`,className:`input input-bordered w-full bg-base-300 text-base-content font-mono text-[14px] focus:border-primary`,autoFocus:!0,spellCheck:!1}),(0,b.jsx)(`p`,{className:`fieldset-label text-[11px] text-base-content/30 mt-1`,children:`Absolute path to a local directory on this machine.`})]}),(0,b.jsxs)(`fieldset`,{className:`fieldset mb-3.5`,children:[(0,b.jsxs)(`legend`,{className:`fieldset-legend text-[11px] font-semibold text-base-content/40 uppercase tracking-[0.08em]`,children:[`Display name `,(0,b.jsx)(`span`,{className:`font-normal normal-case tracking-normal`,children:`(optional)`})]}),(0,b.jsx)(`input`,{type:`text`,value:e.title,onChange:function(t){e.onTitleChange(t.target.value)},placeholder:e.path&&e.path.replace(/\/+$/,``).split(`/`).pop()||`My App`,"aria-label":`Display name`,className:`input input-bordered w-full bg-base-300 text-base-content text-[14px] focus:border-primary`})]})]})}function o$e(e){return(0,b.jsxs)(`div`,{className:`flex flex-col items-center text-center`,children:[(0,b.jsx)(`div`,{className:`wizard-check-pop mb-4`,children:(0,b.jsx)(ju,{size:36,className:`text-success`,strokeWidth:1.5,"aria-hidden":`true`})}),(0,b.jsx)(`h2`,{className:`font-mono text-[26px] font-bold text-base-content tracking-tight mb-2`,children:`You're all set`}),(0,b.jsx)(`p`,{className:`text-[13px] text-base-content/60 leading-relaxed mb-5`,children:`Lattice is configured and ready to go.`}),e.configured.length>0?(0,b.jsx)(`ul`,{className:`list-none p-0 m-0 flex flex-col gap-1.5 text-left w-full`,children:e.configured.map(function(e,t){return(0,b.jsxs)(`li`,{className:`wizard-fade-in flex items-center gap-2 bg-base-300 px-3 py-2 rounded-md`,"data-delay":t*60,children:[(0,b.jsx)(`span`,{className:`w-4 h-4 rounded-full bg-success/20 text-success flex items-center justify-center flex-shrink-0`,children:(0,b.jsx)(L,{size:10})}),(0,b.jsx)(`span`,{className:`font-mono text-[12px] text-base-content/60`,children:e})]},t)})}):(0,b.jsx)(`p`,{className:`text-[11px] text-base-content/30`,children:`Everything was skipped — configure it from settings anytime.`})]})}var s$e=`
559
559
  @keyframes wizard-fade-in {
560
560
  from { opacity: 0; transform: translateY(12px); }
561
561
  to { opacity: 1; transform: translateY(0); }
@@ -644,16 +644,16 @@ ${t.slice(l+2)}`,d+=1;else break}t.push({indent:l,number:parseInt(s,10),content:
644
644
  transform: none !important;
645
645
  }
646
646
  }
647
- `;function P7(e){return`#`+e.replace(/^#/,``)}function F7(e){var t=e.colors,n=(0,x.useMemo)(function(){return{"--preview-bg":P7(t.base00||`1f1f28`),"--preview-surface":P7(t.base01||`2a2a37`),"--preview-selection":P7(t.base02||`363646`),"--preview-comment":P7(t.base03||`54546d`),"--preview-dark-fg":P7(t.base04||`727169`),"--preview-fg":P7(t.base05||`dcd7ba`),"--preview-light-fg":P7(t.base06||`c8c093`),"--preview-bright-fg":P7(t.base07||`ffffff`),"--preview-red":P7(t.base08||`c34043`),"--preview-orange":P7(t.base09||`ffa066`),"--preview-yellow":P7(t.base0A||`c0a36e`),"--preview-green":P7(t.base0B||`76946a`),"--preview-cyan":P7(t.base0C||`6a9589`),"--preview-blue":P7(t.base0D||`7e9cd8`),"--preview-purple":P7(t.base0E||`957fb8`),"--preview-brown":P7(t.base0F||`d27e99`)}},[t]);return e.compact?(0,b.jsx)(`div`,{className:`rounded-lg overflow-hidden border border-base-content/10`,style:{...n,background:`var(--preview-bg)`,color:`var(--preview-fg)`},children:(0,b.jsxs)(`div`,{className:`flex h-[80px]`,children:[(0,b.jsxs)(`div`,{className:`w-10 shrink-0 p-1.5 flex flex-col gap-1`,style:{background:`var(--preview-surface)`},children:[(0,b.jsx)(`div`,{className:`w-full h-1.5 rounded-full`,style:{background:`var(--preview-blue)`,opacity:.6}}),(0,b.jsx)(`div`,{className:`w-full h-1.5 rounded-full`,style:{background:`var(--preview-comment)`}}),(0,b.jsx)(`div`,{className:`w-full h-1.5 rounded-full`,style:{background:`var(--preview-comment)`}})]}),(0,b.jsxs)(`div`,{className:`flex-1 p-2 flex flex-col gap-1.5`,children:[(0,b.jsx)(`div`,{className:`flex justify-end`,children:(0,b.jsx)(`div`,{className:`rounded-lg px-2 py-1 text-[8px] max-w-[70%]`,style:{background:`var(--preview-blue)`,color:`var(--preview-bright-fg)`},children:`Hello world`})}),(0,b.jsx)(`div`,{className:`flex`,children:(0,b.jsx)(`div`,{className:`rounded-lg px-2 py-1 text-[8px] max-w-[70%]`,style:{background:`var(--preview-selection)`,color:`var(--preview-fg)`},children:`Response text`})})]})]})}):(0,b.jsx)(`div`,{className:`rounded-xl overflow-hidden border border-base-content/10 shadow-lg`,style:{...n,background:`var(--preview-bg)`,color:`var(--preview-fg)`},children:(0,b.jsxs)(`div`,{className:`flex h-[280px]`,children:[(0,b.jsxs)(`div`,{className:`w-[120px] shrink-0 p-3 flex flex-col gap-2 border-r`,style:{background:`var(--preview-surface)`,borderColor:`var(--preview-selection)`},children:[(0,b.jsx)(`div`,{className:`text-[10px] font-bold mb-1`,style:{color:`var(--preview-light-fg)`},children:`Projects`}),(0,b.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,b.jsx)(`div`,{className:`w-3 h-3 rounded`,style:{background:`var(--preview-blue)`,opacity:.3}}),(0,b.jsx)(`div`,{className:`text-[9px]`,style:{color:`var(--preview-fg)`},children:`lattice`})]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,b.jsx)(`div`,{className:`w-3 h-3 rounded`,style:{background:`var(--preview-green)`,opacity:.3}}),(0,b.jsx)(`div`,{className:`text-[9px]`,style:{color:`var(--preview-dark-fg)`},children:`my-app`})]}),(0,b.jsxs)(`div`,{className:`mt-auto`,children:[(0,b.jsx)(`div`,{className:`text-[8px] mb-1`,style:{color:`var(--preview-comment)`},children:`Sessions`}),(0,b.jsx)(`div`,{className:`text-[8px] truncate`,style:{color:`var(--preview-dark-fg)`},children:`Fix auth bug`}),(0,b.jsx)(`div`,{className:`text-[8px] truncate`,style:{color:`var(--preview-comment)`},children:`Add dark mode`})]})]}),(0,b.jsxs)(`div`,{className:`flex-1 flex flex-col`,children:[(0,b.jsxs)(`div`,{className:`flex-1 p-3 flex flex-col gap-2 overflow-hidden`,children:[(0,b.jsx)(`div`,{className:`flex justify-end`,children:(0,b.jsx)(`div`,{className:`rounded-xl px-3 py-1.5 text-[10px] max-w-[75%]`,style:{background:`var(--preview-blue)`,color:`var(--preview-bright-fg)`},children:`Can you fix the login page?`})}),(0,b.jsxs)(`div`,{className:`flex gap-2`,children:[(0,b.jsx)(`div`,{className:`w-4 h-4 rounded-full shrink-0 mt-0.5`,style:{background:`var(--preview-blue)`,opacity:.2}}),(0,b.jsxs)(`div`,{className:`rounded-xl px-3 py-1.5 text-[10px] max-w-[75%] border`,style:{background:`var(--preview-selection)`,borderColor:`var(--preview-comment)`,opacity:.3},children:[(0,b.jsx)(`span`,{style:{color:`var(--preview-fg)`},children:`I'll update the `}),(0,b.jsx)(`code`,{className:`px-1 rounded text-[9px]`,style:{background:`var(--preview-bg)`,color:`var(--preview-orange)`},children:`LoginForm`}),(0,b.jsx)(`span`,{style:{color:`var(--preview-fg)`},children:` component.`})]})]}),(0,b.jsxs)(`div`,{className:`rounded-lg p-2 text-[9px] font-mono border`,style:{background:`var(--preview-bg)`,borderColor:`var(--preview-selection)`},children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`span`,{style:{color:`var(--preview-purple)`},children:`function`}),` `,(0,b.jsx)(`span`,{style:{color:`var(--preview-blue)`},children:`login`}),(0,b.jsx)(`span`,{style:{color:`var(--preview-dark-fg)`},children:`(`}),(0,b.jsx)(`span`,{style:{color:`var(--preview-orange)`},children:`user`}),(0,b.jsx)(`span`,{style:{color:`var(--preview-dark-fg)`},children:`)`}),` `,`{`]}),(0,b.jsxs)(`div`,{className:`ml-3`,children:[(0,b.jsx)(`span`,{style:{color:`var(--preview-purple)`},children:`var`}),` `,(0,b.jsx)(`span`,{style:{color:`var(--preview-red)`},children:`token`}),` = `,(0,b.jsx)(`span`,{style:{color:`var(--preview-blue)`},children:`auth`}),`(`,(0,b.jsx)(`span`,{style:{color:`var(--preview-green)`},children:`"secret"`}),`);`]}),(0,b.jsxs)(`div`,{className:`ml-3`,children:[(0,b.jsx)(`span`,{style:{color:`var(--preview-purple)`},children:`return`}),` `,`{`,` `,(0,b.jsx)(`span`,{style:{color:`var(--preview-yellow)`},children:`ok`}),`: `,(0,b.jsx)(`span`,{style:{color:`var(--preview-orange)`},children:`true`}),` `,`}`,`;`]}),(0,b.jsx)(`div`,{children:`}`})]})]}),(0,b.jsx)(`div`,{className:`px-3 py-2 border-t`,style:{borderColor:`var(--preview-selection)`},children:(0,b.jsx)(`div`,{className:`rounded-lg px-3 py-1.5 text-[9px]`,style:{background:`var(--preview-surface)`,color:`var(--preview-comment)`},children:`Type a message...`})})]})]})})}function I7(e){return(0,b.jsx)(`div`,{className:`flex gap-0.5 rounded overflow-hidden`,children:[`base00`,`base01`,`base02`,`base03`,`base04`,`base05`,`base06`,`base07`,`base08`,`base09`,`base0A`,`base0B`,`base0C`,`base0D`,`base0E`,`base0F`].map(function(t){return(0,b.jsx)(`div`,{className:`h-4 flex-1`,style:{background:`#`+(e.colors[t]||`000000`).replace(/^#/,``)},title:t+`: #`+(e.colors[t]||`000000`)},t)})})}function L7(e){return/^#?[0-9a-fA-F]{6}$/.test(e)}function R7(e){return e.replace(/^#/,``).toLowerCase()}function z7(e){var t=R7(e);return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}function B7(e,t,n){return[e,t,n].map(function(e){return Math.max(0,Math.min(255,Math.round(e))).toString(16).padStart(2,`0`)}).join(``)}function V7(e){var t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4}function H7(e){var t=Math.max(0,Math.min(1,e));return t<=.0031308?t*12.92*255:(1.055*t**(1/2.4)-.055)*255}function U7(e,t,n){var r=V7(e),i=V7(t),a=V7(n),o=.4122214708*r+.5363325363*i+.0514459929*a,s=.2119034982*r+.6806995451*i+.1073969566*a,c=.0883024619*r+.2220049168*i+.6696926213*a,l=Math.cbrt(o),u=Math.cbrt(s),d=Math.cbrt(c),f=.2104542553*l+.793617785*u-.0040720468*d,p=1.9779984951*l-2.428592205*u+.4505937099*d,m=.0259040371*l+.7827717662*u-.808675766*d,h=Math.sqrt(p*p+m*m),g=Math.atan2(m,p)*180/Math.PI;return g<0&&(g+=360),{L:f,C:h,h:g}}function W7(e,t,n){var r=n*Math.PI/180,i=t*Math.cos(r),a=t*Math.sin(r),o=e+.3963377774*i+.2158037573*a,s=e-.1055613458*i-.0638541728*a,c=e-.0894841775*i-1.291485548*a,l=o*o*o,u=s*s*s,d=c*c*c,f=4.0767416621*l-3.3077115913*u+.2309699292*d,p=-1.2684380046*l+2.6097574011*u-.3413193965*d,m=-.0041960863*l-.7034186147*u+1.707614701*d;return[Math.round(H7(f)),Math.round(H7(p)),Math.round(H7(m))]}function G7(e,t,n){var[r,i,a]=z7(e),[o,s,c]=z7(t),l=U7(r,i,a),u=U7(o,s,c),d=l.L+(u.L-l.L)*n,f=l.C+(u.C-l.C)*n,p=l.C<.001?u.h:l.h,m=(u.C<.001?l.h:u.h)-p;m>180&&(m-=360),m<-180&&(m+=360);var h=p+m*n;h<0&&(h+=360),h>=360&&(h-=360);var[g,_,v]=W7(d,f,h);return B7(g,_,v)}function K7(e,t){var[n,r,i]=z7(e),a=U7(n,r,i),[o,s,c]=W7(Math.max(0,Math.min(1,a.L+t)),a.C,a.h);return B7(o,s,c)}function q7(e,t){var[n,r,i]=z7(e),a=U7(n,r,i),o=(a.h+t)%360;o<0&&(o+=360);var[s,c,l]=W7(a.L,a.C,o);return B7(s,c,l)}function J7(e,t){var[n,r,i]=z7(e),a=U7(n,r,i),o=a.L;t===`dark`?(o<.65&&(o=.65),o>.85&&(o=.85)):(o<.35&&(o=.35),o>.55&&(o=.55));var[s,c,l]=W7(o,a.C,a.h);return B7(s,c,l)}function s$e(e,t,n,r,i){var a=R7(e),o=R7(t),s=R7(n),c=R7(r);return{base00:a,base01:G7(a,o,.5),base02:o,base03:G7(o,s,.25),base04:G7(o,s,.45),base05:s,base06:i===`dark`?K7(s,.05):K7(s,-.05),base07:i===`dark`?K7(s,.15):K7(s,-.15),base08:J7(q7(c,0),i),base09:J7(q7(c,30),i),base0A:J7(q7(c,60),i),base0B:J7(q7(c,120),i),base0C:J7(q7(c,180),i),base0D:J7(c,i),base0E:J7(q7(c,270),i),base0F:J7(q7(c,330),i)}}var Y7=[`base00`,`base01`,`base02`,`base03`,`base04`,`base05`,`base06`,`base07`,`base08`,`base09`,`base0A`,`base0B`,`base0C`,`base0D`,`base0E`,`base0F`],X7={base00:`Background`,base01:`Lighter Background`,base02:`Selection`,base03:`Comments`,base04:`Dark Foreground`,base05:`Foreground`,base06:`Light Foreground`,base07:`Brightest`,base08:`Red / Variables`,base09:`Orange / Numbers`,base0A:`Yellow / Classes`,base0B:`Green / Strings`,base0C:`Cyan / Support`,base0D:`Blue / Functions`,base0E:`Purple / Keywords`,base0F:`Brown / Deprecated`};function Z7(){return{base00:`1a1a2e`,base01:`222240`,base02:`2a2a4a`,base03:`505070`,base04:`7a7a9a`,base05:`c0c0d0`,base06:`d0d0e0`,base07:`ffffff`,base08:`ff6b6b`,base09:`ffa06b`,base0A:`ffd06b`,base0B:`6bffa0`,base0C:`6bd0ff`,base0D:`6b9fff`,base0E:`c06bff`,base0F:`ff6bb0`}}function c$e(){return{base00:`f5f5f0`,base01:`e8e8e0`,base02:`d5d5cd`,base03:`999990`,base04:`666660`,base05:`333330`,base06:`222220`,base07:`000000`,base08:`c24040`,base09:`b06030`,base0A:`907020`,base0B:`408040`,base0C:`207080`,base0D:`3060b0`,base0E:`703090`,base0F:`a04060`}}function l$e(e){var t=R(),[n,r]=(0,x.useState)(1),[i,a]=(0,x.useState)(e.editTheme?.name||``),[o,s]=(0,x.useState)(e.editTheme?.author||``),[c,l]=(0,x.useState)(e.editTheme?.variant||`dark`),[u,d]=(0,x.useState)(null),[f,p]=(0,x.useState)(e.editTheme?.colors||Z7()),[m,h]=(0,x.useState)(f.base00),[g,_]=(0,x.useState)(f.base02),[v,y]=(0,x.useState)(f.base05),[S,C]=(0,x.useState)(f.base0D),[w,T]=(0,x.useState)(!1);function E(e){d(e);var t=kb.find(function(t){return t.theme.name===e});if(t){for(var n=t.theme,r={},i=0;i<Y7.length;i++)r[Y7[i]]=R7(n[Y7[i]]||`000000`);p(r),l(t.theme.variant),h(r.base00),_(r.base02),y(r.base05),C(r.base0D)}}function D(t){if(l(t),!u&&!e.editTheme){var n=t===`dark`?Z7():c$e();p(n),h(n.base00),_(n.base02),y(n.base05),C(n.base0D)}}function O(e,t){var n=R7(t);e===`bg`&&h(n),e===`surface`&&_(n),e===`fg`&&y(n),e===`accent`&&C(n)}(0,x.useEffect)(function(){n===2&&L7(m)&&L7(g)&&L7(v)&&L7(S)&&p(s$e(R7(m),R7(g),R7(v),R7(S),c))},[m,g,v,S,c,n]);function k(e,t){var n=R7(t);p(function(t){var r={...t};return r[e]=n,r})}function A(){t.send({type:`theme:save`,name:i||`Untitled Theme`,author:o||`Custom`,variant:c,colors:f}),e.onClose()}function j(){for(var e={name:i||`Untitled Theme`,author:o||`Custom`,variant:c},t=0;t<Y7.length;t++)e[Y7[t]]=f[Y7[t]];var n=new Blob([JSON.stringify(e,null,2)],{type:`application/json`}),r=URL.createObjectURL(n),a=document.createElement(`a`);a.href=r,a.download=(i||`custom-theme`).toLowerCase().replace(/[^a-z0-9]+/g,`-`)+`.json`,a.click(),URL.revokeObjectURL(r)}var M=n===1?i.trim().length>0:!0;return(0,cr.createPortal)((0,b.jsx)(`div`,{className:`fixed inset-0 z-[9999] flex items-center justify-center bg-base-content/60 backdrop-blur-sm`,onClick:e.onClose,children:(0,b.jsxs)(`div`,{className:`bg-base-200 border border-base-content/15 rounded-2xl shadow-2xl w-[90vw] max-w-[860px] max-h-[85vh] flex flex-col overflow-hidden`,onClick:function(e){e.stopPropagation()},children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between px-5 py-3.5 border-b border-base-content/10`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,b.jsx)(X_,{size:18,className:`text-primary`}),(0,b.jsx)(`h2`,{className:`text-sm font-semibold text-base-content`,children:e.editTheme?`Edit Theme`:`Create Theme`}),(0,b.jsx)(`div`,{className:`flex items-center gap-1 ml-2`,children:[1,2,3,4].map(function(e){return(0,b.jsx)(`div`,{className:`w-2 h-2 rounded-full transition-colors `+(e===n?`bg-primary`:e<n?`bg-primary/40`:`bg-base-content/15`)},e)})})]}),(0,b.jsx)(`button`,{onClick:e.onClose,className:`btn btn-ghost btn-sm btn-circle`,children:(0,b.jsx)(Nv,{size:16})})]}),(0,b.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-5`,children:[n===1&&(0,b.jsxs)(`div`,{className:`space-y-4`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{className:`text-xs font-medium text-base-content/50 uppercase tracking-wider mb-1.5 block`,children:`Theme Name`}),(0,b.jsx)(`input`,{type:`text`,value:i,onChange:function(e){a(e.target.value)},placeholder:`My Awesome Theme`,className:`input input-bordered w-full max-w-xs text-sm`,autoFocus:!0})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{className:`text-xs font-medium text-base-content/50 uppercase tracking-wider mb-1.5 block`,children:`Variant`}),(0,b.jsxs)(`div`,{className:`flex gap-2`,children:[(0,b.jsxs)(`button`,{onClick:function(){D(`dark`)},className:`btn btn-sm gap-2 `+(c===`dark`?`btn-primary`:`btn-ghost`),children:[(0,b.jsx)(q_,{size:14}),` Dark`]}),(0,b.jsxs)(`button`,{onClick:function(){D(`light`)},className:`btn btn-sm gap-2 `+(c===`light`?`btn-primary`:`btn-ghost`),children:[(0,b.jsx)(Sv,{size:14}),` Light`]})]})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{className:`text-xs font-medium text-base-content/50 uppercase tracking-wider mb-2 block`,children:`Start from (optional)`}),(0,b.jsx)(`div`,{className:`grid grid-cols-4 sm:grid-cols-6 gap-2 max-h-[300px] overflow-y-auto pr-1`,children:kb.filter(function(e){return e.theme.variant===c}).map(function(e){var t=u===e.theme.name;return(0,b.jsxs)(`button`,{onClick:function(){E(e.theme.name)},className:`relative rounded-lg border-2 p-1 transition-all cursor-pointer `+(t?`border-primary ring-2 ring-primary/20`:`border-transparent hover:border-base-content/20`),children:[(0,b.jsx)(I7,{colors:e.theme}),(0,b.jsx)(`div`,{className:`text-[9px] text-base-content/50 mt-1 truncate text-center`,children:e.theme.name}),t&&(0,b.jsx)(`div`,{className:`absolute -top-1 -right-1 w-4 h-4 rounded-full bg-primary flex items-center justify-center`,children:(0,b.jsx)(L,{size:10,className:`text-primary-content`})})]},e.id)})})]})]}),n===2&&(0,b.jsxs)(`div`,{className:`flex gap-6`,children:[(0,b.jsxs)(`div`,{className:`flex-1 space-y-4`,children:[(0,b.jsx)(`p`,{className:`text-xs text-base-content/40 mb-3`,children:`Pick 4 core colors. The remaining 12 are auto-derived.`}),(0,b.jsx)(Q7,{label:`Background`,sublabel:`base00 — Main background`,value:m,onChange:function(e){O(`bg`,e)}}),(0,b.jsx)(Q7,{label:`Surface`,sublabel:`base02 — Panels, selections`,value:g,onChange:function(e){O(`surface`,e)}}),(0,b.jsx)(Q7,{label:`Foreground`,sublabel:`base05 — Main text`,value:v,onChange:function(e){O(`fg`,e)}}),(0,b.jsx)(Q7,{label:`Accent`,sublabel:`base0D — Links, interactive elements`,value:S,onChange:function(e){O(`accent`,e)}})]}),(0,b.jsxs)(`div`,{className:`w-[320px] shrink-0`,children:[(0,b.jsx)(F7,{colors:f,variant:c}),(0,b.jsx)(`div`,{className:`mt-3`,children:(0,b.jsx)(I7,{colors:f})})]})]}),n===3&&(0,b.jsxs)(`div`,{className:`flex gap-6`,children:[(0,b.jsxs)(`div`,{className:`flex-1 space-y-3`,children:[(0,b.jsx)(`button`,{onClick:function(){T(!w)},className:`text-xs text-primary cursor-pointer hover:underline`,children:w?`Hide individual colors`:`Show individual colors`}),w&&(0,b.jsxs)(`div`,{className:`space-y-4`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-[10px] font-semibold text-base-content/30 uppercase tracking-wider mb-2`,children:`Backgrounds`}),(0,b.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:[`base00`,`base01`,`base02`,`base03`].map(function(e){return(0,b.jsx)(Q7,{label:e,sublabel:X7[e],value:f[e],onChange:function(t){k(e,t)},compact:!0},e)})})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-[10px] font-semibold text-base-content/30 uppercase tracking-wider mb-2`,children:`Foregrounds`}),(0,b.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:[`base04`,`base05`,`base06`,`base07`].map(function(e){return(0,b.jsx)(Q7,{label:e,sublabel:X7[e],value:f[e],onChange:function(t){k(e,t)},compact:!0},e)})})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-[10px] font-semibold text-base-content/30 uppercase tracking-wider mb-2`,children:`Syntax & UI`}),(0,b.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:[`base08`,`base09`,`base0A`,`base0B`,`base0C`,`base0D`,`base0E`,`base0F`].map(function(e){return(0,b.jsx)(Q7,{label:e,sublabel:X7[e],value:f[e],onChange:function(t){k(e,t)},compact:!0},e)})})]})]}),!w&&(0,b.jsx)(`p`,{className:`text-xs text-base-content/30`,children:`Colors were auto-derived from your core palette. Click above to fine-tune individual colors.`})]}),(0,b.jsxs)(`div`,{className:`w-[320px] shrink-0`,children:[(0,b.jsx)(F7,{colors:f,variant:c}),(0,b.jsx)(`div`,{className:`mt-3`,children:(0,b.jsx)(I7,{colors:f})})]})]}),n===4&&(0,b.jsxs)(`div`,{className:`space-y-4`,children:[(0,b.jsx)(F7,{colors:f,variant:c}),(0,b.jsxs)(`div`,{className:`flex gap-4`,children:[(0,b.jsxs)(`div`,{className:`flex-1`,children:[(0,b.jsx)(`label`,{className:`text-xs font-medium text-base-content/50 uppercase tracking-wider mb-1 block`,children:`Name`}),(0,b.jsx)(`input`,{type:`text`,value:i,onChange:function(e){a(e.target.value)},className:`input input-bordered input-sm w-full`})]}),(0,b.jsxs)(`div`,{className:`flex-1`,children:[(0,b.jsx)(`label`,{className:`text-xs font-medium text-base-content/50 uppercase tracking-wider mb-1 block`,children:`Author`}),(0,b.jsx)(`input`,{type:`text`,value:o,onChange:function(e){s(e.target.value)},placeholder:`Your name`,className:`input input-bordered input-sm w-full`})]})]}),(0,b.jsx)(I7,{colors:f})]})]}),(0,b.jsxs)(`div`,{className:`flex items-center justify-between px-5 py-3 border-t border-base-content/10`,children:[(0,b.jsx)(`div`,{children:n>1&&(0,b.jsxs)(`button`,{onClick:function(){r(n-1)},className:`btn btn-ghost btn-sm gap-1`,children:[(0,b.jsx)(su,{size:14}),` Back`]})}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n===4&&(0,b.jsxs)(`button`,{onClick:j,className:`btn btn-ghost btn-sm gap-1`,children:[(0,b.jsx)(nm,{size:14}),` Export JSON`]}),n<4?(0,b.jsxs)(`button`,{onClick:function(){r(n+1)},disabled:!M,className:`btn btn-primary btn-sm gap-1`,children:[`Next `,(0,b.jsx)(cu,{size:14})]}):(0,b.jsxs)(`button`,{onClick:A,className:`btn btn-primary btn-sm gap-1`,children:[(0,b.jsx)(lv,{size:14}),` Save Theme`]})]})]})]})}),document.body)}function Q7(e){var t=R7(e.value),n=`#`+t;return(0,b.jsxs)(`div`,{className:`flex items-center gap-2 `+(e.compact?``:`py-1`),children:[(0,b.jsxs)(`label`,{className:`relative cursor-pointer group`,children:[(0,b.jsx)(`div`,{className:`rounded-lg border-2 border-base-content/15 group-hover:border-base-content/30 transition-colors `+(e.compact?`w-7 h-7`:`w-9 h-9`),style:{background:n}}),(0,b.jsx)(`input`,{type:`color`,value:n,onChange:function(t){e.onChange(t.target.value)},className:`absolute inset-0 opacity-0 cursor-pointer w-full h-full`})]}),(0,b.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,b.jsx)(`div`,{className:`font-medium text-base-content/70 `+(e.compact?`text-[10px]`:`text-xs`),children:e.label}),e.sublabel&&(0,b.jsx)(`div`,{className:`text-[9px] text-base-content/30`,children:e.sublabel})]}),(0,b.jsx)(`input`,{type:`text`,value:t,onChange:function(t){e.onChange(t.target.value)},className:`input input-bordered font-mono `+(e.compact?`input-xs w-20 text-[10px]`:`input-sm w-24 text-xs`),maxLength:7})]})}var u$e=[`base00`,`base01`,`base02`,`base03`,`base04`,`base05`,`base06`,`base07`,`base08`,`base09`,`base0A`,`base0B`,`base0C`,`base0D`,`base0E`,`base0F`],d$e=(0,x.memo)(function({entry:e,active:t,onSelect:n}){var r=e.theme;function i(){n(e.id)}return(0,b.jsxs)(`button`,{onClick:i,className:`flex flex-col gap-2 p-3 sm:p-2.5 px-3 rounded-lg border cursor-pointer text-left transition-colors duration-[120ms] relative focus-visible:ring-2 focus-visible:ring-primary `+(t?`border-primary bg-base-300 shadow-sm`:`border-base-content/15 bg-base-300 hover:border-base-content/30`),children:[t&&(0,b.jsx)(`div`,{className:`absolute top-1.5 right-1.5 w-3.5 h-3.5 rounded-full bg-primary flex items-center justify-center`,children:(0,b.jsx)(L,{size:8,className:`text-primary-content`,strokeWidth:1.8})}),(0,b.jsx)(`div`,{className:`flex gap-[3px] flex-wrap w-[80px]`,children:u$e.map(function(e){return(0,b.jsx)(`div`,{className:`w-[10px] h-[10px] rounded-sm flex-shrink-0 ring-1 ring-base-content/10`,style:{background:`#`+r[e]}},e)})}),(0,b.jsx)(`div`,{className:`text-[12px] font-medium text-base-content`,children:r.name})]})});function $7({label:e,entries:t,currentThemeId:n,onSelect:r}){return t.length===0?null:(0,b.jsxs)(`div`,{className:`mb-6`,children:[(0,b.jsx)(`div`,{className:`text-[11px] font-mono font-bold tracking-[0.1em] uppercase text-base-content/40 mb-3`,children:e}),(0,b.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(100px,1fr))] gap-2`,children:t.map(function(e){return(0,b.jsx)(d$e,{entry:e,active:e.id===n,onSelect:r},e.id)})})]})}function f$e(){var e=R(),[t,n]=(0,x.useState)(!1),[r,i]=(0,x.useState)(null),a=yb(),{mode:o,currentThemeId:s,toggleMode:c,setTheme:l,themes:u,allThemes:d}=Mb(),f=(0,x.useMemo)(function(){return d.filter(function(e){return e.id.startsWith(`custom:`)}).map(function(e){var t={};for(var n of Object.keys(e.theme))n.startsWith(`base0`)&&(t[n]=e.theme[n]);return{name:e.theme.name,author:e.theme.author,variant:e.theme.variant,filename:e.id.replace(`custom:`,``),colors:t}})},[d]),p=(0,x.useMemo)(function(){return u.filter(function(e){return e.theme.variant===`dark`})},[u]),m=(0,x.useMemo)(function(){return u.filter(function(e){return e.theme.variant===`light`})},[u]),h=(0,x.useCallback)(function(e){l(e)},[l]);function g(e){i(e),n(!0)}function _(t){e.send({type:`theme:delete`,name:t.filename})}function v(e){var t={name:e.name,author:e.author,variant:e.variant};for(var n of Object.keys(e.colors))t[n]=e.colors[n];var r=new Blob([JSON.stringify(t,null,2)],{type:`application/json`}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=e.filename,a.click(),URL.revokeObjectURL(i)}return(0,b.jsxs)(`div`,{className:`py-2`,children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between mb-6`,children:[(0,b.jsx)(`div`,{className:`text-[12px] font-semibold text-base-content/40`,children:`Color Mode`}),(0,b.jsx)(`button`,{onClick:c,className:`btn btn-ghost btn-sm border border-base-content/20`,children:o===`dark`?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(Sv,{size:12}),`Switch to Light`]}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(q_,{size:12}),`Switch to Dark`]})})]}),(0,b.jsx)($7,{label:`Dark Themes`,entries:p,currentThemeId:s,onSelect:h}),(0,b.jsx)($7,{label:`Light Themes`,entries:m,currentThemeId:s,onSelect:h}),(0,b.jsxs)(`div`,{className:`mb-6`,children:[(0,b.jsx)(`div`,{className:`text-[11px] font-mono font-bold tracking-[0.1em] uppercase text-base-content/40 mb-3`,children:`Custom Themes`}),(0,b.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(100px,1fr))] gap-2`,children:[f.map(function(e){var t=`custom:`+e.filename,n=t===s;return(0,b.jsxs)(`button`,{onClick:function(){h(t)},onContextMenu:function(t){a.open(t,e)},"data-allow-context-menu":!0,className:`flex flex-col gap-2 p-3 sm:p-2.5 px-3 rounded-lg border cursor-pointer text-left transition-colors duration-[120ms] relative focus-visible:ring-2 focus-visible:ring-primary `+(n?`border-primary bg-base-300 shadow-sm`:`border-base-content/15 bg-base-300 hover:border-base-content/30`),children:[n?(0,b.jsx)(`div`,{className:`absolute top-1.5 right-1.5 w-3.5 h-3.5 rounded-full bg-primary flex items-center justify-center`,children:(0,b.jsx)(L,{size:8,className:`text-primary-content`,strokeWidth:1.8})}):(0,b.jsx)(`div`,{role:`button`,className:`absolute top-1.5 right-1.5 p-0.5 rounded hover:bg-base-content/10 transition-colors`,onClick:function(t){t.stopPropagation(),g(e)},children:(0,b.jsx)($_,{size:10,className:`text-base-content/30 hover:text-base-content/60`})}),(0,b.jsx)(I7,{colors:e.colors}),(0,b.jsx)(`div`,{className:`text-[12px] font-medium text-base-content truncate w-full`,children:e.name})]},e.filename)}),(0,b.jsxs)(`button`,{onClick:function(){i(null),n(!0)},className:`flex flex-col items-center justify-center gap-2 p-3 rounded-lg border-2 border-dashed border-base-content/15 cursor-pointer text-left transition-colors duration-[120ms] hover:border-primary/40 hover:bg-primary/5 min-h-[70px]`,children:[(0,b.jsx)(tv,{size:18,className:`text-base-content/25`}),(0,b.jsx)(`div`,{className:`text-[11px] text-base-content/30`,children:`Create Theme`})]})]})]}),a.state&&(0,b.jsx)(vb,{x:a.state.x,y:a.state.y,onClose:a.close,label:`Custom theme actions`,items:[{label:`Edit`,icon:(0,b.jsx)($_,{size:14}),onClick:function(){g(a.state.data)}},{label:`Export JSON`,icon:(0,b.jsx)(nm,{size:14}),onClick:function(){v(a.state.data)}},{type:`divider`},{label:`Delete`,icon:(0,b.jsx)(Tv,{size:14}),danger:!0,onClick:function(){_(a.state.data)}}]}),t&&(0,b.jsx)(l$e,{onClose:function(){n(!1),i(null)},editTheme:r?{name:r.name,author:r.author,variant:r.variant,colors:r.colors}:null})]})}function e9(){var[e,t]=(0,x.useState)(!1),[n,r]=(0,x.useState)(!1),[i,a]=(0,x.useState)(`idle`),o=(0,x.useRef)(null),s=(0,x.useRef)(!1);(0,x.useEffect)(function(){return function(){o.current&&clearTimeout(o.current)}},[]);function c(){t(!0),a(`idle`)}function l(){r(!0),s.current=!0,a(`idle`),o.current&&clearTimeout(o.current),o.current=setTimeout(function(){r(!1),s.current=!1,a(`error`),setTimeout(function(){a(`idle`)},3e3)},5e3)}function u(){r(!1),s.current=!1,a(`saved`),t(!1),o.current&&clearTimeout(o.current),o.current=setTimeout(function(){a(`idle`)},1800)}function d(){t(!1),a(`idle`),r(!1),s.current=!1}return{dirty:e,saving:n,savingRef:s,saveState:i,markDirty:c,startSave:l,confirmSave:u,resetFromServer:d}}var p$e={info:Zh,warning:Ev,error:Cu},m$e={info:`bg-primary`,warning:`bg-warning`,error:`bg-error`},h$e={info:`text-primary`,warning:`text-warning`,error:`text-error`};function g$e(e){return e.items.length===0?null:(0,b.jsx)(`div`,{className:`fixed top-3 right-3 z-[9999] flex flex-col gap-2 max-w-[340px]`,role:`status`,"aria-live":`polite`,"aria-atomic":`false`,children:e.items.map(function(t){var n=p$e[t.type];return(0,b.jsxs)(`div`,{className:`flex items-start gap-2.5 bg-base-300 border border-base-content/10 rounded-lg shadow-xl px-3 py-2.5 animate-[toast-in_0.18s_ease]`,children:[(0,b.jsx)(`div`,{className:`w-0.5 self-stretch rounded-full flex-shrink-0 `+m$e[t.type]}),(0,b.jsx)(n,{size:14,className:`flex-shrink-0 mt-0.5 `+h$e[t.type]}),(0,b.jsx)(`span`,{className:`flex-1 text-[13px] text-base-content/80 leading-snug`,children:t.message}),(0,b.jsx)(`button`,{onClick:function(){e.onDismiss(t.id)},"aria-label":`Dismiss`,className:`flex-shrink-0 text-base-content/30 hover:text-base-content/60 transition-colors mt-0.5`,children:(0,b.jsx)(Nv,{size:13})})]},t.id)})})}var t9=[];function n9(e,t=`info`,n){var r=n?.persistent,i=n?.duration;t===`error`&&r===void 0&&i===void 0&&(r=!0);var a={id:Math.random().toString(36).slice(2),message:e,type:t,persistent:r,duration:i};t9.forEach(function(e){e(a)})}function _$e(){var[e,t]=(0,x.useState)([]),n=(0,x.useCallback)(function(e){t(function(t){return t.filter(function(t){return t.id!==e})})},[]);return(0,x.useEffect)(function(){function e(e){if(t(function(t){return[...t,e]}),!e.persistent){var n=e.duration??5e3;setTimeout(function(){t(function(t){return t.filter(function(t){return t.id!==e.id})})},n)}}return t9.push(e),function(){t9=t9.filter(function(t){return t!==e})}},[]),{items:e,dismiss:n}}function r9({dirty:e,saving:t,saveState:n,onSave:r,extraStatus:i}){var a=t||!e&&n!==`error`,o=(0,x.useRef)(`idle`);return(0,x.useEffect)(function(){o.current!==n&&(n===`saved`?n9(`Settings saved`,`info`):n===`error`&&n9(`Failed to save settings — server did not respond within 5 seconds`,`error`),o.current=n)},[n]),(0,b.jsxs)(`div`,{className:`flex items-center justify-end gap-3`,children:[i&&(0,b.jsx)(`div`,{className:`text-[11px] text-warning/70`,children:i}),!i&&e&&n===`idle`&&!t&&(0,b.jsx)(`div`,{className:`text-[11px] text-warning/70`,children:`Unsaved changes`}),n===`error`&&(0,b.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] text-error`,children:[(0,b.jsx)(Nv,{size:11}),`Save failed — server did not respond`]}),n===`saved`&&(0,b.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] text-success/70`,children:[(0,b.jsx)(L,{size:11}),`Saved`]}),(0,b.jsxs)(`button`,{onClick:r,disabled:a,className:`btn btn-sm gap-1.5 `+(n===`saved`?`btn-success`:n===`error`?`btn-error`:`btn-primary`)+(a?` opacity-50 cursor-not-allowed`:``),children:[t&&(0,b.jsx)(C_,{size:13,className:`animate-spin`}),t?`Saving...`:n===`error`?`Retry`:`Save Changes`]})]})}var i9=[{id:`claude-opus-4-6`,label:`Claude Opus 4.6`},{id:`claude-sonnet-4-6`,label:`Claude Sonnet 4.6`},{id:`claude-haiku-4-5`,label:`Claude Haiku 4.5`},{id:`claude-opus-4-5`,label:`Claude Opus 4.5`},{id:`claude-sonnet-4-5`,label:`Claude Sonnet 4.5`}],v$e=[{id:`low`,label:`Low`},{id:`normal`,label:`Normal`},{id:`high`,label:`High`},{id:`max`,label:`Max`}];function y$e(){var{send:e,subscribe:t,unsubscribe:n}=R(),[r,i]=(0,x.useState)(``),[a,o]=(0,x.useState)(i9[0].id),[s,c]=(0,x.useState)(`normal`),l=e9();(0,x.useEffect)(function(){function r(e){if(e.type===`settings:data`){var t=e.config,n=t.claudeMd?String(t.claudeMd):``,r=t.defaultModel?String(t.defaultModel):i9[0].id,a=t.defaultEffort?String(t.defaultEffort):`normal`;l.savingRef.current?l.confirmSave():(i(n),o(r),c(a),l.resetFromServer())}}return t(`settings:data`,r),e({type:`settings:get`}),function(){n(`settings:data`,r)}},[]);function u(e){o(e),l.markDirty()}function d(e){c(e),l.markDirty()}function f(e){i(e),l.markDirty()}function p(){l.startSave(),e({type:`settings:update`,settings:{claudeMd:r,defaultModel:a,defaultEffort:s}})}return(0,b.jsxs)(`div`,{className:`py-2`,children:[(0,b.jsxs)(`a`,{href:`https://docs.anthropic.com/en/docs/claude-code/memory`,target:`_blank`,rel:`noopener noreferrer`,className:`text-[11px] text-base-content/30 hover:text-primary/70 flex items-center gap-1 mb-4 transition-colors`,children:[(0,b.jsx)(um,{size:11}),`Claude Code docs`]}),(0,b.jsxs)(`div`,{className:`mb-5`,children:[(0,b.jsx)(`label`,{htmlFor:`claude-default-model`,className:`block text-[12px] font-semibold text-base-content/40 mb-2`,children:`Default Model`}),(0,b.jsx)(`select`,{id:`claude-default-model`,value:a,onChange:function(e){u(e.target.value)},className:`w-full h-9 px-3 bg-base-300 border border-base-content/15 rounded-xl text-base-content text-[13px] focus:border-primary focus-visible:outline-none transition-colors duration-[120ms]`,children:i9.map(function(e){return(0,b.jsx)(`option`,{value:e.id,className:`bg-base-300`,children:e.label},e.id)})})]}),(0,b.jsxs)(`div`,{className:`mb-6`,role:`radiogroup`,"aria-label":`Default Effort`,children:[(0,b.jsx)(`div`,{className:`text-[12px] font-semibold text-base-content/40 mb-2`,children:`Default Effort`}),(0,b.jsx)(`div`,{className:`flex gap-2`,children:v$e.map(function(e){var t=s===e.id;return(0,b.jsx)(`button`,{role:`radio`,"aria-checked":t,onClick:function(){d(e.id)},className:`flex-1 py-2.5 sm:py-1.5 rounded-lg border text-[12px] transition-colors duration-[120ms] cursor-pointer focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-1 focus-visible:ring-offset-base-100 `+(t?`border-primary bg-base-300 text-base-content font-semibold`:`border-base-content/15 bg-base-300 text-base-content/40 hover:border-base-content/30 hover:text-base-content/60`),children:e.label},e.id)})})]}),(0,b.jsxs)(`div`,{className:`mb-5`,children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,b.jsx)(`label`,{htmlFor:`claude-global-md`,className:`text-[12px] font-semibold text-base-content/40`,children:`Global CLAUDE.md`}),(0,b.jsx)(`div`,{className:`text-[11px] text-base-content/30 font-mono`,children:`~/.claude/CLAUDE.md`})]}),(0,b.jsx)(`textarea`,{id:`claude-global-md`,value:r,onChange:function(e){f(e.target.value)},placeholder:`# Global instructions for Claude
647
+ `;function P7(e){return`#`+e.replace(/^#/,``)}function F7(e){var t=e.colors,n=(0,x.useMemo)(function(){return{"--preview-bg":P7(t.base00||`1f1f28`),"--preview-surface":P7(t.base01||`2a2a37`),"--preview-selection":P7(t.base02||`363646`),"--preview-comment":P7(t.base03||`54546d`),"--preview-dark-fg":P7(t.base04||`727169`),"--preview-fg":P7(t.base05||`dcd7ba`),"--preview-light-fg":P7(t.base06||`c8c093`),"--preview-bright-fg":P7(t.base07||`ffffff`),"--preview-red":P7(t.base08||`c34043`),"--preview-orange":P7(t.base09||`ffa066`),"--preview-yellow":P7(t.base0A||`c0a36e`),"--preview-green":P7(t.base0B||`76946a`),"--preview-cyan":P7(t.base0C||`6a9589`),"--preview-blue":P7(t.base0D||`7e9cd8`),"--preview-purple":P7(t.base0E||`957fb8`),"--preview-brown":P7(t.base0F||`d27e99`)}},[t]);return e.compact?(0,b.jsx)(`div`,{className:`rounded-lg overflow-hidden border border-base-content/10`,style:{...n,background:`var(--preview-bg)`,color:`var(--preview-fg)`},children:(0,b.jsxs)(`div`,{className:`flex h-[80px]`,children:[(0,b.jsxs)(`div`,{className:`w-10 shrink-0 p-1.5 flex flex-col gap-1`,style:{background:`var(--preview-surface)`},children:[(0,b.jsx)(`div`,{className:`w-full h-1.5 rounded-full`,style:{background:`var(--preview-blue)`,opacity:.6}}),(0,b.jsx)(`div`,{className:`w-full h-1.5 rounded-full`,style:{background:`var(--preview-comment)`}}),(0,b.jsx)(`div`,{className:`w-full h-1.5 rounded-full`,style:{background:`var(--preview-comment)`}})]}),(0,b.jsxs)(`div`,{className:`flex-1 p-2 flex flex-col gap-1.5`,children:[(0,b.jsx)(`div`,{className:`flex justify-end`,children:(0,b.jsx)(`div`,{className:`rounded-lg px-2 py-1 text-[8px] max-w-[70%]`,style:{background:`var(--preview-blue)`,color:`var(--preview-bright-fg)`},children:`Hello world`})}),(0,b.jsx)(`div`,{className:`flex`,children:(0,b.jsx)(`div`,{className:`rounded-lg px-2 py-1 text-[8px] max-w-[70%]`,style:{background:`var(--preview-selection)`,color:`var(--preview-fg)`},children:`Response text`})})]})]})}):(0,b.jsx)(`div`,{className:`rounded-xl overflow-hidden border border-base-content/10 shadow-lg`,style:{...n,background:`var(--preview-bg)`,color:`var(--preview-fg)`},children:(0,b.jsxs)(`div`,{className:`flex h-[280px]`,children:[(0,b.jsxs)(`div`,{className:`w-[120px] shrink-0 p-3 flex flex-col gap-2 border-r`,style:{background:`var(--preview-surface)`,borderColor:`var(--preview-selection)`},children:[(0,b.jsx)(`div`,{className:`text-[10px] font-bold mb-1`,style:{color:`var(--preview-light-fg)`},children:`Projects`}),(0,b.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,b.jsx)(`div`,{className:`w-3 h-3 rounded`,style:{background:`var(--preview-blue)`,opacity:.3}}),(0,b.jsx)(`div`,{className:`text-[9px]`,style:{color:`var(--preview-fg)`},children:`lattice`})]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,b.jsx)(`div`,{className:`w-3 h-3 rounded`,style:{background:`var(--preview-green)`,opacity:.3}}),(0,b.jsx)(`div`,{className:`text-[9px]`,style:{color:`var(--preview-dark-fg)`},children:`my-app`})]}),(0,b.jsxs)(`div`,{className:`mt-auto`,children:[(0,b.jsx)(`div`,{className:`text-[8px] mb-1`,style:{color:`var(--preview-comment)`},children:`Sessions`}),(0,b.jsx)(`div`,{className:`text-[8px] truncate`,style:{color:`var(--preview-dark-fg)`},children:`Fix auth bug`}),(0,b.jsx)(`div`,{className:`text-[8px] truncate`,style:{color:`var(--preview-comment)`},children:`Add dark mode`})]})]}),(0,b.jsxs)(`div`,{className:`flex-1 flex flex-col`,children:[(0,b.jsxs)(`div`,{className:`flex-1 p-3 flex flex-col gap-2 overflow-hidden`,children:[(0,b.jsx)(`div`,{className:`flex justify-end`,children:(0,b.jsx)(`div`,{className:`rounded-xl px-3 py-1.5 text-[10px] max-w-[75%]`,style:{background:`var(--preview-blue)`,color:`var(--preview-bright-fg)`},children:`Can you fix the login page?`})}),(0,b.jsxs)(`div`,{className:`flex gap-2`,children:[(0,b.jsx)(`div`,{className:`w-4 h-4 rounded-full shrink-0 mt-0.5`,style:{background:`var(--preview-blue)`,opacity:.2}}),(0,b.jsxs)(`div`,{className:`rounded-xl px-3 py-1.5 text-[10px] max-w-[75%] border`,style:{background:`var(--preview-selection)`,borderColor:`var(--preview-comment)`,opacity:.3},children:[(0,b.jsx)(`span`,{style:{color:`var(--preview-fg)`},children:`I'll update the `}),(0,b.jsx)(`code`,{className:`px-1 rounded text-[9px]`,style:{background:`var(--preview-bg)`,color:`var(--preview-orange)`},children:`LoginForm`}),(0,b.jsx)(`span`,{style:{color:`var(--preview-fg)`},children:` component.`})]})]}),(0,b.jsxs)(`div`,{className:`rounded-lg p-2 text-[9px] font-mono border`,style:{background:`var(--preview-bg)`,borderColor:`var(--preview-selection)`},children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`span`,{style:{color:`var(--preview-purple)`},children:`function`}),` `,(0,b.jsx)(`span`,{style:{color:`var(--preview-blue)`},children:`login`}),(0,b.jsx)(`span`,{style:{color:`var(--preview-dark-fg)`},children:`(`}),(0,b.jsx)(`span`,{style:{color:`var(--preview-orange)`},children:`user`}),(0,b.jsx)(`span`,{style:{color:`var(--preview-dark-fg)`},children:`)`}),` `,`{`]}),(0,b.jsxs)(`div`,{className:`ml-3`,children:[(0,b.jsx)(`span`,{style:{color:`var(--preview-purple)`},children:`var`}),` `,(0,b.jsx)(`span`,{style:{color:`var(--preview-red)`},children:`token`}),` = `,(0,b.jsx)(`span`,{style:{color:`var(--preview-blue)`},children:`auth`}),`(`,(0,b.jsx)(`span`,{style:{color:`var(--preview-green)`},children:`"secret"`}),`);`]}),(0,b.jsxs)(`div`,{className:`ml-3`,children:[(0,b.jsx)(`span`,{style:{color:`var(--preview-purple)`},children:`return`}),` `,`{`,` `,(0,b.jsx)(`span`,{style:{color:`var(--preview-yellow)`},children:`ok`}),`: `,(0,b.jsx)(`span`,{style:{color:`var(--preview-orange)`},children:`true`}),` `,`}`,`;`]}),(0,b.jsx)(`div`,{children:`}`})]})]}),(0,b.jsx)(`div`,{className:`px-3 py-2 border-t`,style:{borderColor:`var(--preview-selection)`},children:(0,b.jsx)(`div`,{className:`rounded-lg px-3 py-1.5 text-[9px]`,style:{background:`var(--preview-surface)`,color:`var(--preview-comment)`},children:`Type a message...`})})]})]})})}function I7(e){return(0,b.jsx)(`div`,{className:`flex gap-0.5 rounded overflow-hidden`,children:[`base00`,`base01`,`base02`,`base03`,`base04`,`base05`,`base06`,`base07`,`base08`,`base09`,`base0A`,`base0B`,`base0C`,`base0D`,`base0E`,`base0F`].map(function(t){return(0,b.jsx)(`div`,{className:`h-4 flex-1`,style:{background:`#`+(e.colors[t]||`000000`).replace(/^#/,``)},title:t+`: #`+(e.colors[t]||`000000`)},t)})})}function L7(e){return/^#?[0-9a-fA-F]{6}$/.test(e)}function R7(e){return e.replace(/^#/,``).toLowerCase()}function z7(e){var t=R7(e);return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}function B7(e,t,n){return[e,t,n].map(function(e){return Math.max(0,Math.min(255,Math.round(e))).toString(16).padStart(2,`0`)}).join(``)}function V7(e){var t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4}function H7(e){var t=Math.max(0,Math.min(1,e));return t<=.0031308?t*12.92*255:(1.055*t**(1/2.4)-.055)*255}function U7(e,t,n){var r=V7(e),i=V7(t),a=V7(n),o=.4122214708*r+.5363325363*i+.0514459929*a,s=.2119034982*r+.6806995451*i+.1073969566*a,c=.0883024619*r+.2220049168*i+.6696926213*a,l=Math.cbrt(o),u=Math.cbrt(s),d=Math.cbrt(c),f=.2104542553*l+.793617785*u-.0040720468*d,p=1.9779984951*l-2.428592205*u+.4505937099*d,m=.0259040371*l+.7827717662*u-.808675766*d,h=Math.sqrt(p*p+m*m),g=Math.atan2(m,p)*180/Math.PI;return g<0&&(g+=360),{L:f,C:h,h:g}}function W7(e,t,n){var r=n*Math.PI/180,i=t*Math.cos(r),a=t*Math.sin(r),o=e+.3963377774*i+.2158037573*a,s=e-.1055613458*i-.0638541728*a,c=e-.0894841775*i-1.291485548*a,l=o*o*o,u=s*s*s,d=c*c*c,f=4.0767416621*l-3.3077115913*u+.2309699292*d,p=-1.2684380046*l+2.6097574011*u-.3413193965*d,m=-.0041960863*l-.7034186147*u+1.707614701*d;return[Math.round(H7(f)),Math.round(H7(p)),Math.round(H7(m))]}function G7(e,t,n){var[r,i,a]=z7(e),[o,s,c]=z7(t),l=U7(r,i,a),u=U7(o,s,c),d=l.L+(u.L-l.L)*n,f=l.C+(u.C-l.C)*n,p=l.C<.001?u.h:l.h,m=(u.C<.001?l.h:u.h)-p;m>180&&(m-=360),m<-180&&(m+=360);var h=p+m*n;h<0&&(h+=360),h>=360&&(h-=360);var[g,_,v]=W7(d,f,h);return B7(g,_,v)}function K7(e,t){var[n,r,i]=z7(e),a=U7(n,r,i),[o,s,c]=W7(Math.max(0,Math.min(1,a.L+t)),a.C,a.h);return B7(o,s,c)}function q7(e,t){var[n,r,i]=z7(e),a=U7(n,r,i),o=(a.h+t)%360;o<0&&(o+=360);var[s,c,l]=W7(a.L,a.C,o);return B7(s,c,l)}function J7(e,t){var[n,r,i]=z7(e),a=U7(n,r,i),o=a.L;t===`dark`?(o<.65&&(o=.65),o>.85&&(o=.85)):(o<.35&&(o=.35),o>.55&&(o=.55));var[s,c,l]=W7(o,a.C,a.h);return B7(s,c,l)}function c$e(e,t,n,r,i){var a=R7(e),o=R7(t),s=R7(n),c=R7(r);return{base00:a,base01:G7(a,o,.5),base02:o,base03:G7(o,s,.25),base04:G7(o,s,.45),base05:s,base06:i===`dark`?K7(s,.05):K7(s,-.05),base07:i===`dark`?K7(s,.15):K7(s,-.15),base08:J7(q7(c,0),i),base09:J7(q7(c,30),i),base0A:J7(q7(c,60),i),base0B:J7(q7(c,120),i),base0C:J7(q7(c,180),i),base0D:J7(c,i),base0E:J7(q7(c,270),i),base0F:J7(q7(c,330),i)}}var Y7=[`base00`,`base01`,`base02`,`base03`,`base04`,`base05`,`base06`,`base07`,`base08`,`base09`,`base0A`,`base0B`,`base0C`,`base0D`,`base0E`,`base0F`],X7={base00:`Background`,base01:`Lighter Background`,base02:`Selection`,base03:`Comments`,base04:`Dark Foreground`,base05:`Foreground`,base06:`Light Foreground`,base07:`Brightest`,base08:`Red / Variables`,base09:`Orange / Numbers`,base0A:`Yellow / Classes`,base0B:`Green / Strings`,base0C:`Cyan / Support`,base0D:`Blue / Functions`,base0E:`Purple / Keywords`,base0F:`Brown / Deprecated`};function Z7(){return{base00:`1a1a2e`,base01:`222240`,base02:`2a2a4a`,base03:`505070`,base04:`7a7a9a`,base05:`c0c0d0`,base06:`d0d0e0`,base07:`ffffff`,base08:`ff6b6b`,base09:`ffa06b`,base0A:`ffd06b`,base0B:`6bffa0`,base0C:`6bd0ff`,base0D:`6b9fff`,base0E:`c06bff`,base0F:`ff6bb0`}}function l$e(){return{base00:`f5f5f0`,base01:`e8e8e0`,base02:`d5d5cd`,base03:`999990`,base04:`666660`,base05:`333330`,base06:`222220`,base07:`000000`,base08:`c24040`,base09:`b06030`,base0A:`907020`,base0B:`408040`,base0C:`207080`,base0D:`3060b0`,base0E:`703090`,base0F:`a04060`}}function u$e(e){var t=R(),[n,r]=(0,x.useState)(1),[i,a]=(0,x.useState)(e.editTheme?.name||``),[o,s]=(0,x.useState)(e.editTheme?.author||``),[c,l]=(0,x.useState)(e.editTheme?.variant||`dark`),[u,d]=(0,x.useState)(null),[f,p]=(0,x.useState)(e.editTheme?.colors||Z7()),[m,h]=(0,x.useState)(f.base00),[g,_]=(0,x.useState)(f.base02),[v,y]=(0,x.useState)(f.base05),[S,C]=(0,x.useState)(f.base0D),[w,T]=(0,x.useState)(!1);function E(e){d(e);var t=kb.find(function(t){return t.theme.name===e});if(t){for(var n=t.theme,r={},i=0;i<Y7.length;i++)r[Y7[i]]=R7(n[Y7[i]]||`000000`);p(r),l(t.theme.variant),h(r.base00),_(r.base02),y(r.base05),C(r.base0D)}}function D(t){if(l(t),!u&&!e.editTheme){var n=t===`dark`?Z7():l$e();p(n),h(n.base00),_(n.base02),y(n.base05),C(n.base0D)}}function O(e,t){var n=R7(t);e===`bg`&&h(n),e===`surface`&&_(n),e===`fg`&&y(n),e===`accent`&&C(n)}(0,x.useEffect)(function(){n===2&&L7(m)&&L7(g)&&L7(v)&&L7(S)&&p(c$e(R7(m),R7(g),R7(v),R7(S),c))},[m,g,v,S,c,n]);function k(e,t){var n=R7(t);p(function(t){var r={...t};return r[e]=n,r})}function A(){t.send({type:`theme:save`,name:i||`Untitled Theme`,author:o||`Custom`,variant:c,colors:f}),e.onClose()}function j(){for(var e={name:i||`Untitled Theme`,author:o||`Custom`,variant:c},t=0;t<Y7.length;t++)e[Y7[t]]=f[Y7[t]];var n=new Blob([JSON.stringify(e,null,2)],{type:`application/json`}),r=URL.createObjectURL(n),a=document.createElement(`a`);a.href=r,a.download=(i||`custom-theme`).toLowerCase().replace(/[^a-z0-9]+/g,`-`)+`.json`,a.click(),URL.revokeObjectURL(r)}var M=n===1?i.trim().length>0:!0;return(0,cr.createPortal)((0,b.jsx)(`div`,{className:`fixed inset-0 z-[9999] flex items-center justify-center bg-base-content/60 backdrop-blur-sm`,onClick:e.onClose,children:(0,b.jsxs)(`div`,{className:`bg-base-200 border border-base-content/15 rounded-2xl shadow-2xl w-[90vw] max-w-[860px] max-h-[85vh] flex flex-col overflow-hidden`,onClick:function(e){e.stopPropagation()},children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between px-5 py-3.5 border-b border-base-content/10`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,b.jsx)(X_,{size:18,className:`text-primary`}),(0,b.jsx)(`h2`,{className:`text-sm font-semibold text-base-content`,children:e.editTheme?`Edit Theme`:`Create Theme`}),(0,b.jsx)(`div`,{className:`flex items-center gap-1 ml-2`,children:[1,2,3,4].map(function(e){return(0,b.jsx)(`div`,{className:`w-2 h-2 rounded-full transition-colors `+(e===n?`bg-primary`:e<n?`bg-primary/40`:`bg-base-content/15`)},e)})})]}),(0,b.jsx)(`button`,{onClick:e.onClose,className:`btn btn-ghost btn-sm btn-circle`,children:(0,b.jsx)(Nv,{size:16})})]}),(0,b.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-5`,children:[n===1&&(0,b.jsxs)(`div`,{className:`space-y-4`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{className:`text-xs font-medium text-base-content/50 uppercase tracking-wider mb-1.5 block`,children:`Theme Name`}),(0,b.jsx)(`input`,{type:`text`,value:i,onChange:function(e){a(e.target.value)},placeholder:`My Awesome Theme`,className:`input input-bordered w-full max-w-xs text-sm`,autoFocus:!0})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{className:`text-xs font-medium text-base-content/50 uppercase tracking-wider mb-1.5 block`,children:`Variant`}),(0,b.jsxs)(`div`,{className:`flex gap-2`,children:[(0,b.jsxs)(`button`,{onClick:function(){D(`dark`)},className:`btn btn-sm gap-2 `+(c===`dark`?`btn-primary`:`btn-ghost`),children:[(0,b.jsx)(q_,{size:14}),` Dark`]}),(0,b.jsxs)(`button`,{onClick:function(){D(`light`)},className:`btn btn-sm gap-2 `+(c===`light`?`btn-primary`:`btn-ghost`),children:[(0,b.jsx)(Sv,{size:14}),` Light`]})]})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{className:`text-xs font-medium text-base-content/50 uppercase tracking-wider mb-2 block`,children:`Start from (optional)`}),(0,b.jsx)(`div`,{className:`grid grid-cols-4 sm:grid-cols-6 gap-2 max-h-[300px] overflow-y-auto pr-1`,children:kb.filter(function(e){return e.theme.variant===c}).map(function(e){var t=u===e.theme.name;return(0,b.jsxs)(`button`,{onClick:function(){E(e.theme.name)},className:`relative rounded-lg border-2 p-1 transition-all cursor-pointer `+(t?`border-primary ring-2 ring-primary/20`:`border-transparent hover:border-base-content/20`),children:[(0,b.jsx)(I7,{colors:e.theme}),(0,b.jsx)(`div`,{className:`text-[9px] text-base-content/50 mt-1 truncate text-center`,children:e.theme.name}),t&&(0,b.jsx)(`div`,{className:`absolute -top-1 -right-1 w-4 h-4 rounded-full bg-primary flex items-center justify-center`,children:(0,b.jsx)(L,{size:10,className:`text-primary-content`})})]},e.id)})})]})]}),n===2&&(0,b.jsxs)(`div`,{className:`flex gap-6`,children:[(0,b.jsxs)(`div`,{className:`flex-1 space-y-4`,children:[(0,b.jsx)(`p`,{className:`text-xs text-base-content/40 mb-3`,children:`Pick 4 core colors. The remaining 12 are auto-derived.`}),(0,b.jsx)(Q7,{label:`Background`,sublabel:`base00 — Main background`,value:m,onChange:function(e){O(`bg`,e)}}),(0,b.jsx)(Q7,{label:`Surface`,sublabel:`base02 — Panels, selections`,value:g,onChange:function(e){O(`surface`,e)}}),(0,b.jsx)(Q7,{label:`Foreground`,sublabel:`base05 — Main text`,value:v,onChange:function(e){O(`fg`,e)}}),(0,b.jsx)(Q7,{label:`Accent`,sublabel:`base0D — Links, interactive elements`,value:S,onChange:function(e){O(`accent`,e)}})]}),(0,b.jsxs)(`div`,{className:`w-[320px] shrink-0`,children:[(0,b.jsx)(F7,{colors:f,variant:c}),(0,b.jsx)(`div`,{className:`mt-3`,children:(0,b.jsx)(I7,{colors:f})})]})]}),n===3&&(0,b.jsxs)(`div`,{className:`flex gap-6`,children:[(0,b.jsxs)(`div`,{className:`flex-1 space-y-3`,children:[(0,b.jsx)(`button`,{onClick:function(){T(!w)},className:`text-xs text-primary cursor-pointer hover:underline`,children:w?`Hide individual colors`:`Show individual colors`}),w&&(0,b.jsxs)(`div`,{className:`space-y-4`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-[10px] font-semibold text-base-content/30 uppercase tracking-wider mb-2`,children:`Backgrounds`}),(0,b.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:[`base00`,`base01`,`base02`,`base03`].map(function(e){return(0,b.jsx)(Q7,{label:e,sublabel:X7[e],value:f[e],onChange:function(t){k(e,t)},compact:!0},e)})})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-[10px] font-semibold text-base-content/30 uppercase tracking-wider mb-2`,children:`Foregrounds`}),(0,b.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:[`base04`,`base05`,`base06`,`base07`].map(function(e){return(0,b.jsx)(Q7,{label:e,sublabel:X7[e],value:f[e],onChange:function(t){k(e,t)},compact:!0},e)})})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-[10px] font-semibold text-base-content/30 uppercase tracking-wider mb-2`,children:`Syntax & UI`}),(0,b.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:[`base08`,`base09`,`base0A`,`base0B`,`base0C`,`base0D`,`base0E`,`base0F`].map(function(e){return(0,b.jsx)(Q7,{label:e,sublabel:X7[e],value:f[e],onChange:function(t){k(e,t)},compact:!0},e)})})]})]}),!w&&(0,b.jsx)(`p`,{className:`text-xs text-base-content/30`,children:`Colors were auto-derived from your core palette. Click above to fine-tune individual colors.`})]}),(0,b.jsxs)(`div`,{className:`w-[320px] shrink-0`,children:[(0,b.jsx)(F7,{colors:f,variant:c}),(0,b.jsx)(`div`,{className:`mt-3`,children:(0,b.jsx)(I7,{colors:f})})]})]}),n===4&&(0,b.jsxs)(`div`,{className:`space-y-4`,children:[(0,b.jsx)(F7,{colors:f,variant:c}),(0,b.jsxs)(`div`,{className:`flex gap-4`,children:[(0,b.jsxs)(`div`,{className:`flex-1`,children:[(0,b.jsx)(`label`,{className:`text-xs font-medium text-base-content/50 uppercase tracking-wider mb-1 block`,children:`Name`}),(0,b.jsx)(`input`,{type:`text`,value:i,onChange:function(e){a(e.target.value)},className:`input input-bordered input-sm w-full`})]}),(0,b.jsxs)(`div`,{className:`flex-1`,children:[(0,b.jsx)(`label`,{className:`text-xs font-medium text-base-content/50 uppercase tracking-wider mb-1 block`,children:`Author`}),(0,b.jsx)(`input`,{type:`text`,value:o,onChange:function(e){s(e.target.value)},placeholder:`Your name`,className:`input input-bordered input-sm w-full`})]})]}),(0,b.jsx)(I7,{colors:f})]})]}),(0,b.jsxs)(`div`,{className:`flex items-center justify-between px-5 py-3 border-t border-base-content/10`,children:[(0,b.jsx)(`div`,{children:n>1&&(0,b.jsxs)(`button`,{onClick:function(){r(n-1)},className:`btn btn-ghost btn-sm gap-1`,children:[(0,b.jsx)(su,{size:14}),` Back`]})}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n===4&&(0,b.jsxs)(`button`,{onClick:j,className:`btn btn-ghost btn-sm gap-1`,children:[(0,b.jsx)(nm,{size:14}),` Export JSON`]}),n<4?(0,b.jsxs)(`button`,{onClick:function(){r(n+1)},disabled:!M,className:`btn btn-primary btn-sm gap-1`,children:[`Next `,(0,b.jsx)(cu,{size:14})]}):(0,b.jsxs)(`button`,{onClick:A,className:`btn btn-primary btn-sm gap-1`,children:[(0,b.jsx)(lv,{size:14}),` Save Theme`]})]})]})]})}),document.body)}function Q7(e){var t=R7(e.value),n=`#`+t;return(0,b.jsxs)(`div`,{className:`flex items-center gap-2 `+(e.compact?``:`py-1`),children:[(0,b.jsxs)(`label`,{className:`relative cursor-pointer group`,children:[(0,b.jsx)(`div`,{className:`rounded-lg border-2 border-base-content/15 group-hover:border-base-content/30 transition-colors `+(e.compact?`w-7 h-7`:`w-9 h-9`),style:{background:n}}),(0,b.jsx)(`input`,{type:`color`,value:n,onChange:function(t){e.onChange(t.target.value)},className:`absolute inset-0 opacity-0 cursor-pointer w-full h-full`})]}),(0,b.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,b.jsx)(`div`,{className:`font-medium text-base-content/70 `+(e.compact?`text-[10px]`:`text-xs`),children:e.label}),e.sublabel&&(0,b.jsx)(`div`,{className:`text-[9px] text-base-content/30`,children:e.sublabel})]}),(0,b.jsx)(`input`,{type:`text`,value:t,onChange:function(t){e.onChange(t.target.value)},className:`input input-bordered font-mono `+(e.compact?`input-xs w-20 text-[10px]`:`input-sm w-24 text-xs`),maxLength:7})]})}var d$e=[`base00`,`base01`,`base02`,`base03`,`base04`,`base05`,`base06`,`base07`,`base08`,`base09`,`base0A`,`base0B`,`base0C`,`base0D`,`base0E`,`base0F`],f$e=(0,x.memo)(function({entry:e,active:t,onSelect:n}){var r=e.theme;function i(){n(e.id)}return(0,b.jsxs)(`button`,{onClick:i,className:`flex flex-col gap-2 p-3 sm:p-2.5 px-3 rounded-lg border cursor-pointer text-left transition-colors duration-[120ms] relative focus-visible:ring-2 focus-visible:ring-primary `+(t?`border-primary bg-base-300 shadow-sm`:`border-base-content/15 bg-base-300 hover:border-base-content/30`),children:[t&&(0,b.jsx)(`div`,{className:`absolute top-1.5 right-1.5 w-3.5 h-3.5 rounded-full bg-primary flex items-center justify-center`,children:(0,b.jsx)(L,{size:8,className:`text-primary-content`,strokeWidth:1.8})}),(0,b.jsx)(`div`,{className:`flex gap-[3px] flex-wrap w-[80px]`,children:d$e.map(function(e){return(0,b.jsx)(`div`,{className:`w-[10px] h-[10px] rounded-sm flex-shrink-0 ring-1 ring-base-content/10`,style:{background:`#`+r[e]}},e)})}),(0,b.jsx)(`div`,{className:`text-[12px] font-medium text-base-content`,children:r.name})]})});function $7({label:e,entries:t,currentThemeId:n,onSelect:r}){return t.length===0?null:(0,b.jsxs)(`div`,{className:`mb-6`,children:[(0,b.jsx)(`div`,{className:`text-[11px] font-mono font-bold tracking-[0.1em] uppercase text-base-content/40 mb-3`,children:e}),(0,b.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(100px,1fr))] gap-2`,children:t.map(function(e){return(0,b.jsx)(f$e,{entry:e,active:e.id===n,onSelect:r},e.id)})})]})}function p$e(){var e=R(),[t,n]=(0,x.useState)(!1),[r,i]=(0,x.useState)(null),a=yb(),{mode:o,currentThemeId:s,toggleMode:c,setTheme:l,themes:u,allThemes:d}=Mb(),f=(0,x.useMemo)(function(){return d.filter(function(e){return e.id.startsWith(`custom:`)}).map(function(e){var t={};for(var n of Object.keys(e.theme))n.startsWith(`base0`)&&(t[n]=e.theme[n]);return{name:e.theme.name,author:e.theme.author,variant:e.theme.variant,filename:e.id.replace(`custom:`,``),colors:t}})},[d]),p=(0,x.useMemo)(function(){return u.filter(function(e){return e.theme.variant===`dark`})},[u]),m=(0,x.useMemo)(function(){return u.filter(function(e){return e.theme.variant===`light`})},[u]),h=(0,x.useCallback)(function(e){l(e)},[l]);function g(e){i(e),n(!0)}function _(t){e.send({type:`theme:delete`,name:t.filename})}function v(e){var t={name:e.name,author:e.author,variant:e.variant};for(var n of Object.keys(e.colors))t[n]=e.colors[n];var r=new Blob([JSON.stringify(t,null,2)],{type:`application/json`}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=e.filename,a.click(),URL.revokeObjectURL(i)}return(0,b.jsxs)(`div`,{className:`py-2`,children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between mb-6`,children:[(0,b.jsx)(`div`,{className:`text-[12px] font-semibold text-base-content/40`,children:`Color Mode`}),(0,b.jsx)(`button`,{onClick:c,className:`btn btn-ghost btn-sm border border-base-content/20`,children:o===`dark`?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(Sv,{size:12}),`Switch to Light`]}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(q_,{size:12}),`Switch to Dark`]})})]}),(0,b.jsx)($7,{label:`Dark Themes`,entries:p,currentThemeId:s,onSelect:h}),(0,b.jsx)($7,{label:`Light Themes`,entries:m,currentThemeId:s,onSelect:h}),(0,b.jsxs)(`div`,{className:`mb-6`,children:[(0,b.jsx)(`div`,{className:`text-[11px] font-mono font-bold tracking-[0.1em] uppercase text-base-content/40 mb-3`,children:`Custom Themes`}),(0,b.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(100px,1fr))] gap-2`,children:[f.map(function(e){var t=`custom:`+e.filename,n=t===s;return(0,b.jsxs)(`button`,{onClick:function(){h(t)},onContextMenu:function(t){a.open(t,e)},"data-allow-context-menu":!0,className:`flex flex-col gap-2 p-3 sm:p-2.5 px-3 rounded-lg border cursor-pointer text-left transition-colors duration-[120ms] relative focus-visible:ring-2 focus-visible:ring-primary `+(n?`border-primary bg-base-300 shadow-sm`:`border-base-content/15 bg-base-300 hover:border-base-content/30`),children:[n?(0,b.jsx)(`div`,{className:`absolute top-1.5 right-1.5 w-3.5 h-3.5 rounded-full bg-primary flex items-center justify-center`,children:(0,b.jsx)(L,{size:8,className:`text-primary-content`,strokeWidth:1.8})}):(0,b.jsx)(`div`,{role:`button`,className:`absolute top-1.5 right-1.5 p-0.5 rounded hover:bg-base-content/10 transition-colors`,onClick:function(t){t.stopPropagation(),g(e)},children:(0,b.jsx)($_,{size:10,className:`text-base-content/30 hover:text-base-content/60`})}),(0,b.jsx)(I7,{colors:e.colors}),(0,b.jsx)(`div`,{className:`text-[12px] font-medium text-base-content truncate w-full`,children:e.name})]},e.filename)}),(0,b.jsxs)(`button`,{onClick:function(){i(null),n(!0)},className:`flex flex-col items-center justify-center gap-2 p-3 rounded-lg border-2 border-dashed border-base-content/15 cursor-pointer text-left transition-colors duration-[120ms] hover:border-primary/40 hover:bg-primary/5 min-h-[70px]`,children:[(0,b.jsx)(tv,{size:18,className:`text-base-content/25`}),(0,b.jsx)(`div`,{className:`text-[11px] text-base-content/30`,children:`Create Theme`})]})]})]}),a.state&&(0,b.jsx)(vb,{x:a.state.x,y:a.state.y,onClose:a.close,label:`Custom theme actions`,items:[{label:`Edit`,icon:(0,b.jsx)($_,{size:14}),onClick:function(){g(a.state.data)}},{label:`Export JSON`,icon:(0,b.jsx)(nm,{size:14}),onClick:function(){v(a.state.data)}},{type:`divider`},{label:`Delete`,icon:(0,b.jsx)(Tv,{size:14}),danger:!0,onClick:function(){_(a.state.data)}}]}),t&&(0,b.jsx)(u$e,{onClose:function(){n(!1),i(null)},editTheme:r?{name:r.name,author:r.author,variant:r.variant,colors:r.colors}:null})]})}function e9(){var[e,t]=(0,x.useState)(!1),[n,r]=(0,x.useState)(!1),[i,a]=(0,x.useState)(`idle`),o=(0,x.useRef)(null),s=(0,x.useRef)(!1);(0,x.useEffect)(function(){return function(){o.current&&clearTimeout(o.current)}},[]);function c(){t(!0),a(`idle`)}function l(){r(!0),s.current=!0,a(`idle`),o.current&&clearTimeout(o.current),o.current=setTimeout(function(){r(!1),s.current=!1,a(`error`),setTimeout(function(){a(`idle`)},3e3)},5e3)}function u(){r(!1),s.current=!1,a(`saved`),t(!1),o.current&&clearTimeout(o.current),o.current=setTimeout(function(){a(`idle`)},1800)}function d(){t(!1),a(`idle`),r(!1),s.current=!1}return{dirty:e,saving:n,savingRef:s,saveState:i,markDirty:c,startSave:l,confirmSave:u,resetFromServer:d}}var m$e={info:Zh,warning:Ev,error:Cu},h$e={info:`bg-primary`,warning:`bg-warning`,error:`bg-error`},g$e={info:`text-primary`,warning:`text-warning`,error:`text-error`};function _$e(e){return e.items.length===0?null:(0,b.jsx)(`div`,{className:`fixed top-3 right-3 z-[9999] flex flex-col gap-2 max-w-[340px]`,role:`status`,"aria-live":`polite`,"aria-atomic":`false`,children:e.items.map(function(t){var n=m$e[t.type];return(0,b.jsxs)(`div`,{className:`flex items-start gap-2.5 bg-base-300 border border-base-content/10 rounded-lg shadow-xl px-3 py-2.5 animate-[toast-in_0.18s_ease]`,children:[(0,b.jsx)(`div`,{className:`w-0.5 self-stretch rounded-full flex-shrink-0 `+h$e[t.type]}),(0,b.jsx)(n,{size:14,className:`flex-shrink-0 mt-0.5 `+g$e[t.type]}),(0,b.jsx)(`span`,{className:`flex-1 text-[13px] text-base-content/80 leading-snug`,children:t.message}),(0,b.jsx)(`button`,{onClick:function(){e.onDismiss(t.id)},"aria-label":`Dismiss`,className:`flex-shrink-0 text-base-content/30 hover:text-base-content/60 transition-colors mt-0.5`,children:(0,b.jsx)(Nv,{size:13})})]},t.id)})})}var t9=[];function n9(e,t=`info`,n){var r=n?.persistent,i=n?.duration;t===`error`&&r===void 0&&i===void 0&&(r=!0);var a={id:Math.random().toString(36).slice(2),message:e,type:t,persistent:r,duration:i};t9.forEach(function(e){e(a)})}function v$e(){var[e,t]=(0,x.useState)([]),n=(0,x.useCallback)(function(e){t(function(t){return t.filter(function(t){return t.id!==e})})},[]);return(0,x.useEffect)(function(){function e(e){if(t(function(t){return[...t,e]}),!e.persistent){var n=e.duration??5e3;setTimeout(function(){t(function(t){return t.filter(function(t){return t.id!==e.id})})},n)}}return t9.push(e),function(){t9=t9.filter(function(t){return t!==e})}},[]),{items:e,dismiss:n}}function r9({dirty:e,saving:t,saveState:n,onSave:r,extraStatus:i}){var a=t||!e&&n!==`error`,o=(0,x.useRef)(`idle`);return(0,x.useEffect)(function(){o.current!==n&&(n===`saved`?n9(`Settings saved`,`info`):n===`error`&&n9(`Failed to save settings — server did not respond within 5 seconds`,`error`),o.current=n)},[n]),(0,b.jsxs)(`div`,{className:`flex items-center justify-end gap-3`,children:[i&&(0,b.jsx)(`div`,{className:`text-[11px] text-warning/70`,children:i}),!i&&e&&n===`idle`&&!t&&(0,b.jsx)(`div`,{className:`text-[11px] text-warning/70`,children:`Unsaved changes`}),n===`error`&&(0,b.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] text-error`,children:[(0,b.jsx)(Nv,{size:11}),`Save failed — server did not respond`]}),n===`saved`&&(0,b.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] text-success/70`,children:[(0,b.jsx)(L,{size:11}),`Saved`]}),(0,b.jsxs)(`button`,{onClick:r,disabled:a,className:`btn btn-sm gap-1.5 `+(n===`saved`?`btn-success`:n===`error`?`btn-error`:`btn-primary`)+(a?` opacity-50 cursor-not-allowed`:``),children:[t&&(0,b.jsx)(C_,{size:13,className:`animate-spin`}),t?`Saving...`:n===`error`?`Retry`:`Save Changes`]})]})}var i9=[{id:`claude-opus-4-6`,label:`Claude Opus 4.6`},{id:`claude-sonnet-4-6`,label:`Claude Sonnet 4.6`},{id:`claude-haiku-4-5`,label:`Claude Haiku 4.5`},{id:`claude-opus-4-5`,label:`Claude Opus 4.5`},{id:`claude-sonnet-4-5`,label:`Claude Sonnet 4.5`}],y$e=[{id:`low`,label:`Low`},{id:`normal`,label:`Normal`},{id:`high`,label:`High`},{id:`max`,label:`Max`}];function b$e(){var{send:e,subscribe:t,unsubscribe:n}=R(),[r,i]=(0,x.useState)(``),[a,o]=(0,x.useState)(i9[0].id),[s,c]=(0,x.useState)(`normal`),l=e9();(0,x.useEffect)(function(){function r(e){if(e.type===`settings:data`){var t=e.config,n=t.claudeMd?String(t.claudeMd):``,r=t.defaultModel?String(t.defaultModel):i9[0].id,a=t.defaultEffort?String(t.defaultEffort):`normal`;l.savingRef.current?l.confirmSave():(i(n),o(r),c(a),l.resetFromServer())}}return t(`settings:data`,r),e({type:`settings:get`}),function(){n(`settings:data`,r)}},[]);function u(e){o(e),l.markDirty()}function d(e){c(e),l.markDirty()}function f(e){i(e),l.markDirty()}function p(){l.startSave(),e({type:`settings:update`,settings:{claudeMd:r,defaultModel:a,defaultEffort:s}})}return(0,b.jsxs)(`div`,{className:`py-2`,children:[(0,b.jsxs)(`a`,{href:`https://docs.anthropic.com/en/docs/claude-code/memory`,target:`_blank`,rel:`noopener noreferrer`,className:`text-[11px] text-base-content/30 hover:text-primary/70 flex items-center gap-1 mb-4 transition-colors`,children:[(0,b.jsx)(um,{size:11}),`Claude Code docs`]}),(0,b.jsxs)(`div`,{className:`mb-5`,children:[(0,b.jsx)(`label`,{htmlFor:`claude-default-model`,className:`block text-[12px] font-semibold text-base-content/40 mb-2`,children:`Default Model`}),(0,b.jsx)(`select`,{id:`claude-default-model`,value:a,onChange:function(e){u(e.target.value)},className:`w-full h-9 px-3 bg-base-300 border border-base-content/15 rounded-xl text-base-content text-[13px] focus:border-primary focus-visible:outline-none transition-colors duration-[120ms]`,children:i9.map(function(e){return(0,b.jsx)(`option`,{value:e.id,className:`bg-base-300`,children:e.label},e.id)})})]}),(0,b.jsxs)(`div`,{className:`mb-6`,role:`radiogroup`,"aria-label":`Default Effort`,children:[(0,b.jsx)(`div`,{className:`text-[12px] font-semibold text-base-content/40 mb-2`,children:`Default Effort`}),(0,b.jsx)(`div`,{className:`flex gap-2`,children:y$e.map(function(e){var t=s===e.id;return(0,b.jsx)(`button`,{role:`radio`,"aria-checked":t,onClick:function(){d(e.id)},className:`flex-1 py-2.5 sm:py-1.5 rounded-lg border text-[12px] transition-colors duration-[120ms] cursor-pointer focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-1 focus-visible:ring-offset-base-100 `+(t?`border-primary bg-base-300 text-base-content font-semibold`:`border-base-content/15 bg-base-300 text-base-content/40 hover:border-base-content/30 hover:text-base-content/60`),children:e.label},e.id)})})]}),(0,b.jsxs)(`div`,{className:`mb-5`,children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,b.jsx)(`label`,{htmlFor:`claude-global-md`,className:`text-[12px] font-semibold text-base-content/40`,children:`Global CLAUDE.md`}),(0,b.jsx)(`div`,{className:`text-[11px] text-base-content/30 font-mono`,children:`~/.claude/CLAUDE.md`})]}),(0,b.jsx)(`textarea`,{id:`claude-global-md`,value:r,onChange:function(e){f(e.target.value)},placeholder:`# Global instructions for Claude
648
648
 
649
649
  Add your global instructions here...`,rows:14,className:`w-full px-3 py-2.5 bg-base-300 border border-base-content/15 rounded-xl text-base-content text-[12px] font-mono leading-relaxed resize-y focus:border-primary focus-visible:outline-none transition-colors duration-[120ms]`}),(function(){var e=r?r.split(`
650
- `).length:0,t=e>200;return(0,b.jsxs)(`div`,{className:`flex items-center justify-between mt-1.5`,children:[(0,b.jsxs)(`div`,{className:`text-[11px] `+(t?`text-warning`:`text-base-content/25`),children:[e,` line`,e===1?``:`s`,t?` — consider moving content to rules or imports`:``]}),t&&(0,b.jsx)(`div`,{className:`text-[10px] text-warning/70`,children:`soft limit: 200 lines`})]})})()]}),(0,b.jsx)(r9,{dirty:l.dirty,saving:l.saving,saveState:l.saveState,onSave:p})]})}function a9(e){for(var t=new Map,n=new Set,r=0;r<e.length;r++){var i=e[r].key.trim();if(i){var a=(t.get(i)||0)+1;t.set(i,a),a>1&&n.add(i)}}return n}function o9(){return Math.random().toString(36).slice(2,10)}function b$e(){var{send:e,subscribe:t,unsubscribe:n}=R(),[r,i]=(0,x.useState)([]),a=e9();(0,x.useEffect)(function(){function r(e){if(e.type===`settings:data`){var t=e.config.globalEnv??{};a.savingRef.current&&a.confirmSave(),i(Object.entries(t).map(function([e,t]){return{id:o9(),key:e,value:String(t)}})),a.savingRef.current||a.resetFromServer()}}return t(`settings:data`,r),e({type:`settings:get`}),function(){n(`settings:data`,r)}},[]);function o(){i(function(e){return[...e,{id:o9(),key:``,value:``}]}),a.markDirty()}function s(e){i(function(t){return t.filter(function(t){return t.id!==e})}),a.markDirty()}function c(e,t){i(function(n){return n.map(function(n){return n.id===e?{...n,key:t}:n})}),a.markDirty()}function l(e,t){i(function(n){return n.map(function(n){return n.id===e?{...n,value:t}:n})}),a.markDirty()}function u(){var t={};r.forEach(function(e){e.key.trim()&&(t[e.key.trim()]=e.value)}),a.startSave(),e({type:`settings:update`,settings:{globalEnv:t}})}var d=(0,x.useMemo)(function(){return a9(r)},[r]),f=d.size>0;return(0,b.jsxs)(`div`,{className:`py-2`,children:[(0,b.jsxs)(`div`,{className:`flex flex-col gap-3 sm:gap-1.5 mb-3`,children:[r.length===0&&(0,b.jsx)(`div`,{className:`py-4 text-center text-[13px] text-base-content/30`,children:`No environment variables configured.`}),r.map(function(e,t){var n=e.key.trim()!==``&&d.has(e.key.trim());return(0,b.jsxs)(`div`,{className:`flex flex-col sm:grid sm:grid-cols-[1fr_1fr_auto] gap-1.5 sm:items-center`,children:[(0,b.jsxs)(`div`,{className:`relative`,children:[(0,b.jsx)(`input`,{type:`text`,value:e.key,onChange:function(t){c(e.id,t.target.value)},placeholder:`VARIABLE_NAME`,"aria-label":`Variable name for row `+(t+1),"aria-invalid":n,className:`w-full h-9 sm:h-7 px-3 bg-base-300 border rounded-xl text-base-content font-mono text-[12px] focus:border-primary focus-visible:outline-none transition-colors duration-[120ms] `+(n?`border-warning`:`border-base-content/15`)}),n&&(0,b.jsxs)(`div`,{className:`flex items-center gap-1 mt-0.5 text-[10px] text-warning sm:absolute sm:-bottom-3.5 sm:left-0`,role:`alert`,children:[(0,b.jsx)(Ev,{size:9}),`Duplicate key`]})]}),(0,b.jsxs)(`div`,{className:`flex gap-1.5 items-center`,children:[(0,b.jsx)(`input`,{type:`text`,value:e.value,onChange:function(t){l(e.id,t.target.value)},placeholder:`value`,"aria-label":`Value for `+(e.key||`row `+(t+1)),className:`w-full h-9 sm:h-7 px-3 bg-base-300 border border-base-content/15 rounded-xl text-base-content font-mono text-[12px] focus:border-primary focus-visible:outline-none transition-colors duration-[120ms]`}),(0,b.jsx)(`button`,{onClick:function(){s(e.id)},"aria-label":`Delete `+(e.key||`row `+(t+1)),title:`Delete`,className:`btn btn-ghost btn-xs btn-square text-base-content/30 hover:text-error w-9 h-9 flex-shrink-0 sm:hidden focus-visible:ring-2 focus-visible:ring-primary`,children:(0,b.jsx)(Nv,{size:14})})]}),(0,b.jsx)(`button`,{onClick:function(){s(e.id)},"aria-label":`Delete `+(e.key||`row `+(t+1)),title:`Delete`,className:`btn btn-ghost btn-xs btn-square text-base-content/30 hover:text-error w-7 h-7 hidden sm:flex focus-visible:ring-2 focus-visible:ring-primary`,children:(0,b.jsx)(Nv,{size:12})})]},e.id)})]}),(0,b.jsxs)(`button`,{onClick:o,className:`flex items-center gap-1.5 px-3 py-2.5 sm:py-1.5 rounded-xl border border-dashed border-base-content/20 bg-transparent text-base-content/40 text-[12px] hover:text-base-content/60 hover:border-base-content/30 transition-colors duration-[120ms] mb-5 cursor-pointer focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-1 focus-visible:ring-offset-base-100`,children:[(0,b.jsx)(tv,{size:12}),`Add Variable`]}),(0,b.jsx)(r9,{dirty:a.dirty,saving:a.saving,saveState:a.saveState,onSave:u,extraStatus:f?`Duplicate keys will be merged`:void 0})]})}var x$e=(0,x.memo)(function(e){var t=R(),n=Ay(),[r,i]=(0,x.useState)(`generate`),[a,o]=(0,x.useState)(``),[s,c]=(0,x.useState)(`idle`),[l,u]=(0,x.useState)(null),[d,f]=(0,x.useState)(!1),[p,m]=(0,x.useState)(!1),[h,g]=(0,x.useState)([]),[_,v]=(0,x.useState)(``),y=(0,x.useRef)(null),S=(0,x.useRef)(null),C=(0,x.useRef)(null);(0,x.useEffect)(function(){if(!e.isOpen){ky(),o(``),c(`idle`),u(null),f(!1),m(!1),g([]),v(``),i(`generate`),C.current&&=(clearTimeout(C.current),null);return}function n(e){if(e.type===`mesh:addresses_result`){var t=e;g(t.addresses),t.addresses.length>0&&v(t.addresses[0].address)}}t.subscribe(`mesh:addresses_result`,n),t.send({type:`mesh:addresses`});function r(t){t.key===`Escape`&&e.onClose()}return document.addEventListener(`keydown`,r),function(){document.removeEventListener(`keydown`,r),t.unsubscribe(`mesh:addresses_result`,n)}},[e.isOpen]),(0,x.useEffect)(function(){function n(e){e.type===`mesh:invite_code`&&m(!1)}function r(t){t.type===`mesh:paired`&&(c(`paired`),u(null),setTimeout(function(){e.onClose()},3e3))}function i(e){if(e.type===`mesh:pair_failed`){var t=e;c(`failed`),u(t.message)}}return t.subscribe(`mesh:invite_code`,n),t.subscribe(`mesh:paired`,r),t.subscribe(`mesh:pair_failed`,i),function(){t.unsubscribe(`mesh:invite_code`,n),t.unsubscribe(`mesh:paired`,r),t.unsubscribe(`mesh:pair_failed`,i)}},[]);function w(){ky(),m(!0),t.send({type:`mesh:generate_invite`,address:_})}function T(){var e=a.trim();e&&(c(`connecting`),u(null),C.current&&clearTimeout(C.current),C.current=setTimeout(function(){c(function(e){return e===`connecting`?(u(`Pairing timed out. Check the code and try again.`),`failed`):e})},3e4),t.send({type:`mesh:pair`,code:e}))}function E(){n.inviteCode&&navigator.clipboard.writeText(n.inviteCode).then(function(){f(!0),setTimeout(function(){f(!1)},2e3)})}return e.isOpen?(0,b.jsx)(`div`,{ref:y,role:`dialog`,"aria-modal":`true`,"aria-label":`Pair a node`,className:`fixed inset-0 z-[10000] flex items-center justify-center bg-base-content/65 backdrop-blur-sm`,onClick:e.onClose,children:(0,b.jsxs)(`div`,{className:`w-[440px] max-w-[calc(100vw-24px)] rounded-xl border border-base-300 bg-base-200 overflow-hidden shadow-2xl`,onClick:function(e){e.stopPropagation()},children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between px-5 py-4 border-b border-base-300`,children:[(0,b.jsx)(`div`,{className:`text-[14px] font-semibold text-base-content`,children:`Pair a Node`}),(0,b.jsx)(`button`,{onClick:e.onClose,"aria-label":`Close`,className:`btn btn-ghost btn-xs btn-square text-base-content/40 hover:text-base-content`,children:(0,b.jsx)(Nv,{size:14})})]}),(0,b.jsx)(`div`,{className:`flex border-b border-base-300`,children:[`generate`,`enter`].map(function(e){return(0,b.jsx)(`button`,{onClick:function(){i(e)},className:`flex-1 px-4 py-2.5 text-[13px] cursor-pointer transition-colors duration-[120ms] border-b-2 `+(r===e?`font-semibold text-base-content border-primary`:`font-normal text-base-content/40 border-transparent hover:text-base-content/70`),children:e===`generate`?`Generate Invite`:`Enter Code`},e)})}),(0,b.jsxs)(`div`,{className:`p-5`,children:[r===`generate`&&(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-[12px] text-base-content/40 mb-4 leading-relaxed`,children:`Generate an invite code on this machine and share it with the other node. The code encodes this node's address and a one-time auth token.`}),!n.inviteCode&&!p&&h.length>1&&(0,b.jsxs)(`div`,{className:`mb-3`,children:[(0,b.jsx)(`label`,{className:`text-[11px] font-mono text-base-content/35 uppercase tracking-wider mb-1.5 block`,children:`Network interface`}),(0,b.jsx)(`select`,{value:_,onChange:function(e){v(e.target.value)},className:`select select-bordered select-sm w-full bg-base-100 text-base-content text-[13px] font-mono`,children:h.map(function(e){return(0,b.jsxs)(`option`,{value:e.address,children:[e.address,` (`,e.name,`)`]},e.address)})})]}),!n.inviteCode&&!p&&(0,b.jsx)(`button`,{onClick:w,disabled:!_&&h.length>0,className:`btn btn-primary btn-sm`,children:`Generate Invite Code`}),p&&!n.inviteCode&&(0,b.jsxs)(`div`,{className:`flex items-center gap-2 text-[13px] text-base-content/40`,children:[(0,b.jsx)(C_,{size:14,className:`animate-spin text-primary`}),`Generating invite code...`]}),n.inviteCode&&(0,b.jsxs)(`div`,{children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2 px-3.5 py-2.5 rounded bg-base-100 border border-base-300 mb-4`,children:[(0,b.jsx)(`code`,{className:`flex-1 font-mono text-[14px] font-semibold text-base-content tracking-[0.08em] break-all`,children:n.inviteCode}),(0,b.jsxs)(`button`,{onClick:E,title:`Copy code`,className:`btn btn-xs gap-1 flex-shrink-0 `+(d?`btn-success`:`btn-ghost border border-base-300`),children:[d?(0,b.jsx)(L,{size:12}):(0,b.jsx)(Yf,{size:12}),d?`Copied!`:`Copy`]})]}),(0,b.jsx)(`button`,{onClick:w,className:`text-[12px] text-base-content/40 underline cursor-pointer`,children:`Generate new code`})]})]}),r===`enter`&&(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-[12px] text-base-content/40 mb-4 leading-relaxed`,children:`Paste the invite code generated on the other node to pair with it.`}),(0,b.jsx)(`input`,{ref:S,type:`text`,value:a,onChange:function(e){var t=e.target.value.replace(/[^A-Za-z0-9]/g,``);t.toUpperCase().startsWith(`LTCE`)&&(t=t.slice(4)),t.length>16&&(t=t.slice(0,16));for(var n=[],r=0;r<t.length;r+=4)n.push(t.slice(r,r+4));o(n.length>0?`LTCE-`+n.join(`-`):``),s!==`idle`&&(c(`idle`),u(null))},onKeyDown:function(e){e.key===`Enter`&&T()},placeholder:`LTCE-XXXX-XXXX-XXXX-XXXX`,maxLength:24,autoFocus:!0,disabled:s===`connecting`||s===`paired`,className:`input input-bordered w-full bg-base-100 text-base-content font-mono text-[14px] tracking-[0.06em] mb-3 focus:border-primary`}),s===`idle`&&(0,b.jsx)(`button`,{onClick:T,disabled:!a.trim(),className:`btn btn-sm `+(a.trim()?`btn-primary`:`btn-ghost border border-base-300 cursor-not-allowed`),children:`Pair`}),s===`connecting`&&(0,b.jsxs)(`div`,{className:`flex items-center gap-2 text-[13px] text-base-content/40`,children:[(0,b.jsx)(`span`,{className:`w-3 h-3 rounded-full border-2 border-primary border-t-transparent inline-block`,style:{animation:`spin 0.6s linear infinite`}}),`Connecting...`]}),s===`paired`&&(0,b.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[13px] font-semibold text-success`,children:[(0,b.jsx)(L,{size:14}),`Paired successfully!`]}),s===`failed`&&l&&(0,b.jsx)(`div`,{className:`text-[12px] text-error mt-2`,children:l})]})]})]})}):null});function s9(e){var[t,n]=(0,x.useState)(!1),[r,i]=(0,x.useState)(!1);function a(){if(!t){n(!0);return}e.onUnpair(e.node.id),n(!1)}return(0,b.jsxs)(`div`,{className:`flex items-center gap-3 p-3 sm:p-2.5 px-3.5 rounded-lg border border-base-content/15 bg-base-300 mb-2`,children:[e.node.online?(0,b.jsx)(Hu,{size:10,className:`text-success flex-shrink-0`,"aria-label":`Online`}):(0,b.jsx)(md,{size:10,className:`text-base-content/30 flex-shrink-0`,"aria-label":`Offline`}),(0,b.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,b.jsxs)(`div`,{className:`text-[13px] font-medium text-base-content truncate`,children:[e.node.name,e.node.isLocal&&(0,b.jsx)(`span`,{className:`ml-1.5 text-[10px] font-semibold text-primary uppercase tracking-[0.06em]`,children:`local`})]}),(0,b.jsx)(`div`,{className:`text-[11px] text-base-content/40 truncate`,children:(e.node.addresses&&e.node.addresses.length>0?e.node.addresses:[e.node.address+(e.node.port?`:`+e.node.port:``)]).map(function(e,t){return(0,b.jsxs)(`span`,{children:[t>0&&(0,b.jsx)(`span`,{className:`text-base-content/20 mx-1`,children:`/`}),e]},e)})})]}),!e.node.isLocal&&(0,b.jsxs)(`div`,{className:`flex gap-1.5 flex-shrink-0`,children:[!e.node.online&&(r?(0,b.jsxs)(`span`,{className:`flex items-center gap-1 text-[11px] text-base-content/40`,children:[(0,b.jsx)(C_,{size:10,className:`animate-spin`}),`Connecting...`]}):(0,b.jsxs)(`button`,{onClick:function(){i(!0),e.onReconnect(e.node.id),setTimeout(function(){i(!1)},5e3)},className:`btn btn-ghost btn-xs border border-base-content/20 hover:btn-info hover:border-info gap-1`,title:`Attempt to reconnect`,children:[(0,b.jsx)(ov,{size:10}),`Reconnect`]})),t?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`button`,{onClick:a,className:`btn btn-error btn-xs`,children:`Confirm`}),(0,b.jsx)(`button`,{onClick:function(){n(!1)},className:`btn btn-ghost btn-xs`,children:`Cancel`})]}):(0,b.jsx)(`button`,{onClick:a,className:`btn btn-ghost btn-xs border border-base-content/20 hover:btn-error hover:border-error`,children:`Unpair`})]})]})}function S$e(){var e=R(),{nodes:t}=Ay(),[n,r]=(0,x.useState)(!1),i=(0,x.useCallback)(function(){r(!1)},[]);function a(t){e.send({type:`mesh:unpair`,nodeId:t})}function o(t){e.send({type:`mesh:reconnect`,nodeId:t})}var s=t.find(function(e){return e.isLocal}),c=t.filter(function(e){return!e.isLocal});return(0,b.jsxs)(`div`,{className:`py-2`,children:[(0,b.jsxs)(`div`,{className:`mb-5`,children:[(0,b.jsx)(`div`,{className:`text-[12px] font-semibold text-base-content/40 mb-2 tracking-[0.06em]`,children:`This Node`}),s?(0,b.jsx)(s9,{node:s,onUnpair:a,onReconnect:o}):(0,b.jsx)(`div`,{className:`text-[12px] text-base-content/30`,children:`Loading node information...`})]}),(0,b.jsxs)(`div`,{className:`mb-5`,children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,b.jsx)(`div`,{className:`text-[12px] font-semibold text-base-content/40 tracking-[0.06em]`,children:`Paired Nodes`}),(0,b.jsxs)(`button`,{onClick:function(){r(!0)},className:`btn btn-primary btn-sm sm:btn-xs gap-1`,children:[(0,b.jsx)(tv,{size:10}),`Pair New Node`]})]}),c.length===0?(0,b.jsxs)(`div`,{className:`p-4 rounded-lg border border-dashed border-base-content/10 text-center`,children:[(0,b.jsx)(`div`,{className:`text-[12px] text-base-content/30 mb-0.5`,children:`No paired nodes`}),(0,b.jsx)(`div`,{className:`text-[11px] text-base-content/20`,children:`Connect another machine to view its projects and sessions here.`})]}):c.map(function(e){return(0,b.jsx)(s9,{node:e,onUnpair:a,onReconnect:o},e.id)})]}),(0,b.jsx)(x$e,{isOpen:n,onClose:i})]})}function c9(){return{name:``,serverType:`stdio`,command:``,args:``,env:``,url:``}}function l9(e,t){var n=t.type===`http`?`http`:t.type===`sse`?`sse`:`stdio`;return n===`stdio`&&`command`in t?{name:e,serverType:n,command:t.command,args:(t.args??[]).join(`, `),env:Object.entries(t.env??{}).map(function([e,t]){return e+`=`+t}).join(`
650
+ `).length:0,t=e>200;return(0,b.jsxs)(`div`,{className:`flex items-center justify-between mt-1.5`,children:[(0,b.jsxs)(`div`,{className:`text-[11px] `+(t?`text-warning`:`text-base-content/25`),children:[e,` line`,e===1?``:`s`,t?` — consider moving content to rules or imports`:``]}),t&&(0,b.jsx)(`div`,{className:`text-[10px] text-warning/70`,children:`soft limit: 200 lines`})]})})()]}),(0,b.jsx)(r9,{dirty:l.dirty,saving:l.saving,saveState:l.saveState,onSave:p})]})}function a9(e){for(var t=new Map,n=new Set,r=0;r<e.length;r++){var i=e[r].key.trim();if(i){var a=(t.get(i)||0)+1;t.set(i,a),a>1&&n.add(i)}}return n}function o9(){return Math.random().toString(36).slice(2,10)}function x$e(){var{send:e,subscribe:t,unsubscribe:n}=R(),[r,i]=(0,x.useState)([]),a=e9();(0,x.useEffect)(function(){function r(e){if(e.type===`settings:data`){var t=e.config.globalEnv??{};a.savingRef.current&&a.confirmSave(),i(Object.entries(t).map(function([e,t]){return{id:o9(),key:e,value:String(t)}})),a.savingRef.current||a.resetFromServer()}}return t(`settings:data`,r),e({type:`settings:get`}),function(){n(`settings:data`,r)}},[]);function o(){i(function(e){return[...e,{id:o9(),key:``,value:``}]}),a.markDirty()}function s(e){i(function(t){return t.filter(function(t){return t.id!==e})}),a.markDirty()}function c(e,t){i(function(n){return n.map(function(n){return n.id===e?{...n,key:t}:n})}),a.markDirty()}function l(e,t){i(function(n){return n.map(function(n){return n.id===e?{...n,value:t}:n})}),a.markDirty()}function u(){var t={};r.forEach(function(e){e.key.trim()&&(t[e.key.trim()]=e.value)}),a.startSave(),e({type:`settings:update`,settings:{globalEnv:t}})}var d=(0,x.useMemo)(function(){return a9(r)},[r]),f=d.size>0;return(0,b.jsxs)(`div`,{className:`py-2`,children:[(0,b.jsxs)(`div`,{className:`flex flex-col gap-3 sm:gap-1.5 mb-3`,children:[r.length===0&&(0,b.jsx)(`div`,{className:`py-4 text-center text-[13px] text-base-content/30`,children:`No environment variables configured.`}),r.map(function(e,t){var n=e.key.trim()!==``&&d.has(e.key.trim());return(0,b.jsxs)(`div`,{className:`flex flex-col sm:grid sm:grid-cols-[1fr_1fr_auto] gap-1.5 sm:items-center`,children:[(0,b.jsxs)(`div`,{className:`relative`,children:[(0,b.jsx)(`input`,{type:`text`,value:e.key,onChange:function(t){c(e.id,t.target.value)},placeholder:`VARIABLE_NAME`,"aria-label":`Variable name for row `+(t+1),"aria-invalid":n,className:`w-full h-9 sm:h-7 px-3 bg-base-300 border rounded-xl text-base-content font-mono text-[12px] focus:border-primary focus-visible:outline-none transition-colors duration-[120ms] `+(n?`border-warning`:`border-base-content/15`)}),n&&(0,b.jsxs)(`div`,{className:`flex items-center gap-1 mt-0.5 text-[10px] text-warning sm:absolute sm:-bottom-3.5 sm:left-0`,role:`alert`,children:[(0,b.jsx)(Ev,{size:9}),`Duplicate key`]})]}),(0,b.jsxs)(`div`,{className:`flex gap-1.5 items-center`,children:[(0,b.jsx)(`input`,{type:`text`,value:e.value,onChange:function(t){l(e.id,t.target.value)},placeholder:`value`,"aria-label":`Value for `+(e.key||`row `+(t+1)),className:`w-full h-9 sm:h-7 px-3 bg-base-300 border border-base-content/15 rounded-xl text-base-content font-mono text-[12px] focus:border-primary focus-visible:outline-none transition-colors duration-[120ms]`}),(0,b.jsx)(`button`,{onClick:function(){s(e.id)},"aria-label":`Delete `+(e.key||`row `+(t+1)),title:`Delete`,className:`btn btn-ghost btn-xs btn-square text-base-content/30 hover:text-error w-9 h-9 flex-shrink-0 sm:hidden focus-visible:ring-2 focus-visible:ring-primary`,children:(0,b.jsx)(Nv,{size:14})})]}),(0,b.jsx)(`button`,{onClick:function(){s(e.id)},"aria-label":`Delete `+(e.key||`row `+(t+1)),title:`Delete`,className:`btn btn-ghost btn-xs btn-square text-base-content/30 hover:text-error w-7 h-7 hidden sm:flex focus-visible:ring-2 focus-visible:ring-primary`,children:(0,b.jsx)(Nv,{size:12})})]},e.id)})]}),(0,b.jsxs)(`button`,{onClick:o,className:`flex items-center gap-1.5 px-3 py-2.5 sm:py-1.5 rounded-xl border border-dashed border-base-content/20 bg-transparent text-base-content/40 text-[12px] hover:text-base-content/60 hover:border-base-content/30 transition-colors duration-[120ms] mb-5 cursor-pointer focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-1 focus-visible:ring-offset-base-100`,children:[(0,b.jsx)(tv,{size:12}),`Add Variable`]}),(0,b.jsx)(r9,{dirty:a.dirty,saving:a.saving,saveState:a.saveState,onSave:u,extraStatus:f?`Duplicate keys will be merged`:void 0})]})}var S$e=(0,x.memo)(function(e){var t=R(),n=Ay(),[r,i]=(0,x.useState)(`generate`),[a,o]=(0,x.useState)(``),[s,c]=(0,x.useState)(`idle`),[l,u]=(0,x.useState)(null),[d,f]=(0,x.useState)(!1),[p,m]=(0,x.useState)(!1),[h,g]=(0,x.useState)([]),[_,v]=(0,x.useState)(``),y=(0,x.useRef)(null),S=(0,x.useRef)(null),C=(0,x.useRef)(null);(0,x.useEffect)(function(){if(!e.isOpen){ky(),o(``),c(`idle`),u(null),f(!1),m(!1),g([]),v(``),i(`generate`),C.current&&=(clearTimeout(C.current),null);return}function n(e){if(e.type===`mesh:addresses_result`){var t=e;g(t.addresses),t.addresses.length>0&&v(t.addresses[0].address)}}t.subscribe(`mesh:addresses_result`,n),t.send({type:`mesh:addresses`});function r(t){t.key===`Escape`&&e.onClose()}return document.addEventListener(`keydown`,r),function(){document.removeEventListener(`keydown`,r),t.unsubscribe(`mesh:addresses_result`,n)}},[e.isOpen]),(0,x.useEffect)(function(){function n(e){e.type===`mesh:invite_code`&&m(!1)}function r(t){t.type===`mesh:paired`&&(c(`paired`),u(null),setTimeout(function(){e.onClose()},3e3))}function i(e){if(e.type===`mesh:pair_failed`){var t=e;c(`failed`),u(t.message)}}return t.subscribe(`mesh:invite_code`,n),t.subscribe(`mesh:paired`,r),t.subscribe(`mesh:pair_failed`,i),function(){t.unsubscribe(`mesh:invite_code`,n),t.unsubscribe(`mesh:paired`,r),t.unsubscribe(`mesh:pair_failed`,i)}},[]);function w(){ky(),m(!0),t.send({type:`mesh:generate_invite`,address:_})}function T(){var e=a.trim();e&&(c(`connecting`),u(null),C.current&&clearTimeout(C.current),C.current=setTimeout(function(){c(function(e){return e===`connecting`?(u(`Pairing timed out. Check the code and try again.`),`failed`):e})},3e4),t.send({type:`mesh:pair`,code:e}))}function E(){n.inviteCode&&navigator.clipboard.writeText(n.inviteCode).then(function(){f(!0),setTimeout(function(){f(!1)},2e3)})}return e.isOpen?(0,b.jsx)(`div`,{ref:y,role:`dialog`,"aria-modal":`true`,"aria-label":`Pair a node`,className:`fixed inset-0 z-[10000] flex items-center justify-center bg-base-content/65 backdrop-blur-sm`,onClick:e.onClose,children:(0,b.jsxs)(`div`,{className:`w-[440px] max-w-[calc(100vw-24px)] rounded-xl border border-base-300 bg-base-200 overflow-hidden shadow-2xl`,onClick:function(e){e.stopPropagation()},children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between px-5 py-4 border-b border-base-300`,children:[(0,b.jsx)(`div`,{className:`text-[14px] font-semibold text-base-content`,children:`Pair a Node`}),(0,b.jsx)(`button`,{onClick:e.onClose,"aria-label":`Close`,className:`btn btn-ghost btn-xs btn-square text-base-content/40 hover:text-base-content`,children:(0,b.jsx)(Nv,{size:14})})]}),(0,b.jsx)(`div`,{className:`flex border-b border-base-300`,children:[`generate`,`enter`].map(function(e){return(0,b.jsx)(`button`,{onClick:function(){i(e)},className:`flex-1 px-4 py-2.5 text-[13px] cursor-pointer transition-colors duration-[120ms] border-b-2 `+(r===e?`font-semibold text-base-content border-primary`:`font-normal text-base-content/40 border-transparent hover:text-base-content/70`),children:e===`generate`?`Generate Invite`:`Enter Code`},e)})}),(0,b.jsxs)(`div`,{className:`p-5`,children:[r===`generate`&&(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-[12px] text-base-content/40 mb-4 leading-relaxed`,children:`Generate an invite code on this machine and share it with the other node. The code encodes this node's address and a one-time auth token.`}),!n.inviteCode&&!p&&h.length>1&&(0,b.jsxs)(`div`,{className:`mb-3`,children:[(0,b.jsx)(`label`,{className:`text-[11px] font-mono text-base-content/35 uppercase tracking-wider mb-1.5 block`,children:`Network interface`}),(0,b.jsx)(`select`,{value:_,onChange:function(e){v(e.target.value)},className:`select select-bordered select-sm w-full bg-base-100 text-base-content text-[13px] font-mono`,children:h.map(function(e){return(0,b.jsxs)(`option`,{value:e.address,children:[e.address,` (`,e.name,`)`]},e.address)})})]}),!n.inviteCode&&!p&&(0,b.jsx)(`button`,{onClick:w,disabled:!_&&h.length>0,className:`btn btn-primary btn-sm`,children:`Generate Invite Code`}),p&&!n.inviteCode&&(0,b.jsxs)(`div`,{className:`flex items-center gap-2 text-[13px] text-base-content/40`,children:[(0,b.jsx)(C_,{size:14,className:`animate-spin text-primary`}),`Generating invite code...`]}),n.inviteCode&&(0,b.jsxs)(`div`,{children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2 px-3.5 py-2.5 rounded bg-base-100 border border-base-300 mb-4`,children:[(0,b.jsx)(`code`,{className:`flex-1 font-mono text-[14px] font-semibold text-base-content tracking-[0.08em] break-all`,children:n.inviteCode}),(0,b.jsxs)(`button`,{onClick:E,title:`Copy code`,className:`btn btn-xs gap-1 flex-shrink-0 `+(d?`btn-success`:`btn-ghost border border-base-300`),children:[d?(0,b.jsx)(L,{size:12}):(0,b.jsx)(Yf,{size:12}),d?`Copied!`:`Copy`]})]}),(0,b.jsx)(`button`,{onClick:w,className:`text-[12px] text-base-content/40 underline cursor-pointer`,children:`Generate new code`})]})]}),r===`enter`&&(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-[12px] text-base-content/40 mb-4 leading-relaxed`,children:`Paste the invite code generated on the other node to pair with it.`}),(0,b.jsx)(`input`,{ref:S,type:`text`,value:a,onChange:function(e){var t=e.target.value.replace(/[^A-Za-z0-9]/g,``);t.toUpperCase().startsWith(`LTCE`)&&(t=t.slice(4)),t.length>16&&(t=t.slice(0,16));for(var n=[],r=0;r<t.length;r+=4)n.push(t.slice(r,r+4));o(n.length>0?`LTCE-`+n.join(`-`):``),s!==`idle`&&(c(`idle`),u(null))},onKeyDown:function(e){e.key===`Enter`&&T()},placeholder:`LTCE-XXXX-XXXX-XXXX-XXXX`,maxLength:24,autoFocus:!0,disabled:s===`connecting`||s===`paired`,className:`input input-bordered w-full bg-base-100 text-base-content font-mono text-[14px] tracking-[0.06em] mb-3 focus:border-primary`}),s===`idle`&&(0,b.jsx)(`button`,{onClick:T,disabled:!a.trim(),className:`btn btn-sm `+(a.trim()?`btn-primary`:`btn-ghost border border-base-300 cursor-not-allowed`),children:`Pair`}),s===`connecting`&&(0,b.jsxs)(`div`,{className:`flex items-center gap-2 text-[13px] text-base-content/40`,children:[(0,b.jsx)(`span`,{className:`w-3 h-3 rounded-full border-2 border-primary border-t-transparent inline-block`,style:{animation:`spin 0.6s linear infinite`}}),`Connecting...`]}),s===`paired`&&(0,b.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[13px] font-semibold text-success`,children:[(0,b.jsx)(L,{size:14}),`Paired successfully!`]}),s===`failed`&&l&&(0,b.jsx)(`div`,{className:`text-[12px] text-error mt-2`,children:l})]})]})]})}):null});function s9(e){var[t,n]=(0,x.useState)(!1),[r,i]=(0,x.useState)(!1);function a(){if(!t){n(!0);return}e.onUnpair(e.node.id),n(!1)}return(0,b.jsxs)(`div`,{className:`flex items-center gap-3 p-3 sm:p-2.5 px-3.5 rounded-lg border border-base-content/15 bg-base-300 mb-2`,children:[e.node.online?(0,b.jsx)(Hu,{size:10,className:`text-success flex-shrink-0`,"aria-label":`Online`}):(0,b.jsx)(md,{size:10,className:`text-base-content/30 flex-shrink-0`,"aria-label":`Offline`}),(0,b.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,b.jsxs)(`div`,{className:`text-[13px] font-medium text-base-content truncate`,children:[e.node.name,e.node.isLocal&&(0,b.jsx)(`span`,{className:`ml-1.5 text-[10px] font-semibold text-primary uppercase tracking-[0.06em]`,children:`local`})]}),(0,b.jsx)(`div`,{className:`text-[11px] text-base-content/40 truncate`,children:(e.node.addresses&&e.node.addresses.length>0?e.node.addresses:[e.node.address+(e.node.port?`:`+e.node.port:``)]).map(function(e,t){return(0,b.jsxs)(`span`,{children:[t>0&&(0,b.jsx)(`span`,{className:`text-base-content/20 mx-1`,children:`/`}),e]},e)})})]}),!e.node.isLocal&&(0,b.jsxs)(`div`,{className:`flex gap-1.5 flex-shrink-0`,children:[!e.node.online&&(r?(0,b.jsxs)(`span`,{className:`flex items-center gap-1 text-[11px] text-base-content/40`,children:[(0,b.jsx)(C_,{size:10,className:`animate-spin`}),`Connecting...`]}):(0,b.jsxs)(`button`,{onClick:function(){i(!0),e.onReconnect(e.node.id),setTimeout(function(){i(!1)},5e3)},className:`btn btn-ghost btn-xs border border-base-content/20 hover:btn-info hover:border-info gap-1`,title:`Attempt to reconnect`,children:[(0,b.jsx)(ov,{size:10}),`Reconnect`]})),t?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`button`,{onClick:a,className:`btn btn-error btn-xs`,children:`Confirm`}),(0,b.jsx)(`button`,{onClick:function(){n(!1)},className:`btn btn-ghost btn-xs`,children:`Cancel`})]}):(0,b.jsx)(`button`,{onClick:a,className:`btn btn-ghost btn-xs border border-base-content/20 hover:btn-error hover:border-error`,children:`Unpair`})]})]})}function C$e(){var e=R(),{nodes:t}=Ay(),[n,r]=(0,x.useState)(!1),i=(0,x.useCallback)(function(){r(!1)},[]);function a(t){e.send({type:`mesh:unpair`,nodeId:t})}function o(t){e.send({type:`mesh:reconnect`,nodeId:t})}var s=t.find(function(e){return e.isLocal}),c=t.filter(function(e){return!e.isLocal});return(0,b.jsxs)(`div`,{className:`py-2`,children:[(0,b.jsxs)(`div`,{className:`mb-5`,children:[(0,b.jsx)(`div`,{className:`text-[12px] font-semibold text-base-content/40 mb-2 tracking-[0.06em]`,children:`This Node`}),s?(0,b.jsx)(s9,{node:s,onUnpair:a,onReconnect:o}):(0,b.jsx)(`div`,{className:`text-[12px] text-base-content/30`,children:`Loading node information...`})]}),(0,b.jsxs)(`div`,{className:`mb-5`,children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,b.jsx)(`div`,{className:`text-[12px] font-semibold text-base-content/40 tracking-[0.06em]`,children:`Paired Nodes`}),(0,b.jsxs)(`button`,{onClick:function(){r(!0)},className:`btn btn-primary btn-sm sm:btn-xs gap-1`,children:[(0,b.jsx)(tv,{size:10}),`Pair New Node`]})]}),c.length===0?(0,b.jsxs)(`div`,{className:`p-4 rounded-lg border border-dashed border-base-content/10 text-center`,children:[(0,b.jsx)(`div`,{className:`text-[12px] text-base-content/30 mb-0.5`,children:`No paired nodes`}),(0,b.jsx)(`div`,{className:`text-[11px] text-base-content/20`,children:`Connect another machine to view its projects and sessions here.`})]}):c.map(function(e){return(0,b.jsx)(s9,{node:e,onUnpair:a,onReconnect:o},e.id)})]}),(0,b.jsx)(S$e,{isOpen:n,onClose:i})]})}function c9(){return{name:``,serverType:`stdio`,command:``,args:``,env:``,url:``}}function l9(e,t){var n=t.type===`http`?`http`:t.type===`sse`?`sse`:`stdio`;return n===`stdio`&&`command`in t?{name:e,serverType:n,command:t.command,args:(t.args??[]).join(`, `),env:Object.entries(t.env??{}).map(function([e,t]){return e+`=`+t}).join(`
651
651
  `),url:``}:`url`in t?{name:e,serverType:n,command:``,args:``,env:``,url:t.url}:{...c9(),name:e,serverType:n}}function u9(e){if(e.serverType===`stdio`){var t=e.args.trim()?e.args.split(`,`).map(function(e){return e.trim()}).filter(Boolean):[],n={};e.env.split(`
652
652
  `).forEach(function(e){var t=e.indexOf(`=`);t>0&&(n[e.slice(0,t).trim()]=e.slice(t+1).trim())});var r={type:`stdio`,command:e.command.trim(),args:t};return Object.keys(n).length>0&&(r.env=n),r}return{type:e.serverType,url:e.url.trim()}}function d9(e){return(0,b.jsx)(`span`,{className:`px-1.5 py-0.5 rounded-lg text-[10px] uppercase tracking-wider font-mono bg-base-content/10 text-base-content/40 flex-shrink-0`,children:e.type===`http`?`http`:e.type===`sse`?`sse`:`stdio`})}function f9(e){return e.type===`http`||e.type===`sse`?(0,b.jsx)(`div`,{className:`font-mono text-[11px] text-base-content/40 truncate`,children:e.url}):(0,b.jsx)(`div`,{className:`font-mono text-[11px] text-base-content/40 truncate`,children:e.command+((e.args?.length??0)>0?` `+e.args.join(` `):``)})}function p9({form:e,setForm:t,onSave:n,onCancel:r,existingNames:i,idPrefix:a}){var o=`w-full h-9 sm:h-7 px-3 bg-base-300 border border-base-content/15 rounded-xl text-base-content font-mono text-[12px] focus:border-primary focus-visible:outline-none transition-colors duration-[120ms]`,s=e.name.trim()!==``&&i.has(e.name.trim()),c=e.name.trim()!==``&&!s&&(e.serverType===`stdio`?e.command.trim()!==``:e.url.trim()!==``);return(0,b.jsxs)(`div`,{className:`border border-base-content/15 rounded-xl bg-base-300/40 p-4 flex flex-col gap-3`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{htmlFor:a+`-name`,className:`block text-[11px] text-base-content/40 mb-1`,children:`Server Name`}),(0,b.jsx)(`input`,{id:a+`-name`,type:`text`,value:e.name,onChange:function(n){t({...e,name:n.target.value})},placeholder:`my-server`,className:`w-full h-9 sm:h-7 px-3 bg-base-300 border rounded-xl text-base-content font-mono text-[12px] focus:border-primary focus-visible:outline-none transition-colors duration-[120ms] `+(s?`border-warning`:`border-base-content/15`)}),s&&(0,b.jsx)(`div`,{className:`text-[10px] text-warning mt-0.5`,role:`alert`,children:`Name already in use`})]}),(0,b.jsxs)(`fieldset`,{children:[(0,b.jsx)(`legend`,{className:`block text-[11px] text-base-content/40 mb-1.5`,children:`Type`}),(0,b.jsx)(`div`,{className:`flex gap-3`,children:[`stdio`,`http`,`sse`].map(function(n){return(0,b.jsxs)(`label`,{className:`flex items-center gap-1.5 cursor-pointer`,children:[(0,b.jsx)(`input`,{type:`radio`,name:a+`-type`,value:n,checked:e.serverType===n,onChange:function(){t({...e,serverType:n})},className:`radio radio-xs radio-primary`}),(0,b.jsx)(`span`,{className:`text-[12px] font-mono text-base-content uppercase`,children:n})]},n)})})]}),e.serverType===`stdio`&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{htmlFor:a+`-command`,className:`block text-[11px] text-base-content/40 mb-1`,children:`Command`}),(0,b.jsx)(`input`,{id:a+`-command`,type:`text`,value:e.command,onChange:function(n){t({...e,command:n.target.value})},placeholder:`npx`,className:o})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{htmlFor:a+`-args`,className:`block text-[11px] text-base-content/40 mb-1`,children:`Args (comma-separated)`}),(0,b.jsx)(`input`,{id:a+`-args`,type:`text`,value:e.args,onChange:function(n){t({...e,args:n.target.value})},placeholder:`-y, @modelcontextprotocol/server-filesystem`,className:o})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{htmlFor:a+`-env`,className:`block text-[11px] text-base-content/40 mb-1`,children:`Environment (KEY=value, one per line)`}),(0,b.jsx)(`textarea`,{id:a+`-env`,value:e.env,onChange:function(n){t({...e,env:n.target.value})},placeholder:`API_KEY=abc123
653
- DEBUG=true`,rows:3,className:`w-full px-3 py-2 bg-base-300 border border-base-content/15 rounded-xl text-base-content font-mono text-[12px] focus:border-primary focus-visible:outline-none transition-colors duration-[120ms] resize-y`})]})]}),(e.serverType===`http`||e.serverType===`sse`)&&(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{htmlFor:a+`-url`,className:`block text-[11px] text-base-content/40 mb-1`,children:`URL`}),(0,b.jsx)(`input`,{id:a+`-url`,type:`text`,value:e.url,onChange:function(n){t({...e,url:n.target.value})},placeholder:`http://localhost:3000/mcp`,className:o})]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2 justify-end pt-1`,children:[(0,b.jsx)(`button`,{onClick:r,className:`btn btn-ghost btn-sm text-[12px]`,children:`Cancel`}),(0,b.jsx)(`button`,{onClick:n,disabled:!c,className:`btn btn-primary btn-sm text-[12px]`+(c?``:` opacity-50 cursor-not-allowed`),children:`Save`})]})]})}function C$e(){var{send:e,subscribe:t,unsubscribe:n}=R(),[r,i]=(0,x.useState)({}),a=e9(),[o,s]=(0,x.useState)(!1),[c,l]=(0,x.useState)(c9),[u,d]=(0,x.useState)(null),[f,p]=(0,x.useState)(c9),[m,h]=(0,x.useState)(null);(0,x.useEffect)(function(){function r(e){if(e.type===`settings:data`){var t=e.mcpServers??{};a.savingRef.current?a.confirmSave():(i({...t}),a.resetFromServer())}}return t(`settings:data`,r),e({type:`settings:get`}),function(){n(`settings:data`,r)}},[]);var g=Object.entries(r);function _(){var e=c.name.trim();e&&(i({...r,[e]:u9(c)}),s(!1),l(c9()),a.markDirty())}function v(e){d(e),p(l9(e,r[e])),s(!1),h(null)}function y(){if(u){var e=f.name.trim();if(e){var t={...r};e!==u&&delete t[u],t[e]=u9(f),i(t),d(null),a.markDirty()}}}function S(e){if(m!==e){h(e);return}var t={...r};delete t[e],i(t),u===e&&d(null),h(null),a.markDirty()}function C(){a.startSave(),e({type:`settings:update`,settings:{mcpServers:r}})}var w=new Set(Object.keys(r)),T=new Set(Object.keys(r).filter(function(e){return e!==u}));return(0,b.jsxs)(`div`,{className:`py-2`,children:[(0,b.jsxs)(`a`,{href:`https://docs.anthropic.com/en/docs/claude-code/mcp-servers`,target:`_blank`,rel:`noopener noreferrer`,className:`text-[11px] text-base-content/30 hover:text-primary/70 flex items-center gap-1 mb-4 transition-colors`,children:[(0,b.jsx)(um,{size:11}),`Claude Code docs`]}),g.length===0&&!o&&(0,b.jsx)(`div`,{className:`py-4 text-center text-[13px] text-base-content/30 mb-3`,children:`No global MCP servers configured.`}),(0,b.jsx)(`div`,{className:`flex flex-col gap-2 mb-3`,children:g.map(function([e,t]){if(u===e)return(0,b.jsx)(p9,{form:f,setForm:p,onSave:y,onCancel:function(){d(null)},existingNames:T,idPrefix:`global-mcp-edit`},e);var n=m===e;return(0,b.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-2 rounded-xl bg-base-300 border border-base-content/15`,children:[(0,b.jsx)(`span`,{className:`font-mono text-[12px] text-base-content font-semibold flex-shrink-0`,children:e}),d9(t),(0,b.jsx)(`div`,{className:`flex-1 min-w-0`,children:f9(t)}),n?(0,b.jsxs)(`div`,{className:`flex gap-1.5 flex-shrink-0`,children:[(0,b.jsx)(`button`,{onClick:function(){S(e)},className:`btn btn-error btn-xs`,children:`Confirm`}),(0,b.jsx)(`button`,{onClick:function(){h(null)},className:`btn btn-ghost btn-xs`,children:`Cancel`})]}):(0,b.jsxs)(`div`,{className:`flex gap-1 flex-shrink-0`,children:[(0,b.jsx)(`button`,{onClick:function(){v(e)},"aria-label":`Edit `+e,className:`btn btn-ghost btn-xs btn-square text-base-content/30 hover:text-primary focus-visible:ring-2 focus-visible:ring-primary`,children:(0,b.jsx)($_,{size:12})}),(0,b.jsx)(`button`,{onClick:function(){S(e)},"aria-label":`Delete `+e,className:`btn btn-ghost btn-xs btn-square text-base-content/30 hover:text-error focus-visible:ring-2 focus-visible:ring-primary`,children:(0,b.jsx)(Tv,{size:12})})]})]},e)})}),o&&(0,b.jsx)(`div`,{className:`mb-3`,children:(0,b.jsx)(p9,{form:c,setForm:l,onSave:_,onCancel:function(){s(!1),l(c9())},existingNames:w,idPrefix:`global-mcp-add`})}),!o&&(0,b.jsxs)(`button`,{onClick:function(){s(!0),d(null),h(null)},className:`flex items-center gap-1.5 px-3 py-2.5 sm:py-1.5 rounded-xl border border-dashed border-base-content/20 bg-transparent text-base-content/40 text-[12px] hover:text-base-content/60 hover:border-base-content/30 transition-colors duration-[120ms] mb-5 cursor-pointer focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-1 focus-visible:ring-offset-base-100`,children:[(0,b.jsx)(tv,{size:12}),`Add Server`]}),(0,b.jsx)(r9,{dirty:a.dirty,saving:a.saving,saveState:a.saveState,onSave:C})]})}function m9({defaultScope:e,defaultProjectSlug:t}){var{send:n,subscribe:r,unsubscribe:i}=R(),{projects:a}=Dy(),[o,s]=(0,x.useState)(``),[c,l]=(0,x.useState)([]),[u,d]=(0,x.useState)(0),[f,p]=(0,x.useState)(null),[m,h]=(0,x.useState)(!1),[g,_]=(0,x.useState)(null),[v,y]=(0,x.useState)(null),[S,C]=(0,x.useState)(`global`),[w,T]=(0,x.useState)(void 0),E=(0,x.useRef)(null);(0,x.useEffect)(function(){function e(e){if(e.type===`skills:search_results`){var t=e;l(t.skills),d(t.count),p(t.error??null),h(!1)}}function t(e){e.type===`skills:install_result`&&(e.success&&S===`project`&&w&&n({type:`project-settings:get`,projectSlug:w}),_(null))}return r(`skills:search_results`,e),r(`skills:install_result`,t),function(){i(`skills:search_results`,e),i(`skills:install_result`,t)}},[]),(0,x.useEffect)(function(){E.current&&clearTimeout(E.current);var e=o.trim();if(!e){l([]),d(0),p(null),h(!1);return}h(!0),E.current=setTimeout(function(){n({type:`skills:search`,query:e})},300)},[o]);function D(e,t,r){_(e.id),y(null),C(t),T(r),n({type:`skills:install`,source:e.source,scope:t,projectSlug:r})}function O(e){return e>=1e6?(e/1e6).toFixed(1)+`M`:e>=1e3?(e/1e3).toFixed(1)+`K`:String(e)}return(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-[12px] font-semibold text-base-content/40 mb-2`,children:`Skill Marketplace`}),(0,b.jsxs)(`div`,{className:`relative mb-3`,children:[(0,b.jsx)(dv,{size:14,className:`absolute left-3 top-1/2 -translate-y-1/2 text-base-content/30`}),(0,b.jsx)(`input`,{type:`text`,value:o,onChange:function(e){s(e.target.value)},placeholder:`Search skills.sh...`,className:`w-full h-9 sm:h-7 pl-9 pr-3 bg-base-300 border border-base-content/15 rounded-xl text-base-content font-mono text-[12px] focus:border-primary focus-visible:outline-none transition-colors duration-[120ms]`}),m&&(0,b.jsx)(C_,{size:14,className:`absolute right-3 top-1/2 -translate-y-1/2 text-base-content/30 animate-spin`})]}),f&&(0,b.jsx)(`div`,{className:`text-[12px] text-warning mb-2`,children:f}),c.length>0&&(0,b.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:c.slice(0,15).map(function(e){var t=g===e.id,n=v===e.id;return(0,b.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-2 rounded-xl bg-base-300 border border-base-content/15`,children:[(0,b.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,b.jsx)(`div`,{className:`text-[12px] font-semibold text-base-content truncate`,children:e.name}),(0,b.jsx)(`div`,{className:`text-[11px] font-mono text-base-content/30 truncate`,children:e.source})]}),(0,b.jsx)(`span`,{className:`text-[10px] text-base-content/30 font-mono flex-shrink-0`,children:O(e.installs)}),(0,b.jsxs)(`div`,{className:`relative flex-shrink-0`,children:[t?(0,b.jsx)(C_,{size:14,className:`text-primary animate-spin`}):(0,b.jsxs)(`button`,{onClick:function(){y(n?null:e.id)},className:`btn btn-ghost btn-xs text-[11px] text-base-content/50 hover:text-primary gap-1`,children:[(0,b.jsx)(nm,{size:12}),`Install`,(0,b.jsx)(iu,{size:10})]}),n&&(0,b.jsxs)(`div`,{className:`absolute right-0 top-full mt-1 z-50 bg-base-200 border border-base-content/15 rounded-xl shadow-lg py-1 min-w-[160px]`,children:[(0,b.jsx)(`button`,{onClick:function(){D(e,`global`)},className:`w-full text-left px-3 py-1.5 text-[12px] text-base-content/60 hover:bg-base-content/5 hover:text-base-content`,children:`Install globally`}),a.map(function(t){return(0,b.jsxs)(`button`,{onClick:function(){D(e,`project`,t.slug)},className:`w-full text-left px-3 py-1.5 text-[12px] text-base-content/60 hover:bg-base-content/5 hover:text-base-content truncate`,children:[`Install to `,t.title]},t.slug)})]})]})]},e.id)})}),o.trim()&&!m&&c.length===0&&!f&&(0,b.jsx)(`div`,{className:`py-4 text-center text-[13px] text-base-content/30`,children:`No skills found.`})]})}function w$e(e){var t=e.match(/^---\r?\n([\s\S]*?)\r?\n---\s*\r?\n?([\s\S]*)$/);if(!t)return{meta:{},body:e};for(var n={},r=t[1].split(/\r?\n/),i=0;i<r.length;i++){var a=r[i].indexOf(`:`);if(a>0){var o=r[i].slice(0,a).trim();n[o]=r[i].slice(a+1).trim().replace(/^["']|["']$/g,``)}}return{meta:n,body:t[2]}}function h9({skill:e,badge:t,onClick:n,actions:r}){return(0,b.jsxs)(`div`,{onClick:n,className:`flex items-start gap-3 px-3 py-2.5 bg-base-300 border border-base-content/15 rounded-xl transition-colors duration-[120ms]`+(n?` cursor-pointer hover:border-base-content/30 hover:bg-base-300/80`:``),role:n?`button`:void 0,tabIndex:n?0:void 0,onKeyDown:n?function(e){(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),n())}:void 0,children:[(0,b.jsx)(Vm,{size:14,className:`text-base-content/25 mt-0.5 flex-shrink-0`}),(0,b.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(`span`,{className:`text-[13px] font-bold text-base-content truncate`,children:e.name}),t&&(0,b.jsx)(`span`,{className:`shrink-0 text-[10px] font-mono px-1.5 py-0.5 rounded-md bg-base-content/8 text-base-content/40`,children:t})]}),e.description&&(0,b.jsx)(`div`,{className:`text-[12px] text-base-content/40 mt-0.5 line-clamp-2`,children:e.description})]}),r&&(0,b.jsx)(`div`,{className:`flex gap-1 flex-shrink-0 mt-0.5`,onClick:function(e){e.stopPropagation()},children:r})]})}function T$e({skill:e,onDelete:t,onUpdate:n,isDeleting:r,isUpdating:i}){var[a,o]=(0,x.useState)(!1);return(0,b.jsxs)(b.Fragment,{children:[i?(0,b.jsx)(C_,{size:12,className:`text-primary animate-spin mt-1 mx-1`}):(0,b.jsx)(`button`,{onClick:n,"aria-label":`Update `+e.name,className:`btn btn-ghost btn-xs btn-square text-base-content/30 hover:text-info focus-visible:ring-2 focus-visible:ring-primary`,children:(0,b.jsx)(ov,{size:12})}),a?(0,b.jsxs)(`div`,{className:`flex gap-1`,children:[(0,b.jsx)(`button`,{onClick:function(){t(),o(!1)},className:`btn btn-error btn-xs`,disabled:r,children:r?(0,b.jsx)(C_,{size:10,className:`animate-spin`}):`Delete`}),(0,b.jsx)(`button`,{onClick:function(){o(!1)},className:`btn btn-ghost btn-xs`,children:`Cancel`})]}):(0,b.jsx)(`button`,{onClick:function(){o(!0)},"aria-label":`Delete `+e.name,className:`btn btn-ghost btn-xs btn-square text-base-content/30 hover:text-error focus-visible:ring-2 focus-visible:ring-primary`,children:(0,b.jsx)(Tv,{size:12})})]})}function g9({path:e,content:t,onClose:n}){var r=w$e(t),i=Object.keys(r.meta).length>0;return(0,x.useEffect)(function(){function e(e){e.key===`Escape`&&n()}return document.addEventListener(`keydown`,e),function(){document.removeEventListener(`keydown`,e)}},[n]),(0,b.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,role:`dialog`,"aria-modal":`true`,"aria-label":`Skill: `+(r.meta.name||e),children:[(0,b.jsx)(`div`,{className:`absolute inset-0 bg-base-content/50`,onClick:n}),(0,b.jsxs)(`div`,{className:`relative bg-base-200 border border-base-content/15 rounded-2xl shadow-2xl w-full max-w-2xl mx-4 max-h-[80vh] flex flex-col overflow-hidden`,children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between px-5 py-4 border-b border-base-content/15 flex-shrink-0`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,b.jsx)(Vm,{size:16,className:`text-primary flex-shrink-0`}),(0,b.jsx)(`h2`,{className:`text-[15px] font-mono font-bold text-base-content truncate`,children:r.meta.name||e.split(`/`).pop()||e})]}),(0,b.jsx)(`button`,{onClick:n,"aria-label":`Close`,className:`btn btn-ghost btn-xs btn-square text-base-content/40 hover:text-base-content`,children:(0,b.jsx)(Nv,{size:16})})]}),(0,b.jsxs)(`div`,{className:`overflow-y-auto flex-1`,children:[i&&(0,b.jsx)(`div`,{className:`px-5 py-3 border-b border-base-content/10 bg-base-300/30`,children:(0,b.jsx)(`div`,{className:`flex flex-wrap gap-x-6 gap-y-1.5`,children:Object.entries(r.meta).map(function([e,t]){return(0,b.jsxs)(`div`,{className:`flex items-baseline gap-1.5`,children:[(0,b.jsx)(`span`,{className:`text-[11px] font-mono text-base-content/35 uppercase tracking-wider`,children:e}),(0,b.jsx)(`span`,{className:`text-[12px] text-base-content/70`,children:t})]},e)})})}),(0,b.jsx)(`div`,{className:`px-5 py-4`,children:(0,b.jsx)(`div`,{className:`prose prose-sm max-w-none prose-headings:text-base-content prose-headings:font-mono prose-p:text-base-content/70 prose-strong:text-base-content prose-code:text-base-content/60 prose-code:bg-base-100/50 prose-code:px-1 prose-code:py-0.5 prose-code:rounded prose-code:text-[11px] prose-pre:bg-base-100 prose-pre:text-base-content/70 prose-pre:text-[11px] prose-a:text-primary prose-li:text-base-content/70 prose-li:marker:text-base-content/30 [&>*:first-child]:mt-0 [&>*:last-child]:mb-0`,children:(0,b.jsx)(Cw,{remarkPlugins:[hT],children:r.body})})})]}),(0,b.jsx)(`div`,{className:`px-5 py-3 border-t border-base-content/15 flex-shrink-0`,children:(0,b.jsx)(`div`,{className:`text-[11px] font-mono text-base-content/30 truncate`,children:e})})]})]})}function E$e(){var{send:e,subscribe:t,unsubscribe:n}=R(),[r,i]=(0,x.useState)([]),[a,o]=(0,x.useState)(!1),[s,c]=(0,x.useState)(null),[l,u]=(0,x.useState)(null),[d,f]=(0,x.useState)(null);(0,x.useEffect)(function(){function r(e){e.type===`settings:data`&&(i(e.globalSkills??[]),o(!0))}function a(e){if(e.type===`skills:view_result`){var t=e;c({path:t.path,content:t.content})}}function s(e){e.type===`skills:delete_result`&&u(null)}function l(e){e.type===`skills:install_result`&&f(null)}return t(`settings:data`,r),t(`skills:view_result`,a),t(`skills:delete_result`,s),t(`skills:install_result`,l),e({type:`settings:get`}),function(){n(`settings:data`,r),n(`skills:view_result`,a),n(`skills:delete_result`,s),n(`skills:install_result`,l)}},[]);function p(t){e({type:`skills:view`,path:t.path})}function m(t){u(t.path),e({type:`skills:delete`,path:t.path})}function h(t){var n=g(t);n&&(f(t.name),e({type:`skills:update`,source:n}))}function g(e){var t=e.path.split(`/`),n=t.lastIndexOf(`skills`);return n>=0&&n+1<t.length?t[n+1]:e.name}return a?(0,b.jsxs)(`div`,{className:`py-2 space-y-6`,children:[(0,b.jsxs)(`a`,{href:`https://docs.anthropic.com/en/docs/claude-code/slash-commands`,target:`_blank`,rel:`noopener noreferrer`,className:`text-[11px] text-base-content/30 hover:text-primary/70 flex items-center gap-1 mb-4 transition-colors`,children:[(0,b.jsx)(um,{size:11}),`Claude Code docs`]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-[12px] font-semibold text-base-content/40 mb-2`,children:`Installed Skills`}),r.length===0?(0,b.jsxs)(`div`,{className:`py-4 text-center`,children:[(0,b.jsx)(`div`,{className:`text-[12px] text-base-content/30 mb-0.5`,children:`No skills installed`}),(0,b.jsx)(`div`,{className:`text-[11px] text-base-content/20`,children:`Search the marketplace below to add skills.`})]}):(0,b.jsx)(`div`,{className:`space-y-2`,children:r.map(function(e){return(0,b.jsx)(h9,{skill:e,onClick:function(){p(e)},actions:(0,b.jsx)(T$e,{skill:e,onDelete:function(){m(e)},onUpdate:function(){h(e)},isDeleting:l===e.path,isUpdating:d===e.name})},e.path)})})]}),(0,b.jsx)(m9,{defaultScope:`global`}),s&&(0,b.jsx)(g9,{path:s.path,content:s.content,onClose:function(){c(null)}})]}):(0,b.jsx)(`div`,{className:`py-4 space-y-3 animate-pulse`,children:[0,1,2].map(function(e){return(0,b.jsx)(`div`,{className:`bg-base-content/[0.03] rounded-xl h-16`},e)})})}var D$e=[{id:`vscode`,label:`VS Code`},{id:`vscode-insiders`,label:`VS Code Insiders`},{id:`cursor`,label:`Cursor`},{id:`webstorm`,label:`WebStorm`},{id:`intellij`,label:`IntelliJ IDEA`},{id:`pycharm`,label:`PyCharm`},{id:`goland`,label:`GoLand`},{id:`notepad++`,label:`Notepad++`},{id:`sublime`,label:`Sublime Text`},{id:`custom`,label:`Custom`}];function O$e(){var{send:e,subscribe:t,unsubscribe:n}=R(),[r,i]=(0,x.useState)(`vscode`),[a,o]=(0,x.useState)(``),s=e9(),c=(0,x.useRef)(s);c.current=s,(0,x.useEffect)(function(){function r(e){if(e.type===`settings:data`){var t=e.config.editor,n=t?.type??`vscode`,r=t?.customCommand??``;c.current.savingRef.current?c.current.confirmSave():(i(n),o(r),c.current.resetFromServer())}}return t(`settings:data`,r),e({type:`settings:get`}),function(){n(`settings:data`,r)}},[]);function l(e){i(e),s.markDirty()}function u(e){o(e),s.markDirty()}function d(){s.startSave();var t={type:r};r===`custom`&&(t.customCommand=a),e({type:`settings:update`,settings:{editor:t}})}return(0,b.jsxs)(`div`,{className:`py-2`,children:[(0,b.jsxs)(`div`,{className:`mb-5`,children:[(0,b.jsx)(`label`,{htmlFor:`editor-ide-type`,className:`block text-[12px] font-semibold text-base-content/40 mb-1`,children:`IDE`}),(0,b.jsx)(`p`,{className:`text-[11px] text-base-content/30 mb-2`,children:`Choose your preferred editor for opening files from Lattice.`}),(0,b.jsx)(`p`,{className:`text-[11px] text-base-content/20 mb-2`,children:`Files open via your editor's URL scheme handler.`}),(0,b.jsx)(`select`,{id:`editor-ide-type`,value:r,onChange:function(e){l(e.target.value)},className:`w-full h-9 px-3 bg-base-300 border border-base-content/15 rounded-xl text-base-content text-[13px] focus:border-primary focus-visible:outline-none transition-colors duration-[120ms]`,children:D$e.map(function(e){return(0,b.jsx)(`option`,{value:e.id,className:`bg-base-300`,children:e.label},e.id)})})]}),r===`custom`&&(0,b.jsxs)(`div`,{className:`mb-5`,children:[(0,b.jsx)(`label`,{htmlFor:`editor-custom-command`,className:`block text-[12px] font-semibold text-base-content/40 mb-1`,children:`Shell command`}),(0,b.jsxs)(`p`,{className:`text-[11px] text-base-content/30 mb-2`,children:[`Use `,`{file}`,` for the file path and `,`{line}`,` for the line number.`]}),(0,b.jsx)(`input`,{id:`editor-custom-command`,type:`text`,value:a,onChange:function(e){u(e.target.value)},placeholder:`vim +{line} {file}`,className:`w-full h-9 px-3 bg-base-300 border border-base-content/15 rounded-xl text-base-content font-mono text-[13px] focus:border-primary focus-visible:outline-none transition-colors duration-[120ms]`})]}),(0,b.jsx)(r9,{dirty:s.dirty,saving:s.saving,saveState:s.saveState,onSave:d})]})}function k$e(){var{send:e,subscribe:t,unsubscribe:n}=R(),[r,i]=(0,x.useState)([]),[a,o]=(0,x.useState)(``),[s,c]=(0,x.useState)(new Set),[l,u]=(0,x.useState)(!1);(0,x.useEffect)(function(){function r(e){if(e.type===`settings:data`){var t=e,n=t.config;o(n.claudeMd?String(n.claudeMd):``),i(t.globalRules??[])}}return t(`settings:data`,r),e({type:`settings:get`}),function(){n(`settings:data`,r)}},[]);function d(e){c(function(t){var n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}function f(e){var t=e.trim();return t.length<=80?t:t.slice(0,80)+`...`}return(0,b.jsxs)(`div`,{className:`py-2`,children:[(0,b.jsxs)(`a`,{href:`https://docs.anthropic.com/en/docs/claude-code/memory`,target:`_blank`,rel:`noopener noreferrer`,className:`text-[11px] text-base-content/30 hover:text-primary/70 flex items-center gap-1 mb-4 transition-colors`,children:[(0,b.jsx)(um,{size:11}),`Claude Code docs`]}),(0,b.jsxs)(`div`,{className:`mb-6`,children:[(0,b.jsx)(`h2`,{className:`text-[12px] font-semibold text-base-content/40 mb-3`,children:`Global CLAUDE.md`}),!a&&(0,b.jsx)(`div`,{className:`py-4 text-center text-[13px] text-base-content/30`,children:`No global CLAUDE.md found.`}),a&&(0,b.jsxs)(`div`,{className:`border border-base-content/10 rounded-xl overflow-hidden`,children:[(0,b.jsxs)(`button`,{onClick:function(){u(!l)},className:`w-full flex items-center gap-2 px-3 py-2 bg-base-300/50 hover:bg-base-300/70 transition-colors duration-[120ms] cursor-pointer text-left`,children:[l?(0,b.jsx)(iu,{size:12,className:`text-base-content/40 flex-shrink-0`}):(0,b.jsx)(cu,{size:12,className:`text-base-content/40 flex-shrink-0`}),(0,b.jsx)(`span`,{className:`font-mono text-[12px] text-base-content/40 flex-1 truncate`,children:`~/.claude/CLAUDE.md`})]}),!l&&(0,b.jsx)(`div`,{className:`px-3 py-1.5 text-[11px] text-base-content/30 font-mono truncate`,children:f(a)}),l&&(0,b.jsx)(`pre`,{className:`px-3 py-2 text-[12px] text-base-content/40 font-mono whitespace-pre-wrap break-words bg-base-300/30 max-h-[300px] overflow-auto`,children:a})]})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`h2`,{className:`text-[12px] font-semibold text-base-content/40 mb-3`,children:`Global Rules`}),(0,b.jsx)(`p`,{className:`text-[11px] text-base-content/30 mb-3`,children:`Rules from ~/.claude/rules/ — read-only.`}),r.length===0&&(0,b.jsx)(`div`,{className:`py-4 text-center text-[13px] text-base-content/30`,children:`No global rules found.`}),r.length>0&&(0,b.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:r.map(function(e,t){var n=s.has(t);return(0,b.jsxs)(`div`,{className:`border border-base-content/10 rounded-xl overflow-hidden`,children:[(0,b.jsxs)(`button`,{onClick:function(){d(t)},className:`w-full flex items-center gap-2 px-3 py-2 bg-base-300/50 hover:bg-base-300/70 transition-colors duration-[120ms] cursor-pointer text-left`,children:[n?(0,b.jsx)(iu,{size:12,className:`text-base-content/40 flex-shrink-0`}):(0,b.jsx)(cu,{size:12,className:`text-base-content/40 flex-shrink-0`}),(0,b.jsx)(`span`,{className:`font-mono text-[12px] text-base-content/40 flex-1 truncate`,children:e.filename})]}),!n&&(0,b.jsx)(`div`,{className:`px-3 py-1.5 text-[11px] text-base-content/30 font-mono truncate`,children:f(e.content)}),n&&(0,b.jsx)(`pre`,{className:`px-3 py-2 text-[12px] text-base-content/40 font-mono whitespace-pre-wrap break-words bg-base-300/30 max-h-[300px] overflow-auto`,children:e.content})]},e.filename+`-`+t)})})]})]})}var A$e=[`user`,`feedback`,`project`,`reference`];function _9(e){var t=e.match(/^---\r?\n([\s\S]*?)\r?\n---\s*\r?\n?([\s\S]*)$/);if(!t)return{meta:{},body:e};for(var n={},r=t[1].split(/\r?\n/),i=0;i<r.length;i++){var a=r[i].indexOf(`:`);if(a>0){var o=r[i].slice(0,a).trim();n[o]=r[i].slice(a+1).trim().replace(/^["']|["']$/g,``)}}return{meta:n,body:t[2]}}function j$e(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`_`).replace(/^_+|_+$/g,``)||`memory`}function M$e(e,t,n,r){return`---
653
+ DEBUG=true`,rows:3,className:`w-full px-3 py-2 bg-base-300 border border-base-content/15 rounded-xl text-base-content font-mono text-[12px] focus:border-primary focus-visible:outline-none transition-colors duration-[120ms] resize-y`})]})]}),(e.serverType===`http`||e.serverType===`sse`)&&(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{htmlFor:a+`-url`,className:`block text-[11px] text-base-content/40 mb-1`,children:`URL`}),(0,b.jsx)(`input`,{id:a+`-url`,type:`text`,value:e.url,onChange:function(n){t({...e,url:n.target.value})},placeholder:`http://localhost:3000/mcp`,className:o})]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2 justify-end pt-1`,children:[(0,b.jsx)(`button`,{onClick:r,className:`btn btn-ghost btn-sm text-[12px]`,children:`Cancel`}),(0,b.jsx)(`button`,{onClick:n,disabled:!c,className:`btn btn-primary btn-sm text-[12px]`+(c?``:` opacity-50 cursor-not-allowed`),children:`Save`})]})]})}function w$e(){var{send:e,subscribe:t,unsubscribe:n}=R(),[r,i]=(0,x.useState)({}),a=e9(),[o,s]=(0,x.useState)(!1),[c,l]=(0,x.useState)(c9),[u,d]=(0,x.useState)(null),[f,p]=(0,x.useState)(c9),[m,h]=(0,x.useState)(null);(0,x.useEffect)(function(){function r(e){if(e.type===`settings:data`){var t=e.mcpServers??{};a.savingRef.current?a.confirmSave():(i({...t}),a.resetFromServer())}}return t(`settings:data`,r),e({type:`settings:get`}),function(){n(`settings:data`,r)}},[]);var g=Object.entries(r);function _(){var e=c.name.trim();e&&(i({...r,[e]:u9(c)}),s(!1),l(c9()),a.markDirty())}function v(e){d(e),p(l9(e,r[e])),s(!1),h(null)}function y(){if(u){var e=f.name.trim();if(e){var t={...r};e!==u&&delete t[u],t[e]=u9(f),i(t),d(null),a.markDirty()}}}function S(e){if(m!==e){h(e);return}var t={...r};delete t[e],i(t),u===e&&d(null),h(null),a.markDirty()}function C(){a.startSave(),e({type:`settings:update`,settings:{mcpServers:r}})}var w=new Set(Object.keys(r)),T=new Set(Object.keys(r).filter(function(e){return e!==u}));return(0,b.jsxs)(`div`,{className:`py-2`,children:[(0,b.jsxs)(`a`,{href:`https://docs.anthropic.com/en/docs/claude-code/mcp-servers`,target:`_blank`,rel:`noopener noreferrer`,className:`text-[11px] text-base-content/30 hover:text-primary/70 flex items-center gap-1 mb-4 transition-colors`,children:[(0,b.jsx)(um,{size:11}),`Claude Code docs`]}),g.length===0&&!o&&(0,b.jsx)(`div`,{className:`py-4 text-center text-[13px] text-base-content/30 mb-3`,children:`No global MCP servers configured.`}),(0,b.jsx)(`div`,{className:`flex flex-col gap-2 mb-3`,children:g.map(function([e,t]){if(u===e)return(0,b.jsx)(p9,{form:f,setForm:p,onSave:y,onCancel:function(){d(null)},existingNames:T,idPrefix:`global-mcp-edit`},e);var n=m===e;return(0,b.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-2 rounded-xl bg-base-300 border border-base-content/15`,children:[(0,b.jsx)(`span`,{className:`font-mono text-[12px] text-base-content font-semibold flex-shrink-0`,children:e}),d9(t),(0,b.jsx)(`div`,{className:`flex-1 min-w-0`,children:f9(t)}),n?(0,b.jsxs)(`div`,{className:`flex gap-1.5 flex-shrink-0`,children:[(0,b.jsx)(`button`,{onClick:function(){S(e)},className:`btn btn-error btn-xs`,children:`Confirm`}),(0,b.jsx)(`button`,{onClick:function(){h(null)},className:`btn btn-ghost btn-xs`,children:`Cancel`})]}):(0,b.jsxs)(`div`,{className:`flex gap-1 flex-shrink-0`,children:[(0,b.jsx)(`button`,{onClick:function(){v(e)},"aria-label":`Edit `+e,className:`btn btn-ghost btn-xs btn-square text-base-content/30 hover:text-primary focus-visible:ring-2 focus-visible:ring-primary`,children:(0,b.jsx)($_,{size:12})}),(0,b.jsx)(`button`,{onClick:function(){S(e)},"aria-label":`Delete `+e,className:`btn btn-ghost btn-xs btn-square text-base-content/30 hover:text-error focus-visible:ring-2 focus-visible:ring-primary`,children:(0,b.jsx)(Tv,{size:12})})]})]},e)})}),o&&(0,b.jsx)(`div`,{className:`mb-3`,children:(0,b.jsx)(p9,{form:c,setForm:l,onSave:_,onCancel:function(){s(!1),l(c9())},existingNames:w,idPrefix:`global-mcp-add`})}),!o&&(0,b.jsxs)(`button`,{onClick:function(){s(!0),d(null),h(null)},className:`flex items-center gap-1.5 px-3 py-2.5 sm:py-1.5 rounded-xl border border-dashed border-base-content/20 bg-transparent text-base-content/40 text-[12px] hover:text-base-content/60 hover:border-base-content/30 transition-colors duration-[120ms] mb-5 cursor-pointer focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-1 focus-visible:ring-offset-base-100`,children:[(0,b.jsx)(tv,{size:12}),`Add Server`]}),(0,b.jsx)(r9,{dirty:a.dirty,saving:a.saving,saveState:a.saveState,onSave:C})]})}function m9({defaultScope:e,defaultProjectSlug:t}){var{send:n,subscribe:r,unsubscribe:i}=R(),{projects:a}=Dy(),[o,s]=(0,x.useState)(``),[c,l]=(0,x.useState)([]),[u,d]=(0,x.useState)(0),[f,p]=(0,x.useState)(null),[m,h]=(0,x.useState)(!1),[g,_]=(0,x.useState)(null),[v,y]=(0,x.useState)(null),[S,C]=(0,x.useState)(`global`),[w,T]=(0,x.useState)(void 0),E=(0,x.useRef)(null);(0,x.useEffect)(function(){function e(e){if(e.type===`skills:search_results`){var t=e;l(t.skills),d(t.count),p(t.error??null),h(!1)}}function t(e){e.type===`skills:install_result`&&(e.success&&S===`project`&&w&&n({type:`project-settings:get`,projectSlug:w}),_(null))}return r(`skills:search_results`,e),r(`skills:install_result`,t),function(){i(`skills:search_results`,e),i(`skills:install_result`,t)}},[]),(0,x.useEffect)(function(){E.current&&clearTimeout(E.current);var e=o.trim();if(!e){l([]),d(0),p(null),h(!1);return}h(!0),E.current=setTimeout(function(){n({type:`skills:search`,query:e})},300)},[o]);function D(e,t,r){_(e.id),y(null),C(t),T(r),n({type:`skills:install`,source:e.source,scope:t,projectSlug:r})}function O(e){return e>=1e6?(e/1e6).toFixed(1)+`M`:e>=1e3?(e/1e3).toFixed(1)+`K`:String(e)}return(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-[12px] font-semibold text-base-content/40 mb-2`,children:`Skill Marketplace`}),(0,b.jsxs)(`div`,{className:`relative mb-3`,children:[(0,b.jsx)(dv,{size:14,className:`absolute left-3 top-1/2 -translate-y-1/2 text-base-content/30`}),(0,b.jsx)(`input`,{type:`text`,value:o,onChange:function(e){s(e.target.value)},placeholder:`Search skills.sh...`,className:`w-full h-9 sm:h-7 pl-9 pr-3 bg-base-300 border border-base-content/15 rounded-xl text-base-content font-mono text-[12px] focus:border-primary focus-visible:outline-none transition-colors duration-[120ms]`}),m&&(0,b.jsx)(C_,{size:14,className:`absolute right-3 top-1/2 -translate-y-1/2 text-base-content/30 animate-spin`})]}),f&&(0,b.jsx)(`div`,{className:`text-[12px] text-warning mb-2`,children:f}),c.length>0&&(0,b.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:c.slice(0,15).map(function(e){var t=g===e.id,n=v===e.id;return(0,b.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-2 rounded-xl bg-base-300 border border-base-content/15`,children:[(0,b.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,b.jsx)(`div`,{className:`text-[12px] font-semibold text-base-content truncate`,children:e.name}),(0,b.jsx)(`div`,{className:`text-[11px] font-mono text-base-content/30 truncate`,children:e.source})]}),(0,b.jsx)(`span`,{className:`text-[10px] text-base-content/30 font-mono flex-shrink-0`,children:O(e.installs)}),(0,b.jsxs)(`div`,{className:`relative flex-shrink-0`,children:[t?(0,b.jsx)(C_,{size:14,className:`text-primary animate-spin`}):(0,b.jsxs)(`button`,{onClick:function(){y(n?null:e.id)},className:`btn btn-ghost btn-xs text-[11px] text-base-content/50 hover:text-primary gap-1`,children:[(0,b.jsx)(nm,{size:12}),`Install`,(0,b.jsx)(iu,{size:10})]}),n&&(0,b.jsxs)(`div`,{className:`absolute right-0 top-full mt-1 z-50 bg-base-200 border border-base-content/15 rounded-xl shadow-lg py-1 min-w-[160px]`,children:[(0,b.jsx)(`button`,{onClick:function(){D(e,`global`)},className:`w-full text-left px-3 py-1.5 text-[12px] text-base-content/60 hover:bg-base-content/5 hover:text-base-content`,children:`Install globally`}),a.map(function(t){return(0,b.jsxs)(`button`,{onClick:function(){D(e,`project`,t.slug)},className:`w-full text-left px-3 py-1.5 text-[12px] text-base-content/60 hover:bg-base-content/5 hover:text-base-content truncate`,children:[`Install to `,t.title]},t.slug)})]})]})]},e.id)})}),o.trim()&&!m&&c.length===0&&!f&&(0,b.jsx)(`div`,{className:`py-4 text-center text-[13px] text-base-content/30`,children:`No skills found.`})]})}function T$e(e){var t=e.match(/^---\r?\n([\s\S]*?)\r?\n---\s*\r?\n?([\s\S]*)$/);if(!t)return{meta:{},body:e};for(var n={},r=t[1].split(/\r?\n/),i=0;i<r.length;i++){var a=r[i].indexOf(`:`);if(a>0){var o=r[i].slice(0,a).trim();n[o]=r[i].slice(a+1).trim().replace(/^["']|["']$/g,``)}}return{meta:n,body:t[2]}}function h9({skill:e,badge:t,onClick:n,actions:r}){return(0,b.jsxs)(`div`,{onClick:n,className:`flex items-start gap-3 px-3 py-2.5 bg-base-300 border border-base-content/15 rounded-xl transition-colors duration-[120ms]`+(n?` cursor-pointer hover:border-base-content/30 hover:bg-base-300/80`:``),role:n?`button`:void 0,tabIndex:n?0:void 0,onKeyDown:n?function(e){(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),n())}:void 0,children:[(0,b.jsx)(Vm,{size:14,className:`text-base-content/25 mt-0.5 flex-shrink-0`}),(0,b.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(`span`,{className:`text-[13px] font-bold text-base-content truncate`,children:e.name}),t&&(0,b.jsx)(`span`,{className:`shrink-0 text-[10px] font-mono px-1.5 py-0.5 rounded-md bg-base-content/8 text-base-content/40`,children:t})]}),e.description&&(0,b.jsx)(`div`,{className:`text-[12px] text-base-content/40 mt-0.5 line-clamp-2`,children:e.description})]}),r&&(0,b.jsx)(`div`,{className:`flex gap-1 flex-shrink-0 mt-0.5`,onClick:function(e){e.stopPropagation()},children:r})]})}function E$e({skill:e,onDelete:t,onUpdate:n,isDeleting:r,isUpdating:i}){var[a,o]=(0,x.useState)(!1);return(0,b.jsxs)(b.Fragment,{children:[i?(0,b.jsx)(C_,{size:12,className:`text-primary animate-spin mt-1 mx-1`}):(0,b.jsx)(`button`,{onClick:n,"aria-label":`Update `+e.name,className:`btn btn-ghost btn-xs btn-square text-base-content/30 hover:text-info focus-visible:ring-2 focus-visible:ring-primary`,children:(0,b.jsx)(ov,{size:12})}),a?(0,b.jsxs)(`div`,{className:`flex gap-1`,children:[(0,b.jsx)(`button`,{onClick:function(){t(),o(!1)},className:`btn btn-error btn-xs`,disabled:r,children:r?(0,b.jsx)(C_,{size:10,className:`animate-spin`}):`Delete`}),(0,b.jsx)(`button`,{onClick:function(){o(!1)},className:`btn btn-ghost btn-xs`,children:`Cancel`})]}):(0,b.jsx)(`button`,{onClick:function(){o(!0)},"aria-label":`Delete `+e.name,className:`btn btn-ghost btn-xs btn-square text-base-content/30 hover:text-error focus-visible:ring-2 focus-visible:ring-primary`,children:(0,b.jsx)(Tv,{size:12})})]})}function g9({path:e,content:t,onClose:n}){var r=T$e(t),i=Object.keys(r.meta).length>0;return(0,x.useEffect)(function(){function e(e){e.key===`Escape`&&n()}return document.addEventListener(`keydown`,e),function(){document.removeEventListener(`keydown`,e)}},[n]),(0,b.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,role:`dialog`,"aria-modal":`true`,"aria-label":`Skill: `+(r.meta.name||e),children:[(0,b.jsx)(`div`,{className:`absolute inset-0 bg-base-content/50`,onClick:n}),(0,b.jsxs)(`div`,{className:`relative bg-base-200 border border-base-content/15 rounded-2xl shadow-2xl w-full max-w-2xl mx-4 max-h-[80vh] flex flex-col overflow-hidden`,children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between px-5 py-4 border-b border-base-content/15 flex-shrink-0`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,b.jsx)(Vm,{size:16,className:`text-primary flex-shrink-0`}),(0,b.jsx)(`h2`,{className:`text-[15px] font-mono font-bold text-base-content truncate`,children:r.meta.name||e.split(`/`).pop()||e})]}),(0,b.jsx)(`button`,{onClick:n,"aria-label":`Close`,className:`btn btn-ghost btn-xs btn-square text-base-content/40 hover:text-base-content`,children:(0,b.jsx)(Nv,{size:16})})]}),(0,b.jsxs)(`div`,{className:`overflow-y-auto flex-1`,children:[i&&(0,b.jsx)(`div`,{className:`px-5 py-3 border-b border-base-content/10 bg-base-300/30`,children:(0,b.jsx)(`div`,{className:`flex flex-wrap gap-x-6 gap-y-1.5`,children:Object.entries(r.meta).map(function([e,t]){return(0,b.jsxs)(`div`,{className:`flex items-baseline gap-1.5`,children:[(0,b.jsx)(`span`,{className:`text-[11px] font-mono text-base-content/35 uppercase tracking-wider`,children:e}),(0,b.jsx)(`span`,{className:`text-[12px] text-base-content/70`,children:t})]},e)})})}),(0,b.jsx)(`div`,{className:`px-5 py-4`,children:(0,b.jsx)(`div`,{className:`prose prose-sm max-w-none prose-headings:text-base-content prose-headings:font-mono prose-p:text-base-content/70 prose-strong:text-base-content prose-code:text-base-content/60 prose-code:bg-base-100/50 prose-code:px-1 prose-code:py-0.5 prose-code:rounded prose-code:text-[11px] prose-pre:bg-base-100 prose-pre:text-base-content/70 prose-pre:text-[11px] prose-a:text-primary prose-li:text-base-content/70 prose-li:marker:text-base-content/30 [&>*:first-child]:mt-0 [&>*:last-child]:mb-0`,children:(0,b.jsx)(Cw,{remarkPlugins:[hT],children:r.body})})})]}),(0,b.jsx)(`div`,{className:`px-5 py-3 border-t border-base-content/15 flex-shrink-0`,children:(0,b.jsx)(`div`,{className:`text-[11px] font-mono text-base-content/30 truncate`,children:e})})]})]})}function D$e(){var{send:e,subscribe:t,unsubscribe:n}=R(),[r,i]=(0,x.useState)([]),[a,o]=(0,x.useState)(!1),[s,c]=(0,x.useState)(null),[l,u]=(0,x.useState)(null),[d,f]=(0,x.useState)(null);(0,x.useEffect)(function(){function r(e){e.type===`settings:data`&&(i(e.globalSkills??[]),o(!0))}function a(e){if(e.type===`skills:view_result`){var t=e;c({path:t.path,content:t.content})}}function s(e){e.type===`skills:delete_result`&&u(null)}function l(e){e.type===`skills:install_result`&&f(null)}return t(`settings:data`,r),t(`skills:view_result`,a),t(`skills:delete_result`,s),t(`skills:install_result`,l),e({type:`settings:get`}),function(){n(`settings:data`,r),n(`skills:view_result`,a),n(`skills:delete_result`,s),n(`skills:install_result`,l)}},[]);function p(t){e({type:`skills:view`,path:t.path})}function m(t){u(t.path),e({type:`skills:delete`,path:t.path})}function h(t){var n=g(t);n&&(f(t.name),e({type:`skills:update`,source:n}))}function g(e){var t=e.path.split(`/`),n=t.lastIndexOf(`skills`);return n>=0&&n+1<t.length?t[n+1]:e.name}return a?(0,b.jsxs)(`div`,{className:`py-2 space-y-6`,children:[(0,b.jsxs)(`a`,{href:`https://docs.anthropic.com/en/docs/claude-code/slash-commands`,target:`_blank`,rel:`noopener noreferrer`,className:`text-[11px] text-base-content/30 hover:text-primary/70 flex items-center gap-1 mb-4 transition-colors`,children:[(0,b.jsx)(um,{size:11}),`Claude Code docs`]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-[12px] font-semibold text-base-content/40 mb-2`,children:`Installed Skills`}),r.length===0?(0,b.jsxs)(`div`,{className:`py-4 text-center`,children:[(0,b.jsx)(`div`,{className:`text-[12px] text-base-content/30 mb-0.5`,children:`No skills installed`}),(0,b.jsx)(`div`,{className:`text-[11px] text-base-content/20`,children:`Search the marketplace below to add skills.`})]}):(0,b.jsx)(`div`,{className:`space-y-2`,children:r.map(function(e){return(0,b.jsx)(h9,{skill:e,onClick:function(){p(e)},actions:(0,b.jsx)(E$e,{skill:e,onDelete:function(){m(e)},onUpdate:function(){h(e)},isDeleting:l===e.path,isUpdating:d===e.name})},e.path)})})]}),(0,b.jsx)(m9,{defaultScope:`global`}),s&&(0,b.jsx)(g9,{path:s.path,content:s.content,onClose:function(){c(null)}})]}):(0,b.jsx)(`div`,{className:`py-4 space-y-3 animate-pulse`,children:[0,1,2].map(function(e){return(0,b.jsx)(`div`,{className:`bg-base-content/[0.03] rounded-xl h-16`},e)})})}var O$e=[{id:`vscode`,label:`VS Code`},{id:`vscode-insiders`,label:`VS Code Insiders`},{id:`cursor`,label:`Cursor`},{id:`webstorm`,label:`WebStorm`},{id:`intellij`,label:`IntelliJ IDEA`},{id:`pycharm`,label:`PyCharm`},{id:`goland`,label:`GoLand`},{id:`notepad++`,label:`Notepad++`},{id:`sublime`,label:`Sublime Text`},{id:`custom`,label:`Custom`}];function k$e(){var{send:e,subscribe:t,unsubscribe:n}=R(),[r,i]=(0,x.useState)(`vscode`),[a,o]=(0,x.useState)(``),s=e9(),c=(0,x.useRef)(s);c.current=s,(0,x.useEffect)(function(){function r(e){if(e.type===`settings:data`){var t=e.config.editor,n=t?.type??`vscode`,r=t?.customCommand??``;c.current.savingRef.current?c.current.confirmSave():(i(n),o(r),c.current.resetFromServer())}}return t(`settings:data`,r),e({type:`settings:get`}),function(){n(`settings:data`,r)}},[]);function l(e){i(e),s.markDirty()}function u(e){o(e),s.markDirty()}function d(){s.startSave();var t={type:r};r===`custom`&&(t.customCommand=a),e({type:`settings:update`,settings:{editor:t}})}return(0,b.jsxs)(`div`,{className:`py-2`,children:[(0,b.jsxs)(`div`,{className:`mb-5`,children:[(0,b.jsx)(`label`,{htmlFor:`editor-ide-type`,className:`block text-[12px] font-semibold text-base-content/40 mb-1`,children:`IDE`}),(0,b.jsx)(`p`,{className:`text-[11px] text-base-content/30 mb-2`,children:`Choose your preferred editor for opening files from Lattice.`}),(0,b.jsx)(`p`,{className:`text-[11px] text-base-content/20 mb-2`,children:`Files open via your editor's URL scheme handler.`}),(0,b.jsx)(`select`,{id:`editor-ide-type`,value:r,onChange:function(e){l(e.target.value)},className:`w-full h-9 px-3 bg-base-300 border border-base-content/15 rounded-xl text-base-content text-[13px] focus:border-primary focus-visible:outline-none transition-colors duration-[120ms]`,children:O$e.map(function(e){return(0,b.jsx)(`option`,{value:e.id,className:`bg-base-300`,children:e.label},e.id)})})]}),r===`custom`&&(0,b.jsxs)(`div`,{className:`mb-5`,children:[(0,b.jsx)(`label`,{htmlFor:`editor-custom-command`,className:`block text-[12px] font-semibold text-base-content/40 mb-1`,children:`Shell command`}),(0,b.jsxs)(`p`,{className:`text-[11px] text-base-content/30 mb-2`,children:[`Use `,`{file}`,` for the file path and `,`{line}`,` for the line number.`]}),(0,b.jsx)(`input`,{id:`editor-custom-command`,type:`text`,value:a,onChange:function(e){u(e.target.value)},placeholder:`vim +{line} {file}`,className:`w-full h-9 px-3 bg-base-300 border border-base-content/15 rounded-xl text-base-content font-mono text-[13px] focus:border-primary focus-visible:outline-none transition-colors duration-[120ms]`})]}),(0,b.jsx)(r9,{dirty:s.dirty,saving:s.saving,saveState:s.saveState,onSave:d})]})}function A$e(){var{send:e,subscribe:t,unsubscribe:n}=R(),[r,i]=(0,x.useState)([]),[a,o]=(0,x.useState)(``),[s,c]=(0,x.useState)(new Set),[l,u]=(0,x.useState)(!1);(0,x.useEffect)(function(){function r(e){if(e.type===`settings:data`){var t=e,n=t.config;o(n.claudeMd?String(n.claudeMd):``),i(t.globalRules??[])}}return t(`settings:data`,r),e({type:`settings:get`}),function(){n(`settings:data`,r)}},[]);function d(e){c(function(t){var n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}function f(e){var t=e.trim();return t.length<=80?t:t.slice(0,80)+`...`}return(0,b.jsxs)(`div`,{className:`py-2`,children:[(0,b.jsxs)(`a`,{href:`https://docs.anthropic.com/en/docs/claude-code/memory`,target:`_blank`,rel:`noopener noreferrer`,className:`text-[11px] text-base-content/30 hover:text-primary/70 flex items-center gap-1 mb-4 transition-colors`,children:[(0,b.jsx)(um,{size:11}),`Claude Code docs`]}),(0,b.jsxs)(`div`,{className:`mb-6`,children:[(0,b.jsx)(`h2`,{className:`text-[12px] font-semibold text-base-content/40 mb-3`,children:`Global CLAUDE.md`}),!a&&(0,b.jsx)(`div`,{className:`py-4 text-center text-[13px] text-base-content/30`,children:`No global CLAUDE.md found.`}),a&&(0,b.jsxs)(`div`,{className:`border border-base-content/10 rounded-xl overflow-hidden`,children:[(0,b.jsxs)(`button`,{onClick:function(){u(!l)},className:`w-full flex items-center gap-2 px-3 py-2 bg-base-300/50 hover:bg-base-300/70 transition-colors duration-[120ms] cursor-pointer text-left`,children:[l?(0,b.jsx)(iu,{size:12,className:`text-base-content/40 flex-shrink-0`}):(0,b.jsx)(cu,{size:12,className:`text-base-content/40 flex-shrink-0`}),(0,b.jsx)(`span`,{className:`font-mono text-[12px] text-base-content/40 flex-1 truncate`,children:`~/.claude/CLAUDE.md`})]}),!l&&(0,b.jsx)(`div`,{className:`px-3 py-1.5 text-[11px] text-base-content/30 font-mono truncate`,children:f(a)}),l&&(0,b.jsx)(`pre`,{className:`px-3 py-2 text-[12px] text-base-content/40 font-mono whitespace-pre-wrap break-words bg-base-300/30 max-h-[300px] overflow-auto`,children:a})]})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`h2`,{className:`text-[12px] font-semibold text-base-content/40 mb-3`,children:`Global Rules`}),(0,b.jsx)(`p`,{className:`text-[11px] text-base-content/30 mb-3`,children:`Rules from ~/.claude/rules/ — read-only.`}),r.length===0&&(0,b.jsx)(`div`,{className:`py-4 text-center text-[13px] text-base-content/30`,children:`No global rules found.`}),r.length>0&&(0,b.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:r.map(function(e,t){var n=s.has(t);return(0,b.jsxs)(`div`,{className:`border border-base-content/10 rounded-xl overflow-hidden`,children:[(0,b.jsxs)(`button`,{onClick:function(){d(t)},className:`w-full flex items-center gap-2 px-3 py-2 bg-base-300/50 hover:bg-base-300/70 transition-colors duration-[120ms] cursor-pointer text-left`,children:[n?(0,b.jsx)(iu,{size:12,className:`text-base-content/40 flex-shrink-0`}):(0,b.jsx)(cu,{size:12,className:`text-base-content/40 flex-shrink-0`}),(0,b.jsx)(`span`,{className:`font-mono text-[12px] text-base-content/40 flex-1 truncate`,children:e.filename})]}),!n&&(0,b.jsx)(`div`,{className:`px-3 py-1.5 text-[11px] text-base-content/30 font-mono truncate`,children:f(e.content)}),n&&(0,b.jsx)(`pre`,{className:`px-3 py-2 text-[12px] text-base-content/40 font-mono whitespace-pre-wrap break-words bg-base-300/30 max-h-[300px] overflow-auto`,children:e.content})]},e.filename+`-`+t)})})]})]})}var j$e=[`user`,`feedback`,`project`,`reference`];function _9(e){var t=e.match(/^---\r?\n([\s\S]*?)\r?\n---\s*\r?\n?([\s\S]*)$/);if(!t)return{meta:{},body:e};for(var n={},r=t[1].split(/\r?\n/),i=0;i<r.length;i++){var a=r[i].indexOf(`:`);if(a>0){var o=r[i].slice(0,a).trim();n[o]=r[i].slice(a+1).trim().replace(/^["']|["']$/g,``)}}return{meta:n,body:t[2]}}function M$e(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`_`).replace(/^_+|_+$/g,``)||`memory`}function N$e(e,t,n,r){return`---
654
654
  name: `+e+`
655
655
  description: `+t+`
656
656
  type: `+n+`
657
657
  ---
658
- `+r}function N$e({memory:e,onClick:t,onDelete:n}){var[r,i]=(0,x.useState)(!1);return(0,b.jsxs)(`div`,{onClick:t,className:`flex items-start gap-3 px-3 py-2.5 bg-base-300 border border-base-content/15 rounded-xl transition-colors duration-[120ms] cursor-pointer hover:border-base-content/30 hover:bg-base-300/80`,role:`button`,tabIndex:0,onKeyDown:function(e){(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),t())},children:[(0,b.jsx)(uc,{size:14,className:`text-base-content/25 mt-0.5 flex-shrink-0`}),(0,b.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(`span`,{className:`text-[13px] font-bold text-base-content truncate`,children:e.name||e.filename}),(0,b.jsx)(`span`,{className:`shrink-0 text-[10px] font-mono px-1.5 py-0.5 rounded-md bg-base-content/8 text-base-content/40`,children:e.type})]}),e.description&&(0,b.jsx)(`div`,{className:`text-[12px] text-base-content/40 mt-0.5 line-clamp-2`,children:e.description})]}),(0,b.jsx)(`div`,{className:`flex gap-1 flex-shrink-0 mt-0.5`,onClick:function(e){e.stopPropagation()},children:r?(0,b.jsxs)(`div`,{className:`flex gap-1`,children:[(0,b.jsx)(`button`,{onClick:function(){n(),i(!1)},className:`btn btn-error btn-xs`,children:`Delete`}),(0,b.jsx)(`button`,{onClick:function(){i(!1)},className:`btn btn-ghost btn-xs`,children:`Cancel`})]}):(0,b.jsx)(`button`,{onClick:function(){i(!0)},"aria-label":`Delete `+e.name,className:`btn btn-ghost btn-xs btn-square text-base-content/30 hover:text-error focus-visible:ring-2 focus-visible:ring-primary`,children:(0,b.jsx)(Tv,{size:12})})})]})}function P$e({memory:e,content:t,onClose:n,onEdit:r}){var i=_9(t),a=Object.keys(i.meta).length>0,o=(0,x.useRef)(null);return Wr(o,(0,x.useCallback)(function(){n()},[n])),(0,b.jsxs)(`div`,{ref:o,className:`fixed inset-0 z-[9999] flex items-center justify-center`,role:`dialog`,"aria-modal":`true`,"aria-label":`Memory: `+(i.meta.name||e.filename),children:[(0,b.jsx)(`div`,{className:`absolute inset-0 bg-base-content/50`,onClick:n}),(0,b.jsxs)(`div`,{className:`relative bg-base-200 border border-base-content/15 rounded-2xl shadow-2xl w-full max-w-2xl mx-4 max-h-[80vh] flex flex-col overflow-hidden`,children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between px-5 py-4 border-b border-base-content/15 flex-shrink-0`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,b.jsx)(uc,{size:16,className:`text-primary flex-shrink-0`}),(0,b.jsx)(`h2`,{className:`text-[15px] font-mono font-bold text-base-content truncate`,children:i.meta.name||e.filename})]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,b.jsxs)(`button`,{onClick:r,className:`btn btn-ghost btn-xs gap-1.5 text-base-content/50 hover:text-base-content`,children:[(0,b.jsx)($_,{size:12}),`Edit`]}),(0,b.jsx)(`button`,{onClick:n,"aria-label":`Close`,className:`btn btn-ghost btn-xs btn-square text-base-content/40 hover:text-base-content`,children:(0,b.jsx)(Nv,{size:16})})]})]}),(0,b.jsxs)(`div`,{className:`overflow-y-auto flex-1`,children:[a&&(0,b.jsx)(`div`,{className:`px-5 py-3 border-b border-base-content/10 bg-base-300/30`,children:(0,b.jsx)(`div`,{className:`flex flex-wrap gap-x-6 gap-y-1.5`,children:Object.entries(i.meta).map(function([e,t]){return(0,b.jsxs)(`div`,{className:`flex items-baseline gap-1.5`,children:[(0,b.jsx)(`span`,{className:`text-[11px] font-mono text-base-content/35 uppercase tracking-wider`,children:e}),(0,b.jsx)(`span`,{className:`text-[12px] text-base-content/70`,children:t})]},e)})})}),(0,b.jsx)(`div`,{className:`px-5 py-4`,children:(0,b.jsx)(`div`,{className:`prose prose-sm max-w-none prose-headings:text-base-content prose-headings:font-mono prose-p:text-base-content/70 prose-strong:text-base-content prose-code:text-base-content/60 prose-code:bg-base-100/50 prose-code:px-1 prose-code:py-0.5 prose-code:rounded prose-code:text-[11px] prose-pre:bg-base-100 prose-pre:text-base-content/70 prose-pre:text-[11px] prose-a:text-primary prose-li:text-base-content/70 prose-li:marker:text-base-content/30 [&>*:first-child]:mt-0 [&>*:last-child]:mb-0`,children:(0,b.jsx)(Cw,{remarkPlugins:[hT],children:i.body})})})]}),(0,b.jsx)(`div`,{className:`px-5 py-3 border-t border-base-content/15 flex-shrink-0`,children:(0,b.jsx)(`div`,{className:`text-[11px] font-mono text-base-content/30 truncate`,children:e.filename})})]})]})}function F$e({memory:e,initialContent:t,onClose:n,onSave:r,isSaving:i}){var a=e===null,o=_9(t),[s,c]=(0,x.useState)(o.meta.name||(e?e.name:``)),[l,u]=(0,x.useState)(o.meta.description||(e?e.description:``)),[d,f]=(0,x.useState)(o.meta.type||(e?e.type:`project`)),[p,m]=(0,x.useState)(o.body),h=(0,x.useRef)(null);Wr(h,(0,x.useCallback)(function(){n()},[n]));function g(){var t=M$e(s,l,d,p);r(a?j$e(s)+`.md`:e.filename,t)}return(0,b.jsxs)(`div`,{ref:h,className:`fixed inset-0 z-[9999] flex items-center justify-center`,role:`dialog`,"aria-modal":`true`,"aria-label":a?`New Memory`:`Edit Memory`,children:[(0,b.jsx)(`div`,{className:`absolute inset-0 bg-base-content/50`,onClick:n}),(0,b.jsxs)(`div`,{className:`relative bg-base-200 border border-base-content/15 rounded-2xl shadow-2xl w-full max-w-2xl mx-4 max-h-[90vh] flex flex-col overflow-hidden`,children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between px-5 py-4 border-b border-base-content/15 flex-shrink-0`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(uc,{size:16,className:`text-primary flex-shrink-0`}),(0,b.jsx)(`h2`,{className:`text-[15px] font-mono font-bold text-base-content`,children:a?`New Memory`:`Edit Memory`})]}),(0,b.jsx)(`button`,{onClick:n,"aria-label":`Close`,className:`btn btn-ghost btn-xs btn-square text-base-content/40 hover:text-base-content`,children:(0,b.jsx)(Nv,{size:16})})]}),(0,b.jsxs)(`div`,{className:`overflow-y-auto flex-1 px-5 py-4 space-y-4`,children:[(0,b.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,b.jsxs)(`div`,{className:`col-span-2`,children:[(0,b.jsx)(`label`,{className:`text-[11px] font-mono text-base-content/40 uppercase tracking-wider mb-1.5 block`,children:`Name`}),(0,b.jsx)(`input`,{type:`text`,value:s,onChange:function(e){c(e.target.value)},className:`input input-sm w-full bg-base-300 border-base-content/15 text-[13px]`,placeholder:`Memory name`})]}),(0,b.jsxs)(`div`,{className:`col-span-2`,children:[(0,b.jsx)(`label`,{className:`text-[11px] font-mono text-base-content/40 uppercase tracking-wider mb-1.5 block`,children:`Description`}),(0,b.jsx)(`input`,{type:`text`,value:l,onChange:function(e){u(e.target.value)},className:`input input-sm w-full bg-base-300 border-base-content/15 text-[13px]`,placeholder:`Brief description`})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{className:`text-[11px] font-mono text-base-content/40 uppercase tracking-wider mb-1.5 block`,children:`Type`}),(0,b.jsx)(`select`,{value:d,onChange:function(e){f(e.target.value)},className:`select select-sm w-full bg-base-300 border-base-content/15 text-[13px]`,children:A$e.map(function(e){return(0,b.jsx)(`option`,{value:e,children:e.charAt(0).toUpperCase()+e.slice(1)},e)})})]}),!a&&(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{className:`text-[11px] font-mono text-base-content/40 uppercase tracking-wider mb-1.5 block`,children:`Filename`}),(0,b.jsx)(`input`,{type:`text`,value:e.filename,readOnly:!0,className:`input input-sm w-full bg-base-100/50 border-base-content/10 text-[13px] text-base-content/40 cursor-not-allowed`})]})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{className:`text-[11px] font-mono text-base-content/40 uppercase tracking-wider mb-1.5 block`,children:`Content`}),(0,b.jsx)(`textarea`,{value:p,onChange:function(e){m(e.target.value)},className:`textarea w-full bg-base-300 border-base-content/15 text-[13px] font-mono resize-none min-h-[200px]`,placeholder:`Memory content (markdown supported)`})]})]}),(0,b.jsxs)(`div`,{className:`px-5 py-3 border-t border-base-content/15 flex items-center justify-end gap-2 flex-shrink-0`,children:[(0,b.jsx)(`button`,{onClick:n,className:`btn btn-ghost btn-sm`,children:`Cancel`}),(0,b.jsxs)(`button`,{onClick:g,disabled:i||!s.trim(),className:`btn btn-primary btn-sm gap-1.5`,children:[i&&(0,b.jsx)(C_,{size:12,className:`animate-spin`}),a?`Create`:`Save`]})]})]})]})}function v9({projectSlug:e}){var{send:t,subscribe:n,unsubscribe:r}=R(),[i,a]=(0,x.useState)([]),[o,s]=(0,x.useState)(!1),[c,l]=(0,x.useState)(null),[u,d]=(0,x.useState)(null),[f,p]=(0,x.useState)(!1),[m,h]=(0,x.useState)(null);(0,x.useEffect)(function(){function e(e){e.type===`memory:list_result`&&(a(e.memories),s(!1))}function t(e){if(e.type===`memory:view_result`){var t=e;h(function(e){return e&&l({memory:e,content:t.content}),null})}}function i(e){e.type===`memory:save_result`&&(p(!1),d(null),l(null))}function o(e){e.type}return n(`memory:list_result`,e),n(`memory:view_result`,t),n(`memory:save_result`,i),n(`memory:delete_result`,o),function(){r(`memory:list_result`,e),r(`memory:view_result`,t),r(`memory:save_result`,i),r(`memory:delete_result`,o)}},[]),(0,x.useEffect)(function(){e&&(s(!0),t({type:`memory:list`,projectSlug:e}))},[e]);function g(n){h(n),t({type:`memory:view`,projectSlug:e,filename:n.filename})}function _(n){t({type:`memory:delete`,projectSlug:e,filename:n.filename})}function v(n,r){p(!0),t({type:`memory:save`,projectSlug:e,filename:n,content:r})}function y(){c&&(d({memory:c.memory,content:c.content}),l(null))}for(var S={},C=0;C<i.length;C++){var w=i[C],T=w.type||`other`;S[T]||(S[T]=[]),S[T].push(w)}var E=Object.keys(S);return(0,b.jsxs)(`div`,{className:`py-2 space-y-6`,children:[(0,b.jsxs)(`a`,{href:`https://docs.anthropic.com/en/docs/claude-code/memory`,target:`_blank`,rel:`noopener noreferrer`,className:`text-[11px] text-base-content/30 hover:text-primary/70 flex items-center gap-1 transition-colors`,children:[(0,b.jsx)(um,{size:11}),`Claude Code docs`]}),(0,b.jsx)(`div`,{className:`flex items-center justify-end`,children:(0,b.jsxs)(`button`,{onClick:function(){d({memory:null,content:``})},className:`btn btn-primary btn-sm gap-1.5`,children:[(0,b.jsx)(tv,{size:13}),`New Memory`]})}),o&&(0,b.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,b.jsx)(C_,{size:18,className:`animate-spin text-base-content/30`})}),!o&&i.length===0&&(0,b.jsx)(`div`,{className:`py-12 text-center text-[13px] text-base-content/40`,children:`No memories found.`}),!o&&E.map(function(e){return(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-[12px] font-semibold text-base-content/40 mb-2`,children:e.charAt(0).toUpperCase()+e.slice(1)}),(0,b.jsx)(`div`,{className:`space-y-2`,children:S[e].map(function(e){return(0,b.jsx)(N$e,{memory:e,onClick:function(){g(e)},onDelete:function(){_(e)}},e.filename)})})]},e)}),c&&(0,b.jsx)(P$e,{memory:c.memory,content:c.content,onClose:function(){l(null)},onEdit:y}),u!==null&&(0,b.jsx)(F$e,{memory:u.memory,initialContent:u.content,onClose:function(){d(null)},onSave:v,isSaving:f})]})}function I$e(){return(0,b.jsxs)(`div`,{children:[(0,b.jsxs)(`a`,{href:`https://docs.anthropic.com/en/docs/claude-code/memory`,target:`_blank`,rel:`noopener noreferrer`,className:`text-[11px] text-base-content/30 hover:text-primary/70 flex items-center gap-1 mb-4 transition-colors`,children:[(0,b.jsx)(um,{size:11}),`Claude Code docs`]}),(0,b.jsx)(v9,{projectSlug:`__global__`})]})}function L$e(){var{send:e,subscribe:t,unsubscribe:n}=R(),[r,i]=(0,x.useState)([]),[a,o]=(0,x.useState)([]),[s,c]=(0,x.useState)(!1),[l,u]=(0,x.useState)(null),[d,f]=(0,x.useState)(``),[p,m]=(0,x.useState)([]),[h,g]=(0,x.useState)(!1),[_,v]=(0,x.useState)(!1),[y,S]=(0,x.useState)(null),[C,w]=(0,x.useState)(null),[T,E]=(0,x.useState)(null),[D,O]=(0,x.useState)(null),[k,A]=(0,x.useState)(null),[j,M]=(0,x.useState)([]),[N,ee]=(0,x.useState)([]),[te,P]=(0,x.useState)(!1),F=(0,x.useRef)(null);(0,x.useEffect)(function(){function r(e){e.type===`plugin:list_result`&&(i(e.plugins),c(!0))}function a(e){e.type===`plugin:marketplaces_result`&&o(e.marketplaces)}function s(e){e.type===`plugin:search_result`&&(m(e.plugins),g(!1),v(!0))}function l(e){if(e.type===`plugin:install_result`){var t=e;S(null),ne(t.message??(t.success?`Installed`:`Install failed`),t.success)}}function d(e){if(e.type===`plugin:uninstall_result`){var t=e;w(null),ne(t.message??(t.success?`Uninstalled`:`Uninstall failed`),t.success)}}function f(e){if(e.type===`plugin:update_result`){var t=e;E(null),ne(t.message??(t.success?`Updated`:`Update failed`),t.success)}}function p(e){e.type===`plugin:details_result`&&u(e.plugin)}function h(e){e.type===`plugin:errors_result`&&M(e.errors)}function _(e){e.type===`plugin:discover_result`&&(ee(e.plugins),P(!0))}return t(`plugin:list_result`,r),t(`plugin:marketplaces_result`,a),t(`plugin:search_result`,s),t(`plugin:install_result`,l),t(`plugin:uninstall_result`,d),t(`plugin:update_result`,f),t(`plugin:details_result`,p),t(`plugin:errors_result`,h),t(`plugin:discover_result`,_),e({type:`plugin:list`}),e({type:`plugin:marketplaces`}),e({type:`plugin:errors`}),e({type:`plugin:discover`}),function(){n(`plugin:list_result`,r),n(`plugin:marketplaces_result`,a),n(`plugin:search_result`,s),n(`plugin:install_result`,l),n(`plugin:uninstall_result`,d),n(`plugin:update_result`,f),n(`plugin:details_result`,p),n(`plugin:errors_result`,h),n(`plugin:discover_result`,_)}},[]);function ne(e,t){A({text:e,success:t}),setTimeout(function(){A(null)},3e3)}function re(t){e({type:`plugin:details`,name:t.name,marketplace:t.marketplace})}function ie(t,n){S(t+`@`+n),e({type:`plugin:install`,name:t,marketplace:n})}function ae(t){w(t.key),O(null),e({type:`plugin:uninstall`,name:t.name,marketplace:t.marketplace})}function oe(t){E(t.key),e({type:`plugin:update`,name:t.name,marketplace:t.marketplace})}var se=(0,x.useCallback)(function(t){if(f(t),F.current&&clearTimeout(F.current),!t.trim()){m([]),v(!1),g(!1);return}g(!0),F.current=setTimeout(function(){e({type:`plugin:search`,query:t.trim()})},300)},[e]);return s?(0,b.jsxs)(`div`,{className:`py-2 space-y-8`,children:[k&&(0,b.jsx)(`div`,{className:`text-[12px] px-3 py-2 rounded-lg border `+(k.success?`bg-success/10 border-success/20 text-success`:`bg-error/10 border-error/20 text-error`),children:k.text}),j.length>0&&(0,b.jsx)(U$e,{errors:j}),(0,b.jsx)(R$e,{plugins:r,updatingKey:T,uninstallingKey:C,confirmUninstall:D,onViewDetails:re,onUpdate:oe,onUninstall:ae,onConfirmUninstall:O}),(0,b.jsx)(B$e,{query:d,results:p,searching:h,hasSearched:_,installingKey:y,installedKeys:new Set(r.map(function(e){return e.key})),onSearch:se,onInstall:ie}),(0,b.jsx)(W$e,{plugins:N,loaded:te,installingKey:y,installedKeys:new Set(r.map(function(e){return e.key})),onInstall:ie}),(0,b.jsx)(V$e,{marketplaces:a}),l&&(0,b.jsx)(H$e,{plugin:l,onClose:function(){u(null)}})]}):(0,b.jsx)(`div`,{className:`py-4 space-y-3 animate-pulse`,children:[0,1,2].map(function(e){return(0,b.jsx)(`div`,{className:`bg-base-content/[0.03] rounded-xl h-16`},e)})})}function R$e({plugins:e,updatingKey:t,uninstallingKey:n,confirmUninstall:r,onViewDetails:i,onUpdate:a,onUninstall:o,onConfirmUninstall:s}){return(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-[12px] font-semibold text-base-content/40 mb-2`,children:`Installed Plugins`}),e.length===0?(0,b.jsxs)(`div`,{className:`py-6 text-center`,children:[(0,b.jsx)(`div`,{className:`text-[12px] text-base-content/30 mb-0.5`,children:`No plugins installed`}),(0,b.jsx)(`div`,{className:`text-[11px] text-base-content/20`,children:`Browse the marketplace or search below to add plugins.`})]}):(0,b.jsx)(`div`,{className:`space-y-2`,children:e.map(function(e){return(0,b.jsx)(z$e,{plugin:e,isUpdating:t===e.key,isUninstalling:n===e.key,isConfirmingUninstall:r===e.key,onViewDetails:function(){i(e)},onUpdate:function(){a(e)},onUninstall:function(){o(e)},onConfirmUninstall:function(){s(e.key)},onCancelUninstall:function(){s(null)}},e.key)})})]})}function z$e({plugin:e,isUpdating:t,isUninstalling:n,isConfirmingUninstall:r,onViewDetails:i,onUpdate:a,onUninstall:o,onConfirmUninstall:s,onCancelUninstall:c}){return(0,b.jsxs)(`div`,{onClick:i,className:`flex items-start gap-3 px-3 py-2.5 bg-base-300 border border-base-content/15 rounded-xl cursor-pointer hover:border-base-content/30 hover:bg-base-300/80 transition-colors duration-[120ms]`,role:`button`,tabIndex:0,onKeyDown:function(e){(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),i())},children:[(0,b.jsx)(fs,{size:14,className:`text-base-content/25 mt-0.5 flex-shrink-0`}),(0,b.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(`span`,{className:`text-[13px] font-bold text-base-content truncate`,children:e.name}),(0,b.jsxs)(`span`,{className:`shrink-0 text-[10px] font-mono px-1.5 py-0.5 rounded-md bg-base-content/8 text-base-content/40`,children:[`v`,e.version]})]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-3 mt-0.5`,children:[(0,b.jsx)(`span`,{className:`text-[11px] text-base-content/30`,children:e.marketplace}),(0,b.jsxs)(`span`,{className:`text-[11px] text-base-content/25`,children:[e.skillCount,` skill`,e.skillCount===1?``:`s`,e.hookCount>0?`, `+e.hookCount+` hook`+(e.hookCount===1?``:`s`):``,e.ruleCount>0?`, `+e.ruleCount+` rule`+(e.ruleCount===1?``:`s`):``]})]}),e.description&&(0,b.jsx)(`div`,{className:`text-[12px] text-base-content/40 mt-0.5 line-clamp-1`,children:e.description})]}),(0,b.jsxs)(`div`,{className:`flex gap-1 flex-shrink-0 mt-0.5`,onClick:function(e){e.stopPropagation()},children:[t?(0,b.jsx)(C_,{size:12,className:`text-primary animate-spin mt-1 mx-1`}):(0,b.jsx)(`button`,{onClick:a,"aria-label":`Update `+e.name,className:`btn btn-ghost btn-xs btn-square text-base-content/30 hover:text-info focus-visible:ring-2 focus-visible:ring-primary`,children:(0,b.jsx)(ov,{size:12})}),r?(0,b.jsxs)(`div`,{className:`flex gap-1`,children:[(0,b.jsx)(`button`,{onClick:o,className:`btn btn-error btn-xs`,disabled:n,children:n?(0,b.jsx)(C_,{size:10,className:`animate-spin`}):`Remove`}),(0,b.jsx)(`button`,{onClick:c,className:`btn btn-ghost btn-xs`,children:`Cancel`})]}):(0,b.jsx)(`button`,{onClick:s,"aria-label":`Remove `+e.name,className:`btn btn-ghost btn-xs btn-square text-base-content/30 hover:text-error focus-visible:ring-2 focus-visible:ring-primary`,children:(0,b.jsx)(Tv,{size:12})})]})]})}function B$e({query:e,results:t,searching:n,hasSearched:r,installingKey:i,installedKeys:a,onSearch:o,onInstall:s}){return(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-[12px] font-semibold text-base-content/40 mb-2`,children:`Browse Marketplace`}),(0,b.jsxs)(`div`,{className:`relative mb-3`,children:[(0,b.jsx)(dv,{size:13,className:`absolute left-3 top-1/2 -translate-y-1/2 text-base-content/30 pointer-events-none`}),(0,b.jsx)(`input`,{type:`text`,value:e,onChange:function(e){o(e.target.value)},placeholder:`Search plugins...`,className:`w-full bg-base-300 border border-base-content/15 rounded-xl pl-8 pr-3 py-2.5 text-[13px] text-base-content placeholder:text-base-content/30 focus:outline-none focus:border-primary transition-colors`}),n&&(0,b.jsx)(C_,{size:13,className:`absolute right-3 top-1/2 -translate-y-1/2 text-primary animate-spin`})]}),r&&t.length===0&&!n&&(0,b.jsxs)(`div`,{className:`py-4 text-center text-[13px] text-base-content/30`,children:[`No plugins found for "`,e,`"`]}),t.length>0&&(0,b.jsx)(`div`,{className:`space-y-2`,children:t.map(function(e){var t=e.name+`@`+e.marketplace,n=a.has(t),r=i===t;return(0,b.jsxs)(`div`,{className:`flex items-start gap-3 px-3 py-2.5 bg-base-300/50 border border-base-content/10 rounded-xl`,children:[(0,b.jsx)(Y_,{size:14,className:`text-base-content/20 mt-0.5 flex-shrink-0`}),(0,b.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(`span`,{className:`text-[13px] font-bold text-base-content truncate`,children:e.name}),(0,b.jsx)(`span`,{className:`text-[10px] font-mono text-base-content/30`,children:e.marketplace})]}),e.description&&(0,b.jsx)(`div`,{className:`text-[12px] text-base-content/40 mt-0.5 line-clamp-2`,children:e.description}),(0,b.jsxs)(`div`,{className:`flex items-center gap-3 mt-1`,children:[e.author&&(0,b.jsx)(`span`,{className:`text-[10px] text-base-content/25`,children:e.author.name}),e.installs!=null&&e.installs>0&&(0,b.jsxs)(`span`,{className:`text-[10px] text-base-content/25 flex items-center gap-0.5`,children:[(0,b.jsx)(nm,{size:9}),b9(e.installs)]})]})]}),(0,b.jsx)(`div`,{className:`flex-shrink-0 mt-0.5`,onClick:function(e){e.stopPropagation()},children:n?(0,b.jsx)(`span`,{className:`text-[10px] font-mono px-2 py-1 rounded-md bg-success/10 text-success/70`,children:`Installed`}):r?(0,b.jsx)(C_,{size:14,className:`text-primary animate-spin mx-2`}):(0,b.jsx)(`button`,{onClick:function(){s(e.name,e.marketplace)},className:`btn btn-primary btn-xs`,children:`Install`})})]},t)})})]})}function V$e({marketplaces:e}){return e.length===0?null:(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-[12px] font-semibold text-base-content/40 mb-2`,children:`Registered Marketplaces`}),(0,b.jsx)(`div`,{className:`space-y-1.5`,children:e.map(function(e){return(0,b.jsxs)(`div`,{className:`flex items-center gap-2.5 px-3 py-2 bg-base-300/30 border border-base-content/10 rounded-lg`,children:[(0,b.jsx)(Y_,{size:12,className:`text-base-content/20 flex-shrink-0`}),(0,b.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,b.jsx)(`span`,{className:`text-[12px] font-bold text-base-content/60`,children:e.name}),(0,b.jsx)(`span`,{className:`text-[11px] text-base-content/25 ml-2`,children:e.source.repo})]})]},e.name)})})]})}function H$e({plugin:e,onClose:t}){return(0,x.useEffect)(function(){function e(e){e.key===`Escape`&&t()}return document.addEventListener(`keydown`,e),function(){document.removeEventListener(`keydown`,e)}},[t]),(0,b.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,role:`dialog`,"aria-modal":`true`,"aria-label":`Plugin: `+e.name,children:[(0,b.jsx)(`div`,{className:`absolute inset-0 bg-base-content/50`,onClick:t}),(0,b.jsxs)(`div`,{className:`relative bg-base-200 border border-base-content/15 rounded-2xl shadow-2xl w-full max-w-2xl mx-4 max-h-[80vh] flex flex-col overflow-hidden`,children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between px-5 py-4 border-b border-base-content/15 flex-shrink-0`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2.5 min-w-0`,children:[(0,b.jsx)(fs,{size:16,className:`text-primary flex-shrink-0`}),(0,b.jsxs)(`div`,{className:`min-w-0`,children:[(0,b.jsx)(`h2`,{className:`text-[15px] font-mono font-bold text-base-content truncate`,children:e.name}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5`,children:[(0,b.jsxs)(`span`,{className:`text-[10px] font-mono text-base-content/40`,children:[`v`,e.version]}),(0,b.jsx)(`span`,{className:`text-[10px] text-base-content/30`,children:e.marketplace})]})]})]}),(0,b.jsx)(`button`,{onClick:t,"aria-label":`Close`,className:`btn btn-ghost btn-xs btn-square text-base-content/40 hover:text-base-content`,children:(0,b.jsx)(Nv,{size:16})})]}),(0,b.jsxs)(`div`,{className:`overflow-y-auto flex-1`,children:[(0,b.jsx)(`div`,{className:`px-5 py-3 border-b border-base-content/10 bg-base-300/30`,children:(0,b.jsxs)(`div`,{className:`flex flex-wrap gap-x-6 gap-y-1.5`,children:[e.author&&(0,b.jsx)(y9,{label:`Author`,value:e.author.name}),e.license&&(0,b.jsx)(y9,{label:`License`,value:e.license}),(0,b.jsx)(y9,{label:`Installed`,value:x9(e.installedAt)}),(0,b.jsx)(y9,{label:`Updated`,value:x9(e.lastUpdated)}),e.homepage&&(0,b.jsxs)(`a`,{href:e.homepage,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1 text-[11px] text-primary/60 hover:text-primary transition-colors`,children:[(0,b.jsx)(um,{size:10}),`Homepage`]})]})}),e.description&&(0,b.jsx)(`div`,{className:`px-5 py-3 border-b border-base-content/10`,children:(0,b.jsx)(`p`,{className:`text-[13px] text-base-content/60`,children:e.description})}),e.keywords&&e.keywords.length>0&&(0,b.jsx)(`div`,{className:`px-5 py-3 border-b border-base-content/10`,children:(0,b.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.keywords.map(function(e){return(0,b.jsx)(`span`,{className:`text-[10px] font-mono px-1.5 py-0.5 rounded-md bg-base-content/8 text-base-content/40`,children:e},e)})})}),e.skills.length>0&&(0,b.jsxs)(`div`,{className:`px-5 py-3 border-b border-base-content/10`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-2`,children:[(0,b.jsx)(rv,{size:12,className:`text-base-content/30`}),(0,b.jsxs)(`span`,{className:`text-[11px] font-bold text-base-content/40 uppercase tracking-wider`,children:[`Skills (`,e.skills.length,`)`]})]}),(0,b.jsx)(`div`,{className:`space-y-1.5`,children:e.skills.map(function(e){return(0,b.jsxs)(`div`,{className:`flex items-start gap-2 py-1`,children:[(0,b.jsx)(cu,{size:10,className:`text-base-content/20 mt-0.5 flex-shrink-0`}),(0,b.jsxs)(`div`,{className:`min-w-0`,children:[(0,b.jsx)(`span`,{className:`text-[12px] font-bold text-base-content/70`,children:e.name}),e.description&&(0,b.jsx)(`div`,{className:`text-[11px] text-base-content/35 line-clamp-1`,children:e.description})]})]},e.name)})})]}),Object.keys(e.hooks).length>0&&(0,b.jsxs)(`div`,{className:`px-5 py-3 border-b border-base-content/10`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-2`,children:[(0,b.jsx)(kv,{size:12,className:`text-base-content/30`}),(0,b.jsxs)(`span`,{className:`text-[11px] font-bold text-base-content/40 uppercase tracking-wider`,children:[`Hooks (`,Object.keys(e.hooks).length,`)`]})]}),(0,b.jsx)(`div`,{className:`space-y-1`,children:Object.keys(e.hooks).map(function(e){return(0,b.jsxs)(`div`,{className:`flex items-center gap-2 py-0.5`,children:[(0,b.jsx)(cu,{size:10,className:`text-base-content/20 flex-shrink-0`}),(0,b.jsx)(`span`,{className:`text-[12px] font-mono text-base-content/50`,children:e})]},e)})})]}),e.rules.length>0&&(0,b.jsxs)(`div`,{className:`px-5 py-3`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-2`,children:[(0,b.jsx)(uv,{size:12,className:`text-base-content/30`}),(0,b.jsxs)(`span`,{className:`text-[11px] font-bold text-base-content/40 uppercase tracking-wider`,children:[`Rules (`,e.rules.length,`)`]})]}),(0,b.jsx)(`div`,{className:`space-y-1`,children:e.rules.map(function(e){return(0,b.jsxs)(`div`,{className:`flex items-center gap-2 py-0.5`,children:[(0,b.jsx)(cu,{size:10,className:`text-base-content/20 flex-shrink-0`}),(0,b.jsx)(`span`,{className:`text-[12px] font-mono text-base-content/50`,children:e})]},e)})})]})]}),(0,b.jsx)(`div`,{className:`px-5 py-3 border-t border-base-content/15 flex-shrink-0`,children:(0,b.jsxs)(`div`,{className:`text-[11px] font-mono text-base-content/30 truncate`,children:[e.gitCommitSha.slice(0,8),` · `,e.installPath]})})]})]})}function U$e({errors:e}){return(0,b.jsxs)(`div`,{children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-2`,children:[(0,b.jsx)(Ev,{size:12,className:`text-warning`}),(0,b.jsxs)(`span`,{className:`text-[12px] font-semibold text-warning/80`,children:[`Errors (`,e.length,`)`]})]}),(0,b.jsx)(`div`,{className:`space-y-2`,children:e.map(function(e){return(0,b.jsxs)(`div`,{className:`px-3 py-2.5 bg-warning/5 border border-warning/20 rounded-xl`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,b.jsx)(`span`,{className:`text-[13px] font-bold text-base-content`,children:e.name}),(0,b.jsx)(`span`,{className:`text-[10px] font-mono text-base-content/30`,children:e.marketplace})]}),e.errors.map(function(e,t){return(0,b.jsxs)(`div`,{className:`flex items-start gap-1.5 mt-0.5`,children:[(0,b.jsx)(Ev,{size:10,className:`text-warning/60 mt-0.5 flex-shrink-0`}),(0,b.jsx)(`span`,{className:`text-[12px] text-warning/70`,children:e})]},t)})]},e.key)})})]})}function W$e({plugins:e,loaded:t,installingKey:n,installedKeys:r,onInstall:i}){var[a,o]=(0,x.useState)(!1),s=12;if(!t||e.length===0)return null;var c=a?e:e.slice(0,s);return(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`flex items-center justify-between mb-2`,children:(0,b.jsxs)(`div`,{className:`text-[12px] font-semibold text-base-content/40`,children:[`Discover (`,e.length,` available)`]})}),(0,b.jsx)(`div`,{className:`space-y-2`,children:c.map(function(e){var t=e.name+`@`+e.marketplace,a=r.has(t),o=n===t;return(0,b.jsxs)(`div`,{className:`flex items-start gap-3 px-3 py-2.5 bg-base-300/50 border border-base-content/10 rounded-xl`,children:[(0,b.jsx)(Y_,{size:14,className:`text-base-content/20 mt-0.5 flex-shrink-0`}),(0,b.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(`span`,{className:`text-[13px] font-bold text-base-content truncate`,children:e.name}),(0,b.jsx)(`span`,{className:`text-[10px] font-mono text-base-content/30`,children:e.marketplace})]}),e.description&&(0,b.jsx)(`div`,{className:`text-[12px] text-base-content/40 mt-0.5 line-clamp-2`,children:e.description}),(0,b.jsxs)(`div`,{className:`flex items-center gap-3 mt-1`,children:[e.author&&(0,b.jsx)(`span`,{className:`text-[10px] text-base-content/25`,children:e.author.name}),e.installs!=null&&e.installs>0&&(0,b.jsxs)(`span`,{className:`text-[10px] text-base-content/25 flex items-center gap-0.5`,children:[(0,b.jsx)(nm,{size:9}),b9(e.installs)]})]})]}),(0,b.jsx)(`div`,{className:`flex-shrink-0 mt-0.5`,onClick:function(e){e.stopPropagation()},children:a?(0,b.jsx)(`span`,{className:`text-[10px] font-mono px-2 py-1 rounded-md bg-success/10 text-success/70`,children:`Installed`}):o?(0,b.jsx)(C_,{size:14,className:`text-primary animate-spin mx-2`}):(0,b.jsx)(`button`,{onClick:function(){i(e.name,e.marketplace)},className:`btn btn-primary btn-xs`,children:`Install`})})]},t)})}),!a&&e.length>s&&(0,b.jsxs)(`button`,{onClick:function(){o(!0)},className:`mt-3 text-[12px] text-primary/60 hover:text-primary transition-colors`,children:[`Show all `,e.length,` plugins`]}),a&&e.length>s&&(0,b.jsx)(`button`,{onClick:function(){o(!1)},className:`mt-3 text-[12px] text-primary/60 hover:text-primary transition-colors`,children:`Show less`})]})}function y9({label:e,value:t}){return(0,b.jsxs)(`div`,{className:`flex items-baseline gap-1.5`,children:[(0,b.jsx)(`span`,{className:`text-[11px] font-mono text-base-content/35 uppercase tracking-wider`,children:e}),(0,b.jsx)(`span`,{className:`text-[12px] text-base-content/70`,children:t})]})}function b9(e){return e>=1e6?(e/1e6).toFixed(1)+`M`:e>=1e3?(e/1e3).toFixed(1)+`k`:String(e)}function x9(e){try{return new Date(e).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`})}catch{return e}}function G$e(){var[e,t]=(0,x.useState)(function(){return localStorage.getItem(`lattice-notifications-enabled`)===`1`}),n=typeof Notification<`u`?Notification.permission:`denied`;function r(){e?(t(!1),localStorage.setItem(`lattice-notifications-enabled`,`0`)):n===`default`?Notification.requestPermission().then(function(e){e===`granted`&&(t(!0),localStorage.setItem(`lattice-notifications-enabled`,`1`))}):n===`granted`&&(t(!0),localStorage.setItem(`lattice-notifications-enabled`,`1`))}return{enabled:e,permission:n,toggle:r}}function S9(e,t,n,r){if(localStorage.getItem(`lattice-notifications-enabled`)===`1`&&!(typeof Notification>`u`||Notification.permission!==`granted`)){var i=new Notification(e,{body:t,icon:`/icons/icon-192.svg`,tag:n||`lattice`,silent:!1}),a=setTimeout(function(){i.close()},1e4);i.onclick=function(){clearTimeout(a),window.focus(),i.close(),r&&r()}}}function K$e(e){for(var t=(e+`=`.repeat((4-e.length%4)%4)).replace(/-/g,`+`).replace(/_/g,`/`),n=window.atob(t),r=new Uint8Array(n.length),i=0;i<n.length;++i)r[i]=n.charCodeAt(i);return r}function q$e(){var[e,t]=(0,x.useState)(`unsupported`);(0,x.useEffect)(function(){if(!(`serviceWorker`in navigator)||!(`PushManager`in window)){t(`unsupported`);return}if(Notification.permission===`denied`){t(`denied`);return}navigator.serviceWorker.getRegistration(`/sw-push.js`).then(function(e){if(!e){t(`unsubscribed`);return}e.pushManager.getSubscription().then(function(e){t(e?`subscribed`:`unsubscribed`)})})},[]);async function n(){if(!(`serviceWorker`in navigator)||!(`PushManager`in window))return!1;try{if(await Notification.requestPermission()!==`granted`)return t(`denied`),!1;var e=await navigator.serviceWorker.register(`/sw-push.js`,{scope:`/`});await navigator.serviceWorker.ready;var n=await(await fetch(`/api/vapid-public-key`)).json(),r=await e.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:K$e(n.publicKey)});return await fetch(`/api/push-subscribe`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(r.toJSON())}),t(`subscribed`),!0}catch(e){return console.error(`Push subscription failed:`,e),!1}}async function r(){try{var e=await navigator.serviceWorker.getRegistration(`/sw-push.js`);if(e){var n=await e.pushManager.getSubscription();n&&await n.unsubscribe()}t(`unsubscribed`)}catch(e){console.error(`Push unsubscribe failed:`,e)}}return{status:e,subscribe:n,unsubscribe:r}}var J$e=[{key:`responses`,label:`Claude responses`,description:`When Claude finishes a response`},{key:`mesh`,label:`Mesh node changes`,description:`When nodes come online or go offline`},{key:`connection`,label:`Connection events`,description:`WebSocket connect and disconnect`}];function Y$e(){try{var e=localStorage.getItem(`lattice-notification-types`);if(e)return JSON.parse(e)}catch{}return{responses:!0,mesh:!0,connection:!0}}function X$e(e){localStorage.setItem(`lattice-notification-types`,JSON.stringify(e))}function Z$e(){var e=G$e(),t=q$e(),[n,r]=(0,x.useState)(Y$e);function i(e){r(function(t){var n={...t,[e]:!t[e]};return X$e(n),n})}return(0,b.jsxs)(`div`,{className:`py-2 space-y-6`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`h2`,{className:`text-[12px] font-semibold text-base-content/40 mb-3`,children:`Browser Notifications`}),(0,b.jsxs)(`div`,{className:`flex items-center justify-between py-2 px-3 bg-base-300 border border-base-content/15 rounded-xl`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-[13px] text-base-content`,children:`Enable notifications`}),(0,b.jsx)(`div`,{className:`text-[11px] text-base-content/30 mt-0.5`,children:e.permission===`denied`?`Blocked by browser — update in browser settings`:`Get notified about events in Lattice`})]}),(0,b.jsx)(`input`,{type:`checkbox`,className:`toggle toggle-sm toggle-primary`,checked:e.enabled,onChange:e.toggle,disabled:e.permission===`denied`})]})]}),t.status!==`unsupported`&&(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`h2`,{className:`text-[12px] font-semibold text-base-content/40 mb-3`,children:`Push Notifications`}),(0,b.jsxs)(`div`,{className:`flex items-center justify-between py-2 px-3 bg-base-300 border border-base-content/15 rounded-xl`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-[13px] text-base-content`,children:`Enable push notifications`}),(0,b.jsx)(`div`,{className:`text-[11px] text-base-content/30 mt-0.5`,children:t.status===`denied`?`Blocked by browser — update in browser settings`:t.status===`subscribed`?`Receiving push notifications even when the tab is closed`:`Get notified even when Lattice is not open`})]}),(0,b.jsx)(`input`,{type:`checkbox`,className:`toggle toggle-sm toggle-primary`,checked:t.status===`subscribed`,onChange:function(){t.status===`subscribed`?t.unsubscribe():t.subscribe()},disabled:t.status===`denied`})]})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`h2`,{className:`text-[12px] font-semibold text-base-content/40 mb-3`,children:`Notification Types`}),(0,b.jsx)(`div`,{className:`flex flex-col gap-2`,children:J$e.map(function(t){return(0,b.jsxs)(`div`,{className:`flex items-center justify-between py-2 px-3 bg-base-300 border border-base-content/15 rounded-xl`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-[13px] text-base-content`,children:t.label}),(0,b.jsx)(`div`,{className:`text-[11px] text-base-content/30 mt-0.5`,children:t.description})]}),(0,b.jsx)(`input`,{type:`checkbox`,className:`toggle toggle-sm toggle-primary`,checked:n[t.key]!==!1,onChange:function(){i(t.key)},disabled:!e.enabled})]},t.key)})})]})]})}var Q$e=[{id:`warning`,label:`Warning`,description:`Shows a warning but does not block`},{id:`soft-block`,label:`Confirm`,description:`Asks for confirmation before sending`},{id:`hard-block`,label:`Block`,description:`Prevents sending until tomorrow`}];function $$e(){var{send:e,subscribe:t,unsubscribe:n}=R(),r=$n(Uy(),function(e){return e.budgetStatus}),[i,a]=(0,x.useState)(!1),[o,s]=(0,x.useState)(10),[c,l]=(0,x.useState)(`warning`),u=e9();(0,x.useEffect)(function(){function r(e){if(e.type===`settings:data`){var t=e.config;u.savingRef.current?(u.confirmSave(),t.costBudget||ub(null)):(t.costBudget?(a(!0),s(t.costBudget.dailyLimit),l(t.costBudget.enforcement)):(a(!1),s(10),l(`warning`),ub(null)),u.resetFromServer())}}return t(`settings:data`,r),e({type:`settings:get`}),function(){n(`settings:data`,r)}},[]);function d(){u.startSave(),e({type:`settings:update`,settings:{costBudget:i?{dailyLimit:o,enforcement:c}:null}})}return(0,b.jsxs)(`div`,{className:`py-2`,children:[(0,b.jsx)(`p`,{className:`text-[12px] text-base-content/40 mb-5`,children:`Set a daily spending limit to control API costs. The budget resets at midnight.`}),r&&(0,b.jsxs)(`div`,{className:`mb-5 p-3 rounded-xl bg-base-300 border border-base-content/10`,children:[(0,b.jsx)(`div`,{className:`text-[11px] text-base-content/40 font-mono mb-1`,children:`Today's spend`}),(0,b.jsxs)(`div`,{className:`text-[18px] font-mono font-bold text-base-content`,children:[`$`,r.dailySpend.toFixed(2),r.dailyLimit>0&&(0,b.jsx)(`span`,{className:`text-[13px] text-base-content/30 font-normal`,children:` / $`+r.dailyLimit.toFixed(2)})]})]}),(0,b.jsx)(`div`,{className:`mb-5`,children:(0,b.jsxs)(`label`,{className:`flex items-center gap-3 cursor-pointer`,children:[(0,b.jsx)(`input`,{type:`checkbox`,checked:i,onChange:function(e){a(e.target.checked),u.markDirty()},className:`toggle toggle-sm toggle-primary`}),(0,b.jsx)(`span`,{className:`text-[13px] text-base-content`,children:`Enable daily budget`})]})}),i&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`div`,{className:`mb-5`,children:[(0,b.jsx)(`label`,{htmlFor:`budget-daily-limit`,className:`block text-[12px] font-semibold text-base-content/40 mb-2`,children:`Daily limit (USD)`}),(0,b.jsx)(`input`,{id:`budget-daily-limit`,type:`number`,min:.01,step:.5,value:o,onChange:function(e){var t=parseFloat(e.target.value);!isNaN(t)&&t>0&&(s(t),u.markDirty())},className:`w-full h-9 px-3 bg-base-300 border border-base-content/15 rounded-xl text-base-content text-[13px] font-mono focus:border-primary focus-visible:outline-none transition-colors duration-[120ms]`})]}),(0,b.jsxs)(`div`,{className:`mb-6`,role:`radiogroup`,"aria-label":`Enforcement mode`,children:[(0,b.jsx)(`div`,{className:`text-[12px] font-semibold text-base-content/40 mb-2`,children:`Enforcement`}),(0,b.jsx)(`div`,{className:`flex flex-col gap-2`,children:Q$e.map(function(e){var t=c===e.id;return(0,b.jsxs)(`button`,{role:`radio`,"aria-checked":t,onClick:function(){l(e.id),u.markDirty()},className:`w-full text-left px-3 py-2.5 rounded-lg border text-[12px] transition-colors duration-[120ms] cursor-pointer focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-1 focus-visible:ring-offset-base-100 `+(t?`border-primary bg-base-300 text-base-content`:`border-base-content/15 bg-base-300 text-base-content/40 hover:border-base-content/30 hover:text-base-content/60`),children:[(0,b.jsx)(`div`,{className:`font-semibold`,children:e.label}),(0,b.jsx)(`div`,{className:`text-[11px] mt-0.5 `+(t?`text-base-content/50`:`text-base-content/30`),children:e.description})]},e.id)})})]})]}),(0,b.jsx)(r9,{dirty:u.dirty,saving:u.saving,saveState:u.saveState,onSave:d})]})}var e1e={appearance:{title:`Appearance`},notifications:{title:`Notifications`},claude:{title:`Claude`},budget:{title:`Budget`},environment:{title:`Environment`},mcp:{title:`MCP Servers`},skills:{title:`Skills`},plugins:{title:`Plugins`},nodes:{title:`Mesh Nodes`},editor:{title:`Editor`},rules:{title:`Rules`},memory:{title:`Memory`}};function t1e(e){return e===`appearance`?(0,b.jsx)(f$e,{}):e===`notifications`?(0,b.jsx)(Z$e,{}):e===`claude`?(0,b.jsx)(y$e,{}):e===`budget`?(0,b.jsx)($$e,{}):e===`environment`?(0,b.jsx)(b$e,{}):e===`mcp`?(0,b.jsx)(C$e,{}):e===`skills`?(0,b.jsx)(E$e,{}):e===`plugins`?(0,b.jsx)(L$e,{}):e===`nodes`?(0,b.jsx)(S$e,{}):e===`editor`?(0,b.jsx)(O$e,{}):e===`rules`?(0,b.jsx)(k$e,{}):e===`memory`?(0,b.jsx)(I$e,{}):null}function n1e(){var{activeView:e,toggleDrawer:t}=jy();if(e.type!==`settings`)return null;var n=e.section,r=e1e[n];return(0,b.jsxs)(`section`,{"aria-label":`Settings`,className:`flex-1 overflow-auto px-4 sm:px-8 py-4 sm:py-6 max-w-3xl`,children:[r&&(0,b.jsxs)(`div`,{className:`mb-6 flex items-center gap-3`,children:[(0,b.jsx)(`button`,{className:`btn btn-ghost btn-sm btn-square lg:hidden`,"aria-label":`Toggle sidebar`,onClick:t,children:(0,b.jsx)(B_,{size:18})}),(0,b.jsx)(`h1`,{className:`text-lg font-mono font-bold text-base-content`,children:r.title})]}),t1e(n)]})}function C9(e){var{status:t,send:n,subscribe:r,unsubscribe:i}=R(),[a,o]=(0,x.useState)(null),[s,c]=(0,x.useState)(!0),[l,u]=(0,x.useState)(null);(0,x.useEffect)(function(){if(!e)return;function a(t){if(t.type===`project-settings:data`){var n=t;n.projectSlug===e&&(o(n.settings),c(!1),u(null))}}function s(t){if(t.type===`project-settings:error`){var n=t;n.projectSlug===e&&(u(n.message),c(!1))}}return r(`project-settings:data`,a),r(`project-settings:error`,s),t===`connected`&&(c(!0),n({type:`project-settings:get`,projectSlug:e})),function(){i(`project-settings:data`,a),i(`project-settings:error`,s)}},[e,t]);function d(t,r){e&&n({type:`project-settings:update`,projectSlug:e,section:t,settings:r})}return{settings:a,loading:s,error:l,updateSection:d}}function r1e(e){if(!e)return(0,b.jsx)(`div`,{className:`w-8 h-8 rounded-lg bg-base-300 border border-base-content/15 flex items-center justify-center text-base-content/30 text-[11px]`,children:`?`});if(e.type===`lucide`){var t=Fv[e.name];return t?(0,b.jsx)(`div`,{className:`w-8 h-8 rounded-lg bg-base-300 border border-base-content/15 flex items-center justify-center text-base-content`,children:(0,b.jsx)(t,{size:18})}):null}return e.type===`text`?(0,b.jsx)(`div`,{className:`w-8 h-8 rounded-lg bg-base-300 border border-base-content/15 flex items-center justify-center text-[14px] font-bold`,style:e.color?{color:e.color}:void 0,children:e.value}):e.type===`image`?(0,b.jsx)(`img`,{src:e.path,alt:`icon`,className:`w-8 h-8 rounded-lg object-cover border border-base-content/15`,loading:`lazy`}):null}function i1e({value:e,onChange:t}){var n=e&&e.type===`emoji`?void 0:e,[r,i]=(0,x.useState)(n?.type===`text`?`text`:n?.type===`image`?`upload`:`lucide`),[a,o]=(0,x.useState)(``),[s,c]=(0,x.useState)(n?.type===`text`?n.value:``),[l,u]=(0,x.useState)(n?.type===`text`&&n.color||`#ffffff`),d=(0,x.useMemo)(function(){var e=Object.keys(Fv);if(!a.trim())return e.slice(0,60);var t=a.toLowerCase();return e.filter(function(e){return e.toLowerCase().includes(t)}).slice(0,60)},[a]),f=[{id:`lucide`,label:`Lucide`},{id:`text`,label:`Text`},{id:`upload`,label:`Upload`}];function p(e){var n=e.target.files?.[0];if(n){var r=new FileReader;r.onload=function(e){var n=e.target?.result;t({type:`image`,path:n})},r.readAsDataURL(n)}}return(0,b.jsxs)(`div`,{className:`space-y-3`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-3`,children:[r1e(n),(0,b.jsx)(`span`,{className:`text-[11px] text-base-content/40`,children:`Current icon`})]}),(0,b.jsx)(`div`,{className:`flex gap-1`,children:f.map(function(e){return(0,b.jsx)(`button`,{type:`button`,onClick:function(){i(e.id)},className:`btn btn-xs `+(r===e.id?`btn-primary`:`btn-ghost`),children:e.label},e.id)})}),r===`lucide`&&(0,b.jsxs)(`div`,{className:`space-y-2`,children:[(0,b.jsx)(`input`,{type:`text`,value:a,onChange:function(e){o(e.target.value)},placeholder:`Search icons...`,"aria-label":`Search icons`,className:`w-full h-8 px-3 bg-base-300 border border-base-content/15 rounded-xl text-base-content text-[12px] focus:border-primary focus-visible:outline-none transition-colors duration-[120ms]`}),(0,b.jsx)(`div`,{className:`grid grid-cols-10 gap-1 max-h-48 overflow-y-auto`,children:d.map(function(e){var r=Fv[e];return(0,b.jsx)(`button`,{type:`button`,title:e,onClick:function(){t({type:`lucide`,name:e})},className:`w-8 h-8 flex items-center justify-center rounded-lg text-base-content transition-colors duration-75 `+(n?.type===`lucide`&&n.name===e?`border border-primary bg-base-300`:`hover:bg-base-300`),children:(0,b.jsx)(r,{size:16})},e)})})]}),r===`text`&&(0,b.jsxs)(`div`,{className:`flex gap-2`,children:[(0,b.jsx)(`input`,{type:`text`,value:s,maxLength:2,onChange:function(e){c(e.target.value),e.target.value&&t({type:`text`,value:e.target.value,color:l})},placeholder:`1-2 chars`,"aria-label":`Icon text`,className:`flex-1 h-9 px-3 bg-base-300 border border-base-content/15 rounded-xl text-base-content text-[13px] focus:border-primary focus-visible:outline-none transition-colors duration-[120ms]`}),(0,b.jsx)(`input`,{type:`color`,value:l,onChange:function(e){u(e.target.value),s&&t({type:`text`,value:s,color:e.target.value})},className:`w-9 h-9 rounded-xl border border-base-content/15 bg-base-300 cursor-pointer`})]}),r===`upload`&&(0,b.jsxs)(`div`,{className:`space-y-2`,children:[(0,b.jsx)(`input`,{type:`file`,accept:`image/*`,onChange:p,className:`w-full text-[12px] text-base-content/60 file:mr-3 file:py-1.5 file:px-3 file:rounded-lg file:border-0 file:text-[12px] file:bg-base-300 file:text-base-content/60 file:cursor-pointer`}),n?.type===`image`&&(0,b.jsx)(`img`,{src:n.path,alt:`preview`,className:`w-16 h-16 rounded-xl object-cover border border-base-content/15`,loading:`lazy`})]})]})}function a1e({settings:e,updateSection:t}){var[n,r]=(0,x.useState)(e.title),[i,a]=(0,x.useState)(e.icon),o=e9();(0,x.useEffect)(function(){o.savingRef.current?o.confirmSave():(r(e.title),a(e.icon),o.resetFromServer())},[e]);function s(e){r(e),o.markDirty()}function c(e){a(e),o.markDirty()}function l(){o.startSave(),t(`general`,{title:n,icon:i})}return(0,b.jsxs)(`div`,{className:`py-2`,children:[(0,b.jsxs)(`div`,{className:`mb-5`,children:[(0,b.jsx)(`label`,{htmlFor:`project-title`,className:`block text-[12px] font-semibold text-base-content/40 mb-2`,children:`Display Name`}),(0,b.jsx)(`input`,{id:`project-title`,type:`text`,value:n,onChange:function(e){s(e.target.value)},className:`w-full h-9 px-3 bg-base-300 border border-base-content/15 rounded-xl text-base-content text-[13px] focus:border-primary focus-visible:outline-none transition-colors duration-[120ms]`})]}),(0,b.jsxs)(`div`,{className:`mb-5`,children:[(0,b.jsx)(`div`,{className:`block text-[12px] font-semibold text-base-content/40 mb-2`,children:`Icon`}),(0,b.jsx)(i1e,{value:i,onChange:c})]}),(0,b.jsxs)(`div`,{className:`mb-6`,children:[(0,b.jsx)(`div`,{className:`block text-[12px] font-semibold text-base-content/40 mb-2`,children:`Project Path`}),(0,b.jsx)(`div`,{className:`w-full h-9 px-3 bg-base-300 border border-base-content/15 rounded-xl text-base-content/60 text-[12px] font-mono flex items-center select-all`,children:e.path})]}),(0,b.jsx)(r9,{dirty:o.dirty,saving:o.saving,saveState:o.saveState,onSave:l})]})}var w9=[{id:`claude-opus-4-6`,label:`Claude Opus 4.6`},{id:`claude-sonnet-4-6`,label:`Claude Sonnet 4.6`},{id:`claude-haiku-4-5`,label:`Claude Haiku 4.5`},{id:`claude-opus-4-5`,label:`Claude Opus 4.5`},{id:`claude-sonnet-4-5`,label:`Claude Sonnet 4.5`}],o1e=[{id:`low`,label:`Low`},{id:`normal`,label:`Normal`},{id:`high`,label:`High`},{id:`max`,label:`Max`}],s1e=[{id:`adaptive`,label:`Adaptive`},{id:`enabled`,label:`Enabled`},{id:`disabled`,label:`Disabled`}],c1e=[{id:`default`,label:`Default`},{id:`acceptEdits`,label:`Accept Edits`},{id:`plan`,label:`Plan`},{id:`dontAsk`,label:`Don't Ask`}];function l1e(e){return!e||e.type===`adaptive`?`Adaptive`:e.type===`enabled`?`Enabled`:`Disabled`}function u1e(e){var t=w9.find(function(t){return t.id===e});return t?t.label:e}function d1e({settings:e,updateSection:t}){var[n,r]=(0,x.useState)(e.claudeMd??``),[i,a]=(0,x.useState)(e.defaultModel),[o,s]=(0,x.useState)(e.defaultEffort),[c,l]=(0,x.useState)(e.thinking),[u,d]=(0,x.useState)(e.permissionMode),[f,p]=(0,x.useState)(e.thinking?.type===`enabled`?e.thinking.budgetTokens??1e4:1e4),[m,h]=(0,x.useState)(!1),g=e9();(0,x.useEffect)(function(){g.savingRef.current?g.confirmSave():(r(e.claudeMd??``),a(e.defaultModel),s(e.defaultEffort),l(e.thinking),d(e.permissionMode),e.thinking?.type===`enabled`&&p(e.thinking.budgetTokens??1e4),g.resetFromServer())},[e]);function _(){g.startSave();var e=c;e?.type===`enabled`&&(e={type:`enabled`,budgetTokens:f}),t(`claude`,{claudeMd:n||void 0,defaultModel:i,defaultEffort:o,thinking:e,permissionMode:u})}var v=e.global.defaultModel||w9[0].id,y=e.global.defaultEffort||`normal`;return(0,b.jsxs)(`div`,{className:`py-2 space-y-6`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{htmlFor:`project-claude-md`,className:`block text-[12px] font-semibold text-base-content/40 mb-2`,children:`Project CLAUDE.md`}),(0,b.jsx)(`textarea`,{id:`project-claude-md`,value:n,onChange:function(e){r(e.target.value),g.markDirty()},placeholder:`# Project-specific instructions for Claude...`,rows:10,className:`w-full px-3 py-2.5 bg-base-300 border border-base-content/15 rounded-xl text-base-content text-[12px] font-mono leading-relaxed resize-y focus:border-primary focus-visible:outline-none transition-colors duration-[120ms]`}),(function(){var e=n?n.split(`
659
- `).length:0,t=e>200;return(0,b.jsxs)(`div`,{className:`flex items-center justify-between mt-1.5`,children:[(0,b.jsxs)(`div`,{className:`text-[11px] `+(t?`text-warning`:`text-base-content/25`),children:[e,` line`,e===1?``:`s`,t?` — consider moving content to rules or imports`:``]}),t&&(0,b.jsx)(`div`,{className:`text-[10px] text-warning/70`,children:`soft limit: 200 lines`})]})})(),(0,b.jsxs)(`button`,{type:`button`,onClick:function(){h(!m)},className:`flex items-center gap-1.5 mt-2 text-[11px] text-base-content/40 hover:text-base-content/60 transition-colors`,children:[m?(0,b.jsx)(iu,{size:12}):(0,b.jsx)(cu,{size:12}),`Global CLAUDE.md (inherited)`]}),m&&(0,b.jsx)(`textarea`,{readOnly:!0,value:e.global.claudeMd,rows:8,className:`w-full mt-2 px-3 py-2.5 bg-base-300 border border-base-content/15 rounded-xl text-base-content/30 text-[12px] font-mono leading-relaxed resize-y cursor-default focus-visible:outline-none`})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{htmlFor:`project-default-model`,className:`block text-[12px] font-semibold text-base-content/40 mb-2`,children:`Default Model`}),(0,b.jsxs)(`select`,{id:`project-default-model`,value:i??``,onChange:function(e){a(e.target.value||void 0),g.markDirty()},className:`w-full h-9 px-3 bg-base-300 border border-base-content/15 rounded-xl text-base-content text-[13px] focus:border-primary focus-visible:outline-none transition-colors duration-[120ms]`,children:[(0,b.jsxs)(`option`,{value:``,className:`bg-base-300`,children:[`Use global default (`,u1e(v),`)`]}),w9.map(function(e){return(0,b.jsx)(`option`,{value:e.id,className:`bg-base-300`,children:e.label},e.id)})]}),i&&(0,b.jsx)(`button`,{type:`button`,onClick:function(){a(void 0),g.markDirty()},className:`mt-1.5 text-[11px] text-primary/70 hover:text-primary transition-colors`,children:`Clear override`})]}),(0,b.jsxs)(`div`,{role:`radiogroup`,"aria-label":`Default Effort`,children:[(0,b.jsx)(`div`,{className:`text-[12px] font-semibold text-base-content/40 mb-2`,children:`Default Effort`}),(0,b.jsxs)(`div`,{className:`flex gap-2`,children:[(0,b.jsxs)(`button`,{role:`radio`,"aria-checked":o===void 0,onClick:function(){s(void 0),g.markDirty()},className:`flex-1 py-2.5 sm:py-1.5 rounded-lg border text-[12px] transition-colors duration-[120ms] cursor-pointer focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-1 focus-visible:ring-offset-base-100 `+(o===void 0?`border-primary bg-base-300 text-base-content font-semibold`:`border-base-content/15 bg-base-300 text-base-content/40 hover:border-base-content/30 hover:text-base-content/60`),children:[`Global (`,y,`)`]}),o1e.map(function(e){var t=o===e.id;return(0,b.jsx)(`button`,{role:`radio`,"aria-checked":t,onClick:function(){s(e.id),g.markDirty()},className:`flex-1 py-2.5 sm:py-1.5 rounded-lg border text-[12px] transition-colors duration-[120ms] cursor-pointer focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-1 focus-visible:ring-offset-base-100 `+(t?`border-primary bg-base-300 text-base-content font-semibold`:`border-base-content/15 bg-base-300 text-base-content/40 hover:border-base-content/30 hover:text-base-content/60`),children:e.label},e.id)})]})]}),(0,b.jsxs)(`div`,{role:`radiogroup`,"aria-label":`Thinking Mode`,children:[(0,b.jsx)(`div`,{className:`text-[12px] font-semibold text-base-content/40 mb-2`,children:`Thinking Mode`}),(0,b.jsxs)(`div`,{className:`flex gap-2`,children:[(0,b.jsxs)(`button`,{role:`radio`,"aria-checked":c===void 0,onClick:function(){l(void 0),g.markDirty()},className:`flex-1 py-2.5 sm:py-1.5 rounded-lg border text-[12px] transition-colors duration-[120ms] cursor-pointer focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-1 focus-visible:ring-offset-base-100 `+(c===void 0?`border-primary bg-base-300 text-base-content font-semibold`:`border-base-content/15 bg-base-300 text-base-content/40 hover:border-base-content/30 hover:text-base-content/60`),children:[`Global (`,l1e(e.global.thinking),`)`]}),s1e.map(function(e){var t=c?.type===e.id;return(0,b.jsx)(`button`,{role:`radio`,"aria-checked":t,onClick:function(){l(e.id===`enabled`?{type:`enabled`,budgetTokens:f}:{type:e.id}),g.markDirty()},className:`flex-1 py-2.5 sm:py-1.5 rounded-lg border text-[12px] transition-colors duration-[120ms] cursor-pointer focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-1 focus-visible:ring-offset-base-100 `+(t?`border-primary bg-base-300 text-base-content font-semibold`:`border-base-content/15 bg-base-300 text-base-content/40 hover:border-base-content/30 hover:text-base-content/60`),children:e.label},e.id)})]}),c?.type===`enabled`&&(0,b.jsxs)(`div`,{className:`mt-3`,children:[(0,b.jsx)(`label`,{htmlFor:`budget-tokens`,className:`block text-[11px] text-base-content/40 mb-1.5`,children:`Budget Tokens`}),(0,b.jsx)(`input`,{id:`budget-tokens`,type:`number`,min:1e3,step:1e3,value:f,onChange:function(e){var t=parseInt(e.target.value,10);isNaN(t)||(p(t),l({type:`enabled`,budgetTokens:t}),g.markDirty())},className:`w-48 h-9 px-3 bg-base-300 border border-base-content/15 rounded-xl text-base-content text-[13px] font-mono focus:border-primary focus-visible:outline-none transition-colors duration-[120ms]`})]})]}),(0,b.jsxs)(`div`,{role:`radiogroup`,"aria-label":`Permission Mode`,children:[(0,b.jsx)(`div`,{className:`text-[12px] font-semibold text-base-content/40 mb-2`,children:`Permission Mode`}),(0,b.jsx)(`div`,{className:`flex gap-2`,children:c1e.map(function(e){var t=(u??`default`)===e.id;return(0,b.jsx)(`button`,{role:`radio`,"aria-checked":t,onClick:function(){d(e.id===`default`?void 0:e.id),g.markDirty()},className:`flex-1 py-2.5 sm:py-1.5 rounded-lg border text-[12px] transition-colors duration-[120ms] cursor-pointer focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-1 focus-visible:ring-offset-base-100 `+(t?`border-primary bg-base-300 text-base-content font-semibold`:`border-base-content/15 bg-base-300 text-base-content/40 hover:border-base-content/30 hover:text-base-content/60`),children:e.label},e.id)})})]}),(0,b.jsx)(r9,{dirty:g.dirty,saving:g.saving,saveState:g.saveState,onSave:_})]})}function T9(){return Math.random().toString(36).slice(2,10)}function f1e(e){var t={};return e.forEach(function(e){e.key.trim()&&(t[e.key.trim()]=e.value)}),t}function E9(e){return Object.entries(e).map(function([e,t]){return{id:T9(),key:e,value:t}})}function p1e({settings:e,updateSection:t}){var n=e.global.env??{},r=Object.entries(n),[i,a]=(0,x.useState)(function(){return E9(e.env??{})}),o=e9();(0,x.useEffect)(function(){o.savingRef.current?o.confirmSave():(a(E9(e.env??{})),o.resetFromServer())},[e]);var s=(0,x.useMemo)(function(){return new Set(Object.keys(n))},[n]),c=(0,x.useMemo)(function(){return a9(i)},[i]),l=c.size>0;function u(){a(function(e){return[...e,{id:T9(),key:``,value:``}]}),o.markDirty()}function d(e){a(function(t){return t.filter(function(t){return t.id!==e})}),o.markDirty()}function f(e,t){a(function(n){return n.map(function(n){return n.id===e?{...n,key:t}:n})}),o.markDirty()}function p(e,t){a(function(n){return n.map(function(n){return n.id===e?{...n,value:t}:n})}),o.markDirty()}function m(){o.startSave(),t(`environment`,{env:f1e(i)})}var h=`w-full h-9 sm:h-7 px-3 bg-base-300 border border-base-content/15 rounded-xl text-base-content font-mono text-[12px] focus:border-primary focus-visible:outline-none transition-colors duration-[120ms]`;return(0,b.jsxs)(`div`,{className:`py-2`,children:[(0,b.jsxs)(`div`,{className:`mb-6`,children:[(0,b.jsx)(`h2`,{className:`text-[12px] font-semibold text-base-content/40 mb-3`,children:`Global Variables`}),r.length===0&&(0,b.jsx)(`div`,{className:`py-4 text-center text-[13px] text-base-content/30`,children:`No global environment variables.`}),r.length>0&&(0,b.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:r.map(function([e,t]){return(0,b.jsxs)(`div`,{className:`flex flex-col sm:grid sm:grid-cols-[1fr_1fr_auto] gap-1.5 sm:items-center`,children:[(0,b.jsx)(`div`,{className:`h-9 sm:h-7 px-3 bg-base-300/50 border border-base-content/10 rounded-xl flex items-center font-mono text-[12px] text-base-content/40`,children:e}),(0,b.jsx)(`div`,{className:`flex gap-1.5 items-center`,children:(0,b.jsx)(`div`,{className:`h-9 sm:h-7 px-3 bg-base-300/50 border border-base-content/10 rounded-xl flex items-center font-mono text-[12px] text-base-content/40 w-full`,children:String(t)})}),(0,b.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider text-base-content/30 w-7 text-center hidden sm:block`,children:`global`})]},e)})})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`h2`,{className:`text-[12px] font-semibold text-base-content/40 mb-3`,children:`Project Variables`}),(0,b.jsxs)(`div`,{className:`flex flex-col gap-3 sm:gap-1.5 mb-3`,children:[i.length===0&&(0,b.jsx)(`div`,{className:`py-4 text-center text-[13px] text-base-content/30`,children:`No project environment variables.`}),i.map(function(e,t){var n=e.key.trim()!==``&&c.has(e.key.trim()),r=e.key.trim()!==``&&s.has(e.key.trim());return(0,b.jsxs)(`div`,{className:`flex flex-col sm:grid sm:grid-cols-[1fr_1fr_auto] gap-1.5 sm:items-center`,children:[(0,b.jsxs)(`div`,{className:`relative`,children:[(0,b.jsx)(`input`,{type:`text`,value:e.key,onChange:function(t){f(e.id,t.target.value)},placeholder:`VARIABLE_NAME`,"aria-label":`Variable name for row `+(t+1),"aria-invalid":n,className:`w-full h-9 sm:h-7 px-3 bg-base-300 border rounded-xl text-base-content font-mono text-[12px] focus:border-primary focus-visible:outline-none transition-colors duration-[120ms] `+(n?`border-warning`:`border-base-content/15`)}),n&&(0,b.jsxs)(`div`,{className:`flex items-center gap-1 mt-0.5 text-[10px] text-warning sm:absolute sm:-bottom-3.5 sm:left-0`,role:`alert`,children:[(0,b.jsx)(Ev,{size:9}),`Duplicate key`]}),!n&&r&&(0,b.jsx)(`div`,{className:`flex items-center gap-1 mt-0.5 text-[10px] text-warning/70 sm:absolute sm:-bottom-3.5 sm:left-0`,children:`overrides global`})]}),(0,b.jsxs)(`div`,{className:`flex gap-1.5 items-center`,children:[(0,b.jsx)(`input`,{type:`text`,value:e.value,onChange:function(t){p(e.id,t.target.value)},placeholder:`value`,"aria-label":`Value for `+(e.key||`row `+(t+1)),className:h}),(0,b.jsx)(`button`,{onClick:function(){d(e.id)},"aria-label":`Delete `+(e.key||`row `+(t+1)),title:`Delete`,className:`btn btn-ghost btn-xs btn-square text-base-content/30 hover:text-error w-9 h-9 flex-shrink-0 sm:hidden focus-visible:ring-2 focus-visible:ring-primary`,children:(0,b.jsx)(Nv,{size:14})})]}),(0,b.jsx)(`button`,{onClick:function(){d(e.id)},"aria-label":`Delete `+(e.key||`row `+(t+1)),title:`Delete`,className:`btn btn-ghost btn-xs btn-square text-base-content/30 hover:text-error w-7 h-7 hidden sm:flex focus-visible:ring-2 focus-visible:ring-primary`,children:(0,b.jsx)(Nv,{size:12})})]},e.id)})]}),(0,b.jsxs)(`button`,{onClick:u,className:`flex items-center gap-1.5 px-3 py-2.5 sm:py-1.5 rounded-xl border border-dashed border-base-content/20 bg-transparent text-base-content/40 text-[12px] hover:text-base-content/60 hover:border-base-content/30 transition-colors duration-[120ms] mb-5 cursor-pointer focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-1 focus-visible:ring-offset-base-100`,children:[(0,b.jsx)(tv,{size:12}),`Add Variable`]}),(0,b.jsx)(r9,{dirty:o.dirty,saving:o.saving,saveState:o.saveState,onSave:m,extraStatus:l?`Duplicate keys will be merged`:void 0})]})]})}function D9({rules:e,onDelete:t,readOnly:n,labelPrefix:r}){return e.length===0?(0,b.jsx)(`div`,{className:`py-3 text-center text-[13px] text-base-content/30`,children:`No rules defined.`}):(0,b.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:e.map(function(e,i){return(0,b.jsxs)(`div`,{className:`flex items-center gap-2 h-9 sm:h-7 px-3 rounded-xl border font-mono text-[12px] `+(n?`bg-base-300/50 border-base-content/10 text-base-content/40`:`bg-base-300 border-base-content/15 text-base-content`),children:[(0,b.jsx)(`span`,{className:`flex-1 truncate`,children:e}),n&&(0,b.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider text-base-content/30 flex-shrink-0`,children:`global`}),!n&&t&&(0,b.jsx)(`button`,{onClick:function(){t(i)},"aria-label":`Delete `+(r||``)+` rule: `+e,title:`Delete`,className:`btn btn-ghost btn-xs btn-square text-base-content/30 hover:text-error flex-shrink-0 focus-visible:ring-2 focus-visible:ring-primary`,children:(0,b.jsx)(Nv,{size:12})})]},e+`-`+i)})})}function O9({onAdd:e,label:t}){var[n,r]=(0,x.useState)(``);function i(){var t=n.trim();t&&(e(t),r(``))}function a(e){e.key===`Enter`&&(e.preventDefault(),i())}return(0,b.jsxs)(`div`,{className:`flex items-center gap-1.5 mt-1.5`,children:[(0,b.jsx)(`input`,{type:`text`,value:n,onChange:function(e){r(e.target.value)},onKeyDown:a,placeholder:`e.g. Bash(curl:*)`,"aria-label":t,className:`flex-1 h-9 sm:h-7 px-3 bg-base-300 border border-base-content/15 rounded-xl text-base-content font-mono text-[12px] focus:border-primary focus-visible:outline-none transition-colors duration-[120ms]`}),(0,b.jsxs)(`button`,{onClick:i,disabled:!n.trim(),className:`flex items-center gap-1.5 px-3 h-9 sm:h-7 rounded-xl border border-dashed border-base-content/20 bg-transparent text-base-content/40 text-[12px] hover:text-base-content/60 hover:border-base-content/30 transition-colors duration-[120ms] cursor-pointer focus-visible:ring-2 focus-visible:ring-primary`+(n.trim()?``:` opacity-50 cursor-not-allowed`),children:[(0,b.jsx)(tv,{size:12}),`Add`]})]})}function m1e({settings:e,updateSection:t}){var[n,r]=(0,x.useState)(function(){return[...e.permissions.allow??[]]}),[i,a]=(0,x.useState)(function(){return[...e.permissions.deny??[]]}),o=e9();(0,x.useEffect)(function(){o.savingRef.current?o.confirmSave():(r([...e.permissions.allow??[]]),a([...e.permissions.deny??[]]),o.resetFromServer())},[e]);function s(e){r(function(t){var n=[...t];return n.splice(e,1),n}),o.markDirty()}function c(e){a(function(t){var n=[...t];return n.splice(e,1),n}),o.markDirty()}function l(e){r(function(t){return[...t,e]}),o.markDirty()}function u(e){a(function(t){return[...t,e]}),o.markDirty()}function d(){o.startSave(),t(`permissions`,{allow:n,deny:i})}var f=e.global.permissions?.allow??[],p=e.global.permissions?.deny??[];return(0,b.jsxs)(`div`,{className:`py-2`,children:[(0,b.jsxs)(`div`,{className:`mb-6`,children:[(0,b.jsx)(`h2`,{className:`text-[12px] font-semibold text-base-content/40 mb-3`,children:`Allow Rules`}),(0,b.jsx)(D9,{rules:n,onDelete:s,labelPrefix:`allow`}),(0,b.jsx)(O9,{onAdd:l,label:`New allow rule`})]}),(0,b.jsxs)(`div`,{className:`mb-6`,children:[(0,b.jsx)(`h2`,{className:`text-[12px] font-semibold text-base-content/40 mb-3`,children:`Deny Rules`}),(0,b.jsx)(D9,{rules:i,onDelete:c,labelPrefix:`deny`}),(0,b.jsx)(O9,{onAdd:u,label:`New deny rule`})]}),(0,b.jsx)(`div`,{className:`mb-8`,children:(0,b.jsx)(r9,{dirty:o.dirty,saving:o.saving,saveState:o.saveState,onSave:d})}),(f.length>0||p.length>0)&&(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`h2`,{className:`text-[12px] font-semibold text-base-content/40 mb-3`,children:`Global Permissions`}),f.length>0&&(0,b.jsxs)(`div`,{className:`mb-4`,children:[(0,b.jsx)(`div`,{className:`text-[11px] text-base-content/40 uppercase tracking-wider mb-1.5`,children:`Allow`}),(0,b.jsx)(D9,{rules:f,readOnly:!0})]}),p.length>0&&(0,b.jsxs)(`div`,{className:`mb-4`,children:[(0,b.jsx)(`div`,{className:`text-[11px] text-base-content/40 uppercase tracking-wider mb-1.5`,children:`Deny`}),(0,b.jsx)(D9,{rules:p,readOnly:!0})]})]})]})}function h1e({settings:e,projectSlug:t}){var{send:n,subscribe:r,unsubscribe:i}=R(),a=e.global.skills,o=e.skills,s=a.length>0||o.length>0,[c,l]=(0,x.useState)(null);(0,x.useEffect)(function(){function e(e){if(e.type===`skills:view_result`){var t=e;l({path:t.path,content:t.content})}}return r(`skills:view_result`,e),function(){i(`skills:view_result`,e)}},[]);function u(e){n({type:`skills:view`,path:e})}return(0,b.jsxs)(`div`,{className:`py-2 space-y-6`,children:[!s&&(0,b.jsx)(`div`,{className:`py-12 text-center text-[13px] text-base-content/40`,children:`No skills found.`}),a.length>0&&(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-[12px] font-semibold text-base-content/40 mb-2`,children:`Global Skills`}),(0,b.jsx)(`div`,{className:`space-y-2`,children:a.map(function(e){return(0,b.jsx)(h9,{skill:e,badge:`global`,onClick:function(){u(e.path)}},e.path)})})]}),o.length>0&&(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-[12px] font-semibold text-base-content/40 mb-2`,children:`Project Skills`}),(0,b.jsx)(`div`,{className:`space-y-2`,children:o.map(function(e){return(0,b.jsx)(h9,{skill:e,onClick:function(){u(e.path)}},e.path)})})]}),(0,b.jsx)(m9,{defaultScope:`project`,defaultProjectSlug:t}),c&&(0,b.jsx)(g9,{path:c.path,content:c.content,onClose:function(){l(null)}})]})}function g1e({settings:e,updateSection:t}){var n=e.global.rules??[],[r,i]=(0,x.useState)(function(){return(e.rules??[]).map(function(e){return{filename:e.filename,content:e.content}})}),[a,o]=(0,x.useState)(new Set),[s,c]=(0,x.useState)(new Set),[l,u]=(0,x.useState)(!1),[d,f]=(0,x.useState)(``),[p,m]=(0,x.useState)(``),h=e9();(0,x.useEffect)(function(){h.savingRef.current?h.confirmSave():(i((e.rules??[]).map(function(e){return{filename:e.filename,content:e.content}})),h.resetFromServer())},[e]);function g(e){o(function(t){var n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}function _(e){c(function(t){var n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}function v(e,t){i(function(n){return n.map(function(n,r){return r===e?{...n,content:t}:n})}),h.markDirty()}function y(e){i(function(t){return t.filter(function(t,n){return n!==e})}),c(new Set),h.markDirty()}function S(){var e=d.trim();!e||!e.endsWith(`.md`)||(i(function(t){return[...t,{filename:e,content:p}]}),f(``),m(``),u(!1),h.markDirty())}function C(){u(!1),f(``),m(``)}function w(){h.startSave(),t(`rules`,{rules:r})}function T(e){var t=e.trim();return t.length<=80?t:t.slice(0,80)+`...`}var E=`w-full px-3 py-2 bg-base-300 border border-base-content/15 rounded-xl text-base-content font-mono text-[12px] focus:border-primary focus-visible:outline-none transition-colors duration-[120ms] resize-y min-h-[120px]`,D=`w-full h-9 sm:h-7 px-3 bg-base-300 border border-base-content/15 rounded-xl text-base-content font-mono text-[12px] focus:border-primary focus-visible:outline-none transition-colors duration-[120ms]`;return(0,b.jsxs)(`div`,{className:`py-2`,children:[(0,b.jsxs)(`a`,{href:`https://docs.anthropic.com/en/docs/claude-code/memory`,target:`_blank`,rel:`noopener noreferrer`,className:`text-[11px] text-base-content/30 hover:text-primary/70 flex items-center gap-1 mb-4 transition-colors`,children:[(0,b.jsx)(um,{size:11}),`Claude Code docs`]}),(0,b.jsxs)(`div`,{className:`mb-6`,children:[(0,b.jsx)(`h2`,{className:`text-[12px] font-semibold text-base-content/40 mb-3`,children:`Global Rules`}),n.length===0&&(0,b.jsx)(`div`,{className:`py-4 text-center text-[13px] text-base-content/30`,children:`No global rules.`}),n.length>0&&(0,b.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:n.map(function(e,t){var n=a.has(t);return(0,b.jsxs)(`div`,{className:`border border-base-content/10 rounded-xl overflow-hidden`,children:[(0,b.jsxs)(`button`,{onClick:function(){g(t)},className:`w-full flex items-center gap-2 px-3 py-2 bg-base-300/50 hover:bg-base-300/70 transition-colors duration-[120ms] cursor-pointer text-left`,children:[n?(0,b.jsx)(iu,{size:12,className:`text-base-content/40 flex-shrink-0`}):(0,b.jsx)(cu,{size:12,className:`text-base-content/40 flex-shrink-0`}),(0,b.jsx)(`span`,{className:`font-mono text-[12px] text-base-content/40 flex-1 truncate`,children:e.filename}),(0,b.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider text-base-content/30`,children:`global`})]}),!n&&(0,b.jsx)(`div`,{className:`px-3 py-1.5 text-[11px] text-base-content/30 font-mono truncate`,children:T(e.content)}),n&&(0,b.jsx)(`pre`,{className:`px-3 py-2 text-[12px] text-base-content/40 font-mono whitespace-pre-wrap break-words bg-base-300/30 max-h-[300px] overflow-auto`,children:e.content})]},e.filename+`-`+t)})})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`h2`,{className:`text-[12px] font-semibold text-base-content/40 mb-3`,children:`Project Rules`}),r.length===0&&!l&&(0,b.jsx)(`div`,{className:`py-4 text-center text-[13px] text-base-content/30 mb-3`,children:`No project rules.`}),r.length>0&&(0,b.jsx)(`div`,{className:`flex flex-col gap-1.5 mb-3`,children:r.map(function(e,t){var n=s.has(t);return(0,b.jsxs)(`div`,{className:`border border-base-content/15 rounded-xl overflow-hidden`,children:[(0,b.jsxs)(`div`,{className:`w-full flex items-center gap-2 px-3 py-2 bg-base-300 text-left`,children:[(0,b.jsxs)(`button`,{onClick:function(){_(t)},className:`flex items-center gap-2 flex-1 min-w-0 cursor-pointer hover:text-base-content/80 transition-colors`,children:[n?(0,b.jsx)(iu,{size:12,className:`text-base-content/60 flex-shrink-0`}):(0,b.jsx)(cu,{size:12,className:`text-base-content/60 flex-shrink-0`}),(0,b.jsx)(`span`,{className:`font-mono text-[12px] text-base-content flex-1 truncate text-left`,children:e.filename})]}),(0,b.jsx)(`button`,{onClick:function(){y(t)},className:`btn btn-ghost btn-xs btn-square text-base-content/30 hover:text-error flex-shrink-0 focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":`Delete `+e.filename,children:(0,b.jsx)(Nv,{size:14})})]}),!n&&(0,b.jsx)(`div`,{className:`px-3 py-1.5 text-[11px] text-base-content/50 font-mono truncate`,children:T(e.content)}),n&&(0,b.jsx)(`div`,{className:`px-3 py-2 bg-base-300/30`,children:(0,b.jsx)(`textarea`,{value:e.content,onChange:function(e){v(t,e.target.value)},className:E,rows:8,"aria-label":`Content for `+e.filename})})]},e.filename+`-`+t)})}),l&&(0,b.jsxs)(`div`,{className:`border border-dashed border-base-content/20 rounded-xl p-3 mb-3 flex flex-col gap-2`,children:[(0,b.jsx)(`input`,{type:`text`,value:d,onChange:function(e){f(e.target.value)},placeholder:`filename.md`,"aria-label":`New rule filename`,className:D}),(0,b.jsx)(`textarea`,{value:p,onChange:function(e){m(e.target.value)},placeholder:`Rule content...`,"aria-label":`New rule content`,className:E,rows:5}),(0,b.jsxs)(`div`,{className:`flex gap-2 justify-end`,children:[(0,b.jsx)(`button`,{onClick:C,className:`btn btn-ghost btn-sm text-[12px]`,children:`Cancel`}),(0,b.jsx)(`button`,{onClick:S,disabled:!d.trim()||!d.trim().endsWith(`.md`),className:`btn btn-sm btn-primary text-[12px]`+(!d.trim()||!d.trim().endsWith(`.md`)?` opacity-50 cursor-not-allowed`:``),children:`Add`})]})]}),!l&&(0,b.jsxs)(`button`,{onClick:function(){u(!0)},className:`flex items-center gap-1.5 px-3 py-2.5 sm:py-1.5 rounded-xl border border-dashed border-base-content/20 bg-transparent text-base-content/40 text-[12px] hover:text-base-content/60 hover:border-base-content/30 transition-colors duration-[120ms] mb-5 cursor-pointer focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-1 focus-visible:ring-offset-base-100`,children:[(0,b.jsx)(tv,{size:12}),`Add Rule`]}),(0,b.jsx)(r9,{dirty:h.dirty,saving:h.saving,saveState:h.saveState,onSave:w})]})]})}function _1e({settings:e,updateSection:t}){var n=e.global.mcpServers??{},r=Object.entries(n),[i,a]=(0,x.useState)(function(){return{...e.mcpServers??{}}}),o=e9(),[s,c]=(0,x.useState)(!1),[l,u]=(0,x.useState)(c9),[d,f]=(0,x.useState)(null),[p,m]=(0,x.useState)(c9),[h,g]=(0,x.useState)(null);(0,x.useEffect)(function(){o.savingRef.current?o.confirmSave():(a({...e.mcpServers??{}}),o.resetFromServer())},[e]);var _=Object.entries(i);function v(){var e=l.name.trim();e&&(a({...i,[e]:u9(l)}),c(!1),u(c9()),o.markDirty())}function y(e){f(e),m(l9(e,i[e])),c(!1),g(null)}function S(){if(d){var e=p.name.trim();if(e){var t={...i};e!==d&&delete t[d],t[e]=u9(p),a(t),f(null),o.markDirty()}}}function C(e){if(h!==e){g(e);return}var t={...i};delete t[e],a(t),d===e&&f(null),g(null),o.markDirty()}function w(){o.startSave(),t(`mcp`,{mcpServers:i})}var T=new Set(Object.keys(i)),E=new Set(Object.keys(i).filter(function(e){return e!==d}));return(0,b.jsxs)(`div`,{className:`py-2`,children:[(0,b.jsxs)(`div`,{className:`mb-6`,children:[(0,b.jsx)(`h2`,{className:`text-[12px] font-semibold text-base-content/40 mb-3`,children:`Global MCP Servers`}),r.length===0&&(0,b.jsx)(`div`,{className:`py-4 text-center text-[13px] text-base-content/30`,children:`No global MCP servers.`}),r.length>0&&(0,b.jsx)(`div`,{className:`flex flex-col gap-2`,children:r.map(function([e,t]){return(0,b.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-2 rounded-xl bg-base-300/50 border border-base-content/10`,children:[(0,b.jsx)(`span`,{className:`font-mono text-[12px] text-base-content/40 font-semibold flex-shrink-0`,children:e}),d9(t),(0,b.jsx)(`div`,{className:`flex-1 min-w-0`,children:f9(t)}),(0,b.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider text-base-content/30 flex-shrink-0`,children:`global`})]},e)})})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`h2`,{className:`text-[12px] font-semibold text-base-content/40 mb-3`,children:`Project MCP Servers`}),_.length===0&&!s&&(0,b.jsx)(`div`,{className:`py-4 text-center text-[13px] text-base-content/30 mb-3`,children:`No project MCP servers.`}),(0,b.jsx)(`div`,{className:`flex flex-col gap-2 mb-3`,children:_.map(function([e,t]){if(d===e)return(0,b.jsx)(p9,{form:p,setForm:m,onSave:S,onCancel:function(){f(null)},existingNames:E,idPrefix:`mcp-edit`},e);var n=h===e;return(0,b.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-2 rounded-xl bg-base-300 border border-base-content/15`,children:[(0,b.jsx)(`span`,{className:`font-mono text-[12px] text-base-content font-semibold flex-shrink-0`,children:e}),d9(t),(0,b.jsx)(`div`,{className:`flex-1 min-w-0`,children:f9(t)}),n?(0,b.jsxs)(`div`,{className:`flex gap-1.5 flex-shrink-0`,children:[(0,b.jsx)(`button`,{onClick:function(){C(e)},className:`btn btn-error btn-xs`,children:`Confirm`}),(0,b.jsx)(`button`,{onClick:function(){g(null)},className:`btn btn-ghost btn-xs`,children:`Cancel`})]}):(0,b.jsxs)(`div`,{className:`flex gap-1 flex-shrink-0`,children:[(0,b.jsx)(`button`,{onClick:function(){y(e)},"aria-label":`Edit `+e,className:`btn btn-ghost btn-xs btn-square text-base-content/30 hover:text-primary focus-visible:ring-2 focus-visible:ring-primary`,children:(0,b.jsx)($_,{size:12})}),(0,b.jsx)(`button`,{onClick:function(){C(e)},"aria-label":`Delete `+e,className:`btn btn-ghost btn-xs btn-square text-base-content/30 hover:text-error focus-visible:ring-2 focus-visible:ring-primary`,children:(0,b.jsx)(Tv,{size:12})})]})]},e)})}),s&&(0,b.jsx)(`div`,{className:`mb-3`,children:(0,b.jsx)(p9,{form:l,setForm:u,onSave:v,onCancel:function(){c(!1),u(c9())},existingNames:T,idPrefix:`mcp-add`})}),!s&&(0,b.jsxs)(`button`,{onClick:function(){c(!0),f(null),g(null)},className:`flex items-center gap-1.5 px-3 py-2.5 sm:py-1.5 rounded-xl border border-dashed border-base-content/20 bg-transparent text-base-content/40 text-[12px] hover:text-base-content/60 hover:border-base-content/30 transition-colors duration-[120ms] mb-5 cursor-pointer focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-1 focus-visible:ring-offset-base-100`,children:[(0,b.jsx)(tv,{size:12}),`Add Server`]}),(0,b.jsx)(r9,{dirty:o.dirty,saving:o.saving,saveState:o.saveState,onSave:w})]})]})}function v1e(e){return localStorage.getItem(`lattice-mute-`+e)===`1`}function y1e(e,t){localStorage.setItem(`lattice-mute-`+e,t?`1`:`0`)}function b1e({projectSlug:e}){var t=e??``,[n,r]=(0,x.useState)(function(){return v1e(t)});function i(){var e=!n;r(e),y1e(t,e)}return(0,b.jsx)(`div`,{className:`py-2 space-y-6`,children:(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`h2`,{className:`text-[12px] font-semibold text-base-content/40 mb-3`,children:`Project Notifications`}),(0,b.jsxs)(`div`,{className:`flex items-center justify-between py-2 px-3 bg-base-300 border border-base-content/15 rounded-xl`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-[13px] text-base-content`,children:`Mute all notifications`}),(0,b.jsx)(`div`,{className:`text-[11px] text-base-content/30 mt-0.5`,children:`Suppress all browser notifications from this project`})]}),(0,b.jsx)(`input`,{type:`checkbox`,className:`toggle toggle-sm toggle-primary`,checked:n,onChange:i})]})]})})}function x1e({settings:e,updateSection:t}){var{send:n,subscribe:r,unsubscribe:i}=R(),[a,o]=(0,x.useState)([]),[s,c]=(0,x.useState)(!1),[l,u]=(0,x.useState)(e.disabledPlugins??[]),[d,f]=(0,x.useState)(!1);(0,x.useEffect)(function(){function e(e){e.type===`plugin:list_result`&&(o(e.plugins),c(!0))}return r(`plugin:list_result`,e),n({type:`plugin:list`}),function(){i(`plugin:list_result`,e)}},[]),(0,x.useEffect)(function(){u(e.disabledPlugins??[])},[e.disabledPlugins]);function p(e){var n=l.indexOf(e)===-1?l.concat(e):l.filter(function(t){return t!==e});u(n),f(!0),t(`plugins`,{disabledPlugins:n}),setTimeout(function(){f(!1)},500)}if(!s)return(0,b.jsx)(`div`,{className:`text-[13px] text-base-content/40 py-4`,children:`Loading...`});if(a.length===0)return(0,b.jsx)(`div`,{className:`py-6 text-center text-[13px] text-base-content/30`,children:`No plugins installed. Install plugins from Global Settings to use them in projects.`});var m=a.length-l.length;return(0,b.jsxs)(`div`,{className:`py-2 space-y-4`,children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,b.jsx)(`p`,{className:`text-[12px] text-base-content/40`,children:`Toggle plugins on/off for this project. Disabled plugins won't load in new sessions.`}),d&&(0,b.jsx)(C_,{size:12,className:`text-primary animate-spin`})]}),(0,b.jsxs)(`div`,{className:`text-[11px] text-base-content/30 mb-1`,children:[m,` of `,a.length,` enabled`]}),(0,b.jsx)(`div`,{className:`space-y-1.5`,children:a.map(function(e){var t=l.indexOf(e.key)!==-1;return(0,b.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-2.5 rounded-xl border transition-colors duration-[120ms] `+(t?`bg-base-300/30 border-base-content/8 opacity-50`:`bg-base-300 border-base-content/15`),children:[(0,b.jsx)(fs,{size:14,className:`text-base-content/25 flex-shrink-0`}),(0,b.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(`span`,{className:`text-[13px] font-bold text-base-content truncate`,children:e.name}),(0,b.jsxs)(`span`,{className:`text-[10px] font-mono px-1.5 py-0.5 rounded-md bg-base-content/8 text-base-content/40`,children:[`v`,e.version]})]}),(0,b.jsxs)(`div`,{className:`text-[11px] text-base-content/30 mt-0.5`,children:[e.marketplace,e.skillCount>0?` · `+e.skillCount+` skill`+(e.skillCount===1?``:`s`):``]})]}),(0,b.jsx)(`input`,{type:`checkbox`,checked:!t,onChange:function(){p(e.key)},className:`toggle toggle-sm toggle-primary`,"aria-label":(t?`Enable`:`Disable`)+` `+e.name})]},e.key)})})]})}var S1e={general:{title:`General`},notifications:{title:`Notifications`},claude:{title:`Claude`},environment:{title:`Environment`},mcp:{title:`MCP Servers`},skills:{title:`Skills`},plugins:{title:`Plugins`},rules:{title:`Rules`},permissions:{title:`Permissions`},memory:{title:`Memory`}};function C1e(e,t,n,r){return e===`general`?(0,b.jsx)(a1e,{settings:t,updateSection:n}):e===`claude`?(0,b.jsx)(d1e,{settings:t,updateSection:n}):e===`environment`?(0,b.jsx)(p1e,{settings:t,updateSection:n}):e===`permissions`?(0,b.jsx)(m1e,{settings:t,updateSection:n}):e===`skills`?(0,b.jsx)(h1e,{settings:t,projectSlug:r}):e===`plugins`?(0,b.jsx)(x1e,{settings:t,updateSection:n}):e===`rules`?(0,b.jsx)(g1e,{settings:t,updateSection:n}):e===`mcp`?(0,b.jsx)(_1e,{settings:t,updateSection:n}):e===`memory`?(0,b.jsx)(v9,{projectSlug:r}):e===`notifications`?(0,b.jsx)(b1e,{projectSlug:r}):(0,b.jsxs)(`div`,{className:`py-2 text-[13px] text-base-content/40`,children:[e,` section coming soon.`]})}function w1e(){var{activeView:e,activeProjectSlug:t,toggleDrawer:n}=jy();if(e.type!==`project-settings`)return null;var r=e.section,i=S1e[r],{settings:a,loading:o,error:s,updateSection:c}=C9(t);return(0,b.jsxs)(`section`,{"aria-label":`Project Settings`,className:`flex-1 overflow-auto px-4 sm:px-8 py-4 sm:py-6 max-w-3xl`,children:[i&&(0,b.jsxs)(`div`,{className:`mb-6 flex items-center gap-3`,children:[(0,b.jsx)(`button`,{className:`btn btn-ghost btn-sm btn-square lg:hidden`,"aria-label":`Toggle sidebar`,onClick:n,children:(0,b.jsx)(B_,{size:18})}),(0,b.jsx)(`h1`,{className:`text-lg font-mono font-bold text-base-content`,children:i.title})]}),o&&(0,b.jsx)(`div`,{className:`text-[13px] text-base-content/40 py-4`,children:`Loading...`}),s&&(0,b.jsx)(`div`,{className:`text-[13px] text-error py-4`,children:s}),!o&&!s&&a&&C1e(r,a,c,t??void 0)]})}function T1e(e){var t=Date.now()-e,n=Math.floor(t/1e3);if(n<60)return n+`s ago`;var r=Math.floor(n/60);if(r<60)return r+`m ago`;var i=Math.floor(r/60);return i<24?i+`h ago`:Math.floor(i/24)+`d ago`}function E1e(){Cb();var{nodes:e}=Ay(),{projects:t}=Dy(),n=jy(),{send:r,subscribe:i,unsubscribe:a}=R(),[o,s]=(0,x.useState)([]),[c,l]=(0,x.useState)(null),u=(0,x.useMemo)(function(){return e.filter(function(e){return e.online})},[e]);(0,x.useEffect)(function(){function e(e){e.type===`session:list_all`&&s(e.sessions)}function t(e){e.type===`settings:data`&&l(e.config)}return i(`session:list_all`,e),i(`settings:data`,t),r({type:`session:list_all_request`}),r({type:`settings:get`}),function(){a(`session:list_all`,e),a(`settings:data`,t)}},[]);var d=(0,x.useMemo)(function(){for(var e=new Map,n=0;n<t.length;n++)e.set(t[n].slug,t[n].title);return e},[t]);function f(e){return d.get(e)||e}var p=(0,x.useMemo)(function(){for(var e=new Map,t=0;t<o.length;t++){var n=o[t],r=e.get(n.projectSlug);r||(r=[],e.set(n.projectSlug,r)),r.push(n)}return e},[o]),m=e.filter(function(e){return!e.isLocal});return(0,b.jsx)(`div`,{className:`flex-1 overflow-auto`,children:(0,b.jsxs)(`div`,{className:`max-w-2xl mx-auto px-4 sm:px-8 py-6 sm:py-10`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-3 mb-2`,children:[(0,b.jsx)(`button`,{className:`btn btn-ghost btn-sm btn-square lg:hidden`,"aria-label":`Toggle sidebar`,onClick:n.toggleDrawer,children:(0,b.jsx)(B_,{size:18})}),(0,b.jsx)(Iv,{size:28}),(0,b.jsx)(`h1`,{className:`text-lg font-mono font-bold text-base-content`,children:`Lattice`})]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-4 text-[11px] font-mono text-base-content/30 mb-10 ml-[43px]`,children:[(0,b.jsxs)(`span`,{children:[u.length,`/`,e.length,` nodes`]}),(0,b.jsx)(`span`,{className:`text-base-content/15`,children:`/`}),(0,b.jsxs)(`span`,{children:[t.length,` projects`]}),(0,b.jsx)(`span`,{className:`text-base-content/15`,children:`/`}),(0,b.jsxs)(`span`,{children:[o.length,` sessions`]})]}),(0,b.jsx)(`div`,{className:`mb-12`,children:(0,b.jsx)(hQ,{})}),o.length>0&&(0,b.jsxs)(`div`,{className:`mb-12`,children:[(0,b.jsx)(`h2`,{className:`text-[11px] font-semibold tracking-wider uppercase text-base-content/40 mb-3`,children:`Recent Sessions`}),(0,b.jsx)(`div`,{className:`flex flex-col gap-1`,children:o.slice(0,8).map(function(e){return(0,b.jsxs)(`button`,{onClick:function(){Gv(e.id,e.projectSlug,e.title),n.navigateToSession(e.projectSlug,e.id)},className:`flex items-center gap-3 px-3 py-2 rounded-lg hover:bg-base-200 transition-colors duration-[120ms] cursor-pointer text-left focus-visible:ring-2 focus-visible:ring-primary group`,children:[(0,b.jsx)(U_,{size:12,className:`text-base-content/20 flex-shrink-0`}),(0,b.jsx)(`span`,{className:`flex-1 text-[12px] text-base-content/70 truncate group-hover:text-base-content`,children:wb(e.title)||`Untitled`}),(0,b.jsx)(`span`,{className:`text-[10px] font-mono text-base-content/25 flex-shrink-0`,children:f(e.projectSlug)}),(0,b.jsx)(`span`,{className:`text-[10px] text-base-content/20 font-mono flex-shrink-0`,children:T1e(e.updatedAt)}),(0,b.jsx)(cu,{size:10,className:`text-base-content/15 flex-shrink-0 opacity-0 group-hover:opacity-100`})]},e.id)})})]}),t.length>0&&(0,b.jsxs)(`div`,{className:`mb-12`,children:[(0,b.jsx)(`h2`,{className:`text-[11px] font-semibold tracking-wider uppercase text-base-content/40 mb-3`,children:`Projects`}),(0,b.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2`,children:t.map(function(e){var t=p.get(e.slug)||[];return(0,b.jsxs)(`button`,{onClick:function(){n.setActiveProjectSlug(e.slug)},className:`flex items-center gap-3 px-3 py-2.5 rounded-lg hover:bg-base-200 transition-colors duration-[120ms] cursor-pointer text-left focus-visible:ring-2 focus-visible:ring-primary group`,children:[(0,b.jsx)(Wm,{size:14,className:`text-base-content/20 flex-shrink-0`}),(0,b.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,b.jsx)(`div`,{className:`text-[13px] font-semibold text-base-content/70 truncate group-hover:text-base-content`,children:e.title}),(0,b.jsxs)(`div`,{className:`text-[10px] text-base-content/25 font-mono`,children:[t.length,` session`,t.length===1?``:`s`,e.isRemote&&(0,b.jsxs)(`span`,{className:`ml-1.5 text-base-content/20`,children:[`on `,e.nodeName]})]})]}),(0,b.jsx)(cu,{size:12,className:`text-base-content/15 flex-shrink-0 opacity-0 group-hover:opacity-100`})]},e.slug+`@`+e.nodeId)})})]}),m.length>0&&(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`h2`,{className:`text-[11px] font-semibold tracking-wider uppercase text-base-content/40 mb-3`,children:`Mesh`}),(0,b.jsx)(`div`,{className:`flex flex-wrap gap-x-6 gap-y-2`,children:m.map(function(e){return(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.online?(0,b.jsx)(Hu,{size:10,className:`text-success flex-shrink-0`}):(0,b.jsx)(md,{size:10,className:`text-base-content/20 flex-shrink-0`}),(0,b.jsx)(`span`,{className:`text-[12px] text-base-content/50`,children:e.name}),(0,b.jsxs)(`span`,{className:`text-[10px] text-base-content/20 font-mono`,children:[e.projects.length,`p`]})]},e.id)})})]})]})})}function k9({label:e,value:t,icon:n,loading:r}){return(0,b.jsxs)(`div`,{className:`bg-base-300 rounded-xl border border-base-content/15 p-3 px-4`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2 mb-1.5`,children:[n,(0,b.jsx)(`span`,{className:`text-[11px] font-semibold tracking-wider uppercase text-base-content/40`,children:e})]}),r?(0,b.jsx)(`div`,{className:`h-7 w-10 bg-base-content/10 rounded animate-pulse`}):(0,b.jsx)(`div`,{className:`text-xl font-mono font-bold text-base-content`,children:t})]})}function A9({label:e,icon:t,onClick:n}){return(0,b.jsxs)(`button`,{onClick:n,className:`flex items-center gap-2.5 px-3 py-2 rounded-xl border border-base-content/15 bg-base-300 text-[12px] text-base-content/60 hover:text-base-content hover:border-base-content/30 transition-colors duration-[120ms] cursor-pointer focus-visible:ring-2 focus-visible:ring-primary`,children:[t,(0,b.jsx)(`span`,{className:`flex-1 text-left`,children:e}),(0,b.jsx)(cu,{size:12,className:`text-base-content/30`})]})}function D1e(){var e=jy();if(e.activeView.type!==`project-dashboard`)return null;var{settings:t,loading:n}=C9(e.activeProjectSlug),{projects:r}=Dy(),{send:i,subscribe:a,unsubscribe:o,status:s}=R(),[c,l]=(0,x.useState)([]),[u,d]=(0,x.useState)(!0),f=r.find(function(t){return t.slug===e.activeProjectSlug}),p=f?.title??e.activeProjectSlug??`Project`;(0,x.useEffect)(function(){if(!e.activeProjectSlug)return;function t(t){if(t.type===`session:list`){var n=t;n.projectSlug===e.activeProjectSlug&&(l(n.sessions.slice().sort(function(e,t){return t.updatedAt-e.updatedAt})),d(!1))}}return a(`session:list`,t),s===`connected`&&(d(!0),i({type:`session:list_request`,projectSlug:e.activeProjectSlug})),function(){o(`session:list`,t)}},[e.activeProjectSlug,s]);function m(t){e.openProjectSettings(t)}function h(t){f&&(Gv(t.id,f.slug,t.title),e.setActiveSessionId(t.id))}var g=c.length,_=t?Object.keys(t.mcpServers).length:0,v=t?Object.keys(t.global.mcpServers).length:0,y=t?t.rules.length:0,S=t?t.global.rules.length:0,C=t?Object.keys(t.env).length:0;return(0,b.jsxs)(`div`,{className:`flex-1 overflow-auto px-4 sm:px-8 py-4 sm:py-6 max-w-3xl`,children:[(0,b.jsxs)(`div`,{className:`mb-6 flex items-center gap-3`,children:[(0,b.jsx)(`button`,{className:`btn btn-ghost btn-sm btn-square lg:hidden`,"aria-label":`Toggle sidebar`,onClick:e.toggleDrawer,children:(0,b.jsx)(B_,{size:18})}),(0,b.jsx)(`h1`,{className:`text-lg font-mono font-bold text-base-content`,children:p})]}),(0,b.jsxs)(`div`,{className:`space-y-6`,children:[(0,b.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-3`,children:[(0,b.jsx)(k9,{label:`Sessions`,value:g,icon:(0,b.jsx)(U_,{size:14,className:`text-primary`}),loading:u}),(0,b.jsx)(k9,{label:`MCP Servers`,value:_+v,icon:(0,b.jsx)(ev,{size:14,className:`text-accent`}),loading:n}),(0,b.jsx)(k9,{label:`Rules`,value:y+S,icon:(0,b.jsx)(uv,{size:14,className:`text-info`}),loading:n}),(0,b.jsx)(k9,{label:`Env Vars`,value:C,icon:(0,b.jsx)(Cv,{size:14,className:`text-success`}),loading:n})]}),n?(0,b.jsx)(`div`,{className:`bg-base-content/10 rounded-xl h-32 animate-pulse`}):t?.claudeMd?(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-[12px] font-semibold text-base-content/40 mb-2`,children:`CLAUDE.md`}),(0,b.jsx)(`div`,{className:`px-3 py-2.5 bg-base-300 border border-base-content/15 rounded-xl font-mono text-[11px] text-base-content/60 leading-relaxed max-h-48 overflow-y-auto`,children:(0,b.jsx)(`pre`,{className:`whitespace-pre-wrap`,children:t.claudeMd})})]}):null,(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-[12px] font-semibold text-base-content/40 mb-2`,children:`Recent Sessions`}),u?(0,b.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:[0,1,2].map(function(e){return(0,b.jsx)(`div`,{className:`bg-base-content/10 rounded-xl h-10 animate-pulse`},e)})}):c.length>0?(0,b.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:c.slice(0,5).map(function(e){return(0,b.jsxs)(`button`,{onClick:function(){h(e)},className:`flex items-center gap-3 px-3 py-2 rounded-xl border border-base-content/15 bg-base-300 hover:border-base-content/30 transition-colors duration-[120ms] cursor-pointer text-left focus-visible:ring-2 focus-visible:ring-primary`,children:[(0,b.jsx)(U_,{size:12,className:`text-base-content/30 flex-shrink-0`}),(0,b.jsx)(`span`,{className:`flex-1 text-[12px] text-base-content truncate`,children:e.title||`Untitled`}),(0,b.jsx)(`span`,{className:`text-[10px] text-base-content/30 font-mono flex-shrink-0`,children:new Date(e.updatedAt).toLocaleDateString()}),(0,b.jsx)(cu,{size:12,className:`text-base-content/20 flex-shrink-0`})]},e.id)})}):(0,b.jsx)(`div`,{className:`text-[12px] text-base-content/30`,children:`No sessions yet`})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-[12px] font-semibold text-base-content/40 mb-2`,children:`Settings`}),(0,b.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-3 gap-2`,children:[(0,b.jsx)(A9,{label:`General`,icon:(0,b.jsx)(hv,{size:13,className:`text-base-content/40`}),onClick:function(){m(`general`)}}),(0,b.jsx)(A9,{label:`Claude`,icon:(0,b.jsx)(Vm,{size:13,className:`text-base-content/40`}),onClick:function(){m(`claude`)}}),(0,b.jsx)(A9,{label:`Environment`,icon:(0,b.jsx)(Cv,{size:13,className:`text-base-content/40`}),onClick:function(){m(`environment`)}}),(0,b.jsx)(A9,{label:`MCP Servers`,icon:(0,b.jsx)(ev,{size:13,className:`text-base-content/40`}),onClick:function(){m(`mcp`)}}),(0,b.jsx)(A9,{label:`Rules`,icon:(0,b.jsx)(uv,{size:13,className:`text-base-content/40`}),onClick:function(){m(`rules`)}}),(0,b.jsx)(A9,{label:`Permissions`,icon:(0,b.jsx)(gv,{size:13,className:`text-base-content/40`}),onClick:function(){m(`permissions`)}})]})]}),t&&(0,b.jsx)(`div`,{className:`text-[11px] text-base-content/30 font-mono truncate`,children:t.path})]})]})}function O1e({isOpen:e,onClose:t}){var{send:n,subscribe:r,unsubscribe:i}=R(),{nodes:a}=Ay(),o=e9(),s=a.find(function(e){return e.isLocal}),c=s?s.id:``,[l,u]=(0,x.useState)(null),[d,f]=(0,x.useState)(``),[p,m]=(0,x.useState)(7654),[h,g]=(0,x.useState)(!1),[_,v]=(0,x.useState)(!1),[y,S]=(0,x.useState)(!1),[C,w]=(0,x.useState)(`auto`),T=(0,x.useRef)(null),E=(0,x.useRef)(null);Wr(E,(0,x.useCallback)(function(){t()},[t]),e),(0,x.useEffect)(function(){if(!e)return;function t(e){if(e.type===`settings:data`){var t=e.config;u(t),o.saving?o.confirmSave():(f(t.name),m(t.port),g(t.tls),v(t.debug),w(t.wsl??`auto`),o.resetFromServer())}}return r(`settings:data`,t),n({type:`settings:get`}),function(){i(`settings:data`,t)}},[e]),(0,x.useEffect)(function(){return function(){T.current&&clearTimeout(T.current)}},[]);function D(){o.startSave(),n({type:`settings:update`,settings:{name:d,port:p,tls:h,debug:_,wsl:C}})}function O(){c&&(navigator.clipboard.writeText(c),S(!0),T.current&&clearTimeout(T.current),T.current=setTimeout(function(){S(!1)},2e3))}if(!e)return null;var k=`w-full h-9 px-3 bg-base-300 border border-base-content/15 rounded-xl text-base-content text-[13px] focus:border-primary focus-visible:outline-none transition-colors duration-[120ms]`;return(0,b.jsxs)(`div`,{ref:E,className:`fixed inset-0 z-[9999] flex items-center justify-center`,role:`dialog`,"aria-modal":`true`,"aria-label":`Node Settings`,children:[(0,b.jsx)(`div`,{className:`absolute inset-0 bg-base-content/50`,onClick:t}),(0,b.jsxs)(`div`,{className:`relative bg-base-200 border border-base-content/15 rounded-2xl shadow-2xl w-full max-w-md mx-4 overflow-hidden`,children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between px-5 py-4 border-b border-base-content/15`,children:[(0,b.jsx)(`h2`,{className:`text-[15px] font-mono font-bold text-base-content`,children:`Node Settings`}),(0,b.jsx)(`button`,{onClick:t,"aria-label":`Close`,className:`btn btn-ghost btn-xs btn-square text-base-content/40 hover:text-base-content`,children:(0,b.jsx)(Nv,{size:16})})]}),(0,b.jsxs)(`div`,{className:`px-5 py-4 space-y-4 max-h-[70vh] overflow-y-auto`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{htmlFor:`node-id`,className:`block text-[12px] font-semibold text-base-content/40 mb-1.5`,children:`Node ID`}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(`div`,{className:`flex-1 h-9 px-3 bg-base-300/50 border border-base-content/10 rounded-xl font-mono text-[11px] text-base-content/50 flex items-center truncate select-all`,children:c||`Loading...`}),(0,b.jsx)(`button`,{onClick:O,disabled:!c,"aria-label":`Copy node ID`,className:`btn btn-ghost btn-sm btn-square text-base-content/30 hover:text-base-content flex-shrink-0`,children:y?(0,b.jsx)(L,{size:14,className:`text-success`}):(0,b.jsx)(Yf,{size:14})})]})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{htmlFor:`node-name`,className:`block text-[12px] font-semibold text-base-content/40 mb-1.5`,children:`Node Name`}),(0,b.jsx)(`input`,{id:`node-name`,type:`text`,value:d,onChange:function(e){f(e.target.value),o.markDirty()},placeholder:`My Node`,className:k})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{htmlFor:`node-port`,className:`block text-[12px] font-semibold text-base-content/40 mb-1.5`,children:`Port`}),(0,b.jsx)(`input`,{id:`node-port`,type:`number`,value:p,onChange:function(e){var t=parseInt(e.target.value,10);isNaN(t)||(m(t),o.markDirty())},min:1,max:65535,className:k+` font-mono`})]}),(0,b.jsxs)(`div`,{className:`flex items-center justify-between py-1`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-[12px] font-semibold text-base-content/40`,children:`TLS`}),(0,b.jsx)(`div`,{className:`text-[11px] text-base-content/30`,children:`Encrypt connections between nodes`})]}),(0,b.jsx)(`input`,{type:`checkbox`,checked:h,onChange:function(e){g(e.target.checked),o.markDirty()},className:`toggle toggle-sm toggle-primary`,"aria-label":`Enable TLS`})]}),(0,b.jsxs)(`div`,{className:`flex items-center justify-between py-1`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-[12px] font-semibold text-base-content/40`,children:`Debug Mode`}),(0,b.jsx)(`div`,{className:`text-[11px] text-base-content/30`,children:`Enable verbose logging`})]}),(0,b.jsx)(`input`,{type:`checkbox`,checked:_,onChange:function(e){v(e.target.checked),o.markDirty()},className:`toggle toggle-sm toggle-primary`,"aria-label":`Enable debug mode`})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-[12px] font-semibold text-base-content/40 mb-1.5`,children:`WSL Mode`}),(0,b.jsx)(`div`,{className:`text-[11px] text-base-content/30 mb-2`,children:`Convert file paths for Windows editors when running under WSL`}),(0,b.jsxs)(`select`,{value:String(C),onChange:function(e){var t=e.target.value;w(t===`true`?!0:t===`false`?!1:`auto`),o.markDirty()},className:k,children:[(0,b.jsx)(`option`,{value:`auto`,children:`Auto-detect`}),(0,b.jsx)(`option`,{value:`true`,children:`Enabled`}),(0,b.jsx)(`option`,{value:`false`,children:`Disabled`})]})]})]}),(0,b.jsx)(`div`,{className:`px-5 py-3 border-t border-base-content/15`,children:(0,b.jsx)(r9,{dirty:o.dirty,saving:o.saving,saveState:o.saveState,onSave:D})})]})]})}function k1e({isOpen:e,onClose:t}){var{send:n,subscribe:r,unsubscribe:i}=R(),{projects:a}=Dy(),[o,s]=(0,x.useState)(``),[c,l]=(0,x.useState)([]),[u,d]=(0,x.useState)(``),[f,p]=(0,x.useState)(!1),[m,h]=(0,x.useState)(!1),[g,_]=(0,x.useState)(-1),[v,y]=(0,x.useState)(null),[S,C]=(0,x.useState)(!1),[w,T]=(0,x.useState)([]),[E,D]=(0,x.useState)(``),O=(0,x.useRef)(null),k=(0,x.useRef)(null),A=(0,x.useRef)(null),j=(0,x.useRef)(!1),M=(0,x.useRef)(!1),N=(0,x.useRef)(null);Wr(N,(0,x.useCallback)(function(){t()},[t]),e),(0,x.useEffect)(function(){if(!e)return;s(``),l([]),d(``),p(!1),h(!1),y(null),C(!1),T([]),M.current=!1,n({type:`browse:list`,path:`~`}),n({type:`browse:suggestions`});function a(e){if(e.type===`browse:list_result`){var t=e;l(t.entries),D(t.homedir),_(-1),j.current&&t.entries.length>0&&h(!0)}}function o(e){e.type===`browse:suggestions_result`&&T(e.suggestions)}function c(e){e.type===`projects:list`&&M.current&&(M.current=!1,C(!1),t())}return r(`browse:list_result`,a),r(`browse:suggestions_result`,o),r(`projects:list`,c),function(){i(`browse:list_result`,a),i(`browse:suggestions_result`,o),i(`projects:list`,c)}},[e]),(0,x.useEffect)(function(){if(!e)return;function t(e){A.current&&!A.current.contains(e.target)&&k.current&&!k.current.contains(e.target)&&h(!1)}return document.addEventListener(`mousedown`,t),function(){document.removeEventListener(`mousedown`,t)}},[e]),(0,x.useEffect)(function(){if(e){O.current&&clearTimeout(O.current);var t=o.trim();if(!t){n({type:`browse:list`,path:`~`});return}O.current=setTimeout(function(){var e=t;if(!t.endsWith(`/`)){var r=t.lastIndexOf(`/`);e=r>=0?t.slice(0,r+1):t}n({type:`browse:list`,path:e})},200)}},[o,e]);function ee(e){return e.startsWith(`~/`)&&E?E+e.slice(1):e===`~`&&E?E:e}function te(e){s(e.path+`/`),h(!1),y(null),f||(e.projectName?d(e.projectName):d(e.name)),n({type:`browse:list`,path:e.path}),k.current&&k.current.focus()}function P(e){d(e),p(e.length>0)}function F(){j.current=!0,re().length>0&&h(!0)}function ne(){j.current=!1}function re(){var e=o.trim();if(!e||e.endsWith(`/`))return c;var t=e.lastIndexOf(`/`),n=t>=0?e.slice(t+1).toLowerCase():e.toLowerCase();return n?c.filter(function(e){return e.name.toLowerCase().startsWith(n)}):c}function ie(){var e=o.trim();if(!e)return!1;var t=ee(e.endsWith(`/`)?e.slice(0,-1):e);return!a.some(function(e){return e.path===t})}function ae(){var e=o.trim();if(!e)return{type:`info`,text:`Type a path to browse directories`};var t=ee(e.endsWith(`/`)?e.slice(0,-1):e);return a.some(function(e){return e.path===t})?{type:`error`,text:`Already added as a project`}:null}function oe(e){var t=re();if(!m||t.length===0){e.key===`Enter`&&ce&&(e.preventDefault(),le());return}e.key===`ArrowDown`?(e.preventDefault(),_(function(e){var n=e+1;return n>=t.length&&(n=0),se(n),n})):e.key===`ArrowUp`?(e.preventDefault(),_(function(e){var n=e-1;return n<0&&(n=t.length-1),se(n),n})):e.key===`Tab`||e.key===`Enter`?g>=0&&g<t.length?(e.preventDefault(),te(t[g]),_(-1)):e.key===`Enter`&&ce&&(e.preventDefault(),le()):e.key===`Escape`&&(e.stopPropagation(),h(!1),_(-1))}function se(e){if(A.current){var t=A.current.children;t[e]&&t[e].scrollIntoView({block:`nearest`})}}var ce=ie()&&!S;function le(){var e=o.trim();if(!(!e||S)){var t=ee(e.endsWith(`/`)?e.slice(0,-1):e),r=u.trim()||t.split(`/`).pop()||`Untitled`;C(!0),M.current=!0,n({type:`settings:update`,settings:{projects:[{path:t,title:r}]}})}}if(!e)return null;var ue=re(),de=ae();return(0,b.jsxs)(`div`,{ref:N,className:`fixed inset-0 z-[9999] flex items-center justify-center`,role:`dialog`,"aria-modal":`true`,"aria-label":`Add Project`,children:[(0,b.jsx)(`div`,{className:`absolute inset-0 bg-base-content/50`,onClick:t}),(0,b.jsxs)(`div`,{className:`relative bg-base-200 border border-base-content/15 rounded-2xl shadow-2xl w-full max-w-3xl mx-4 overflow-hidden`,children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between px-5 py-4 border-b border-base-content/15`,children:[(0,b.jsx)(`h2`,{className:`text-[15px] font-mono font-bold text-base-content`,children:`Add Project`}),(0,b.jsx)(`button`,{onClick:t,"aria-label":`Close`,className:`btn btn-ghost btn-xs btn-square text-base-content/40 hover:text-base-content`,children:(0,b.jsx)(Nv,{size:16})})]}),(0,b.jsxs)(`div`,{className:`px-5 py-4 space-y-4`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{htmlFor:`project-path`,className:`block text-[12px] font-semibold text-base-content/40 mb-1.5`,children:`Project Path`}),(0,b.jsxs)(`div`,{className:`relative`,children:[(0,b.jsx)(`input`,{ref:k,id:`project-path`,type:`text`,value:o,onChange:function(e){s(e.target.value),h(!0),_(-1),y(null)},onFocus:F,onBlur:ne,onKeyDown:oe,placeholder:`~/projects/my-app`,autoFocus:!0,className:`w-full h-9 px-3 bg-base-300 border border-base-content/15 rounded-xl text-base-content font-mono text-[12px] focus:border-primary focus-visible:outline-none transition-colors duration-[120ms]`}),m&&ue.length>0&&(0,b.jsx)(`div`,{ref:A,className:`absolute top-full left-0 right-0 mt-1 z-50 bg-base-200 border border-base-content/15 rounded-xl shadow-lg max-h-48 overflow-y-auto`,children:ue.map(function(e,t){return(0,b.jsxs)(`button`,{onMouseDown:function(e){e.preventDefault()},onClick:function(){te(e),_(-1)},onMouseEnter:function(){_(t)},className:`w-full flex items-center gap-2 px-3 py-2 text-left text-[12px] font-mono transition-colors duration-[80ms] `+(t===g?`bg-base-content/10 text-base-content`:`text-base-content/60 hover:bg-base-content/5 hover:text-base-content`),children:[(0,b.jsx)(Wm,{size:12,className:`text-base-content/25 flex-shrink-0`}),(0,b.jsxs)(`span`,{className:`flex-1 truncate`,children:[e.name,`/`]}),e.projectName&&(0,b.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded-md bg-accent/15 text-accent/70 flex-shrink-0 truncate max-w-[100px]`,children:e.projectName}),e.hasClaudeMd&&(0,b.jsxs)(`span`,{className:`flex items-center gap-0.5 text-[10px] px-1.5 py-0.5 rounded-md bg-primary/15 text-primary/70 flex-shrink-0`,children:[(0,b.jsx)(Vm,{size:8}),`CLAUDE.md`]})]},e.path)})})]}),(0,b.jsx)(`div`,{className:`text-[10px] text-base-content/25 mt-1`,children:`Type a path or click directories to navigate`}),!o.trim()&&w.length>0&&!m&&(0,b.jsxs)(`div`,{className:`mt-2`,children:[(0,b.jsx)(`div`,{className:`text-[11px] font-semibold text-base-content/30 mb-1.5`,children:`Projects Claude has worked in`}),(0,b.jsx)(`div`,{className:`flex flex-col gap-1 max-h-48 overflow-y-auto`,children:w.map(function(e){return(0,b.jsxs)(`button`,{title:e.path,onClick:function(){s(e.path+`/`),f||d(e.name),T([]),n({type:`browse:list`,path:e.path})},className:`w-full flex items-center gap-2 px-3 py-1.5 text-left text-[12px] font-mono text-base-content/50 hover:bg-base-content/5 hover:text-base-content rounded-lg transition-colors duration-[80ms]`,children:[(0,b.jsx)(Wm,{size:12,className:`text-base-content/25 flex-shrink-0`}),(0,b.jsx)(`span`,{className:`flex-1 truncate`,children:e.path}),e.hasClaudeMd&&(0,b.jsxs)(`span`,{className:`flex items-center gap-0.5 text-[10px] px-1.5 py-0.5 rounded-md bg-primary/15 text-primary/70 flex-shrink-0`,children:[(0,b.jsx)(Vm,{size:8}),`CLAUDE.md`]})]},e.path)})})]})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsxs)(`label`,{htmlFor:`project-title`,className:`block text-[12px] font-semibold text-base-content/40 mb-1.5`,children:[`Title `,(0,b.jsx)(`span`,{className:`font-normal opacity-60`,children:`(optional)`})]}),(0,b.jsx)(`input`,{id:`project-title`,type:`text`,value:u,onChange:function(e){P(e.target.value)},placeholder:`Auto-derived from path`,className:`w-full h-9 px-3 bg-base-300 border border-base-content/15 rounded-xl text-base-content text-[13px] focus:border-primary focus-visible:outline-none transition-colors duration-[120ms]`})]}),de&&(0,b.jsx)(`div`,{className:`flex items-center gap-2 px-3 py-2 rounded-xl border text-[11px] `+(de.type===`error`?`bg-error/10 border-error/20 text-error`:de.type===`success`?`bg-success/10 border-success/20 text-success`:`bg-base-content/5 border-base-content/10 text-base-content/40`),children:de.text})]}),(0,b.jsxs)(`div`,{className:`px-5 py-3 border-t border-base-content/15 flex justify-end gap-2`,children:[(0,b.jsx)(`button`,{onClick:t,className:`btn btn-ghost btn-sm text-[12px]`,children:`Cancel`}),(0,b.jsx)(`button`,{onClick:le,disabled:!ce,className:`btn btn-primary btn-sm text-[12px]`+(ce?``:` opacity-50 cursor-not-allowed`),children:S?(0,b.jsx)(C_,{size:14,className:`animate-spin`}):`Add Project`})]})]})]})}function A1e(){var{activeProject:e}=Dy(),{nodes:t}=Ay(),n=jy();if(!e||!e.isRemote||n.activeView.type!==`chat`)return null;var r=t.find(function(t){return t.id===e.nodeId});return!r||r.online?null:(0,b.jsx)(`div`,{className:`absolute inset-0 z-40 flex items-center justify-center bg-base-100/80 backdrop-blur-sm`,children:(0,b.jsxs)(`div`,{className:`bg-base-300 border border-base-content/15 rounded-2xl shadow-2xl px-8 py-6 max-w-sm text-center`,children:[(0,b.jsx)(Av,{size:28,className:`text-warning mx-auto mb-3`}),(0,b.jsx)(`h3`,{className:`text-[15px] font-mono font-bold text-base-content mb-1`,children:`Node Disconnected`}),(0,b.jsxs)(`p`,{className:`text-[13px] text-base-content/50 mb-3`,children:[(0,b.jsx)(`span`,{className:`font-semibold text-base-content/70`,children:r.name}),` is unreachable.`]}),(0,b.jsxs)(`div`,{className:`flex items-center justify-center gap-2 text-[12px] text-base-content/40`,children:[(0,b.jsx)(C_,{size:12,className:`animate-spin`}),`Attempting to reconnect...`]}),(0,b.jsx)(`p`,{className:`text-[11px] text-base-content/25 mt-3`,children:`Session state preserved. Operations will resume on reconnect.`})]})})}var j9=15,M9=.35,j1e=.4,N9=`translate 0.25s cubic-bezier(0.4, 0, 0.2, 1)`,P9=`opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1)`,F9=`transform 0.25s cubic-bezier(0.4, 0, 0.2, 1)`;function M1e(e,t,n,r){var i=(0,x.useRef)({isOpen:t,onOpen:n,onClose:r});i.current={isOpen:t,onOpen:n,onClose:r},(0,x.useEffect)(function(){var t=0,n=0,r=0,a=0,o=0,s=!1,c=!1,l=null,u=null,d=null,f=null,p=0;function m(){var t=e.current;if(!t)return!1;u=t.querySelector(`:scope > *:not(.drawer-overlay)`),d=t.querySelector(`:scope > .drawer-overlay`);var n=t.parentElement;return n&&(f=n.querySelector(`:scope > .drawer-content`)),u&&(p=u.getBoundingClientRect().width),!!u}function h(e){if(u){var t=Math.max(-p,Math.min(0,e)),n=1+t/p;if(u.style.transition=`none`,u.style.translate=t+`px`,d&&(d.style.transition=`none`,d.style.opacity=String(n)),f){var r=1-n*.03;f.style.transition=`none`,f.style.transform=`scale(`+r+`)`,f.style.transformOrigin=`left center`}}}function g(){u&&(u.style.transition=``,u.style.translate=``),d&&(d.style.transition=``,d.style.opacity=``),f&&(f.style.transition=``,f.style.transform=``,f.style.transformOrigin=``)}function _(){u&&(u.style.transition=N9,u.style.translate=`0%`,d&&(d.style.transition=P9,d.style.opacity=`1`),f&&(f.style.transition=F9,f.style.transform=`scale(0.97)`,f.style.transformOrigin=`left center`))}function v(){u&&(u.style.transition=N9,u.style.translate=`-100%`,d&&(d.style.transition=P9,d.style.opacity=`0`),f&&(f.style.transition=F9,f.style.transform=`scale(1)`,f.style.transformOrigin=`left center`))}var y=null;function b(){y!==null&&(clearTimeout(y),y=null)}function x(){if(b(),u){var e=!1;function t(){e||(e=!0,u&&u.removeEventListener(`transitionend`,t),b(),g())}u.addEventListener(`transitionend`,t,{once:!0}),y=setTimeout(t,350)}else g()}function S(e){if(!(window.innerWidth>=1024)){var i=e.touches[0];t=i.clientX,n=i.clientY,r=i.clientX,a=Date.now(),o=0,s=!0,c=!1,l=null}}function C(u){if(s){var d=u.touches[0],f=Date.now(),g=f-a;if(g>0&&(o=(d.clientX-r)/g),r=d.clientX,a=f,l===null){var _=Math.abs(d.clientX-t),v=Math.abs(d.clientY-n);if(_>=j9||v>=j9)if(_>v){if(l=`h`,c=!0,!m()){s=!1;return}var y=e.current;y&&(y.style.visibility=`visible`,y.style.pointerEvents=`auto`,y.style.opacity=`1`)}else{l=`v`,s=!1;return}else return}if(c){var b=d.clientX-t;i.current.isOpen?h(Math.min(0,b)):h(-p+Math.max(0,b))}}}function w(){if(!s||!c){s=!1,l=null;return}var e=r-t,n=i.current.isOpen;s=!1,c=!1,l=null,(Math.abs(o)>j1e?o>0:n?e>-p*M9:e>p*M9)?(_(),n||i.current.onOpen()):(v(),n&&i.current.onClose()),x()}function T(){if(c){g();var t=e.current;t&&(t.style.visibility=``,t.style.pointerEvents=``,t.style.opacity=``),f&&(f.style.transition=``,f.style.transform=``,f.style.transformOrigin=``)}s=!1,c=!1,l=null}return document.addEventListener(`touchstart`,S,{passive:!0}),document.addEventListener(`touchmove`,C,{passive:!0}),document.addEventListener(`touchend`,w,{passive:!0}),document.addEventListener(`touchcancel`,T,{passive:!0}),function(){b(),document.removeEventListener(`touchstart`,S),document.removeEventListener(`touchmove`,C),document.removeEventListener(`touchend`,w),document.removeEventListener(`touchcancel`,T)}},[e])}function I9(){var e=R(),[t,n]=(0,x.useState)(!1),[r,i]=(0,x.useState)(!1),[a,o]=(0,x.useState)(!1),s=(0,x.useRef)(null),c=(0,x.useRef)(0);(0,x.useEffect)(function(){var e=setTimeout(function(){i(!0)},600);return function(){clearTimeout(e)}},[]),(0,x.useEffect)(function(){if(e.status!==`connected`)return;function t(){n(!0)}return e.subscribe(`projects:list`,t),function(){e.unsubscribe(`projects:list`,t)}},[e]);var l=t&&r,u=a&&e.status!==`connected`,d=l&&!u,f=!l||u;if((0,x.useEffect)(function(){if(l&&!a){var e=setTimeout(function(){o(!0)},300);return function(){clearTimeout(e)}}},[l,a]),(0,x.useEffect)(function(){var e=s.current;if(!e)return;var t=e.getContext(`2d`);if(!t)return;var n=9,r=26,i=3.5,a=20,o=a*2+(n-1)*r,l=window.devicePixelRatio||1;e.width=o*l,e.height=o*l,e.style.width=o+`px`,e.style.height=o+`px`,t.scale(l,l);for(var u=o/2,d=o/2,f=14,p=4,m=(f*2+p)/2,h=u-m,g=d-m,_=u+m,v=d+m,y=getComputedStyle(document.documentElement).getPropertyValue(`--color-primary`).trim(),b=y?`oklch(`+y+`)`:`oklch(55% 0.25 280)`,x=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,S=[],C=0;C<n;C++)for(var w=0;w<n;w++){var T=a+w*r,E=a+C*r,D=T+i>h&&T-i<_&&E+i>g&&E-i<v;S.push({x:T,y:E,col:w,row:C,hidden:D,brightness:.08})}var O=[],k=10,A=performance.now();function j(e){for(var t=S[e],r=[],i=-1;i<=1;i++)for(var a=-1;a<=1;a++)if(!(i===0&&a===0)){var o=t.row+i,s=t.col+a;if(o>=0&&o<n&&s>=0&&s<n){var c=o*n+s;S[c].hidden||r.push(c)}}return r}function M(){t.clearRect(0,0,o,o);for(var e=0;e<S.length;e++){var n=S[e];n.hidden||(t.beginPath(),t.arc(n.x,n.y,i,0,Math.PI*2),t.fillStyle=b,t.globalAlpha=.15,t.fill(),t.globalAlpha=1)}for(var r=[[h,g],[h+f+p,g],[h,g+f+p],[h+f+p,g+f+p]],a=0;a<r.length;a++)t.fillStyle=b,t.globalAlpha=.9,t.fillRect(r[a][0],r[a][1],f,f),t.globalAlpha=1}if(x){M();return}function N(){if(A=performance.now(),t.clearRect(0,0,o,o),O.length<k&&Math.random()<.04){for(var e=[],n=0;n<S.length;n++)S[n].hidden||e.push(n);for(var r=0;r<5&&O.length<k;){var a=e[Math.floor(Math.random()*e.length)],s=j(a);if(s.length>0){for(var l=s[Math.floor(Math.random()*s.length)],u=!1,d=0;d<O.length;d++)if(O[d].a===a&&O[d].b===l||O[d].a===l&&O[d].b===a){u=!0;break}if(!u){O.push({a,b:l,birth:A,duration:2e3+Math.random()*3e3,fadeIn:400,fadeOut:400});break}}r++}}for(var m=new Set,_=[],v=0;v<O.length;v++){var y=O[v],x=A-y.birth;if(!(x>y.duration)){_.push(y);var C=1;x<y.fadeIn?C=x/y.fadeIn:x>y.duration-y.fadeOut&&(C=(y.duration-x)/y.fadeOut),m.add(y.a),m.add(y.b);var w=S[y.a],T=S[y.b];t.beginPath(),t.moveTo(w.x,w.y),t.lineTo(T.x,T.y),t.strokeStyle=b,t.globalAlpha=C*.35,t.lineWidth=1.5,t.stroke(),t.globalAlpha=1}}O=_;for(var E=0;E<S.length;E++){var D=S[E];if(!D.hidden){var M=m.has(E)?.7:.08;D.brightness+=(M-D.brightness)*.08,t.beginPath(),t.arc(D.x,D.y,i,0,Math.PI*2),t.fillStyle=b,t.globalAlpha=D.brightness,t.fill(),t.globalAlpha=1}}for(var ee=.4+.2*Math.sin(A/800),te=[[h,g],[h+f+p,g],[h,g+f+p],[h+f+p,g+f+p]],P=0;P<te.length;P++){var F=te[P][0],ne=te[P][1];t.save(),t.shadowColor=b,t.shadowBlur=8+ee*6,t.fillStyle=b,t.globalAlpha=.85+ee*.15,t.fillRect(F,ne,f,f),t.restore()}c.current=requestAnimationFrame(N)}return c.current=requestAnimationFrame(N),function(){cancelAnimationFrame(c.current)}},[]),!f&&l)return null;var p=u?`Reconnecting...`:e.status===`connecting`?`Connecting...`:`Loading projects...`;return(0,b.jsx)(`div`,{className:`fixed inset-0 z-[9999] flex flex-col items-center justify-center `+(u?`bg-base-100/90`:`bg-base-100`),style:{opacity:d?0:1,transition:`opacity 300ms ease-out`,pointerEvents:d?`none`:`auto`},children:(0,b.jsxs)(`div`,{className:`flex flex-col items-center gap-7`,children:[(0,b.jsx)(`canvas`,{ref:s}),(0,b.jsxs)(`div`,{className:`flex flex-col items-center gap-2`,children:[(0,b.jsx)(`span`,{className:`text-[16px] font-mono font-bold text-base-content tracking-tight`,children:`Lattice`}),(0,b.jsx)(`span`,{className:`text-[12px] text-base-content/40`,children:p})]})]})})}function N1e(){var e=jy(),t=R(),n=e.confirmRemoveSlug,r=(0,x.useRef)(null);return Wr(r,(0,x.useCallback)(function(){e.closeConfirmRemove()},[e.closeConfirmRemove]),!!n),n?((function(){try{return fy().state}catch{return null}})(),(0,b.jsxs)(`div`,{ref:r,className:`fixed inset-0 z-[9999] flex items-center justify-center`,role:`dialog`,"aria-modal":`true`,"aria-label":`Remove Project`,children:[(0,b.jsx)(`div`,{className:`absolute inset-0 bg-base-content/50`,onClick:e.closeConfirmRemove}),(0,b.jsxs)(`div`,{className:`relative bg-base-200 border border-base-content/15 rounded-2xl shadow-2xl w-full max-w-sm mx-4 overflow-hidden`,children:[(0,b.jsx)(`div`,{className:`px-5 py-4 border-b border-base-content/15`,children:(0,b.jsx)(`h2`,{className:`text-[15px] font-mono font-bold text-base-content`,children:`Remove Project`})}),(0,b.jsx)(`div`,{className:`px-5 py-4`,children:(0,b.jsxs)(`p`,{className:`text-[13px] text-base-content/60`,children:[`Remove `,(0,b.jsx)(`span`,{className:`font-semibold text-base-content`,children:n}),` from Lattice? This won't delete any files on disk.`]})}),(0,b.jsxs)(`div`,{className:`px-5 py-3 border-t border-base-content/15 flex justify-end gap-2`,children:[(0,b.jsx)(`button`,{onClick:e.closeConfirmRemove,className:`btn btn-ghost btn-sm text-[12px]`,children:`Cancel`}),(0,b.jsx)(`button`,{onClick:function(){t.send({type:`settings:update`,settings:{removeProject:n}}),e.activeProjectSlug===n&&e.goToDashboard(),e.closeConfirmRemove()},className:`btn btn-error btn-sm text-[12px]`,children:`Remove`})]})]})]})):null}function P1e(){var[e,t]=(0,x.useState)(null),n=R();(0,x.useEffect)(function(){function e(e){e.type===`settings:data`&&t(e.config?.setupComplete===!0)}return n.subscribe(`settings:data`,e),n.status===`connected`&&n.send({type:`settings:get`}),function(){n.unsubscribe(`settings:data`,e)}},[n.status]);var r=jy(),i=(0,x.useRef)(null);return M1e(i,r.drawerOpen,yy,by),(0,x.useEffect)(function(){function e(e){e.key===`Escape`&&fy().state.sidebarMode===`settings`&&_y()}return document.addEventListener(`keydown`,e),window.addEventListener(`popstate`,vy),function(){document.removeEventListener(`keydown`,e),window.removeEventListener(`popstate`,vy)}},[]),e===null?(0,b.jsx)(I9,{}):e?(0,b.jsxs)(`div`,{className:`flex w-full h-full overflow-hidden bg-base-100`,children:[(0,b.jsx)(`a`,{href:`#main-content`,className:`sr-only focus:not-sr-only focus:fixed focus:top-2 focus:left-2 focus:z-[99999] focus:px-4 focus:py-2 focus:bg-primary focus:text-primary-content focus:rounded-lg focus:text-sm focus:font-semibold`,children:`Skip to content`}),(0,b.jsx)(I9,{}),(0,b.jsxs)(`div`,{className:`drawer lg:drawer-open h-full w-full`,children:[(0,b.jsx)(`input`,{id:`sidebar-drawer`,type:`checkbox`,className:`drawer-toggle`,checked:r.drawerOpen,readOnly:!0}),(0,b.jsxs)(`main`,{id:`main-content`,className:`drawer-content flex flex-col h-full min-w-0 overflow-hidden relative`,children:[(0,b.jsx)(Pr,{}),(0,b.jsx)(A1e,{})]}),(0,b.jsxs)(`div`,{ref:i,className:`drawer-side z-50 h-full`,children:[(0,b.jsx)(`label`,{htmlFor:`sidebar-drawer`,"aria-label":`close sidebar`,className:`drawer-overlay`,onClick:by}),(0,b.jsx)(`nav`,{"aria-label":`Sidebar navigation`,className:`h-full w-full lg:w-[284px] flex flex-col overflow-hidden`,children:(0,b.jsx)(Bve,{onSessionSelect:by})})]})]}),(0,b.jsx)(O1e,{isOpen:r.nodeSettingsOpen,onClose:r.closeNodeSettings}),(0,b.jsx)(k1e,{isOpen:r.addProjectOpen,onClose:r.closeAddProject}),(0,b.jsx)(N1e,{})]}):(0,b.jsx)(QQe,{onComplete:function(){t(!0)}})}var F1e=class extends x.Component{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error(`[lattice] View error in `+this.props.viewName+`:`,e,t.componentStack)}render(){if(this.state.hasError){var e=this;return(0,b.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full bg-base-100 bg-lattice-grid gap-4 p-8`,children:[(0,b.jsx)(Ev,{size:32,className:`text-warning/50`}),(0,b.jsxs)(`div`,{className:`text-center max-w-[500px]`,children:[(0,b.jsxs)(`p`,{className:`text-[14px] font-mono text-base-content/60 mb-1`,children:[`Error in `,this.props.viewName]}),(0,b.jsx)(`p`,{className:`text-[12px] text-base-content/30 mb-4 font-mono break-all`,children:this.state.error?.message||`Unknown error`}),(0,b.jsxs)(`button`,{onClick:function(){e.setState({hasError:!1,error:null})},className:`btn btn-ghost btn-sm text-[12px] gap-1.5`,children:[(0,b.jsx)(ov,{size:12}),`Retry`]})]})]})}return this.props.children}};function L9(){var e=jy(),t=Vb(),n=e.activeView.type,r=t.panes.find(function(e){return e.id===t.activePaneId}),i=r?t.tabs.find(function(e){return e.id===r.activeTabId}):null;i&&i.id;var a=n===`settings`?(0,b.jsx)(n1e,{}):n===`project-settings`?(0,b.jsx)(w1e,{}):n===`dashboard`?(0,b.jsx)(E1e,{}):n===`project-dashboard`?(0,b.jsx)(D1e,{}):n===`analytics`?(0,b.jsx)(jQ,{}):(0,b.jsx)(YQe,{});return(0,b.jsx)(F1e,{viewName:n,children:a})}var R9=Tr({component:P1e}),I1e=Cr({getParentRoute:function(){return R9},path:`/`,component:L9}),L1e=Cr({getParentRoute:function(){return R9},path:`/$projectSlug`,component:L9}),R1e=Cr({getParentRoute:function(){return R9},path:`/settings/$section`,component:L9}),z1e=Cr({getParentRoute:function(){return R9},path:`/settings`,component:L9}),B1e=Cr({getParentRoute:function(){return R9},path:`/$projectSlug/settings/$section`,component:L9}),V1e=Cr({getParentRoute:function(){return R9},path:`/$projectSlug/settings`,component:L9}),H1e=zr({routeTree:R9.addChildren([I1e,z1e,R1e,V1e,B1e,L1e])}),U1e=3e4,W1e=100;function G1e(e){var[t,n]=(0,x.useState)(`connecting`),r=(0,x.useRef)(null),i=(0,x.useRef)(1e3),a=(0,x.useRef)(null),o=(0,x.useRef)(!1),s=(0,x.useRef)(new Map),c=(0,x.useRef)(!1),l=(0,x.useRef)([]);function u(){if(!o.current){var e=Jge(),t=new WebSocket(e);r.current=t,n(`connecting`),t.onopen=function(){if(o.current){t.close();return}if(n(`connected`),i.current=1e3,c.current){n9(`Reconnected to daemon`,`info`),S9(`Lattice`,`Reconnected to daemon`,`connection`),t.send(JSON.stringify({type:`settings:get`}));var e=Uy().state;e.activeProjectSlug&&e.activeSessionId&&t.send(JSON.stringify({type:`session:activate`,projectSlug:e.activeProjectSlug,sessionId:e.activeSessionId}))}c.current=!0,t.send(JSON.stringify({type:`brainstorm:status_request`}));var r=l.current;l.current=[],r.forEach(function(e){t.send(JSON.stringify(e))})},t.onmessage=function(e){try{var t=JSON.parse(e.data);t.type===`chat:done`&&document.hidden&&S9(`Claude responded`,Uy().state.activeSessionTitle||`Session`,`chat-done`),t.type===`mesh:node_online`&&S9(`Lattice`,t.nodeId+` came online`,`mesh`),t.type===`mesh:node_offline`&&S9(`Lattice`,t.nodeId+` went offline`,`mesh`);var n=s.current.get(t.type);n&&n.forEach(function(e){e(t)})}catch(e){console.warn(`[lattice] Failed to parse WebSocket message:`,e)}},t.onclose=function(){o.current||(n(`disconnected`),r.current=null,c.current&&(n9(`Disconnected from daemon. Reconnecting automatically...`,`warning`),S9(`Lattice`,`Lost connection to daemon`,`connection`)),d())},t.onerror=function(){t.close()}}}function d(){if(!o.current){var e=i.current;a.current=setTimeout(function(){i.current=Math.min(i.current*2,U1e),u()},e)}}function f(){a.current!==null&&(clearTimeout(a.current),a.current=null),i.current=1e3,r.current&&=(r.current.close(),null),u()}function p(e){var t=r.current;t&&t.readyState===WebSocket.OPEN?t.send(JSON.stringify(e)):(l.current.length>=W1e&&l.current.shift(),l.current.push(e))}function m(e,t){var n=s.current.get(e);n||(n=new Set,s.current.set(e,n)),n.add(t)}function h(e,t){var n=s.current.get(e);n&&(n.delete(t),n.size===0&&s.current.delete(e))}return(0,x.useEffect)(function(){function e(){Wv(`brainstorm`)}function t(e){e.type===`brainstorm:status`&&e.active&&Wv(`brainstorm`)}m(`brainstorm:content`,e),m(`brainstorm:status`,t);var n=Qge(function(e){e.type===`brainstorm`&&p({type:`brainstorm:stop`})});return function(){h(`brainstorm:content`,e),h(`brainstorm:status`,t),n()}},[]),(0,x.useEffect)(function(){return o.current=!1,u(),function(){o.current=!0,a.current!==null&&(clearTimeout(a.current),a.current=null),r.current&&=(r.current.close(),null)}},[]),(0,b.jsx)(Lv.Provider,{value:{status:t,send:p,subscribe:m,unsubscribe:h,reconnectNow:f},children:e.children})}var K1e=class extends x.Component{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error(`[lattice] Render error:`,e,t.componentStack)}handleReload(){window.location.reload()}render(){return this.state.hasError?this.props.fallback?this.props.fallback:(0,b.jsx)(`div`,{className:`min-h-screen bg-base-100 flex items-center justify-center`,children:(0,b.jsxs)(`div`,{className:`text-center max-w-[400px] p-8`,children:[(0,b.jsx)(`h2`,{className:`text-[20px] font-semibold text-error mb-3`,children:`Something went wrong`}),(0,b.jsx)(`p`,{className:`text-[14px] text-base-content/60 mb-5`,children:this.state.error?.message||`An unexpected error occurred.`}),(0,b.jsx)(`button`,{onClick:this.handleReload,className:`btn btn-primary btn-sm`,children:`Reload`})]})}):this.props.children}},q1e=(0,x.createContext)(null);function J1e(){return(0,x.useContext)(q1e)?.defaultOptions??{}}function z9(){if(typeof navigator>`u`)return`linux`;let e=navigator.platform?.toLowerCase()??``,t=navigator.userAgent?.toLowerCase()??``;return e.includes(`mac`)||t.includes(`mac`)?`mac`:e.includes(`win`)||t.includes(`win`)?`windows`:`linux`}var B9=[`Control`,`Alt`,`Shift`,`Meta`];new Set(B9);var V9={Control:`Control`,Ctrl:`Control`,control:`Control`,ctrl:`Control`,Shift:`Shift`,shift:`Shift`,Alt:`Alt`,Option:`Alt`,alt:`Alt`,option:`Alt`,Command:`Meta`,Cmd:`Meta`,Meta:`Meta`,command:`Meta`,cmd:`Meta`,meta:`Meta`,CommandOrControl:`Mod`,Mod:`Mod`,commandorcontrol:`Mod`,mod:`Mod`};function H9(e,t=z9()){return e===`Mod`?t===`mac`?`Meta`:`Control`:e}var Y1e=new Set(`ABCDEFGHIJKLMNOPQRSTUVWXYZ`.split(``)),X1e=new Set([`0`,`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`]),Z1e=new Set([`F1`,`F2`,`F3`,`F4`,`F5`,`F6`,`F7`,`F8`,`F9`,`F10`,`F11`,`F12`]),Q1e=new Set([`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`Home`,`End`,`PageUp`,`PageDown`]),$1e=new Set([`Enter`,`Escape`,`Space`,`Tab`,`Backspace`,`Delete`]),e0e=new Set([`/`,`[`,`]`,`\\`,`=`,`-`,`,`,`.`,`;`,"`"]),U9={Minus:`-`,Equal:`=`,Slash:`/`,BracketLeft:`[`,BracketRight:`]`,Backslash:`\\`,Comma:`,`,Period:`.`,Backquote:"`",Semicolon:`;`};new Set([...Y1e,...X1e,...Z1e,...Q1e,...$1e,...e0e]);var W9={Esc:`Escape`,esc:`Escape`,escape:`Escape`,Return:`Enter`,return:`Enter`,enter:`Enter`," ":`Space`,space:`Space`,Spacebar:`Space`,spacebar:`Space`,tab:`Tab`,backspace:`Backspace`,Del:`Delete`,del:`Delete`,delete:`Delete`,Up:`ArrowUp`,up:`ArrowUp`,arrowup:`ArrowUp`,Down:`ArrowDown`,down:`ArrowDown`,arrowdown:`ArrowDown`,Left:`ArrowLeft`,left:`ArrowLeft`,arrowleft:`ArrowLeft`,Right:`ArrowRight`,right:`ArrowRight`,arrowright:`ArrowRight`,home:`Home`,end:`End`,pageup:`PageUp`,pagedown:`PageDown`,PgUp:`PageUp`,PgDn:`PageDown`,pgup:`PageUp`,pgdn:`PageDown`};function G9(e){return/^\p{Letter}$/u.test(e)}function K9(e){if(e in W9)return W9[e];if(G9(e)){let t=e.toUpperCase();return t.length===1?t:e}let t=e.toUpperCase();return/^F([1-9]|1[0-2])$/.test(t)?t:e}function q9(e,t=z9()){let n=e.split(`+`),r=new Set,i=``;for(let e=0;e<n.length;e++){let a=n[e].trim();if(e===n.length-1)i=K9(a);else{let e=V9[a]??V9[a.toLowerCase()];if(e){let n=H9(e,t);r.add(n)}else n.length===1&&(i=K9(a))}}return!i&&n.length>0&&(i=K9(n[n.length-1].trim())),{key:i,ctrl:r.has(`Control`),shift:r.has(`Shift`),alt:r.has(`Alt`),meta:r.has(`Meta`),modifiers:B9.filter(e=>r.has(e))}}function J9(e,t=z9()){let n=e.ctrl??!1,r=e.shift??!1,i=e.alt??!1,a=e.meta??!1;e.mod&&(H9(`Mod`,t)===`Control`?n=!0:a=!0);let o=B9.filter(e=>{switch(e){case`Control`:return n;case`Shift`:return r;case`Alt`:return i;case`Meta`:return a;default:return!1}});return{key:e.key,ctrl:n,shift:r,alt:i,meta:a,modifiers:o}}function Y9(e){let t=[];for(let n of B9)e.modifiers.includes(n)&&t.push(n);return t.push(e.key),t.join(`+`)}function X9(e,t,n=z9()){let r=typeof t==`string`?q9(t,n):t;if(e.ctrlKey!==r.ctrl||e.shiftKey!==r.shift||e.altKey!==r.alt||e.metaKey!==r.meta)return!1;let i=K9(e.key),a=r.key;if(i!==`Dead`&&i.length===1&&a.length===1){if(i.toUpperCase()===a.toUpperCase())return!0;if(G9(i)&&(/^[A-Za-z]$/.test(i)||!e.altKey))return!1}if(e.code&&(i===`Dead`||i.length===1&&a.length===1)){if(e.code.startsWith(`Key`)){let t=e.code.slice(3);if(t.length===1&&/^[A-Za-z]$/.test(t))return t.toUpperCase()===a.toUpperCase()}if(e.code.startsWith(`Digit`)){let t=e.code.slice(5);if(t.length===1&&/^[0-9]$/.test(t))return t===a}return e.code in U9?U9[e.code]===a:!1}return i===a}var t0e={preventDefault:!0,stopPropagation:!0,eventType:`keydown`,enabled:!0,ignoreInputs:!0,conflictBehavior:`warn`};function n0e(e){return!(e.ctrl||e.meta||e.key===`Escape`)}function r0e(e){if(!e)return!1;if(e instanceof HTMLInputElement){let t=e.type.toLowerCase();return!(t===`button`||t===`submit`||t===`reset`)}return!!(e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement||e instanceof HTMLElement&&e.isContentEditable)}function i0e(e,t){return t===document||t===window?e.currentTarget===t||e.currentTarget===document.documentElement:t===window?e.currentTarget===window||e.currentTarget===document||e.currentTarget===document.documentElement:!!(t instanceof HTMLElement&&(e.currentTarget===t||e.target instanceof Node&&t.contains(e.target)))}function a0e(e,t,n,r){if(n!==`allow`){if(n===`warn`){console.warn(`'${t}' is already registered. Multiple handlers will be triggered. Use conflictBehavior: 'replace' to replace the existing handler, or conflictBehavior: 'allow' to suppress this warning.`);return}if(n===`error`)throw Error(`'${t}' is already registered. Use conflictBehavior: 'replace' to replace the existing handler, or conflictBehavior: 'allow' to allow multiple registrations.`);r(e)}}var o0e=0;function Z9(){return`hotkey_${++o0e}`}var s0e=class e{static#e=null;#t;#n=new Map;#r=new Map;constructor(){this.registrations=new Gn(new Map),this.#t=z9()}static getInstance(){return e.#e||=new e,e.#e}static resetInstance(){e.#e&&=(e.#e.destroy(),null)}register(e,t,n={}){if(typeof document>`u`&&!n.target){let e=t;return{id:Z9(),unregister:()=>{},get callback(){return e},set callback(t){e=t},setOptions:()=>{},get isActive(){return!1}}}let r=Z9(),i=n.platform??this.#t,a=typeof e==`string`?q9(e,i):J9(e,i),o=typeof e==`string`?e:Y9(a),s=n.target??document,c=n.conflictBehavior??`warn`,l=this.#d(o,s);l&&a0e(l.id,o,c,e=>this.#i(e));let u=n.ignoreInputs??n0e(a),d={id:r,hotkey:o,parsedHotkey:a,callback:t,options:{...t0e,requireReset:!1,...n,platform:i,ignoreInputs:u},hasFired:!1,triggerCount:0,target:s};this.registrations.setState(e=>new Map(e).set(r,d)),this.#r.has(s)||this.#r.set(s,new Set),this.#r.get(s).add(r),this.#a(s);let f=this;return{get id(){return r},unregister:()=>{f.#i(r)},get callback(){return f.registrations.state.get(r)?.callback??t},set callback(e){let t=f.registrations.state.get(r);t&&(t.callback=e)},setOptions:e=>{f.registrations.setState(t=>{let n=t.get(r);if(n){let i=new Map(t);return i.set(r,{...n,options:{...n.options,...e}}),i}return t})},get isActive(){return f.registrations.state.has(r)}}}#i(e){let t=this.registrations.state.get(e);if(!t)return;let n=t.target;this.registrations.setState(t=>{let n=new Map(t);return n.delete(e),n});let r=this.#r.get(n);r&&(r.delete(e),r.size===0&&this.#o(n))}#a(e){if(typeof document>`u`||this.#n.has(e))return;let t=this.#l(e),n=this.#u(e);e.addEventListener(`keydown`,t),e.addEventListener(`keyup`,n),this.#n.set(e,{keydown:t,keyup:n})}#o(e){if(typeof document>`u`)return;let t=this.#n.get(e);t&&(e.removeEventListener(`keydown`,t.keydown),e.removeEventListener(`keyup`,t.keyup),this.#n.delete(e),this.#r.delete(e))}#s(e,t,n){let r=this.#r.get(t);if(r)for(let i of r){let r=this.registrations.state.get(i);if(r&&i0e(e,t)&&r.options.enabled&&!(r.options.ignoreInputs!==!1&&r0e(e.target)&&e.target!==r.target))if(n===`keydown`){if(r.options.eventType!==`keydown`)continue;X9(e,r.parsedHotkey,r.options.platform)&&(r.options.preventDefault&&e.preventDefault(),r.options.stopPropagation&&e.stopPropagation(),(!r.options.requireReset||!r.hasFired)&&(this.#c(r,e),r.options.requireReset&&(r.hasFired=!0)))}else r.options.eventType===`keyup`&&X9(e,r.parsedHotkey,r.options.platform)&&this.#c(r,e),r.options.requireReset&&r.hasFired&&this.#f(r,e)&&(r.hasFired=!1)}}#c(e,t){e.options.preventDefault&&t.preventDefault(),e.options.stopPropagation&&t.stopPropagation(),e.triggerCount++,this.registrations.setState(e=>new Map(e));let n={hotkey:e.hotkey,parsedHotkey:e.parsedHotkey};e.callback(t,n)}#l(e){return t=>{this.#s(t,e,`keydown`)}}#u(e){return t=>{this.#s(t,e,`keyup`)}}#d(e,t){for(let n of this.registrations.state.values())if(n.hotkey===e&&n.target===t)return n;return null}#f(e,t){let n=e.parsedHotkey,r=K9(t.key),i=n.key.length===1?n.key.toUpperCase():n.key;return!!((r.length===1?r.toUpperCase():r)===i||n.ctrl&&r===`Control`||n.shift&&r===`Shift`||n.alt&&r===`Alt`||n.meta&&r===`Meta`)}triggerRegistration(e){let t=this.registrations.state.get(e);if(!t)return!1;let n=t.parsedHotkey,r=new KeyboardEvent(t.options.eventType??`keydown`,{key:n.key,ctrlKey:n.ctrl,shiftKey:n.shift,altKey:n.alt,metaKey:n.meta,bubbles:!0,cancelable:!0});return t.triggerCount++,this.registrations.setState(e=>new Map(e)),t.callback(r,{hotkey:t.hotkey,parsedHotkey:t.parsedHotkey}),!0}getRegistrationCount(){return this.registrations.state.size}isRegistered(e,t){for(let n of this.registrations.state.values())if(n.hotkey===e&&(t===void 0||n.target===t))return!0;return!1}destroy(){for(let e of this.#n.keys())this.#o(e);this.registrations.setState(()=>new Map),this.#n.clear(),this.#r.clear()}};function c0e(){return s0e.getInstance()}function Q9(e,t,n={}){let r={...J1e().hotkey,...n},i=c0e(),a=(0,x.useRef)(null),o=(0,x.useRef)(t),s=(0,x.useRef)(r),c=(0,x.useRef)(i);o.current=t,s.current=r,c.current=i;let l=(0,x.useRef)(null),u=(0,x.useRef)(null),d=r.platform??z9(),f=typeof e==`string`?e:Y9(J9(e,d)),{target:p,...m}=r;(0,x.useEffect)(()=>{let e=l0e(s.current.target)?s.current.target.current:s.current.target??(typeof document<`u`?document:null);if(!e)return;let t=l.current!==null&&l.current!==e,n=u.current!==null&&u.current!==f;return a.current?.isActive&&(t||n)&&(a.current.unregister(),a.current=null),(!a.current||!a.current.isActive)&&(a.current=c.current.register(f,o.current,{...s.current,target:e})),l.current=e,u.current=f,()=>{a.current?.isActive&&(a.current.unregister(),a.current=null)}},[f,n.enabled]),a.current?.isActive&&(a.current.callback=t,a.current.setOptions(m))}function l0e(e){return typeof e==`object`&&!!e&&`current`in e}function u0e(){var[e,t]=(0,x.useState)(!1),[n,r]=(0,x.useState)(``),[i,a]=(0,x.useState)(0),o=(0,x.useRef)(null),s=(0,x.useRef)(null),{projects:c,setActiveProject:l}=Dy(),u=MT(),{mode:d,toggleMode:f,allThemes:p,setTheme:m,currentThemeId:h}=Mb(),g=R(),_=jy(),v=(0,x.useCallback)(function(){t(!1),r(``),a(0)},[]);Q9(`Mod+K`,function(e){e.preventDefault(),t(function(e){return e&&(r(``),a(0)),!e})}),Q9(`Escape`,function(e){e.preventDefault(),v()},{enabled:e}),(0,x.useEffect)(function(){e&&o.current&&o.current.focus()},[e]);var y=(0,x.useMemo)(function(){var e=[];e.push({id:`nav:dashboard`,label:`Go to Dashboard`,group:`Navigation`,icon:(0,b.jsx)(Q_,{size:14}),action:function(){_.goToDashboard(),v()},keywords:`home overview`}),c.forEach(function(t){e.push({id:`project:`+t.slug,label:t.title||t.slug,description:t.path,group:`Projects`,icon:(0,b.jsx)(Wm,{size:14}),action:function(){l(t),v()},keywords:`switch project `+t.slug})});var t=Uy().state;t.activeProjectSlug&&e.push({id:`session:new`,label:`New Session`,group:`Session`,icon:(0,b.jsx)(U_,{size:14}),action:function(){g.send({type:`session:create`,projectSlug:t.activeProjectSlug}),v()},keywords:`create chat conversation`}),[{id:`appearance`,label:`Appearance`,keywords:`theme visual colors`},{id:`claude`,label:`Claude Settings`,keywords:`api model key`},{id:`environment`,label:`Environment`,keywords:`env variables config`},{id:`mcp`,label:`MCP Servers`,keywords:`model context protocol`},{id:`skills`,label:`Skills`,keywords:`capabilities commands`},{id:`nodes`,label:`Mesh Nodes`,keywords:`machines network`}].forEach(function(t){e.push({id:`settings:`+t.id,label:t.label,group:`Settings`,icon:(0,b.jsx)(hv,{size:14}),action:function(){_.openSettings(t.id),v()},keywords:t.keywords})}),e.push({id:`theme:toggle`,label:d===`dark`?`Switch to Light Mode`:`Switch to Dark Mode`,group:`Theme`,icon:d===`dark`?(0,b.jsx)(Sv,{size:14}):(0,b.jsx)(q_,{size:14}),action:function(){f(),v()},keywords:`dark light mode toggle`});var n=d===`dark`?`dark`:`light`;return p.filter(function(e){return e.theme.variant===n}).forEach(function(t){t.id!==h&&e.push({id:`theme:`+t.id,label:t.theme.name,group:`Theme`,icon:d===`dark`?(0,b.jsx)(q_,{size:14}):(0,b.jsx)(Sv,{size:14}),action:function(){m(t.id),v()},keywords:`color scheme `+t.theme.name})}),u.forEach(function(t){e.push({id:`skill:`+t.name,label:`/`+t.name,description:t.description,group:`Skills`,icon:(0,b.jsx)(Pv,{size:14}),action:function(){var e=document.querySelector(`textarea[aria-label='Message input']`);e&&(e.value=`/`+t.name+` `,e.focus(),e.dispatchEvent(new Event(`input`,{bubbles:!0}))),v()},keywords:t.description})}),e.push({id:`system:restart`,label:`Restart Daemon`,group:`System`,icon:(0,b.jsx)(sv,{size:14}),action:function(){g.send({type:`settings:restart`}),v()},keywords:`reboot server`}),e},[c,u,d,p,h,_,g,v,l,f,m]),S=(0,x.useMemo)(function(){if(!n.trim())return y;var e=n.toLowerCase();return y.filter(function(t){for(var n=(t.label+` `+(t.description||``)+` `+(t.keywords||``)+` `+t.group).toLowerCase(),r=e.split(/\s+/),i=0;i<r.length;i++)if(!n.includes(r[i]))return!1;return!0})},[n,y]);(0,x.useEffect)(function(){a(0)},[S.length,n]),(0,x.useEffect)(function(){if(s.current){var e=s.current.querySelector(`[data-active='true']`);e&&e.scrollIntoView({block:`nearest`})}},[i]);function C(e){e.key===`ArrowDown`?(e.preventDefault(),a(function(e){return e<S.length-1?e+1:0})):e.key===`ArrowUp`?(e.preventDefault(),a(function(e){return e>0?e-1:S.length-1})):e.key===`Enter`&&(e.preventDefault(),S[i]&&S[i].action())}var w=(0,x.useMemo)(function(){var e=[],t=new Map,n=0;return S.forEach(function(r){var i=t.get(r.group);i||(i=[],t.set(r.group,i),e.push({name:r.group,items:i})),i.push(Object.assign({},r,{globalIndex:n})),n++}),e},[S]);return e?(0,b.jsxs)(`div`,{className:`fixed inset-0 z-[9998] flex items-start justify-center pt-[15vh]`,onClick:v,children:[(0,b.jsx)(`div`,{className:`absolute inset-0 bg-base-content/50`}),(0,b.jsxs)(`div`,{className:`relative w-full max-w-[520px] mx-4 bg-base-200 border border-base-content/10 rounded-xl shadow-2xl overflow-hidden`,onClick:function(e){e.stopPropagation()},children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-3 border-b border-base-content/10`,children:[(0,b.jsx)(dv,{size:16,className:`text-base-content/30 flex-shrink-0`}),(0,b.jsx)(`input`,{ref:o,type:`text`,value:n,onChange:function(e){r(e.target.value)},onKeyDown:C,placeholder:`Type a command...`,className:`flex-1 bg-transparent text-[14px] text-base-content outline-none placeholder:text-base-content/30`}),(0,b.jsx)(`kbd`,{className:`text-[10px] font-mono text-base-content/20 bg-base-300 px-1.5 py-0.5 rounded`,children:`ESC`})]}),(0,b.jsxs)(`div`,{ref:s,className:`max-h-[360px] overflow-y-auto py-1.5`,children:[w.length===0&&(0,b.jsx)(`div`,{className:`px-4 py-8 text-center text-[13px] text-base-content/30`,children:`No commands found`}),w.map(function(e){return(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`px-4 pt-2 pb-1`,children:(0,b.jsx)(`span`,{className:`text-[9px] uppercase tracking-widest text-base-content/30 font-mono font-bold`,children:e.name})}),e.items.map(function(e){var t=e.globalIndex===i;return(0,b.jsxs)(`button`,{"data-active":t,onMouseEnter:function(){a(e.globalIndex)},onMouseDown:function(e){e.preventDefault()},onClick:function(){e.action()},className:`flex w-full items-center gap-3 px-4 py-2 text-left transition-colors `+(t?`bg-primary/10`:`hover:bg-base-content/5`),children:[(0,b.jsx)(`div`,{className:`flex-shrink-0 `+(t?`text-primary`:`text-base-content/30`),children:e.icon}),(0,b.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,b.jsx)(`div`,{className:`text-[13px] truncate `+(t?`text-base-content`:`text-base-content/70`),children:e.label}),e.description&&(0,b.jsx)(`div`,{className:`text-[11px] text-base-content/30 truncate`,children:e.description})]})]},e.id)})]},e.name)})]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-2 border-t border-base-content/10 text-[10px] text-base-content/25 font-mono`,children:[(0,b.jsx)(`span`,{children:`↑↓ navigate`}),(0,b.jsx)(`span`,{children:`↵ select`}),(0,b.jsx)(`span`,{children:`esc close`})]})]})]}):null}var d0e=[{name:`Chat`,shortcuts:[{keys:[`Enter`],description:`Send message`},{keys:[`Shift`,`Enter`],description:`New line`},{keys:[`↑`],description:`Previous input history`},{keys:[`↓`],description:`Next input history`},{keys:[`/`],description:`Slash commands`},{keys:[`Escape`],description:`Close autocomplete`}]},{name:`Navigation`,shortcuts:[{keys:[typeof navigator<`u`&&navigator.platform.indexOf(`Mac`)!==-1?`⌘`:`Ctrl`,`K`],description:`Command palette`},{keys:[`?`],description:`Keyboard shortcuts`},{keys:[`Escape`],description:`Close modal / exit settings`}]},{name:`Session`,shortcuts:[{keys:[`/clear`],description:`New session`},{keys:[`/copy`],description:`Copy last response`},{keys:[`/export`],description:`Export conversation`},{keys:[`/rename`],description:`Rename session`}]}];function $9(e){return(0,b.jsx)(`kbd`,{className:`bg-base-300 border border-base-content/20 rounded px-1.5 py-0.5 text-[11px] font-mono text-base-content/70 leading-none inline-flex items-center justify-center min-w-[22px]`,children:e.children})}function f0e(){var[e,t]=(0,x.useState)(!1);return(0,x.useEffect)(function(){function n(n){if(n.key===`?`&&!n.ctrlKey&&!n.metaKey&&!n.altKey){var r=n.target.tagName;if(r===`INPUT`||r===`TEXTAREA`||n.target.isContentEditable)return;n.preventDefault(),t(!0)}n.key===`Escape`&&e&&t(!1)}return document.addEventListener(`keydown`,n),function(){document.removeEventListener(`keydown`,n)}},[e]),e?(0,b.jsxs)(`div`,{className:`fixed inset-0 z-[9998] flex items-center justify-center`,onClick:function(){t(!1)},children:[(0,b.jsx)(`div`,{className:`absolute inset-0 bg-base-content/50`}),(0,b.jsxs)(`div`,{className:`relative w-full max-w-[540px] mx-4 bg-base-200 border border-base-content/15 rounded-2xl shadow-xl overflow-hidden`,onClick:function(e){e.stopPropagation()},children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between px-5 py-3.5 border-b border-base-content/10`,children:[(0,b.jsx)(`h2`,{className:`text-[14px] font-mono font-bold text-base-content tracking-tight`,children:`Keyboard Shortcuts`}),(0,b.jsx)(`button`,{onClick:function(){t(!1)},className:`w-6 h-6 rounded flex items-center justify-center text-base-content/30 hover:text-base-content/60 transition-colors`,children:(0,b.jsx)(Nv,{size:14})})]}),(0,b.jsx)(`div`,{className:`px-5 py-4 max-h-[70vh] overflow-y-auto`,children:(0,b.jsx)(`div`,{className:`flex flex-col gap-5`,children:d0e.map(function(e){return(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-[9px] uppercase tracking-widest text-base-content/30 font-mono font-bold mb-2`,children:e.name}),(0,b.jsx)(`div`,{className:`flex flex-col gap-1`,children:e.shortcuts.map(function(e,t){return(0,b.jsxs)(`div`,{className:`flex items-center justify-between py-1.5 px-2 rounded hover:bg-base-content/5 transition-colors`,children:[(0,b.jsx)(`span`,{className:`text-[13px] text-base-content/60`,children:e.description}),(0,b.jsx)(`div`,{className:`flex items-center gap-1 flex-shrink-0 ml-4`,children:e.keys.map(function(e,t){return(0,b.jsxs)(`span`,{className:`flex items-center gap-1`,children:[t>0&&(0,b.jsx)(`span`,{className:`text-[10px] text-base-content/20`,children:`+`}),(0,b.jsx)($9,{children:e})]},t)})})]},t)})})]},e.name)})})}),(0,b.jsx)(`div`,{className:`px-5 py-2.5 border-t border-base-content/10 flex justify-end`,children:(0,b.jsxs)(`span`,{className:`text-[10px] font-mono text-base-content/20`,children:[`Press `,(0,b.jsx)($9,{children:`Esc`}),` to close`]})})]})]}):null}function p0e(){var[e,t]=(0,x.useState)(!1),[n,r]=(0,x.useState)(null);(0,x.useEffect)(function(){`serviceWorker`in navigator&&navigator.serviceWorker.ready.then(function(e){e.addEventListener(`updatefound`,function(){var n=e.installing;if(n){var i=n;i.addEventListener(`statechange`,function(){i.state===`installed`&&navigator.serviceWorker.controller&&(r(e),t(!0))})}})})},[]);function i(){n&&n.waiting&&n.waiting.postMessage({type:`SKIP_WAITING`}),window.location.reload()}return e?(0,b.jsxs)(`div`,{className:`fixed bottom-4 right-4 z-[9998] bg-base-300 border border-base-content/15 rounded-xl shadow-2xl px-4 py-3 flex items-center gap-3 max-w-sm`,children:[(0,b.jsx)(ov,{size:16,className:`text-primary flex-shrink-0`}),(0,b.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,b.jsx)(`div`,{className:`text-[13px] text-base-content font-semibold`,children:`Update available`}),(0,b.jsx)(`div`,{className:`text-[11px] text-base-content/40`,children:`A new version of Lattice is ready.`})]}),(0,b.jsx)(`button`,{onClick:i,className:`btn btn-primary btn-xs`,children:`Reload`})]}):null}function m0e(){var e=R();(0,x.useEffect)(function(){function t(e){e.type===`theme:custom_list`&&Sve((e.themes||[]).map(function(e){return{id:`custom:`+e.filename,theme:{name:e.name,author:e.author,variant:e.variant,...e.colors}}}))}function n(t){(t.type===`theme:saved`||t.type===`theme:deleted`)&&e.send({type:`theme:list_custom`})}return e.subscribe(`theme:custom_list`,t),e.subscribe(`theme:saved`,n),e.subscribe(`theme:deleted`,n),function(){e.unsubscribe(`theme:custom_list`,t),e.unsubscribe(`theme:saved`,n),e.unsubscribe(`theme:deleted`,n)}},[])}function h0e(){var{items:e,dismiss:t}=_$e();return m0e(),(0,x.useEffect)(function(){function e(e){e.target.closest(`[data-allow-context-menu]`)||e.preventDefault()}return document.addEventListener(`contextmenu`,e),function(){document.removeEventListener(`contextmenu`,e)}},[]),(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(Hr,{router:H1e}),(0,b.jsx)(u0e,{}),(0,b.jsx)(f0e,{}),(0,b.jsx)(g$e,{items:e,onDismiss:t}),(0,b.jsx)(p0e,{})]})}function g0e(){return(0,b.jsx)(K1e,{children:(0,b.jsx)(G1e,{children:(0,b.jsx)(h0e,{})})})}typeof crypto<`u`&&!crypto.randomUUID&&(crypto.randomUUID=function(){return`10000000-1000-4000-8000-100000000000`.replace(/[018]/g,function(e){var t=Number(e);return(t^crypto.getRandomValues(new Uint8Array(1))[0]&15>>t/4).toString(16)})}),(0,S.createRoot)(document.getElementById(`root`)).render((0,b.jsx)(x.StrictMode,{children:(0,b.jsx)(g0e,{})}));export{Fx as a,$b as c,Px as i,s as l,ww as n,jx as o,Ix as r,tx as s,$N as t};
658
+ `+r}function P$e({memory:e,onClick:t,onDelete:n}){var[r,i]=(0,x.useState)(!1);return(0,b.jsxs)(`div`,{onClick:t,className:`flex items-start gap-3 px-3 py-2.5 bg-base-300 border border-base-content/15 rounded-xl transition-colors duration-[120ms] cursor-pointer hover:border-base-content/30 hover:bg-base-300/80`,role:`button`,tabIndex:0,onKeyDown:function(e){(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),t())},children:[(0,b.jsx)(uc,{size:14,className:`text-base-content/25 mt-0.5 flex-shrink-0`}),(0,b.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(`span`,{className:`text-[13px] font-bold text-base-content truncate`,children:e.name||e.filename}),(0,b.jsx)(`span`,{className:`shrink-0 text-[10px] font-mono px-1.5 py-0.5 rounded-md bg-base-content/8 text-base-content/40`,children:e.type})]}),e.description&&(0,b.jsx)(`div`,{className:`text-[12px] text-base-content/40 mt-0.5 line-clamp-2`,children:e.description})]}),(0,b.jsx)(`div`,{className:`flex gap-1 flex-shrink-0 mt-0.5`,onClick:function(e){e.stopPropagation()},children:r?(0,b.jsxs)(`div`,{className:`flex gap-1`,children:[(0,b.jsx)(`button`,{onClick:function(){n(),i(!1)},className:`btn btn-error btn-xs`,children:`Delete`}),(0,b.jsx)(`button`,{onClick:function(){i(!1)},className:`btn btn-ghost btn-xs`,children:`Cancel`})]}):(0,b.jsx)(`button`,{onClick:function(){i(!0)},"aria-label":`Delete `+e.name,className:`btn btn-ghost btn-xs btn-square text-base-content/30 hover:text-error focus-visible:ring-2 focus-visible:ring-primary`,children:(0,b.jsx)(Tv,{size:12})})})]})}function F$e({memory:e,content:t,onClose:n,onEdit:r}){var i=_9(t),a=Object.keys(i.meta).length>0,o=(0,x.useRef)(null);return Wr(o,(0,x.useCallback)(function(){n()},[n])),(0,b.jsxs)(`div`,{ref:o,className:`fixed inset-0 z-[9999] flex items-center justify-center`,role:`dialog`,"aria-modal":`true`,"aria-label":`Memory: `+(i.meta.name||e.filename),children:[(0,b.jsx)(`div`,{className:`absolute inset-0 bg-base-content/50`,onClick:n}),(0,b.jsxs)(`div`,{className:`relative bg-base-200 border border-base-content/15 rounded-2xl shadow-2xl w-full max-w-2xl mx-4 max-h-[80vh] flex flex-col overflow-hidden`,children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between px-5 py-4 border-b border-base-content/15 flex-shrink-0`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,b.jsx)(uc,{size:16,className:`text-primary flex-shrink-0`}),(0,b.jsx)(`h2`,{className:`text-[15px] font-mono font-bold text-base-content truncate`,children:i.meta.name||e.filename})]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,b.jsxs)(`button`,{onClick:r,className:`btn btn-ghost btn-xs gap-1.5 text-base-content/50 hover:text-base-content`,children:[(0,b.jsx)($_,{size:12}),`Edit`]}),(0,b.jsx)(`button`,{onClick:n,"aria-label":`Close`,className:`btn btn-ghost btn-xs btn-square text-base-content/40 hover:text-base-content`,children:(0,b.jsx)(Nv,{size:16})})]})]}),(0,b.jsxs)(`div`,{className:`overflow-y-auto flex-1`,children:[a&&(0,b.jsx)(`div`,{className:`px-5 py-3 border-b border-base-content/10 bg-base-300/30`,children:(0,b.jsx)(`div`,{className:`flex flex-wrap gap-x-6 gap-y-1.5`,children:Object.entries(i.meta).map(function([e,t]){return(0,b.jsxs)(`div`,{className:`flex items-baseline gap-1.5`,children:[(0,b.jsx)(`span`,{className:`text-[11px] font-mono text-base-content/35 uppercase tracking-wider`,children:e}),(0,b.jsx)(`span`,{className:`text-[12px] text-base-content/70`,children:t})]},e)})})}),(0,b.jsx)(`div`,{className:`px-5 py-4`,children:(0,b.jsx)(`div`,{className:`prose prose-sm max-w-none prose-headings:text-base-content prose-headings:font-mono prose-p:text-base-content/70 prose-strong:text-base-content prose-code:text-base-content/60 prose-code:bg-base-100/50 prose-code:px-1 prose-code:py-0.5 prose-code:rounded prose-code:text-[11px] prose-pre:bg-base-100 prose-pre:text-base-content/70 prose-pre:text-[11px] prose-a:text-primary prose-li:text-base-content/70 prose-li:marker:text-base-content/30 [&>*:first-child]:mt-0 [&>*:last-child]:mb-0`,children:(0,b.jsx)(Cw,{remarkPlugins:[hT],children:i.body})})})]}),(0,b.jsx)(`div`,{className:`px-5 py-3 border-t border-base-content/15 flex-shrink-0`,children:(0,b.jsx)(`div`,{className:`text-[11px] font-mono text-base-content/30 truncate`,children:e.filename})})]})]})}function I$e({memory:e,initialContent:t,onClose:n,onSave:r,isSaving:i}){var a=e===null,o=_9(t),[s,c]=(0,x.useState)(o.meta.name||(e?e.name:``)),[l,u]=(0,x.useState)(o.meta.description||(e?e.description:``)),[d,f]=(0,x.useState)(o.meta.type||(e?e.type:`project`)),[p,m]=(0,x.useState)(o.body),h=(0,x.useRef)(null);Wr(h,(0,x.useCallback)(function(){n()},[n]));function g(){var t=N$e(s,l,d,p);r(a?M$e(s)+`.md`:e.filename,t)}return(0,b.jsxs)(`div`,{ref:h,className:`fixed inset-0 z-[9999] flex items-center justify-center`,role:`dialog`,"aria-modal":`true`,"aria-label":a?`New Memory`:`Edit Memory`,children:[(0,b.jsx)(`div`,{className:`absolute inset-0 bg-base-content/50`,onClick:n}),(0,b.jsxs)(`div`,{className:`relative bg-base-200 border border-base-content/15 rounded-2xl shadow-2xl w-full max-w-2xl mx-4 max-h-[90vh] flex flex-col overflow-hidden`,children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between px-5 py-4 border-b border-base-content/15 flex-shrink-0`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(uc,{size:16,className:`text-primary flex-shrink-0`}),(0,b.jsx)(`h2`,{className:`text-[15px] font-mono font-bold text-base-content`,children:a?`New Memory`:`Edit Memory`})]}),(0,b.jsx)(`button`,{onClick:n,"aria-label":`Close`,className:`btn btn-ghost btn-xs btn-square text-base-content/40 hover:text-base-content`,children:(0,b.jsx)(Nv,{size:16})})]}),(0,b.jsxs)(`div`,{className:`overflow-y-auto flex-1 px-5 py-4 space-y-4`,children:[(0,b.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,b.jsxs)(`div`,{className:`col-span-2`,children:[(0,b.jsx)(`label`,{className:`text-[11px] font-mono text-base-content/40 uppercase tracking-wider mb-1.5 block`,children:`Name`}),(0,b.jsx)(`input`,{type:`text`,value:s,onChange:function(e){c(e.target.value)},className:`input input-sm w-full bg-base-300 border-base-content/15 text-[13px]`,placeholder:`Memory name`})]}),(0,b.jsxs)(`div`,{className:`col-span-2`,children:[(0,b.jsx)(`label`,{className:`text-[11px] font-mono text-base-content/40 uppercase tracking-wider mb-1.5 block`,children:`Description`}),(0,b.jsx)(`input`,{type:`text`,value:l,onChange:function(e){u(e.target.value)},className:`input input-sm w-full bg-base-300 border-base-content/15 text-[13px]`,placeholder:`Brief description`})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{className:`text-[11px] font-mono text-base-content/40 uppercase tracking-wider mb-1.5 block`,children:`Type`}),(0,b.jsx)(`select`,{value:d,onChange:function(e){f(e.target.value)},className:`select select-sm w-full bg-base-300 border-base-content/15 text-[13px]`,children:j$e.map(function(e){return(0,b.jsx)(`option`,{value:e,children:e.charAt(0).toUpperCase()+e.slice(1)},e)})})]}),!a&&(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{className:`text-[11px] font-mono text-base-content/40 uppercase tracking-wider mb-1.5 block`,children:`Filename`}),(0,b.jsx)(`input`,{type:`text`,value:e.filename,readOnly:!0,className:`input input-sm w-full bg-base-100/50 border-base-content/10 text-[13px] text-base-content/40 cursor-not-allowed`})]})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{className:`text-[11px] font-mono text-base-content/40 uppercase tracking-wider mb-1.5 block`,children:`Content`}),(0,b.jsx)(`textarea`,{value:p,onChange:function(e){m(e.target.value)},className:`textarea w-full bg-base-300 border-base-content/15 text-[13px] font-mono resize-none min-h-[200px]`,placeholder:`Memory content (markdown supported)`})]})]}),(0,b.jsxs)(`div`,{className:`px-5 py-3 border-t border-base-content/15 flex items-center justify-end gap-2 flex-shrink-0`,children:[(0,b.jsx)(`button`,{onClick:n,className:`btn btn-ghost btn-sm`,children:`Cancel`}),(0,b.jsxs)(`button`,{onClick:g,disabled:i||!s.trim(),className:`btn btn-primary btn-sm gap-1.5`,children:[i&&(0,b.jsx)(C_,{size:12,className:`animate-spin`}),a?`Create`:`Save`]})]})]})]})}function v9({projectSlug:e}){var{send:t,subscribe:n,unsubscribe:r}=R(),[i,a]=(0,x.useState)([]),[o,s]=(0,x.useState)(!1),[c,l]=(0,x.useState)(null),[u,d]=(0,x.useState)(null),[f,p]=(0,x.useState)(!1),[m,h]=(0,x.useState)(null);(0,x.useEffect)(function(){function e(e){e.type===`memory:list_result`&&(a(e.memories),s(!1))}function t(e){if(e.type===`memory:view_result`){var t=e;h(function(e){return e&&l({memory:e,content:t.content}),null})}}function i(e){e.type===`memory:save_result`&&(p(!1),d(null),l(null))}function o(e){e.type}return n(`memory:list_result`,e),n(`memory:view_result`,t),n(`memory:save_result`,i),n(`memory:delete_result`,o),function(){r(`memory:list_result`,e),r(`memory:view_result`,t),r(`memory:save_result`,i),r(`memory:delete_result`,o)}},[]),(0,x.useEffect)(function(){e&&(s(!0),t({type:`memory:list`,projectSlug:e}))},[e]);function g(n){h(n),t({type:`memory:view`,projectSlug:e,filename:n.filename})}function _(n){t({type:`memory:delete`,projectSlug:e,filename:n.filename})}function v(n,r){p(!0),t({type:`memory:save`,projectSlug:e,filename:n,content:r})}function y(){c&&(d({memory:c.memory,content:c.content}),l(null))}for(var S={},C=0;C<i.length;C++){var w=i[C],T=w.type||`other`;S[T]||(S[T]=[]),S[T].push(w)}var E=Object.keys(S);return(0,b.jsxs)(`div`,{className:`py-2 space-y-6`,children:[(0,b.jsxs)(`a`,{href:`https://docs.anthropic.com/en/docs/claude-code/memory`,target:`_blank`,rel:`noopener noreferrer`,className:`text-[11px] text-base-content/30 hover:text-primary/70 flex items-center gap-1 transition-colors`,children:[(0,b.jsx)(um,{size:11}),`Claude Code docs`]}),(0,b.jsx)(`div`,{className:`flex items-center justify-end`,children:(0,b.jsxs)(`button`,{onClick:function(){d({memory:null,content:``})},className:`btn btn-primary btn-sm gap-1.5`,children:[(0,b.jsx)(tv,{size:13}),`New Memory`]})}),o&&(0,b.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,b.jsx)(C_,{size:18,className:`animate-spin text-base-content/30`})}),!o&&i.length===0&&(0,b.jsx)(`div`,{className:`py-12 text-center text-[13px] text-base-content/40`,children:`No memories found.`}),!o&&E.map(function(e){return(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-[12px] font-semibold text-base-content/40 mb-2`,children:e.charAt(0).toUpperCase()+e.slice(1)}),(0,b.jsx)(`div`,{className:`space-y-2`,children:S[e].map(function(e){return(0,b.jsx)(P$e,{memory:e,onClick:function(){g(e)},onDelete:function(){_(e)}},e.filename)})})]},e)}),c&&(0,b.jsx)(F$e,{memory:c.memory,content:c.content,onClose:function(){l(null)},onEdit:y}),u!==null&&(0,b.jsx)(I$e,{memory:u.memory,initialContent:u.content,onClose:function(){d(null)},onSave:v,isSaving:f})]})}function L$e(){return(0,b.jsxs)(`div`,{children:[(0,b.jsxs)(`a`,{href:`https://docs.anthropic.com/en/docs/claude-code/memory`,target:`_blank`,rel:`noopener noreferrer`,className:`text-[11px] text-base-content/30 hover:text-primary/70 flex items-center gap-1 mb-4 transition-colors`,children:[(0,b.jsx)(um,{size:11}),`Claude Code docs`]}),(0,b.jsx)(v9,{projectSlug:`__global__`})]})}function R$e(){var{send:e,subscribe:t,unsubscribe:n}=R(),[r,i]=(0,x.useState)([]),[a,o]=(0,x.useState)([]),[s,c]=(0,x.useState)(!1),[l,u]=(0,x.useState)(null),[d,f]=(0,x.useState)(``),[p,m]=(0,x.useState)([]),[h,g]=(0,x.useState)(!1),[_,v]=(0,x.useState)(!1),[y,S]=(0,x.useState)(null),[C,w]=(0,x.useState)(null),[T,E]=(0,x.useState)(null),[D,O]=(0,x.useState)(null),[k,A]=(0,x.useState)(null),[j,M]=(0,x.useState)([]),[N,ee]=(0,x.useState)([]),[te,P]=(0,x.useState)(!1),F=(0,x.useRef)(null);(0,x.useEffect)(function(){function r(e){e.type===`plugin:list_result`&&(i(e.plugins),c(!0))}function a(e){e.type===`plugin:marketplaces_result`&&o(e.marketplaces)}function s(e){e.type===`plugin:search_result`&&(m(e.plugins),g(!1),v(!0))}function l(e){if(e.type===`plugin:install_result`){var t=e;S(null),ne(t.message??(t.success?`Installed`:`Install failed`),t.success)}}function d(e){if(e.type===`plugin:uninstall_result`){var t=e;w(null),ne(t.message??(t.success?`Uninstalled`:`Uninstall failed`),t.success)}}function f(e){if(e.type===`plugin:update_result`){var t=e;E(null),ne(t.message??(t.success?`Updated`:`Update failed`),t.success)}}function p(e){e.type===`plugin:details_result`&&u(e.plugin)}function h(e){e.type===`plugin:errors_result`&&M(e.errors)}function _(e){e.type===`plugin:discover_result`&&(ee(e.plugins),P(!0))}return t(`plugin:list_result`,r),t(`plugin:marketplaces_result`,a),t(`plugin:search_result`,s),t(`plugin:install_result`,l),t(`plugin:uninstall_result`,d),t(`plugin:update_result`,f),t(`plugin:details_result`,p),t(`plugin:errors_result`,h),t(`plugin:discover_result`,_),e({type:`plugin:list`}),e({type:`plugin:marketplaces`}),e({type:`plugin:errors`}),e({type:`plugin:discover`}),function(){n(`plugin:list_result`,r),n(`plugin:marketplaces_result`,a),n(`plugin:search_result`,s),n(`plugin:install_result`,l),n(`plugin:uninstall_result`,d),n(`plugin:update_result`,f),n(`plugin:details_result`,p),n(`plugin:errors_result`,h),n(`plugin:discover_result`,_)}},[]);function ne(e,t){A({text:e,success:t}),setTimeout(function(){A(null)},3e3)}function re(t){e({type:`plugin:details`,name:t.name,marketplace:t.marketplace})}function ie(t,n){S(t+`@`+n),e({type:`plugin:install`,name:t,marketplace:n})}function ae(t){w(t.key),O(null),e({type:`plugin:uninstall`,name:t.name,marketplace:t.marketplace})}function oe(t){E(t.key),e({type:`plugin:update`,name:t.name,marketplace:t.marketplace})}var se=(0,x.useCallback)(function(t){if(f(t),F.current&&clearTimeout(F.current),!t.trim()){m([]),v(!1),g(!1);return}g(!0),F.current=setTimeout(function(){e({type:`plugin:search`,query:t.trim()})},300)},[e]);return s?(0,b.jsxs)(`div`,{className:`py-2 space-y-8`,children:[k&&(0,b.jsx)(`div`,{className:`text-[12px] px-3 py-2 rounded-lg border `+(k.success?`bg-success/10 border-success/20 text-success`:`bg-error/10 border-error/20 text-error`),children:k.text}),j.length>0&&(0,b.jsx)(W$e,{errors:j}),(0,b.jsx)(z$e,{plugins:r,updatingKey:T,uninstallingKey:C,confirmUninstall:D,onViewDetails:re,onUpdate:oe,onUninstall:ae,onConfirmUninstall:O}),(0,b.jsx)(V$e,{query:d,results:p,searching:h,hasSearched:_,installingKey:y,installedKeys:new Set(r.map(function(e){return e.key})),onSearch:se,onInstall:ie}),(0,b.jsx)(G$e,{plugins:N,loaded:te,installingKey:y,installedKeys:new Set(r.map(function(e){return e.key})),onInstall:ie}),(0,b.jsx)(H$e,{marketplaces:a}),l&&(0,b.jsx)(U$e,{plugin:l,onClose:function(){u(null)}})]}):(0,b.jsx)(`div`,{className:`py-4 space-y-3 animate-pulse`,children:[0,1,2].map(function(e){return(0,b.jsx)(`div`,{className:`bg-base-content/[0.03] rounded-xl h-16`},e)})})}function z$e({plugins:e,updatingKey:t,uninstallingKey:n,confirmUninstall:r,onViewDetails:i,onUpdate:a,onUninstall:o,onConfirmUninstall:s}){return(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-[12px] font-semibold text-base-content/40 mb-2`,children:`Installed Plugins`}),e.length===0?(0,b.jsxs)(`div`,{className:`py-6 text-center`,children:[(0,b.jsx)(`div`,{className:`text-[12px] text-base-content/30 mb-0.5`,children:`No plugins installed`}),(0,b.jsx)(`div`,{className:`text-[11px] text-base-content/20`,children:`Browse the marketplace or search below to add plugins.`})]}):(0,b.jsx)(`div`,{className:`space-y-2`,children:e.map(function(e){return(0,b.jsx)(B$e,{plugin:e,isUpdating:t===e.key,isUninstalling:n===e.key,isConfirmingUninstall:r===e.key,onViewDetails:function(){i(e)},onUpdate:function(){a(e)},onUninstall:function(){o(e)},onConfirmUninstall:function(){s(e.key)},onCancelUninstall:function(){s(null)}},e.key)})})]})}function B$e({plugin:e,isUpdating:t,isUninstalling:n,isConfirmingUninstall:r,onViewDetails:i,onUpdate:a,onUninstall:o,onConfirmUninstall:s,onCancelUninstall:c}){return(0,b.jsxs)(`div`,{onClick:i,className:`flex items-start gap-3 px-3 py-2.5 bg-base-300 border border-base-content/15 rounded-xl cursor-pointer hover:border-base-content/30 hover:bg-base-300/80 transition-colors duration-[120ms]`,role:`button`,tabIndex:0,onKeyDown:function(e){(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),i())},children:[(0,b.jsx)(fs,{size:14,className:`text-base-content/25 mt-0.5 flex-shrink-0`}),(0,b.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(`span`,{className:`text-[13px] font-bold text-base-content truncate`,children:e.name}),(0,b.jsxs)(`span`,{className:`shrink-0 text-[10px] font-mono px-1.5 py-0.5 rounded-md bg-base-content/8 text-base-content/40`,children:[`v`,e.version]})]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-3 mt-0.5`,children:[(0,b.jsx)(`span`,{className:`text-[11px] text-base-content/30`,children:e.marketplace}),(0,b.jsxs)(`span`,{className:`text-[11px] text-base-content/25`,children:[e.skillCount,` skill`,e.skillCount===1?``:`s`,e.hookCount>0?`, `+e.hookCount+` hook`+(e.hookCount===1?``:`s`):``,e.ruleCount>0?`, `+e.ruleCount+` rule`+(e.ruleCount===1?``:`s`):``]})]}),e.description&&(0,b.jsx)(`div`,{className:`text-[12px] text-base-content/40 mt-0.5 line-clamp-1`,children:e.description})]}),(0,b.jsxs)(`div`,{className:`flex gap-1 flex-shrink-0 mt-0.5`,onClick:function(e){e.stopPropagation()},children:[t?(0,b.jsx)(C_,{size:12,className:`text-primary animate-spin mt-1 mx-1`}):(0,b.jsx)(`button`,{onClick:a,"aria-label":`Update `+e.name,className:`btn btn-ghost btn-xs btn-square text-base-content/30 hover:text-info focus-visible:ring-2 focus-visible:ring-primary`,children:(0,b.jsx)(ov,{size:12})}),r?(0,b.jsxs)(`div`,{className:`flex gap-1`,children:[(0,b.jsx)(`button`,{onClick:o,className:`btn btn-error btn-xs`,disabled:n,children:n?(0,b.jsx)(C_,{size:10,className:`animate-spin`}):`Remove`}),(0,b.jsx)(`button`,{onClick:c,className:`btn btn-ghost btn-xs`,children:`Cancel`})]}):(0,b.jsx)(`button`,{onClick:s,"aria-label":`Remove `+e.name,className:`btn btn-ghost btn-xs btn-square text-base-content/30 hover:text-error focus-visible:ring-2 focus-visible:ring-primary`,children:(0,b.jsx)(Tv,{size:12})})]})]})}function V$e({query:e,results:t,searching:n,hasSearched:r,installingKey:i,installedKeys:a,onSearch:o,onInstall:s}){return(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-[12px] font-semibold text-base-content/40 mb-2`,children:`Browse Marketplace`}),(0,b.jsxs)(`div`,{className:`relative mb-3`,children:[(0,b.jsx)(dv,{size:13,className:`absolute left-3 top-1/2 -translate-y-1/2 text-base-content/30 pointer-events-none`}),(0,b.jsx)(`input`,{type:`text`,value:e,onChange:function(e){o(e.target.value)},placeholder:`Search plugins...`,className:`w-full bg-base-300 border border-base-content/15 rounded-xl pl-8 pr-3 py-2.5 text-[13px] text-base-content placeholder:text-base-content/30 focus:outline-none focus:border-primary transition-colors`}),n&&(0,b.jsx)(C_,{size:13,className:`absolute right-3 top-1/2 -translate-y-1/2 text-primary animate-spin`})]}),r&&t.length===0&&!n&&(0,b.jsxs)(`div`,{className:`py-4 text-center text-[13px] text-base-content/30`,children:[`No plugins found for "`,e,`"`]}),t.length>0&&(0,b.jsx)(`div`,{className:`space-y-2`,children:t.map(function(e){var t=e.name+`@`+e.marketplace,n=a.has(t),r=i===t;return(0,b.jsxs)(`div`,{className:`flex items-start gap-3 px-3 py-2.5 bg-base-300/50 border border-base-content/10 rounded-xl`,children:[(0,b.jsx)(Y_,{size:14,className:`text-base-content/20 mt-0.5 flex-shrink-0`}),(0,b.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(`span`,{className:`text-[13px] font-bold text-base-content truncate`,children:e.name}),(0,b.jsx)(`span`,{className:`text-[10px] font-mono text-base-content/30`,children:e.marketplace})]}),e.description&&(0,b.jsx)(`div`,{className:`text-[12px] text-base-content/40 mt-0.5 line-clamp-2`,children:e.description}),(0,b.jsxs)(`div`,{className:`flex items-center gap-3 mt-1`,children:[e.author&&(0,b.jsx)(`span`,{className:`text-[10px] text-base-content/25`,children:e.author.name}),e.installs!=null&&e.installs>0&&(0,b.jsxs)(`span`,{className:`text-[10px] text-base-content/25 flex items-center gap-0.5`,children:[(0,b.jsx)(nm,{size:9}),b9(e.installs)]})]})]}),(0,b.jsx)(`div`,{className:`flex-shrink-0 mt-0.5`,onClick:function(e){e.stopPropagation()},children:n?(0,b.jsx)(`span`,{className:`text-[10px] font-mono px-2 py-1 rounded-md bg-success/10 text-success/70`,children:`Installed`}):r?(0,b.jsx)(C_,{size:14,className:`text-primary animate-spin mx-2`}):(0,b.jsx)(`button`,{onClick:function(){s(e.name,e.marketplace)},className:`btn btn-primary btn-xs`,children:`Install`})})]},t)})})]})}function H$e({marketplaces:e}){return e.length===0?null:(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-[12px] font-semibold text-base-content/40 mb-2`,children:`Registered Marketplaces`}),(0,b.jsx)(`div`,{className:`space-y-1.5`,children:e.map(function(e){return(0,b.jsxs)(`div`,{className:`flex items-center gap-2.5 px-3 py-2 bg-base-300/30 border border-base-content/10 rounded-lg`,children:[(0,b.jsx)(Y_,{size:12,className:`text-base-content/20 flex-shrink-0`}),(0,b.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,b.jsx)(`span`,{className:`text-[12px] font-bold text-base-content/60`,children:e.name}),(0,b.jsx)(`span`,{className:`text-[11px] text-base-content/25 ml-2`,children:e.source.repo})]})]},e.name)})})]})}function U$e({plugin:e,onClose:t}){return(0,x.useEffect)(function(){function e(e){e.key===`Escape`&&t()}return document.addEventListener(`keydown`,e),function(){document.removeEventListener(`keydown`,e)}},[t]),(0,b.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,role:`dialog`,"aria-modal":`true`,"aria-label":`Plugin: `+e.name,children:[(0,b.jsx)(`div`,{className:`absolute inset-0 bg-base-content/50`,onClick:t}),(0,b.jsxs)(`div`,{className:`relative bg-base-200 border border-base-content/15 rounded-2xl shadow-2xl w-full max-w-2xl mx-4 max-h-[80vh] flex flex-col overflow-hidden`,children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between px-5 py-4 border-b border-base-content/15 flex-shrink-0`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2.5 min-w-0`,children:[(0,b.jsx)(fs,{size:16,className:`text-primary flex-shrink-0`}),(0,b.jsxs)(`div`,{className:`min-w-0`,children:[(0,b.jsx)(`h2`,{className:`text-[15px] font-mono font-bold text-base-content truncate`,children:e.name}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5`,children:[(0,b.jsxs)(`span`,{className:`text-[10px] font-mono text-base-content/40`,children:[`v`,e.version]}),(0,b.jsx)(`span`,{className:`text-[10px] text-base-content/30`,children:e.marketplace})]})]})]}),(0,b.jsx)(`button`,{onClick:t,"aria-label":`Close`,className:`btn btn-ghost btn-xs btn-square text-base-content/40 hover:text-base-content`,children:(0,b.jsx)(Nv,{size:16})})]}),(0,b.jsxs)(`div`,{className:`overflow-y-auto flex-1`,children:[(0,b.jsx)(`div`,{className:`px-5 py-3 border-b border-base-content/10 bg-base-300/30`,children:(0,b.jsxs)(`div`,{className:`flex flex-wrap gap-x-6 gap-y-1.5`,children:[e.author&&(0,b.jsx)(y9,{label:`Author`,value:e.author.name}),e.license&&(0,b.jsx)(y9,{label:`License`,value:e.license}),(0,b.jsx)(y9,{label:`Installed`,value:x9(e.installedAt)}),(0,b.jsx)(y9,{label:`Updated`,value:x9(e.lastUpdated)}),e.homepage&&(0,b.jsxs)(`a`,{href:e.homepage,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1 text-[11px] text-primary/60 hover:text-primary transition-colors`,children:[(0,b.jsx)(um,{size:10}),`Homepage`]})]})}),e.description&&(0,b.jsx)(`div`,{className:`px-5 py-3 border-b border-base-content/10`,children:(0,b.jsx)(`p`,{className:`text-[13px] text-base-content/60`,children:e.description})}),e.keywords&&e.keywords.length>0&&(0,b.jsx)(`div`,{className:`px-5 py-3 border-b border-base-content/10`,children:(0,b.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.keywords.map(function(e){return(0,b.jsx)(`span`,{className:`text-[10px] font-mono px-1.5 py-0.5 rounded-md bg-base-content/8 text-base-content/40`,children:e},e)})})}),e.skills.length>0&&(0,b.jsxs)(`div`,{className:`px-5 py-3 border-b border-base-content/10`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-2`,children:[(0,b.jsx)(rv,{size:12,className:`text-base-content/30`}),(0,b.jsxs)(`span`,{className:`text-[11px] font-bold text-base-content/40 uppercase tracking-wider`,children:[`Skills (`,e.skills.length,`)`]})]}),(0,b.jsx)(`div`,{className:`space-y-1.5`,children:e.skills.map(function(e){return(0,b.jsxs)(`div`,{className:`flex items-start gap-2 py-1`,children:[(0,b.jsx)(cu,{size:10,className:`text-base-content/20 mt-0.5 flex-shrink-0`}),(0,b.jsxs)(`div`,{className:`min-w-0`,children:[(0,b.jsx)(`span`,{className:`text-[12px] font-bold text-base-content/70`,children:e.name}),e.description&&(0,b.jsx)(`div`,{className:`text-[11px] text-base-content/35 line-clamp-1`,children:e.description})]})]},e.name)})})]}),Object.keys(e.hooks).length>0&&(0,b.jsxs)(`div`,{className:`px-5 py-3 border-b border-base-content/10`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-2`,children:[(0,b.jsx)(kv,{size:12,className:`text-base-content/30`}),(0,b.jsxs)(`span`,{className:`text-[11px] font-bold text-base-content/40 uppercase tracking-wider`,children:[`Hooks (`,Object.keys(e.hooks).length,`)`]})]}),(0,b.jsx)(`div`,{className:`space-y-1`,children:Object.keys(e.hooks).map(function(e){return(0,b.jsxs)(`div`,{className:`flex items-center gap-2 py-0.5`,children:[(0,b.jsx)(cu,{size:10,className:`text-base-content/20 flex-shrink-0`}),(0,b.jsx)(`span`,{className:`text-[12px] font-mono text-base-content/50`,children:e})]},e)})})]}),e.rules.length>0&&(0,b.jsxs)(`div`,{className:`px-5 py-3`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-2`,children:[(0,b.jsx)(uv,{size:12,className:`text-base-content/30`}),(0,b.jsxs)(`span`,{className:`text-[11px] font-bold text-base-content/40 uppercase tracking-wider`,children:[`Rules (`,e.rules.length,`)`]})]}),(0,b.jsx)(`div`,{className:`space-y-1`,children:e.rules.map(function(e){return(0,b.jsxs)(`div`,{className:`flex items-center gap-2 py-0.5`,children:[(0,b.jsx)(cu,{size:10,className:`text-base-content/20 flex-shrink-0`}),(0,b.jsx)(`span`,{className:`text-[12px] font-mono text-base-content/50`,children:e})]},e)})})]})]}),(0,b.jsx)(`div`,{className:`px-5 py-3 border-t border-base-content/15 flex-shrink-0`,children:(0,b.jsxs)(`div`,{className:`text-[11px] font-mono text-base-content/30 truncate`,children:[e.gitCommitSha.slice(0,8),` · `,e.installPath]})})]})]})}function W$e({errors:e}){return(0,b.jsxs)(`div`,{children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-2`,children:[(0,b.jsx)(Ev,{size:12,className:`text-warning`}),(0,b.jsxs)(`span`,{className:`text-[12px] font-semibold text-warning/80`,children:[`Errors (`,e.length,`)`]})]}),(0,b.jsx)(`div`,{className:`space-y-2`,children:e.map(function(e){return(0,b.jsxs)(`div`,{className:`px-3 py-2.5 bg-warning/5 border border-warning/20 rounded-xl`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,b.jsx)(`span`,{className:`text-[13px] font-bold text-base-content`,children:e.name}),(0,b.jsx)(`span`,{className:`text-[10px] font-mono text-base-content/30`,children:e.marketplace})]}),e.errors.map(function(e,t){return(0,b.jsxs)(`div`,{className:`flex items-start gap-1.5 mt-0.5`,children:[(0,b.jsx)(Ev,{size:10,className:`text-warning/60 mt-0.5 flex-shrink-0`}),(0,b.jsx)(`span`,{className:`text-[12px] text-warning/70`,children:e})]},t)})]},e.key)})})]})}function G$e({plugins:e,loaded:t,installingKey:n,installedKeys:r,onInstall:i}){var[a,o]=(0,x.useState)(!1),s=12;if(!t||e.length===0)return null;var c=a?e:e.slice(0,s);return(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`flex items-center justify-between mb-2`,children:(0,b.jsxs)(`div`,{className:`text-[12px] font-semibold text-base-content/40`,children:[`Discover (`,e.length,` available)`]})}),(0,b.jsx)(`div`,{className:`space-y-2`,children:c.map(function(e){var t=e.name+`@`+e.marketplace,a=r.has(t),o=n===t;return(0,b.jsxs)(`div`,{className:`flex items-start gap-3 px-3 py-2.5 bg-base-300/50 border border-base-content/10 rounded-xl`,children:[(0,b.jsx)(Y_,{size:14,className:`text-base-content/20 mt-0.5 flex-shrink-0`}),(0,b.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(`span`,{className:`text-[13px] font-bold text-base-content truncate`,children:e.name}),(0,b.jsx)(`span`,{className:`text-[10px] font-mono text-base-content/30`,children:e.marketplace})]}),e.description&&(0,b.jsx)(`div`,{className:`text-[12px] text-base-content/40 mt-0.5 line-clamp-2`,children:e.description}),(0,b.jsxs)(`div`,{className:`flex items-center gap-3 mt-1`,children:[e.author&&(0,b.jsx)(`span`,{className:`text-[10px] text-base-content/25`,children:e.author.name}),e.installs!=null&&e.installs>0&&(0,b.jsxs)(`span`,{className:`text-[10px] text-base-content/25 flex items-center gap-0.5`,children:[(0,b.jsx)(nm,{size:9}),b9(e.installs)]})]})]}),(0,b.jsx)(`div`,{className:`flex-shrink-0 mt-0.5`,onClick:function(e){e.stopPropagation()},children:a?(0,b.jsx)(`span`,{className:`text-[10px] font-mono px-2 py-1 rounded-md bg-success/10 text-success/70`,children:`Installed`}):o?(0,b.jsx)(C_,{size:14,className:`text-primary animate-spin mx-2`}):(0,b.jsx)(`button`,{onClick:function(){i(e.name,e.marketplace)},className:`btn btn-primary btn-xs`,children:`Install`})})]},t)})}),!a&&e.length>s&&(0,b.jsxs)(`button`,{onClick:function(){o(!0)},className:`mt-3 text-[12px] text-primary/60 hover:text-primary transition-colors`,children:[`Show all `,e.length,` plugins`]}),a&&e.length>s&&(0,b.jsx)(`button`,{onClick:function(){o(!1)},className:`mt-3 text-[12px] text-primary/60 hover:text-primary transition-colors`,children:`Show less`})]})}function y9({label:e,value:t}){return(0,b.jsxs)(`div`,{className:`flex items-baseline gap-1.5`,children:[(0,b.jsx)(`span`,{className:`text-[11px] font-mono text-base-content/35 uppercase tracking-wider`,children:e}),(0,b.jsx)(`span`,{className:`text-[12px] text-base-content/70`,children:t})]})}function b9(e){return e>=1e6?(e/1e6).toFixed(1)+`M`:e>=1e3?(e/1e3).toFixed(1)+`k`:String(e)}function x9(e){try{return new Date(e).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`})}catch{return e}}function K$e(){var[e,t]=(0,x.useState)(function(){return localStorage.getItem(`lattice-notifications-enabled`)===`1`}),n=typeof Notification<`u`?Notification.permission:`denied`;function r(){e?(t(!1),localStorage.setItem(`lattice-notifications-enabled`,`0`)):n===`default`?Notification.requestPermission().then(function(e){e===`granted`&&(t(!0),localStorage.setItem(`lattice-notifications-enabled`,`1`))}):n===`granted`&&(t(!0),localStorage.setItem(`lattice-notifications-enabled`,`1`))}return{enabled:e,permission:n,toggle:r}}function S9(e,t,n,r){if(localStorage.getItem(`lattice-notifications-enabled`)===`1`&&!(typeof Notification>`u`||Notification.permission!==`granted`)){var i=new Notification(e,{body:t,icon:`/icons/icon-192.svg`,tag:n||`lattice`,silent:!1}),a=setTimeout(function(){i.close()},1e4);i.onclick=function(){clearTimeout(a),window.focus(),i.close(),r&&r()}}}function q$e(e){for(var t=(e+`=`.repeat((4-e.length%4)%4)).replace(/-/g,`+`).replace(/_/g,`/`),n=window.atob(t),r=new Uint8Array(n.length),i=0;i<n.length;++i)r[i]=n.charCodeAt(i);return r}function J$e(){var[e,t]=(0,x.useState)(`unsupported`);(0,x.useEffect)(function(){if(!(`serviceWorker`in navigator)||!(`PushManager`in window)){t(`unsupported`);return}if(Notification.permission===`denied`){t(`denied`);return}navigator.serviceWorker.getRegistration(`/sw-push.js`).then(function(e){if(!e){t(`unsubscribed`);return}e.pushManager.getSubscription().then(function(e){t(e?`subscribed`:`unsubscribed`)})})},[]);async function n(){if(!(`serviceWorker`in navigator)||!(`PushManager`in window))return!1;try{if(await Notification.requestPermission()!==`granted`)return t(`denied`),!1;var e=await navigator.serviceWorker.register(`/sw-push.js`,{scope:`/`});await navigator.serviceWorker.ready;var n=await(await fetch(`/api/vapid-public-key`)).json(),r=await e.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:q$e(n.publicKey)});return await fetch(`/api/push-subscribe`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(r.toJSON())}),t(`subscribed`),!0}catch(e){return console.error(`Push subscription failed:`,e),!1}}async function r(){try{var e=await navigator.serviceWorker.getRegistration(`/sw-push.js`);if(e){var n=await e.pushManager.getSubscription();n&&await n.unsubscribe()}t(`unsubscribed`)}catch(e){console.error(`Push unsubscribe failed:`,e)}}return{status:e,subscribe:n,unsubscribe:r}}var Y$e=[{key:`responses`,label:`Claude responses`,description:`When Claude finishes a response`},{key:`mesh`,label:`Mesh node changes`,description:`When nodes come online or go offline`},{key:`connection`,label:`Connection events`,description:`WebSocket connect and disconnect`}];function X$e(){try{var e=localStorage.getItem(`lattice-notification-types`);if(e)return JSON.parse(e)}catch{}return{responses:!0,mesh:!0,connection:!0}}function Z$e(e){localStorage.setItem(`lattice-notification-types`,JSON.stringify(e))}function Q$e(){var e=K$e(),t=J$e(),[n,r]=(0,x.useState)(X$e);function i(e){r(function(t){var n={...t,[e]:!t[e]};return Z$e(n),n})}return(0,b.jsxs)(`div`,{className:`py-2 space-y-6`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`h2`,{className:`text-[12px] font-semibold text-base-content/40 mb-3`,children:`Browser Notifications`}),(0,b.jsxs)(`div`,{className:`flex items-center justify-between py-2 px-3 bg-base-300 border border-base-content/15 rounded-xl`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-[13px] text-base-content`,children:`Enable notifications`}),(0,b.jsx)(`div`,{className:`text-[11px] text-base-content/30 mt-0.5`,children:e.permission===`denied`?`Blocked by browser — update in browser settings`:`Get notified about events in Lattice`})]}),(0,b.jsx)(`input`,{type:`checkbox`,className:`toggle toggle-sm toggle-primary`,checked:e.enabled,onChange:e.toggle,disabled:e.permission===`denied`})]})]}),t.status!==`unsupported`&&(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`h2`,{className:`text-[12px] font-semibold text-base-content/40 mb-3`,children:`Push Notifications`}),(0,b.jsxs)(`div`,{className:`flex items-center justify-between py-2 px-3 bg-base-300 border border-base-content/15 rounded-xl`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-[13px] text-base-content`,children:`Enable push notifications`}),(0,b.jsx)(`div`,{className:`text-[11px] text-base-content/30 mt-0.5`,children:t.status===`denied`?`Blocked by browser — update in browser settings`:t.status===`subscribed`?`Receiving push notifications even when the tab is closed`:`Get notified even when Lattice is not open`})]}),(0,b.jsx)(`input`,{type:`checkbox`,className:`toggle toggle-sm toggle-primary`,checked:t.status===`subscribed`,onChange:function(){t.status===`subscribed`?t.unsubscribe():t.subscribe()},disabled:t.status===`denied`})]})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`h2`,{className:`text-[12px] font-semibold text-base-content/40 mb-3`,children:`Notification Types`}),(0,b.jsx)(`div`,{className:`flex flex-col gap-2`,children:Y$e.map(function(t){return(0,b.jsxs)(`div`,{className:`flex items-center justify-between py-2 px-3 bg-base-300 border border-base-content/15 rounded-xl`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-[13px] text-base-content`,children:t.label}),(0,b.jsx)(`div`,{className:`text-[11px] text-base-content/30 mt-0.5`,children:t.description})]}),(0,b.jsx)(`input`,{type:`checkbox`,className:`toggle toggle-sm toggle-primary`,checked:n[t.key]!==!1,onChange:function(){i(t.key)},disabled:!e.enabled})]},t.key)})})]})]})}var $$e=[{id:`warning`,label:`Warning`,description:`Shows a warning but does not block`},{id:`soft-block`,label:`Confirm`,description:`Asks for confirmation before sending`},{id:`hard-block`,label:`Block`,description:`Prevents sending until tomorrow`}];function e1e(){var{send:e,subscribe:t,unsubscribe:n}=R(),r=$n(Uy(),function(e){return e.budgetStatus}),[i,a]=(0,x.useState)(!1),[o,s]=(0,x.useState)(10),[c,l]=(0,x.useState)(`warning`),u=e9();(0,x.useEffect)(function(){function r(e){if(e.type===`settings:data`){var t=e.config;u.savingRef.current?(u.confirmSave(),t.costBudget||ub(null)):(t.costBudget?(a(!0),s(t.costBudget.dailyLimit),l(t.costBudget.enforcement)):(a(!1),s(10),l(`warning`),ub(null)),u.resetFromServer())}}return t(`settings:data`,r),e({type:`settings:get`}),function(){n(`settings:data`,r)}},[]);function d(){u.startSave(),e({type:`settings:update`,settings:{costBudget:i?{dailyLimit:o,enforcement:c}:null}})}return(0,b.jsxs)(`div`,{className:`py-2`,children:[(0,b.jsx)(`p`,{className:`text-[12px] text-base-content/40 mb-5`,children:`Set a daily spending limit to control API costs. The budget resets at midnight.`}),r&&(0,b.jsxs)(`div`,{className:`mb-5 p-3 rounded-xl bg-base-300 border border-base-content/10`,children:[(0,b.jsx)(`div`,{className:`text-[11px] text-base-content/40 font-mono mb-1`,children:`Today's spend`}),(0,b.jsxs)(`div`,{className:`text-[18px] font-mono font-bold text-base-content`,children:[`$`,r.dailySpend.toFixed(2),r.dailyLimit>0&&(0,b.jsx)(`span`,{className:`text-[13px] text-base-content/30 font-normal`,children:` / $`+r.dailyLimit.toFixed(2)})]})]}),(0,b.jsx)(`div`,{className:`mb-5`,children:(0,b.jsxs)(`label`,{className:`flex items-center gap-3 cursor-pointer`,children:[(0,b.jsx)(`input`,{type:`checkbox`,checked:i,onChange:function(e){a(e.target.checked),u.markDirty()},className:`toggle toggle-sm toggle-primary`}),(0,b.jsx)(`span`,{className:`text-[13px] text-base-content`,children:`Enable daily budget`})]})}),i&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`div`,{className:`mb-5`,children:[(0,b.jsx)(`label`,{htmlFor:`budget-daily-limit`,className:`block text-[12px] font-semibold text-base-content/40 mb-2`,children:`Daily limit (USD)`}),(0,b.jsx)(`input`,{id:`budget-daily-limit`,type:`number`,min:.01,step:.5,value:o,onChange:function(e){var t=parseFloat(e.target.value);!isNaN(t)&&t>0&&(s(t),u.markDirty())},className:`w-full h-9 px-3 bg-base-300 border border-base-content/15 rounded-xl text-base-content text-[13px] font-mono focus:border-primary focus-visible:outline-none transition-colors duration-[120ms]`})]}),(0,b.jsxs)(`div`,{className:`mb-6`,role:`radiogroup`,"aria-label":`Enforcement mode`,children:[(0,b.jsx)(`div`,{className:`text-[12px] font-semibold text-base-content/40 mb-2`,children:`Enforcement`}),(0,b.jsx)(`div`,{className:`flex flex-col gap-2`,children:$$e.map(function(e){var t=c===e.id;return(0,b.jsxs)(`button`,{role:`radio`,"aria-checked":t,onClick:function(){l(e.id),u.markDirty()},className:`w-full text-left px-3 py-2.5 rounded-lg border text-[12px] transition-colors duration-[120ms] cursor-pointer focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-1 focus-visible:ring-offset-base-100 `+(t?`border-primary bg-base-300 text-base-content`:`border-base-content/15 bg-base-300 text-base-content/40 hover:border-base-content/30 hover:text-base-content/60`),children:[(0,b.jsx)(`div`,{className:`font-semibold`,children:e.label}),(0,b.jsx)(`div`,{className:`text-[11px] mt-0.5 `+(t?`text-base-content/50`:`text-base-content/30`),children:e.description})]},e.id)})})]})]}),(0,b.jsx)(r9,{dirty:u.dirty,saving:u.saving,saveState:u.saveState,onSave:d})]})}var t1e={appearance:{title:`Appearance`},notifications:{title:`Notifications`},claude:{title:`Claude`},budget:{title:`Budget`},environment:{title:`Environment`},mcp:{title:`MCP Servers`},skills:{title:`Skills`},plugins:{title:`Plugins`},nodes:{title:`Mesh Nodes`},editor:{title:`Editor`},rules:{title:`Rules`},memory:{title:`Memory`}};function n1e(e){return e===`appearance`?(0,b.jsx)(p$e,{}):e===`notifications`?(0,b.jsx)(Q$e,{}):e===`claude`?(0,b.jsx)(b$e,{}):e===`budget`?(0,b.jsx)(e1e,{}):e===`environment`?(0,b.jsx)(x$e,{}):e===`mcp`?(0,b.jsx)(w$e,{}):e===`skills`?(0,b.jsx)(D$e,{}):e===`plugins`?(0,b.jsx)(R$e,{}):e===`nodes`?(0,b.jsx)(C$e,{}):e===`editor`?(0,b.jsx)(k$e,{}):e===`rules`?(0,b.jsx)(A$e,{}):e===`memory`?(0,b.jsx)(L$e,{}):null}function r1e(){var{activeView:e,toggleDrawer:t}=jy();if(e.type!==`settings`)return null;var n=e.section,r=t1e[n];return(0,b.jsxs)(`section`,{"aria-label":`Settings`,className:`flex-1 overflow-auto px-4 sm:px-8 py-4 sm:py-6 max-w-3xl`,children:[r&&(0,b.jsxs)(`div`,{className:`mb-6 flex items-center gap-3`,children:[(0,b.jsx)(`button`,{className:`btn btn-ghost btn-sm btn-square lg:hidden`,"aria-label":`Toggle sidebar`,onClick:t,children:(0,b.jsx)(B_,{size:18})}),(0,b.jsx)(`h1`,{className:`text-lg font-mono font-bold text-base-content`,children:r.title})]}),n1e(n)]})}function C9(e){var{status:t,send:n,subscribe:r,unsubscribe:i}=R(),[a,o]=(0,x.useState)(null),[s,c]=(0,x.useState)(!0),[l,u]=(0,x.useState)(null);(0,x.useEffect)(function(){if(!e)return;function a(t){if(t.type===`project-settings:data`){var n=t;n.projectSlug===e&&(o(n.settings),c(!1),u(null))}}function s(t){if(t.type===`project-settings:error`){var n=t;n.projectSlug===e&&(u(n.message),c(!1))}}return r(`project-settings:data`,a),r(`project-settings:error`,s),t===`connected`&&(c(!0),n({type:`project-settings:get`,projectSlug:e})),function(){i(`project-settings:data`,a),i(`project-settings:error`,s)}},[e,t]);function d(t,r){e&&n({type:`project-settings:update`,projectSlug:e,section:t,settings:r})}return{settings:a,loading:s,error:l,updateSection:d}}function i1e(e){if(!e)return(0,b.jsx)(`div`,{className:`w-8 h-8 rounded-lg bg-base-300 border border-base-content/15 flex items-center justify-center text-base-content/30 text-[11px]`,children:`?`});if(e.type===`lucide`){var t=Fv[e.name];return t?(0,b.jsx)(`div`,{className:`w-8 h-8 rounded-lg bg-base-300 border border-base-content/15 flex items-center justify-center text-base-content`,children:(0,b.jsx)(t,{size:18})}):null}return e.type===`text`?(0,b.jsx)(`div`,{className:`w-8 h-8 rounded-lg bg-base-300 border border-base-content/15 flex items-center justify-center text-[14px] font-bold`,style:e.color?{color:e.color}:void 0,children:e.value}):e.type===`image`?(0,b.jsx)(`img`,{src:e.path,alt:`icon`,className:`w-8 h-8 rounded-lg object-cover border border-base-content/15`,loading:`lazy`}):null}function a1e({value:e,onChange:t}){var n=e&&e.type===`emoji`?void 0:e,[r,i]=(0,x.useState)(n?.type===`text`?`text`:n?.type===`image`?`upload`:`lucide`),[a,o]=(0,x.useState)(``),[s,c]=(0,x.useState)(n?.type===`text`?n.value:``),[l,u]=(0,x.useState)(n?.type===`text`&&n.color||`#ffffff`),d=(0,x.useMemo)(function(){var e=Object.keys(Fv);if(!a.trim())return e.slice(0,60);var t=a.toLowerCase();return e.filter(function(e){return e.toLowerCase().includes(t)}).slice(0,60)},[a]),f=[{id:`lucide`,label:`Lucide`},{id:`text`,label:`Text`},{id:`upload`,label:`Upload`}];function p(e){var n=e.target.files?.[0];if(n){var r=new FileReader;r.onload=function(e){var n=e.target?.result;t({type:`image`,path:n})},r.readAsDataURL(n)}}return(0,b.jsxs)(`div`,{className:`space-y-3`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-3`,children:[i1e(n),(0,b.jsx)(`span`,{className:`text-[11px] text-base-content/40`,children:`Current icon`})]}),(0,b.jsx)(`div`,{className:`flex gap-1`,children:f.map(function(e){return(0,b.jsx)(`button`,{type:`button`,onClick:function(){i(e.id)},className:`btn btn-xs `+(r===e.id?`btn-primary`:`btn-ghost`),children:e.label},e.id)})}),r===`lucide`&&(0,b.jsxs)(`div`,{className:`space-y-2`,children:[(0,b.jsx)(`input`,{type:`text`,value:a,onChange:function(e){o(e.target.value)},placeholder:`Search icons...`,"aria-label":`Search icons`,className:`w-full h-8 px-3 bg-base-300 border border-base-content/15 rounded-xl text-base-content text-[12px] focus:border-primary focus-visible:outline-none transition-colors duration-[120ms]`}),(0,b.jsx)(`div`,{className:`grid grid-cols-10 gap-1 max-h-48 overflow-y-auto`,children:d.map(function(e){var r=Fv[e];return(0,b.jsx)(`button`,{type:`button`,title:e,onClick:function(){t({type:`lucide`,name:e})},className:`w-8 h-8 flex items-center justify-center rounded-lg text-base-content transition-colors duration-75 `+(n?.type===`lucide`&&n.name===e?`border border-primary bg-base-300`:`hover:bg-base-300`),children:(0,b.jsx)(r,{size:16})},e)})})]}),r===`text`&&(0,b.jsxs)(`div`,{className:`flex gap-2`,children:[(0,b.jsx)(`input`,{type:`text`,value:s,maxLength:2,onChange:function(e){c(e.target.value),e.target.value&&t({type:`text`,value:e.target.value,color:l})},placeholder:`1-2 chars`,"aria-label":`Icon text`,className:`flex-1 h-9 px-3 bg-base-300 border border-base-content/15 rounded-xl text-base-content text-[13px] focus:border-primary focus-visible:outline-none transition-colors duration-[120ms]`}),(0,b.jsx)(`input`,{type:`color`,value:l,onChange:function(e){u(e.target.value),s&&t({type:`text`,value:s,color:e.target.value})},className:`w-9 h-9 rounded-xl border border-base-content/15 bg-base-300 cursor-pointer`})]}),r===`upload`&&(0,b.jsxs)(`div`,{className:`space-y-2`,children:[(0,b.jsx)(`input`,{type:`file`,accept:`image/*`,onChange:p,className:`w-full text-[12px] text-base-content/60 file:mr-3 file:py-1.5 file:px-3 file:rounded-lg file:border-0 file:text-[12px] file:bg-base-300 file:text-base-content/60 file:cursor-pointer`}),n?.type===`image`&&(0,b.jsx)(`img`,{src:n.path,alt:`preview`,className:`w-16 h-16 rounded-xl object-cover border border-base-content/15`,loading:`lazy`})]})]})}function o1e({settings:e,updateSection:t}){var[n,r]=(0,x.useState)(e.title),[i,a]=(0,x.useState)(e.icon),o=e9();(0,x.useEffect)(function(){o.savingRef.current?o.confirmSave():(r(e.title),a(e.icon),o.resetFromServer())},[e]);function s(e){r(e),o.markDirty()}function c(e){a(e),o.markDirty()}function l(){o.startSave(),t(`general`,{title:n,icon:i})}return(0,b.jsxs)(`div`,{className:`py-2`,children:[(0,b.jsxs)(`div`,{className:`mb-5`,children:[(0,b.jsx)(`label`,{htmlFor:`project-title`,className:`block text-[12px] font-semibold text-base-content/40 mb-2`,children:`Display Name`}),(0,b.jsx)(`input`,{id:`project-title`,type:`text`,value:n,onChange:function(e){s(e.target.value)},className:`w-full h-9 px-3 bg-base-300 border border-base-content/15 rounded-xl text-base-content text-[13px] focus:border-primary focus-visible:outline-none transition-colors duration-[120ms]`})]}),(0,b.jsxs)(`div`,{className:`mb-5`,children:[(0,b.jsx)(`div`,{className:`block text-[12px] font-semibold text-base-content/40 mb-2`,children:`Icon`}),(0,b.jsx)(a1e,{value:i,onChange:c})]}),(0,b.jsxs)(`div`,{className:`mb-6`,children:[(0,b.jsx)(`div`,{className:`block text-[12px] font-semibold text-base-content/40 mb-2`,children:`Project Path`}),(0,b.jsx)(`div`,{className:`w-full h-9 px-3 bg-base-300 border border-base-content/15 rounded-xl text-base-content/60 text-[12px] font-mono flex items-center select-all`,children:e.path})]}),(0,b.jsx)(r9,{dirty:o.dirty,saving:o.saving,saveState:o.saveState,onSave:l})]})}var w9=[{id:`claude-opus-4-6`,label:`Claude Opus 4.6`},{id:`claude-sonnet-4-6`,label:`Claude Sonnet 4.6`},{id:`claude-haiku-4-5`,label:`Claude Haiku 4.5`},{id:`claude-opus-4-5`,label:`Claude Opus 4.5`},{id:`claude-sonnet-4-5`,label:`Claude Sonnet 4.5`}],s1e=[{id:`low`,label:`Low`},{id:`normal`,label:`Normal`},{id:`high`,label:`High`},{id:`max`,label:`Max`}],c1e=[{id:`adaptive`,label:`Adaptive`},{id:`enabled`,label:`Enabled`},{id:`disabled`,label:`Disabled`}],l1e=[{id:`default`,label:`Default`},{id:`acceptEdits`,label:`Accept Edits`},{id:`plan`,label:`Plan`},{id:`dontAsk`,label:`Don't Ask`}];function u1e(e){return!e||e.type===`adaptive`?`Adaptive`:e.type===`enabled`?`Enabled`:`Disabled`}function d1e(e){var t=w9.find(function(t){return t.id===e});return t?t.label:e}function f1e({settings:e,updateSection:t}){var[n,r]=(0,x.useState)(e.claudeMd??``),[i,a]=(0,x.useState)(e.defaultModel),[o,s]=(0,x.useState)(e.defaultEffort),[c,l]=(0,x.useState)(e.thinking),[u,d]=(0,x.useState)(e.permissionMode),[f,p]=(0,x.useState)(e.thinking?.type===`enabled`?e.thinking.budgetTokens??1e4:1e4),[m,h]=(0,x.useState)(!1),g=e9();(0,x.useEffect)(function(){g.savingRef.current?g.confirmSave():(r(e.claudeMd??``),a(e.defaultModel),s(e.defaultEffort),l(e.thinking),d(e.permissionMode),e.thinking?.type===`enabled`&&p(e.thinking.budgetTokens??1e4),g.resetFromServer())},[e]);function _(){g.startSave();var e=c;e?.type===`enabled`&&(e={type:`enabled`,budgetTokens:f}),t(`claude`,{claudeMd:n||void 0,defaultModel:i,defaultEffort:o,thinking:e,permissionMode:u})}var v=e.global.defaultModel||w9[0].id,y=e.global.defaultEffort||`normal`;return(0,b.jsxs)(`div`,{className:`py-2 space-y-6`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{htmlFor:`project-claude-md`,className:`block text-[12px] font-semibold text-base-content/40 mb-2`,children:`Project CLAUDE.md`}),(0,b.jsx)(`textarea`,{id:`project-claude-md`,value:n,onChange:function(e){r(e.target.value),g.markDirty()},placeholder:`# Project-specific instructions for Claude...`,rows:10,className:`w-full px-3 py-2.5 bg-base-300 border border-base-content/15 rounded-xl text-base-content text-[12px] font-mono leading-relaxed resize-y focus:border-primary focus-visible:outline-none transition-colors duration-[120ms]`}),(function(){var e=n?n.split(`
659
+ `).length:0,t=e>200;return(0,b.jsxs)(`div`,{className:`flex items-center justify-between mt-1.5`,children:[(0,b.jsxs)(`div`,{className:`text-[11px] `+(t?`text-warning`:`text-base-content/25`),children:[e,` line`,e===1?``:`s`,t?` — consider moving content to rules or imports`:``]}),t&&(0,b.jsx)(`div`,{className:`text-[10px] text-warning/70`,children:`soft limit: 200 lines`})]})})(),(0,b.jsxs)(`button`,{type:`button`,onClick:function(){h(!m)},className:`flex items-center gap-1.5 mt-2 text-[11px] text-base-content/40 hover:text-base-content/60 transition-colors`,children:[m?(0,b.jsx)(iu,{size:12}):(0,b.jsx)(cu,{size:12}),`Global CLAUDE.md (inherited)`]}),m&&(0,b.jsx)(`textarea`,{readOnly:!0,value:e.global.claudeMd,rows:8,className:`w-full mt-2 px-3 py-2.5 bg-base-300 border border-base-content/15 rounded-xl text-base-content/30 text-[12px] font-mono leading-relaxed resize-y cursor-default focus-visible:outline-none`})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{htmlFor:`project-default-model`,className:`block text-[12px] font-semibold text-base-content/40 mb-2`,children:`Default Model`}),(0,b.jsxs)(`select`,{id:`project-default-model`,value:i??``,onChange:function(e){a(e.target.value||void 0),g.markDirty()},className:`w-full h-9 px-3 bg-base-300 border border-base-content/15 rounded-xl text-base-content text-[13px] focus:border-primary focus-visible:outline-none transition-colors duration-[120ms]`,children:[(0,b.jsxs)(`option`,{value:``,className:`bg-base-300`,children:[`Use global default (`,d1e(v),`)`]}),w9.map(function(e){return(0,b.jsx)(`option`,{value:e.id,className:`bg-base-300`,children:e.label},e.id)})]}),i&&(0,b.jsx)(`button`,{type:`button`,onClick:function(){a(void 0),g.markDirty()},className:`mt-1.5 text-[11px] text-primary/70 hover:text-primary transition-colors`,children:`Clear override`})]}),(0,b.jsxs)(`div`,{role:`radiogroup`,"aria-label":`Default Effort`,children:[(0,b.jsx)(`div`,{className:`text-[12px] font-semibold text-base-content/40 mb-2`,children:`Default Effort`}),(0,b.jsxs)(`div`,{className:`flex gap-2`,children:[(0,b.jsxs)(`button`,{role:`radio`,"aria-checked":o===void 0,onClick:function(){s(void 0),g.markDirty()},className:`flex-1 py-2.5 sm:py-1.5 rounded-lg border text-[12px] transition-colors duration-[120ms] cursor-pointer focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-1 focus-visible:ring-offset-base-100 `+(o===void 0?`border-primary bg-base-300 text-base-content font-semibold`:`border-base-content/15 bg-base-300 text-base-content/40 hover:border-base-content/30 hover:text-base-content/60`),children:[`Global (`,y,`)`]}),s1e.map(function(e){var t=o===e.id;return(0,b.jsx)(`button`,{role:`radio`,"aria-checked":t,onClick:function(){s(e.id),g.markDirty()},className:`flex-1 py-2.5 sm:py-1.5 rounded-lg border text-[12px] transition-colors duration-[120ms] cursor-pointer focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-1 focus-visible:ring-offset-base-100 `+(t?`border-primary bg-base-300 text-base-content font-semibold`:`border-base-content/15 bg-base-300 text-base-content/40 hover:border-base-content/30 hover:text-base-content/60`),children:e.label},e.id)})]})]}),(0,b.jsxs)(`div`,{role:`radiogroup`,"aria-label":`Thinking Mode`,children:[(0,b.jsx)(`div`,{className:`text-[12px] font-semibold text-base-content/40 mb-2`,children:`Thinking Mode`}),(0,b.jsxs)(`div`,{className:`flex gap-2`,children:[(0,b.jsxs)(`button`,{role:`radio`,"aria-checked":c===void 0,onClick:function(){l(void 0),g.markDirty()},className:`flex-1 py-2.5 sm:py-1.5 rounded-lg border text-[12px] transition-colors duration-[120ms] cursor-pointer focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-1 focus-visible:ring-offset-base-100 `+(c===void 0?`border-primary bg-base-300 text-base-content font-semibold`:`border-base-content/15 bg-base-300 text-base-content/40 hover:border-base-content/30 hover:text-base-content/60`),children:[`Global (`,u1e(e.global.thinking),`)`]}),c1e.map(function(e){var t=c?.type===e.id;return(0,b.jsx)(`button`,{role:`radio`,"aria-checked":t,onClick:function(){l(e.id===`enabled`?{type:`enabled`,budgetTokens:f}:{type:e.id}),g.markDirty()},className:`flex-1 py-2.5 sm:py-1.5 rounded-lg border text-[12px] transition-colors duration-[120ms] cursor-pointer focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-1 focus-visible:ring-offset-base-100 `+(t?`border-primary bg-base-300 text-base-content font-semibold`:`border-base-content/15 bg-base-300 text-base-content/40 hover:border-base-content/30 hover:text-base-content/60`),children:e.label},e.id)})]}),c?.type===`enabled`&&(0,b.jsxs)(`div`,{className:`mt-3`,children:[(0,b.jsx)(`label`,{htmlFor:`budget-tokens`,className:`block text-[11px] text-base-content/40 mb-1.5`,children:`Budget Tokens`}),(0,b.jsx)(`input`,{id:`budget-tokens`,type:`number`,min:1e3,step:1e3,value:f,onChange:function(e){var t=parseInt(e.target.value,10);isNaN(t)||(p(t),l({type:`enabled`,budgetTokens:t}),g.markDirty())},className:`w-48 h-9 px-3 bg-base-300 border border-base-content/15 rounded-xl text-base-content text-[13px] font-mono focus:border-primary focus-visible:outline-none transition-colors duration-[120ms]`})]})]}),(0,b.jsxs)(`div`,{role:`radiogroup`,"aria-label":`Permission Mode`,children:[(0,b.jsx)(`div`,{className:`text-[12px] font-semibold text-base-content/40 mb-2`,children:`Permission Mode`}),(0,b.jsx)(`div`,{className:`flex gap-2`,children:l1e.map(function(e){var t=(u??`default`)===e.id;return(0,b.jsx)(`button`,{role:`radio`,"aria-checked":t,onClick:function(){d(e.id===`default`?void 0:e.id),g.markDirty()},className:`flex-1 py-2.5 sm:py-1.5 rounded-lg border text-[12px] transition-colors duration-[120ms] cursor-pointer focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-1 focus-visible:ring-offset-base-100 `+(t?`border-primary bg-base-300 text-base-content font-semibold`:`border-base-content/15 bg-base-300 text-base-content/40 hover:border-base-content/30 hover:text-base-content/60`),children:e.label},e.id)})})]}),(0,b.jsx)(r9,{dirty:g.dirty,saving:g.saving,saveState:g.saveState,onSave:_})]})}function T9(){return Math.random().toString(36).slice(2,10)}function p1e(e){var t={};return e.forEach(function(e){e.key.trim()&&(t[e.key.trim()]=e.value)}),t}function E9(e){return Object.entries(e).map(function([e,t]){return{id:T9(),key:e,value:t}})}function m1e({settings:e,updateSection:t}){var n=e.global.env??{},r=Object.entries(n),[i,a]=(0,x.useState)(function(){return E9(e.env??{})}),o=e9();(0,x.useEffect)(function(){o.savingRef.current?o.confirmSave():(a(E9(e.env??{})),o.resetFromServer())},[e]);var s=(0,x.useMemo)(function(){return new Set(Object.keys(n))},[n]),c=(0,x.useMemo)(function(){return a9(i)},[i]),l=c.size>0;function u(){a(function(e){return[...e,{id:T9(),key:``,value:``}]}),o.markDirty()}function d(e){a(function(t){return t.filter(function(t){return t.id!==e})}),o.markDirty()}function f(e,t){a(function(n){return n.map(function(n){return n.id===e?{...n,key:t}:n})}),o.markDirty()}function p(e,t){a(function(n){return n.map(function(n){return n.id===e?{...n,value:t}:n})}),o.markDirty()}function m(){o.startSave(),t(`environment`,{env:p1e(i)})}var h=`w-full h-9 sm:h-7 px-3 bg-base-300 border border-base-content/15 rounded-xl text-base-content font-mono text-[12px] focus:border-primary focus-visible:outline-none transition-colors duration-[120ms]`;return(0,b.jsxs)(`div`,{className:`py-2`,children:[(0,b.jsxs)(`div`,{className:`mb-6`,children:[(0,b.jsx)(`h2`,{className:`text-[12px] font-semibold text-base-content/40 mb-3`,children:`Global Variables`}),r.length===0&&(0,b.jsx)(`div`,{className:`py-4 text-center text-[13px] text-base-content/30`,children:`No global environment variables.`}),r.length>0&&(0,b.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:r.map(function([e,t]){return(0,b.jsxs)(`div`,{className:`flex flex-col sm:grid sm:grid-cols-[1fr_1fr_auto] gap-1.5 sm:items-center`,children:[(0,b.jsx)(`div`,{className:`h-9 sm:h-7 px-3 bg-base-300/50 border border-base-content/10 rounded-xl flex items-center font-mono text-[12px] text-base-content/40`,children:e}),(0,b.jsx)(`div`,{className:`flex gap-1.5 items-center`,children:(0,b.jsx)(`div`,{className:`h-9 sm:h-7 px-3 bg-base-300/50 border border-base-content/10 rounded-xl flex items-center font-mono text-[12px] text-base-content/40 w-full`,children:String(t)})}),(0,b.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider text-base-content/30 w-7 text-center hidden sm:block`,children:`global`})]},e)})})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`h2`,{className:`text-[12px] font-semibold text-base-content/40 mb-3`,children:`Project Variables`}),(0,b.jsxs)(`div`,{className:`flex flex-col gap-3 sm:gap-1.5 mb-3`,children:[i.length===0&&(0,b.jsx)(`div`,{className:`py-4 text-center text-[13px] text-base-content/30`,children:`No project environment variables.`}),i.map(function(e,t){var n=e.key.trim()!==``&&c.has(e.key.trim()),r=e.key.trim()!==``&&s.has(e.key.trim());return(0,b.jsxs)(`div`,{className:`flex flex-col sm:grid sm:grid-cols-[1fr_1fr_auto] gap-1.5 sm:items-center`,children:[(0,b.jsxs)(`div`,{className:`relative`,children:[(0,b.jsx)(`input`,{type:`text`,value:e.key,onChange:function(t){f(e.id,t.target.value)},placeholder:`VARIABLE_NAME`,"aria-label":`Variable name for row `+(t+1),"aria-invalid":n,className:`w-full h-9 sm:h-7 px-3 bg-base-300 border rounded-xl text-base-content font-mono text-[12px] focus:border-primary focus-visible:outline-none transition-colors duration-[120ms] `+(n?`border-warning`:`border-base-content/15`)}),n&&(0,b.jsxs)(`div`,{className:`flex items-center gap-1 mt-0.5 text-[10px] text-warning sm:absolute sm:-bottom-3.5 sm:left-0`,role:`alert`,children:[(0,b.jsx)(Ev,{size:9}),`Duplicate key`]}),!n&&r&&(0,b.jsx)(`div`,{className:`flex items-center gap-1 mt-0.5 text-[10px] text-warning/70 sm:absolute sm:-bottom-3.5 sm:left-0`,children:`overrides global`})]}),(0,b.jsxs)(`div`,{className:`flex gap-1.5 items-center`,children:[(0,b.jsx)(`input`,{type:`text`,value:e.value,onChange:function(t){p(e.id,t.target.value)},placeholder:`value`,"aria-label":`Value for `+(e.key||`row `+(t+1)),className:h}),(0,b.jsx)(`button`,{onClick:function(){d(e.id)},"aria-label":`Delete `+(e.key||`row `+(t+1)),title:`Delete`,className:`btn btn-ghost btn-xs btn-square text-base-content/30 hover:text-error w-9 h-9 flex-shrink-0 sm:hidden focus-visible:ring-2 focus-visible:ring-primary`,children:(0,b.jsx)(Nv,{size:14})})]}),(0,b.jsx)(`button`,{onClick:function(){d(e.id)},"aria-label":`Delete `+(e.key||`row `+(t+1)),title:`Delete`,className:`btn btn-ghost btn-xs btn-square text-base-content/30 hover:text-error w-7 h-7 hidden sm:flex focus-visible:ring-2 focus-visible:ring-primary`,children:(0,b.jsx)(Nv,{size:12})})]},e.id)})]}),(0,b.jsxs)(`button`,{onClick:u,className:`flex items-center gap-1.5 px-3 py-2.5 sm:py-1.5 rounded-xl border border-dashed border-base-content/20 bg-transparent text-base-content/40 text-[12px] hover:text-base-content/60 hover:border-base-content/30 transition-colors duration-[120ms] mb-5 cursor-pointer focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-1 focus-visible:ring-offset-base-100`,children:[(0,b.jsx)(tv,{size:12}),`Add Variable`]}),(0,b.jsx)(r9,{dirty:o.dirty,saving:o.saving,saveState:o.saveState,onSave:m,extraStatus:l?`Duplicate keys will be merged`:void 0})]})]})}function D9({rules:e,onDelete:t,readOnly:n,labelPrefix:r}){return e.length===0?(0,b.jsx)(`div`,{className:`py-3 text-center text-[13px] text-base-content/30`,children:`No rules defined.`}):(0,b.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:e.map(function(e,i){return(0,b.jsxs)(`div`,{className:`flex items-center gap-2 h-9 sm:h-7 px-3 rounded-xl border font-mono text-[12px] `+(n?`bg-base-300/50 border-base-content/10 text-base-content/40`:`bg-base-300 border-base-content/15 text-base-content`),children:[(0,b.jsx)(`span`,{className:`flex-1 truncate`,children:e}),n&&(0,b.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider text-base-content/30 flex-shrink-0`,children:`global`}),!n&&t&&(0,b.jsx)(`button`,{onClick:function(){t(i)},"aria-label":`Delete `+(r||``)+` rule: `+e,title:`Delete`,className:`btn btn-ghost btn-xs btn-square text-base-content/30 hover:text-error flex-shrink-0 focus-visible:ring-2 focus-visible:ring-primary`,children:(0,b.jsx)(Nv,{size:12})})]},e+`-`+i)})})}function O9({onAdd:e,label:t}){var[n,r]=(0,x.useState)(``);function i(){var t=n.trim();t&&(e(t),r(``))}function a(e){e.key===`Enter`&&(e.preventDefault(),i())}return(0,b.jsxs)(`div`,{className:`flex items-center gap-1.5 mt-1.5`,children:[(0,b.jsx)(`input`,{type:`text`,value:n,onChange:function(e){r(e.target.value)},onKeyDown:a,placeholder:`e.g. Bash(curl:*)`,"aria-label":t,className:`flex-1 h-9 sm:h-7 px-3 bg-base-300 border border-base-content/15 rounded-xl text-base-content font-mono text-[12px] focus:border-primary focus-visible:outline-none transition-colors duration-[120ms]`}),(0,b.jsxs)(`button`,{onClick:i,disabled:!n.trim(),className:`flex items-center gap-1.5 px-3 h-9 sm:h-7 rounded-xl border border-dashed border-base-content/20 bg-transparent text-base-content/40 text-[12px] hover:text-base-content/60 hover:border-base-content/30 transition-colors duration-[120ms] cursor-pointer focus-visible:ring-2 focus-visible:ring-primary`+(n.trim()?``:` opacity-50 cursor-not-allowed`),children:[(0,b.jsx)(tv,{size:12}),`Add`]})]})}function h1e({settings:e,updateSection:t}){var[n,r]=(0,x.useState)(function(){return[...e.permissions.allow??[]]}),[i,a]=(0,x.useState)(function(){return[...e.permissions.deny??[]]}),o=e9();(0,x.useEffect)(function(){o.savingRef.current?o.confirmSave():(r([...e.permissions.allow??[]]),a([...e.permissions.deny??[]]),o.resetFromServer())},[e]);function s(e){r(function(t){var n=[...t];return n.splice(e,1),n}),o.markDirty()}function c(e){a(function(t){var n=[...t];return n.splice(e,1),n}),o.markDirty()}function l(e){r(function(t){return[...t,e]}),o.markDirty()}function u(e){a(function(t){return[...t,e]}),o.markDirty()}function d(){o.startSave(),t(`permissions`,{allow:n,deny:i})}var f=e.global.permissions?.allow??[],p=e.global.permissions?.deny??[];return(0,b.jsxs)(`div`,{className:`py-2`,children:[(0,b.jsxs)(`div`,{className:`mb-6`,children:[(0,b.jsx)(`h2`,{className:`text-[12px] font-semibold text-base-content/40 mb-3`,children:`Allow Rules`}),(0,b.jsx)(D9,{rules:n,onDelete:s,labelPrefix:`allow`}),(0,b.jsx)(O9,{onAdd:l,label:`New allow rule`})]}),(0,b.jsxs)(`div`,{className:`mb-6`,children:[(0,b.jsx)(`h2`,{className:`text-[12px] font-semibold text-base-content/40 mb-3`,children:`Deny Rules`}),(0,b.jsx)(D9,{rules:i,onDelete:c,labelPrefix:`deny`}),(0,b.jsx)(O9,{onAdd:u,label:`New deny rule`})]}),(0,b.jsx)(`div`,{className:`mb-8`,children:(0,b.jsx)(r9,{dirty:o.dirty,saving:o.saving,saveState:o.saveState,onSave:d})}),(f.length>0||p.length>0)&&(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`h2`,{className:`text-[12px] font-semibold text-base-content/40 mb-3`,children:`Global Permissions`}),f.length>0&&(0,b.jsxs)(`div`,{className:`mb-4`,children:[(0,b.jsx)(`div`,{className:`text-[11px] text-base-content/40 uppercase tracking-wider mb-1.5`,children:`Allow`}),(0,b.jsx)(D9,{rules:f,readOnly:!0})]}),p.length>0&&(0,b.jsxs)(`div`,{className:`mb-4`,children:[(0,b.jsx)(`div`,{className:`text-[11px] text-base-content/40 uppercase tracking-wider mb-1.5`,children:`Deny`}),(0,b.jsx)(D9,{rules:p,readOnly:!0})]})]})]})}function g1e({settings:e,projectSlug:t}){var{send:n,subscribe:r,unsubscribe:i}=R(),a=e.global.skills,o=e.skills,s=a.length>0||o.length>0,[c,l]=(0,x.useState)(null);(0,x.useEffect)(function(){function e(e){if(e.type===`skills:view_result`){var t=e;l({path:t.path,content:t.content})}}return r(`skills:view_result`,e),function(){i(`skills:view_result`,e)}},[]);function u(e){n({type:`skills:view`,path:e})}return(0,b.jsxs)(`div`,{className:`py-2 space-y-6`,children:[!s&&(0,b.jsx)(`div`,{className:`py-12 text-center text-[13px] text-base-content/40`,children:`No skills found.`}),a.length>0&&(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-[12px] font-semibold text-base-content/40 mb-2`,children:`Global Skills`}),(0,b.jsx)(`div`,{className:`space-y-2`,children:a.map(function(e){return(0,b.jsx)(h9,{skill:e,badge:`global`,onClick:function(){u(e.path)}},e.path)})})]}),o.length>0&&(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-[12px] font-semibold text-base-content/40 mb-2`,children:`Project Skills`}),(0,b.jsx)(`div`,{className:`space-y-2`,children:o.map(function(e){return(0,b.jsx)(h9,{skill:e,onClick:function(){u(e.path)}},e.path)})})]}),(0,b.jsx)(m9,{defaultScope:`project`,defaultProjectSlug:t}),c&&(0,b.jsx)(g9,{path:c.path,content:c.content,onClose:function(){l(null)}})]})}function _1e({settings:e,updateSection:t}){var n=e.global.rules??[],[r,i]=(0,x.useState)(function(){return(e.rules??[]).map(function(e){return{filename:e.filename,content:e.content}})}),[a,o]=(0,x.useState)(new Set),[s,c]=(0,x.useState)(new Set),[l,u]=(0,x.useState)(!1),[d,f]=(0,x.useState)(``),[p,m]=(0,x.useState)(``),h=e9();(0,x.useEffect)(function(){h.savingRef.current?h.confirmSave():(i((e.rules??[]).map(function(e){return{filename:e.filename,content:e.content}})),h.resetFromServer())},[e]);function g(e){o(function(t){var n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}function _(e){c(function(t){var n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}function v(e,t){i(function(n){return n.map(function(n,r){return r===e?{...n,content:t}:n})}),h.markDirty()}function y(e){i(function(t){return t.filter(function(t,n){return n!==e})}),c(new Set),h.markDirty()}function S(){var e=d.trim();!e||!e.endsWith(`.md`)||(i(function(t){return[...t,{filename:e,content:p}]}),f(``),m(``),u(!1),h.markDirty())}function C(){u(!1),f(``),m(``)}function w(){h.startSave(),t(`rules`,{rules:r})}function T(e){var t=e.trim();return t.length<=80?t:t.slice(0,80)+`...`}var E=`w-full px-3 py-2 bg-base-300 border border-base-content/15 rounded-xl text-base-content font-mono text-[12px] focus:border-primary focus-visible:outline-none transition-colors duration-[120ms] resize-y min-h-[120px]`,D=`w-full h-9 sm:h-7 px-3 bg-base-300 border border-base-content/15 rounded-xl text-base-content font-mono text-[12px] focus:border-primary focus-visible:outline-none transition-colors duration-[120ms]`;return(0,b.jsxs)(`div`,{className:`py-2`,children:[(0,b.jsxs)(`a`,{href:`https://docs.anthropic.com/en/docs/claude-code/memory`,target:`_blank`,rel:`noopener noreferrer`,className:`text-[11px] text-base-content/30 hover:text-primary/70 flex items-center gap-1 mb-4 transition-colors`,children:[(0,b.jsx)(um,{size:11}),`Claude Code docs`]}),(0,b.jsxs)(`div`,{className:`mb-6`,children:[(0,b.jsx)(`h2`,{className:`text-[12px] font-semibold text-base-content/40 mb-3`,children:`Global Rules`}),n.length===0&&(0,b.jsx)(`div`,{className:`py-4 text-center text-[13px] text-base-content/30`,children:`No global rules.`}),n.length>0&&(0,b.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:n.map(function(e,t){var n=a.has(t);return(0,b.jsxs)(`div`,{className:`border border-base-content/10 rounded-xl overflow-hidden`,children:[(0,b.jsxs)(`button`,{onClick:function(){g(t)},className:`w-full flex items-center gap-2 px-3 py-2 bg-base-300/50 hover:bg-base-300/70 transition-colors duration-[120ms] cursor-pointer text-left`,children:[n?(0,b.jsx)(iu,{size:12,className:`text-base-content/40 flex-shrink-0`}):(0,b.jsx)(cu,{size:12,className:`text-base-content/40 flex-shrink-0`}),(0,b.jsx)(`span`,{className:`font-mono text-[12px] text-base-content/40 flex-1 truncate`,children:e.filename}),(0,b.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider text-base-content/30`,children:`global`})]}),!n&&(0,b.jsx)(`div`,{className:`px-3 py-1.5 text-[11px] text-base-content/30 font-mono truncate`,children:T(e.content)}),n&&(0,b.jsx)(`pre`,{className:`px-3 py-2 text-[12px] text-base-content/40 font-mono whitespace-pre-wrap break-words bg-base-300/30 max-h-[300px] overflow-auto`,children:e.content})]},e.filename+`-`+t)})})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`h2`,{className:`text-[12px] font-semibold text-base-content/40 mb-3`,children:`Project Rules`}),r.length===0&&!l&&(0,b.jsx)(`div`,{className:`py-4 text-center text-[13px] text-base-content/30 mb-3`,children:`No project rules.`}),r.length>0&&(0,b.jsx)(`div`,{className:`flex flex-col gap-1.5 mb-3`,children:r.map(function(e,t){var n=s.has(t);return(0,b.jsxs)(`div`,{className:`border border-base-content/15 rounded-xl overflow-hidden`,children:[(0,b.jsxs)(`div`,{className:`w-full flex items-center gap-2 px-3 py-2 bg-base-300 text-left`,children:[(0,b.jsxs)(`button`,{onClick:function(){_(t)},className:`flex items-center gap-2 flex-1 min-w-0 cursor-pointer hover:text-base-content/80 transition-colors`,children:[n?(0,b.jsx)(iu,{size:12,className:`text-base-content/60 flex-shrink-0`}):(0,b.jsx)(cu,{size:12,className:`text-base-content/60 flex-shrink-0`}),(0,b.jsx)(`span`,{className:`font-mono text-[12px] text-base-content flex-1 truncate text-left`,children:e.filename})]}),(0,b.jsx)(`button`,{onClick:function(){y(t)},className:`btn btn-ghost btn-xs btn-square text-base-content/30 hover:text-error flex-shrink-0 focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":`Delete `+e.filename,children:(0,b.jsx)(Nv,{size:14})})]}),!n&&(0,b.jsx)(`div`,{className:`px-3 py-1.5 text-[11px] text-base-content/50 font-mono truncate`,children:T(e.content)}),n&&(0,b.jsx)(`div`,{className:`px-3 py-2 bg-base-300/30`,children:(0,b.jsx)(`textarea`,{value:e.content,onChange:function(e){v(t,e.target.value)},className:E,rows:8,"aria-label":`Content for `+e.filename})})]},e.filename+`-`+t)})}),l&&(0,b.jsxs)(`div`,{className:`border border-dashed border-base-content/20 rounded-xl p-3 mb-3 flex flex-col gap-2`,children:[(0,b.jsx)(`input`,{type:`text`,value:d,onChange:function(e){f(e.target.value)},placeholder:`filename.md`,"aria-label":`New rule filename`,className:D}),(0,b.jsx)(`textarea`,{value:p,onChange:function(e){m(e.target.value)},placeholder:`Rule content...`,"aria-label":`New rule content`,className:E,rows:5}),(0,b.jsxs)(`div`,{className:`flex gap-2 justify-end`,children:[(0,b.jsx)(`button`,{onClick:C,className:`btn btn-ghost btn-sm text-[12px]`,children:`Cancel`}),(0,b.jsx)(`button`,{onClick:S,disabled:!d.trim()||!d.trim().endsWith(`.md`),className:`btn btn-sm btn-primary text-[12px]`+(!d.trim()||!d.trim().endsWith(`.md`)?` opacity-50 cursor-not-allowed`:``),children:`Add`})]})]}),!l&&(0,b.jsxs)(`button`,{onClick:function(){u(!0)},className:`flex items-center gap-1.5 px-3 py-2.5 sm:py-1.5 rounded-xl border border-dashed border-base-content/20 bg-transparent text-base-content/40 text-[12px] hover:text-base-content/60 hover:border-base-content/30 transition-colors duration-[120ms] mb-5 cursor-pointer focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-1 focus-visible:ring-offset-base-100`,children:[(0,b.jsx)(tv,{size:12}),`Add Rule`]}),(0,b.jsx)(r9,{dirty:h.dirty,saving:h.saving,saveState:h.saveState,onSave:w})]})]})}function v1e({settings:e,updateSection:t}){var n=e.global.mcpServers??{},r=Object.entries(n),[i,a]=(0,x.useState)(function(){return{...e.mcpServers??{}}}),o=e9(),[s,c]=(0,x.useState)(!1),[l,u]=(0,x.useState)(c9),[d,f]=(0,x.useState)(null),[p,m]=(0,x.useState)(c9),[h,g]=(0,x.useState)(null);(0,x.useEffect)(function(){o.savingRef.current?o.confirmSave():(a({...e.mcpServers??{}}),o.resetFromServer())},[e]);var _=Object.entries(i);function v(){var e=l.name.trim();e&&(a({...i,[e]:u9(l)}),c(!1),u(c9()),o.markDirty())}function y(e){f(e),m(l9(e,i[e])),c(!1),g(null)}function S(){if(d){var e=p.name.trim();if(e){var t={...i};e!==d&&delete t[d],t[e]=u9(p),a(t),f(null),o.markDirty()}}}function C(e){if(h!==e){g(e);return}var t={...i};delete t[e],a(t),d===e&&f(null),g(null),o.markDirty()}function w(){o.startSave(),t(`mcp`,{mcpServers:i})}var T=new Set(Object.keys(i)),E=new Set(Object.keys(i).filter(function(e){return e!==d}));return(0,b.jsxs)(`div`,{className:`py-2`,children:[(0,b.jsxs)(`div`,{className:`mb-6`,children:[(0,b.jsx)(`h2`,{className:`text-[12px] font-semibold text-base-content/40 mb-3`,children:`Global MCP Servers`}),r.length===0&&(0,b.jsx)(`div`,{className:`py-4 text-center text-[13px] text-base-content/30`,children:`No global MCP servers.`}),r.length>0&&(0,b.jsx)(`div`,{className:`flex flex-col gap-2`,children:r.map(function([e,t]){return(0,b.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-2 rounded-xl bg-base-300/50 border border-base-content/10`,children:[(0,b.jsx)(`span`,{className:`font-mono text-[12px] text-base-content/40 font-semibold flex-shrink-0`,children:e}),d9(t),(0,b.jsx)(`div`,{className:`flex-1 min-w-0`,children:f9(t)}),(0,b.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider text-base-content/30 flex-shrink-0`,children:`global`})]},e)})})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`h2`,{className:`text-[12px] font-semibold text-base-content/40 mb-3`,children:`Project MCP Servers`}),_.length===0&&!s&&(0,b.jsx)(`div`,{className:`py-4 text-center text-[13px] text-base-content/30 mb-3`,children:`No project MCP servers.`}),(0,b.jsx)(`div`,{className:`flex flex-col gap-2 mb-3`,children:_.map(function([e,t]){if(d===e)return(0,b.jsx)(p9,{form:p,setForm:m,onSave:S,onCancel:function(){f(null)},existingNames:E,idPrefix:`mcp-edit`},e);var n=h===e;return(0,b.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-2 rounded-xl bg-base-300 border border-base-content/15`,children:[(0,b.jsx)(`span`,{className:`font-mono text-[12px] text-base-content font-semibold flex-shrink-0`,children:e}),d9(t),(0,b.jsx)(`div`,{className:`flex-1 min-w-0`,children:f9(t)}),n?(0,b.jsxs)(`div`,{className:`flex gap-1.5 flex-shrink-0`,children:[(0,b.jsx)(`button`,{onClick:function(){C(e)},className:`btn btn-error btn-xs`,children:`Confirm`}),(0,b.jsx)(`button`,{onClick:function(){g(null)},className:`btn btn-ghost btn-xs`,children:`Cancel`})]}):(0,b.jsxs)(`div`,{className:`flex gap-1 flex-shrink-0`,children:[(0,b.jsx)(`button`,{onClick:function(){y(e)},"aria-label":`Edit `+e,className:`btn btn-ghost btn-xs btn-square text-base-content/30 hover:text-primary focus-visible:ring-2 focus-visible:ring-primary`,children:(0,b.jsx)($_,{size:12})}),(0,b.jsx)(`button`,{onClick:function(){C(e)},"aria-label":`Delete `+e,className:`btn btn-ghost btn-xs btn-square text-base-content/30 hover:text-error focus-visible:ring-2 focus-visible:ring-primary`,children:(0,b.jsx)(Tv,{size:12})})]})]},e)})}),s&&(0,b.jsx)(`div`,{className:`mb-3`,children:(0,b.jsx)(p9,{form:l,setForm:u,onSave:v,onCancel:function(){c(!1),u(c9())},existingNames:T,idPrefix:`mcp-add`})}),!s&&(0,b.jsxs)(`button`,{onClick:function(){c(!0),f(null),g(null)},className:`flex items-center gap-1.5 px-3 py-2.5 sm:py-1.5 rounded-xl border border-dashed border-base-content/20 bg-transparent text-base-content/40 text-[12px] hover:text-base-content/60 hover:border-base-content/30 transition-colors duration-[120ms] mb-5 cursor-pointer focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-1 focus-visible:ring-offset-base-100`,children:[(0,b.jsx)(tv,{size:12}),`Add Server`]}),(0,b.jsx)(r9,{dirty:o.dirty,saving:o.saving,saveState:o.saveState,onSave:w})]})]})}function y1e(e){return localStorage.getItem(`lattice-mute-`+e)===`1`}function b1e(e,t){localStorage.setItem(`lattice-mute-`+e,t?`1`:`0`)}function x1e({projectSlug:e}){var t=e??``,[n,r]=(0,x.useState)(function(){return y1e(t)});function i(){var e=!n;r(e),b1e(t,e)}return(0,b.jsx)(`div`,{className:`py-2 space-y-6`,children:(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`h2`,{className:`text-[12px] font-semibold text-base-content/40 mb-3`,children:`Project Notifications`}),(0,b.jsxs)(`div`,{className:`flex items-center justify-between py-2 px-3 bg-base-300 border border-base-content/15 rounded-xl`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-[13px] text-base-content`,children:`Mute all notifications`}),(0,b.jsx)(`div`,{className:`text-[11px] text-base-content/30 mt-0.5`,children:`Suppress all browser notifications from this project`})]}),(0,b.jsx)(`input`,{type:`checkbox`,className:`toggle toggle-sm toggle-primary`,checked:n,onChange:i})]})]})})}function S1e({settings:e,updateSection:t}){var{send:n,subscribe:r,unsubscribe:i}=R(),[a,o]=(0,x.useState)([]),[s,c]=(0,x.useState)(!1),[l,u]=(0,x.useState)(e.disabledPlugins??[]),[d,f]=(0,x.useState)(!1);(0,x.useEffect)(function(){function e(e){e.type===`plugin:list_result`&&(o(e.plugins),c(!0))}return r(`plugin:list_result`,e),n({type:`plugin:list`}),function(){i(`plugin:list_result`,e)}},[]),(0,x.useEffect)(function(){u(e.disabledPlugins??[])},[e.disabledPlugins]);function p(e){var n=l.indexOf(e)===-1?l.concat(e):l.filter(function(t){return t!==e});u(n),f(!0),t(`plugins`,{disabledPlugins:n}),setTimeout(function(){f(!1)},500)}if(!s)return(0,b.jsx)(`div`,{className:`text-[13px] text-base-content/40 py-4`,children:`Loading...`});if(a.length===0)return(0,b.jsx)(`div`,{className:`py-6 text-center text-[13px] text-base-content/30`,children:`No plugins installed. Install plugins from Global Settings to use them in projects.`});var m=a.length-l.length;return(0,b.jsxs)(`div`,{className:`py-2 space-y-4`,children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,b.jsx)(`p`,{className:`text-[12px] text-base-content/40`,children:`Toggle plugins on/off for this project. Disabled plugins won't load in new sessions.`}),d&&(0,b.jsx)(C_,{size:12,className:`text-primary animate-spin`})]}),(0,b.jsxs)(`div`,{className:`text-[11px] text-base-content/30 mb-1`,children:[m,` of `,a.length,` enabled`]}),(0,b.jsx)(`div`,{className:`space-y-1.5`,children:a.map(function(e){var t=l.indexOf(e.key)!==-1;return(0,b.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-2.5 rounded-xl border transition-colors duration-[120ms] `+(t?`bg-base-300/30 border-base-content/8 opacity-50`:`bg-base-300 border-base-content/15`),children:[(0,b.jsx)(fs,{size:14,className:`text-base-content/25 flex-shrink-0`}),(0,b.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(`span`,{className:`text-[13px] font-bold text-base-content truncate`,children:e.name}),(0,b.jsxs)(`span`,{className:`text-[10px] font-mono px-1.5 py-0.5 rounded-md bg-base-content/8 text-base-content/40`,children:[`v`,e.version]})]}),(0,b.jsxs)(`div`,{className:`text-[11px] text-base-content/30 mt-0.5`,children:[e.marketplace,e.skillCount>0?` · `+e.skillCount+` skill`+(e.skillCount===1?``:`s`):``]})]}),(0,b.jsx)(`input`,{type:`checkbox`,checked:!t,onChange:function(){p(e.key)},className:`toggle toggle-sm toggle-primary`,"aria-label":(t?`Enable`:`Disable`)+` `+e.name})]},e.key)})})]})}var C1e={general:{title:`General`},notifications:{title:`Notifications`},claude:{title:`Claude`},environment:{title:`Environment`},mcp:{title:`MCP Servers`},skills:{title:`Skills`},plugins:{title:`Plugins`},rules:{title:`Rules`},permissions:{title:`Permissions`},memory:{title:`Memory`}};function w1e(e,t,n,r){return e===`general`?(0,b.jsx)(o1e,{settings:t,updateSection:n}):e===`claude`?(0,b.jsx)(f1e,{settings:t,updateSection:n}):e===`environment`?(0,b.jsx)(m1e,{settings:t,updateSection:n}):e===`permissions`?(0,b.jsx)(h1e,{settings:t,updateSection:n}):e===`skills`?(0,b.jsx)(g1e,{settings:t,projectSlug:r}):e===`plugins`?(0,b.jsx)(S1e,{settings:t,updateSection:n}):e===`rules`?(0,b.jsx)(_1e,{settings:t,updateSection:n}):e===`mcp`?(0,b.jsx)(v1e,{settings:t,updateSection:n}):e===`memory`?(0,b.jsx)(v9,{projectSlug:r}):e===`notifications`?(0,b.jsx)(x1e,{projectSlug:r}):(0,b.jsxs)(`div`,{className:`py-2 text-[13px] text-base-content/40`,children:[e,` section coming soon.`]})}function T1e(){var{activeView:e,activeProjectSlug:t,toggleDrawer:n}=jy();if(e.type!==`project-settings`)return null;var r=e.section,i=C1e[r],{settings:a,loading:o,error:s,updateSection:c}=C9(t);return(0,b.jsxs)(`section`,{"aria-label":`Project Settings`,className:`flex-1 overflow-auto px-4 sm:px-8 py-4 sm:py-6 max-w-3xl`,children:[i&&(0,b.jsxs)(`div`,{className:`mb-6 flex items-center gap-3`,children:[(0,b.jsx)(`button`,{className:`btn btn-ghost btn-sm btn-square lg:hidden`,"aria-label":`Toggle sidebar`,onClick:n,children:(0,b.jsx)(B_,{size:18})}),(0,b.jsx)(`h1`,{className:`text-lg font-mono font-bold text-base-content`,children:i.title})]}),o&&(0,b.jsx)(`div`,{className:`text-[13px] text-base-content/40 py-4`,children:`Loading...`}),s&&(0,b.jsx)(`div`,{className:`text-[13px] text-error py-4`,children:s}),!o&&!s&&a&&w1e(r,a,c,t??void 0)]})}function E1e(e){var t=Date.now()-e,n=Math.floor(t/1e3);if(n<60)return n+`s ago`;var r=Math.floor(n/60);if(r<60)return r+`m ago`;var i=Math.floor(r/60);return i<24?i+`h ago`:Math.floor(i/24)+`d ago`}function D1e(){Cb();var{nodes:e}=Ay(),{projects:t}=Dy(),n=jy(),{send:r,subscribe:i,unsubscribe:a}=R(),[o,s]=(0,x.useState)([]),[c,l]=(0,x.useState)(null),u=(0,x.useMemo)(function(){return e.filter(function(e){return e.online})},[e]);(0,x.useEffect)(function(){function e(e){e.type===`session:list_all`&&s(e.sessions)}function t(e){e.type===`settings:data`&&l(e.config)}return i(`session:list_all`,e),i(`settings:data`,t),r({type:`session:list_all_request`}),r({type:`settings:get`}),function(){a(`session:list_all`,e),a(`settings:data`,t)}},[]);var d=(0,x.useMemo)(function(){for(var e=new Map,n=0;n<t.length;n++)e.set(t[n].slug,t[n].title);return e},[t]);function f(e){return d.get(e)||e}var p=(0,x.useMemo)(function(){for(var e=new Map,t=0;t<o.length;t++){var n=o[t],r=e.get(n.projectSlug);r||(r=[],e.set(n.projectSlug,r)),r.push(n)}return e},[o]),m=e.filter(function(e){return!e.isLocal});return(0,b.jsx)(`div`,{className:`flex-1 overflow-auto`,children:(0,b.jsxs)(`div`,{className:`max-w-2xl mx-auto px-4 sm:px-8 py-6 sm:py-10`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-3 mb-2`,children:[(0,b.jsx)(`button`,{className:`btn btn-ghost btn-sm btn-square lg:hidden`,"aria-label":`Toggle sidebar`,onClick:n.toggleDrawer,children:(0,b.jsx)(B_,{size:18})}),(0,b.jsx)(Iv,{size:28}),(0,b.jsx)(`h1`,{className:`text-lg font-mono font-bold text-base-content`,children:`Lattice`})]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-4 text-[11px] font-mono text-base-content/30 mb-10 ml-[43px]`,children:[(0,b.jsxs)(`span`,{children:[u.length,`/`,e.length,` nodes`]}),(0,b.jsx)(`span`,{className:`text-base-content/15`,children:`/`}),(0,b.jsxs)(`span`,{children:[t.length,` projects`]}),(0,b.jsx)(`span`,{className:`text-base-content/15`,children:`/`}),(0,b.jsxs)(`span`,{children:[o.length,` sessions`]})]}),(0,b.jsx)(`div`,{className:`mb-12`,children:(0,b.jsx)(hQ,{})}),o.length>0&&(0,b.jsxs)(`div`,{className:`mb-12`,children:[(0,b.jsx)(`h2`,{className:`text-[11px] font-semibold tracking-wider uppercase text-base-content/40 mb-3`,children:`Recent Sessions`}),(0,b.jsx)(`div`,{className:`flex flex-col gap-1`,children:o.slice(0,8).map(function(e){return(0,b.jsxs)(`button`,{onClick:function(){Gv(e.id,e.projectSlug,e.title),n.navigateToSession(e.projectSlug,e.id)},className:`flex items-center gap-3 px-3 py-2 rounded-lg hover:bg-base-200 transition-colors duration-[120ms] cursor-pointer text-left focus-visible:ring-2 focus-visible:ring-primary group`,children:[(0,b.jsx)(U_,{size:12,className:`text-base-content/20 flex-shrink-0`}),(0,b.jsx)(`span`,{className:`flex-1 text-[12px] text-base-content/70 truncate group-hover:text-base-content`,children:wb(e.title)||`Untitled`}),(0,b.jsx)(`span`,{className:`text-[10px] font-mono text-base-content/25 flex-shrink-0`,children:f(e.projectSlug)}),(0,b.jsx)(`span`,{className:`text-[10px] text-base-content/20 font-mono flex-shrink-0`,children:E1e(e.updatedAt)}),(0,b.jsx)(cu,{size:10,className:`text-base-content/15 flex-shrink-0 opacity-0 group-hover:opacity-100`})]},e.id)})})]}),t.length>0&&(0,b.jsxs)(`div`,{className:`mb-12`,children:[(0,b.jsx)(`h2`,{className:`text-[11px] font-semibold tracking-wider uppercase text-base-content/40 mb-3`,children:`Projects`}),(0,b.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2`,children:t.map(function(e){var t=p.get(e.slug)||[];return(0,b.jsxs)(`button`,{onClick:function(){n.setActiveProjectSlug(e.slug)},className:`flex items-center gap-3 px-3 py-2.5 rounded-lg hover:bg-base-200 transition-colors duration-[120ms] cursor-pointer text-left focus-visible:ring-2 focus-visible:ring-primary group`,children:[(0,b.jsx)(Wm,{size:14,className:`text-base-content/20 flex-shrink-0`}),(0,b.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,b.jsx)(`div`,{className:`text-[13px] font-semibold text-base-content/70 truncate group-hover:text-base-content`,children:e.title}),(0,b.jsxs)(`div`,{className:`text-[10px] text-base-content/25 font-mono`,children:[t.length,` session`,t.length===1?``:`s`,e.isRemote&&(0,b.jsxs)(`span`,{className:`ml-1.5 text-base-content/20`,children:[`on `,e.nodeName]})]})]}),(0,b.jsx)(cu,{size:12,className:`text-base-content/15 flex-shrink-0 opacity-0 group-hover:opacity-100`})]},e.slug+`@`+e.nodeId)})})]}),m.length>0&&(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`h2`,{className:`text-[11px] font-semibold tracking-wider uppercase text-base-content/40 mb-3`,children:`Mesh`}),(0,b.jsx)(`div`,{className:`flex flex-wrap gap-x-6 gap-y-2`,children:m.map(function(e){return(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.online?(0,b.jsx)(Hu,{size:10,className:`text-success flex-shrink-0`}):(0,b.jsx)(md,{size:10,className:`text-base-content/20 flex-shrink-0`}),(0,b.jsx)(`span`,{className:`text-[12px] text-base-content/50`,children:e.name}),(0,b.jsxs)(`span`,{className:`text-[10px] text-base-content/20 font-mono`,children:[e.projects.length,`p`]})]},e.id)})})]})]})})}function k9({label:e,value:t,icon:n,loading:r}){return(0,b.jsxs)(`div`,{className:`bg-base-300 rounded-xl border border-base-content/15 p-3 px-4`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2 mb-1.5`,children:[n,(0,b.jsx)(`span`,{className:`text-[11px] font-semibold tracking-wider uppercase text-base-content/40`,children:e})]}),r?(0,b.jsx)(`div`,{className:`h-7 w-10 bg-base-content/10 rounded animate-pulse`}):(0,b.jsx)(`div`,{className:`text-xl font-mono font-bold text-base-content`,children:t})]})}function A9({label:e,icon:t,onClick:n}){return(0,b.jsxs)(`button`,{onClick:n,className:`flex items-center gap-2.5 px-3 py-2 rounded-xl border border-base-content/15 bg-base-300 text-[12px] text-base-content/60 hover:text-base-content hover:border-base-content/30 transition-colors duration-[120ms] cursor-pointer focus-visible:ring-2 focus-visible:ring-primary`,children:[t,(0,b.jsx)(`span`,{className:`flex-1 text-left`,children:e}),(0,b.jsx)(cu,{size:12,className:`text-base-content/30`})]})}function O1e(){var e=jy();if(e.activeView.type!==`project-dashboard`)return null;var{settings:t,loading:n}=C9(e.activeProjectSlug),{projects:r}=Dy(),{send:i,subscribe:a,unsubscribe:o,status:s}=R(),[c,l]=(0,x.useState)([]),[u,d]=(0,x.useState)(!0),f=r.find(function(t){return t.slug===e.activeProjectSlug}),p=f?.title??e.activeProjectSlug??`Project`;(0,x.useEffect)(function(){if(!e.activeProjectSlug)return;function t(t){if(t.type===`session:list`){var n=t;n.projectSlug===e.activeProjectSlug&&(l(n.sessions.slice().sort(function(e,t){return t.updatedAt-e.updatedAt})),d(!1))}}return a(`session:list`,t),s===`connected`&&(d(!0),i({type:`session:list_request`,projectSlug:e.activeProjectSlug})),function(){o(`session:list`,t)}},[e.activeProjectSlug,s]);function m(t){e.openProjectSettings(t)}function h(t){f&&(Gv(t.id,f.slug,t.title),e.setActiveSessionId(t.id))}var g=c.length,_=t?Object.keys(t.mcpServers).length:0,v=t?Object.keys(t.global.mcpServers).length:0,y=t?t.rules.length:0,S=t?t.global.rules.length:0,C=t?Object.keys(t.env).length:0;return(0,b.jsxs)(`div`,{className:`flex-1 overflow-auto px-4 sm:px-8 py-4 sm:py-6 max-w-3xl`,children:[(0,b.jsxs)(`div`,{className:`mb-6 flex items-center gap-3`,children:[(0,b.jsx)(`button`,{className:`btn btn-ghost btn-sm btn-square lg:hidden`,"aria-label":`Toggle sidebar`,onClick:e.toggleDrawer,children:(0,b.jsx)(B_,{size:18})}),(0,b.jsx)(`h1`,{className:`text-lg font-mono font-bold text-base-content`,children:p})]}),(0,b.jsxs)(`div`,{className:`space-y-6`,children:[(0,b.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-3`,children:[(0,b.jsx)(k9,{label:`Sessions`,value:g,icon:(0,b.jsx)(U_,{size:14,className:`text-primary`}),loading:u}),(0,b.jsx)(k9,{label:`MCP Servers`,value:_+v,icon:(0,b.jsx)(ev,{size:14,className:`text-accent`}),loading:n}),(0,b.jsx)(k9,{label:`Rules`,value:y+S,icon:(0,b.jsx)(uv,{size:14,className:`text-info`}),loading:n}),(0,b.jsx)(k9,{label:`Env Vars`,value:C,icon:(0,b.jsx)(Cv,{size:14,className:`text-success`}),loading:n})]}),n?(0,b.jsx)(`div`,{className:`bg-base-content/10 rounded-xl h-32 animate-pulse`}):t?.claudeMd?(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-[12px] font-semibold text-base-content/40 mb-2`,children:`CLAUDE.md`}),(0,b.jsx)(`div`,{className:`px-3 py-2.5 bg-base-300 border border-base-content/15 rounded-xl font-mono text-[11px] text-base-content/60 leading-relaxed max-h-48 overflow-y-auto`,children:(0,b.jsx)(`pre`,{className:`whitespace-pre-wrap`,children:t.claudeMd})})]}):null,(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-[12px] font-semibold text-base-content/40 mb-2`,children:`Recent Sessions`}),u?(0,b.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:[0,1,2].map(function(e){return(0,b.jsx)(`div`,{className:`bg-base-content/10 rounded-xl h-10 animate-pulse`},e)})}):c.length>0?(0,b.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:c.slice(0,5).map(function(e){return(0,b.jsxs)(`button`,{onClick:function(){h(e)},className:`flex items-center gap-3 px-3 py-2 rounded-xl border border-base-content/15 bg-base-300 hover:border-base-content/30 transition-colors duration-[120ms] cursor-pointer text-left focus-visible:ring-2 focus-visible:ring-primary`,children:[(0,b.jsx)(U_,{size:12,className:`text-base-content/30 flex-shrink-0`}),(0,b.jsx)(`span`,{className:`flex-1 text-[12px] text-base-content truncate`,children:e.title||`Untitled`}),(0,b.jsx)(`span`,{className:`text-[10px] text-base-content/30 font-mono flex-shrink-0`,children:new Date(e.updatedAt).toLocaleDateString()}),(0,b.jsx)(cu,{size:12,className:`text-base-content/20 flex-shrink-0`})]},e.id)})}):(0,b.jsx)(`div`,{className:`text-[12px] text-base-content/30`,children:`No sessions yet`})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-[12px] font-semibold text-base-content/40 mb-2`,children:`Settings`}),(0,b.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-3 gap-2`,children:[(0,b.jsx)(A9,{label:`General`,icon:(0,b.jsx)(hv,{size:13,className:`text-base-content/40`}),onClick:function(){m(`general`)}}),(0,b.jsx)(A9,{label:`Claude`,icon:(0,b.jsx)(Vm,{size:13,className:`text-base-content/40`}),onClick:function(){m(`claude`)}}),(0,b.jsx)(A9,{label:`Environment`,icon:(0,b.jsx)(Cv,{size:13,className:`text-base-content/40`}),onClick:function(){m(`environment`)}}),(0,b.jsx)(A9,{label:`MCP Servers`,icon:(0,b.jsx)(ev,{size:13,className:`text-base-content/40`}),onClick:function(){m(`mcp`)}}),(0,b.jsx)(A9,{label:`Rules`,icon:(0,b.jsx)(uv,{size:13,className:`text-base-content/40`}),onClick:function(){m(`rules`)}}),(0,b.jsx)(A9,{label:`Permissions`,icon:(0,b.jsx)(gv,{size:13,className:`text-base-content/40`}),onClick:function(){m(`permissions`)}})]})]}),t&&(0,b.jsx)(`div`,{className:`text-[11px] text-base-content/30 font-mono truncate`,children:t.path})]})]})}function k1e({isOpen:e,onClose:t}){var{send:n,subscribe:r,unsubscribe:i}=R(),{nodes:a}=Ay(),o=e9(),s=a.find(function(e){return e.isLocal}),c=s?s.id:``,[l,u]=(0,x.useState)(null),[d,f]=(0,x.useState)(``),[p,m]=(0,x.useState)(7654),[h,g]=(0,x.useState)(!1),[_,v]=(0,x.useState)(!1),[y,S]=(0,x.useState)(!1),[C,w]=(0,x.useState)(`auto`),T=(0,x.useRef)(null),E=(0,x.useRef)(null);Wr(E,(0,x.useCallback)(function(){t()},[t]),e),(0,x.useEffect)(function(){if(!e)return;function t(e){if(e.type===`settings:data`){var t=e.config;u(t),o.saving?o.confirmSave():(f(t.name),m(t.port),g(t.tls),v(t.debug),w(t.wsl??`auto`),o.resetFromServer())}}return r(`settings:data`,t),n({type:`settings:get`}),function(){i(`settings:data`,t)}},[e]),(0,x.useEffect)(function(){return function(){T.current&&clearTimeout(T.current)}},[]);function D(){o.startSave(),n({type:`settings:update`,settings:{name:d,port:p,tls:h,debug:_,wsl:C}})}function O(){c&&(navigator.clipboard.writeText(c),S(!0),T.current&&clearTimeout(T.current),T.current=setTimeout(function(){S(!1)},2e3))}if(!e)return null;var k=`w-full h-9 px-3 bg-base-300 border border-base-content/15 rounded-xl text-base-content text-[13px] focus:border-primary focus-visible:outline-none transition-colors duration-[120ms]`;return(0,b.jsxs)(`div`,{ref:E,className:`fixed inset-0 z-[9999] flex items-center justify-center`,role:`dialog`,"aria-modal":`true`,"aria-label":`Node Settings`,children:[(0,b.jsx)(`div`,{className:`absolute inset-0 bg-base-content/50`,onClick:t}),(0,b.jsxs)(`div`,{className:`relative bg-base-200 border border-base-content/15 rounded-2xl shadow-2xl w-full max-w-md mx-4 overflow-hidden`,children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between px-5 py-4 border-b border-base-content/15`,children:[(0,b.jsx)(`h2`,{className:`text-[15px] font-mono font-bold text-base-content`,children:`Node Settings`}),(0,b.jsx)(`button`,{onClick:t,"aria-label":`Close`,className:`btn btn-ghost btn-xs btn-square text-base-content/40 hover:text-base-content`,children:(0,b.jsx)(Nv,{size:16})})]}),(0,b.jsxs)(`div`,{className:`px-5 py-4 space-y-4 max-h-[70vh] overflow-y-auto`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{htmlFor:`node-id`,className:`block text-[12px] font-semibold text-base-content/40 mb-1.5`,children:`Node ID`}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(`div`,{className:`flex-1 h-9 px-3 bg-base-300/50 border border-base-content/10 rounded-xl font-mono text-[11px] text-base-content/50 flex items-center truncate select-all`,children:c||`Loading...`}),(0,b.jsx)(`button`,{onClick:O,disabled:!c,"aria-label":`Copy node ID`,className:`btn btn-ghost btn-sm btn-square text-base-content/30 hover:text-base-content flex-shrink-0`,children:y?(0,b.jsx)(L,{size:14,className:`text-success`}):(0,b.jsx)(Yf,{size:14})})]})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{htmlFor:`node-name`,className:`block text-[12px] font-semibold text-base-content/40 mb-1.5`,children:`Node Name`}),(0,b.jsx)(`input`,{id:`node-name`,type:`text`,value:d,onChange:function(e){f(e.target.value),o.markDirty()},placeholder:`My Node`,className:k})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{htmlFor:`node-port`,className:`block text-[12px] font-semibold text-base-content/40 mb-1.5`,children:`Port`}),(0,b.jsx)(`input`,{id:`node-port`,type:`number`,value:p,onChange:function(e){var t=parseInt(e.target.value,10);isNaN(t)||(m(t),o.markDirty())},min:1,max:65535,className:k+` font-mono`})]}),(0,b.jsxs)(`div`,{className:`flex items-center justify-between py-1`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-[12px] font-semibold text-base-content/40`,children:`TLS`}),(0,b.jsx)(`div`,{className:`text-[11px] text-base-content/30`,children:`Encrypt connections between nodes`})]}),(0,b.jsx)(`input`,{type:`checkbox`,checked:h,onChange:function(e){g(e.target.checked),o.markDirty()},className:`toggle toggle-sm toggle-primary`,"aria-label":`Enable TLS`})]}),(0,b.jsxs)(`div`,{className:`flex items-center justify-between py-1`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-[12px] font-semibold text-base-content/40`,children:`Debug Mode`}),(0,b.jsx)(`div`,{className:`text-[11px] text-base-content/30`,children:`Enable verbose logging`})]}),(0,b.jsx)(`input`,{type:`checkbox`,checked:_,onChange:function(e){v(e.target.checked),o.markDirty()},className:`toggle toggle-sm toggle-primary`,"aria-label":`Enable debug mode`})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-[12px] font-semibold text-base-content/40 mb-1.5`,children:`WSL Mode`}),(0,b.jsx)(`div`,{className:`text-[11px] text-base-content/30 mb-2`,children:`Convert file paths for Windows editors when running under WSL`}),(0,b.jsxs)(`select`,{value:String(C),onChange:function(e){var t=e.target.value;w(t===`true`?!0:t===`false`?!1:`auto`),o.markDirty()},className:k,children:[(0,b.jsx)(`option`,{value:`auto`,children:`Auto-detect`}),(0,b.jsx)(`option`,{value:`true`,children:`Enabled`}),(0,b.jsx)(`option`,{value:`false`,children:`Disabled`})]})]})]}),(0,b.jsx)(`div`,{className:`px-5 py-3 border-t border-base-content/15`,children:(0,b.jsx)(r9,{dirty:o.dirty,saving:o.saving,saveState:o.saveState,onSave:D})})]})]})}function A1e({isOpen:e,onClose:t}){var{send:n,subscribe:r,unsubscribe:i}=R(),{projects:a}=Dy(),[o,s]=(0,x.useState)(``),[c,l]=(0,x.useState)([]),[u,d]=(0,x.useState)(``),[f,p]=(0,x.useState)(!1),[m,h]=(0,x.useState)(!1),[g,_]=(0,x.useState)(-1),[v,y]=(0,x.useState)(null),[S,C]=(0,x.useState)(!1),[w,T]=(0,x.useState)([]),[E,D]=(0,x.useState)(``),O=(0,x.useRef)(null),k=(0,x.useRef)(null),A=(0,x.useRef)(null),j=(0,x.useRef)(!1),M=(0,x.useRef)(!1),N=(0,x.useRef)(null);Wr(N,(0,x.useCallback)(function(){t()},[t]),e),(0,x.useEffect)(function(){if(!e)return;s(``),l([]),d(``),p(!1),h(!1),y(null),C(!1),T([]),M.current=!1,n({type:`browse:list`,path:`~`}),n({type:`browse:suggestions`});function a(e){if(e.type===`browse:list_result`){var t=e;l(t.entries),D(t.homedir),_(-1),j.current&&t.entries.length>0&&h(!0)}}function o(e){e.type===`browse:suggestions_result`&&T(e.suggestions)}function c(e){e.type===`projects:list`&&M.current&&(M.current=!1,C(!1),t())}return r(`browse:list_result`,a),r(`browse:suggestions_result`,o),r(`projects:list`,c),function(){i(`browse:list_result`,a),i(`browse:suggestions_result`,o),i(`projects:list`,c)}},[e]),(0,x.useEffect)(function(){if(!e)return;function t(e){A.current&&!A.current.contains(e.target)&&k.current&&!k.current.contains(e.target)&&h(!1)}return document.addEventListener(`mousedown`,t),function(){document.removeEventListener(`mousedown`,t)}},[e]),(0,x.useEffect)(function(){if(e){O.current&&clearTimeout(O.current);var t=o.trim();if(!t){n({type:`browse:list`,path:`~`});return}O.current=setTimeout(function(){var e=t;if(!t.endsWith(`/`)){var r=t.lastIndexOf(`/`);e=r>=0?t.slice(0,r+1):t}n({type:`browse:list`,path:e})},200)}},[o,e]);function ee(e){return e.startsWith(`~/`)&&E?E+e.slice(1):e===`~`&&E?E:e}function te(e){s(e.path+`/`),h(!1),y(null),f||(e.projectName?d(e.projectName):d(e.name)),n({type:`browse:list`,path:e.path}),k.current&&k.current.focus()}function P(e){d(e),p(e.length>0)}function F(){j.current=!0,re().length>0&&h(!0)}function ne(){j.current=!1}function re(){var e=o.trim();if(!e||e.endsWith(`/`))return c;var t=e.lastIndexOf(`/`),n=t>=0?e.slice(t+1).toLowerCase():e.toLowerCase();return n?c.filter(function(e){return e.name.toLowerCase().startsWith(n)}):c}function ie(){var e=o.trim();if(!e)return!1;var t=ee(e.endsWith(`/`)?e.slice(0,-1):e);return!a.some(function(e){return e.path===t})}function ae(){var e=o.trim();if(!e)return{type:`info`,text:`Type a path to browse directories`};var t=ee(e.endsWith(`/`)?e.slice(0,-1):e);return a.some(function(e){return e.path===t})?{type:`error`,text:`Already added as a project`}:null}function oe(e){var t=re();if(!m||t.length===0){e.key===`Enter`&&ce&&(e.preventDefault(),le());return}e.key===`ArrowDown`?(e.preventDefault(),_(function(e){var n=e+1;return n>=t.length&&(n=0),se(n),n})):e.key===`ArrowUp`?(e.preventDefault(),_(function(e){var n=e-1;return n<0&&(n=t.length-1),se(n),n})):e.key===`Tab`||e.key===`Enter`?g>=0&&g<t.length?(e.preventDefault(),te(t[g]),_(-1)):e.key===`Enter`&&ce&&(e.preventDefault(),le()):e.key===`Escape`&&(e.stopPropagation(),h(!1),_(-1))}function se(e){if(A.current){var t=A.current.children;t[e]&&t[e].scrollIntoView({block:`nearest`})}}var ce=ie()&&!S;function le(){var e=o.trim();if(!(!e||S)){var t=ee(e.endsWith(`/`)?e.slice(0,-1):e),r=u.trim()||t.split(`/`).pop()||`Untitled`;C(!0),M.current=!0,n({type:`settings:update`,settings:{projects:[{path:t,title:r}]}})}}if(!e)return null;var ue=re(),de=ae();return(0,b.jsxs)(`div`,{ref:N,className:`fixed inset-0 z-[9999] flex items-center justify-center`,role:`dialog`,"aria-modal":`true`,"aria-label":`Add Project`,children:[(0,b.jsx)(`div`,{className:`absolute inset-0 bg-base-content/50`,onClick:t}),(0,b.jsxs)(`div`,{className:`relative bg-base-200 border border-base-content/15 rounded-2xl shadow-2xl w-full max-w-3xl mx-4 overflow-hidden`,children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between px-5 py-4 border-b border-base-content/15`,children:[(0,b.jsx)(`h2`,{className:`text-[15px] font-mono font-bold text-base-content`,children:`Add Project`}),(0,b.jsx)(`button`,{onClick:t,"aria-label":`Close`,className:`btn btn-ghost btn-xs btn-square text-base-content/40 hover:text-base-content`,children:(0,b.jsx)(Nv,{size:16})})]}),(0,b.jsxs)(`div`,{className:`px-5 py-4 space-y-4`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{htmlFor:`project-path`,className:`block text-[12px] font-semibold text-base-content/40 mb-1.5`,children:`Project Path`}),(0,b.jsxs)(`div`,{className:`relative`,children:[(0,b.jsx)(`input`,{ref:k,id:`project-path`,type:`text`,value:o,onChange:function(e){s(e.target.value),h(!0),_(-1),y(null)},onFocus:F,onBlur:ne,onKeyDown:oe,placeholder:`~/projects/my-app`,autoFocus:!0,className:`w-full h-9 px-3 bg-base-300 border border-base-content/15 rounded-xl text-base-content font-mono text-[12px] focus:border-primary focus-visible:outline-none transition-colors duration-[120ms]`}),m&&ue.length>0&&(0,b.jsx)(`div`,{ref:A,className:`absolute top-full left-0 right-0 mt-1 z-50 bg-base-200 border border-base-content/15 rounded-xl shadow-lg max-h-48 overflow-y-auto`,children:ue.map(function(e,t){return(0,b.jsxs)(`button`,{onMouseDown:function(e){e.preventDefault()},onClick:function(){te(e),_(-1)},onMouseEnter:function(){_(t)},className:`w-full flex items-center gap-2 px-3 py-2 text-left text-[12px] font-mono transition-colors duration-[80ms] `+(t===g?`bg-base-content/10 text-base-content`:`text-base-content/60 hover:bg-base-content/5 hover:text-base-content`),children:[(0,b.jsx)(Wm,{size:12,className:`text-base-content/25 flex-shrink-0`}),(0,b.jsxs)(`span`,{className:`flex-1 truncate`,children:[e.name,`/`]}),e.projectName&&(0,b.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded-md bg-accent/15 text-accent/70 flex-shrink-0 truncate max-w-[100px]`,children:e.projectName}),e.hasClaudeMd&&(0,b.jsxs)(`span`,{className:`flex items-center gap-0.5 text-[10px] px-1.5 py-0.5 rounded-md bg-primary/15 text-primary/70 flex-shrink-0`,children:[(0,b.jsx)(Vm,{size:8}),`CLAUDE.md`]})]},e.path)})})]}),(0,b.jsx)(`div`,{className:`text-[10px] text-base-content/25 mt-1`,children:`Type a path or click directories to navigate`}),!o.trim()&&w.length>0&&!m&&(0,b.jsxs)(`div`,{className:`mt-2`,children:[(0,b.jsx)(`div`,{className:`text-[11px] font-semibold text-base-content/30 mb-1.5`,children:`Projects Claude has worked in`}),(0,b.jsx)(`div`,{className:`flex flex-col gap-1 max-h-48 overflow-y-auto`,children:w.map(function(e){return(0,b.jsxs)(`button`,{title:e.path,onClick:function(){s(e.path+`/`),f||d(e.name),T([]),n({type:`browse:list`,path:e.path})},className:`w-full flex items-center gap-2 px-3 py-1.5 text-left text-[12px] font-mono text-base-content/50 hover:bg-base-content/5 hover:text-base-content rounded-lg transition-colors duration-[80ms]`,children:[(0,b.jsx)(Wm,{size:12,className:`text-base-content/25 flex-shrink-0`}),(0,b.jsx)(`span`,{className:`flex-1 truncate`,children:e.path}),e.hasClaudeMd&&(0,b.jsxs)(`span`,{className:`flex items-center gap-0.5 text-[10px] px-1.5 py-0.5 rounded-md bg-primary/15 text-primary/70 flex-shrink-0`,children:[(0,b.jsx)(Vm,{size:8}),`CLAUDE.md`]})]},e.path)})})]})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsxs)(`label`,{htmlFor:`project-title`,className:`block text-[12px] font-semibold text-base-content/40 mb-1.5`,children:[`Title `,(0,b.jsx)(`span`,{className:`font-normal opacity-60`,children:`(optional)`})]}),(0,b.jsx)(`input`,{id:`project-title`,type:`text`,value:u,onChange:function(e){P(e.target.value)},placeholder:`Auto-derived from path`,className:`w-full h-9 px-3 bg-base-300 border border-base-content/15 rounded-xl text-base-content text-[13px] focus:border-primary focus-visible:outline-none transition-colors duration-[120ms]`})]}),de&&(0,b.jsx)(`div`,{className:`flex items-center gap-2 px-3 py-2 rounded-xl border text-[11px] `+(de.type===`error`?`bg-error/10 border-error/20 text-error`:de.type===`success`?`bg-success/10 border-success/20 text-success`:`bg-base-content/5 border-base-content/10 text-base-content/40`),children:de.text})]}),(0,b.jsxs)(`div`,{className:`px-5 py-3 border-t border-base-content/15 flex justify-end gap-2`,children:[(0,b.jsx)(`button`,{onClick:t,className:`btn btn-ghost btn-sm text-[12px]`,children:`Cancel`}),(0,b.jsx)(`button`,{onClick:le,disabled:!ce,className:`btn btn-primary btn-sm text-[12px]`+(ce?``:` opacity-50 cursor-not-allowed`),children:S?(0,b.jsx)(C_,{size:14,className:`animate-spin`}):`Add Project`})]})]})]})}function j1e(){var{activeProject:e}=Dy(),{nodes:t}=Ay(),n=jy();if(!e||!e.isRemote||n.activeView.type!==`chat`)return null;var r=t.find(function(t){return t.id===e.nodeId});return!r||r.online?null:(0,b.jsx)(`div`,{className:`absolute inset-0 z-40 flex items-center justify-center bg-base-100/80 backdrop-blur-sm`,children:(0,b.jsxs)(`div`,{className:`bg-base-300 border border-base-content/15 rounded-2xl shadow-2xl px-8 py-6 max-w-sm text-center`,children:[(0,b.jsx)(Av,{size:28,className:`text-warning mx-auto mb-3`}),(0,b.jsx)(`h3`,{className:`text-[15px] font-mono font-bold text-base-content mb-1`,children:`Node Disconnected`}),(0,b.jsxs)(`p`,{className:`text-[13px] text-base-content/50 mb-3`,children:[(0,b.jsx)(`span`,{className:`font-semibold text-base-content/70`,children:r.name}),` is unreachable.`]}),(0,b.jsxs)(`div`,{className:`flex items-center justify-center gap-2 text-[12px] text-base-content/40`,children:[(0,b.jsx)(C_,{size:12,className:`animate-spin`}),`Attempting to reconnect...`]}),(0,b.jsx)(`p`,{className:`text-[11px] text-base-content/25 mt-3`,children:`Session state preserved. Operations will resume on reconnect.`})]})})}var j9=15,M9=.35,M1e=.4,N9=`translate 0.25s cubic-bezier(0.4, 0, 0.2, 1)`,P9=`opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1)`,F9=`transform 0.25s cubic-bezier(0.4, 0, 0.2, 1)`;function N1e(e,t,n,r){var i=(0,x.useRef)({isOpen:t,onOpen:n,onClose:r});i.current={isOpen:t,onOpen:n,onClose:r},(0,x.useEffect)(function(){var t=0,n=0,r=0,a=0,o=0,s=!1,c=!1,l=null,u=null,d=null,f=null,p=0;function m(){var t=e.current;if(!t)return!1;u=t.querySelector(`:scope > *:not(.drawer-overlay)`),d=t.querySelector(`:scope > .drawer-overlay`);var n=t.parentElement;return n&&(f=n.querySelector(`:scope > .drawer-content`)),u&&(p=u.getBoundingClientRect().width),!!u}function h(e){if(u){var t=Math.max(-p,Math.min(0,e)),n=1+t/p;if(u.style.transition=`none`,u.style.translate=t+`px`,d&&(d.style.transition=`none`,d.style.opacity=String(n)),f){var r=1-n*.03;f.style.transition=`none`,f.style.transform=`scale(`+r+`)`,f.style.transformOrigin=`left center`}}}function g(){u&&(u.style.transition=``,u.style.translate=``),d&&(d.style.transition=``,d.style.opacity=``),f&&(f.style.transition=``,f.style.transform=``,f.style.transformOrigin=``)}function _(){u&&(u.style.transition=N9,u.style.translate=`0%`,d&&(d.style.transition=P9,d.style.opacity=`1`),f&&(f.style.transition=F9,f.style.transform=`scale(0.97)`,f.style.transformOrigin=`left center`))}function v(){u&&(u.style.transition=N9,u.style.translate=`-100%`,d&&(d.style.transition=P9,d.style.opacity=`0`),f&&(f.style.transition=F9,f.style.transform=`scale(1)`,f.style.transformOrigin=`left center`))}var y=null;function b(){y!==null&&(clearTimeout(y),y=null)}function x(){if(b(),u){var e=!1;function t(){e||(e=!0,u&&u.removeEventListener(`transitionend`,t),b(),g())}u.addEventListener(`transitionend`,t,{once:!0}),y=setTimeout(t,350)}else g()}function S(e){if(!(window.innerWidth>=1024)){var i=e.touches[0];t=i.clientX,n=i.clientY,r=i.clientX,a=Date.now(),o=0,s=!0,c=!1,l=null}}function C(u){if(s){var d=u.touches[0],f=Date.now(),g=f-a;if(g>0&&(o=(d.clientX-r)/g),r=d.clientX,a=f,l===null){var _=Math.abs(d.clientX-t),v=Math.abs(d.clientY-n);if(_>=j9||v>=j9)if(_>v){if(l=`h`,c=!0,!m()){s=!1;return}var y=e.current;y&&(y.style.visibility=`visible`,y.style.pointerEvents=`auto`,y.style.opacity=`1`)}else{l=`v`,s=!1;return}else return}if(c){var b=d.clientX-t;i.current.isOpen?h(Math.min(0,b)):h(-p+Math.max(0,b))}}}function w(){if(!s||!c){s=!1,l=null;return}var e=r-t,n=i.current.isOpen;s=!1,c=!1,l=null,(Math.abs(o)>M1e?o>0:n?e>-p*M9:e>p*M9)?(_(),n||i.current.onOpen()):(v(),n&&i.current.onClose()),x()}function T(){if(c){g();var t=e.current;t&&(t.style.visibility=``,t.style.pointerEvents=``,t.style.opacity=``),f&&(f.style.transition=``,f.style.transform=``,f.style.transformOrigin=``)}s=!1,c=!1,l=null}return document.addEventListener(`touchstart`,S,{passive:!0}),document.addEventListener(`touchmove`,C,{passive:!0}),document.addEventListener(`touchend`,w,{passive:!0}),document.addEventListener(`touchcancel`,T,{passive:!0}),function(){b(),document.removeEventListener(`touchstart`,S),document.removeEventListener(`touchmove`,C),document.removeEventListener(`touchend`,w),document.removeEventListener(`touchcancel`,T)}},[e])}function I9(){var e=R(),[t,n]=(0,x.useState)(!1),[r,i]=(0,x.useState)(!1),[a,o]=(0,x.useState)(!1),s=(0,x.useRef)(null),c=(0,x.useRef)(0);(0,x.useEffect)(function(){var e=setTimeout(function(){i(!0)},600);return function(){clearTimeout(e)}},[]),(0,x.useEffect)(function(){if(e.status!==`connected`)return;function t(){n(!0)}return e.subscribe(`projects:list`,t),function(){e.unsubscribe(`projects:list`,t)}},[e]);var l=t&&r,u=a&&e.status!==`connected`,d=l&&!u,f=!l||u;if((0,x.useEffect)(function(){if(l&&!a){var e=setTimeout(function(){o(!0)},300);return function(){clearTimeout(e)}}},[l,a]),(0,x.useEffect)(function(){var e=s.current;if(!e)return;var t=e.getContext(`2d`);if(!t)return;var n=9,r=26,i=3.5,a=20,o=a*2+(n-1)*r,l=window.devicePixelRatio||1;e.width=o*l,e.height=o*l,e.style.width=o+`px`,e.style.height=o+`px`,t.scale(l,l);for(var u=o/2,d=o/2,f=14,p=4,m=(f*2+p)/2,h=u-m,g=d-m,_=u+m,v=d+m,y=getComputedStyle(document.documentElement).getPropertyValue(`--color-primary`).trim(),b=y?`oklch(`+y+`)`:`oklch(55% 0.25 280)`,x=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,S=[],C=0;C<n;C++)for(var w=0;w<n;w++){var T=a+w*r,E=a+C*r,D=T+i>h&&T-i<_&&E+i>g&&E-i<v;S.push({x:T,y:E,col:w,row:C,hidden:D,brightness:.08})}var O=[],k=10,A=performance.now();function j(e){for(var t=S[e],r=[],i=-1;i<=1;i++)for(var a=-1;a<=1;a++)if(!(i===0&&a===0)){var o=t.row+i,s=t.col+a;if(o>=0&&o<n&&s>=0&&s<n){var c=o*n+s;S[c].hidden||r.push(c)}}return r}function M(){t.clearRect(0,0,o,o);for(var e=0;e<S.length;e++){var n=S[e];n.hidden||(t.beginPath(),t.arc(n.x,n.y,i,0,Math.PI*2),t.fillStyle=b,t.globalAlpha=.15,t.fill(),t.globalAlpha=1)}for(var r=[[h,g],[h+f+p,g],[h,g+f+p],[h+f+p,g+f+p]],a=0;a<r.length;a++)t.fillStyle=b,t.globalAlpha=.9,t.fillRect(r[a][0],r[a][1],f,f),t.globalAlpha=1}if(x){M();return}function N(){if(A=performance.now(),t.clearRect(0,0,o,o),O.length<k&&Math.random()<.04){for(var e=[],n=0;n<S.length;n++)S[n].hidden||e.push(n);for(var r=0;r<5&&O.length<k;){var a=e[Math.floor(Math.random()*e.length)],s=j(a);if(s.length>0){for(var l=s[Math.floor(Math.random()*s.length)],u=!1,d=0;d<O.length;d++)if(O[d].a===a&&O[d].b===l||O[d].a===l&&O[d].b===a){u=!0;break}if(!u){O.push({a,b:l,birth:A,duration:2e3+Math.random()*3e3,fadeIn:400,fadeOut:400});break}}r++}}for(var m=new Set,_=[],v=0;v<O.length;v++){var y=O[v],x=A-y.birth;if(!(x>y.duration)){_.push(y);var C=1;x<y.fadeIn?C=x/y.fadeIn:x>y.duration-y.fadeOut&&(C=(y.duration-x)/y.fadeOut),m.add(y.a),m.add(y.b);var w=S[y.a],T=S[y.b];t.beginPath(),t.moveTo(w.x,w.y),t.lineTo(T.x,T.y),t.strokeStyle=b,t.globalAlpha=C*.35,t.lineWidth=1.5,t.stroke(),t.globalAlpha=1}}O=_;for(var E=0;E<S.length;E++){var D=S[E];if(!D.hidden){var M=m.has(E)?.7:.08;D.brightness+=(M-D.brightness)*.08,t.beginPath(),t.arc(D.x,D.y,i,0,Math.PI*2),t.fillStyle=b,t.globalAlpha=D.brightness,t.fill(),t.globalAlpha=1}}for(var ee=.4+.2*Math.sin(A/800),te=[[h,g],[h+f+p,g],[h,g+f+p],[h+f+p,g+f+p]],P=0;P<te.length;P++){var F=te[P][0],ne=te[P][1];t.save(),t.shadowColor=b,t.shadowBlur=8+ee*6,t.fillStyle=b,t.globalAlpha=.85+ee*.15,t.fillRect(F,ne,f,f),t.restore()}c.current=requestAnimationFrame(N)}return c.current=requestAnimationFrame(N),function(){cancelAnimationFrame(c.current)}},[]),!f&&l)return null;var p=u?`Reconnecting...`:e.status===`connecting`?`Connecting...`:`Loading projects...`;return(0,b.jsx)(`div`,{className:`fixed inset-0 z-[9999] flex flex-col items-center justify-center `+(u?`bg-base-100/90`:`bg-base-100`),style:{opacity:d?0:1,transition:`opacity 300ms ease-out`,pointerEvents:d?`none`:`auto`},children:(0,b.jsxs)(`div`,{className:`flex flex-col items-center gap-7`,children:[(0,b.jsx)(`canvas`,{ref:s}),(0,b.jsxs)(`div`,{className:`flex flex-col items-center gap-2`,children:[(0,b.jsx)(`span`,{className:`text-[16px] font-mono font-bold text-base-content tracking-tight`,children:`Lattice`}),(0,b.jsx)(`span`,{className:`text-[12px] text-base-content/40`,children:p})]})]})})}function P1e(){var e=jy(),t=R(),n=e.confirmRemoveSlug,r=(0,x.useRef)(null);return Wr(r,(0,x.useCallback)(function(){e.closeConfirmRemove()},[e.closeConfirmRemove]),!!n),n?((function(){try{return fy().state}catch{return null}})(),(0,b.jsxs)(`div`,{ref:r,className:`fixed inset-0 z-[9999] flex items-center justify-center`,role:`dialog`,"aria-modal":`true`,"aria-label":`Remove Project`,children:[(0,b.jsx)(`div`,{className:`absolute inset-0 bg-base-content/50`,onClick:e.closeConfirmRemove}),(0,b.jsxs)(`div`,{className:`relative bg-base-200 border border-base-content/15 rounded-2xl shadow-2xl w-full max-w-sm mx-4 overflow-hidden`,children:[(0,b.jsx)(`div`,{className:`px-5 py-4 border-b border-base-content/15`,children:(0,b.jsx)(`h2`,{className:`text-[15px] font-mono font-bold text-base-content`,children:`Remove Project`})}),(0,b.jsx)(`div`,{className:`px-5 py-4`,children:(0,b.jsxs)(`p`,{className:`text-[13px] text-base-content/60`,children:[`Remove `,(0,b.jsx)(`span`,{className:`font-semibold text-base-content`,children:n}),` from Lattice? This won't delete any files on disk.`]})}),(0,b.jsxs)(`div`,{className:`px-5 py-3 border-t border-base-content/15 flex justify-end gap-2`,children:[(0,b.jsx)(`button`,{onClick:e.closeConfirmRemove,className:`btn btn-ghost btn-sm text-[12px]`,children:`Cancel`}),(0,b.jsx)(`button`,{onClick:function(){t.send({type:`settings:update`,settings:{removeProject:n}}),e.activeProjectSlug===n&&e.goToDashboard(),e.closeConfirmRemove()},className:`btn btn-error btn-sm text-[12px]`,children:`Remove`})]})]})]})):null}function F1e(){var[e,t]=(0,x.useState)(null),n=R();(0,x.useEffect)(function(){function e(e){e.type===`settings:data`&&t(e.config?.setupComplete===!0)}return n.subscribe(`settings:data`,e),n.status===`connected`&&n.send({type:`settings:get`}),function(){n.unsubscribe(`settings:data`,e)}},[n.status]);var r=jy(),i=(0,x.useRef)(null);return N1e(i,r.drawerOpen,yy,by),(0,x.useEffect)(function(){function e(e){e.key===`Escape`&&fy().state.sidebarMode===`settings`&&_y()}return document.addEventListener(`keydown`,e),window.addEventListener(`popstate`,vy),function(){document.removeEventListener(`keydown`,e),window.removeEventListener(`popstate`,vy)}},[]),e===null?(0,b.jsx)(I9,{}):e?(0,b.jsxs)(`div`,{className:`flex w-full h-full overflow-hidden bg-base-100`,children:[(0,b.jsx)(`a`,{href:`#main-content`,className:`sr-only focus:not-sr-only focus:fixed focus:top-2 focus:left-2 focus:z-[99999] focus:px-4 focus:py-2 focus:bg-primary focus:text-primary-content focus:rounded-lg focus:text-sm focus:font-semibold`,children:`Skip to content`}),(0,b.jsx)(I9,{}),(0,b.jsxs)(`div`,{className:`drawer lg:drawer-open h-full w-full`,children:[(0,b.jsx)(`input`,{id:`sidebar-drawer`,type:`checkbox`,className:`drawer-toggle`,checked:r.drawerOpen,readOnly:!0}),(0,b.jsxs)(`main`,{id:`main-content`,className:`drawer-content flex flex-col h-full min-w-0 overflow-hidden relative`,children:[(0,b.jsx)(Pr,{}),(0,b.jsx)(j1e,{})]}),(0,b.jsxs)(`div`,{ref:i,className:`drawer-side z-50 h-full`,children:[(0,b.jsx)(`label`,{htmlFor:`sidebar-drawer`,"aria-label":`close sidebar`,className:`drawer-overlay`,onClick:by}),(0,b.jsx)(`nav`,{"aria-label":`Sidebar navigation`,className:`h-full w-full lg:w-[284px] flex flex-col overflow-hidden`,children:(0,b.jsx)(Bve,{onSessionSelect:by})})]})]}),(0,b.jsx)(k1e,{isOpen:r.nodeSettingsOpen,onClose:r.closeNodeSettings}),(0,b.jsx)(A1e,{isOpen:r.addProjectOpen,onClose:r.closeAddProject}),(0,b.jsx)(P1e,{})]}):(0,b.jsx)($Qe,{onComplete:function(){t(!0)}})}var I1e=class extends x.Component{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error(`[lattice] View error in `+this.props.viewName+`:`,e,t.componentStack)}render(){if(this.state.hasError){var e=this;return(0,b.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full bg-base-100 bg-lattice-grid gap-4 p-8`,children:[(0,b.jsx)(Ev,{size:32,className:`text-warning/50`}),(0,b.jsxs)(`div`,{className:`text-center max-w-[500px]`,children:[(0,b.jsxs)(`p`,{className:`text-[14px] font-mono text-base-content/60 mb-1`,children:[`Error in `,this.props.viewName]}),(0,b.jsx)(`p`,{className:`text-[12px] text-base-content/30 mb-4 font-mono break-all`,children:this.state.error?.message||`Unknown error`}),(0,b.jsxs)(`button`,{onClick:function(){e.setState({hasError:!1,error:null})},className:`btn btn-ghost btn-sm text-[12px] gap-1.5`,children:[(0,b.jsx)(ov,{size:12}),`Retry`]})]})]})}return this.props.children}};function L9(){var e=jy(),t=Vb(),n=e.activeView.type,r=t.panes.find(function(e){return e.id===t.activePaneId}),i=r?t.tabs.find(function(e){return e.id===r.activeTabId}):null;i&&i.id;var a=n===`settings`?(0,b.jsx)(r1e,{}):n===`project-settings`?(0,b.jsx)(T1e,{}):n===`dashboard`?(0,b.jsx)(D1e,{}):n===`project-dashboard`?(0,b.jsx)(O1e,{}):n===`analytics`?(0,b.jsx)(jQ,{}):(0,b.jsx)(XQe,{});return(0,b.jsx)(I1e,{viewName:n,children:a})}var R9=Tr({component:F1e}),L1e=Cr({getParentRoute:function(){return R9},path:`/`,component:L9}),R1e=Cr({getParentRoute:function(){return R9},path:`/$projectSlug`,component:L9}),z1e=Cr({getParentRoute:function(){return R9},path:`/settings/$section`,component:L9}),B1e=Cr({getParentRoute:function(){return R9},path:`/settings`,component:L9}),V1e=Cr({getParentRoute:function(){return R9},path:`/$projectSlug/settings/$section`,component:L9}),H1e=Cr({getParentRoute:function(){return R9},path:`/$projectSlug/settings`,component:L9}),U1e=zr({routeTree:R9.addChildren([L1e,B1e,z1e,H1e,V1e,R1e])}),W1e=3e4,G1e=100;function K1e(e){var[t,n]=(0,x.useState)(`connecting`),r=(0,x.useRef)(null),i=(0,x.useRef)(1e3),a=(0,x.useRef)(null),o=(0,x.useRef)(!1),s=(0,x.useRef)(new Map),c=(0,x.useRef)(!1),l=(0,x.useRef)([]);function u(){if(!o.current){var e=Jge(),t=new WebSocket(e);r.current=t,n(`connecting`),t.onopen=function(){if(o.current){t.close();return}if(n(`connected`),i.current=1e3,c.current){n9(`Reconnected to daemon`,`info`),S9(`Lattice`,`Reconnected to daemon`,`connection`),t.send(JSON.stringify({type:`settings:get`}));var e=Uy().state;e.activeProjectSlug&&e.activeSessionId&&t.send(JSON.stringify({type:`session:activate`,projectSlug:e.activeProjectSlug,sessionId:e.activeSessionId}))}c.current=!0,t.send(JSON.stringify({type:`brainstorm:status_request`}));var r=l.current;l.current=[],r.forEach(function(e){t.send(JSON.stringify(e))})},t.onmessage=function(e){try{var t=JSON.parse(e.data);t.type===`chat:done`&&document.hidden&&S9(`Claude responded`,Uy().state.activeSessionTitle||`Session`,`chat-done`),t.type===`mesh:node_online`&&S9(`Lattice`,t.nodeId+` came online`,`mesh`),t.type===`mesh:node_offline`&&S9(`Lattice`,t.nodeId+` went offline`,`mesh`);var n=s.current.get(t.type);n&&n.forEach(function(e){e(t)})}catch(e){console.warn(`[lattice] Failed to parse WebSocket message:`,e)}},t.onclose=function(){o.current||(n(`disconnected`),r.current=null,c.current&&(n9(`Disconnected from daemon. Reconnecting automatically...`,`warning`),S9(`Lattice`,`Lost connection to daemon`,`connection`)),d())},t.onerror=function(){t.close()}}}function d(){if(!o.current){var e=i.current;a.current=setTimeout(function(){i.current=Math.min(i.current*2,W1e),u()},e)}}function f(){a.current!==null&&(clearTimeout(a.current),a.current=null),i.current=1e3,r.current&&=(r.current.close(),null),u()}function p(e){var t=r.current;t&&t.readyState===WebSocket.OPEN?t.send(JSON.stringify(e)):(l.current.length>=G1e&&l.current.shift(),l.current.push(e))}function m(e,t){var n=s.current.get(e);n||(n=new Set,s.current.set(e,n)),n.add(t)}function h(e,t){var n=s.current.get(e);n&&(n.delete(t),n.size===0&&s.current.delete(e))}return(0,x.useEffect)(function(){function e(){Wv(`brainstorm`)}function t(e){e.type===`brainstorm:status`&&e.active&&Wv(`brainstorm`)}m(`brainstorm:content`,e),m(`brainstorm:status`,t);var n=Qge(function(e){e.type===`brainstorm`&&p({type:`brainstorm:stop`})});return function(){h(`brainstorm:content`,e),h(`brainstorm:status`,t),n()}},[]),(0,x.useEffect)(function(){return o.current=!1,u(),function(){o.current=!0,a.current!==null&&(clearTimeout(a.current),a.current=null),r.current&&=(r.current.close(),null)}},[]),(0,b.jsx)(Lv.Provider,{value:{status:t,send:p,subscribe:m,unsubscribe:h,reconnectNow:f},children:e.children})}var q1e=class extends x.Component{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error(`[lattice] Render error:`,e,t.componentStack)}handleReload(){window.location.reload()}render(){return this.state.hasError?this.props.fallback?this.props.fallback:(0,b.jsx)(`div`,{className:`min-h-screen bg-base-100 flex items-center justify-center`,children:(0,b.jsxs)(`div`,{className:`text-center max-w-[400px] p-8`,children:[(0,b.jsx)(`h2`,{className:`text-[20px] font-semibold text-error mb-3`,children:`Something went wrong`}),(0,b.jsx)(`p`,{className:`text-[14px] text-base-content/60 mb-5`,children:this.state.error?.message||`An unexpected error occurred.`}),(0,b.jsx)(`button`,{onClick:this.handleReload,className:`btn btn-primary btn-sm`,children:`Reload`})]})}):this.props.children}},J1e=(0,x.createContext)(null);function Y1e(){return(0,x.useContext)(J1e)?.defaultOptions??{}}function z9(){if(typeof navigator>`u`)return`linux`;let e=navigator.platform?.toLowerCase()??``,t=navigator.userAgent?.toLowerCase()??``;return e.includes(`mac`)||t.includes(`mac`)?`mac`:e.includes(`win`)||t.includes(`win`)?`windows`:`linux`}var B9=[`Control`,`Alt`,`Shift`,`Meta`];new Set(B9);var V9={Control:`Control`,Ctrl:`Control`,control:`Control`,ctrl:`Control`,Shift:`Shift`,shift:`Shift`,Alt:`Alt`,Option:`Alt`,alt:`Alt`,option:`Alt`,Command:`Meta`,Cmd:`Meta`,Meta:`Meta`,command:`Meta`,cmd:`Meta`,meta:`Meta`,CommandOrControl:`Mod`,Mod:`Mod`,commandorcontrol:`Mod`,mod:`Mod`};function H9(e,t=z9()){return e===`Mod`?t===`mac`?`Meta`:`Control`:e}var X1e=new Set(`ABCDEFGHIJKLMNOPQRSTUVWXYZ`.split(``)),Z1e=new Set([`0`,`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`]),Q1e=new Set([`F1`,`F2`,`F3`,`F4`,`F5`,`F6`,`F7`,`F8`,`F9`,`F10`,`F11`,`F12`]),$1e=new Set([`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`Home`,`End`,`PageUp`,`PageDown`]),e0e=new Set([`Enter`,`Escape`,`Space`,`Tab`,`Backspace`,`Delete`]),t0e=new Set([`/`,`[`,`]`,`\\`,`=`,`-`,`,`,`.`,`;`,"`"]),U9={Minus:`-`,Equal:`=`,Slash:`/`,BracketLeft:`[`,BracketRight:`]`,Backslash:`\\`,Comma:`,`,Period:`.`,Backquote:"`",Semicolon:`;`};new Set([...X1e,...Z1e,...Q1e,...$1e,...e0e,...t0e]);var W9={Esc:`Escape`,esc:`Escape`,escape:`Escape`,Return:`Enter`,return:`Enter`,enter:`Enter`," ":`Space`,space:`Space`,Spacebar:`Space`,spacebar:`Space`,tab:`Tab`,backspace:`Backspace`,Del:`Delete`,del:`Delete`,delete:`Delete`,Up:`ArrowUp`,up:`ArrowUp`,arrowup:`ArrowUp`,Down:`ArrowDown`,down:`ArrowDown`,arrowdown:`ArrowDown`,Left:`ArrowLeft`,left:`ArrowLeft`,arrowleft:`ArrowLeft`,Right:`ArrowRight`,right:`ArrowRight`,arrowright:`ArrowRight`,home:`Home`,end:`End`,pageup:`PageUp`,pagedown:`PageDown`,PgUp:`PageUp`,PgDn:`PageDown`,pgup:`PageUp`,pgdn:`PageDown`};function G9(e){return/^\p{Letter}$/u.test(e)}function K9(e){if(e in W9)return W9[e];if(G9(e)){let t=e.toUpperCase();return t.length===1?t:e}let t=e.toUpperCase();return/^F([1-9]|1[0-2])$/.test(t)?t:e}function q9(e,t=z9()){let n=e.split(`+`),r=new Set,i=``;for(let e=0;e<n.length;e++){let a=n[e].trim();if(e===n.length-1)i=K9(a);else{let e=V9[a]??V9[a.toLowerCase()];if(e){let n=H9(e,t);r.add(n)}else n.length===1&&(i=K9(a))}}return!i&&n.length>0&&(i=K9(n[n.length-1].trim())),{key:i,ctrl:r.has(`Control`),shift:r.has(`Shift`),alt:r.has(`Alt`),meta:r.has(`Meta`),modifiers:B9.filter(e=>r.has(e))}}function J9(e,t=z9()){let n=e.ctrl??!1,r=e.shift??!1,i=e.alt??!1,a=e.meta??!1;e.mod&&(H9(`Mod`,t)===`Control`?n=!0:a=!0);let o=B9.filter(e=>{switch(e){case`Control`:return n;case`Shift`:return r;case`Alt`:return i;case`Meta`:return a;default:return!1}});return{key:e.key,ctrl:n,shift:r,alt:i,meta:a,modifiers:o}}function Y9(e){let t=[];for(let n of B9)e.modifiers.includes(n)&&t.push(n);return t.push(e.key),t.join(`+`)}function X9(e,t,n=z9()){let r=typeof t==`string`?q9(t,n):t;if(e.ctrlKey!==r.ctrl||e.shiftKey!==r.shift||e.altKey!==r.alt||e.metaKey!==r.meta)return!1;let i=K9(e.key),a=r.key;if(i!==`Dead`&&i.length===1&&a.length===1){if(i.toUpperCase()===a.toUpperCase())return!0;if(G9(i)&&(/^[A-Za-z]$/.test(i)||!e.altKey))return!1}if(e.code&&(i===`Dead`||i.length===1&&a.length===1)){if(e.code.startsWith(`Key`)){let t=e.code.slice(3);if(t.length===1&&/^[A-Za-z]$/.test(t))return t.toUpperCase()===a.toUpperCase()}if(e.code.startsWith(`Digit`)){let t=e.code.slice(5);if(t.length===1&&/^[0-9]$/.test(t))return t===a}return e.code in U9?U9[e.code]===a:!1}return i===a}var n0e={preventDefault:!0,stopPropagation:!0,eventType:`keydown`,enabled:!0,ignoreInputs:!0,conflictBehavior:`warn`};function r0e(e){return!(e.ctrl||e.meta||e.key===`Escape`)}function i0e(e){if(!e)return!1;if(e instanceof HTMLInputElement){let t=e.type.toLowerCase();return!(t===`button`||t===`submit`||t===`reset`)}return!!(e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement||e instanceof HTMLElement&&e.isContentEditable)}function a0e(e,t){return t===document||t===window?e.currentTarget===t||e.currentTarget===document.documentElement:t===window?e.currentTarget===window||e.currentTarget===document||e.currentTarget===document.documentElement:!!(t instanceof HTMLElement&&(e.currentTarget===t||e.target instanceof Node&&t.contains(e.target)))}function o0e(e,t,n,r){if(n!==`allow`){if(n===`warn`){console.warn(`'${t}' is already registered. Multiple handlers will be triggered. Use conflictBehavior: 'replace' to replace the existing handler, or conflictBehavior: 'allow' to suppress this warning.`);return}if(n===`error`)throw Error(`'${t}' is already registered. Use conflictBehavior: 'replace' to replace the existing handler, or conflictBehavior: 'allow' to allow multiple registrations.`);r(e)}}var s0e=0;function Z9(){return`hotkey_${++s0e}`}var c0e=class e{static#e=null;#t;#n=new Map;#r=new Map;constructor(){this.registrations=new Gn(new Map),this.#t=z9()}static getInstance(){return e.#e||=new e,e.#e}static resetInstance(){e.#e&&=(e.#e.destroy(),null)}register(e,t,n={}){if(typeof document>`u`&&!n.target){let e=t;return{id:Z9(),unregister:()=>{},get callback(){return e},set callback(t){e=t},setOptions:()=>{},get isActive(){return!1}}}let r=Z9(),i=n.platform??this.#t,a=typeof e==`string`?q9(e,i):J9(e,i),o=typeof e==`string`?e:Y9(a),s=n.target??document,c=n.conflictBehavior??`warn`,l=this.#d(o,s);l&&o0e(l.id,o,c,e=>this.#i(e));let u=n.ignoreInputs??r0e(a),d={id:r,hotkey:o,parsedHotkey:a,callback:t,options:{...n0e,requireReset:!1,...n,platform:i,ignoreInputs:u},hasFired:!1,triggerCount:0,target:s};this.registrations.setState(e=>new Map(e).set(r,d)),this.#r.has(s)||this.#r.set(s,new Set),this.#r.get(s).add(r),this.#a(s);let f=this;return{get id(){return r},unregister:()=>{f.#i(r)},get callback(){return f.registrations.state.get(r)?.callback??t},set callback(e){let t=f.registrations.state.get(r);t&&(t.callback=e)},setOptions:e=>{f.registrations.setState(t=>{let n=t.get(r);if(n){let i=new Map(t);return i.set(r,{...n,options:{...n.options,...e}}),i}return t})},get isActive(){return f.registrations.state.has(r)}}}#i(e){let t=this.registrations.state.get(e);if(!t)return;let n=t.target;this.registrations.setState(t=>{let n=new Map(t);return n.delete(e),n});let r=this.#r.get(n);r&&(r.delete(e),r.size===0&&this.#o(n))}#a(e){if(typeof document>`u`||this.#n.has(e))return;let t=this.#l(e),n=this.#u(e);e.addEventListener(`keydown`,t),e.addEventListener(`keyup`,n),this.#n.set(e,{keydown:t,keyup:n})}#o(e){if(typeof document>`u`)return;let t=this.#n.get(e);t&&(e.removeEventListener(`keydown`,t.keydown),e.removeEventListener(`keyup`,t.keyup),this.#n.delete(e),this.#r.delete(e))}#s(e,t,n){let r=this.#r.get(t);if(r)for(let i of r){let r=this.registrations.state.get(i);if(r&&a0e(e,t)&&r.options.enabled&&!(r.options.ignoreInputs!==!1&&i0e(e.target)&&e.target!==r.target))if(n===`keydown`){if(r.options.eventType!==`keydown`)continue;X9(e,r.parsedHotkey,r.options.platform)&&(r.options.preventDefault&&e.preventDefault(),r.options.stopPropagation&&e.stopPropagation(),(!r.options.requireReset||!r.hasFired)&&(this.#c(r,e),r.options.requireReset&&(r.hasFired=!0)))}else r.options.eventType===`keyup`&&X9(e,r.parsedHotkey,r.options.platform)&&this.#c(r,e),r.options.requireReset&&r.hasFired&&this.#f(r,e)&&(r.hasFired=!1)}}#c(e,t){e.options.preventDefault&&t.preventDefault(),e.options.stopPropagation&&t.stopPropagation(),e.triggerCount++,this.registrations.setState(e=>new Map(e));let n={hotkey:e.hotkey,parsedHotkey:e.parsedHotkey};e.callback(t,n)}#l(e){return t=>{this.#s(t,e,`keydown`)}}#u(e){return t=>{this.#s(t,e,`keyup`)}}#d(e,t){for(let n of this.registrations.state.values())if(n.hotkey===e&&n.target===t)return n;return null}#f(e,t){let n=e.parsedHotkey,r=K9(t.key),i=n.key.length===1?n.key.toUpperCase():n.key;return!!((r.length===1?r.toUpperCase():r)===i||n.ctrl&&r===`Control`||n.shift&&r===`Shift`||n.alt&&r===`Alt`||n.meta&&r===`Meta`)}triggerRegistration(e){let t=this.registrations.state.get(e);if(!t)return!1;let n=t.parsedHotkey,r=new KeyboardEvent(t.options.eventType??`keydown`,{key:n.key,ctrlKey:n.ctrl,shiftKey:n.shift,altKey:n.alt,metaKey:n.meta,bubbles:!0,cancelable:!0});return t.triggerCount++,this.registrations.setState(e=>new Map(e)),t.callback(r,{hotkey:t.hotkey,parsedHotkey:t.parsedHotkey}),!0}getRegistrationCount(){return this.registrations.state.size}isRegistered(e,t){for(let n of this.registrations.state.values())if(n.hotkey===e&&(t===void 0||n.target===t))return!0;return!1}destroy(){for(let e of this.#n.keys())this.#o(e);this.registrations.setState(()=>new Map),this.#n.clear(),this.#r.clear()}};function l0e(){return c0e.getInstance()}function Q9(e,t,n={}){let r={...Y1e().hotkey,...n},i=l0e(),a=(0,x.useRef)(null),o=(0,x.useRef)(t),s=(0,x.useRef)(r),c=(0,x.useRef)(i);o.current=t,s.current=r,c.current=i;let l=(0,x.useRef)(null),u=(0,x.useRef)(null),d=r.platform??z9(),f=typeof e==`string`?e:Y9(J9(e,d)),{target:p,...m}=r;(0,x.useEffect)(()=>{let e=u0e(s.current.target)?s.current.target.current:s.current.target??(typeof document<`u`?document:null);if(!e)return;let t=l.current!==null&&l.current!==e,n=u.current!==null&&u.current!==f;return a.current?.isActive&&(t||n)&&(a.current.unregister(),a.current=null),(!a.current||!a.current.isActive)&&(a.current=c.current.register(f,o.current,{...s.current,target:e})),l.current=e,u.current=f,()=>{a.current?.isActive&&(a.current.unregister(),a.current=null)}},[f,n.enabled]),a.current?.isActive&&(a.current.callback=t,a.current.setOptions(m))}function u0e(e){return typeof e==`object`&&!!e&&`current`in e}function d0e(){var[e,t]=(0,x.useState)(!1),[n,r]=(0,x.useState)(``),[i,a]=(0,x.useState)(0),o=(0,x.useRef)(null),s=(0,x.useRef)(null),{projects:c,setActiveProject:l}=Dy(),u=MT(),{mode:d,toggleMode:f,allThemes:p,setTheme:m,currentThemeId:h}=Mb(),g=R(),_=jy(),v=(0,x.useCallback)(function(){t(!1),r(``),a(0)},[]);Q9(`Mod+K`,function(e){e.preventDefault(),t(function(e){return e&&(r(``),a(0)),!e})}),Q9(`Escape`,function(e){e.preventDefault(),v()},{enabled:e}),(0,x.useEffect)(function(){e&&o.current&&o.current.focus()},[e]);var y=(0,x.useMemo)(function(){var e=[];e.push({id:`nav:dashboard`,label:`Go to Dashboard`,group:`Navigation`,icon:(0,b.jsx)(Q_,{size:14}),action:function(){_.goToDashboard(),v()},keywords:`home overview`}),c.forEach(function(t){e.push({id:`project:`+t.slug,label:t.title||t.slug,description:t.path,group:`Projects`,icon:(0,b.jsx)(Wm,{size:14}),action:function(){l(t),v()},keywords:`switch project `+t.slug})});var t=Uy().state;t.activeProjectSlug&&e.push({id:`session:new`,label:`New Session`,group:`Session`,icon:(0,b.jsx)(U_,{size:14}),action:function(){g.send({type:`session:create`,projectSlug:t.activeProjectSlug}),v()},keywords:`create chat conversation`}),[{id:`appearance`,label:`Appearance`,keywords:`theme visual colors`},{id:`claude`,label:`Claude Settings`,keywords:`api model key`},{id:`environment`,label:`Environment`,keywords:`env variables config`},{id:`mcp`,label:`MCP Servers`,keywords:`model context protocol`},{id:`skills`,label:`Skills`,keywords:`capabilities commands`},{id:`nodes`,label:`Mesh Nodes`,keywords:`machines network`}].forEach(function(t){e.push({id:`settings:`+t.id,label:t.label,group:`Settings`,icon:(0,b.jsx)(hv,{size:14}),action:function(){_.openSettings(t.id),v()},keywords:t.keywords})}),e.push({id:`theme:toggle`,label:d===`dark`?`Switch to Light Mode`:`Switch to Dark Mode`,group:`Theme`,icon:d===`dark`?(0,b.jsx)(Sv,{size:14}):(0,b.jsx)(q_,{size:14}),action:function(){f(),v()},keywords:`dark light mode toggle`});var n=d===`dark`?`dark`:`light`;return p.filter(function(e){return e.theme.variant===n}).forEach(function(t){t.id!==h&&e.push({id:`theme:`+t.id,label:t.theme.name,group:`Theme`,icon:d===`dark`?(0,b.jsx)(q_,{size:14}):(0,b.jsx)(Sv,{size:14}),action:function(){m(t.id),v()},keywords:`color scheme `+t.theme.name})}),u.forEach(function(t){e.push({id:`skill:`+t.name,label:`/`+t.name,description:t.description,group:`Skills`,icon:(0,b.jsx)(Pv,{size:14}),action:function(){var e=document.querySelector(`textarea[aria-label='Message input']`);e&&(e.value=`/`+t.name+` `,e.focus(),e.dispatchEvent(new Event(`input`,{bubbles:!0}))),v()},keywords:t.description})}),e.push({id:`system:restart`,label:`Restart Daemon`,group:`System`,icon:(0,b.jsx)(sv,{size:14}),action:function(){g.send({type:`settings:restart`}),v()},keywords:`reboot server`}),e},[c,u,d,p,h,_,g,v,l,f,m]),S=(0,x.useMemo)(function(){if(!n.trim())return y;var e=n.toLowerCase();return y.filter(function(t){for(var n=(t.label+` `+(t.description||``)+` `+(t.keywords||``)+` `+t.group).toLowerCase(),r=e.split(/\s+/),i=0;i<r.length;i++)if(!n.includes(r[i]))return!1;return!0})},[n,y]);(0,x.useEffect)(function(){a(0)},[S.length,n]),(0,x.useEffect)(function(){if(s.current){var e=s.current.querySelector(`[data-active='true']`);e&&e.scrollIntoView({block:`nearest`})}},[i]);function C(e){e.key===`ArrowDown`?(e.preventDefault(),a(function(e){return e<S.length-1?e+1:0})):e.key===`ArrowUp`?(e.preventDefault(),a(function(e){return e>0?e-1:S.length-1})):e.key===`Enter`&&(e.preventDefault(),S[i]&&S[i].action())}var w=(0,x.useMemo)(function(){var e=[],t=new Map,n=0;return S.forEach(function(r){var i=t.get(r.group);i||(i=[],t.set(r.group,i),e.push({name:r.group,items:i})),i.push(Object.assign({},r,{globalIndex:n})),n++}),e},[S]);return e?(0,b.jsxs)(`div`,{className:`fixed inset-0 z-[9998] flex items-start justify-center pt-[15vh]`,onClick:v,children:[(0,b.jsx)(`div`,{className:`absolute inset-0 bg-base-content/50`}),(0,b.jsxs)(`div`,{className:`relative w-full max-w-[520px] mx-4 bg-base-200 border border-base-content/10 rounded-xl shadow-2xl overflow-hidden`,onClick:function(e){e.stopPropagation()},children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-3 border-b border-base-content/10`,children:[(0,b.jsx)(dv,{size:16,className:`text-base-content/30 flex-shrink-0`}),(0,b.jsx)(`input`,{ref:o,type:`text`,value:n,onChange:function(e){r(e.target.value)},onKeyDown:C,placeholder:`Type a command...`,className:`flex-1 bg-transparent text-[14px] text-base-content outline-none placeholder:text-base-content/30`}),(0,b.jsx)(`kbd`,{className:`text-[10px] font-mono text-base-content/20 bg-base-300 px-1.5 py-0.5 rounded`,children:`ESC`})]}),(0,b.jsxs)(`div`,{ref:s,className:`max-h-[360px] overflow-y-auto py-1.5`,children:[w.length===0&&(0,b.jsx)(`div`,{className:`px-4 py-8 text-center text-[13px] text-base-content/30`,children:`No commands found`}),w.map(function(e){return(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`px-4 pt-2 pb-1`,children:(0,b.jsx)(`span`,{className:`text-[9px] uppercase tracking-widest text-base-content/30 font-mono font-bold`,children:e.name})}),e.items.map(function(e){var t=e.globalIndex===i;return(0,b.jsxs)(`button`,{"data-active":t,onMouseEnter:function(){a(e.globalIndex)},onMouseDown:function(e){e.preventDefault()},onClick:function(){e.action()},className:`flex w-full items-center gap-3 px-4 py-2 text-left transition-colors `+(t?`bg-primary/10`:`hover:bg-base-content/5`),children:[(0,b.jsx)(`div`,{className:`flex-shrink-0 `+(t?`text-primary`:`text-base-content/30`),children:e.icon}),(0,b.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,b.jsx)(`div`,{className:`text-[13px] truncate `+(t?`text-base-content`:`text-base-content/70`),children:e.label}),e.description&&(0,b.jsx)(`div`,{className:`text-[11px] text-base-content/30 truncate`,children:e.description})]})]},e.id)})]},e.name)})]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-2 border-t border-base-content/10 text-[10px] text-base-content/25 font-mono`,children:[(0,b.jsx)(`span`,{children:`↑↓ navigate`}),(0,b.jsx)(`span`,{children:`↵ select`}),(0,b.jsx)(`span`,{children:`esc close`})]})]})]}):null}var f0e=[{name:`Chat`,shortcuts:[{keys:[`Enter`],description:`Send message`},{keys:[`Shift`,`Enter`],description:`New line`},{keys:[`↑`],description:`Previous input history`},{keys:[`↓`],description:`Next input history`},{keys:[`/`],description:`Slash commands`},{keys:[`Escape`],description:`Close autocomplete`}]},{name:`Navigation`,shortcuts:[{keys:[typeof navigator<`u`&&navigator.platform.indexOf(`Mac`)!==-1?`⌘`:`Ctrl`,`K`],description:`Command palette`},{keys:[`?`],description:`Keyboard shortcuts`},{keys:[`Escape`],description:`Close modal / exit settings`}]},{name:`Session`,shortcuts:[{keys:[`/clear`],description:`New session`},{keys:[`/copy`],description:`Copy last response`},{keys:[`/export`],description:`Export conversation`},{keys:[`/rename`],description:`Rename session`}]}];function $9(e){return(0,b.jsx)(`kbd`,{className:`bg-base-300 border border-base-content/20 rounded px-1.5 py-0.5 text-[11px] font-mono text-base-content/70 leading-none inline-flex items-center justify-center min-w-[22px]`,children:e.children})}function p0e(){var[e,t]=(0,x.useState)(!1);return(0,x.useEffect)(function(){function n(n){if(n.key===`?`&&!n.ctrlKey&&!n.metaKey&&!n.altKey){var r=n.target.tagName;if(r===`INPUT`||r===`TEXTAREA`||n.target.isContentEditable)return;n.preventDefault(),t(!0)}n.key===`Escape`&&e&&t(!1)}return document.addEventListener(`keydown`,n),function(){document.removeEventListener(`keydown`,n)}},[e]),e?(0,b.jsxs)(`div`,{className:`fixed inset-0 z-[9998] flex items-center justify-center`,onClick:function(){t(!1)},children:[(0,b.jsx)(`div`,{className:`absolute inset-0 bg-base-content/50`}),(0,b.jsxs)(`div`,{className:`relative w-full max-w-[540px] mx-4 bg-base-200 border border-base-content/15 rounded-2xl shadow-xl overflow-hidden`,onClick:function(e){e.stopPropagation()},children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between px-5 py-3.5 border-b border-base-content/10`,children:[(0,b.jsx)(`h2`,{className:`text-[14px] font-mono font-bold text-base-content tracking-tight`,children:`Keyboard Shortcuts`}),(0,b.jsx)(`button`,{onClick:function(){t(!1)},className:`w-6 h-6 rounded flex items-center justify-center text-base-content/30 hover:text-base-content/60 transition-colors`,children:(0,b.jsx)(Nv,{size:14})})]}),(0,b.jsx)(`div`,{className:`px-5 py-4 max-h-[70vh] overflow-y-auto`,children:(0,b.jsx)(`div`,{className:`flex flex-col gap-5`,children:f0e.map(function(e){return(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-[9px] uppercase tracking-widest text-base-content/30 font-mono font-bold mb-2`,children:e.name}),(0,b.jsx)(`div`,{className:`flex flex-col gap-1`,children:e.shortcuts.map(function(e,t){return(0,b.jsxs)(`div`,{className:`flex items-center justify-between py-1.5 px-2 rounded hover:bg-base-content/5 transition-colors`,children:[(0,b.jsx)(`span`,{className:`text-[13px] text-base-content/60`,children:e.description}),(0,b.jsx)(`div`,{className:`flex items-center gap-1 flex-shrink-0 ml-4`,children:e.keys.map(function(e,t){return(0,b.jsxs)(`span`,{className:`flex items-center gap-1`,children:[t>0&&(0,b.jsx)(`span`,{className:`text-[10px] text-base-content/20`,children:`+`}),(0,b.jsx)($9,{children:e})]},t)})})]},t)})})]},e.name)})})}),(0,b.jsx)(`div`,{className:`px-5 py-2.5 border-t border-base-content/10 flex justify-end`,children:(0,b.jsxs)(`span`,{className:`text-[10px] font-mono text-base-content/20`,children:[`Press `,(0,b.jsx)($9,{children:`Esc`}),` to close`]})})]})]}):null}function m0e(){var[e,t]=(0,x.useState)(!1),[n,r]=(0,x.useState)(null);(0,x.useEffect)(function(){`serviceWorker`in navigator&&navigator.serviceWorker.ready.then(function(e){e.addEventListener(`updatefound`,function(){var n=e.installing;if(n){var i=n;i.addEventListener(`statechange`,function(){i.state===`installed`&&navigator.serviceWorker.controller&&(r(e),t(!0))})}})})},[]);function i(){n&&n.waiting&&n.waiting.postMessage({type:`SKIP_WAITING`}),window.location.reload()}return e?(0,b.jsxs)(`div`,{className:`fixed bottom-4 right-4 z-[9998] bg-base-300 border border-base-content/15 rounded-xl shadow-2xl px-4 py-3 flex items-center gap-3 max-w-sm`,children:[(0,b.jsx)(ov,{size:16,className:`text-primary flex-shrink-0`}),(0,b.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,b.jsx)(`div`,{className:`text-[13px] text-base-content font-semibold`,children:`Update available`}),(0,b.jsx)(`div`,{className:`text-[11px] text-base-content/40`,children:`A new version of Lattice is ready.`})]}),(0,b.jsx)(`button`,{onClick:i,className:`btn btn-primary btn-xs`,children:`Reload`})]}):null}function h0e(){var e=R();(0,x.useEffect)(function(){function t(e){e.type===`theme:custom_list`&&Sve((e.themes||[]).map(function(e){return{id:`custom:`+e.filename,theme:{name:e.name,author:e.author,variant:e.variant,...e.colors}}}))}function n(t){(t.type===`theme:saved`||t.type===`theme:deleted`)&&e.send({type:`theme:list_custom`})}return e.subscribe(`theme:custom_list`,t),e.subscribe(`theme:saved`,n),e.subscribe(`theme:deleted`,n),function(){e.unsubscribe(`theme:custom_list`,t),e.unsubscribe(`theme:saved`,n),e.unsubscribe(`theme:deleted`,n)}},[])}function g0e(){var{items:e,dismiss:t}=v$e();return h0e(),(0,x.useEffect)(function(){function e(e){e.target.closest(`[data-allow-context-menu]`)||e.preventDefault()}return document.addEventListener(`contextmenu`,e),function(){document.removeEventListener(`contextmenu`,e)}},[]),(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(Hr,{router:U1e}),(0,b.jsx)(d0e,{}),(0,b.jsx)(p0e,{}),(0,b.jsx)(_$e,{items:e,onDismiss:t}),(0,b.jsx)(m0e,{})]})}function _0e(){return(0,b.jsx)(q1e,{children:(0,b.jsx)(K1e,{children:(0,b.jsx)(g0e,{})})})}typeof crypto<`u`&&!crypto.randomUUID&&(crypto.randomUUID=function(){return`10000000-1000-4000-8000-100000000000`.replace(/[018]/g,function(e){var t=Number(e);return(t^crypto.getRandomValues(new Uint8Array(1))[0]&15>>t/4).toString(16)})}),(0,S.createRoot)(document.getElementById(`root`)).render((0,b.jsx)(x.StrictMode,{children:(0,b.jsx)(_0e,{})}));export{Fx as a,$b as c,Px as i,s as l,ww as n,jx as o,Ix as r,tx as s,$N as t};