tarsk 0.4.27 → 0.4.28

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 (82) hide show
  1. package/dist/index.js +438 -148
  2. package/dist/public/assets/account-view-DcpSNB3N.js +1 -0
  3. package/dist/public/assets/alert-dialog-CQRWdGnn.js +1 -0
  4. package/dist/public/assets/api-CH5gAPs5.js +1 -0
  5. package/dist/public/assets/{browser-tab-DlzO5cMP.js → browser-tab-CiAz6nc1.js} +1 -1
  6. package/dist/public/assets/chat-input-container-C6U_WFFu.js +21 -0
  7. package/dist/public/assets/context-menu-A9p22S7d.js +1 -0
  8. package/dist/public/assets/conversation-history-view-CD_uVRNY.js +1 -0
  9. package/dist/public/assets/{dialogs-config-DZFG2IQM.js → dialogs-config-vkfELnGl.js} +3 -3
  10. package/dist/public/assets/diff-view-CjbcDB6m.js +3 -0
  11. package/dist/public/assets/explorer-tab-view-BfycKUUW.js +2 -0
  12. package/dist/public/assets/explorer-tree-DTFYhczJ.js +1 -0
  13. package/dist/public/assets/explorer-view-C0KcZ8NQ.js +1 -0
  14. package/dist/public/assets/history-view-Dn0hQIKU.js +1 -0
  15. package/dist/public/assets/index-Bdde81Uo.css +1 -0
  16. package/dist/public/assets/index-DKQVo4Vz.js +29 -0
  17. package/dist/public/assets/markdown-renderer-CNuyXHcy.js +10 -0
  18. package/dist/public/assets/mcp-server-card-DBEBe3Qh.js +1 -0
  19. package/dist/public/assets/onboarding-DslO5AS6.js +1 -0
  20. package/dist/public/assets/onboarding-dialog-CE-GhoDt.js +1 -0
  21. package/dist/public/assets/{page-toolbar-TvYsDwUY.js → page-toolbar-CloU_Kvo.js} +1 -1
  22. package/dist/public/assets/{project-settings-view-C7GW_R0m.js → project-settings-view-CxD9JZoB.js} +1 -1
  23. package/dist/public/assets/providers-list-view-CNxVBJlM.js +1 -0
  24. package/dist/public/assets/radio-group-Co0Lg6se.js +1 -0
  25. package/dist/public/assets/react-vendor-DyE9sO8V.js +22 -0
  26. package/dist/public/assets/{resizable-DzrIos_Y.js → resizable-dToeUeVD.js} +1 -1
  27. package/dist/public/assets/{run-stop-button-k1LeM0M-.js → run-stop-button-DZ4JFwdL.js} +2 -2
  28. package/dist/public/assets/settings-instructions-view-DWzAH2yN.js +1 -0
  29. package/dist/public/assets/{settings-mcp-servers-view-Becs_RxN.js → settings-mcp-servers-view-q6gGMMVX.js} +4 -4
  30. package/dist/public/assets/settings-models-view-BDDFQWWC.js +1 -0
  31. package/dist/public/assets/settings-rules-view-DsEwgDFr.js +8 -0
  32. package/dist/public/assets/{settings-skills-view-aPv03-bO.js → settings-skills-view-DV40_L1o.js} +2 -2
  33. package/dist/public/assets/{settings-slash-commands-view-DLMWXQXA.js → settings-slash-commands-view-BEk3BgOY.js} +1 -1
  34. package/dist/public/assets/settings-subagents-view-d3P4ylDX.js +2 -0
  35. package/dist/public/assets/settings-view-ClTMPafQ.js +2 -0
  36. package/dist/public/assets/{side-panel-container-oMcXib2A.js → side-panel-container-BAYoMt7B.js} +2 -2
  37. package/dist/public/assets/{skeleton-Bc0U0oGc.js → skeleton-DveUQR4w.js} +1 -1
  38. package/dist/public/assets/standard-list-item-BLlgm1qW.js +1 -0
  39. package/dist/public/assets/store-BcwWHqYr.js +4 -0
  40. package/dist/public/assets/{tab-context-CCvlrC0o.js → tab-context-DWD20a4z.js} +1 -1
  41. package/dist/public/assets/tabs-CgvpwOBj.js +1 -0
  42. package/dist/public/assets/{terminal-panel-GuO2XygM.js → terminal-panel-CkIe2d2K.js} +2 -2
  43. package/dist/public/assets/textarea-C2UIAa7y.js +1 -0
  44. package/dist/public/assets/todos-view-C-awG1dZ.js +1 -0
  45. package/dist/public/assets/{use-toast-DqmC-mB5.js → use-toast-yY7qQuQP.js} +1 -1
  46. package/dist/public/assets/{utils-Cy2s2TEb.js → utils-BKss67Vg.js} +1 -1
  47. package/dist/public/assets/{whisper-wasm-Clnf-l-9.js → whisper-wasm-B7iuRPFr.js} +1 -1
  48. package/dist/public/ide/antigravity.svg +1 -0
  49. package/dist/public/ide/devin.svg +1 -0
  50. package/dist/public/index.html +22 -21
  51. package/package.json +1 -1
  52. package/dist/public/assets/account-view-BFhjAYmz.js +0 -1
  53. package/dist/public/assets/alert-dialog--tUzAWFm.js +0 -1
  54. package/dist/public/assets/api-BBbysRIh.js +0 -1
  55. package/dist/public/assets/chat-input-container-B_qVOGzW.js +0 -21
  56. package/dist/public/assets/context-menu-D5slxFcc.js +0 -1
  57. package/dist/public/assets/conversation-history-view-B4zHwyrw.js +0 -1
  58. package/dist/public/assets/diff-view-fOVqrHQW.js +0 -3
  59. package/dist/public/assets/explorer-tab-view-MLrWJ1Y0.js +0 -2
  60. package/dist/public/assets/explorer-tree-8TyBYuC7.js +0 -1
  61. package/dist/public/assets/explorer-view-5U70mfAJ.js +0 -1
  62. package/dist/public/assets/history-view-BR8scGnM.js +0 -1
  63. package/dist/public/assets/index-0BuHfewk.css +0 -1
  64. package/dist/public/assets/index-BTbiyooe.js +0 -37
  65. package/dist/public/assets/mcp-server-card-DupwHcKT.js +0 -1
  66. package/dist/public/assets/onboarding-Cn5RqOCa.js +0 -1
  67. package/dist/public/assets/onboarding-dialog-BXsvjU1t.js +0 -1
  68. package/dist/public/assets/providers-list-view-AVt5I1WB.js +0 -1
  69. package/dist/public/assets/radio-group-Mifbn8sU.js +0 -1
  70. package/dist/public/assets/react-vendor-Bao-KYKs.js +0 -22
  71. package/dist/public/assets/settings-instructions-view-CgfWSPmK.js +0 -1
  72. package/dist/public/assets/settings-models-view-BqdD_7GR.js +0 -1
  73. package/dist/public/assets/settings-rules-view-D7j5OHUi.js +0 -8
  74. package/dist/public/assets/settings-subagents-view-DBYzNE4W.js +0 -2
  75. package/dist/public/assets/settings-view-CccwUKkf.js +0 -2
  76. package/dist/public/assets/standard-list-item-D2lbPXa1.js +0 -1
  77. package/dist/public/assets/store-CwvBC-YP.js +0 -2
  78. package/dist/public/assets/tabs-Mb_cjIfE.js +0 -1
  79. package/dist/public/assets/textarea-DpXOZLt8.js +0 -1
  80. package/dist/public/assets/todos-view-C4GMi1Np.js +0 -1
  81. /package/dist/public/assets/{dist-BI23Ei33.js → dist-Bjt_i1zi.js} +0 -0
  82. /package/dist/public/assets/{monaco-DDfTQM3i.js → monaco-SWcefg0q.js} +0 -0
@@ -1,2 +1,2 @@
1
- import{bt as e}from"./react-vendor-Bao-KYKs.js";var t=class e{static levels={DEBUG:0,INFO:1,WARN:2,ERROR:3};level;prefix;constructor(t=e.levels.INFO,n=``){this.level=t,this.prefix=n}debug(...t){this.level<=e.levels.DEBUG&&console.debug(`[${this.prefix}] [DEBUG]`,...t)}info(...t){this.level<=e.levels.INFO&&console.info(`[${this.prefix}] [INFO]`,...t)}warn(...t){this.level<=e.levels.WARN&&console.warn(`[${this.prefix}] [WARN]`,...t)}error(...t){this.level<=e.levels.ERROR&&console.error(`[${this.prefix}] [ERROR]`,...t)}setLevel(e){this.level=e}getLevel(){return this.level}};function n(e){try{return JSON.stringify(e)}catch{return`"[non-serializable]"`}}function r(e){let t;try{t=n(e)}catch{console.error(`[voice-log] failed to serialize log payload`);return}fetch(`/api/logs`,{method:`POST`,headers:{"Content-Type":`application/json`},body:t}).catch(e=>{console.error(`[voice-log] fetch to /api/logs failed:`,e)})}function i(e){function t(t,n,i){r({level:t,context:e,message:n,data:i});let a=`[${e}]`;t===`ERROR`?console.error(a,n,i??``):t===`WARN`?console.warn(a,n,i??``):t===`DEBUG`?console.debug(a,n,i??``):console.info(a,n,i??``)}return{debug:(e,n)=>t(`DEBUG`,e,n),info:(e,n)=>t(`INFO`,e,n),warn:(e,n)=>t(`WARN`,e,n),error:(e,n)=>t(`ERROR`,e,n),separator:e=>t(`INFO`,`${`─`.repeat(20)} ${e} ${`─`.repeat(20)}`)}}var a=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11])),o={language:`auto`,threads:4,translate:!1};function s(e){let t=String(e).trim().replace(`,`,`.`),n=t.split(`:`).map(Number);if(n.some(Number.isNaN))throw Error(`Bad time: "${e}"`);let r=0,i=0,a=0;if(n.length===3)[r,i]=n,a=parseFloat(t.split(`:`).pop()||`0`);else if(n.length===2)[i]=n,a=parseFloat(t.split(`:`).pop()||`0`);else throw Error(`Bad time format: "${e}"`);return Math.floor(((r*60+i)*60+a)*1e3)}function c(e){let t=/^\s*\[?\s*([0-9]{1,2}:[0-9]{2}:(?:[0-9]{2}[.,][0-9]{1,3})|[0-9]{1,2}:[0-9]{2}[.,][0-9]{1,3})\s*-->\s*([0-9]{1,2}:[0-9]{2}:(?:[0-9]{2}[.,][0-9]{1,3})|[0-9]{1,2}:[0-9]{2}[.,][0-9]{1,3})\s*\]?\s*(.*)\s*$/.exec(e);if(!t)throw Error(`Line does not match VTT-like pattern: `+e);let n=t[1],r=t[2],i=t[3]||``,a=s(n),o=s(r);if(o<a)throw Error(`End time is before start time`);return{startMs:a,endMs:o,start:n,end:r,text:i}}function l(e){return new Promise(t=>setTimeout(t,e))}function u(e,t){let n=null,r=!1,i=null,a=null;return{timeoutError:()=>new Promise((o,s)=>{a=o,i=s,n=setTimeout(()=>{!r&&i&&(r=!0,i(Error(t)))},e)}),clear:()=>{n&&=(clearTimeout(n),null),a&&=(a(),null),r=!0,i=null}}}function d(e,t=16e3*100){let n=[];for(let r=0;r<e.length;r+=t)n.push(e.subarray(r,r+t));return n}var f=class{logger;constructor(e,n){this.whisperService=e,this.logger=new t(n?.logLevel||t.levels.ERROR,`TranscriptionSession`)}async*streaming(e,t={}){let{timeoutMs:n=3e4}=t,r=d(e),i=0;for(let e of r){let r=[],a=null,o=!1,s,c=0,{timeoutError:d,clear:f}=u(n,`Transcribe timeout`),p=()=>this.whisperService.transcribe(e,e=>{c=e.timeEnd,e.timeStart+=i,e.timeEnd+=i,this.logger.debug(`Transcription segment in session:`,e),a?(a(e),a=null):r.push(e),f()},t).then(()=>{this.logger.debug(`Transcription done in session then`),o=!0,i+=c,f(),a?.(void 0)}).catch(e=>{this.logger.debug(`Transcription error in session catch:`,e),s=e,f(),a?.(void 0)});for(p();;){if(s){if(t.restartModelOnError){this.whisperService.restartModel(),p();continue}throw s}if(o)break;if(r.length)yield r.shift();else try{let e=await Promise.race([new Promise(e=>a=e),d()]);e&&(yield e)}catch(e){s=e}}t.sleepMsBetweenChunks&&await l(t.sleepMsBetweenChunks)}}async*streamimg(e,t={}){yield*this.streaming(e,t)}},p=i(`WhisperWasmService`),m=class extends EventTarget{on(e,t){return this.addEventListener(e,t),()=>this.removeEventListener(e,t)}emit(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))}},h=class{wasmModule=null;instance=null;modelFileName=`whisper.bin`;isTranscribing=!1;bus=new m;logger;modelData=null;constructor(e){this.logger=new t(e?.logLevel??t.levels.ERROR,`WhisperWasmService`),e?.init&&this.loadWasmScript()}async checkWasmSupport(){return await a()}async loadWasmScript(){let t=`${typeof window<`u`?window.location.origin:``}/wasm/libmain-D9-QM3iM.mjs`;p.info(`Loading WASM script`,{url:t}),this.wasmModule=await(await e(async()=>{let{default:e}=await import(t);return{default:e}},[])).default({print:(e,...t)=>{t.length>0&&this.logger.debug(t),e.startsWith(`[`)?(this.logger.info(e),this.bus.emit(`transcribe`,e)):(this.logger.debug(e),this.bus.emit(`system_info`,e))},printErr:(e,...t)=>{t.length>0&&this.logger.debug(t),this.logger.warn(e),p.warn(`WASM stderr output`,{message:e,extra:t.length?t:void 0}),this.bus.emit(`transcribeError`,e)}}),p.info(`WASM script loaded successfully`)}async initModel(e){if(!await this.checkWasmSupport())throw Error(`WASM is not supported`);return p.info(`Initializing WASM model`,{sizeBytes:e.byteLength,sizeMB:(e.byteLength/1024/1024).toFixed(2)}),this.modelData=e,this.wasmModule&&(this.wasmModule.FS_unlink(this.modelFileName),this.wasmModule.free(),p.debug(`Previous WASM module freed`)),await this.loadWasmScript(),await l(100),p.info(`Storing model in WASM FS`,{fileName:this.modelFileName,sizeBytes:e.byteLength}),this.storeFS(this.modelFileName,e),p.info(`Creating WASM instance`),this.instance=this.wasmModule.init(this.modelFileName),p.info(`WASM instance created`,{instance:this.instance}),Promise.resolve()}restartModel(){if(!this.modelData)throw Error(`Model not loaded`);return this.initModel(this.modelData)}storeFS(e,t){if(!this.wasmModule)throw Error(`WASM module not loaded`);try{this.wasmModule.FS_unlink(e)}catch{}this.wasmModule.FS_createDataFile(`/`,e,t,!0,!0,!0)}async transcribe(e,t,n={}){if(this.isTranscribing)throw Error(`Already transcribing`);if(!this.wasmModule)throw Error(`WASM module not loaded`);if(!this.instance)throw Error(`WASM instance not loaded`);e.length>16e3*120&&this.logger.warn(`It's not recommended to transcribe audio data that is longer than 120 seconds`),this.isTranscribing=!0;let{language:r=`auto`,threads:i=4,translate:a=!1}={...o,...n},s=[],l=Date.now();p.info(`Calling WASM full_default`,{sampleCount:e.length,durationSec:(e.length/16e3).toFixed(2),language:r,threads:i,translate:a,instance:this.instance});try{this.wasmModule.full_default(this.instance,e,r,i,a),p.info(`WASM full_default returned without throwing`)}catch(e){let t=e instanceof Error?e.message:String(e);throw p.error(`WASM full_default threw an exception`,{error:t,type:e instanceof Error?e.constructor.name:typeof e,stack:e instanceof Error?e.stack?.split(`
1
+ import{xt as e}from"./react-vendor-DyE9sO8V.js";var t=class e{static levels={DEBUG:0,INFO:1,WARN:2,ERROR:3};level;prefix;constructor(t=e.levels.INFO,n=``){this.level=t,this.prefix=n}debug(...t){this.level<=e.levels.DEBUG&&console.debug(`[${this.prefix}] [DEBUG]`,...t)}info(...t){this.level<=e.levels.INFO&&console.info(`[${this.prefix}] [INFO]`,...t)}warn(...t){this.level<=e.levels.WARN&&console.warn(`[${this.prefix}] [WARN]`,...t)}error(...t){this.level<=e.levels.ERROR&&console.error(`[${this.prefix}] [ERROR]`,...t)}setLevel(e){this.level=e}getLevel(){return this.level}};function n(e){try{return JSON.stringify(e)}catch{return`"[non-serializable]"`}}function r(e){let t;try{t=n(e)}catch{console.error(`[voice-log] failed to serialize log payload`);return}fetch(`/api/logs`,{method:`POST`,headers:{"Content-Type":`application/json`},body:t}).catch(e=>{console.error(`[voice-log] fetch to /api/logs failed:`,e)})}function i(e){function t(t,n,i){r({level:t,context:e,message:n,data:i});let a=`[${e}]`;t===`ERROR`?console.error(a,n,i??``):t===`WARN`?console.warn(a,n,i??``):t===`DEBUG`?console.debug(a,n,i??``):console.info(a,n,i??``)}return{debug:(e,n)=>t(`DEBUG`,e,n),info:(e,n)=>t(`INFO`,e,n),warn:(e,n)=>t(`WARN`,e,n),error:(e,n)=>t(`ERROR`,e,n),separator:e=>t(`INFO`,`${`─`.repeat(20)} ${e} ${`─`.repeat(20)}`)}}var a=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11])),o={language:`auto`,threads:4,translate:!1};function s(e){let t=String(e).trim().replace(`,`,`.`),n=t.split(`:`).map(Number);if(n.some(Number.isNaN))throw Error(`Bad time: "${e}"`);let r=0,i=0,a=0;if(n.length===3)[r,i]=n,a=parseFloat(t.split(`:`).pop()||`0`);else if(n.length===2)[i]=n,a=parseFloat(t.split(`:`).pop()||`0`);else throw Error(`Bad time format: "${e}"`);return Math.floor(((r*60+i)*60+a)*1e3)}function c(e){let t=/^\s*\[?\s*([0-9]{1,2}:[0-9]{2}:(?:[0-9]{2}[.,][0-9]{1,3})|[0-9]{1,2}:[0-9]{2}[.,][0-9]{1,3})\s*-->\s*([0-9]{1,2}:[0-9]{2}:(?:[0-9]{2}[.,][0-9]{1,3})|[0-9]{1,2}:[0-9]{2}[.,][0-9]{1,3})\s*\]?\s*(.*)\s*$/.exec(e);if(!t)throw Error(`Line does not match VTT-like pattern: `+e);let n=t[1],r=t[2],i=t[3]||``,a=s(n),o=s(r);if(o<a)throw Error(`End time is before start time`);return{startMs:a,endMs:o,start:n,end:r,text:i}}function l(e){return new Promise(t=>setTimeout(t,e))}function u(e,t){let n=null,r=!1,i=null,a=null;return{timeoutError:()=>new Promise((o,s)=>{a=o,i=s,n=setTimeout(()=>{!r&&i&&(r=!0,i(Error(t)))},e)}),clear:()=>{n&&=(clearTimeout(n),null),a&&=(a(),null),r=!0,i=null}}}function d(e,t=16e3*100){let n=[];for(let r=0;r<e.length;r+=t)n.push(e.subarray(r,r+t));return n}var f=class{logger;constructor(e,n){this.whisperService=e,this.logger=new t(n?.logLevel||t.levels.ERROR,`TranscriptionSession`)}async*streaming(e,t={}){let{timeoutMs:n=3e4}=t,r=d(e),i=0;for(let e of r){let r=[],a=null,o=!1,s,c=0,{timeoutError:d,clear:f}=u(n,`Transcribe timeout`),p=()=>this.whisperService.transcribe(e,e=>{c=e.timeEnd,e.timeStart+=i,e.timeEnd+=i,this.logger.debug(`Transcription segment in session:`,e),a?(a(e),a=null):r.push(e),f()},t).then(()=>{this.logger.debug(`Transcription done in session then`),o=!0,i+=c,f(),a?.(void 0)}).catch(e=>{this.logger.debug(`Transcription error in session catch:`,e),s=e,f(),a?.(void 0)});for(p();;){if(s){if(t.restartModelOnError){this.whisperService.restartModel(),p();continue}throw s}if(o)break;if(r.length)yield r.shift();else try{let e=await Promise.race([new Promise(e=>a=e),d()]);e&&(yield e)}catch(e){s=e}}t.sleepMsBetweenChunks&&await l(t.sleepMsBetweenChunks)}}async*streamimg(e,t={}){yield*this.streaming(e,t)}},p=i(`WhisperWasmService`),m=class extends EventTarget{on(e,t){return this.addEventListener(e,t),()=>this.removeEventListener(e,t)}emit(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))}},h=class{wasmModule=null;instance=null;modelFileName=`whisper.bin`;isTranscribing=!1;bus=new m;logger;modelData=null;constructor(e){this.logger=new t(e?.logLevel??t.levels.ERROR,`WhisperWasmService`),e?.init&&this.loadWasmScript()}async checkWasmSupport(){return await a()}async loadWasmScript(){let t=`${typeof window<`u`?window.location.origin:``}/wasm/libmain-D9-QM3iM.mjs`;p.info(`Loading WASM script`,{url:t}),this.wasmModule=await(await e(async()=>{let{default:e}=await import(t);return{default:e}},[])).default({print:(e,...t)=>{t.length>0&&this.logger.debug(t),e.startsWith(`[`)?(this.logger.info(e),this.bus.emit(`transcribe`,e)):(this.logger.debug(e),this.bus.emit(`system_info`,e))},printErr:(e,...t)=>{t.length>0&&this.logger.debug(t),this.logger.warn(e),p.warn(`WASM stderr output`,{message:e,extra:t.length?t:void 0}),this.bus.emit(`transcribeError`,e)}}),p.info(`WASM script loaded successfully`)}async initModel(e){if(!await this.checkWasmSupport())throw Error(`WASM is not supported`);return p.info(`Initializing WASM model`,{sizeBytes:e.byteLength,sizeMB:(e.byteLength/1024/1024).toFixed(2)}),this.modelData=e,this.wasmModule&&(this.wasmModule.FS_unlink(this.modelFileName),this.wasmModule.free(),p.debug(`Previous WASM module freed`)),await this.loadWasmScript(),await l(100),p.info(`Storing model in WASM FS`,{fileName:this.modelFileName,sizeBytes:e.byteLength}),this.storeFS(this.modelFileName,e),p.info(`Creating WASM instance`),this.instance=this.wasmModule.init(this.modelFileName),p.info(`WASM instance created`,{instance:this.instance}),Promise.resolve()}restartModel(){if(!this.modelData)throw Error(`Model not loaded`);return this.initModel(this.modelData)}storeFS(e,t){if(!this.wasmModule)throw Error(`WASM module not loaded`);try{this.wasmModule.FS_unlink(e)}catch{}this.wasmModule.FS_createDataFile(`/`,e,t,!0,!0,!0)}async transcribe(e,t,n={}){if(this.isTranscribing)throw Error(`Already transcribing`);if(!this.wasmModule)throw Error(`WASM module not loaded`);if(!this.instance)throw Error(`WASM instance not loaded`);e.length>16e3*120&&this.logger.warn(`It's not recommended to transcribe audio data that is longer than 120 seconds`),this.isTranscribing=!0;let{language:r=`auto`,threads:i=4,translate:a=!1}={...o,...n},s=[],l=Date.now();p.info(`Calling WASM full_default`,{sampleCount:e.length,durationSec:(e.length/16e3).toFixed(2),language:r,threads:i,translate:a,instance:this.instance});try{this.wasmModule.full_default(this.instance,e,r,i,a),p.info(`WASM full_default returned without throwing`)}catch(e){let t=e instanceof Error?e.message:String(e);throw p.error(`WASM full_default threw an exception`,{error:t,type:e instanceof Error?e.constructor.name:typeof e,stack:e instanceof Error?e.stack?.split(`
2
2
  `).slice(0,5).join(` | `):void 0}),this.isTranscribing=!1,e}return await new Promise((e,n)=>{let r=this.bus.on(`transcribe`,e=>{let{startMs:n,endMs:r,text:i}=c(e.detail),a={timeStart:n,timeEnd:r,text:i,raw:e.detail};s.push(a),t?.(a)}),i=setTimeout(()=>{this.isTranscribing=!1,r(),a(),this.logger.error(`Transcribe timeout`),n(Error(`Transcribe timeout`)),this.bus.emit(`transcribeError`,`Transcribe timeout`)},240*1e3),a=this.bus.on(`transcribeError`,t=>{this.isTranscribing=!1,r(),a(),clearTimeout(i),this.logger.debug(`Transcribe error`,t.detail),e({segments:s,transcribeDurationMs:Date.now()-l})})})}createSession(){return new f(this,{logLevel:this.logger.getLevel()})}},g={"tiny.en":{id:`tiny.en`,name:`Tiny English`,size:75,language:`en`,quantized:!1,url:`https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-tiny.en.bin`},tiny:{id:`tiny`,name:`Tiny Multilingual`,size:75,language:`multilingual`,quantized:!1,url:`https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-tiny.bin`},"base.en":{id:`base.en`,name:`Base English`,size:142,language:`en`,quantized:!1,url:`https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-base.en.bin`},base:{id:`base`,name:`Base Multilingual`,size:142,language:`multilingual`,quantized:!1,url:`https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-base.bin`},"small.en":{id:`small.en`,name:`Small English`,size:466,language:`en`,quantized:!1,url:`https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-small.en.bin`},small:{id:`small`,name:`Small Multilingual`,size:466,language:`multilingual`,quantized:!1,url:`https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-small.bin`},"tiny.en-q5_1":{id:`tiny.en-q5_1`,name:`Tiny English (Q5_1)`,size:31,language:`en`,quantized:!0,url:`https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-tiny.en-q5_1.bin`},"tiny-q5_1":{id:`tiny-q5_1`,name:`Tiny Multilingual (Q5_1)`,size:31,language:`multilingual`,quantized:!0,url:`https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-tiny-q5_1.bin`},"base.en-q5_1":{id:`base.en-q5_1`,name:`Base English (Q5_1)`,size:57,language:`en`,quantized:!0,url:`https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-base.en-q5_1.bin`},"base-q5_1":{id:`base-q5_1`,name:`Base Multilingual (Q5_1)`,size:57,language:`multilingual`,quantized:!0,url:`https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-base-q5_1.bin`},"small.en-q5_1":{id:`small.en-q5_1`,name:`Small English (Q5_1)`,size:182,language:`en`,quantized:!0,url:`https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-small.en-q5_1.bin`},"small-q5_1":{id:`small-q5_1`,name:`Small Multilingual (Q5_1)`,size:182,language:`multilingual`,quantized:!0,url:`https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-small-q5_1.bin`},"medium.en-q5_0":{id:`medium.en-q5_0`,name:`Medium English (Q5_0)`,size:515,language:`en`,quantized:!0,url:`https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-medium.en-q5_0.bin`},"medium-q5_0":{id:`medium-q5_0`,name:`Medium Multilingual (Q5_0)`,size:515,language:`multilingual`,quantized:!0,url:`https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-medium-q5_0.bin`},"large-q5_0":{id:`large-q5_0`,name:`Large Multilingual (Q5_0)`,size:1030,language:`multilingual`,quantized:!0,url:`https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-large-q5_0.bin`}};function _(){return Object.values(g).map(({url:e,...t})=>t)}function v(e){return g[e]}var y=class{cacheEnabled=!0;models=_();logger;constructor(e={logLevel:t.levels.ERROR}){this.logger=new t(e.logLevel,`ModelManager`)}async loadModel(e,t=!0,n){let r=v(e);if(!r)throw Error(`Model ${e} not found in config`);if(this.cacheEnabled&&t){let t=await this.getCachedModel(e);if(t)return this.logger.info(`Model ${e} loaded from cache`),n&&n(100),t}this.logger.info(`Loading model ${e} from ${r.url}`);let i=await fetch(r.url);if(!i.ok)throw Error(`Failed to load model: ${i.statusText}`);let a=i.headers.get(`content-length`),o=a?parseInt(a,10):0,s=0,c=i.body?.getReader();if(!c)throw Error(`Response body is not readable`);let l=[];try{let e=!1;for(;!e;){let t=await c.read();e=t.done,!e&&t.value&&(l.push(t.value),s+=t.value.length,n&&o>0&&n(Math.round(s/o*100)))}}finally{c.releaseLock()}let u=l.reduce((e,t)=>e+t.length,0),d=new Uint8Array(u),f=0;for(let e of l)d.set(e,f),f+=e.length;return this.cacheEnabled&&t&&await this.saveModelToCache(e,d),n&&n(100),d}async loadModelByUrl(e,t){try{if(this.cacheEnabled){let n=await this.getCachedModelByUrl(e);if(n)return this.logger.info(`WASM module loaded from cache by URL: ${e}`),t&&t(100),n}this.logger.info(`Loading WASM module from URL: ${e}`);let n=await fetch(e);if(!n.ok)throw Error(`Failed to load WASM module: ${n.statusText}`);let r=n.headers.get(`content-length`),i=r?parseInt(r,10):0,a=0,o=n.body?.getReader();if(!o)throw Error(`Response body is not readable`);let s=[];try{let e=!1;for(;!e;){let n=await o.read();e=n.done,!e&&n.value&&(s.push(n.value),a+=n.value.length,t&&i>0&&t(Math.round(a/i*100)))}}finally{o.releaseLock()}let c=s.reduce((e,t)=>e+t.length,0),l=new Uint8Array(c),u=0;for(let e of s)l.set(e,u),u+=e.length;return this.cacheEnabled&&await this.saveModelToCacheByUrl(e,l),t&&t(100),l}catch(e){this.logger.error(e);let t=e instanceof Error?e.message:`Failed to load WASM module`;throw Error(t)}}async getCachedModelByUrl(e){try{let t=(await this.openIndexedDB()).transaction([`modelsByUrl`],`readonly`).objectStore(`modelsByUrl`);return new Promise((n,r)=>{let i=t.get(e);i.onsuccess=()=>{let e=i.result;e&&e.data?n(e.data):n(null)},i.onerror=()=>r(i.error)})}catch(e){return this.logger.error(`Error reading model from cache by URL:`,e),null}}async saveModelToCacheByUrl(e,t){try{let n=(await this.openIndexedDB()).transaction([`modelsByUrl`],`readwrite`).objectStore(`modelsByUrl`);await new Promise((r,i)=>{let a=n.put({url:e,data:t,timestamp:Date.now(),size:t.length});a.onsuccess=()=>r(),a.onerror=()=>i(a.error)}),this.logger.info(`Model saved to cache by URL: ${e}`)}catch(e){this.logger.error(`Error saving model to cache by URL:`,e)}}async getAvailableModels(){let e=[...this.models];if(!this.cacheEnabled)return e;try{let t=await this.getCachedModelNames();return e.map(e=>({...e,cached:t.includes(e.id)}))}catch(t){return this.logger.error(`Error checking cache status:`,t),e}}getAvailableModelsSync(){return[...this.models]}getModelConfig(e){return v(e)}async saveModelToCache(e,t){try{let n=(await this.openIndexedDB()).transaction([`models`],`readwrite`).objectStore(`models`);await new Promise((r,i)=>{let a=n.put({name:e,data:t,timestamp:Date.now(),size:t.length});a.onsuccess=()=>r(),a.onerror=()=>i(a.error)}),this.logger.info(`Model ${e} saved to cache`)}catch(e){this.logger.error(`Error saving model to cache:`,e)}}async getCachedModel(e){try{let t=(await this.openIndexedDB()).transaction([`models`],`readonly`).objectStore(`models`);return new Promise((n,r)=>{let i=t.get(e);i.onsuccess=()=>{let e=i.result;e&&e.data?n(e.data):n(null)},i.onerror=()=>r(i.error)})}catch(e){return this.logger.error(`Error getting cached model:`,e),null}}async getCachedModelNames(){try{let e=(await this.openIndexedDB()).transaction([`models`],`readonly`).objectStore(`models`);return new Promise((t,n)=>{let r=e.getAllKeys();r.onsuccess=()=>{let e=r.result;t(e)},r.onerror=()=>n(r.error)})}catch(e){return this.logger.error(`Error getting cached model names:`,e),[]}}async openIndexedDB(){return new Promise((e,t)=>{let n=indexedDB.open(`WhisperModels`,2);n.onerror=()=>t(n.error),n.onsuccess=()=>e(n.result),n.onupgradeneeded=e=>{let t=e.target.result;if(!t.objectStoreNames.contains(`models`)){let e=t.createObjectStore(`models`,{keyPath:`name`});e.createIndex(`timestamp`,`timestamp`,{unique:!1}),e.createIndex(`size`,`size`,{unique:!1})}if(!t.objectStoreNames.contains(`modelsByUrl`)){let e=t.createObjectStore(`modelsByUrl`,{keyPath:`url`});e.createIndex(`timestamp`,`timestamp`,{unique:!1}),e.createIndex(`size`,`size`,{unique:!1})}}})}async clearCache(){try{let e=(await this.openIndexedDB()).transaction([`models`,`modelsByUrl`],`readwrite`),t=e.objectStore(`models`);await new Promise((e,n)=>{let r=t.clear();r.onsuccess=()=>e(),r.onerror=()=>n(r.error)});let n=e.objectStore(`modelsByUrl`);await new Promise((e,t)=>{let r=n.clear();r.onsuccess=()=>e(),r.onerror=()=>t(r.error)}),this.logger.info(`Model cache cleared`)}catch(e){this.logger.error(`Error clearing cache:`,e)}}async getCacheInfo(){try{let e=(await this.openIndexedDB()).transaction([`models`],`readonly`).objectStore(`models`);return new Promise((t,n)=>{let r=e.getAll();r.onsuccess=()=>{let e=r.result,n=e.reduce((e,t)=>e+(t.size||0),0);t({count:e.length,totalSize:n})},r.onerror=()=>n(r.error)})}catch(e){return this.logger.error(`Error getting cache info:`,e),{count:0,totalSize:0}}}},b={targetSampleRate:16e3,targetChannels:1,inputSampleRate:16e3,normalize:!0,noiseReduction:!1,logLevel:t.levels.ERROR,signal:void 0,recordingDurationMs:1e4};function x(e){return typeof e==`number`?e:e?t.levels[e]:t.levels.ERROR}function S(e){return new t(x(e.logLevel),`AudioConverter`)}function C(e){if(e?.aborted)throw new DOMException(`Aborted`,`AbortError`)}function w(){return typeof window>`u`?!1:!!(window.AudioContext||window.webkitAudioContext||window.OfflineAudioContext||window.webkitOfflineAudioContext)}async function T(e,t={},n={}){if(!w())throw Error(`Web Audio API is not supported in this browser`);let r={...b,...t},i=S(r),a=[];try{C(r.signal),i.info(`Converting from MediaStream`),n.onProgress?.(0,`Starting recording...`);let t=await N(e,r,n,i);n.onProgress?.(50,`Recording completed, decoding...`);let o=await E(await t.arrayBuffer(),r,n,i);n.onProgress?.(70,`Audio decoded, processing...`);let s=await D(o,r,n,i,a);return n.onProgress?.(100,`Conversion completed`),s}catch(e){throw i.error(`MediaStream conversion failed:`,e),n.onError?.(e),e}}async function E(e,t,n,r){n.onProgress?.(15,`Decoding audio data`);let i=new(window.AudioContext||window.webkitAudioContext)({sampleRate:t.targetSampleRate});try{return await i.decodeAudioData(e)}catch(e){throw r.error(`Audio decoding failed:`,e),Error(`Failed to decode audio: ${e.message}`)}finally{try{await i.close()}catch{}}}async function D(e,t,n,r,i){n.onProgress?.(50,`Converting audio format...`),M(e,t,i);let a=await O(e,t,n);n.onProgress?.(70,`Converting to Float32Array...`);let o=k(a);return n.onProgress?.(80,`Applying effects...`),t.normalize&&A(o),t.noiseReduction&&j(o),n.onProgress?.(90,`Finalizing...`),{audioData:o,audioInfo:{sampleRate:a.sampleRate,duration:a.duration,channels:a.numberOfChannels,bitDepth:32,format:`float32`},warnings:i.length>0?i:void 0}}async function O(e,t,n){n.onProgress?.(60,`Converting audio format...`);let r=new(window.OfflineAudioContext||window.webkitOfflineAudioContext)(t.targetChannels,Math.floor(e.length*t.targetSampleRate/e.sampleRate),t.targetSampleRate),i=r.createBufferSource();return i.buffer=e,i.connect(r.destination),i.start(0),await r.startRendering()}function k(e){if(e.numberOfChannels===1)return e.getChannelData(0);{let t=e.getChannelData(0),n=e.getChannelData(1),r=new Float32Array(t.length);for(let e=0;e<t.length;e++)r[e]=(t[e]+n[e])/2;return r}}function A(e){let t=0;for(let n=0;n<e.length;n++)t=Math.max(t,Math.abs(e[n]));if(t>0){let n=.95/t;for(let t=0;t<e.length;t++)e[t]*=n}}function j(e){let t=new Float32Array(e.length);for(let n=0;n<e.length;n++){let r=0,i=0;for(let t=Math.max(0,n-3);t<=Math.min(e.length-1,n+3);t++)r+=e[t],i++;t[n]=r/i}e.set(t)}function M(e,t,n){e.numberOfChannels>2&&n.push(`Audio has ${e.numberOfChannels} channels, will be mixed to mono`),e.sampleRate!==t.targetSampleRate&&n.push(`Audio sample rate (${e.sampleRate}Hz) will be converted to ${t.targetSampleRate}Hz`)}async function N(e,t,n,r){if(typeof window>`u`)throw Error(`MediaStream recording is only supported in browser environments`);if(!window.MediaRecorder)throw Error(`MediaRecorder is not supported in this browser`);let i=window.MediaRecorder,a=[`audio/webm;codecs=opus`,`audio/webm`,`audio/ogg;codecs=opus`,`audio/ogg`].find(e=>i.isTypeSupported(e)),o=new i(e,a?{mimeType:a}:void 0),s=[],c=new Promise((e,t)=>{o.ondataavailable=e=>{e.data&&e.data.size>0&&s.push(e.data)},o.onerror=()=>t(Error(`MediaRecorder error`)),o.onstop=()=>{let t=a||o.mimeType||`application/octet-stream`;e(new Blob(s,{type:t}))}}),l=t.signal,u=()=>{try{o.state!==`inactive`&&o.stop()}catch{}};l?.addEventListener(`abort`,u,{once:!0});let d=t.recordingDurationMs??1e4,f=setTimeout(()=>{try{o.state!==`inactive`&&o.stop()}catch{}},d);n.onProgress?.(20,`Recording audio...`),r.debug(`Starting MediaRecorder`,{mimeType:a??o.mimeType,durationMs:d}),o.start(250);try{return await c}finally{clearTimeout(f),l?.removeEventListener(`abort`,u)}}export{i,y as n,h as r,T as t};
@@ -0,0 +1 @@
1
+ <svg width="16" height="15" viewBox="0 0 16 15" fill="none" xmlns="http://www.w3.org/2000/svg"><mask id="antigravity__mask0_111_52" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="16" height="15"><path d="M14.0777 13.984C14.945 14.6345 16.2458 14.2008 15.0533 13.0084C11.476 9.53949 12.2349 0 7.79033 0C3.34579 0 4.10461 9.53949 0.527295 13.0084C-0.773543 14.3092 0.635692 14.6345 1.50293 13.984C4.86344 11.7076 4.64663 7.69664 7.79033 7.69664C10.934 7.69664 10.7172 11.7076 14.0777 13.984Z" fill="black"/></mask><g mask="url(#antigravity__mask0_111_52)"><g filter="url(#antigravity__filter0_f_111_52)"><path d="M-0.658907 -3.2306C-0.922679 -0.906781 1.07986 1.22861 3.81388 1.53894C6.54791 1.84927 8.97811 0.217009 9.24188 -2.10681C9.50565 -4.43063 7.50312 -6.56602 4.76909 -6.87635C2.03506 -7.18667 -0.395135 -5.55442 -0.658907 -3.2306Z" fill="#FFE432"/></g><g filter="url(#antigravity__filter1_f_111_52)"><path d="M9.88233 4.36642C10.5673 7.31568 13.566 9.13902 16.5801 8.43896C19.5942 7.73891 21.4823 4.78056 20.7973 1.83131C20.1123 -1.11795 17.1136 -2.94128 14.0995 -2.24123C11.0854 -1.54118 9.19733 1.41717 9.88233 4.36642Z" fill="#FC413D"/></g><g filter="url(#antigravity__filter2_f_111_52)"><path d="M-8.05291 6.34512C-7.18736 9.38883 -3.28925 10.9473 0.653774 9.82598C4.5968 8.7047 7.09158 5.32829 6.22603 2.28458C5.36048 -0.759142 1.46236 -2.31758 -2.48066 -1.19629C-6.42368 -0.0750048 -8.91846 3.3014 -8.05291 6.34512Z" fill="#00B95C"/></g><g filter="url(#antigravity__filter3_f_111_52)"><path d="M-8.05291 6.34512C-7.18736 9.38883 -3.28925 10.9473 0.653774 9.82598C4.5968 8.7047 7.09158 5.32829 6.22603 2.28458C5.36048 -0.759142 1.46236 -2.31758 -2.48066 -1.19629C-6.42368 -0.0750048 -8.91846 3.3014 -8.05291 6.34512Z" fill="#00B95C"/></g><g filter="url(#antigravity__filter4_f_111_52)"><path d="M-4.92402 8.86746C-2.75421 11.0837 0.982691 10.9438 3.42257 8.55507C5.86246 6.1663 6.08139 2.43321 3.91158 0.216963C1.74177 -1.99928 -1.99513 -1.85942 -4.43501 0.529349C-6.87489 2.91812 -7.09383 6.65122 -4.92402 8.86746Z" fill="#00B95C"/></g><g filter="url(#antigravity__filter5_f_111_52)"><path d="M6.42819 17.2263C7.10197 20.1273 9.91278 21.953 12.7063 21.3042C15.4998 20.6553 17.2182 17.7777 16.5444 14.8767C15.8707 11.9757 13.0599 10.15 10.2663 10.7988C7.47281 11.4477 5.75441 14.3253 6.42819 17.2263Z" fill="#3186FF"/></g><g filter="url(#antigravity__filter6_f_111_52)"><path d="M1.66508 -5.94539C0.254213 -2.80254 1.7978 0.951609 5.11277 2.43973C8.42774 3.92785 12.2588 2.58642 13.6696 -0.556431C15.0805 -3.69928 13.5369 -7.45343 10.222 -8.94155C6.90699 -10.4297 3.07594 -9.08824 1.66508 -5.94539Z" fill="#FBBC04"/></g><g filter="url(#antigravity__filter7_f_111_52)"><path d="M-2.11428 24.3903C-5.52984 23.0496 0.307266 12.0177 1.75874 8.32038C3.21024 4.62304 7.15576 2.71272 10.5713 4.05357C13.9869 5.39442 18.0354 12.7796 16.5838 16.477C15.1323 20.1743 1.30129 25.7311 -2.11428 24.3903Z" fill="#3186FF"/></g><g filter="url(#antigravity__filter8_f_111_52)"><path d="M18.5814 10.6598C17.6669 11.727 15.2806 11.1828 13.2514 9.44417C11.2222 7.70556 10.3185 5.43097 11.2329 4.3637C12.1473 3.29646 14.5336 3.84069 16.5628 5.57928C18.592 7.31789 19.4958 9.59249 18.5814 10.6598Z" fill="#749BFF"/></g><g filter="url(#antigravity__filter9_f_111_52)"><path d="M11.7552 5.22715C15.5162 7.77124 19.8471 7.93838 21.4286 5.60045C23.0101 3.26253 21.2433 -0.695128 17.4823 -3.23922C13.7213 -5.78331 9.39044 -5.95044 7.80896 -3.61252C6.22747 -1.27459 7.99428 2.68306 11.7552 5.22715Z" fill="#FC413D"/></g><g filter="url(#antigravity__filter10_f_111_52)"><path d="M-0.592149 1.08896C-1.5239 3.33663 -1.21959 5.59799 0.0875457 6.13985C1.39468 6.68171 3.20966 5.29888 4.14141 3.05121C5.07316 0.803541 4.76885 -1.45782 3.46171 -1.99968C2.15458 -2.54154 0.339602 -1.15871 -0.592149 1.08896Z" fill="#FFEE48"/></g></g><defs><filter id="antigravity__filter0_f_111_52" x="-2.12817" y="-8.35998" width="12.8393" height="11.383" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur stdDeviation="0.722959" result="effect1_foregroundBlur_111_52"/></filter><filter id="antigravity__filter1_f_111_52" x="2.75168" y="-9.38089" width="25.1763" height="24.96" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur stdDeviation="3.49513" result="effect1_foregroundBlur_111_52"/></filter><filter id="antigravity__filter2_f_111_52" x="-14.1669" y="-7.50196" width="26.5068" height="23.6338" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur stdDeviation="2.97119" result="effect1_foregroundBlur_111_52"/></filter><filter id="antigravity__filter3_f_111_52" x="-14.1669" y="-7.50196" width="26.5068" height="23.6338" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur stdDeviation="2.97119" result="effect1_foregroundBlur_111_52"/></filter><filter id="antigravity__filter4_f_111_52" x="-12.3607" y="-7.29981" width="23.709" height="23.6846" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur stdDeviation="2.97119" result="effect1_foregroundBlur_111_52"/></filter><filter id="antigravity__filter5_f_111_52" x="0.634962" y="5.02095" width="21.7027" height="22.0616" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur stdDeviation="2.82351" result="effect1_foregroundBlur_111_52"/></filter><filter id="antigravity__filter6_f_111_52" x="-3.97547" y="-14.6666" width="23.2857" height="22.8313" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur stdDeviation="2.5589" result="effect1_foregroundBlur_111_52"/></filter><filter id="antigravity__filter7_f_111_52" x="-7.7407" y="-0.945408" width="29.1982" height="30.1105" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur stdDeviation="2.2852" result="effect1_foregroundBlur_111_52"/></filter><filter id="antigravity__filter8_f_111_52" x="6.78641" y="-0.27231" width="16.2415" height="15.5681" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur stdDeviation="2.04485" result="effect1_foregroundBlur_111_52"/></filter><filter id="antigravity__filter9_f_111_52" x="3.77526" y="-8.71693" width="21.687" height="19.4212" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur stdDeviation="1.72712" result="effect1_foregroundBlur_111_52"/></filter><filter id="antigravity__filter10_f_111_52" x="-5.40727" y="-6.39238" width="14.3639" height="16.9254" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur stdDeviation="2.1376" result="effect1_foregroundBlur_111_52"/></filter></defs></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="60" height="60" viewBox="0 0 60 60" fill="none"><path d="M23.2312 25.1611L23.2312 25.1651C24.079 24.6758 25.0422 24.4173 26.0173 24.4173L26.089 24.4173L26.1904 24.4193C26.2581 24.4212 26.3238 24.4232 26.3914 24.4292L26.4412 24.4332C27.2452 24.4928 28.0094 24.7196 28.7218 25.1114C28.7934 25.1512 28.8631 25.1909 28.9328 25.2327C28.9865 25.2665 29.0402 25.3003 29.0959 25.3361L29.1477 25.3699C29.5875 25.6663 29.9835 26.0263 30.3338 26.4479C30.3815 26.5056 30.4273 26.5633 30.483 26.6369L30.5109 26.6727C30.5467 26.7204 30.5825 26.7701 30.6163 26.8198L30.678 26.9093C30.7059 26.9511 30.7318 26.9929 30.7576 27.0346C30.7795 27.0704 30.8014 27.1062 30.8233 27.142L30.8611 27.2057C31.3507 28.051 31.6094 29.0176 31.6094 29.9961L31.6074 29.9961C31.6074 30.9766 31.3487 31.9412 30.8591 32.7865L30.7736 32.9317C30.7377 32.9894 30.7019 33.045 30.6661 33.1007L30.6382 33.1425C30.1845 33.8088 29.6074 34.3557 28.9089 34.7774C28.8392 34.8191 28.7696 34.8589 28.6979 34.8987C28.6422 34.9305 28.5845 34.9584 28.5268 34.9882L28.4711 35.016C27.9934 35.2487 27.484 35.4118 26.9447 35.5033C26.871 35.5152 26.7974 35.5252 26.7238 35.5351L26.6621 35.5431C26.6024 35.5491 26.5427 35.555 26.481 35.561C26.4452 35.563 26.4094 35.567 26.3735 35.5689C26.3238 35.5729 26.276 35.5749 26.2263 35.5749C26.1845 35.5749 26.1427 35.5769 26.1009 35.5789L26.0253 35.5789L26.0213 35.5789C25.0442 35.5789 24.081 35.3203 23.2332 34.8311L18.067 31.8517L7.73063 37.8263L7.72664 49.7497L18.063 55.7144L28.4034 49.7477L28.4034 43.783C28.4034 42.8025 28.6621 41.8379 29.1517 40.9926L29.2372 40.8474C29.2731 40.7898 29.3089 40.7341 29.3447 40.6784L29.3726 40.6366C29.8263 39.9703 30.4034 39.4234 31.1019 39.0018C31.1716 38.96 31.2412 38.9202 31.3129 38.8804C31.3686 38.8506 31.4243 38.8208 31.484 38.7909L31.5397 38.7631C32.0173 38.5304 32.5268 38.3673 33.0661 38.2758C33.1397 38.2639 33.2134 38.2539 33.287 38.244L33.3487 38.236C33.4084 38.2301 33.4681 38.2241 33.5318 38.2181L33.6373 38.2102C33.687 38.2062 33.7348 38.2042 33.7845 38.2042C33.8263 38.2042 33.8681 38.2022 33.9099 38.2002L33.9855 38.2002L33.9895 38.2002C34.9666 38.2002 35.9298 38.4588 36.7776 38.9481L41.9458 41.9274L52.2861 35.9608L52.2822 24.0334L41.9478 18.0668L36.7796 21.0541L36.7756 21.0461C35.9258 21.5354 34.9646 21.788 33.9815 21.7939L33.9159 21.7939L33.8124 21.7919C33.7447 21.79 33.6791 21.788 33.6114 21.782L33.5616 21.778C32.7577 21.7184 31.9935 21.4916 31.281 21.0998C31.2094 21.06 31.1397 21.0203 31.0701 20.9785C31.0144 20.9447 30.9606 20.9089 30.9069 20.8751L30.8552 20.8413C30.4154 20.5449 30.0193 20.1849 29.6691 19.7633C29.6213 19.7056 29.5755 19.6479 29.5198 19.5743L29.492 19.5385C29.4561 19.4908 29.4203 19.4411 29.3865 19.3914L29.3248 19.3019C29.2969 19.2601 29.2711 19.2183 29.2452 19.1766C29.2233 19.1408 29.1994 19.105 29.1775 19.0672L29.1417 19.0055C28.6522 18.1602 28.3934 17.1936 28.3934 16.2151L28.3915 16.2151L28.3915 10.2524L18.1048 4.31363L18.0551 4.28578L7.71869 10.2604L7.71471 22.1838L18.0511 28.1484L23.2213 25.1651L23.2312 25.1611Z" fill="#191919" fill-opacity="0.4"/></svg>
@@ -19,28 +19,29 @@
19
19
  <meta name="apple-mobile-web-app-title" content="Tarsk" />
20
20
 
21
21
  <title>Tarsk</title>
22
- <script type="module" crossorigin src="/assets/index-BTbiyooe.js"></script>
22
+ <script type="module" crossorigin src="/assets/index-DKQVo4Vz.js"></script>
23
23
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-B1FJdls4.js">
24
- <link rel="modulepreload" crossorigin href="/assets/dialogs-config-DZFG2IQM.js">
25
- <link rel="modulepreload" crossorigin href="/assets/history-view-BR8scGnM.js">
26
- <link rel="modulepreload" crossorigin href="/assets/monaco-DDfTQM3i.js">
27
- <link rel="modulepreload" crossorigin href="/assets/react-vendor-Bao-KYKs.js">
28
- <link rel="modulepreload" crossorigin href="/assets/onboarding-Cn5RqOCa.js">
29
- <link rel="modulepreload" crossorigin href="/assets/alert-dialog--tUzAWFm.js">
30
- <link rel="modulepreload" crossorigin href="/assets/use-toast-DqmC-mB5.js">
31
- <link rel="modulepreload" crossorigin href="/assets/store-CwvBC-YP.js">
32
- <link rel="modulepreload" crossorigin href="/assets/tab-context-CCvlrC0o.js">
33
- <link rel="modulepreload" crossorigin href="/assets/whisper-wasm-Clnf-l-9.js">
34
- <link rel="modulepreload" crossorigin href="/assets/utils-Cy2s2TEb.js">
35
- <link rel="modulepreload" crossorigin href="/assets/chat-input-container-B_qVOGzW.js">
36
- <link rel="modulepreload" crossorigin href="/assets/page-toolbar-TvYsDwUY.js">
37
- <link rel="modulepreload" crossorigin href="/assets/run-stop-button-k1LeM0M-.js">
38
- <link rel="modulepreload" crossorigin href="/assets/side-panel-container-oMcXib2A.js">
39
- <link rel="modulepreload" crossorigin href="/assets/resizable-DzrIos_Y.js">
40
- <link rel="modulepreload" crossorigin href="/assets/standard-list-item-D2lbPXa1.js">
41
- <link rel="modulepreload" crossorigin href="/assets/tabs-Mb_cjIfE.js">
42
- <link rel="modulepreload" crossorigin href="/assets/textarea-DpXOZLt8.js">
43
- <link rel="stylesheet" crossorigin href="/assets/index-0BuHfewk.css">
24
+ <link rel="modulepreload" crossorigin href="/assets/dialogs-config-vkfELnGl.js">
25
+ <link rel="modulepreload" crossorigin href="/assets/history-view-Dn0hQIKU.js">
26
+ <link rel="modulepreload" crossorigin href="/assets/monaco-SWcefg0q.js">
27
+ <link rel="modulepreload" crossorigin href="/assets/react-vendor-DyE9sO8V.js">
28
+ <link rel="modulepreload" crossorigin href="/assets/onboarding-DslO5AS6.js">
29
+ <link rel="modulepreload" crossorigin href="/assets/alert-dialog-CQRWdGnn.js">
30
+ <link rel="modulepreload" crossorigin href="/assets/use-toast-yY7qQuQP.js">
31
+ <link rel="modulepreload" crossorigin href="/assets/store-BcwWHqYr.js">
32
+ <link rel="modulepreload" crossorigin href="/assets/tab-context-DWD20a4z.js">
33
+ <link rel="modulepreload" crossorigin href="/assets/whisper-wasm-B7iuRPFr.js">
34
+ <link rel="modulepreload" crossorigin href="/assets/utils-BKss67Vg.js">
35
+ <link rel="modulepreload" crossorigin href="/assets/chat-input-container-C6U_WFFu.js">
36
+ <link rel="modulepreload" crossorigin href="/assets/markdown-renderer-CNuyXHcy.js">
37
+ <link rel="modulepreload" crossorigin href="/assets/page-toolbar-CloU_Kvo.js">
38
+ <link rel="modulepreload" crossorigin href="/assets/run-stop-button-DZ4JFwdL.js">
39
+ <link rel="modulepreload" crossorigin href="/assets/side-panel-container-BAYoMt7B.js">
40
+ <link rel="modulepreload" crossorigin href="/assets/resizable-dToeUeVD.js">
41
+ <link rel="modulepreload" crossorigin href="/assets/standard-list-item-BLlgm1qW.js">
42
+ <link rel="modulepreload" crossorigin href="/assets/tabs-CgvpwOBj.js">
43
+ <link rel="modulepreload" crossorigin href="/assets/textarea-C2UIAa7y.js">
44
+ <link rel="stylesheet" crossorigin href="/assets/index-Bdde81Uo.css">
44
45
  </head>
45
46
  <body class="font-sans antialiased">
46
47
  <div id="root"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tarsk",
3
- "version": "0.4.27",
3
+ "version": "0.4.28",
4
4
  "description": "CLI for Tarsk - Project Threads Manager",
5
5
  "keywords": [
6
6
  "cli",
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{Dr as t,Ji as n,Jt as r,Q as i,Rn as a,ca as o,ya as s,yi as c}from"./dialogs-config-DZFG2IQM.js";import{t as l}from"./use-toast-DqmC-mB5.js";import{t as u}from"./skeleton-Bc0U0oGc.js";var d=e(s(),1),f=t();function p(){let[e,t]=(0,d.useState)(null),[s,p]=(0,d.useState)(!0);(0,d.useEffect)(()=>{m();let e=()=>{document.visibilityState===`visible`&&m()};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[]);async function m(){p(!0);try{t(await i())}catch(e){l({title:`Error`,description:e instanceof Error?e.message:`Failed to load account info`,variant:`destructive`})}finally{p(!1)}}function h(){r(`https://buy.stripe.com/14AcN6feK0Jjbheb2H3Nm03?client_reference_id=${e?.clientReferenceId??``}`)}function g(){r(`https://buy.stripe.com/9B67sMd6CgIh70Y0o33Nm04?client_reference_id=${e?.clientReferenceId??``}`)}if(s)return(0,f.jsxs)(`div`,{className:`max-w-2xl mx-auto p-6`,children:[(0,f.jsxs)(`div`,{className:`mb-6`,children:[(0,f.jsx)(u,{className:`h-8 w-32 mb-2`}),(0,f.jsx)(u,{className:`h-4 w-64`})]}),(0,f.jsxs)(`div`,{className:`space-y-6`,children:[(0,f.jsxs)(`div`,{className:`flex gap-4`,children:[(0,f.jsxs)(`div`,{className:`flex-1 rounded-xl border bg-card p-5 space-y-2`,children:[(0,f.jsx)(u,{className:`h-4 w-20`}),(0,f.jsx)(u,{className:`h-9 w-28`})]}),(0,f.jsxs)(`div`,{className:`flex-1 rounded-xl border bg-card p-5 space-y-3`,children:[(0,f.jsx)(u,{className:`h-4 w-24`}),(0,f.jsx)(u,{className:`h-6 w-32`}),(0,f.jsx)(u,{className:`h-4 w-full`})]})]}),(0,f.jsxs)(`div`,{className:`space-y-3`,children:[(0,f.jsx)(u,{className:`h-4 w-24`}),(0,f.jsxs)(`div`,{className:`rounded-xl border bg-card p-5 flex items-center justify-between gap-4`,children:[(0,f.jsxs)(`div`,{className:`space-y-1 flex-1`,children:[(0,f.jsx)(u,{className:`h-5 w-28`}),(0,f.jsx)(u,{className:`h-4 w-64`})]}),(0,f.jsx)(u,{className:`h-9 w-28 shrink-0`})]}),(0,f.jsxs)(`div`,{className:`rounded-xl border bg-card p-5 flex items-center justify-between gap-4`,children:[(0,f.jsxs)(`div`,{className:`space-y-1 flex-1`,children:[(0,f.jsx)(u,{className:`h-5 w-36`}),(0,f.jsx)(u,{className:`h-4 w-56`}),(0,f.jsx)(u,{className:`h-4 w-32`})]}),(0,f.jsx)(u,{className:`h-9 w-24 shrink-0`})]})]})]})]});let _=e?.plan===`unlimited-pro`;return(0,f.jsxs)(`div`,{className:`max-w-2xl mx-auto p-6`,children:[(0,f.jsxs)(`div`,{className:`mb-6`,children:[(0,f.jsx)(`h1`,{className:`text-2xl font-bold`,children:`Account`}),(0,f.jsx)(`p`,{className:`text-muted-foreground`,children:`Manage your Tarsk plan and prompt balance.`})]}),(0,f.jsxs)(`div`,{className:`space-y-6`,children:[(0,f.jsxs)(`div`,{className:`flex gap-4`,children:[(0,f.jsxs)(`div`,{className:`flex-1 rounded-xl border bg-card p-5 space-y-2`,children:[(0,f.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-muted-foreground`,children:[(0,f.jsx)(c,{className:`h-4 w-4`}),`Balance`]}),(0,f.jsx)(`div`,{className:`flex items-end gap-2`,children:_?(0,f.jsx)(`span`,{className:`text-3xl font-bold`,children:`Unlimited`}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(`span`,{className:`text-3xl font-bold`,children:e?.promptsRemaining.toLocaleString()??0}),(0,f.jsx)(`span`,{className:`text-muted-foreground mb-1 text-sm`,children:`prompts remaining`})]})})]}),(0,f.jsxs)(`div`,{className:`flex-1 rounded-xl border bg-card p-5 space-y-3`,children:[(0,f.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-muted-foreground`,children:[(0,f.jsx)(n,{className:`h-4 w-4`}),`Current Plan`]}),(0,f.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,f.jsx)(`span`,{className:`text-lg font-semibold`,children:_?`Unlimited Pro`:`Pay as you go`}),_&&(0,f.jsx)(`span`,{className:`rounded-full bg-primary/10 px-2 py-0.5 text-xs font-medium text-primary`,children:`Active`})]}),(0,f.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:_?`You have unlimited prompts with no restrictions.`:`Purchase prompts as needed. Upgrade to Pro for unlimited access.`})]})]}),!_&&(0,f.jsxs)(`div`,{className:`space-y-3`,children:[(0,f.jsx)(`h2`,{className:`text-sm font-semibold text-muted-foreground uppercase tracking-wide`,children:`Add Prompts`}),(0,f.jsxs)(`div`,{className:`rounded-xl border bg-card p-5 flex items-center justify-between gap-4`,children:[(0,f.jsxs)(`div`,{className:`space-y-1`,children:[(0,f.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,f.jsx)(`span`,{className:`font-semibold`,children:`1,000 Prompts`})}),(0,f.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Top up your balance with 1,000 additional prompts for $5.`})]}),(0,f.jsx)(a,{onClick:h,className:`shrink-0`,children:`Top Up Balance`})]}),(0,f.jsxs)(`div`,{className:`rounded-xl border bg-card p-5 flex items-center justify-between gap-4`,children:[(0,f.jsxs)(`div`,{className:`space-y-1`,children:[(0,f.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,f.jsx)(n,{className:`h-4 w-4 text-primary`}),(0,f.jsx)(`span`,{className:`font-semibold`,children:`Unlimited Pro Plan`})]}),(0,f.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Unlimited prompts for $100 and lifetime access to Tarsk.`}),(0,f.jsxs)(`ul`,{className:`text-sm text-muted-foreground space-y-0.5`,children:[(0,f.jsxs)(`li`,{className:`flex items-center gap-1.5`,children:[(0,f.jsx)(o,{className:`h-3 w-3 text-primary`}),`Unlimited prompts`]}),(0,f.jsxs)(`li`,{className:`flex items-center gap-1.5`,children:[(0,f.jsx)(o,{className:`h-3 w-3 text-primary`}),`Priority access`]})]})]}),(0,f.jsx)(a,{onClick:g,className:`shrink-0`,children:`Purchase`})]})]})]})]})}export{p as default};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{Dr as t,Jn as n,_a as r,ya as i,zn as a}from"./dialogs-config-DZFG2IQM.js";import{at as o,ct as s,dt as c,ft as l,lt as u,ot as d,st as f,ut as p}from"./react-vendor-Bao-KYKs.js";var m=r(),h=e(i(),1),g=t(),_=c,v=p,y=h.forwardRef((e,t)=>{let r=(0,m.c)(9),i,a;r[0]===e?(i=r[1],a=r[2]):({className:i,...a}=e,r[0]=e,r[1]=i,r[2]=a);let o;r[3]===i?o=r[4]:(o=n(`fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0`,i),r[3]=i,r[4]=o);let s;return r[5]!==a||r[6]!==t||r[7]!==o?(s=(0,g.jsx)(u,{className:o,...a,ref:t}),r[5]=a,r[6]=t,r[7]=o,r[8]=s):s=r[8],s});y.displayName=u.displayName;var b=h.forwardRef((e,t)=>{let r=(0,m.c)(10),i,a;r[0]===e?(i=r[1],a=r[2]):({className:i,...a}=e,r[0]=e,r[1]=i,r[2]=a);let o;r[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,g.jsx)(y,{}),r[3]=o):o=r[3];let s;r[4]===i?s=r[5]:(s=n(`fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg`,i),r[4]=i,r[5]=s);let c;return r[6]!==a||r[7]!==t||r[8]!==s?(c=(0,g.jsxs)(v,{children:[o,(0,g.jsx)(f,{ref:t,className:s,...a})]}),r[6]=a,r[7]=t,r[8]=s,r[9]=c):c=r[9],c});b.displayName=f.displayName;var x=e=>{let t=(0,m.c)(8),r,i;t[0]===e?(r=t[1],i=t[2]):({className:r,...i}=e,t[0]=e,t[1]=r,t[2]=i);let a;t[3]===r?a=t[4]:(a=n(`flex flex-col space-y-2 text-center sm:text-left`,r),t[3]=r,t[4]=a);let o;return t[5]!==i||t[6]!==a?(o=(0,g.jsx)(`div`,{className:a,...i}),t[5]=i,t[6]=a,t[7]=o):o=t[7],o};x.displayName=`AlertDialogHeader`;var S=e=>{let t=(0,m.c)(8),r,i;t[0]===e?(r=t[1],i=t[2]):({className:r,...i}=e,t[0]=e,t[1]=r,t[2]=i);let a;t[3]===r?a=t[4]:(a=n(`flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2`,r),t[3]=r,t[4]=a);let o;return t[5]!==i||t[6]!==a?(o=(0,g.jsx)(`div`,{className:a,...i}),t[5]=i,t[6]=a,t[7]=o):o=t[7],o};S.displayName=`AlertDialogFooter`;var C=h.forwardRef((e,t)=>{let r=(0,m.c)(9),i,a;r[0]===e?(i=r[1],a=r[2]):({className:i,...a}=e,r[0]=e,r[1]=i,r[2]=a);let o;r[3]===i?o=r[4]:(o=n(`text-lg font-semibold`,i),r[3]=i,r[4]=o);let s;return r[5]!==a||r[6]!==t||r[7]!==o?(s=(0,g.jsx)(l,{ref:t,className:o,...a}),r[5]=a,r[6]=t,r[7]=o,r[8]=s):s=r[8],s});C.displayName=l.displayName;var w=h.forwardRef((e,t)=>{let r=(0,m.c)(9),i,a;r[0]===e?(i=r[1],a=r[2]):({className:i,...a}=e,r[0]=e,r[1]=i,r[2]=a);let o;r[3]===i?o=r[4]:(o=n(`text-sm text-muted-foreground`,i),r[3]=i,r[4]=o);let c;return r[5]!==a||r[6]!==t||r[7]!==o?(c=(0,g.jsx)(s,{ref:t,className:o,...a}),r[5]=a,r[6]=t,r[7]=o,r[8]=c):c=r[8],c});w.displayName=s.displayName;var T=h.forwardRef((e,t)=>{let r=(0,m.c)(9),i,s;r[0]===e?(i=r[1],s=r[2]):({className:i,...s}=e,r[0]=e,r[1]=i,r[2]=s);let c;r[3]===i?c=r[4]:(c=n(a(),i),r[3]=i,r[4]=c);let l;return r[5]!==s||r[6]!==t||r[7]!==c?(l=(0,g.jsx)(o,{ref:t,className:c,...s}),r[5]=s,r[6]=t,r[7]=c,r[8]=l):l=r[8],l});T.displayName=o.displayName;var E=h.forwardRef((e,t)=>{let r=(0,m.c)(9),i,o;r[0]===e?(i=r[1],o=r[2]):({className:i,...o}=e,r[0]=e,r[1]=i,r[2]=o);let s;r[3]===i?s=r[4]:(s=n(a({variant:`outline`}),`mt-2 sm:mt-0`,i),r[3]=i,r[4]=s);let c;return r[5]!==o||r[6]!==t||r[7]!==s?(c=(0,g.jsx)(d,{ref:t,className:s,...o}),r[5]=o,r[6]=t,r[7]=s,r[8]=c):c=r[8],c});E.displayName=d.displayName;export{w as a,C as c,b as i,T as n,S as o,E as r,x as s,_ as t};
@@ -1 +0,0 @@
1
- import{An as e,Dn as t,En as n,On as r,Tn as i,jn as a,kn as o}from"./dialogs-config-DZFG2IQM.js";async function s(e,r){return t(`api/threads/${n(e)}/explorer?path=${encodeURIComponent(r)}`)}async function c(e,r){return t(`api/threads/${n(e)}/ai-file?path=${encodeURIComponent(r)}`)}async function l(e,t,r){return a(`api/threads/${n(e)}/ai-file`,{path:t,content:r})}async function u(e,t){return i(`api/threads/${n(e)}/explorer?path=${encodeURIComponent(t)}`)}async function d(e,t,r){return o(`api/threads/${n(e)}/explorer`,{path:t,newName:r})}async function f(t,r,i){return e(`api/threads/${n(t)}/explorer/file`,{dirPath:r,name:i})}function p(e,t){return`${r()}/api/threads/${n(e)}/explorer/media?path=${encodeURIComponent(t)}`}async function m(t,r,i){return e(`api/threads/${n(t)}/explorer/folder`,{dirPath:r,name:i})}export{p as a,l as c,c as i,m as n,s as o,u as r,d as s,f as t};
@@ -1,21 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{$ as t,$i as n,Br as r,Bt as i,Ci as a,Cn as o,D as s,Di as c,Dr as l,Ft as u,Gn as d,Gr as f,Hi as p,Hn as m,Ii as h,Jn as g,Kn as _,Mr as v,Mt as y,Nr as b,Nt as x,On as S,Ot as C,Pi as w,Pt as T,Qt as E,Ri as D,Rn as O,Si as k,Un as A,Ur as j,Vi as M,Wn as N,X as P,_a as F,aa as I,ai as L,at as R,ca as ee,d as te,dn as ne,dt as re,ea as z,ei as B,et as V,gn as H,hn as U,ia as W,ii as G,ki as K,kt as q,la as J,li as ie,ln as ae,m as oe,mi as se,na as ce,nt as le,pa as ue,qn as de,qr as fe,ra as pe,rt as me,vi as he,w as ge,wi as _e,wn as ve,y as ye,ya as be,zr as xe}from"./dialogs-config-DZFG2IQM.js";import{$ as Se,B as Ce,G as we,H as Te,J as Ee,K as De,L as Oe,Q as ke,R as Ae,U as je,V as Me,X as Ne,Y as Pe,Z as Fe,q as Ie,vt as Le}from"./react-vendor-Bao-KYKs.js";import{a as Re,l as ze,s as Be,t as Y,u as Ve}from"./store-CwvBC-YP.js";import{c as He,s as Ue,u as We}from"./history-view-BR8scGnM.js";import{n as Ge,t as Ke}from"./use-toast-DqmC-mB5.js";import{a as qe,c as Je,i as Ye,o as Xe,s as Ze,t as Qe}from"./alert-dialog--tUzAWFm.js";import{n as $e}from"./tab-context-CCvlrC0o.js";import{r as et}from"./onboarding-Cn5RqOCa.js";import{i as tt,n as nt,r as rt,t as it}from"./whisper-wasm-Clnf-l-9.js";import{n as at}from"./utils-Cy2s2TEb.js";var X=F(),Z=e(be(),1),Q=l();function ot(e){let t=(0,X.c)(30),{node:n,level:r,renderNode:i,defaultOpen:a,indent:o,childContainerClassName:s,openState:c,onToggle:l,forceOpenIds:u}=e,d=!!(n.children&&n.children.length>0),f,p,m;if(t[0]!==a||t[1]!==u||t[2]!==d||t[3]!==r||t[4]!==n||t[5]!==l||t[6]!==c||t[7]!==i){f=u?.has(n.id)||(c[n.id]??a);let e;t[11]!==n.id||t[12]!==l?(e=()=>l(n.id),t[11]=n.id,t[12]=l,t[13]=e):e=t[13];let o=e;p=`min-w-0`,m=i(n,{isOpen:f,level:r,toggle:o,hasChildren:d}),t[0]=a,t[1]=u,t[2]=d,t[3]=r,t[4]=n,t[5]=l,t[6]=c,t[7]=i,t[8]=f,t[9]=p,t[10]=m}else f=t[8],p=t[9],m=t[10];let h;t[14]!==s||t[15]!==a||t[16]!==u||t[17]!==d||t[18]!==o||t[19]!==f||t[20]!==r||t[21]!==n.children||t[22]!==l||t[23]!==c||t[24]!==i?(h=d&&f&&(0,Q.jsx)(`div`,{style:{paddingLeft:o},className:s,children:n.children.map(e=>(0,Q.jsx)(ot,{node:e,level:r+1,renderNode:i,defaultOpen:a,indent:o,childContainerClassName:s,openState:c,onToggle:l,forceOpenIds:u},e.id))}),t[14]=s,t[15]=a,t[16]=u,t[17]=d,t[18]=o,t[19]=f,t[20]=r,t[21]=n.children,t[22]=l,t[23]=c,t[24]=i,t[25]=h):h=t[25];let g;return t[26]!==p||t[27]!==m||t[28]!==h?(g=(0,Q.jsxs)(`div`,{className:p,children:[m,h]}),t[26]=p,t[27]=m,t[28]=h,t[29]=g):g=t[29],g}function st(e){let t=(0,X.c)(27),{nodes:n,renderNode:r,resetKey:i,defaultOpen:a,forceOpenIds:o,indent:s,childContainerClassName:c,className:l}=e,u=a===void 0?!1:a,d=s===void 0?16:s,f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f={},t[0]=f):f=t[0];let[p,m]=(0,Z.useState)(f),[h,_]=(0,Z.useState)(i);i!==h&&(_(i),m({}));let v;t[1]===o?v=t[2]:(v=o?new Set(o):void 0,t[1]=o,t[2]=v);let y=v,b;t[3]===u?b=t[4]:(b=e=>{m(t=>({...t,[e]:!(t[e]??u)}))},t[3]=u,t[4]=b);let x=b,S;t[5]===l?S=t[6]:(S=g(`min-w-0`,l),t[5]=l,t[6]=S);let C;if(t[7]!==c||t[8]!==u||t[9]!==y||t[10]!==x||t[11]!==d||t[12]!==n||t[13]!==p||t[14]!==r){let e;t[16]!==c||t[17]!==u||t[18]!==y||t[19]!==x||t[20]!==d||t[21]!==p||t[22]!==r?(e=e=>(0,Q.jsx)(ot,{node:e,level:0,renderNode:r,defaultOpen:u,indent:d,childContainerClassName:c,openState:p,onToggle:x,forceOpenIds:y},e.id),t[16]=c,t[17]=u,t[18]=y,t[19]=x,t[20]=d,t[21]=p,t[22]=r,t[23]=e):e=t[23],C=n.map(e),t[7]=c,t[8]=u,t[9]=y,t[10]=x,t[11]=d,t[12]=n,t[13]=p,t[14]=r,t[15]=C}else C=t[15];let w;return t[24]!==S||t[25]!==C?(w=(0,Q.jsx)(`div`,{className:S,children:C}),t[24]=S,t[25]=C,t[26]=w):w=t[26],w}var ct=(0,Z.createContext)({todos:[],setTodos:()=>{}});function lt(e){let t=(0,X.c)(10),{children:n,threadId:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=[],t[0]=i):i=t[0];let[a,o]=(0,Z.useState)(i),s=(0,Z.useRef)(-1),c;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(c=(e,t)=>{t>=s.current&&(s.current=t,o(e))},t[1]=c):c=t[1];let l=c,u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>{s.current=-1,o([])},t[2]=u):u=t[2];let d;t[3]===r?d=t[4]:(d=[r],t[3]=r,t[4]=d),(0,Z.useEffect)(u,d);let f;t[5]===a?f=t[6]:(f={todos:a,setTodos:l},t[5]=a,t[6]=f);let p;return t[7]!==n||t[8]!==f?(p=(0,Q.jsx)(ct.Provider,{value:f,children:n}),t[7]=n,t[8]=f,t[9]=p):p=t[9],p}function ut(e){let t=[e.result,e.content],n=[];for(let e of t)if(typeof e==`string`)n.push(e);else if(Array.isArray(e))for(let t of e)typeof t==`object`&&t&&`text`in t&&typeof t.text==`string`&&n.push(t.text);for(let e of n){let t=e.trim();if(t.startsWith(`{`))try{let e=JSON.parse(t);if(e&&Array.isArray(e.todos))return e.todos}catch(e){console.error(`Failed to parse todo JSON:`,e)}}return null}function dt(e){let t=(0,X.c)(5),{todos:n,sequence:r}=e,{setTodos:i}=(0,Z.useContext)(ct),a,o;return t[0]!==r||t[1]!==i||t[2]!==n?(a=()=>{i(n,r)},o=[n,i,r],t[0]=r,t[1]=i,t[2]=n,t[3]=a,t[4]=o):(a=t[3],o=t[4]),(0,Z.useEffect)(a,o),null}var ft=new Map,pt=new Map;function mt(e){return ft.get(e)}function ht(e,t){let n=pt.get(e);return n||(n=new Set,pt.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&pt.delete(e)}}function gt(e){let t=pt.get(e);if(t)for(let e of t)e()}function _t(e,t){return async function(n,r){let i=await fetch(e+`/api/browser-js/execute-tool`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({threadId:t,toolName:n,params:r})});if(!i.ok){let e=await i.text();try{let t=JSON.parse(e).error||{};e=t.details||t.message||e}catch{}return{text:null,error:`Tool `+n+` failed: `+e}}let a=await i.json();return{text:a.content&&a.content[0]?a.content[0].text:null,error:null}}}function vt(e,t,n){if(ft.has(e))return;ft.set(e,{status:`running`}),gt(e);let r=S();(async()=>{try{let i=_t(r,n),a=Object.getPrototypeOf(async function(){}).constructor,o=await new a(`callTool`,t)(i),s=o===void 0?null:o;ft.set(e,{status:`success`,result:s}),gt(e),await U(e,s)}catch(t){let n=t instanceof Error?t.stack||t.message:String(t);ft.set(e,{status:`error`,error:n}),gt(e);try{await U(e,{error:n})}catch(e){console.error(`[browser-js-executor] failed to submit error result`,e)}}})()}function yt({initialValue:e}={}){let{state:n,dispatch:r}=Re(),[i,a]=(0,Z.useState)(e??``),[s,c]=(0,Z.useState)(-1),[l,u]=(0,Z.useState)(``),[d,f]=(0,Z.useState)(0),[p,m]=(0,Z.useState)([]),[h,g]=(0,Z.useState)(()=>(n.selectedThreadId?n.projectModelSelections[n.selectedThreadId]:void 0)??null),_=(0,Z.useRef)(h?.id??``),v=(0,Z.useRef)(h?.provider??``),y=(0,Z.useRef)(null),[b,x]=(0,Z.useState)(!1),[S,w]=(0,Z.useState)(!1),[T,E]=(0,Z.useState)([]),[D,O]=(0,Z.useState)(!1),[k,A]=(0,Z.useState)(!1),[j,M]=(0,Z.useState)(!1),[N,P]=(0,Z.useState)([]),[F,I]=(0,Z.useState)(null),[L,R]=(0,Z.useState)([]),[ee,te]=(0,Z.useState)(!1),[ne,re]=(0,Z.useState)(``),[z,B]=(0,Z.useState)(0),[H,U]=(0,Z.useState)([]),[W,G]=(0,Z.useState)([]),[K,q]=(0,Z.useState)(!1),[J,ie]=(0,Z.useState)(``),ae=(0,Z.useRef)(null),oe=(0,Z.useRef)(null),se=(0,Z.useRef)(null),ce=(0,Z.useRef)(null),ue=(0,Z.useRef)(null),de=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{_.current=h?.id??``,v.current=h?.provider??``},[h?.id,h?.provider]);let fe=(0,Z.useCallback)((e,t)=>{g(e);let i=n.selectedThreadId;if(!i||(r({type:Y.SetProjectModel,threadId:i,model:e}),t?.persist===!1))return;let a=`${i}:${e.provider??``}:${e.id}`;y.current!==a&&(y.current=a,console.log(`[useChatInputState] Persisting model to thread:`,{threadId:i,model:{id:e.id,provider:e.provider}}),o(i,{model:e.id,modelProvider:e.provider}).then(()=>{y.current===a&&(y.current=null),console.log(`[useChatInputState] Model persisted successfully`)}).catch(e=>{y.current===a&&(y.current=null),console.error(`Failed to save model to thread:`,e)}))},[n.selectedThreadId,r]);(0,Z.useEffect)(()=>{(async()=>{let e=n.selectedProjectId?n.projects.find(e=>e.projectId===n.selectedProjectId)?.threads.find(e=>e.threadId===n.selectedThreadId):void 0,t=n.selectedThreadId?n.projectModelSelections[n.selectedThreadId]:void 0,r=e?.model??t?.id??null,i=e?.modelProvider??t?.provider??null;console.log(`[useChatInputState] Loading models for thread:`,{threadId:n.selectedThreadId,projectId:n.selectedProjectId,currentThread:e?{model:e.model,modelProvider:e.modelProvider}:void 0,storedModel:t?{id:t.id,provider:t.provider}:void 0,savedModelId:r,savedModelProvider:i});try{let e=await V(),t=Object.values(e).flat();if(t.length===0){m([]),g(null);return}m(t);let n=r&&i?t.find(e=>e.id===r&&e.provider===i)??null:null,a=t[0],o=n??a,s=!n&&!!(r||i),c=_.current===o.id&&v.current===o.provider;console.log(`[useChatInputState] Model selection decision:`,{matchedSavedModel:n?{id:n.id}:null,fallbackModel:{id:a.id},modelToSelect:{id:o.id},shouldPersistFallback:s,hasSameSelection:c,currentSelected:{id:_.current,provider:v.current}}),c||fe(o,{persist:s})}catch(e){console.error(`Failed to load enabled models:`,e)}})()},[n.selectedThreadId,n.selectedProjectId,n.projects,fe]);let pe=(0,Z.useRef)(fe);(0,Z.useEffect)(()=>{pe.current=fe},[fe]),(0,Z.useEffect)(()=>{n.configUpdatedAt!==0&&(async()=>{try{let e=await V(),t=Object.values(e).flat();if(t.length>0){m(t);let e=_.current,n=v.current;t.some(t=>t.id===e&&t.provider===n)||pe.current(t[0],{persist:!0})}}catch(e){console.error(`Failed to reload enabled models:`,e)}})()},[n.configUpdatedAt]),(0,Z.useEffect)(()=>{!j||N.length>0||(async()=>{try{let e=await t(),n=Object.values(e).flat();n.length>0&&(P(n),I(e=>e??n[0]))}catch(e){console.error(`Failed to load image models:`,e)}})()},[j,N.length]);let[me,he]=(0,Z.useState)(n.selectedThreadId);return(0,Z.useEffect)(()=>{n.selectedThreadId!==me&&setTimeout(()=>{he(n.selectedThreadId),R([]),te(!1),U([]),G([]),q(!1),O(!1),M(!1),A(!1)},0)},[n.selectedThreadId,me]),(0,Z.useEffect)(()=>{n.selectedThreadId&&C(n.selectedThreadId).then(({commands:e,skills:t})=>{console.log(`Loaded slash commands:`,e,`skills:`,t),U(e),G(t)}).catch(e=>console.error(`Failed to load slash commands and skills:`,e))},[n.selectedThreadId]),(0,Z.useEffect)(()=>{n.focusChatInput&&n.selectedThreadId&&!n.isStreaming&&(oe.current?.focus(),r({type:Y.ClearFocusChatInput}))},[n.focusChatInput,n.selectedThreadId,n.isStreaming,r]),(0,Z.useEffect)(()=>{let e=e=>{se.current&&!se.current.contains(e.target)&&x(!1),ce.current&&!ce.current.contains(e.target)&&w(!1)};if(b||S)return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[b,S]),{message:i,setMessage:a,historyIndex:s,setHistoryIndex:c,draftMessage:l,setDraftMessage:u,cursorPosition:d,setCursorPosition:f,availableModels:p,setAvailableModels:m,selectedModel:h,setSelectedModel:fe,selectedModelIdRef:_,showModelMenu:b,setShowModelMenu:x,showPlusMenu:S,setShowPlusMenu:w,attachments:T,setAttachments:E,planMode:D,setPlanMode:O,ralphMode:k,setRalphMode:A,imageMode:j,setImageMode:M,availableImageModels:N,setAvailableImageModels:P,selectedImageModel:F,setSelectedImageModel:I,allFiles:L,setAllFiles:R,showSuggestions:ee,setShowSuggestions:te,suggestionQuery:ne,setSuggestionQuery:re,selectedIndex:z,setSelectedIndex:B,slashCommands:H,setSlashCommands:U,skills:W,setSkills:G,showCommandSuggestions:K,setShowCommandSuggestions:q,commandQuery:J,setCommandQuery:ie,fileInputRef:ae,textareaRef:oe,modelMenuRef:se,plusMenuRef:ce,suggestionsRef:ue,commandSuggestionsRef:de,handleNewChat:async()=>{if(n.selectedThreadId)try{let e=await ge(n.selectedThreadId);r({type:Y.ClearMessages}),console.log(`New conversation started:`,e);let t=await le(n.selectedThreadId);r({type:Y.SetMessages,messages:t.messages})}catch(e){console.error(`Failed to start new chat:`,e)}},state:n,dispatch:r}}var bt=e=>{te(e)};function xt(e){let t=(0,X.c)(102),{message:n,setMessage:r,attachments:i,selectedModel:a,onSend:o,isStreaming:s,selectedThreadId:c,isListening:l,stopListening:u,resetTranscript:d,dispatch:f,historyIndex:p,setHistoryIndex:m,draftMessage:h,setDraftMessage:g,cursorPosition:_,setCursorPosition:v,showSuggestions:b,setShowSuggestions:x,suggestionQuery:S,setSuggestionQuery:C,allFiles:w,setAllFiles:T,selectedIndex:E,setSelectedIndex:D,showCommandSuggestions:O,setShowCommandSuggestions:k,commandQuery:A,setCommandQuery:j,slashCommands:M,skills:N,textareaRef:P,setAttachments:F,planMode:I,setPlanMode:L,ralphMode:R,setRalphMode:ee,imageMode:te,setImageMode:ne,selectedImageModel:re}=e,z;t[0]!==i||t[1]!==f||t[2]!==te||t[3]!==l||t[4]!==s||t[5]!==n||t[6]!==o||t[7]!==I||t[8]!==R||t[9]!==d||t[10]!==re||t[11]!==a||t[12]!==c||t[13]!==F||t[14]!==g||t[15]!==m||t[16]!==r||t[17]!==u||t[18]!==P?(z=()=>{if(!n.trim()&&i.length===0||!c)return;let e=te?re:a;e&&(l&&(u(),d()),s?f({type:Y.EnqueueChatMessage,message:{id:`queued-${Date.now()}`,threadId:c,message:n,model:e.id,attachments:i,provider:e.provider,planMode:I,imageMode:te,ralphMode:R}}):o(n,e.id,i,e.provider,I,te,R),bt(n),r(``),F([]),m(-1),g(``),P.current&&(P.current.style.height=`auto`))},t[0]=i,t[1]=f,t[2]=te,t[3]=l,t[4]=s,t[5]=n,t[6]=o,t[7]=I,t[8]=R,t[9]=d,t[10]=re,t[11]=a,t[12]=c,t[13]=F,t[14]=g,t[15]=m,t[16]=r,t[17]=u,t[18]=P,t[19]=z):z=t[19];let B=z,V;t[20]!==_||t[21]!==n||t[22]!==r||t[23]!==x||t[24]!==S||t[25]!==P?(V=e=>{let t=n.substring(0,_-S.length-1);r(`${t}${e} ${n.substring(_)}`),x(!1),setTimeout(()=>{if(P.current){P.current.focus();let n=t.length+e.length+1;P.current.setSelectionRange(n,n)}},0)},t[20]=_,t[21]=n,t[22]=r,t[23]=x,t[24]=S,t[25]=P,t[26]=V):V=t[26];let H=V,U;t[27]!==A||t[28]!==_||t[29]!==n||t[30]!==ne||t[31]!==r||t[32]!==L||t[33]!==ee||t[34]!==k||t[35]!==P?(U=e=>{let t=n.substring(0,_-A.length-1),i=n.substring(_);r(`${t}${e.content}${i}`),k(!1),setTimeout(()=>{if(P.current){P.current.focus();let n=t.length+e.content.length;P.current.setSelectionRange(n,n)}},0),e.metadata.mode===`plan`?(L(!0),ee(!1),ne(!1)):e.metadata.mode===`ralph`&&(ee(!0),L(!1),ne(!1))},t[27]=A,t[28]=_,t[29]=n,t[30]=ne,t[31]=r,t[32]=L,t[33]=ee,t[34]=k,t[35]=P,t[36]=U):U=t[36];let W=U,G;t[37]!==A||t[38]!==_||t[39]!==n||t[40]!==r||t[41]!==k||t[42]!==P?(G=e=>{let t=n.substring(0,_-A.length-1),i=n.substring(_),a=e.name.includes(` `)?`/"${e.name}"`:`/${e.name}`;r(`${t}${a}${i}`),k(!1),setTimeout(()=>{if(P.current){P.current.focus();let e=t.length+a.length;P.current.setSelectionRange(e,e)}},0)},t[37]=A,t[38]=_,t[39]=n,t[40]=r,t[41]=k,t[42]=P,t[43]=G):G=t[43];let K=G,q,J,ie,ae;if(t[44]!==w||t[45]!==A||t[46]!==h||t[47]!==B||t[48]!==p||t[49]!==W||t[50]!==H||t[51]!==K||t[52]!==n||t[53]!==E||t[54]!==c||t[55]!==T||t[56]!==j||t[57]!==v||t[58]!==g||t[59]!==m||t[60]!==r||t[61]!==D||t[62]!==k||t[63]!==x||t[64]!==C||t[65]!==O||t[66]!==b||t[67]!==N||t[68]!==M||t[69]!==S){ie=e=>{if(O){if(e.key===`ArrowDown`){e.preventDefault(),D((E+1)%q.length);return}if(e.key===`ArrowUp`){e.preventDefault(),D((E-1+q.length)%q.length);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault();let t=q[E];t&&(t.type===`command`?W(t.data):K(t.data));return}if(e.key===`Escape`){k(!1);return}}if(b){let t=J.length>0;if(e.key===`ArrowDown`&&t){e.preventDefault(),D((E+1)%J.length);return}if(e.key===`ArrowUp`&&t){e.preventDefault(),D((E-1+J.length)%J.length);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault(),J[E]&&H(J[E]);return}if(e.key===`Escape`){x(!1);return}}if(e.key===`Enter`&&!e.shiftKey){e.preventDefault(),B();return}let t=oe();t.length!==0&&(e.key===`ArrowUp`?(e.preventDefault(),p===-1?(g(n),m(t.length-1),r(t[t.length-1])):p>0&&(m(p-1),r(t[p-1]))):e.key===`ArrowDown`&&(e.preventDefault(),p>0?(m(p-1),r(t[p-1])):p===0&&(m(-1),r(h))))};let e;t[74]!==w||t[75]!==c||t[76]!==T||t[77]!==j||t[78]!==v||t[79]!==r||t[80]!==D||t[81]!==k||t[82]!==x||t[83]!==C?(e=e=>{let t=e.target.value,n=e.target.selectionStart;r(t),v(n);let i=t.substring(0,n),a=i.lastIndexOf(`/`);if(a!==-1){let e=a>0?i[a-1]:``;if(a===0||/\s/.test(e)){let e=i.substring(a+1);e.includes(` `)?k(!1):(j(e),k(!0),x(!1),D(0))}else k(!1)}else{k(!1);let e=i.lastIndexOf(`#`);if(e!==-1){let t=e>0?i[e-1]:``;if(e===0||/\s/.test(t)){let t=i.substring(e+1);t.includes(` `)?x(!1):(C(t),x(!0),D(0),w.length===0&&c&&y(c).then(e=>{T(e)}).catch(wt))}else x(!1)}else x(!1)}let o=e.target;o.style.height=`auto`,o.style.height=`${Math.min(o.scrollHeight,160)}px`},t[74]=w,t[75]=c,t[76]=T,t[77]=j,t[78]=v,t[79]=r,t[80]=D,t[81]=k,t[82]=x,t[83]=C,t[84]=e):e=t[84],ae=e;let i;if(t[85]!==A||t[86]!==N||t[87]!==M){let e;t[89]===A?e=t[90]:(e=e=>e.name.toLowerCase().includes(A.toLowerCase()),t[89]=A,t[90]=e);let n=M.filter(e),r;t[91]===A?r=t[92]:(r=e=>e.name.toLowerCase().includes(A.toLowerCase()),t[91]=A,t[92]=r);let a=N.filter(r);i=[...n.map(Ct),...a.map(St)],t[85]=A,t[86]=N,t[87]=M,t[88]=i}else i=t[88];q=i.slice(0,10),J=b?w.filter(e=>e.toLowerCase().includes(S.toLowerCase())).slice(0,10):[],t[44]=w,t[45]=A,t[46]=h,t[47]=B,t[48]=p,t[49]=W,t[50]=H,t[51]=K,t[52]=n,t[53]=E,t[54]=c,t[55]=T,t[56]=j,t[57]=v,t[58]=g,t[59]=m,t[60]=r,t[61]=D,t[62]=k,t[63]=x,t[64]=C,t[65]=O,t[66]=b,t[67]=N,t[68]=M,t[69]=S,t[70]=q,t[71]=J,t[72]=ie,t[73]=ae}else q=t[70],J=t[71],ie=t[72],ae=t[73];let se;return t[93]!==q||t[94]!==J||t[95]!==ie||t[96]!==B||t[97]!==ae||t[98]!==W||t[99]!==H||t[100]!==K?(se={handleSend:B,handleKeyDown:ie,handleTextareaInput:ae,insertFileReference:H,insertCommand:W,insertSkill:K,allSuggestions:q,fileSuggestions:J},t[93]=q,t[94]=J,t[95]=ie,t[96]=B,t[97]=ae,t[98]=W,t[99]=H,t[100]=K,t[101]=se):se=t[101],se}function St(e){return{type:`skill`,data:e}}function Ct(e){return{type:`command`,data:e}}function wt(e){return console.error(`Failed to fetch files:`,e)}function Tt(e){let t=(0,X.c)(21),{visible:n,commands:r,skills:i,query:a,selectedIndex:o,onSelectCommand:s,onSelectSkill:c,onMouseEnterSuggestion:l,containerRef:u}=e;if(!n)return null;let d;if(t[0]!==r||t[1]!==a||t[2]!==i){let e;t[4]===a?e=t[5]:(e=e=>e.name.toLowerCase().includes(a.toLowerCase()),t[4]=a,t[5]=e);let n=r.filter(e),o;t[6]===a?o=t[7]:(o=e=>e.name.toLowerCase().includes(a.toLowerCase()),t[6]=a,t[7]=o);let s=i.filter(o);d=[...n.map(Dt),...s.map(Et)].slice(0,10),t[0]=r,t[1]=a,t[2]=i,t[3]=d}else d=t[3];let f=d,p;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Q.jsx)(j,{className:`h-3 w-3`}),t[8]=p):p=t[8];let m=a&&` matching "${a}"`,h;t[9]===m?h=t[10]:(h=(0,Q.jsxs)(`div`,{className:`px-2 py-1.5 text-xs font-semibold text-muted-foreground border-b border-border/50 mb-1 flex items-center gap-2`,children:[p,`Commands & Skills`,m]}),t[9]=m,t[10]=h);let _;t[11]!==f||t[12]!==l||t[13]!==s||t[14]!==c||t[15]!==o?(_=f.length>0?f.map((e,t)=>{let n=t===o;if(e.type===`command`){let r=e.data;return(0,Q.jsxs)(`button`,{type:`button`,className:g(`flex w-full flex-col gap-1 rounded-lg px-3 py-2 text-left transition-colors`,n?`bg-accent text-accent-foreground`:`text-popover-foreground hover:bg-accent/50`),onClick:()=>s(r),onMouseEnter:()=>l(t),children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(j,{className:`h-3 w-3 text-muted-foreground`}),(0,Q.jsxs)(`span`,{className:`font-medium`,children:[`/`,r.name]}),r.metadata.argumentHint&&(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r.metadata.argumentHint}),r.scope===`project`&&(0,Q.jsx)(`span`,{className:`ml-auto text-[10px] rounded-full bg-primary/10 px-1.5 py-0.5 text-primary`,children:`project`})]}),r.metadata.description&&(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r.metadata.description})]},`cmd-${r.name}`)}else{let r=e.data;return(0,Q.jsxs)(`button`,{type:`button`,className:g(`flex w-full flex-col gap-1 rounded-lg px-3 py-2 text-left transition-colors`,n?`bg-accent text-accent-foreground`:`text-popover-foreground hover:bg-accent/50`),onClick:()=>c(r),onMouseEnter:()=>l(t),children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(v,{className:`h-3 w-3 text-amber-500`}),(0,Q.jsxs)(`span`,{className:`font-medium`,children:[`/`,r.name]}),(0,Q.jsx)(`span`,{className:`ml-auto text-[10px] rounded-full bg-amber-500/10 px-1.5 py-0.5 text-amber-700 dark:text-amber-400`,children:`skill`}),r.scope===`project`&&(0,Q.jsx)(`span`,{className:`text-[10px] rounded-full bg-primary/10 px-1.5 py-0.5 text-primary`,children:`project`})]}),(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r.description})]},`skill-${r.name}`)}}):(0,Q.jsxs)(`div`,{className:`px-3 py-4 text-center text-xs text-muted-foreground`,children:[`No commands or skills found.`,(0,Q.jsx)(`br`,{}),(0,Q.jsxs)(`span`,{className:`text-[10px]`,children:[`Create commands in `,(0,Q.jsx)(`code`,{className:`bg-muted px-1 rounded`,children:`.agents/commands/`}),` or skills in `,(0,Q.jsx)(`code`,{className:`bg-muted px-1 rounded`,children:`.agents/skills/`})]})]}),t[11]=f,t[12]=l,t[13]=s,t[14]=c,t[15]=o,t[16]=_):_=t[16];let y;return t[17]!==u||t[18]!==h||t[19]!==_?(y=(0,Q.jsxs)(`div`,{ref:u,className:`absolute bottom-full left-0 mb-2 w-full max-h-64 overflow-y-auto rounded-xl border border-border bg-popover p-1 shadow-lg z-50 animate-in fade-in slide-in-from-bottom-2`,children:[h,_]}),t[17]=u,t[18]=h,t[19]=_,t[20]=y):y=t[20],y}function Et(e){return{type:`skill`,data:e}}function Dt(e){return{type:`command`,data:e}}function Ot(e){return e.startsWith(`image/`)}function kt(e){let t=(0,X.c)(7),{attachments:n,onRemove:r}=e;if(n.length===0)return null;let i;if(t[0]!==n||t[1]!==r){let e;t[3]===r?e=t[4]:(e=(e,t)=>(0,Q.jsx)(`div`,{className:`group relative flex items-center gap-1 rounded-md bg-muted text-xs text-muted-foreground`,children:Ot(e.mimeType)?(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.content}`,alt:e.fileName,className:`h-16 w-16 rounded-md object-cover`}),(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>r(t),className:`absolute -right-1.5 -top-1.5 flex h-4 w-4 items-center justify-center rounded-full bg-foreground text-background opacity-0 transition-opacity group-hover:opacity-100`,children:[(0,Q.jsx)(b,{className:`h-2.5 w-2.5`}),(0,Q.jsx)(`span`,{className:`sr-only`,children:`Remove attachment`})]})]}):(0,Q.jsxs)(`span`,{className:`flex items-center gap-1 px-2 py-1`,children:[(0,Q.jsx)(ie,{className:`h-3 w-3`}),e.fileName,(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>r(t),className:`ml-1 hover:text-foreground`,children:[(0,Q.jsx)(b,{className:`h-3 w-3`}),(0,Q.jsx)(`span`,{className:`sr-only`,children:`Remove attachment`})]})]})},t),t[3]=r,t[4]=e),i=n.map(e),t[0]=n,t[1]=r,t[2]=i}else i=t[2];let a;return t[5]===i?a=t[6]:(a=(0,Q.jsx)(`div`,{className:`mb-2 flex flex-wrap gap-1.5`,children:i}),t[5]=i,t[6]=a),a}function At(e,t){let n=e.target.files;if(!n||n.length===0)return;let r=Array.from(n),i=r.length,a=Array.from({length:i}),o=0;e.target.value=``,r.forEach((e,n)=>{let r=new FileReader;r.onload=()=>{let s=r.result.split(`,`)[1];a[n]={fileName:e.name,content:s,mimeType:e.type||`application/octet-stream`},o+=1,o===i&&t(a)},r.readAsDataURL(e)})}function jt(e){let t=(0,X.c)(16),{showSuggestions:n,fileSuggestions:r,suggestionQuery:i,selectedIndex:a,onSelectFile:o,onMouseEnterSuggestion:s,containerRef:c}=e;if(!n||r.length===0)return null;let l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Q.jsx)(B,{className:`h-3 w-3`}),t[0]=l):l=t[0];let u;t[1]===i?u=t[2]:(u=(0,Q.jsxs)(`div`,{className:`px-2 py-1.5 text-xs font-semibold text-muted-foreground border-b border-border/50 mb-1 flex items-center gap-2`,children:[l,`Files matching "`,i,`"`]}),t[1]=i,t[2]=u);let d;if(t[3]!==r||t[4]!==s||t[5]!==o||t[6]!==a){let e;t[8]!==s||t[9]!==o||t[10]!==a?(e=(e,t)=>{let n=e.split(`/`).pop()??e;return(0,Q.jsxs)(`button`,{type:`button`,className:g(`flex w-full items-center gap-2 rounded-lg px-3 py-2 text-sm text-left transition-colors`,t===a?`bg-accent text-accent-foreground`:`text-popover-foreground hover:bg-accent/50`),onClick:()=>o(e),onMouseEnter:()=>s(t),children:[e.endsWith(`.ts`)||e.endsWith(`.tsx`)||e.endsWith(`.js`)||e.endsWith(`.jsx`)?(0,Q.jsx)(p,{className:`h-4 w-4 text-blue-500`}):(0,Q.jsx)(M,{className:`h-4 w-4 text-muted-foreground`}),(0,Q.jsxs)(`div`,{className:`flex flex-col overflow-hidden`,children:[(0,Q.jsx)(`span`,{className:`truncate font-medium`,children:n}),(0,Q.jsx)(`span`,{className:`truncate text-[10px] text-muted-foreground opacity-70`,children:e})]})]},e)},t[8]=s,t[9]=o,t[10]=a,t[11]=e):e=t[11],d=r.map(e),t[3]=r,t[4]=s,t[5]=o,t[6]=a,t[7]=d}else d=t[7];let f;return t[12]!==c||t[13]!==u||t[14]!==d?(f=(0,Q.jsxs)(`div`,{ref:c,className:`absolute bottom-full left-0 mb-2 w-full max-h-64 overflow-y-auto rounded-xl border border-border bg-popover p-1 shadow-lg z-50 animate-in fade-in slide-in-from-bottom-2`,children:[u,d]}),t[12]=c,t[13]=u,t[14]=d,t[15]=f):f=t[15],f}function Mt(e){let t=(0,X.c)(3),{provider:n}=e;if(!n)return null;let r=`https://models.tarsk.io/svg/${n}.svg`,i=`${n} logo`,a;return t[0]!==r||t[1]!==i?(a=(0,Q.jsx)(`img`,{src:r,alt:i,className:`h-3.5 w-3.5 flex-shrink-0 dark:invert`,onError:Nt}),t[0]=r,t[1]=i,t[2]=a):a=t[2],a}function Nt(e){e.currentTarget.style.visibility=`hidden`}function Pt(e){let t=(0,X.c)(26),{availableModels:n,selectedModel:r,onModelSelect:i}=e,[a,o]=Z.useState(!1),s=Z.useRef(null),c,l;t[0]===a?(c=t[1],l=t[2]):(c=()=>{let e=e=>{s.current&&!s.current.contains(e.target)&&o(!1)};if(a)return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},l=[a],t[0]=a,t[1]=c,t[2]=l),Z.useEffect(c,l);let u;t[3]===i?u=t[4]:(u=e=>{i(e),o(!1)},t[3]=i,t[4]=u);let d=u,f;t[5]===a?f=t[6]:(f=()=>o(!a),t[5]=a,t[6]=f);let p=r?.provider,m;t[7]===p?m=t[8]:(m=(0,Q.jsx)(Mt,{provider:p}),t[7]=p,t[8]=m);let h;t[9]===r?h=t[10]:(h=r?et(r.id):`No model`,t[9]=r,t[10]=h);let g;t[11]===h?g=t[12]:(g=(0,Q.jsx)(`span`,{className:`text-xs font-medium`,children:h}),t[11]=h,t[12]=g);let _;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,Q.jsx)(W,{className:`h-3 w-3`}),t[13]=_):_=t[13];let v;t[14]!==f||t[15]!==m||t[16]!==g?(v=(0,Q.jsxs)(O,{variant:`action`,size:`icon-sm`,className:`gap-1 w-auto px-2`,onClick:f,children:[m,g,_]}),t[14]=f,t[15]=m,t[16]=g,t[17]=v):v=t[17];let y;t[18]!==n||t[19]!==d||t[20]!==r?.id||t[21]!==a?(y=a&&(0,Q.jsx)(`div`,{className:`absolute bottom-full left-0 mb-1 w-80 max-h-80 overflow-y-auto rounded-lg border border-border bg-popover p-1 shadow-md z-50`,children:Object.entries(n.reduce(Ft,{})).map(e=>{let[t,n]=e;return(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 px-3 py-1.5 text-xs font-semibold text-muted-foreground uppercase tracking-wide`,children:[(0,Q.jsx)(Mt,{provider:t}),t]}),n.map(e=>(0,Q.jsx)(`button`,{type:`button`,className:`flex w-full items-center whitespace-nowrap rounded-md px-3 py-1.5 pl-8 text-sm text-popover-foreground hover:bg-accent ${e.id===r?.id?`bg-accent font-medium`:``}`,onClick:()=>d(e),children:et(e.id)},e.id))]},t)})}),t[18]=n,t[19]=d,t[20]=r?.id,t[21]=a,t[22]=y):y=t[22];let b;return t[23]!==v||t[24]!==y?(b=(0,Q.jsxs)(`div`,{className:`relative`,ref:s,children:[v,y]}),t[23]=v,t[24]=y,t[25]=b):b=t[25],b}function Ft(e,t){let n=t.provider??`Other`;return e[n]||(e[n]=[]),e[n].push(t),e}var It=[{value:`build`,label:`Build`,icon:K},{value:`plan`,label:`Plan`,icon:_e},{value:`image`,label:`Image`,icon:c},{value:`ralph`,label:`Ralph`,icon:G}];function Lt(e,t,n){return n?`ralph`:e?`plan`:t?`image`:`build`}function Rt(e){let t=(0,X.c)(31),{planMode:n,imageMode:r,ralphMode:i,setPlanMode:a,setImageMode:o,setRalphMode:s}=e,[c,l]=Z.useState(!1),u=Z.useRef(null),d;t[0]!==r||t[1]!==n||t[2]!==i?(d=Lt(n,r,i),t[0]=r,t[1]=n,t[2]=i,t[3]=d):d=t[3];let f=d,p;t[4]===f?p=t[5]:(p=It.find(e=>e.value===f),t[4]=f,t[5]=p);let m=p,h=m.icon,g,_;t[6]===c?(g=t[7],_=t[8]):(g=()=>{let e=function(e){u.current&&!u.current.contains(e.target)&&l(!1)};if(c)return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},_=[c],t[6]=c,t[7]=g,t[8]=_),Z.useEffect(g,_);let v;t[9]!==o||t[10]!==a||t[11]!==s?(v=function(e){a(e===`plan`),o(e===`image`),s(e===`ralph`),l(!1)},t[9]=o,t[10]=a,t[11]=s,t[12]=v):v=t[12];let y=v,b;t[13]===c?b=t[14]:(b=()=>l(!c),t[13]=c,t[14]=b);let x;t[15]===h?x=t[16]:(x=(0,Q.jsx)(h,{className:`h-3.5 w-3.5`}),t[15]=h,t[16]=x);let S;t[17]===m.label?S=t[18]:(S=(0,Q.jsx)(`span`,{className:`text-xs font-medium`,children:m.label}),t[17]=m.label,t[18]=S);let C;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,Q.jsx)(W,{className:`h-3 w-3`}),t[19]=C):C=t[19];let w;t[20]!==b||t[21]!==x||t[22]!==S?(w=(0,Q.jsxs)(O,{variant:`action`,size:`icon-sm`,className:`gap-1 w-auto px-2`,onClick:b,children:[x,S,C]}),t[20]=b,t[21]=x,t[22]=S,t[23]=w):w=t[23];let T;t[24]!==f||t[25]!==c||t[26]!==y?(T=c&&(0,Q.jsx)(`div`,{className:`absolute bottom-full right-0 mb-1 w-40 rounded-lg border border-border bg-popover p-1 shadow-md z-50`,children:It.map(e=>{let t=e.icon,n=e.value===f;return(0,Q.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded-md px-3 py-2 text-sm text-popover-foreground hover:bg-accent`,onClick:()=>y(e.value),children:[(0,Q.jsx)(t,{className:`h-3.5 w-3.5`}),e.label,n&&(0,Q.jsx)(ee,{className:`ml-auto h-3.5 w-3.5`})]},e.value)})}),t[24]=f,t[25]=c,t[26]=y,t[27]=T):T=t[27];let E;return t[28]!==w||t[29]!==T?(E=(0,Q.jsxs)(`div`,{className:`relative`,ref:u,children:[w,T]}),t[28]=w,t[29]=T,t[30]=E):E=t[30],E}function zt(e){let t=(0,X.c)(17),{onFileAttach:n}=e,[r,i]=Z.useState(!1),a=Z.useRef(null),o,s;t[0]===r?(o=t[1],s=t[2]):(o=()=>{let e=e=>{a.current&&!a.current.contains(e.target)&&i(!1)};if(r)return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},s=[r],t[0]=r,t[1]=o,t[2]=s),Z.useEffect(o,s);let c;t[3]===n?c=t[4]:(c=function(){n(),i(!1)},t[3]=n,t[4]=c);let l=c,u;t[5]===r?u=t[6]:(u=()=>i(!r),t[5]=r,t[6]=u);let d,f;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Q.jsx)(L,{}),f=(0,Q.jsx)(`span`,{className:`sr-only`,children:`More options`}),t[7]=d,t[8]=f):(d=t[7],f=t[8]);let p;t[9]===u?p=t[10]:(p=(0,Q.jsxs)(O,{variant:`action`,size:`icon-sm`,onClick:u,children:[d,f]}),t[9]=u,t[10]=p);let m;t[11]!==l||t[12]!==r?(m=r&&(0,Q.jsx)(`div`,{className:`absolute bottom-full left-0 mb-1 w-48 rounded-lg border border-border bg-popover p-1 shadow-md z-50`,children:(0,Q.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded-md px-3 py-2 text-sm text-popover-foreground hover:bg-accent`,onClick:l,children:[(0,Q.jsx)(ie,{className:`h-3.5 w-3.5`}),`Attach File`]})}),t[11]=l,t[12]=r,t[13]=m):m=t[13];let h;return t[14]!==p||t[15]!==m?(h=(0,Q.jsxs)(`div`,{className:`relative`,ref:a,children:[p,m]}),t[14]=p,t[15]=m,t[16]=h):h=t[16],h}var $=tt(`useWhisperSpeech`),Bt=`/api/voice-model/download`;function Vt(){let[e,t]=(0,Z.useState)(`idle`),[n,r]=(0,Z.useState)(null),[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(null),[c,l]=(0,Z.useState)(``),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(0),m=(0,Z.useRef)(null),h=(0,Z.useRef)(null),g=(0,Z.useRef)(null),_=(0,Z.useRef)(null),v=(0,Z.useRef)(null),y=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>{let e=!1;async function n(){t(`checking-support`),$.separator(`VOICE SESSION START`),$.info(`Checking WASM support`,{userAgent:navigator.userAgent,platform:navigator.platform});try{let n=new rt;m.current=n;let i=await n.checkWasmSupport();if(e)return;if($.info(`WASM SIMD support check result`,{supported:i}),r(i),!i){$.error(`WASM SIMD not supported — voice input disabled`),t(`error`),d(`WebAssembly SIMD is not supported in this environment.`);return}let o=new nt;h.current=o,$.info(`Checking IndexedDB model cache`,{url:Bt});try{let r=await o.loadModelByUrl(Bt);if(e||($.info(`Cached model found — initializing WASM`,{sizeBytes:r.byteLength,sizeMB:(r.byteLength/1024/1024).toFixed(2)}),a(!0),t(`initializing`),await n.initModel(r),e))return;$.info(`WASM model initialized from cache — ready`),t(`ready`)}catch(n){if(e)return;$.info(`Model not in cache — download required`,{reason:n instanceof Error?n.message:String(n)}),t(`needs-model`)}}catch(n){if(e)return;let r=n instanceof Error?n.message:`Unknown error`;$.error(`Failed to check speech recognition support`,{error:r}),t(`error`),d(`Failed to check speech recognition support: ${r}`)}}return n().catch(e=>{console.error(`Failed to check speech recognition support:`,e)}),()=>{e=!0,g.current&&g.current.getTracks().forEach(e=>e.stop())}},[]);let b=(0,Z.useCallback)(async()=>{if(!(!m.current||!h.current)){t(`downloading-model`),p(0),d(null),$.info(`Model download requested`,{url:Bt});try{let e=await h.current.loadModelByUrl(Bt,e=>{p(e),e%10==0&&$.debug(`Model download progress`,{progress:e})});$.info(`Model download complete — initializing WASM`,{sizeBytes:e.byteLength,sizeMB:(e.byteLength/1024/1024).toFixed(2)}),t(`initializing`),await m.current.initModel(e),$.info(`WASM model initialized after download — ready`),a(!0),t(`ready`)}catch(e){let n=e instanceof Error?e.message:`An unknown error occurred.`;$.error(`Model download or initialization failed`,{error:n}),t(`needs-model`),d(n)}}},[]),x=(0,Z.useCallback)(async()=>{if(!(!m.current||!i)){if(y.current=!1,t(`requesting-mic`),d(null),l(``),$.separator(`RECORDING START`),$.info(`Requesting microphone access`),!navigator.mediaDevices?.getUserMedia){$.error(`navigator.mediaDevices.getUserMedia not available in this environment`),t(`ready`),s(!1),d(`Microphone is not available in this environment.`);return}try{let e=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0}}),n=e.getAudioTracks();$.info(`Microphone access granted`,{trackCount:n.length,tracks:n.map(e=>({label:e.label,readyState:e.readyState,settings:e.getSettings()}))}),g.current=e,s(!0);let r=new AbortController;_.current=r,t(`recording`),$.info(`Recording started`),v.current=it(e,{signal:r.signal,recordingDurationMs:12e4,logLevel:0},{onError:e=>{$.error(`Audio conversion error during recording`,{error:e instanceof Error?e.message:String(e)})}})}catch(e){if(t(`ready`),e instanceof DOMException&&e.name===`NotAllowedError`)$.error(`Microphone access denied (NotAllowedError)`),s(!1),d(`Microphone access was denied. Please allow microphone access to use voice input.`);else if(e instanceof DOMException&&e.name===`NotFoundError`)$.error(`No microphone found (NotFoundError)`),s(!1),d(`No microphone was found. Please connect a microphone to use voice input.`);else{let t=e instanceof Error?e.message:`Unknown error`;$.error(`Microphone error`,{error:t,type:e instanceof DOMException?e.name:typeof e}),d(`Microphone error: ${t}`)}}}},[i]),S=(0,Z.useCallback)(async()=>{if(!v.current){$.info(`stopListening called but no active recording`),g.current&&=(g.current.getTracks().forEach(e=>e.stop()),null),i&&t(`ready`);return}$.info(`Stopping recording — waiting for audio data`),_.current?.abort(),t(`transcribing`);try{let e=await v.current;if(y.current){$.info(`Transcription cancelled by user`),t(`ready`);return}let n=(e.audioData.length/16e3).toFixed(2);$.info(`Audio capture complete — starting transcription`,{sampleCount:e.audioData.length,durationSec:n,sampleRate:16e3}),g.current&&=(g.current.getTracks().forEach(e=>e.stop()),null);let r=Date.now(),i=typeof SharedArrayBuffer<`u`?4:1,a=m.current.createSession().streaming(e.audioData,{language:`en`,threads:i,translate:!1}),o=``,s=0;for await(let e of a){if(y.current)break;s++,o+=e.text.trim()+` `,$.debug(`Transcription segment received`,{index:s,text:e.text,timeStart:e.timeStart,timeEnd:e.timeEnd}),l(o.trim())}$.info(`Transcription complete`,{segmentCount:s,durationMs:Date.now()-r,textLength:o.trim().length,text:o.trim().slice(0,100)}),t(`ready`)}catch(e){if(y.current){t(`ready`);return}let n=e instanceof Error?e.message:`Unknown transcription error`;if($.error(`Transcription failed`,{error:n,errorType:e instanceof Error?e.constructor.name:typeof e,stack:e instanceof Error?e.stack?.split(`
2
- `).slice(0,5).join(` | `):void 0}),m.current&&n.includes(`Aborted`)){$.info(`WASM aborted — reinitializing model for next attempt`),t(`initializing`);try{await m.current.restartModel(),$.info(`WASM reinitialized successfully`)}catch(e){$.error(`WASM reinitialization failed`,{error:e instanceof Error?e.message:String(e)})}}t(`ready`),d(`Transcription failed: ${n}`)}finally{v.current=null,_.current=null}},[i]),C=(0,Z.useCallback)(()=>{l(``),d(null)},[]);return{state:e,isSupported:n===!0,isWasmSupported:n,isModelLoaded:i,isMicrophoneAvailable:o,transcript:c,error:u,downloadProgress:f,startListening:x,stopListening:S,requestModelDownload:b,resetTranscript:C}}var Ht=Z.forwardRef((e,t)=>{let n=(0,X.c)(13),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({className:r,value:a,...i}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o;n[4]===r?o=n[5]:(o=g(`relative h-4 w-full overflow-hidden rounded-full bg-secondary`,r),n[4]=r,n[5]=o);let s=`translateX(-${100-(a||0)}%)`,c;n[6]===s?c=n[7]:(c=(0,Q.jsx)(ke,{className:`h-full w-full flex-1 bg-primary transition-all`,style:{transform:s}}),n[6]=s,n[7]=c);let l;return n[8]!==i||n[9]!==t||n[10]!==o||n[11]!==c?(l=(0,Q.jsx)(Se,{ref:t,className:o,...i,children:c}),n[8]=i,n[9]=t,n[10]=o,n[11]=c,n[12]=l):l=n[12],l});Ht.displayName=Se.displayName;var Ut=75;function Wt(e){let t=(0,X.c)(11),{open:n,onOpenChange:r,onConfirm:i,downloading:a,progress:o,error:s}=e,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Q.jsxs)(_,{children:[(0,Q.jsx)(de,{children:`Download Voice Model`}),(0,Q.jsxs)(N,{children:[`To enable voice-to-text, a voice model needs to be downloaded. This is a one-time download of approximately `,Ut,`MB. The model will be cached locally for future use.`]})]}),t[0]=c):c=t[0];let l;t[1]!==a||t[2]!==s||t[3]!==i||t[4]!==r||t[5]!==o?(l=(0,Q.jsxs)(A,{children:[c,a?(0,Q.jsxs)(`div`,{className:`space-y-3 py-4`,children:[(0,Q.jsx)(Ht,{value:o,className:`w-full`}),(0,Q.jsx)(`p`,{className:`text-center text-sm text-muted-foreground`,children:o<100?`Downloading model... ${o}%`:`Initializing model...`})]}):s?(0,Q.jsxs)(`div`,{className:`space-y-4 py-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-3 rounded-md bg-destructive/10 p-3 text-sm text-destructive`,children:[(0,Q.jsx)(pe,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,Q.jsx)(`p`,{children:s})]}),(0,Q.jsxs)(d,{children:[(0,Q.jsx)(O,{variant:`outline`,onClick:()=>r(!1),children:`Cancel`}),(0,Q.jsx)(O,{onClick:i,children:`Try Again`})]})]}):(0,Q.jsxs)(d,{children:[(0,Q.jsx)(O,{variant:`outline`,onClick:()=>r(!1),children:`Cancel`}),(0,Q.jsx)(O,{onClick:i,children:`Download Model`})]})]}),t[1]=a,t[2]=s,t[3]=i,t[4]=r,t[5]=o,t[6]=l):l=t[6];let u;return t[7]!==r||t[8]!==n||t[9]!==l?(u=(0,Q.jsx)(m,{open:n,onOpenChange:r,children:l}),t[7]=r,t[8]=n,t[9]=l,t[10]=u):u=t[10],u}function Gt(e){let t=(0,X.c)(65),{onTranscript:n}=e,{state:r,isWasmSupported:i,transcript:a,error:o,downloadProgress:s,startListening:c,stopListening:l,requestModelDownload:u,resetTranscript:d}=Vt(),{toast:f}=Ge(),[p,m]=(0,Z.useState)(!1),h=(0,Z.useRef)(``),g=(0,Z.useRef)(null),_=r===`recording`,v=r===`transcribing`,y=_||v,b=r===`needs-model`,x=r===`downloading-model`||r===`initializing`,S=r===`checking-support`||r===`idle`,C,w;t[0]!==p||t[1]!==o||t[2]!==f?(C=()=>{o&&o!==g.current&&!p&&f({title:`Voice Input Error`,description:o,variant:`destructive`}),g.current=o},w=[o,p,f],t[0]=p,t[1]=o,t[2]=f,t[3]=C,t[4]=w):(C=t[3],w=t[4]),(0,Z.useEffect)(C,w);let T,E;t[5]!==n||t[6]!==a?(T=()=>{if(a&&a!==h.current){let e=a.substring(h.current.length);h.current=a,n(e)}},E=[a,n],t[5]=n,t[6]=a,t[7]=T,t[8]=E):(T=t[7],E=t[8]),(0,Z.useEffect)(T,E);let D,A;t[9]===a?(D=t[10],A=t[11]):(D=()=>{a||(h.current=``)},A=[a],t[9]=a,t[10]=D,t[11]=A),(0,Z.useEffect)(D,A);let j;t[12]!==y||t[13]!==b||t[14]!==d||t[15]!==c||t[16]!==r||t[17]!==l?(j=()=>{if(b){m(!0);return}y?l():r===`ready`&&(d(),c())},t[12]=y,t[13]=b,t[14]=d,t[15]=c,t[16]=r,t[17]=l,t[18]=j):j=t[18];let M=j,N;t[19]===u?N=t[20]:(N=()=>{u()},t[19]=u,t[20]=N);let P=N,F,I;if(t[21]!==p||t[22]!==r?(I=()=>{r===`ready`&&p&&m(!1)},F=[r,p],t[21]=p,t[22]=r,t[23]=F,t[24]=I):(F=t[23],I=t[24]),(0,Z.useEffect)(I,F),S)return null;if(i===!1){let e;return t[25]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsxs)(Ue,{children:[(0,Q.jsx)(We,{asChild:!0,children:(0,Q.jsxs)(O,{variant:`ghost`,size:`icon-sm`,disabled:!0,className:`text-muted-foreground`,children:[(0,Q.jsx)(he,{className:`opacity-50`}),(0,Q.jsx)(`span`,{className:`sr-only`,children:`Voice input not supported`})]})}),(0,Q.jsx)(He,{side:`top`,className:`bg-popover text-popover-foreground`,children:`Voice input not supported in this browser`})]}),t[25]=e):e=t[25],e}let L;t[26]!==o||t[27]!==x||t[28]!==_||t[29]!==v||t[30]!==b?(L=()=>o||(x?`Downloading speech model...`:v?`Transcribing...`:_?`Stop listening`:b?`Click to download speech model`:`Start listening`),t[26]=o,t[27]=x,t[28]=_,t[29]=v,t[30]=b,t[31]=L):L=t[31];let R=L,ee;t[32]!==x||t[33]!==_||t[34]!==v?(ee=()=>x||v?(0,Q.jsx)(k,{className:`animate-spin`}):_?(0,Q.jsxs)(`span`,{className:`recording-waveform`,"aria-hidden":!0,children:[(0,Q.jsx)(`span`,{className:`recording-waveform-bar`,style:{animationDelay:`0ms`}}),(0,Q.jsx)(`span`,{className:`recording-waveform-bar`,style:{animationDelay:`150ms`}}),(0,Q.jsx)(`span`,{className:`recording-waveform-bar`,style:{animationDelay:`75ms`}}),(0,Q.jsx)(`span`,{className:`recording-waveform-bar`,style:{animationDelay:`225ms`}})]}):(0,Q.jsx)(he,{}),t[32]=x,t[33]=_,t[34]=v,t[35]=ee):ee=t[35];let te=ee,ne;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,Q.jsx)(`style`,{children:`
3
- .recording-waveform {
4
- display: flex;
5
- align-items: center;
6
- gap: 2px;
7
- height: 16px;
8
- }
9
- .recording-waveform-bar {
10
- display: block;
11
- width: 3px;
12
- height: 4px;
13
- border-radius: 2px;
14
- background: currentColor;
15
- animation: waveform-bounce 0.7s ease-in-out infinite alternate;
16
- }
17
- @keyframes waveform-bounce {
18
- from { height: 3px; }
19
- to { height: 14px; }
20
- }
21
- `}),t[36]=ne):ne=t[36];let re=_?`bg-primary text-primary-foreground hover:bg-primary/90`:v?`text-muted-foreground`:`text-muted-foreground hover:text-background`,z=S||x||v,B;t[37]===te?B=t[38]:(B=te(),t[37]=te,t[38]=B);let V;t[39]===R?V=t[40]:(V=R(),t[39]=R,t[40]=V);let H;t[41]===V?H=t[42]:(H=(0,Q.jsx)(`span`,{className:`sr-only`,children:V}),t[41]=V,t[42]=H);let U;t[43]!==M||t[44]!==re||t[45]!==z||t[46]!==B||t[47]!==H?(U=(0,Q.jsx)(We,{asChild:!0,children:(0,Q.jsxs)(O,{variant:`ghost`,size:`icon-sm`,className:re,onClick:M,disabled:z,children:[B,H]})}),t[43]=M,t[44]=re,t[45]=z,t[46]=B,t[47]=H,t[48]=U):U=t[48];let W;t[49]===R?W=t[50]:(W=R(),t[49]=R,t[50]=W);let G;t[51]===W?G=t[52]:(G=(0,Q.jsx)(He,{side:`top`,className:`bg-popover text-popover-foreground max-w-64`,children:W}),t[51]=W,t[52]=G);let K;t[53]!==U||t[54]!==G?(K=(0,Q.jsxs)(Ue,{children:[U,G]}),t[53]=U,t[54]=G,t[55]=K):K=t[55];let q;t[56]!==p||t[57]!==s||t[58]!==o||t[59]!==P||t[60]!==x?(q=(0,Q.jsx)(Wt,{open:p,onOpenChange:m,onConfirm:P,downloading:x,progress:s,error:o}),t[56]=p,t[57]=s,t[58]=o,t[59]=P,t[60]=x,t[61]=q):q=t[61];let J;return t[62]!==K||t[63]!==q?(J=(0,Q.jsxs)(Q.Fragment,{children:[ne,K,q]}),t[62]=K,t[63]=q,t[64]=J):J=t[64],J}function Kt(e){let t=(0,X.c)(8),{queuedMessages:n,onRemoveQueuedMessage:r}=e;if(n.length===0)return null;let i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Q.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground`,children:`Queued messages`}),t[0]=i):i=t[0];let a;if(t[1]!==r||t[2]!==n){let e;t[4]===r?e=t[5]:(e=e=>(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3 rounded-md border border-border/60 bg-background px-3 py-2 text-sm`,children:[(0,Q.jsx)(`p`,{className:`flex-1 whitespace-pre-wrap text-foreground`,children:e.message}),(0,Q.jsx)(`button`,{type:`button`,className:`rounded-full p-1 text-muted-foreground transition-colors hover:bg-foreground hover:text-background`,onClick:()=>r(e.id),"aria-label":`Remove queued message`,children:(0,Q.jsx)(b,{className:`h-3.5 w-3.5`})})]},e.id),t[4]=r,t[5]=e),a=n.map(e),t[1]=r,t[2]=n,t[3]=a}else a=t[3];let o;return t[6]===a?o=t[7]:(o=(0,Q.jsxs)(`div`,{className:`mb-3 rounded-lg border border-border/60 bg-muted/30 px-4 py-3`,children:[i,(0,Q.jsx)(`div`,{className:`mt-2 flex flex-col gap-2`,children:a})]}),t[6]=a,t[7]=o),o}function qt(e){let t=(0,X.c)(136),{onSend:n,onStop:r,isStreaming:i,disabled:a,initialValue:o,queuedMessages:s,onRemoveQueuedMessage:c,isOverlay:l}=e,u=i===void 0?!1:i,d=l===void 0?!1:l,f;t[0]===o?f=t[1]:(f={initialValue:o},t[0]=o,t[1]=f);let{message:p,setMessage:m,historyIndex:h,setHistoryIndex:g,draftMessage:_,setDraftMessage:v,cursorPosition:y,setCursorPosition:b,availableModels:x,selectedModel:S,setSelectedModel:C,attachments:w,setAttachments:T,planMode:E,setPlanMode:D,ralphMode:k,setRalphMode:A,imageMode:j,setImageMode:M,availableImageModels:N,selectedImageModel:P,setSelectedImageModel:F,allFiles:I,setAllFiles:L,showSuggestions:R,setShowSuggestions:ee,suggestionQuery:te,setSuggestionQuery:ne,selectedIndex:re,setSelectedIndex:z,slashCommands:B,skills:V,showCommandSuggestions:H,setShowCommandSuggestions:U,commandQuery:W,setCommandQuery:G,fileInputRef:K,textareaRef:q,suggestionsRef:J,commandSuggestionsRef:ie,state:ae,dispatch:oe}=yt(f),se=j?P:S,ce=j?N:x,le=ae.selectedThreadId??void 0,de;t[2]!==I||t[3]!==w||t[4]!==W||t[5]!==y||t[6]!==oe||t[7]!==_||t[8]!==h||t[9]!==j||t[10]!==u||t[11]!==p||t[12]!==n||t[13]!==E||t[14]!==k||t[15]!==P||t[16]!==re||t[17]!==S||t[18]!==L||t[19]!==T||t[20]!==G||t[21]!==b||t[22]!==v||t[23]!==g||t[24]!==M||t[25]!==m||t[26]!==D||t[27]!==A||t[28]!==z||t[29]!==U||t[30]!==ee||t[31]!==ne||t[32]!==H||t[33]!==R||t[34]!==V||t[35]!==B||t[36]!==te||t[37]!==le||t[38]!==q?(de={message:p,setMessage:m,attachments:w,selectedModel:S,onSend:n,isStreaming:u,selectedThreadId:le,isListening:!1,stopListening:Zt,resetTranscript:Xt,dispatch:oe,historyIndex:h,setHistoryIndex:g,draftMessage:_,setDraftMessage:v,cursorPosition:y,setCursorPosition:b,showSuggestions:R,setShowSuggestions:ee,suggestionQuery:te,setSuggestionQuery:ne,allFiles:I,setAllFiles:L,selectedIndex:re,setSelectedIndex:z,showCommandSuggestions:H,setShowCommandSuggestions:U,commandQuery:W,setCommandQuery:G,slashCommands:B,skills:V,textareaRef:q,setAttachments:T,planMode:E,setPlanMode:D,ralphMode:k,setRalphMode:A,imageMode:j,setImageMode:M,selectedImageModel:P},t[2]=I,t[3]=w,t[4]=W,t[5]=y,t[6]=oe,t[7]=_,t[8]=h,t[9]=j,t[10]=u,t[11]=p,t[12]=n,t[13]=E,t[14]=k,t[15]=P,t[16]=re,t[17]=S,t[18]=L,t[19]=T,t[20]=G,t[21]=b,t[22]=v,t[23]=g,t[24]=M,t[25]=m,t[26]=D,t[27]=A,t[28]=z,t[29]=U,t[30]=ee,t[31]=ne,t[32]=H,t[33]=R,t[34]=V,t[35]=B,t[36]=te,t[37]=le,t[38]=q,t[39]=de):de=t[39];let{handleSend:pe,handleKeyDown:me,handleTextareaInput:he,insertFileReference:ge,insertCommand:_e,insertSkill:ve,fileSuggestions:ye}=xt(de),be;t[40]===m?be=t[41]:(be=e=>{m(t=>(t.endsWith(` `),t+e))},t[40]=m,t[41]=be);let Se=be,Ce;t[42]===T?Ce=t[43]:(Ce=e=>{let t=e.clipboardData?.items;if(!t)return;let n=Array.from(t).filter(Yt);if(n.length!==0){e.preventDefault();for(let e of n){let t=e.getAsFile();if(!t)continue;let n=new FileReader;n.onload=()=>{let e=n.result.split(`,`)[1];T(n=>[...n,{fileName:t.name||`pasted-image.${t.type.split(`/`)[1]||`png`}`,content:e,mimeType:t.type}])},n.readAsDataURL(t)}}},t[42]=T,t[43]=Ce);let we=Ce,Te=d?`absolute inset-x-0 bottom-0 mx-auto w-full max-w-3xl px-4 pb-4 pointer-events-none`:`relative mx-auto w-full max-w-3xl px-4 pb-4`,Ee=`flex flex-col rounded-2xl border focus-within:ring-2 focus-within:ring-brand pointer-events-auto ${d?`border-border/50 bg-background/80 shadow-lg backdrop-blur-sm`:`border-border bg-background shadow-2xl`}`,De;t[44]!==c||t[45]!==s?(De=(0,Q.jsx)(Kt,{queuedMessages:s,onRemoveQueuedMessage:c}),t[44]=c,t[45]=s,t[46]=De):De=t[46];let Oe=k?`Describe stories for Ralph to implement autonomously...`:E?`Describe what you want Tarsk to plan...`:j?`Describe the image you want to generate...`:`Ask Tarsk anything, # for files, / for commands & skills`,ke;t[47]!==a||t[48]!==me||t[49]!==we||t[50]!==he||t[51]!==p||t[52]!==Oe||t[53]!==q?(ke=(0,Q.jsx)(`textarea`,{ref:q,value:p,onChange:he,onKeyDown:me,onPaste:we,placeholder:Oe,rows:1,className:`w-full resize-none bg-transparent px-6 pt-4 pb-4 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none`,disabled:a}),t[47]=a,t[48]=me,t[49]=we,t[50]=he,t[51]=p,t[52]=Oe,t[53]=q,t[54]=ke):ke=t[54];let Ae;t[55]!==W||t[56]!==ie||t[57]!==_e||t[58]!==ve||t[59]!==re||t[60]!==z||t[61]!==H||t[62]!==V||t[63]!==B?(Ae=(0,Q.jsx)(Tt,{visible:H,commands:B,skills:V,query:W,selectedIndex:re,onSelectCommand:_e,onSelectSkill:ve,onMouseEnterSuggestion:z,containerRef:ie}),t[55]=W,t[56]=ie,t[57]=_e,t[58]=ve,t[59]=re,t[60]=z,t[61]=H,t[62]=V,t[63]=B,t[64]=Ae):Ae=t[64];let je;t[65]!==ye||t[66]!==ge||t[67]!==re||t[68]!==z||t[69]!==R||t[70]!==te||t[71]!==J?(je=(0,Q.jsx)(jt,{showSuggestions:R,fileSuggestions:ye,suggestionQuery:te,selectedIndex:re,onSelectFile:ge,onMouseEnterSuggestion:z,containerRef:J}),t[65]=ye,t[66]=ge,t[67]=re,t[68]=z,t[69]=R,t[70]=te,t[71]=J,t[72]=je):je=t[72];let Me;t[73]!==w||t[74]!==S?.id||t[75]!==S?.name||t[76]!==S?.supportsImages||t[77]!==T?(Me=w.length>0&&(0,Q.jsxs)(`div`,{className:`px-4`,children:[(0,Q.jsx)(kt,{attachments:w,onRemove:e=>T(t=>t.filter((t,n)=>n!==e))}),w.some(Jt)&&S?.supportsImages===!1&&(0,Q.jsxs)(`div`,{className:`mb-2 flex items-center gap-1.5 text-xs text-amber-500`,children:[(0,Q.jsx)(xe,{className:`h-3 w-3 shrink-0`}),(0,Q.jsxs)(`span`,{children:[`Images are not supported by `,S?.name||S?.id]})]})]}),t[73]=w,t[74]=S?.id,t[75]=S?.name,t[76]=S?.supportsImages,t[77]=T,t[78]=Me):Me=t[78];let Ne;t[79]===K?Ne=t[80]:(Ne=(0,Q.jsx)(zt,{onFileAttach:()=>K.current?.click()}),t[79]=K,t[80]=Ne);let Pe;t[81]===Se?Pe=t[82]:(Pe=(0,Q.jsx)(Gt,{onTranscript:Se}),t[81]=Se,t[82]=Pe);let Fe=j?F:C,Ie;t[83]!==ce||t[84]!==se||t[85]!==Fe?(Ie=(0,Q.jsx)(Pt,{availableModels:ce,selectedModel:se,onModelSelect:Fe}),t[83]=ce,t[84]=se,t[85]=Fe,t[86]=Ie):Ie=t[86];let Le;t[87]!==Ne||t[88]!==Pe||t[89]!==Ie?(Le=(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[Ne,Pe,Ie]}),t[87]=Ne,t[88]=Pe,t[89]=Ie,t[90]=Le):Le=t[90];let Re;t[91]!==j||t[92]!==E||t[93]!==k||t[94]!==M||t[95]!==D||t[96]!==A?(Re=(0,Q.jsx)(Rt,{planMode:E,imageMode:j,ralphMode:k,setPlanMode:D,setImageMode:M,setRalphMode:A}),t[91]=j,t[92]=E,t[93]=k,t[94]=M,t[95]=D,t[96]=A,t[97]=Re):Re=t[97];let ze=u?r:pe,Be;t[98]!==w.length||t[99]!==a||t[100]!==se||t[101]!==u||t[102]!==p?(Be=!u&&((a??!1)||!p.trim()&&w.length===0||!se),t[98]=w.length,t[99]=a,t[100]=se,t[101]=u,t[102]=p,t[103]=Be):Be=t[103];let Y;t[104]===u?Y=t[105]:(Y=u?(0,Q.jsx)(fe,{className:`h-3 w-3 fill-current`}):(0,Q.jsx)(ue,{className:`h-3 w-3`}),t[104]=u,t[105]=Y);let Ve=u?`Stop generation`:`Send message`,He;t[106]===Ve?He=t[107]:(He=(0,Q.jsx)(`span`,{className:`sr-only`,children:Ve}),t[106]=Ve,t[107]=He);let Ue;t[108]!==ze||t[109]!==Be||t[110]!==Y||t[111]!==He?(Ue=(0,Q.jsxs)(O,{size:`icon`,className:`h-7 w-7 rounded-full`,onClick:ze,disabled:Be,children:[Y,He]}),t[108]=ze,t[109]=Be,t[110]=Y,t[111]=He,t[112]=Ue):Ue=t[112];let We;t[113]!==Re||t[114]!==Ue?(We=(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[Re,Ue]}),t[113]=Re,t[114]=Ue,t[115]=We):We=t[115];let Ge;t[116]!==Le||t[117]!==We?(Ge=(0,Q.jsxs)(`div`,{className:`flex items-center justify-between px-3 pb-2`,children:[Le,We]}),t[116]=Le,t[117]=We,t[118]=Ge):Ge=t[118];let Ke;t[119]!==De||t[120]!==ke||t[121]!==Ae||t[122]!==je||t[123]!==Me||t[124]!==Ge||t[125]!==Ee?(Ke=(0,Q.jsxs)(`div`,{className:Ee,children:[De,ke,Ae,je,Me,Ge]}),t[119]=De,t[120]=ke,t[121]=Ae,t[122]=je,t[123]=Me,t[124]=Ge,t[125]=Ee,t[126]=Ke):Ke=t[126];let qe;t[127]===T?qe=t[128]:(qe=e=>At(e,e=>T(t=>[...t,...e])),t[127]=T,t[128]=qe);let Je;t[129]!==K||t[130]!==qe?(Je=(0,Q.jsx)(`input`,{ref:K,type:`file`,multiple:!0,className:`hidden`,onChange:qe}),t[129]=K,t[130]=qe,t[131]=Je):Je=t[131];let Ye;return t[132]!==Ke||t[133]!==Je||t[134]!==Te?(Ye=(0,Q.jsxs)(`div`,{className:Te,children:[Ke,Je]}),t[132]=Ke,t[133]=Je,t[134]=Te,t[135]=Ye):Ye=t[135],Ye}function Jt(e){return e.mimeType.startsWith(`image/`)}function Yt(e){return e.type.startsWith(`image/`)}function Xt(){}function Zt(){}var Qt=De,$t=Fe,en=Ee,tn=Z.forwardRef((e,t)=>{let n=(0,X.c)(14),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({className:i,inset:a,children:r,...o}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let s=a&&`pl-8`,c;n[5]!==i||n[6]!==s?(c=g(`flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0`,s,i),n[5]=i,n[6]=s,n[7]=c):c=n[7];let l;n[8]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Q.jsx)(I,{className:`ml-auto`}),n[8]=l):l=n[8];let u;return n[9]!==r||n[10]!==o||n[11]!==t||n[12]!==c?(u=(0,Q.jsxs)(Ne,{ref:t,className:c,...o,children:[r,l]}),n[9]=r,n[10]=o,n[11]=t,n[12]=c,n[13]=u):u=n[13],u});tn.displayName=Ne.displayName;var nn=Z.forwardRef((e,t)=>{let n=(0,X.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=g(`z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,Q.jsx)(Pe,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});nn.displayName=Pe.displayName;var rn=Z.forwardRef((e,t)=>{let n=(0,X.c)(11),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({className:r,sideOffset:a,...i}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o=a===void 0?4:a,s;n[4]===r?s=n[5]:(s=g(`z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,r),n[4]=r,n[5]=s);let c;return n[6]!==i||n[7]!==t||n[8]!==o||n[9]!==s?(c=(0,Q.jsx)(je,{children:(0,Q.jsx)(Ae,{ref:t,sideOffset:o,className:s,...i})}),n[6]=i,n[7]=t,n[8]=o,n[9]=s,n[10]=c):c=n[10],c});rn.displayName=Ae.displayName;var an=Z.forwardRef((e,t)=>{let n=(0,X.c)(11),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({className:r,inset:i,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o=i&&`pl-8`,s;n[4]!==r||n[5]!==o?(s=g(`relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0`,o,r),n[4]=r,n[5]=o,n[6]=s):s=n[6];let c;return n[7]!==a||n[8]!==t||n[9]!==s?(c=(0,Q.jsx)(Ce,{ref:t,className:s,...a}),n[7]=a,n[8]=t,n[9]=s,n[10]=c):c=n[10],c});an.displayName=Ce.displayName;var on=Z.forwardRef((e,t)=>{let n=(0,X.c)(14),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({className:a,children:i,checked:r,...o}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let s;n[5]===a?s=n[6]:(s=g(`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,a),n[5]=a,n[6]=s);let c;n[7]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Q.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,Q.jsx)(Me,{children:(0,Q.jsx)(ee,{className:`h-4 w-4`})})}),n[7]=c):c=n[7];let l;return n[8]!==r||n[9]!==i||n[10]!==o||n[11]!==t||n[12]!==s?(l=(0,Q.jsxs)(Oe,{ref:t,className:s,checked:r,...o,children:[c,i]}),n[8]=r,n[9]=i,n[10]=o,n[11]=t,n[12]=s,n[13]=l):l=n[13],l});on.displayName=Oe.displayName;var sn=Z.forwardRef((e,t)=>{let n=(0,X.c)(12),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({className:i,children:r,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o;n[4]===i?o=n[5]:(o=g(`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,i),n[4]=i,n[5]=o);let s;n[6]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Q.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,Q.jsx)(Me,{children:(0,Q.jsx)(z,{className:`h-2 w-2 fill-current`})})}),n[6]=s):s=n[6];let c;return n[7]!==r||n[8]!==a||n[9]!==t||n[10]!==o?(c=(0,Q.jsxs)(we,{ref:t,className:o,...a,children:[s,r]}),n[7]=r,n[8]=a,n[9]=t,n[10]=o,n[11]=c):c=n[11],c});sn.displayName=we.displayName;var cn=Z.forwardRef((e,t)=>{let n=(0,X.c)(11),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({className:r,inset:i,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o=i&&`pl-8`,s;n[4]!==r||n[5]!==o?(s=g(`px-2 py-1.5 text-sm font-semibold`,o,r),n[4]=r,n[5]=o,n[6]=s):s=n[6];let c;return n[7]!==a||n[8]!==t||n[9]!==s?(c=(0,Q.jsx)(Te,{ref:t,className:s,...a}),n[7]=a,n[8]=t,n[9]=s,n[10]=c):c=n[10],c});cn.displayName=Te.displayName;var ln=Z.forwardRef((e,t)=>{let n=(0,X.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=g(`-mx-1 my-1 h-px bg-muted`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,Q.jsx)(Ie,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});ln.displayName=Ie.displayName;var un=e=>{let t=(0,X.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=g(`ml-auto text-xs tracking-widest opacity-60`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(`span`,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a};un.displayName=`DropdownMenuShortcut`;function dn(e){let t=(0,X.c)(17),{currentBranch:n,availableBranches:r,isLoadingBranches:i,isCheckingOut:a,onLoadBranches:o,onCheckoutBranch:s}=e,c;t[0]===o?c=t[1]:(c=e=>{e&&o()},t[0]=o,t[1]=c);let l;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Q.jsx)(h,{className:`h-3.5 w-3.5 shrink-0`}),t[2]=l):l=t[2];let u=n||`Unknown`,d;t[3]===u?d=t[4]:(d=(0,Q.jsx)($t,{asChild:!0,children:(0,Q.jsxs)(O,{variant:`outline`,size:`sm`,className:`h-7 px-2 text-xs bg-background gap-1.5 border-none text-muted-foreground hover:bg-accent hover:text-accent-foreground`,children:[l,u]})}),t[3]=u,t[4]=d);let f;t[5]!==r||t[6]!==n||t[7]!==a||t[8]!==i||t[9]!==s?(f=i?(0,Q.jsxs)(`div`,{className:`px-2 py-1.5 text-xs text-muted-foreground flex items-center gap-2`,children:[(0,Q.jsx)(k,{className:`h-3 w-3 animate-spin`}),`Loading branches...`]}):r.length===0?(0,Q.jsx)(`div`,{className:`px-2 py-1.5 text-xs text-muted-foreground`,children:`No branches found`}):r.map(e=>(0,Q.jsxs)(an,{disabled:e===n||a,onClick:()=>s(e),children:[(0,Q.jsx)(h,{className:`h-3.5 w-3.5 mr-2 shrink-0`}),(0,Q.jsx)(`span`,{className:e===n?`font-semibold text-foreground`:``,children:e}),e===n&&(0,Q.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:`current`})]},e)),t[5]=r,t[6]=n,t[7]=a,t[8]=i,t[9]=s,t[10]=f):f=t[10];let p;t[11]===f?p=t[12]:(p=(0,Q.jsx)(rn,{align:`start`,children:f}),t[11]=f,t[12]=p);let m;return t[13]!==c||t[14]!==d||t[15]!==p?(m=(0,Q.jsxs)(Qt,{onOpenChange:c,children:[d,p]}),t[13]=c,t[14]=d,t[15]=p,t[16]=m):m=t[16],m}function fn({threadId:e,currentConversationId:t,children:n}){let[i,a]=(0,Z.useState)(null),[o,s]=(0,Z.useState)(null),[c,l]=(0,Z.useState)(null),[u,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)(!1),[g,_]=(0,Z.useState)(!1);if((0,Z.useEffect)(()=>{if(!m||g||!e)return;async function n(){d(!0),p(null);try{let n=(await q(e)).currentConversationId??t,[r,i]=await Promise.allSettled([x(e).catch(e=>{throw console.error(`Thread usage summary failed:`,e),e}),n?R(e,n).catch(e=>{throw console.error(`Conversation usage failed:`,e),e}):Promise.resolve(null)]);if(r.status===`fulfilled`)a(r.value);else throw console.error(`Failed to fetch thread usage summary:`,r.reason),r.reason;if(i?.status===`fulfilled`&&i.value){if(s(i.value),i.value.model?.model){let e=i.value.model.model,t=i.value.model.provider,n=t&&e?`${t}/${e}`:e;console.log(`Fetching model info for:`,n,`(provider:`,t,`model:`,e+`)`),re(n).then(l).catch(e=>{console.warn(`Failed to fetch model info:`,e)})}}else if(i?.status===`rejected`)throw console.error(`Failed to fetch conversation usage:`,i.reason),i.reason;_(!0)}catch(e){console.error(`[TokenUsageTooltip] Failed to load usage data:`,e),p(`Failed to load usage data`)}finally{d(!1)}}n()},[m,g,e,t]),!e||e===``)return console.log(`[TokenUsageTooltip] No valid threadId, returning children only`),(0,Q.jsx)(Q.Fragment,{children:n});let y=e=>e==null||e===0?`0`:e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toString();return e?(0,Q.jsxs)(Ue,{open:m,onOpenChange:e=>{h(e),!e&&g&&_(!1)},children:[(0,Q.jsx)(We,{asChild:!0,children:n}),(0,Q.jsx)(He,{side:`top`,align:`center`,className:`max-w-xs`,children:(0,Q.jsxs)(`div`,{className:`text-xs text-muted-foreground space-y-2`,children:[u&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(J,{className:`h-3 w-3 animate-pulse`}),(0,Q.jsx)(`span`,{children:`Loading usage...`})]}),f&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(J,{className:`h-3 w-3`}),(0,Q.jsx)(`span`,{children:`No usage information for this thread`})]}),!u&&!f&&i&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(J,{className:`h-3 w-3`}),(0,Q.jsxs)(`span`,{className:`font-medium`,children:[y(i.totalTokens),` tokens`]})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(r,{className:`h-3 w-3`}),(0,Q.jsxs)(`span`,{children:[i.conversationCount,` chats`]})]})]}),o&&(0,Q.jsxs)(`div`,{className:`border-t border-border pt-2 space-y-1`,children:[(0,Q.jsx)(`div`,{className:`text-xs font-semibold text-foreground`,children:`Current Chat:`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(v,{className:`h-3 w-3`}),(0,Q.jsxs)(`span`,{children:[((e,t)=>{let n=y(e);return t?`${n} (${Math.round(e/t*100)}%)`:n})(o.footprint?.totalTokens??o.usage.totalTokens,typeof c?.context_length==`number`?c.context_length:void 0),` `,`tokens`]})]}),o.model.model&&(0,Q.jsxs)(`div`,{className:`text-muted-foreground`,children:[o.model.model,c?.context_length&&(0,Q.jsxs)(`span`,{className:`ml-1`,children:[y(typeof c.context_length==`number`?c.context_length:0),` `,`context)`]})]})]}),(0,Q.jsxs)(`div`,{className:`border-t border-border pt-2 flex items-center gap-3 text-[10px] text-muted-foreground`,children:[(0,Q.jsxs)(`span`,{children:[`In: `,y(i.totalInputTokens)]}),(0,Q.jsxs)(`span`,{children:[`Out: `,y(i.totalOutputTokens)]}),(0,Q.jsxs)(`span`,{children:[`Avg: `,y(i.averageTokensPerConversation),`/chat`]})]})]})]})})]}):(0,Q.jsx)(Q.Fragment,{children:n})}function pn(e){let t=(0,X.c)(7),{threadId:n}=e,[i,a]=(0,Z.useState)(),o,s;if(t[0]===n?(o=t[1],s=t[2]):(o=()=>{(async function(){if(n)try{a((await q(n)).currentConversationId)}catch(e){console.error(`Failed to fetch thread data:`,e)}})()},s=[n],t[0]=n,t[1]=o,t[2]=s),(0,Z.useEffect)(o,s),!n||n===``)return null;let c;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Q.jsxs)(O,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground hover:text-background`,children:[(0,Q.jsx)(r,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{className:`sr-only`,children:`View token usage`})]}),t[3]=c):c=t[3];let l;return t[4]!==i||t[5]!==n?(l=(0,Q.jsx)(fn,{threadId:n,currentConversationId:i,children:c}),t[4]=i,t[5]=n,t[6]=l):l=t[6],l}var mn=3e4,hn=new Map;function gn(e,t){let n=hn.get(e);if(n)for(let e of n)e(t)}function _n(e,t){let n=hn.get(e);return n||(n=new Set,hn.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&hn.delete(e)}}function vn(e){let[t,n]=(0,Z.useState)(!1),[r,i]=(0,Z.useState)(0),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(``),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(void 0),[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(`Up to date`),[x,S]=(0,Z.useState)(null),[C,w]=(0,Z.useState)(!1),[E,D]=(0,Z.useState)(void 0),[O,k]=(0,Z.useState)(void 0),[A,j]=(0,Z.useState)(!1),[M,N]=(0,Z.useState)(!1),P=(0,Z.useRef)(!0),F=(0,Z.useCallback)(e=>{n(e.hasChanges),i(e.changedFilesCount),o(e.hasUnpushedCommits),c(e.currentBranch),v(e.hasRemoteBranch),u(e.isOnGitHub),f(e.remoteUrl),m(e.canCreateRepo),g(e.repoUrl),b(e.status),S(e.defaultBranch??null),w(e.prExists),D(e.prUrl),k(e.prState),j(e.commitsAheadOfDefault??!1)},[]),I=(0,Z.useRef)(F);I.current=F;let L=(0,Z.useCallback)(async(t=!1)=>{if(!e)return;let n=setTimeout(()=>N(!0),100);try{let n=`unified-git-status-${e}`;t&&ve.invalidate(n);let r=await ve.get(n,()=>T(e,t),mn);F(r),gn(e,r)}catch(e){console.error(`Failed to fetch unified git status:`,e)}finally{clearTimeout(n),N(!1)}},[e,F]);return(0,Z.useEffect)(()=>{if(e)return _n(e,e=>{I.current(e)})},[e]),(0,Z.useEffect)(()=>{e&&(async()=>{if(P.current){let t=`unified-git-status-${e}`,n=ve.getSync(t);n&&F(n),P.current=!1}await L()})()},[e,L,F]),{hasChanges:t,changedFilesCount:r,hasUnpushedCommits:a,hasRemoteBranch:_,currentBranch:s,isOnGitHub:l,remoteUrl:d,canCreateRepo:p,repoUrl:h,status:y,defaultBranch:x,prExists:C,prUrl:E,prState:O,commitsAheadOfDefault:A,isRefreshing:M,fetchUnifiedStatus:L}}function yn(e){let[t,n]=(0,Z.useState)([]),[r,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(!1),c=vn(e);async function l(){if(!(!e||r)){a(!0);try{n((await i(e)).branches)}catch{n([])}finally{a(!1)}}}async function d(t){if(!(!e||t===c.currentBranch)){s(!0);try{await u(e,t),await c.fetchUnifiedStatus(!0),Ke({title:`Switched to branch "${t}"`})}catch(e){Ke({title:`Failed to switch branch`,description:e instanceof Error?e.message:String(e),variant:`destructive`})}finally{s(!1)}}}return{currentBranch:c.currentBranch,availableBranches:t,isLoadingBranches:r,isCheckingOut:o,loadBranches:l,checkoutBranch:d,fetchUnifiedStatus:c.fetchUnifiedStatus}}function bn(e){let t=(0,X.c)(8),{collapsed:n}=e,{theme:r,setTheme:i}=at();if(n)return null;let a;t[0]!==i||t[1]!==r?(a=()=>i(r===`dark`?`light`:`dark`),t[0]=i,t[1]=r,t[2]=a):a=t[2];let o,s,c;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Q.jsx)(f,{className:`h-4 w-4 rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0`}),s=(0,Q.jsx)(se,{className:`absolute h-4 w-4 rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100`}),c=(0,Q.jsx)(`span`,{className:`sr-only`,children:`Toggle theme`}),t[3]=o,t[4]=s,t[5]=c):(o=t[3],s=t[4],c=t[5]);let l;return t[6]===a?l=t[7]:(l=(0,Q.jsxs)(O,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground hover:text-background`,onClick:a,children:[o,s,c]}),t[6]=a,t[7]=l),l}function xn({threadId:e}){let[t,n]=(0,Z.useState)(!1),[r,i]=(0,Z.useState)(null),a=yn(e);return(0,Z.useEffect)(()=>{e&&me(e).then(i).catch(()=>{})},[e]),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-8 py-2 mt-[-1rem] min-h-[2.25rem]`,children:[e&&(0,Q.jsx)(dn,{currentBranch:a.currentBranch,availableBranches:a.availableBranches,isLoadingBranches:a.isLoadingBranches,isCheckingOut:a.isCheckingOut,onLoadBranches:a.loadBranches,onCheckoutBranch:a.checkoutBranch}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(bn,{collapsed:!1}),(0,Q.jsx)(pn,{threadId:e}),e&&(0,Q.jsxs)(Ue,{children:[(0,Q.jsx)(We,{asChild:!0,children:(0,Q.jsx)(O,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground hover:text-background`,onClick:async()=>{if(!(!e||t)){n(!0);try{let t=await me(e);await navigator.clipboard.writeText(t)}finally{n(!1)}}},disabled:t,"aria-label":`Copy repository folder path`,children:(0,Q.jsx)(D,{className:`h-4 w-4`})})}),(0,Q.jsxs)(He,{side:`top`,className:`bg-slate-900 text-white`,children:[(0,Q.jsx)(`div`,{children:`Copy repository folder path`}),r&&(0,Q.jsx)(`div`,{className:`opacity-70 text-xs`,children:r})]})]})]})]})}function Sn(e,t){if(!(!t||!e.includes(`"run_js"`)))try{let n=JSON.parse(e.trim());if(!Array.isArray(n))return;for(let e of n)e?.type===`tool_use`&&e?.name===`run_js`&&e?.id&&e?.input?.code&&vt(e.id,e.input.code,t)}catch{}}function Cn(){let{state:e,dispatch:t}=Re(),[n,r]=(0,Z.useState)(null),[i,a]=(0,Z.useState)(!1),c=(0,Z.useRef)(``),l=(0,Z.useRef)(``),u=(0,Z.useRef)([]),d=(0,Z.useRef)(!1),f=(0,Z.useRef)(null),p=(0,Z.useRef)(null),m=(0,Z.useRef)(()=>{}),[h,g]=(0,Z.useState)(null),_=(0,Z.useRef)(!1),v=(0,Z.useRef)(!1),y=(0,Z.useRef)(null),b=(0,Z.useRef)(null),x=(0,Z.useRef)(null),{selectedThreadId:S,selectedProjectId:C,messages:w,queuedChatMessages:T,isStreaming:D,streamingModel:O,processingThreadIds:k}=e,A=!!(S&&k.includes(S)),j=(0,Z.useCallback)(n=>{if(f.current=null,p.current=null,_.current){_.current=!1;return}let r=u.current,i=Be(r)||`...`;if(y.current&&(r.length===0||i===`...`)){let r={messageId:`msg-${Date.now()}-error`,sender:`agent`,content:`Error: ${y.current}`,contentType:`text`,timestamp:new Date().toISOString(),model:e.streamingModel||n,isThinking:!1};t({type:Y.AddMessage,message:r}),t({type:Y.ResetStream}),S&&t({type:Y.RemoveProcessingThread,threadId:S}),y.current=null;return}let a={messageId:`msg-${Date.now()}-agent`,sender:`agent`,content:i,contentType:`markdown`,timestamp:new Date().toISOString(),model:e.streamingModel||n,isThinking:!1};c.current=``,l.current=``,u.current=[],y.current=null,t({type:Y.AddMessage,message:a}),t({type:Y.ResetStream}),S&&(t({type:Y.MarkThreadCompleted,threadId:S}),t({type:Y.RemoveProcessingThread,threadId:S}))},[e.streamingModel,t,S]);(0,Z.useEffect)(()=>{m.current=j},[j]);let M=(0,Z.useCallback)(()=>{S&&g(S),_.current=!0,S&&ne(S),f.current&&=(f.current.abort(),null),p.current&&=(p.current(),null),c.current=``,l.current=``,u.current=[],y.current=null;let n={messageId:`msg-${Date.now()}-stopped`,sender:`agent`,content:`I've stopped working on your request.`,contentType:`text`,timestamp:new Date().toISOString(),model:e.streamingModel||`default`,isThinking:!1};t({type:Y.AddMessage,message:n}),t({type:Y.ResetStream}),S&&(t({type:Y.MarkThreadCompleted,threadId:S}),t({type:Y.RemoveProcessingThread,threadId:S}))},[S,t,e.streamingModel]);(0,Z.useEffect)(()=>{v.current&&!D&&f.current&&(f.current.abort(),f.current=null,p.current&&=(p.current(),null),m.current(O||`default`)),v.current=D},[D,O]),(0,Z.useEffect)(()=>{if(b.current&&=(clearTimeout(b.current),null),D){let e=12e4,t=n=>{b.current&&=(clearTimeout(b.current),null),b.current=setTimeout(()=>{let n=Date.now(),r=x?.current??null;if(r!=null){let i=n-r;if(i<e){t(e-i);return}}console.warn(`[stream-safety] Streaming stuck for 2 minutes with no activity, auto-finalizing`),f.current&&=(f.current.abort(),null),p.current&&=(p.current(),null),m.current(O||`default`)},n)},n=e;if(x?.current!=null){let t=Date.now()-x.current;n=t>=e?0:e-t}t(n)}return()=>{b.current&&=(clearTimeout(b.current),null)}},[D,O]),(0,Z.useEffect)(()=>()=>{f.current&&=(f.current.abort(),null),p.current&&=(p.current(),null),c.current=``,l.current=``,u.current=[],d.current=!1,y.current=null,t({type:Y.ResetStream})},[S,t]),(0,Z.useEffect)(()=>{if(!S)return;let e=!1;async function n(){try{let n=await le(S);e||t({type:Y.SetMessages,messages:n.messages})}catch(n){console.error(`Failed to load chat history:`,n),e||t({type:Y.SetMessages,messages:[]})}}return n(),()=>{e=!0}},[S,C,t]),(0,Z.useEffect)(()=>{if(!S||!A||D)return;let e=new AbortController;return f.current=e,t({type:Y.ResetStream}),t({type:Y.SetStreaming,isStreaming:!0}),c.current=``,l.current=``,u.current=[],d.current=!1,y.current=null,H(S,e.signal).then(n=>{if(!n||e.signal.aborted){m.current(`default`);return}p.current=E(n,e=>{if(t({type:Y.IncrementStreamEventCount}),e.type===`error`){let t=e.content||`Unknown error occurred`;y.current=t,r(t);return}if(e.type!==`message`){if(e.type===`toolcall_delta`){e.partial?.content?.[0]?.id&&e.delta&&t({type:Y.UpdateToolCallProgress,toolCallId:e.partial.content[0].id,progress:{toolCallId:e.partial.content[0].id,toolName:e.partial.content[0].name,delta:e.delta,partial:e.partial}});return}if(e.model&&t({type:Y.SetStreamModel,model:e.model}),e.type===`thinking`||e.isThinking){let n=e.content??``;Sn(n,S),l.current+=n;let r=ze(u.current,`thinking`,n);u.current=r,t({type:Y.AppendStreamChunk,chunkType:`thinking`,content:n,segments:r})}else if(e.type===`result`)d.current=!0,c.current=e.content??``,u.current=Ve(u.current,e.content??``),t({type:Y.SetStreamContent,content:e.content??``});else{if(d.current)return;c.current+=e.content??``;let n=ze(u.current,`content`,e.content??``);u.current=n,t({type:Y.AppendStreamChunk,chunkType:`content`,content:e.content??``,segments:n})}}},()=>{m.current(`default`)},e=>{if(e.includes(`AbortError`)||e.includes(`canceled`)||e.includes(`BodyStreamBuffer was aborted`)){m.current(`default`);return}y.current=e,r(e)},e=>{if(t({type:Y.IncrementStreamEventCount}),e.role===`assistant`){let n=e.content??``,r=typeof n==`string`?n:JSON.stringify(n);if(e.isThinking??!1){l.current+=r;let e=ze(u.current,`thinking`,r);u.current=e,t({type:Y.AppendStreamChunk,chunkType:`thinking`,content:r,segments:e});return}let i=!1;if(typeof n==`object`&&Array.isArray(n)&&n.length>0)i=!0;else if(typeof r==`string`&&r.trim().startsWith(`[`))try{let e=JSON.parse(r);i=Array.isArray(e)&&e.length>0}catch{}if(i)d.current=!0,c.current=r,u.current=Ve(u.current,r),t({type:Y.SetStreamContent,content:r});else{c.current+=r;let e=ze(u.current,`content`,r);u.current=e,t({type:Y.AppendStreamChunk,chunkType:`content`,content:r,segments:e})}}else if(e.role===`tool`){let n=e.content??``,r=typeof n==`string`?n:JSON.stringify(n);if(r){c.current+=r;let e=ze(u.current,`content`,r);u.current=e,t({type:Y.AppendStreamChunk,chunkType:`content`,content:r,segments:e})}}})}).catch(e=>{if(e instanceof Error&&e.name===`AbortError`){t({type:Y.ResetStream});return}if(e instanceof Error&&e.message.includes(`not currently processing`)){t({type:Y.ResetStream});return}console.error(`Failed to subscribe to chat stream:`,e),t({type:Y.ResetStream})}),()=>{e.abort(),p.current&&=(p.current(),null)}},[S,A]);let N=(0,Z.useCallback)(async(n,i,h,_,v,b,x)=>{if(!S)return;r(null),g(null),f.current&&f.current.abort(),p.current&&p.current();let w=`msg-${Date.now()}`,T;try{let e=await s(S,w);e.success&&e.stashed&&e.checkpointRef&&(T=e.checkpointRef)}catch{}let D={messageId:w,sender:`user`,content:n,contentType:`text`,timestamp:new Date().toISOString(),model:i,attachments:h.map(e=>({fileName:e.fileName,content:e.content,mimeType:e.mimeType})),checkpointRef:T};t({type:Y.AddMessage,message:D});let O=n.trim().replace(/\n/g,` `).slice(0,100);if(C&&S&&(o(S,{title:O}).catch(e=>{console.error(`Failed to update thread title:`,e)}),t({type:Y.UpdateThreadTitle,projectId:C,threadId:S,title:O})),b){let e=_??void 0;if(!e&&typeof i==`string`){let t=i.split(/[:/]/)[0]?.trim();t&&(e=t)}if(!e){let e={messageId:`msg-${Date.now()}-error`,sender:`agent`,content:`Image generation is not available because no provider is configured for the selected model.`,contentType:`text`,timestamp:new Date().toISOString(),model:i,isThinking:!1};t({type:Y.AddMessage,message:e}),t({type:Y.ResetStream});return}t({type:Y.SetStreaming,isStreaming:!0});try{let r=await P(n,i,e,S),a={messageId:`msg-${Date.now()}-agent`,sender:`agent`,content:n,contentType:`text`,timestamp:new Date().toISOString(),model:i,isThinking:!1,generatedImageUrl:r.imageUrl,generatedImageData:r.imageData};t({type:Y.AddMessage,message:a})}catch(e){let n=e instanceof Error?e.message:`Image generation failed`,r={messageId:`msg-${Date.now()}-error`,sender:`agent`,content:`Error: ${n}`,contentType:`text`,timestamp:new Date().toISOString(),model:i,isThinking:!1};t({type:Y.AddMessage,message:r})}finally{t({type:Y.ResetStream})}return}t({type:Y.ResetStream}),t({type:Y.SetStreaming,isStreaming:!0}),c.current=``,d.current=!1;let k=new AbortController;f.current=k;try{let a=await ae(S,n,i,h,k.signal,_,v,x);if(!a){m.current(i);return}p.current=E(a,n=>{if(t({type:Y.IncrementStreamEventCount}),n.type===`error`){let e=n.content||`Unknown error occurred`;y.current=e,r(e);return}if(n.type!==`message`){if(n.type===`toolcall_delta`){if(n.partial?.content?.[0]?.id&&n.delta){let e=n.partial.content[0].id,r=n.partial.content[0].name;t({type:Y.UpdateToolCallProgress,toolCallId:e,progress:{toolCallId:e,toolName:r,delta:n.delta,partial:n.partial}})}return}if(n.model&&t({type:Y.SetStreamModel,model:n.model}),n.type===`thinking`||n.isThinking){let r=n.content??``;Sn(r,e.selectedThreadId),l.current+=r;let i=ze(u.current,`thinking`,r);u.current=i,t({type:Y.AppendStreamChunk,chunkType:`thinking`,content:r,segments:i})}else if(n.type===`result`)d.current=!0,c.current=n.content??``,u.current=Ve(u.current,n.content??``),t({type:Y.SetStreamContent,content:n.content??``});else{if(d.current)return;c.current+=n.content??``;let e=ze(u.current,`content`,n.content??``);u.current=e,t({type:Y.AppendStreamChunk,chunkType:`content`,content:n.content??``,segments:e})}}},()=>{m.current(i)},e=>{if(e.includes(`AbortError`)||e.includes(`canceled`)||e.includes(`BodyStreamBuffer was aborted`)){m.current(i);return}y.current=e,r(e)},e=>{if(t({type:Y.IncrementStreamEventCount}),e.role===`assistant`){let n=e.content??``,r=typeof n==`string`?n:JSON.stringify(n);if(e.isThinking??!1){l.current+=r;let e=ze(u.current,`thinking`,r);u.current=e,t({type:Y.AppendStreamChunk,chunkType:`thinking`,content:r,segments:e});return}let i=!1;if(typeof n==`object`&&Array.isArray(n)&&n.length>0)i=!0;else if(typeof r==`string`&&r.trim().startsWith(`[`))try{let e=JSON.parse(r);i=Array.isArray(e)&&e.length>0}catch{}if(i)d.current=!0,c.current=r,u.current=Ve(u.current,r),t({type:Y.SetStreamContent,content:r});else{c.current+=r;let e=ze(u.current,`content`,r);u.current=e,t({type:Y.AppendStreamChunk,chunkType:`content`,content:r,segments:e})}}else if(e.role===`tool`){let n=e.content??``,r=typeof n==`string`?n:JSON.stringify(n);if(r){c.current+=r;let e=ze(u.current,`content`,r);u.current=e,t({type:Y.AppendStreamChunk,chunkType:`content`,content:r,segments:e})}}})}catch(e){if(e instanceof Error&&e.name===`AbortError`||e instanceof Error&&e.message.includes(`BodyStreamBuffer was aborted`))return;if(e instanceof ye){t({type:Y.ResetStream}),a(!0);return}r(e instanceof Error?e.message:`Failed to send message. Please ensure the CLI server is running on localhost:641`),y.current=e instanceof Error?e.message:`Failed to send message. Please ensure the CLI server is running on localhost:641`,t({type:Y.ResetStream})}},[S,C,t]);(0,Z.useEffect)(()=>{let n=e.pendingChatMessage;if(!n||D||n.threadId!==S)return;let r=setTimeout(()=>{t({type:Y.ClearPendingChatMessage}),N(n.message,n.model,[],n.provider)},100);return()=>clearTimeout(r)},[e.pendingChatMessage,D,S,t,N]);let F=(0,Z.useMemo)(()=>S?T.filter(e=>e.threadId===S):[],[S,T]),I=(0,Z.useRef)(!1);return(0,Z.useEffect)(()=>{if(D||!S||F.length===0||I.current)return;let[e]=F;I.current=!0,t({type:Y.RemoveQueuedChatMessage,queuedMessageId:e.id});let n=setTimeout(()=>{N(e.message,e.model,e.attachments,e.provider,e.planMode,e.imageMode,e.ralphMode),I.current=!1},0);return()=>{clearTimeout(n),I.current=!1}},[t,N,D,F,S]),{error:n,setError:r,handleSend:N,handleStop:M,isStreaming:D,selectedThreadId:S,queuedMessagesForThread:F,handleRemoveQueuedMessage:(0,Z.useCallback)(e=>{let n=F.find(t=>t.id===e);t({type:Y.RemoveQueuedChatMessage,queuedMessageId:e}),!(!n||D||w.length>0||!S)&&N(n.message,n.model,n.attachments,n.provider,n.planMode,n.imageMode,n.ralphMode)},[t,N,D,w.length,F,S]),showEmptyBalanceDialog:i,setShowEmptyBalanceDialog:a}}function wn(e){let t=(0,X.c)(10),{open:n,onClose:r}=e,i=Le(),a;t[0]===r?a=t[1]:(a=e=>{e||r()},t[0]=r,t[1]=a);let o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Q.jsxs)(Ze,{children:[(0,Q.jsx)(Je,{children:`Balance empty`}),(0,Q.jsx)(qe,{children:`You have no prompts remaining. Purchase additional prompts to continue.`})]}),t[2]=o):o=t[2];let s;t[3]!==i||t[4]!==r?(s=(0,Q.jsxs)(Ye,{children:[o,(0,Q.jsx)(Xe,{children:(0,Q.jsx)(O,{onClick:()=>{r(),i(`/settings/account`)},children:`Go to Account`})})]}),t[3]=i,t[4]=r,t[5]=s):s=t[5];let c;return t[6]!==n||t[7]!==a||t[8]!==s?(c=(0,Q.jsx)(Qe,{open:n,onOpenChange:a,children:s}),t[6]=n,t[7]=a,t[8]=s,t[9]=c):c=t[9],c}function Tn(e){let t=(0,X.c)(13),{todos:n}=e,r;t[0]===n?r=t[1]:(r=n.filter(Dn),t[0]=n,t[1]=r);let i=r.length,a;t[2]===n.length?a=t[3]:(a=n.length===0&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No todo items.`}),t[2]=n.length,t[3]=a);let o;t[4]===n?o=t[5]:(o=n.map(En),t[4]=n,t[5]=o);let s;t[6]!==i||t[7]!==n.length?(s=n.length>0&&(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground pt-1`,children:[i,`/`,n.length,` completed`]}),t[6]=i,t[7]=n.length,t[8]=s):s=t[8];let c;return t[9]!==a||t[10]!==o||t[11]!==s?(c=(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[a,o,s]}),t[9]=a,t[10]=o,t[11]=s,t[12]=c):c=t[12],c}function En(e){return(0,Q.jsxs)(`div`,{className:`flex items-start gap-2 text-sm`,children:[e.status===`done`?(0,Q.jsx)(ce,{className:`h-4 w-4 shrink-0 mt-0.5 text-brand`}):e.status===`working`?(0,Q.jsx)(n,{className:`h-4 w-4 shrink-0 mt-0.5 text-yellow-500`}):(0,Q.jsx)(z,{className:`h-4 w-4 shrink-0 mt-0.5 text-muted-foreground`}),(0,Q.jsx)(`span`,{className:e.status===`done`?`line-through text-muted-foreground`:`text-foreground`,children:e.description})]},e.id)}function Dn(e){return e.status===`done`}function On(){let e=(0,X.c)(16),{todos:t}=(0,Z.useContext)(ct),[n,r]=(0,Z.useState)(!1),i;e[0]===t?i=e[1]:(i=t.filter(kn),e[0]=t,e[1]=i);let o=i.length;if(t.length-o<=0)return null;let s,c;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>r(!0),c=(0,Q.jsx)(a,{className:`h-4 w-4 shrink-0`}),e[2]=s,e[3]=c):(s=e[2],c=e[3]);let l;e[4]!==o||e[5]!==t.length?(l=(0,Q.jsxs)(O,{variant:`outline`,size:`sm`,className:`gap-2 bg-background ml-2`,onClick:s,children:[c,o,` of `,t.length,` complete`]}),e[4]=o,e[5]=t.length,e[6]=l):l=e[6];let u;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Q.jsx)(_,{children:(0,Q.jsx)(de,{children:`Tasks`})}),e[7]=u):u=e[7];let d;e[8]===t?d=e[9]:(d=(0,Q.jsxs)(A,{className:`max-w-md`,children:[u,(0,Q.jsx)(Tn,{todos:t})]}),e[8]=t,e[9]=d);let f;e[10]!==n||e[11]!==d?(f=(0,Q.jsx)(m,{open:n,onOpenChange:r,children:d}),e[10]=n,e[11]=d,e[12]=f):f=e[12];let p;return e[13]!==l||e[14]!==f?(p=(0,Q.jsxs)(Q.Fragment,{children:[l,f]}),e[13]=l,e[14]=f,e[15]=p):p=e[15],p}function kn(e){return e.status===`done`}function An(e){let t=(0,X.c)(34),{messages:n}=e,r;t[0]===n?r=t[1]:(r=n===void 0?[]:n,t[0]=n,t[1]=r);let i=r,{state:a,dispatch:o}=Re(),{isCreatingProject:s,selectedThreadId:c}=a,{handleSend:l,handleStop:u,isStreaming:d,queuedMessagesForThread:f,handleRemoveQueuedMessage:p,showEmptyBalanceDialog:m,setShowEmptyBalanceDialog:h}=Cn(),g=a.pendingChatMessage?.threadId===c,_=d||g,v=i.length>0,{hasChanges:y,changedFilesCount:b}=vn(c??void 0),{setActiveMainTab:x}=$e(),S;t[2]!==o||t[3]!==c?(S=async()=>{if(c)try{let e=await ge(c);o({type:Y.ClearMessages}),console.log(`New conversation started:`,e);let t=await le(c);o({type:Y.SetMessages,messages:t.messages})}catch(e){console.error(`Failed to start new chat:`,e)}},t[2]=o,t[3]=c,t[4]=S):S=t[4];let C=S,T;t[5]===h?T=t[6]:(T=()=>h(!1),t[5]=h,t[6]=T);let E;t[7]!==m||t[8]!==T?(E=(0,Q.jsx)(wn,{open:m,onClose:T}),t[7]=m,t[8]=T,t[9]=E):E=t[9];let D;t[10]!==b||t[11]!==C||t[12]!==y||t[13]!==v||t[14]!==x?(D=v&&(0,Q.jsxs)(`div`,{className:`absolute -top-12 left-0 z-10 ml-8`,children:[(0,Q.jsxs)(O,{variant:`outline`,size:`sm`,className:`gap-2`,onClick:C,children:[(0,Q.jsx)(L,{className:`h-4 w-4 shrink-0`}),`New Chat`]}),y&&(0,Q.jsxs)(O,{variant:`outline`,size:`sm`,className:`gap-2 ml-2`,onClick:()=>x(`review`),children:[(0,Q.jsx)(w,{className:`h-4 w-4 shrink-0`}),b,` `,b===1?`File`:`Files`,` Changed`]}),(0,Q.jsx)(On,{})]}),t[10]=b,t[11]=C,t[12]=y,t[13]=v,t[14]=x,t[15]=D):D=t[15];let k=!c&&!s,A;t[16]!==_||t[17]!==p||t[18]!==l||t[19]!==u||t[20]!==f||t[21]!==k?(A=(0,Q.jsx)(qt,{onSend:l,onStop:u,isStreaming:_,disabled:k,initialValue:``,queuedMessages:f,onRemoveQueuedMessage:p,isOverlay:!1}),t[16]=_,t[17]=p,t[18]=l,t[19]=u,t[20]=f,t[21]=k,t[22]=A):A=t[22];let j;t[23]!==D||t[24]!==A?(j=(0,Q.jsxs)(`div`,{className:`relative`,children:[D,A]}),t[23]=D,t[24]=A,t[25]=j):j=t[25];let M=c??void 0,N;t[26]===M?N=t[27]:(N=(0,Q.jsx)(xn,{threadId:M}),t[26]=M,t[27]=N);let P;t[28]!==N||t[29]!==j?(P=(0,Q.jsxs)(`div`,{className:`relative mx-auto min-w-[400px] w-[90vw] max-w-3xl`,children:[j,N]}),t[28]=N,t[29]=j,t[30]=P):P=t[30];let F;return t[31]!==P||t[32]!==E?(F=(0,Q.jsxs)(Q.Fragment,{children:[E,P]}),t[31]=P,t[32]=E,t[33]=F):F=t[33],F}export{st as _,an as a,nn as c,vt as d,mt as f,ut as g,lt as h,rn as i,tn as l,dt as m,vn as n,ln as o,ht as p,Qt as r,en as s,An as t,$t as u};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{Dr as t,Jn as n,_a as r,aa as i,ca as a,ea as o,ya as s}from"./dialogs-config-DZFG2IQM.js";import{b as c,d as l,f as u,g as d,h as f,l as p,m,o as h,s as g,u as _,v,y}from"./react-vendor-Bao-KYKs.js";var b=r(),x=e(s(),1),S=t(),C=f,w=c,T=x.forwardRef((e,t)=>{let r=(0,b.c)(14),a,o,s,c;r[0]===e?(a=r[1],o=r[2],s=r[3],c=r[4]):({className:o,inset:s,children:a,...c}=e,r[0]=e,r[1]=a,r[2]=o,r[3]=s,r[4]=c);let l=s&&`pl-8`,u;r[5]!==o||r[6]!==l?(u=n(`flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground`,l,o),r[5]=o,r[6]=l,r[7]=u):u=r[7];let d;r[8]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,S.jsx)(i,{className:`ml-auto h-4 w-4`}),r[8]=d):d=r[8];let f;return r[9]!==a||r[10]!==c||r[11]!==t||r[12]!==u?(f=(0,S.jsxs)(y,{ref:t,className:u,...c,children:[a,d]}),r[9]=a,r[10]=c,r[11]=t,r[12]=u,r[13]=f):f=r[13],f});T.displayName=y.displayName;var E=x.forwardRef((e,t)=>{let r=(0,b.c)(9),i,a;r[0]===e?(i=r[1],a=r[2]):({className:i,...a}=e,r[0]=e,r[1]=i,r[2]=a);let o;r[3]===i?o=r[4]:(o=n(`z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,i),r[3]=i,r[4]=o);let s;return r[5]!==a||r[6]!==t||r[7]!==o?(s=(0,S.jsx)(v,{ref:t,className:o,...a}),r[5]=a,r[6]=t,r[7]=o,r[8]=s):s=r[8],s});E.displayName=v.displayName;var D=x.forwardRef((e,t)=>{let r=(0,b.c)(9),i,a;r[0]===e?(i=r[1],a=r[2]):({className:i,...a}=e,r[0]=e,r[1]=i,r[2]=a);let o;r[3]===i?o=r[4]:(o=n(`z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md animate-in fade-in-80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,i),r[3]=i,r[4]=o);let s;return r[5]!==a||r[6]!==t||r[7]!==o?(s=(0,S.jsx)(u,{children:(0,S.jsx)(g,{ref:t,className:o,...a})}),r[5]=a,r[6]=t,r[7]=o,r[8]=s):s=r[8],s});D.displayName=g.displayName;var O=x.forwardRef((e,t)=>{let r=(0,b.c)(11),i,a,o;r[0]===e?(i=r[1],a=r[2],o=r[3]):({className:i,inset:a,...o}=e,r[0]=e,r[1]=i,r[2]=a,r[3]=o);let s=a&&`pl-8`,c;r[4]!==i||r[5]!==s?(c=n(`relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,s,i),r[4]=i,r[5]=s,r[6]=c):c=r[6];let l;return r[7]!==o||r[8]!==t||r[9]!==c?(l=(0,S.jsx)(p,{ref:t,className:c,...o}),r[7]=o,r[8]=t,r[9]=c,r[10]=l):l=r[10],l});O.displayName=p.displayName;var k=x.forwardRef((e,t)=>{let r=(0,b.c)(14),i,o,s,c;r[0]===e?(i=r[1],o=r[2],s=r[3],c=r[4]):({className:s,children:o,checked:i,...c}=e,r[0]=e,r[1]=i,r[2]=o,r[3]=s,r[4]=c);let l;r[5]===s?l=r[6]:(l=n(`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,s),r[5]=s,r[6]=l);let u;r[7]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,S.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,S.jsx)(_,{children:(0,S.jsx)(a,{className:`h-4 w-4`})})}),r[7]=u):u=r[7];let d;return r[8]!==i||r[9]!==o||r[10]!==c||r[11]!==t||r[12]!==l?(d=(0,S.jsxs)(h,{ref:t,className:l,checked:i,...c,children:[u,o]}),r[8]=i,r[9]=o,r[10]=c,r[11]=t,r[12]=l,r[13]=d):d=r[13],d});k.displayName=h.displayName;var A=x.forwardRef((e,t)=>{let r=(0,b.c)(12),i,a,s;r[0]===e?(i=r[1],a=r[2],s=r[3]):({className:a,children:i,...s}=e,r[0]=e,r[1]=i,r[2]=a,r[3]=s);let c;r[4]===a?c=r[5]:(c=n(`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,a),r[4]=a,r[5]=c);let l;r[6]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,S.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,S.jsx)(_,{children:(0,S.jsx)(o,{className:`h-2 w-2 fill-current`})})}),r[6]=l):l=r[6];let u;return r[7]!==i||r[8]!==s||r[9]!==t||r[10]!==c?(u=(0,S.jsxs)(m,{ref:t,className:c,...s,children:[l,i]}),r[7]=i,r[8]=s,r[9]=t,r[10]=c,r[11]=u):u=r[11],u});A.displayName=m.displayName;var j=x.forwardRef((e,t)=>{let r=(0,b.c)(11),i,a,o;r[0]===e?(i=r[1],a=r[2],o=r[3]):({className:i,inset:a,...o}=e,r[0]=e,r[1]=i,r[2]=a,r[3]=o);let s=a&&`pl-8`,c;r[4]!==i||r[5]!==s?(c=n(`px-2 py-1.5 text-sm font-semibold text-foreground`,s,i),r[4]=i,r[5]=s,r[6]=c):c=r[6];let u;return r[7]!==o||r[8]!==t||r[9]!==c?(u=(0,S.jsx)(l,{ref:t,className:c,...o}),r[7]=o,r[8]=t,r[9]=c,r[10]=u):u=r[10],u});j.displayName=l.displayName;var M=x.forwardRef((e,t)=>{let r=(0,b.c)(9),i,a;r[0]===e?(i=r[1],a=r[2]):({className:i,...a}=e,r[0]=e,r[1]=i,r[2]=a);let o;r[3]===i?o=r[4]:(o=n(`-mx-1 my-1 h-px bg-border`,i),r[3]=i,r[4]=o);let s;return r[5]!==a||r[6]!==t||r[7]!==o?(s=(0,S.jsx)(d,{ref:t,className:o,...a}),r[5]=a,r[6]=t,r[7]=o,r[8]=s):s=r[8],s});M.displayName=d.displayName;var N=e=>{let t=(0,b.c)(8),r,i;t[0]===e?(r=t[1],i=t[2]):({className:r,...i}=e,t[0]=e,t[1]=r,t[2]=i);let a;t[3]===r?a=t[4]:(a=n(`ml-auto text-xs tracking-widest text-muted-foreground`,r),t[3]=r,t[4]=a);let o;return t[5]!==i||t[6]!==a?(o=(0,S.jsx)(`span`,{className:a,...i}),t[5]=i,t[6]=a,t[7]=o):o=t[7],o};N.displayName=`ContextMenuShortcut`;export{w as a,M as i,D as n,O as r,C as t};
@@ -1 +0,0 @@
1
- import{t as e}from"./history-view-BR8scGnM.js";export{e as ConversationHistoryView,e as default};
@@ -1,3 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{Bi as t,Cn as n,Dr as r,Gn as i,Hn as a,J as o,Jn as s,Kn as c,Li as l,Mn as u,Ri as d,Rn as f,Si as p,Un as m,Ut as h,_a as g,_i as _,aa as v,bi as y,di as b,et as x,kt as S,oa as C,ot as w,qn as T,ri as E,ui as D,ya as O,yi as k}from"./dialogs-config-DZFG2IQM.js";import{S as ee}from"./react-vendor-Bao-KYKs.js";import{a as A,t as j}from"./store-CwvBC-YP.js";import{t as M}from"./textarea-DpXOZLt8.js";import{c as N,s as P,u as te}from"./history-view-BR8scGnM.js";import{_ as ne,t as re}from"./chat-input-container-B_qVOGzW.js";import{t as F}from"./standard-list-item-D2lbPXa1.js";import{n as ie}from"./utils-Cy2s2TEb.js";import{t as ae}from"./page-toolbar-TvYsDwUY.js";import{n as oe,r as se,t as I}from"./resizable-DzrIos_Y.js";import{a as L,n as R,r as ce,t as z}from"./context-menu-D5slxFcc.js";var B=e(O(),1),V=g(),H=r();function U(e){let t=(0,V.c)(17),{children:n,title:r,headerAction:i,footer:a}=e,o;t[0]===r?o=t[1]:(o=r&&(0,H.jsx)(`span`,{className:`text-sm font-semibold tracking-tight`,children:r}),t[0]=r,t[1]=o);let s;t[2]===o?s=t[3]:(s=(0,H.jsx)(`div`,{className:`flex items-center gap-2`,children:o}),t[2]=o,t[3]=s);let c;t[4]===i?c=t[5]:(c=i&&(0,H.jsx)(`div`,{className:`flex items-center gap-2 ml-auto`,children:i}),t[4]=i,t[5]=c);let l;t[6]!==s||t[7]!==c?(l=(0,H.jsxs)(`div`,{className:`flex items-center justify-between border-b border-sidebar-border px-4 py-6`,children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let d;t[9]===n?d=t[10]:(d=(0,H.jsx)(u,{className:`flex-1`,children:n}),t[9]=n,t[10]=d);let f;t[11]===a?f=t[12]:(f=a&&(0,H.jsx)(`div`,{className:`border-t border-sidebar-border`,children:a}),t[11]=a,t[12]=f);let p;return t[13]!==l||t[14]!==d||t[15]!==f?(p=(0,H.jsxs)(`div`,{className:`flex flex-col h-full`,children:[l,d,f]}),t[13]=l,t[14]=d,t[15]=f,t[16]=p):p=t[16],p}function le(e){let t=[],n={};return e.forEach((e,r)=>{let i=e.path.split(`/`),a=t,o=``;for(let e=0;e<i.length-1;e++){if(o=o?`${o}/${i[e]}`:i[e],!n[o]){let t={id:`dir:${o}`,name:i[e],children:[]};n[o]=t,a.push(t)}a=n[o].children}a.push({id:`file:${e.path}`,name:i[i.length-1],fileIndex:r,status:e.status})}),t}var W={added:`text-green-500`,deleted:`text-red-500`,untracked:`text-green-500`,renamed:`text-blue-500`,modified:`text-orange-500`},G={added:`A`,deleted:`D`,untracked:`U`,renamed:`R`,modified:`M`};function K(e){return s(`status-badge font-mono text-xs font-semibold`,W[e]??`text-orange-500`)}function ue(e){return G[e]??`M`}function de(e){let n=(0,V.c)(37),{treeData:r,files:i,isLoading:a,error:o,selectedFileIndex:c,onFileSelect:u,onRevertFile:f}=e,m;n[0]===i?m=n[1]:(m=i.reduce(pe,0),n[0]=i,n[1]=m);let h=m,g;n[2]===i?g=n[3]:(g=i.reduce(q,0),n[2]=i,n[3]=g);let _=g,y=i.length===1?``:`s`,b;n[4]!==i.length||n[5]!==y?(b=(0,H.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[i.length,` file`,y]}),n[4]=i.length,n[5]=y,n[6]=b):b=n[6];let x;n[7]===h?x=n[8]:(x=(0,H.jsxs)(`span`,{className:`text-xs text-green-500`,children:[`+`,h]}),n[7]=h,n[8]=x);let S;n[9]===_?S=n[10]:(S=(0,H.jsxs)(`span`,{className:`text-xs text-red-500`,children:[`-`,_]}),n[9]=_,n[10]=S);let C;n[11]!==b||n[12]!==x||n[13]!==S?(C=(0,H.jsxs)(`div`,{className:`flex items-center gap-1`,children:[b,x,S]}),n[11]=b,n[12]=x,n[13]=S,n[14]=C):C=n[14];let w=C;if(a){let e;n[15]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,H.jsx)(`div`,{className:`flex-1 flex items-center justify-center pt-3 pb-2`,children:(0,H.jsx)(p,{className:`h-6 w-6 animate-spin text-muted-foreground`})}),n[15]=e):e=n[15];let t;return n[16]===w?t=n[17]:(t=(0,H.jsx)(U,{title:`Review Changes`,headerAction:w,children:e}),n[16]=w,n[17]=t),t}if(o){let e;n[18]===o?e=n[19]:(e=(0,H.jsx)(`div`,{className:`flex-1 flex items-center justify-center p-4 pt-7 pb-2`,children:(0,H.jsx)(`p`,{className:`text-destructive text-xs text-center`,children:o})}),n[18]=o,n[19]=e);let t;return n[20]!==w||n[21]!==e?(t=(0,H.jsx)(U,{title:`Review Changes`,headerAction:w,children:e}),n[20]=w,n[21]=e,n[22]=t):t=n[22],t}if(i.length===0){let e;n[23]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,H.jsx)(`div`,{className:`flex-1 flex items-center justify-center p-4 pt-7 pb-2`,children:(0,H.jsx)(`p`,{className:`text-muted-foreground text-xs text-center`,children:`No changes to review`})}),n[23]=e):e=n[23];let t;return n[24]===w?t=n[25]:(t=(0,H.jsx)(U,{title:`Review Changes`,headerAction:w,children:e}),n[24]=w,n[25]=t),t}let T;n[26]!==i||n[27]!==u||n[28]!==f||n[29]!==c?(T=(e,n)=>{let{isOpen:r,toggle:a}=n,o=!!e.children,p=(0,H.jsxs)(F,{onClick:()=>{o?a():e.fileIndex!==void 0&&u(e.fileIndex)},selected:!o&&e.fileIndex===c,className:`gap-1.5`,children:[o?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(v,{className:s(`h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform`,r&&`rotate-90`)}),r?(0,H.jsx)(d,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}):(0,H.jsx)(l,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`})]}):(0,H.jsx)(t,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),(0,H.jsx)(`span`,{className:`truncate flex-1 min-w-0`,children:e.name}),!o&&e.status&&(0,H.jsx)(`span`,{className:K(e.status),children:ue(e.status)})]});return o?p:(0,H.jsxs)(z,{children:[(0,H.jsx)(L,{asChild:!0,children:p}),(0,H.jsx)(R,{children:(0,H.jsxs)(ce,{onClick:()=>{e.fileIndex!==void 0&&f?.(i[e.fileIndex])},children:[(0,H.jsx)(E,{className:`mr-2 h-3.5 w-3.5`}),`Revert Change`]})})]})},n[26]=i,n[27]=u,n[28]=f,n[29]=c,n[30]=T):T=n[30];let D;n[31]!==T||n[32]!==r?(D=(0,H.jsx)(`div`,{className:`flex-1 overflow-y-auto pt-3 pb-2 px-1`,children:(0,H.jsx)(ne,{nodes:r,defaultOpen:!0,resetKey:r,indent:16,childContainerClassName:`ml-4 border-l border-sidebar-border pl-2`,renderNode:T})}),n[31]=T,n[32]=r,n[33]=D):D=n[33];let O;return n[34]!==w||n[35]!==D?(O=(0,H.jsx)(U,{title:`Review Changes`,headerAction:w,children:D}),n[34]=w,n[35]=D,n[36]=O):O=n[36],O}function q(e,t){return e+t.hunks.reduce(J,0)}function J(e,t){return e+t.changes.filter(fe).length}function fe(e){return e.type===`delete`}function pe(e,t){return e+t.hunks.reduce(Y,0)}function Y(e,t){return e+t.changes.filter(me).length}function me(e){return e.type===`add`}function he(e){let t=(0,V.c)(2),{isOpen:n}=e,r=n===void 0||n?`ml-[-40px]`:``,i;return t[0]===r?i=t[1]:(i=(0,H.jsx)(I,{withHandle:!0,className:r}),t[0]=r,t[1]=i),i}function ge(e){let t=(0,V.c)(35),{open:n,lineNumber:r,lineContent:o,initialComment:s,isEditing:l,onSave:u,onDelete:d,onClose:p}=e,[h,g]=(0,B.useState)((s===void 0?``:s)??``),_;t[0]!==u||t[1]!==h?(_=()=>{h.trim()&&u(h.trim())},t[0]=u,t[1]=h,t[2]=_):_=t[2];let v=_,y;t[3]===v?y=t[4]:(y=e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),v())},t[3]=v,t[4]=y);let b=y,x;t[5]===p?x=t[6]:(x=e=>{e||p()},t[5]=p,t[6]=x);let S;t[7]===r?S=t[8]:(S=(0,H.jsx)(c,{children:(0,H.jsxs)(T,{className:`text-sm font-medium`,children:[`Comment on line `,r]})}),t[7]=r,t[8]=S);let C=o||` `,w;t[9]===C?w=t[10]:(w=(0,H.jsx)(`div`,{className:`rounded bg-muted px-3 py-2 font-mono text-xs text-muted-foreground overflow-x-auto whitespace-pre`,children:C}),t[9]=C,t[10]=w);let E;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(E=e=>g(e.target.value),t[11]=E):E=t[11];let D;t[12]!==b||t[13]!==h?(D=(0,H.jsx)(M,{autoFocus:!0,placeholder:`Add a comment... (Cmd+Enter to save)`,value:h,onChange:E,onKeyDown:b,rows:12,className:`resize-none text-sm`}),t[12]=b,t[13]=h,t[14]=D):D=t[14];let O;t[15]!==l||t[16]!==d?(O=l&&d&&(0,H.jsx)(f,{variant:`destructive`,size:`sm`,onClick:d,className:`mr-auto`,children:`Delete`}),t[15]=l,t[16]=d,t[17]=O):O=t[17];let k;t[18]===h?k=t[19]:(k=h.trim(),t[18]=h,t[19]=k);let ee=!k,A;t[20]!==v||t[21]!==ee?(A=(0,H.jsx)(f,{size:`sm`,onClick:v,disabled:ee,children:`Save`}),t[20]=v,t[21]=ee,t[22]=A):A=t[22];let j;t[23]!==O||t[24]!==A?(j=(0,H.jsxs)(i,{className:`gap-2 sm:gap-0`,children:[O,A]}),t[23]=O,t[24]=A,t[25]=j):j=t[25];let N;t[26]!==j||t[27]!==S||t[28]!==w||t[29]!==D?(N=(0,H.jsxs)(m,{className:`max-w-2xl`,children:[S,w,D,j]}),t[26]=j,t[27]=S,t[28]=w,t[29]=D,t[30]=N):N=t[30];let P;return t[31]!==n||t[32]!==N||t[33]!==x?(P=(0,H.jsx)(a,{open:n,onOpenChange:x,children:N}),t[31]=n,t[32]=N,t[33]=x,t[34]=P):P=t[34],P}function X({threadId:e,onExit:t}){let{state:r,dispatch:i}=A(),{resolvedTheme:a}=ie(),[c,l]=(0,B.useState)([]),[u,d]=(0,B.useState)(!0),[p,m]=(0,B.useState)(null),[g,T]=(0,B.useState)(0),[E,O]=(0,B.useState)(!1),[M,ne]=(0,B.useState)(!1),F=(0,B.useRef)(null),I=(0,B.useMemo)(()=>r.diffComments[e]??[],[r.diffComments,e]),L=(0,B.useCallback)(t=>{let n=r.diffComments[e]??[],a=typeof t==`function`?t(n):t;i({type:j.SetDiffComments,threadId:e,comments:a})},[i,e,r.diffComments]),[R,ce]=(0,B.useState)(null),[z,V]=(0,B.useState)(null),[U,W]=(0,B.useState)(null),G=(0,B.useRef)(null),K=(0,B.useRef)(I),ue=(0,B.useRef)(R),q=(0,B.useRef)({isFullView:E,selectedFileIndex:g,files:c}),J=(0,B.useRef)({original:[],modified:[]}),fe=(0,B.useRef)(!0);(0,B.useEffect)(()=>{K.current=I},[I]),(0,B.useEffect)(()=>{ue.current=R},[R]),(0,B.useEffect)(()=>{q.current={isFullView:E,selectedFileIndex:g,files:c}},[E,g,c]);let pe=(0,B.useCallback)(()=>{F.current&&(M?F.current.expand():F.current.collapse())},[M]),Y=(0,B.useCallback)(async()=>{if(e){d(!0),m(null);try{l((await w(e)).files||[]),T(0)}catch(e){m(e instanceof Error?e.message:`Failed to load diff`)}finally{d(!1)}}},[e]);(0,B.useEffect)(()=>{Y()},[Y]);let me=(0,B.useCallback)(async t=>{try{await h(e,t.path),await Y()}catch(e){m(e instanceof Error?e.message:`Failed to revert file`)}},[e,Y]),X=(0,B.useRef)(!1);(0,B.useEffect)(()=>{if((r.diffComments[e]??[]).length>0){X.current=!0;return}S(e).then(t=>{t.diffComments&&t.diffComments.length>0&&i({type:j.SetDiffComments,threadId:e,comments:t.diffComments}),X.current=!0}).catch(()=>{X.current=!0})},[e]),(0,B.useEffect)(()=>{X.current&&n(e,{diffComments:I}).catch(()=>{})},[e,I]);let _e=(0,B.useMemo)(()=>le(c),[c]),Z=e=>{if(e.hunks.length===0)return null;let t=1/0,n=0;return e.hunks.forEach(e=>{let r=Math.min(e.oldStart,e.newStart),i=e.oldStart+e.oldLines,a=e.newStart+e.newLines,o=Math.max(i,a);t=Math.min(t,r),n=Math.max(n,o)}),t===1/0?null:{startLine:Math.max(1,t-2),endLine:n+2}},ve=(e,t,n)=>e.split(`
2
- `).slice(t-1,n).join(`
3
- `),ye=e=>{let t=Z(e);return t?t.startLine<=1:!0},be=e=>({ts:`typescript`,tsx:`typescript`,js:`javascript`,jsx:`javascript`,json:`json`,md:`markdown`,css:`css`,scss:`scss`,html:`html`,py:`python`,rb:`ruby`,go:`go`,rs:`rust`,java:`java`,kt:`kotlin`,swift:`swift`,c:`c`,cpp:`cpp`,h:`c`,hpp:`cpp`,sh:`shell`,yaml:`yaml`,yml:`yaml`,xml:`xml`,sql:`sql`})[e.split(`.`).pop()??``]||`plaintext`,Q=c[g],xe=Q?E?Q.oldContent:(()=>{let e=Z(Q);return e?ve(Q.oldContent,e.startLine,e.endLine):Q.oldContent})():``,Se=Q?E?Q.newContent:(()=>{let e=Z(Q);return e?ve(Q.newContent,e.startLine,e.endLine):Q.newContent})():``,$=(0,B.useCallback)(()=>{if(!fe.current)return;let e=G.current;if(!e)return;let{isFullView:t,selectedFileIndex:n,files:r}=q.current,i=K.current,a=ue.current,o=r[n];if(!o)return;let s=(e,r)=>{let s=t?null:Z(o),c=i.filter(e=>e.fileIndex===n&&e.side===r).map(e=>{let t=s?e.lineNumber-s.startLine+1:e.lineNumber;if(t<1)return null;let n=i.indexOf(e)===a;return{range:{startLineNumber:t,startColumn:1,endLineNumber:t,endColumn:1},options:{isWholeLine:!0,className:n?`diff-comment-active-line`:`diff-comment-marked-line`,glyphMarginHoverMessage:{value:e.comment}}}}).filter(e=>e!==null),l=r===`original`?J.current.original:J.current.modified,u=e.deltaDecorations(l,c);r===`original`?J.current.original=u:J.current.modified=u};s(e.getOriginalEditor(),`original`),s(e.getModifiedEditor(),`modified`)},[]);(0,B.useEffect)(()=>{$()},[$,I,R,g,E,Q]),(0,B.useEffect)(()=>()=>{G.current=null,J.current={original:[],modified:[]}},[g]),(0,B.useEffect)(()=>()=>{fe.current=!1,G.current&&=(G.current.getOriginalEditor().getModel()?.dispose(),G.current.getModifiedEditor().getModel()?.dispose(),G.current.dispose(),null),J.current={original:[],modified:[]}},[]);let Ce=(0,B.useCallback)(e=>{G.current=e;let t=(e,t)=>{e.onMouseDown(n=>{if(!n.target?.position)return;let r=n.target.position.lineNumber,{isFullView:i,selectedFileIndex:a,files:o}=q.current,s=o[a];if(!s)return;let c=i?null:Z(s),l=c?c.startLine+r-1:r,u=e.getModel()?.getLineContent(r)??``,d=K.current.find(e=>e.fileIndex===a&&e.lineNumber===l&&e.side===t);d?W(d):V({lineNumber:l,lineContent:u,side:t})})};t(e.getOriginalEditor(),`original`),t(e.getModifiedEditor(),`modified`),setTimeout(()=>{G.current===e&&$()},150)},[$]),we=(0,B.useCallback)(e=>{if(z&&Q){let t={id:`comment-${Date.now()}`,filePath:Q.path,fileIndex:g,lineNumber:z.lineNumber,lineContent:z.lineContent,comment:e,side:z.side};L(e=>[...e,t]),V(null)}else U&&(L(t=>t.map(t=>t.id===U.id?{...t,comment:e}:t)),W(null))},[z,U,Q,g,L]),Te=(0,B.useCallback)(()=>{U&&(L(e=>e.filter(e=>e.id!==U.id)),W(null))},[U,L]),Ee=(0,B.useCallback)(e=>{if(I.length===0)return;let t=(e%I.length+I.length)%I.length,n=I[t];ce(t),T(n.fileIndex),setTimeout(()=>{let e=G.current;if(!e)return;let t=c[n.fileIndex];if(!t)return;let r=E?null:Z(t),i=r?n.lineNumber-r.startLine+1:n.lineNumber;(n.side===`original`?e.getOriginalEditor():e.getModifiedEditor()).revealLineInCenter(Math.max(1,i)),$()},100)},[I,c,E,$]),De=(0,B.useCallback)(()=>{Ee((R??0)-1)},[Ee,R]),Oe=(0,B.useCallback)(()=>{Ee((R??-1)+1)},[Ee,R]),ke=(0,B.useCallback)(async()=>{let n=r.projectModelSelections[e];if(!n)try{let e=await x(),t=Object.values(e).flat();if(t.length>0)n=t[0];else{console.error(`No models available to process comments`);return}}catch(e){console.error(`Failed to load models:`,e);return}let a=n.id,s=n.provider;try{let{prompt:n}=await o(e,I);L([]),i({type:j.SetPendingChatMessage,message:{threadId:e,message:n,model:a,provider:s}}),t()}catch(e){console.error(`Failed to fix comments:`,e),typeof window<`u`&&window.alert(`Failed to process comments. Please try again.`)}},[I,r.projectModelSelections,i,e,t,L]),Ae={readOnly:!0,renderSideBySide:!0,ignoreTrimWhitespace:!1,renderOverviewRuler:!0,scrollBeyondLastLine:!1,minimap:{enabled:!1},folding:!1,lineNumbers:Q&&(E||ye(Q))?`on`:`off`,diffWordWrap:`on`,originalEditable:!1,automaticLayout:!0};return(0,H.jsxs)(`div`,{className:`diff-view-root flex h-full flex-col`,children:[(0,H.jsx)(`div`,{className:`diff-body flex flex-1 overflow-hidden`,children:(0,H.jsxs)(se,{direction:`horizontal`,children:[(0,H.jsx)(oe,{ref:F,defaultSize:25,minSize:12,maxSize:40,collapsible:!0,collapsedSize:0,onCollapse:()=>ne(!0),onExpand:()=>ne(!1),className:`border-r border-transparent`,children:(0,H.jsx)(`div`,{className:`h-full overflow-hidden`,children:(0,H.jsx)(de,{treeData:_e,files:c,isLoading:u,error:p,selectedFileIndex:g,onFileSelect:T,onRevertFile:me})})}),(0,H.jsx)(he,{isOpen:!M}),(0,H.jsx)(oe,{className:`overflow-hidden bg-transparent`,children:(0,H.jsxs)(`div`,{className:`diff-editor-panel flex h-full bg-transparent flex-col overflow-hidden`,children:[(0,H.jsxs)(ae,{className:s(`bg-transparent`,M&&`h-auto py-3 flex-col items-start gap-3 md:flex-row md:items-center md:h-[71px] md:py-0 md:gap-2 justify-between`),children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsxs)(f,{variant:`ghost`,size:`icon`,className:`h-8 w-8 text-muted-foreground shrink-0`,onClick:pe,children:[M?(0,H.jsx)(D,{className:`h-4 w-4`}):(0,H.jsx)(b,{className:`h-4 w-4`}),(0,H.jsx)(`span`,{className:`sr-only`,children:`Toggle file tree`})]}),(0,H.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:Q?Q.path:`Review Changes`})]}),(0,H.jsxs)(`div`,{className:s(`flex items-center gap-2`,M&&`ml-0`,!M&&`ml-auto`,`md:ml-auto`),children:[(0,H.jsx)(f,{variant:`ghost`,size:`sm`,onClick:()=>O(e=>!e),disabled:!Q,className:`h-8 gap-1 px-2 text-xs`,children:E?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(_,{className:`h-3 w-3`}),` Show changes only`]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(y,{className:`h-3 w-3`}),` Show full file`]})}),I.length>0&&(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsxs)(P,{children:[(0,H.jsx)(te,{asChild:!0,children:(0,H.jsx)(f,{variant:`ghost`,size:`icon`,className:`h-8 w-8 rounded-full`,onClick:De,disabled:(R??0)===0,children:(0,H.jsx)(C,{className:`h-3 w-3`})})}),(0,H.jsx)(N,{children:`Previous comment`})]}),(0,H.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap`,children:I.length===1?`1 Comment`:`Comment ${(R??0)+1} of ${I.length}`}),(0,H.jsxs)(P,{children:[(0,H.jsx)(te,{asChild:!0,children:(0,H.jsx)(f,{variant:`ghost`,size:`icon`,className:`h-8 w-8 rounded-full`,onClick:Oe,disabled:(R??0)===I.length-1,children:(0,H.jsx)(v,{className:`h-3 w-3`})})}),(0,H.jsx)(N,{children:`Next comment`})]})]}),I.length>0&&(0,H.jsxs)(P,{children:[(0,H.jsx)(te,{asChild:!0,children:(0,H.jsxs)(f,{size:`sm`,onClick:ke,className:`h-8 gap-1 px-3 text-xs bg-foreground text-background hover:bg-foreground/90`,children:[(0,H.jsx)(k,{className:`h-3 w-3`}),`Fix all comments`]})}),(0,H.jsx)(N,{children:`Send all comments to Tarsk for resolution`})]})]})]}),(0,H.jsxs)(`div`,{className:`flex-1 bg-transparent relative`,children:[(0,H.jsx)(ee,{height:`100%`,language:be(Q?.path||``),original:xe,modified:Se,theme:a===`dark`?`vs-dark`:`vs-light`,onMount:Ce,options:Ae},`diff-${g}`),(0,H.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0`,children:(0,H.jsx)(re,{})})]})]})})]})}),(0,H.jsx)(ge,{open:z!==null||U!==null,lineNumber:U?.lineNumber??z?.lineNumber??0,lineContent:U?.lineContent??z?.lineContent??``,initialComment:U?.comment,isEditing:U!==null,onSave:we,onDelete:Te,onClose:()=>{V(null),W(null)}},`${U?.id??``}-${z?.lineNumber??``}-${z?.side??``}`)]})}export{X as DiffView,X as default};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/explorer-tree-8TyBYuC7.js","assets/rolldown-runtime-B1FJdls4.js","assets/dialogs-config-DZFG2IQM.js","assets/api-BBbysRIh.js","assets/alert-dialog--tUzAWFm.js","assets/react-vendor-Bao-KYKs.js","assets/history-view-BR8scGnM.js","assets/monaco-DDfTQM3i.js","assets/context-menu-D5slxFcc.js","assets/standard-list-item-D2lbPXa1.js","assets/use-toast-DqmC-mB5.js","assets/tab-context-CCvlrC0o.js","assets/explorer-view-5U70mfAJ.js","assets/page-toolbar-TvYsDwUY.js","assets/store-CwvBC-YP.js","assets/utils-Cy2s2TEb.js"])))=>i.map(i=>d[i]);
2
- import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{Dr as t,Mn as n,_a as r,ya as i}from"./dialogs-config-DZFG2IQM.js";import{bt as a}from"./react-vendor-Bao-KYKs.js";import{a as o}from"./store-CwvBC-YP.js";import{n as s}from"./tab-context-CCvlrC0o.js";import{n as c,r as l,t as u}from"./resizable-DzrIos_Y.js";var d=r(),f=e(i(),1),p=t(),m=(0,f.lazy)(()=>a(()=>import(`./explorer-tree-8TyBYuC7.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11]))),h=(0,f.lazy)(()=>a(()=>import(`./explorer-view-5U70mfAJ.js`),__vite__mapDeps([12,1,5,6,2,7,3,13,10,14,15])));function g(){let e=(0,d.c)(17),{state:t}=o(),r=t.selectedThreadId,[i,a]=(0,f.useState)(null),{pendingExplorerPath:g,setPendingExplorerPath:v,explorerClearPath:y,setExplorerClearPath:b}=s(),x,S;e[0]!==g||e[1]!==v?(x=()=>{g&&(a({name:g.split(`/`).pop()??g,type:`file`,path:g}),v(null))},S=[g,v],e[0]=g,e[1]=v,e[2]=x,e[3]=S):(x=e[2],S=e[3]),(0,f.useEffect)(x,S);let C,w;e[4]!==y||e[5]!==b?(C=()=>{y&&(a(e=>e&&(e.path===y||e.path.startsWith(y+`/`)?null:e)),b(null))},w=[y,b],e[4]=y,e[5]=b,e[6]=C,e[7]=w):(C=e[6],w=e[7]),(0,f.useEffect)(C,w);let T;e[8]!==i?.path||e[9]!==r?(T=(0,p.jsx)(c,{defaultSize:25,minSize:15,maxSize:50,className:`overflow-hidden border-r border-border`,children:(0,p.jsx)(n,{className:`h-full`,children:r?(0,p.jsx)(f.Suspense,{fallback:(0,p.jsx)(`div`,{className:`space-y-1 px-2 py-2`,children:[1,2,3].map(_)}),children:(0,p.jsx)(m,{threadId:r,selectedPath:i?.path??null,onFileSelect:a})}):(0,p.jsx)(`p`,{className:`px-3 py-4 text-xs text-muted-foreground text-center`,children:`No thread selected.`})})}),e[8]=i?.path,e[9]=r,e[10]=T):T=e[10];let E;e[11]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,p.jsx)(u,{withHandle:!0}),e[11]=E):E=e[11];let D;e[12]===i?D=e[13]:(D=(0,p.jsx)(c,{className:`overflow-hidden`,children:(0,p.jsx)(f.Suspense,{fallback:null,children:(0,p.jsx)(h,{selectedFile:i})})}),e[12]=i,e[13]=D);let O;return e[14]!==T||e[15]!==D?(O=(0,p.jsx)(`div`,{className:`flex h-full flex-col overflow-hidden`,children:(0,p.jsxs)(l,{direction:`horizontal`,className:`flex-1 overflow-hidden`,children:[T,E,D]})}),e[14]=T,e[15]=D,e[16]=O):O=e[16],O}function _(e){return(0,p.jsx)(`div`,{className:`animate-pulse h-7 bg-muted rounded-full`},e)}export{g as default};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{Bi as t,Dr as n,Li as r,Ri as i,Si as a,_a as o,aa as s,sa as c,ya as l}from"./dialogs-config-DZFG2IQM.js";import{t as u}from"./use-toast-DqmC-mB5.js";import{t as d}from"./standard-list-item-D2lbPXa1.js";import{a as f,c as p,i as m,n as h,r as g,t as _}from"./alert-dialog--tUzAWFm.js";import{n as v}from"./tab-context-CCvlrC0o.js";import{a as y,i as ee,n as b,r as x,t as S}from"./context-menu-D5slxFcc.js";import{n as C,o as w,r as T,s as E,t as D}from"./api-BBbysRIh.js";var O=o(),k=e(l(),1),A=n();function te(e){let t=(0,O.c)(17),{defaultValue:n,onCommit:r,onCancel:i,level:a,basePadding:o,icon:s}=e,c=(0,k.useRef)(null),l,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>{c.current?.focus(),c.current?.select()},u=[],t[0]=l,t[1]=u):(l=t[0],u=t[1]),(0,k.useEffect)(l,u);let f;t[2]!==i||t[3]!==r?(f=function(e){if(e.key===`Enter`){let e=c.current?.value.trim()??``;e?r(e):i()}else e.key===`Escape`&&i()},t[2]=i,t[3]=r,t[4]=f):f=t[4];let p=f,m;t[5]!==i||t[6]!==r?(m=function(){let e=c.current?.value.trim()??``;e?r(e):i()},t[5]=i,t[6]=r,t[7]=m):m=t[7];let h=m,g;t[8]!==n||t[9]!==h||t[10]!==p?(g=(0,A.jsx)(`input`,{ref:c,defaultValue:n,onKeyDown:p,onBlur:h,className:`flex-1 min-w-0 bg-transparent outline-none border border-border rounded px-1 text-sm`,onClick:j}),t[8]=n,t[9]=h,t[10]=p,t[11]=g):g=t[11];let _;return t[12]!==o||t[13]!==s||t[14]!==a||t[15]!==g?(_=(0,A.jsxs)(d,{level:a,basePadding:o,children:[s,g]}),t[12]=o,t[13]=s,t[14]=a,t[15]=g,t[16]=_):_=t[16],_}function j(e){return e.stopPropagation()}function ne(e){let n=(0,O.c)(101),{node:o,level:l,selectedPath:u,expandedPaths:f,loadedDirs:p,loadingPaths:m,renamingPath:h,newItemIn:g,onToggleFolder:_,onSelectFile:v,onStartRename:C,onCommitRename:w,onCancelRename:T,onDelete:E,onNewFile:D,onNewFolder:k,onCommitNewItem:j,onCancelNewItem:P}=e,F;n[0]!==f||n[1]!==o.path?(F=f.has(o.path),n[0]=f,n[1]=o.path,n[2]=F):F=n[2];let I=F,L;n[3]!==m||n[4]!==o.path?(L=m.has(o.path),n[3]=m,n[4]=o.path,n[5]=L):L=n[5];let R=L,z,B;if(n[6]!==f||n[7]!==I||n[8]!==R||n[9]!==l||n[10]!==p||n[11]!==m||n[12]!==g||n[13]!==o||n[14]!==P||n[15]!==T||n[16]!==j||n[17]!==w||n[18]!==E||n[19]!==D||n[20]!==k||n[21]!==v||n[22]!==C||n[23]!==_||n[24]!==h||n[25]!==u){B=Symbol.for(`react.early_return_sentinel`);bb0:{let e=p.get(o.path)??[];z=h===o.path;let O=g?.dirPath===o.path&&I;if(o.type===`folder`){let M=o.ignored?`opacity-50`:void 0,F;n[28]!==o||n[29]!==_?(F=e=>{e.stopPropagation(),_(o)},n[28]=o,n[29]=_,n[30]=F):F=n[30];let L;n[31]!==I||n[32]!==R?(L=(0,A.jsx)(`span`,{className:`text-muted-foreground w-3 flex-shrink-0`,children:R?(0,A.jsx)(a,{className:`h-3 w-3 animate-spin`}):I?(0,A.jsx)(c,{className:`h-3 w-3`}):(0,A.jsx)(s,{className:`h-3 w-3`})}),n[31]=I,n[32]=R,n[33]=L):L=n[33];let V;n[34]!==I||n[35]!==z||n[36]!==o||n[37]!==T||n[38]!==w?(V=z?(0,A.jsxs)(A.Fragment,{children:[I?(0,A.jsx)(i,{className:`h-4 w-4 flex-shrink-0`}):(0,A.jsx)(r,{className:`h-4 w-4 flex-shrink-0`}),(0,A.jsx)(`input`,{autoFocus:!0,defaultValue:o.name,onKeyDown:e=>{if(e.key===`Enter`){let t=e.target.value.trim();t?w(o,t):T()}else e.key===`Escape`&&T()},onBlur:e=>{let t=e.target.value.trim();t?w(o,t):T()},onClick:N,className:`flex-1 min-w-0 bg-transparent outline-none border border-border rounded px-1 text-sm`})]}):(0,A.jsxs)(A.Fragment,{children:[I?(0,A.jsx)(i,{className:`h-4 w-4 flex-shrink-0`}):(0,A.jsx)(r,{className:`h-4 w-4 flex-shrink-0`}),(0,A.jsx)(`span`,{className:`flex-1 truncate`,children:o.name})]}),n[34]=I,n[35]=z,n[36]=o,n[37]=T,n[38]=w,n[39]=V):V=n[39];let H;n[40]!==l||n[41]!==M||n[42]!==F||n[43]!==L||n[44]!==V?(H=(0,A.jsxs)(d,{level:l,basePadding:10,className:M,onClick:F,children:[L,V]}),n[40]=l,n[41]=M,n[42]=F,n[43]=L,n[44]=V,n[45]=H):H=n[45];let U=I&&(0,A.jsx)(`div`,{children:R&&!p.has(o.path)?(0,A.jsx)(`div`,{className:`animate-pulse h-4 bg-muted rounded mx-4 my-1`}):(0,A.jsxs)(A.Fragment,{children:[O&&(0,A.jsx)(te,{defaultValue:``,level:l+1,basePadding:g.type===`folder`?10:22,icon:g.type===`folder`?(0,A.jsx)(r,{className:`h-4 w-4 flex-shrink-0`}):(0,A.jsx)(t,{className:`h-4 w-4 flex-shrink-0 text-muted-foreground`}),onCommit:j,onCancel:P}),e.map(e=>(0,A.jsx)(ne,{node:e,level:l+1,selectedPath:u,expandedPaths:f,loadedDirs:p,loadingPaths:m,renamingPath:h,newItemIn:g,onToggleFolder:_,onSelectFile:v,onStartRename:C,onCommitRename:w,onCancelRename:T,onDelete:E,onNewFile:D,onNewFolder:k,onCommitNewItem:j,onCancelNewItem:P},e.path))]})}),W;n[46]!==H||n[47]!==U?(W=(0,A.jsxs)(`div`,{children:[H,U]}),n[46]=H,n[47]=U,n[48]=W):W=n[48];let G=W,K;n[49]===G?K=n[50]:(K=(0,A.jsx)(y,{asChild:!0,children:G}),n[49]=G,n[50]=K);let q;n[51]!==o.path||n[52]!==D?(q=(0,A.jsx)(x,{onSelect:()=>D(o.path),children:`New File...`}),n[51]=o.path,n[52]=D,n[53]=q):q=n[53];let J;n[54]!==o.path||n[55]!==k?(J=(0,A.jsx)(x,{onSelect:()=>k(o.path),children:`New Folder...`}),n[54]=o.path,n[55]=k,n[56]=J):J=n[56];let Y;n[57]===Symbol.for(`react.memo_cache_sentinel`)?(Y=(0,A.jsx)(ee,{}),n[57]=Y):Y=n[57];let X;n[58]!==o||n[59]!==C?(X=(0,A.jsx)(x,{onSelect:()=>C(o),children:`Rename...`}),n[58]=o,n[59]=C,n[60]=X):X=n[60];let Z;n[61]!==o||n[62]!==E?(Z=(0,A.jsx)(x,{onSelect:()=>E(o),className:`text-destructive focus:text-destructive`,children:`Delete`}),n[61]=o,n[62]=E,n[63]=Z):Z=n[63];let Q;n[64]!==q||n[65]!==J||n[66]!==X||n[67]!==Z?(Q=(0,A.jsxs)(b,{children:[q,J,Y,X,Z]}),n[64]=q,n[65]=J,n[66]=X,n[67]=Z,n[68]=Q):Q=n[68];let $;n[69]!==K||n[70]!==Q?($=(0,A.jsxs)(S,{children:[K,Q]}),n[69]=K,n[70]=Q,n[71]=$):$=n[71],B=$;break bb0}}n[6]=f,n[7]=I,n[8]=R,n[9]=l,n[10]=p,n[11]=m,n[12]=g,n[13]=o,n[14]=P,n[15]=T,n[16]=j,n[17]=w,n[18]=E,n[19]=D,n[20]=k,n[21]=v,n[22]=C,n[23]=_,n[24]=h,n[25]=u,n[26]=z,n[27]=B}else z=n[26],B=n[27];if(B!==Symbol.for(`react.early_return_sentinel`))return B;let V=u===o.path,H=o.ignored?`opacity-50`:void 0,U;n[72]!==o||n[73]!==v?(U=()=>v(o),n[72]=o,n[73]=v,n[74]=U):U=n[74];let W;n[75]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,A.jsx)(t,{className:`h-4 w-4 flex-shrink-0 text-muted-foreground`}),n[75]=W):W=n[75];let G;n[76]!==z||n[77]!==o||n[78]!==T||n[79]!==w?(G=z?(0,A.jsx)(`input`,{autoFocus:!0,defaultValue:o.name,onKeyDown:e=>{if(e.key===`Enter`){let t=e.target.value.trim();t?w(o,t):T()}else e.key===`Escape`&&T()},onBlur:e=>{let t=e.target.value.trim();t?w(o,t):T()},onClick:M,className:`flex-1 min-w-0 bg-transparent outline-none border border-border rounded px-1 text-sm`}):(0,A.jsx)(`span`,{className:`flex-1 truncate`,children:o.name}),n[76]=z,n[77]=o,n[78]=T,n[79]=w,n[80]=G):G=n[80];let K;n[81]!==l||n[82]!==V||n[83]!==H||n[84]!==U||n[85]!==G?(K=(0,A.jsxs)(d,{level:l,basePadding:22,selected:V,className:H,onClick:U,children:[W,G]}),n[81]=l,n[82]=V,n[83]=H,n[84]=U,n[85]=G,n[86]=K):K=n[86];let q=K,J;n[87]===q?J=n[88]:(J=(0,A.jsx)(y,{asChild:!0,children:q}),n[87]=q,n[88]=J);let Y;n[89]!==o||n[90]!==C?(Y=(0,A.jsx)(x,{onSelect:()=>C(o),children:`Rename...`}),n[89]=o,n[90]=C,n[91]=Y):Y=n[91];let X;n[92]!==o||n[93]!==E?(X=(0,A.jsx)(x,{onSelect:()=>E(o),className:`text-destructive focus:text-destructive`,children:`Delete`}),n[92]=o,n[93]=E,n[94]=X):X=n[94];let Z;n[95]!==Y||n[96]!==X?(Z=(0,A.jsxs)(b,{children:[Y,X]}),n[95]=Y,n[96]=X,n[97]=Z):Z=n[97];let Q;return n[98]!==J||n[99]!==Z?(Q=(0,A.jsxs)(S,{children:[J,Z]}),n[98]=J,n[99]=Z,n[100]=Q):Q=n[100],Q}function M(e){return e.stopPropagation()}function N(e){return e.stopPropagation()}function P({threadId:e,selectedPath:n,onFileSelect:i}){let[a,o]=(0,k.useState)(new Map),[s,c]=(0,k.useState)(new Set),[l,d]=(0,k.useState)(new Set),[ee,O]=(0,k.useState)(null),[j,M]=(0,k.useState)(null),[N,P]=(0,k.useState)(null),{explorerRefreshTick:F,pendingExplorerPath:I}=v();async function L(t){if(!(!e||a.has(t))){d(e=>new Set(e).add(t));try{let n=await w(e,t);o(e=>new Map(e).set(t,n.entries))}catch{u({title:`Error`,description:`Failed to load directory`,variant:`destructive`})}finally{d(e=>{let n=new Set(e);return n.delete(t),n})}}}let R=(0,k.useCallback)(async t=>{if(e){d(e=>new Set(e).add(t));try{let n=await w(e,t);o(e=>new Map(e).set(t,n.entries))}catch{u({title:`Error`,description:`Failed to reload directory`,variant:`destructive`})}finally{d(e=>{let n=new Set(e);return n.delete(t),n})}}},[e]);(0,k.useEffect)(()=>{e&&(o(new Map),c(new Set),d(new Set),O(null),M(null),L(``))},[e]),(0,k.useEffect)(()=>{if(F>0&&e){R(``);for(let e of s)R(e)}},[F]),(0,k.useEffect)(()=>{if(!I||!e)return;let t=I.split(`/`);t.pop();let n=[],r=``;for(let e of t)r=r?`${r}/${e}`:e,n.push(r);if(n.length!==0){c(e=>{let t=new Set(e);for(let e of n)t.add(e);return t});for(let e of n)L(e)}},[I,e]);function z(e){s.has(e.path)?c(t=>{let n=new Set(t);return n.delete(e.path),n}):(c(t=>new Set(t).add(e.path)),L(e.path))}function B(e){let t=e.lastIndexOf(`/`);return t>=0?e.slice(0,t):``}function V(e){P(e)}async function H(){if(!N)return;let t=N;P(null);try{await T(e,t.path),await R(B(t.path)),c(e=>{let n=new Set(e);for(let e of n)(e===t.path||e.startsWith(t.path+`/`))&&n.delete(e);return n}),o(e=>{let n=new Map(e);for(let e of n.keys())(e===t.path||e.startsWith(t.path+`/`))&&n.delete(e);return n})}catch{u({title:`Error`,description:`Failed to move "${t.name}" to trash`,variant:`destructive`})}}function U(e){M(null),O(e.path)}async function W(t,n){if(n===t.name){O(null);return}O(null);try{await E(e,t.path,n),await R(B(t.path)),t.type===`folder`&&(c(e=>{let n=new Set(e);for(let e of n)(e===t.path||e.startsWith(t.path+`/`))&&n.delete(e);return n}),o(e=>{let n=new Map(e);for(let e of n.keys())(e===t.path||e.startsWith(t.path+`/`))&&n.delete(e);return n}))}catch{u({title:`Error`,description:`Failed to rename "${t.name}"`,variant:`destructive`})}}function G(e){O(null),s.has(e)||(c(t=>new Set(t).add(e)),L(e)),M({dirPath:e,type:`file`})}function K(e){O(null),s.has(e)||(c(t=>new Set(t).add(e)),L(e)),M({dirPath:e,type:`folder`})}async function q(t){if(!j)return;let{dirPath:n,type:r}=j;M(null);try{r===`file`?await D(e,n,t):await C(e,n,t),await R(n)}catch{u({title:`Error`,description:`Failed to create ${r} "${t}"`,variant:`destructive`})}}function J(){M(null)}let Y=a.get(``)??[],X=l.has(``),Z=j?.dirPath===``?(0,A.jsx)(te,{defaultValue:``,level:0,basePadding:j.type===`folder`?10:22,icon:j.type===`folder`?(0,A.jsx)(r,{className:`h-4 w-4 flex-shrink-0`}):(0,A.jsx)(t,{className:`h-4 w-4 flex-shrink-0 text-muted-foreground`}),onCommit:q,onCancel:J}):null;return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(_,{open:N!==null,onOpenChange:e=>!e&&P(null),children:(0,A.jsxs)(m,{children:[(0,A.jsx)(p,{children:`Move to Trash`}),(0,A.jsxs)(f,{children:[`Move “`,N?.name,`” to trash?`]}),(0,A.jsxs)(`div`,{className:`flex gap-3 justify-end`,children:[(0,A.jsx)(g,{children:`Cancel`}),(0,A.jsx)(h,{onClick:()=>void H(),children:`Move to Trash`})]})]})}),(0,A.jsxs)(S,{children:[(0,A.jsx)(y,{asChild:!0,children:(0,A.jsx)(`div`,{className:`py-2 min-h-full`,children:X?(0,A.jsx)(`div`,{className:`space-y-1 px-2`,children:[1,2,3].map(e=>(0,A.jsx)(`div`,{className:`animate-pulse h-7 bg-muted rounded-full`},e))}):(0,A.jsxs)(A.Fragment,{children:[Z,Y.map(e=>(0,A.jsx)(ne,{node:e,level:0,selectedPath:n,expandedPaths:s,loadedDirs:a,loadingPaths:l,renamingPath:ee,newItemIn:j,onToggleFolder:z,onSelectFile:i,onStartRename:U,onCommitRename:W,onCancelRename:()=>O(null),onDelete:V,onNewFile:G,onNewFolder:K,onCommitNewItem:q,onCancelNewItem:J},e.path))]})})}),(0,A.jsxs)(b,{children:[(0,A.jsx)(x,{onSelect:()=>G(``),children:`New File...`}),(0,A.jsx)(x,{onSelect:()=>K(``),children:`New Folder...`})]})]})]})}export{P as default};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{Dr as t,Rn as n,Si as r,Vi as i,ya as a}from"./dialogs-config-DZFG2IQM.js";import{x as o}from"./react-vendor-Bao-KYKs.js";import{a as s}from"./store-CwvBC-YP.js";import{t as c}from"./use-toast-DqmC-mB5.js";import{n as l}from"./utils-Cy2s2TEb.js";import{t as u}from"./page-toolbar-TvYsDwUY.js";import{a as d,c as f,i as p}from"./api-BBbysRIh.js";var m=e(a(),1),h=t(),g=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`svg`,`ico`,`bmp`,`tiff`,`tif`]),_=new Set([`mp4`,`webm`,`mov`,`avi`]);function v(e){let t=e.split(`.`).pop()?.toLowerCase()??``;return g.has(t)?`image`:_.has(t)?`video`:null}function y(e){return{ts:`typescript`,tsx:`typescript`,js:`javascript`,jsx:`javascript`,json:`json`,md:`markdown`,mdc:`markdown`,css:`css`,scss:`scss`,html:`html`,py:`python`,sh:`shell`,yaml:`yaml`,yml:`yaml`,xml:`xml`,sql:`sql`}[e.split(`.`).pop()??``]??`plaintext`}function b({selectedFile:e}){let{state:t}=s(),{resolvedTheme:a}=l(),g=t.selectedThreadId,_=(0,m.useRef)(null),[b,x]=(0,m.useState)(``),[S,C]=(0,m.useState)(``),[w,T]=(0,m.useState)(!1),[E,D]=(0,m.useState)(!1);(0,m.useEffect)(()=>()=>{_.current&&=(_.current.getModel()?.dispose(),_.current.dispose(),null)},[]);async function O(){if(!(!g||!e)){D(!0);try{await f(g,e.path,b),C(b),c({title:`Saved`,description:`${e.name} saved successfully.`})}catch(e){c({title:`Error`,description:e instanceof Error?e.message:`Failed to save file`,variant:`destructive`})}finally{D(!1)}}}let k=(0,m.useCallback)(async e=>{if(g){T(!0);try{let t=await p(g,e.path);x(t.content),C(t.content)}catch(e){c({title:`Error`,description:e instanceof Error?e.message:`Failed to load file`,variant:`destructive`})}finally{T(!1)}}},[g]);return(0,m.useEffect)(()=>{e&&g?v(e.path)||k(e):(x(``),C(``))},[e,g,k]),g?(0,h.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,h.jsxs)(u,{className:`justify-between`,children:[(0,h.jsxs)(`div`,{className:`flex flex-col`,children:[(0,h.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:e?e.name:`Select a file to edit`}),(0,h.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e?e.path:`Browse and edit repository files`})]}),e&&!v(e.path)&&(0,h.jsx)(`div`,{className:`flex gap-1`,children:(0,h.jsxs)(n,{size:`sm`,onClick:()=>void O(),disabled:E||!b||b===S,children:[E?(0,h.jsx)(r,{className:`h-4 w-4 animate-spin`}):null,`Save`]})})]}),(0,h.jsx)(`div`,{className:`flex-1 overflow-hidden`,children:(0,h.jsx)(`div`,{className:`h-full relative overflow-hidden`,children:w?(0,h.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,h.jsx)(r,{className:`h-6 w-6 animate-spin text-muted-foreground`})}):e&&v(e.path)===`image`?(0,h.jsx)(`div`,{className:`flex items-center justify-center h-full p-4 overflow-auto`,children:(0,h.jsx)(`img`,{src:d(g,e.path),alt:e.name,className:`max-w-full max-h-full object-contain`})}):e&&v(e.path)===`video`?(0,h.jsx)(`div`,{className:`flex items-center justify-center h-full p-4`,children:(0,h.jsx)(`video`,{src:d(g,e.path),controls:!0,className:`max-w-full max-h-full`})}):e?(0,h.jsx)(o,{height:`100%`,language:y(e.path),value:b,onChange:e=>x(e??``),onMount:e=>{_.current=e},theme:a===`dark`?`vs-dark`:`vs-light`,options:{minimap:{enabled:!1},scrollBeyondLastLine:!1,wordWrap:`on`,automaticLayout:!0,fontSize:13,lineNumbers:`on`,renderLineHighlight:`line`,scrollbar:{vertical:`auto`,horizontal:`auto`}}}):(0,h.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-3 text-center p-8`,children:[(0,h.jsx)(i,{className:`h-10 w-10 text-muted-foreground/50`}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`p`,{className:`text-sm font-medium text-muted-foreground`,children:`No file selected`}),(0,h.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:`Select a file from the tree to edit it`})]})]})})})]}):(0,h.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-3 text-center`,children:[(0,h.jsx)(i,{className:`h-8 w-8 text-muted-foreground`}),(0,h.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Select a thread to browse its files`})]})}export{b as default};